Re: [pygccxml-development] Utilizing typedef in code generated by Py++
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2007-05-10 17:54:37
|
On 5/10/07, Patrick Hartling <pa...@in...> wrote:
> I have run into a case where a typedef used for portability varies in the
> actual type in use. The type being defined is GLenum from OpenGL. On Linux
> and Windows, the underlying type for GLenum is unsigned int, but on Mac OS
> X, it is unsigned long. When Py++ generates the Boost.Python bindings code
> for functions that include GLenum in their signature, it uses the underlying
> type in the function signature typedef rather than GLenum. This results in
> compile failures when generating the code on Linux and trying to compile on
> Mac OS X (or vice versa).
>
> In trying to resolve this, I have come up with two questions:
>
> 1. Can Py++ generate code that uses typedefs instead of fully expanded
> types?
Right now it cannot, but it is possible to implement this feature.
Also you should understand that the user will have to say when Py++
should use a typedef or real type.
> 2. Is there a way to have a special case where GLenum can be used in the
> generated code and everything else can continue using fully expanded
> types?
Yes. There are so many ways to implement this in Py++. I don't know
the exact use case, so I will give you all possible solutions:
1. You can ask Py++ to generate your code instead of the default one:
http://www.language-binding.net/pyplusplus/documentation/inserting_code.html
Not the best one
2. Lets say you have function argument or member variable with such
fully expanded type and you want Py++ to generate typedef - you can
just replace the type of the variable:
from pygccxml import declarations
mb = module_builder_t( ... )
f = mb.member_function( 'f' )
#lets say that you want to replace second argument
f.arguments[1].type = declarations.dummy_type_t( 'GLenum' )
dummy_type_t documentation
http://www.language-binding.net/pygccxml/apidocs/pygccxml.declarations.cpptypes.dummy_type_t-class.html
If you give some concrete example, may be I will be able to provide
better answer.
> The second question came to mind because this currently affects only two
> .cpp files out of over 350 being generated by Py++.
:-) Be sure to read the first link I gave to the end. It is possible
to configure Py++ to generate code which will contain only bare
minimum of included files.
HTH
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|