summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVincent Sanders <vincent.sanders@collabora.co.uk>2012-11-27 13:46:18 +0000
committerVincent Sanders <vincent.sanders@collabora.co.uk>2012-11-27 13:46:18 +0000
commite0e92e4a68a87ebba0583f2a26514f619cc08a30 (patch)
tree4804262d80a12c3a14d1e08e467e95adc0e1b09e /src
parentb29ff13b599730bf3eaec8f142e584f23e78c1fb (diff)
downloadnsgenbind-e0e92e4a68a87ebba0583f2a26514f619cc08a30.tar.gz
nsgenbind-e0e92e4a68a87ebba0583f2a26514f619cc08a30.tar.bz2
ensure nullable type extension on strings is obeyed
Diffstat (limited to 'src')
-rw-r--r--src/jsapi-libdom-property.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 87cbc10..6bb695a 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -437,6 +437,7 @@ static int output_return(struct binding *binding,
{
struct webidl_node *type_node = NULL;
struct webidl_node *type_base = NULL;
+ struct webidl_node *type_nullable = NULL;
enum webidl_type webidl_arg_type;
type_node = webidl_node_find_type(webidl_node_getnode(node),
@@ -449,6 +450,10 @@ static int output_return(struct binding *binding,
webidl_arg_type = webidl_node_getint(type_base);
+ type_nullable = webidl_node_find_type(webidl_node_getnode(type_node),
+ NULL,
+ WEBIDL_NODE_TYPE_TYPE_NULLABLE);
+
switch (webidl_arg_type) {
case WEBIDL_TYPE_USER:
/* User type are represented with jsobject */
@@ -502,6 +507,14 @@ static int output_return(struct binding *binding,
case WEBIDL_TYPE_STRING:
/* JSString * */
+ if (type_nullable == NULL) {
+ /* entry is not nullable ensure it is set to a string */
+ fprintf(binding->outfile,
+ "\tif (%s == NULL) {\n"
+ "\t\t%s = JS_NewStringCopyN(cx, NULL, 0);\n"
+ "\t}\n",
+ ident, ident);
+ }
fprintf(binding->outfile,
"\tJSAPI_PROP_SET_RVAL(cx, vp, JSAPI_STRING_TO_JSVAL(%s));\n",
ident);