JavaScript-1.5 Reference

JS_InstanceOf Function

Summary

Determines if an object is an instance of a specified JS class.

Syntax

JSBool JS_InstanceOf(JSContext *cx, JSObject *obj,
    JSClass *clasp, jsval *argv);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information.
objJSObject *Object to test.
claspJSClass *Class against which to test the object.
argvjsval *Optional argument vector. If you do not want to pass an argument vector, pass NULL for this argument.

Description

JS_InstanceOf determines if a specified JS object, obj, has a JS class struct, clasp. If the object's internal class pointer corresponds to clasp, this function returns JS_TRUE, indicating that the object is an instance of the class. Otherwise, JS_InstanceOf returns JS_FALSE.

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.

See Also

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JSClass | JS_GetClass | JS_InitClass | JS_ReportError ]

This page was generated by APIDOC