/** * Returns a count of all the breakpoints * * @return A V8Array of Breakpoints. */ public int getScriptBreakPointCount() { V8Array breakPoints = debugObject.executeArrayFunction(SCRIPT_BREAK_POINTS, null); try { return breakPoints.length(); } finally { breakPoints.close(); } }
/** * Get all the BreakPoint IDs as an array. * * @return A list of BreakPoint IDs. */ public int[] getScriptBreakPointIDs() { V8Array breakPoints = debugObject.executeArrayFunction(SCRIPT_BREAK_POINTS, null); try { int[] result = new int[breakPoints.length()]; for (int i = 0; i < breakPoints.length(); i++) { V8Object breakPoint = breakPoints.getObject(i); try { result[i] = breakPoint.executeIntegerFunction(NUMBER, null); } finally { breakPoint.close(); } } return result; } finally { breakPoints.close(); } }
/** * Return the properties for this object as an array of PropertyMirror objects. * * @param kind Indicate whether named, indexed or both kinds of properties are requested * @param limit Limit the number of properties returned to the specified value * @return {Array} Property mirrors for this object */ public PropertiesArray getProperties(final PropertyKind kind, final int limit) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(kind.index); parameters.push(limit); V8Array result = null; try { result = v8Object.executeArrayFunction(PROPERTIES, parameters); return new PropertiesArray(result); } finally { parameters.close(); if ((result != null) && !result.isReleased()) { result.close(); result = null; } } }
/** * Returns all the property names for the given object. * * @param kind Indicate whether named, indexed or both kinds of properties are requested. * @param limit Limit the number of properties returned to the specified value * @return All the property names for a given object */ public String[] getPropertyNames(final PropertyKind kind, final int limit) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(kind.index); parameters.push(limit); V8Array propertyNames = null; try { propertyNames = v8Object.executeArrayFunction(PROPERTY_NAMES, parameters); String[] result = new String[propertyNames.length()]; for (int i = 0; i < result.length; i++) { result[i] = propertyNames.getString(i); } return result; } finally { parameters.close(); if (propertyNames != null) { propertyNames.close(); } } }
/** * Returns a count of all the breakpoints * * @return A V8Array of Breakpoints. */ public int getScriptBreakPointCount() { V8Array breakPoints = debugObject.executeArrayFunction(SCRIPT_BREAK_POINTS, null); try { return breakPoints.length(); } finally { breakPoints.close(); } }
@Test(expected = UnsupportedOperationException.class) public void testExecuteArrayFunctionUndefined() { V8Object undefined = v8.getObject("object"); undefined.executeArrayFunction("foo", null); }
/** * Get all the BreakPoint IDs as an array. * * @return A list of BreakPoint IDs. */ public int[] getScriptBreakPointIDs() { V8Array breakPoints = debugObject.executeArrayFunction(SCRIPT_BREAK_POINTS, null); try { int[] result = new int[breakPoints.length()]; for (int i = 0; i < breakPoints.length(); i++) { V8Object breakPoint = breakPoints.getObject(i); try { result[i] = breakPoint.executeIntegerFunction(NUMBER, null); } finally { breakPoint.close(); } } return result; } finally { breakPoints.close(); } }
/** * Returns all the property names for the given object. * * @param kind Indicate whether named, indexed or both kinds of properties are requested. * @param limit Limit the number of properties returned to the specified value * @return All the property names for a given object */ public String[] getPropertyNames(final PropertyKind kind, final int limit) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(kind.index); parameters.push(limit); V8Array propertyNames = null; try { propertyNames = v8Object.executeArrayFunction(PROPERTY_NAMES, parameters); String[] result = new String[propertyNames.length()]; for (int i = 0; i < result.length; i++) { result[i] = propertyNames.getString(i); } return result; } finally { parameters.close(); if (propertyNames != null) { propertyNames.close(); } } }
/** * Return the properties for this object as an array of PropertyMirror objects. * * @param kind Indicate whether named, indexed or both kinds of properties are requested * @param limit Limit the number of properties returned to the specified value * @return {Array} Property mirrors for this object */ public PropertiesArray getProperties(final PropertyKind kind, final int limit) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(kind.index); parameters.push(limit); V8Array result = null; try { result = v8Object.executeArrayFunction(PROPERTIES, parameters); return new PropertiesArray(result); } finally { parameters.close(); if ((result != null) && !result.isReleased()) { result.close(); result = null; } } }
@Test public void testV8ArrayFunctionCallOnJSObject() { ICallback callback = mock(ICallback.class); doReturn(v8.executeArrayScript("x = ['a','b','c']; x")).when(callback).v8ArrayMethodNoParameters(); V8Object v8Object = new V8Object(v8); v8Object.registerJavaMethod(callback, "v8ArrayMethodNoParameters", "foo", new Class<?>[0]); V8Array result = v8Object.executeArrayFunction("foo", null); verify(callback).v8ArrayMethodNoParameters(); assertEquals(3, result.length()); assertEquals("a", result.getString(0)); assertEquals("b", result.getString(1)); assertEquals("c", result.getString(2)); v8Object.close(); result.close(); }
/** * Returns a count of all the breakpoints * * @return A V8Array of Breakpoints. */ public int getScriptBreakPointCount() { V8Array breakPoints = debugObject.executeArrayFunction(SCRIPT_BREAK_POINTS, null); try { return breakPoints.length(); } finally { breakPoints.release(); } }
/** * Returns a count of all the breakpoints * * @return A V8Array of Breakpoints. */ public int getScriptBreakPointCount() { V8Array breakPoints = debugObject.executeArrayFunction(SCRIPT_BREAK_POINTS, null); try { return breakPoints.length(); } finally { breakPoints.release(); } }
@Test public void testArrayFunctionCallOnObject() { v8.executeVoidScript("function add(x, y) {return [x,y];}"); v8.executeVoidScript("adder = {};"); v8.executeVoidScript("adder.addFuction = add;"); V8Object object = v8.getObject("adder"); V8Array parameters = new V8Array(v8); parameters.push(true); parameters.push(false); V8Array result = object.executeArrayFunction("addFuction", parameters); parameters.close(); assertFalse(result.getBoolean(1)); assertTrue(result.getBoolean(0)); result.close(); object.close(); }
/** * Get all the BreakPoint IDs as an array. * * @return A list of BreakPoint IDs. */ public int[] getScriptBreakPointIDs() { V8Array breakPoints = debugObject.executeArrayFunction(SCRIPT_BREAK_POINTS, null); try { int[] result = new int[breakPoints.length()]; for (int i = 0; i < breakPoints.length(); i++) { V8Object breakPoint = breakPoints.getObject(i); try { result[i] = breakPoint.executeIntegerFunction(NUMBER, null); } finally { breakPoint.release(); } } return result; } finally { breakPoints.release(); } }
/** * Get all the BreakPoint IDs as an array. * * @return A list of BreakPoint IDs. */ public int[] getScriptBreakPointIDs() { V8Array breakPoints = debugObject.executeArrayFunction(SCRIPT_BREAK_POINTS, null); try { int[] result = new int[breakPoints.length()]; for (int i = 0; i < breakPoints.length(); i++) { V8Object breakPoint = breakPoints.getObject(i); try { result[i] = breakPoint.executeIntegerFunction(NUMBER, null); } finally { breakPoint.release(); } } return result; } finally { breakPoints.release(); } }
/** * Return the properties for this object as an array of PropertyMirror objects. * * @param kind Indicate whether named, indexed or both kinds of properties are requested * @param limit Limit the number of properties returned to the specified value * @return {Array} Property mirrors for this object */ public PropertiesArray getProperties(final PropertyKind kind, final int limit) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(kind.index); parameters.push(limit); V8Array result = null; try { result = v8Object.executeArrayFunction(PROPERTIES, parameters); return new PropertiesArray(result); } finally { parameters.release(); if ((result != null) && !result.isReleased()) { result.release(); result = null; } } }
/** * Return the properties for this object as an array of PropertyMirror objects. * * @param kind Indicate whether named, indexed or both kinds of properties are requested * @param limit Limit the number of properties returned to the specified value * @return {Array} Property mirrors for this object */ public PropertiesArray getProperties(final PropertyKind kind, final int limit) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(kind.index); parameters.push(limit); V8Array result = null; try { result = v8Object.executeArrayFunction(PROPERTIES, parameters); return new PropertiesArray(result); } finally { parameters.release(); if ((result != null) && !result.isReleased()) { result.release(); result = null; } } }
/** * Returns all the property names for the given object. * * @param kind Indicate whether named, indexed or both kinds of properties are requested. * @param limit Limit the number of properties returned to the specified value * @return All the property names for a given object */ public String[] getPropertyNames(final PropertyKind kind, final int limit) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(kind.index); parameters.push(limit); V8Array propertyNames = null; try { propertyNames = v8Object.executeArrayFunction(PROPERTY_NAMES, parameters); String[] result = new String[propertyNames.length()]; for (int i = 0; i < result.length; i++) { result[i] = propertyNames.getString(i); } return result; } finally { parameters.release(); if (propertyNames != null) { propertyNames.release(); } } }
/** * Returns all the property names for the given object. * * @param kind Indicate whether named, indexed or both kinds of properties are requested. * @param limit Limit the number of properties returned to the specified value * @return All the property names for a given object */ public String[] getPropertyNames(final PropertyKind kind, final int limit) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(kind.index); parameters.push(limit); V8Array propertyNames = null; try { propertyNames = v8Object.executeArrayFunction(PROPERTY_NAMES, parameters); String[] result = new String[propertyNames.length()]; for (int i = 0; i < result.length; i++) { result[i] = propertyNames.getString(i); } return result; } finally { parameters.release(); if (propertyNames != null) { propertyNames.release(); } } }