mirror of
https://github.com/godotengine/godot.git
synced 2025-10-31 21:51:22 +00:00
GDScript: Lambda hotswap fixes
This commit is contained in:
parent
d5064a7d44
commit
4d4ec47690
6 changed files with 92 additions and 180 deletions
|
|
@ -139,20 +139,14 @@ void GDScriptLambdaCallable::call(const Variant **p_arguments, int p_argcount, V
|
|||
}
|
||||
}
|
||||
|
||||
GDScriptLambdaCallable::GDScriptLambdaCallable(Ref<GDScript> p_script, GDScriptFunction *p_function, const Vector<Variant> &p_captures) {
|
||||
GDScriptLambdaCallable::GDScriptLambdaCallable(Ref<GDScript> p_script, GDScriptFunction *p_function, const Vector<Variant> &p_captures) :
|
||||
function(p_function) {
|
||||
ERR_FAIL_NULL(p_script.ptr());
|
||||
ERR_FAIL_NULL(p_function);
|
||||
script = p_script;
|
||||
function = p_function;
|
||||
captures = p_captures;
|
||||
|
||||
h = (uint32_t)hash_murmur3_one_64((uint64_t)this);
|
||||
|
||||
updatable_func_ptr_element = p_script->_add_func_ptr_to_update(&function);
|
||||
}
|
||||
|
||||
GDScriptLambdaCallable::~GDScriptLambdaCallable() {
|
||||
GDScript::_remove_func_ptr_to_update(updatable_func_ptr_element);
|
||||
}
|
||||
|
||||
bool GDScriptLambdaSelfCallable::compare_equal(const CallableCustom *p_a, const CallableCustom *p_b) {
|
||||
|
|
@ -264,37 +258,23 @@ void GDScriptLambdaSelfCallable::call(const Variant **p_arguments, int p_argcoun
|
|||
}
|
||||
}
|
||||
|
||||
GDScriptLambdaSelfCallable::GDScriptLambdaSelfCallable(Ref<RefCounted> p_self, GDScriptFunction *p_function, const Vector<Variant> &p_captures) {
|
||||
GDScriptLambdaSelfCallable::GDScriptLambdaSelfCallable(Ref<RefCounted> p_self, GDScriptFunction *p_function, const Vector<Variant> &p_captures) :
|
||||
function(p_function) {
|
||||
ERR_FAIL_NULL(p_self.ptr());
|
||||
ERR_FAIL_NULL(p_function);
|
||||
reference = p_self;
|
||||
object = p_self.ptr();
|
||||
function = p_function;
|
||||
captures = p_captures;
|
||||
|
||||
h = (uint32_t)hash_murmur3_one_64((uint64_t)this);
|
||||
|
||||
GDScript *gds = p_function->get_script();
|
||||
if (gds != nullptr) {
|
||||
updatable_func_ptr_element = gds->_add_func_ptr_to_update(&function);
|
||||
}
|
||||
}
|
||||
|
||||
GDScriptLambdaSelfCallable::GDScriptLambdaSelfCallable(Object *p_self, GDScriptFunction *p_function, const Vector<Variant> &p_captures) {
|
||||
GDScriptLambdaSelfCallable::GDScriptLambdaSelfCallable(Object *p_self, GDScriptFunction *p_function, const Vector<Variant> &p_captures) :
|
||||
function(p_function) {
|
||||
ERR_FAIL_NULL(p_self);
|
||||
ERR_FAIL_NULL(p_function);
|
||||
object = p_self;
|
||||
function = p_function;
|
||||
captures = p_captures;
|
||||
|
||||
h = (uint32_t)hash_murmur3_one_64((uint64_t)this);
|
||||
|
||||
GDScript *gds = p_function->get_script();
|
||||
if (gds != nullptr) {
|
||||
updatable_func_ptr_element = gds->_add_func_ptr_to_update(&function);
|
||||
}
|
||||
}
|
||||
|
||||
GDScriptLambdaSelfCallable::~GDScriptLambdaSelfCallable() {
|
||||
GDScript::_remove_func_ptr_to_update(updatable_func_ptr_element);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue