Hello Darin, Thank you for your help. I have responded below and have 1 main question at the end.
On Wed, May 27, 2009 at 9:23 PM, Darin Adler <[email protected]> wrote: > On May 27, 2009, at 8:34 AM, Jack Wootton wrote: > >> I'm using JSObjectSetProperty. >> >> [...] >> >> 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'. > > This function is used to set the property of a particular JavaScript object. > To do this in JavaScript the syntax is: > > object.propertyName = value; > > The value is the new value to be stored in the JavaScript property. > >> (note I was >> unable to use kJSClassDefinitionEmpty because of compile errors about >> a missing symbol '_kJSClassDefinitionEmpty') > > What platform? Did you file a bug about this? I am using the s60 webkit port. N I have not reported a bug about this yet. I would like to ensure it is a bug before doing so. > >> 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? > > The class name is used for debugging purposes and for the default behavior > of the toString function. If your name is "foo" then toString will yield > "[object foo]". Thank you for this clear explanation. > >> 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? > > JSClassDefinition can be used to make a JSClassRef. A JSClassRef can be used > to construct JavaScript objects with behavior that is implemented with C > functions. I understand the first part of your answer, but what i can't find it how to specify which C functions should be"bound" to the JavaScript functions. So for example, I add a new attribute to the window object named "foo", and I add a method to foo, named "func1". This would result in window.foo.func1(), or just foo.func1() (since the window object does not need to be explicitly used). However I would like foo() to call some C function, the functionality of func1() needs to be implemented in C and a value returned to the JavaScript environment. How I can i do this with JSObjectRef or the rest of the JavaScriptCore API? Many thanks, Jack > > -- Darin > > -- Regards Jack _______________________________________________ webkit-dev mailing list [email protected] http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

