[webkit-dev] JSClassCreate & JSObjectSetProperty question

Jack Wootton jackwootton at gmail.com
Wed May 27 08:34:16 PDT 2009

Hi all,

For ease here is the link to the API documentation


I'm using JSObjectSetProperty.  Here is the function signature:

void JSObjectSetProperty(
    JSContextRef ctx,
    JSObjectRef object,
    JSStringRef propertyName,
    JSValueRef value,
    JSPropertyAttributes attributes,
    JSValueRef *exception);

I successfully have the execution context to use, the window
JSObjectRef, property name, attributes and use NULL for exception (all
these parameters make sense to me).  However I'm unsure about the
purpose of the parameter 'JSValueRef value'.

Starting from the beginning I created a JSClassDefinition (note I was
unable to use kJSClassDefinitionEmpty because of compile errors about
a missing symbol '_kJSClassDefinitionEmpty')

JSClassDefinition globalObjectClassDefinition = { 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
globalObjectClassDefinition.version = 1;
char myword[] = {'f', 'o', 'o', '\0' };
globalObjectClassDefinition.className = myword;

Question 1.  What is the class name?  The documentation describes it
as "A null-terminated UTF8 string containing the class's name.".
However it does not mention what it's for, or what it represents
within the program.  Is anyone able to elaborate please?  Does it
represent a C class I've al;ready created, that I must describe by
using the JSClassDefinition?

Question 2. I am unclear as to the purpose of the JSClassDefinition.
Does it represent a C class or a JavaScript class?  Are the callbacks
to C / C++ functions?

Many thanks,

attempting to use JSClassCreate, the definition of which is here:


More information about the webkit-dev mailing list