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

Method CallObjectMethodRetInt

sdk/angelscript/source/as_scriptengine.cpp:4516–4593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4514}
4515
4516int asCScriptEngine::CallObjectMethodRetInt(void *obj, int func) const
4517{
4518 asCScriptFunction *s = scriptFunctions[func];
4519 asASSERT( s != 0 );
4520 asSSystemFunctionInterface *i = s->sysFuncIntf;
4521
4522#if defined(__GNUC__) || defined(AS_PSVITA)
4523 if( i->callConv == ICC_GENERIC_METHOD )
4524 {
4525 asCGeneric gen(const_cast<asCScriptEngine*>(this), s, obj, 0);
4526 void (*f)(asIScriptGeneric *) = (void (*)(asIScriptGeneric *))(i->func);
4527 f(&gen);
4528 return *(int*)gen.GetReturnPointer();
4529 }
4530#ifndef AS_NO_CLASS_METHODS
4531 else if( i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL )
4532 {
4533 // For virtual thiscalls we must call the method as a true class method so that the compiler will lookup the function address in the vftable
4534 union
4535 {
4536 asSIMPLEMETHOD_t mthd;
4537 struct
4538 {
4539 asFUNCTION_t func;
4540 asPWORD baseOffset;
4541 } f;
4542 } p;
4543 p.f.func = (asFUNCTION_t)(i->func);
4544 p.f.baseOffset = asPWORD(i->baseOffset);
4545
4546 obj = (void*) ((char*) obj + i->compositeOffset);
4547 if(i->isCompositeIndirect)
4548 obj = *((void**)obj);
4549
4550 int (asCSimpleDummy::*f)() = (int (asCSimpleDummy::*)())(p.mthd);
4551 return (((asCSimpleDummy*)obj)->*f)();
4552 }
4553#endif
4554 else /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/
4555 {
4556 int (*f)(void *) = (int (*)(void *))(i->func);
4557 return f(obj);
4558 }
4559#else
4560#ifndef AS_NO_CLASS_METHODS
4561 if( i->callConv == ICC_THISCALL )
4562 {
4563 union
4564 {
4565 asSIMPLEMETHOD_t mthd;
4566 asFUNCTION_t func;
4567 } p;
4568 p.func = (asFUNCTION_t)(i->func);
4569 int (asCSimpleDummy::*f)() = (int (asCSimpleDummy::*)())p.mthd;
4570
4571 obj = (void*) ((char*) obj + i->compositeOffset);
4572 if(i->isCompositeIndirect)
4573 obj = *((void**)obj);

Callers 4

DestroyNewGarbageMethod · 0.80
DestroyOldGarbageMethod · 0.80

Calls 1

GetReturnPointerMethod · 0.80

Tested by

no test coverage detected