diff options
-rw-r--r-- | ReleaseNotes.txt | 2 | ||||
-rw-r--r-- | src/libical-glib/api/i-cal-attach.xml | 2 | ||||
-rw-r--r-- | src/libical-glib/tools/generator.c | 10 | ||||
-rw-r--r-- | src/libical-glib/tools/source-structure-boilerplate-template | 1 | ||||
-rw-r--r-- | src/libical-glib/tools/xml-parser.c | 20 | ||||
-rw-r--r-- | src/libical-glib/tools/xml-parser.h | 1 |
6 files changed, 34 insertions, 2 deletions
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 0332b947..f580fa4b 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -3,7 +3,7 @@ Release Highlights Version 3.0.7 (UNRELEASED): --------------------------- - * + * libical-glib: Fix ICalAttach handling of the icalattach native structure Version 3.0.6 (14 Sep 2019): ---------------------------- diff --git a/src/libical-glib/api/i-cal-attach.xml b/src/libical-glib/api/i-cal-attach.xml index c0c1e108..e4fcf0d2 100644 --- a/src/libical-glib/api/i-cal-attach.xml +++ b/src/libical-glib/api/i-cal-attach.xml @@ -13,7 +13,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library. If not, see <http://www.gnu.org/licenses/>. --> -<structure namespace="ICal" name="Attach" native="icalattach" destroy_func="icalattach_unref"> +<structure namespace="ICal" name="Attach" native="icalattach" destroy_func="icalattach_unref" new_full_extra_code="if (owner) { icalattach_ref (native); owner = NULL; }"> <method name="i_cal_attach_new_from_url" corresponds="icalattach_new_from_url" kind="constructor" since="1.0"> <parameter type="const gchar *" name="url" comment="The url from which the object is created"/> <returns type="ICalAttach *" annotation="transfer full" comment="The newly created #ICalAttach from the @url" /> diff --git a/src/libical-glib/tools/generator.c b/src/libical-glib/tools/generator.c index 712d9bc1..64a9f5ea 100644 --- a/src/libical-glib/tools/generator.c +++ b/src/libical-glib/tools/generator.c @@ -911,6 +911,12 @@ void generate_code_from_template(FILE *in, FILE *out, Structure *structure, GHas val = g_hash_table_lookup(table, buffer); write_str(out, val); val = NULL; + + if (g_strcmp0(buffer, "new_full_extraCode") == 0) + write_str(out, "\n "); + } else if (g_strcmp0(buffer, "new_full_extraCode") == 0) { + /* For simplicity, after lookup in the 'table', to + not force declaration of it in every .xml file */ } else if (g_strcmp0(buffer, "structure_boilerplate") == 0) { if (structure->native != NULL) generate_header_structure_boilerplate(out, structure, table); @@ -1266,6 +1272,10 @@ GHashTable *get_hash_table_from_structure(Structure *structure) (void)g_hash_table_insert(table, (gchar *)"defaultNative", g_strdup(structure->defaultNative)); } + if (structure->new_full_extraCode && *structure->new_full_extraCode) { + (void)g_hash_table_insert(table, (gchar *)"new_full_extraCode", + g_strdup(structure->new_full_extraCode)); + } } (void)g_hash_table_insert(table, (char *)"native", g_strdup(structure->native)); diff --git a/src/libical-glib/tools/source-structure-boilerplate-template b/src/libical-glib/tools/source-structure-boilerplate-template index ceddd505..77d20aae 100644 --- a/src/libical-glib/tools/source-structure-boilerplate-template +++ b/src/libical-glib/tools/source-structure-boilerplate-template @@ -26,6 +26,7 @@ ${new_full} ${native} *clone;^$$^!${isBare} if (native == NULL) return NULL;^$ + ${new_full_extraCode} $^${isBare} clone = g_new (${native}, 1); *clone = native;^$ diff --git a/src/libical-glib/tools/xml-parser.c b/src/libical-glib/tools/xml-parser.c index e7b1b42f..c5520119 100644 --- a/src/libical-glib/tools/xml-parser.c +++ b/src/libical-glib/tools/xml-parser.c @@ -27,6 +27,7 @@ Structure *structure_new() structure->methods = NULL; structure->isBare = FALSE; structure->isPossibleGlobal = FALSE; + structure->new_full_extraCode = NULL; structure->enumerations = NULL; structure->destroyFunc = NULL; structure->cloneFunc = NULL; @@ -68,6 +69,7 @@ void structure_free(Structure * structure) g_free(structure->destroyFunc); g_free(structure->cloneFunc); g_free(structure->defaultNative); + g_free(structure->new_full_extraCode); g_hash_table_destroy(structure->dependencies); g_free(structure); } @@ -251,6 +253,22 @@ void enumeration_free(Enumeration * enumeration) g_free(enumeration); } +static gchar *dup_attribute_value(xmlDocPtr doc, const xmlNode * list, int inLine) +{ + xmlChar *xml_value; + gchar *glib_value; + + xml_value = xmlNodeListGetString(doc, list, inLine); + if (!xml_value) + return NULL; + + glib_value = g_strdup((const gchar *) xml_value); + + xmlFree(xml_value); + + return glib_value; +} + GList *get_list_from_string(const gchar * str) { gchar **ret; @@ -530,6 +548,8 @@ gboolean parse_structure(xmlNode * node, Structure * structure) structure->destroyFunc = (gchar *) xmlNodeListGetString(attr->doc, attr->children, 1); } else if (xmlStrcmp(attr->name, (xmlChar *) "clone_func") == 0) { structure->cloneFunc = (gchar *) xmlNodeListGetString(attr->doc, attr->children, 1); + } else if (xmlStrcmp(attr->name, (xmlChar *) "new_full_extra_code") == 0) { + structure->new_full_extraCode = dup_attribute_value(attr->doc, attr->children, 1); } else if (xmlStrcmp(attr->name, (xmlChar *) "default_native") == 0) { structure->defaultNative = (gchar *) xmlNodeListGetString(attr->doc, attr->children, 1); } else if (xmlStrcmp(attr->name, (xmlChar *) "is_bare") == 0) { diff --git a/src/libical-glib/tools/xml-parser.h b/src/libical-glib/tools/xml-parser.h index 33527c0c..3313753f 100644 --- a/src/libical-glib/tools/xml-parser.h +++ b/src/libical-glib/tools/xml-parser.h @@ -61,6 +61,7 @@ typedef struct Structure { GList *methods; gboolean isBare; gboolean isPossibleGlobal; + gchar *new_full_extraCode; GList *enumerations; GHashTable *dependencies; gchar *destroyFunc; |