Skip to content

Commit

Permalink
update zig, new for syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Feb 28, 2023
1 parent ff405f6 commit a7e24cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/object.zig
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub const Object = struct {
const argsInfo = @typeInfo(@TypeOf(args)).Struct;
assert(argsInfo.is_tuple);
var js_args: [argsInfo.fields.len]js.Value = undefined;
inline for (argsInfo.fields) |field, i| {
inline for (argsInfo.fields, 0..) |field, i| {
js_args[i] = switch (field.type) {
js.Object => @field(args, field.name).value,
else => js.Value.init(@field(args, field.name)),
Expand All @@ -91,7 +91,7 @@ pub const Object = struct {

// We need to free all the arguments given to use that weren't
// already js.Objects. If they were, its up to the caller to free.
defer inline for (argsInfo.fields) |field, i| {
defer inline for (argsInfo.fields, 0..) |field, i| {
if (field.type != js.Object) js_args[i].deinit();
};

Expand All @@ -112,7 +112,7 @@ pub const Object = struct {
const argsInfo = @typeInfo(@TypeOf(args)).Struct;
assert(argsInfo.is_tuple);
var js_args: [argsInfo.fields.len]js.Value = undefined;
inline for (argsInfo.fields) |field, i| {
inline for (argsInfo.fields, 0..) |field, i| {
js_args[i] = switch (field.type) {
js.Object => @field(args, field.name).value,
else => js.Value.init(@field(args, field.name)),
Expand All @@ -121,7 +121,7 @@ pub const Object = struct {

// We need to free all the arguments given to use that weren't
// already js.Objects. If they were, its up to the caller to free.
defer inline for (argsInfo.fields) |field, i| {
defer inline for (argsInfo.fields, 0..) |field, i| {
if (field.type != js.Object) js_args[i].deinit();
};

Expand Down
8 changes: 4 additions & 4 deletions src/value.zig
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ pub const Value = enum(u64) {
// for the ZigJS JS class. This makes it possible to access the memory
// for example.
nan = @bitCast(u64, js.Ref.nan),
null = @bitCast(u64, js.Ref.@"null"),
true = @bitCast(u64, js.Ref.@"true"),
false = @bitCast(u64, js.Ref.@"false"),
undefined = @bitCast(u64, js.Ref.@"undefined"),
null = @bitCast(u64, js.Ref.null),
true = @bitCast(u64, js.Ref.true),
false = @bitCast(u64, js.Ref.false),
undefined = @bitCast(u64, js.Ref.undefined),
global = @bitCast(u64, js.Ref.global),
runtime = @bitCast(u64, js.Ref.runtime),

Expand Down

0 comments on commit a7e24cd

Please sign in to comment.