[pygccxml-development] py++ and make_contructor
Brought to you by:
mbaas,
roman_yakovenko
From: Damien F. <dam...@mo...> - 2008-08-13 15:44:58
|
Hi , so I have class with create function that act a factory function . typedef boost::smart_ptr<Color> ColorPtr ; class Color { static ColorPtr create(); static ColorPtr create(int i); private: Color(); } make sense for the c++ side by in python I want to hide that so I can do col = Color() # this is actually calling Color.create() .. // this code that py++ create { //::Color::create typedef ::ColorPtr ( *create_function_type )( ); Color_exposer.def( "create" , create_function_type( &::Color::create ) , "Create a color 0 0 0 " ); } I found that I can use make_contructor easily and do : { typedef ::ColorPtr ( *create_function_type )( ); Color_exposer.def ("__init__", bp::make_constructor(create_function_type(&::Color::create) ) ); } so is there a nice way for ne to generate this code for any class that have static boost::smart_ptr<Class> create(....) methods ? looking onto the source I saw : class constructor_transformed_t <cid:par...@mo...>( calldef_t ): that doesn something that might be in the right direction for me . I can see how I would find all the methods that match this style . and doing all the typed def and thing but it look like I might be able to do md.classes().decls('create').make_contructors() :) well not that simple but something in that direction ? thanks the more I get into py++ the more I like it !! |