run on isolate

This commit is contained in:
ekibun
2020-10-03 00:40:47 +08:00
parent 097e118e5d
commit 8a72bac6a9
11 changed files with 390 additions and 72 deletions

View File

@@ -3,7 +3,7 @@
* @Author: ekibun
* @Date: 2020-09-19 22:07:47
* @LastEditors: ekibun
* @LastEditTime: 2020-09-24 13:38:08
* @LastEditTime: 2020-10-02 16:37:16
*/
import 'dart:async';
import 'dart:ffi';
@@ -22,6 +22,11 @@ class JSRefValue implements JSRef {
runtimeOpaques[rt]?.ref?.add(this);
}
JSRefValue.fromAddress(int ctx, int val) {
this.ctx = Pointer.fromAddress(ctx);
this.val = Pointer.fromAddress(val);
}
@override
void release() {
if (val != null) {
@@ -65,10 +70,11 @@ class JSPromise extends JSRefValue {
class JSFunction extends JSRefValue {
JSFunction(Pointer ctx, Pointer val) : super(ctx, val);
@override
noSuchMethod(Invocation invocation) {
JSFunction.fromAddress(int ctx, int val) : super.fromAddress(ctx, val);
invoke(List<dynamic> arguments) {
if (val == null) return;
List<Pointer> args = invocation.positionalArguments
List<Pointer> args = arguments
.map(
(e) => dartToJs(ctx, e),
)
@@ -85,6 +91,11 @@ class JSFunction extends JSRefValue {
}
return ret;
}
@override
noSuchMethod(Invocation invocation) {
return invoke(invocation.positionalArguments);
}
}
Pointer jsGetPropertyStr(Pointer ctx, Pointer val, String prop) {