mirror of
https://github.com/wgh136/flutter_qjs.git
synced 2025-09-27 13:27:24 +00:00
run on isolate
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user