Skip to content

Commit

Permalink
Update @fieldParentPtr behaviour to resolve change in nightly build v…
Browse files Browse the repository at this point in the history
…0.12.0-dev.3439+31a7f22b8
  • Loading branch information
timsavage authored and kubkon committed Apr 6, 2024
1 parent 9308a64 commit 0daa453
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/parse.zig
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,28 @@ pub const Node = struct {
if (self.tag != T.base_tag) {
return null;
}
return @fieldParentPtr(T, "base", self);
return @fieldParentPtr("base", self);
}

pub fn deinit(self: *Node, allocator: Allocator) void {
switch (self.tag) {
.doc => {
const parent = @fieldParentPtr(Node.Doc, "base", self);
const parent: *Node.Doc = @fieldParentPtr("base", self);
parent.deinit(allocator);
allocator.destroy(parent);
},
.map => {
const parent = @fieldParentPtr(Node.Map, "base", self);
const parent: *Node.Map = @fieldParentPtr("base", self);
parent.deinit(allocator);
allocator.destroy(parent);
},
.list => {
const parent = @fieldParentPtr(Node.List, "base", self);
const parent: *Node.List = @fieldParentPtr("base", self);
parent.deinit(allocator);
allocator.destroy(parent);
},
.value => {
const parent = @fieldParentPtr(Node.Value, "base", self);
const parent: *Node.Value = @fieldParentPtr("base", self);
parent.deinit(allocator);
allocator.destroy(parent);
},
Expand All @@ -70,10 +70,10 @@ pub const Node = struct {
writer: anytype,
) !void {
return switch (self.tag) {
.doc => @fieldParentPtr(Node.Doc, "base", self).format(fmt, options, writer),
.map => @fieldParentPtr(Node.Map, "base", self).format(fmt, options, writer),
.list => @fieldParentPtr(Node.List, "base", self).format(fmt, options, writer),
.value => @fieldParentPtr(Node.Value, "base", self).format(fmt, options, writer),
.doc => @as(*const Node.Doc, @fieldParentPtr("base", self)).format(fmt, options, writer),
.map => @as(*const Node.Map, @fieldParentPtr("base", self)).format(fmt, options, writer),
.list => @as(*const Node.List, @fieldParentPtr("base", self)).format(fmt, options, writer),
.value => @as(*const Node.Value, @fieldParentPtr("base", self)).format(fmt, options, writer),
};
}

Expand Down

0 comments on commit 0daa453

Please sign in to comment.