Wrapped class definitions for use in C++ code


28-04-2008 19:39:45


I'm working on adapting some pre-existing C++ libraries for Ogre to work with PythonOgre (which is *great*), and am running into some trouble.

Our project is using 1.2RC1 successfully. I've got everything wrapped up manually with Boost Python because the calls are very simple, and have been able to test parts. But I need to pass references to a few Ogre objects in to C++ from Python.

To do this, it looks like I need to be able to at least generate the Py++ wrapper classes using the current source distribution so that I can use those class definitions (e.g., TextureManager_wrapper) as arguments in my C++ code...

But I am having a heck of a time getting code generation to work on Windows. Successfully (I think) installed pygccxml, pyplusplus, etc. Retrieved source from SVN. Edited PythonOgreConfig_nt.py to find boost, and so on..

Lots of errors running code_generators/ogre/generate_code.py - mostly seeming to relate to some incorrect mixture of compiler settings or gcc vs msvc?

"ogre-win32-v1-4-6/ogrenew/OgreMain/include/OgreSharedPtr.h:130: error: invalid
conversion from `void*' to `const char*' "

Two quick questions:

- Is there a source snapshot of generated code for 1.2RC1? I think this would get me over this issue quickly if I could compile against its wrapper declarations... I could only find 1.1

- Any hints or more detailed instructions on the code generation step on Windows? Do we need to be super careful about versions? I have tried boost_1_34_1 and boost_1_35_0, and gccxml-0.6.0... Are there defines to make sure to set manually?

Any help would be appreciated! Thanks much!


29-04-2008 19:01:49

You are going about this the wrong way I think. You should not need to have access to the generated wrapper at all. As long as you build your custom wrapper against the same Boost.Python that Python-Ogre is built against, the conversion should just happen. You *do not* need to use the types generated by Py++.


29-04-2008 19:23:25

Thanks for the reply. Ok - that's what I thought, and I will try again, but I had tried that the first time and couldn't for the life of me get the texturemanager reference to pass into the C++ code without a signature error.

I tried different variants, that were basically like this:

void myfunc(Ogre::TextureManager& tm)
void myfunc(const Ogre::TextureManager& tm)
void myfunc(const Ogre::TextureManager* tm) (or a sharedptr)

>>> tm = Ogre.TextureManager.getSingleton()
>>> myfunc(tm)

And got a C++ signature mismatch error.

Perhaps I'm doing something else wrong in a very basic way?



29-04-2008 19:24:25

one of those prototypes had a typo... should have been

void myfunc(Ogre::TextureManager* tm) (or a sharedptr)