Marshal NULL MonoString* as empty Godot string
This commit is contained in:
parent
9969c5c6a1
commit
6e3d4ee9a6
@ -54,7 +54,7 @@ String generate_core_api_project(const String &p_dir, const Vector<String> &p_fi
|
||||
ERR_FAIL_V(String());
|
||||
}
|
||||
|
||||
return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : "";
|
||||
return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : String();
|
||||
}
|
||||
|
||||
String generate_editor_api_project(const String &p_dir, const String &p_core_dll_path, const Vector<String> &p_files) {
|
||||
@ -75,7 +75,7 @@ String generate_editor_api_project(const String &p_dir, const String &p_core_dll
|
||||
ERR_FAIL_V(String());
|
||||
}
|
||||
|
||||
return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : "";
|
||||
return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : String();
|
||||
}
|
||||
|
||||
String generate_game_project(const String &p_dir, const String &p_name, const Vector<String> &p_files) {
|
||||
@ -96,7 +96,7 @@ String generate_game_project(const String &p_dir, const String &p_name, const Ve
|
||||
ERR_FAIL_V(String());
|
||||
}
|
||||
|
||||
return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : "";
|
||||
return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : String();
|
||||
}
|
||||
|
||||
void add_item(const String &p_project_path, const String &p_item_type, const String &p_include) {
|
||||
|
@ -290,7 +290,7 @@ int GDMonoField::get_int_value(MonoObject *p_object) {
|
||||
|
||||
String GDMonoField::get_string_value(MonoObject *p_object) {
|
||||
MonoObject *val = get_value(p_object);
|
||||
return val ? GDMonoMarshal::mono_string_to_godot((MonoString *)val) : String();
|
||||
return GDMonoMarshal::mono_string_to_godot((MonoString *)val);
|
||||
}
|
||||
|
||||
bool GDMonoField::has_attribute(GDMonoClass *p_attr_class) {
|
||||
|
@ -490,8 +490,9 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
|
||||
return unbox<double>(p_obj);
|
||||
|
||||
case MONO_TYPE_STRING: {
|
||||
String str = mono_string_to_godot((MonoString *)p_obj);
|
||||
return str;
|
||||
if (p_obj == NULL)
|
||||
return Variant(); // NIL
|
||||
return mono_string_to_godot_not_null((MonoString *)p_obj);
|
||||
} break;
|
||||
|
||||
case MONO_TYPE_VALUETYPE: {
|
||||
|
@ -62,13 +62,20 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type);
|
||||
String mono_to_utf8_string(MonoString *p_mono_string);
|
||||
String mono_to_utf16_string(MonoString *p_mono_string);
|
||||
|
||||
_FORCE_INLINE_ String mono_string_to_godot(MonoString *p_mono_string) {
|
||||
_FORCE_INLINE_ String mono_string_to_godot_not_null(MonoString *p_mono_string) {
|
||||
if (sizeof(CharType) == 2)
|
||||
return mono_to_utf16_string(p_mono_string);
|
||||
|
||||
return mono_to_utf8_string(p_mono_string);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ String mono_string_to_godot(MonoString *p_mono_string) {
|
||||
if (p_mono_string == NULL)
|
||||
return String();
|
||||
|
||||
return mono_string_to_godot_not_null(p_mono_string);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ MonoString *mono_from_utf8_string(const String &p_string) {
|
||||
return mono_string_new(mono_domain_get(), p_string.utf8().get_data());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user