diff options
| author | Ignacio Roldán Etcheverry <ignalfonsore@gmail.com> | 2021-10-19 00:26:56 +0200 |
|---|---|---|
| committer | Ignacio Roldán Etcheverry <ignalfonsore@gmail.com> | 2021-10-19 00:33:51 +0200 |
| commit | cad05f012d9260803d9ce2afe644fb99cf72bf6d (patch) | |
| tree | 4734f3ed9b71eee2fd28295c1400bd59332878fc /modules/mono/mono_gd/gd_mono_property.cpp | |
| parent | 5bb3dbbedd4f32974eef36ffc83bbe29abb65ab1 (diff) | |
| download | redot-engine-cad05f012d9260803d9ce2afe644fb99cf72bf6d.tar.gz | |
C#: Fix property set call boxing value when unboxed was expected
Diffstat (limited to 'modules/mono/mono_gd/gd_mono_property.cpp')
| -rw-r--r-- | modules/mono/mono_gd/gd_mono_property.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/modules/mono/mono_gd/gd_mono_property.cpp b/modules/mono/mono_gd/gd_mono_property.cpp index 5391b7775e..5c7cf29e88 100644 --- a/modules/mono/mono_gd/gd_mono_property.cpp +++ b/modules/mono/mono_gd/gd_mono_property.cpp @@ -65,6 +65,8 @@ GDMonoProperty::GDMonoProperty(MonoProperty *p_mono_property, GDMonoClass *p_own type.type_class = GDMono::get_singleton()->get_class(param_type_class); } + param_buffer_size = GDMonoMarshal::variant_get_managed_unboxed_size(type); + attrs_fetched = false; attributes = nullptr; } @@ -147,24 +149,20 @@ bool GDMonoProperty::has_setter() { return mono_property_get_set_method(mono_property) != nullptr; } -void GDMonoProperty::set_value(MonoObject *p_object, MonoObject *p_value, MonoException **r_exc) { - MonoMethod *prop_method = mono_property_get_set_method(mono_property); - void *params[1] = { p_value }; - MonoException *exc = nullptr; - GDMonoUtils::runtime_invoke(prop_method, p_object, params, &exc); - if (exc) { - if (r_exc) { - *r_exc = exc; - } else { - GDMonoUtils::set_pending_exception(exc); - } - } -} +void GDMonoProperty::set_value_from_variant(MonoObject *p_object, const Variant &p_value, MonoException **r_exc) { + uint8_t *buffer = (uint8_t *)alloca(param_buffer_size); + unsigned int offset = 0; -void GDMonoProperty::set_value(MonoObject *p_object, void **p_params, MonoException **r_exc) { - MonoException *exc = nullptr; - GDMonoUtils::property_set_value(mono_property, p_object, p_params, &exc); + void *params[1] = { + GDMonoMarshal::variant_to_managed_unboxed(p_value, type, buffer, offset) + }; + +#ifdef DEBUG_ENABLED + CRASH_COND(offset != param_buffer_size); +#endif + MonoException *exc = nullptr; + GDMonoUtils::property_set_value(mono_property, p_object, params, &exc); if (exc) { if (r_exc) { *r_exc = exc; |
