Re: [pygccxml-development] Python Property Generation
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-06-18 06:47:16
|
On 6/18/06, Lakin Wecker <lak...@gm...> wrote: > Hi all, > > In working on my python-ogre bindings using pyplusplus, I wanted to > generate properties for the Ogre API. Roman had directed me towards > the custom code creators included with pyplusplus: > pygccxml/pyplusplus_dev/examples/custom_code_creator/generate_code.py > > The following code is heavily based on this example, however the Ogre > API is not quite as rigorous as the cpp-code used in the examples, so > it is also heavily modified: > > 1) Read Only properties are generated when there is no setter. > 2) The method type is also included in the generated cpp code to > distinguish between overloaded method names. > 3) Extra checking is done to ensure that the methods found are indeed > getters and setters. (Only one argument and void return type for > setters. No arguments and non-void return type for getter. The getter > return type and the setter argument type should match). > 4) In Ogre, there are some cases where a base class initially defines > the getter and setter, and the inheriting class overrides _only_ the > getter(See the Ogre::Frustum, Ogre::Camera classes for an example). > In this case, the above code was generating a read only property for > the inheriting class. I've enhanced the code to look at base classes > to complete the properties. IE, if there is no setter, an appropriate > setter is searched for (recursively) along the bases, the same is done > if there is no getter. > 5) In Ogre, pointers and references returned are always internal > references, and many of the properties return pointers and references. > If the getters return a reference or a pointer the call_policies are > set on the property. (this could be refactored to be more flexible). > > I made a best-effort to find the easiest way to do some of these > things using the provided API, but I may have missed items. So I'm > open to criticisms, or suggestions of how to improve the code by using > pygccxml/pyplusplus API's. Cool! I'd like to review the code, but it is very difficult, can you attach the file with the code or may be to update the web site? Thanks -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |