Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-07-07 05:53:46


Author: matus.chochlik
Date: 2008-07-07 05:53:45 EDT (Mon, 07 Jul 2008)
New Revision: 47176
URL: http://svn.boost.org/trac/boost/changeset/47176

Log:
- Added support for function types
- Added support for pointers to function pointers
- Added support for functions returning pointers to functions
- Added support for references to functions

Text files modified:
   sandbox/mirror/boost/mirror/detail/decorated_type_name.hpp | 35 ++++++++++++++-------
   sandbox/mirror/boost/mirror/detail/full_name_builder.hpp | 3 +
   sandbox/mirror/boost/mirror/detail/function_type_name.hpp | 62 ++++++++++++++++++++++++++++++++-------
   sandbox/mirror/boost/mirror/meta_types/_free_fn.hpp | 4 +-
   sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml | 7 +++
   sandbox/mirror/libs/mirror/example/registering/types.cpp | 25 ++++++++++++++-
   6 files changed, 106 insertions(+), 30 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-07 05:53:45 EDT (Mon, 07 Jul 2008)
@@ -28,11 +28,13 @@
         {
                 bstring left;
                 bstring right;
- bstring ex(BOOST_STR_LIT(" "));
- bstring temp(build_name(full_or_base, left, right, ex));
+ bstring ex;
+ bstring arg;
+ bstring temp(build_name(full_or_base, left, right, ex, arg));
                 left.append(temp);
                 left.append(right);
                 left.append(ex);
+ left.append(arg);
                 return left;
         }
 
@@ -42,15 +44,17 @@
                 mpl::bool_<FullName> full_or_base,
                 bstring& left,
                 bstring& right,
- bstring& ex
+ bstring& ex,
+ bstring& arg
         )
         {
- Decorator D(left, right, ex);
+ Decorator D(left, right, ex, arg);
                 return MetaType::build_name(
                         full_or_base,
                         left,
                         right,
- ex
+ ex,
+ arg
                 );
         }
 
@@ -79,6 +83,8 @@
         }
 };
 
+/**
+ */
 template <class MetaType, class Decorator>
 struct decorated_type_name
 : decorated_type_name_finisher<
@@ -92,6 +98,9 @@
         inline type_name_decorator(bstring&, bstring&);
 };
 
+/** Base class for decorators that append something to 'right'
+ * path of the type name
+ */
 struct type_name_right_postfix_decorator
 {
         inline type_name_right_postfix_decorator(bstring& _r, const bchar* _pfx)
@@ -110,7 +119,7 @@
 struct type_name_decorator<T*>
 : type_name_right_postfix_decorator
 {
- inline type_name_decorator(bstring&, bstring& _right, bstring&)
+ inline type_name_decorator(bstring&, bstring& _right, bstring&, bstring&)
         : type_name_right_postfix_decorator(_right, BOOST_STR_LIT(" *"))
         { }
 };
@@ -121,7 +130,7 @@
 struct type_name_decorator<T&>
 : type_name_right_postfix_decorator
 {
- inline type_name_decorator(bstring&, bstring& _right, bstring&)
+ inline type_name_decorator(bstring&, bstring& _right, bstring&, bstring&)
         : type_name_right_postfix_decorator(_right, BOOST_STR_LIT(" &"))
         { }
 };
@@ -131,7 +140,7 @@
 struct type_name_decorator<const T>
 : type_name_right_postfix_decorator
 {
- inline type_name_decorator(bstring&, bstring& _right, bstring&)
+ inline type_name_decorator(bstring&, bstring& _right, bstring&, bstring&)
         : type_name_right_postfix_decorator(_right, BOOST_STR_LIT(" const"))
         { }
 };
@@ -141,7 +150,7 @@
 struct type_name_decorator<volatile T>
 : type_name_right_postfix_decorator
 {
- inline type_name_decorator(bstring&, bstring& _right, bstring&)
+ inline type_name_decorator(bstring&, bstring& _right, bstring&, bstring&)
         : type_name_right_postfix_decorator(_right, BOOST_STR_LIT(" volatile"))
         { }
 };
@@ -151,7 +160,7 @@
 struct type_name_decorator<const volatile T>
 : type_name_right_postfix_decorator
 {
- inline type_name_decorator(bstring&, bstring& _r, bstring&)
+ inline type_name_decorator(bstring&, bstring& _r, bstring&, bstring&)
         : type_name_right_postfix_decorator(_r, BOOST_STR_LIT(" const volatile"))
         { }
 };
@@ -160,8 +169,9 @@
 template <typename T>
 struct type_name_decorator< T[] >
 {
- inline type_name_decorator(bstring&, bstring&, bstring& _ex)
+ inline type_name_decorator(bstring&, bstring&, bstring& _ex, bstring&)
         {
+ if(_ex.empty()) _ex.append(BOOST_STR_LIT(" "));
                 _ex.append(BOOST_STR_LIT("[]"));
         }
 };
@@ -191,9 +201,10 @@
                 return res;
         }
 public:
- inline type_name_decorator(bstring&, bstring&, bstring& _ex)
+ inline type_name_decorator(bstring&, bstring&, bstring& _ex, bstring&)
         {
                 static bstring s_postfix(init_postfix());
+ if(_ex.empty()) _ex.append(BOOST_STR_LIT(" "));
                 _ex.append(s_postfix);
         }
 };

Modified: sandbox/mirror/boost/mirror/detail/full_name_builder.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/full_name_builder.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/full_name_builder.hpp 2008-07-07 05:53:45 EDT (Mon, 07 Jul 2008)
@@ -88,7 +88,8 @@
                         mpl::bool_<FullName> full_or_base,
                         bstring& left,
                         bstring& right,
- bstring& ex
+ bstring& ex,
+ bstring& arg
                 )
                 {
                         return get_name(full_or_base);

Modified: sandbox/mirror/boost/mirror/detail/function_type_name.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/function_type_name.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/function_type_name.hpp 2008-07-07 05:53:45 EDT (Mon, 07 Jul 2008)
@@ -96,27 +96,65 @@
         template <bool FullName>
         inline static bstring init_name(mpl::bool_<FullName> full_or_base)
         {
+ bstring left;
+ bstring right;
+ bstring ex;
+ bstring arg;
+ bstring temp(build_name(full_or_base, left, right, ex, arg));
+ left.append(temp);
+ left.append(right);
+ left.append(ex);
+ left.append(arg);
+ return left;
+ }
+public:
+ template <bool FullName>
+ inline static bstring build_name(
+ mpl::bool_<FullName> full_or_base,
+ bstring& left,
+ bstring& right,
+ bstring& ex,
+ bstring& arg
+ )
+ {
                 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));
                 //
+ bstring rv_left;
+ bstring rv_right;
+ bstring rv_ex;
+ bstring rv_arg;
+ bstring rv_t(meta_RV::build_name(
+ full_or_base,
+ rv_left,
+ rv_right,
+ rv_ex,
+ rv_arg
+ ));
+ //
+ // return value
+ left.append(rv_left);
+ left.append(rv_t);
+ left.append(rv_right);
+ left.append(rv_ex);
+ // open pars.
+ left.append(space);
+ left.append(l_par);
                 // the calling convention
- res.append(space);
- res.append(l_par);
- res.append(CallingConvention::name());
- res.append(aster);
- res.append(r_par);
+ left.append(CallingConvention::name());
+ arg.append(r_par);
                 //
                 // argument list
- res.append(l_par);
- append_args(((ArgTypeList*)0), res, full_or_base);
- res.append(r_par);
- return res;
+ arg.append(l_par);
+ append_args(((ArgTypeList*)0), arg, full_or_base);
+ arg.append(r_par);
+ // the rest of the ret val type
+ arg.append(rv_arg);
+ return bstring();
         }
 };
 

Modified: sandbox/mirror/boost/mirror/meta_types/_free_fn.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_types/_free_fn.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_types/_free_fn.hpp 2008-07-07 05:53:45 EDT (Mon, 07 Jul 2008)
@@ -56,7 +56,7 @@
         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))>\
+struct meta_type<RetVal (BOOST_PP_ENUM_PARAMS(ARG_COUNT, T))>\
 : detail::function_type_name< \
         RetVal, \
         calling_convention::__ ## CALLING_CONVENTION ## _, \
@@ -64,7 +64,7 @@
> \
 { \
         typedef typename meta_type<void>::scope scope; \
- typedef RetVal(*reflected_type)(BOOST_PP_ENUM_PARAMS(ARG_COUNT, T)); \
+ typedef RetVal(reflected_type)(BOOST_PP_ENUM_PARAMS(ARG_COUNT, T)); \
 };
 
 BOOST_PP_REPEAT(16, BOOST_MIRROR_DECLARE_FREE_FUNCTION_META_TYPE, default)

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-07 05:53:45 EDT (Mon, 07 Jul 2008)
@@ -256,7 +256,12 @@
                         - 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
+ - Added support for pointer to function typenames
+
+ - Added support for function types
+ - Added support for pointers to function pointers
+ - Added support for functions returning pointers to functions
+ - Added support for references to functions
 
                         - Tested with MSVC++ 2008 EE On Vista
                 </revision>

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-07 05:53:45 EDT (Mon, 07 Jul 2008)
@@ -185,14 +185,35 @@
         bcout << "|44| " << BOOST_MIRRORED_TYPE(const volatile ::baz*) ::full_name() << endl;
         bcout << "|44| " << BOOST_MIRRORED_TYPEDEF(::, foobar) ::full_name() << endl;
         //
+ // multi-dimensional arrays
         typedef ::bar * const * T45 [][1][2][3][4][5][6][7][8][9];
         bcout << "|45| " << BOOST_MIRRORED_TYPE(T45) ::full_name() << endl;
- //
+ //
+ // function pointers
         bcout << "|46| " << BOOST_MIRRORED_TYPEOF(&test::zero) ::full_name() << endl;
- //
+ // more function pointers
         typedef const foo * volatile (*T47)(const ::bar&, volatile ::baz*, T45);
         bcout << "|47| " << BOOST_MIRRORED_TYPE(T47) ::full_name() << endl;
         //
+ // arrays of function pointers
+ typedef T47 const * T48[2][3];
+ bcout << "|48| " << BOOST_MIRRORED_TYPE(T48) ::full_name() << endl;
+ //
+ // pointer to functions returning pointers to functions
+ typedef int(*A49)(double);
+ typedef A49 const * (*B49)(char);
+ typedef B49 volatile * (*C49)(wchar_t);
+ typedef C49 T49;
+ bcout << "|49| " << BOOST_MIRRORED_TYPE(T49) ::full_name() << endl;
+ //
+ // function returning pointer to functions
+ typedef C49 const * volatile * (T50)(short);
+ bcout << "|50| " << BOOST_MIRRORED_TYPE(T50) ::full_name() << endl;
+ //
+ // reference to function returning pointer to functions
+ typedef T50& T51;
+ bcout << "|51| " << BOOST_MIRRORED_TYPE(T51) ::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