@Override public boolean equals(final Object that) { if ((that instanceof V8Object) && ((V8Object) that).isUndefined()) { return true; } return false; }
@Override public boolean equals(final Object that) { if ((that instanceof V8Object) && ((V8Object) that).isUndefined()) { return true; } return false; }
@Override public boolean equals(final Object that) { if ((that instanceof V8Object) && ((V8Object) that).isUndefined()) { return true; } return false; }
@Override public boolean equals(final Object that) { if ((that instanceof V8Object) && ((V8Object) that).isUndefined()) { return true; } return false; }
/** * Invoke the JavaScript function on the current runtime. * * @param receiver The object on which to call the function on. The * receiver will be mapped to 'this' in JavaScript. If receiver is null * or undefined, then the V8 runtime will be used instead. * @param parameters The parameters passed to the JS Function. * * @return The result of JavaScript function. */ @SuppressWarnings("resource") public Object call(V8Object receiver, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(receiver); v8.checkRuntime(parameters); receiver = receiver != null ? receiver : v8; long parametersHandle = parameters == null ? 0 : parameters.getHandle(); long receiverHandle = receiver.isUndefined() ? v8.getHandle() : receiver.getHandle(); return v8.executeFunction(v8.getV8RuntimePtr(), receiverHandle, objectHandle, parametersHandle); }
@Test public void testResultUndefinedExceptionObjectScript() { V8Object result = v8.executeObjectScript(""); assertTrue(result.isUndefined()); }
/*** Undefined ***/ @Test public void testUndefinedObjectProperty() { V8Object result = v8.getObject("object"); assertTrue(result.isUndefined()); }
@Test public void testResultUndefinedForNoReturnInobjectFunction() { v8.executeVoidScript("function foo() {};"); V8Object result = v8.executeObjectFunction("foo", null); assertTrue(result.isUndefined()); }
@Override public boolean equals(final Object that) { if ((that instanceof V8Object) && ((V8Object) that).isUndefined()) { return true; } return false; }
@Override public boolean equals(final Object that) { if ((that instanceof V8Object) && ((V8Object) that).isUndefined()) { return true; } return false; }
@Override public boolean equals(final Object that) { if ((that instanceof V8Object) && ((V8Object) that).isUndefined()) { return true; } return false; }
@Override public boolean equals(final Object that) { if ((that instanceof V8Object) && ((V8Object) that).isUndefined()) { return true; } return false; }
@Test public void testArrayGetObjectIndexOutOfBounds() { V8Array array = v8.executeArrayScript("[];"); V8Object result = array.getObject(0); assertTrue(result.isUndefined()); array.close(); }
/** * Invoke the JavaScript function on the current runtime. * * @param receiver The object on which to call the function on. The * receiver will be mapped to 'this' in JavaScript. If receiver is null * or undefined, then the V8 runtime will be used instead. * @param parameters The parameters passed to the JS Function. * * @return The result of JavaScript function. */ @SuppressWarnings("resource") public Object call(V8Object receiver, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(receiver); v8.checkRuntime(parameters); receiver = receiver != null ? receiver : v8; long parametersHandle = parameters == null ? 0 : parameters.getHandle(); long receiverHandle = receiver.isUndefined() ? v8.getHandle() : receiver.getHandle(); return v8.executeFunction(v8.getV8RuntimePtr(), receiverHandle, objectHandle, parametersHandle); }
/** * Recursively convert a V8 object to a map and release it * @param obj the object to convert * @return the map */ private Map<String, Object> convertObject(V8Object obj) { if (obj.isUndefined()) { return null; } Map<String, Object> r = new LinkedHashMap<>(); for (String k : obj.getKeys()) { Object o = obj.get(k); if (o instanceof V8Array) { o = convert((V8Array)o, List.class); } else if (o instanceof V8Object) { o = convert((V8Object)o, Map.class); } r.put(k, o); } return r; }
/** * Recursively convert a V8 object to a map and release it * @param obj the object to convert * @return the map */ private Map<String, Object> convertObject(V8Object obj) { if (obj.isUndefined()) { return null; } Map<String, Object> r = new LinkedHashMap<>(); for (String k : obj.getKeys()) { Object o = obj.get(k); if (o instanceof V8Array) { o = convert((V8Array)o, List.class); } else if (o instanceof V8Object) { o = convert((V8Object)o, Map.class); } r.put(k, o); } return r; }
/** * Invoke the JavaScript function on the current runtime. * * @param receiver The object on which to call the function on. The * receiver will be mapped to 'this' in JavaScript. If receiver is null * or undefined, then the V8 runtime will be used instead. * @param parameters The parameters passed to the JS Function. * * @return The result of JavaScript function. */ public Object call(V8Object receiver, final V8Array parameters) { v8.checkThread(); checkReleased(); receiver = receiver != null ? receiver : v8; long parametersHandle = parameters == null ? 0 : parameters.getHandle(); long receiverHandle = receiver.isUndefined() ? v8.getHandle() : receiver.getHandle(); return v8.executeFunction(v8.getV8RuntimePtr(), receiverHandle, objectHandle, parametersHandle); }
/** * Invoke the JavaScript function on the current runtime. * * @param receiver The object on which to call the function on. The * receiver will be mapped to 'this' in JavaScript. If receiver is null * or undefined, then the V8 runtime will be used instead. * @param parameters The parameters passed to the JS Function. * * @return The result of JavaScript function. */ public Object call(V8Object receiver, final V8Array parameters) { v8.checkThread(); checkReleased(); receiver = receiver != null ? receiver : v8; long parametersHandle = parameters == null ? 0 : parameters.getHandle(); long receiverHandle = receiver.isUndefined() ? v8.getHandle() : receiver.getHandle(); return v8.executeFunction(v8.getV8RuntimePtr(), receiverHandle, objectHandle, parametersHandle); }