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

Function ScriptWeakRefTemplateCallback

sdk/add_on/weakref/weakref.cpp:32–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32static bool ScriptWeakRefTemplateCallback(asITypeInfo *ti, bool &/*dontGarbageCollect*/)
33{
34 asITypeInfo *subType = ti->GetSubType();
35
36 // Weak references only work for reference types
37 if( subType == 0 ) return false;
38 if( !(subType->GetFlags() & asOBJ_REF) ) return false;
39
40 // The subtype shouldn't be a handle
41 if( ti->GetSubTypeId() & asTYPEID_OBJHANDLE )
42 return false;
43
44 // Make sure the type really supports weak references
45 asUINT cnt = subType->GetBehaviourCount();
46 for( asUINT n = 0; n < cnt; n++ )
47 {
48 asEBehaviours beh;
49 subType->GetBehaviourByIndex(n, &beh);
50 if( beh == asBEHAVE_GET_WEAKREF_FLAG )
51 return true;
52 }
53
54 ti->GetEngine()->WriteMessage("weakref", 0, 0, asMSGTYPE_ERROR, "The subtype doesn't support weak references");
55 return false;
56}
57
58CScriptWeakRef::CScriptWeakRef(asITypeInfo *type)
59{

Callers 1

Calls 7

GetFlagsMethod · 0.80
WriteMessageMethod · 0.80
GetSubTypeMethod · 0.45
GetSubTypeIdMethod · 0.45
GetBehaviourCountMethod · 0.45
GetBehaviourByIndexMethod · 0.45
GetEngineMethod · 0.45

Tested by

no test coverage detected