1 module as.tinf; 2 import as.def; 3 import as.engine; 4 import as.mod; 5 import std.exception; 6 import std..string; 7 8 /** 9 Angelscript type info 10 */ 11 class Type { 12 private: 13 ScriptEngine engine; 14 Module mod; 15 16 ~this() { 17 this.engine = null; 18 } 19 20 package(as): 21 asITypeInfo* info; 22 23 this(ScriptEngine engine, asITypeInfo* info) { 24 this.engine = engine; 25 this.mod = new Module(engine, asTypeInfo_GetModule(info)); 26 this.info = info; 27 } 28 29 this(ScriptEngine engine, Module mod, asITypeInfo* info) { 30 this.engine = engine; 31 this.mod = mod; 32 this.info = info; 33 } 34 35 public: 36 /** 37 Gets the scripting engine this type belongs to 38 */ 39 ScriptEngine getEngine() { 40 return engine; 41 } 42 43 /** 44 Gets the config group this type belongs to 45 */ 46 string getConfigGroup() { 47 return cast(string)asTypeInfo_GetConfigGroup(info).fromStringz; 48 } 49 50 /** 51 Gets this type's access mask 52 */ 53 asDWORD getAccessMask() { 54 return asTypeInfo_GetAccessMask(info); 55 } 56 57 /** 58 Gets the module this type belongs to 59 */ 60 Module getModule() { 61 return mod; 62 } 63 64 /** 65 Add a reference to this type 66 */ 67 int addRef() { 68 return asTypeInfo_AddRef(info); 69 } 70 71 /** 72 Release a reference from this type 73 */ 74 int release() { 75 return asTypeInfo_Release(info); 76 } 77 78 /** 79 Gets the name of this type 80 */ 81 string getName() { 82 return cast(string)asTypeInfo_GetName(info).fromStringz; 83 } 84 85 /** 86 Gets this type's namespace 87 */ 88 string getNamespace() { 89 return cast(string)asTypeInfo_GetNamespace(info).fromStringz; 90 } 91 92 /** 93 Gets this type's base type 94 95 This method will return null if this type has no base type 96 */ 97 Type getBaseType() { 98 auto baseType = asTypeInfo_GetBaseType(info); 99 return baseType !is null ? new Type(engine, baseType) : null; 100 } 101 102 /** 103 Gets whether this type derives from the specified other type 104 */ 105 bool derivesFrom(Type other) { 106 return asTypeInfo_DerivesFrom(info, other.info); 107 } 108 109 /** 110 Gets this type's flags 111 */ 112 asDWORD getFlags() { 113 return asTypeInfo_GetFlags(info); 114 } 115 116 /** 117 Gets the size in bytes of this type 118 */ 119 asUINT getSize() { 120 return asTypeInfo_GetSize(info); 121 } 122 123 /** 124 Gets this type's type id 125 */ 126 int getTypeId() { 127 return asTypeInfo_GetTypeId(info); 128 } 129 130 /** 131 Gets the id the specified subtype 132 */ 133 int getSubTypeId(asUINT subtypeIndex) { 134 return asTypeInfo_GetSubTypeId(info, subtypeIndex); 135 } 136 137 /** 138 Gets the subtype by its index 139 140 Returns null if there's no subtype at that index 141 */ 142 Type getSubType(asUINT subtypeIndex) { 143 auto subType = asTypeInfo_GetSubType(info, subtypeIndex); 144 return subType !is null ? new Type(engine, subType) : null; 145 } 146 147 /** 148 Gets the amount of subtypes this type has 149 */ 150 asUINT getSubTypeCount() { 151 return asTypeInfo_GetSubTypeCount(info); 152 } 153 154 /** 155 Gets the amount of interfaces this type implements 156 */ 157 asUINT getInterfaceCount() { 158 return asTypeInfo_GetInterfaceCount(info); 159 } 160 161 /** 162 Gets the interface at the specified index 163 164 Returns null if there's no interface at that index 165 */ 166 Type getInterface(asUINT index) { 167 auto iface = asTypeInfo_GetInterface(info, index); 168 return iface !is null ? new Type(engine, iface) : null; 169 } 170 171 /** 172 Gets whether this type implements the specified interface 173 */ 174 bool implements(Type other) { 175 return asTypeInfo_Implements(info, other.info); 176 } 177 }