2024-05-31 08:26:52 -07:00
|
|
|
package grime
|
2024-03-06 13:44:38 -08:00
|
|
|
|
2024-05-31 08:26:52 -07:00
|
|
|
//#region("base")
|
2024-05-12 22:56:39 -07:00
|
|
|
|
2024-02-13 23:29:28 -08:00
|
|
|
import "base:builtin"
|
2024-02-27 04:50:57 -08:00
|
|
|
copy :: builtin.copy
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-02-29 16:37:37 -08:00
|
|
|
import "base:intrinsics"
|
2024-03-12 17:55:29 -07:00
|
|
|
mem_zero :: intrinsics.mem_zero
|
2024-03-02 15:19:27 -08:00
|
|
|
ptr_sub :: intrinsics.ptr_sub
|
2024-02-29 16:37:37 -08:00
|
|
|
type_has_field :: intrinsics.type_has_field
|
|
|
|
type_elem_type :: intrinsics.type_elem_type
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-02-22 18:19:29 -08:00
|
|
|
import "base:runtime"
|
2024-04-07 22:35:53 -07:00
|
|
|
Byte :: runtime.Byte
|
|
|
|
Kilobyte :: runtime.Kilobyte
|
|
|
|
Megabyte :: runtime.Megabyte
|
|
|
|
Gigabyte :: runtime.Gigabyte
|
|
|
|
Terabyte :: runtime.Terabyte
|
|
|
|
Petabyte :: runtime.Petabyte
|
|
|
|
Exabyte :: runtime.Exabyte
|
|
|
|
resize_non_zeroed :: runtime.non_zero_mem_resize
|
|
|
|
SourceCodeLocation :: runtime.Source_Code_Location
|
2024-05-31 08:26:52 -07:00
|
|
|
|
|
|
|
//#endregion("base")
|
|
|
|
|
|
|
|
//#region("core")
|
|
|
|
|
2024-02-27 04:50:57 -08:00
|
|
|
import c "core:c/libc"
|
2024-05-31 08:26:52 -07:00
|
|
|
mem_fmt :: c.memset
|
|
|
|
|
2024-06-17 22:33:50 -07:00
|
|
|
import "core:container/queue"
|
|
|
|
Queue :: queue.Queue
|
|
|
|
|
2024-02-27 04:50:57 -08:00
|
|
|
import "core:dynlib"
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-02-22 20:15:29 -08:00
|
|
|
import "core:hash"
|
2024-06-02 22:04:24 -07:00
|
|
|
crc32 :: hash.crc32
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-03-09 07:21:48 -08:00
|
|
|
import "core:hash/xxhash"
|
|
|
|
xxh32 :: xxhash.XXH32
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-02-27 04:50:57 -08:00
|
|
|
import fmt_io "core:fmt"
|
2024-05-22 14:13:56 -07:00
|
|
|
str_fmt_out :: fmt_io.printf
|
2024-02-27 04:50:57 -08:00
|
|
|
str_fmt_tmp :: fmt_io.tprintf
|
2024-05-22 14:13:56 -07:00
|
|
|
str_fmt :: fmt_io.aprintf // Decided to make aprintf the default. (It will always be the default allocator)
|
2024-02-27 04:50:57 -08:00
|
|
|
str_fmt_builder :: fmt_io.sbprintf
|
|
|
|
str_fmt_buffer :: fmt_io.bprintf
|
|
|
|
str_to_file_ln :: fmt_io.fprintln
|
|
|
|
str_tmp_from_any :: fmt_io.tprint
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-04-07 22:35:53 -07:00
|
|
|
import "core:math"
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-01-29 23:27:45 -08:00
|
|
|
import "core:mem"
|
2024-03-07 00:10:21 -08:00
|
|
|
align_forward_int :: mem.align_forward_int
|
2024-03-19 20:25:48 -07:00
|
|
|
align_forward_uint :: mem.align_forward_uint
|
|
|
|
align_forward_uintptr :: mem.align_forward_uintptr
|
2024-02-27 04:50:57 -08:00
|
|
|
Allocator :: mem.Allocator
|
|
|
|
AllocatorError :: mem.Allocator_Error
|
2024-03-05 07:40:28 -08:00
|
|
|
AllocatorMode :: mem.Allocator_Mode
|
|
|
|
AllocatorModeSet :: mem.Allocator_Mode_Set
|
2024-02-27 04:50:57 -08:00
|
|
|
alloc :: mem.alloc
|
|
|
|
alloc_bytes :: mem.alloc_bytes
|
2024-03-11 23:32:16 -07:00
|
|
|
alloc_bytes_non_zeroed :: mem.alloc_bytes_non_zeroed
|
2024-02-27 04:50:57 -08:00
|
|
|
Arena :: mem.Arena
|
|
|
|
arena_allocator :: mem.arena_allocator
|
|
|
|
arena_init :: mem.arena_init
|
2024-03-05 07:40:28 -08:00
|
|
|
byte_slice :: mem.byte_slice
|
2024-03-07 00:10:21 -08:00
|
|
|
copy_non_overlapping :: mem.copy_non_overlapping
|
2024-02-27 04:50:57 -08:00
|
|
|
free :: mem.free
|
2024-03-07 00:10:21 -08:00
|
|
|
is_power_of_two_uintptr :: mem.is_power_of_two
|
2024-02-27 04:50:57 -08:00
|
|
|
ptr_offset :: mem.ptr_offset
|
2024-03-05 07:40:28 -08:00
|
|
|
resize :: mem.resize
|
2024-02-27 04:50:57 -08:00
|
|
|
slice_ptr :: mem.slice_ptr
|
|
|
|
TrackingAllocator :: mem.Tracking_Allocator
|
|
|
|
tracking_allocator :: mem.tracking_allocator
|
|
|
|
tracking_allocator_init :: mem.tracking_allocator_init
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-01-29 23:27:45 -08:00
|
|
|
import "core:mem/virtual"
|
2024-03-06 13:44:38 -08:00
|
|
|
VirtualProtectFlags :: virtual.Protect_Flags
|
2024-05-31 08:26:52 -07:00
|
|
|
|
|
|
|
// TODO(Ed): Use os2 when the package is considered complete.
|
2024-02-22 18:19:29 -08:00
|
|
|
import "core:os"
|
2024-02-27 04:50:57 -08:00
|
|
|
FileFlag_Create :: os.O_CREATE
|
|
|
|
FileFlag_ReadWrite :: os.O_RDWR
|
|
|
|
FileTime :: os.File_Time
|
|
|
|
file_close :: os.close
|
|
|
|
file_open :: os.open
|
|
|
|
file_read :: os.read
|
|
|
|
file_remove :: os.remove
|
|
|
|
file_seek :: os.seek
|
|
|
|
file_status :: os.stat
|
|
|
|
file_write :: os.write
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-02-13 14:16:39 -08:00
|
|
|
import "core:path/filepath"
|
2024-02-27 04:50:57 -08:00
|
|
|
file_name_from_path :: filepath.short_stem
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-05-19 08:06:09 -07:00
|
|
|
import "core:strconv"
|
|
|
|
parse_f32 :: strconv.parse_f32
|
|
|
|
parse_u64 :: strconv.parse_u64
|
|
|
|
parse_uint :: strconv.parse_uint
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-02-27 04:50:57 -08:00
|
|
|
import str "core:strings"
|
2024-03-19 20:25:48 -07:00
|
|
|
StringBuilder :: str.Builder
|
|
|
|
str_builder_from_bytes :: str.builder_from_bytes
|
|
|
|
str_builder_init :: str.builder_init
|
|
|
|
str_builder_to_writer :: str.to_writer
|
2024-02-27 04:50:57 -08:00
|
|
|
str_builder_to_string :: str.to_string
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-03-02 07:24:09 -08:00
|
|
|
import "core:time"
|
2024-03-08 15:45:08 -08:00
|
|
|
Duration :: time.Duration
|
|
|
|
duration_seconds :: time.duration_seconds
|
|
|
|
duration_ms :: time.duration_milliseconds
|
|
|
|
thread_sleep :: time.sleep
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-03-02 07:24:09 -08:00
|
|
|
import "core:unicode"
|
|
|
|
is_white_space :: unicode.is_white_space
|
2024-05-31 08:26:52 -07:00
|
|
|
|
2024-02-27 04:50:57 -08:00
|
|
|
import "core:unicode/utf8"
|
2024-03-02 15:19:27 -08:00
|
|
|
str_rune_count :: utf8.rune_count_in_string
|
2024-03-02 07:24:09 -08:00
|
|
|
runes_to_string :: utf8.runes_to_string
|
2024-03-02 15:19:27 -08:00
|
|
|
// string_to_runes :: utf8.string_to_runes
|
2024-05-31 08:26:52 -07:00
|
|
|
|
|
|
|
//#endregion("core")
|
|
|
|
|
2024-03-19 20:25:48 -07:00
|
|
|
import "thirdparty:backtrace"
|
|
|
|
StackTraceData :: backtrace.Trace_Const
|
|
|
|
stacktrace :: backtrace.trace
|
|
|
|
stacktrace_lines :: backtrace.lines
|
2024-01-29 23:27:45 -08:00
|
|
|
|
2024-05-31 08:26:52 -07:00
|
|
|
//#region("Proc overload mappings")
|
2024-03-08 00:34:21 -08:00
|
|
|
|
2024-05-18 22:21:51 -07:00
|
|
|
array_append :: proc {
|
|
|
|
array_append_value,
|
|
|
|
array_append_array,
|
|
|
|
array_append_slice,
|
|
|
|
}
|
|
|
|
|
2024-05-31 16:31:27 -07:00
|
|
|
array_append_at :: proc {
|
|
|
|
array_append_at_slice,
|
|
|
|
array_append_at_value,
|
|
|
|
}
|
|
|
|
|
2024-02-29 16:37:37 -08:00
|
|
|
is_power_of_two :: proc {
|
|
|
|
is_power_of_two_u32,
|
2024-03-07 00:10:21 -08:00
|
|
|
is_power_of_two_uintptr,
|
2024-02-29 16:37:37 -08:00
|
|
|
}
|
2024-02-23 06:36:23 -08:00
|
|
|
|
2024-06-17 22:33:50 -07:00
|
|
|
iterator :: proc {
|
|
|
|
iterator_queue,
|
2024-06-23 00:04:38 -07:00
|
|
|
iterator_ringbuf_fixed,
|
2024-06-17 22:33:50 -07:00
|
|
|
}
|
|
|
|
|
2024-05-31 14:58:18 -07:00
|
|
|
make :: proc {
|
|
|
|
array_init,
|
2024-05-31 17:51:30 -07:00
|
|
|
hmap_chained_init,
|
|
|
|
hmap_zpl_init,
|
2024-05-31 14:58:18 -07:00
|
|
|
|
2024-06-17 22:33:50 -07:00
|
|
|
make_queue,
|
|
|
|
|
2024-05-31 14:58:18 -07:00
|
|
|
// Usual
|
|
|
|
make_slice,
|
|
|
|
make_dynamic_array,
|
|
|
|
make_dynamic_array_len,
|
|
|
|
make_dynamic_array_len_cap,
|
|
|
|
make_map,
|
|
|
|
make_multi_pointer,
|
|
|
|
}
|
|
|
|
|
2024-06-17 22:33:50 -07:00
|
|
|
next :: proc {
|
|
|
|
next_queue_iterator,
|
|
|
|
}
|
|
|
|
|
2024-05-31 16:31:27 -07:00
|
|
|
push :: proc {
|
|
|
|
stack_push,
|
|
|
|
}
|
|
|
|
|
2024-06-17 22:33:50 -07:00
|
|
|
space_left :: proc {
|
|
|
|
queue.space,
|
|
|
|
}
|
|
|
|
|
|
|
|
reload :: proc {
|
|
|
|
reload_array,
|
|
|
|
reload_queue,
|
|
|
|
reload_map,
|
|
|
|
}
|
|
|
|
|
2024-05-31 17:51:30 -07:00
|
|
|
to_runes :: proc {
|
|
|
|
string_to_runes,
|
|
|
|
}
|
|
|
|
|
2024-02-29 16:37:37 -08:00
|
|
|
to_string :: proc {
|
2024-03-02 07:24:09 -08:00
|
|
|
runes_to_string,
|
2024-02-29 16:37:37 -08:00
|
|
|
str_builder_to_string,
|
|
|
|
}
|
2024-03-02 15:19:27 -08:00
|
|
|
|
2024-03-19 20:25:48 -07:00
|
|
|
to_writer :: proc {
|
|
|
|
str_builder_to_writer,
|
|
|
|
}
|
|
|
|
|
2024-05-31 08:26:52 -07:00
|
|
|
//#endregion("Proc overload mappings")
|