Re: [pygccxml-development] More questions on the Ogre Binding
Brought to you by:
mbaas,
roman_yakovenko
|
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/
> > >
> >
>
|