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

Function SetCB

sdk/tests/test_feature/source/test_functionptr.cpp:41–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39void *cbo = 0;
40asITypeInfo *cbot = 0;
41void SetCB(asIScriptGeneric *gen)
42{
43 if( cb )
44 cb->Release();
45 if( cbo )
46 {
47 gen->GetEngine()->ReleaseScriptObject(cbo, cbot);
48 cbo = cbot = 0;
49 }
50 asIScriptFunction *f = (asIScriptFunction*)gen->GetArgAddress(0);
51
52 // For 2.32.2 and earlier, the generic calling convention automatically released all
53 // handles received, so to compensate for that it would be necessary to add a ref if
54 // the handle should be kept
55 if( gen->GetEngine()->GetEngineProperty(asEP_GENERIC_CALL_MODE) == 0 )
56 f->AddRef();
57
58 if( f && f->GetFuncType() == asFUNC_DELEGATE )
59 {
60 cbo = f->GetDelegateObject();
61 cbot = f->GetDelegateObjectType();
62 cb = f->GetDelegateFunction();
63
64 // Hold on to the objects
65 gen->GetEngine()->AddRefScriptObject(cbo, cbot);
66 cb->AddRef();
67
68 // Release the delegate, which we don't need
69 f->Release();
70 }
71 else
72 {
73 cb = f;
74 }
75}
76
77bool Test()
78{

Callers

nothing calls this directly

Calls 11

ReleaseScriptObjectMethod · 0.80
GetArgAddressMethod · 0.80
GetEnginePropertyMethod · 0.80
GetFuncTypeMethod · 0.80
GetDelegateObjectMethod · 0.80
GetDelegateObjectTypeMethod · 0.80
GetDelegateFunctionMethod · 0.80
AddRefScriptObjectMethod · 0.80
ReleaseMethod · 0.45
GetEngineMethod · 0.45
AddRefMethod · 0.45

Tested by

no test coverage detected