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

Function CallSystemFunctionNative

sdk/angelscript/source/as_callfunc_xenon.cpp:502–729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500}
501
502asQWORD CallSystemFunctionNative(asCContext *context, asCScriptFunction *descr, void *obj, asDWORD *args, void *retPointer, asQWORD &/*retQW2*/, void */*secondObject*/)
503{
504 // TODO: Xenon does not yet support THISCALL_OBJFIRST/LAST
505
506 asCScriptEngine *engine = context->m_engine;
507 asSSystemFunctionInterface *sysFunc = descr->sysFuncIntf;
508 int callConv = sysFunc->callConv;
509 asQWORD retQW = 0;
510 void *func = (void*)sysFunc->func;
511 asDWORD *vftable;
512
513 // Pack the arguments into an array that ppcFunc() can use to load each CPU register properly
514 asBYTE ppcArgsType[AS_PPC_MAX_ARGS + AS_PPC_RETURNINMEM_REG + AS_PPC_THISCALL_REG + AS_PPC_ENDOFARGS];
515 asQWORD ppcArgs[AS_PPC_MAX_ARGS + AS_PPC_RETURNINMEM_REG + AS_PPC_THISCALL_REG];
516 int argsCnt = 0;
517
518 // If the function returns an object in memory, we allocate the memory and put the ptr to the front (will go to r3)
519 if( sysFunc->hostReturnInMemory )
520 {
521 ppcArgs[argsCnt] = (asDWORD)retPointer;
522 ppcArgsType[argsCnt] = ppcINTARG;
523 argsCnt++;
524 }
525
526 // If we have an object and it's not objectlast, then we put it as the first arg
527 if ( obj &&
528 callConv != ICC_CDECL_OBJLAST &&
529 callConv != ICC_CDECL_OBJLAST_RETURNINMEM )
530 {
531 ppcArgs[argsCnt] = (asDWORD)obj;
532 ppcArgsType[argsCnt] = ppcINTARG;
533 argsCnt++;
534 }
535
536 // If the function takes any objects by value, they must be copied
537 // to the stack, shifting the other arguments as necessary. paramBuffer
538 // will then replace the args pointer that was received from the VM.
539 // TODO: Is this really how XBox 360 passes objects by value?
540 asDWORD paramBuffer[AS_PPC_MAX_ARGS];
541 if( sysFunc->takesObjByVal )
542 {
543 int paramSize = 0;
544 int spos = 0;
545 int dpos = 1;
546
547 for( asUINT n = 0; n < descr->parameterTypes.GetLength(); n++ )
548 {
549 // Parameter object by value
550 if( descr->parameterTypes[n].IsObject() &&
551 !descr->parameterTypes[n].IsObjectHandle() &&
552 !descr->parameterTypes[n].IsReference() )
553 {
554#ifdef COMPLEX_OBJS_PASSED_BY_REF
555 if( descr->parameterTypes[n].GetTypeInfo()->flags & COMPLEX_MASK )
556 {
557 paramBuffer[dpos++] = args[spos++];
558 paramSize++;
559 }

Callers

nothing calls this directly

Calls 15

IsObjectMethod · 0.80
IsObjectHandleMethod · 0.80
GetTypeInfoMethod · 0.80
GetSizeInMemoryBytesMethod · 0.80
CallFreeMethod · 0.80
GetSizeInMemoryDWordsMethod · 0.80
GetSizeOnStackDWordsMethod · 0.80
IsFloatTypeMethod · 0.80
IsDoubleTypeMethod · 0.80
SetInternalExceptionMethod · 0.80
IsVariableArgumentFunction · 0.70
GetReturnedFloatFunction · 0.70

Tested by

no test coverage detected