Skip to content

Commit

Permalink
fix: use lowercase enum for >= 0.14 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
CashWasabi committed Jan 22, 2025
1 parent 8229331 commit 0225788
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion src/parsing/parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn ParserType(comptime options: TemplateOptions) type {
fn RenderError(comptime TRender: type) type {
switch (@typeInfo(TRender)) {
.pointer => |pointer| {
if (pointer.size == .One) {
if (pointer.size == .one) {
const Render = pointer.child;
return Render.Error;
}
Expand Down
22 changes: 11 additions & 11 deletions src/rendering/Fields.zig
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ pub fn byValue(comptime TField: type) bool {
pub inline fn isNull(comptime T: type, data: T) bool {
return switch (@typeInfo(T)) {
.pointer => |info| switch (info.size) {
.One => return isNull(@TypeOf(data.*), data.*),
.Slice => return false,
.Many => @compileError("[*] pointers not supported"),
.C => @compileError("[*c] pointers not supported"),
.one => return isNull(@TypeOf(data.*), data.*),
.slice => return false,
.many => @compileError("[*] pointers not supported"),
.c => @compileError("[*c] pointers not supported"),
},
.optional => return data == null,
else => return false,
Expand All @@ -234,10 +234,10 @@ pub inline fn isNull(comptime T: type, data: T) bool {
pub inline fn lenOf(comptime T: type, data: T) ?usize {
return switch (@typeInfo(T)) {
.pointer => |info| switch (info.size) {
.One => return null,
.Slice => return data.len,
.Many => @compileError("[*] pointers not supported"),
.C => @compileError("[*c] pointers not supported"),
.one => return null,
.slice => return data.len,
.many => @compileError("[*] pointers not supported"),
.c => @compileError("[*c] pointers not supported"),
},
.array, .vector => return data.len,
.optional => if (data) |value| return lenOf(@TypeOf(value), value) else null,
Expand Down Expand Up @@ -385,7 +385,7 @@ test "enum literal " {
// TODO: Not sure if it's a supported use case.
if (true) return error.SkipZigTest;

const data = .{ .value = .AreYouSure, .level = .{ .value = .Totally } };
const data = .{ .value = .are_you_sure, .level = .{ .value = .totally } };

const field = getField(&data, "value");
try std.testing.expectEqual(field, data.value);
Expand All @@ -398,8 +398,8 @@ test "enum literal " {
}

test "enum" {
const Options = enum { AreYouSure, Totally };
var data = .{ .value = Options.AreYouSure, .level = .{ .value = Options.Totally } };
const Options = enum { are_you_sure, totally };
var data = .{ .value = Options.are_you_sure, .level = .{ .value = Options.totally } };

const field = getField(&data, "value");
try std.testing.expectEqual(field, data.value);
Expand Down
4 changes: 2 additions & 2 deletions src/rendering/context.zig
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ pub fn PathResolutionType(comptime Payload: type) type {
}

pub const Escape = enum {
Escaped,
Unescaped,
escaped,
unescaped,
};

pub fn ContextType(
Expand Down
8 changes: 4 additions & 4 deletions src/rendering/contexts/ffi/context.zig
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,12 @@ const context_tests = struct {

const writer = list.writer();

try interpolateCtx(writer, person_ctx, "id", .Unescaped);
try interpolateCtx(writer, person_ctx, "id", .unescaped);
try testing.expectEqualStrings("100", list.items);

list.clearAndFree();

try interpolateCtx(writer, person_ctx, "name", .Unescaped);
try interpolateCtx(writer, person_ctx, "name", .unescaped);
try testing.expectEqualStrings("Angus McGyver", list.items);

list.clearAndFree();
Expand All @@ -721,12 +721,12 @@ const context_tests = struct {

const writer = list.writer();

try interpolateCtx(writer, person_ctx, "boss.id", .Unescaped);
try interpolateCtx(writer, person_ctx, "boss.id", .unescaped);
try testing.expectEqualStrings("101", list.items);

list.clearAndFree();

try interpolateCtx(writer, person_ctx, "boss.name", .Unescaped);
try interpolateCtx(writer, person_ctx, "boss.name", .unescaped);
try testing.expectEqualStrings("Peter Thornton", list.items);

list.clearAndFree();
Expand Down
24 changes: 12 additions & 12 deletions src/rendering/contexts/native/context.zig
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ const context_tests = struct {

const ctx = DummyRenderEngine.getContextType(if (by_value) data else @as(*const Data, &data));

try interpolateCtx(writer, ctx, path, .Unescaped);
try interpolateCtx(writer, ctx, path, .unescaped);
}

fn interpolateCtx(writer: anytype, ctx: DummyRenderEngine.Context, identifier: []const u8, escape: Escape) anyerror!void {
Expand Down Expand Up @@ -1030,7 +1030,7 @@ const context_tests = struct {
{
list.clearAndFree();

try interpolateCtx(writer, person_ctx, "address.street", .Unescaped);
try interpolateCtx(writer, person_ctx, "address.street", .unescaped);
try testing.expectEqualStrings("nearby", list.items);
}

Expand All @@ -1052,7 +1052,7 @@ const context_tests = struct {
{
list.clearAndFree();

try interpolateCtx(writer, address_ctx, "street", .Unescaped);
try interpolateCtx(writer, address_ctx, "street", .unescaped);
try testing.expectEqualStrings("nearby", list.items);
}

Expand All @@ -1074,14 +1074,14 @@ const context_tests = struct {
{
list.clearAndFree();

try interpolateCtx(writer, street_ctx, "", .Unescaped);
try interpolateCtx(writer, street_ctx, "", .unescaped);
try testing.expectEqualStrings("nearby", list.items);
}

{
list.clearAndFree();

try interpolateCtx(writer, street_ctx, ".", .Unescaped);
try interpolateCtx(writer, street_ctx, ".", .unescaped);
try testing.expectEqualStrings("nearby", list.items);
}
}
Expand All @@ -1103,7 +1103,7 @@ const context_tests = struct {
{
list.clearAndFree();

try interpolateCtx(writer, person_ctx, "indication.address.street", .Unescaped);
try interpolateCtx(writer, person_ctx, "indication.address.street", .unescaped);
try testing.expectEqualStrings("far away street", list.items);
}

Expand All @@ -1125,7 +1125,7 @@ const context_tests = struct {
{
list.clearAndFree();

try interpolateCtx(writer, indication_ctx, "address.street", .Unescaped);
try interpolateCtx(writer, indication_ctx, "address.street", .unescaped);
try testing.expectEqualStrings("far away street", list.items);
}

Expand All @@ -1147,7 +1147,7 @@ const context_tests = struct {
{
list.clearAndFree();

try interpolateCtx(writer, address_ctx, "street", .Unescaped);
try interpolateCtx(writer, address_ctx, "street", .unescaped);
try testing.expectEqualStrings("far away street", list.items);
}

Expand All @@ -1169,14 +1169,14 @@ const context_tests = struct {
{
list.clearAndFree();

try interpolateCtx(writer, street_ctx, "", .Unescaped);
try interpolateCtx(writer, street_ctx, "", .unescaped);
try testing.expectEqualStrings("far away street", list.items);
}

{
list.clearAndFree();

try interpolateCtx(writer, street_ctx, ".", .Unescaped);
try interpolateCtx(writer, street_ctx, ".", .unescaped);
try testing.expectEqualStrings("far away street", list.items);
}
}
Expand Down Expand Up @@ -1288,7 +1288,7 @@ const context_tests = struct {

list.clearAndFree();

try interpolateCtx(writer, item_1, "name", .Unescaped);
try interpolateCtx(writer, item_1, "name", .unescaped);
try testing.expectEqualStrings("item 1", list.items);

const item_2 = iterator.next() orelse {
Expand All @@ -1298,7 +1298,7 @@ const context_tests = struct {

list.clearAndFree();

try interpolateCtx(writer, item_2, "name", .Unescaped);
try interpolateCtx(writer, item_2, "name", .unescaped);
try testing.expectEqualStrings("item 2", list.items);

const no_more = iterator.next();
Expand Down
12 changes: 6 additions & 6 deletions src/rendering/contexts/native/invoker.zig
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn InvokerType(
);
},
.pointer => |info| switch (info.size) {
.One => return try recursiveFind(
.one => return try recursiveFind(
depth,
info.child,
action_param,
Expand All @@ -117,7 +117,7 @@ pub fn InvokerType(
next_path_parts,
index,
),
.Slice => {
.slice => {
//Slice supports the "len" field,
if (next_path_parts.len == 0 and std.mem.eql(u8, "len", current_path_part)) {
return if (next_path_parts.len == 0)
Expand All @@ -128,8 +128,8 @@ pub fn InvokerType(
.chain_broken;
}
},
.Many => @compileError("[*] pointers not supported"),
.C => @compileError("[*c] pointers not supported"),
.many => @compileError("[*] pointers not supported"),
.c => @compileError("[*c] pointers not supported"),
},
.optional => |info| {
if (!Fields.isNull(Data, data)) {
Expand Down Expand Up @@ -276,15 +276,15 @@ pub fn InvokerType(
.iterator_consumed;
},
.pointer => |info| switch (info.size) {
.One => {
.one => {
return try iterateAt(
info.child,
action_param,
Fields.lhs(Data, data),
index,
);
},
.Slice => {
.slice => {
//Slice of u8 is always string
if (info.child != u8) {
return if (index < data.len)
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/contexts/native/lambda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub fn LambdaInvokerType(comptime TData: type, comptime TFn: type) type {
switch (@typeInfo(TData)) {
.pointer => |info| {
switch (info.size) {
.One => {
.one => {
if (info.child == fnArg) {

// Context is a pointer, but the parameter is a value
Expand Down
Loading

0 comments on commit 0225788

Please sign in to comment.