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

Method CallScriptObjectMethod

sdk/angelscript/source/as_scriptengine.cpp:5471–5553  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

5469
5470// internal
5471int asCScriptEngine::CallScriptObjectMethod(void *obj, int funcId)
5472{
5473 asIScriptContext *ctx = 0;
5474 int r = 0;
5475 bool isNested = false;
5476
5477 // Use nested call in the context if there is an active context
5478 ctx = asGetActiveContext();
5479 if (ctx)
5480 {
5481 // It may not always be possible to reuse the current context,
5482 // in which case we'll have to create a new one any way.
5483 if (ctx->GetEngine() == this && ctx->PushState() == asSUCCESS)
5484 isNested = true;
5485 else
5486 ctx = 0;
5487 }
5488
5489 if (ctx == 0)
5490 {
5491 // Request a context from the engine
5492 ctx = RequestContext();
5493 if (ctx == 0)
5494 {
5495 // TODO: How to best report this failure?
5496 return asERROR;
5497 }
5498 }
5499
5500 r = ctx->Prepare(scriptFunctions[funcId]);
5501 if (r < 0)
5502 {
5503 if (isNested)
5504 ctx->PopState();
5505 else
5506 ReturnContext(ctx);
5507 // TODO: How to best report this failure?
5508 return asERROR;
5509 }
5510
5511 // Set the object
5512 ctx->SetObject(obj);
5513
5514 for (;;)
5515 {
5516 r = ctx->Execute();
5517
5518 // We can't allow this execution to be suspended
5519 // so resume the execution immediately
5520 if (r != asEXECUTION_SUSPENDED)
5521 break;
5522 }
5523
5524 if (r != asEXECUTION_FINISHED)
5525 {
5526 if (isNested)
5527 {
5528 ctx->PopState();

Callers

nothing calls this directly

Calls 8

PushStateMethod · 0.80
PopStateMethod · 0.80
SetObjectMethod · 0.80
ExecuteMethod · 0.80
SetExceptionMethod · 0.80
AbortMethod · 0.80
GetEngineMethod · 0.45
PrepareMethod · 0.45

Tested by

no test coverage detected