Mirror reflection library 0.5.13
|
00001 00011 #ifndef MIRROR_META_TYPE_1011291729_HPP 00012 #define MIRROR_META_TYPE_1011291729_HPP 00013 00014 #include <mirror/preprocessor.hpp> 00015 #include <mirror/meta_namespace.hpp> 00016 #include <mirror/auxiliary/template_type_name.hpp> 00017 #include <mirror/auxiliary/meta_type.hpp> 00018 #include <mirror/ct_string/basic_string.hpp> 00019 #include <mirror/meta_prog/lambda.hpp> 00020 00021 MIRROR_NAMESPACE_BEGIN 00022 00023 namespace _type { 00024 00025 // Specialization of this structure provide basic meta-data about types 00026 template <typename Type> 00027 struct _ 00028 { 00029 typedef spec_type_tag kind; 00030 typedef mirror::cts::string<> ct_name; 00031 }; 00032 00033 } // namespace _type 00034 00035 // Implementation of the type_category meta-function 00036 template <typename T> 00037 struct type_category 00038 { 00039 typedef typename mirror::_type::_<T>::kind type; 00040 }; 00041 00042 template <typename T> 00043 typename type_category<T>::type 00044 categorize_type(const T&) 00045 { 00046 return typename type_category<T>::type(); 00047 } 00048 00049 00050 template <class Type> 00051 struct meta_type 00052 : aux::meta_type_name_impl< 00053 Type, 00054 typename mirror::_type::_<Type>::category 00055 > 00056 { 00057 typedef typename aux::full_meta_object< 00058 typename mirror::_type::_<Type>::scope 00059 >::type scope; 00060 00061 typedef Type original_type; 00062 00063 typedef typename mirror::_type::_<Type>::ct_name static_name; 00064 }; 00065 00066 template <class Type> 00067 struct reflected 00068 { 00069 typedef typename aux::reflect_type<Type>::type type; 00070 }; 00071 00072 template <class Type> 00073 struct reflected_type : public aux::reflect_type<Type>::type 00074 { 00075 typedef typename aux::reflect_type<Type>::type type; 00076 }; 00077 00078 template <class MetaType, class ModifierExpr> 00079 struct apply_modifier 00080 { 00081 typedef typename reflected< 00082 typename mirror::mp::apply< 00083 ModifierExpr, 00084 typename original_type< 00085 MetaType 00086 >::type 00087 >::type 00088 >::type type; 00089 }; 00090 00091 // Implementation of the parameters meta-function for templated types 00092 template <template <typename...> class Template, typename ... Params> 00093 struct template_parameters<meta_type<Template<Params...> > > 00094 { 00095 typedef mp::range<meta_type<Params>...> type; 00096 }; 00097 00098 // Implementation of the parameters meta-function for templated classes 00099 template <template <typename...> class Template, typename ... Params> 00100 struct template_parameters<meta_class<Template<Params...> > > 00101 { 00102 typedef mp::range<meta_class<Params>...> type; 00103 }; 00104 00105 #define MIRROR_REG_GLOBAL_SCOPE_TYPE_BASICS(KIND, NAME, SPELLED) \ 00106 namespace _type { \ 00107 template <> \ 00108 struct _< NAME > \ 00109 { \ 00110 typedef meta_type_tag category; \ 00111 typedef mirror::spec_ ## KIND ## _tag kind; \ 00112 typedef mirror::_namespace::_ scope; \ 00113 MIRROR_IMPLEMENT_META_OBJECT_NAME_FUNCTIONS(#NAME) \ 00114 typedef typename mirror::cts::string< \ 00115 MIRROR_PP_EXPAND_ARGS SPELLED \ 00116 >::type ct_name; \ 00117 }; \ 00118 } 00119 00120 #define MIRROR_REG_GLOBAL_SCOPE_TYPE_CTS(NAME, SPELLED) \ 00121 MIRROR_REG_GLOBAL_SCOPE_TYPE_BASICS(type, NAME, SPELLED) \ 00122 MIRROR_ADD_TO_GLOBAL_LIST( \ 00123 mirror::_namespace::_, \ 00124 mirror::meta_type< NAME > \ 00125 ) 00126 00127 #ifdef MIRROR_DOCUMENTATION_ONLY 00128 00129 00138 #define MIRROR_REG_GLOBAL_SCOPE_TYPE(NAME) 00139 #else 00140 #define MIRROR_REG_GLOBAL_SCOPE_TYPE(NAME) \ 00141 MIRROR_REG_GLOBAL_SCOPE_TYPE_CTS(NAME, ()) 00142 #endif 00143 00144 // Helper macro used in implementation of MIRROR_REG_TYPE 00145 #define MIRROR_REG_TYPE_BASICS(KIND, NAMESPACE, NAME, SPELLED) \ 00146 namespace _type { \ 00147 template <> \ 00148 struct _< :: NAMESPACE :: NAME > \ 00149 { \ 00150 typedef meta_type_tag category; \ 00151 typedef mirror::spec_ ## KIND ## _tag kind; \ 00152 typedef mirror::_namespace:: NAMESPACE ::_ scope; \ 00153 MIRROR_IMPLEMENT_META_OBJECT_NAME_FUNCTIONS(#NAME) \ 00154 typedef typename mirror::cts::string< \ 00155 MIRROR_PP_EXPAND_ARGS SPELLED \ 00156 >::type ct_name; \ 00157 }; \ 00158 } /* namespace _type */ 00159 00160 #define MIRROR_REG_TYPE_CTS(NAMESPACE, NAME, SPELLED) \ 00161 MIRROR_REG_TYPE_BASICS(type, NAMESPACE, NAME, SPELLED) \ 00162 MIRROR_ADD_TO_GLOBAL_LIST( \ 00163 mirror::_namespace :: NAMESPACE :: _, \ 00164 mirror::meta_type< :: NAMESPACE :: NAME > \ 00165 ) 00166 00167 #ifdef MIRROR_DOCUMENTATION_ONLY 00168 00169 00180 #define MIRROR_REG_TYPE(NAMESPACE, NAME) 00181 #else 00182 #define MIRROR_REG_TYPE(NAMESPACE, NAME) \ 00183 MIRROR_REG_TYPE_CTS(NAMESPACE, NAME, ()) 00184 #endif 00185 00186 // Helper macro used in implementation of MIRROR_REG_*_NESTED 00187 #define MIRROR_REG_NESTED_TYPE_BASICS(KIND, PARENT_CLASS, NAME, SPELLED) \ 00188 namespace _type { \ 00189 template <> \ 00190 struct _< :: PARENT_CLASS :: NAME > \ 00191 { \ 00192 typedef meta_type_tag category; \ 00193 typedef mirror::spec_ ## KIND ## _tag kind; \ 00194 typedef mirror::_class::_< :: PARENT_CLASS > scope; \ 00195 MIRROR_IMPLEMENT_META_OBJECT_NAME_FUNCTIONS(#NAME) \ 00196 typedef typename mirror::cts::string< \ 00197 MIRROR_PP_EXPAND_ARGS SPELLED \ 00198 >::type ct_name; \ 00199 }; \ 00200 } /* namespace _type */ 00201 00202 #ifdef MIRROR_DOCUMENTATION_ONLY 00203 00204 00217 #define MIRRORED_TYPE(FULL_TYPE_NAME) mirror::MetaType 00218 #else 00219 #define MIRRORED_TYPE(FULL_TYPE_NAME) \ 00220 mirror::meta_type< FULL_TYPE_NAME > 00221 #endif 00222 00223 MIRROR_NAMESPACE_END 00224 00225 #endif //include guard 00226