pull/149/head
FongMi 3 years ago
parent 135e6223b1
commit fe3f80ed55
  1. 2
      quickjs/src/main/java/com/fongmi/quickjs/method/Console.java
  2. 16
      quickjs/src/main/java/com/fongmi/quickjs/method/Function.java
  3. 9
      quickjs/src/main/java/com/fongmi/quickjs/utils/Module.java

@ -5,7 +5,7 @@ import com.whl.quickjs.wrapper.QuickJSContext;
public class Console implements QuickJSContext.Console {
private static final String TAG = Console.class.getSimpleName();
private static final String TAG = "quickjs";
@Override
public void log(String info) {

@ -8,32 +8,32 @@ import java.util.concurrent.Callable;
public class Function implements Callable<Object> {
private final JSObject jsObject;
private final JSObject object;
private final Object[] args;
private final String name;
private Object result;
public static Function call(JSObject jsObject, String name, Object[] args) {
return new Function(jsObject, name, args);
public static Function call(JSObject object, String name, Object[] args) {
return new Function(object, name, args);
}
private Function(JSObject jsObject, String name, Object[] args) {
this.jsObject = jsObject;
private Function(JSObject object, String name, Object[] args) {
this.object = object;
this.name = name;
this.args = args;
}
@Override
public Object call() throws Exception {
result = jsObject.getJSFunction(name).call(args);
result = object.getJSFunction(name).call(args);
if (!(result instanceof JSObject)) return result;
JSObject promise = (JSObject) result;
JSFunction then = promise.getJSFunction("then");
if (then != null) then.call(jsCallFunction);
if (then != null) then.call(func);
return result;
}
private final JSCallFunction jsCallFunction = new JSCallFunction() {
private final JSCallFunction func = new JSCallFunction() {
@Override
public Object call(Object... args) {
return result = args[0];

@ -1,6 +1,7 @@
package com.fongmi.quickjs.utils;
import android.net.Uri;
import android.util.Base64;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Path;
@ -52,4 +53,12 @@ public class Module {
return "";
}
}
public byte[] bb(String content) {
byte[] bytes = Base64.decode(content.substring(4), Base64.DEFAULT);
byte[] newBytes = new byte[bytes.length - 4];
newBytes[0] = 1;
System.arraycopy(bytes, 5, newBytes, 1, bytes.length - 5);
return newBytes;
}
}

Loading…
Cancel
Save