diff options
| author | Thomas Herzog <therzog@mail.de> | 2018-08-30 19:55:04 +0200 |
|---|---|---|
| committer | Thomas Herzog <therzog@mail.de> | 2018-08-30 19:55:04 +0200 |
| commit | 917bd5b2c2db4b97c385422d2b6df1d2a3e17b60 (patch) | |
| tree | e5f1f717aab9e006fa4f3c66d3afafcdace2f942 /modules/gdnative/nativescript/nativescript.cpp | |
| parent | a1019c2c82f786cb5f2f1b59bbe5e28f93573a88 (diff) | |
| download | redot-engine-917bd5b2c2db4b97c385422d2b6df1d2a3e17b60.tar.gz | |
[NativeScript] implement refcount instance binding funcs
Diffstat (limited to 'modules/gdnative/nativescript/nativescript.cpp')
| -rw-r--r-- | modules/gdnative/nativescript/nativescript.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 608c7aa4a5..147e375fe6 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -1370,6 +1370,54 @@ void NativeScriptLanguage::free_instance_binding_data(void *p_data) { delete &binding_data; } +void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_object) { + + void *data = p_object->get_script_instance_binding(lang_idx); + + if (!data) + return; + + Vector<void *> &binding_data = *(Vector<void *> *)data; + + for (int i = 0; i < binding_data.size(); i++) { + if (!binding_data[i]) + continue; + + if (!binding_functions[i].first) + continue; + + if (binding_functions[i].second.refcount_incremented_instance_binding) { + binding_functions[i].second.refcount_incremented_instance_binding(binding_data[i], p_object); + } + } +} + +bool NativeScriptLanguage::refcount_decremented_instance_binding(Object *p_object) { + + void *data = p_object->get_script_instance_binding(lang_idx); + + if (!data) + return true; + + Vector<void *> &binding_data = *(Vector<void *> *)data; + + bool can_die = true; + + for (int i = 0; i < binding_data.size(); i++) { + if (!binding_data[i]) + continue; + + if (!binding_functions[i].first) + continue; + + if (binding_functions[i].second.refcount_decremented_instance_binding) { + can_die = can_die && binding_functions[i].second.refcount_decremented_instance_binding(binding_data[i], p_object); + } + } + + return can_die; +} + void NativeScriptLanguage::set_global_type_tag(int p_idx, StringName p_class_name, const void *p_type_tag) { if (!global_type_tags.has(p_idx)) { global_type_tags.insert(p_idx, HashMap<StringName, const void *>()); |
