Re: [pygccxml-development] Py++ typedef handling
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2009-04-23 18:04:16
|
On Thu, Apr 23, 2009 at 8:01 PM, Patrick Hartling <pat...@pr...> wrote: > I have asked a couple of questions about typedef handling in the past, and I > have yet another one: is there anything that I can do to force Py++ to use > the typedefs from the original code in function default argument values and > in instance method return types? I guess, it is possible to attach "pretty name" to a type and use it for code generation, but this is a huge change. > What I see is that the typedef gets used in > some places but not others. I haven't identified a pattern to this yet, but > I am sure that there is one. Yes: http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py?revision=1664&view=markup Take a look on "_get_alias" method. > I have attached code that demonstrates the behavior that I see. test.cpp was > generated on Windows using Py++ 1.0 and GCC-XML (emulating Visual C++ 9.0) > built from its CVS repository as of April 21, 2009. I have added comments to > the generated test.cpp where I see unexpected behavior. From looking at the > output generated by GCC-XML, I think I understand how the typedef > information used in template parameters gets lost, and that is unfortunate. > Maybe there is some room to improve GCC-XML in this area. It is very difficult. A year or two ago I tried to add something similar to GCCXML ad got lost in GCC code. May be you will have more luck. > In case it matters, the use of 64-bit integers in the example is deliberate. > Our code uses 64-bit types, and we use typedefs to mask the variation in the > type declaration depending on operating system and bit width of the binary > output. 64-bit integers are not the only type that has caused us problems, > but this is the one that crops up most consistently. You can do few tricks, before Py++ starts working: * rename classes and types * construct new types and typedefs It is not a nice way. If your code has some coding convention or other rules you can rely on, it should not be too difficult. Take a look on http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py?revision=1428&view=markup file. It contains code that does exactly this. Let me know if you need more help. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |