Subj : Re: generic getter for more than 256 properties To : Brann Joly From : Brendan Eich Date : Wed May 12 2004 10:46 am Brann Joly wrote: >>The id passed to a JSPropertyOp (getProperty, setProperty in JSClass) >>comes from the name parameter to JS_DefineProperty, etc. (the property >>defining APIs that lack the "WithTinyId" suffix in their names). When >>you define a normal property, there is no tinyid. When you define a >>property with a tinyid, the tinyid, tagged as an int jsval, gets passed >>to your JSPropertyOps. > > > How do u convert the name into an int? i can't find anything about that in > the documentation:( You have to hash the jsval, which could be int- or string-tagged, yourself. See jshash.h and jsdhash.h, read the comments in the latter to decide which hashtable you want to use. > I plan to write a small tutorial on generic wrappers/getters/setters when > i'm done with my project, since I feel like documentation on this particular > topic is really missing :( Yes, this is something that has been done before (XPConnect, PyXPCOM, a few others) by people who knew the way to go, and didn't get misled by tinyids. The docs should be better. /be .