Subj : Re: gc questions (and various questions also) To : netscape.public.mozilla.jseng From : Brann Joly Date : Wed May 12 2004 11:22 pm Thx for the quick answer, brendan :) > JS_DefineObject is just shorthand for JS_NewObject; JS_DefineProperty. > See the source. What's the interest of defining an object as a property of another one? (in both case, my getter will be called when the property will be accessed, and I will have the possibility to return whatever i want, wont i?) Is it only because as a property of another object, the object is rooted for GC ? > > Why wouldn't you use the resolve JSClass hook instead? Lazily creating > on each get adds overhead to all but the first get calls that you might > want to avoid. Yes, i create the object prototype only once (and i keep the Jsclass structure somewhere), but i'm creating objects only when they are needed, since i dont want my whole Dom tree to be duplicated into memory > > Are these Vector objects values of properties of some other object? If > you are trying to follow the DOM, might they be named by id attributes, > and fetched via document.getElementById? But then they would want to be > DOM Elements, not just Vectors. You'r perfectly right, and my tree is not exactly Dom compliant (it's not mine, and things are as they are:() In fact, each attributes is a C++ type, and various exotic types have been typedefed, such as vector or others so what do you think of my solution, i rewrite it here : I thought that i could create an object with 3 properties (x, y, z) and a private tag to my vector in dom, with a specialized getter returning the ints to spidermonkey if the user tries to access x, y or z . .