diff options
author | Tomeu Vizoso <tomeu.vizoso@collabora.co.uk> | 2010-06-08 16:40:35 +0200 |
---|---|---|
committer | Tomeu Vizoso <tomeu.vizoso@collabora.co.uk> | 2010-06-08 17:35:12 +0200 |
commit | 22ae017ffd3052c0b81822b2ca6e41626b76b9c4 (patch) | |
tree | b280bde67eaa4096bd8a83ad539a8fe9c7c14f5c /girepository/girparser.c | |
parent | 862cdbe9ed2464c722e566238980895d08a48106 (diff) | |
download | gobject-introspection-22ae017ffd3052c0b81822b2ca6e41626b76b9c4.tar.gz |
Support the (transfer) annotation for properties.
* girepository/*: Add g_property_info_get_ownership_transfer() and write
the transfer attribute of properties into the typelib.
* giscanner/*: Parse the (transfer) annotation and write it into the .gir.
* tools/generate.c: Read the transfer annotation for properties and write
to the .tgir.
https://bugzilla.gnome.org/show_bug.cgi?id=620484
Diffstat (limited to 'girepository/girparser.c')
-rw-r--r-- | girepository/girparser.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/girepository/girparser.c b/girepository/girparser.c index bda72e12..65f038ce 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -841,6 +841,44 @@ start_function (GMarkupParseContext *context, } static void +parse_property_transfer (GIrNodeProperty *property, + const gchar *transfer, + ParseContext *ctx) +{ + if (transfer == NULL) + { + GIrNodeInterface *iface = (GIrNodeInterface *)CURRENT_NODE (ctx); + + g_warning ("required attribute 'transfer-ownership' for property '%s' in " + "type '%s.%s'", property->node.name, ctx->namespace, + iface->node.name); + } + else if (strcmp (transfer, "none") == 0) + { + property->transfer = FALSE; + property->shallow_transfer = FALSE; + } + else if (strcmp (transfer, "container") == 0) + { + property->transfer = FALSE; + property->shallow_transfer = TRUE; + } + else if (strcmp (transfer, "full") == 0) + { + property->transfer = TRUE; + property->shallow_transfer = FALSE; + } + else + { + GIrNodeInterface *iface = (GIrNodeInterface *)CURRENT_NODE (ctx); + + g_warning ("Unknown transfer-ownership value: '%s' for property '%s' in " + "type '%s.%s'", transfer, property->node.name, ctx->namespace, + iface->node.name); + } +} + +static void parse_param_transfer (GIrNodeParam *param, const gchar *transfer, const gchar *name) { if (transfer == NULL) @@ -1237,12 +1275,14 @@ start_property (GMarkupParseContext *context, const gchar *writable; const gchar *construct; const gchar *construct_only; + const gchar *transfer; name = find_attribute ("name", attribute_names, attribute_values); readable = find_attribute ("readable", attribute_names, attribute_values); writable = find_attribute ("writable", attribute_names, attribute_values); construct = find_attribute ("construct", attribute_names, attribute_values); construct_only = find_attribute ("construct-only", attribute_names, attribute_values); + transfer = find_attribute ("transfer-ownership", attribute_names, attribute_values); if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); @@ -1274,6 +1314,8 @@ start_property (GMarkupParseContext *context, else property->construct_only = FALSE; + parse_property_transfer (property, transfer, ctx); + iface = (GIrNodeInterface *)CURRENT_NODE (ctx); iface->members = g_list_append (iface->members, property); |