Re: [pygccxml-development] Py++ typedef handling
Brought to you by:
mbaas,
roman_yakovenko
From: Patrick H. <pat...@pr...> - 2009-04-23 23:03:19
|
On Apr 23, 2009, at 1:03 PM, Roman Yakovenko wrote: > 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. Is such an approach necessary, though? Since the type information identified by GCC-XML is the typedef, doesn't that mean that pygccxml or Py++ is "drilling down" to the un-aliased type in some cases? >> 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 used the alias property in some cases. Does it apply to what I posted, though? If so, then I am not seeing the full extent of what opportunities exist for operating on Py++ objects. For example, how can the alias property be used to alter the type casting done for keyword argument values? >> 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. I cannot make any promises, and it depends on how my work hours are allocated. I would like to see this addressed, though, and maybe I can make a case for devoting time to it. >> 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. That pointer is helpful. It set me on a course where I have already resolved several of our most frustrating issues. I have attached a small patch against the SVN trunk that makes a significant difference in generating more portable code--at least in our case. I have not yet run this change through the test suite (as I still have to learn how to run the test suite). -Patrick -- Patrick L. Hartling Senior Software Engineer, Priority 5 http://www.priority5.com/ The information transmitted in this communication is intended only for the person or entity to which it is addressed and contains proprietary material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please destroy any copies, contact the sender and delete the material from any computer. |