diff --git a/wrap/Class.h b/wrap/Class.h index 54db8970b..5c04bd609 100644 --- a/wrap/Class.h +++ b/wrap/Class.h @@ -37,13 +37,14 @@ struct Class { typedef std::map StaticMethods; /// Constructor creates an empty class - Class(bool verbose=true) : isVirtual(false), verbose_(verbose) {} + Class(bool verbose=true) : isVirtual(false), isSerializable(false), verbose_(verbose) {} // Then the instance variables are set directly by the Module constructor std::string name; ///< Class name std::vector templateArgs; ///< Template arguments std::string typedefName; ///< The name to typedef *from*, if this class is actually a typedef, i.e. typedef [typedefName] [name] bool isVirtual; ///< Whether the class is part of a virtual inheritance chain + bool isSerializable; ///< Whether we can use boost.serialization to serialize the class std::vector qualifiedParent; ///< The *single* parent - the last string is the parent class name, preceededing elements are a namespace stack Methods methods; ///< Class methods StaticMethods static_methods; ///< Static methods diff --git a/wrap/Module.cpp b/wrap/Module.cpp index d5bbd881e..02c1787b7 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -378,13 +378,21 @@ void Module::parseMarkup(const std::string& data) { throw ParseFailed((int)info.length); } - //Explicitly add methods to the classes from parents so it shows in documentation + // Post-process classes for serialization markers + BOOST_FOREACH(Class& cls, classes) { + Class::Methods::iterator serialize_it = cls.methods.find("serialize"); + if (serialize_it != cls.methods.end()) { + cls.isSerializable = true; + cls.methods.erase(serialize_it); + } + } + + // Explicitly add methods to the classes from parents so it shows in documentation BOOST_FOREACH(Class& cls, classes) { map inhereted = appendInheretedMethods(cls, classes); cls.methods.insert(inhereted.begin(), inhereted.end()); } - } /* ************************************************************************* */ diff --git a/wrap/tests/geometry.h b/wrap/tests/geometry.h index 13553e986..6c6ed28ad 100644 --- a/wrap/tests/geometry.h +++ b/wrap/tests/geometry.h @@ -22,6 +22,9 @@ class Point3 { // static functions - use static keyword and uppercase static double staticFunction(); static Point3 StaticFunctionRet(double z); + + // enabling serialization functionality + void serialize() const; // Just triggers a flag internally and removes actual function }; // another comment diff --git a/wrap/tests/testWrap.cpp b/wrap/tests/testWrap.cpp index 648058c6d..f993867e5 100644 --- a/wrap/tests/testWrap.cpp +++ b/wrap/tests/testWrap.cpp @@ -251,6 +251,9 @@ TEST( wrap, parse_geometry ) { LONGS_EQUAL(1, m1.argLists.size()); EXPECT_LONGS_EQUAL(0, m1.argLists.front().size()); EXPECT(m1.is_const_); + + // check serialization flag + EXPECT(cls.isSerializable); } // Test class is the third one