
2005-04-13 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr> * mlc/properties.hh (f_get_type): Better version. * mlc/types.hh (not_ok): New type. * mlc/contract.hh (mlc_check_method_impl): New macro. * mlc/cmp.hh (is_ok): New meta-function. Index: mlc/properties.hh =================================================================== --- mlc/properties.hh (revision 140) +++ mlc/properties.hh (working copy) @@ -193,7 +193,7 @@ typedef \ typename f_rec_get_type<category, from_type, typedef_type>::ret \ type; \ - \ + \ ~f_get_type() \ { \ mlc::implies< mlc::is_found<default_prop>, \ @@ -202,7 +202,13 @@ mlc::is_found<type> >::ensure(); \ } \ \ - typedef typename mlc::if_< mlc::is_found<prop>, prop, type>::ret ret; \ + typedef typename mlc::if_< mlc::is_ok<prop>, \ + prop, \ + typename mlc::if_< mlc::is_ok<type>, \ + type, \ + mlc::internal::not_ok \ + > ::ret \ + > ::ret ret; \ }; \ \ } \ @@ -216,6 +222,7 @@ FromType, \ Namespace::internal::typedef_::Alias##_type>::ret + # define mlc_type_of(Namespace, Category, FromType, Alias) \ typename mlc_type_of_(Namespace, Category, FromType, Alias) Index: mlc/types.hh =================================================================== --- mlc/types.hh (revision 140) +++ mlc/types.hh (working copy) @@ -51,14 +51,14 @@ class no_type { private: no_type(); }; class default_type { private: default_type(); }; - namespace internal { class not_found { private: not_found(); }; + class not_ok { private: not_ok(); }; } // end of namespace mlc::internal + - } // end of namespace mlc Index: mlc/contract.hh =================================================================== --- mlc/contract.hh (revision 140) +++ mlc/contract.hh (working copy) @@ -40,4 +40,22 @@ # define postcondition(expr) assert(expr) +# define mlc_check_method_impl(WHERE, RETURN, NAME, ARG, CONST) \ +{ \ + typedef RETURN (WHERE::*meth)(ARG) CONST; \ + meth adr = &E::impl_##NAME; \ + adr = 0; \ +} \ +struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n + + +# define mlc_check_method_impl_2(WHERE, RETURN, NAME, ARG1, ARG2, CONST) \ +{ \ + typedef RETURN (WHERE::*meth)(ARG1, ARG2) CONST; \ + meth adr = &E::impl_##NAME; \ + adr = 0; \ +} \ +struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n + + #endif // ! METALIC_CONTRACT_HH Index: mlc/cmp.hh =================================================================== --- mlc/cmp.hh (revision 140) +++ mlc/cmp.hh (working copy) @@ -79,6 +79,16 @@ { }; + + + template <typename T> + struct is_ok : public and_< and_< neq<T, internal::not_found>, + neq<T, internal::not_ok> >, + neq<T, undefined_type> > + { + }; + + } // end of namespace mlc