MCPcopy Create free account
hub / github.com/Siv3D/OpenSiv3D / GetTypeIdFromDataType

Method GetTypeIdFromDataType

Siv3D/src/ThirdParty/angelscript/as_scriptengine.cpp:4758–4823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4756}
4757
4758int asCScriptEngine::GetTypeIdFromDataType(const asCDataType &dtIn) const
4759{
4760 if( dtIn.IsNullHandle() ) return asTYPEID_VOID;
4761
4762 if( dtIn.GetTypeInfo() == 0 )
4763 {
4764 // Primitives have pre-fixed typeIds
4765 switch( dtIn.GetTokenType() )
4766 {
4767 case ttVoid: return asTYPEID_VOID;
4768 case ttBool: return asTYPEID_BOOL;
4769 case ttInt8: return asTYPEID_INT8;
4770 case ttInt16: return asTYPEID_INT16;
4771 case ttInt: return asTYPEID_INT32;
4772 case ttInt64: return asTYPEID_INT64;
4773 case ttUInt8: return asTYPEID_UINT8;
4774 case ttUInt16: return asTYPEID_UINT16;
4775 case ttUInt: return asTYPEID_UINT32;
4776 case ttUInt64: return asTYPEID_UINT64;
4777 case ttFloat: return asTYPEID_FLOAT;
4778 case ttDouble: return asTYPEID_DOUBLE;
4779 default:
4780 // All types should be covered by the above. The variable type is not really a type
4781 asASSERT(dtIn.GetTokenType() == ttQuestion);
4782 return -1;
4783 }
4784 }
4785
4786 int typeId = -1;
4787 asCTypeInfo *ot = dtIn.GetTypeInfo();
4788 asASSERT(ot != &functionBehaviours);
4789 // Object's hold the typeId themselves
4790 typeId = ot->typeId;
4791
4792 if( typeId == -1 )
4793 {
4794 ACQUIREEXCLUSIVE(engineRWLock);
4795 // Make sure another thread didn't determine the typeId while we were waiting for the lock
4796 if( ot->typeId == -1 )
4797 {
4798 typeId = typeIdSeqNbr++;
4799 if( ot->flags & asOBJ_SCRIPT_OBJECT ) typeId |= asTYPEID_SCRIPTOBJECT;
4800 else if( ot->flags & asOBJ_TEMPLATE ) typeId |= asTYPEID_TEMPLATE;
4801 else if( ot->flags & asOBJ_ENUM ) {} // TODO: Should we have a specific bit for this?
4802 else typeId |= asTYPEID_APPOBJECT;
4803
4804 ot->typeId = typeId;
4805
4806 mapTypeIdToTypeInfo.Insert(typeId, ot);
4807 }
4808 RELEASEEXCLUSIVE(engineRWLock);
4809 }
4810
4811 // Add flags according to the requested type
4812 if( dtIn.GetTypeInfo() && !(dtIn.GetTypeInfo()->flags & asOBJ_ASHANDLE) )
4813 {
4814 // The ASHANDLE types behave like handles, but are really
4815 // 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
PrepareArgumentMethod · 0.80
CompileInitializationMethod · 0.80
CompileInitListMethod · 0.80
PerformAssignmentMethod · 0.80
CompileRefCastMethod · 0.80

Calls 6

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

Tested by

no test coverage detected