Subj : Re: JSClass callbacks To : Jamie Nordmeyer From : Brendan Eich Date : Fri Mar 25 2005 11:06 am Jamie Nordmeyer wrote: > Is there a good internet resource, or can somebody provide information, on > when and why to use the Resolve hook? In the simplest example I've seen, > the resolve hook is simply JS_ResolveStandardClass. In more complex > examples, it's actually defining new properties for an object. JS_ResolveStandardClass defines new properties too, so there's no difference in principle between those cases. You write "simply" and "more complex", and you're right that if you have to define the id yourself, the API call is a little more complicated than the API call to JS_ResolveStandardClass. But the idea's the same: when resolve is called, id does not name a property directly contained in obj (it might name a property in a prototype of obj; we don't know yet, and resolve could check if it needs to know). If the object's class "knows" about id somehow -- it's on a list of well-known properties that should be resolved lazily, not defined eagerly when obj was created, e.g. -- then resolve should define a property for id. The most common application is when reflecting properties in obj from a "peer" object system implemented in C, C++, Java, etc., where the bridge between JS and its peer must not eagerly reflect all objects and properties for obvious performance reasons, but must reflect those (obj, id) pairs demanded by running scripts. /be .