OUTPUT typemaps on methods that don't return void
SWIGJSC_ValueIsArray could be implemented by JSValueIsArray in later versions of Javascript webkit, similar fix to previous commits for v8. Enhance testing of OUTPUT typemaps to test more than one output.
This commit is contained in:
parent
5ed74fd19b
commit
4b64becbbb
5 changed files with 38 additions and 6 deletions
|
|
@ -317,6 +317,30 @@ unsigned int SWIGJSC_ArrayLength(JSContextRef context, JSObjectRef arr) {
|
|||
}
|
||||
}
|
||||
|
||||
SWIGRUNTIME
|
||||
bool SWIGJSC_ValueIsArray(JSContextRef context, JSValueRef value) {
|
||||
if (JSValueIsObject(context, value)) {
|
||||
static JSStringRef ArrayString = NULL;
|
||||
static JSStringRef isArrayString = NULL;
|
||||
JSObjectRef array = NULL;
|
||||
JSObjectRef isArray = NULL;
|
||||
JSValueRef retval = NULL;
|
||||
|
||||
if (!ArrayString)
|
||||
ArrayString = JSStringCreateWithUTF8CString("Array");
|
||||
if (!isArrayString)
|
||||
isArrayString = JSStringCreateWithUTF8CString("isArray");
|
||||
|
||||
array = (JSObjectRef)JSObjectGetProperty(context, JSContextGetGlobalObject(context), ArrayString, NULL);
|
||||
isArray = (JSObjectRef)JSObjectGetProperty(context, array, isArrayString, NULL);
|
||||
retval = JSObjectCallAsFunction(context, isArray, NULL, 1, &value, NULL);
|
||||
|
||||
if (JSValueIsBoolean(context, retval))
|
||||
return JSValueToBoolean(context, retval);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SWIGRUNTIME
|
||||
JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueRef obj) {
|
||||
JSObjectRef arr;
|
||||
|
|
@ -324,6 +348,8 @@ JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueR
|
|||
|
||||
if (JSValueIsUndefined(context, value)) {
|
||||
arr = JSObjectMakeArray(context, 0, 0, 0);
|
||||
} else if (!SWIGJSC_ValueIsArray(context, value)) {
|
||||
arr = JSObjectMakeArray(context, 1, &value, 0);
|
||||
} else {
|
||||
arr = JSValueToObject(context, value, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue