Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-04-29 03:44:45


Author: matus.chochlik
Date: 2008-04-29 03:44:44 EDT (Tue, 29 Apr 2008)
New Revision: 44875
URL: http://svn.boost.org/trac/boost/changeset/44875

Log:
Fixed several files to be able to compile mirror under g++.
Updated example special/boost_tuple.cpp to show for_each functionality on meta_class::all_attributes.
Text files modified:
   sandbox/mirror/boost/char_type_switch/string.hpp | 5 ++++-
   sandbox/mirror/boost/mirror/detail/nontrivial_type_name.hpp | 14 +++++++-------
   sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp | 4 ++--
   sandbox/mirror/boost/mirror/meta_class.hpp | 1 -
   sandbox/mirror/boost/mirror/meta_type.hpp | 9 +++++++++
   sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp | 2 +-
   sandbox/mirror/libs/mirror/example/special/boost_tuple.cpp | 36 ++++++++++++++++++++++++++++++++----
   7 files changed, 55 insertions(+), 16 deletions(-)

Modified: sandbox/mirror/boost/char_type_switch/string.hpp
==============================================================================
--- sandbox/mirror/boost/char_type_switch/string.hpp (original)
+++ sandbox/mirror/boost/char_type_switch/string.hpp 2008-04-29 03:44:44 EDT (Tue, 29 Apr 2008)
@@ -51,8 +51,10 @@
 // disable the deprecated function warning on msvc
 // this warning is issued when not using the "safe"
 // versions of string functions like strcpy_s (vs. strcpy)
+#ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable : 4996)
+#endif
 
 
 /** string compare
@@ -101,8 +103,9 @@
 }
 
 // enable the deprecated function warnings on msvc
+#ifdef _MSC_VER
 #pragma warning(pop)
-
+#endif
 
 
 } // namespace boost

Modified: sandbox/mirror/boost/mirror/detail/nontrivial_type_name.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/nontrivial_type_name.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/nontrivial_type_name.hpp 2008-04-29 03:44:44 EDT (Tue, 29 Apr 2008)
@@ -58,10 +58,10 @@
 , implementation<meta_type, meta_data, false>
 {
 private:
- typedef typename implementation<meta_type, meta_data, true> implementation_base_name;
- typedef typename implementation<meta_type, meta_data, false> implementation_full_name;
+ typedef implementation<meta_type, meta_data, true> implementation_base_name;
+ typedef implementation<meta_type, meta_data, false> implementation_full_name;
 
-#ifndef BOOST_MIRROR_USE_STATIC_NAME_STRINGS
+#ifdef BOOST_MIRROR_USE_DYNAMIC_NAME_STRINGS
         inline static bchar* new_string(const size_t size)
         {
                 assert(size != 0);
@@ -76,12 +76,12 @@
                 return !str[0];
         }
 
- template <bool base_name>
- static const bchar* get_name(mpl::bool_<base_name>)
+ template <bool format_base_name>
+ static const bchar* get_name(mpl::bool_<format_base_name>)
         {
- typedef typename implementation<meta_type, meta_data, base_name>
+ typedef implementation<meta_type, meta_data, format_base_name>
                         impl;
-#ifdef BOOST_MIRROR_USE_STATIC_NAME_STRINGS
+#ifndef BOOST_MIRROR_USE_DYNAMIC_NAME_STRINGS
                 static bchar the_name[impl::name_length+1] = {BOOST_STR_LIT("")};
 #else
                 static ::std::auto_ptr<bchar> the_name_holder(new_string(impl::name_length+1));

Modified: sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp 2008-04-29 03:44:44 EDT (Tue, 29 Apr 2008)
@@ -57,7 +57,7 @@
         //
         static bchar* convert(bchar* _str, size_t _max_len)
         {
- assert(_max_len > length::value);
+ assert(_max_len > size_t(length::value));
                 do_copy_to(_str, length());
                 _str[length::value] = BOOST_STR_LIT('\0');
                 return _str;
@@ -104,7 +104,7 @@
         static bchar* convert(bchar* _str, size_t _max_len)
         {
                 // check the length
- assert(_max_len > length::value);
+ assert(_max_len > size_t(length::value));
                 // apply prefix
                 do_apply_prefix_to(_str, prefix_length());
                 // calculate offset

Modified: sandbox/mirror/boost/mirror/meta_class.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_class.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_class.hpp 2008-04-29 03:44:44 EDT (Tue, 29 Apr 2008)
@@ -335,7 +335,6 @@
                         template <int I>
                         struct own_attrib_meta_class_and_pos
                         {
- typedef typename meta_class meta_class;
                                 typedef typename mpl::int_<mpl::minus<
                                         mpl::int_<I>,
                                         typename mpl::size<inherited_member_attrib_type_list>::type

Modified: sandbox/mirror/boost/mirror/meta_type.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_type.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_type.hpp 2008-04-29 03:44:44 EDT (Tue, 29 Apr 2008)
@@ -199,6 +199,15 @@
 /** Meta-types for arrays
  */
 template <class element_type, size_t size>
+struct meta_type<const element_type[size]> : detail::static_array_type_name<
+ meta_type<const element_type>, size
+>
+{
+ typedef typename meta_type<element_type>::scope scope;
+ typedef element_type base_type[size];
+};
+
+template <class element_type, size_t size>
 struct meta_type<element_type[size]> : detail::static_array_type_name<
         meta_type<element_type>, size
>

Modified: sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_types/boost_tuple.hpp 2008-04-29 03:44:44 EDT (Tue, 29 Apr 2008)
@@ -52,7 +52,7 @@
 
 // designate tuples::null_type as typelist null type
 template <>
-struct is_typelist_null_type<::boost::tuples::null_type> : ::boost::true_type { };
+struct is_typelist_null_type< ::boost::tuples::null_type> : ::boost::true_type { };
 
 
 } // namespace detail

Modified: sandbox/mirror/libs/mirror/example/special/boost_tuple.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/example/special/boost_tuple.cpp (original)
+++ sandbox/mirror/libs/mirror/example/special/boost_tuple.cpp 2008-04-29 03:44:44 EDT (Tue, 29 Apr 2008)
@@ -27,6 +27,30 @@
 
 #include <boost/mirror/meta_classes/boost_tuple.hpp>
 
+template <class a_class>
+class attrib_value_printer
+{
+public:
+ attrib_value_printer(a_class& _inst)
+ : inst(_inst){ }
+
+ template <class meta_class, class meta_attributes, class iterator, class attrib_type>
+ void operator()(meta_class mc, meta_attributes ma, iterator pos, attrib_type*) const
+ {
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ bcout <<
+ " " <<
+ ma.base_name(pos) <<
+ " = " <<
+ ma.get(inst, pos) <<
+ endl;
+ }
+private:
+ a_class& inst;
+};
+
 
 int main(void)
 {
@@ -82,12 +106,16 @@
         assert(meta_T1::all_attributes::get(t1, mpl::int_<0>()) == tuples::get<0>(t1));
         assert(meta_T1::all_attributes::get(t1, mpl::int_<1>()) == tuples::get<1>(t1));
         //
- tuple<int, int, int, int, int, int, int, int, int, int> x(0,1,2,3,4,5,6,7,8,9);
         //
- typedef BOOST_MIRROR_REFLECT_TYPEOF(x) meta_X;
+ tuple<int, int, int, int, int, int, int, int, int, int> x(0,1,2,3,4,5,6,7,8,9);
+ typedef BOOST_MIRROR_REFLECT_CLASS(BOOST_TYPEOF(x)) meta_X;
+ attrib_value_printer<meta_X::base_type> p(x);
         //
- //bcout << meta_X::all_attributes::base_name(mpl::int_<0>()) << " = ";
- //bcout << meta_X::all_attributes::get(x, mpl::int_<0>()) << endl;
+ bcout << "The type name is: "<< meta_X::base_name() << endl;
+ bcout << "---------------------------------------------------" << endl;
+ meta_X::all_attributes::for_each(p);
+ bcout << "---------------------------------------------------" << endl;
+ bcout << "Finished" << 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