diff options
author | Ryan Lortie <desrt@desrt.ca> | 2014-04-16 11:39:09 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2014-05-06 08:18:41 -0400 |
commit | bb9b9bd77309134ad5d1b06a0af9755a3e93a5d8 (patch) | |
tree | be4d434a46c6922d6292e665a5da43b3f4acfd07 /girepository | |
parent | 3ede3b8f9e038cde4a731e9e56c4060961d74ef8 (diff) | |
download | gobject-introspection-bb9b9bd77309134ad5d1b06a0af9755a3e93a5d8.tar.gz |
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
Diffstat (limited to 'girepository')
-rw-r--r-- | girepository/girparser.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/girepository/girparser.c b/girepository/girparser.c index ac21f6a9..6c768669 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -1065,6 +1065,7 @@ start_parameter (GMarkupParseContext *context, const gchar *closure; const gchar *destroy; const gchar *skip; + const gchar *nullable; GIrNodeParam *param; if (!(strcmp (element_name, "parameter") == 0 && @@ -1082,6 +1083,7 @@ start_parameter (GMarkupParseContext *context, closure = find_attribute ("closure", attribute_names, attribute_values); destroy = find_attribute ("destroy", attribute_names, attribute_values); skip = find_attribute ("skip", attribute_names, attribute_values); + nullable = find_attribute ("nullable", attribute_names, attribute_values); if (name == NULL) name = "unknown"; @@ -1126,11 +1128,19 @@ start_parameter (GMarkupParseContext *context, else param->optional = FALSE; - if (allow_none && strcmp (allow_none, "1") == 0) + if (nullable && strcmp (nullable, "1") == 0) param->nullable = TRUE; else 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) param->skip = TRUE; else @@ -2172,6 +2182,7 @@ start_return_value (GMarkupParseContext *context, GIrNodeParam *param; const gchar *transfer; const gchar *skip; + const gchar *nullable; if (!(strcmp (element_name, "return-value") == 0 && ctx->state == STATE_FUNCTION)) @@ -2197,6 +2208,10 @@ start_return_value (GMarkupParseContext *context, if (!parse_param_transfer (param, transfer, NULL, error)) 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) { case G_IR_NODE_FUNCTION: |