diff options
author | John-Mark Bell <jmb@netsurf-browser.org> | 2016-02-01 11:34:35 +0000 |
---|---|---|
committer | John-Mark Bell <jmb@netsurf-browser.org> | 2016-02-01 11:34:35 +0000 |
commit | b0b8fe9acf002cbfeb68873cac6e01345e173fa8 (patch) | |
tree | 63595a55ac340381fdf0a0f46203c97caf0610e5 | |
parent | d81d30699f57f0ca41b917c854ef6d0875a18129 (diff) | |
download | nsgenbind-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.c | 9 | ||||
-rw-r--r-- | src/ir.c | 6 | ||||
-rw-r--r-- | src/ir.h | 1 |
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"); @@ -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( @@ -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 */ }; |