Re: [pygccxml-development] typedef lookup feature from long ago...
Brought to you by:
mbaas,
roman_yakovenko
|
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
>>
>>
>
>
|