Subj : Re: generic getter for more than 256 properties To : Brann Joly From : Brendan Eich Date : Tue May 11 2004 12:36 pm Brann Joly wrote: > hi:) > > now my generic method wrapper question is solved, thanks to Brendan and > Shanti advices, but i'm in trouble with generic getters. > I thought the tinyid would have solved the question, but it seems to bring > two problems : > - the number of properties an object can have (including inherited > properties) is limited to 256 > - i have to be carefull on the way i'm choosing my tiniyId, so that the > tinyId is never the same as another inherited property tinyids exist so native class implementations can share getters and setters among a small set of known properties. If you are dealing with a very large set of known properties, or an unknown set of properties, then you are outside of the design target area. > I have found a similar thread on > http://groups.google.com/groups?hl=fr&lr=&ie=UTF-8&oe=UTF-8&threadm=401ea1ba%241%4010.10.0.241&rnum=1&prev=/groups%3Fq%3D%2522256%2Bproperties%2522%2Bgroup:netscape.public.mozilla.jseng%26hl%3Dfr%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3Dnetscape.public.mozilla.jseng%26selm%3D401ea1ba%25241%254010.10.0.241%26rnum%3D1 > but the only answer in it is "dont use a generic getter with more than 256 > properties" ... > > Of course i may stick to the 256 properties limit and find some tricks for > the tinyId attribution, but isn't there a cleaner solution? > (I need to use a generic getter because the objects are created at run time, > thus denying any compile time getter generation solution) Why would you want to use tinyids at all? Why not just map the id to whatever you need, internal to your implementation, using a hashtable? > when a native function is called, a hiden parameter ( argv[-1] ) contains > the name of the property, and i can access to its reserved slots. argv[-2], not argv[-1] (argv[-1] is the |this| parameter in JS, canonically named |obj| in the JSNative signature). /be .