summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2016-02-01 20:14:34 (GMT)
committer John-Mark Bell <jmb@netsurf-browser.org>2016-02-01 20:14:34 (GMT)
commit66e9aa8d66aae27098693554d26100417606164b (patch)
treeaffd18b5ffc14f2742e7cb1ab8c5da80cbbd9bf7
parentb0b8fe9acf002cbfeb68873cac6e01345e173fa8 (diff)
downloadnsgenbind-66e9aa8d66aae27098693554d26100417606164b.tar.gz
nsgenbind-66e9aa8d66aae27098693554d26100417606164b.tar.bz2
Add support for TreatNullAs=EmptyString extended attribute.
-rw-r--r--src/duk-libdom-generated.c17
-rw-r--r--src/ir.c4
-rw-r--r--src/ir.h1
3 files changed, 20 insertions, 2 deletions
diff --git a/src/duk-libdom-generated.c b/src/duk-libdom-generated.c
index 0790e00..9305dcf 100644
--- a/src/duk-libdom-generated.c
+++ b/src/duk-libdom-generated.c
@@ -262,8 +262,21 @@ output_generated_attribute_setter(FILE* outf,
"\tdom_exception exc;\n"
"\tdom_string *str;\n"
"\tduk_size_t slen;\n"
- "\tconst char *s;\n"
- "\ts = duk_safe_to_lstring(ctx, 0, &slen);\n"
+ "\tconst char *s;\n");
+ if ((atributee->treatnullas != NULL) &&
+ (strcmp(atributee->treatnullas, "EmptyString") == 0)) {
+ fprintf(outf,
+ "\tif (duk_is_null(ctx, 0)) {\n"
+ "\t\ts = \"\";\n"
+ "\t\tslen = 0;\n"
+ "\t} else {\n"
+ "\t\ts = duk_safe_to_lstring(ctx, 0, &slen);\n"
+ "\t}\n");
+ } else {
+ fprintf(outf,
+ "\ts = duk_safe_to_lstring(ctx, 0, &slen);\n");
+ }
+ fprintf(outf,
"\n"
"\texc = dom_string_create((const uint8_t *)s, slen, &str);\n"
"\tif (exc != DOM_NO_ERR) {\n"
diff --git a/src/ir.c b/src/ir.c
index 7a1bc5a..f77eb3d 100644
--- a/src/ir.c
+++ b/src/ir.c
@@ -607,6 +607,10 @@ attribute_map_new(struct webidl_node *interface,
cure->name);
}
+ /* check for treatnullas extended attribute */
+ cure->treatnullas = get_extended_value(at_node,
+ "TreatNullAs");
+
/* move to next attribute */
cure++;
diff --git a/src/ir.h b/src/ir.h
index a6fcf12..6b848ea 100644
--- a/src/ir.h
+++ b/src/ir.h
@@ -69,6 +69,7 @@ struct ir_attribute_entry {
enum webidl_type_modifier modifier; /**< modifier for the attribute intself */
const char *putforwards; /**< putforwards attribute */
+ const char *treatnullas; /**< treatnullas attribute */
struct genbind_node *getter; /**< getter from binding */
struct genbind_node *setter; /**< getter from binding */