summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2021-07-15 11:41:57 -0300
committerreduz <reduzio@gmail.com>2021-07-15 11:41:57 -0300
commitb5d5d13f562864dda790c310bad300ea4f3f76dc (patch)
treee7c433fcd0288ee060cb11ddef14a88e166da379
parent9427bf38427da6366118bfd21fbb2f064bc5719d (diff)
Add ability to set object instance binding on creation
* Required by binding generators * Makes it easier to create the bindings on construction.
-rw-r--r--core/object/object.cpp11
-rw-r--r--core/object/object.h4
2 files changed, 14 insertions, 1 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 296d876701..0644012318 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -1769,6 +1769,17 @@ uint32_t Object::get_edited_version() const {
}
#endif
+void Object::set_instance_binding(void *p_token, void *p_binding, const GDNativeInstanceBindingCallbacks *p_callbacks) {
+ // This is only meant to be used on creation by the binder.
+ ERR_FAIL_COND(_instance_bindings != nullptr);
+ _instance_bindings = (InstanceBinding *)memalloc(sizeof(InstanceBinding));
+ _instance_bindings[0].binding = p_binding;
+ _instance_bindings[0].free_callback = p_callbacks->free_callback;
+ _instance_bindings[0].reference_callback = p_callbacks->reference_callback;
+ _instance_bindings[0].token = p_token;
+ _instance_binding_count = 1;
+}
+
void *Object::get_instance_binding(void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks) {
void *binding = nullptr;
_instance_binding_mutex.lock();
diff --git a/core/object/object.h b/core/object/object.h
index 33d9b627f6..89385b81a3 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -804,8 +804,10 @@ public:
#endif
- //used by script languages to store binding data
+ // Used by script languages to store binding data.
void *get_instance_binding(void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks);
+ // Used on creation by binding only.
+ void set_instance_binding(void *p_token, void *p_binding, const GDNativeInstanceBindingCallbacks *p_callbacks);
void clear_internal_resource_paths();