Commit 8071df3b authored by Roland Levillain's avatar Roland Levillain
Browse files

Polish stc/scoop2.hh.

	The work is far from beeing finished; we still have to address
	the problem of deferred virtual types.

	* doc/algorithms.ml: Add a new (non working) example.
	Typos.
	* stc/scoop.hh (stc_find_deduce_vtype): Add a missing argument.
	* stc/scoop2.hh (stc::none): New.
	(stc::is_found_, stc::is_not_found_): New.
	(SCOOPED_NAMESPACE): Set to oln.
	(stc_match_pair_0p_with, stc_match_pair_1p_with
	(stc_match_pair_2p_with, stc_match_pair_1p_with_error)
	(stc_match_pair_2p_with_error): New macros.
	(merge2_): Use them to simplify this struct.
	(stc_match_triple_0p_with, stc_match_triple_1p_with)
	(stc_match_triple_2p_with, stc_match_triple_3p_with)
	(stc_match_triple_2p_with_error, stc_match_triple_3p_with_error):
	New macros.
	(merge3_): Use them to simplify this struct.
	(find): Rename struct as...
	(find_vtype): ...this.
	(vtype): New struct.
	(stc_deferred_vtype, stc_vtype_, stc_vtype)
	(stc_find_deduce_vtype_, stc_find_deduce_vtype)
	(stc_deduce_deferred_vtype, stc_deduce_vtype_, stc_deduce_vtype):
	New macros.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@722 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent a8c4ebf0
2007-01-26 Roland Levillain <roland@lrde.epita.fr>
Polish stc/scoop2.hh.
The work is far from beeing finished; we still have to address
the problem of deferred virtual types.
* doc/algorithms.ml: Add a new (non working) example.
Typos.
* stc/scoop.hh (stc_find_deduce_vtype): Add a missing argument.
* stc/scoop2.hh (stc::none): New.
(stc::is_found_, stc::is_not_found_): New.
(SCOOPED_NAMESPACE): Set to oln.
(stc_match_pair_0p_with, stc_match_pair_1p_with
(stc_match_pair_2p_with, stc_match_pair_1p_with_error)
(stc_match_pair_2p_with_error): New macros.
(merge2_): Use them to simplify this struct.
(stc_match_triple_0p_with, stc_match_triple_1p_with)
(stc_match_triple_2p_with, stc_match_triple_3p_with)
(stc_match_triple_2p_with_error, stc_match_triple_3p_with_error):
New macros.
(merge3_): Use them to simplify this struct.
(find): Rename struct as...
(find_vtype): ...this.
(vtype): New struct.
(stc_deferred_vtype, stc_vtype_, stc_vtype)
(stc_find_deduce_vtype_, stc_find_deduce_vtype)
(stc_deduce_deferred_vtype, stc_deduce_vtype_, stc_deduce_vtype):
New macros.
2007-01-26 Thomas Moulard <thomas.moulard@lrde.epita.fr>
Add mini-oln.
......
......@@ -80,8 +80,8 @@ let merge2 (local_res : cxx_type) (super_res : cxx_type) : cxx_type =
| Stc_Not_found, u -> u
(* local_res == stc::abstract. *)
| Stc_Abstract, Stc_Abstract -> Stc_Abstract
| Stc_Abstract, Stc_Not_found -> Stc_Abstract
| Stc_Abstract, Stc_Abstract -> Stc_Abstract
| Stc_Abstract, Stc_Final _ -> error "Final VT redefined abstract"
| Stc_Abstract, _ -> error "VT redefined abstract."
......@@ -182,7 +182,7 @@ let rec find_rec (source : cxx_type) (target : string) : cxx_type =
end
| _ -> error "find_rec: source is not a SCOOP class."
(* Like find_rec, but only search in the inheritance branch. *)
(* Like find_rec, but search only in the inheritance branch. *)
and find_rec_in_supers (source : cxx_type) (target : string) : cxx_type =
match source with
| Stc_None -> Stc_Not_found
......@@ -206,7 +206,6 @@ let find (source : cxx_type) (target : string) : cxx_type =
;;
(*-----------.
| Examples. |
`-----------*)
......@@ -611,3 +610,39 @@ let value_cast__image2d_int__float =
assert (find image2d_int "value_type" = Std_Int);
assert (find value_cast__image2d_int__float "value_type" = Std_Float);;
(*--------------.
| Limitations. |
`--------------*)
(* Another Olena-like example with recursive definitions.
class internal_dpoint_nd < stc::none
{
vtype mydim_type = find dpoint2d "dim_type";
}
class dpoint2d < internal_dpoint_nd
{
// Dummy value (because our C++ types are limited in this prototype).
vtype dim_type = int
}
*)
(* However, we can't write this
let rec internal_dpoint_nd =
Scoop_Class { super = Stc_None;
vtypes = create_vtypes ["mydim_type",
(find dpoint2d "dim_type")] }
and dpoint2d =
Scoop_Class { super = internal_dpoint_nd;
vtypes = create_vtypes ["dim_type", Std_Int] }
in
find dpoint2d "dim_type";;
because of the limitations of the recursive definitions of OCaml.
These limitations reflect issues w.r.t. recursive definitions in
C++ too. A new mechanism is needed, both in this OCaml prototype
and in its C++ counterpart (stc/scoop2.hh).
*)
......@@ -801,7 +801,7 @@ struct e_n_d__w_i_t_h___s_e_m_i_c_o_l_o_n;
Namespace::typedef_::Target1##_type>::ret, \
Namespace::typedef_::Target2##_type>::ret
# define stc_find_deduce_vtype(Namespace, From, Target) \
# define stc_find_deduce_vtype(Namespace, From, Target1, Target2) \
typename \
Namespace::find_vtype< typename \
Namespace::find_vtype<From, \
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment