[C++-sig] pyste, patch to allow injecting code in class definition
Baptiste Lepilleur
gaiacrtn at free.fr
Mon Jun 28 15:21:24 CEST 2004
The attached patch allows the user to inject code in the class
definition code, just like declaration_code() & module_code(). Among other
things, this allows us to add properties when pyste support fail (anonymous
union...).
Example of usage:
Vector3 = Class( "Ogre::Vector3", "OgreVector3.h" )
class_code( Vector3, '.def_readwrite( "x", &Ogre::Vector3::x )' )
class_code( Vector3, '.def_readwrite( "y", &Ogre::Vector3::y )' )
class_code( Vector3, '.def_readwrite( "z", &Ogre::Vector3::z )' )
Which produces:
class_< Ogre::Vector3 >("Vector3", init< >())
.def(init< Ogre::Real, Ogre::Real, Ogre::Real >())
.def_readwrite( "x", &Ogre::Vector3::x )
.def_readwrite( "y", &Ogre::Vector3::y )
.def_readwrite( "z", &Ogre::Vector3::z )
;
Baptiste.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: class_code.patch
Type: application/octet-stream
Size: 1819 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040628/f31f2406/attachment.obj>
More information about the Cplusplus-sig
mailing list