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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user