Dear all,

I am working in the following scenario: I have a class "Derived" which inherits 
from "Base" and wrappers for both. Both have their own static debug flag and 
getters and setters for it (see code at the end of the mail). I try to use 
".add_static_property" to make the debug flags visible in python, however if I 
do this for both Base and Derived, I get:

python -c "import testInheritance"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
    None.None(Boost.Python.StaticProperty)
did not match C++ signature:
    None(bool)

Already when trying to import the module. If I do not add the property for 
Derived, I can import the module but then using debug on the Derived set the 
debug for Base instead. What am I doing wrong? Is this a bug? Does anybody know 
a solution? Any help would be greatly appreciated!

Best regards,
Karl Bicker

PS: I would also like to make you aware of a stackoverflow question of mine: 
http://stackoverflow.com/questions/12202763/boost-python-inheriting-from-wrapped-classes

Code:
----------------------------------------------------------------------------
#include<boost/python.hpp>

namespace bp = boost::python;

struct Base {

    Base() { };

    static bool debug() { return _debug; };
    static void setDebug(const bool debug = true) { _debug = debug; };
  
  private:
    static bool _debug;

};

struct BaseWrapper : Base,
                     bp::wrapper<Base>
{
    
    BaseWrapper() :
        Base(),
        bp::wrapper<Base>() { };

    BaseWrapper(const Base& base) :
        Base(base),
        bp::wrapper<Base>() { };

};

struct Derived : Base
{

    Derived() : Base() { };

    static bool debug() { return _debug; };
    static void setDebug(const bool debug = true) { _debug = debug; };
  
  private:
    static bool _debug;


};

struct DerivedWrapper : Derived,
                        bp::wrapper<Derived>
{

    DerivedWrapper() :
        Derived(),
        bp::wrapper<Derived>() { };
    
    DerivedWrapper(const Derived derived) :
        Derived(derived),
        bp::wrapper<Derived>() { };

};

bool Base::_debug = false;
bool Derived::_debug = false;

BOOST_PYTHON_MODULE(testInheritance){

    bp::class_<BaseWrapper>("Base")
        .add_static_property("debug", &BaseWrapper::debug, 
&BaseWrapper::setDebug);

    bp::class_<DerivedWrapper, bp::bases<Base> >("Derived")
        .add_static_property("debug", &DerivedWrapper::debug, 
&DerivedWrapper::setDebug);

}
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to