diff options
Diffstat (limited to 'modules/mono/mono_gd/gd_mono_method.cpp')
-rw-r--r-- | modules/mono/mono_gd/gd_mono_method.cpp | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/modules/mono/mono_gd/gd_mono_method.cpp b/modules/mono/mono_gd/gd_mono_method.cpp index 01afd1e51e..467cdbcc20 100644 --- a/modules/mono/mono_gd/gd_mono_method.cpp +++ b/modules/mono/mono_gd/gd_mono_method.cpp @@ -32,6 +32,8 @@ #include "gd_mono_class.h" #include "gd_mono_marshal.h" +#include <mono/metadata/attrdefs.h> + void GDMonoMethod::_update_signature() { // Apparently MonoMethodSignature needs not to be freed. // mono_method_signature caches the result, we don't need to cache it ourselves. @@ -41,7 +43,6 @@ void GDMonoMethod::_update_signature() { } void GDMonoMethod::_update_signature(MonoMethodSignature *p_method_sig) { - is_instance = mono_signature_is_instance(p_method_sig); params_count = mono_signature_get_param_count(p_method_sig); MonoType *ret_type = mono_signature_get_return_type(p_method_sig); @@ -61,15 +62,34 @@ void GDMonoMethod::_update_signature(MonoMethodSignature *p_method_sig) { param_type.type_encoding = mono_type_get_type(param_raw_type); - if (param_type.type_encoding != MONO_TYPE_VOID) { - MonoClass *param_type_class = mono_class_from_mono_type(param_raw_type); - param_type.type_class = GDMono::get_singleton()->get_class(param_type_class); - } + MonoClass *param_type_class = mono_class_from_mono_type(param_raw_type); + param_type.type_class = GDMono::get_singleton()->get_class(param_type_class); param_types.push_back(param_type); } } +bool GDMonoMethod::is_static() { + return mono_method_get_flags(mono_method, NULL) & MONO_METHOD_ATTR_STATIC; +} + +GDMonoClassMember::Visibility GDMonoMethod::get_visibility() { + switch (mono_method_get_flags(mono_method, NULL) & MONO_METHOD_ATTR_ACCESS_MASK) { + case MONO_METHOD_ATTR_PRIVATE: + return GDMonoClassMember::PRIVATE; + case MONO_METHOD_ATTR_FAM_AND_ASSEM: + return GDMonoClassMember::PROTECTED_AND_INTERNAL; + case MONO_METHOD_ATTR_ASSEM: + return GDMonoClassMember::INTERNAL; + case MONO_METHOD_ATTR_FAMILY: + return GDMonoClassMember::PROTECTED; + case MONO_METHOD_ATTR_PUBLIC: + return GDMonoClassMember::PUBLIC; + default: + ERR_FAIL_V(GDMonoClassMember::PRIVATE); + } +} + void *GDMonoMethod::get_thunk() { return mono_method_get_unmanaged_thunk(mono_method); } @@ -87,11 +107,11 @@ MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, MonoObject *ret = mono_runtime_invoke_array(mono_method, p_object, params, &exc); if (exc) { + ret = NULL; if (r_exc) { *r_exc = exc; } else { - ERR_PRINT(GDMonoUtils::get_exception_name_and_message(exc).utf8()); - mono_print_unhandled_exception(exc); + GDMonoUtils::print_unhandled_exception(exc); } } @@ -104,8 +124,7 @@ MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, if (r_exc) { *r_exc = exc; } else { - ERR_PRINT(GDMonoUtils::get_exception_name_and_message(exc).utf8()); - mono_print_unhandled_exception(exc); + GDMonoUtils::print_unhandled_exception(exc); } } @@ -123,11 +142,11 @@ MonoObject *GDMonoMethod::invoke_raw(MonoObject *p_object, void **p_params, Mono MonoObject *ret = mono_runtime_invoke(mono_method, p_object, p_params, &exc); if (exc) { + ret = NULL; if (r_exc) { *r_exc = exc; } else { - ERR_PRINT(GDMonoUtils::get_exception_name_and_message(exc).utf8()); - mono_print_unhandled_exception(exc); + GDMonoUtils::print_unhandled_exception(exc); } } @@ -143,7 +162,7 @@ bool GDMonoMethod::has_attribute(GDMonoClass *p_attr_class) { if (!attributes) return false; - return mono_custom_attrs_has_attr(attributes, p_attr_class->get_raw()); + return mono_custom_attrs_has_attr(attributes, p_attr_class->get_mono_ptr()); } MonoObject *GDMonoMethod::get_attribute(GDMonoClass *p_attr_class) { @@ -155,7 +174,7 @@ MonoObject *GDMonoMethod::get_attribute(GDMonoClass *p_attr_class) { if (!attributes) return NULL; - return mono_custom_attrs_get_attr(attributes, p_attr_class->get_raw()); + return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr()); } void GDMonoMethod::fetch_attributes() { |