MOZ_ALWAYS_INLINE bool bool_valueOf_impl(JSContext *cx, CallArgs args) { HandleValue thisv = args.thisv(); JS_ASSERT(IsBoolean(thisv)); bool b = thisv.isBoolean() ? thisv.toBoolean() : thisv.toObject().as<BooleanObject>().unbox(); args.rval().setBoolean(b); return true; }
MOZ_ALWAYS_INLINE bool bool_toSource_impl(JSContext *cx, CallArgs args) { HandleValue thisv = args.thisv(); JS_ASSERT(IsBoolean(thisv)); bool b = thisv.isBoolean() ? thisv.toBoolean() : thisv.toObject().as<BooleanObject>().unbox(); StringBuffer sb(cx); if (!sb.append("(new Boolean(") || !BooleanToStringBuffer(b, sb) || !sb.append("))")) return false; JSString *str = sb.finishString(); if (!str) return false; args.rval().setString(str); return true; }