From 22a0942400d5b1e93e28d36781289e5431063061 Mon Sep 17 00:00:00 2001 From: Tony Rice Date: Sun, 7 May 2017 12:32:25 -0500 Subject: [PATCH 1/5] NodeJSTest: bumping version to 7.10.0 --- src/test/java/com/eclipsesource/v8/NodeJSTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 31552fd3df5af9bf36e294c269239abe129bd318 Mon Sep 17 00:00:00 2001 From: Tony Rice Date: Sun, 7 May 2017 12:33:04 -0500 Subject: [PATCH 2/5] com_eclipsesource_v8_V8Impl.cpp: adding missing registers for windows build --- jni/com_eclipsesource_v8_V8Impl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 From 7b598239056637c5076fae4abe1472fc1925630e Mon Sep 17 00:00:00 2001 From: Tony Rice Date: Sun, 7 May 2017 12:34:09 -0500 Subject: [PATCH 3/5] LibraryLoader: improving loadLibrary by attempting to load the library via it's full name --- src/main/java/com/eclipsesource/v8/LibraryLoader.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 From 4781101d34e2317210931bd570b1a3ed3d877603 Mon Sep 17 00:00:00 2001 From: Tony Rice Date: Sat, 13 May 2017 21:17:46 -0500 Subject: [PATCH 4/5] V8Array: implementing generic push(Object object) --- .../java/com/eclipsesource/v8/V8Array.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main/java/com/eclipsesource/v8/V8Array.java b/src/main/java/com/eclipsesource/v8/V8Array.java index 7e87f66ab..e6ebd430a 100644 --- a/src/main/java/com/eclipsesource/v8/V8Array.java +++ b/src/main/java/com/eclipsesource/v8/V8Array.java @@ -532,6 +532,42 @@ 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 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; From 071df17110cb0c617300bdb4fdf9ce1dc9cf377d Mon Sep 17 00:00:00 2001 From: Tony Rice Date: Sat, 13 May 2017 22:17:30 -0500 Subject: [PATCH 5/5] V8Array: making improvement to push(object) ensuring tests pass --- src/main/java/com/eclipsesource/v8/V8Array.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/eclipsesource/v8/V8Array.java b/src/main/java/com/eclipsesource/v8/V8Array.java index e6ebd430a..cf0bc7ca2 100644 --- a/src/main/java/com/eclipsesource/v8/V8Array.java +++ b/src/main/java/com/eclipsesource/v8/V8Array.java @@ -555,6 +555,10 @@ public V8Array push(final Object value) { 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){