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

Method GetGlobalFunctionByDecl

sdk/angelscript/source/as_scriptengine.cpp:3271–3326  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

3269
3270// interface
3271asIScriptFunction *asCScriptEngine::GetGlobalFunctionByDecl(const char *decl) const
3272{
3273 asCBuilder bld(const_cast<asCScriptEngine*>(this), 0);
3274
3275 // Don't write parser errors to the message callback
3276 bld.silent = true;
3277
3278 asCScriptFunction func(const_cast<asCScriptEngine*>(this), 0, asFUNC_DUMMY);
3279 int r = bld.ParseFunctionDeclaration(0, decl, &func, false, 0, 0, defaultNamespace);
3280 if( r < 0 )
3281 return 0;
3282
3283 asSNameSpace *ns = defaultNamespace;
3284 // Search script functions for matching interface
3285 while( ns )
3286 {
3287 asIScriptFunction *f = 0;
3288 const asCArray<unsigned int> &idxs = registeredGlobalFuncs.GetIndexes(ns, func.name);
3289 for( unsigned int n = 0; n < idxs.GetLength(); n++ )
3290 {
3291 const asCScriptFunction *funcPtr = registeredGlobalFuncs.Get(idxs[n]);
3292 if( funcPtr->objectType == 0 &&
3293 func.returnType == funcPtr->returnType &&
3294 func.parameterTypes.GetLength() == funcPtr->parameterTypes.GetLength()
3295 )
3296 {
3297 bool match = true;
3298 for( asUINT p = 0; p < func.parameterTypes.GetLength(); ++p )
3299 {
3300 if( func.parameterTypes[p] != funcPtr->parameterTypes[p] )
3301 {
3302 match = false;
3303 break;
3304 }
3305 }
3306
3307 if( match )
3308 {
3309 if( f == 0 )
3310 f = const_cast<asCScriptFunction*>(funcPtr);
3311 else
3312 // Multiple functions
3313 return 0;
3314 }
3315 }
3316 }
3317
3318 if( f )
3319 return f;
3320
3321 // Recursively search parent namespaces
3322 ns = GetParentNameSpace(ns);
3323 }
3324
3325 return 0;
3326}
3327
3328

Callers 5

test_debug.cppFile · 0.80
TestFunction · 0.80
TestFunction · 0.80
test_namespace.cppFile · 0.80
TestExecuteFunction · 0.80

Calls 3

GetLengthMethod · 0.45
GetMethod · 0.45

Tested by 3

TestFunction · 0.64
TestFunction · 0.64
TestExecuteFunction · 0.64