Skip to content

Commit b5c9cc5

Browse files
nurpaxnatecraddock
authored andcommitted
build fixes for zig dev 0.14.0-dev.1820+ea527f7a8
1 parent e3a97ad commit b5c9cc5

File tree

4 files changed

+45
-45
lines changed

4 files changed

+45
-45
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup Zig
2121
uses: mlugg/setup-zig@v1
2222
with:
23-
version: 0.13.0
23+
version: 0.14.0-dev.1820+ea527f7a8
2424

2525
- name: Run tests
2626
run: make test

build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn build(b: *Build) void {
7878
.target = target,
7979
.optimize = optimize,
8080
});
81-
c_headers.addIncludeDir(b.getInstallPath(install_lib.h_dir.?, ""));
81+
c_headers.addIncludePath(lib.getEmittedIncludeTree());
8282
c_headers.step.dependOn(&install_lib.step);
8383
ziglua.addImport("c", c_headers.createModule());
8484

src/define.zig

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn addEnum(
7777
try state.definitions.items[index].appendSlice(name(T));
7878
try state.definitions.items[index].appendSlice("\n");
7979

80-
inline for (@typeInfo(T).Enum.fields) |field| {
80+
inline for (@typeInfo(T).@"enum".fields) |field| {
8181
try state.definitions.items[index].appendSlice("---|\' \"");
8282
try state.definitions.items[index].appendSlice(field.name);
8383
try state.definitions.items[index].appendSlice("\" \'\n");
@@ -98,7 +98,7 @@ pub fn addClass(
9898
try state.definitions.items[index].appendSlice(name(T));
9999
try state.definitions.items[index].appendSlice("\n");
100100

101-
inline for (@typeInfo(T).Struct.fields) |field| {
101+
inline for (@typeInfo(T).@"struct".fields) |field| {
102102
try state.definitions.items[index].appendSlice("---@field ");
103103
try state.definitions.items[index].appendSlice(field.name);
104104

@@ -118,11 +118,11 @@ fn luaTypeName(
118118
comptime T: type,
119119
) !void {
120120
switch (@typeInfo(T)) {
121-
.Struct => {
121+
.@"struct" => {
122122
try state.definitions.items[index].appendSlice(name(T));
123123
try addClass(state, T);
124124
},
125-
.Pointer => |info| {
125+
.pointer => |info| {
126126
if (info.child == u8 and info.size == .Slice) {
127127
try state.definitions.items[index].appendSlice("string");
128128
} else switch (info.size) {
@@ -135,30 +135,30 @@ fn luaTypeName(
135135
},
136136
}
137137
},
138-
.Array => |info| {
138+
.array => |info| {
139139
try luaTypeName(state, index, info.child);
140140
try state.definitions.items[index].appendSlice("[]");
141141
},
142142

143-
.Vector => |info| {
143+
.vector => |info| {
144144
try luaTypeName(state, index, info.child);
145145
try state.definitions.items[index].appendSlice("[]");
146146
},
147-
.Optional => |info| {
147+
.optional => |info| {
148148
try luaTypeName(state, index, info.child);
149149
try state.definitions.items[index].appendSlice(" | nil");
150150
},
151-
.Enum => {
151+
.@"enum" => {
152152
try state.definitions.items[index].appendSlice(name(T));
153153
try addEnum(state, T);
154154
},
155-
.Int => {
155+
.int => {
156156
try state.definitions.items[index].appendSlice("integer");
157157
},
158-
.Float => {
158+
.float => {
159159
try state.definitions.items[index].appendSlice("number");
160160
},
161-
.Bool => {
161+
.bool => {
162162
try state.definitions.items[index].appendSlice("boolean");
163163
},
164164
else => {

src/lib.zig

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,18 +3003,18 @@ pub const Lua = opaque {
30033003
const childinfo = @typeInfo(typeinfo.child);
30043004
if (typeinfo.child == u8 and typeinfo.size != .One) {
30053005
return true;
3006-
} else if (typeinfo.size == .One and childinfo == .Array and childinfo.Array.child == u8) {
3006+
} else if (typeinfo.size == .One and childinfo == .array and childinfo.array.child == u8) {
30073007
return true;
30083008
}
30093009
return false;
30103010
}
30113011

30123012
/// Pushes any string type
30133013
fn pushAnyString(lua: *Lua, value: anytype) !void {
3014-
const info = @typeInfo(@TypeOf(value)).Pointer;
3014+
const info = @typeInfo(@TypeOf(value)).pointer;
30153015
switch (info.size) {
30163016
.One => {
3017-
const childinfo = @typeInfo(info.child).Array;
3017+
const childinfo = @typeInfo(info.child).array;
30183018
std.debug.assert(childinfo.child == u8);
30193019
std.debug.assert(childinfo.sentinel != null);
30203020

@@ -3046,13 +3046,13 @@ pub const Lua = opaque {
30463046
/// tagged unions, optionals, and strings
30473047
pub fn pushAny(lua: *Lua, value: anytype) !void {
30483048
switch (@typeInfo(@TypeOf(value))) {
3049-
.Int, .ComptimeInt => {
3049+
.int, .comptime_int => {
30503050
lua.pushInteger(@intCast(value));
30513051
},
3052-
.Float, .ComptimeFloat => {
3052+
.float, .comptime_float => {
30533053
lua.pushNumber(@floatCast(value));
30543054
},
3055-
.Pointer => |info| {
3055+
.pointer => |info| {
30563056
if (comptime isTypeString(info)) {
30573057
try lua.pushAnyString(value);
30583058
} else switch (info.size) {
@@ -3074,39 +3074,39 @@ pub const Lua = opaque {
30743074
},
30753075
}
30763076
},
3077-
.Array => {
3077+
.array => {
30783078
lua.createTable(0, 0);
30793079
for (value, 0..) |index_value, i| {
30803080
try lua.pushAny(i + 1);
30813081
try lua.pushAny(index_value);
30823082
lua.setTable(-3);
30833083
}
30843084
},
3085-
.Vector => |info| {
3085+
.vector => |info| {
30863086
try lua.pushAny(@as([info.len]info.child, value));
30873087
},
3088-
.Bool => {
3088+
.bool => {
30893089
lua.pushBoolean(value);
30903090
},
3091-
.Enum => {
3091+
.@"enum" => {
30923092
_ = lua.pushStringZ(@tagName(value));
30933093
},
3094-
.Optional, .Null => {
3094+
.optional, .null => {
30953095
if (value == null) {
30963096
lua.pushNil();
30973097
} else {
30983098
try lua.pushAny(value.?);
30993099
}
31003100
},
3101-
.Struct => |info| {
3101+
.@"struct" => |info| {
31023102
lua.createTable(0, 0);
31033103
inline for (info.fields) |field| {
31043104
try lua.pushAny(field.name);
31053105
try lua.pushAny(@field(value, field.name));
31063106
lua.setTable(-3);
31073107
}
31083108
},
3109-
.Union => |info| {
3109+
.@"union" => |info| {
31103110
if (info.tag_type == null) @compileError("Parameter type is not a tagged union");
31113111
lua.createTable(0, 0);
31123112
errdefer lua.pop(1);
@@ -3119,10 +3119,10 @@ pub const Lua = opaque {
31193119
}
31203120
lua.setTable(-3);
31213121
},
3122-
.Fn => {
3122+
.@"fn" => {
31233123
lua.autoPushFunction(value);
31243124
},
3125-
.Void => {
3125+
.void => {
31263126
lua.createTable(0, 0);
31273127
},
31283128
else => {
@@ -3171,15 +3171,15 @@ pub const Lua = opaque {
31713171
}
31723172

31733173
switch (@typeInfo(T)) {
3174-
.Int => {
3174+
.int => {
31753175
const result = try lua.toInteger(index);
31763176
return @as(T, @intCast(result));
31773177
},
3178-
.Float => {
3178+
.float => {
31793179
const result = try lua.toNumber(index);
31803180
return @as(T, @floatCast(result));
31813181
},
3182-
.Array, .Vector => {
3182+
.array, .vector => {
31833183
const child = std.meta.Child(T);
31843184
const arr_len = switch (@typeInfo(T)) {
31853185
inline else => |i| i.len,
@@ -3201,7 +3201,7 @@ pub const Lua = opaque {
32013201
}
32023202
return result;
32033203
},
3204-
.Pointer => |info| {
3204+
.pointer => |info| {
32053205
if (comptime isTypeString(info)) {
32063206
const string: [*:0]const u8 = try lua.toString(index);
32073207
const end = std.mem.indexOfSentinel(u8, 0, string);
@@ -3231,10 +3231,10 @@ pub const Lua = opaque {
32313231
},
32323232
}
32333233
},
3234-
.Bool => {
3234+
.bool => {
32353235
return lua.toBoolean(index);
32363236
},
3237-
.Enum => |info| {
3237+
.@"enum" => |info| {
32383238
const string = try lua.toAnyInternal([]const u8, a, allow_alloc, index);
32393239
inline for (info.fields) |enum_member| {
32403240
if (std.mem.eql(u8, string, enum_member.name)) {
@@ -3243,10 +3243,10 @@ pub const Lua = opaque {
32433243
}
32443244
return error.InvalidEnumTagName;
32453245
},
3246-
.Struct => {
3246+
.@"struct" => {
32473247
return try lua.toStruct(T, a, allow_alloc, index);
32483248
},
3249-
.Union => |u| {
3249+
.@"union" => |u| {
32503250
if (u.tag_type == null) @compileError("Parameter type is not a tagged union");
32513251
if (!lua.isTable(index)) return error.ValueIsNotATable;
32523252

@@ -3265,14 +3265,14 @@ pub const Lua = opaque {
32653265
}
32663266
return error.TableIsEmpty;
32673267
},
3268-
.Optional => {
3268+
.optional => {
32693269
if (lua.isNil(index)) {
32703270
return null;
32713271
} else {
3272-
return try lua.toAnyInternal(@typeInfo(T).Optional.child, a, allow_alloc, index);
3272+
return try lua.toAnyInternal(@typeInfo(T).optional.child, a, allow_alloc, index);
32733273
}
32743274
},
3275-
.Void => {
3275+
.void => {
32763276
if (!lua.isTable(index)) return error.ValueIsNotATable;
32773277
lua.pushValue(index);
32783278
defer lua.pop(1);
@@ -3323,7 +3323,7 @@ pub const Lua = opaque {
33233323

33243324
var result: T = undefined;
33253325

3326-
inline for (@typeInfo(T).Struct.fields) |field| {
3326+
inline for (@typeInfo(T).@"struct".fields) |field| {
33273327
const field_type_info = comptime @typeInfo(field.type);
33283328
const field_name = comptime field.name ++ "";
33293329
_ = lua.pushStringZ(field_name);
@@ -3333,7 +3333,7 @@ pub const Lua = opaque {
33333333
if (lua_field_type == .nil) {
33343334
if (field.default_value) |default_value| {
33353335
@field(result, field.name) = @as(*const field.type, @ptrCast(@alignCast(default_value))).*;
3336-
} else if (field_type_info != .Optional) {
3336+
} else if (field_type_info != .optional) {
33373337
return error.LuaTableMissingValue;
33383338
}
33393339
} else {
@@ -3377,7 +3377,7 @@ pub const Lua = opaque {
33773377
//automatically generates a wrapper function
33783378
fn GenerateInterface(comptime function: anytype) type {
33793379
const info = @typeInfo(@TypeOf(function));
3380-
if (info != .Fn) {
3380+
if (info != .@"fn") {
33813381
@compileLog(info);
33823382
@compileLog(function);
33833383
@compileError("function pointer must be passed");
@@ -3386,10 +3386,10 @@ pub const Lua = opaque {
33863386
pub fn interface(lua: *Lua) i32 {
33873387
var parameters: std.meta.ArgsTuple(@TypeOf(function)) = undefined;
33883388

3389-
inline for (info.Fn.params, 0..) |param, i| {
3389+
inline for (info.@"fn".params, 0..) |param, i| {
33903390
const param_info = @typeInfo(param.type.?);
33913391
//only use the overhead of creating the arena allocator if needed
3392-
if (comptime param_info == .Pointer and param_info.Pointer.size != .One) {
3392+
if (comptime param_info == .pointer and param_info.pointer.size != .One) {
33933393
const parsed = lua.toAnyAlloc(param.type.?, (i + 1)) catch |err| {
33943394
lua.raiseErrorStr(@errorName(err), .{});
33953395
};
@@ -3406,7 +3406,7 @@ pub const Lua = opaque {
34063406
}
34073407
}
34083408

3409-
if (@typeInfo(info.Fn.return_type.?) == .ErrorUnion) {
3409+
if (@typeInfo(info.@"fn".return_type.?) == .error_union) {
34103410
const result = @call(.auto, function, parameters) catch |err| {
34113411
lua.raiseErrorStr(@errorName(err), .{});
34123412
};

0 commit comments

Comments
 (0)