Fix fmt implementation for js

This commit is contained in:
gingerBill
2023-06-26 15:55:35 +01:00
parent c8f475174e
commit 6c6f9f7d25
+10 -13
View File
@@ -11,27 +11,24 @@ foreign odin_env {
} }
@(private="file") @(private="file")
write_vtable := io.Stream_VTable{ write_stream_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) {
impl_write = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { if mode == .Write {
fd := u32(uintptr(s.stream_data)) fd := u32(uintptr(stream_data))
write(fd, p) write(fd, p)
return len(p), nil return i64(len(p)), nil
}, }
return 0, .Empty
} }
@(private="file") @(private="file")
stdout := io.Writer{ stdout := io.Writer{
stream = { procedure = write_stream_proc,
stream_vtable = &write_vtable, data = rawptr(uintptr(1)),
stream_data = rawptr(uintptr(1)),
},
} }
@(private="file") @(private="file")
stderr := io.Writer{ stderr := io.Writer{
stream = { procedure = write_stream_proc,
stream_vtable = &write_vtable, data = rawptr(uintptr(2)),
stream_data = rawptr(uintptr(2)),
},
} }
// print formats using the default print settings and writes to stdout // print formats using the default print settings and writes to stdout