| 30 | } |
| 31 | |
| 32 | static 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 | |
| 58 | CScriptWeakRef::CScriptWeakRef(asITypeInfo *type) |
| 59 | { |
no test coverage detected