| 271 | } |
| 272 | |
| 273 | asQWORD 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(¶mBuffer[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(); |
nothing calls this directly
no test coverage detected