@@ -166,7 +166,7 @@ pub const Session = struct {
166166 // const ctx_opaque = @as(*anyopaque, @ptrCast(ctx));
167167 self .inspector = try jsruntime .Inspector .init (
168168 arena ,
169- self .env , // TODO: change to 'env' when https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
169+ & self .env ,
170170 if (@TypeOf (ctx ) == void ) @constCast (@ptrCast (&{})) else ctx ,
171171 InspectorContainer .onInspectorResponse ,
172172 InspectorContainer .onInspectorEvent ,
@@ -231,8 +231,7 @@ pub const Session = struct {
231231 }
232232
233233 // load polyfills
234- // TODO: change to 'env' when https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
235- try polyfill .load (self .arena .allocator (), self .env );
234+ try polyfill .load (self .arena .allocator (), & self .env );
236235
237236 // inspector
238237 self .contextCreated (page , aux_data );
@@ -265,7 +264,7 @@ pub const Session = struct {
265264
266265 fn contextCreated (self : * Session , page : * Page , aux_data : ? []const u8 ) void {
267266 log .debug ("inspector context created" , .{});
268- self .inspector .contextCreated (self .env , "" , page .origin orelse "://" , aux_data );
267+ self .inspector .contextCreated (& self .env , "" , page .origin orelse "://" , aux_data );
269268 }
270269};
271270
@@ -317,15 +316,15 @@ pub const Page = struct {
317316 pub fn wait (self : * Page ) ! void {
318317 // try catch
319318 var try_catch : jsruntime.TryCatch = undefined ;
320- try_catch .init (self .session .env );
319+ try_catch .init (& self .session .env );
321320 defer try_catch .deinit ();
322321
323322 self .session .env .wait () catch | err | {
324323 // the js env could not be started if the document wasn't an HTML.
325324 if (err == error .EnvNotStarted ) return ;
326325
327326 const arena = self .arena ;
328- if (try try_catch .err (arena , self .session .env )) | msg | {
327+ if (try try_catch .err (arena , & self .session .env )) | msg | {
329328 defer arena .free (msg );
330329 log .info ("wait error: {s}" , .{msg });
331330 return ;
@@ -592,8 +591,6 @@ pub const Page = struct {
592591 // TODO handle charset attribute
593592 const opt_text = try parser .nodeTextContent (parser .elementToNode (s .element ));
594593 if (opt_text ) | text | {
595- // TODO: change to &self.session.env when
596- // https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
597594 try s .eval (self .arena , self .session .env , text );
598595 return ;
599596 }
@@ -659,8 +656,6 @@ pub const Page = struct {
659656 const arena = self .arena ;
660657
661658 const body = try self .fetchData (arena , s .src , null );
662- // TODO: change to &self.session.env when
663- // https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
664659 try s .eval (arena , self .session .env , body );
665660 }
666661
@@ -704,24 +699,24 @@ pub const Page = struct {
704699 return .unknown ;
705700 }
706701
707- fn eval (self : Script , arena : Allocator , env : Env , body : []const u8 ) ! void {
702+ fn eval (self : Script , arena : Allocator , env : Env , body : []const u8 ) ! void { // TODO use an *const Env
708703 var try_catch : jsruntime.TryCatch = undefined ;
709- try_catch .init (env );
704+ try_catch .init (& env );
710705 defer try_catch .deinit ();
711706
712707 const res = switch (self .kind ) {
713708 .unknown = > return error .UnknownScript ,
714- .javascript = > env .exec (body , self .src ),
715- .module = > env .module (body , self .src ),
709+ .javascript = > env .exec (body , self .src ), // TODO use an *const Env
710+ .module = > env .module (body , self .src ), // TODO use an *const Env
716711 } catch {
717- if (try try_catch .err (arena , env )) | msg | {
712+ if (try try_catch .err (arena , & env )) | msg | {
718713 log .info ("eval script {s}: {s}" , .{ self .src , msg });
719714 }
720715 return FetchError .JsErr ;
721716 };
722717
723718 if (builtin .mode == .Debug ) {
724- const msg = try res .toString (arena , env );
719+ const msg = try res .toString (arena , & env );
725720 log .debug ("eval script {s}: {s}" , .{ self .src , msg });
726721 }
727722 }
0 commit comments