Subj : Re: (Spidermonkey) Converting a property name to a tinyId To : netscape.public.mozilla.jseng From : zakalawe@mac.com (James Turner) Date : Fri Mar 14 2003 01:11 pm Brendan Eich wrote in message news:<3E6F838B.8060907@meer.net>... > It does, but maybe you can get it from where you need it. Where in your > code do you have this pressing need? If within a property getter or > setter, then of course JSVAL_IS_INT(id) is true, and JSVAL_TO_INT(id) > gives the tinyid. Otherwise, if you have only a short list of > properties, linear search should be ok. We could add a > JS_GetPropertyTinyId as you suggest, but maybe it's not worth the code > bloat (minor, but still) in the common engine, if only a few embeddings > need it and can compute what it returns otherwise. > > So sell me! Well ... I have no illusions about the general aplicability of this function to other embedders, feel free to simply post a code snippet that gets the job done. Anyway, the reason I need this is I'm 'dual-purpose'ing my property setters (and maybe getters too). I.e they are hooked up as 'direct' JSPropertyOps in the property defintions for my object. But I also want to invoke the same code logic in response to some other events (persistence and network transmission, it's a long story). So, again, I think I need this. I could make it work by havinng the implementation of my propertyOps check the property by both ID *and* name (so either works), but that all seems like hackage and duplication that could be avoided. Note : obtaining the behaviour by execting a trival script from an in-memory string is *not* acceptable (I figure at least one person will suggest it) Am I right, or just plain silly? James .