diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2018-01-18 11:23:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-18 11:23:50 +0100 |
commit | 9d45b719d4ed1f50c93f3234b31233ae5039987c (patch) | |
tree | fe5608de5b549ac21e04668e9f7a6778f82ed2ca /modules/mono/mono_gd/gd_mono_marshal.cpp | |
parent | 945248052cd35df2dcc2408fdd48f3ea511a0562 (diff) | |
parent | 2dc6725cc467a1aa17980a2aedcd84f6f0a477e2 (diff) | |
download | redot-engine-9d45b719d4ed1f50c93f3234b31233ae5039987c.tar.gz |
Merge pull request #15820 from paulloz/fix-csharp-call-with-object-return
Fix marshalling when a function is returning an object from c#
Diffstat (limited to 'modules/mono/mono_gd/gd_mono_marshal.cpp')
-rw-r--r-- | modules/mono/mono_gd/gd_mono_marshal.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 1ec8f41c91..aa1a8e39c7 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -459,11 +459,7 @@ Variant mono_object_to_variant(MonoObject *p_obj) { type.type_encoding = mono_type_get_type(raw_type); type.type_class = tclass; - return mono_object_to_variant(p_obj, type); -} - -Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) { - switch (p_type.type_encoding) { + switch (type.type_encoding) { case MONO_TYPE_BOOLEAN: return (bool)unbox<MonoBoolean>(p_obj); @@ -497,7 +493,7 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) { } break; case MONO_TYPE_VALUETYPE: { - GDMonoClass *tclass = p_type.type_class; + GDMonoClass *tclass = type.type_class; if (tclass == CACHED_CLASS(Vector2)) RETURN_UNBOXED_STRUCT(Vector2, p_obj); @@ -535,7 +531,7 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) { case MONO_TYPE_ARRAY: case MONO_TYPE_SZARRAY: { - MonoArrayType *array_type = mono_type_get_array_type(GDMonoClass::get_raw_type(p_type.type_class)); + MonoArrayType *array_type = mono_type_get_array_type(GDMonoClass::get_raw_type(type.type_class)); if (array_type->eklass == CACHED_CLASS_RAW(MonoObject)) return mono_array_to_Array((MonoArray *)p_obj); @@ -566,7 +562,7 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) { } break; case MONO_TYPE_CLASS: { - GDMonoClass *type_class = p_type.type_class; + GDMonoClass *type_class = type.type_class; // GodotObject if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) { @@ -586,14 +582,14 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) { } break; case MONO_TYPE_GENERICINST: { - if (CACHED_RAW_MONO_CLASS(Dictionary) == p_type.type_class->get_mono_ptr()) { + if (CACHED_RAW_MONO_CLASS(Dictionary) == type.type_class->get_mono_ptr()) { return mono_object_to_Dictionary(p_obj); } } break; } ERR_EXPLAIN(String() + "Attempted to convert an unmarshallable managed type to Variant. Name: \'" + - p_type.type_class->get_name() + "\' Encoding: " + itos(p_type.type_encoding)); + type.type_class->get_name() + "\' Encoding: " + itos(type.type_encoding)); ERR_FAIL_V(Variant()); } |