Hello, I stumbled into this seemingly stupid problem, but don't know a way out. I have got pretty much everything working in my setup, except for the fact that the wrapper file is 50k lines big and cl.exe crashes after some minutes compiling it. I read the Best Practices article and started to include caching, and finally split_module into my generator. Now the creation fails because of filename length. 'vector_less_std_scope_vector_less_unsigned_short_comma__std_scope_allocator _less_unsigned_short_grate___grate__comma__std_scope_allocator_less_std _scope_vector_less_unsigned_short_comma__std_scope_allocator_less_ unsigned_short_grate___grate___grate___grate_.pypp.hpp' is a 266 characters filename, and it is one of the rather short. It's just a vector<vector<unsigned short> > > . I have a ton of more nested containers, and cannot manually alias them all. Then, I tried to make a typedef vector<vector<unsigned short> > > vector_vector_ushort; but this changed nothing for me. So it may once again be proof of my ignorance, but could you point me in the right direction? It'd be eternally grateful :) N.
On 11/20/06, Nicolas Tessore <Tessore@stud.uni-heidelberg.de> wrote:
Now the creation fails because of filename length. ... I have a ton of more nested containers, and cannot manually alias them all.
The solution is to create some function that will create an alias from an instantiation of std container. Obviously Py++ does if for you, but the names it creates are very long and ugly. You can do something better. Take a look on container traits classes: http://tinyurl.com/yeezdc . These classes will help you to extract value_type( mapped_type ) from the container. ( source code: http://tinyurl.com/yeco7e ) Use pygccxml.declaration.all_container_traits variable. It defines a list of all container traits classes Now the code is pretty trivial: def find_out_container_traits( cls ): for ct in pygccxml.declaration.all_container_traits: if ct.is_my_case( cls ): return ct else: return None def mangle( cls, ct ): element_type = ct.element_type( cls ) cls.rename( .... ) mb = module_builder_t( ... ) for cls in mb.classes(): ct = find_out_container_traits( cls ) if ct: mangle( cls, ct ) This should work.
Then, I tried to make a
typedef vector<vector<unsigned short> > > vector_vector_ushort;
but this changed nothing for me.
I think that the reason is that too many different typedefs for the instantiation
So it may once again be proof of my ignorance, but could you point me in the right direction?
Is this the right direction? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
Thanks a lot: pygccxml.declaration.all_container_traits was exactly what I had been looking for. (I should get used to "container" for templated types.) Thanks again! N.
On 11/20/06, Nicolas Tessore <wz_@gmx.net> wrote:
Thanks a lot:
pygccxml.declaration.all_container_traits
was exactly what I had been looking for.
(I should get used to "container" for templated types.)
It seems to me that you are surprised by the terminology I use, am I right? If so can you explain why? I'll be glad to fix it. Thanks. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
Roman Yakovenko, 20.11.2006 19:26
On 11/20/06, Nicolas Tessore <wz_@gmx.net> wrote:
Thanks a lot:
pygccxml.declaration.all_container_traits
was exactly what I had been looking for.
(I should get used to "container" for templated types.)
It seems to me that you are surprised by the terminology I use, am I right? If so can you explain why? I'll be glad to fix it.
Thanks.
No, I was just too narrow-minded to search for the obvious phrase "container". My bad! N.
On 11/20/06, Nicolas Tessore <wz_@gmx.net> wrote:
Roman Yakovenko, 20.11.2006 19:26
On 11/20/06, Nicolas Tessore <wz_@gmx.net> wrote:
Thanks a lot:
pygccxml.declaration.all_container_traits
was exactly what I had been looking for.
(I should get used to "container" for templated types.)
It seems to me that you are surprised by the terminology I use, am I right? If so can you explain why? I'll be glad to fix it.
Thanks.
No, I was just too narrow-minded to search for the obvious phrase "container". My bad!
I could be wrong, but std uses "containers" terminology. .NET for example uses "collection" word. So, I thought it should be clear what I mean. It has nothing to do with templates. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
Roman Yakovenko, 20.11.2006 19:56
I could be wrong, but std uses "containers" terminology. .NET for example uses "collection" word. So, I thought it should be clear what I mean. It has nothing to do with templates.
Of course, you are right. I just failed to realize the above. Anyway, there is still a problem with the new approach: I extended it to all templates, and failed, somehow, neither the container approach nor the templates.is_instantiation method seems to be able to catch the map<T> type (and list<T> as well, I think): ------------------------------------------------------------------------ # Function to rename the STL containers def rename_containers( cls ): class_trait = None // check there are really some map containers if cls.name.startswith("map"): print cls.name for ct in declarations.all_container_traits: if ct.is_my_case( cls ): class_trait = ct if not (class_trait or declarations.templates.is_instantiation(cls.decl_string)): return // no map container ever makes it here - vector does! print cls.name cls.rename(TemplateAlias(cls.decl_string)) ... # Rename the container types classes = mb.classes() map( rename_containers, classes ) ------------------------------------------------------------------------ From what I understand, the declarations.templates.is_instantiation(cls.decl_string) line alone should be able to catch whatever template type I run into. What am I missing this time? N.
On 11/21/06, Nicolas Tessore <Tessore@stud.uni-heidelberg.de> wrote:
Roman Yakovenko, 20.11.2006 19:56
I could be wrong, but std uses "containers" terminology. .NET for example uses "collection" word. So, I thought it should be clear what I mean. It has nothing to do with templates.
Of course, you are right. I just failed to realize the above.
Anyway, there is still a problem with the new approach: I extended it to all templates, and failed, somehow, neither the container approach nor the templates.is_instantiation method seems to be able to catch the map<T> type (and list<T> as well, I think):
Strange, this test ( http://tinyurl.com/y2a5g6 ) shows that it does work for map and vector ( not list, but still it is not too different )
------------------------------------------------------------------------
# Function to rename the STL containers def rename_containers( cls ): class_trait = None
// check there are really some map containers if cls.name.startswith("map"): print cls.name
for ct in declarations.all_container_traits: if ct.is_my_case( cls ): class_trait = ct
if not (class_trait or declarations.templates.is_instantiation(cls.decl_string)): return
// no map container ever makes it here - vector does! print cls.name cls.rename(TemplateAlias(cls.decl_string))
...
# Rename the container types classes = mb.classes() map( rename_containers, classes )
------------------------------------------------------------------------
From what I understand, the declarations.templates.is_instantiation(cls.decl_string) line alone should be able to catch whatever template type I run into.
Don't use "cls.decl_string" but cls.name. pygccxml implements small and naive parser for C++ templates. It works most of the time. It does not able to parser string like x::y::z< a, b, c >, but z< a, b, c >. P.S. If it does not help, can you come up with small test case that reproduce the problem? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
Roman Yakovenko, 21.11.2006 07:33
Strange, this test ( http://tinyurl.com/y2a5g6 ) shows that it does work for map and vector ( not list, but still it is not too different )
I also cannot see why it should not be working for me!
Don't use "cls.decl_string" but cls.name. pygccxml implements small and naive parser for C++ templates. It works most of the time. It does not able to parser string like x::y::z< a, b, c >, but z< a, b, c >.
I found that both .name and .decl_string don't have the initial scope, and both don't work for me.
P.S. If it does not help, can you come up with small test case that reproduce the problem?
That's the most absurd thing of it all: I tryed if not declarations.templates.is_instantiation(cls.name): print cls.name and then copied the output string, and manually tried it with print declarations.templates.is_instantiation("map<... >") which would always show as True. I'm confused, seems like I have to catch the maps manually with a cls.name.startswith("map") or something alike. N.
On 11/23/06, Nicolas Tessore <Tessore@stud.uni-heidelberg.de> wrote:
Roman Yakovenko, 21.11.2006 07:33
Strange, this test ( http://tinyurl.com/y2a5g6 ) shows that it does work for map and vector ( not list, but still it is not too different )
I also cannot see why it should not be working for me!
Don't use "cls.decl_string" but cls.name. pygccxml implements small and naive parser for C++ templates. It works most of the time. It does not able to parser string like x::y::z< a, b, c >, but z< a, b, c >.
I found that both .name and .decl_string don't have the initial scope, and both don't work for me.
P.S. If it does not help, can you come up with small test case that reproduce the problem?
That's the most absurd thing of it all: I tryed
if not declarations.templates.is_instantiation(cls.name): print cls.name
and then copied the output string, and manually tried it with
print declarations.templates.is_instantiation("map<... >")
which would always show as True.
I'm confused, seems like I have to catch the maps manually with a cls.name.startswith("map") or something alike.
Wait a little. Can you send me privately zipped GCC-XML generated file and small script that shows your problem? I'd like to understand the problem. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
participants (3)
-
Nicolas Tessore -
Nicolas Tessore -
Roman Yakovenko