From 0a3e2fe392056a05e134dbfe3aa566208686f9b2 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 17 Oct 2023 18:33:35 +0200 Subject: [PATCH] wpt: refacto js eval --- src/main_wpt.zig | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main_wpt.zig b/src/main_wpt.zig index c0a0bbba..155fe733 100644 --- a/src/main_wpt.zig +++ b/src/main_wpt.zig @@ -178,7 +178,8 @@ fn runWPT(arena: *std.heap.ArenaAllocator, f: []const u8, loader: *FileLoader) ! try js_env.attachObject(try js_env.getGlobal(), "self", null); try js_env.attachObject(try js_env.getGlobal(), "window", null); - var res = jsruntime.JSResult{}; + // thanks to the arena, we don't need to deinit res. + var res: jsruntime.JSResult = undefined; const init = \\window.listeners = []; @@ -198,17 +199,17 @@ fn runWPT(arena: *std.heap.ArenaAllocator, f: []const u8, loader: *FileLoader) ! \\}; \\window.removeEventListener = function () {}; ; - try js_env.run(alloc, init, "init", &res, null); + res = try evalJS(js_env, alloc, init, "init"); if (!res.success) { return res; } // TODO load