22 #ifndef AGS_ENGINE_AC_DYNOBJ_CC_MANAGED_OBJECT_POOL_H 23 #define AGS_ENGINE_AC_DYNOBJ_CC_MANAGED_OBJECT_POOL_H 25 #include "common/std/vector.h" 26 #include "common/std/queue.h" 27 #include "common/std/map.h" 29 #include "ags/shared/core/platform.h" 30 #include "ags/engine/script/runtime_script_value.h" 31 #include "ags/engine/ac/dynobj/cc_script_object.h" 44 uint operator()(
void *v)
const {
45 return static_cast<uint
>(
reinterpret_cast<uintptr
>(v));
53 struct ManagedObject {
54 ScriptValueType obj_type;
61 return obj_type != kScValUndefined;
64 ManagedObject() : obj_type(kScValUndefined), handle(0), addr(
nullptr),
65 callback(
nullptr), refCount(0) {}
66 ManagedObject(ScriptValueType theType, int32_t theHandle,
68 : obj_type(theType), handle(theHandle), addr(theAddr),
69 callback(theCallback), refCount(0) {
73 int objectCreationCounter;
80 int Add(
int handle,
void *address,
IScriptObject *callback, ScriptValueType obj_type);
81 int Remove(ManagedObject &o,
bool force =
false);
82 void RunGarbageCollection();
86 int32_t AddRef(int32_t handle);
87 int CheckDispose(int32_t handle);
88 int32_t SubRef(int32_t handle);
89 int32_t AddressToHandle(
void *addr);
90 void *HandleToAddress(int32_t handle);
91 ScriptValueType HandleToAddressAndManager(int32_t handle,
void *&
object,
IScriptObject *&manager);
92 int RemoveObject(
void *address);
93 void RunGarbageCollectionIfAppropriate();
94 int AddObject(
void *address,
IScriptObject *callback, ScriptValueType obj_type);
95 int AddUnserializedObject(
void *address,
IScriptObject *callback, ScriptValueType obj_type,
int handle);
101 void *disableDisposeForObject{
nullptr };
105 #if DEBUG_MANAGED_OBJECTS 106 #define ManagedObjectLog(...) Debug::Printf(kDbgGroup_ManObj, kDbgMsg_Debug, __VA_ARGS__) 108 #define ManagedObjectLog(...) Definition: achievements_tables.h:27
Definition: managed_object_pool.h:50
Definition: managed_object_pool.h:43
Definition: cc_script_object.h:60
Definition: cc_script_object.h:113