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

Method GetMethodIdByDecl

sdk/angelscript/source/as_scriptengine.cpp:1523–1557  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

1521
1522// internal
1523int asCScriptEngine::GetMethodIdByDecl(const asCObjectType *ot, const char *decl, asCModule *mod)
1524{
1525 asCBuilder bld(this, mod);
1526
1527 // Don't write parser errors to the message callback
1528 bld.silent = true;
1529
1530 asCScriptFunction func(this, mod, asFUNC_DUMMY);
1531
1532 // Set the object type so that the signature can be properly compared
1533 // This cast is OK, it will only be used for comparison
1534 func.objectType = const_cast<asCObjectType*>(ot);
1535 func.objectType->AddRefInternal();
1536
1537 int r = bld.ParseFunctionDeclaration(func.objectType, decl, &func, false);
1538 if( r < 0 )
1539 return asINVALID_DECLARATION;
1540
1541 // Search script functions for matching interface
1542 int id = -1;
1543 for( asUINT n = 0; n < ot->methods.GetLength(); ++n )
1544 {
1545 if( func.IsSignatureEqual(scriptFunctions[ot->methods[n]]) )
1546 {
1547 if( id == -1 )
1548 id = ot->methods[n];
1549 else
1550 return asMULTIPLE_FUNCTIONS;
1551 }
1552 }
1553
1554 if( id == -1 ) return asNO_FUNCTION;
1555
1556 return id;
1557}
1558
1559
1560// internal

Callers 1

GetMethodByDeclMethod · 0.80

Calls 4

IsSignatureEqualMethod · 0.80
AddRefInternalMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected