Thread: [pygccxml-development] Re: typedef lookup feature from long ago...
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-05-31 04:14:18
|
On 5/31/06, Allen Bierbaum <al...@vr...> wrote: > Roman: > > Taking into account that you will be out of contact soon, there is one > feature I know I am going to need that I used in the old prototype API. > I must apologize that I don't remember the exact details, but what it > boiled down to was being able to lookup a full resolved type from a typedef. > > So if I had something like: > > typedef really_complex< nested<int>, ugly<long>, 56> simple_t; > > I would need to be able to look it up from simple_t to get the type > information. It is the mTypeDefMap inside the old pypp_api (it is still > in experimental). > > The code to look at is in parse() at the end: > > typedef_decls = declarations.make_flatten(parsed_decls) > typedef_decls = decls = filter( lambda x: (isinstance( x, > declarations.typedef_t ) and > not > x.name.startswith('__') and > x.location.file_name != > "<internal>") > , typedef_decls ) > > self.mTypeDefMap = {} > for d in typedef_decls: > type_def_name = d.name > full_name = declarations.full_name(d) > if full_name.startswith("::"): # Remove the base namespace > full_name = full_name[2:] > real_type_name = d.type.decl_string > if real_type_name.startswith("::"): # Remove base namespace > real_type_name = real_type_name[2:] > self.mTypeDefMap[full_name] = real_type_name > > > So my question is, do I have another "easy" way to do this with the > current API? Typedef class has 2 properties: name and type. I believe type is what you are looking for. > I probably won't need it until this weekend or the beginning of next > week, but if you are going to get busy I wanted to ask before you have > better things to do then answer e-mails from pesky people like me. :) :-) > -Allen > > -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Allen B. <al...@vr...> - 2006-06-19 22:10:39
|
Roman Yakovenko wrote: > On 5/31/06, Allen Bierbaum <al...@vr...> wrote: > >> Roman: >> >> Taking into account that you will be out of contact soon, there is one >> feature I know I am going to need that I used in the old prototype API. >> I must apologize that I don't remember the exact details, but what it >> boiled down to was being able to lookup a full resolved type from a >> typedef. >> >> So if I had something like: >> >> typedef really_complex< nested<int>, ugly<long>, 56> simple_t; >> >> I would need to be able to look it up from simple_t to get the type >> information. It is the mTypeDefMap inside the old pypp_api (it is still >> in experimental). >> >> The code to look at is in parse() at the end: >> >> typedef_decls = declarations.make_flatten(parsed_decls) >> typedef_decls = decls = filter( lambda x: (isinstance( x, >> declarations.typedef_t ) and >> not >> x.name.startswith('__') and >> x.location.file_name != >> "<internal>") >> , typedef_decls ) >> >> self.mTypeDefMap = {} >> for d in typedef_decls: >> type_def_name = d.name >> full_name = declarations.full_name(d) >> if full_name.startswith("::"): # Remove the base namespace >> full_name = full_name[2:] >> real_type_name = d.type.decl_string >> if real_type_name.startswith("::"): # Remove base namespace >> real_type_name = real_type_name[2:] >> self.mTypeDefMap[full_name] = real_type_name >> >> >> So my question is, do I have another "easy" way to do this with the >> current API? > > > Typedef class has 2 properties: name and type. I believe type is what > you are looking for. .type is the correct type, but it is not the decl_wrapper for the type that the typedef aliases. For example: typedef really_complex< nested<int>, ugly<long>, 56> simple_t; td = ns.typedef("simple_t") td is a pygccxml.declarations.cpptypes.declared_t and td.declaration is a pyplusplus.decl_wrapper.typedef_wrapper.typedef_t but what I want is the class_wrapper for "really_complex< nested<int>, ugly<long>, 56>". How do I get to this object? -Allen > >> I probably won't need it until this weekend or the beginning of next >> week, but if you are going to get busy I wanted to ask before you have >> better things to do then answer e-mails from pesky people like me. :) > > > :-) > >> -Allen >> >> > > |
From: Roman Y. <rom...@gm...> - 2006-06-20 04:27:34
|
On 6/20/06, Allen Bierbaum <al...@vr...> wrote: > Roman Yakovenko wrote: > > > On 5/31/06, Allen Bierbaum <al...@vr...> wrote: > > > >> Roman: > >> > >> Taking into account that you will be out of contact soon, there is one > >> feature I know I am going to need that I used in the old prototype API. > >> I must apologize that I don't remember the exact details, but what it > >> boiled down to was being able to lookup a full resolved type from a > >> typedef. > >> > >> So if I had something like: > >> > >> typedef really_complex< nested<int>, ugly<long>, 56> simple_t; > >> > >> I would need to be able to look it up from simple_t to get the type > >> information. It is the mTypeDefMap inside the old pypp_api (it is still > >> in experimental). > >> > >> The code to look at is in parse() at the end: > >> > >> typedef_decls = declarations.make_flatten(parsed_decls) > >> typedef_decls = decls = filter( lambda x: (isinstance( x, > >> declarations.typedef_t ) and > >> not > >> x.name.startswith('__') and > >> x.location.file_name != > >> "<internal>") > >> , typedef_decls ) > >> > >> self.mTypeDefMap = {} > >> for d in typedef_decls: > >> type_def_name = d.name > >> full_name = declarations.full_name(d) > >> if full_name.startswith("::"): # Remove the base namespace > >> full_name = full_name[2:] > >> real_type_name = d.type.decl_string > >> if real_type_name.startswith("::"): # Remove base namespace > >> real_type_name = real_type_name[2:] > >> self.mTypeDefMap[full_name] = real_type_name > >> > >> > >> So my question is, do I have another "easy" way to do this with the > >> current API? > > > > > > Typedef class has 2 properties: name and type. I believe type is what > > you are looking for. > > .type is the correct type, but it is not the decl_wrapper for the type > that the typedef aliases. > > For example: > > typedef really_complex< nested<int>, ugly<long>, 56> simple_t; > > td = ns.typedef("simple_t") > > td is a pygccxml.declarations.cpptypes.declared_t and > td.declaration is a pyplusplus.decl_wrapper.typedef_wrapper.typedef_t > but what I want is the class_wrapper for "really_complex< nested<int>, > ugly<long>, 56>". How do I get to this object? td.type.declaration ? May be it is a time to send me small script, so I will be able to provide you a solution. It seems to me that we have small misunderstanding > -Allen > > > > >> I probably won't need it until this weekend or the beginning of next > >> week, but if you are going to get busy I wanted to ask before you have > >> better things to do then answer e-mails from pesky people like me. :) > > > > > > :-) > > > >> -Allen > >> > >> > > > > > > -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Allen B. <al...@vr...> - 2006-06-20 16:39:27
|
Roman Yakovenko wrote: > [...] > >> >> .type is the correct type, but it is not the decl_wrapper for the type >> that the typedef aliases. >> >> For example: >> >> typedef really_complex< nested<int>, ugly<long>, 56> simple_t; >> >> td = ns.typedef("simple_t") >> >> td is a pygccxml.declarations.cpptypes.declared_t and >> td.declaration is a pyplusplus.decl_wrapper.typedef_wrapper.typedef_t >> but what I want is the class_wrapper for "really_complex< nested<int>, >> ugly<long>, 56>". How do I get to this object? > > > td.type.declaration ? > > May be it is a time to send me small script, so I will be able to > provide you a solution. > It seems to me that we have small misunderstanding I ended up having to do something like this: td.type.declaration.type.declaration Once I get done with the binding generation I can point you at the script I am using so you can see what I have to do to get to this type information. -Allen > >> -Allen >> >> > >> >> I probably won't need it until this weekend or the beginning of next >> >> week, but if you are going to get busy I wanted to ask before you >> have >> >> better things to do then answer e-mails from pesky people like me. :) >> > >> > >> > :-) >> > >> >> -Allen >> >> >> >> >> > >> > >> >> > > |
From: Roman Y. <rom...@gm...> - 2006-06-20 21:17:50
|
On 6/20/06, Allen Bierbaum <al...@vr...> wrote: > I ended up having to do something like this: > > td.type.declaration.type.declaration If I understand you right: you have typedef to other typedef right? In this case you can use function remove_alias. > Once I get done with the binding generation I can point you at the > script I am using so you can see what I have to do to get to this type > information. > -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |