$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: chochlik_at_[hidden]
Date: 2008-07-09 13:58:06
Author: matus.chochlik
Date: 2008-07-09 13:58:05 EDT (Wed, 09 Jul 2008)
New Revision: 47275
URL: http://svn.boost.org/trac/boost/changeset/47275
Log:
- Added several comments to the examples
- The query-meta-functions do not need to and should not return the 'dest' reference anymore, this was rewritten to work automatically
Text files modified: 
   sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp      |     8 +-                                      
   sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml        |     5 +                                       
   sandbox/mirror/libs/mirror/example/registering/classes.cpp    |    93 +++++++++++++++++++++++++++++++++++---- 
   sandbox/mirror/libs/mirror/example/registering/namespaces.cpp |     2                                         
   sandbox/mirror/libs/mirror/example/registering/types.cpp      |    10 +--                                     
   5 files changed, 96 insertions(+), 22 deletions(-)
Modified: sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp	(original)
+++ sandbox/mirror/boost/mirror/detail/meta_attribs_base.hpp	2008-07-09 13:58:05 EDT (Wed, 09 Jul 2008)
@@ -206,7 +206,7 @@
                 const Class& instance, \
                 position_of_##NAME, \
                 DestType& dest \
-	) QUERY_BODY 
+	) { QUERY_BODY return dest;}
 
  /** Helper macro expanding into the declaraion of setter
  *  function of the meta-attribute
@@ -347,7 +347,7 @@
 ) BOOST_MIRROR_REG_TEMPLATE_OR_CLASS_ATTRIB( \
                 SPECIFIERS, TYPE_SELECTOR, NAME, \
                 {return instance.NAME;}, \
-		{dest = DestType(instance.NAME); return dest;}, \
+		{dest = DestType(instance.NAME);}, \
                 {instance.NAME = value;}, \
                 TYPENAME_KW \
         )
@@ -398,7 +398,7 @@
 ) BOOST_MIRROR_REG_TEMPLATE_OR_CLASS_ATTRIB( \
                 SPECIFIERS, TYPE_SELECTOR, NAME, \
                 {return instance.GETTER_CALL;}, \
-		{dest = DestType(instance.GETTER_CALL); return dest;}, \
+		{dest = DestType(instance.GETTER_CALL);}, \
                 {instance.SETTER_CALL;}, \
                 TYPENAME_KW \
         )
@@ -480,7 +480,7 @@
                 TYPE_SELECTOR, \
                 NAME, \
                 {return instance.NAME;}, \
-		{dest = DestType(instance.NAME); return dest;}, \
+		{dest = DestType(instance.NAME);}, \
                 {instance.NAME = value;}, \
                 BOOST_PP_EMPTY() \
         )
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-09 13:58:05 EDT (Wed, 09 Jul 2008)
@@ -275,7 +275,10 @@
                         - Tested with intel 10.1 on SuSE (fails with some examples)
                 </revision>
                 <revision id="20080709" major="0" minor="2" micro="1" author="m_ch">
-			- The name_to_string utility has been removed meta_object's base_name and full_name member functions are to be used instead.
+			- Added support for types derived from a typedef-ined type
+			- The name_to_string utility has been removed meta_object's base_name and full_name member functions are to be used instead
+			- Added several comments to the examples
+			- The query-meta-functions do not need to and should not return the 'dest' reference anymore, this was rewritten to work automatically
                 </revision>
         </revisions>
 </library>
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-09 13:58:05 EDT (Wed, 09 Jul 2008)
@@ -34,7 +34,6 @@
 
 /** First declare some namespaces and classes
  */
-
 namespace test {
 namespace feature {
 namespace detail {
@@ -59,6 +58,8 @@
         // This line allows mirror to access non-public
         // class members
         BOOST_MIRROR_FRIENDLY_CLASS(bar_base)
+
+	// declare some members
         int an_int;
         long a_long;
 };
@@ -166,7 +167,24 @@
 /** Class attributes
  */
 // register the attributes of bar_base
-BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::stuff::detail::bar_base)	
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::stuff::detail::bar_base)
+	//
+	// this is a macro for registering simple attributes without any 
+	// without getter a or a setter function
+	//
+	// the first argument is the storage class specifier.
+	// it can have these three values: 
+	// _ - for non static nor mutable member attributes
+	// static - for static attribs
+	// mutable - for mutable attribs
+	//
+	// the second argument is the type of the attribute
+	//
+	// the third argument is the name of the argument
+	//
+	// this macro can be used if the attribute is public
+	// or the class has been declared to include the 
+	// BOOST_MIRROR_FRIENDLY_CLASS(...) macro
         BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, int, an_int)
         BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, long, a_long)
 BOOST_MIRROR_REG_CLASS_ATTRIBS_END
@@ -178,47 +196,99 @@
         BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(_, double, a_double)
         //
         // this 'virtual' attribute has only a getter (cannot be set)
+	//
+	// this is a more general registering macro that allows to specify 
+	// how to get, query and set the value of an attribute
+	// 
+	// the first three arguments are the same as with 
+	// BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(...) macro
+	//
+	// The fourth argument is the body of a meta-getter function.
+	// Basically it should be wrapped in curly braces
+	// and contain a return statement returning the value of the attribute.
+	// There are several types and variables accessible in the body of
+	// the function:
+	// - Class = the type of the class to which the attribute belongs
+	// - instance = a const reference to the instance of the class
+	//              to which the attribute belongs
+	//
+	// The fifth argument is the body of a meta-query function
+	// This function should assign the value of the argument to the
+	// passed reference 
+	// Again there are several types and variables that can be referenced
+	// in the body of the function:
+	// - Class = the type of the class to which the attribute belongs
+	// - DestType = the type of the reference to which the attribute's
+	//              value is going to be assigned
+	// - instance = a const reference to the instance of the class
+	//              to which the attribute belongs
+	// - dest = a reference to a variable where the value of the attribute
+	//          should be assigned. 
+	//
+	// The sixth argument is a meta-setter function
+	// This function should assign the passed value to the attribute
+	//
+	// There are several types and variables that can be referenced
+	// in the body of the function:
+	// - Class = the type of the class to which the attribute belongs
+	// - instance = a const reference to the instance of the class
+	//              to which the attribute belongs
+	// - value = the value that should be assigned to the attribute
+	//           directly or by the means of a setter function
         BOOST_MIRROR_REG_CLASS_ATTRIB(
                 _, int, a_ro_val, 
                 {return instance.get_ro_val();},
-		{dest = DestType(instance.get_ro_val()); return dest;},
-		{ }
+		{dest = DestType(instance.get_ro_val());},
+		{ } // no setting
         )
         // this 'virtual' attribute has only a setter (cannot be queried)
         BOOST_MIRROR_REG_CLASS_ATTRIB(
                 _, int, a_wo_val, 
-		{return 0;},
-		{return dest;},
+		{return 0;}, // get a dummy value
+		{ },         // do not query the value
                 {instance.set_wo_val(value);}
         )
         //
         // this is an attrib that has no getter but has a setter function
         // NOTE that the type of this attribute is typedef'd 
+	//
+	// When registering attributes that have typedef-ined types 
+	// the BOOST_MIRROR_TYPEDEF(namespace, typedef'd type) 
+	// to notify mirror that the type was typedefined
+	// The typedef must be registered with mirror prior doing this
         BOOST_MIRROR_REG_CLASS_ATTRIB(
                 _, BOOST_MIRROR_TYPEDEF(::boost, bstring), a_string, 
                 {return instance.a_string;},
-		{dest = DestType(instance.a_string); return dest;},
+		{dest = DestType(instance.a_string);},
                 {instance.set_string(value);}
         )
         // another typedefd attribute
+	//
+	// The types of attributes can also be types derived from a typedef'd
+	// type. Such types are again referred to by the BOOST_MIRROR_TYPEDEF
+	// macro
         BOOST_MIRROR_REG_CLASS_ATTRIB(
                 static, const BOOST_MIRROR_TYPEDEF(::boost, bchar) * (*)(int), a_function, 
                 {return instance.a_function;},
-		{dest = DestType(instance.a_function); return dest;},
+		{dest = DestType(instance.a_function);},
                 { } // no setter
         )
         //
