summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2016-02-01 11:34:35 (GMT)
committer John-Mark Bell <jmb@netsurf-browser.org>2016-02-01 11:34:35 (GMT)
commitb0b8fe9acf002cbfeb68873cac6e01345e173fa8 (patch)
tree63595a55ac340381fdf0a0f46203c97caf0610e5
parentd81d30699f57f0ca41b917c854ef6d0875a18129 (diff)
downloadnsgenbind-b0b8fe9acf002cbfeb68873cac6e01345e173fa8.tar.gz
nsgenbind-b0b8fe9acf002cbfeb68873cac6e01345e173fa8.tar.bz2
Expose nullable flag in IR and have generated getters use it.
-rw-r--r--src/duk-libdom-generated.c9
-rw-r--r--src/ir.c6
-rw-r--r--src/ir.h1
3 files changed, 14 insertions, 2 deletions
diff --git a/src/duk-libdom-generated.c b/src/duk-libdom-generated.c
index bae0826..0790e00 100644
--- a/src/duk-libdom-generated.c
+++ b/src/duk-libdom-generated.c
@@ -102,8 +102,13 @@ output_generated_attribute_getter(FILE* outf,
"\t\t\tdom_string_data(str),\n"
"\t\t\tdom_string_length(str));\n"
"\t\tdom_string_unref(str);\n"
- "\t} else {\n"
- "\t\tduk_push_lstring(ctx, NULL, 0);\n"
+ "\t} else {\n");
+ if (atributee->typev[0].nullable) {
+ fprintf(outf, "\t\tduk_push_null(ctx);\n");
+ } else {
+ fprintf(outf, "\t\tduk_push_lstring(ctx, NULL, 0);\n");
+ }
+ fprintf(outf,
"\t}\n"
"\n"
"\treturn 1;\n");
diff --git a/src/ir.c b/src/ir.c
index 8084c40..7a1bc5a 100644
--- a/src/ir.c
+++ b/src/ir.c
@@ -483,6 +483,12 @@ type_map_new(struct webidl_node *node,
cure->modifier = WEBIDL_TYPE_MODIFIER_NONE;
}
+ /* type nullability */
+ cure->nullable = (webidl_node_find_type(
+ webidl_node_getnode(type_node),
+ NULL,
+ WEBIDL_NODE_TYPE_TYPE_NULLABLE) != NULL);
+
/* type name */
cure->name = webidl_node_gettext(
webidl_node_find_type(
diff --git a/src/ir.h b/src/ir.h
index d3dd5d0..a6fcf12 100644
--- a/src/ir.h
+++ b/src/ir.h
@@ -53,6 +53,7 @@ struct ir_operation_entry {
struct ir_type_entry {
enum webidl_type base; /**< base of the type (long, short, user etc.) */
enum webidl_type_modifier modifier; /**< modifier for the type */
+ bool nullable; /**< the type is nullable */
const char *name; /**< name of type for user types */
};