示例#1
0
/* ToObject() on a value */
js_Object *jsV_toobject(js_State *J, const js_Value *v)
{
	switch (v->type) {
	default:
	case JS_TUNDEFINED: js_typeerror(J, "cannot convert undefined to object");
	case JS_TNULL: js_typeerror(J, "cannot convert null to object");
	case JS_TBOOLEAN: return jsV_newboolean(J, v->u.boolean);
	case JS_TNUMBER: return jsV_newnumber(J, v->u.number);
	case JS_TSTRING: return jsV_newstring(J, v->u.string);
	case JS_TOBJECT: return v->u.object;
	}
}
示例#2
0
void js_newboolean(js_State *J, int v)
{
	js_pushobject(J, jsV_newboolean(J, v));
}