Subj : Re: JSClass callbacks To : netscape.public.mozilla.jseng From : Jamie Nordmeyer Date : Fri Mar 25 2005 11:21 am Oh, OK. So for example, if I wanted to create my own version of the 'new ActiveXObject' call used in Internet Explorer's implementation of Javascript to attach to a late-bound COM object, the Resolve hook is where I'd do this then. For example: var obj = new ActiveXObject("SomeObject.SomeClass"); obj.someLateBoundFunc(); I get it now. Cool. Thanks a ton, Brenden! "Brendan Eich" wrote in message news:4244613F.8010708@meer.net... > 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 .