Navigate from ClassInfo to TypeInfo
Daniel Keep
daniel.keep.lists at gmail.com
Tue Apr 14 23:52:17 PDT 2009
Frank Benoit wrote:
> Daniel Keep schrieb:
>> Ok. What do you propose to do with this TypeInfo?
>>
>> The ONLY thing a given TypeInfo_Class gives you is the ClassInfo, which
>> you already have. The TypeInfo object itself gives you getHash, equals
>> and compare, all of which are in Object and thus redundant, tsize which
>> is the size of a pointer, swap which I can't see a use for, next which
>> is useless, init which is also redundant and flags which is already in
>> ClassInfo.
>>
>> Again, why do you even want that specific TypeInfo when it is less
>> useful than the ClassInfo?
>>
>> -- Daniel
>
> I need to have a "something" to retrieve and pass around to hold all
> available information about a type. Including classes, interfaces and
> primitives.
> Because of ClassInfo cannot have information about primitives, I need to
> work with TypeInfo.
> Because of I have that need to retrieve that "something" from any object
> reference also, i need a way from classinfo to typeinfo.
>
I remember having to do something similar once. I think I solved it by
carrying around these:
> struct ExTypeInfo
> {
> TypeInfo ti;
> ClassInfo ci;
> }
That, or you could store them as Objects, and then use upcasts to work
out which it is.
> if( auto ti = cast(TypeInfo) info )
> // It's a general type info
>
> else if( auto ci = cast(ClassInfo) info )
> // It's a class
>
> else
> assert(false);
-- Daniel
More information about the Digitalmars-d
mailing list