diff options
author | Eric Wing <ewing -dot- public |-at-| gmail.com> | 2014-05-18 03:43:47 -0700 |
---|---|---|
committer | Oliver Buchtala <oliver.buchtala@googlemail.com> | 2014-05-19 16:04:22 +0200 |
commit | d5ea32d7607c1991ae74293472d73740c90e5db8 (patch) | |
tree | 607d2125c40093437c2c59aeee55cb5194b6c091 | |
parent | 2471e4ad9f1b6b9f851cf359fd6fd6b9aa34e9b8 (diff) | |
download | swig-d5ea32d7607c1991ae74293472d73740c90e5db8.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.swg | 7 |
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; } |