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

Method BindImportedFunction

sdk/angelscript/source/as_module.cpp:1391–1421  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

1389
1390// interface
1391int asCModule::BindImportedFunction(asUINT index, asIScriptFunction *func)
1392{
1393 // First unbind the old function
1394 int r = UnbindImportedFunction(index);
1395 if( r < 0 ) return r;
1396
1397 // Must verify that the interfaces are equal
1398 asCScriptFunction *dst = GetImportedFunction(index);
1399 if( dst == 0 ) return asNO_FUNCTION;
1400
1401 if( func == 0 )
1402 return asINVALID_ARG;
1403
1404 // Only script functions and registered functions can be bound
1405 // Class methods, delegates, other imported functions are not allowed
1406 if (func->GetFuncType() != asFUNC_SCRIPT && func->GetFuncType() != asFUNC_SYSTEM)
1407 return asNOT_SUPPORTED;
1408
1409 asCScriptFunction *src = m_engine->GetScriptFunction(func->GetId());
1410 if( src == 0 )
1411 return asNO_FUNCTION;
1412
1413 // Verify function signature
1414 if (!dst->IsSignatureExceptNameEqual(src))
1415 return asINVALID_INTERFACE;
1416
1417 m_bindInformations[index]->boundFunctionId = src->GetId();
1418 src->AddRefInternal();
1419
1420 return asSUCCESS;
1421}
1422
1423// interface
1424int asCModule::UnbindImportedFunction(asUINT index)

Callers 2

TestFunction · 0.80
BindImportedFunctionsFunction · 0.80

Calls 5

GetFuncTypeMethod · 0.80
GetScriptFunctionMethod · 0.80
GetIdMethod · 0.80
AddRefInternalMethod · 0.45

Tested by 2

TestFunction · 0.64
BindImportedFunctionsFunction · 0.64