[webkit-dev] JSObjectMakeFunction question

Maciej Stachowiak mjs at apple.com
Mon Jun 1 08:56:32 PDT 2009

On Jun 1, 2009, at 8:29 AM, Jack Wootton wrote:

> It seems some casting is required for this though?
> JSValueRef JSObjectCallAsFunction(


> The above function accepts a JSObjectRef object.
> However
> JSValueRef JSObjectGetProperty(


> returns JSValueRef

Setting aside the actual typedefs (which are our attempt to trick the  
C type system), JavaScript has objects and some primitive values that  
are not objects. So every object is a kind of value, but not all  
values are objects.

JSObjectGetProperty retrieves a property from an object, and it can't  
guarantee whether the result will be an object or a primitive, so it  
returns JSValueRef. If you can be certain the value is in fact an  
object (functions are a kind of object), you can just downcast. If you  
are not certain (for example the property can be defined or altered by  
script), you can use JSValueIsObject to check before casting.


More information about the webkit-dev mailing list