Thread: [pygccxml-development] Declarations order
Brought to you by:
mbaas,
roman_yakovenko
From: Daniele P. <mu...@gm...> - 2009-06-04 10:26:28
|
Hi to all, In my wrappers-generator program, I'm using the pygccxml declarations hierarchy to retrieve all declarations from a C library. Now I've some problems with the order of the declarations obtained from the header-parsing process. Supposing those two structures in the global namespace: typedef struct Foo { .... } Foo; typedef struct Bar { Foo *foo; ...... } Bar; I need to wrap the Foo structure first than Bar because the Foo type is used as a Bar's field type. The problem is that, when I iter among the pygccxml definitions (by example, among the ones returned by the mdecl_wrapper_t instance obtained by the "global_namespace.classes()" call) the definitions are often not sorted by declaration-order. The question is: do I need to order the declarations manually or there's some other easier way? Sorting the declarations of a small library it's not a big problem, but when I've to wrap libraries with thousand of declarations the situation changes... Thanks for any advice, Daniele |
From: Roman Y. <rom...@gm...> - 2009-06-07 06:14:43
|
On Thu, Jun 4, 2009 at 1:26 PM, Daniele Pianu<mu...@gm...> wrote: > Hi to all, > In my wrappers-generator program, I'm using the pygccxml declarations > hierarchy to retrieve all declarations from a C library. Now I've some > problems with the order of the declarations obtained from the > header-parsing process. Supposing those two structures in the global > namespace: > > typedef struct Foo > { > .... > } Foo; > > typedef struct Bar > { > Foo *foo; > ...... > } Bar; > > I need to wrap the Foo structure first than Bar because the Foo type > is used as a Bar's field type. The problem is that, when I iter among > the pygccxml definitions (by example, among the ones returned by the > mdecl_wrapper_t instance obtained by the "global_namespace.classes()" > call) the definitions are often not sorted by declaration-order. The > question is: do I need to order the declarations manually or there's > some other easier way? You will have to sort the declarations. > Sorting the declarations of a small library > it's not a big problem, but when I've to wrap libraries with thousand > of declarations the situation changes... Not really, at least this is not the functionality I saw in profilers. I needed the same functionality for my code generators ( Py++ and ctypes ), so I wrote few classes that sort classes: http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/pyplusplus/creators_factory/sort_algorithms.py?revision=1663&view=markup HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |