Subj : Re: argv argument to JS_InstanceOf To : Braden McDaniel From : Brendan Eich Date : Sun Aug 10 2003 11:16 pm Braden McDaniel wrote: >The SpiderMonkey API docs for JS_InstanceOf include > > If you pass a non-null argument vector, argv, to JS_InstanceOf, and obj > is not an instance of clasp, this function may report a class mismatch > before returning. To do so, JS_InstanceOf tests whether or not there is > a function name associated with the argument vector, and if there is, > reports the name in an error message using the JS_ReportError function. > >I'm really not sure exactly what that second sentence means. Could someone >provide a brief example of how this would be used? > What atrocious writing. At least the docs are in CVS right near the source, so anyone motivated can provide a patch. I'll get to this. 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. This is one of few cases where the API takes a cx argument and can fail (return false or null) without necessarily reporting/throwing -- null argv means the caller wants only a test, no other effects. /be .