[webkit-dev] bindings layer should have a consistent way of getting at named items in collections

Maciej Stachowiak mjs at apple.com
Tue Oct 14 17:51:12 PDT 2008

On Oct 14, 2008, at 3:15 PM, Ojan Vafai wrote:

> I currently see nameGetter, namedItem and getNamedItem in a number  
> of different files that all currently have custom bindings that  
> normalize to a nameGetter function.
> Can we just have all the collection types normalize on a single name  
> for this function? It would mean that much of this custom binding  
> could be avoided.
> I'm running into this with Chromium as I am trying to replace our  
> PluginArray and MimeTypeArray with WebKit's. This is messing with  
> our templates that currently just use namedItem (although could just  
> as easily use nameGetter if that's preferred).
> The big differences with our MimeTypeArray implementation is that it  
> kept a Vector of MimeTypes, returned raw pointers and used namedItem  
> instead of nameGetter. It would be great if we could unify these.

It would be great to make things as consistently as possible, though  
the key here is "as possible". Some of the IDL interfaces define an  
explicit namedItem() or getNamedItem() function, while others have  
only an implicit name getter. It is even possible in theory for an  
interface to have only a method named namedItem() but no implicit get- 
by-name behavior.

What I would suggest is to give every class that supports get-by-name  
a method called "namedGetter", which is just an inline call to  
namedItem or getNamedItem or whatever, if there is an appropriate such  
method. Then the bindings generator could be changed so it can make  
use of that, and not require you to write namedItem() by hand in the  
JS bindings (by this I mean the JSC JS bindings).


More information about the webkit-dev mailing list