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:
Eric Wing 2014-05-18 03:43:47 -07:00 committed by Oliver Buchtala
commit 05ed0325dc

View file

@ -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;
}