Subj : Re: Help with embedding spidermonkey please!!! To : =?ISO-8859-1?Q?Georg_Maa=DF?= From : Brendan Eich Date : Sat Nov 08 2003 11:39 am Georg Maaß wrote: > 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? No advantage in that case, you're right -- unless there are multiple instances of ScriptEngine. Think of the JSClass (and JSObjectOps) as poor-man's-C++-vtables-in-C. C++ vtables are static and readonly, so can be one per class per program (linkers can coalesce identical ones for the same-named type that arise in separate shared libraries). /be .