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

Method CallObjectMethodRetPtr

sdk/angelscript/source/as_scriptengine.cpp:4595–4672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4593}
4594
4595void *asCScriptEngine::CallObjectMethodRetPtr(void *obj, int func) const
4596{
4597 asCScriptFunction *s = scriptFunctions[func];
4598 asASSERT( s != 0 );
4599 asSSystemFunctionInterface *i = s->sysFuncIntf;
4600
4601#if defined(__GNUC__) || defined(AS_PSVITA)
4602 if( i->callConv == ICC_GENERIC_METHOD )
4603 {
4604 asCGeneric gen(const_cast<asCScriptEngine*>(this), s, obj, 0);
4605 void (*f)(asIScriptGeneric *) = (void (*)(asIScriptGeneric *))(i->func);
4606 f(&gen);
4607 return *(void**)gen.GetReturnPointer();
4608 }
4609#ifndef AS_NO_CLASS_METHODS
4610 else if( i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL )
4611 {
4612 // 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
4613 union
4614 {
4615 asSIMPLEMETHOD_t mthd;
4616 struct
4617 {
4618 asFUNCTION_t func;
4619 asPWORD baseOffset;
4620 } f;
4621 } p;
4622 p.f.func = (asFUNCTION_t)(i->func);
4623 p.f.baseOffset = asPWORD(i->baseOffset);
4624
4625 obj = (void*) ((char*) obj + i->compositeOffset);
4626 if(i->isCompositeIndirect)
4627 obj = *((void**)obj);
4628
4629 void *(asCSimpleDummy::*f)() = (void *(asCSimpleDummy::*)())(p.mthd);
4630 return (((asCSimpleDummy*)obj)->*f)();
4631 }
4632#endif
4633 else /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/
4634 {
4635 void *(*f)(void *) = (void *(*)(void *))(i->func);
4636 return f(obj);
4637 }
4638#else
4639#ifndef AS_NO_CLASS_METHODS
4640 if( i->callConv == ICC_THISCALL )
4641 {
4642 union
4643 {
4644 asSIMPLEMETHOD_t mthd;
4645 asFUNCTION_t func;
4646 } p;
4647 p.func = (asFUNCTION_t)(i->func);
4648 void *(asCSimpleDummy::*f)() = (void *(asCSimpleDummy::*)())p.mthd;
4649
4650 obj = (void*) ((char*) obj + i->compositeOffset);
4651 if(i->isCompositeIndirect)
4652 obj = *((void**)obj);

Callers 1

INSTRUCTIONFunction · 0.80

Calls 1

GetReturnPointerMethod · 0.80

Tested by

no test coverage detected