if (JSVAL_IS_PRIMITIVE(cval)) { js_ReportIsNotFunction(cx, &cval, JS_TRUE); return NULL; }
js_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto,                   JSObject *parent, uintN argc, jsval *argv){    jsval cval, rval;    JSObject *obj, *ctor;    if (!FindConstructor(cx, parent, clasp->name, &cval))        return NULL;    /*     * If proto or parent are NULL, set them to Constructor.prototype and/or     * Constructor.__parent__, just like JSOP_NEW does.     */    ctor = JSVAL_TO_OBJECT(cval);    if (!parent)        parent = OBJ_GET_PARENT(cx, ctor);    if (!proto) {        if (!OBJ_GET_PROPERTY(cx, ctor,                              (jsid)cx->runtime->atomState.classPrototypeAtom,                              &rval)) {            return NULL;        }        if (JSVAL_IS_OBJECT(rval))            proto = JSVAL_TO_OBJECT(rval);    }    obj = js_NewObject(cx, clasp, proto, parent);    if (!obj)        return NULL;    if (!js_InternalConstruct(cx, obj, cval, argc, argv, &rval))        goto bad;    return JSVAL_IS_OBJECT(rval) ? JSVAL_TO_OBJECT(rval) : obj;bad:    cx->newborn[GCX_OBJECT] = NULL;    return NULL;}