Notify instance binding data api of refcount increment/decrement

This commit is contained in:
Ignacio Etcheverry
2018-02-22 15:34:08 +01:00
parent 79a225ac2a
commit 908a30964a
10 changed files with 129 additions and 23 deletions

View File

@ -40,24 +40,33 @@ class MonoGCHandle : public Reference {
GDCLASS(MonoGCHandle, Reference)
bool released;
bool weak;
uint32_t handle;
public:
enum HandleType {
STRONG_HANDLE,
WEAK_HANDLE
};
static uint32_t make_strong_handle(MonoObject *p_object);
static uint32_t make_weak_handle(MonoObject *p_object);
static Ref<MonoGCHandle> create_strong(MonoObject *p_object);
static Ref<MonoGCHandle> create_weak(MonoObject *p_object);
_FORCE_INLINE_ bool is_weak() { return weak; }
_FORCE_INLINE_ MonoObject *get_target() const { return released ? NULL : mono_gchandle_get_target(handle); }
_FORCE_INLINE_ void set_handle(uint32_t p_handle) {
handle = p_handle;
_FORCE_INLINE_ void set_handle(uint32_t p_handle, HandleType p_handle_type) {
released = false;
weak = p_handle_type == WEAK_HANDLE;
handle = p_handle;
}
void release();
MonoGCHandle(uint32_t p_handle);
MonoGCHandle(uint32_t p_handle, HandleType p_handle_type);
~MonoGCHandle();
};