Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Support arrays of NodePath and RID in mono #53577

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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