From da234cdbc6a86c2b447ae57a7a5ce2d8090543ea Mon Sep 17 00:00:00 2001 From: magian1127 <14800320+magian1127@users.noreply.github.com> Date: Mon, 18 Jan 2021 16:34:10 +0800 Subject: [PATCH] C # mono supports Unicode code --- modules/mono/csharp_script.cpp | 4 ++-- modules/mono/mono_gd/gd_mono_assembly.cpp | 4 ++-- modules/mono/mono_gd/gd_mono_class.cpp | 14 +++++++------- modules/mono/mono_gd/gd_mono_field.cpp | 2 +- modules/mono/mono_gd/gd_mono_property.cpp | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 18fe44108f..bd29dc1876 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2604,7 +2604,7 @@ void CSharpScript::load_script_signals(GDMonoClass *p_class, GDMonoClass *p_nati MonoCustomAttrInfo *event_attrs = mono_custom_attrs_from_event(top->get_mono_ptr(), raw_event); if (event_attrs) { if (mono_custom_attrs_has_attr(event_attrs, CACHED_CLASS(SignalAttribute)->get_mono_ptr())) { - const char *event_name = mono_event_get_name(raw_event); + String event_name = String::utf8(mono_event_get_name(raw_event)); found_event_signals.push_back(StringName(event_name)); } @@ -2808,7 +2808,7 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage name_only_hint_string += ","; } - String enum_field_name = mono_field_get_name(field); + String enum_field_name = String::utf8(mono_field_get_name(field)); r_hint_string += enum_field_name; name_only_hint_string += enum_field_name; diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp index c6920814b9..1fe06bfbee 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.cpp +++ b/modules/mono/mono_gd/gd_mono_assembly.cpp @@ -379,8 +379,8 @@ GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) { return match->value(); } - StringName namespace_name = mono_class_get_namespace(p_mono_class); - StringName class_name = mono_class_get_name(p_mono_class); + StringName namespace_name = String::utf8(mono_class_get_namespace(p_mono_class)); + StringName class_name = String::utf8(mono_class_get_name(p_mono_class)); GDMonoClass *wrapped_class = memnew(GDMonoClass(namespace_name, class_name, p_mono_class, this)); diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp index 0ed7fcf375..f9fddd931b 100644 --- a/modules/mono/mono_gd/gd_mono_class.cpp +++ b/modules/mono/mono_gd/gd_mono_class.cpp @@ -177,7 +177,7 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base void *iter = nullptr; MonoMethod *raw_method = nullptr; while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != nullptr) { - StringName name = mono_method_get_name(raw_method); + StringName name = String::utf8(mono_method_get_name(raw_method)); // get_method implicitly fetches methods and adds them to this->methods GDMonoMethod *method = get_method(raw_method, name); @@ -319,7 +319,7 @@ GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method) { MonoMethodSignature *sig = mono_method_signature(p_raw_method); int params_count = mono_signature_get_param_count(sig); - StringName method_name = mono_method_get_name(p_raw_method); + StringName method_name = String::utf8(mono_method_get_name(p_raw_method)); return get_method(p_raw_method, method_name, params_count); } @@ -392,7 +392,7 @@ const Vector &GDMonoClass::get_all_fields() { void *iter = nullptr; MonoClassField *raw_field = nullptr; while ((raw_field = mono_class_get_fields(mono_class, &iter)) != nullptr) { - StringName name = mono_field_get_name(raw_field); + StringName name = String::utf8(mono_field_get_name(raw_field)); Map::Element *match = fields.find(name); @@ -441,7 +441,7 @@ const Vector &GDMonoClass::get_all_properties() { void *iter = nullptr; MonoProperty *raw_property = nullptr; while ((raw_property = mono_class_get_properties(mono_class, &iter)) != nullptr) { - StringName name = mono_property_get_name(raw_property); + StringName name = String::utf8(mono_property_get_name(raw_property)); Map::Element *match = properties.find(name); @@ -468,14 +468,14 @@ const Vector &GDMonoClass::get_all_delegates() { MonoClass *raw_class = nullptr; while ((raw_class = mono_class_get_nested_types(mono_class, &iter)) != nullptr) { if (mono_class_is_delegate(raw_class)) { - StringName name = mono_class_get_name(raw_class); + StringName name = String::utf8(mono_class_get_name(raw_class)); Map::Element *match = delegates.find(name); if (match) { delegates_list.push_back(match->get()); } else { - GDMonoClass *delegate = memnew(GDMonoClass(mono_class_get_namespace(raw_class), mono_class_get_name(raw_class), raw_class, assembly)); + GDMonoClass *delegate = memnew(GDMonoClass(String::utf8(mono_class_get_namespace(raw_class)), String::utf8(mono_class_get_name(raw_class)), raw_class, assembly)); delegates.insert(name, delegate); delegates_list.push_back(delegate); } @@ -492,7 +492,7 @@ const Vector &GDMonoClass::get_all_methods() { void *iter = nullptr; MonoMethod *raw_method = nullptr; while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != nullptr) { - method_list.push_back(memnew(GDMonoMethod(mono_method_get_name(raw_method), raw_method))); + method_list.push_back(memnew(GDMonoMethod(String::utf8(mono_method_get_name(raw_method)), raw_method))); } method_list_fetched = true; diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp index d91bb8210f..1d4d52dfce 100644 --- a/modules/mono/mono_gd/gd_mono_field.cpp +++ b/modules/mono/mono_gd/gd_mono_field.cpp @@ -509,7 +509,7 @@ IMonoClassMember::Visibility GDMonoField::get_visibility() { GDMonoField::GDMonoField(MonoClassField *p_mono_field, GDMonoClass *p_owner) { owner = p_owner; mono_field = p_mono_field; - name = mono_field_get_name(mono_field); + name = String::utf8(mono_field_get_name(mono_field)); MonoType *field_type = mono_field_get_type(mono_field); type.type_encoding = mono_type_get_type(field_type); MonoClass *field_type_class = mono_class_from_mono_type(field_type); diff --git a/modules/mono/mono_gd/gd_mono_property.cpp b/modules/mono/mono_gd/gd_mono_property.cpp index dc3d225082..5391b7775e 100644 --- a/modules/mono/mono_gd/gd_mono_property.cpp +++ b/modules/mono/mono_gd/gd_mono_property.cpp @@ -40,7 +40,7 @@ GDMonoProperty::GDMonoProperty(MonoProperty *p_mono_property, GDMonoClass *p_owner) { owner = p_owner; mono_property = p_mono_property; - name = mono_property_get_name(mono_property); + name = String::utf8(mono_property_get_name(mono_property)); MonoMethod *prop_method = mono_property_get_get_method(mono_property);