https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog
from Thierry Geraud <theo(a)lrde.epita.fr>
Add implies, comma, typedef ret handling; then update.
* mlc/implies.hh: New file.
* mlc/is_a.hh: Update.
* mlc/comma.hh: New file.
* mlc/typedef.hh (in_, in_onlyif_): Rename as...
(from_, from_only_if_): ...this.
(mlc_typedef_in, mlc_typedef_in_): New macros.
(mlc_ret): New macro.
comma.hh | 39 +++++++++++++++++++++++++++++++++
implies.hh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
is_a.hh | 4 +--
typedef.hh | 41 +++++++++++++++++++++++++++--------
4 files changed, 144 insertions(+), 11 deletions(-)
Index: mlc/implies.hh
--- mlc/implies.hh (revision 0)
+++ mlc/implies.hh (revision 0)
@@ -0,0 +1,71 @@
+// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef METALIC_IMPLIES_HH
+# define METALIC_IMPLIES_HH
+
+# include <mlc/bool.hh>
+
+
+/*! \macro mlc_implies(Left_BExpr, Right_BExpr)
+**
+** Macro correponding to mlc::implies_<L, R>, for use in a template
+** context.
+**
+** \see mlc::implies_<L, R>
+*/
+
+# define mlc_implies(Left_BExpr, Right_BExpr) \
+ typename mlc::implies_<Left_BExpr, Right_BExpr>::ret
+
+# define mlc_implies_(Left_BExpr, Right_BExpr) \
+ mlc::implies_<Left_BExpr, Right_BExpr>::ret
+
+
+namespace mlc
+{
+
+ /*! \class mlc::implies_<L, R>
+ **
+ ** Logical implication "L => R" with L and R being Boolean
+ ** expression types. This class is also a Boolean expression type.
+ **
+ ** Sample use:
+ ** mlc::implies_< mlc_is_builtin(T), mlc_eq(T, int) >::ensure();
+ ** which means "if T is a buit-in type, it has to be int".
+ */
+
+ template <typename L, typename R>
+ struct implies_
+ : public bool_<( !mlc_bool(L) || mlc_bool(R) )>
+ {};
+
+} // end of namespace mlc
+
+
+
+#endif // ! METALIC_IMPLIES_HH
Index: mlc/is_a.hh
--- mlc/is_a.hh (revision 393)
+++ mlc/is_a.hh (working copy)
@@ -237,7 +237,7 @@
*/
# define mlc_is_a(T, U) \
-mlc::wrap<typename mlc::internal::is_a<sizeof(mlc::form::of<U
>())>::ret<T,U > >
+mlc::wrap_<typename mlc::internal::is_a<sizeof(mlc::form::of<U
>())>::ret<T,U > >
/*! \macro mlc_is_a_(T, U)
@@ -249,7 +249,7 @@
*/
# define mlc_is_a_(T, U) \
-mlc::wrap<mlc::internal::is_a< sizeof(mlc::form::of<U >())>::ret<T,U
> >
+mlc::wrap_<mlc::internal::is_a< sizeof(mlc::form::of<U >())>::ret<T,U
> >
#endif // ! METALIC_IS_A_HH
Index: mlc/comma.hh
--- mlc/comma.hh (revision 0)
+++ mlc/comma.hh (revision 0)
@@ -0,0 +1,39 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef METALIC_COMMA_HH
+# define METALIC_COMMA_HH
+
+
+// FIXME: doc
+
+# define mlc_comma_1(a, b) a, b
+# define mlc_comma_2(a, b, c) a, b, c
+# define mlc_comma_3(a, b, c, d) a, b, c, d
+
+
+#endif // ! METALIC_COMMA_HH
Index: mlc/typedef.hh
--- mlc/typedef.hh (revision 393)
+++ mlc/typedef.hh (working copy)
@@ -169,7 +169,7 @@
struct TypedefName \
{ \
template <class T> \
- struct in_ \
+ struct from_ \
{ \
private: \
typedef internal::TypedefName helper_; \
@@ -184,17 +184,17 @@
}; \
\
template <class T, bool b> \
- struct in_onlyif_; \
+ struct from_onlyif_; \
\
\
template <class T> \
- struct in_onlyif_ <T, true> \
+ struct from_onlyif_ <T, true> \
{ \
- typedef typename in_<T>::ret ret; \
+ typedef typename from_<T>::ret ret; \
}; \
\
template <class T> \
- struct in_onlyif_ <T, false> \
+ struct from_onlyif_ <T, false> \
{ \
typedef mlc::dummy ret; \
}; \
@@ -214,13 +214,25 @@
*/
#define mlc_typedef(Type, TypedefName) \
- typename typedef_::TypedefName::in_<Type>::ret
+ typename typedef_::TypedefName::from_<Type>::ret
#define mlc_typedef_(Type, TypedefName) \
- typedef_::TypedefName::in_<Type>::ret
+ typedef_::TypedefName::from_<Type>::ret
+/*! \macro mlc_typedef_in(Namespace, Type, TypedefName)
+**
+** FIXME: doc
+*/
+
+# define mlc_typedef_in(Namespace, Type, TypedefName) \
+ typename Namespace::typedef_::TypedefName::from_<Type>::ret
+
+# define mlc_typedef_in_(Namespace, Type, TypedefName) \
+ Namespace::typedef_::TypedefName::from_<Type>::ret
+
+
/*! \macro mlc_typedef_onlyif(Type, TypedefName, Bexpr)
**
@@ -228,11 +240,22 @@
*/
#define mlc_typedef_onlyif(Type, TypedefName, Bexpr) \
- typename typedef_::TypedefName::in_onlyif_<Type, mlc_bool(Bexpr)>::ret
+ typename typedef_::TypedefName::from_onlyif_<Type, mlc_bool(Bexpr)>::ret
#define mlc_typedef_onlyif_(Type, TypedefName, Bexpr) \
- typedef_::TypedefName::in_onlyif_<Type, mlc_bool(Bexpr)>::ret
+ typedef_::TypedefName::from_onlyif_<Type, mlc_bool(Bexpr)>::ret
+
+
+
+/*! \FIXME: what's the correct comment flag here?
+**
+** Since we often rely on having a typedef named "ret" in types, we offer
+** a default equipment for this particular typedef. FIXME: doc
+*/
+
+mlc_decl_typedef(ret);
+# define mlc_ret(Type) typename typedef_::ret::from_<Type>::ret