diff options
| author | gingerBill <bill@gingerbill.org> | 2020-12-02 23:17:21 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-12-02 23:17:21 +0000 |
| commit | c4172e391443a021e43ff55938b86637eec4e1d2 (patch) | |
| tree | 80e482dde07b3fc3ca821479a6350da8a133857b /core/strings | |
| parent | 8e08ae47fbe038b6b8415b3da7715936f4fd852c (diff) | |
Rename stream field names
Diffstat (limited to 'core/strings')
| -rw-r--r-- | core/strings/builder.odin | 18 | ||||
| -rw-r--r-- | core/strings/reader.odin | 22 |
2 files changed, 29 insertions, 11 deletions
diff --git a/core/strings/builder.odin b/core/strings/builder.odin index e5b93fb67..b31190215 100644 --- a/core/strings/builder.odin +++ b/core/strings/builder.odin @@ -32,6 +32,24 @@ make_builder :: proc{ make_builder_len_cap, }; +init_builder_none :: proc(b: ^Builder, allocator := context.allocator) { + b.buf = make([dynamic]byte, allocator); +} + +init_builder_len :: proc(b: ^Builder, len: int, allocator := context.allocator) { + b.buf = make([dynamic]byte, len, allocator); +} + +init_builder_len_cap :: proc(b: ^Builder, len, cap: int, allocator := context.allocator) { + b.buf = make([dynamic]byte, len, cap, allocator); +} + +init_builder :: proc{ + init_builder_none, + init_builder_len, + init_builder_len_cap, +}; + diff --git a/core/strings/reader.odin b/core/strings/reader.odin index 1dbfe9451..46256641f 100644 --- a/core/strings/reader.odin +++ b/core/strings/reader.odin @@ -11,7 +11,8 @@ Reader :: struct { } reader_reset :: proc(r: ^Reader, s: string) { - r.data = r; + r.stream_data = r; + r.stream_vtable = _reader_vtable; r.s = s; r.i = 0; r.prev_rune = -1; @@ -20,18 +21,17 @@ reader_reset :: proc(r: ^Reader, s: string) { new_reader :: proc(s: string, allocator := context.allocator) -> ^Reader { r := new(Reader, allocator); reader_reset(r, s); - r.vtable = _reader_vtable; return r; } @(private) _reader_vtable := &io.Stream_VTable{ impl_size = proc(s: io.Stream) -> i64 { - r := (^Reader)(s.data); + r := (^Reader)(s.stream_data); return i64(len(r.s)); }, impl_read = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - r := (^Reader)(s.data); + r := (^Reader)(s.stream_data); if r.i >= i64(len(r.s)) { return 0, .EOF; } @@ -41,7 +41,7 @@ _reader_vtable := &io.Stream_VTable{ return; }, impl_read_at = proc(s: io.Stream, p: []byte, off: i64) -> (n: int, err: io.Error) { - r := (^Reader)(s.data); + r := (^Reader)(s.stream_data); if off < 0 { return 0, .Invalid_Offset; } @@ -55,7 +55,7 @@ _reader_vtable := &io.Stream_VTable{ return; }, impl_read_byte = proc(s: io.Stream) -> (byte, io.Error) { - r := (^Reader)(s.data); + r := (^Reader)(s.stream_data); r.prev_rune = -1; if r.i >= i64(len(r.s)) { return 0, .EOF; @@ -65,7 +65,7 @@ _reader_vtable := &io.Stream_VTable{ return b, nil; }, impl_unread_byte = proc(s: io.Stream) -> io.Error { - r := (^Reader)(s.data); + r := (^Reader)(s.stream_data); if r.i <= 0 { return .Invalid_Unread; } @@ -74,7 +74,7 @@ _reader_vtable := &io.Stream_VTable{ return nil; }, impl_read_rune = proc(s: io.Stream) -> (ch: rune, size: int, err: io.Error) { - r := (^Reader)(s.data); + r := (^Reader)(s.stream_data); if r.i >= i64(len(r.s)) { r.prev_rune = -1; return 0, 0, .EOF; @@ -89,7 +89,7 @@ _reader_vtable := &io.Stream_VTable{ return; }, impl_unread_rune = proc(s: io.Stream) -> io.Error { - r := (^Reader)(s.data); + r := (^Reader)(s.stream_data); if r.i <= 0 { return .Invalid_Unread; } @@ -101,7 +101,7 @@ _reader_vtable := &io.Stream_VTable{ return nil; }, impl_seek = proc(s: io.Stream, offset: i64, whence: io.Seek_From) -> (i64, io.Error) { - r := (^Reader)(s.data); + r := (^Reader)(s.stream_data); r.prev_rune = -1; abs: i64; switch whence { @@ -122,7 +122,7 @@ _reader_vtable := &io.Stream_VTable{ return abs, nil; }, impl_write_to = proc(s: io.Stream, w: io.Writer) -> (n: i64, err: io.Error) { - r := (^Reader)(s.data); + r := (^Reader)(s.stream_data); r.prev_rune = -1; if r.i >= i64(len(r.s)) { return 0, nil; |