update quickjs

This commit is contained in:
ekibun
2021-03-28 16:49:28 +08:00
parent e87f50956a
commit ba270b95ef
2 changed files with 5 additions and 9 deletions

View File

@@ -160,9 +160,8 @@ extern "C"
DLLEXPORT JSValue *jsEval(JSContext *ctx, const char *input, size_t input_len, const char *filename, int32_t eval_flags) DLLEXPORT JSValue *jsEval(JSContext *ctx, const char *input, size_t input_len, const char *filename, int32_t eval_flags)
{ {
JSRuntime *rt = JS_GetRuntime(ctx); JSRuntime *rt = JS_GetRuntime(ctx);
uint8_t *stack_top = JS_SetStackTop(rt, 0); JS_UpdateStackTop(rt);
JSValue *ret = new JSValue(JS_Eval(ctx, input, input_len, filename, eval_flags)); JSValue *ret = new JSValue(JS_Eval(ctx, input, input_len, filename, eval_flags));
JS_SetStackTop(rt, stack_top);
return ret; return ret;
} }
@@ -262,9 +261,8 @@ extern "C"
DLLEXPORT const char *jsToCString(JSContext *ctx, JSValueConst *val) DLLEXPORT const char *jsToCString(JSContext *ctx, JSValueConst *val)
{ {
JSRuntime *rt = JS_GetRuntime(ctx); JSRuntime *rt = JS_GetRuntime(ctx);
uint8_t *stack_top = JS_SetStackTop(rt, 0); JS_UpdateStackTop(rt);
const char *ret = JS_ToCString(ctx, *val); const char *ret = JS_ToCString(ctx, *val);
JS_SetStackTop(rt, stack_top);
return ret; return ret;
} }
@@ -355,9 +353,8 @@ extern "C"
int32_t argc, JSValueConst *argv) int32_t argc, JSValueConst *argv)
{ {
JSRuntime *rt = JS_GetRuntime(ctx); JSRuntime *rt = JS_GetRuntime(ctx);
uint8_t *stack_top = JS_SetStackTop(rt, 0); JS_UpdateStackTop(rt);
JSValue *ret = new JSValue(JS_Call(ctx, *func_obj, *this_obj, argc, argv)); JSValue *ret = new JSValue(JS_Call(ctx, *func_obj, *this_obj, argc, argv));
JS_SetStackTop(rt, stack_top);
return ret; return ret;
} }
@@ -373,10 +370,9 @@ extern "C"
DLLEXPORT int32_t jsExecutePendingJob(JSRuntime *rt) DLLEXPORT int32_t jsExecutePendingJob(JSRuntime *rt)
{ {
uint8_t *stack_top = JS_SetStackTop(rt, 0); JS_UpdateStackTop(rt);
JSContext *ctx; JSContext *ctx;
int ret = JS_ExecutePendingJob(rt, &ctx); int ret = JS_ExecutePendingJob(rt, &ctx);
JS_SetStackTop(rt, stack_top);
return ret; return ret;
} }