Skip to content

Commit 659d0bd

Browse files
committed
Make pretty-printing more cross-platform.
1 parent dbda7a6 commit 659d0bd

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

src/root.zig

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,7 +2713,8 @@ pub const Lua = opaque {
27132713
short_src: [DebugShortSourceLen]u8 = undefined,
27142714

27152715
pub fn prettyPrint(self: *Lua.DebugInfo, writer: std.io.AnyWriter) !void {
2716-
try writer.print("{*} {{\n", .{self});
2716+
const addr: u64 = @intFromPtr(self);
2717+
try writer.print("root.Lua.DebugInfo@0x{x} {{\n", .{addr});
27172718
if (HookEventKind.isHookEventKind(@intFromEnum(self.event))) {
27182719
try writer.print(" event: '{s}' ({d}),\n", .{ @tagName(self.event), @intFromEnum(self.event) });
27192720
} else {
@@ -2839,7 +2840,8 @@ pub const Lua = opaque {
28392840
short_src: [DebugShortSourceLen]u8 = undefined,
28402841

28412842
pub fn prettyPrint(self: *Lua.DebugInfoFunction, writer: std.io.AnyWriter) !void {
2842-
try writer.print("{*} {{\n", .{self});
2843+
const addr: u64 = @intFromPtr(self);
2844+
try writer.print("root.Lua.DebugInfoFunction@0x{x} {{\n", .{addr});
28432845
try writer.print(" what: '{s}',\n", .{@tagName(self.what)});
28442846

28452847
if (std.mem.indexOf(u8, self.short_src[0..DebugShortSourceLen], &.{0})) |i| {
@@ -5375,12 +5377,12 @@ test "getInfo() can debug info can be pretty printed" {
53755377
try info.prettyPrint(fbs.writer().any());
53765378

53775379
const actual = fbs.getWritten();
5378-
try std.testing.expectEqual(279, actual.len);
5380+
try std.testing.expectEqual(281, actual.len);
53795381

53805382
// The output contains a pointer address too, so we will match the two parts around that.
53815383
try std.testing.expectEqualStrings(
5382-
\\root.Lua.DebugInfo@
5383-
, actual[0..19]);
5384+
\\root.Lua.DebugInfo@0x
5385+
, actual[0..21]);
53845386

53855387
try std.testing.expectEqualStrings(
53865388
\\ {
@@ -5401,7 +5403,7 @@ test "getInfo() can debug info can be pretty printed" {
54015403
\\```
54025404
\\}
54035405
\\
5404-
, actual[31..]);
5406+
, actual[33..]);
54055407
}
54065408

54075409
test "getInfoFunction() can be used to show debug information about a function" {
@@ -5448,12 +5450,12 @@ test "getInfoFunction() can pretty printed" {
54485450
try info.prettyPrint(fbs.writer().any());
54495451

54505452
const actual = fbs.getWritten();
5451-
try std.testing.expectEqual(209, actual.len);
5453+
try std.testing.expectEqual(211, actual.len);
54525454

54535455
// The output contains a pointer address too, so we will match the two parts around that.
54545456
try std.testing.expectEqualStrings(
5455-
\\root.Lua.DebugInfoFunction@
5456-
, actual[0..27]);
5457+
\\root.Lua.DebugInfoFunction@0x
5458+
, actual[0..29]);
54575459

54585460
try std.testing.expectEqualStrings(
54595461
\\ {
@@ -5470,5 +5472,5 @@ test "getInfoFunction() can pretty printed" {
54705472
\\```
54715473
\\}
54725474
\\
5473-
, actual[39..]);
5475+
, actual[41..]);
54745476
}

0 commit comments

Comments
 (0)