minor misc (end of day stuff)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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)] }
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user