mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Remove multilevel calls
In general they are more confusing to users because they expect inheritance to fully override parent methods. This behavior can be enabled by script writers using a simple super() call.
This commit is contained in:
parent
b7dc08fcf6
commit
2b9d9bc364
17 changed files with 19 additions and 264 deletions
|
@ -897,7 +897,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
|
|||
|
||||
// Call OnBeforeSerialize
|
||||
if (csi->script->script_class->implements_interface(CACHED_CLASS(ISerializationListener))) {
|
||||
obj->get_script_instance()->call_multilevel(string_names.on_before_serialize);
|
||||
obj->get_script_instance()->call(string_names.on_before_serialize);
|
||||
}
|
||||
|
||||
// Save instance info
|
||||
|
@ -1133,7 +1133,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
|
|||
|
||||
// Call OnAfterDeserialization
|
||||
if (csi->script->script_class->implements_interface(CACHED_CLASS(ISerializationListener))) {
|
||||
obj->get_script_instance()->call_multilevel(string_names.on_after_deserialize);
|
||||
obj->get_script_instance()->call(string_names.on_after_deserialize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1866,41 +1866,6 @@ Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args,
|
|||
return Variant();
|
||||
}
|
||||
|
||||
void CSharpInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
|
||||
GD_MONO_SCOPE_THREAD_ATTACH;
|
||||
|
||||
if (script.is_valid()) {
|
||||
MonoObject *mono_object = get_mono_object();
|
||||
|
||||
ERR_FAIL_NULL(mono_object);
|
||||
|
||||
_call_multilevel(mono_object, p_method, p_args, p_argcount);
|
||||
}
|
||||
}
|
||||
|
||||
void CSharpInstance::_call_multilevel(MonoObject *p_mono_object, const StringName &p_method, const Variant **p_args, int p_argcount) {
|
||||
GD_MONO_ASSERT_THREAD_ATTACHED;
|
||||
|
||||
GDMonoClass *top = script->script_class;
|
||||
|
||||
while (top && top != script->native) {
|
||||
GDMonoMethod *method = top->get_method(p_method, p_argcount);
|
||||
|
||||
if (method) {
|
||||
method->invoke(p_mono_object, p_args);
|
||||
return;
|
||||
}
|
||||
|
||||
top = top->get_parent_class();
|
||||
}
|
||||
}
|
||||
|
||||
void CSharpInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
|
||||
// Sorry, the method is the one that controls the call order
|
||||
|
||||
call_multilevel(p_method, p_args, p_argcount);
|
||||
}
|
||||
|
||||
bool CSharpInstance::_reference_owner_unsafe() {
|
||||
#ifdef DEBUG_ENABLED
|
||||
CRASH_COND(!base_ref);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue