static void OutputExceptionDetails(MonoObject* exc) { MonoClass* eclass = mono_object_get_class(exc); if (eclass) { MonoObject* toStringExc = nullptr; MonoString* msg = mono_object_to_string(exc, &toStringExc); MonoProperty* prop = mono_class_get_property_from_name(eclass, "StackTrace"); MonoMethod* getter = mono_property_get_get_method(prop); MonoString* msg2 = (MonoString*)mono_runtime_invoke(getter, exc, NULL, NULL); if (toStringExc) { MonoProperty* prop = mono_class_get_property_from_name(eclass, "Message"); MonoMethod* getter = mono_property_get_get_method(prop); msg = (MonoString*)mono_runtime_invoke(getter, exc, NULL, NULL); } GlobalError("Unhandled exception in Mono script environment: %s %s", mono_string_to_utf8(msg), mono_string_to_utf8(msg2)); } }
GDMonoProperty::GDMonoProperty(MonoProperty *p_mono_property, GDMonoClass *p_owner) { owner = p_owner; mono_property = p_mono_property; name = mono_property_get_name(mono_property); MonoMethod *prop_method = mono_property_get_get_method(mono_property); if (prop_method) { MonoMethodSignature *getter_sig = mono_method_signature(prop_method); MonoType *ret_type = mono_signature_get_return_type(getter_sig); type.type_encoding = mono_type_get_type(ret_type); MonoClass *ret_type_class = mono_class_from_mono_type(ret_type); type.type_class = GDMono::get_singleton()->get_class(ret_type_class); } else { prop_method = mono_property_get_set_method(mono_property); MonoMethodSignature *setter_sig = mono_method_signature(prop_method); void *iter = NULL; MonoType *param_raw_type = mono_signature_get_params(setter_sig, &iter); type.type_encoding = mono_type_get_type(param_raw_type); MonoClass *param_type_class = mono_class_from_mono_type(param_raw_type); type.type_class = GDMono::get_singleton()->get_class(param_type_class); } attrs_fetched = false; attributes = NULL; }
GDMonoClassMember::Visibility GDMonoProperty::get_visibility() { MonoMethod *prop_method = mono_property_get_get_method(mono_property); if (prop_method == NULL) prop_method = mono_property_get_set_method(mono_property); switch (mono_method_get_flags(prop_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); } }
bool GDMonoProperty::is_static() { MonoMethod *prop_method = mono_property_get_get_method(mono_property); if (prop_method == NULL) prop_method = mono_property_get_set_method(mono_property); return mono_method_get_flags(prop_method, NULL) & MONO_METHOD_ATTR_STATIC; }
bool GDMonoProperty::has_getter() { return mono_property_get_get_method(mono_property) != NULL; }
mioMethod mioProperty::getGetter() const { if (!mproperty) { return nullptr; } return mono_property_get_get_method(mproperty); }
MonoProperty *CScriptClass::GetMonoProperty(const char *name, bool requireSetter, bool requireGetter) { MonoClass *pClass = (MonoClass *)m_pObject; MonoProperty *pCurProperty = nullptr; void *pIterator = 0; while (pClass != nullptr) { pCurProperty = mono_class_get_properties(pClass, &pIterator); if(pCurProperty == nullptr) { pClass = mono_class_get_parent(pClass); if(pClass == mono_get_object_class()) break; pIterator = 0; continue; } if(!strcmp(mono_property_get_name(pCurProperty), name)) { if(requireSetter && mono_property_get_set_method(pCurProperty) == nullptr) continue; if(requireGetter && mono_property_get_get_method(pCurProperty) == nullptr) continue; return pCurProperty; } } return nullptr; }