diff --git a/code2/grime/assert.odin b/code2/grime/assert.odin index c96f61b..492523e 100644 --- a/code2/grime/assert.odin +++ b/code2/grime/assert.odin @@ -1,6 +1,6 @@ package grime -// Below should be defined per-package +// TODO(Ed): Below should be defined per-package? ensure :: #force_inline proc(condition: bool, msg: string, location := #caller_location) -> bool { if condition do return true diff --git a/code2/grime/filesystem.odin b/code2/grime/filesystem.odin index 7d323c3..0e8d60f 100644 --- a/code2/grime/filesystem.odin +++ b/code2/grime/filesystem.odin @@ -1,7 +1,7 @@ package grime // TODO(Ed): Review when os2 is done. -// TODO(Ed): Make an async option... +// TODO(Ed): Make an async option? file_copy_sync :: proc( path_src, path_dst: string, allocator := context.allocator ) -> b32 { file_size : i64 diff --git a/code2/grime/hashing.odin b/code2/grime/hashing.odin index ee8b88f..a705cd1 100644 --- a/code2/grime/hashing.odin +++ b/code2/grime/hashing.odin @@ -13,7 +13,7 @@ hash64_djb8 :: #force_inline proc "contextless" (hash: ^u64, bytes: []byte ) { hash32_fnv1a :: #force_inline proc "contextless" (hash: ^u32, data: []byte, seed := u32(0x811c9dc5)) { hash^ = seed; for b in data { hash^ = (hash^ ~ u32(b)) * 0x01000193 } } - +// Ripped from core:hash, fnv64a @(optimization_mode="favor_size") hash64_fnv1a :: #force_inline proc "contextless" (hash: ^u64, data: []byte, seed := u64(0xcbf29ce484222325)) { hash^ = seed; for b in data { hash^ = (hash^ ~ u64(b)) * 0x100000001b3 } diff --git a/code2/grime/key_table_inear.odin b/code2/grime/key_table_inear.odin index ecc6146..bee444a 100644 --- a/code2/grime/key_table_inear.odin +++ b/code2/grime/key_table_inear.odin @@ -18,14 +18,14 @@ KTL_Meta :: struct { type: typeid, } -ktl_get :: #force_inline proc(kt: []KTL_Slot($Type), key: u64) -> ^Type { +ktl_get :: #force_inline proc "contextless" (kt: []KTL_Slot($Type), key: u64) -> ^Type { for & slot in kt { if key == slot.key do return & slot.value; } return nil } // Unique populator for key-value pair strings -ktl_populate_slice_a2_str :: #force_inline proc (kt: ^[]KTL_Slot(string), backing: Odin_Allocator, values: [][2]string) { +ktl_populate_slice_a2_str :: #force_inline proc(kt: ^[]KTL_Slot(string), backing: Odin_Allocator, values: [][2]string) { assert(kt != nil) if len(values) == 0 { return } raw_bytes, error := mem_alloc(size_of(KTL_Slot(string)) * len(values), ainfo = backing); assert(error == .None); diff --git a/code2/grime/key_table_wip.odin b/code2/grime/key_table_wip.odin index e8c0d9b..6a4a42c 100644 --- a/code2/grime/key_table_wip.odin +++ b/code2/grime/key_table_wip.odin @@ -8,7 +8,7 @@ So it has been stripped and instead applied on procedure site, the parent container or is responsible for tracking that. TODO(Ed): Resolve appropriate Key-Table term for it. -TODO(Ed): Complete this later if we actually have issues with KT1CX or Odin's map. +TODO(Ed): Complete this later if we actually want something beyond KT1CX or Odin's map. */ KT_Slot :: struct( diff --git a/code2/grime/memory.odin b/code2/grime/memory.odin index f06d315..8f1f24c 100644 --- a/code2/grime/memory.odin +++ b/code2/grime/memory.odin @@ -73,8 +73,8 @@ slice_copy :: #force_inline proc "contextless" (dst, src: $SliceType / []$Type) slice_fill :: #force_inline proc "contextless" (s: $SliceType / []$Type, value: Type) { memory_fill(cursor(s), value, len(s)) } -@(require_results) slice_to_bytes :: #force_inline proc "contextless" (s: []$Type) -> []byte { return ([^]byte)(raw_data(s))[:len(s) * size_of(Type)] } -@(require_results) slice_raw :: #force_inline proc "contextless" (s: []$Type) -> SliceRaw(Type) { return transmute(SliceRaw(Type)) s } +@(require_results) slice_to_bytes :: #force_inline proc "contextless" (s: []$Type) -> []byte { return ([^]byte)(raw_data(s))[:len(s) * size_of(Type)] } +@(require_results) slice_raw :: #force_inline proc "contextless" (s: []$Type) -> SliceRaw(Type) { return transmute(SliceRaw(Type)) s } @(require_results) type_to_bytes :: #force_inline proc "contextless" (obj: ^$Type) -> []byte { return ([^]byte)(obj)[:size_of(Type)] } diff --git a/code2/grime/virtual_arena.odin b/code2/grime/virtual_arena.odin index 8e6918a..17379ff 100644 --- a/code2/grime/virtual_arena.odin +++ b/code2/grime/virtual_arena.odin @@ -268,7 +268,6 @@ varena_push_item :: #force_inline proc(va: ^VArena, $Type: typeid, alignment: in raw, error := varena_alloc(va, size_of(Type), alignment, should_zero, location) return transmute(^Type) cursor(raw), error } - varena_push_slice :: #force_inline proc(va: ^VArena, $Type: typeid, amount: int, alignment: int = MEMORY_ALIGNMENT_DEFAULT, should_zero := true, location := #caller_location ) -> ([]Type, AllocatorError) { raw, error := varena_alloc(va, size_of(Type) * amount, alignment, should_zero, location) diff --git a/code2/grime/virtual_chained_arena.odin b/code2/grime/virtual_chained_arena.odin index c0a7ef6..893c2af 100644 --- a/code2/grime/virtual_chained_arena.odin +++ b/code2/grime/virtual_chained_arena.odin @@ -92,8 +92,6 @@ arena_rewind :: proc(arena: ^Arena, save_point: AllocatorSP) { } arena_save :: #force_inline proc(arena: ^Arena) -> AllocatorSP { return { type_sig = arena_allocator_proc, slot = arena.base_pos + arena.current.pos } } - - arena_allocator_proc :: proc(input: AllocatorProc_In, output: ^AllocatorProc_Out) { panic("not implemented") } @@ -118,7 +116,11 @@ else { arena_allocator :: #force_inline proc "contextless" (arena: ^Arena) -> Odin_Allocator { return transmute(Odin_Allocator) AllocatorInfo{procedure = arena_allocator_proc, data = arena} } } -arena_push :: proc() +arena_push_item :: proc() +{ + +} +arena_push_array :: proc() { } diff --git a/code2/host/pkg_mappings.odin b/code2/host/pkg_mappings.odin index 4337ac1..6510571 100644 --- a/code2/host/pkg_mappings.odin +++ b/code2/host/pkg_mappings.odin @@ -83,6 +83,10 @@ import grime "codebase:grime" grime_set_profiler_module_context :: grime.set_profiler_module_context grime_set_profiler_thread_buffer :: grime.set_profiler_thread_buffer + ensure :: grime.ensure + fatal :: grime.fatal + verify :: grime.verify + file_is_locked :: grime.file_is_locked logger_init :: grime.logger_init to_odin_logger :: grime.to_odin_logger @@ -137,24 +141,24 @@ import "codebase:sectr" ThreadMemory :: sectr.ThreadMemory WorkerID :: sectr.WorkerID -ensure :: #force_inline proc( condition : b32, msg : string, location := #caller_location ) { - if condition do return - log_print( msg, LoggerLevel.Warning, location ) - debug_trap() -} -// TODO(Ed) : Setup exit codes! -fatal :: #force_inline proc( msg : string, exit_code : int = -1, location := #caller_location ) { - log_print( msg, LoggerLevel.Fatal, location ) - debug_trap() - process_exit( exit_code ) -} -// TODO(Ed) : Setup exit codes! -verify :: #force_inline proc( condition : b32, msg : string, exit_code : int = -1, location := #caller_location ) { - if condition do return - log_print( msg, LoggerLevel.Fatal, location ) - debug_trap() - process_exit( exit_code ) -} +// ensure :: #force_inline proc( condition : b32, msg : string, location := #caller_location ) { +// if condition do return +// log_print( msg, LoggerLevel.Warning, location ) +// debug_trap() +// } +// // TODO(Ed) : Setup exit codes! +// fatal :: #force_inline proc( msg : string, exit_code : int = -1, location := #caller_location ) { +// log_print( msg, LoggerLevel.Fatal, location ) +// debug_trap() +// process_exit( exit_code ) +// } +// // TODO(Ed) : Setup exit codes! +// verify :: #force_inline proc( condition : b32, msg : string, exit_code : int = -1, location := #caller_location ) { +// if condition do return +// log_print( msg, LoggerLevel.Fatal, location ) +// debug_trap() +// process_exit( exit_code ) +// } log_print :: proc( msg : string, level := LoggerLevel.Info, loc := #caller_location ) { context.allocator = arena_allocator(& host_memory.host_scratch) diff --git a/code2/sectr/pkg_mappings.odin b/code2/sectr/pkg_mappings.odin index ed5f1c4..296e0bf 100644 --- a/code2/sectr/pkg_mappings.odin +++ b/code2/sectr/pkg_mappings.odin @@ -61,6 +61,10 @@ import "core:time" tick_now :: time.tick_now import "codebase:grime" + ensure :: grime.ensure + fatal :: grime.fatal + verify :: grime.verify + Array :: grime.Array array_to_slice :: grime.array_to_slice array_append_array :: grime.array_append_array @@ -117,24 +121,24 @@ Tera :: Giga * 1024 S_To_MS :: grime.S_To_MS -ensure :: #force_inline proc( condition : b32, msg : string, location := #caller_location ) { - if condition do return - log_print( msg, LoggerLevel.Warning, location ) - debug_trap() -} -// TODO(Ed) : Setup exit codes! -fatal :: #force_inline proc( msg : string, exit_code : int = -1, location := #caller_location ) { - log_print( msg, LoggerLevel.Fatal, location ) - debug_trap() - process_exit( exit_code ) -} -// TODO(Ed) : Setup exit codes! -verify :: #force_inline proc( condition : b32, msg : string, exit_code : int = -1, location := #caller_location ) { - if condition do return - log_print( msg, LoggerLevel.Fatal, location ) - debug_trap() - process_exit( exit_code ) -} +// ensure :: #force_inline proc( condition : b32, msg : string, location := #caller_location ) { +// if condition do return +// log_print( msg, LoggerLevel.Warning, location ) +// debug_trap() +// } +// // TODO(Ed) : Setup exit codes! +// fatal :: #force_inline proc( msg : string, exit_code : int = -1, location := #caller_location ) { +// log_print( msg, LoggerLevel.Fatal, location ) +// debug_trap() +// process_exit( exit_code ) +// } +// // TODO(Ed) : Setup exit codes! +// verify :: #force_inline proc( condition : b32, msg : string, exit_code : int = -1, location := #caller_location ) { +// if condition do return +// log_print( msg, LoggerLevel.Fatal, location ) +// debug_trap() +// process_exit( exit_code ) +// } log_print :: proc( msg : string, level := LoggerLevel.Info, loc := #caller_location ) { context.allocator = odin_arena_allocator(& memory.host_scratch) diff --git a/scripts/update_deps.ps1 b/scripts/update_deps.ps1 index 38300c6..0f24b43 100644 --- a/scripts/update_deps.ps1 +++ b/scripts/update_deps.ps1 @@ -12,6 +12,8 @@ $url_odin_repo = 'https://github.com/Ed94/Odin.git' $url_sokol = 'https://github.com/Ed94/sokol-odin.git' $url_sokol_tools = 'https://github.com/floooh/sokol-tools-bin.git' +# TODO(Ed): https://github.com/karl-zylinski/odin-handle-map + $path_harfbuzz = join-path $path_thirdparty 'harfbuzz' $path_ini_parser = join-path $path_thirdparty 'ini' $path_odin = join-path $path_toolchain 'Odin'