diff --git a/jni/com_eclipsesource_v8_V8Impl.cpp b/jni/com_eclipsesource_v8_V8Impl.cpp index 363c88ab6..eec765e11 100644 --- a/jni/com_eclipsesource_v8_V8Impl.cpp +++ b/jni/com_eclipsesource_v8_V8Impl.cpp @@ -314,6 +314,8 @@ extern "C" { void _register_fs(void); void _register_http_parser(void); void _register_os(void); + void _register_config(void); + void _register_url(void); void _register_util(void); void _register_v8(void); void _register_zlib(void); @@ -356,6 +358,8 @@ JNIEXPORT void JNICALL Java_com_eclipsesource_v8_V8__1startNodeJS _register_fs(); _register_http_parser(); _register_os(); + _register_config(); + _register_url(); _register_util(); _register_v8(); _register_zlib(); @@ -1918,4 +1922,4 @@ jobject getResult(JNIEnv *env, jobject &v8, jlong v8RuntimePtr, Handle &r JNIEXPORT jlong JNICALL Java_com_eclipsesource_v8_V8__1getBuildID (JNIEnv *, jobject) { return 2; -} +} \ No newline at end of file diff --git a/src/main/java/com/eclipsesource/v8/LibraryLoader.java b/src/main/java/com/eclipsesource/v8/LibraryLoader.java index 84b9ba4aa..11d3d53ae 100644 --- a/src/main/java/com/eclipsesource/v8/LibraryLoader.java +++ b/src/main/java/com/eclipsesource/v8/LibraryLoader.java @@ -40,16 +40,20 @@ private static String computeLibraryFullName() { static void loadLibrary(final String tempDirectory) { if ( isAndroid() ) { - System.loadLibrary("j2v8"); - return; + System.loadLibrary("j2v8"); + return; } StringBuffer message = new StringBuffer(); String libShortName = computeLibraryShortName(); String libFullName = computeLibraryFullName(); String ideLocation = System.getProperty("user.dir") + SEPARATOR + "jni" + SEPARATOR + computeLibraryFullName(); + String path = null; /* Try loading library from java library path */ + if (load(libFullName, message)) { + return; + } if (load(libShortName, message)) { return; } @@ -213,4 +217,4 @@ static String getOS() { throw new UnsatisfiedLinkError("Unsupported platform: " + getOsName()); } -} +} \ No newline at end of file diff --git a/src/main/java/com/eclipsesource/v8/V8Array.java b/src/main/java/com/eclipsesource/v8/V8Array.java index 7e87f66ab..cf0bc7ca2 100644 --- a/src/main/java/com/eclipsesource/v8/V8Array.java +++ b/src/main/java/com/eclipsesource/v8/V8Array.java @@ -532,6 +532,46 @@ public V8Array push(final V8Value value) { return this; } + /** + * Pushes a Object 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 Object value) { + v8.checkThread(); + checkReleased(); + if(value instanceof V8Value){ + v8.checkRuntime((V8Value) value); + } + if (value == null) { + v8.addArrayNullItem(v8.getV8RuntimePtr(), getHandle()); + } else if (value.equals(V8.getUndefined())) { + v8.addArrayUndefinedItem(v8.getV8RuntimePtr(), getHandle()); + } else { + if(value instanceof Double){ + v8.addArrayDoubleItem(v8.getV8RuntimePtr(), getHandle(), (Double) value); + } else if(value instanceof Integer){ + v8.addArrayIntItem(v8.getV8RuntimePtr(), getHandle(), (Integer) value); + } else if(value instanceof Float) { + v8.addArrayDoubleItem(v8.getV8RuntimePtr(), getHandle(), ((Float) value).doubleValue()); + } else if(value instanceof Number) { + v8.addArrayDoubleItem(v8.getV8RuntimePtr(), getHandle(), ((Number) value).doubleValue()); + } else if(value instanceof Boolean){ + v8.addArrayBooleanItem(v8.getV8RuntimePtr(), getHandle(), (Boolean) value); + } else if(value instanceof String){ + v8.addArrayStringItem(v8.getV8RuntimePtr(), getHandle(), (String) value); + } else if(value instanceof V8Value){ + v8.addArrayObjectItem(v8.getV8RuntimePtr(), getHandle(), ((V8Value) value).getHandle()); + } else { + throw new UnsupportedOperationException(); + } + } + return this; + } + /** * Pushes null to the next available spot in the Array. In * particular, this[length] = null; diff --git a/src/test/java/com/eclipsesource/v8/NodeJSTest.java b/src/test/java/com/eclipsesource/v8/NodeJSTest.java index 3d2aa95c7..9f2230960 100644 --- a/src/test/java/com/eclipsesource/v8/NodeJSTest.java +++ b/src/test/java/com/eclipsesource/v8/NodeJSTest.java @@ -66,7 +66,7 @@ public void run() { public void testGetVersion() { String result = nodeJS.getNodeVersion(); - assertEquals("7.4.0", result); + assertEquals("7.10.0", result); } @Test @@ -177,4 +177,4 @@ private static File createTemporaryScriptFile(final String script, final String } -} +} \ No newline at end of file