From 85c973f98648465ab065317f8e7db6153d093984 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 3 Nov 2012 17:37:59 +0000 Subject: add jsstring to jsval conversion macro that copes with null jsstrings --- javascript/jsapi.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'javascript') diff --git a/javascript/jsapi.h b/javascript/jsapi.h index e7c10c139..61baa5ce1 100644 --- a/javascript/jsapi.h +++ b/javascript/jsapi.h @@ -94,6 +94,8 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx, outchar = JS_GetStringBytes(injsstring); \ outlen = strlen(outchar) +/* string type cast */ +#define JSAPI_STRING_TO_JSVAL(str) ((str == NULL)?JSVAL_NULL:STRING_TO_JSVAL(str)) #else /* #if JS_VERSION <= 180 */ @@ -152,6 +154,8 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx, JS_EncodeStringToBuffer(injsstring, outchar, outlen); \ outchar[outlen] = '\0' +/* string type cast */ +#define JSAPI_STRING_TO_JSVAL(str) ((str == NULL)?JSVAL_NULL:STRING_TO_JSVAL(str)) #endif -- cgit v1.2.3