|
Boost-Commit : |
From: chochlik_at_[hidden]
Date: 2008-07-05 09:55:54
Author: matus.chochlik
Date: 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
New Revision: 47109
URL: http://svn.boost.org/trac/boost/changeset/47109
Log:
Split meta-types for non-trivial types into separate files
Added support for function typenames
Added:
sandbox/mirror/boost/mirror/detail/function_type_name.hpp (contents, props changed)
sandbox/mirror/boost/mirror/meta_types/_array.hpp (contents, props changed)
sandbox/mirror/boost/mirror/meta_types/_const_volatile.hpp (contents, props changed)
sandbox/mirror/boost/mirror/meta_types/_free_fn.hpp (contents, props changed)
sandbox/mirror/boost/mirror/meta_types/_native.hpp (contents, props changed)
sandbox/mirror/boost/mirror/meta_types/_ptr_ref.hpp (contents, props changed)
sandbox/mirror/boost/mirror/meta_types/boost_bstring.hpp (contents, props changed)
sandbox/mirror/boost/mirror/meta_types/std_string.hpp (contents, props changed)
Text files modified:
sandbox/mirror/boost/mirror/detail/decorated_type_name.hpp | 19 +
sandbox/mirror/boost/mirror/meta_data_fwd.hpp | 4
sandbox/mirror/boost/mirror/meta_inheritance.hpp | 2
sandbox/mirror/boost/mirror/meta_type.hpp | 323 +--------------------------------------
sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml | 5
sandbox/mirror/libs/mirror/example/registering/classes.cpp | 53 +++---
sandbox/mirror/libs/mirror/example/registering/types.cpp | 15 +
7 files changed, 74 insertions(+), 347 deletions(-)
Modified: sandbox/mirror/boost/mirror/detail/decorated_type_name.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/decorated_type_name.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/decorated_type_name.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -20,9 +20,9 @@
namespace detail {
template <class MetaType, class Decorator>
-struct decorated_type_name
+struct decorated_type_name_base
{
-private:
+protected:
template <bool FullName>
inline static bstring init_name(mpl::bool_<FullName> full_or_base)
{
@@ -36,7 +36,6 @@
return left;
}
-
public:
template <bool FullName>
inline static bstring build_name(
@@ -55,6 +54,13 @@
);
}
+
+};
+
+template <class Base>
+struct decorated_type_name_finisher : public Base
+{
+public:
template <bool FullName>
static const bstring& get_name(mpl::bool_<FullName> full_or_base)
{
@@ -71,9 +77,14 @@
{
return get_name(mpl::true_());
}
-
};
+template <class MetaType, class Decorator>
+struct decorated_type_name
+: decorated_type_name_finisher<
+ decorated_type_name_base<MetaType, Decorator>
+> { };
+
// no-op decorator
template <typename T>
struct type_name_decorator
Added: sandbox/mirror/boost/mirror/detail/function_type_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/function_type_name.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -0,0 +1,140 @@
+/**
+ * \file boost/mirror/detail/function_type_name.hpp
+ *
+ * Helpers for composing function typenames
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_DETAIL_FUNCTION_TYPE_NAME_HPP
+#define BOOST_MIRROR_META_DETAIL_FUNCTION_TYPE_NAME_HPP
+
+#include <boost/mpl/for_each.hpp>
+#include <boost/mpl/pop_back.hpp>
+#include <boost/mpl/back.hpp>
+#include <boost/mpl/transform.hpp>
+#include <boost/mpl/identity.hpp>
+//
+#include <boost/mirror/meta_data_fwd.hpp>
+#include <boost/mirror/detail/decorated_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+template <
+ typename RetValType,
+ typename CallingConvention,
+ typename ArgTypeList
+>
+struct function_type_name_base
+{
+private:
+ template <class FullOrBase>
+ class append_arg_typename
+ {
+ public:
+ template <typename T>
+ inline void operator()(::boost::mpl::identity<T>)
+ {
+ static bstring comma(BOOST_STR_LIT(", "));
+ list.append(BOOST_MIRRORED_TYPE(T)::get_name(FullOrBase()));
+ list.append(comma);
+ }
+
+ inline append_arg_typename(bstring& _list)
+ : list(_list)
+ { }
+ private:
+ bstring& list;
+ };
+
+ template <typename T>
+ struct to_identity
+ {
+ typedef mpl::identity<T> type;
+ };
+
+ template <typename TypeList, class FullOrBase>
+ inline static void append_args(
+ TypeList*,
+ bstring& str,
+ FullOrBase full_or_base
+ )
+ {
+ // append type names and a comma for all
+ // arguments bar the last
+ //
+ // transform the typelist
+ typedef typename mpl::transform<
+ typename mpl::pop_back<
+ ArgTypeList
+ >::type,
+ to_identity<mpl::_>
+ >:: type args_wo_last;
+ //
+ // call the functor
+ ::boost::mpl::for_each<
+ args_wo_last
+ >(append_arg_typename<FullOrBase>(str));
+ //
+ // append the last argument
+ typedef mpl::back<TypeList>::type last_arg_type;
+ str.append(BOOST_MIRRORED_TYPE(last_arg_type)::get_name(full_or_base));
+ }
+
+ // overload for empty argument list
+ template <class FullOrBase>
+ inline static void append_args(mpl::vector<>*, bstring& str, FullOrBase)
+ {
+ str.append(bstring(BOOST_STR_LIT("void")));
+ }
+
+protected:
+ template <bool FullName>
+ inline static bstring init_name(mpl::bool_<FullName> full_or_base)
+ {
+ static bstring space(BOOST_STR_LIT(" "));
+ static bstring l_par(BOOST_STR_LIT("("));
+ static bstring r_par(BOOST_STR_LIT(")"));
+ static bstring aster(BOOST_STR_LIT("*"));
+ //
+ // the return value type
+ typedef BOOST_MIRRORED_TYPE(RetValType) meta_RV;
+ bstring res(meta_RV::get_name(full_or_base));
+ //
+ // the calling convention
+ res.append(space);
+ res.append(l_par);
+ res.append(CallingConvention::name());
+ res.append(aster);
+ res.append(r_par);
+ //
+ // argument list
+ res.append(l_par);
+ append_args(((ArgTypeList*)0), res, full_or_base);
+ res.append(r_par);
+ return res;
+ }
+};
+
+template <
+ typename RetValType,
+ typename CallingConvention,
+ typename ArgTypeList
+>
+struct function_type_name
+: decorated_type_name_finisher<
+ function_type_name_base<RetValType, CallingConvention, ArgTypeList>
+> { };
+
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Modified: sandbox/mirror/boost/mirror/meta_data_fwd.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_data_fwd.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_data_fwd.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -101,13 +101,13 @@
/** Macro that expands into the meta_class for the
* given type or class.
*/
-#define BOOST_MIRROR_REFLECT_CLASS(CLASS) \
+#define BOOST_MIRRORED_CLASS(CLASS) \
::boost::mirror::meta_class<CLASS>
/** Macro that expands into the meta_class for the
* given type or class.
*/
-#define BOOST_MIRROR_REFLECT_CLASS_VT(CLASS, VARIANT_TAG) \
+#define BOOST_MIRRORED_CLASS_VT(CLASS, VARIANT_TAG) \
::boost::mirror::meta_class<\
CLASS, \
VARIANT_TAG\
Modified: sandbox/mirror/boost/mirror/meta_inheritance.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_inheritance.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_inheritance.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -35,7 +35,7 @@
typedef InheritanceSpec inheritance_specifier;
typedef AccessSpec access_specifier;
typedef BaseClass base_class;
- typedef BOOST_MIRROR_REFLECT_CLASS(BaseClass) meta_base_class;
+ typedef BOOST_MIRRORED_CLASS(BaseClass) meta_base_class;
};
/** This template stores the inheritance type and access specifier
Modified: sandbox/mirror/boost/mirror/meta_type.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_type.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_type.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -10,321 +10,24 @@
#ifndef BOOST_MIRROR_META_TYPE_HPP
#define BOOST_MIRROR_META_TYPE_HPP
-#include <boost/preprocessor/list/for_each.hpp>
-
-// meta namespaces
-#include <boost/mirror/meta_namespace.hpp>
//
-// type name decorations
-#include <boost/mirror/detail/decorated_type_name.hpp>
+// registering of meta-types
+#include <boost/mirror/detail/meta_type_registering.hpp>
+// register native types
+#include <boost/mirror/meta_types/_native.hpp>
+#include <boost/mirror/meta_types/std_string.hpp>
+// register bstrings
+#include <boost/mirror/meta_types/boost_bstring.hpp>
+//
+// non-trivial types
+#include <boost/mirror/meta_types/_const_volatile.hpp>
+#include <boost/mirror/meta_types/_ptr_ref.hpp>
+#include <boost/mirror/meta_types/_array.hpp>
+#include <boost/mirror/meta_types/_free_fn.hpp>
namespace boost {
namespace mirror {
-/** Meta-data describing types
- */
-template <typename Type>
-struct meta_type
-: public detail::full_name_builder<
- typename detail::registered_type_info<Type>::scope,
- detail::registered_type_info<Type>
->
-{
- inline static const bstring& base_name(void)
- {
- return get_name(mpl::false_());
- }
-
- inline static const bstring& full_name(void)
- {
- return get_name(mpl::true_());
- }
-
- typedef detail::registered_type_info<Type> base_info;
- typedef typename base_info::scope scope;
- typedef typename base_info::reflected_type reflected_type;
-};
-
-/** Helper macro used to declare base-name getting functions
- * and base-name length static constants
- */
-#define BOOST_MIRROR_REG_TYPE_DECLARE_BASE_NAME_HELPER(TYPE_NAME) \
- static const bstring& get_name(mpl::false_) \
- { \
- static bstring s_name(BOOST_STR_LIT(#TYPE_NAME)); \
- return s_name; \
- }
-
-/** Macro for registering global-scope types
- */
-#define BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(BASE_NAME) \
- namespace detail { \
- template <> struct registered_type_info< BASE_NAME > \
- { \
- typedef BOOST_MIRRORED_GLOBAL_SCOPE() scope; \
- typedef BASE_NAME reflected_type; \
- BOOST_MIRROR_REG_TYPE_DECLARE_BASE_NAME_HELPER(BASE_NAME) \
- }; \
- } // namespace detail
-
-/** 'Shorthand' for BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE macro
- */
-#define BOOST_MIRROR_REG_TYPE_GS(BASE_NAME) \
- BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(BASE_NAME)
-
-
-/** Macro for registering types nested in namespaces
- */
-#define BOOST_MIRROR_REG_TYPE(NAMESPACE, BASE_NAME) \
- namespace detail { \
- template <> struct registered_type_info< NAMESPACE::BASE_NAME > \
- { \
- typedef BOOST_MIRRORED_NAMESPACE(NAMESPACE) scope; \
- typedef NAMESPACE::BASE_NAME reflected_type; \
- BOOST_MIRROR_REG_TYPE_DECLARE_BASE_NAME_HELPER(BASE_NAME) \
- }; \
- } // namespace detail
-
-/** Macro that expands into a typedef-ined type selectos
- */
-#define BOOST_MIRROR_GET_TYPEDEFD_TYPE_SELECTOR(NAMESPACE, TYPEDEFD_NAME) \
- ::boost::mirror::typedef_::TYPEDEFD_NAME < \
- BOOST_MIRRORED_NAMESPACE( NAMESPACE ) \
- > \
-
-/** Macro for registering typedef-ined types in the global scope
- */
-#define BOOST_MIRROR_REG_TYPEDEF_GLOBAL_SCOPE(TYPEDEFD_NAME) \
- namespace typedef_ { \
- template <class MetaNamespace> struct TYPEDEFD_NAME; \
- template <> struct TYPEDEFD_NAME< \
- BOOST_MIRRORED_GLOBAL_SCOPE() \
- > { }; \
- } /* namespace typedef_ */ \
- namespace detail { \
- template <> struct registered_type_info< \
- BOOST_MIRROR_GET_TYPEDEFD_TYPE_SELECTOR( :: , TYPEDEFD_NAME) \
- > \
- { \
- typedef BOOST_MIRRORED_GLOBAL_SCOPE() scope; \
- typedef ::TYPEDEFD_NAME reflected_type; \
- BOOST_MIRROR_REG_TYPE_DECLARE_BASE_NAME_HELPER(TYPEDEFD_NAME) \
- }; \
- } // namespace detail
-
-#define BOOST_MIRROR_REG_TYPEDEF_GS(TYPEDEFD_NAME) \
- BOOST_MIRROR_REG_TYPEDEF_GLOBAL_SCOPE(TYPEDEFD_NAME)
-
-
-/** Macro for registering typedef-ined types in namespaces
- */
-#define BOOST_MIRROR_REG_TYPEDEF(NAMESPACE, TYPEDEFD_NAME) \
- namespace typedef_ { \
- template <class MetaNamespace> struct TYPEDEFD_NAME; \
- template <> struct TYPEDEFD_NAME< \
- BOOST_MIRRORED_NAMESPACE( NAMESPACE ) \
- > { }; \
- } /* namespace typedef_ */ \
- namespace detail { \
- template <> struct registered_type_info< \
- BOOST_MIRROR_GET_TYPEDEFD_TYPE_SELECTOR(NAMESPACE, TYPEDEFD_NAME) \
- > \
- { \
- typedef BOOST_MIRRORED_NAMESPACE(NAMESPACE) scope; \
- typedef NAMESPACE::TYPEDEFD_NAME reflected_type; \
- BOOST_MIRROR_REG_TYPE_DECLARE_BASE_NAME_HELPER(TYPEDEFD_NAME) \
- }; \
- } // namespace detail
-
-/** Declaration of meta types for types in declared inside
- * of a class.
- */
-#define BOOST_MIRROR_REG_TYPE_EMBEDDED(WRAPPER, BASE_NAME) \
- template <> struct meta_type< WRAPPER::BASE_NAME > \
- { \
- typedef meta_type< WRAPPER > scope; \
- typedef WRAPPER::BASE_NAME reflected_type; \
- BOOST_MIRROR_REG_TYPE_DECLARE_BASE_NAME_HELPER(BASE_NAME) \
- };
-
-#define BOOST_MIRROR_REG_TYPE_EMB(WRAPPER, BASE_NAME) \
- BOOST_MIRROR_REG_TYPE_EMBEDDED(WRAPPER, BASE_NAME)
-
-
-/** Register C++ native types
- */
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(void)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(bool)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(char)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(unsigned char)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(signed char)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(wchar_t)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(short int)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(unsigned short int)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(int)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(unsigned int)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(long int)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(unsigned long int)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(float)
-BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(double)
-
-/** Register std string and wstring
- */
-BOOST_MIRROR_REG_TYPE(::std, string)
-BOOST_MIRROR_REG_TYPE(::std, wstring)
-/** Now register the bchar and bstring too
- */
-BOOST_MIRROR_REG_TYPEDEF(::boost, bchar)
-BOOST_MIRROR_REG_TYPEDEF(::boost, bstring)
-
-/** Meta-types for pointers
- */
-template <class PointeeType>
-struct meta_type<PointeeType*> : detail::decorated_type_name<
- meta_type<PointeeType>,
- detail::type_name_decorator<PointeeType*>
->
-{
- typedef typename meta_type<PointeeType>::scope scope;
- typedef PointeeType* reflected_type;
-};
-
-
-
-/** Meta-types for arrays
- */
-template <class ElementType, size_t Size>
-struct meta_type<ElementType[Size]> : detail::decorated_type_name<
- meta_type<ElementType>,
- detail::type_name_decorator<ElementType[Size]>
->
-{
- typedef typename meta_type<ElementType>::scope scope;
- typedef ElementType reflected_type[Size];
-};
-
-
-template <class ElementType, size_t Size>
-struct meta_type<const ElementType[Size]> : detail::decorated_type_name<
- meta_type<const ElementType>,
- detail::type_name_decorator<ElementType[Size]>
->
-{
- typedef typename meta_type<ElementType>::scope scope;
- typedef const ElementType reflected_type[Size];
-};
-
-template <class ElementType, size_t Size>
-struct meta_type<volatile ElementType[Size]> : detail::decorated_type_name<
- meta_type<volatile ElementType>,
- detail::type_name_decorator<ElementType[Size]>
->
-{
- typedef typename meta_type<ElementType>::scope scope;
- typedef volatile ElementType reflected_type[Size];
-};
-
-template <class ElementType, size_t Size>
-struct meta_type<const volatile ElementType[Size]>
-: detail::decorated_type_name<
- meta_type<const volatile ElementType>,
- detail::type_name_decorator<ElementType[Size]>
->
-{
- typedef typename meta_type<ElementType>::scope scope;
- typedef const volatile ElementType reflected_type[Size];
-};
-
-template <class ElementType>
-struct meta_type<ElementType[]> : detail::decorated_type_name<
- meta_type<ElementType>,
- detail::type_name_decorator<ElementType[]>
->
-{
- typedef typename meta_type<ElementType>::scope scope;
- typedef ElementType reflected_type[];
-};
-
-template <class ElementType>
-struct meta_type<const ElementType []> : detail::decorated_type_name<
- meta_type<const ElementType>,
- detail::type_name_decorator<ElementType []>
->
-{
- typedef typename meta_type<ElementType>::scope scope;
- typedef ElementType const reflected_type [];
-};
-
-template <class ElementType>
-struct meta_type<volatile ElementType []> : detail::decorated_type_name<
- meta_type<volatile ElementType>,
- detail::type_name_decorator<ElementType []>
->
-{
- typedef typename meta_type<ElementType>::scope scope;
- typedef ElementType volatile reflected_type [];
-};
-
-template <class ElementType>
-struct meta_type<const volatile ElementType []>
-: detail::decorated_type_name<
- meta_type<const volatile ElementType>,
- detail::type_name_decorator<ElementType []>
->
-{
- typedef typename meta_type<ElementType>::scope scope;
- typedef ElementType const volatile reflected_type [];
-};
-
-
-
-/** Meta-types for references
- */
-template <class ReferredToType>
-struct meta_type<ReferredToType&> : detail::decorated_type_name<
- meta_type<ReferredToType>,
- detail::type_name_decorator<ReferredToType&>
->
-{
- typedef typename meta_type<ReferredToType>::scope scope;
- typedef ReferredToType& reflected_type;
-};
-
-/** Meta-types for const types
- */
-template <class NonConstType>
-struct meta_type<const NonConstType> : detail::decorated_type_name<
- meta_type<NonConstType>,
- detail::type_name_decorator<const NonConstType>
->
-{
- typedef typename meta_type<NonConstType>::scope scope;
- typedef const NonConstType reflected_type;
-};
-
-/** Meta-types for volatile types
- */
-template <class NonVolatileType>
-struct meta_type<volatile NonVolatileType> : detail::decorated_type_name<
- meta_type<NonVolatileType>,
- detail::type_name_decorator<volatile NonVolatileType>
->
-{
- typedef typename meta_type<NonVolatileType>::scope scope;
- typedef volatile NonVolatileType reflected_type;
-};
-
-/** Meta-types for const volatile types
- */
-template <class NonCVType>
-struct meta_type<const volatile NonCVType> : detail::decorated_type_name<
- meta_type<NonCVType>,
- detail::type_name_decorator<const volatile NonCVType>
->
-{
- typedef typename meta_type<NonCVType>::scope scope;
- typedef const volatile NonCVType reflected_type;
-};
} // namespace mirror
} // namespace boost
Added: sandbox/mirror/boost/mirror/meta_types/_array.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_types/_array.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -0,0 +1,112 @@
+/**
+ * \file boost/mirror/meta_types/_array.hpp
+ *
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_TYPES_ARRAY_HPP
+#define BOOST_MIRROR_META_TYPES_ARRAY_HPP
+
+// registering of meta-types
+#include <boost/mirror/detail/meta_type_registering.hpp>
+// type name decorations
+#include <boost/mirror/detail/decorated_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+
+
+/** Meta-types for arrays
+ */
+template <class ElementType, size_t Size>
+struct meta_type<ElementType[Size]> : detail::decorated_type_name<
+ meta_type<ElementType>,
+ detail::type_name_decorator<ElementType[Size]>
+>
+{
+ typedef typename meta_type<ElementType>::scope scope;
+ typedef ElementType reflected_type[Size];
+};
+
+
+template <class ElementType, size_t Size>
+struct meta_type<const ElementType[Size]> : detail::decorated_type_name<
+ meta_type<const ElementType>,
+ detail::type_name_decorator<ElementType[Size]>
+>
+{
+ typedef typename meta_type<ElementType>::scope scope;
+ typedef const ElementType reflected_type[Size];
+};
+
+template <class ElementType, size_t Size>
+struct meta_type<volatile ElementType[Size]> : detail::decorated_type_name<
+ meta_type<volatile ElementType>,
+ detail::type_name_decorator<ElementType[Size]>
+>
+{
+ typedef typename meta_type<ElementType>::scope scope;
+ typedef volatile ElementType reflected_type[Size];
+};
+
+template <class ElementType, size_t Size>
+struct meta_type<const volatile ElementType[Size]>
+: detail::decorated_type_name<
+ meta_type<const volatile ElementType>,
+ detail::type_name_decorator<ElementType[Size]>
+>
+{
+ typedef typename meta_type<ElementType>::scope scope;
+ typedef const volatile ElementType reflected_type[Size];
+};
+
+template <class ElementType>
+struct meta_type<ElementType[]> : detail::decorated_type_name<
+ meta_type<ElementType>,
+ detail::type_name_decorator<ElementType[]>
+>
+{
+ typedef typename meta_type<ElementType>::scope scope;
+ typedef ElementType reflected_type[];
+};
+
+template <class ElementType>
+struct meta_type<const ElementType []> : detail::decorated_type_name<
+ meta_type<const ElementType>,
+ detail::type_name_decorator<ElementType []>
+>
+{
+ typedef typename meta_type<ElementType>::scope scope;
+ typedef ElementType const reflected_type [];
+};
+
+template <class ElementType>
+struct meta_type<volatile ElementType []> : detail::decorated_type_name<
+ meta_type<volatile ElementType>,
+ detail::type_name_decorator<ElementType []>
+>
+{
+ typedef typename meta_type<ElementType>::scope scope;
+ typedef ElementType volatile reflected_type [];
+};
+
+template <class ElementType>
+struct meta_type<const volatile ElementType []>
+: detail::decorated_type_name<
+ meta_type<const volatile ElementType>,
+ detail::type_name_decorator<ElementType []>
+>
+{
+ typedef typename meta_type<ElementType>::scope scope;
+ typedef ElementType const volatile reflected_type [];
+};
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/meta_types/_const_volatile.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_types/_const_volatile.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -0,0 +1,61 @@
+/**
+ * \file boost/mirror/meta_types/_const_volatile.hpp
+ *
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_TYPES_CONST_VOLATILE_HPP
+#define BOOST_MIRROR_META_TYPES_CONST_VOLATILE_HPP
+
+// registering of meta-types
+#include <boost/mirror/detail/meta_type_registering.hpp>
+// type name decorations
+#include <boost/mirror/detail/decorated_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+
+/** Meta-types for const types
+ */
+template <class NonConstType>
+struct meta_type<const NonConstType> : detail::decorated_type_name<
+ meta_type<NonConstType>,
+ detail::type_name_decorator<const NonConstType>
+>
+{
+ typedef typename meta_type<NonConstType>::scope scope;
+ typedef const NonConstType reflected_type;
+};
+
+/** Meta-types for volatile types
+ */
+template <class NonVolatileType>
+struct meta_type<volatile NonVolatileType> : detail::decorated_type_name<
+ meta_type<NonVolatileType>,
+ detail::type_name_decorator<volatile NonVolatileType>
+>
+{
+ typedef typename meta_type<NonVolatileType>::scope scope;
+ typedef volatile NonVolatileType reflected_type;
+};
+
+/** Meta-types for const volatile types
+ */
+template <class NonCVType>
+struct meta_type<const volatile NonCVType> : detail::decorated_type_name<
+ meta_type<NonCVType>,
+ detail::type_name_decorator<const volatile NonCVType>
+>
+{
+ typedef typename meta_type<NonCVType>::scope scope;
+ typedef const volatile NonCVType reflected_type;
+};
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/meta_types/_free_fn.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_types/_free_fn.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -0,0 +1,77 @@
+/**
+ * \file boost/mirror/meta_types/_free_fn.hpp
+ *
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_TYPES_FREE_FN_HPP
+#define BOOST_MIRROR_META_TYPES_FREE_FN_HPP
+
+// preprocessor helpers
+#include <boost/preprocessor/repeat.hpp>
+#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+
+// registering of meta-types
+#include <boost/mirror/detail/meta_type_registering.hpp>
+// type name decorations
+#include <boost/mirror/detail/function_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+
+namespace calling_convention {
+
+#define BOOST_MIRROR_DECLARE_CALLING_CONVENTION_HELPER(CC) \
+ struct __##CC##_ \
+ { \
+ inline static const bstring& name(void) \
+ { \
+ static bstring cc_name(BOOST_CTS_STRINGIZE(__##CC)); \
+ return cc_name; \
+ } \
+ };
+
+ BOOST_MIRROR_DECLARE_CALLING_CONVENTION_HELPER(cdecl)
+ BOOST_MIRROR_DECLARE_CALLING_CONVENTION_HELPER(stdcall)
+ BOOST_MIRROR_DECLARE_CALLING_CONVENTION_HELPER(pascal)
+
+ struct __default_
+ {
+ inline static bstring name(void){return bstring();}
+ };
+
+// undefine the helper macros
+#undef BOOST_MIRROR_DECLARE_CALLING_CONVENTION_HELPER
+}
+
+/** Meta-type for free function types
+ */
+#define BOOST_MIRROR_DECLARE_FREE_FUNCTION_META_TYPE( \
+ X, \
+ ARG_COUNT, \
+ CALLING_CONVENTION \
+) \
+template <typename RetVal BOOST_PP_ENUM_TRAILING_PARAMS(ARG_COUNT, class T) > \
+struct meta_type<RetVal(*)(BOOST_PP_ENUM_PARAMS(ARG_COUNT, T))>\
+: detail::function_type_name< \
+ RetVal, \
+ calling_convention::__ ## CALLING_CONVENTION ## _, \
+ mpl::vector<BOOST_PP_ENUM_PARAMS(ARG_COUNT, T)> \
+> \
+{ \
+ typedef typename meta_type<void>::scope scope; \
+ typedef RetVal(*reflected_type)(BOOST_PP_ENUM_PARAMS(ARG_COUNT, T)); \
+};
+
+BOOST_PP_REPEAT(16, BOOST_MIRROR_DECLARE_FREE_FUNCTION_META_TYPE, default)
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/meta_types/_native.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_types/_native.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -0,0 +1,44 @@
+/**
+ * \file boost/mirror/meta_types/_native.hpp
+ *
+ * Registering of native C++ types
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_TYPES_NATIVE_HPP
+#define BOOST_MIRROR_META_TYPES_NATIVE_HPP
+
+// meta namespaces
+#include <boost/mirror/meta_namespace.hpp>
+// registering of meta-types
+#include <boost/mirror/detail/meta_type_registering.hpp>
+
+namespace boost {
+namespace mirror {
+
+
+/** Register C++ native types
+ */
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(void)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(bool)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(char)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(unsigned char)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(signed char)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(wchar_t)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(short int)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(unsigned short int)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(int)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(unsigned int)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(long int)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(unsigned long int)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(float)
+BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(double)
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/meta_types/_ptr_ref.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_types/_ptr_ref.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -0,0 +1,49 @@
+/**
+ * \file boost/mirror/meta_types/_ptr_ref.hpp
+ *
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_TYPES_PTR_REF_HPP
+#define BOOST_MIRROR_META_TYPES_PTR_REF_HPP
+
+// registering of meta-types
+#include <boost/mirror/detail/meta_type_registering.hpp>
+// type name decorations
+#include <boost/mirror/detail/decorated_type_name.hpp>
+
+namespace boost {
+namespace mirror {
+
+/** Meta-types for pointers
+ */
+template <class PointeeType>
+struct meta_type<PointeeType*> : detail::decorated_type_name<
+ meta_type<PointeeType>,
+ detail::type_name_decorator<PointeeType*>
+>
+{
+ typedef typename meta_type<PointeeType>::scope scope;
+ typedef PointeeType* reflected_type;
+};
+
+/** Meta-types for references
+ */
+template <class ReferredToType>
+struct meta_type<ReferredToType&> : detail::decorated_type_name<
+ meta_type<ReferredToType>,
+ detail::type_name_decorator<ReferredToType&>
+>
+{
+ typedef typename meta_type<ReferredToType>::scope scope;
+ typedef ReferredToType& reflected_type;
+};
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/meta_types/boost_bstring.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_types/boost_bstring.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -0,0 +1,31 @@
+/**
+ * \file boost/mirror/meta_types/std_string.hpp
+ *
+ * Registering of native C++ string types
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_TYPES_BOOST_BSTRING_HPP
+#define BOOST_MIRROR_META_TYPES_BOOST_BSTRING_HPP
+
+// register string types
+#include <boost/mirror/meta_types/std_string.hpp>
+#include <boost/char_type_switch/string.hpp>
+
+namespace boost {
+namespace mirror {
+
+/** Register the bchar and bstring
+ */
+BOOST_MIRROR_REG_TYPEDEF(::boost, bchar)
+BOOST_MIRROR_REG_TYPEDEF(::boost, bstring)
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/meta_types/std_string.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_types/std_string.hpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -0,0 +1,29 @@
+/**
+ * \file boost/mirror/meta_types/std_string.hpp
+ *
+ * Registering of native C++ string types
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_TYPES_STD_STRING_HPP
+#define BOOST_MIRROR_META_TYPES_STD_STRING_HPP
+
+// register native types
+#include <boost/mirror/meta_types/_native.hpp>
+
+namespace boost {
+namespace mirror {
+
+/** Register std string and wstring
+ */
+BOOST_MIRROR_REG_TYPE(::std, string)
+BOOST_MIRROR_REG_TYPE(::std, wstring)
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Modified: sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml
==============================================================================
--- sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml (original)
+++ sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -229,7 +229,7 @@
- Tested with gcc 4.3.0 on SuSE
- Tested with intel 10.1 on SuSE
</revision>
- <revision id="20080704" major="0" minor="2" micro="0" author="m_ch">
+ <revision id="20080705" major="0" minor="2" micro="0" author="m_ch">
- New branch
- Several features implemented by the means of the preprocessor were rewritten using templates
- Fully qualified name composing has been rewritten using standard C++ strings
@@ -255,6 +255,9 @@
- Added BOOST_MIRROR_REG_TYPEEF_GS and for BOOST_MIRROR_REG_TYPEDEF_GLOBAL_SCOPE for registering global scope typedefs
- Added BOOST_MIRROR_REG_TYPE_EMBEDDED and for BOOST_MIRROR_REG_TYPE_EMB for registering embedded types
+ - Split meta-types for non-trivial types into separate files
+ - Added support for function typenames
+
- Tested with MSVC++ 2008 EE On Vista
</revision>
</revisions>
Modified: sandbox/mirror/libs/mirror/example/registering/classes.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/example/registering/classes.cpp (original)
+++ sandbox/mirror/libs/mirror/example/registering/classes.cpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -118,20 +118,20 @@
/** Register the namespaces
*/
-BOOST_MIRROR_REG_NAMESPACE_TOP_LEVEL(test)
-BOOST_MIRROR_REG_NAMESPACE(_test, feature)
-BOOST_MIRROR_REG_NAMESPACE(_test_feature, detail)
-BOOST_MIRROR_REG_NAMESPACE(_test, stuff)
-BOOST_MIRROR_REG_NAMESPACE(_test_stuff, detail)
+BOOST_MIRROR_REG_NAMESPACE((test))
+BOOST_MIRROR_REG_NAMESPACE((test)(feature))
+BOOST_MIRROR_REG_NAMESPACE((test)(feature)(detail))
+BOOST_MIRROR_REG_NAMESPACE((test)(stuff))
+BOOST_MIRROR_REG_NAMESPACE((test)(stuff)(detail))
//
/** Register the types
*/
-BOOST_MIRROR_REG_TYPE(_test_feature_detail, ::test::feature::detail, foo_base)
-BOOST_MIRROR_REG_TYPE(_test_feature_detail, ::test::feature::detail, foo_base2)
-BOOST_MIRROR_REG_TYPE(_test_feature_detail, ::test::feature::detail, foo_base3)
-BOOST_MIRROR_REG_TYPE(_test_feature_detail, ::test::feature::detail, foo)
-BOOST_MIRROR_REG_TYPE(_test_stuff_detail, ::test::stuff::detail, bar_base)
-BOOST_MIRROR_REG_TYPE(_test_stuff_detail, ::test::stuff::detail, bar)
+BOOST_MIRROR_REG_TYPE(::test::feature::detail, foo_base)
+BOOST_MIRROR_REG_TYPE(::test::feature::detail, foo_base2)
+BOOST_MIRROR_REG_TYPE(::test::feature::detail, foo_base3)
+BOOST_MIRROR_REG_TYPE(::test::feature::detail, foo)
+BOOST_MIRROR_REG_TYPE(::test::stuff::detail, bar_base)
+BOOST_MIRROR_REG_TYPE(::test::stuff::detail, bar)
// register the embedded type that is declared inside of the bar class
BOOST_MIRROR_REG_TYPE_EMBEDDED(::test::stuff::detail::bar, bar_part)
@@ -175,7 +175,8 @@
// this is an attrib that has no getter but has a setter function
// Also note that macros with the _TD suffix allow to register
// attributes with typedef'd types
- BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER_TD(4, _boost, ::boost, bstring, a_string, set_string)
+ //BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER_TD(4, _boost, ::boost, bstring, a_string, set_string)
+ BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER_ONLY(4, ::boost::bstring, a_string, set_string)
//
// and the last one is accessed by the means of a pair of getter/setter functions
BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_SETTER(5, bool, a_bool, get_bool, set_bool)
@@ -304,7 +305,7 @@
{
using namespace ::std;
s << endl << " - " <<
- name_to_stream< BOOST_MIRROR_REFLECT_TYPE(typename MetaAttribute::type) >() <<
+ name_to_stream< BOOST_MIRRORED_TYPE(typename MetaAttribute::type) >() <<
" " <<
ma.base_name();
}
@@ -363,35 +364,35 @@
// use the pretty printer to print out into about the given types
//
// pointer to native type
- bcout << "|01| " << endl << pretty_printer<BOOST_MIRROR_REFLECT_TYPE(double*)>() << endl;
+ bcout << "|01| " << endl << pretty_printer<BOOST_MIRRORED_TYPE(double*)>() << endl;
// a class defined in a namespace
- bcout << "|02| " << endl << pretty_printer<BOOST_MIRROR_REFLECT_CLASS(foo)>() << endl;
- bcout << "|03| " << endl << pretty_printer<BOOST_MIRROR_REFLECT_CLASS(bar)>() << endl;
+ bcout << "|02| " << endl << pretty_printer<BOOST_MIRRORED_CLASS(foo)>() << endl;
+ bcout << "|03| " << endl << pretty_printer<BOOST_MIRRORED_CLASS(bar)>() << endl;
// an embedded class
- bcout << "|04| " << endl << pretty_printer<BOOST_MIRROR_REFLECT_CLASS(bar::bar_part)>() << endl;
+ bcout << "|04| " << endl << pretty_printer<BOOST_MIRRORED_CLASS(bar::bar_part)>() << endl;
// typedef'd type
- bcout << "|05| " << endl << pretty_printer<BOOST_MIRROR_REFLECT_TYPEDEFD(_boost, bchar)>() << endl;
+ bcout << "|05| " << endl << pretty_printer<BOOST_MIRRORED_TYPEDEF(::boost, bchar)>() << endl;
// type of an expression
- bcout << "|06| " << endl << pretty_printer<BOOST_MIRROR_REFLECT_TYPEOF("foo")>() << endl;
+ bcout << "|06| " << endl << pretty_printer<BOOST_MIRRORED_TYPEOF("foo")>() << endl;
//
// full typenames
- //bcout << "|07| " << BOOST_MIRROR_REFLECT_TYPEOF("foo") ::full_name() << endl;
+ //bcout << "|07| " << BOOST_MIRRORED_TYPEOF("foo") ::full_name() << endl;
//
bar_base x = {123, 456L};
bar_base y = {234, 567L};
//
// the meta-attributes can be used to examine
// values of the members too
- assert(BOOST_MIRROR_REFLECT_CLASS(BOOST_TYPEOF(x))::attributes::get(x, mpl::int_<0>()) == x.an_int);
- assert(BOOST_MIRROR_REFLECT_CLASS(BOOST_TYPEOF(x))::attributes::get(x, mpl::int_<1>()) == x.a_long);
+ assert(BOOST_MIRRORED_CLASS(BOOST_TYPEOF(x))::attributes::get(x, mpl::int_<0>()) == x.an_int);
+ assert(BOOST_MIRRORED_CLASS(BOOST_TYPEOF(x))::attributes::get(x, mpl::int_<1>()) == x.a_long);
// and also to set them
- BOOST_MIRROR_REFLECT_CLASS(BOOST_TYPEOF(x))::attributes::set(
+ BOOST_MIRRORED_CLASS(BOOST_TYPEOF(x))::attributes::set(
x, mpl::int_<0>(),
- BOOST_MIRROR_REFLECT_CLASS(BOOST_TYPEOF(y))::attributes::get(y, mpl::int_<0>())
+ BOOST_MIRRORED_CLASS(BOOST_TYPEOF(y))::attributes::get(y, mpl::int_<0>())
);
- BOOST_MIRROR_REFLECT_CLASS(BOOST_TYPEOF(x))::attributes::set(
+ BOOST_MIRRORED_CLASS(BOOST_TYPEOF(x))::attributes::set(
x, mpl::int_<1>(),
- BOOST_MIRROR_REFLECT_CLASS(BOOST_TYPEOF(y))::attributes::get(y, mpl::int_<1>())
+ BOOST_MIRRORED_CLASS(BOOST_TYPEOF(y))::attributes::get(y, mpl::int_<1>())
);
//
assert(x.an_int == y.an_int);
Modified: sandbox/mirror/libs/mirror/example/registering/types.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/example/registering/types.cpp (original)
+++ sandbox/mirror/libs/mirror/example/registering/types.cpp 2008-07-05 09:55:53 EDT (Sat, 05 Jul 2008)
@@ -68,6 +68,11 @@
} // namespace mirror
} // namespace boost
+namespace test {
+
+ int zero(void){return 0;}
+
+}
int main(void)
{
@@ -180,9 +185,13 @@
bcout << "|44| " << BOOST_MIRRORED_TYPE(const volatile ::baz*) ::full_name() << endl;
bcout << "|44| " << BOOST_MIRRORED_TYPEDEF(::, foobar) ::full_name() << endl;
//
- typedef ::bar * const * t45 [][1][2][3][4][5][6][7][8][9];
- bcout << typeid(t45).name() << endl;
- bcout << "|45| " << BOOST_MIRRORED_TYPE(t45) ::full_name() << endl;
+ typedef ::bar * const * T45 [][1][2][3][4][5][6][7][8][9];
+ bcout << "|45| " << BOOST_MIRRORED_TYPE(T45) ::full_name() << endl;
+ //
+ bcout << "|46| " << BOOST_MIRRORED_TYPEOF(&test::zero) ::full_name() << endl;
+ //
+ typedef const foo * volatile (*T47)(const ::bar&, volatile ::baz*, T45);
+ bcout << "|47| " << BOOST_MIRRORED_TYPE(T47) ::full_name() << endl;
//
return 0;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk