Subj : Using JS_InstanceOf with jsval's To : netscape.public.mozilla.jseng From : gibson@cs.utah.edu (Mike Gibson) Date : Tue Jan 20 2004 12:59 pm I'm having problems getting JS_InstanceOf to return what I expect when I use jsval's returned from scripts. I create s simple object model with the class "A" as the parent of "B". JS_InstanceOf then tells me "new A();" is an instance of "B", which isn't correct. Am I using it right? With the following JavaScript (test.js): function A() { this.a = 1; } function B() { this.b = 2; } B.prototype = new A; I run the following C++ code (standard init code snipped): // Compile and run the above JavaScript ... snip ... char *s; jsval aval, bval; s = "a = new A();"; ok = JS_EvaluateScript(cx, glob, s, strlen(s), "", 0, &aval); s = "b = new B();"; ok = JS_EvaluateScript(cx, glob, s, strlen(s), "", 0, &bval); // this JS_Instance call returns true when it should return false JS_InstanceOf(cx, JSVAL_TO_OBJECT(aval), JS_GetClass(JSVAL_TO_OBJECT(bval)), NULL)); Thanks, Mike Gibson gibson@cs.utah.edu .