chore: changes for lang.Type
This commit is contained in:
parent
2cb7b2709d
commit
eeac7a08b6
2 changed files with 13 additions and 13 deletions
|
|
@ -14,8 +14,8 @@
|
||||||
.lazy = true,
|
.lazy = true,
|
||||||
},
|
},
|
||||||
.build_crab = .{
|
.build_crab = .{
|
||||||
.url = "git+https://github.com/nurulhudaapon/build.crab?ref=zig-dev#fd666880b60cd9b209459a6966689113978aaf03",
|
.url = "git+https://github.com/nurulhudaapon/build.crab?ref=zig-dev#69a630f8fa9ccca37a8ba2e898e7934e3b5b8fe2",
|
||||||
.hash = "build_crab-0.2.1-U0id_xnKAACLofQELmEzeT_mjjbHeCs9SfEoSg6nBBGC",
|
.hash = "build_crab-0.2.1-U0id_zfKAAAvOuam-kPYKMuEQpHuEBjrP96uQCVj94yr",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.paths = .{
|
.paths = .{
|
||||||
|
|
|
||||||
22
src/root.zig
22
src/root.zig
|
|
@ -526,10 +526,10 @@ fn assertDecls(comptime T: type, checks: anytype) !void {
|
||||||
var hasField = false;
|
var hasField = false;
|
||||||
if (typeInfo == .@"struct") {
|
if (typeInfo == .@"struct") {
|
||||||
const struct_info = typeInfo.@"struct";
|
const struct_info = typeInfo.@"struct";
|
||||||
inline for (struct_info.fields) |field| {
|
inline for (struct_info.field_names) |field_name| {
|
||||||
// Check both camelCase and snake_case
|
// Check both camelCase and snake_case
|
||||||
if (std.mem.eql(u8, field.name, check) or
|
if (std.mem.eql(u8, field_name, check) or
|
||||||
std.mem.eql(u8, field.name, camelToSnakeCase(check)))
|
std.mem.eql(u8, field_name, camelToSnakeCase(check)))
|
||||||
{
|
{
|
||||||
hasField = true;
|
hasField = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -548,39 +548,39 @@ fn assertDecls(comptime T: type, checks: anytype) !void {
|
||||||
const struct_info = typeInfo.@"struct";
|
const struct_info = typeInfo.@"struct";
|
||||||
|
|
||||||
// Check declarations
|
// Check declarations
|
||||||
inline for (struct_info.decls) |decl| {
|
inline for (struct_info.decl_names) |decl_name| {
|
||||||
// Allow deinit as extraneous
|
// Allow deinit as extraneous
|
||||||
if (comptime std.mem.eql(u8, decl.name, "deinit")) continue;
|
if (comptime std.mem.eql(u8, decl_name, "deinit")) continue;
|
||||||
|
|
||||||
var found = false;
|
var found = false;
|
||||||
inline for (checks) |check| {
|
inline for (checks) |check| {
|
||||||
if (std.mem.eql(u8, decl.name, check)) {
|
if (std.mem.eql(u8, decl_name, check)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
std.log.err("Extraneous {s} decl: {s}", .{ @typeName(T), decl.name });
|
std.log.err("Extraneous {s} decl: {s}", .{ @typeName(T), decl_name });
|
||||||
try std.testing.expect(false);
|
try std.testing.expect(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check fields (properties)
|
// Check fields (properties)
|
||||||
inline for (struct_info.fields) |field| {
|
inline for (struct_info.field_names) |field_name| {
|
||||||
// Allow internal fields (starting with underscore)
|
// Allow internal fields (starting with underscore)
|
||||||
if (comptime std.mem.startsWith(u8, field.name, "_")) continue;
|
if (comptime std.mem.startsWith(u8, field_name, "_")) continue;
|
||||||
|
|
||||||
var found = false;
|
var found = false;
|
||||||
inline for (checks) |check| {
|
inline for (checks) |check| {
|
||||||
if (std.mem.eql(u8, field.name, camelToSnakeCase(check))) {
|
if (std.mem.eql(u8, field_name, camelToSnakeCase(check))) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
std.log.err("Extraneous {s} field: {s}", .{ @typeName(T), field.name });
|
std.log.err("Extraneous {s} field: {s}", .{ @typeName(T), field_name });
|
||||||
try std.testing.expect(false);
|
try std.testing.expect(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue