Merge pull request #50484 from reduz/fix-instance-set-binding-on-create

Add ability to set object instance binding on creation
This commit is contained in:
Juan Linietsky 2021-07-15 14:04:04 -03:00 committed by GitHub
commit 28ee24b971
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -1769,6 +1769,17 @@ uint32_t Object::get_edited_version() const {
} }
#endif #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 *Object::get_instance_binding(void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks) {
void *binding = nullptr; void *binding = nullptr;
_instance_binding_mutex.lock(); _instance_binding_mutex.lock();

View File

@ -804,8 +804,10 @@ public:
#endif #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); 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(); void clear_internal_resource_paths();