summaryrefslogtreecommitdiff
path: root/modules/mono/glue/gd_glue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/glue/gd_glue.cpp')
-rw-r--r--modules/mono/glue/gd_glue.cpp96
1 files changed, 81 insertions, 15 deletions
diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp
index 041d29c7bf..9bea625450 100644
--- a/modules/mono/glue/gd_glue.cpp
+++ b/modules/mono/glue/gd_glue.cpp
@@ -71,48 +71,114 @@ MonoObject *godot_icall_GD_instance_from_id(uint64_t p_instance_id) {
}
void godot_icall_GD_print(MonoArray *p_what) {
- Array what = GDMonoMarshal::mono_array_to_Array(p_what);
String str;
- for (int i = 0; i < what.size(); i++)
- str += what[i].operator String();
+ int length = mono_array_length(p_what);
+
+ for (int i = 0; i < length; i++) {
+ MonoObject *elem = mono_array_get(p_what, MonoObject *, i);
+
+ MonoException *exc = NULL;
+ String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc);
+
+ if (exc) {
+ GDMonoUtils::set_pending_exception(exc);
+ return;
+ }
+
+ str += elem_str;
+ }
+
print_line(str);
}
void godot_icall_GD_printerr(MonoArray *p_what) {
- Array what = GDMonoMarshal::mono_array_to_Array(p_what);
+
String str;
- for (int i = 0; i < what.size(); i++)
- str += what[i].operator String();
+ int length = mono_array_length(p_what);
+
+ for (int i = 0; i < length; i++) {
+ MonoObject *elem = mono_array_get(p_what, MonoObject *, i);
+
+ MonoException *exc = NULL;
+ String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc);
+
+ if (exc) {
+ GDMonoUtils::set_pending_exception(exc);
+ return;
+ }
+
+ str += elem_str;
+ }
+
print_error(str);
}
void godot_icall_GD_printraw(MonoArray *p_what) {
- Array what = GDMonoMarshal::mono_array_to_Array(p_what);
String str;
- for (int i = 0; i < what.size(); i++)
- str += what[i].operator String();
+ int length = mono_array_length(p_what);
+
+ for (int i = 0; i < length; i++) {
+ MonoObject *elem = mono_array_get(p_what, MonoObject *, i);
+
+ MonoException *exc = NULL;
+ String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc);
+
+ if (exc) {
+ GDMonoUtils::set_pending_exception(exc);
+ return;
+ }
+
+ str += elem_str;
+ }
+
OS::get_singleton()->print("%s", str.utf8().get_data());
}
void godot_icall_GD_prints(MonoArray *p_what) {
- Array what = GDMonoMarshal::mono_array_to_Array(p_what);
String str;
- for (int i = 0; i < what.size(); i++) {
+ int length = mono_array_length(p_what);
+
+ for (int i = 0; i < length; i++) {
+ MonoObject *elem = mono_array_get(p_what, MonoObject *, i);
+
+ MonoException *exc = NULL;
+ String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc);
+
+ if (exc) {
+ GDMonoUtils::set_pending_exception(exc);
+ return;
+ }
+
if (i)
str += " ";
- str += what[i].operator String();
+
+ str += elem_str;
}
+
print_line(str);
}
void godot_icall_GD_printt(MonoArray *p_what) {
- Array what = GDMonoMarshal::mono_array_to_Array(p_what);
String str;
- for (int i = 0; i < what.size(); i++) {
+ int length = mono_array_length(p_what);
+
+ for (int i = 0; i < length; i++) {
+ MonoObject *elem = mono_array_get(p_what, MonoObject *, i);
+
+ MonoException *exc = NULL;
+ String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc);
+
+ if (exc) {
+ GDMonoUtils::set_pending_exception(exc);
+ return;
+ }
+
if (i)
str += "\t";
- str += what[i].operator String();
+
+ str += elem_str;
}
+
print_line(str);
}