logo       

C++ class inheritance using shadow class: msg#00080

programming.swig

Subject: C++ class inheritance using shadow class

Hi there,

I've been using Swig successfully for a while now but I'm stuck with this one!

I've got a basic C++ class:


class System
{
public:
System(void);
float Dt;
float VoxelSize;
int NVoxelX, NVoxelY,NVoxelZ;
Vector SimulationBoxOrigin;
};

inline System::System(void)
{
Dt = 0;
VoxelSize = 0;
NVoxelX = NVoxelY = NVoxelZ = 0;
SimulationBoxOrigin = Vector(0,0,0);
}

I then swig it using shadow classes, that works fine. Now I would like to add extra python features to this classes, so I want to use inheritance.

>>> class Sys(System):
... def __init__(self):
... print Sys.VoxelSize
...
>>> c = Sys()
<property object at 0x818ce24>
>>> c.VoxelSize
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: Type error. Expected _p_System
>>>

The inheritance doesn't seem to work! Any reason why that should be??
Looking forward to your suggestions,

Alex


_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise