Mono: Remove automatic script multilevel calls

This commit is contained in:
Ignacio Etcheverry 2018-01-30 18:53:00 +01:00
parent f12e8568d4
commit 84437b4864
2 changed files with 9 additions and 22 deletions

View File

@ -947,19 +947,6 @@ void CSharpLanguage::free_instance_binding_data(void *p_data) {
#endif #endif
} }
void CSharpInstance::_ml_call_reversed(MonoObject *p_mono_object, GDMonoClass *p_klass, const StringName &p_method, const Variant **p_args, int p_argcount) {
GDMonoClass *base = p_klass->get_parent_class();
if (base && base != script->native)
_ml_call_reversed(p_mono_object, base, p_method, p_args, p_argcount);
GDMonoMethod *method = p_klass->get_method(p_method, p_argcount);
if (method) {
method->invoke(p_mono_object, p_args);
}
}
CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpScript *p_script, const Ref<MonoGCHandle> &p_gchandle) { CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpScript *p_script, const Ref<MonoGCHandle> &p_gchandle) {
CSharpInstance *instance = memnew(CSharpInstance); CSharpInstance *instance = memnew(CSharpInstance);
@ -1028,6 +1015,8 @@ bool CSharpInstance::set(const StringName &p_name, const Variant &p_value) {
if (ret && GDMonoMarshal::unbox<MonoBoolean>(ret) == true) if (ret && GDMonoMarshal::unbox<MonoBoolean>(ret) == true)
return true; return true;
break;
} }
top = top->get_parent_class(); top = top->get_parent_class();
@ -1088,6 +1077,8 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
r_ret = GDMonoMarshal::mono_object_to_variant(ret); r_ret = GDMonoMarshal::mono_object_to_variant(ret);
return true; return true;
} }
break;
} }
top = top->get_parent_class(); top = top->get_parent_class();
@ -1190,8 +1181,10 @@ void CSharpInstance::_call_multilevel(MonoObject *p_mono_object, const StringNam
while (top && top != script->native) { while (top && top != script->native) {
GDMonoMethod *method = top->get_method(p_method, p_argcount); GDMonoMethod *method = top->get_method(p_method, p_argcount);
if (method) if (method) {
method->invoke(p_mono_object, p_args); method->invoke(p_mono_object, p_args);
return;
}
top = top->get_parent_class(); top = top->get_parent_class();
} }
@ -1199,13 +1192,9 @@ void CSharpInstance::_call_multilevel(MonoObject *p_mono_object, const StringNam
void CSharpInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) { void CSharpInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
if (script.is_valid()) { // Sorry, the method is the one that controls the call order
MonoObject *mono_object = get_mono_object();
ERR_FAIL_NULL(mono_object); call_multilevel(p_method, p_args, p_argcount);
_ml_call_reversed(mono_object, script->script_class, p_method, p_args, p_argcount);
}
} }
void CSharpInstance::_reference_owner_unsafe() { void CSharpInstance::_reference_owner_unsafe() {

View File

@ -172,8 +172,6 @@ class CSharpInstance : public ScriptInstance {
bool base_ref; bool base_ref;
bool ref_dying; bool ref_dying;
void _ml_call_reversed(MonoObject *p_mono_object, GDMonoClass *klass, const StringName &p_method, const Variant **p_args, int p_argcount);
void _reference_owner_unsafe(); void _reference_owner_unsafe();
void _unreference_owner_unsafe(); void _unreference_owner_unsafe();