Subj : Re: (Spidermonkey) Converting a property name to a tinyId To : James Turner From : Brendan Eich Date : Tue Mar 18 2003 03:15 pm James Turner wrote: >Brendan Eich wrote in message news:<3E7662AB.4060006@meer.net>... > > > >>What do you mean by default behavior? The default getProperty and >>setProperty implementations are stubs that return true. Can't you just do >> >> if (!JSVAL_IS_INT(prop)) >> return JS_TRUE; >> return ins->setBuiltinProperty(JSVAL_TO_INT(prop), value); >> >>here? (I'm pretending setBuiltinProperty returns a boolean indicating >>error/exception with false.) >> >> > >Ah, sorry, my terminology is wrong. What I meant was, there doesn't >seem to be a way, when defining property op in a JSClass, to access >the default behaviour of JSObject. I.e, add properties to the object's >map, lookup undefined properties on the prototype, and so forth. > That happens in logic one level above the JSClass level, normally. If your class getter is being called, it's because someone is getting a property that you defined on the object or its class prototype, or because no such property exists anywhere, and the object being referenced directly is of your class. In the latter case (no such property), delegating the get to a prototype doesn't make sense, generally -- the property wasn't found in any object on the prototype chain. But suppose you did want to delegate to a prototype's class getter. Then you're in the same boat as the former case, where the property exists on your class of object (either the one directly referenced, or a prototype of the same class). If you want to delegate to a grand-proto (say, to Object.prototype), you can do that using JS_GetPrototype and JS_GetProperty, but you'll need to use the original id, not a tinyid, of course, when calling JS_GetProperty. > So >you can't write 'filtering' property ops, at least as I currently >understand it. > Watchpoints are implemented as setter filters. I'm not sure exactly what you want to do, though. Perhaps a concrete example would make things clear. /be > >Am I correct, or got the wrong end of the proverbial stick? I've >looked through all the examples I could find, but most people using >JSClass seem to be only using builtin properties. > >H&H >James > > .