mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-23 01:18:53 +02:00
Support (out caller-allocates)
People have wanted support for marking (out) on functions of the form: /** * clutter_color_from_pixel: * @pixel: A pixel * @color: (out): Color to initialize with value of @pixel */ void clutter_color_from_pixel (guint32 pixel, ClutterColor *color); Where the caller is supposed to have allocated the argument; the C function just initializes it. This patch adds support for this argument passing style to introspection. In this case, we see the (out), and notice that there's only a single indirection (*) on the argument, and assume that this means (out caller-allocates). https://bugzilla.gnome.org/show_bug.cgi?id=604749
This commit is contained in:
20
girparser.c
20
girparser.c
@@ -881,8 +881,8 @@ start_parameter (GMarkupParseContext *context,
|
||||
const gchar *name;
|
||||
const gchar *direction;
|
||||
const gchar *retval;
|
||||
const gchar *dipper;
|
||||
const gchar *optional;
|
||||
const gchar *caller_allocates;
|
||||
const gchar *allow_none;
|
||||
const gchar *transfer;
|
||||
const gchar *scope;
|
||||
@@ -897,9 +897,9 @@ start_parameter (GMarkupParseContext *context,
|
||||
name = find_attribute ("name", attribute_names, attribute_values);
|
||||
direction = find_attribute ("direction", attribute_names, attribute_values);
|
||||
retval = find_attribute ("retval", attribute_names, attribute_values);
|
||||
dipper = find_attribute ("dipper", attribute_names, attribute_values);
|
||||
optional = find_attribute ("optional", attribute_names, attribute_values);
|
||||
allow_none = find_attribute ("allow-none", attribute_names, attribute_values);
|
||||
caller_allocates = find_attribute ("caller-allocates", attribute_names, attribute_values);
|
||||
transfer = find_attribute ("transfer-ownership", attribute_names, attribute_values);
|
||||
scope = find_attribute ("scope", attribute_names, attribute_values);
|
||||
closure = find_attribute ("closure", attribute_names, attribute_values);
|
||||
@@ -919,16 +919,27 @@ start_parameter (GMarkupParseContext *context,
|
||||
{
|
||||
param->in = FALSE;
|
||||
param->out = TRUE;
|
||||
if (caller_allocates == NULL)
|
||||
{
|
||||
g_set_error (error,
|
||||
G_MARKUP_ERROR,
|
||||
G_MARKUP_ERROR_INVALID_CONTENT,
|
||||
"caller-allocates attribute required on out parameters");
|
||||
return FALSE;
|
||||
}
|
||||
param->caller_allocates = strcmp (caller_allocates, "1") == 0;
|
||||
}
|
||||
else if (direction && strcmp (direction, "inout") == 0)
|
||||
{
|
||||
param->in = TRUE;
|
||||
param->out = TRUE;
|
||||
param->caller_allocates = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
param->in = TRUE;
|
||||
param->out = FALSE;
|
||||
param->caller_allocates = FALSE;
|
||||
}
|
||||
|
||||
if (retval && strcmp (retval, "1") == 0)
|
||||
@@ -936,11 +947,6 @@ start_parameter (GMarkupParseContext *context,
|
||||
else
|
||||
param->retval = FALSE;
|
||||
|
||||
if (dipper && strcmp (dipper, "1") == 0)
|
||||
param->dipper = TRUE;
|
||||
else
|
||||
param->dipper = FALSE;
|
||||
|
||||
if (optional && strcmp (optional, "1") == 0)
|
||||
param->optional = TRUE;
|
||||
else
|
||||
|
Reference in New Issue
Block a user