private static Object tryBoolean(Object value) { if (value == NOT_FOUND) return NOT_FOUND; return ScriptRuntime.toBoolean(value); }
/** * Convert the value to a JavaScript boolean value. * <p> * See ECMA 9.2. * * @param value a JavaScript value * @return the corresponding boolean value converted using * the ECMA rules */ public static boolean toBoolean(Object value) { return ScriptRuntime.toBoolean(value); }
/** * @param newValue the new return value */ @JsxSetter(CHROME) public void setReturnValue(final Object newValue) { preventDefault_ = !ScriptRuntime.toBoolean(newValue); } }
private static boolean stack_boolean(CallFrame frame, int i) { Object x = frame.stack[i]; if (x == Boolean.TRUE) { return true; } else if (x == Boolean.FALSE) { return false; } else if (x == UniqueTag.DOUBLE_MARK) { double d = frame.sDbl[i]; return d == d && d != 0.0; } else if (x == null || x == Undefined.instance) { return false; } else if (x instanceof Number) { double d = ((Number)x).doubleValue(); return (d == d && d != 0.0); } else if (x instanceof Boolean) { return ((Boolean)x).booleanValue(); } else { return ScriptRuntime.toBoolean(x); } }
/** * @param newValue the new return value */ @JsxSetter(CHROME) public void setReturnValue(final Object newValue) { preventDefault_ = !ScriptRuntime.toBoolean(newValue); } }
private int applyDescriptorToAttributeBitset(int attributes, ScriptableObject desc) { Object enumerable = getProperty(desc, "enumerable"); if (enumerable != NOT_FOUND) { attributes = ScriptRuntime.toBoolean(enumerable) ? attributes & ~DONTENUM : attributes | DONTENUM; } Object writable = getProperty(desc, "writable"); if (writable != NOT_FOUND) { attributes = ScriptRuntime.toBoolean(writable) ? attributes & ~READONLY : attributes | READONLY; } Object configurable = getProperty(desc, "configurable"); if (configurable != NOT_FOUND) { attributes = ScriptRuntime.toBoolean(configurable) ? attributes & ~PERMANENT : attributes | PERMANENT; } return attributes; }
public static Object convertArg(Context cx, Scriptable scope, Object arg, int typeTag) { switch (typeTag) { case JAVA_STRING_TYPE: if (arg instanceof String) return arg; return ScriptRuntime.toString(arg); case JAVA_INT_TYPE: if (arg instanceof Integer) return arg; return Integer.valueOf(ScriptRuntime.toInt32(arg)); case JAVA_BOOLEAN_TYPE: if (arg instanceof Boolean) return arg; return ScriptRuntime.toBoolean(arg) ? Boolean.TRUE : Boolean.FALSE; case JAVA_DOUBLE_TYPE: if (arg instanceof Double) return arg; return new Double(ScriptRuntime.toNumber(arg)); case JAVA_SCRIPTABLE_TYPE: return ScriptRuntime.toObjectOrNull(cx, arg, scope); case JAVA_OBJECT_TYPE: return arg; default: throw new IllegalArgumentException(); } }
@Override protected void setInstanceIdValue(int id, Object value) { int shifted = id - super.getMaxInstanceId(); switch (shifted) { case Id_multiline: case Id_STAR: getImpl().multiline = ScriptRuntime.toBoolean(value); return; case Id_input: case Id_UNDERSCORE: getImpl().input = ScriptRuntime.toString(value); return; } super.setInstanceIdValue(id, value); }
async = ScriptRuntime.toBoolean(asyncParam);
async = ScriptRuntime.toBoolean(asyncParam);
async = ScriptRuntime.toBoolean(asyncParam);
async = ScriptRuntime.toBoolean(asyncParam);
((ScriptableObject) args[0]).avoidObjectDetection() ? true : ScriptRuntime.toBoolean(args[0]);
boolean keyOnly = args.length > 1 && ScriptRuntime.toBoolean(args[1]); if (thisObj != null) {