On Aug 19, 2009, at 11:37 AM, Brian Barnes wrote:
JSValueRef JSObjectSetArray(JSContextRef ctx,size_t valueCount,const
JSValueRef values[],JSValueRef *exception)
This looks to be duplicating the functionality of JSObjectMakeArray
(see <http://trac.webkit.org/browser/trunk/JavaScriptCore/API/JSObjectRef.h#L433
>).
bool JSValueIsArray(JSContextRef ctx,JSValueRef value)
{
char *ch,str[64];
JSStringRef jsStr;
JSObjectRef arrayObj;
JSValueRef val;
// only check objects
if (!JSValueIsObject(ctx,value)) return(FALSE);
// get constructor
arrayObj=JSValueToObject(ctx,value,NULL);
if (arrayObj==NULL) return(FALSE);
jsStr=JSStringCreateWithUTF8CString("constructor");
val=JSObjectGetProperty(ctx,arrayObj,jsStr,NULL);
JSStringRelease(jsStr);
if (val==NULL) return(FALSE);
// get constructor as a function
jsStr=JSValueToStringCopy(ctx,val,NULL);
if (jsStr==NULL) return(FALSE);
JSStringGetUTF8CString(jsStr,str,64);
str[63]=0x0;
JSStringRelease(jsStr);
// special check to make sure we don't have Array
// anywhere else in a function body or there just
// instead a function body
ch=strchr(str,'{');
if (ch==NULL) return(FALSE);
*ch=0x0;
// look for array in string
return(strstr(str,"Array")!=NULL);
}
There are definitely more efficient ways to do this below the JSC API
layer. I don't think there's any API to do this currently.
-Adam
_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev