28 #ifndef AGS_ENGINE_SCRIPT_RUNTIME_SCRIPT_VALUE_H 29 #define AGS_ENGINE_SCRIPT_RUNTIME_SCRIPT_VALUE_H 31 #include "ags/engine/ac/dynobj/cc_script_object.h" 32 #include "ags/engine/ac/dynobj/cc_static_array.h" 33 #include "ags/engine/script/script_api.h" 34 #include "ags/shared/util/memory.h" 36 #include "ags/plugins/plugin_base.h" 40 enum ScriptValueType {
66 Type = kScValUndefined;
96 ScriptAPIFunction *SPfn;
97 ScriptAPIObjectFunction *ObjPfn;
115 inline bool IsValid()
const {
116 return Type != kScValUndefined;
119 inline bool IsNull()
const {
120 return Ptr ==
nullptr && IValue == 0;
123 inline bool GetAsBool()
const {
127 inline void *GetPtrWithOffset()
const {
128 return PtrU8 + IValue;
131 inline void *GetRValuePtrWithOffset()
const {
132 return static_cast<uint8_t *
>(RValue->GetPtrWithOffset()) + this->IValue;
141 Type = kScValInteger;
151 Type = kScValInteger;
161 Type = kScValInteger;
181 return SetInt32(val ? 1 : 0);
185 return SetFloat(val ? 1.0F : 0.0F);
189 Type = kScValPluginArg;
199 Type = kScValStackPtr;
202 RValue = stack_entry;
219 Type = kScValGlobalVar;
222 RValue = glvar_value;
230 Type = kScValStringLiteral;
233 Ptr =
const_cast<char *
>(str);
240 Type = kScValStaticArray;
250 Type = kScValScriptObject;
260 Type = kScValPluginObject;
279 Type = kScValStaticFunction;
289 Type = kScValPluginFunction;
299 Type = kScValObjectFunction;
309 Type = kScValCodePtr;
323 if (rval.Type == kScValPluginFunction) {
324 assert(!rval.methodName.empty());
325 return (Type == kScValPluginFunction) && (rval.methodName == methodName);
328 return ((intptr_t)Ptr + (intptr_t)IValue) == ((intptr_t)rval.Ptr + (intptr_t)rval.IValue);
331 return !(*
this == rval);
338 switch (this->Type) {
339 case kScValStackPtr: {
341 switch (RValue->Type) {
350 case kScValGlobalVar: {
352 switch (RValue->Type) {
355 return RuntimeScriptValue().SetInt32(AGS::Shared::Memory::ReadInt32LE(GetRValuePtrWithOffset()));
361 case kScValStaticArray:
362 case kScValScriptObject:
363 return RuntimeScriptValue().SetInt32(this->ObjMgr->ReadInt32(this->Ptr, this->IValue));
374 switch (this->Type) {
375 case kScValStackPtr: {
377 switch (RValue->Type) {
380 *(int32_t *)(GetRValuePtrWithOffset()) = rval.IValue;
393 case kScValGlobalVar: {
395 switch (RValue->Type) {
398 AGS::Shared::Memory::WriteInt32LE(GetRValuePtrWithOffset(), rval.IValue);
407 case kScValStaticArray:
408 case kScValScriptObject: {
409 this->ObjMgr->WriteInt32(this->Ptr, this->IValue, rval.IValue);
413 *((int32_t *)this->GetPtrWithOffset()) = rval.IValue;
426 uint8_t ReadByte()
const;
427 int16_t ReadInt16()
const;
428 int32_t ReadInt32()
const;
429 void WriteByte(uint8_t val);
430 void WriteInt16(int16_t val);
431 void WriteInt32(int32_t val);
440 void *GetDirectPtr()
const;
Definition: cc_script_object.h:60
Definition: runtime_script_value.h:63
Definition: cc_static_array.h:60
Definition: plugin_base.h:171
Definition: geometry.h:148
Definition: plugin_base.h:151
Definition: plugin_base.h:189