本文整理了Java中com.eclipsesource.v8.V8.getObject()
方法的一些代码示例,展示了V8.getObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。V8.getObject()
方法的具体详情如下:
包路径:com.eclipsesource.v8.V8
类名称:V8
方法名:getObject
[英]Returns the number of Object References for this runtime.
[中]返回此运行时的对象引用数。
代码示例来源:origin: eclipsesource/J2V8
private void setupDebugObject(final V8 runtime) {
V8Object outerDebug = runtime.getObject(DEBUG_OBJECT_NAME);
try {
debugObject = outerDebug.getObject(V8_DEBUG_OBJECT);
} finally {
outerDebug.close();
}
}
代码示例来源:origin: eclipsesource/J2V8
this.waitForConnection = waitForConnection;
V8Object debugScope = runtime.getObject(DEBUG_OBJECT_NAME);
if (debugScope == null) {
System.err.println("Cannot initialize debugger server - global debug object not found.");
代码示例来源:origin: eclipsesource/J2V8
/**
* Returns the version of Node.js that is runtime is built against.
* This uses process.versions.node to get the version.
*
* @return The version of Node.js.
*/
public String getNodeVersion() {
if (nodeVersion != null) {
return nodeVersion;
}
V8Object process = null;
V8Object versions = null;
try {
process = v8.getObject(PROCESS);
versions = process.getObject(VERSIONS);
nodeVersion = versions.getString(NODE);
} finally {
safeRelease(process);
safeRelease(versions);
}
return nodeVersion;
}
代码示例来源:origin: eclipsesource/J2V8
/**
* Execute a NodeJS script. This will load the script and execute it on the
* next tick. This is the same as how NodeJS executes scripts at startup. Since
* the script won't actually run until the next tick, this method does not return
* a result.
*
* @param file The script to execute.
*/
public void exec(final File file) {
V8Function scriptExecution = createScriptExecutionCallback(file);
V8Object process = null;
V8Array parameters = null;
try {
process = v8.getObject(PROCESS);
parameters = new V8Array(v8);
parameters.push(scriptExecution);
process.executeObjectFunction(NEXT_TICK, parameters);
} finally {
safeRelease(process);
safeRelease(parameters);
safeRelease(scriptExecution);
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testAddBooleanUndefined() {
V8Object undefined = v8.getObject("object");
undefined.add("foo", false);
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testAddUndefinedUndefined() {
V8Object undefined = v8.getObject("object");
undefined.addUndefined("foo");
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testExecuteIntFunctionUndefined() {
V8Object undefined = v8.getObject("object");
undefined.executeIntegerFunction("foo", null);
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testExecuteBooleanFunctionUndefined() {
V8Object undefined = v8.getObject("object");
undefined.executeBooleanFunction("foo", null);
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testExecuteObjectFunctionUndefined() {
V8Object undefined = v8.getObject("object");
undefined.executeObjectFunction("foo", null);
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testExecuteVoidFunctionUndefined() {
V8Object undefined = v8.getObject("object");
undefined.executeVoidFunction("foo", null);
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testGetObjectUndefined() {
V8Object undefined = v8.getObject("object");
undefined.getObject("foo");
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testUndefinedToString() {
V8Object undefined = v8.getObject("object");
assertEquals("undefined", undefined.toString());
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testAddObjectUndefined() {
V8Object undefined = v8.getObject("object");
V8Object object = new V8Object(v8);
try {
undefined.add("foo", object);
} finally {
object.close();
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testSetPrototype() {
V8Object undefined = v8.getObject("object");
V8Object prototype = new V8Object(v8);
try {
undefined.setPrototype(prototype);
} finally {
prototype.close();
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testGetFunction() {
v8.executeVoidScript("function add(x, y) {return x+y;}");
V8Object result = v8.getObject("add");
assertTrue(result instanceof V8Function);
result.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test(expected = UnsupportedOperationException.class)
public void testAddArrayUndefined() {
V8Object undefined = v8.getObject("object");
V8Array array = new V8Array(v8);
try {
undefined.add("foo", array);
} finally {
array.close();
}
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testCallFunctionNullParameters() {
v8.executeVoidScript("function call() {return true;}");
V8Function function = (V8Function) v8.getObject("call");
boolean result = (Boolean) function.call(v8, null);
assertTrue(result);
function.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testTwinIsFunction() {
v8.executeVoidScript("function add(x, y) {return x+y;}");
V8Function v8Object = (V8Function) v8.getObject("add");
V8Function twin = v8Object.twin();
assertTrue(twin instanceof V8Function);
v8Object.close();
twin.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testNestedInteger() {
v8.executeVoidScript("foo = {bar: {key:6}}");
V8Object foo = v8.getObject("foo");
V8Object bar = foo.getObject("bar");
assertEquals(6, bar.getInteger("key"));
foo.close();
bar.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testDoesNotContainKey() {
V8Map<String> map = new V8Map<String>();
v8.executeVoidScript("var x = {}");
V8Object v8Object = v8.getObject("x");
assertFalse(map.containsKey(v8Object));
v8Object.close();
map.close();
}
内容来源于网络,如有侵权,请联系作者删除!