Skip to content

Commit

Permalink
Merge pull request #53577 from raulsntos/fix-mono-to-variant-array-3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Oct 15, 2021
2 parents 3ca8003 + ec2f86e commit 5ff8d0e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/mono/mono_gd/gd_mono_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions modules/mono/mono_gd/gd_mono_marshal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5ff8d0e

Please sign in to comment.