From e0e92e4a68a87ebba0583f2a26514f619cc08a30 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 27 Nov 2012 13:46:18 +0000 Subject: ensure nullable type extension on strings is obeyed --- src/jsapi-libdom-property.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') 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); -- cgit v1.2.3