mirror of
https://github.com/wgh136/flutter_qjs.git
synced 2025-09-27 05:27:23 +00:00
wrap dart object to js.
This commit is contained in:
20
cxx/ffi.cpp
20
cxx/ffi.cpp
@@ -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)
|
||||
|
Reference in New Issue
Block a user