MCPcopy Create free account
hub / github.com/anjo76/angelscript / GetTypeIdFromDataType

Method GetTypeIdFromDataType

sdk/angelscript/source/as_scriptengine.cpp:5060–5125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5058}
5059
5060int asCScriptEngine::GetTypeIdFromDataType(const asCDataType &dtIn) const
5061{
5062 if( dtIn.IsNullHandle() ) return asTYPEID_VOID;
5063
5064 if( dtIn.GetTypeInfo() == 0 )
5065 {
5066 // Primitives have pre-fixed typeIds
5067 switch( dtIn.GetTokenType() )
5068 {
5069 case ttVoid: return asTYPEID_VOID;
5070 case ttBool: return asTYPEID_BOOL;
5071 case ttInt8: return asTYPEID_INT8;
5072 case ttInt16: return asTYPEID_INT16;
5073 case ttInt: return asTYPEID_INT32;
5074 case ttInt64: return asTYPEID_INT64;
5075 case ttUInt8: return asTYPEID_UINT8;
5076 case ttUInt16: return asTYPEID_UINT16;
5077 case ttUInt: return asTYPEID_UINT32;
5078 case ttUInt64: return asTYPEID_UINT64;
5079 case ttFloat: return asTYPEID_FLOAT;
5080 case ttDouble: return asTYPEID_DOUBLE;
5081 default:
5082 // All types should be covered by the above. The variable type is not really a type
5083 asASSERT(dtIn.GetTokenType() == ttQuestion || dtIn.IsAuto());
5084 return -1;
5085 }
5086 }
5087
5088 int typeId = -1;
5089 asCTypeInfo *ot = dtIn.GetTypeInfo();
5090 asASSERT(ot != &functionBehaviours);
5091 // Object's hold the typeId themselves
5092 typeId = ot->typeId;
5093
5094 if( typeId == -1 )
5095 {
5096 ACQUIREEXCLUSIVE(engineRWLock);
5097 // Make sure another thread didn't determine the typeId while we were waiting for the lock
5098 if( ot->typeId == -1 )
5099 {
5100 typeId = typeIdSeqNbr++;
5101 if( ot->flags & asOBJ_SCRIPT_OBJECT ) typeId |= asTYPEID_SCRIPTOBJECT;
5102 else if( ot->flags & asOBJ_TEMPLATE ) typeId |= asTYPEID_TEMPLATE;
5103 else if( ot->flags & asOBJ_ENUM ) {} // TODO: Should we have a specific bit for this?
5104 else typeId |= asTYPEID_APPOBJECT;
5105
5106 ot->typeId = typeId;
5107
5108 mapTypeIdToTypeInfo.Insert(typeId, ot);
5109 }
5110 RELEASEEXCLUSIVE(engineRWLock);
5111 }
5112
5113 // Add flags according to the requested type
5114 if( dtIn.GetTypeInfo() && !(dtIn.GetTypeInfo()->flags & asOBJ_ASHANDLE) )
5115 {
5116 // The ASHANDLE types behave like handles, but are really
5117 // value types so the typeId is never returned as a handle

Callers 15

GetTypeIdMethod · 0.80
GetPropertyTypeIdMethod · 0.80
ReadUsedTypeIdsMethod · 0.80
GetTypeIdMethod · 0.80
GetTypedefTypeIdMethod · 0.80
CallCopyConstructorMethod · 0.80
CompileInitAsCopyMethod · 0.80
PrepareArgumentMethod · 0.80
CompileInitializationMethod · 0.80

Calls 7

IsNullHandleMethod · 0.80
GetTypeInfoMethod · 0.80
GetTokenTypeMethod · 0.80
IsAutoMethod · 0.80
IsObjectHandleMethod · 0.80
IsHandleToConstMethod · 0.80
InsertMethod · 0.45

Tested by

no test coverage detected