mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
More style improvements
This commit is contained in:
@@ -78,7 +78,7 @@ _Context :: struct {
|
|||||||
|
|
||||||
@(private="package")
|
@(private="package")
|
||||||
_init :: proc(ctx: ^Context) -> (ok: bool) {
|
_init :: proc(ctx: ^Context) -> (ok: bool) {
|
||||||
defer if !ok do destroy(ctx)
|
defer if !ok { destroy(ctx) }
|
||||||
|
|
||||||
ctx.impl.state = backtrace_create_state("odin-debug-trace", 1, nil, ctx)
|
ctx.impl.state = backtrace_create_state("odin-debug-trace", 1, nil, ctx)
|
||||||
return ctx.impl.state != nil
|
return ctx.impl.state != nil
|
||||||
|
|||||||
@@ -274,8 +274,7 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca
|
|||||||
.Linger,
|
.Linger,
|
||||||
.Send_Timeout,
|
.Send_Timeout,
|
||||||
.Receive_Timeout:
|
.Receive_Timeout:
|
||||||
t, ok := value.(time.Duration)
|
t := value.(time.Duration) or_else panic("set_option() value must be a time.Duration here", loc)
|
||||||
if !ok do panic("set_option() value must be a time.Duration here", loc)
|
|
||||||
|
|
||||||
micros := i64(time.duration_microseconds(t))
|
micros := i64(time.duration_microseconds(t))
|
||||||
timeval_value.microseconds = int(micros % 1e6)
|
timeval_value.microseconds = int(micros % 1e6)
|
||||||
|
|||||||
@@ -263,12 +263,15 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca
|
|||||||
ptr = &bool_value
|
ptr = &bool_value
|
||||||
len = size_of(bool_value)
|
len = size_of(bool_value)
|
||||||
case .Linger:
|
case .Linger:
|
||||||
t, ok := value.(time.Duration)
|
t := value.(time.Duration) or_else panic("set_option() value must be a time.Duration here", loc)
|
||||||
if !ok do panic("set_option() value must be a time.Duration here", loc)
|
|
||||||
|
|
||||||
num_secs := i64(time.duration_seconds(t))
|
num_secs := i64(time.duration_seconds(t))
|
||||||
if time.Duration(num_secs * 1e9) != t do return .Linger_Only_Supports_Whole_Seconds
|
if time.Duration(num_secs * 1e9) != t {
|
||||||
if num_secs > i64(max(u16)) do return .Value_Out_Of_Range
|
return .Linger_Only_Supports_Whole_Seconds
|
||||||
|
}
|
||||||
|
if num_secs > i64(max(u16)) {
|
||||||
|
return .Value_Out_Of_Range
|
||||||
|
}
|
||||||
linger_value.l_onoff = 1
|
linger_value.l_onoff = 1
|
||||||
linger_value.l_linger = c.ushort(num_secs)
|
linger_value.l_linger = c.ushort(num_secs)
|
||||||
|
|
||||||
@@ -277,8 +280,7 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca
|
|||||||
case
|
case
|
||||||
.Receive_Timeout,
|
.Receive_Timeout,
|
||||||
.Send_Timeout:
|
.Send_Timeout:
|
||||||
t, ok := value.(time.Duration)
|
t := value.(time.Duration) or_else panic("set_option() value must be a time.Duration here", loc)
|
||||||
if !ok do panic("set_option() value must be a time.Duration here", loc)
|
|
||||||
|
|
||||||
int_value = i32(time.duration_milliseconds(t))
|
int_value = i32(time.duration_milliseconds(t))
|
||||||
ptr = &int_value
|
ptr = &int_value
|
||||||
|
|||||||
@@ -705,7 +705,9 @@ set_current_directory :: proc(path: string) -> (err: Errno) {
|
|||||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||||
cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
||||||
res := _unix_chdir(cstr)
|
res := _unix_chdir(cstr)
|
||||||
if res == -1 do return Errno(get_last_error())
|
if res == -1 {
|
||||||
|
return Errno(get_last_error())
|
||||||
|
}
|
||||||
return ERROR_NONE
|
return ERROR_NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -743,7 +745,9 @@ get_page_size :: proc() -> int {
|
|||||||
// NOTE(tetra): The page size never changes, so why do anything complicated
|
// NOTE(tetra): The page size never changes, so why do anything complicated
|
||||||
// if we don't have to.
|
// if we don't have to.
|
||||||
@static page_size := -1
|
@static page_size := -1
|
||||||
if page_size != -1 do return page_size
|
if page_size != -1 {
|
||||||
|
return page_size
|
||||||
|
}
|
||||||
|
|
||||||
page_size = int(_unix_getpagesize())
|
page_size = int(_unix_getpagesize())
|
||||||
return page_size
|
return page_size
|
||||||
|
|||||||
@@ -714,7 +714,9 @@ set_current_directory :: proc(path: string) -> (err: Errno) {
|
|||||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||||
cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
||||||
res := _unix_chdir(cstr)
|
res := _unix_chdir(cstr)
|
||||||
if res == -1 do return Errno(get_last_error())
|
if res == -1 {
|
||||||
|
return Errno(get_last_error())
|
||||||
|
}
|
||||||
return ERROR_NONE
|
return ERROR_NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -755,7 +757,9 @@ get_page_size :: proc() -> int {
|
|||||||
// NOTE(tetra): The page size never changes, so why do anything complicated
|
// NOTE(tetra): The page size never changes, so why do anything complicated
|
||||||
// if we don't have to.
|
// if we don't have to.
|
||||||
@static page_size := -1
|
@static page_size := -1
|
||||||
if page_size != -1 do return page_size
|
if page_size != -1 {
|
||||||
|
return page_size
|
||||||
|
}
|
||||||
|
|
||||||
page_size = int(_unix_getpagesize())
|
page_size = int(_unix_getpagesize())
|
||||||
return page_size
|
return page_size
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ StringCopyToOdinString :: proc(
|
|||||||
max := StringGetMaximumSizeForEncoding(length, StringEncoding(StringBuiltInEncodings.UTF8))
|
max := StringGetMaximumSizeForEncoding(length, StringEncoding(StringBuiltInEncodings.UTF8))
|
||||||
|
|
||||||
buf, err := make([]byte, max, allocator)
|
buf, err := make([]byte, max, allocator)
|
||||||
if err != nil do return
|
if err != nil { return }
|
||||||
|
|
||||||
raw_str := runtime.Raw_String {
|
raw_str := runtime.Raw_String {
|
||||||
data = raw_data(buf),
|
data = raw_data(buf),
|
||||||
|
|||||||
Vendored
+3
-1
@@ -39,7 +39,9 @@ foreign WinSock2 {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.fd_count >= FD_SETSIZE do return
|
if s.fd_count >= FD_SETSIZE {
|
||||||
|
return
|
||||||
|
}
|
||||||
s.fd_array[s.fd_count] = fd
|
s.fd_array[s.fd_count] = fd
|
||||||
s.fd_count += 1
|
s.fd_count += 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user