pygccxml-development Mailing List for C++ Python language bindings (Page 18)
Brought to you by:
mbaas,
roman_yakovenko
You can subscribe to this list here.
2006 |
Jan
|
Feb
(6) |
Mar
(160) |
Apr
(96) |
May
(152) |
Jun
(72) |
Jul
(99) |
Aug
(189) |
Sep
(161) |
Oct
(110) |
Nov
(9) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(13) |
Feb
(48) |
Mar
(35) |
Apr
(7) |
May
(37) |
Jun
(8) |
Jul
(15) |
Aug
(8) |
Sep
(2) |
Oct
(1) |
Nov
(2) |
Dec
(38) |
2008 |
Jan
(11) |
Feb
(29) |
Mar
(17) |
Apr
(3) |
May
|
Jun
(64) |
Jul
(49) |
Aug
(51) |
Sep
(18) |
Oct
(22) |
Nov
(9) |
Dec
(9) |
2009 |
Jan
(28) |
Feb
(15) |
Mar
(2) |
Apr
(11) |
May
(6) |
Jun
(2) |
Jul
(3) |
Aug
(34) |
Sep
(5) |
Oct
(7) |
Nov
(13) |
Dec
(14) |
2010 |
Jan
(39) |
Feb
(3) |
Mar
(3) |
Apr
(14) |
May
(11) |
Jun
(8) |
Jul
(9) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
|
Jun
(3) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2016 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2021 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
From: Vincent F. <vin...@gm...> - 2008-06-20 07:16:08
|
More precisions again, I'm mapping the following function : std::map<int,node> & getNodes(void) ; I specify the call policy like that : nastranDb.member_function('getNodes').call_policies = call_policies.return_value_policy(call_policies.reference_existing_object) Is this the good way to do? Is there a possibility to directly get Python lists, or tuples etc? 2008/6/19, Vincent Ferries <vin...@gm...>: > In fact, it allways produce me classes like > pyferespost.map_less__int_comma__postLib_scope_nastran_scope_property__grate_, > I understand the reason but, is it a way to use python lists, sets and > dictionnaries instead of generated ones which seams to lack some > functionalities? > Or is it a way to implement these functionalities? > > 2008/6/19, Vincent Ferries <vin...@gm...>: >> I read this unit tests before, but don't seem to get the same type of >> vectors/maps. >> >> I don't really know what I am missing, maybe a wrong call policy? >> I set the call policy of getters on those maps to >> call_policies.reference_existing_object. >> The module creator generate me a list of vector and map wrappers with >> the methods I just listed above. I can't obviously access it like a >> list or a dictionary. >> >> I'm using base implementation of indexing_suite (not >> indexing_suite_v2, I have problems to compile while using it). If I >> can access different children elements it'll be fine for me, no real >> need of indexing_suite_v2. >> >> 2008/6/19, Roman Yakovenko <rom...@gm...>: >>> On Thu, Jun 19, 2008 at 11:00 AM, Vincent Ferries >>> <vin...@gm...> wrote: >>>> For dictionaries you can directly use structures like : >>>> >>>> for (key, values) in dict: >>>> >>>> and the key/values elements will be matching key and list of values. >>>> >>>> >>>> But I'm not able to access them in this way. >>>> >>>> >>>> Using reflection to list accessibles methods on the map I get : >>>> >>>> __call__ x.__call__(...) <==> x(...) >>>> __class__ instancemethod(function, instance, class) Create an >>>> instance method object. >>>> __cmp__ x.__cmp__(y) <==> cmp(x,y) >>>> __delattr__ x.__delattr__('name') <==> del x.name >>>> __get__ descr.__get__(obj[, type]) -> value >>>> __getattribute__ x.__getattribute__('name') <==> x.name >>>> __hash__ x.__hash__() <==> hash(x) >>>> __init__ x.__init__(...) initializes x; see x.__class__.__doc__ for >>>> signature >>>> __new__ T.__new__(S, ...) -> a new object with type S, a subtype of T >>>> __reduce__ helper for pickle >>>> __reduce_ex__ helper for pickle >>>> __repr__ x.__repr__() <==> repr(x) >>>> __setattr__ x.__setattr__('name', value) <==> x.name = value >>>> __str__ x.__str__() <==> str(x) >>>> im_class None >>>> im_func None >>>> >>>> >>>> "values" function don't appear... >>> >>> Please create small test case that reproduce the problem. >>> >>> According to my unit tests >>> * >>> http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/indexing_suites_tester.py?revision=414&view=markup >>> * >>> http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/indexing_suites2_tester.py?revision=1081&view=markup >>> >>> the functionality works just fine. >>> >>> >>> >>> -- >>> Roman Yakovenko >>> C++ Python language binding >>> http://www.language-binding.net/ >>> >> > |
From: Vincent F. <vin...@gm...> - 2008-06-19 09:33:10
|
In fact, it allways produce me classes like pyferespost.map_less__int_comma__postLib_scope_nastran_scope_property__grate_, I understand the reason but, is it a way to use python lists, sets and dictionnaries instead of generated ones which seams to lack some functionalities? Or is it a way to implement these functionalities? 2008/6/19, Vincent Ferries <vin...@gm...>: > I read this unit tests before, but don't seem to get the same type of > vectors/maps. > > I don't really know what I am missing, maybe a wrong call policy? > I set the call policy of getters on those maps to > call_policies.reference_existing_object. > The module creator generate me a list of vector and map wrappers with > the methods I just listed above. I can't obviously access it like a > list or a dictionary. > > I'm using base implementation of indexing_suite (not > indexing_suite_v2, I have problems to compile while using it). If I > can access different children elements it'll be fine for me, no real > need of indexing_suite_v2. > > 2008/6/19, Roman Yakovenko <rom...@gm...>: >> On Thu, Jun 19, 2008 at 11:00 AM, Vincent Ferries >> <vin...@gm...> wrote: >>> For dictionaries you can directly use structures like : >>> >>> for (key, values) in dict: >>> >>> and the key/values elements will be matching key and list of values. >>> >>> >>> But I'm not able to access them in this way. >>> >>> >>> Using reflection to list accessibles methods on the map I get : >>> >>> __call__ x.__call__(...) <==> x(...) >>> __class__ instancemethod(function, instance, class) Create an >>> instance method object. >>> __cmp__ x.__cmp__(y) <==> cmp(x,y) >>> __delattr__ x.__delattr__('name') <==> del x.name >>> __get__ descr.__get__(obj[, type]) -> value >>> __getattribute__ x.__getattribute__('name') <==> x.name >>> __hash__ x.__hash__() <==> hash(x) >>> __init__ x.__init__(...) initializes x; see x.__class__.__doc__ for >>> signature >>> __new__ T.__new__(S, ...) -> a new object with type S, a subtype of T >>> __reduce__ helper for pickle >>> __reduce_ex__ helper for pickle >>> __repr__ x.__repr__() <==> repr(x) >>> __setattr__ x.__setattr__('name', value) <==> x.name = value >>> __str__ x.__str__() <==> str(x) >>> im_class None >>> im_func None >>> >>> >>> "values" function don't appear... >> >> Please create small test case that reproduce the problem. >> >> According to my unit tests >> * >> http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/indexing_suites_tester.py?revision=414&view=markup >> * >> http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/indexing_suites2_tester.py?revision=1081&view=markup >> >> the functionality works just fine. >> >> >> >> -- >> Roman Yakovenko >> C++ Python language binding >> http://www.language-binding.net/ >> > |
From: Vincent F. <vin...@gm...> - 2008-06-19 08:28:21
|
I read this unit tests before, but don't seem to get the same type of vectors/maps. I don't really know what I am missing, maybe a wrong call policy? I set the call policy of getters on those maps to call_policies.reference_existing_object. The module creator generate me a list of vector and map wrappers with the methods I just listed above. I can't obviously access it like a list or a dictionary. I'm using base implementation of indexing_suite (not indexing_suite_v2, I have problems to compile while using it). If I can access different children elements it'll be fine for me, no real need of indexing_suite_v2. 2008/6/19, Roman Yakovenko <rom...@gm...>: > On Thu, Jun 19, 2008 at 11:00 AM, Vincent Ferries > <vin...@gm...> wrote: >> For dictionaries you can directly use structures like : >> >> for (key, values) in dict: >> >> and the key/values elements will be matching key and list of values. >> >> >> But I'm not able to access them in this way. >> >> >> Using reflection to list accessibles methods on the map I get : >> >> __call__ x.__call__(...) <==> x(...) >> __class__ instancemethod(function, instance, class) Create an >> instance method object. >> __cmp__ x.__cmp__(y) <==> cmp(x,y) >> __delattr__ x.__delattr__('name') <==> del x.name >> __get__ descr.__get__(obj[, type]) -> value >> __getattribute__ x.__getattribute__('name') <==> x.name >> __hash__ x.__hash__() <==> hash(x) >> __init__ x.__init__(...) initializes x; see x.__class__.__doc__ for >> signature >> __new__ T.__new__(S, ...) -> a new object with type S, a subtype of T >> __reduce__ helper for pickle >> __reduce_ex__ helper for pickle >> __repr__ x.__repr__() <==> repr(x) >> __setattr__ x.__setattr__('name', value) <==> x.name = value >> __str__ x.__str__() <==> str(x) >> im_class None >> im_func None >> >> >> "values" function don't appear... > > Please create small test case that reproduce the problem. > > According to my unit tests > * > http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/indexing_suites_tester.py?revision=414&view=markup > * > http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/indexing_suites2_tester.py?revision=1081&view=markup > > the functionality works just fine. > > > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Roman Y. <rom...@gm...> - 2008-06-19 08:06:52
|
On Thu, Jun 19, 2008 at 11:00 AM, Vincent Ferries <vin...@gm...> wrote: > For dictionaries you can directly use structures like : > > for (key, values) in dict: > > and the key/values elements will be matching key and list of values. > > > But I'm not able to access them in this way. > > > Using reflection to list accessibles methods on the map I get : > > __call__ x.__call__(...) <==> x(...) > __class__ instancemethod(function, instance, class) Create an > instance method object. > __cmp__ x.__cmp__(y) <==> cmp(x,y) > __delattr__ x.__delattr__('name') <==> del x.name > __get__ descr.__get__(obj[, type]) -> value > __getattribute__ x.__getattribute__('name') <==> x.name > __hash__ x.__hash__() <==> hash(x) > __init__ x.__init__(...) initializes x; see x.__class__.__doc__ for signature > __new__ T.__new__(S, ...) -> a new object with type S, a subtype of T > __reduce__ helper for pickle > __reduce_ex__ helper for pickle > __repr__ x.__repr__() <==> repr(x) > __setattr__ x.__setattr__('name', value) <==> x.name = value > __str__ x.__str__() <==> str(x) > im_class None > im_func None > > > "values" function don't appear... Please create small test case that reproduce the problem. According to my unit tests * http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/indexing_suites_tester.py?revision=414&view=markup * http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/indexing_suites2_tester.py?revision=1081&view=markup the functionality works just fine. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-19 08:00:13
|
For dictionaries you can directly use structures like : for (key, values) in dict: and the key/values elements will be matching key and list of values. But I'm not able to access them in this way. Using reflection to list accessibles methods on the map I get : __call__ x.__call__(...) <==> x(...) __class__ instancemethod(function, instance, class) Create an instance method object. __cmp__ x.__cmp__(y) <==> cmp(x,y) __delattr__ x.__delattr__('name') <==> del x.name __get__ descr.__get__(obj[, type]) -> value __getattribute__ x.__getattribute__('name') <==> x.name __hash__ x.__hash__() <==> hash(x) __init__ x.__init__(...) initializes x; see x.__class__.__doc__ for signature __new__ T.__new__(S, ...) -> a new object with type S, a subtype of T __reduce__ helper for pickle __reduce_ex__ helper for pickle __repr__ x.__repr__() <==> repr(x) __setattr__ x.__setattr__('name', value) <==> x.name = value __str__ x.__str__() <==> str(x) im_class None im_func None "values" function don't appear... 2008/6/19, Roman Yakovenko <rom...@gm...>: > On Thu, Jun 19, 2008 at 10:16 AM, Vincent Ferries > <vin...@gm...> wrote: >> The method NastranDatabase.getNodes() has the following signature in >> the C++ code : std::map<int,node> & getNodes(void) ; >> >> In my python code, I'm able to call it and get the corresponding >> map_indexing_suite_map_less__int_comma__postLib_scope_nastran_scope_node__grate_ >> object. >> When I iterate over this instance, I get the example listed above. >> But don't know how to access corresponding int and NastranNode for >> every element in the list... >> >> Hope this is better explained. > > A little bit. > > Iterating over std::map class is same as iterating over dictionary: > you get tuple of <key, value> > if you are interested in values only, you can use "values" function. > > Take a look on Py++ unittests. > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Roman Y. <rom...@gm...> - 2008-06-19 07:40:31
|
On Thu, Jun 19, 2008 at 10:16 AM, Vincent Ferries <vin...@gm...> wrote: > The method NastranDatabase.getNodes() has the following signature in > the C++ code : std::map<int,node> & getNodes(void) ; > > In my python code, I'm able to call it and get the corresponding > map_indexing_suite_map_less__int_comma__postLib_scope_nastran_scope_node__grate_ > object. > When I iterate over this instance, I get the example listed above. > But don't know how to access corresponding int and NastranNode for > every element in the list... > > Hope this is better explained. A little bit. Iterating over std::map class is same as iterating over dictionary: you get tuple of <key, value> if you are interested in values only, you can use "values" function. Take a look on Py++ unittests. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-19 07:16:25
|
The method NastranDatabase.getNodes() has the following signature in the C++ code : std::map<int,node> & getNodes(void) ; In my python code, I'm able to call it and get the corresponding map_indexing_suite_map_less__int_comma__postLib_scope_nastran_scope_node__grate_ object. When I iterate over this instance, I get the example listed above. But don't know how to access corresponding int and NastranNode for every element in the list... Hope this is better explained. Thanks again. 2008/6/18, Roman Yakovenko <rom...@gm...>: > On Wed, Jun 18, 2008 at 6:50 PM, Vincent Ferries > <vin...@gm...> wrote: >> I've generated most of what I needed. >> I'm currently trying to recover all the informations stocked in my >> different objects. >> >> I'm initializing an object with childrens (nodes in this example). >> >> I've said myself the best way should be using iterators over such >> lists (vector, maps etc). >> I tried the following example : >> >> >> nodes = self.internalDb.getNodes() >> iterator = nodes.__iter__() >> for it in iterator: >> print it >> >> >> >> It prints me a list of lines like that : >> >> (52208839, <pyferespost.NastranNode object at 0xb7e01dec>) >> >> >> >> I'd like to access to the inner object (in this case a NastranNode) >> but don't really know how... > > Sorry, but I don't understand you. Small and complete example is needed. > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Roman Y. <rom...@gm...> - 2008-06-18 17:55:09
|
On Wed, Jun 18, 2008 at 6:50 PM, Vincent Ferries <vin...@gm...> wrote: > I've generated most of what I needed. > I'm currently trying to recover all the informations stocked in my > different objects. > > I'm initializing an object with childrens (nodes in this example). > > I've said myself the best way should be using iterators over such > lists (vector, maps etc). > I tried the following example : > > > nodes = self.internalDb.getNodes() > iterator = nodes.__iter__() > for it in iterator: > print it > > > > It prints me a list of lines like that : > > (52208839, <pyferespost.NastranNode object at 0xb7e01dec>) > > > > I'd like to access to the inner object (in this case a NastranNode) > but don't really know how... Sorry, but I don't understand you. Small and complete example is needed. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-18 15:50:25
|
I've generated most of what I needed. I'm currently trying to recover all the informations stocked in my different objects. I'm initializing an object with childrens (nodes in this example). I've said myself the best way should be using iterators over such lists (vector, maps etc). I tried the following example : nodes = self.internalDb.getNodes() iterator = nodes.__iter__() for it in iterator: print it It prints me a list of lines like that : (52208839, <pyferespost.NastranNode object at 0xb7e01dec>) I'd like to access to the inner object (in this case a NastranNode) but don't really know how... Thanks in advance! Vincent FERRIES |
From: Roman Y. <rom...@gm...> - 2008-06-14 18:05:28
|
On Fri, Jun 13, 2008 at 10:11 AM, Vincent Ferries <vin...@gm...> wrote: > I prefer to keep most of ths code hidden. > I'll post you just what is need if possible. > > There are two call_policies definitions and what's done with includes. > > > nastranPfManip = mb.namespace('postLib').namespace('nastran', > recursive=False).class_('opfManip') > reference_functions.append(nastranPfManip.member_function('getOstream')) > > nastranElement = mb.namespace('postLib').namespace('nastran', > recursive=False).class_('element') > pointee_functions.append(nastranElement.member_function('getCornerNodes')) > > for function in reference_functions : > function.call_policies = > call_policies.return_value_policy(call_policies.reference_existing_object) > > for function in pointee_functions : > # Seems to generate import troubles > function.call_policies = > call_policies.return_value_policy(call_policies.return_pointee_value) > > > > for the includes I use the folowing line which links to all my .h files: > > > mb.code_creator.add_include(os.path.join(settings.ferespost_path, > "pyferespost.h")) > > > And the initialization : > > > header_files = [os.path.join(settings.ferespost_path, "pyferespost.h")] > #header_files = [os.path.join(settings.ferespost_path, "CLA/util/idfier.h")] > > > # Create configuration for GCC-XML parser > # Initialize module builder > mb = module_builder.module_builder_t(header_files, > gccxml_path=settings.gccxml_path, > working_directory=settings.ferespost_path, > include_paths=[settings.ferespost_path], define_symbols=[]) > > #Well, don't you want to see what is going on? > # Please be quiet... I'll be grateful > # mb.print_declarations() > > #Creating code creator. After this step you should not > modify/customize declarations. > mb.build_code_creator(settings.module_name) > mb.code_creator.license = license > mb.code_creator.user_defined_directories.append(settings.ferespost_path) > mb.code_creator.precompiled_header = 'boost/python.hpp' I don't see problem with the code you posted. I also created small unit test and it doesn't reproduce the problem. In the directory, you generate code too, Py++ will place "__call_policies.pypp.hpp". This is the file, that contains the relevant class definition. You will have to create small test case, that reproduce the problem. I don't see other way to solve it. Sorry. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Gustavo C. <gjc...@gm...> - 2008-06-13 22:04:49
|
2008/6/13 Gustavo Carneiro <gjc...@gm...>: > 2008/6/11 Gustavo Carneiro <gjc...@gm...>: > >> 2008/6/10 Roman Yakovenko <rom...@gm...>: >> >>> On Mon, Jun 9, 2008 at 1:36 PM, Gustavo Carneiro <gjc...@gm...> >>> wrote: >>> > As seen in >>> > >>> > https://bugs.launchpad.net/bugs/238455 >>> > >>> > I am getting problems in PyBindGen related to differences in types like >>> > "char*" vs "char *", also the position of the 'const' keyword may >>> change, >>> > etc. >>> > >>> > I am looking for some robust, pure python code to parse C types and >>> extract >>> > features from it, or produce a canonical type string, so that I can use >>> it >>> > PyBindGen. Does something like this exist in pygccxml >>> >>> No, but we can discuss such addition to pygccxml. I think this is a >>> nice & useful feature. >>> >>> > or elsewhere that I can steal? :-) >>> >>> May be from here: http://code.google.com/p/cppclean/wiki/InternalDesign >> >> >> Thanks for the link! This code looks nice, if excessive for what I want. >> Using and adapting this code to parse C types is now on my medium priority >> TODO list. If I get something useful out of it, I'll post here the result. >> > > OK, I have results :-) > Due to the mailing list rejecting ZIP files, the zip file I sent can be found here: http://telecom.inescporto.pt/~gjc/ctypeparser.zip Regards. > > > gjc@dark-tower:ctypeparser$ python ctypeparser.py > 'char *' => 'char *' > 'const foo::bar<const char*, zbr&>*' => 'foo::bar< char const *, zbr & > > const *' > 'const ::bar*' => '::bar const *' > 'const char*const' => 'char const * const' > 'const char*const*const' => 'char const * const * const' > > > This code uses the tokenizer from cppclean project, with minor > modifications. On top of it it I wrote a minimal type parser which reorders > 'const' modifiers to _a_ canonical position (to the right, in this case), > and finally converts the result back to a string with deterministic spacing > applied to tokens. It also handles templated types recursively. > > Let me know what you think. > > If it is suitable, next step is add some unit tests and then you can copy > it to pygccxml, if you want. I'll add another copy to pybindgen. > > One thing I am not completely sure yet is how to handle namespaced > identififers. I am tempted to assume a context where no 'using namespace > xxx' statment would have been used and assume all identifiers are relative > to the root namespace. On that assumption I would like to remove any > leading :: in identifiers. Any thoughts? > > Regards. > > > -- > Gustavo J. A. M. Carneiro > INESC Porto, Telecommunications and Multimedia Unit > "The universe is always one step beyond logic." -- Frank Herbert > -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert |
From: Roman Y. <rom...@gm...> - 2008-06-12 19:35:51
|
On Thu, Jun 12, 2008 at 2:48 PM, Vincent Ferries <vin...@gm...> wrote: > Here it is. > The file fyrespost.h contains includes to all my .h files Can you post your script? I need to see how you define call policies and what you do with "include"s. If you cannot, please create small test case that reproduce the problem. Thanks P.S. All my relevant testers shows that this functionality just works. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-12 11:55:34
|
Here it is. The file fyrespost.h contains includes to all my .h files // This file has been generated by Py++. #include "boost/python.hpp" #include "NASTRAN/material/material.h" #include "pyferespost.h" #include "NastranMaterial.pypp.hpp" namespace bp = boost::python; struct material_wrapper : postLib::nastran::material, bp::wrapper< postLib::nastran::material > { material_wrapper( ) : postLib::nastran::material( ) , bp::wrapper< postLib::nastran::material >(){ // null constructor } material_wrapper(::postLib::nastran::material const & in ) : postLib::nastran::material( boost::ref(in) ) , bp::wrapper< postLib::nastran::material >(){ // copy constructor } virtual bool fillClaMaterial( ::postLib::cla::material & tmpMat ) const { if( bp::override func_fillClaMaterial = this->get_override( "fillClaMaterial" ) ) return func_fillClaMaterial( boost::ref(tmpMat) ); else return this->postLib::nastran::material::fillClaMaterial( boost::ref(tmpMat) ); } bool default_fillClaMaterial( ::postLib::cla::material & tmpMat ) const { return postLib::nastran::material::fillClaMaterial( boost::ref(tmpMat) ); } virtual void write( ::std::ostream & os ) const { if( bp::override func_write = this->get_override( "write" ) ) func_write( boost::ref(os) ); else this->postLib::nastran::material::write( boost::ref(os) ); } void default_write( ::std::ostream & os ) const { postLib::nastran::material::write( boost::ref(os) ); } }; void register_NastranMaterial_class(){ { //::postLib::nastran::material typedef bp::class_< material_wrapper > NastranMaterial_exposer_t; NastranMaterial_exposer_t NastranMaterial_exposer = NastranMaterial_exposer_t( "NastranMaterial" ); bp::scope NastranMaterial_scope( NastranMaterial_exposer ); bp::class_< postLib::nastran::material::matType >( "NastranMattype" ) .def( "activate" , &::postLib::nastran::material::matType::activate , ( bp::arg("typeName") ) ) .def( "desactivate" , &::postLib::nastran::material::matType::desactivate , ( bp::arg("typeName") ) ) .def( "getIdFromName" , &::postLib::nastran::material::matType::getIdFromName , ( bp::arg("typeName") ) ) .def( "getNameFromId" , &::postLib::nastran::material::matType::getNameFromId , ( bp::arg("typeId") ) ) .def( "isActive" , (bool (*)( int ))( &::postLib::nastran::material::matType::isActive ) , ( bp::arg("typeId") ) ) .def( "isActive" , (bool (*)( ::std::string const & ))( &::postLib::nastran::material::matType::isActive ) , ( bp::arg("typeName") ) ) .def( "isTotallySupported" , (bool ( ::postLib::nastran::material::matType::* )( int ) )( &::postLib::nastran::material::matType::isTotallySupported ) , ( bp::arg("typeId") ) ) .def( "isTotallySupported" , (bool ( ::postLib::nastran::material::matType::* )( ::std::string const & ) )( &::postLib::nastran::material::matType::isTotallySupported ) , ( bp::arg("typeName") ) ) .def_readonly( "CREEP", postLib::nastran::material::matType::CREEP ) .def_readonly( "MAT1", postLib::nastran::material::matType::MAT1 ) .def_readonly( "MAT10", postLib::nastran::material::matType::MAT10 ) .def_readonly( "MAT11", postLib::nastran::material::matType::MAT11 ) .def_readonly( "MAT2", postLib::nastran::material::matType::MAT2 ) .def_readonly( "MAT3", postLib::nastran::material::matType::MAT3 ) .def_readonly( "MAT4", postLib::nastran::material::matType::MAT4 ) .def_readonly( "MAT5", postLib::nastran::material::matType::MAT5 ) .def_readonly( "MAT8", postLib::nastran::material::matType::MAT8 ) .def_readonly( "MAT9", postLib::nastran::material::matType::MAT9 ) .def_readonly( "MATHP", postLib::nastran::material::matType::MATHP ) .def_readonly( "MATS1", postLib::nastran::material::matType::MATS1 ) .def_readonly( "MATT1", postLib::nastran::material::matType::MATT1 ) .def_readonly( "MATT2", postLib::nastran::material::matType::MATT2 ) .def_readonly( "MATT3", postLib::nastran::material::matType::MATT3 ) .def_readonly( "MATT4", postLib::nastran::material::matType::MATT4 ) .def_readonly( "MATT5", postLib::nastran::material::matType::MATT5 ) .def_readonly( "MATT8", postLib::nastran::material::matType::MATT8 ) .def_readonly( "MATT9", postLib::nastran::material::matType::MATT9 ) .def_readwrite( "activeCards", postLib::nastran::material::matType::activeCards ) .def_readwrite( "mapNamesIds", postLib::nastran::material::matType::mapNamesIds ) .staticmethod( "activate" ) .staticmethod( "desactivate" ) .staticmethod( "getIdFromName" ) .staticmethod( "getNameFromId" ) .staticmethod( "isActive" ); NastranMaterial_exposer.def( bp::init< >() ); NastranMaterial_exposer.def( bp::init< postLib::nastran::material const & >(( bp::arg("in") )) ); { //::postLib::nastran::material::clear typedef void ( ::postLib::nastran::material::*clear_function_type )( ) ; NastranMaterial_exposer.def( "clear" , clear_function_type( &::postLib::nastran::material::clear ) ); } { //::postLib::nastran::material::fillClaMaterial typedef bool ( ::postLib::nastran::material::*fillClaMaterial_function_type )( ::postLib::cla::material & ) const; typedef bool ( material_wrapper::*default_fillClaMaterial_function_type )( ::postLib::cla::material & ) const; NastranMaterial_exposer.def( "fillClaMaterial" , fillClaMaterial_function_type(&::postLib::nastran::material::fillClaMaterial) , default_fillClaMaterial_function_type(&material_wrapper::default_fillClaMaterial) , ( bp::arg("tmpMat") ) ); } { //::postLib::nastran::material::getNbrWords typedef unsigned int ( ::postLib::nastran::material::*getNbrWords_function_type )( ) const; NastranMaterial_exposer.def( "getNbrWords" , getNbrWords_function_type( &::postLib::nastran::material::getNbrWords ) ); } { //::postLib::nastran::material::getType typedef int ( ::postLib::nastran::material::*getType_function_type )( ) const; NastranMaterial_exposer.def( "getType" , getType_function_type( &::postLib::nastran::material::getType ) ); } { //::postLib::nastran::material::getTypeName typedef ::std::string ( ::postLib::nastran::material::*getTypeName_function_type )( ) const; NastranMaterial_exposer.def( "getTypeName" , getTypeName_function_type( &::postLib::nastran::material::getTypeName ) ); } { //::postLib::nastran::material::getWords typedef int const * ( ::postLib::nastran::material::*getWords_function_type )( ) const; NastranMaterial_exposer.def( "getWords" , getWords_function_type( &::postLib::nastran::material::getWords ) , bp::return_value_policy< pyplusplus::call_policies::return_pointee_value >() ); } { //::postLib::nastran::material::operator= typedef ::postLib::nastran::material const & ( ::postLib::nastran::material::*assign_function_type )( ::postLib::nastran::material const & ) ; NastranMaterial_exposer.def( "assign" , assign_function_type( &::postLib::nastran::material::operator= ) , ( bp::arg("in") ) , bp::return_value_policy< bp::copy_const_reference >() ); } { //::postLib::nastran::material::scanBdfCard typedef void ( *scanBdfCard_function_type )( ::postLib::generic::dataBase &,::postLib::nastran::scanBdf::card const & ); NastranMaterial_exposer.def( "scanBdfCard" , scanBdfCard_function_type( &::postLib::nastran::material::scanBdfCard ) , ( bp::arg("DB"), bp::arg("tmpCard") ) ); } { //::postLib::nastran::material::scanOp2Record typedef void ( *scanOp2Record_function_type )( ::postLib::generic::dataBase &,::std::string,int,::std::vector< int > & ); NastranMaterial_exposer.def( "scanOp2Record" , scanOp2Record_function_type( &::postLib::nastran::material::scanOp2Record ) , ( bp::arg("DB"), bp::arg("hName"), bp::arg("nbr"), bp::arg("iBlock") ) ); } { //::postLib::nastran::material::setNbrWords typedef void ( ::postLib::nastran::material::*setNbrWords_function_type )( unsigned int ) ; NastranMaterial_exposer.def( "setNbrWords" , setNbrWords_function_type( &::postLib::nastran::material::setNbrWords ) , ( bp::arg("nbr") ) ); } { //::postLib::nastran::material::write typedef void ( ::postLib::nastran::material::*write_function_type )( ::std::ostream & ) const; typedef void ( material_wrapper::*default_write_function_type )( ::std::ostream & ) const; NastranMaterial_exposer.def( "write" , write_function_type(&::postLib::nastran::material::write) , default_write_function_type(&material_wrapper::default_write) , ( bp::arg("os") ) ); } NastranMaterial_exposer.staticmethod( "scanBdfCard" ); NastranMaterial_exposer.staticmethod( "scanOp2Record" ); } } 2008/6/12, Roman Yakovenko <rom...@gm...>: > On Thu, Jun 12, 2008 at 1:33 PM, Vincent Ferries > <vin...@gm...> wrote: >> I added some different call_policies to wrap some functions. >> These functions where not fully wrapped due to missing informations on >> call_policies. >> I added the following call_policy : >> >> function.call_policies = >> call_policies.return_value_policy(call_policies.return_pointee_value) >> >> I encounter problems during compilation : >> >> wrappers/NastranMaterial.pypp.cpp: In function 'void >> register_NastranMaterial_class()': >> wrappers/NastranMaterial.pypp.cpp:179: error: 'pyplusplus' was not >> declared in this scope >> wrappers/NastranMaterial.pypp.cpp:179: error: template argument 1 is >> invalid >> scons: *** [wrappers/NastranMaterial.pypp.os] Error 1 >> scons: building terminated because of errors. >> >> There is nothing in the examples on call_policies I haven't in my python >> script. >> Am I missing something? > > Do you replace "include" files? Can you post NastranMaterial.pypp.cpp file? > > Thanks > > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Roman Y. <rom...@gm...> - 2008-06-12 10:57:59
|
On Thu, Jun 12, 2008 at 1:33 PM, Vincent Ferries <vin...@gm...> wrote: > I added some different call_policies to wrap some functions. > These functions where not fully wrapped due to missing informations on > call_policies. > I added the following call_policy : > > function.call_policies = > call_policies.return_value_policy(call_policies.return_pointee_value) > > I encounter problems during compilation : > > wrappers/NastranMaterial.pypp.cpp: In function 'void > register_NastranMaterial_class()': > wrappers/NastranMaterial.pypp.cpp:179: error: 'pyplusplus' was not > declared in this scope > wrappers/NastranMaterial.pypp.cpp:179: error: template argument 1 is invalid > scons: *** [wrappers/NastranMaterial.pypp.os] Error 1 > scons: building terminated because of errors. > > There is nothing in the examples on call_policies I haven't in my python script. > Am I missing something? Do you replace "include" files? Can you post NastranMaterial.pypp.cpp file? Thanks -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-12 10:53:38
|
Ok, my classes were all generated in a namespace called postLib. I've found it and replaced code by : def rename_in_namespace(mb, nameList): for namespaceName in nameList: nspace = mb.namespace('postLib').namespace(namespaceName, recursive=False) for clz in nspace.classes(): clz.rename(namespaceName.capitalize() + clz.name.capitalize()) This point is working now and I can see the light! I'll have to fully understand call_policies to finish wrapping the whole library. I'll read the docs again and again :) I open a new subject for the next little problem. Thans a lot! 2008/6/12, Roman Yakovenko <rom...@gm...>: > On Thu, Jun 12, 2008 at 11:11 AM, Vincent Ferries > <vin...@gm...> wrote: >> I'm renaming most of my classes to avoid them to override themselves >> like explained in an other subject. >> >> In order to achieve this I coded following functions which prefix the >> classes in python with their namespace names. >> >> >> rename_in_namespace(mb, ['nastran', 'samcef', 'generic', 'cla']) >> >> #Writing code to file. >> mb.split_module(settings.generated_files_dir) >> >> >> def rename_in_namespace(mb, nameList): >> for namespaceName in nameList: >> nspace = mb.global_ns.namespace(namespaceName) >> for clz in nspace.classes(): >> clz.rename(namespaceName.capitalize() + clz.name.capitalize()) >> >> >> >> There isn't apparently any way to get the name of the namespace the >> class is in, > > Did you read the code I posted? > clz.parent will give you reference to the parent scope. In your case > this will return reference to the namespace > > You also can use clz.decl_string, which will return full name ::X::Y::x > >> but it's not right here the problem, I know their names >> explicitely. > > It is up to you > >> When I try to generate the wrapper code, I'm encountering following errors >> : >> >> >> Traceback (most recent call last): >> File "generate_code.py", line 73, in ? >> export() >> File "generate_code.py", line 59, in export >> rename_in_namespace(mb, ['nastran', 'samcef', 'generic', 'cla']) >> File "generate_code.py", line 67, in rename_in_namespace >> nspace = mb.global_ns.namespace(namespaceName) >> File >> "/usr/lib/python2.4/site-packages/pygccxml/declarations/namespace.py", >> line 74, in namespace >> , recursive=recursive ) >> File >> "/usr/lib/python2.4/site-packages/pygccxml/declarations/scopedef.py", >> line 343, in _find_single >> found = matcher_module.matcher.get_single( matcher, decls, False ) >> File "/usr/lib/python2.4/site-packages/pygccxml/declarations/matcher.py", >> line 81, in get_single >> raise matcher.multiple_declarations_found_t( decl_matcher ) >> pygccxml.declarations.matcher.multiple_declarations_found_t: Multiple >> declarations has been found. matcher: [(decl type==namespace_t) and >> (name==nastran)] >> >> >> >> Even if the same namespace is defined many times, the delarations >> should complete themselves, not redefine each other right? > > Right, but this functionality is missing in Py++, but as you already > saw it is pretty easy to implement it in the user script. > >> Why do I have this error? > > Because you have multiple namespaces named "nastran". I think next > solution will work for you: > > mb = module_builder_t( ... ) > gns = mb.global_ns > > nastran = gns.namespace( "nastran", recursive=False ) > > This will search for namespace "nastran" under the global one. It will > not look under other namespaces. > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Vincent F. <vin...@gm...> - 2008-06-12 10:42:51
|
I added some different call_policies to wrap some functions. These functions where not fully wrapped due to missing informations on call_policies. I added the following call_policy : function.call_policies = call_policies.return_value_policy(call_policies.return_pointee_value) I encounter problems during compilation : wrappers/NastranMaterial.pypp.cpp: In function 'void register_NastranMaterial_class()': wrappers/NastranMaterial.pypp.cpp:179: error: 'pyplusplus' was not declared in this scope wrappers/NastranMaterial.pypp.cpp:179: error: template argument 1 is invalid scons: *** [wrappers/NastranMaterial.pypp.os] Error 1 scons: building terminated because of errors. There is nothing in the examples on call_policies I haven't in my python script. Am I missing something? |
From: Roman Y. <rom...@gm...> - 2008-06-12 09:12:48
|
On Thu, Jun 12, 2008 at 11:11 AM, Vincent Ferries <vin...@gm...> wrote: > I'm renaming most of my classes to avoid them to override themselves > like explained in an other subject. > > In order to achieve this I coded following functions which prefix the > classes in python with their namespace names. > > > rename_in_namespace(mb, ['nastran', 'samcef', 'generic', 'cla']) > > #Writing code to file. > mb.split_module(settings.generated_files_dir) > > > def rename_in_namespace(mb, nameList): > for namespaceName in nameList: > nspace = mb.global_ns.namespace(namespaceName) > for clz in nspace.classes(): > clz.rename(namespaceName.capitalize() + clz.name.capitalize()) > > > > There isn't apparently any way to get the name of the namespace the > class is in, Did you read the code I posted? clz.parent will give you reference to the parent scope. In your case this will return reference to the namespace You also can use clz.decl_string, which will return full name ::X::Y::x > but it's not right here the problem, I know their names > explicitely. It is up to you > When I try to generate the wrapper code, I'm encountering following errors : > > > Traceback (most recent call last): > File "generate_code.py", line 73, in ? > export() > File "generate_code.py", line 59, in export > rename_in_namespace(mb, ['nastran', 'samcef', 'generic', 'cla']) > File "generate_code.py", line 67, in rename_in_namespace > nspace = mb.global_ns.namespace(namespaceName) > File "/usr/lib/python2.4/site-packages/pygccxml/declarations/namespace.py", > line 74, in namespace > , recursive=recursive ) > File "/usr/lib/python2.4/site-packages/pygccxml/declarations/scopedef.py", > line 343, in _find_single > found = matcher_module.matcher.get_single( matcher, decls, False ) > File "/usr/lib/python2.4/site-packages/pygccxml/declarations/matcher.py", > line 81, in get_single > raise matcher.multiple_declarations_found_t( decl_matcher ) > pygccxml.declarations.matcher.multiple_declarations_found_t: Multiple > declarations has been found. matcher: [(decl type==namespace_t) and > (name==nastran)] > > > > Even if the same namespace is defined many times, the delarations > should complete themselves, not redefine each other right? Right, but this functionality is missing in Py++, but as you already saw it is pretty easy to implement it in the user script. > Why do I have this error? Because you have multiple namespaces named "nastran". I think next solution will work for you: mb = module_builder_t( ... ) gns = mb.global_ns nastran = gns.namespace( "nastran", recursive=False ) This will search for namespace "nastran" under the global one. It will not look under other namespaces. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-12 08:11:20
|
I'm renaming most of my classes to avoid them to override themselves like explained in an other subject. In order to achieve this I coded following functions which prefix the classes in python with their namespace names. rename_in_namespace(mb, ['nastran', 'samcef', 'generic', 'cla']) #Writing code to file. mb.split_module(settings.generated_files_dir) def rename_in_namespace(mb, nameList): for namespaceName in nameList: nspace = mb.global_ns.namespace(namespaceName) for clz in nspace.classes(): clz.rename(namespaceName.capitalize() + clz.name.capitalize()) There isn't apparently any way to get the name of the namespace the class is in, but it's not right here the problem, I know their names explicitely. When I try to generate the wrapper code, I'm encountering following errors : Traceback (most recent call last): File "generate_code.py", line 73, in ? export() File "generate_code.py", line 59, in export rename_in_namespace(mb, ['nastran', 'samcef', 'generic', 'cla']) File "generate_code.py", line 67, in rename_in_namespace nspace = mb.global_ns.namespace(namespaceName) File "/usr/lib/python2.4/site-packages/pygccxml/declarations/namespace.py", line 74, in namespace , recursive=recursive ) File "/usr/lib/python2.4/site-packages/pygccxml/declarations/scopedef.py", line 343, in _find_single found = matcher_module.matcher.get_single( matcher, decls, False ) File "/usr/lib/python2.4/site-packages/pygccxml/declarations/matcher.py", line 81, in get_single raise matcher.multiple_declarations_found_t( decl_matcher ) pygccxml.declarations.matcher.multiple_declarations_found_t: Multiple declarations has been found. matcher: [(decl type==namespace_t) and (name==nastran)] Even if the same namespace is defined many times, the delarations should complete themselves, not redefine each other right? Why do I have this error? |
From: Roman Y. <rom...@gm...> - 2008-06-11 10:49:49
|
On Wed, Jun 11, 2008 at 1:18 PM, Vincent Ferries <vin...@gm...> wrote: > It seems to work! Good. It could be nice if you can start other thread for different problem. > Now my problem is that many methods use std::vector types. > The compilation pass without problems but I don't know how to call my > functions... > It generates me a lot of files like > vector_less__std_scope_string__grate_ or > vector_less__std_scope_vector_less__int__grate__grate_ > I think these are the equivalent of the C++ definitions : > std::vector<std::string> and std::vector<std::vector<int>> converted > to file names. Yes it is. > But I don't know how to call them in my Python code or what I must do > in my generator code to be able to call them easily from python code. > (the problem is the same with maps, and yes, I've read all the > documentations on language-bindings site about this subject) These classes are not different from others. They have ugly name, but the usage is same. Take a look on Py++ unittests: http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp?revision=902&view=markup http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/indexing_suites2_tester.py?revision=1081&view=markup -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-11 10:18:08
|
It seems to work! Now my problem is that many methods use std::vector types. The compilation pass without problems but I don't know how to call my functions... It generates me a lot of files like vector_less__std_scope_string__grate_ or vector_less__std_scope_vector_less__int__grate__grate_ I think these are the equivalent of the C++ definitions : std::vector<std::string> and std::vector<std::vector<int>> converted to file names. But I don't know how to call them in my Python code or what I must do in my generator code to be able to call them easily from python code. (the problem is the same with maps, and yes, I've read all the documentations on language-bindings site about this subject) Thanks again and again! 2008/6/10, Roman Yakovenko <rom...@gm...>: > On Tue, Jun 10, 2008 at 6:21 PM, Vincent Ferries > <vin...@gm...> wrote: >> I'll try to be more precise. > > Now you are talking :-) > >> Py++ generate the file dataBase.pypp.cpp two times, one for the class >> ::postLib::generic::dataBase and another for the class >> ::postLib::nastran::dataBase for example. >> The second declaration remove the first one and I'm only able to call >> the second one. >> So, when I instanciate one class in my python code, I don't have >> access to the superclass methods, nore the other classes of the same >> name. The only one which is recognized is the last defined. >> >> This problem doesn't appear in C++ code cause they are in different >> namespaces. >> But in python, they are in the same module and the declarations in the >> wrapper have superposed, so that there is only one instead of two or >> more. >> >> The solutions I imagine are to generate many python modules or to >> rename the classes so that they doesn't destroy themselves. >> I could for example rename them NastranDataBase and GenericDataBase to >> be called in python code for example, or use generic.dataBase or >> nastran.dataBase in my python code (using modules). >> I remember I've seen class name redefinition somewhere in py++ but I'm >> searching for some hours and doesn't find it anymore... > > Here is solution for you: > > mb = module_builder_t() > > for cls in mb.classes(): > #find out all classes with the same name > other_classes = mb.classes( cls.name ) > other_classes = filter( lambda other_cls: not other_cls is cls ) > for other_cls in other_classes: > #use parent name to mangle the final name of the class > #You can implement any logic you want here > other_cls.rename( other_cls.parent.name + '_' + other_cls.name ) > > You also can do this for all classes - add namespace name to the class name. > > Another solution could be to create module per namespace + one module > that will contain common stuff. If you will decide to go with this > approach be sure to read this: > http://language-binding.net/pyplusplus/documentation/multi_module_development.html > > > HTH > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Gustavo C. <gjc...@gm...> - 2008-06-11 09:45:21
|
2008/6/10 Roman Yakovenko <rom...@gm...>: > On Mon, Jun 9, 2008 at 1:36 PM, Gustavo Carneiro <gjc...@gm...> > wrote: > > As seen in > > > > https://bugs.launchpad.net/bugs/238455 > > > > I am getting problems in PyBindGen related to differences in types like > > "char*" vs "char *", also the position of the 'const' keyword may change, > > etc. > > > > I am looking for some robust, pure python code to parse C types and > extract > > features from it, or produce a canonical type string, so that I can use > it > > PyBindGen. Does something like this exist in pygccxml > > No, but we can discuss such addition to pygccxml. I think this is a > nice & useful feature. > > > or elsewhere that I can steal? :-) > > May be from here: http://code.google.com/p/cppclean/wiki/InternalDesign Thanks for the link! This code looks nice, if excessive for what I want. Using and adapting this code to parse C types is now on my medium priority TODO list. If I get something useful out of it, I'll post here the result. Thanks, -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert |
From: Roman Y. <rom...@gm...> - 2008-06-10 15:37:20
|
On Tue, Jun 10, 2008 at 6:21 PM, Vincent Ferries <vin...@gm...> wrote: > I'll try to be more precise. Now you are talking :-) > Py++ generate the file dataBase.pypp.cpp two times, one for the class > ::postLib::generic::dataBase and another for the class > ::postLib::nastran::dataBase for example. > The second declaration remove the first one and I'm only able to call > the second one. > So, when I instanciate one class in my python code, I don't have > access to the superclass methods, nore the other classes of the same > name. The only one which is recognized is the last defined. > > This problem doesn't appear in C++ code cause they are in different namespaces. > But in python, they are in the same module and the declarations in the > wrapper have superposed, so that there is only one instead of two or > more. > > The solutions I imagine are to generate many python modules or to > rename the classes so that they doesn't destroy themselves. > I could for example rename them NastranDataBase and GenericDataBase to > be called in python code for example, or use generic.dataBase or > nastran.dataBase in my python code (using modules). > I remember I've seen class name redefinition somewhere in py++ but I'm > searching for some hours and doesn't find it anymore... Here is solution for you: mb = module_builder_t() for cls in mb.classes(): #find out all classes with the same name other_classes = mb.classes( cls.name ) other_classes = filter( lambda other_cls: not other_cls is cls ) for other_cls in other_classes: #use parent name to mangle the final name of the class #You can implement any logic you want here other_cls.rename( other_cls.parent.name + '_' + other_cls.name ) You also can do this for all classes - add namespace name to the class name. Another solution could be to create module per namespace + one module that will contain common stuff. If you will decide to go with this approach be sure to read this: http://language-binding.net/pyplusplus/documentation/multi_module_development.html HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-10 15:21:09
|
I'll try to be more precise. Py++ generate the file dataBase.pypp.cpp two times, one for the class ::postLib::generic::dataBase and another for the class ::postLib::nastran::dataBase for example. The second declaration remove the first one and I'm only able to call the second one. So, when I instanciate one class in my python code, I don't have access to the superclass methods, nore the other classes of the same name. The only one which is recognized is the last defined. This problem doesn't appear in C++ code cause they are in different namespaces. But in python, they are in the same module and the declarations in the wrapper have superposed, so that there is only one instead of two or more. The solutions I imagine are to generate many python modules or to rename the classes so that they doesn't destroy themselves. I could for example rename them NastranDataBase and GenericDataBase to be called in python code for example, or use generic.dataBase or nastran.dataBase in my python code (using modules). I remember I've seen class name redefinition somewhere in py++ but I'm searching for some hours and doesn't find it anymore... 2008/6/10, Roman Yakovenko <rom...@gm...>: > On Tue, Jun 10, 2008 at 4:11 PM, Vincent Ferries > <vin...@gm...> wrote: >> I finished compiling the whole project as a standalone library and >> include it compiling my own wrappers. >> I've a much more elaborated example working. >> >> My problem now is that some classes redefine other ones and have the same >> name. >> For example I have the 3 following classes : >> ::postLib::nastran::dataBase, postLib::generic::dataBase and >> ::postLib::samcef::dataBase. >> I got some errors saying that this name is allready defined and don't >> really know how to distinguish them in the project. >> >> Any idea or workaround would be appreciated? > > Sorry, the question is too general and it is not related to Py++ > functionality. > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Roman Y. <rom...@gm...> - 2008-06-10 13:42:02
|
On Tue, Jun 10, 2008 at 4:11 PM, Vincent Ferries <vin...@gm...> wrote: > I finished compiling the whole project as a standalone library and > include it compiling my own wrappers. > I've a much more elaborated example working. > > My problem now is that some classes redefine other ones and have the same name. > For example I have the 3 following classes : > ::postLib::nastran::dataBase, postLib::generic::dataBase and > ::postLib::samcef::dataBase. > I got some errors saying that this name is allready defined and don't > really know how to distinguish them in the project. > > Any idea or workaround would be appreciated? Sorry, the question is too general and it is not related to Py++ functionality. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Vincent F. <vin...@gm...> - 2008-06-10 13:11:11
|
I finished compiling the whole project as a standalone library and include it compiling my own wrappers. I've a much more elaborated example working. My problem now is that some classes redefine other ones and have the same name. For example I have the 3 following classes : ::postLib::nastran::dataBase, postLib::generic::dataBase and ::postLib::samcef::dataBase. I got some errors saying that this name is allready defined and don't really know how to distinguish them in the project. Any idea or workaround would be appreciated? Thanks again! 2008/6/10, Roman Yakovenko <rom...@gm...>: > On Tue, Jun 10, 2008 at 1:42 AM, Vincent Ferries > <vin...@gm...> wrote: >> >> >> 2008/6/9 Roman Yakovenko <rom...@gm...>: >>> >>> On Mon, Jun 9, 2008 at 6:35 PM, Vincent Ferries >>> <vin...@gm...> wrote: >>> > I now include my cpp code with the directive : >>> > mb.code_creator.add_include(myCorrespondingCppFile.cpp) >>> > >>> > Is this the right way to do it? >>> >>> No. I generally doesn't include cpp files. >>> >>> I think the problem is here(scons file): >>> >>> def get_py_ferespost_files(): >>> source_files = filter(lambda s: s.endswith('.cpp'), >>> os.listdir(settings.generated_files_dir)) >>> return map(lambda fname: os.path.join(settings.generated_files_dir, >>> fname), source_files) >> >> I currently use this method to generate the library from the generated >> source. >> >>> >>> If you generate code to a directory other than wrapped library code, >>> than the cpp files of the library ( forepost )is not included into the >>> build. Just update your scons. >> >> That's the case, but there are many folders (and subfolders) where the >> sources are. >> I don't know where I need to generate and how I can manage all the >> dependencies. > > This question is not related to Py++. I suggest you to read SCONS > documentation. > >>> >>> > And another question (yes, again...). >>> > The project I'm trying to wrap is quite complex and has a lot of >>> > cross-dependencies. >>> > (a file A including another file B which include A for example). >>> > I don't know how to déclare such dependencies using py++. >>> > Any help would be appreciated. >>> >>> What do you mean "to declare dependencies"? >> >> If I understand what you were saying, I can declare all the .h files into >> one same .h file and compile it to make the full library. >> >> Then, I have to compile all the .cpp sources and generated .cpp together >> to >> compile my .so file? > > No. You'd better compiler the project to standalone library and than > add it to the link line. > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |