[webkit-dev] WebScripting protocol: valueForUndefinedKey: never gets called

Eddy Bruël ejpbruel at gmail.com
Tue Nov 17 16:41:18 PST 2009

Hi Geoffrey,

Sure, I'll file a bug report for you.

About your workaround though: wouldn't
only be called when the user tries to call a method that is not explicitly
exposed to Javascript?
Say for instance, that instead of calling a method by writing: x.test(), I
would want to get it as a
property by writing var y = x. test (I could wrap the selector in an object
implementing the
WebScripting protocol, and override invokeDefaultMethodWithArguments:).

This wouldn't be solved by your workaround, or am I mistaken? I'm kind of
desperate for a
solution, even if temporary, since this (potential) bug voids the entire
route we had in mind for our
reflection layer. Any help or pointers you could offer me would be greatly



On Tue, Nov 17, 2009 at 9:02 PM, Geoffrey Garen <ggaren at apple.com> wrote:

> Hi Eddy.
> This seems like a bug to me. Would you be willing to file it at
> bugs.webkit.org?
> I have a guess at a possible work-around. In the class where you've
> implemented valueForUndefinedKey:, try also
> implementing invokeUndefinedMethodFromWebScript:withArguments:.
> Thanks,
> Geoff
> On Nov 17, 2009, at 7:37 AM, Eddy Bruël wrote:
> Hi everybody,
> I am in the process of writing some code in ObjC, which would allow
> me to make calls from Javascript to C++ objects implementing a
> simple reflection interface (it basically allows you to associated
> indices with names, and perform operations such as
> getting/setting/calling on these indices).
> In order to do this, I created a simple ObjC wrapper object around the
> C++ interface, which implements the WebScripting protocol. However,
> since this wrapper object does not have any member variables (they
> are all hidden behind the C++ interface), I cannot expose these to
> Javascript directly.
> Instead, I've tried to make them available using KVC, specifically by
> using the methods valueForUndefinedKey: and
> setValue:forUndefinedKey:. For isKeyExcludedFromWebScript: and
> isSelectorExcludedFromWebScript: I simply always return YES.
> Setting properties like this seems to work fine. The method get called,
> and I simply forward it to the reflection interface. Getting properties, on
> the other hand, does not seem to work: valueForUndefinedKey: simply
> does not get called. At all.
> I found an entry on the Apple mailing lists of somebody seemingly
> having the same problem as me. Unfortunately, there was no answer:
> http://lists.apple.com/archives/webkitsdk-dev/2008/Oct/msg00021.html
> Am I overlooking something? Are there any other methods I need to
> override in order for this to work? Or is it simply a bug in WebKit, since
> this approach to exposing properties seems to be non-standard, at least.
> Any feedback on this issue would be very much appreciated! :-)
> Cheers,
> Eddy
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20091118/62976a0a/attachment.html>

More information about the webkit-dev mailing list