[webkit-dev] JS: Getter/Setter callbacks at Property level

Maciej Stachowiak mjs at apple.com
Wed Jul 22 22:39:09 PDT 2009


Jumping in late here, but a couple of points:

1) Instead of JSClassSetPropertyGetterSetter, it might be more in line  
with the class design to be able to define getters and setters in the  
class struct, just as functions are. In addition to being more  
convenient, this API may also provide future optimization  
opportunities when we optimize access to programmatically defined  
properties.

2) There's not currently a performance penalty for re-checking the  
property name in the catchall getter that you currently have  
available, because it gets called without JavaScriptCore doing a  
property lookup first.

3) Probably the easiest way to restructure your code with the current  
API is to have a single get function that checks against property  
names, and calls the right individual property getting functions. That  
should require less rewriting, while working mostly in the bounds of  
the current API.

4) When we add support for ES5 property attributes, it would probably  
make sense to expose this in the API as well, which would make it  
possible to define one-off getters on objects.

  - Maciej

On Jul 22, 2009, at 10:26 PM, Geoffrey Garen wrote:

> Sure!
>
> Geoff
>
> On Jul 20, 2009, at 3:51 PM, Brian Barnes wrote:
>
>> What should be my next step, here?  Submit a "bug" for this?
>>
>> [>] Brian
>>
>> On Jul 20, 2009, at 6:05 PM, Geoffrey Garen wrote:
>>
>>>> How about separate call backs at the class level?  That would  
>>>> solve my problem with minimal code movement.  Something like:
>>>>
>>>> JSClassSetPropertyGetterSetter 
>>>> (ctx,class,"red",myRedGetter,myRedSetter);
>>>>
>>>> Would that be more within the design?
>>>
>>> Yes. That's what I had in mind when I mentioned "an API for adding  
>>> C getters and setters to a class individually."
>>>
>>> Geoff
>>>
>>
>
> _______________________________________________
> 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/20090722/d760c5a3/attachment.html>


More information about the webkit-dev mailing list