-	// and the last one is accessed by the means of a pair of getter/setter functions
+	// this attribute is accessed by the means of a pair of getter/setter functions
+	//
+	// note that is the getter function is not const a const_cast is necessary
         BOOST_MIRROR_REG_CLASS_ATTRIB(
                 _, bool, a_bool, 
                 {return const_cast<Class&>(instance).get_bool();},
-		{dest = DestType(const_cast<Class&>(instance).get_bool()); return dest;},
+		{dest = DestType(const_cast<Class&>(instance).get_bool());},
                 {instance.set_bool(value);}
         )
         //
         // register a static member attribute
+	// instead of the '_', the keyword 'static' is used 
         BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(static, short, a_short)
         // register a mutable member attribute
+	// instead of the '_', the keyword 'mutable' is used 
         BOOST_MIRROR_REG_SIMPLE_CLASS_ATTRIB(mutable, wchar_t, a_widechar)
 BOOST_MIRROR_REG_CLASS_ATTRIBS_END
 
@@ -405,7 +475,10 @@
         //
         // pointer to native type
         bcout << "|01| " << endl << pretty_printer<BOOST_MIRRORED_TYPE(double*)>() << endl;
+	//
         // a class defined in a namespace
+	// classes are reflected using the BOOST_MIRRORED_CLASS(Class) macro
+	// this macro expands into a meta_class specialization
         bcout << "|02| " << endl << pretty_printer<BOOST_MIRRORED_CLASS(foo)>() << endl;
         bcout << "|03| " << endl << pretty_printer<BOOST_MIRRORED_CLASS(bar)>() << endl;
         // an embedded class 
Modified: sandbox/mirror/libs/mirror/example/registering/namespaces.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/example/registering/namespaces.cpp	(original)
+++ sandbox/mirror/libs/mirror/example/registering/namespaces.cpp	2008-07-09 13:58:05 EDT (Wed, 09 Jul 2008)
@@ -62,7 +62,7 @@
         // meta_namespace<> specialization for the given namespace 
         //
         // define an alternative name for the global scope meta-namespace
-	// BOOST_MIRRORED_NAMESPACE(::) is equivalent to this
+	// BOOST_MIRRORED_NAMESPACE_GS is equivalent to this
         typedef BOOST_MIRRORED_GLOBAL_SCOPE() meta_ns_global_scope;
 
         // define an alternative name for the ::test namespace meta-data
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-09 13:58:05 EDT (Wed, 09 Jul 2008)
@@ -93,13 +93,12 @@
         typedef BOOST_MIRRORED_TYPE(foo) meta_foo;
         typedef BOOST_MIRRORED_TYPE(bar) meta_bar;
         //
-	// put the full name of the type to the output stream
-	//
+	// write the full name of the type to the output stream
         bcout << "|00| " << BOOST_MIRRORED_TYPE(int) ::full_name() << endl;
         bcout << "|01| " << BOOST_MIRRORED_TYPE(foo) ::full_name() << endl;
         bcout << "|02| " << BOOST_MIRRORED_TYPE(bar) ::full_name() << endl;
         //
-	// Do the same thing with the typedef'd type
+	// Do the same thing with the typedef'd meta-type
         bcout << "|03| " << meta_foo ::full_name() << endl;
         bcout << "|04| " << meta_bar ::full_name() << endl;
 
@@ -111,7 +110,6 @@
         bcout << "|08| " << BOOST_MIRRORED_TYPE(bar**&) ::full_name() << endl;
         bcout << "|09| " << BOOST_MIRRORED_TYPE(const foo**)::full_name() << endl;
         bcout << "|10| " << BOOST_MIRRORED_TYPE(volatile bar*&)::full_name() << endl;
-	//
         bcout << "|11| " << BOOST_MIRRORED_TYPE(const volatile foo)::full_name() << endl;
         bcout << "|12| " << BOOST_MIRRORED_TYPE(const volatile bar*)::full_name() << endl;
         //
@@ -137,8 +135,8 @@
         typedef BOOST_MIRRORED_TYPEDEF(::boost, bchar) meta_bchar_td;
         // this reflects the meta-type for the typedef type foobar
         typedef BOOST_MIRRORED_TYPEDEF(::test::feature::detail, foobar) meta_foobar_td;
-
-	//
+	// 
+	// use the typedefined meta-types
         bcout << "|19| " << meta_bchar     ::full_name() << endl;
         bcout << "|20| " << meta_bchar_td  ::full_name() << endl;
         bcout << "|21| " << meta_foobar_td ::full_name() << endl;