implementing a.b.c() behavior

6 views
Skip to first unread message

LG

unread,
May 25, 2010, 1:50:06 PM5/25/10
to JSCocoa
Hi All,

Suppose i have a behavior for a.b() as

JSC::JSLock lock(false);
WebCore::JSDOMWindow *window = WebCore::toJSDOMWindow(pFrame,
mainThreadNormalWorld());
if (window) {
RootObject *root = pFrame->script()->bindingRootObject();
setJavaVM(vm);
// Add the binding to JS environment
JSC::ExecState* exec = window->globalExec();
JSC::JSObject* addedObject =
WeakJavaInstance::create(javascriptObj,
root)->createRuntimeObject(exec);
const jchar* s = env->GetStringChars(interfaceName, NULL);
if (s) {
// Add the binding name to the window's table of child
objects.
JSC::PutPropertySlot slot;
window->put(exec, JSC::Identifier(exec, (const UChar *)s,
env->GetStringLength(interfaceName)), addedObject,
slot);
env->ReleaseStringChars(interfaceName, s);
checkException(env);
}
}

how do i implement a.b.c() kinda behavior?
can you please help me achieve this

Patrick Geiller

unread,
May 26, 2010, 3:14:08 AM5/26/10
to jsc...@googlegroups.com

That's something you should ask to the WebKit mailing list. JSCocoa is a bridge that only uses the public JavascriptCore API, not the kind of code you're using here.

In JSCocoa, letting the user write a.b.c or a.b.c() in runtime was achieved by returning a wrapper object, but this was very fragile as it would miss some cases (don't remember which ones).

-Patrick

> --
> JSCocoa: http://inexdo.com/JSCocoa
> Source: http://github.com/parmanoir/jscocoa/tree/master
> Docs: http://code.google.com/p/jscocoa/
> Group: http://groups.google.com/group/jscocoa
> Unsubscribe: jscocoa+u...@googlegroups.com

Reply all
Reply to author
Forward
0 new messages