From ec2f86ec9a381a9b036a6afc392258d01c332fcd Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Fri, 8 Oct 2021 18:52:40 +0200 Subject: [PATCH] Support arrays of StringName, NodePath and RID in mono --- modules/mono/mono_gd/gd_mono_field.cpp | 10 ++++++++++ modules/mono/mono_gd/gd_mono_marshal.cpp | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp index f19cc88f3f9..0a25b4b61f9 100644 --- a/modules/mono/mono_gd/gd_mono_field.cpp +++ b/modules/mono/mono_gd/gd_mono_field.cpp @@ -281,6 +281,16 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_ break; } + if (array_type->eklass == CACHED_CLASS_RAW(NodePath)) { + SET_FROM_ARRAY(Array); + break; + } + + if (array_type->eklass == CACHED_CLASS_RAW(RID)) { + SET_FROM_ARRAY(Array); + break; + } + GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass); if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class)) { MonoArray *managed = GDMonoMarshal::Array_to_mono_array(p_value.operator ::Array(), array_type_class); diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 40c6b4ed656..2325230a99d 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -133,6 +133,12 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) { if (array_type->eklass == CACHED_CLASS_RAW(Color)) return Variant::POOL_COLOR_ARRAY; + if (array_type->eklass == CACHED_CLASS_RAW(NodePath)) + return Variant::ARRAY; + + if (array_type->eklass == CACHED_CLASS_RAW(RID)) + return Variant::ARRAY; + GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass); if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class)) return Variant::ARRAY; @@ -511,6 +517,12 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty if (array_type->eklass == CACHED_CLASS_RAW(Color)) return (MonoObject *)PoolColorArray_to_mono_array(p_var->operator PoolColorArray()); + if (array_type->eklass == CACHED_CLASS_RAW(NodePath)) + return (MonoObject *)Array_to_mono_array(p_var->operator Array()); + + if (array_type->eklass == CACHED_CLASS_RAW(RID)) + return (MonoObject *)Array_to_mono_array(p_var->operator Array()); + GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass); if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class)) return (MonoObject *)Array_to_mono_array(p_var->operator Array(), array_type_class); @@ -794,6 +806,12 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type if (array_type->eklass == CACHED_CLASS_RAW(Color)) return mono_array_to_PoolColorArray((MonoArray *)p_obj); + if (array_type->eklass == CACHED_CLASS_RAW(NodePath)) + return mono_array_to_Array((MonoArray *)p_obj); + + if (array_type->eklass == CACHED_CLASS_RAW(RID)) + return mono_array_to_Array((MonoArray *)p_obj); + GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass); if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class)) return mono_array_to_Array((MonoArray *)p_obj);