summaryrefslogtreecommitdiff
path: root/src/libical-glib
diff options
context:
space:
mode:
authorCorentin Noël <corentin.noel@collabora.com>2022-09-05 11:08:15 +0200
committerAllen Winter <allen.winter@kdab.com>2022-10-04 16:14:23 -0400
commit537642936828ec21c1fb5543dfe85d9898ed9232 (patch)
treeab3d213a494e2b13de278ed6585d861f30d8f54a /src/libical-glib
parent265348a09e1e04f6209e24d5667948779d61bf96 (diff)
downloadlibical-git-537642936828ec21c1fb5543dfe85d9898ed9232.tar.gz
libical-glib/recurrence: Return arrays with the right computed size.
Consumers of this API are expecting the array to already have the right size. Do the work for them and return a well-size array.
Diffstat (limited to 'src/libical-glib')
-rw-r--r--src/libical-glib/api/i-cal-recurrence.xml99
1 files changed, 81 insertions, 18 deletions
diff --git a/src/libical-glib/api/i-cal-recurrence.xml b/src/libical-glib/api/i-cal-recurrence.xml
index ce019dd4..70dfe838 100644
--- a/src/libical-glib/api/i-cal-recurrence.xml
+++ b/src/libical-glib/api/i-cal-recurrence.xml
@@ -191,11 +191,18 @@
<method name="i_cal_recurrence_get_by_second_array" corresponds="CUSTOM" kind="get" since="1.0">
<parameter type="ICalRecurrence *" name="recur" comment="The #ICalRecurrence"/>
<returns type="GArray *" annotation="transfer full, element-type gshort" comment="The by_second of #ICalRecurrence."/>
- <comment>Gets the by_second array from #ICalRecurrence. The array size if I_CAL_BY_SECOND_SIZE.</comment>
+ <comment>Gets the by_second array from #ICalRecurrence. The array has a maximum size of I_CAL_BY_SECOND_SIZE.</comment>
<custom> GArray *array;
+ struct icalrecurrencetype *native_recurrence;
+ guint size;
g_return_val_if_fail (recur != NULL &amp;&amp; I_CAL_IS_RECURRENCE (recur), NULL);
+ native_recurrence = (struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur);
array = g_array_new (FALSE, TRUE, sizeof (gshort));
- g_array_append_vals (array, ((struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur))->by_second, I_CAL_BY_SECOND_SIZE);
+ for (size = 0; size &lt; I_CAL_BY_SECOND_SIZE; size++) {
+ if (native_recurrence->by_second[size] == I_CAL_RECURRENCE_ARRAY_MAX)
+ break;
+ }
+ g_array_append_vals (array, native_recurrence->by_second, size);
return array;</custom>
</method>
<method name="i_cal_recurrence_set_by_second_array" corresponds="CUSTOM" kind="set" since="1.0">
@@ -238,11 +245,18 @@
<method name="i_cal_recurrence_get_by_minute_array" corresponds="CUSTOM" kind="get" since="1.0">
<parameter type="ICalRecurrence *" name="recur" comment="The #ICalRecurrence"/>
<returns type="GArray *" annotation="transfer full, element-type gshort" comment="The by_minute of #ICalRecurrence."/>
- <comment>Gets the by_minute array from #ICalRecurrence. The array size is I_CAL_BY_MINUTE_SIZE.</comment>
+ <comment>Gets the by_minute array from #ICalRecurrence. The array has a maximum size of I_CAL_BY_MINUTE_SIZE.</comment>
<custom> GArray *array;
+ struct icalrecurrencetype *native_recurrence;
+ guint size;
g_return_val_if_fail (recur != NULL &amp;&amp; I_CAL_IS_RECURRENCE (recur), NULL);
+ native_recurrence = (struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur);
array = g_array_new (FALSE, FALSE, sizeof (gshort));
- g_array_append_vals (array, ((struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur))->by_minute, I_CAL_BY_MINUTE_SIZE);
+ for (size = 0; size &lt; I_CAL_BY_MINUTE_SIZE; size++) {
+ if (native_recurrence->by_minute[size] == I_CAL_RECURRENCE_ARRAY_MAX)
+ break;
+ }
+ g_array_append_vals (array, native_recurrence->by_minute, size);
return array;</custom>
</method>
<method name="i_cal_recurrence_set_by_minute_array" corresponds="CUSTOM" kind="set" since="1.0">
@@ -285,11 +299,18 @@
<method name="i_cal_recurrence_get_by_hour_array" corresponds="CUSTOM" kind="get" since="1.0">
<parameter type="ICalRecurrence *" name="recur" comment="The #ICalRecurrence"/>
<returns type="GArray *" annotation="transfer full, element-type gshort" comment="The by_hour of #ICalRecurrence."/>
- <comment>Gets the by_hour array from #ICalRecurrence. The array size is I_CAL_BY_HOUR_SIZE.</comment>
+ <comment>Gets the by_hour array from #ICalRecurrence. The array has a maximum size of I_CAL_BY_HOUR_SIZE.</comment>
<custom> GArray *array;
+ struct icalrecurrencetype *native_recurrence;
+ guint size;
g_return_val_if_fail (recur != NULL &amp;&amp; I_CAL_IS_RECURRENCE (recur), NULL);
array = g_array_new (FALSE, FALSE, sizeof (gshort));
- g_array_append_vals (array, ((struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur))->by_hour, I_CAL_BY_HOUR_SIZE);
+ native_recurrence = (struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur);
+ for (size = 0; size &lt; I_CAL_BY_HOUR_SIZE; size++) {
+ if (native_recurrence->by_hour[size] == I_CAL_RECURRENCE_ARRAY_MAX)
+ break;
+ }
+ g_array_append_vals (array, native_recurrence->by_hour, size);
return array;</custom>
</method>
<method name="i_cal_recurrence_set_by_hour_array" corresponds="CUSTOM" kind="set" since="1.0">
@@ -332,11 +353,18 @@
<method name="i_cal_recurrence_get_by_day_array" corresponds="CUSTOM" kind="get" since="1.0">
<parameter type="ICalRecurrence *" name="recur" comment="The #ICalRecurrence"/>
<returns type="GArray *" annotation="transfer full, element-type gshort" comment="The by_day of #ICalRecurrence."/>
- <comment>Gets the by_day array from #ICalRecurrence. The array size is I_CAL_BY_DAY_SIZE.</comment>
+ <comment>Gets the by_day array from #ICalRecurrence. The array has a maximum size of I_CAL_BY_DAY_SIZE.</comment>
<custom> GArray *array;
+ struct icalrecurrencetype *native_recurrence;
+ guint size;
g_return_val_if_fail (recur != NULL &amp;&amp; I_CAL_IS_RECURRENCE (recur), NULL);
array = g_array_new (FALSE, FALSE, sizeof (gshort));
- g_array_append_vals (array, ((struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur))->by_day, I_CAL_BY_DAY_SIZE);
+ native_recurrence = (struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur);
+ for (size = 0; size &lt; I_CAL_BY_DAY_SIZE; size++) {
+ if (native_recurrence->by_day[size] == I_CAL_RECURRENCE_ARRAY_MAX)
+ break;
+ }
+ g_array_append_vals (array, native_recurrence->by_day, size);
return array;</custom>
</method>
<method name="i_cal_recurrence_set_by_day_array" corresponds="CUSTOM" kind="set" since="1.0">
@@ -379,11 +407,18 @@
<method name="i_cal_recurrence_get_by_month_day_array" corresponds="CUSTOM" kind="get" since="1.0">
<parameter type="ICalRecurrence *" name="recur" comment="The #ICalRecurrence"/>
<returns type="GArray *" annotation="transfer full, element-type gshort" comment="The by_month_day of #ICalRecurrence."/>
- <comment>Gets the by_month_day array from #ICalRecurrence. The array size is I_CAL_BY_MONTHDAY_SIZE.</comment>
+ <comment>Gets the by_month_day array from #ICalRecurrence. The array has a maximum size of I_CAL_BY_MONTHDAY_SIZE.</comment>
<custom> GArray *array;
+ struct icalrecurrencetype *native_recurrence;
+ guint size;
g_return_val_if_fail (recur != NULL &amp;&amp; I_CAL_IS_RECURRENCE (recur), NULL);
array = g_array_new (FALSE, FALSE, sizeof (gshort));
- g_array_append_vals (array, ((struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur))->by_month_day, I_CAL_BY_MONTHDAY_SIZE);
+ native_recurrence = (struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur);
+ for (size = 0; size &lt; I_CAL_BY_MONTHDAY_SIZE; size++) {
+ if (native_recurrence->by_month_day[size] == I_CAL_RECURRENCE_ARRAY_MAX)
+ break;
+ }
+ g_array_append_vals (array, native_recurrence->by_month_day, size);
return array;</custom>
</method>
<method name="i_cal_recurrence_set_by_month_day_array" corresponds="CUSTOM" kind="set" since="1.0">
@@ -426,11 +461,18 @@
<method name="i_cal_recurrence_get_by_year_day_array" corresponds="CUSTOM" kind="get" since="1.0">
<parameter type="ICalRecurrence *" name="recur" comment="The #ICalRecurrence"/>
<returns type="GArray *" annotation="transfer full, element-type gshort" comment="The by_year_day of #ICalRecurrence."/>
- <comment>Gets the by_year_day array from #ICalRecurrence. The array size is I_CAL_BY_YEARDAY_SIZE.</comment>
+ <comment>Gets the by_year_day array from #ICalRecurrence. The array has a maximum size of I_CAL_BY_YEARDAY_SIZE.</comment>
<custom> GArray *array;
+ struct icalrecurrencetype *native_recurrence;
+ guint size;
g_return_val_if_fail (recur != NULL &amp;&amp; I_CAL_IS_RECURRENCE (recur), NULL);
array = g_array_new (FALSE, FALSE, sizeof (gshort));
- g_array_append_vals (array, ((struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur))->by_year_day, I_CAL_BY_YEARDAY_SIZE);
+ native_recurrence = (struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur);
+ for (size = 0; size &lt; I_CAL_BY_YEARDAY_SIZE; size++) {
+ if (native_recurrence->by_year_day[size] == I_CAL_RECURRENCE_ARRAY_MAX)
+ break;
+ }
+ g_array_append_vals (array, native_recurrence->by_year_day, size);
return array;</custom>
</method>
<method name="i_cal_recurrence_set_by_year_day_array" corresponds="CUSTOM" kind="set" since="1.0">
@@ -473,11 +515,18 @@
<method name="i_cal_recurrence_get_by_week_no_array" corresponds="CUSTOM" kind="get" since="1.0">
<parameter type="ICalRecurrence *" name="recur" comment="The #ICalRecurrence"/>
<returns type="GArray *" annotation="transfer full, element-type gshort" comment="The by_week_no of #ICalRecurrence."/>
- <comment>Gets the by_week_no array from #ICalRecurrence. The array size is I_CAL_BY_WEEKNO_SIZE.</comment>
+ <comment>Gets the by_week_no array from #ICalRecurrence. The array has a maximum size of I_CAL_BY_WEEKNO_SIZE.</comment>
<custom> GArray *array;
+ struct icalrecurrencetype *native_recurrence;
+ guint size;
g_return_val_if_fail (recur != NULL &amp;&amp; I_CAL_IS_RECURRENCE (recur), NULL);
array = g_array_new (FALSE, FALSE, sizeof (gshort));
- g_array_append_vals (array, ((struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur))->by_week_no, I_CAL_BY_WEEKNO_SIZE);
+ native_recurrence = (struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur);
+ for (size = 0; size &lt; I_CAL_BY_WEEKNO_SIZE; size++) {
+ if (native_recurrence->by_week_no[size] == I_CAL_RECURRENCE_ARRAY_MAX)
+ break;
+ }
+ g_array_append_vals (array, native_recurrence->by_week_no, size);
return array;</custom>
</method>
<method name="i_cal_recurrence_set_by_week_no_array" corresponds="CUSTOM" kind="set" since="1.0">
@@ -520,11 +569,18 @@
<method name="i_cal_recurrence_get_by_month_array" corresponds="CUSTOM" kind="get" since="1.0">
<parameter type="ICalRecurrence *" name="recur" comment="The #ICalRecurrence"/>
<returns type="GArray *" annotation="transfer full, element-type gshort" comment="The by_month of #ICalRecurrence."/>
- <comment>Gets the by_month array from #ICalRecurrence. The array size is I_CAL_BY_MONTH_SIZE.</comment>
+ <comment>Gets the by_month array from #ICalRecurrence. The array has a maximum size of I_CAL_BY_MONTH_SIZE.</comment>
<custom> GArray *array;
+ struct icalrecurrencetype *native_recurrence;
+ guint size;
g_return_val_if_fail (recur != NULL &amp;&amp; I_CAL_IS_RECURRENCE (recur), NULL);
array = g_array_new (FALSE, FALSE, sizeof (gshort));
- g_array_append_vals (array, ((struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur))->by_month, I_CAL_BY_MONTH_SIZE);
+ native_recurrence = (struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur);
+ for (size = 0; size &lt; I_CAL_BY_MONTH_SIZE; size++) {
+ if (native_recurrence->by_month[size] == I_CAL_RECURRENCE_ARRAY_MAX)
+ break;
+ }
+ g_array_append_vals (array, native_recurrence->by_month, size);
return array;</custom>
</method>
<method name="i_cal_recurrence_set_by_month_array" corresponds="CUSTOM" kind="set" since="1.0">
@@ -567,11 +623,18 @@
<method name="i_cal_recurrence_get_by_set_pos_array" corresponds="CUSTOM" kind="get" since="1.0">
<parameter type="ICalRecurrence *" name="recur" comment="The #ICalRecurrence"/>
<returns type="GArray *" annotation="transfer full, element-type gshort" comment="The by_set_pos of #ICalRecurrence."/>
- <comment>Gets the by_set_pos array from #ICalRecurrence. The array size is I_CAL_BY_SETPOS_SIZE.</comment>
+ <comment>Gets the by_set_pos array from #ICalRecurrence. The array has a maximum size of I_CAL_BY_SETPOS_SIZE.</comment>
<custom> GArray *array;
+ struct icalrecurrencetype *native_recurrence;
+ guint size;
g_return_val_if_fail (recur != NULL &amp;&amp; I_CAL_IS_RECURRENCE (recur), NULL);
array = g_array_new (FALSE, FALSE, sizeof (gshort));
- g_array_append_vals (array, ((struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur))->by_set_pos, I_CAL_BY_SETPOS_SIZE);
+ native_recurrence = (struct icalrecurrencetype *)i_cal_object_get_native ((ICalObject *)recur);
+ for (size = 0; size &lt; I_CAL_BY_SETPOS_SIZE; size++) {
+ if (native_recurrence->by_set_pos[size] == I_CAL_RECURRENCE_ARRAY_MAX)
+ break;
+ }
+ g_array_append_vals (array, native_recurrence->by_set_pos, size);
return array;</custom>
</method>
<method name="i_cal_recurrence_set_by_set_pos_array" corresponds="CUSTOM" kind="set" since="1.0">