Java Code Examples for org.mozilla.javascript.ScriptRuntime#constructError()
The following examples show how to use
org.mozilla.javascript.ScriptRuntime#constructError() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeTypedArrayView.java From JsDroidCmd with Mozilla Public License 2.0 | 6 votes |
private void setRange(NativeTypedArrayView v, int off) { if (off >= length) { throw ScriptRuntime.constructError("RangeError", "offset out of range"); } if (v.length > (length - off)) { throw ScriptRuntime.constructError("RangeError", "source array too long"); } if (v.arrayBuffer == arrayBuffer) { // Copy to temporary space first, as per spec, to avoid messing up overlapping copies Object[] tmp = new Object[v.length]; for (int i = 0; i < v.length; i++) { tmp[i] = v.js_get(i); } for (int i = 0; i < v.length; i++) { js_set(i + off, tmp[i]); } } else { for (int i = 0; i < v.length; i++) { js_set(i + off, v.js_get(i)); } } }
Example 2
Source File: NativeRegExp.java From JsDroidCmd with Mozilla Public License 2.0 | 6 votes |
private static void addCharacterRangeToCharSet(RECharSet cs, char c1, char c2) { int i; int byteIndex1 = (c1 / 8); int byteIndex2 = (c2 / 8); if ((c2 >= cs.length) || (c1 > c2)) { throw ScriptRuntime.constructError("SyntaxError", "invalid range in character class"); } c1 &= 0x7; c2 &= 0x7; if (byteIndex1 == byteIndex2) { cs.bits[byteIndex1] |= ((0xFF) >> (7 - (c2 - c1))) << c1; } else { cs.bits[byteIndex1] |= 0xFF << c1; for (i = byteIndex1 + 1; i < byteIndex2; i++) cs.bits[i] = (byte)0xFF; cs.bits[byteIndex2] |= (0xFF) >> (7 - c2); } }
Example 3
Source File: NativeRegExp.java From astor with GNU General Public License v2.0 | 6 votes |
private static void addCharacterRangeToCharSet(RECharSet cs, char c1, char c2) { int i; int byteIndex1 = (c1 / 8); int byteIndex2 = (c2 / 8); if ((c2 >= cs.length) || (c1 > c2)) { throw ScriptRuntime.constructError("SyntaxError", "invalid range in character class"); } c1 &= 0x7; c2 &= 0x7; if (byteIndex1 == byteIndex2) { cs.bits[byteIndex1] |= ((0xFF) >> (7 - (c2 - c1))) << c1; } else { cs.bits[byteIndex1] |= 0xFF << c1; for (i = byteIndex1 + 1; i < byteIndex2; i++) cs.bits[i] = (byte)0xFF; cs.bits[byteIndex2] |= (0xFF) >> (7 - c2); } }
Example 4
Source File: NativeArrayBuffer.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
/** * Create a buffer of the specified length in bytes. */ public NativeArrayBuffer(int len) { if (len < 0) { throw ScriptRuntime.constructError("RangeError", "Negative array length " + len); } if (len == 0) { buffer = EMPTY_BUF; } else { buffer = new byte[len]; } }
Example 5
Source File: NativeTypedArrayView.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
private void setRange(NativeArray a, int off) { if (off > length) { throw ScriptRuntime.constructError("RangeError", "offset out of range"); } if ((off + a.size()) > length) { throw ScriptRuntime.constructError("RangeError", "offset + length out of range"); } int pos = off; for (Object val : a) { js_set(pos, val); pos++; } }
Example 6
Source File: NativeDataView.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
private void checkOffset(Object[] args, int pos) { if (args.length <= pos) { throw ScriptRuntime.constructError("TypeError", "missing required offset parameter"); } if (Undefined.instance.equals(args[pos])) { throw ScriptRuntime.constructError("RangeError", "invalid offset"); } }
Example 7
Source File: NativeDataView.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
private void checkValue(Object[] args, int pos) { if (args.length <= pos) { throw ScriptRuntime.constructError("TypeError", "missing required value parameter"); } if (Undefined.instance.equals(args[pos])) { throw ScriptRuntime.constructError("RangeError", "invalid value parameter"); } }
Example 8
Source File: NativeDataView.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
private NativeDataView js_constructor(NativeArrayBuffer ab, int offset, int length) { if (length < 0) { throw ScriptRuntime.constructError("RangeError", "length out of range"); } if ((offset < 0) || ((offset + length) > ab.getLength())) { throw ScriptRuntime.constructError("RangeError", "offset out of range"); } return new NativeDataView(ab, offset, length); }
Example 9
Source File: NativeRegExp.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
private static void addCharacterToCharSet(RECharSet cs, char c) { int byteIndex = (c / 8); if (c >= cs.length) { throw ScriptRuntime.constructError("SyntaxError", "invalid range in character class"); } cs.bits[byteIndex] |= 1 << (c & 0x7); }
Example 10
Source File: NativeRegExp.java From astor with GNU General Public License v2.0 | 5 votes |
private static void addCharacterToCharSet(RECharSet cs, char c) { int byteIndex = (c / 8); if (c >= cs.length) { throw ScriptRuntime.constructError("SyntaxError", "invalid range in character class"); } cs.bits[byteIndex] |= 1 << (c & 0x7); }
Example 11
Source File: NativeDataView.java From JsDroidCmd with Mozilla Public License 2.0 | 4 votes |
private void rangeCheck(int offset, int len) { if ((offset < 0) || ((offset + len) > byteLength)) { throw ScriptRuntime.constructError("RangeError", "offset out of range"); } }
Example 12
Source File: NativeDataView.java From JsDroidCmd with Mozilla Public License 2.0 | 4 votes |
@Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(getClassName())) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (id) { case Id_constructor: if (isArg(args, 0) && (args[0] instanceof NativeArrayBuffer)) { NativeArrayBuffer ab = (NativeArrayBuffer)args[0]; int off = isArg(args, 1) ? ScriptRuntime.toInt32(args[1]) : 0; int len = isArg(args, 2) ? ScriptRuntime.toInt32(args[2]) : ab.getLength() - off; return js_constructor(ab, off, len); } else { throw ScriptRuntime.constructError("TypeError", "Missing parameters"); } case Id_getInt8: return realThis(thisObj, f).js_getInt(1, true, args); case Id_getUint8: return realThis(thisObj, f).js_getInt(1, false, args); case Id_getInt16: return realThis(thisObj, f).js_getInt(2, true, args); case Id_getUint16: return realThis(thisObj, f).js_getInt(2, false, args); case Id_getInt32: return realThis(thisObj, f).js_getInt(4, true, args); case Id_getUint32: return realThis(thisObj, f).js_getInt(4, false, args); case Id_getFloat32: return realThis(thisObj, f).js_getFloat(4, args); case Id_getFloat64: return realThis(thisObj, f).js_getFloat(8, args); case Id_setInt8: realThis(thisObj, f).js_setInt(1, true, args); return Undefined.instance; case Id_setUint8: realThis(thisObj, f).js_setInt(1, false, args); return Undefined.instance; case Id_setInt16: realThis(thisObj, f).js_setInt(2, true, args); return Undefined.instance; case Id_setUint16: realThis(thisObj, f).js_setInt(2, false, args); return Undefined.instance; case Id_setInt32: realThis(thisObj, f).js_setInt(4, true, args); return Undefined.instance; case Id_setUint32: realThis(thisObj, f).js_setInt(4, false, args); return Undefined.instance; case Id_setFloat32: realThis(thisObj, f).js_setFloat(4, args); return Undefined.instance; case Id_setFloat64: realThis(thisObj, f).js_setFloat(8, args); return Undefined.instance; } throw new IllegalArgumentException(String.valueOf(id)); }
Example 13
Source File: NativeRegExp.java From JsDroidCmd with Mozilla Public License 2.0 | 4 votes |
private static void reportError(String messageId, String arg) { String msg = ScriptRuntime.getMessage1(messageId, arg); throw ScriptRuntime.constructError("SyntaxError", msg); }
Example 14
Source File: NativeRegExp.java From astor with GNU General Public License v2.0 | 4 votes |
private static void reportError(String messageId, String arg) { String msg = ScriptRuntime.getMessage1(messageId, arg); throw ScriptRuntime.constructError("SyntaxError", msg); }
Example 15
Source File: ExtensionErrorConstructor.java From io with Apache License 2.0 | 2 votes |
/** * エラーオブジェクトを生成する. * @param message エラーメッセージ * @return エラーオブジェクト */ public static EcmaError construct(String message) { return ScriptRuntime.constructError("Error", message); }