Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Improvements and Issue #253 #259

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion jni/com_eclipsesource_v8_V8Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1918,4 +1922,4 @@ jobject getResult(JNIEnv *env, jobject &v8, jlong v8RuntimePtr, Handle<Value> &r
JNIEXPORT jlong JNICALL Java_com_eclipsesource_v8_V8__1getBuildID
(JNIEnv *, jobject) {
return 2;
}
}
10 changes: 7 additions & 3 deletions src/main/java/com/eclipsesource/v8/LibraryLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -213,4 +217,4 @@ static String getOS() {
throw new UnsatisfiedLinkError("Unsupported platform: " + getOsName());
}

}
}
40 changes: 40 additions & 0 deletions src/main/java/com/eclipsesource/v8/V8Array.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/eclipsesource/v8/NodeJSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -177,4 +177,4 @@ private static File createTemporaryScriptFile(final String script, final String
}


}
}