-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from taoweiji/develop
add auto gc
- Loading branch information
Showing
20 changed files
with
160 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 18 additions & 42 deletions
60
example/src/main/java/com/quickjs/android/example/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,38 @@ | ||
package com.quickjs.android.example; | ||
|
||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.eclipsesource.v8.V8; | ||
import com.eclipsesource.v8.V8Array; | ||
import com.eclipsesource.v8.V8Object; | ||
import com.quickjs.android.JSArray; | ||
import com.quickjs.android.JSContext; | ||
import com.quickjs.android.JSObject; | ||
import com.quickjs.android.QuickJS; | ||
|
||
import java.util.Arrays; | ||
import com.quickjs.JSArray; | ||
import com.quickjs.JSContext; | ||
import com.quickjs.JSObject; | ||
import com.quickjs.QuickJS; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
private QuickJS quickJS; | ||
private JSContext jsContext; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
quickJS = QuickJS.createRuntime(); | ||
jsContext = quickJS.createContext(); | ||
jsContext = quickJS.createContext(); | ||
test(); | ||
} | ||
|
||
void test() { | ||
QuickJS quickJS = QuickJS.createRuntime(); | ||
JSContext context = quickJS.createContext(); | ||
context.executeVoidScript("function test(data){ return data}", "file.js"); | ||
JSArray array = new JSArray(context); | ||
array.push(Integer.MAX_VALUE); | ||
int result = context.executeIntegerFunction("test", array); | ||
array.close(); | ||
context.close(); | ||
quickJS.close(); | ||
jsContext.executeVoidScript("function test(data){ return data}", "file.js"); | ||
new JSArray(jsContext); | ||
new JSObject(jsContext); | ||
} | ||
|
||
void testV8() { | ||
V8 v8 = V8.createV8Runtime(); | ||
// v8.executeStringFunction() | ||
// v8.contains(); | ||
V8Object jsObject = new V8Object(v8); | ||
jsObject.registerJavaMethod(new com.eclipsesource.v8.JavaVoidCallback() { | ||
|
||
@Override | ||
public void invoke(V8Object v8Object, V8Array v8Array) { | ||
// v8Array.getInteger(v8Array.getString()) | ||
} | ||
}, ""); | ||
// jsObject.executeBooleanFunction(); | ||
// v8.executeVoidFunction(); | ||
// v8.add() | ||
// v8.add() | ||
// jsObject.add() | ||
// v8.getInteger() | ||
v8.close(); | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
// jsContext.close(); | ||
quickJS.close(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
...va/com/quickjs/android/JSContextTest.java → ...dTest/java/com/quickjs/JSContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
...a/com/quickjs/android/JSFunctionTest.java → ...Test/java/com/quickjs/JSFunctionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...java/com/quickjs/android/QuickJSTest.java → ...oidTest/java/com/quickjs/QuickJSTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.quickjs.android"> | ||
package="com.quickjs"> | ||
|
||
</manifest> |
Oops, something went wrong.