summaryrefslogtreecommitdiff
path: root/src/core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/core.zig')
-rw-r--r--src/core.zig26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/core.zig b/src/core.zig
index f2e1fe0..d870e8c 100644
--- a/src/core.zig
+++ b/src/core.zig
@@ -99,7 +99,7 @@ pub fn Param(comptime Id: type) type {
99 takes_value: bool, 99 takes_value: bool,
100 names: Names, 100 names: Names,
101 101
102 pub fn init(id: Id, takes_value: bool, names: &const Names) Self { 102 pub fn init(id: Id, takes_value: bool, names: *const Names) Self {
103 // Assert, that if the param have no name, then it has to take 103 // Assert, that if the param have no name, then it has to take
104 // a value. 104 // a value.
105 debug.assert( 105 debug.assert(
@@ -123,10 +123,10 @@ pub fn Arg(comptime Id: type) type {
123 return struct { 123 return struct {
124 const Self = this; 124 const Self = this;
125 125
126 param: &const Param(Id), 126 param: *const Param(Id),
127 value: ?[]const u8, 127 value: ?[]const u8,
128 128
129 pub fn init(param: &const Param(Id), value: ?[]const u8) Self { 129 pub fn init(param: *const Param(Id), value: ?[]const u8) Self {
130 return Self { 130 return Self {
131 .param = param, 131 .param = param,
132 .value = value, 132 .value = value,
@@ -141,9 +141,9 @@ pub fn ArgIterator(comptime E: type) type {
141 const Self = this; 141 const Self = this;
142 const Error = E; 142 const Error = E;
143 143
144 nextFn: fn(iter: &Self) Error!?[]const u8, 144 nextFn: fn(iter: *Self) Error!?[]const u8,
145 145
146 pub fn next(iter: &Self) Error!?[]const u8 { 146 pub fn next(iter: *Self) Error!?[]const u8 {
147 return iter.nextFn(iter); 147 return iter.nextFn(iter);
148 } 148 }
149 }; 149 };
@@ -168,7 +168,7 @@ pub const ArgSliceIterator = struct {
168 }; 168 };
169 } 169 }
170 170
171 fn nextFn(iter: &ArgIterator(Error)) Error!?[]const u8 { 171 fn nextFn(iter: *ArgIterator(Error)) Error!?[]const u8 {
172 const self = @fieldParentPtr(ArgSliceIterator, "iter", iter); 172 const self = @fieldParentPtr(ArgSliceIterator, "iter", iter);
173 if (self.args.len <= self.index) 173 if (self.args.len <= self.index)
174 return null; 174 return null;
@@ -187,7 +187,7 @@ pub const OsArgIterator = struct {
187 args: os.ArgIterator, 187 args: os.ArgIterator,
188 iter: ArgIterator(Error), 188 iter: ArgIterator(Error),
189 189
190 pub fn init(allocator: &mem.Allocator) OsArgIterator { 190 pub fn init(allocator: *mem.Allocator) OsArgIterator {
191 return OsArgIterator { 191 return OsArgIterator {
192 .arena = heap.ArenaAllocator.init(allocator), 192 .arena = heap.ArenaAllocator.init(allocator),
193 .args = os.args(), 193 .args = os.args(),
@@ -197,11 +197,11 @@ pub const OsArgIterator = struct {
197 }; 197 };
198 } 198 }
199 199
200 pub fn deinit(iter: &OsArgIterator) void { 200 pub fn deinit(iter: *OsArgIterator) void {
201 iter.arena.deinit(); 201 iter.arena.deinit();
202 } 202 }
203 203
204 fn nextFn(iter: &ArgIterator(Error)) Error!?[]const u8 { 204 fn nextFn(iter: *ArgIterator(Error)) Error!?[]const u8 {
205 const self = @fieldParentPtr(OsArgIterator, "iter", iter); 205 const self = @fieldParentPtr(OsArgIterator, "iter", iter);
206 if (builtin.os == builtin.Os.windows) { 206 if (builtin.os == builtin.Os.windows) {
207 return try self.args.next(self.allocator) ?? return null; 207 return try self.args.next(self.allocator) ?? return null;
@@ -229,10 +229,10 @@ pub fn Clap(comptime Id: type, comptime ArgError: type) type {
229 }; 229 };
230 230
231 params: []const Param(Id), 231 params: []const Param(Id),
232 iter: &ArgIterator(ArgError), 232 iter: *ArgIterator(ArgError),
233 state: State, 233 state: State,
234 234
235 pub fn init(params: []const Param(Id), iter: &ArgIterator(ArgError)) Self { 235 pub fn init(params: []const Param(Id), iter: *ArgIterator(ArgError)) Self {
236 var res = Self { 236 var res = Self {
237 .params = params, 237 .params = params,
238 .iter = iter, 238 .iter = iter,
@@ -243,7 +243,7 @@ pub fn Clap(comptime Id: type, comptime ArgError: type) type {
243 } 243 }
244 244
245 /// Get the next ::Arg that matches a ::Param. 245 /// Get the next ::Arg that matches a ::Param.
246 pub fn next(clap: &Self) !?Arg(Id) { 246 pub fn next(clap: *Self) !?Arg(Id) {
247 const ArgInfo = struct { 247 const ArgInfo = struct {
248 const Kind = enum { Long, Short, Bare }; 248 const Kind = enum { Long, Short, Bare };
249 249
@@ -334,7 +334,7 @@ pub fn Clap(comptime Id: type, comptime ArgError: type) type {
334 } 334 }
335 } 335 }
336 336
337 fn chainging(clap: &Self, state: &const State.Chaining) !?Arg(Id) { 337 fn chainging(clap: *Self, state: *const State.Chaining) !?Arg(Id) {
338 const arg = state.arg; 338 const arg = state.arg;
339 const index = state.index; 339 const index = state.index;
340 const next_index = index + 1; 340 const next_index = index + 1;