Subj : Re: argv argument to JS_InstanceOf To : Braden McDaniel From : Brendan Eich Date : Thu Aug 14 2003 12:35 am Braden McDaniel wrote: >On Sun, 10 Aug 2003 22:16:26 -0700, Brendan Eich wrote: > > > >>What the docs are trying to say is that if you want to check whether an >>object is an instance of a class without errors (as exceptions, unless >>OOM, in the modern engine) being reported/thrown, pass NULL for argv. >>If you are OTOH calling JS_InstanceOf from a native function and *want* >>an error report implicating the native's "obj" parameter as not being of >>the right class, while also naming the native function, then pass argv. >> >> > >Will vp work just as well when inside a JSPropertyOp? > No. It's harder to cause the wrong |obj| parameter to be passed to your class's getProperty or setProperty. You have to delegate to a prototype object other than the class prototype. Either someone is using JS_SetPrototype, or someone must be mucking directly with __proto__. In such hard cases, you usually want to use JS_GetInstancePrivate from the JSPropertyOp, passing null for argv, and thus detecting the class mismatch without reporting an error. The mismatched method case is an error because there's no way to do what's being asked, but a get or set on an id found in a prototype of the "wrong" class should just access the slot (if any), without any class-specific get/setProperty filtering. /be .