|
C structures in python
|
Posted: Oct 24, 2005 1:15 PM
|
|
Advertisement
|
I am trying to access C structures in python. Have created an extension of the C using SWIG. -------------------------------------------------------- sample code for structure VPX_RealPoint -------------------------------------------------------- class VPX_RealPoint(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, VPX_RealPoint, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, VPX_RealPoint, name) def __repr__(self): return "<%s.%s; proxy of C VPX_RealPoint instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) __swig_setmethods__["x"] = VPX_InterApp.VPX_RealPoint_x_set __swig_getmethods__["x"] = VPX_InterApp.VPX_RealPoint_x_get if _newclass:x = property(VPX_InterApp.VPX_RealPoint_x_get, VPX_InterApp.VPX_RealPoint_x_set) __swig_setmethods__["y"] = VPX_InterApp.VPX_RealPoint_y_set __swig_getmethods__["y"] = VPX_InterApp.VPX_RealPoint_y_get if _newclass:y = property(VPX_InterApp.VPX_RealPoint_y_get, VPX_InterApp.VPX_RealPoint_y_set) def __init__(self, *args): _swig_setattr(self, VPX_RealPoint, 'this', VPX_InterApp.new_VPX_RealPoint(*args)) _swig_setattr(self, VPX_RealPoint, 'thisown', 1) def __del__(self, destroy=VPX_InterApp.delete_VPX_RealPoint): try: if self.thisown: destroy(self) except: pass
class VPX_RealPointPtr(VPX_RealPoint): def __init__(self, this): _swig_setattr(self, VPX_RealPoint, 'this', this) if not hasattr(self,"thisown"): _swig_setattr(self, VPX_RealPoint, 'thisown', 0) _swig_setattr(self, VPX_RealPoint,self.__class__,VPX_RealPoint) VPX_InterApp.VPX_RealPoint_swigregi ster(VPX_RealPointPtr) //------------------------------------------------------- --
Now how do I access the structure. SWIG example says
import test RT=test.VPX_RealPoint()
however the above gives me an error Attribute error: 'module' object has no attribute 'VPX_RealPoint'
Could anyone tell me how to proceed? Thanks in advance CCure
|
|