@Override protected V8Value createTwin() { return new V8Array(v8); }
public V8Array array() { return register(v8, new V8Array(v8)); }
@Override public Object invoke(final V8Object receiver, final V8Array parameters) { V8Array requireParams = new V8Array(v8); try { requireParams.push(file.getAbsolutePath()); return require.call(null, requireParams); } finally { requireParams.close(); } } });
private static V8Array toV8Array(final V8 v8, final List<? extends Object> list, final Map<Object, V8Value> cache) { if (cache.containsKey(new ListWrapper(list))) { return (V8Array) cache.get(new ListWrapper(list)); } V8Array result = new V8Array(v8); cache.put(new ListWrapper(list), result); try { for (int i = 0; i < list.size(); i++) { Object value = list.get(i); pushValue(v8, result, value, cache); } } catch (IllegalStateException e) { result.close(); throw e; } return result; }
/** * Enables a breakpoint. * * @param breakpointID The breakpoint to enable. */ public void enableScriptBreakPoint(final int breakpointID) { V8Array parameters = new V8Array(runtime); parameters.push(breakpointID); try { debugObject.executeVoidFunction(ENABLE_SCRIPT_BREAK_POINT, parameters); } finally { parameters.close(); } }
/** * Disables a breakpoint. * * @param breakpointID The breakpoint to disable */ public void disableScriptBreakPoint(final int breakpointID) { V8Array parameters = new V8Array(runtime); parameters.push(breakpointID); try { debugObject.executeVoidFunction(DISABLE_SCRIPT_BREAK_POINT, parameters); } finally { parameters.close(); } }
/** * Removes a Breakpoint. * * @param breakpointID The ID of the breakpoint to remove. */ public void clearBreakPoint(final int breakpointID) { V8Array parameters = new V8Array(runtime); parameters.push(breakpointID); try { debugObject.executeVoidFunction(CLEAR_BREAK_POINT, parameters); } finally { parameters.close(); } }
/** * Registers a function breakpoint. When the JavaScript function * is invoked, the breakpoint will be 'hit'. * * @param function The function on which to register the breakpoint. * @return The berakpointID. */ public int setBreakpoint(final V8Function function) { V8Array parameters = new V8Array(runtime); parameters.push(function); try { return debugObject.executeIntegerFunction(SET_BREAK_POINT, parameters); } finally { parameters.close(); } }
/** * Invokes NodeJS require() on the specified file. This will load the module, execute * it and return the exports object to the caller. The exports object must be released. * * @param file The module to load. * @return The exports object. */ public V8Object require(final File file) { v8.checkThread(); V8Array requireParams = new V8Array(v8); try { requireParams.push(file.getAbsolutePath()); return (V8Object) require.call(null, requireParams); } finally { requireParams.close(); } }
/** * Returns the name of the argument at the given index. * * @param index The index of the argument name to return. * @return The name of argument at the given index. */ public String getArgumentName(final int index) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(index); try { return v8Object.executeStringFunction(ARGUMENT_NAME, parameters); } finally { parameters.close(); } }
/** * Returns the name of the local variable at the given index. * * @param index The index of the local variable name to return. * @return The name of local variable at the given index. */ public String getLocalName(final int index) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(index); try { return v8Object.executeStringFunction(LOCAL_NAME, parameters); } finally { parameters.close(); } }
/** * Sets a condition to be evaluated before determining if * the breakpoint event should be fired. * * @param condition A JavaScript condition to be evaluated. */ public void setCondition(final String condition) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(condition); try { v8Object.executeVoidFunction(SET_CONDITION, parameters); } finally { parameters.close(); } }
/** * Indicates to the debugger how to proceed. If not called, * the debugger will continue running until the next breakpoint * is hit. * * @param action The step action to use. */ public void prepareStep(final StepAction action) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(action.index); try { v8Object.executeVoidFunction(PREPARE_STEP, parameters); } finally { parameters.close(); } }
/** * Changes the current condition on the breakpoint as specified by the breakpoint ID * * @param breakpointID The ID of the breakpoint of which to change the condition on * @param condition The new condition to set */ public void changeBreakPointCondition(final int breakpointID, final String condition) { V8Array parameters = new V8Array(runtime); parameters.push(breakpointID); parameters.push(condition); try { debugObject.executeVoidFunction(CHANGE_BREAK_POINT_CONDITION, parameters); } finally { parameters.close(); } }
/** * Sets the value of a variable in this scope. * * @param name The name of the variable * @param value The value */ public void setVariableValue(final String name, final boolean value) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(name); parameters.push(value); try { v8Object.executeVoidFunction(SET_VARIABLE_VALUE, parameters); } finally { parameters.close(); } }
/** * Sets the value of a variable in this scope. * * @param name The name of the variable * @param value The value */ public void setVariableValue(final String name, final double value) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(name); parameters.push(value); try { v8Object.executeVoidFunction(SET_VARIABLE_VALUE, parameters); } finally { parameters.close(); } }
/** * Sets the value of a variable in this scope. * * @param name The name of the variable * @param value The value */ public void setVariableValue(final String name, final V8Value value) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(name); parameters.push(value); try { v8Object.executeVoidFunction(SET_VARIABLE_VALUE, parameters); } finally { parameters.close(); } }
/** * Sets the value of a variable in this scope. * * @param name The name of the variable * @param value The value */ public void setVariableValue(final String name, final int value) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(name); parameters.push(value); try { v8Object.executeVoidFunction(SET_VARIABLE_VALUE, parameters); } finally { parameters.close(); } }
/** * Sets the value of a variable in this scope. * * @param name The name of the variable * @param value The value */ public void setVariableValue(final String name, final String value) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(name); parameters.push(value); try { v8Object.executeVoidFunction(SET_VARIABLE_VALUE, parameters); } finally { parameters.close(); } }
private void setupBreakpointHandler() { BreakpointHandler handler = new BreakpointHandler(); debugObject.registerJavaMethod(handler, DEBUG_BREAK_HANDLER); V8Function debugHandler = null; V8Array parameters = null; try { debugHandler = (V8Function) debugObject.getObject(DEBUG_BREAK_HANDLER); parameters = new V8Array(runtime); parameters.push(debugHandler); debugObject.executeFunction(SET_LISTENER, parameters); } finally { if ((debugHandler != null) && !debugHandler.isReleased()) { debugHandler.close(); } if ((parameters != null) && !parameters.isReleased()) { parameters.close(); } } }