Re: [pygccxml-development] Force bp::no_init
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-09-21 05:04:44
|
On 9/20/06, Kevin Bluck <tec...@ne...> wrote: > Is there some way to force a class_ to be instantiated with bp::no_init, > as in: > > bp::class_<Foo>("Foo", bp::no_init) > > I have a class that should not be constructible in Python, but instead > only available via a factory function. The matching C++ class does have > a public default constructor and is not abstract. It's a third-party > library so I can't change the declaration. > > I couldn't find any apparent decoration method to do this. I tried > explicitly ignoring the default constructor but that didn't work either. > You are not the first person who ask this question. I will add control to the Py++ over this functionality. Now possible solution: mbuilder = module_builder_t( ..., optimize_queries=True, .... ) #execute next code before any other statement. #this is needed because you modify declarations tree. #You can not change source code, but you do can change what Py++ sees Foo = mbuilder.class_( "Foo" ) constructors = Foo.constructors() for c in constructors: if not c.is_copy_constructor: Foo.remove_declaration( c ) mbuilder.run_query_optimizer() This should help. If not, comeback and I will add "no_init" functionality to the class. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |