Subj : Re: Help with embedding spidermonkey please!!! To : netscape.public.mozilla.jseng From : =?ISO-8859-1?Q?Georg_Maa=DF?= Date : Sat Nov 08 2003 08:33 pm Brendan Eich wrote: > Thanks, Georg. I wanted to add an explanation of why this is so: the JS > engine uses the *address* of each JSClass as the unique-per-class (among > all runtimes!) [[Class]] internal property value (see ECMA-262). This > internal property of all native objects tells us what class each belongs > to, via pointer comparison or, more frequently, via calls through > clasp->getProperty, etc. (or clasp->getObjectOps()->...). > > Make each JSClass static and you'll be happy. > > /be > His ScriptEngine class destroys the runtime in its destructor. So what is the advantage of static ScriptEngine members containing JSClasses in opposite to non static members? Non static members allow individual global object instances for ecah instance of the ScriptEngine class. Static members result in one shared instance for each static member. This may be less memory consumption than using individual instances, but I guess if a ScriptEngine class is defined instead of a ScriptEngine namespace, then independent gobal objects are desired. Other wise a namespace in stead of a class would be the more suitable language construct for this purpose. Or are there other aspects why you suggest to declare the JSClasses as static members? Georg -- Georg Maaß - bioshop.de D-76227 Karlsruhe, Westmarkstraße 82 HTML, XML / JavaScript, C++, Java, PHP, VB / CGI, JSP, ASP, ASP.net - The ultimative DHTML engine: http://gml-modul.sourceforge.net - http://sourceforge.net/projects/gml-modul .