authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-06-07 03:30:37 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-06-07 03:30:37 -07:00
log8c0bd9996d16c7a625eab9ce3ca93714802d472d
treeb380fef679232b2b045b82fb19984528377a6801
parentfcd70831ae5913e52ccc87149bcc99859eb0e81d

use const arrays everywhere for more immutability


5 files changed, 20 insertions(+), 20 deletions(-)

src/util/dep.zig+5-5
...@@ -18,11 +18,11 @@ pub const Dep = struct {...@@ -18,11 +18,11 @@ pub const Dep = struct {
18 name: []const u8,18 name: []const u8,
19 main: []const u8,19 main: []const u8,
20 version: []const u8,20 version: []const u8,
21 c_include_dirs: [][]const u8,21 c_include_dirs: []const []const u8,
22 c_source_flags: [][]const u8,22 c_source_flags: []const []const u8,
23 c_source_files: [][]const u8,23 c_source_files: []const []const u8,
24 only_os: [][]const u8,24 only_os: []const []const u8,
25 except_os: [][]const u8,25 except_os: []const []const u8,
26 yaml: ?yaml.Mapping,26 yaml: ?yaml.Mapping,
2727
28 pub fn clean_path(self: Dep) ![]const u8 {28 pub fn clean_path(self: Dep) ![]const u8 {
src/util/funcs.zig+1-1
...@@ -123,7 +123,7 @@ pub fn print_all(w: std.fs.File.Writer, items: anytype, ln: bool) !void {...@@ -123,7 +123,7 @@ pub fn print_all(w: std.fs.File.Writer, items: anytype, ln: bool) !void {
123 }123 }
124}124}
125125
126pub fn list_contains(haystack: [][]const u8, needle: []const u8) bool {126pub fn list_contains(haystack: []const []const u8, needle: []const u8) bool {
127 for (haystack) |item| {127 for (haystack) |item| {
128 if (std.mem.eql(u8, item, needle)) {128 if (std.mem.eql(u8, item, needle)) {
129 return true;129 return true;
src/util/modfile.zig+5-5
...@@ -17,14 +17,14 @@ pub const ModFile = struct {...@@ -17,14 +17,14 @@ pub const ModFile = struct {
17 id: []const u8,17 id: []const u8,
18 name: []const u8,18 name: []const u8,
19 main: []const u8,19 main: []const u8,
20 c_include_dirs: [][]const u8,20 c_include_dirs: []const []const u8,
21 c_source_flags: [][]const u8,21 c_source_flags: []const []const u8,
22 c_source_files: [][]const u8,22 c_source_files: []const []const u8,
23 deps: []const u.Dep,23 deps: []const u.Dep,
24 yaml: yaml.Mapping,24 yaml: yaml.Mapping,
25 devdeps: []const u.Dep,25 devdeps: []const u.Dep,
26 root_files: [][]const u8,26 root_files: []const []const u8,
27 files: [][]const u8,27 files: []const []const u8,
2828
29 pub fn init(alloc: *std.mem.Allocator, fpath: []const u8) !Self {29 pub fn init(alloc: *std.mem.Allocator, fpath: []const u8) !Self {
30 //30 //
src/util/module.zig+5-5
...@@ -13,11 +13,11 @@ pub const Module = struct {...@@ -13,11 +13,11 @@ pub const Module = struct {
13 id: []const u8,13 id: []const u8,
14 name: []const u8,14 name: []const u8,
15 main: []const u8,15 main: []const u8,
16 c_include_dirs: [][]const u8,16 c_include_dirs: []const []const u8,
17 c_source_flags: [][]const u8,17 c_source_flags: []const []const u8,
18 c_source_files: [][]const u8,18 c_source_files: []const []const u8,
19 only_os: [][]const u8,19 only_os: []const []const u8,
20 except_os: [][]const u8,20 except_os: []const []const u8,
21 yaml: ?yaml.Mapping,21 yaml: ?yaml.Mapping,
2222
23 deps: []Module,23 deps: []Module,
src/util/yaml.zig+4-4
...@@ -8,7 +8,7 @@ const u = @import("./index.zig");...@@ -8,7 +8,7 @@ const u = @import("./index.zig");
8//8//
9//9//
1010
11const Array = [][]const u8;11const Array = []const []const u8;
1212
13pub const Document = struct {13pub const Document = struct {
14 mapping: Mapping,14 mapping: Mapping,
...@@ -18,7 +18,7 @@ pub const Item = union(enum) {...@@ -18,7 +18,7 @@ pub const Item = union(enum) {
18 event: c.yaml_event_t,18 event: c.yaml_event_t,
19 kv: Key,19 kv: Key,
20 mapping: Mapping,20 mapping: Mapping,
21 sequence: []Item,21 sequence: []const Item,
22 document: Document,22 document: Document,
23 string: []const u8,23 string: []const u8,
2424
...@@ -54,7 +54,7 @@ pub const Key = struct {...@@ -54,7 +54,7 @@ pub const Key = struct {
54pub const Value = union(enum) {54pub const Value = union(enum) {
55 string: []const u8,55 string: []const u8,
56 mapping: Mapping,56 mapping: Mapping,
57 sequence: []Item,57 sequence: []const Item,
5858
59 pub fn format(self: Value, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) @TypeOf(writer).Error!void {59 pub fn format(self: Value, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) @TypeOf(writer).Error!void {
60 try writer.writeAll("Value{");60 try writer.writeAll("Value{");
...@@ -78,7 +78,7 @@ pub const Value = union(enum) {...@@ -78,7 +78,7 @@ pub const Value = union(enum) {
78};78};
7979
80pub const Mapping = struct {80pub const Mapping = struct {
81 items: []Key,81 items: []const Key,
8282
83 pub fn get(self: Mapping, k: []const u8) ?Value {83 pub fn get(self: Mapping, k: []const u8) ?Value {
84 for (self.items) |item| {84 for (self.items) |item| {