Re: [pygccxml-development] Py++ typedef handling
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2009-04-28 05:58:28
|
On Fri, Apr 24, 2009 at 2:03 AM, Patrick Hartling <pat...@pr...> wrote: >> 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? Yes it does. And you know, may be you are right. May be it will be enough to "fix" those places. >>> 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 was thinking about using that alias, when I format function arguments. For example: #ifdef os64: typedef std::vector< int64 > numbers_t; #else typedef std::vector< int32 > numbers_t; #endif void do_smth( numbers_t& ); I think, today, Py++ will generate do_smth with std::vector, which contains int64 or int32. Finding out, that std::vector< int[32|64] > class has alias and using it can improve the generated code. Obviously, your patch produce the same result and it is much better than my idea. I need to check\verify my ideas before I raise them and may be to sleep a little bit more :-) >> 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. Good luck. GCC code is not the easiest code to read and understand. >> 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). I committed the patch. Thank you. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |