tango.core.RuntimeTraits

Provides runtime traits, which provide much of the functionality of tango.core.Traits and is-expressions, as well as some functionality that is only available at runtime, using runtime type information.

Authors:
Chris Wright (dhasenan)

License:
Tango License, Apache 2.0

TypeInfo realType(TypeInfo type);
If the given type represents a typedef, return the actual type.

ClassInfo asClass(TypeInfo type);
If the given type represents a class, return its ClassInfo; else return null;

bool isDerived(ClassInfo derived, ClassInfo base);
Returns true iff one type is an ancestor of the other, or if the types are the same. If either is null, returns false.

bool implements(ClassInfo implementor, ClassInfo iface);
Returns true iff implementor implements the interface described by iface. This is an expensive operation (linear in the number of interfaces and base classes).

bool isImplicitly(ClassInfo test, ClassInfo target);
Returns true iff an instance of class test is implicitly castable to target. This is an expensive operation (isDerived + implements).

bool isImplicitly(TypeInfo test, TypeInfo target);
Returns true iff an instance of type test is implicitly castable to target. If the types describe classes or interfaces, this is an expensive operation.

TypeInfo_Class[] baseClasses(ClassInfo type);


TypeInfo_Class[] baseInterfaces(ClassInfo type);
Returns a list of all interfaces that this type implements, directly or indirectly. This includes base interfaces of types the class implements, and interfaces that base classes implement, and base interfaces of interfaces that base classes implement. This is an expensive operation.

TypeInfo_Class[] interfaceGraph(ClassInfo type);
Returns all the interfaces that this type directly implements, including inherited interfaces. This is an expensive operation.

Examples:
 interface I1 {}
 interface I2 : I1 {}
 class A : I2 {}

 auto interfaces = interfaceGraph (A.classinfo);
 // interfaces = [I1.classinfo, I2.classinfo]
 interface I1 {}
 interface I2 {}
 class A : I1 {}
 class B : A, I2 {}

 auto interfaces = interfaceGraph (B.classinfo);
 // interfaces = [I2.classinfo]


struct applyInterfaces;
Iterate through all interfaces that type implements, directly or indirectly, including base interfaces.

static applyInterfaces opCall(ClassInfo type);


int opApply(scope int delegate(ref TypeInfo_Class) dg);


TypeInfo_Class[] baseTypes(ClassInfo type);


ModuleInfo* moduleOf(ClassInfo type);


TypeInfo_Class[] directInterfaces(ClassInfo type);
Returns a list of interfaces that this class directly implements.

TypeInfo_Class[] derivedTypes(ClassInfo type);
Returns a list of all types that are derived from the given type. This does not count interfaces; that is, if type is an interface, you will only get derived interfaces back. It is an expensive operations.

bool isDynamicArray(TypeInfo type);


bool isStaticArray(TypeInfo type);


bool isArray(TypeInfo type);
Returns true iff the given type is a dynamic or static array (false for associative arrays and non-arrays).

bool isAssociativeArray(TypeInfo type);


bool isCharacter(TypeInfo type);


bool isString(TypeInfo type);


bool isUnsignedInteger(TypeInfo type);


bool isSignedInteger(TypeInfo type);


bool isInteger(TypeInfo type);


bool isBool(TypeInfo type);


bool isFloat(TypeInfo type);


bool isPrimitive(TypeInfo type);


bool isInterface(TypeInfo type);
Returns true iff the given type represents an interface.

bool isPointer(TypeInfo type);


bool isClass(TypeInfo type);
Returns true iff the type represents a class (false for interfaces).

bool isStruct(TypeInfo type);


bool isFunction(TypeInfo type);


bool isReferenceType(TypeInfo type);
Returns true iff the given type is a reference type.

bool isUserDefined(TypeInfo type);
Returns true iff the given type represents a user-defined type. This does not include functions, delegates, aliases, or typedefs.

bool isValueType(TypeInfo type);
Returns true for all value types, false for all reference types. For functions and delegates, returns false (is this the way it should be?).

TypeInfo keyType(TypeInfo type);
The key type of the given type. For an array, size_t; for an associative array T[U], U.

TypeInfo valueType(TypeInfo type);
The value type of the given type -- given T[] or T[n], T; given T[U], T; given T*, T; anything else, null.

TypeInfo returnType(TypeInfo type);
If the given type represents a delegate or function, the return type of that function. Otherwise, null.


Page generated by Ddoc. Copyright (c) 2009, CHRISTOPHER WRIGHT