Subj : Re: Properties not defined with JS_DefineProperty possible? To : netscape.public.mozilla.jseng From : Thomas Sondergaard Date : Sat Jan 15 2005 12:53 pm On Sat, 08 Jan 2005 14:06:46 -0800, Brendan Eich wrote: > Of course -- JSClass.getProperty and JSClass.setProperty can mirror > changes from and to your std::map. You can set the JSClass.flags bit > JSCLASS_SHARE_ALL_PROPERTIES to avoid any parallel map being managed by > SpiderMonkey. Then for each get or set, the appropriate JSClass hook > will be called and you can fetch or store using your map. Hi Brendan, Yes, I realize that I don't have to keep *values* in sync and that I can have spidermonkey invoke the get/setProperty (JSPropertyOp) to get/set the value from my native object, but can I avoid having to tell spidermonkey what properties (names!) exist up front with JSDefineProperty/JSDefineProperties? As an example, let's say I have defined an object called 'data' and I want the properties on it to reflect the contents of my c++ std::map. So if the expression "data['noOfImages']" (or "data.noOfImages") is evaluated how does the js engine know which jsid to pass to my getPropertyOp if I have not previously told the engine that the object has a property with that name using JSDefinePropert*? Is this possible? What I'm thinking of is a hook that the engine will call to lookup properties on an object dynamically. Cheers, Thomas .