oliver at apple.com
Thu Dec 11 03:06:16 PST 2008
On Dec 11, 2008, at 2:27 AM, Thomas Gutteridge wrote:
> application to allow some logic to be implemented in script and
> therefore modified without recompilation. Although, I can create
> give them names that can be used to reference them from script.
> For example, I'm trying to use JSObjectMakeFunctionWithCallback to
> I'd like to then invoke this function from a script. However, the
> "name" parameter is apparently only "used when converting the function
> to string". The name I give is undefined if I use it in a script.
> Is what I'm trying to do possible?
The "name" property that you're specifying is what will be used if you
want to do myFunction.toString(). Accessing a function by name
requires the function (or other object) being on an object in scope.
The easiest way to achieve this is by putting it on the global
object. This will let you call it in the same way people use 'alert',
'document', etc on js in a web page.
Something akin to the following should work (assuming jsFunction is
your JSC function wrapper, and context is your JSC context):
JSValueRef exception = 0;
JSObjectRef global = JSContextGetGlobalObject(context);
kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly,
printf("Argh! an exception!!!!");
Now your function will be available in JS as "myCFunction" on the
More information about the webkit-dev