Re: [pygccxml-development] Two problems
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-06-01 17:56:43
|
On 6/1/06, Lakin Wecker <lak...@gm...> wrote: > I'll look into adding the same functions to Matrix4. I'm sure Ogre > will accept the patch. However, in the mean time I can avoid those > functions ... boost.python has nice feature. It allows you to expose free function as a class method. class Matrix4{...}; Vector4 get_column( Matrix4& m, int i ){...} If you expose both declaration, then from Python you can write: import Ogre Ogre.Matrix4.GetColumn = Ogre.get_column Every user of Matrix4 in Python will not note the difference. You can take a look on pyplusplus_dev/examples/boost_dev rational example. I use this trick there > In the end I'd like to have a more pythonic way of accessing > Matrix{4|3}, Vector{4|3|2}, Quaternion, and ColourValue .... > basically by interchanging python lists/tuples etc. I thought about this. There are few ways to achieve the result. The idea is simple: Every time function takes as argument M[3|4] or V[2|3|4] It should able to take list or tuple. So you will need to write code that converts. You can choose, where to write the code in C++ or in Python. The C++ version will be a little faster, but it is much convenient to develop the functionality in Python. In Python there are 2 ways to implement what you want: 1. Simple approach: every relevant function should be redefined in Python and implements conversion. 2. Another idea is to use decorators. In Israel, at Python user group meeting, somebody solve problem similar to our using generators. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |