diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2014-05-06 18:53:21 +0200 |
---|---|---|
committer | Giovanni Campagna <gcampagna@src.gnome.org> | 2014-07-03 10:31:17 +0200 |
commit | a4c9d09d7a89d3c80b4465a5c2ae0efa24158b24 (patch) | |
tree | f56b061a761dd45ed64d9015c8a7cf00b46be710 /girepository/girparser.c | |
parent | b2bf49eae922bffddc952fcc22e4acbd7d40c5f3 (diff) | |
download | gobject-introspection-a4c9d09d7a89d3c80b4465a5c2ae0efa24158b24.tar.gz |
Parse and expose ownership transfer for instance parameters
Knowing the ownership transfer for instance parameters is
necessary for correct memory management of functions which
"eat" their instance argument, such as g_dbus_method_invocation_return_*.
Parse this information from the gir file and store in the
typelib, and then provide new API on GICallableInfo to
retrieve this.
https://bugzilla.gnome.org/show_bug.cgi?id=729662
Diffstat (limited to 'girepository/girparser.c')
-rw-r--r-- | girepository/girparser.c | 74 |
1 files changed, 69 insertions, 5 deletions
diff --git a/girepository/girparser.c b/girepository/girparser.c index 6c768669..f928c2e2 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -1047,6 +1047,71 @@ parse_param_transfer (GIrNodeParam *param, const gchar *transfer, const gchar *n } static gboolean +start_instance_parameter (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + const gchar *transfer; + gboolean transfer_full; + + if (!(strcmp (element_name, "instance-parameter") == 0 && + ctx->state == STATE_FUNCTION_PARAMETERS)) + return FALSE; + + transfer = find_attribute ("transfer-ownership", attribute_names, attribute_values); + + state_switch (ctx, STATE_PASSTHROUGH); + + if (strcmp (transfer, "full") == 0) + transfer_full = TRUE; + else if (strcmp (transfer, "none") == 0) + transfer_full = FALSE; + else + { + g_set_error (error, G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + "invalid value for 'transfer-ownership' for instance parameter: %s", transfer); + return FALSE; + } + + switch (CURRENT_NODE (ctx)->type) + { + case G_IR_NODE_FUNCTION: + case G_IR_NODE_CALLBACK: + { + GIrNodeFunction *func; + + func = (GIrNodeFunction *)CURRENT_NODE (ctx); + func->instance_transfer_full = transfer_full; + } + break; + case G_IR_NODE_SIGNAL: + { + GIrNodeSignal *signal; + + signal = (GIrNodeSignal *)CURRENT_NODE (ctx); + signal->instance_transfer_full = transfer_full; + } + break; + case G_IR_NODE_VFUNC: + { + GIrNodeVFunc *vfunc; + + vfunc = (GIrNodeVFunc *)CURRENT_NODE (ctx); + vfunc->instance_transfer_full = transfer_full; + } + break; + default: + g_assert_not_reached (); + } + + return TRUE; +} + +static gboolean start_parameter (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, @@ -2848,11 +2913,10 @@ start_element_handler (GMarkupParseContext *context, attribute_names, attribute_values, ctx, error)) goto out; - else if (strcmp (element_name, "instance-parameter") == 0) - { - state_switch (ctx, STATE_PASSTHROUGH); - goto out; - } + else if (start_instance_parameter (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; else if (strcmp (element_name, "c:include") == 0) { state_switch (ctx, STATE_C_INCLUDE); |