[cable] cswig/python inheritance
Kaben Nanlohy
k_cable.public.kitware.com at random.poofygoof.com
Mon Feb 23 12:22:08 EST 2004
Hi;
I have a workaround for this question so its answer is not crucial;
but if you have a ready answer (and I'll bet that you do)
then I would love to hear it.
How should I inform gccxml/cswig of an inheritance hierarchy ?
Here is a demo of the problem I've encountered. Suppose that I wrap
classes Alice, Bob, and Carrie for use in python :
class Alice {
public:
Alice(){}
};
class Bob : public Alice {
public:
Bob(){}
};
class Carrie {
public:
void bleah(Alice *){}
};
In c++ I can pass to Carrie::bleah() a pointer
to an instance of Bob because Bob subclasses Alice.
If I wrap these classes using gccxml/cswig then the following fails :
In [1]: import ABC
In [2]: alice=ABC.Alice()
In [3]: bob=ABC.Bob()
In [4]: carrie=ABC.Carrie()
In [5]: carrie.bleah(bob)
With the error :
TypeError: Type error. Got _p_Bob, expected _p_Alice
But if I either :
- wrap the classes in straight swig, or
- describe them in a swig file and pass that file to cswig
using the -l option
then the sequence of commands succeeds.
***
When I examine the gccxml-/cswig-generated python in ABC.py I see :
class Alice(_object):
.
.
class Bob(_object):
.
.
class Carrie(_object):
.
.
When I examine the swig-generated bindings I find :
class Alice(_object):
.
.
class Bob(Alice):
.
.
class Carrie(_object):
.
.
In the second case the class definitions have inheritance information
that the first case lacks.
Okay. Any thoughts ?
Many thanks -- Kaben
More information about the cable
mailing list