| 4435 | } |
| 4436 | |
| 4437 | bool asCScriptEngine::CallObjectMethodRetBool(void *obj, int func) const |
| 4438 | { |
| 4439 | asCScriptFunction *s = scriptFunctions[func]; |
| 4440 | asASSERT( s != 0 ); |
| 4441 | asSSystemFunctionInterface *i = s->sysFuncIntf; |
| 4442 | |
| 4443 | #if defined(__GNUC__) || defined(AS_PSVITA) |
| 4444 | if( i->callConv == ICC_GENERIC_METHOD ) |
| 4445 | { |
| 4446 | asCGeneric gen(const_cast<asCScriptEngine*>(this), s, obj, 0); |
| 4447 | void (*f)(asIScriptGeneric *) = (void (*)(asIScriptGeneric *))(i->func); |
| 4448 | f(&gen); |
| 4449 | return *(bool*)gen.GetReturnPointer(); |
| 4450 | } |
| 4451 | #ifndef AS_NO_CLASS_METHODS |
| 4452 | else if( i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL ) |
| 4453 | { |
| 4454 | // 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 |
| 4455 | union |
| 4456 | { |
| 4457 | asSIMPLEMETHOD_t mthd; |
| 4458 | struct |
| 4459 | { |
| 4460 | asFUNCTION_t func; |
| 4461 | asPWORD baseOffset; |
| 4462 | } f; |
| 4463 | } p; |
| 4464 | |
| 4465 | obj = (void*) ((char*) obj + i->compositeOffset); |
| 4466 | if(i->isCompositeIndirect) |
| 4467 | obj = *((void**)obj); |
| 4468 | |
| 4469 | p.f.func = (asFUNCTION_t)(i->func); |
| 4470 | p.f.baseOffset = asPWORD(i->baseOffset); |
| 4471 | bool (asCSimpleDummy::*f)() = (bool (asCSimpleDummy::*)())(p.mthd); |
| 4472 | return (((asCSimpleDummy*)obj)->*f)(); |
| 4473 | } |
| 4474 | #endif |
| 4475 | else /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/ |
| 4476 | { |
| 4477 | bool (*f)(void *) = (bool (*)(void *))(i->func); |
| 4478 | return f(obj); |
| 4479 | } |
| 4480 | #else |
| 4481 | #ifndef AS_NO_CLASS_METHODS |
| 4482 | if( i->callConv == ICC_THISCALL ) |
| 4483 | { |
| 4484 | union |
| 4485 | { |
| 4486 | asSIMPLEMETHOD_t mthd; |
| 4487 | asFUNCTION_t func; |
| 4488 | } p; |
| 4489 | p.func = (asFUNCTION_t)(i->func); |
| 4490 | bool (asCSimpleDummy::*f)() = (bool (asCSimpleDummy::*)())p.mthd; |
| 4491 | |
| 4492 | obj = (void*) ((char*) obj + i->compositeOffset); |
| 4493 | if(i->isCompositeIndirect) |
| 4494 | obj = *((void**)obj); |
no test coverage detected