Commit 3993ecfc authored by Thierry Geraud's avatar Thierry Geraud
Browse files

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.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@394 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 4aff4039
2006-02-10 Thierry Geraud <theo@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.
2006-02-09 Thierry Geraud <theo@lrde.epita.fr> 2006-02-09 Thierry Geraud <theo@lrde.epita.fr>
Modify slightly the ensure_ and ensure_list_ tools. Modify slightly the ensure_ and ensure_list_ tools.
......
// 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
// 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
...@@ -237,7 +237,7 @@ namespace mlc ...@@ -237,7 +237,7 @@ namespace mlc
*/ */
# define mlc_is_a(T, U) \ # 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) /*! \macro mlc_is_a_(T, U)
...@@ -249,7 +249,7 @@ mlc::wrap<typename mlc::internal::is_a<sizeof(mlc::form::of<U >())>::ret<T,U > > ...@@ -249,7 +249,7 @@ mlc::wrap<typename mlc::internal::is_a<sizeof(mlc::form::of<U >())>::ret<T,U > >
*/ */
# define mlc_is_a_(T, U) \ # 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 #endif // ! METALIC_IS_A_HH
...@@ -169,7 +169,7 @@ namespace typedef_ { \ ...@@ -169,7 +169,7 @@ namespace typedef_ { \
struct TypedefName \ struct TypedefName \
{ \ { \
template <class T> \ template <class T> \
struct in_ \ struct from_ \
{ \ { \
private: \ private: \
typedef internal::TypedefName helper_; \ typedef internal::TypedefName helper_; \
...@@ -184,17 +184,17 @@ namespace typedef_ { \ ...@@ -184,17 +184,17 @@ namespace typedef_ { \
}; \ }; \
\ \
template <class T, bool b> \ template <class T, bool b> \
struct in_onlyif_; \ struct from_onlyif_; \
\ \
\ \
template <class T> \ 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> \ template <class T> \
struct in_onlyif_ <T, false> \ struct from_onlyif_ <T, false> \
{ \ { \
typedef mlc::dummy ret; \ typedef mlc::dummy ret; \
}; \ }; \
...@@ -213,26 +213,49 @@ struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n ...@@ -213,26 +213,49 @@ struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
** FIXME: doc ** FIXME: doc
*/ */
#define mlc_typedef(Type, TypedefName) \ # define mlc_typedef(Type, TypedefName) \
typename typedef_::TypedefName::in_<Type>::ret typename typedef_::TypedefName::from_<Type>::ret
#define mlc_typedef_(Type, TypedefName) \ # 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) /*! \macro mlc_typedef_onlyif(Type, TypedefName, Bexpr)
** **
** FIXME: doc ** FIXME: doc
*/ */
#define mlc_typedef_onlyif(Type, TypedefName, Bexpr) \ # 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::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
*/
#define mlc_typedef_onlyif_(Type, TypedefName, Bexpr) \ mlc_decl_typedef(ret);
typedef_::TypedefName::in_onlyif_<Type, mlc_bool(Bexpr)>::ret
# define mlc_ret(Type) typename typedef_::ret::from_<Type>::ret
......
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