Clean up of the core library to make the stream vtables not be pointers directly.

This commit is contained in:
gingerBill
2022-09-15 10:00:50 +01:00
parent 1e595f2e26
commit f50fc33749
12 changed files with 45 additions and 33 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ import "core:io"
to_stream :: proc(f: ^File) -> (s: io.Stream) {
s.stream_data = f
s.stream_vtable = _file_stream_vtable
s.stream_vtable = &_file_stream_vtable
return
}
@@ -26,7 +26,7 @@ error_to_io_error :: proc(ferr: Error) -> io.Error {
@(private)
_file_stream_vtable := &io.Stream_VTable{
_file_stream_vtable := io.Stream_VTable{
impl_read = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) {
f := (^File)(s.stream_data)
ferr: Error
+2 -2
View File
@@ -5,13 +5,13 @@ import "core:io"
stream_from_handle :: proc(fd: Handle) -> io.Stream {
s: io.Stream
s.stream_data = rawptr(uintptr(fd))
s.stream_vtable = _file_stream_vtable
s.stream_vtable = &_file_stream_vtable
return s
}
@(private)
_file_stream_vtable := &io.Stream_VTable{
_file_stream_vtable := io.Stream_VTable{
impl_read = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) {
fd := Handle(uintptr(s.stream_data))
os_err: Errno