https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog
from Thierry Geraud <theo(a)lrde.epita.fr>
Add new features such as variadic type list.
* mlc/elt.hh: New file.
* mlc/bool.hh (iff_): New class.
* mlc/pair.hh: New file.
* mlc/valist.hh: New file.
* mlc/cmp.hh: Update.
* mlc/uint.hh: New file.
bool.hh | 22 +++++--
cmp.hh | 2
elt.hh | 38 +++++++++++++
pair.hh | 99 +++++++++++++++++++++++++++++++++++
uint.hh | 68 ++++++++++++++++++++++++
valist.hh | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 396 insertions(+), 7 deletions(-)
Index: mlc/elt.hh
--- mlc/elt.hh (revision 0)
+++ mlc/elt.hh (revision 0)
@@ -0,0 +1,38 @@
+// 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_ELT_HH
+# define METALIC_ELT_HH
+
+
+# define mlc_elt(Type, Ith) typename Type::template elt<I>::ret
+
+# define mlc_elt_(Type, Ith) Type::template elt<I>::ret
+
+
+
+#endif // ! METALIC_ELT_HH
Index: mlc/bool.hh
--- mlc/bool.hh (revision 407)
+++ mlc/bool.hh (working copy)
@@ -30,9 +30,10 @@
# include <mlc/value.hh>
# include <mlc/flags.hh>
+# include <mlc/wrap.hh>
-/*! \macro mlc_bool(BExpr)
+/*! \def mlc_bool(BExpr)
**
** Macro that retrieves a Boolean value from a Boolean expression type.
** Its result is either true or false.
@@ -41,9 +42,14 @@
-// FIXME: keep it or not?
-# define mlc_type_when(T, BExpr) \
- typename type_when_<T, BExpr>::ret
+/*! \def mlc_iff(Type, BExpr)
+**
+** FIXME: doc
+*/
+# define mlc_iff(Type, BExpr) typename mlc::iff_<Type, BExpr>::ret
+# define mlc_iff_(Type, BExpr) mlc::iff_<Type, BExpr>::ret
+
+
@@ -266,9 +272,13 @@
};
- // FIXME: keep it or not?
+ /*! \class mlc::iff_<T, bexpr>
+ **
+ ** FIXME: doc
+ ** T iff bexpr
+ */
template <typename T, typename bexpr>
- struct type_when_ :
+ struct iff_ :
private ensure_<bexpr>
{
typedef T ret;
Index: mlc/pair.hh
--- mlc/pair.hh (revision 0)
+++ mlc/pair.hh (revision 0)
@@ -0,0 +1,99 @@
+// 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_PAIR_HH
+# define METALIC_PAIR_HH
+
+# include <mlc/bool.hh>
+# include <mlc/uint.hh>
+
+
+
+
+namespace mlc
+{
+
+ namespace internal
+ {
+
+ template <typename E1, typename E2, unsigned i>
+ struct pair_elt_;
+
+ } // end of namespace mlc::internal
+
+
+ /*! \class mlc::pair_<E1, E2>
+ **
+ ** This class is FIXME */
+
+ template <typename E1, typename E2>
+ struct pair_ : public mlc::abstract::type
+ {
+ static const unsigned size_value = 2;
+
+ typedef E1 first_elt;
+ typedef E2 second_elt;
+
+ template <unsigned i>
+ struct elt : private ensure_< or_< uint_equal_<i, 1>,
+ uint_equal_<i, 2> > >,
+ public internal::pair_elt_<E1, E2, i>
+ {
+ };
+ };
+
+
+
+ namespace internal
+ {
+
+ template <typename E1, typename E2>
+ struct pair_elt_ <E1, E2, 1>
+ {
+ typedef E1 ret;
+ };
+
+ template <typename E1, typename E2>
+ struct pair_elt_ <E1, E2, 2>
+ {
+ typedef E2 ret;
+ };
+
+ } // end of namespace mlc::internal
+
+
+
+} // end of namespace mlc
+
+
+
+# include <mlc/elt.hh>
+
+
+
+
+#endif // ! METALIC_PAIR_HH
Index: mlc/valist.hh
--- mlc/valist.hh (revision 0)
+++ mlc/valist.hh (revision 0)
@@ -0,0 +1,174 @@
+// 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_VALIST_HH
+# define METALIC_VALIST_HH
+
+# include <mlc/bool.hh>
+# include <mlc/cmp.hh>
+# include <mlc/uint.hh>
+
+
+# define mlc_internal_valist_decl_params_ \
+ typename E1, typename E2, typename E3, \
+ typename E4, typename E5, typename E6, typename E7, \
+ typename E8, typename E9
+
+
+# define mlc_internal_valist_params_ \
+ E1, E2, E3, E4, E5, E6, E7, E8, E9
+
+
+# define mlc_internal_valist_elt_spe(I) \
+ template < mlc_internal_valist_decl_params_ > \
+ struct valist_elt_ < mlc_internal_valist_params_, I > \
+ : private ensure_< neq_<E##I, internal::valist_none> > \
+ { \
+ typedef E##I ret; \
+ }
+
+
+
+namespace mlc
+{
+
+ namespace internal
+ {
+
+ struct valist_none;
+
+ template < mlc_internal_valist_decl_params_,
+ unsigned i >
+ struct valist_elt_;
+
+ template <typename list> struct valist_size_;
+
+ } // end of namespace mlc::internal
+
+
+ /*! \class mlc::valist_<E1,..>
+ **
+ ** This class is FIXME */
+
+ template < typename E1 = internal::valist_none,
+ typename E2 = internal::valist_none,
+ typename E3 = internal::valist_none,
+ typename E4 = internal::valist_none,
+ typename E5 = internal::valist_none,
+ typename E6 = internal::valist_none,
+ typename E7 = internal::valist_none,
+ typename E8 = internal::valist_none,
+ typename E9 = internal::valist_none >
+ struct valist_ : public mlc::abstract::type
+ {
+ static const unsigned size_value = internal::valist_size_<
+ valist_<mlc_internal_valist_params_> >::value;
+
+ template <unsigned i>
+ struct elt : private ensure_list_< uint_greater_or_equal_<i, 1>,
+ uint_less_or_equal_<i, size_value> >,
+ public internal::valist_elt_<mlc_internal_valist_params_, i>
+ {
+ };
+ };
+
+
+
+ namespace internal
+ {
+
+ mlc_internal_valist_elt_spe(1);
+ mlc_internal_valist_elt_spe(2);
+ mlc_internal_valist_elt_spe(3);
+ mlc_internal_valist_elt_spe(4);
+ mlc_internal_valist_elt_spe(5);
+ mlc_internal_valist_elt_spe(6);
+ mlc_internal_valist_elt_spe(7);
+ mlc_internal_valist_elt_spe(8);
+ mlc_internal_valist_elt_spe(9);
+
+
+ template <>
+ struct valist_size_ < valist_<> >
+ { enum { value = 0 }; };
+
+ template <class E1>
+ struct valist_size_ < valist_<E1> >
+ { enum { value = 1 }; };
+
+ template <class E1, class E2>
+ struct valist_size_ < valist_<E1,E2> >
+ { enum { value = 2 }; };
+
+ template <class E1, class E2, class E3>
+ struct valist_size_ < valist_<E1,E2,E3> >
+ { enum { value = 3 }; };
+
+ template <class E1, class E2, class E3, class E4>
+ struct valist_size_ < valist_<E1,E2,E3,E4> >
+ { enum { value = 4 }; };
+
+ template <class E1, class E2, class E3, class E4,
+ class E5>
+ struct valist_size_ < valist_<E1,E2,E3,E4,E5> >
+ { enum { value = 5 }; };
+
+ template <class E1, class E2, class E3, class E4,
+ class E5, class E6>
+ struct valist_size_ < valist_<E1,E2,E3,E4,E5,E6> >
+ { enum { value = 6 }; };
+
+ template <class E1, class E2, class E3, class E4,
+ class E5, class E6, class E7>
+ struct valist_size_ < valist_<E1,E2,E3,E4,E5,E6,E7> >
+ { enum { value = 7 }; };
+
+ template <class E1, class E2, class E3, class E4,
+ class E5, class E6, class E7, class E8>
+ struct valist_size_ < valist_<E1,E2,E3,E4,E5,E6,E7,E8> >
+ { enum { value = 8 }; };
+
+ template <class E1, class E2, class E3, class E4,
+ class E5, class E6, class E7, class E8,
+ class E9>
+ struct valist_size_ < valist_<E1,E2,E3,E4,E5,E6,E7,E8,E9> >
+ { enum { value = 9 }; };
+
+
+
+ } // end of namespace mlc::internal
+
+
+
+} // end of namespace mlc
+
+
+# include <mlc/elt.hh>
+
+
+
+#endif // ! METALIC_VALIST_HH
Index: mlc/cmp.hh
--- mlc/cmp.hh (revision 407)
+++ mlc/cmp.hh (working copy)
@@ -107,7 +107,7 @@
/// Check whether a type is a sound (supposedly before using it).
template <typename T>
- struct is_ok : public ands_< neq_<T, not_found>,
+ struct is_ok : public and_list_< neq_<T, not_found>,
neq_<T, not_ok>,
neq_<T, undefined > >
{
Index: mlc/uint.hh
--- mlc/uint.hh (revision 0)
+++ mlc/uint.hh (revision 0)
@@ -0,0 +1,68 @@
+// 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_UINT_HH
+# define METALIC_UINT_HH
+
+# include <mlc/bool.hh>
+
+
+namespace mlc
+{
+
+ // FIXME: doc and complete code...
+
+ template <unsigned lvalue, unsigned rvalue>
+ struct uint_equal_ : public bool_<( lvalue == rvalue )>
+ {};
+
+ template <unsigned lvalue, unsigned rvalue>
+ struct uint_not_equal_ : public bool_<( lvalue != rvalue )>
+ {};
+
+ template <unsigned lvalue, unsigned rvalue>
+ struct uint_greater_ : public bool_<( lvalue > rvalue )>
+ {};
+
+ template <unsigned lvalue, unsigned rvalue>
+ struct uint_greater_or_equal_ : public bool_<( lvalue >= rvalue )>
+ {};
+
+ template <unsigned lvalue, unsigned rvalue>
+ struct uint_less_ : public bool_<( lvalue < rvalue )>
+ {};
+
+ template <unsigned lvalue, unsigned rvalue>
+ struct uint_less_or_equal_ : public bool_<( lvalue <= rvalue )>
+ {};
+
+
+} // end of namespace mlc
+
+
+
+#endif // ! METALIC_UINT_HH