[webkit-dev] when can I treat a JSValueRef as a JSObjectRef?

Patrick Mueller pmuellr at muellerware.org
Mon May 4 10:17:37 PDT 2009


Since JSValueRef and JSObjectRef are typedef's to the same OpaqueJSValue 
  structure (pointer), it appears you could almost use them in the same 
contexts.  And if fact, it appears you can use a JSObjectRef wherever a 
JSValueRef is defined in the API.  And you can sometimes use a 
JSValueRef wherever a JSObjectRef is defined.

It would be nice to see this documented a little better.  My current 
guess is that if JSValueGetType() returns kJSTypeObject for a 
JSValueRef, you can safely treat it as a JSObjectRef.  If it doesn't, 
then you can't.

Guess is based on looking at the code, seeing the pointer dereferenced 
in the JSObjectRef cases, but knowing that those pointers are actually 
sometimes tagged pointers for literal values, in which case the 
dereference won't work.

-- 
Patrick Mueller



More information about the webkit-dev mailing list