|
Boost-Commit : |
From: chochlik_at_[hidden]
Date: 2008-05-02 05:16:53
Author: matus.chochlik
Date: 2008-05-02 05:16:52 EDT (Fri, 02 May 2008)
New Revision: 45013
URL: http://svn.boost.org/trac/boost/changeset/45013
Log:
- Fixed certain things in order to make compilation with gcc possible.
- Note this version may report memory leaks on program exit.
- Tested and successfully compiled with gcc 4.2.1 and gcc 4.3.0
on OpenSuSE
Text files modified:
sandbox/mirror/boost/mirror/detail/nontrivial_type_name.hpp | 12 ++++++++----
sandbox/mirror/boost/mirror/meta_attributes.hpp | 8 +++++---
sandbox/mirror/boost/mirror/meta_class.hpp | 2 +-
sandbox/mirror/boost/mirror/traversal.hpp | 20 +++++++++++++-------
sandbox/mirror/boost/mirror/visitors/sample.hpp | 2 +-
sandbox/mirror/libs/mirror/example/registering/classes.cpp | 4 ++--
sandbox/mirror/libs/mirror/example/special/boost_tuple.cpp | 6 +-----
7 files changed, 31 insertions(+), 23 deletions(-)
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-05-02 05:16:52 EDT (Fri, 02 May 2008)
@@ -61,7 +61,6 @@
typedef implementation<meta_type, meta_data, true> implementation_base_name;
typedef implementation<meta_type, meta_data, false> implementation_full_name;
-#ifdef BOOST_MIRROR_USE_DYNAMIC_NAME_STRINGS
inline static bchar* new_string(const size_t size)
{
assert(size != 0);
@@ -69,7 +68,6 @@
result[0] = 0;
return result;
}
-#endif
inline static bool name_not_initialized(const bchar* str)
{
@@ -81,10 +79,16 @@
{
typedef implementation<meta_type, meta_data, format_base_name>
impl;
+ const int name_len(impl::name_length);
#ifndef BOOST_MIRROR_USE_DYNAMIC_NAME_STRINGS
- static bchar the_name[impl::name_length+1] = {BOOST_STR_LIT("")};
+ //static bchar the_name[name_len + 1] = {BOOST_STR_LIT("")};
+ // TODO: the previews line won't compile since
+ // name_len is not an integral constant.
+ // Thus we need to find some better workaround
+ // because this one will cause memory leaks.
+ static bchar* the_name = new_string(name_len+1);
#else
- static ::std::auto_ptr<bchar> the_name_holder(new_string(impl::name_length+1));
+ static ::std::auto_ptr<bchar> the_name_holder(new_string(name_len+1));
bchar* the_name = the_name_holder.get();
#endif
if(name_not_initialized(the_name))
Modified: sandbox/mirror/boost/mirror/meta_attributes.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_attributes.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_attributes.hpp 2008-05-02 05:16:52 EDT (Fri, 02 May 2008)
@@ -17,6 +17,7 @@
namespace boost {
namespace mirror {
+namespace detail {
/** This is basically the same as the "attributes" structure
* but allows to work with all member attributes including
@@ -28,7 +29,8 @@
>
struct meta_class_all_attributes
{
- typedef meta_class<_reflected_type, _variant_tag> meta_class;
+ typedef boost::mirror::meta_class<_reflected_type, _variant_tag>
+ meta_class;
/** This struct "hides" the internal helpers
*/
struct detail
@@ -478,7 +480,6 @@
}
}; // all_attributes
-namespace detail {
/** Instances of this template are used to store information
* about single class' member attribute and are used mainly
* in the algorithms.
@@ -493,7 +494,8 @@
{
// the meta-class for the class to which
// the attribute belongs
- typedef meta_class<_reflected_type, _variant_tag> meta_class;
+ typedef ::boost::mirror::meta_class<_reflected_type, _variant_tag>
+ meta_class;
// the meta-attributes list (own/all)
// into which the attribute belongs
Modified: sandbox/mirror/boost/mirror/meta_class.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_class.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_class.hpp 2008-05-02 05:16:52 EDT (Fri, 02 May 2008)
@@ -71,7 +71,7 @@
/** Same as attributes but containing also the inherited attributes
*/
- typedef meta_class_all_attributes<reflected_class, variant_tag >
+ typedef detail::meta_class_all_attributes<reflected_class, variant_tag >
all_attributes;
};
Modified: sandbox/mirror/boost/mirror/traversal.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/traversal.hpp (original)
+++ sandbox/mirror/boost/mirror/traversal.hpp 2008-05-02 05:16:52 EDT (Fri, 02 May 2008)
@@ -15,6 +15,11 @@
namespace boost {
namespace mirror {
+
+
+template <class meta_class> struct deep_traversal_of;
+template <class meta_class> struct flat_traversal_of;
+
namespace detail {
template <class meta_class>
@@ -32,8 +37,9 @@
void operator ()(meta_attribute ma)
{
visitor.enter_attribute(ma);
+ typedef typename meta_attribute::type attrib_type;
deep_traversal_of<
- BOOST_MIRROR_REFLECT_CLASS(meta_attribute::type)
+ BOOST_MIRROR_REFLECT_CLASS(attrib_type)
>::accept(visitor);
visitor.leave_attribute(ma);
}
@@ -59,9 +65,9 @@
void operator ()(meta_inheritance mbc)
{
visitor.enter_base_class(mbc);
- deep_traversal_of<
- meta_inheritance::meta_base_class
- >::accept(visitor);
+ typedef typename meta_inheritance::meta_base_class
+ meta_base_class;
+ deep_traversal_of<meta_base_class>::accept(visitor);
visitor.leave_base_class(mbc);
}
private:
@@ -87,8 +93,8 @@
{
meta_class mc;
visitor.enter_type(mc);
- for_each<meta_class::base_classes>(show_bases_to(visitor));
- for_each<meta_class::attributes>(show_attribs_to(visitor));
+ for_each<typename meta_class::base_classes>(show_bases_to(visitor));
+ for_each<typename meta_class::attributes>(show_attribs_to(visitor));
visitor.leave_type(mc);
}
};
@@ -101,7 +107,7 @@
{
meta_class mc;
visitor.enter_type(mc);
- for_each<meta_class::all_attributes>(show_attribs_to(visitor));
+ for_each<typename meta_class::all_attributes>(show_attribs_to(visitor));
visitor.leave_type(mc);
}
};
Modified: sandbox/mirror/boost/mirror/visitors/sample.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/visitors/sample.hpp (original)
+++ sandbox/mirror/boost/mirror/visitors/sample.hpp 2008-05-02 05:16:52 EDT (Fri, 02 May 2008)
@@ -39,7 +39,7 @@
bcout <<
"<type name='" <<
meta_class::base_name();
- if(!reflects_global_scope<meta_class::scope>::value)
+ if(!reflects_global_scope<typename meta_class::scope>::value)
{
bcout <<
"' scope='" <<
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-05-02 05:16:52 EDT (Fri, 02 May 2008)
@@ -279,7 +279,7 @@
else s << "no base classes.";
//
// execute the printer on the list of base classes
- for_each<meta_object::base_classes>(base_class_printer<out_stream>(s));
+ for_each<typename meta_object::base_classes>(base_class_printer<out_stream>(s));
//
return s << endl;
}
@@ -329,7 +329,7 @@
// execute the printer on the list of member attributes
// note that the type of functor and the implementation
// of for_each is likely subject to changes
- for_each<meta_object::attributes>(attrib_printer<out_stream>(s));
+ for_each<typename meta_object::attributes>(attrib_printer<out_stream>(s));
return s << ::std::endl;
}
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-05-02 05:16:52 EDT (Fri, 02 May 2008)
@@ -76,8 +76,7 @@
typedef tuple<char, wchar_t, short int const> T5;
typedef pair<T4, T5> T6;
typedef vector<tuple<T1, T2, T3, T4, T5, T6> > T7;
- typedef set<map<list<T1>, T7> > T8;
- typedef tuple<T1, T2, T8> T;
+ typedef set<map<list<T1>, T7> > T;
//
typedef BOOST_MIRROR_REFLECT_CLASS(T) meta_T;
//
@@ -90,9 +89,6 @@
bcout << "---------------------------------------------------" << endl;
bcout << "The full type name is: "<< meta_T::full_name() << endl;
bcout << "---------------------------------------------------" << endl;
- bcout << "The class has "<< meta_T::all_attributes::size::value << " members" << endl;
- bcout << "---------------------------------------------------" << endl;
- bcout << "---------------------------------------------------" << endl;
//
T1 t1(12, 34.56, 0);
typedef BOOST_MIRROR_REFLECT_CLASS(T1) meta_T1;
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