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

Method SetArgVarType

sdk/angelscript/source/as_context.cpp:1394–1431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1392}
1393
1394int asCContext::SetArgVarType(asUINT arg, void *ptr, int typeId)
1395{
1396 if( m_status != asEXECUTION_PREPARED )
1397 return asCONTEXT_NOT_PREPARED;
1398
1399 if( arg >= (unsigned)m_initialFunction->parameterTypes.GetLength() )
1400 {
1401 m_status = asEXECUTION_ERROR;
1402 return asINVALID_ARG;
1403 }
1404
1405 // Verify the type of the argument
1406 asCDataType *dt = &m_initialFunction->parameterTypes[arg];
1407 if( dt->GetTokenType() != ttQuestion )
1408 {
1409 m_status = asEXECUTION_ERROR;
1410 return asINVALID_TYPE;
1411 }
1412
1413 // Determine the position of the argument
1414 int offset = 0;
1415 if( m_initialFunction->objectType )
1416 offset += AS_PTR_SIZE;
1417
1418 // If function returns object by value an extra pointer is pushed on the stack
1419 if( m_returnValueSize )
1420 offset += AS_PTR_SIZE;
1421
1422 for( asUINT n = 0; n < arg; n++ )
1423 offset += m_initialFunction->parameterTypes[n].GetSizeOnStackDWords();
1424
1425 // Set the typeId and pointer
1426 *(asPWORD*)(&m_regs.stackFramePointer[offset]) = (asPWORD)ptr;
1427 offset += AS_PTR_SIZE;
1428 *(int*)(&m_regs.stackFramePointer[offset]) = typeId;
1429
1430 return 0;
1431}
1432
1433// TODO: Instead of GetAddressOfArg, maybe we need a SetArgValue(int arg, void *value, bool takeOwnership) instead.
1434

Callers 1

RefCastObjectMethod · 0.80

Calls 3

GetTokenTypeMethod · 0.80
GetSizeOnStackDWordsMethod · 0.80
GetLengthMethod · 0.45

Tested by

no test coverage detected