https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Set the pseudosuper link using a separate class instead of an
internal virtual type.
* stc/properties.hh (stc_equip_namespace_with_properties):
Generate a set_pseudosuper_type struct. Use it to get the
pseudosuper links in recursive vtype retrieval algorithms.
(stc_set_pseudosuper, stc_pseudosuper, stc_pseudosuper_): New
macros.
* tests/properties.cc: Adjust.
stc/properties.hh | 46 +++++++++++++++++++++++++++++++++++++---------
tests/properties.cc | 20 +++++++-------------
2 files changed, 44 insertions(+), 22 deletions(-)
Index: tests/properties.cc
--- tests/properties.cc (revision 425)
+++ tests/properties.cc (working copy)
@@ -118,24 +118,18 @@
// Forward declaration.
struct C;
- // C do not derive from B, but we want its vtypes to ``inherit''
- // from B's vtypes (see the specilization
- // vtypes<category::my_cat, C>.
+ // C doesn't derive from B, but we want its vtypes to ``inherit''
+ // from B's vtypes (see the specialization
+ // types<category::my_cat, C>).
+
+ // Warning, this sugar might me remove from properties.hh.
+ /// Link to B (``pseudo'' inheritance).
+ stc_set_pseudosuper(C, B);
/// Types associated to my::C.
template<>
struct vtypes<category::my_cat, C>
{
- // FIXME: Having this link here is not elegant when you consider
- // ext_vtype<>: this means that even if you have only a vtype
- // declared as ext_vtype, you'll still have to define a
- // corresponding vtypes<>, at least to define the pseudosuper
- // class. What about externalizing this information, maybe with
- // set_pseudosuper_type<>, and a macro set_pseudosuper() as sugar?
-
- /// Link to B (``pseudo'' inheritance).
- typedef B pseudosuper_type;
-
// A type defined only here (and not in the super class).
typedef double zorg_type;
};
Index: stc/properties.hh
--- stc/properties.hh (revision 425)
+++ stc/properties.hh (working copy)
@@ -72,6 +72,17 @@
}; \
\
\
+ /* ------------------------ */ \
+ /* ``Pseudo'' inheritance. */ \
+ /* ------------------------ */ \
+ \
+ template <typename type> \
+ struct set_pseudosuper_type \
+ { \
+ typedef mlc::none ret; \
+ }; \
+ \
+ \
/* --------------- */ \
/* Virtual types. */ \
/* --------------- */ \
@@ -137,8 +148,7 @@
/** Implicit parent (i.e. super), if any. */ \
typedef stc_super(from_type) super; \
/** Pseudosuper class, if any. */ \
- typedef stc_internal_get_typedef(types, typedef_::pseudosuper_type) \
- pseudosuper; \
+ typedef stc_pseudosuper(from_type) pseudosuper; \
\
typedef typename \
mlc::if_< \
@@ -206,11 +216,7 @@
/** Implicit parent (i.e. super), if any. */ \
typedef stc_super(from_type) super; \
/** Pseudosuper class, if any. */ \
- /* FIXME: Looking for this information is not elegant. Have a */ \
- /* look at static/tests/properties.cc for a better suggestion. */ \
- typedef vtypes<category, from_type> types; \
- typedef stc_internal_get_typedef(types, typedef_::pseudosuper_type) \
- pseudosuper; \
+ typedef stc_pseudosuper(from_type) pseudosuper; \
\
typedef typename \
mlc::if_< \
@@ -343,8 +349,10 @@
| Macros. |
`---------*/
-/* FIXME: I don't know this macro will be really usable; what if T is
- a template class? */
+/* FIXME: I don't know whether this macro will be really usable; what
+ if Type is a template class? We would have to provide additional
+ versions of this macro, with support for one parameter, two
+ parameters, etc. */
/// \def Declare the immediate base class \a Super of \a Type.
# define stc_set_super(Type, Super) \
template <> \
@@ -353,6 +361,18 @@
typedef Super ret; \
}
+/* FIXME: I don't know whether this macro will be really usable; what
+ if Type is a template class? We would have to provide additional
+ versions of this macro, with support for one parameter, two
+ parameters, etc. */
+/// \def Declare the pseudosuper class \a PseudoSuper of \a Type.
+# define stc_set_pseudosuper(Type, PseudoSuper) \
+ template <> \
+ struct set_pseudosuper_type<Type> \
+ { \
+ typedef PseudoSuper ret; \
+ }
+
/// \def Get the immediate base class of T (version with typename).
# define stc_super(T) \
typename set_super_type<T>::ret
@@ -361,6 +381,14 @@
# define stc_super_(T) \
set_super_type<T>::ret
+/// \def Get the pseudosuper class of T (version with typename).
+# define stc_pseudosuper(T) \
+ typename set_pseudosuper_type<T>::ret
+
+/// \def Get the pseudosuper class of T (version without typename).
+# define stc_pseudosuper_(T) \
+ set_pseudosuper_type<T>::ret
+
/// Get the property \a Typedef from \a FromType (version with typename).
#define stc_typeof(Category, FromType, Typedef) \
typename typeof_<Category, FromType, typedef_:: Typedef##_type >::ret
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
* ChangeLog, metalic/ChangeLog: Clean up ChangeLogs.
* extended/ChangeLog: New.
extended/ChangeLog | 5 +++++
metalic/ChangeLog | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
Index: extended/ChangeLog
--- extended/ChangeLog (revision 0)
+++ extended/ChangeLog (revision 0)
@@ -0,0 +1,5 @@
+2006-03-14 Roland Levillain <roland(a)lrde.epita.fr>
+
+ * tests/Makefile.am (mlcdir, nobase_mlc_HEADERS): Remove.
+ (AM_CPPFLAGS): New.
+ * xtd/Makefile.am: New file.
Index: metalic/ChangeLog
--- metalic/ChangeLog (revision 424)
+++ metalic/ChangeLog (working copy)
@@ -1,3 +1,16 @@
+2006-03-14 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Catch up with recent changes and fix some tests of Metalic.
+
+ * mlc/properties.hh (mlc_equip_namespace_with_properties):
+ Catch up with recent changes in typedef.hh/ret.hh.
+ Don't declare a local `ret' typedef; include mlc/ret.hh, and use
+ the `mlc_ret' macro instead.
+ * mlc/cmp.hh (eq_<T, T>): Solve ambiguous calls to
+ ensure().
+ * tests/ret.cc: Include mlc/ret.hh instead of
+ mlc/typedef.hh.
+
2006-03-10 Thierry Geraud <theo(a)lrde.epita.fr>
Minor addition.
@@ -43,6 +56,33 @@
* mlc/switch.hh: Change that makes this file soon obsolete.
* mlc/case.hh: New file.
+2006-02-20 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Revamp the virtual types (aka properties) system.
+
+ No longer use the C++'s inheritance mechanism to ``pack'' the
+ internal vtypes of a class. Rely on a metacode algorithm to
+ recursively look for vtypes in internal and external vtypes
+ instead, using both the super link and a ``pseudosuper'' link to
+ visit the upper classes. The set/get classes have been replaced
+ by a single class (in fact, by two classes, one for internal
+ vtypes, the other for external vtypes). The pseudosuper link is
+ used to inherit (or fetch) the vtypes from a given class, without
+ needing to inherit from this class.
+
+ * mlc/properties.hh (mlc_equip_namespace_with_properties):
+ Rewrite this macro.
+ (set_types, set_ext_types): Rename as...
+ (vtypes, ext_vtypes): ...this.
+ (get_types, get_ext_type): Remove.
+ * tests/properties.cc: Update the test.
+ Check for new cases (external vtype, pseudo inheritance of
+ vtypes).
+ (rec_get_vtype, rec_get_ext_vtype): New.
+ This class holds the algorithm for the recursive retrieval of
+ internal/external vtypes.
+ (typeof_): Adjust.
+
2006-02-17 Thierry Geraud <theo(a)lrde.epita.fr>
Enhance error handling in mlc::switch_.