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

Eddy Bruël ejpbruel at gmail.com
Tue Nov 17 07:37:51 PST 2009

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:

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! :-)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20091117/fa4f7a13/attachment.html>

More information about the webkit-dev mailing list