2
0
Эх сурвалжийг харах

Convert all uses of `*_from_slice` to `*_from_bytes` where appropriate

gingerBill 3 жил өмнө
parent
commit
33895b6d92

+ 2 - 1
core/bytes/bytes.odin

@@ -16,7 +16,8 @@ clone_safe :: proc(s: []byte, allocator := context.allocator, loc := #caller_loc
 	return c[:len(s)], nil
 }
 
-ptr_from_slice :: proc(str: []byte) -> ^byte {
+ptr_from_slice :: ptr_from_bytes
+ptr_from_bytes :: proc(str: []byte) -> ^byte {
 	d := transmute(mem.Raw_String)str
 	return d.data
 }

+ 3 - 3
core/fmt/fmt.odin

@@ -119,17 +119,17 @@ tprintf :: proc(fmt: string, args: ..any) -> string {
 
 // bprint procedures return a string using a buffer from an array
 bprint :: proc(buf: []byte, args: ..any, sep := " ") -> string {
-	sb := strings.builder_from_slice(buf[0:len(buf)])
+	sb := strings.builder_from_bytes(buf[0:len(buf)])
 	return sbprint(buf=&sb, args=args, sep=sep)
 }
 // bprintln procedures return a string using a buffer from an array
 bprintln :: proc(buf: []byte, args: ..any, sep := " ") -> string {
-	sb := strings.builder_from_slice(buf[0:len(buf)])
+	sb := strings.builder_from_bytes(buf[0:len(buf)])
 	return sbprintln(buf=&sb, args=args, sep=sep)
 }
 // bprintf procedures return a string using a buffer from an array
 bprintf :: proc(buf: []byte, fmt: string, args: ..any) -> string {
-	sb := strings.builder_from_slice(buf[0:len(buf)])
+	sb := strings.builder_from_bytes(buf[0:len(buf)])
 	return sbprintf(&sb, fmt, ..args)
 }
 

+ 1 - 1
core/log/file_console_logger.odin

@@ -67,7 +67,7 @@ file_console_logger_proc :: proc(logger_data: rawptr, level: Level, text: string
 		h = data.file_handle
 	}
 	backing: [1024]byte //NOTE(Hoej): 1024 might be too much for a header backing, unless somebody has really long paths.
-	buf := strings.builder_from_slice(backing[:])
+	buf := strings.builder_from_bytes(backing[:])
 
 	do_level_header(options, level, &buf)
 

+ 12 - 9
core/os/os2/file.odin

@@ -34,17 +34,20 @@ File_Flag :: enum {
 	Trunc,
 	Sparse,
 	Close_On_Exec,
+
+	Unbuffered_IO,
 }
 
-O_RDONLY :: File_Flags{.Read}
-O_WRONLY :: File_Flags{.Write}
-O_RDWR   :: File_Flags{.Read, .Write}
-O_APPEND :: File_Flags{.Append}
-O_CREATE :: File_Flags{.Create}
-O_EXCL   :: File_Flags{.Excl}
-O_SYNC   :: File_Flags{.Sync}
-O_TRUNC  :: File_Flags{.Trunc}
-O_SPARSE :: File_Flags{.Sparse}
+O_RDONLY  :: File_Flags{.Read}
+O_WRONLY  :: File_Flags{.Write}
+O_RDWR    :: File_Flags{.Read, .Write}
+O_APPEND  :: File_Flags{.Append}
+O_CREATE  :: File_Flags{.Create}
+O_EXCL    :: File_Flags{.Excl}
+O_SYNC    :: File_Flags{.Sync}
+O_TRUNC   :: File_Flags{.Trunc}
+O_SPARSE  :: File_Flags{.Sparse}
+O_CLOEXEC :: File_Flags{.Close_On_Exec}
 
 
 

+ 3 - 2
core/strings/builder.odin

@@ -124,11 +124,11 @@ reset_builder :: proc(b: ^Builder) {
 	used in `fmt.bprint*`
 	
 	bytes: [8]byte // <-- gets filled
-	builder := strings.builder_from_slice(bytes[:])
+	builder := strings.builder_from_bytes(bytes[:])
 	strings.write_byte(&builder, 'a') -> "a"
 	strings.write_byte(&builder, 'b') -> "ab"
 */
-builder_from_slice :: proc(backing: []byte) -> Builder {
+builder_from_bytes :: proc(backing: []byte) -> Builder {
 	s := transmute(mem.Raw_Slice)backing
 	d := mem.Raw_Dynamic_Array{
 		data = s.data,
@@ -140,6 +140,7 @@ builder_from_slice :: proc(backing: []byte) -> Builder {
 		buf = transmute([dynamic]byte)d,
 	}
 }
+builder_from_slice :: builder_from_bytes
 
 // cast the builder byte buffer to a string and return it
 to_string :: proc(b: Builder) -> string {

+ 1 - 1
core/sys/darwin/xnu_system_call_wrappers.odin

@@ -402,7 +402,7 @@ syscall_openat :: #force_inline proc(fd: int, path: cstring, oflag: u32, mode: u
 	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.openat), uintptr(fd), transmute(uintptr)path, uintptr(oflag), uintptr(mode))
 } 
 
-syscall_getentropy :: #force_inline proc(buf: ^u8, buflen: u64) -> c.int {
+syscall_getentropy :: #force_inline proc(buf: [^]u8, buflen: u64) -> c.int {
 	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(buf), uintptr(buflen))
 }
 

+ 1 - 1
core/sys/unix/syscalls_linux.odin

@@ -1522,6 +1522,6 @@ sys_gettid :: proc "contextless" () -> int {
 	return cast(int)intrinsics.syscall(SYS_gettid)
 }
 
-sys_getrandom :: proc "contextless" (buf: ^byte, buflen: int, flags: uint) -> int {
+sys_getrandom :: proc "contextless" (buf: [^]byte, buflen: int, flags: uint) -> int {
 	return cast(int)intrinsics.syscall(SYS_getrandom, buf, cast(uintptr)(buflen), cast(uintptr)(flags))
 }

+ 1 - 1
core/sys/windows/bcrypt.odin

@@ -7,5 +7,5 @@ BCRYPT_USE_SYSTEM_PREFERRED_RNG: DWORD : 0x00000002
 
 @(default_calling_convention="stdcall")
 foreign bcrypt {
-	BCryptGenRandom :: proc(hAlgorithm: LPVOID, pBuffer: ^u8, cbBuffer: ULONG, dwFlags: ULONG) -> LONG ---
+	BCryptGenRandom :: proc(hAlgorithm: LPVOID, pBuffer: [^]u8, cbBuffer: ULONG, dwFlags: ULONG) -> LONG ---
 }

+ 3 - 3
core/text/i18n/gettext.odin

@@ -18,7 +18,7 @@ import "core:os"
 import "core:strings"
 import "core:bytes"
 
-parse_mo_from_slice :: proc(data: []u8, options := DEFAULT_PARSE_OPTIONS, pluralizer: proc(int) -> int = nil, allocator := context.allocator) -> (translation: ^Translation, err: Error) {
+parse_mo_from_bytes :: proc(data: []byte, options := DEFAULT_PARSE_OPTIONS, pluralizer: proc(int) -> int = nil, allocator := context.allocator) -> (translation: ^Translation, err: Error) {
 	context.allocator = allocator
 	/*
 		An MO file should have at least a 4-byte magic, 2 x 2 byte version info,
@@ -126,10 +126,10 @@ parse_mo_file :: proc(filename: string, options := DEFAULT_PARSE_OPTIONS, plural
 
 	if !data_ok { return {}, .File_Error }
 
-	return parse_mo_from_slice(data, options, pluralizer, allocator)
+	return parse_mo_from_bytes(data, options, pluralizer, allocator)
 }
 
-parse_mo :: proc { parse_mo_file, parse_mo_from_slice }
+parse_mo :: proc { parse_mo_file, parse_mo_from_bytes }
 
 /*
 	Helpers.

+ 3 - 3
core/text/i18n/qt_linguist.odin

@@ -27,7 +27,7 @@ TS_XML_Options := xml.Options{
 	expected_doctype = "TS",
 }
 
-parse_qt_linguist_from_slice :: proc(data: []u8, options := DEFAULT_PARSE_OPTIONS, pluralizer: proc(int) -> int = nil, allocator := context.allocator) -> (translation: ^Translation, err: Error) {
+parse_qt_linguist_from_bytes :: proc(data: []byte, options := DEFAULT_PARSE_OPTIONS, pluralizer: proc(int) -> int = nil, allocator := context.allocator) -> (translation: ^Translation, err: Error) {
 	context.allocator = allocator
 
 	ts, xml_err := xml.parse(data, TS_XML_Options)
@@ -150,7 +150,7 @@ parse_qt_linguist_file :: proc(filename: string, options := DEFAULT_PARSE_OPTION
 
 	if !data_ok { return {}, .File_Error }
 
-	return parse_qt_linguist_from_slice(data, options, pluralizer, allocator)
+	return parse_qt_linguist_from_bytes(data, options, pluralizer, allocator)
 }
 
-parse_qt :: proc { parse_qt_linguist_file, parse_qt_linguist_from_slice }
+parse_qt :: proc { parse_qt_linguist_file, parse_qt_linguist_from_bytes }

+ 1 - 1
vendor/microui/microui.odin

@@ -309,7 +309,7 @@ init :: proc(ctx: ^Context) {
 	ctx.draw_frame  = default_draw_frame
 	ctx._style      = default_style
 	ctx.style       = &ctx._style
-	ctx.text_input  = strings.builder_from_slice(ctx._text_store[:])
+	ctx.text_input  = strings.builder_from_bytes(ctx._text_store[:])
 }
 
 begin :: proc(ctx: ^Context) {