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.
This commit is contained in:
parent
8498e4878d
commit
05ed0325dc
1 changed files with 7 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue