Skip to content

Commit

Permalink
chore: update to zig version 0.14.0-dev.1398+c34cfe486
Browse files Browse the repository at this point in the history
  • Loading branch information
travisstaloch committed Sep 2, 2024
1 parent f547c63 commit 22d85a1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/common.zig
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub const TraitFn = fn (type) bool;

pub fn isContainer(comptime T: type) bool {
return switch (@typeInfo(T)) {
.Struct, .Union, .Enum, .Opaque => true,
.@"struct", .@"union", .@"enum", .@"opaque" => true,
else => false,
};
}
Expand All @@ -139,7 +139,7 @@ pub fn hasFn(comptime name: []const u8) TraitFn {
if (!comptime isContainer(T)) return false;
if (!comptime @hasDecl(T, name)) return false;
const DeclType = @TypeOf(@field(T, name));
return @typeInfo(DeclType) == .Fn;
return @typeInfo(DeclType) == .@"fn";
}
};
return Closure.trait;
Expand Down
22 changes: 11 additions & 11 deletions src/dom.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ pub const Element = struct {
options: cmn.GetOptions,
comptime child_info: std.builtin.Type,
) cmn.Error!void {
const Cchild = child_info.Pointer.child;
const Cchild = child_info.pointer.child;
const allocator = options.allocator orelse return error.AllocatorRequired;
var elems = std.ArrayList(Cchild).init(allocator);
const arr = ele.get_array() catch unreachable;
Expand Down Expand Up @@ -1849,30 +1849,30 @@ pub const Element = struct {
const T = @TypeOf(out);
const info = @typeInfo(T);
switch (info) {
.Pointer => {
.pointer => {
const C = std.meta.Child(T);
if (comptime cmn.hasFn("jsonParse")(C))
return C.jsonParse(ele, out, options);

const child_info = @typeInfo(C);
switch (info.Pointer.size) {
switch (info.pointer.size) {
.One => {
switch (child_info) {
.Int => out.* = std.math.cast(C, try if (child_info.Int.signedness == .signed)
.int => out.* = std.math.cast(C, try if (child_info.int.signedness == .signed)
ele.get_int64()
else
ele.get_uint64()) orelse return error.Overflow,
.Float => out.* = @as(C, @floatCast(try ele.get_double())),
.Bool => out.* = try ele.get_bool(),
.Optional => out.* = if (ele.is(.NULL))
.float => out.* = @as(C, @floatCast(try ele.get_double())),
.bool => out.* = try ele.get_bool(),
.optional => out.* = if (ele.is(.NULL))
null
else blk: {
var x: std.meta.Child(C) = undefined;
try ele.jsonParse(&x, options);
break :blk x;
},
.Array => try ele.jsonParse(@as([]std.meta.Child(C), out), options),
.Struct => {
.array => try ele.jsonParse(@as([]std.meta.Child(C), out), options),
.@"struct" => {
switch (ele.tape.tape_ref_type()) {
.START_OBJECT => {
var obj = ele.get_object() catch unreachable;
Expand All @@ -1884,8 +1884,8 @@ pub const Element = struct {
else => return error.INCORRECT_TYPE,
}
},
.Pointer => if (child_info.Pointer.size == .Slice) {
if (child_info.Pointer.child == u8) {
.pointer => if (child_info.pointer.size == .Slice) {
if (child_info.pointer.child == u8) {
// std.debug.print("ele.tape.tape_ref_type()={}", .{ele.tape.tape_ref_type()});
switch (ele.tape.tape_ref_type()) {
.STRING => out.* = try ele.get_string(),
Expand Down
24 changes: 12 additions & 12 deletions src/ondemand.zig
Original file line number Diff line number Diff line change
Expand Up @@ -97,35 +97,35 @@ pub const Value = struct {
const T = @TypeOf(out);
const info = @typeInfo(T);
switch (info) {
.Pointer => {
.pointer => {
const C = std.meta.Child(T);
if (comptime cmn.hasFn("jsonParse")(C))
return C.jsonParse(val, out, options);

const child_info = @typeInfo(C);
switch (info.Pointer.size) {
switch (info.pointer.size) {
.One => {
switch (child_info) {
.Int => out.* = try val.get_int(C),
.Float => out.* = @floatCast(try val.get_double()),
.Bool => out.* = try val.get_bool(),
.Optional => out.* = if (try val.is_null())
.int => out.* = try val.get_int(C),
.float => out.* = @floatCast(try val.get_double()),
.bool => out.* = try val.get_bool(),
.optional => out.* = if (try val.is_null())
null
else blk: {
var x: std.meta.Child(C) = undefined;
try val.jsonParse(&x, options);
break :blk x;
},
.Array => {
.array => {
var arr = try val.get_array();
var iter = arr.iterator();
for (out) |*out_ele| {
var arr_ele = (try iter.next()) orelse break;
try arr_ele.jsonParse(out_ele, options);
}
},
.Pointer => {
if (child_info.Pointer.size == .Slice) {
.pointer => {
if (child_info.pointer.size == .Slice) {
if (options.allocator) |allocator| {
switch (try val.get_type()) {
.array => {
Expand All @@ -148,15 +148,15 @@ pub const Value = struct {
} else @compileError("unsupported type: " ++ @typeName(T) ++
". expecting slice");
},
.Struct => {
.@"struct" => {
switch (try val.iter.get_type()) {
.object => {
var obj = try val.get_object();
inline for (std.meta.fields(C)) |field| {
const field_info = @typeInfo(field.type);
if (obj.find_field_unordered(field.name)) |obj_val_| {
var obj_val = obj_val_;
if (field_info != .Pointer)
if (field_info != .pointer)
try obj_val.jsonParse(&@field(out, field.name), options)
else {
if (options.allocator != null)
Expand Down Expand Up @@ -1084,7 +1084,7 @@ pub const ValueIterator = struct {
try vi.advance_non_root_scalar(@typeName(T), peek_len),
.{},
);
return std.math.cast(T, if (@typeInfo(T).Int.signedness == .signed)
return std.math.cast(T, if (@typeInfo(T).int.signedness == .signed)
@as(i64, @bitCast(u64int))
else
u64int) orelse return error.Overflow;
Expand Down

0 comments on commit 22d85a1

Please sign in to comment.