/** * 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); }
/** * Invokes a JavaScript function which does not return a result. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. */ public void executeVoidFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); v8.executeVoidFunction(v8.getV8RuntimePtr(), objectHandle, name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a Java Object. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A Java Object representing the result of the function call. */ public Object executeFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeFunction(v8.getV8RuntimePtr(), UNKNOWN, objectHandle, name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a integer. If the * result is not an integer, or does not exist, then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return An integer representing the result of the function call or V8ResultUndefined * if the result is not an integer. */ public int executeIntegerFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeIntegerFunction(v8.getV8RuntimePtr(), getHandle(), name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a double. If the * result is not a double, or does not exist, then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A double representing the result of the function call or V8ResultUndefined * if the result is not a double. */ public double executeDoubleFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeDoubleFunction(v8.getV8RuntimePtr(), getHandle(), name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a String. If the * result is not a String, or does not exist, then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A String representing the result of the function call or V8ResultUndefined * if the result is not a String. */ public String executeStringFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeStringFunction(v8.getV8RuntimePtr(), getHandle(), name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a boolean. If the * result is not a boolean, or does not exist, then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A boolean representing the result of the function call or V8ResultUndefined * if the result is not a boolean. */ public boolean executeBooleanFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeBooleanFunction(v8.getV8RuntimePtr(), getHandle(), name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a V8Array. If the * result is not a V8Array then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A V8Array representing the result of the function call or V8ResultUndefined * if the result is not a V8Array. The result must be released. */ public V8Array executeArrayFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); Object result = v8.executeFunction(v8.getV8RuntimePtr(), V8_ARRAY, objectHandle, name, parametersHandle); if (result instanceof V8Array) { return (V8Array) result; } throw new V8ResultUndefined(); }
/** * Invoke a JavaScript function and return the result as a V8Object. If the * result is not a V8Object then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A V8Object representing the result of the function call or V8ResultUndefined * if the result is not a V8Object. The result must be released. */ public V8Object executeObjectFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); Object result = v8.executeFunction(v8.getV8RuntimePtr(), V8_OBJECT, objectHandle, name, parametersHandle); if (result instanceof V8Object) { return (V8Object) result; } throw new V8ResultUndefined(); }
/** * Adds a key value pair to the receiver where the value is a V8Value. * * @param key The key to associate the value with. * @param value The value to add. * * @return The receiver. */ public V8Object add(final String key, final V8Value value) { v8.checkThread(); checkReleased(); v8.checkRuntime(value); if (value == null) { v8.addNull(v8.getV8RuntimePtr(), objectHandle, key); } else if (value.equals(V8.getUndefined())) { v8.addUndefined(v8.getV8RuntimePtr(), objectHandle, key); } else { v8.addObject(v8.getV8RuntimePtr(), objectHandle, key, value.getHandle()); } return this; }
/** * Pushes a V8Value to the next available spot in the Array. In * particular, this[length] = value; * * @param value The value to push to the array. * * @return The receiver. */ public V8Array push(final V8Value value) { v8.checkThread(); checkReleased(); v8.checkRuntime(value); if (value == null) { v8.addArrayNullItem(v8.getV8RuntimePtr(), getHandle()); } else if (value.equals(V8.getUndefined())) { v8.addArrayUndefinedItem(v8.getV8RuntimePtr(), getHandle()); } else { v8.addArrayObjectItem(v8.getV8RuntimePtr(), getHandle(), value.getHandle()); } return this; }
checkReleased(); if (value instanceof V8Value) { v8.checkRuntime((V8Value) value);
/** * Invokes a JavaScript function which does not return a result. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. */ public void executeVoidFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); v8.executeVoidFunction(v8.getV8RuntimePtr(), objectHandle, name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a Java Object. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A Java Object representing the result of the function call. */ public Object executeFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeFunction(v8.getV8RuntimePtr(), UNKNOWN, objectHandle, name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a double. If the * result is not a double, or does not exist, then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A double representing the result of the function call or V8ResultUndefined * if the result is not a double. */ public double executeDoubleFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeDoubleFunction(v8.getV8RuntimePtr(), getHandle(), name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a integer. If the * result is not an integer, or does not exist, then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return An integer representing the result of the function call or V8ResultUndefined * if the result is not an integer. */ public int executeIntegerFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeIntegerFunction(v8.getV8RuntimePtr(), getHandle(), name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a String. If the * result is not a String, or does not exist, then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A String representing the result of the function call or V8ResultUndefined * if the result is not a String. */ public String executeStringFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeStringFunction(v8.getV8RuntimePtr(), getHandle(), name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a boolean. If the * result is not a boolean, or does not exist, then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A boolean representing the result of the function call or V8ResultUndefined * if the result is not a boolean. */ public boolean executeBooleanFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeBooleanFunction(v8.getV8RuntimePtr(), getHandle(), name, parametersHandle); }
/** * Adds a key value pair to the receiver where the value is a V8Value. * * @param key The key to associate the value with. * @param value The value to add. * * @return The receiver. */ public V8Object add(final String key, final V8Value value) { v8.checkThread(); checkReleased(); v8.checkRuntime(value); if (value == null) { v8.addNull(v8.getV8RuntimePtr(), objectHandle, key); } else if (value.equals(V8.getUndefined())) { v8.addUndefined(v8.getV8RuntimePtr(), objectHandle, key); } else { v8.addObject(v8.getV8RuntimePtr(), objectHandle, key, value.getHandle()); } return this; }
/** * Pushes a V8Value to the next available spot in the Array. In * particular, this[length] = value; * * @param value The value to push to the array. * * @return The receiver. */ public V8Array push(final V8Value value) { v8.checkThread(); checkReleased(); v8.checkRuntime(value); if (value == null) { v8.addArrayNullItem(v8.getV8RuntimePtr(), getHandle()); } else if (value.equals(V8.getUndefined())) { v8.addArrayUndefinedItem(v8.getV8RuntimePtr(), getHandle()); } else { v8.addArrayObjectItem(v8.getV8RuntimePtr(), getHandle(), value.getHandle()); } return this; }