wrap dart object to js.

This commit is contained in:
ekibun
2021-01-18 02:02:12 +08:00
parent 8e950c5b14
commit 7de32aac0b
9 changed files with 104 additions and 29 deletions

View File

@@ -105,8 +105,11 @@ extern "C"
DLLEXPORT JSValue *jsEval(JSContext *ctx, const char *input, size_t input_len, const char *filename, int32_t eval_flags)
{
JS_ResetStackTop(JS_GetRuntime(ctx));
return new JSValue(JS_Eval(ctx, input, input_len, filename, eval_flags));
JSRuntime *rt = JS_GetRuntime(ctx);
uint8_t *stack_top = JS_SetStackTop(rt, 0);
JSValue *ret = new JSValue(JS_Eval(ctx, input, input_len, filename, eval_flags));
JS_SetStackTop(rt, stack_top);
return ret;
}
DLLEXPORT int32_t jsValueGetTag(JSValue *val)
@@ -283,8 +286,11 @@ extern "C"
DLLEXPORT JSValue *jsCall(JSContext *ctx, JSValueConst *func_obj, JSValueConst *this_obj,
int32_t argc, JSValueConst *argv)
{
JS_ResetStackTop(JS_GetRuntime(ctx));
return new JSValue(JS_Call(ctx, *func_obj, *this_obj, argc, argv));
JSRuntime *rt = JS_GetRuntime(ctx);
uint8_t *stack_top = JS_SetStackTop(rt, 0);
JSValue *ret = new JSValue(JS_Call(ctx, *func_obj, *this_obj, argc, argv));
JS_SetStackTop(rt, stack_top);
return ret;
}
DLLEXPORT int32_t jsIsException(JSValueConst *val)
@@ -299,9 +305,11 @@ extern "C"
DLLEXPORT int32_t jsExecutePendingJob(JSRuntime *rt)
{
JS_ResetStackTop(rt);
uint8_t *stack_top = JS_SetStackTop(rt, 0);
JSContext *ctx;
return JS_ExecutePendingJob(rt, &ctx);
int ret = JS_ExecutePendingJob(rt, &ctx);
JS_SetStackTop(rt, stack_top);
return ret;
}
DLLEXPORT JSValue *jsNewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs)