Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
jsbool.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define JSVAL_HOLE   BOOLEAN_TO_JSVAL(2)
#define JSVAL_ARETURN   BOOLEAN_TO_JSVAL(3)

Functions

JSObjectjs_InitBooleanClass (JSContext *cx, JSObject *obj)
JSObjectjs_BooleanToObject (JSContext *cx, JSBool b)
JSStringjs_BooleanToString (JSContext *cx, JSBool b)
JSBool js_ValueToBoolean (JSContext *cx, jsval v, JSBool *bp)

Variables

JSClass js_BooleanClass

Define Documentation

Definition at line 58 of file jsbool.h.

Definition at line 57 of file jsbool.h.


Function Documentation

Definition at line 178 of file jsbool.c.

{
    JSObject *obj;

    obj = js_NewObject(cx, &js_BooleanClass, NULL, NULL);
    if (!obj)
        return NULL;
    OBJ_SET_SLOT(cx, obj, JSSLOT_PRIVATE, BOOLEAN_TO_JSVAL(b));
    return obj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 190 of file jsbool.c.

{
    return ATOM_TO_STRING(cx->runtime->atomState.booleanAtoms[b ? 1 : 0]);
}

Definition at line 165 of file jsbool.c.

{
    JSObject *proto;

    proto = JS_InitClass(cx, obj, NULL, &js_BooleanClass, Boolean, 1,
                        NULL, boolean_methods, NULL, NULL);
    if (!proto)
        return NULL;
    OBJ_SET_SLOT(cx, proto, JSSLOT_PRIVATE, JSVAL_FALSE);
    return proto;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_ValueToBoolean ( JSContext cx,
jsval  v,
JSBool bp 
)

Definition at line 196 of file jsbool.c.

{
    JSBool b;
    jsdouble d;

    if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) {
        b = JS_FALSE;
    } else if (JSVAL_IS_OBJECT(v)) {
        if (!JS_VERSION_IS_ECMA(cx)) {
            if (!OBJ_DEFAULT_VALUE(cx, JSVAL_TO_OBJECT(v), JSTYPE_BOOLEAN, &v))
                return JS_FALSE;
            if (!JSVAL_IS_BOOLEAN(v))
                v = JSVAL_TRUE;         /* non-null object is true */
            b = JSVAL_TO_BOOLEAN(v);
        } else {
            b = JS_TRUE;
        }
    } else if (JSVAL_IS_STRING(v)) {
        b = JSSTRING_LENGTH(JSVAL_TO_STRING(v)) ? JS_TRUE : JS_FALSE;
    } else if (JSVAL_IS_INT(v)) {
        b = JSVAL_TO_INT(v) ? JS_TRUE : JS_FALSE;
    } else if (JSVAL_IS_DOUBLE(v)) {
        d = *JSVAL_TO_DOUBLE(v);
        b = (!JSDOUBLE_IS_NaN(d) && d != 0) ? JS_TRUE : JS_FALSE;
    } else {
        JS_ASSERT(JSVAL_IS_BOOLEAN(v));
        b = JSVAL_TO_BOOLEAN(v);
    }

    *bp = b;
    return JS_TRUE;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 57 of file jsbool.c.