MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / SetArgObject

Method SetArgObject

src/server/angelscript/angelscript/source/as_context.cpp:1042–1098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1040}
1041
1042int asCContext::SetArgObject(asUINT arg, void *obj)
1043{
1044 if( m_status != asEXECUTION_PREPARED )
1045 return asCONTEXT_NOT_PREPARED;
1046
1047 if( arg >= (unsigned)m_initialFunction->parameterTypes.GetLength() )
1048 {
1049 m_status = asEXECUTION_ERROR;
1050 return asINVALID_ARG;
1051 }
1052
1053 // Verify the type of the argument
1054 asCDataType *dt = &m_initialFunction->parameterTypes[arg];
1055 if( !dt->IsObject() && !dt->IsFuncdef() )
1056 {
1057 m_status = asEXECUTION_ERROR;
1058 return asINVALID_TYPE;
1059 }
1060
1061 // If the object should be sent by value we must make a copy of it
1062 if( !dt->IsReference() )
1063 {
1064 if( dt->IsObjectHandle() )
1065 {
1066 // Increase the reference counter
1067 if (obj && dt->IsFuncdef())
1068 ((asIScriptFunction*)obj)->AddRef();
1069 else
1070 {
1071 asSTypeBehaviour *beh = &CastToObjectType(dt->GetTypeInfo())->beh;
1072 if (obj && beh->addref)
1073 m_engine->CallObjectMethod(obj, beh->addref);
1074 }
1075 }
1076 else
1077 {
1078 obj = m_engine->CreateScriptObjectCopy(obj, dt->GetTypeInfo());
1079 }
1080 }
1081
1082 // Determine the position of the argument
1083 int offset = 0;
1084 if( m_initialFunction->objectType )
1085 offset += AS_PTR_SIZE;
1086
1087 // If function returns object by value an extra pointer is pushed on the stack
1088 if( m_returnValueSize )
1089 offset += AS_PTR_SIZE;
1090
1091 for( asUINT n = 0; n < arg; n++ )
1092 offset += m_initialFunction->parameterTypes[n].GetSizeOnStackDWords();
1093
1094 // Set the value
1095 *(asPWORD*)(&m_regs.stackFramePointer[offset]) = (asPWORD)obj;
1096
1097 return 0;
1098}
1099

Callers 7

runAppMethod · 0.80
CreateControllerMethod · 0.80
CallOnMessageMethod · 0.80
ScriptObjectCopyFactoryFunction · 0.80
EqualsMethod · 0.80
operator()Function · 0.80
ScriptCreateCoRoutineFunction · 0.80

Calls 11

CastToObjectTypeFunction · 0.85
IsFuncdefMethod · 0.80
IsReferenceMethod · 0.80
IsObjectHandleMethod · 0.80
GetTypeInfoMethod · 0.80
CallObjectMethodMethod · 0.80
GetSizeOnStackDWordsMethod · 0.80
GetLengthMethod · 0.45
IsObjectMethod · 0.45
AddRefMethod · 0.45

Tested by

no test coverage detected