From 22358e7ced8fc68d760e162ef313d04660400997 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Mon, 17 Jul 2023 15:21:03 -0300 Subject: [PATCH] Fix array of string properties. And probably other non-nullable array properties. Tests already exists but the bug was hidden by the existence of a setter method that was overwriting the buggy property setter method. --- ecr/property.ecr | 1 + spec/libtest/test_subject.c | 2 ++ spec/libtest/test_subject.h | 8 -------- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/ecr/property.ecr b/ecr/property.ecr index 77ff401..f775d65 100644 --- a/ecr/property.ecr +++ b/ecr/property.ecr @@ -2,6 +2,7 @@ def <%= to_call(prop.name) %>=(value : <%= prop_type_name %>) : <%= prop_type_name %> <% if prop.type_info.array? -%> # handle array + unsafe_value = value.to_a.map(&.to_unsafe).to_unsafe <% else -%> unsafe_value = value <% end %> diff --git a/spec/libtest/test_subject.c b/spec/libtest/test_subject.c index 33d5818..208a18f 100644 --- a/spec/libtest/test_subject.c +++ b/spec/libtest/test_subject.c @@ -27,6 +27,8 @@ static void test_subject_iface_interface_init(TestIfaceInterface* iface) { G_DEFINE_TYPE_WITH_CODE(TestSubject, test_subject, G_TYPE_OBJECT, G_ADD_PRIVATE(TestSubject) G_IMPLEMENT_INTERFACE(TEST_TYPE_IFACE, test_subject_iface_interface_init)) +void test_subject_set_str_list(TestSubject* self, const char** list); + typedef enum { PROP_STRING = 1, PROP_BOOLEAN, diff --git a/spec/libtest/test_subject.h b/spec/libtest/test_subject.h index 978570e..86afe5b 100644 --- a/spec/libtest/test_subject.h +++ b/spec/libtest/test_subject.h @@ -105,14 +105,6 @@ void test_subject_set_simple_func(TestSubject* self, TestSubjectSimpleFunc func, */ gboolean test_subject_call_simple_func(TestSubject* self, int number); -/** - * test_subject_set_str_list: - * @list: (array zero-terminated=1): - * - * Setter for str_list property. - */ -void test_subject_set_str_list(TestSubject* self, const char** list); - /** * test_subject_may_return_null: * @return_nil: