Stefan Seefeld wrote:
> hi there,
>
> I'm still struggling with the internal APIs as I'm
> trying to make them more type-safe and const-correct.
>
> Here are some specific questions:
>
> What's the semantics (goal in general, invariants, etc.)
> of the following methods:
Below is what I managed to figure out quickly. Please verify. If
anything does not make sense, let me know. If it does, *please* insert
as a comment.
>
> * Encoding::GetBaseName()
This is now EncodingUtil::GetBaseName(). Comment says:
// GetBaseName() returns "Foo" if ENCODE is "Q[2][1]X[3]Foo", for
// example.
// If an error occurs, the function returns 0.
Let me know what is unclear.
> * Encoding::ResolveTypedefName()
Also has been moved to EncodingUntil::ResolveTypedefName().
Takes environment 'env' and typedef encoding ('name' & 'len'), returns
environment in which the given typedef is defined.
Typeinfo --- this class is intended to represent types, however the
representation is not unique, because:
- typedefs are expanded lazily (thus many operations need
an environment, to be able to look up typedefs definitions),
- dereferences ('*') are applied lazily.
> * TypeInfo::Reference()
Precondition: *this represents some type T
Postcondition: *this represents type T*
> * TypeInfo::Dereference(t)
Precondition: *this represents some type equivalent to T*
Postcondition: *this represents type T
> * TypeInfo::Normalize()
[I fail to understand this function clearly; my findings:]
- strips top-level cv-qualifiers
- if *this represents dereferenced function pointer changes *this
so that it represents function return type,
- if *this represents dereferenced typedef, expands typedef and
tries to proceed with dereferencing
Name suggests that the actual represented type should not change,
although its representation may (e.g. typedefs are expanded if
necessary). However some details are misterious (member function
pointers for instance).
> * TypeInfo::SkipCv()
Strips all top-level cv-qualifiers from type represented by *this; if
after stripping *this represents a typedef, expands typdef and proceeds.
> * TypeInfo::SkipName(encode, e)
Preconditions:
- encode points into cstring which encodes a typeinfo.
- encode points to the beginning of class or template name withing
the encoded typeinfo cstring
Postcondition:
- return value points immediately after the class or template name
in the encoded typeinfo cstring; if cstring contains typedef names,
they are expanded in environment e
> * TypeInfo::ResolveTypedef(e, ptr, resolvable)
Preconditions:
- ptr points to the beginning of a typedef name in an encoding
- e is an environment, in which the typedef occures (lookup begins
in this environment)
Postconditions:
- if typedef can be correctly looked up, *this represents the same
type, but with the typedef name expanded.
- otherwise *this is unchanged if 'resolvable == false' or
becomes unknown (special state) otherwise.
> Thanks for any clarification !
Hope this helps.
Best regards
Grzegorz
>
> Stefan
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> _______________________________________________
> Opencxx-users mailing list
> Ope...@li...
> https://lists.sourceforge.net/lists/listinfo/opencxx-users
|