本文整理了Java中com.eclipsesource.v8.V8.get()
方法的一些代码示例,展示了V8.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。V8.get()
方法的具体详情如下:
包路径:com.eclipsesource.v8.V8
类名称:V8
方法名:get
[英]Returns the number of active runtimes.
[中]返回活动运行时的数量。
代码示例来源:origin: eclipsesource/J2V8
/**
* Returns the value associated with this key. Values are Java Objects.
* If the value is a primitive, its boxed type is returned. If the
* value is a V8Value, it must be released.
*
* @param key The key whose value to return.
*
* @return The value associated with this key.
*/
public Object get(final String key) {
v8.checkThread();
checkReleased();
checkKey(key);
return v8.get(v8.getV8RuntimePtr(), V8_OBJECT, objectHandle, key);
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testSetBreakpointByFunction() {
DebugHandler handler = new DebugHandler(v8);
v8.executeScript(script, "script", 0);
V8Function function = (V8Function) v8.get("foo");
handler.setBreakpoint(function);
BreakHandler breakHandler = mock(BreakHandler.class);
handler.addBreakHandler(breakHandler);
function.call(null, null);
verify(breakHandler, times(1)).onBreak(eq(DebugEvent.Break), any(ExecutionState.class), any(EventData.class), any(V8Object.class));
handler.close();
function.close();
}
代码示例来源:origin: eclipsesource/J2V8
/**
* Returns the V8Array value associated with this key. If the value
* associated with this key does not exist then UNDEFINED is returned.
* If the value exists but is not an array then
* V8ResultUndefined exception is thrown.
*
* @param key The key whose value to return.
*
* @return The V8Array value associated with this key.
*/
public V8Array getArray(final String key) {
v8.checkThread();
checkReleased();
checkKey(key);
Object result = v8.get(v8.getV8RuntimePtr(), V8_ARRAY, objectHandle, key);
if ((result == null) || (result instanceof V8Array)) {
return (V8Array) result;
}
throw new V8ResultUndefined();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void getArrayBuffer() {
v8.executeVoidScript("var buffer = new ArrayBuffer(8);");
V8ArrayBuffer buffer = (V8ArrayBuffer) v8.get("buffer");
assertNotNull(buffer);
buffer.close();
}
代码示例来源:origin: eclipsesource/J2V8
/**
* Returns the V8Object value associated with this key. If the value
* associated with this key does not exist then UNDEFINED is returned.
* If the value exists but is not an JS Object then
* V8ResultUndefined exception is thrown.
*
* @param key The key whose value to return.
*
* @return The V8Object value associated with this key.
*/
public V8Object getObject(final String key) {
v8.checkThread();
checkReleased();
checkKey(key);
Object result = v8.get(v8.getV8RuntimePtr(), V8_OBJECT, objectHandle, key);
if ((result == null) || (result instanceof V8Object)) {
return (V8Object) result;
}
throw new V8ResultUndefined();
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = Error.class)
public void testSharingObjectsShouldNotCrashVM() {
V8 engine = null;
V8 engine2 = null;
try {
engine = V8.createV8Runtime();
engine2 = V8.createV8Runtime();
engine.executeScript("b = { 'c': 'c' }");
engine2.executeScript("a = { 'd': 'd' };");
V8Object a = (V8Object) engine2.get("a");
V8Object b = (V8Object) engine.get("b");
b.add("data", a);
} finally {
engine.release(false);
engine2.release(false);
}
}
代码示例来源:origin: eclipsesource/J2V8
/**
* Returns the value associated with this key. Values are Java Objects.
* If the value is a primitive, its boxed type is returned. If the
* value is a V8Value, it must be released.
*
* @param key The key whose value to return.
*
* @return The value associated with this key.
*/
public Object get(final String key) {
v8.checkThread();
checkReleased();
checkKey(key);
return v8.get(v8.getV8RuntimePtr(), V8_OBJECT, objectHandle, key);
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetTypedArray_IntegerTypeAfterNull() {
v8.executeVoidScript("var buf = new ArrayBuffer(100);\n"
+ "var intsArray = new Int32Array(buf);\n"
+ "intsArray[0] = null;\n");
V8Array intsArray = (V8Array) v8.get("intsArray");
assertEquals(V8Value.INTEGER, intsArray.getType());
intsArray.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetTypedArray_IntegerType() {
v8.executeVoidScript("var buf = new ArrayBuffer(100);\n"
+ "var intsArray = new Int32Array(buf);\n");
V8Array intsArray = (V8Array) v8.get("intsArray");
assertEquals(V8Value.INTEGER, intsArray.getType());
intsArray.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetTypedArray_IntegerTypeAfterUndefined() {
v8.executeVoidScript("var buf = new ArrayBuffer(100);\n"
+ "var intsArray = new Int32Array(buf);\n"
+ "intsArray[0] = undefined;\n");
V8Array intsArray = (V8Array) v8.get("intsArray");
assertEquals(V8Value.INTEGER, intsArray.getType());
intsArray.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetTypedArray_IntegerTypeAfterFloat() {
v8.executeVoidScript("var buf = new ArrayBuffer(100);\n"
+ "var intsArray = new Int32Array(buf);\n"
+ "intsArray[0] = 7.4;\n");
V8Array intsArray = (V8Array) v8.get("intsArray");
assertEquals(V8Value.INTEGER, intsArray.getType());
intsArray.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetTypedArray_DoubleType() {
v8.executeVoidScript("var buf = new ArrayBuffer(80);\n"
+ "var doublesArray = new Float64Array(buf);");
V8Array doublesArray = (V8Array) v8.get("doublesArray");
assertEquals(V8Value.DOUBLE, doublesArray.getType());
doublesArray.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testSetBreakpointByFunctionReturnsID() {
DebugHandler handler = new DebugHandler(v8);
v8.executeScript(script, "script", 0);
V8Function function = (V8Function) v8.get("foo");
int breakpointID = handler.setBreakpoint(function);
assertEquals(1, breakpointID);
handler.close();
function.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = Error.class)
public void testSharingObjectsAsFunctionCallParameters_ArrayFunction() {
V8 engine = null;
V8 engine2 = null;
try {
engine = V8.createV8Runtime();
engine2 = V8.createV8Runtime();
engine.executeScript("b = function(param){return param;}");
engine2.executeScript("a = [[1,2,3]];");
V8Array a = (V8Array) engine2.get("a");
engine.executeArrayFunction("b", a);
} finally {
engine.release(false);
engine2.release(false);
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = Error.class)
public void testSharingObjectsAsFunctionCallParameters_VoidFunction() {
V8 engine = null;
V8 engine2 = null;
try {
engine = V8.createV8Runtime();
engine2 = V8.createV8Runtime();
engine.executeScript("b = function(param1, param2){ param1 + param2;}");
engine2.executeScript("a = [3, 4];");
V8Array a = (V8Array) engine2.get("a");
engine.executeVoidFunction("b", a);
} finally {
engine.release(false);
engine2.release(false);
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = Error.class)
public void testSharingObjectsAsFunctionCallParameters_ObjectFunction() {
V8 engine = null;
V8 engine2 = null;
try {
engine = V8.createV8Runtime();
engine2 = V8.createV8Runtime();
engine.executeScript("b = function(param){return param;}");
engine2.executeScript("a = [{name: 'joe'}];");
V8Array a = (V8Array) engine2.get("a");
engine.executeObjectFunction("b", a);
} finally {
engine.release(false);
engine2.release(false);
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = Error.class)
public void testSharingObjectsAsFunctionCallParameters_BooleanFunction() {
V8 engine = null;
V8 engine2 = null;
try {
engine = V8.createV8Runtime();
engine2 = V8.createV8Runtime();
engine.executeScript("b = function(param){return param;}");
engine2.executeScript("a = [false];");
V8Array a = (V8Array) engine2.get("a");
engine.executeBooleanFunction("b", a);
} finally {
engine.release(false);
engine2.release(false);
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = Error.class)
public void testSharingObjectsAsFunctionCallParameters_StringFunction() {
V8 engine = null;
V8 engine2 = null;
try {
engine = V8.createV8Runtime();
engine2 = V8.createV8Runtime();
engine.executeScript("b = function(param){return param;}");
engine2.executeScript("a = ['foo'];");
V8Array a = (V8Array) engine2.get("a");
engine.executeStringFunction("b", a);
} finally {
engine.release(false);
engine2.release(false);
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = Error.class)
public void testSharingObjectsAsFunctionCallParameters_JSFunction() {
V8 engine = null;
V8 engine2 = null;
try {
engine = V8.createV8Runtime();
engine2 = V8.createV8Runtime();
engine.executeScript("b = function(param){ param[0] + param[1];}");
engine2.executeScript("a = [3, 4];");
V8Array a = (V8Array) engine2.get("a");
engine.executeJSFunction("b", a);
} finally {
engine.release(false);
engine2.release(false);
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = Error.class)
public void testSharingObjectsAsFunctionCallParameters_DoubleFunction() {
V8 engine = null;
V8 engine2 = null;
try {
engine = V8.createV8Runtime();
engine2 = V8.createV8Runtime();
engine.executeScript("b = function(param){return param;}");
engine2.executeScript("a = [3.14];");
V8Array a = (V8Array) engine2.get("a");
engine.executeDoubleFunction("b", a);
} finally {
engine.release(false);
engine2.release(false);
}
}
内容来源于网络,如有侵权,请联系作者删除!