[C++-SIG] HELP: wrapping with CXX, multiple inheritance issue

Barry Scott bscott at Ridgeway-Sys.com
Thu Jun 8 17:44:39 CEST 2000


Using the CXX 5.0 is a better base then 4.2. HOwever its not the going to
fix the inheritance.

I think the root cause of your problems is that you cannot use C++
derivation
to create related Python objects.

		BArry



-----Original Message-----
From: Ben [mailto:skeltobc at mailandnews.com]
Sent: 07 June 2000 18:25
To: c++-sig at python.org
Subject: [C++-SIG] HELP: wrapping with CXX, multiple inheritance issue


Hi

I am using CXX-4.2 to wrap a c++ library, but Im having some troubles with 
multiple inheritance issues. This is what I have:

class BaseObjectWrapper
  : public PythonExtension<BaseObjectWrapper>, 
    public BaseObjectInLibrary {
public:
  BaseObjectWrapper ();
  virtual ~BaseObjectWrapper ();

  Py::Object PythonMethod1 (const Py::Tuple& args);
  Py::Object PythonMethod2 (const Py::Tuple& args);

  static void init_type (void);

  STD::string asString () const;
  virtual Py::Object repr ();
};

and

class DerivedObjectWrapper
  : public PythonExtension<DerivedObjectWrapper>, 
    public DerivedObjectInLibrary,
    public BaseObjectWrapper {
public:
  DerivedObjectWrapper ();
  virtual ~DerivedObjectWrapper ();

  Py::Object PythonMethod3 (const Py::Tuple& args);
  Py::Object PythonMethod4 (const Py::Tuple& args);

  static void init_type (void);

  STD::string asString () const;
  virtual Py::Object repr ();
};

DerivedObjectWrapper inherits BaseObjectWrapper and in the library 
DerivedObjectInLibrary inherits BaseObjectInLibrary. 

Now when I compile, I get this:

../../../cxx/CXX-4.2/Include/CXX_Extensions.h: In function `static void 
Py::Pyth
onExtension<DerivedObjectWrapper>::extension_object_deallocator(PyObject
*)':
../../../cxx/CXX-4.2/Include/CXX_Extensions.h:528:   instantiated from 
`Py::Pyth
onExtension<DerivedObjectWrapper>::behaviors()'
../../../cxx/CXX-4.2/Include/CXX_Extensions.h:497:   instantiated from 
`Py::Pyth
onExtension<DerivedObjectWrapper>::type_object()'
../../../cxx/CXX-4.2/Include/CXX_Extensions.h:516:   instantiated from 
`Py::Pyth
onExtension<DerivedObjectWrapper>::PythonExtension()'
pythonwrapper.cpp:63:   instantiated from here
../../../cxx/CXX-4.2/Include/CXX_Extensions.h:673: type 
`DerivedObjectWrapper' is ambiguous bas
eclass of `PyObject'

plus a whole lot of warnings about ambiguous behaviours () and 
add_varargs_method () due I guess to references to these methods from 
PythonExtension<DerivedObjectWrapper> as well as 
PythonExtension<BaseObjectWrapper> via the BaseObjectWrapper inheritance. 
Line 63 in pythonwrapper.cpp is the point where the constructor is defined.
I 
can handle the ambiguity in DerivedObjectWrapper::init_type, but I don't
know 
what I should be doing with the constructor. Ive programmed some in C++ 
before finding Python but Ive never attempted to use C++'s tricky stuff. 

I could of course just lose the BaseObjectWrapper inheritance in 
DerivedObjectWrapper and rewrite the BaseObjectWrapper methods in 
DerivedObjectWrapper and other derived classes, but Im sure it's not
supposed 
to work that way.

Any help here would be appreciated.

cheers
--Ben

_______________________________________________
C++-SIG maillist  -  C++-SIG at python.org
http://www.python.org/mailman/listinfo/c++-sig




More information about the Cplusplus-sig mailing list