mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-16 04:28:05 +02:00
compiler: girparser: parse 'nullable' attribute
Parse the 'nullable' attribute on parameters and function return types. Additionally, tweak the meaning of the 'allow-none' attribute. We now only treat it as equivalent to 'nullable' for non-out parameters. For out parameters, we treat it to mean the same as the already-recognised 'optional' parameter (which we only recently started actually using). https://bugzilla.gnome.org/show_bug.cgi?id=660879
This commit is contained in:
parent
6d1df44ff7
commit
45e28fa698
17
girparser.c
17
girparser.c
@ -1065,6 +1065,7 @@ start_parameter (GMarkupParseContext *context,
|
|||||||
const gchar *closure;
|
const gchar *closure;
|
||||||
const gchar *destroy;
|
const gchar *destroy;
|
||||||
const gchar *skip;
|
const gchar *skip;
|
||||||
|
const gchar *nullable;
|
||||||
GIrNodeParam *param;
|
GIrNodeParam *param;
|
||||||
|
|
||||||
if (!(strcmp (element_name, "parameter") == 0 &&
|
if (!(strcmp (element_name, "parameter") == 0 &&
|
||||||
@ -1082,6 +1083,7 @@ start_parameter (GMarkupParseContext *context,
|
|||||||
closure = find_attribute ("closure", attribute_names, attribute_values);
|
closure = find_attribute ("closure", attribute_names, attribute_values);
|
||||||
destroy = find_attribute ("destroy", attribute_names, attribute_values);
|
destroy = find_attribute ("destroy", attribute_names, attribute_values);
|
||||||
skip = find_attribute ("skip", attribute_names, attribute_values);
|
skip = find_attribute ("skip", attribute_names, attribute_values);
|
||||||
|
nullable = find_attribute ("nullable", attribute_names, attribute_values);
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = "unknown";
|
name = "unknown";
|
||||||
@ -1126,11 +1128,19 @@ start_parameter (GMarkupParseContext *context,
|
|||||||
else
|
else
|
||||||
param->optional = FALSE;
|
param->optional = FALSE;
|
||||||
|
|
||||||
if (allow_none && strcmp (allow_none, "1") == 0)
|
if (nullable && strcmp (nullable, "1") == 0)
|
||||||
param->nullable = TRUE;
|
param->nullable = TRUE;
|
||||||
else
|
else
|
||||||
param->nullable = FALSE;
|
param->nullable = FALSE;
|
||||||
|
|
||||||
|
if (allow_none && strcmp (allow_none, "1") == 0)
|
||||||
|
{
|
||||||
|
if (param->out)
|
||||||
|
param->optional = TRUE;
|
||||||
|
else
|
||||||
|
param->nullable = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (skip && strcmp (skip, "1") == 0)
|
if (skip && strcmp (skip, "1") == 0)
|
||||||
param->skip = TRUE;
|
param->skip = TRUE;
|
||||||
else
|
else
|
||||||
@ -2172,6 +2182,7 @@ start_return_value (GMarkupParseContext *context,
|
|||||||
GIrNodeParam *param;
|
GIrNodeParam *param;
|
||||||
const gchar *transfer;
|
const gchar *transfer;
|
||||||
const gchar *skip;
|
const gchar *skip;
|
||||||
|
const gchar *nullable;
|
||||||
|
|
||||||
if (!(strcmp (element_name, "return-value") == 0 &&
|
if (!(strcmp (element_name, "return-value") == 0 &&
|
||||||
ctx->state == STATE_FUNCTION))
|
ctx->state == STATE_FUNCTION))
|
||||||
@ -2197,6 +2208,10 @@ start_return_value (GMarkupParseContext *context,
|
|||||||
if (!parse_param_transfer (param, transfer, NULL, error))
|
if (!parse_param_transfer (param, transfer, NULL, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
nullable = find_attribute ("nullable", attribute_names, attribute_values);
|
||||||
|
if (nullable && g_str_equal (nullable, "1"))
|
||||||
|
param->nullable = TRUE;
|
||||||
|
|
||||||
switch (CURRENT_NODE (ctx)->type)
|
switch (CURRENT_NODE (ctx)->type)
|
||||||
{
|
{
|
||||||
case G_IR_NODE_FUNCTION:
|
case G_IR_NODE_FUNCTION:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user