summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wing <ewing -dot- public |-at-| gmail.com>2014-05-18 03:43:47 -0700
committerOliver Buchtala <oliver.buchtala@googlemail.com>2014-05-18 21:27:54 +0200
commit05ed0325dc4bd9ddc126d3dacc6b38686f7382cf (patch)
treef3ab054663137f6fc6a40a3eb5ba8e048369729a
parent8498e4878d130a6ae24843084408339f3bf910ce (diff)
downloadswig-05ed0325dc4bd9ddc126d3dacc6b38686f7382cf.tar.gz
JavaScriptCore: ConvertPtr should allow JavaScript null to be a valid value.
It is common in C to accept NULL to functions for pointer parameters. extern void DoSomething(struct Foo* foo); ... DoSomething(NULL); Thus, JavaScript null should be allowed: module.DoSomething(null); But the current ConvertPtr definition accepts only objects. This modifies it to allow null.
-rw-r--r--Lib/javascript/jsc/javascriptrun.swg7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/javascript/jsc/javascriptrun.swg b/Lib/javascript/jsc/javascriptrun.swg
index 813c7deb4..9655b0eb6 100644
--- a/Lib/javascript/jsc/javascriptrun.swg
+++ b/Lib/javascript/jsc/javascriptrun.swg
@@ -129,6 +129,13 @@ SWIGRUNTIME int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef ob
SWIGRUNTIME int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, void** ptr, swig_type_info *info, int flags) {
JSObjectRef objRef;
+
+ /* special case: JavaScript null => C NULL pointer */
+ if(JSValueIsNull(context, valRef)) {
+ *ptr=0;
+ return SWIG_OK;
+ }
+
if(!JSValueIsObject(context, valRef)) {
return SWIG_TypeError;
}