Subj : Binding a global object (again) To : netscape.public.mozilla.jseng From : jjl@pobox.com (John J. Lee) Date : Sat Aug 30 2003 05:29 pm I made a second attempt to bind a Python class to the JS global object. This time, my getProperty routine isn't getting called to look up Python attributes on the global object. Previously, I've got by just using getProperty and setProperty. Presumably I need to provide some other functions -- lookupProperty or hasInstance, maybe? Looking at the JSObjectOps documentation and jspubtd.h, I'm still left with these basic questions: 1. What's the difference between getProperty and lookupProperty, and when does lookupProperty need to be defined? 2. What's hasInstance for? What I'm doing is: malloc'ing a JSClass jsclass (I use one per Python class, to answer your question of a previous post), then: jsglobj = JS_NewObject(cx, jsclass, NULL, NULL); JS_InitStandardClasses(cx, jsglobj); where jsclass has the same setProperty / getProperty functions that I use for every other bound Python class, but they don't get called when I evaluate a JS script like "name;" that attempts to access a property of the global object. Instead, I get: ReferenceError: name is not defined OTOH, if I do this immediately after the JS_NewObject above: JS_DefineProperty(cx, jsglobj, "window", OBJECT_TO_JSVAL(jsglobj), NULL, NULL, 0); the script "window.name;" works as expected (and getProperty is called first for "window", then for "name"). Thanks for any help John .