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

Function CallSystemFunctionNative

sdk/angelscript/source/as_callfunc_sh4.cpp:273–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273asQWORD CallSystemFunctionNative(asCContext *context, asCScriptFunction *descr, void *obj, asDWORD *args, void *retPointer, asQWORD &/*retQW2*/, void */*secondObject*/)
274{
275 // TODO: SH4 does not yet support THISCALL_OBJFIRST/LAST
276
277 asCScriptEngine *engine = context->m_engine;
278 asSSystemFunctionInterface *sysFunc = descr->sysFuncIntf;
279 int callConv = sysFunc->callConv;
280
281 asQWORD retQW = 0;
282
283 void *func = (void*)sysFunc->func;
284 int paramSize = sysFunc->paramSize;
285 asDWORD *vftable;
286
287 if( descr->returnType.IsObject() && !descr->returnType.IsReference() && !descr->returnType.IsObjectHandle() )
288 {
289 sh4Args[AS_SH4_MAX_ARGS+1] = (asDWORD) retPointer;
290 }
291
292 asASSERT(descr->parameterTypes.GetLength() <= 32);
293
294 // mark all float arguments
295 int argBit = 1;
296 int hostFlags = 0;
297 int intArgs = 0;
298 for( asUINT a = 0; a < descr->parameterTypes.GetLength(); a++ ) {
299 if (descr->parameterTypes[a].IsFloatType()) {
300 hostFlags |= argBit;
301 } else intArgs++;
302 argBit <<= 1;
303 }
304
305 asDWORD paramBuffer[64];
306 if( sysFunc->takesObjByVal )
307 {
308 paramSize = 0;
309 int spos = 0;
310 int dpos = 1;
311 for( asUINT n = 0; n < descr->parameterTypes.GetLength(); n++ )
312 {
313 if( descr->parameterTypes[n].IsObject() && !descr->parameterTypes[n].IsObjectHandle() && !descr->parameterTypes[n].IsReference() )
314 {
315#ifdef COMPLEX_OBJS_PASSED_BY_REF
316 if( descr->parameterTypes[n].GetTypeInfo()->flags & COMPLEX_MASK )
317 {
318 paramBuffer[dpos++] = args[spos++];
319 paramSize++;
320 }
321 else
322#endif
323 {
324 // Copy the object's memory to the buffer
325 memcpy(&paramBuffer[dpos], *(void**)(args+spos), descr->parameterTypes[n].GetSizeInMemoryBytes());
326 // Delete the original memory
327 engine->CallFree(*(char**)(args+spos));
328 spos++;
329 dpos += descr->parameterTypes[n].GetSizeInMemoryDWords();
330 paramSize += descr->parameterTypes[n].GetSizeInMemoryDWords();

Callers

nothing calls this directly

Calls 15

IsObjectMethod · 0.80
IsObjectHandleMethod · 0.80
IsFloatTypeMethod · 0.80
GetTypeInfoMethod · 0.80
GetSizeInMemoryBytesMethod · 0.80
CallFreeMethod · 0.80
GetSizeInMemoryDWordsMethod · 0.80
GetSizeOnStackDWordsMethod · 0.80
SetInternalExceptionMethod · 0.80
CallCDeclFunctionFunction · 0.70
CallThisCallFunctionFunction · 0.70

Tested by

no test coverage detected