Subj : Re: Binding a global object (again) To : John J Lee From : Brendan Eich Date : Sat Aug 30 2003 08:25 pm John J Lee wrote: >What actually happens is that get_property never gets called, and >instead I get this error from the JS engine: > >ReferenceError: name is not defined > Unqualified references (name, not window.name) do not call JSClass.getProperty for each object on the scope chain. If you haven't predefined name, you will get that ReferenceError. If you want to define name lazily, you need a non-stub JSClass.resolve hook. Don't use JSObjectOps, but if you were, you'd notice that JSObjectOps.lookupProperty is called for each object on the scope chain when evaluating 'name;'. Only when lookupProperty finds a property will JSObjectOps.getProperty be called, and only then (for the native JSObjectOps implementation) will JSClass.getProperty be called. JSClass is the lower-level API that shares lots of code common to all native objects (and to most "host" objects) in the upper layer that implements JSObjectsOps for the native case (in jsobj.c). You're right, I commented everything in jspubtd.h, both JSClass and JSObjectOps function pointer typedefs. I could have left the JSObjectOps ones undocumented, but comments helped people working on the engine, too. Probably the right thing to do is split JSObjectOps out into a separate jsobjapi.h, because parts of jsobj.h would want to move there too. But that may not happen. /be .