Java Code Examples for org.mozilla.javascript.Undefined#instance()
The following examples show how to use
org.mozilla.javascript.Undefined#instance() .
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: NativeRegExp.java From JsDroidCmd with Mozilla Public License 2.0 | 6 votes |
Scriptable compile(Context cx, Scriptable scope, Object[] args) { if (args.length > 0 && args[0] instanceof NativeRegExp) { if (args.length > 1 && args[1] != Undefined.instance) { // report error throw ScriptRuntime.typeError0("msg.bad.regexp.compile"); } NativeRegExp thatObj = (NativeRegExp) args[0]; this.re = thatObj.re; this.lastIndex = thatObj.lastIndex; return this; } String s = args.length == 0 || args[0] instanceof Undefined ? "" : escapeRegExp(args[0]); String global = args.length > 1 && args[1] != Undefined.instance ? ScriptRuntime.toString(args[1]) : null; this.re = compileRE(cx, s, global, false); this.lastIndex = 0d; return this; }
Example 2
Source File: JsGlobal.java From JsDroidCmd with Mozilla Public License 2.0 | 6 votes |
@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { String key = Context.toString(args[0]); try { IConfigService config = ProxyServiceManager.getService(pkg + ".config", IConfigService.class); if (config != null) { Object ret = config.read(key); if (ret != null) { return ret.toString(); } } } catch (Exception e) { } return Undefined.instance; }
Example 3
Source File: NativeUint16Array.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override protected Object js_set(int index, Object c) { if (checkIndex(index)) { return Undefined.instance; } int val = Conversions.toUint16(c); ByteIo.writeUint16(arrayBuffer.buffer, (index * BYTES_PER_ELEMENT) + offset, val, false); return null; }
Example 4
Source File: NativeFloat32Array.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override protected Object js_get(int index) { if (checkIndex(index)) { return Undefined.instance; } return ByteIo.readFloat32(arrayBuffer.buffer, (index * BYTES_PER_ELEMENT) + offset, false); }
Example 5
Source File: NativeInt8Array.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override protected Object js_set(int index, Object c) { if (checkIndex(index)) { return Undefined.instance; } int val = Conversions.toInt8(c); ByteIo.writeInt8(arrayBuffer.buffer, index + offset, val); return null; }
Example 6
Source File: NativeInt8Array.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override protected Object js_get(int index) { if (checkIndex(index)) { return Undefined.instance; } return ByteIo.readInt8(arrayBuffer.buffer, index + offset); }
Example 7
Source File: NativeInt32Array.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override protected Object js_set(int index, Object c) { if (checkIndex(index)) { return Undefined.instance; } int val = ScriptRuntime.toInt32(c); ByteIo.writeInt32(arrayBuffer.buffer, (index * BYTES_PER_ELEMENT) + offset, val, false); return null; }
Example 8
Source File: JsGlobal.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { try { String key = Context.toString(args[0]); String value = Context.toString(args[1]); IConfigService config = ProxyServiceManager.getService(pkg + ".config", IConfigService.class); if (config != null) { config.save(key, value); } } catch (Exception e) { } return Undefined.instance; }
Example 9
Source File: NativeRegExp.java From astor with GNU General Public License v2.0 | 5 votes |
private Object execSub(Context cx, Scriptable scopeObj, Object[] args, int matchType) { RegExpImpl reImpl = getImpl(cx); String str; if (args.length == 0) { str = reImpl.input; if (str == null) { reportError("msg.no.re.input.for", toString()); } } else { str = ScriptRuntime.toString(args[0]); } double d = ((re.flags & JSREG_GLOB) != 0) ? lastIndex : 0; Object rval; if (d < 0 || str.length() < d) { lastIndex = 0; rval = null; } else { int indexp[] = { (int)d }; rval = executeRegExp(cx, scopeObj, reImpl, str, indexp, matchType); if ((re.flags & JSREG_GLOB) != 0) { lastIndex = (rval == null || rval == Undefined.instance) ? 0 : indexp[0]; } } return rval; }
Example 10
Source File: NativeUint8ClampedArray.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override protected Object js_get(int index) { if (checkIndex(index)) { return Undefined.instance; } return ByteIo.readUint8(arrayBuffer.buffer, index + offset); }
Example 11
Source File: JsGlobal.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { BySelector by = (BySelector) Context.jsToJava(args[0], BySelector.class); Object ret = UiDevice.getInstance().findObject(by); if (ret != null) { return ret; } return Undefined.instance; }
Example 12
Source File: NativeUint32Array.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override protected Object js_set(int index, Object c) { if (checkIndex(index)) { return Undefined.instance; } long val = Conversions.toUint32(c); ByteIo.writeUint32(arrayBuffer.buffer, (index * BYTES_PER_ELEMENT) + offset, val, false); return null; }
Example 13
Source File: NativeFloat64Array.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override protected Object js_set(int index, Object c) { if (checkIndex(index)) { return Undefined.instance; } double val = ScriptRuntime.toNumber(c); long base = Double.doubleToLongBits(val); ByteIo.writeUint64(arrayBuffer.buffer, (index * BYTES_PER_ELEMENT) + offset, base, false); return null; }
Example 14
Source File: JsGlobal.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { UiDevice.getInstance().takeScreenshot( new File(Context.toString(args[0]))); return Undefined.instance; }
Example 15
Source File: NativeUint8Array.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override protected Object js_set(int index, Object c) { if (checkIndex(index)) { return Undefined.instance; } int val = Conversions.toUint8(c); ByteIo.writeUint8(arrayBuffer.buffer, index + offset, val); return null; }
Example 16
Source File: NativeInt16Array.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
@Override protected Object js_set(int index, Object c) { if (checkIndex(index)) { return Undefined.instance; } int val = Conversions.toInt16(c); ByteIo.writeInt16(arrayBuffer.buffer, (index * BYTES_PER_ELEMENT) + offset, val, false); return null; }
Example 17
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 18
Source File: JsGlobal.java From JsDroidCmd with Mozilla Public License 2.0 | 4 votes |
@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { quit(); return Undefined.instance; }
Example 19
Source File: JsDebugFrame.java From birt with Eclipse Public License 1.0 | 4 votes |
public synchronized VMValue evaluate( String expression ) { int currentState = debugger.currentState( ); if ( currentState == VM_TERMINATED ) { return null; } JsValue result = null; Debugger oldDebugger = cx.getDebugger( ); Object oldContextData = cx.getDebuggerContextData( ); int oldLevel = cx.getOptimizationLevel( ); cx.setDebugger( null, null ); cx.setOptimizationLevel( -1 ); cx.setGeneratingDebug( false ); try { Callable script = (Callable) cx.compileString( expression, EVALUATOR_LITERAL, 0, null ); Object val = script.call( cx, scope, thisObj, ScriptRuntime.emptyArgs ); if ( val == Undefined.instance ) { result = new JsValue( UNDEFINED_LITERAL, UNDEFINED_TYPE ); } else { result = new JsValue( val ); } } catch ( Exception ex ) { result = new JsValue( ex.getMessage( ), EXCEPTION_TYPE ); } finally { cx.setGeneratingDebug( true ); cx.setOptimizationLevel( oldLevel ); cx.setDebugger( oldDebugger, oldContextData ); } return result; }
Example 20
Source File: DetermineBasalAdapterSMBJS.java From AndroidAPS with GNU Affero General Public License v3.0 | 3 votes |
private Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) { if (jsonObject == null) return Undefined.instance; Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), (context, scriptable, scriptable1, objects) -> objects[1]); return param; }