Thread: [pygccxml-development] More questions on the Ogre Binding
Brought to you by:
mbaas,
roman_yakovenko
From: Lakin W. <lak...@gm...> - 2006-05-29 02:49:10
|
Hi list, This question is probably more for Roman, than the list directly, but I'm sending it to the list for archival purposes. First off, I'm using revision 178. And I've uploaded the scripts I'm using to: http://lakin.weckers.net/ogre/ generate_code.py doesn't show any errors, but trying to compile the resulting code results in an error of: for both Vector3.pypp.cpp, and Quaternion.pypp.cpp for the line which looks similar to: .def_readonly( "", &Ogre::Vector3 ) Commenting this out allows the build to continue, but Matrix4.pypp.cpp errors with: g++ `pkg-config --cflags OGRE` -I/usr/include/python2.4 -fPIC -Icpp -c -o cpp/Matrix4.pypp.os cpp/Matrix4.pypp.cpp cpp/Matrix4.pypp.cpp: In function 'void register_Matrix4_class()': cpp/Matrix4.pypp.cpp:12: error: wrong number of template arguments (16, should be 15) /usr/include/boost/python/init.hpp:58: error: provided for 'template<class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14> class boost::python::init' scons: *** [cpp/Matrix4.pypp.os] Error 1 Boost comes with a default limit of 15 for the arity of the init stuff, and this should be fixed by using a -DBOOST_PYTHON_MAX_ARITY=16 , but this results in the error given in : http://lakin.weckers.net/ogre/Scons.log Which, for the life of me, I can't solve. Lakin |
From: Roman Y. <rom...@gm...> - 2006-05-29 05:02:33
|
On 5/29/06, Lakin Wecker <lak...@gm...> wrote: > Hi list, > > This question is probably more for Roman, than the list directly, but > I'm sending it to the list for archival purposes. > > First off, I'm using revision 178. And I've uploaded the scripts > I'm using to: > http://lakin.weckers.net/ogre/ > > generate_code.py doesn't show any errors, but trying to compile the > resulting code results in an error of: > > for both Vector3.pypp.cpp, and Quaternion.pypp.cpp for the line which > looks similar to: > > .def_readonly( "", &Ogre::Vector3 ) Fixed, committed. The problem was unnamed member variable within Vector3 cl= ass. For the time being, those variables will not be exported to Python. Solutio= n: mb =3D module_builder_t(...) Vector3 =3D mb.class_( "Vector3" ) Vector3.add_code( 'add_property( "x", &Ogre::Vector3::x)' ) Or something like this. I did not test the code. --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Lakin W. <lak...@gm...> - 2006-05-29 17:35:10
|
Gah! I really need to remember to reply-all .... Sorry roman, and the list. Lakin ---------- Forwarded message ---------- From: Lakin Wecker <lak...@gm...> Date: May 29, 2006 11:34 AM Subject: Re: [pygccxml-development] More questions on the Ogre Binding To: Roman Yakovenko <rom...@gm...> On 5/28/06, Roman Yakovenko <rom...@gm...> wrote: > On 5/29/06, Lakin Wecker <lak...@gm...> wrote: > For the time being, those variables will not be exported to Python. Solut= ion: > > mb =3D module_builder_t(...) > Vector3 =3D mb.class_( "Vector3" ) > Vector3.add_code( 'add_property( "x", &Ogre::Vector3::x)' ) Yeah, something like that will work, but it would be better if py++ would export these variables automatically. Are you planning on fixing this? (If so, then the rest of this letter is not necessary.) I looked at the code causing the problem, and it's all code similar to: class Foo{ union { struct { float r,g,b,a; }; float val[4]; }; }; So (if my understanding is correct), the union is unnamed, but the union's members can be access through Foo::r, Foo::g, Foo::b, Foo::a, and Foo::val. It would be awesome if py++ exported these appropriately. Lakin |
From: Roman Y. <rom...@gm...> - 2006-05-29 18:13:18
|
On 5/29/06, Lakin Wecker <lak...@gm...> wrote: > Yeah, something like that will work, but it would be better if py++ > would export these variables automatically. Are you planning on > fixing this? (If so, then the rest of this letter is not necessary.) > > I looked at the code causing the problem, and it's all code similar to: > > class Foo{ > union { > struct { > float r,g,b,a; > }; > float val[4]; > }; > }; > > So (if my understanding is correct), the union is unnamed, but the > union's members can be access through Foo::r, Foo::g, Foo::b, Foo::a, > and Foo::val. > > It would be awesome if py++ exported these appropriately. I will add this feature, but not in a week or two. I could be wrong, but there are 4 or 5 places, where ogre uses such constructs. mb =3D module_builder_t(...) ogre =3D mb.namespace( 'ogre' ) print len( ogre.classes( '' ) ) / 2 for unnamed_cls in ogre.classes( '' ): named_parent =3D unnamed.parent if not named_parent.name: named_parent =3D named_parent.parent for mvar in named_paret.member_variables(): named_parent.add_code( 'add_property( "%(mvar)s", &Ogre::Vector3::%(mvar)s)" % dict( mvar=3Dmvar.name ) ) ) May be the previous code needs to be fixed, but I think you've got the idea= . I work on preparing source code to release. This means: source code is open for bug fixes + documentation. I have to do it, otherwise my project will never have documentation :-(. --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Lakin W. <lak...@gm...> - 2006-05-29 19:31:30
|
On 5/29/06, Roman Yakovenko <rom...@gm...> wrote: > > I will add this feature, but not in a week or two. Cool. > I could be wrong, but there are > 4 or 5 places, where ogre uses such constructs. You're right, and the following approach will be sufficient for the time being. Lakin > mb =3D module_builder_t(...) > ogre =3D mb.namespace( 'ogre' ) > print len( ogre.classes( '' ) ) / 2 > > for unnamed_cls in ogre.classes( '' ): > named_parent =3D unnamed.parent > if not named_parent.name: > named_parent =3D named_parent.parent > for mvar in named_paret.member_variables(): > named_parent.add_code( > 'add_property( "%(mvar)s", &Ogre::Vector3::%(mvar)s)" > % dict( mvar=3Dmvar.name ) ) ) > > May be the previous code needs to be fixed, but I think you've got the id= ea. > > I work on preparing source code to release. This means: source code is op= en > for bug fixes + documentation. I have to do it, otherwise my project will > never have documentation :-(. > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > |
From: Lakin W. <lak...@gm...> - 2006-05-29 20:08:36
|
Thanks roman, that approach worked. For archival purposes, the final code that I used is: def fix_unnamed_classes (mb): ogre_ns =3D mb.namespace ('Ogre') print len (ogre_ns.classes ('')) / 2 for unnamed_cls in ogre_ns.classes( '' ): named_parent =3D unnamed_cls.parent if not named_parent.name: named_parent =3D named_parent.parent for mvar in unnamed_cls.public_members: if not mvar.name: continue named_parent.add_code( 'add_property( "%(mvar)s", &Ogre::Vector3::%(mvar)s)' \ % dict( mvar=3Dmvar.name ) ) The only strange part is that some of the names in unnamed_cls.public_members are blank themselves, so I had to filter them out as well. Lakin On 5/29/06, Lakin Wecker <lak...@gm...> wrote: > On 5/29/06, Roman Yakovenko <rom...@gm...> wrote: > > > > I will add this feature, but not in a week or two. > > Cool. > > > I could be wrong, but there are > > 4 or 5 places, where ogre uses such constructs. > > You're right, and the following approach will be sufficient for the > time being. > > Lakin > > > mb =3D module_builder_t(...) > > ogre =3D mb.namespace( 'ogre' ) > > print len( ogre.classes( '' ) ) / 2 > > > > for unnamed_cls in ogre.classes( '' ): > > named_parent =3D unnamed.parent > > if not named_parent.name: > > named_parent =3D named_parent.parent > > for mvar in named_paret.member_variables(): > > named_parent.add_code( > > 'add_property( "%(mvar)s", &Ogre::Vector3::%(mvar)s)" > > % dict( mvar=3Dmvar.name ) ) ) > > > > May be the previous code needs to be fixed, but I think you've got the = idea. > > > > I work on preparing source code to release. This means: source code is = open > > for bug fixes + documentation. I have to do it, otherwise my project wi= ll > > never have documentation :-(. > > > > -- > > Roman Yakovenko > > C++ Python language binding > > http://www.language-binding.net/ > > > |
From: Lakin W. <lak...@gm...> - 2006-05-29 21:52:58
|
Well, if I hadn't made a typo, that approach would have worked. Fortunately for me, the compiler reminded me that all of these members aren't in the Ogre::Vector3 namespace, but rather in the Ogre::%(parent_name)s namespace. The updated code (which actually works and produces code that compiles) looks like: def fix_unnamed_classes (mb): ogre_ns =3D mb.namespace ('Ogre') print len (ogre_ns.classes ('')) / 2 for unnamed_cls in ogre_ns.classes( '' ): named_parent =3D unnamed_cls.parent if not named_parent.name: named_parent =3D named_parent.parent for mvar in unnamed_cls.public_members: if not mvar.name: continue named_parent.add_code( 'add_property( "%(mvar)s", &Ogre::%(parent)s::%(mvar)s)' \ % dict( mvar=3Dmvar.name, parent=3Dnamed_parent.name ) ) Lakin On 5/29/06, Lakin Wecker <lak...@gm...> wrote: > Thanks roman, that approach worked. For archival purposes, the final > code that I used is: > > def fix_unnamed_classes (mb): > ogre_ns =3D mb.namespace ('Ogre') > print len (ogre_ns.classes ('')) / 2 > > for unnamed_cls in ogre_ns.classes( '' ): > named_parent =3D unnamed_cls.parent > if not named_parent.name: > named_parent =3D named_parent.parent > > for mvar in unnamed_cls.public_members: > if not mvar.name: > continue > named_parent.add_code( > 'add_property( "%(mvar)s", &Ogre::Vector3::%(mvar)s)' \ > % dict( mvar=3Dmvar.name ) ) > > The only strange part is that some of the names in > unnamed_cls.public_members are blank themselves, so I had to filter > them out as well. > > Lakin > > On 5/29/06, Lakin Wecker <lak...@gm...> wrote: > > On 5/29/06, Roman Yakovenko <rom...@gm...> wrote: > > > > > > I will add this feature, but not in a week or two. > > > > Cool. > > > > > I could be wrong, but there are > > > 4 or 5 places, where ogre uses such constructs. > > > > You're right, and the following approach will be sufficient for the > > time being. > > > > Lakin > > > > > mb =3D module_builder_t(...) > > > ogre =3D mb.namespace( 'ogre' ) > > > print len( ogre.classes( '' ) ) / 2 > > > > > > for unnamed_cls in ogre.classes( '' ): > > > named_parent =3D unnamed.parent > > > if not named_parent.name: > > > named_parent =3D named_parent.parent > > > for mvar in named_paret.member_variables(): > > > named_parent.add_code( > > > 'add_property( "%(mvar)s", &Ogre::Vector3::%(mvar)s)" > > > % dict( mvar=3Dmvar.name ) ) ) > > > > > > May be the previous code needs to be fixed, but I think you've got th= e idea. > > > > > > I work on preparing source code to release. This means: source code i= s open > > > for bug fixes + documentation. I have to do it, otherwise my project = will > > > never have documentation :-(. > > > > > > -- > > > Roman Yakovenko > > > C++ Python language binding > > > http://www.language-binding.net/ > > > > > > |
From: Roman Y. <rom...@gm...> - 2006-05-30 04:56:35
|
On 5/30/06, Lakin Wecker <lak...@gm...> wrote: > Well, if I hadn't made a typo, that approach would have worked. > Fortunately for me, the compiler reminded me that all of these members > aren't in the Ogre::Vector3 namespace, but rather in the > Ogre::%(parent_name)s namespace. > The updated code (which actually works and produces code that > compiles) looks like: > > def fix_unnamed_classes (mb): > ogre_ns = mb.namespace ('Ogre') > print len (ogre_ns.classes ('')) / 2 > > for unnamed_cls in ogre_ns.classes( '' ): > named_parent = unnamed_cls.parent > if not named_parent.name: > named_parent = named_parent.parent > > for mvar in unnamed_cls.public_members: > if not mvar.name: > continue > named_parent.add_code( > 'add_property( "%(mvar)s", &Ogre::%(parent)s::%(mvar)s)' \ > % dict( mvar=mvar.name, > parent=named_parent.name ) ) Thank you! -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |