From 4817510c5d3ff7a9d588cc10f561a664a7e34c7a Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 17 Dec 2019 19:38:08 -0800 Subject: [PATCH] Final type fixups; package and build stuff straightened out --- 4ed_api_implementation.cpp | 17 +- 4ed_app_models.h | 2 +- 4ed_buffer.cpp | 28 +- 4ed_dynamic_variables.cpp | 4 +- 4ed_edit.cpp | 43 +- 4ed_file.cpp | 6 +- 4ed_file.h | 2 +- 4ed_layout.cpp | 8 +- 4ed_mem.cpp | 22 +- 4ed_search_list.cpp | 4 +- 4ed_search_list.h | 2 +- 4ed_system_api.cpp | 6 +- 4ed_text_layout.h | 4 +- 4ed_working_set.cpp | 16 +- bin/4ed_build.cpp | 77 +- custom/4coder_app_links_allocator.cpp | 4 +- custom/4coder_auto_indent.cpp | 4 +- custom/4coder_base_commands.cpp | 28 +- custom/4coder_base_types.cpp | 952 +++++++++--------- custom/4coder_base_types.h | 78 +- custom/4coder_cli_command.cpp | 6 +- custom/4coder_clipboard.cpp | 2 +- custom/4coder_code_index.cpp | 10 +- custom/4coder_config.cpp | 32 +- custom/4coder_default_hooks.cpp | 8 +- custom/4coder_delta_rule.cpp | 10 +- custom/4coder_doc_content_types.h | 2 +- custom/4coder_draw.cpp | 12 +- custom/4coder_events.cpp | 8 +- custom/4coder_file.cpp | 2 +- custom/4coder_file.h | 2 +- custom/4coder_file_moving.h | 2 +- custom/4coder_hash_functions.cpp | 10 +- custom/4coder_helper.cpp | 30 +- custom/4coder_insertion.cpp | 8 +- custom/4coder_jump_sticky.cpp | 10 +- custom/4coder_jumping.cpp | 30 +- custom/4coder_layout_rule.cpp | 12 +- custom/4coder_lister_base.cpp | 10 +- custom/4coder_log_parser.cpp | 18 +- custom/4coder_malloc_allocator.cpp | 8 +- custom/4coder_miblo_numbers.cpp | 2 +- custom/4coder_profile_inspect.h | 2 +- custom/4coder_project_commands.cpp | 8 +- custom/4coder_stringf.cpp | 10 +- custom/4coder_system_allocator.cpp | 21 +- custom/4coder_system_types.h | 2 +- custom/4coder_token.cpp | 2 +- custom/4coder_types.h | 14 +- custom/bin/setup_cl_generic.bat | 4 - custom/bin/setup_cl_x64.bat | 4 + custom/generated/custom_api.h | 18 +- custom/generated/custom_api_constructor.cpp | 4 +- custom/generated/custom_api_master_list.h | 6 +- custom/generated/lexer_cpp.cpp | 10 +- custom/generated/system_api.h | 18 +- custom/generated/system_api_constructor.cpp | 6 +- custom/generated/system_api_master_list.h | 6 +- .../4coder_lex_gen_hand_written.cpp | 6 +- .../lexer_generator/4coder_lex_gen_main.cpp | 20 +- docs/4ed_doc_helper.cpp | 4 +- opengl/4ed_opengl_defines.h | 2 +- opengl/4ed_opengl_render.cpp | 4 +- platform_mac/mac_4ed.cpp | 4 +- platform_mac/osx_objective_c_to_cpp_links.h | 6 +- platform_unix/unix_4ed_functions.cpp | 2 +- platform_win32/win32_4ed.cpp | 12 +- platform_win32/win32_4ed_functions.cpp | 14 +- project.4coder | 8 + site/4ed_site_render_main.cpp | 3 +- site/static/home.html | 1 + 71 files changed, 852 insertions(+), 910 deletions(-) diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index bea22d6c..933262b4 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -363,7 +363,7 @@ buffer_seek_string(Application_Links *app, Buffer_ID buffer, String_Const_u8 nee Gap_Buffer *gap_buffer = &file->state.buffer; i64 size = buffer_size(gap_buffer); List_String_Const_u8 chunks = buffer_get_chunks(scratch, gap_buffer); - Interval_i64 range = {}; + Range_i64 range = {}; if (direction == Scan_Forward){ i64 adjusted_pos = start_pos + 1; start_pos = clamp_top(adjusted_pos, size); @@ -1979,7 +1979,7 @@ managed_id_get(Application_Links *app, String_Const_u8 group, String_Const_u8 na } api(custom) function void* -managed_scope_get_attachment(Application_Links *app, Managed_Scope scope, Managed_ID id, umem size){ +managed_scope_get_attachment(Application_Links *app, Managed_Scope scope, Managed_ID id, u64 size){ Models *models = (Models*)app->cmd_context; Dynamic_Workspace *workspace = get_dynamic_workspace(models, scope); void *result = 0; @@ -2283,7 +2283,7 @@ set_custom_hook(Application_Links *app, Hook_ID hook_id, Void_Func *func_ptr){ } api(custom) function b32 -set_custom_hook_memory_size(Application_Links *app, Hook_ID hook_id, umem size){ +set_custom_hook_memory_size(Application_Links *app, Hook_ID hook_id, u64 size){ Models *models = (Models*)app->cmd_context; b32 result = true; switch (hook_id){ @@ -2738,8 +2738,8 @@ set_window_title(Application_Links *app, String_Const_u8 title) { Models *models = (Models*)app->cmd_context; models->has_new_title = true; - umem cap_before_null = (umem)(models->title_capacity - 1); - umem copy_size = clamp_top(title.size, cap_before_null); + u64 cap_before_null = (u64)(models->title_capacity - 1); + u64 copy_size = clamp_top(title.size, cap_before_null); block_copy(models->title_space, title.str, copy_size); models->title_space[copy_size] = 0; } @@ -2824,8 +2824,8 @@ text_layout_create(Application_Links *app, Buffer_ID buffer_id, Rect_f32 rect, B y = next_y; } - Interval_i64 visible_line_number_range = Ii64(buffer_point.line_number, line_number); - Interval_i64 visible_range = Ii64(buffer_get_first_pos_from_line_number(buffer, visible_line_number_range.min), + Range_i64 visible_line_number_range = Ii64(buffer_point.line_number, line_number); + Range_i64 visible_range = Ii64(buffer_get_first_pos_from_line_number(buffer, visible_line_number_range.min), buffer_get_last_pos_from_line_number(buffer, visible_line_number_range.max)); i64 item_count = range_size_inclusive(visible_range); @@ -2978,8 +2978,7 @@ text_layout_character_on_screen(Application_Links *app, Text_Layout_ID layout_id } api(custom) function void -paint_text_color(Application_Links *app, Text_Layout_ID layout_id, Interval_i64 range, - ARGB_Color color){ +paint_text_color(Application_Links *app, Text_Layout_ID layout_id, Range_i64 range, ARGB_Color color){ Models *models = (Models*)app->cmd_context; Rect_f32 result = {}; Text_Layout *layout = text_layout_get(&models->text_layouts, layout_id); diff --git a/4ed_app_models.h b/4ed_app_models.h index 53e7801a..4c7a4bf3 100644 --- a/4ed_app_models.h +++ b/4ed_app_models.h @@ -63,7 +63,7 @@ struct Models{ Tick_Function *tick; Render_Caller_Function *render_caller; Delta_Rule_Function *delta_rule; - umem delta_rule_memory_size; + u64 delta_rule_memory_size; Hook_Function *buffer_viewer_update; Custom_Command_Function *view_event_handler; diff --git a/4ed_buffer.cpp b/4ed_buffer.cpp index 56cf88a2..c625e6f0 100644 --- a/4ed_buffer.cpp +++ b/4ed_buffer.cpp @@ -278,12 +278,12 @@ buffer_line_count(Gap_Buffer *buffer){ } internal void -buffer_init(Gap_Buffer *buffer, u8 *data, umem size, Base_Allocator *allocator){ +buffer_init(Gap_Buffer *buffer, u8 *data, u64 size, Base_Allocator *allocator){ block_zero_struct(buffer); buffer->allocator = allocator; - umem capacity = round_up_umem(size*2, KB(4)); + u64 capacity = round_up_u64(size*2, KB(4)); Data memory = base_allocate(allocator, capacity); buffer->data = (u8*)memory.data; buffer->size1 = size/2; @@ -357,21 +357,21 @@ buffer_get_chunks(Arena *arena, Gap_Buffer *buffer){ string_list_push(arena, &list, SCu8(buffer->data, buffer->size1)); } if (buffer->size2 > 0){ - umem gap_2_pos = buffer->size1 + buffer->gap_size; + u64 gap_2_pos = buffer->size1 + buffer->gap_size; string_list_push(arena, &list, SCu8(buffer->data + gap_2_pos, buffer->size2)); } return(list); } internal void -buffer_chunks_clamp(List_String_Const_u8 *chunks, Interval_i64 range){ +buffer_chunks_clamp(List_String_Const_u8 *chunks, Range_i64 range){ i64 p = 0; List_String_Const_u8 list = {}; for (Node_String_Const_u8 *node = chunks->first, *next = 0; node != 0; node = next){ next = node->next; - Interval_i64 node_range = Ii64(p, p + node->string.size); + Range_i64 node_range = Ii64(p, p + node->string.size); if (range_overlap(range, node_range)){ i64 first = Max(node_range.first, range.first) - node_range.first; i64 one_past_last = Min(node_range.one_past_last, range.one_past_last) - node_range.first; @@ -387,17 +387,17 @@ buffer_chunks_clamp(List_String_Const_u8 *chunks, Interval_i64 range){ } internal String_Const_u8 -buffer_stringify(Arena *arena, Gap_Buffer *buffer, Interval_i64 range){ +buffer_stringify(Arena *arena, Gap_Buffer *buffer, Range_i64 range){ List_String_Const_u8 list = buffer_get_chunks(arena, buffer); buffer_chunks_clamp(&list, range); return(string_list_flatten(arena, list, StringFill_NullTerminate)); } internal String_Const_u8 -buffer_eol_convert_out(Arena *arena, Gap_Buffer *buffer, Interval_i64 range){ +buffer_eol_convert_out(Arena *arena, Gap_Buffer *buffer, Range_i64 range){ List_String_Const_u8 list = buffer_get_chunks(arena, buffer); buffer_chunks_clamp(&list, range); - umem cap = list.total_size*2; + u64 cap = list.total_size*2; u8 *memory = push_array(arena, u8, cap); u8 *memory_opl = memory + cap; u8 *ptr = memory; @@ -549,7 +549,7 @@ push_line_move(Arena *arena, Line_Move *moves, i64 new_line_first, function i64 count_lines(String_Const_u8 string){ i64 result = 0; - for (umem i = 0; i < string.size; i += 1){ + for (u64 i = 0; i < string.size; i += 1){ if (string.str[i] == '\n'){ result += 1; } @@ -560,7 +560,7 @@ count_lines(String_Const_u8 string){ function void fill_line_starts(i64 *lines_starts, String_Const_u8 string, i64 text_base){ i64 *ptr = lines_starts; - for (umem i = 0; i < string.size; i += 1){ + for (u64 i = 0; i < string.size; i += 1){ if (string.str[i] == '\n'){ *ptr = text_base + i + 1; ptr += 1; @@ -693,9 +693,9 @@ buffer_remeasure_starts(Arena *scratch, Gap_Buffer *buffer, } #endif -internal Interval_i64 +internal Range_i64 buffer_get_pos_range_from_line_number(Gap_Buffer *buffer, i64 line_number){ - Interval_i64 result = {}; + Range_i64 result = {}; if (1 <= line_number && line_number < buffer->line_start_count){ result.first = buffer->line_starts[line_number - 1]; result.one_past_last = buffer->line_starts[line_number]; @@ -815,7 +815,7 @@ buffer_get_chunk_position(String_Const_u8_Array chunks, i64 buffer_size, i64 rea pos.real_pos = real_pos; pos.chunk_pos = real_pos; if (pos.real_pos != buffer_size){ - for (;(imem)(chunks.vals[pos.chunk_index].size) <= pos.chunk_pos;){ + for (;(i64)(chunks.vals[pos.chunk_index].size) <= pos.chunk_pos;){ Assert(pos.chunk_index < chunks.count); pos.chunk_pos -= (i32)chunks.vals[pos.chunk_index].size; pos.chunk_index += 1; @@ -842,7 +842,7 @@ buffer_chunk_position_iterate(String_Const_u8_Array chunks, Buffer_Chunk_Positio pos->chunk_pos = (i32)chunks.vals[pos->chunk_index].size - 1; } } - else if (pos->chunk_pos >= (imem)(chunks.vals[pos->chunk_index].size)){ + else if (pos->chunk_pos >= (i64)(chunks.vals[pos->chunk_index].size)){ pos->chunk_index += 1; if (pos->chunk_index == chunks.count){ past_end = 1; diff --git a/4ed_dynamic_variables.cpp b/4ed_dynamic_variables.cpp index 32536eef..e2995507 100644 --- a/4ed_dynamic_variables.cpp +++ b/4ed_dynamic_variables.cpp @@ -97,7 +97,7 @@ dynamic_variable_block_init(Base_Allocator *allocator, Dynamic_Variable_Block *b } internal Data -dynamic_variable_get(Dynamic_Variable_Block *block, Managed_ID id, umem size){ +dynamic_variable_get(Dynamic_Variable_Block *block, Managed_ID id, u64 size){ Data result = {}; Table_Lookup lookup = table_lookup(&block->id_to_data_table, id); if (lookup.found_match){ @@ -425,7 +425,7 @@ lifetime_get_or_create_intersection_key(Lifetime_Allocator *lifetime_allocator, } // Initialize - umem new_memory_size = sizeof(Lifetime_Object*)*count; + u64 new_memory_size = sizeof(Lifetime_Object*)*count; Data new_memory = base_allocate(lifetime_allocator->allocator, new_memory_size); new_key->members = (Lifetime_Object**)new_memory.data; block_copy_dynamic_array(new_key->members, object_ptr_array, count); diff --git a/4ed_edit.cpp b/4ed_edit.cpp index 673d5278..73d4ca81 100644 --- a/4ed_edit.cpp +++ b/4ed_edit.cpp @@ -9,12 +9,12 @@ // TOP -internal void +function void pre_edit_state_change(Models *models, Editing_File *file){ file_add_dirty_flag(file, DirtyState_UnsavedChanges); } -internal void +function void pre_edit_history_prep(Editing_File *file, Edit_Behaviors behaviors){ if (!behaviors.do_not_post_to_history){ history_dump_records_after_index(&file->state.history, @@ -22,9 +22,9 @@ pre_edit_history_prep(Editing_File *file, Edit_Behaviors behaviors){ } } -internal void +function void post_edit_call_hook(Thread_Context *tctx, Models *models, Editing_File *file, - Range_i64 new_range, umem original_size){ + Range_i64 new_range, u64 original_size){ // NOTE(allen): edit range hook if (models->buffer_edit_range != 0){ Application_Links app = {}; @@ -34,7 +34,7 @@ post_edit_call_hook(Thread_Context *tctx, Models *models, Editing_File *file, } } -internal void +function void edit_fix_markers__write_workspace_markers(Dynamic_Workspace *workspace, Buffer_ID buffer_id, Cursor_With_Index *cursors, Cursor_With_Index *r_cursors, i32 *cursor_count, i32 *r_cursor_count){ @@ -56,7 +56,7 @@ edit_fix_markers__write_workspace_markers(Dynamic_Workspace *workspace, Buffer_I } } -internal void +function void edit_fix_markers__read_workspace_markers(Dynamic_Workspace *workspace, Buffer_ID buffer_id, Cursor_With_Index *cursors, Cursor_With_Index *r_cursors, i32 *cursor_count, i32 *r_cursor_count){ for (Managed_Buffer_Markers_Header *node = workspace->buffer_markers_list.first; @@ -77,19 +77,19 @@ edit_fix_markers__read_workspace_markers(Dynamic_Workspace *workspace, Buffer_ID } } -internal f32 +function f32 edit_fix_markers__compute_scroll_y(i32 line_height, f32 old_y_val, f32 new_y_val_aligned){ f32 y_offset = mod_f32(old_y_val, line_height); f32 y_position = new_y_val_aligned + y_offset; return(y_position); } -internal i32 +function i32 edit_fix_markers__compute_scroll_y(i32 line_height, i32 old_y_val, f32 new_y_val_aligned){ return((i32)edit_fix_markers__compute_scroll_y(line_height, (f32)old_y_val, new_y_val_aligned)); } -internal void +function void edit_fix_markers(Thread_Context *tctx, Models *models, Editing_File *file, Batch_Edit *batch){ Layout *layout = &models->layout; @@ -200,7 +200,7 @@ edit_fix_markers(Thread_Context *tctx, Models *models, Editing_File *file, } } -internal void +function void file_end_file(Thread_Context *tctx, Models *models, Editing_File *file){ if (models->end_buffer != 0){ Application_Links app = {}; @@ -213,9 +213,8 @@ file_end_file(Thread_Context *tctx, Models *models, Editing_File *file){ file->lifetime_object = lifetime_alloc_object(lifetime_allocator, DynamicWorkspace_Buffer, file); } -internal void -edit__apply(Thread_Context *tctx, Models *models, Editing_File *file, - Interval_i64 range, String_Const_u8 string, Edit_Behaviors behaviors){ +function void +edit__apply(Thread_Context *tctx, Models *models, Editing_File *file, Range_i64 range, String_Const_u8 string, Edit_Behaviors behaviors){ Edit edit = {}; edit.text = string; edit.range = range; @@ -241,7 +240,7 @@ edit__apply(Thread_Context *tctx, Models *models, Editing_File *file, } } -internal void +function void edit_single(Thread_Context *tctx, Models *models, Editing_File *file, Range_i64 range, String_Const_u8 string, Edit_Behaviors behaviors){ pre_edit_state_change(models, file); @@ -261,7 +260,7 @@ edit_single(Thread_Context *tctx, Models *models, Editing_File *file, Ii64_size(range.first, string.size), range_size(range)); } -internal void +function void edit__apply_record_forward(Thread_Context *tctx, Models *models, Editing_File *file, Record *record, Edit_Behaviors behaviors_prototype){ // NOTE(allen): // NOTE(allen): // NOTE(allen): // NOTE(allen): // NOTE(allen): // Whenever you change this also change the backward version! @@ -270,7 +269,7 @@ edit__apply_record_forward(Thread_Context *tctx, Models *models, Editing_File *f case RecordKind_Single: { String_Const_u8 str = record->single.forward_text; - Interval_i64 range = Ii64(record->single.first, record->single.first + record->single.backward_text.size); + Range_i64 range = Ii64(record->single.first, record->single.first + record->single.backward_text.size); edit_single(tctx, models, file, range, str, behaviors_prototype); }break; @@ -292,7 +291,7 @@ edit__apply_record_forward(Thread_Context *tctx, Models *models, Editing_File *f } } -internal void +function void edit__apply_record_backward(Thread_Context *tctx, Models *models, Editing_File *file, Record *record, Edit_Behaviors behaviors_prototype){ // NOTE(allen): // NOTE(allen): // NOTE(allen): // NOTE(allen): // NOTE(allen): // Whenever you change this also change the forward version! @@ -301,7 +300,7 @@ edit__apply_record_backward(Thread_Context *tctx, Models *models, Editing_File * case RecordKind_Single: { String_Const_u8 str = record->single.backward_text; - Interval_i64 range = Ii64(record->single.first, record->single.first + record->single.forward_text.size); + Range_i64 range = Ii64(record->single.first, record->single.first + record->single.forward_text.size); edit_single(tctx, models, file, range, str, behaviors_prototype); }break; @@ -323,7 +322,7 @@ edit__apply_record_backward(Thread_Context *tctx, Models *models, Editing_File * } } -internal void +function void edit_change_current_history_state(Thread_Context *tctx, Models *models, Editing_File *file, i32 target_index){ History *history = &file->state.history; if (history->activated && file->state.current_record_index != target_index){ @@ -358,7 +357,7 @@ edit_change_current_history_state(Thread_Context *tctx, Models *models, Editing_ } } -internal b32 +function b32 edit_merge_history_range(Thread_Context *tctx, Models *models, Editing_File *file, History_Record_Index first_index, History_Record_Index last_index, Record_Merge_Flag flags){ b32 result = false; History *history = &file->state.history; @@ -419,7 +418,7 @@ edit_batch_check(Thread_Context *tctx, Profile_Global_List *list, Batch_Edit *ba return(result); } -internal b32 +function b32 edit_batch(Thread_Context *tctx, Models *models, Editing_File *file, Batch_Edit *batch, Edit_Behaviors behaviors){ b32 result = true; @@ -502,7 +501,7 @@ edit_batch(Thread_Context *tctx, Models *models, Editing_File *file, //////////////////////////////// -internal Editing_File* + function Editing_File* create_file(Thread_Context *tctx, Models *models, String_Const_u8 file_name, Buffer_Create_Flag flags){ Editing_File *result = 0; diff --git a/4ed_file.cpp b/4ed_file.cpp index ddb191ac..a201fe9b 100644 --- a/4ed_file.cpp +++ b/4ed_file.cpp @@ -111,7 +111,7 @@ file_clear_dirty_flags(Editing_File *file){ internal void file_name_terminate(Editing_File_Name *name){ - umem size = name->name_size; + u64 size = name->name_size; size = clamp_top(size, sizeof(name->name_space) - 1); name->name_space[size] = 0; name->name_size = size; @@ -395,7 +395,7 @@ file_line_y_difference(Thread_Context *tctx, Models *models, Editing_File *file, i64 line_a, i64 line_b){ f32 result = 0.f; if (line_a != line_b){ - Interval_i64 line_range = Ii64(line_a, line_b); + Range_i64 line_range = Ii64(line_a, line_b); for (i64 i = line_range.min; i < line_range.max; i += 1){ Layout_Item_List line = file_get_line_layout(tctx, models, file, layout_func, width, face, i); result += line.height; @@ -522,7 +522,7 @@ internal i64 file_line_character_difference(Thread_Context *tctx, Models *models, Editing_File *file, Layout_Function *layout_func, f32 width, Face *face, i64 line_a, i64 line_b){ i64 result = 0; if (line_a != line_b){ - Interval_i64 line_range = Ii64(line_a, line_b); + Range_i64 line_range = Ii64(line_a, line_b); for (i64 i = line_range.min; i < line_range.max; i += 1){ Layout_Item_List line = file_get_line_layout(tctx, models, file, layout_func, width, face, i); result += line.character_count; diff --git a/4ed_file.h b/4ed_file.h index 81fdc93c..1eb82013 100644 --- a/4ed_file.h +++ b/4ed_file.h @@ -79,7 +79,7 @@ struct Editing_File_State{ struct Editing_File_Name{ u8 name_space[256]; - umem name_size; + u64 name_size; }; struct Editing_File{ diff --git a/4ed_layout.cpp b/4ed_layout.cpp index 55f36761..e64c12da 100644 --- a/4ed_layout.cpp +++ b/4ed_layout.cpp @@ -348,8 +348,8 @@ layout_get_absolute_position_of_split(Panel *panel){ return(pos); } -internal Range -layout__get_limiting_range_on_split_children(i32 mid, b32 vertical_split, Panel *panel, Range range){ +internal Range_i32 +layout__get_limiting_range_on_split_children(i32 mid, b32 vertical_split, Panel *panel, Range_i32 range){ if (panel->kind == PanelKind_Intermediate){ if (vertical_split == panel->vertical_split){ i32 pos = layout_get_absolute_position_of_split(panel); @@ -366,10 +366,10 @@ layout__get_limiting_range_on_split_children(i32 mid, b32 vertical_split, Panel return(range); } -internal Range +internal Range_i32 layout_get_limiting_range_on_split(Layout *layout, Panel *panel){ // root level min max - Range range = {}; + Range_i32 range = {}; if (panel->vertical_split){ range.max = layout->full_dim.x; } diff --git a/4ed_mem.cpp b/4ed_mem.cpp index 8864dd02..01e08762 100644 --- a/4ed_mem.cpp +++ b/4ed_mem.cpp @@ -12,25 +12,25 @@ #if 0 internal void -block_zero(void *a, umem size){ +block_zero(void *a, u64 size){ for (u8 *ptr = (u8*)a, *e = ptr + size; ptr < e; ptr += 1){ *ptr = 0; } } internal void -block_fill_ones(void *a, umem size){ +block_fill_ones(void *a, u64 size){ for (u8 *ptr = (u8*)a, *e = ptr + size; ptr < e; ptr += 1){ *ptr = 0xFF; } } internal void -block_copy(void *dst, void *src, umem size){ +block_copy(void *dst, void *src, u64 size){ for (u8 *d = (u8*)dst, *s = (u8*)src, *e = s + size; s < e; d += 1, s += 1){ *d = *s; } } internal i32 -block_compare(void *a, void *b, umem size){ +block_compare(void *a, void *b, u64 size){ for (u8 *aptr = (u8*)a, *bptr = (u8*)b, *e = bptr + size; bptr < e; aptr += 1, bptr += 1){ i32 dif = (i32)*aptr - (i32)*bptr; if (dif != 0){ @@ -40,31 +40,31 @@ block_compare(void *a, void *b, umem size){ return(0); } internal void -block_fill_u8(void *a, umem size, u8 val){ +block_fill_u8(void *a, u64 size, u8 val){ for (u8 *ptr = (u8*)a, *e = ptr + size; ptr < e; ptr += 1){ *ptr = val; } } internal void -block_fill_u16(void *a, umem size, u16 val){ +block_fill_u16(void *a, u64 size, u16 val){ Assert(size%sizeof(u16) == 0); - umem count = size/sizeof(u16); + u64 count = size/sizeof(u16); for (u16 *ptr = (u16*)a, *e = ptr + count; ptr < e; ptr += 1){ *ptr = val; } } internal void -block_fill_u32(void *a, umem size, u32 val){ +block_fill_u32(void *a, u64 size, u32 val){ Assert(size%sizeof(u32) == 0); - umem count = size/sizeof(u32); + u64 count = size/sizeof(u32); for (u32 *ptr = (u32*)a, *e = ptr + count; ptr < e; ptr += 1){ *ptr = val; } } internal void -block_fill_u64(void *a, umem size, u64 val){ +block_fill_u64(void *a, u64 size, u64 val){ Assert(size%sizeof(u64) == 0); - umem count = size/sizeof(u64); + u64 count = size/sizeof(u64); for (u64 *ptr = (u64*)a, *e = ptr + count; ptr < e; ptr += 1){ *ptr = val; } diff --git a/4ed_search_list.cpp b/4ed_search_list.cpp index 4e08ed0e..9eecc551 100644 --- a/4ed_search_list.cpp +++ b/4ed_search_list.cpp @@ -29,7 +29,7 @@ function String_Const_u8 get_full_path(Arena *arena, Path_Search_List *search_list, String_Const_u8 relative){ String_Const_u8 result = {}; Temp_Memory restore_point = begin_temp(arena); - umem buffer_cap = search_list->max_member_length + relative.size + 1; + u64 buffer_cap = search_list->max_member_length + relative.size + 1; u8 *buffer = push_array(arena, u8, buffer_cap); u8 *opl = buffer + buffer_cap; u8 *relative_base = opl - 1 - relative.size; @@ -38,7 +38,7 @@ get_full_path(Arena *arena, Path_Search_List *search_list, String_Const_u8 relat for (Node_String_Const_u8 *node = search_list->list.first; node != 0; node = node->next){ - umem node_size = node->string.size; + u64 node_size = node->string.size; u8 *path_base = relative_base - node_size; block_copy(path_base, node->string.str, node_size); String_Const_u8 name = SCu8(path_base, opl); diff --git a/4ed_search_list.h b/4ed_search_list.h index e82c3fe2..ab10fc76 100644 --- a/4ed_search_list.h +++ b/4ed_search_list.h @@ -14,7 +14,7 @@ struct Path_Search_List{ List_String_Const_u8 list; - umem max_member_length; + u64 max_member_length; }; #endif diff --git a/4ed_system_api.cpp b/4ed_system_api.cpp index 3293ae82..2a98bb8d 100644 --- a/4ed_system_api.cpp +++ b/4ed_system_api.cpp @@ -229,21 +229,21 @@ api_call(arena, api, "condition_variable_make", { API_Call *call = api_call(arena, api, "memory_allocate", "void*"); - api_param(arena, call, "umem", "size"); + api_param(arena, call, "u64", "size"); api_param(arena, call, "String_Const_u8", "location"); } { API_Call *call = api_call(arena, api, "memory_set_protection", "b32"); api_param(arena, call, "void*", "ptr"); - api_param(arena, call, "umem", "size"); + api_param(arena, call, "u64", "size"); api_param(arena, call, "u32", "flags"); } { API_Call *call = api_call(arena, api, "memory_free", "void"); api_param(arena, call, "void*", "ptr"); - api_param(arena, call, "umem", "size"); + api_param(arena, call, "u64", "size"); } { diff --git a/4ed_text_layout.h b/4ed_text_layout.h index d9a09ead..1bf39702 100644 --- a/4ed_text_layout.h +++ b/4ed_text_layout.h @@ -18,8 +18,8 @@ union Text_Layout{ Arena *arena; Buffer_ID buffer_id; Buffer_Point point; - Interval_i64 visible_range; - Interval_i64 visible_line_number_range; + Range_i64 visible_range; + Range_i64 visible_line_number_range; Rect_f32 rect; ARGB_Color *item_colors; Layout_Function *layout_func; diff --git a/4ed_working_set.cpp b/4ed_working_set.cpp index 2a6271e0..e51c6c40 100644 --- a/4ed_working_set.cpp +++ b/4ed_working_set.cpp @@ -207,7 +207,7 @@ get_file_from_identifier(Working_Set *working_set, Buffer_Identifier buffer){ // TODO(allen): Bring the clipboard fully to the custom side. internal String_Const_u8* -working_set_next_clipboard_string(Heap *heap, Working_Set *working, umem str_size){ +working_set_next_clipboard_string(Heap *heap, Working_Set *working, u64 str_size){ i32 clipboard_current = working->clipboard_current; if (working->clipboard_size == 0){ clipboard_current = 0; @@ -276,7 +276,7 @@ internal b32 get_canon_name(Arena *scratch, String_Const_u8 file_name, Editing_File_Name *canon_name){ Temp_Memory temp = begin_temp(scratch); String_Const_u8 canonical = system_get_canonical(scratch, file_name); - umem size = Min(sizeof(canon_name->name_space), canonical.size); + u64 size = Min(sizeof(canon_name->name_space), canonical.size); block_copy(canon_name->name_space, canonical.str, size); canon_name->name_size = size; end_temp(temp); @@ -288,7 +288,7 @@ internal void file_bind_file_name(Working_Set *working_set, Editing_File *file, String_Const_u8 canon_file_name){ Assert(file->unique_name.name_size == 0); Assert(file->canon.name_size == 0); - umem size = canon_file_name.size; + u64 size = canon_file_name.size; size = clamp_top(size, sizeof(file->canon.name_space) - 1); file->canon.name_size = size; block_copy(file->canon.name_space, canon_file_name.str, size); @@ -323,11 +323,11 @@ buffer_name_has_conflict(Working_Set *working_set, String_Const_u8 base_name){ internal void buffer_resolve_name_low_level(Arena *scratch, Working_Set *working_set, Editing_File_Name *name, String_Const_u8 base_name){ - umem size = base_name.size; + u64 size = base_name.size; size = clamp_top(size, sizeof(name->name_space)); block_copy(name->name_space, base_name.str, size); String_u8 string = Su8(name->name_space, size, sizeof(name->name_space)); - umem original_size = string.size; + u64 original_size = string.size; u64 file_x = 0; for (b32 hit_conflict = true; hit_conflict;){ hit_conflict = buffer_name_has_conflict(working_set, string.string); @@ -354,14 +354,14 @@ buffer_bind_name_low_level(Arena *scratch, Working_Set *working_set, Editing_Fil buffer_resolve_name_low_level(scratch, working_set, &new_name, name); { - umem size = base_name.size; + u64 size = base_name.size; size = clamp_top(size, sizeof(file->base_name.name_space)); block_copy(file->base_name.name_space, base_name.str, size); file->base_name.name_size = size; } { - umem size = new_name.name_size; + u64 size = new_name.name_size; block_copy(file->unique_name.name_space, new_name.name_space, size); file->unique_name.name_size = size; } @@ -431,7 +431,7 @@ buffer_bind_name(Thread_Context *tctx, Models *models, Arena *scratch, Working_S if (i > 0){ b = string_from_file_name(&file_ptr->unique_name); } - umem unique_name_capacity = 256; + u64 unique_name_capacity = 256; u8 *unique_name_buffer = push_array(scratch, u8, unique_name_capacity); Assert(b.size <= unique_name_capacity); block_copy(unique_name_buffer, b.str, b.size); diff --git a/bin/4ed_build.cpp b/bin/4ed_build.cpp index 9d155087..4362da1a 100644 --- a/bin/4ed_build.cpp +++ b/bin/4ed_build.cpp @@ -137,14 +137,14 @@ enum{ OPTIMIZATION = 0x20, SUPER = 0x40, INTERNAL = 0x80, - KEEP_ASSERT = 0x100, + SHIP = 0x100, }; internal char** get_defines_from_flags(Arena *arena, u32 flags){ char **result = 0; - if (HasFlag(flags, KEEP_ASSERT)){ - result = fm_list(arena, fm_list_one_item(arena, "FRED_KEEP_ASSERT"), result); + if (HasFlag(flags, SHIP)){ + result = fm_list(arena, fm_list_one_item(arena, "SHIP_MODE"), result); } if (HasFlag(flags, INTERNAL)){ result = fm_list(arena, fm_list_one_item(arena, "FRED_INTERNAL"), result); @@ -270,6 +270,7 @@ build(Arena *arena, u32 flags, u32 arch, char *code_path, char **code_files, cha fm_finish_build_line(&line); + //printf("%s\n", line.build_options); systemf("%s", line.build_options); fm_popdir(temp); @@ -419,25 +420,6 @@ build_and_run(Arena *arena, char *cdir, char *filename, char *name, u32 flags){ } } -internal void -string_build(Arena *arena, char *cdir){ - char *dir = fm_str(arena, BUILD_DIR); - - { - char *file = fm_str(arena, "string/4ed_string_builder.cpp"); - BEGIN_TIME_SECTION(); - build(arena, OPTS | DEBUG_INFO, Arch_X64, cdir, file, dir, "string_builder", 0, 0, includes); - END_TIME_SECTION("build string_builder"); - } - - if (prev_error == 0){ - char *cmd = fm_str(arena, cdir, "/", dir, "/string_builder"); - BEGIN_TIME_SECTION(); - fm_execute_in_dir(fm_str(arena, cdir, "/string"), cmd, 0); - END_TIME_SECTION("run string_builder"); - } -} - internal void buildsuper(Arena *arena, char *cdir, char *file, u32 arch){ printf("BUILDSUPER: cdir: %s; file: %s; arch: %u\n", cdir, file, arch); @@ -458,29 +440,6 @@ buildsuper(Arena *arena, char *cdir, char *file, u32 arch){ fflush(stdout); } -// TODO(allen): Remove this -internal i32 -get_freetype_include(char *out, u32 max){ - i32 size = 0; -#if 0 -#if OS_LINUX - char freetype_include[512]; - FILE *file = popen("pkg-config --cflags freetype2", "r"); - if (file != 0){ - fgets(freetype_include, sizeof(freetype_include), file); - size = strlen(freetype_include); - memcpy(out, freetype_include, size); - pclose(file); - } -#elif OS_MAC - char *freetype_include = "/usr/local/include/freetype2"; - size = strlen(freetype_include); - memcpy(out, freetype_include, size); -#endif -#endif - return(size); -} - internal void build_main(Arena *arena, char *cdir, b32 update_local_theme, u32 flags, u32 arch){ char *dir = fm_str(arena, BUILD_DIR); @@ -491,14 +450,6 @@ build_main(Arena *arena, char *cdir, b32 update_local_theme, u32 flags, u32 arch char **build_includes = includes; - char ft_include[512]; - i32 ft_size = get_freetype_include(ft_include, sizeof(ft_include) - 1); - if (ft_size > 0){ - ft_include[ft_size] = 0; - fprintf(stdout, "FREETYPE: %s\n", ft_include); - build_includes = fm_list(arena, build_includes, fm_list_one_item(arena, ft_include)); - } - BEGIN_TIME_SECTION(); build(arena, OPTS | SHARED_CODE | flags, arch, cdir, file, dir, "4ed_app" DLL, get_defines_from_flags(arena, flags), exports, build_includes); END_TIME_SECTION("build 4ed_app"); @@ -564,7 +515,7 @@ package(Arena *arena, char *cdir){ fflush(stdout); char *tier_names[] = { "demo", "super", }; - u32 base_flags = OPTIMIZATION | KEEP_ASSERT | DEBUG_INFO; + u32 base_flags = SHIP | DEBUG_INFO | OPTIMIZATION; u32 tier_flags[] = { 0, SUPER, }; fm_make_folder_if_missing(arena, pack_dir); @@ -633,16 +584,20 @@ int main(int argc, char **argv){ Assert(n < sizeof(cdir)); END_TIME_SECTION("current directory"); -#if defined(DEV_BUILD) || defined(OPT_BUILD) || defined(DEV_BUILD_X86) - u32 flags = DEBUG_INFO | SUPER | INTERNAL; + u32 flags = SUPER; u32 arch = Arch_X64; -#if defined(OPT_BUILD) - flags |= OPTIMIZATION; -#endif -#if defined(DEV_BUILD_X86) + #if defined(DEV_BUILD) || defined(DEV_BUILD_X86) + flags |= DEBUG_INFO | INTERNAL; + #endif +#if defined(OPT_BUILD) || defined(OPT_BUILD_X86) + flags |= OPTIMIZATION; + #endif +#if defined(DEV_BUILD_X86) || defined(OPT_BUILD_X86) arch = Arch_X86; #endif - standard_build(&arena, cdir, flags, arch); + +#if defined(DEV_BUILD) || defined(OPT_BUILD) || defined(DEV_BUILD_X86) +standard_build(&arena, cdir, flags, arch); #elif defined(PACKAGE) package(&arena, cdir); diff --git a/custom/4coder_app_links_allocator.cpp b/custom/4coder_app_links_allocator.cpp index 1330ef7b..0b306625 100644 --- a/custom/4coder_app_links_allocator.cpp +++ b/custom/4coder_app_links_allocator.cpp @@ -15,13 +15,13 @@ Scratch_Block::Scratch_Block(Application_Links *app){ //////////////////////////////// internal Arena* -reserve_arena(Application_Links *app, umem chunk_size, umem align){ +reserve_arena(Application_Links *app, u64 chunk_size, u64 align){ Thread_Context *tctx = get_thread_context(app); return(reserve_arena(tctx, chunk_size, align)); } internal Arena* -reserve_arena(Application_Links *app, umem chunk_size){ +reserve_arena(Application_Links *app, u64 chunk_size){ Thread_Context *tctx = get_thread_context(app); return(reserve_arena(tctx, chunk_size)); } diff --git a/custom/4coder_auto_indent.cpp b/custom/4coder_auto_indent.cpp index e97828b7..d05d98f8 100644 --- a/custom/4coder_auto_indent.cpp +++ b/custom/4coder_auto_indent.cpp @@ -26,7 +26,7 @@ make_batch_from_indentations(Application_Links *app, Arena *arena, Buffer_ID buf } if (correct_indentation != indent_info.indent_pos){ - umem str_size = 0; + u64 str_size = 0; u8 *str = 0; if (HasFlag(flags, Indent_UseTab)){ i64 tab_count = correct_indentation/tab_width; @@ -399,7 +399,7 @@ CUSTOM_DOC("Inserts text and auto-indents the line on which the cursor sits if a String_Const_u8 insert = to_writable(&in); if (insert.str != 0 && insert.size > 0){ b32 do_auto_indent = false; - for (umem i = 0; !do_auto_indent && i < insert.size; i += 1){ + for (u64 i = 0; !do_auto_indent && i < insert.size; i += 1){ switch (insert.str[i]){ case ';': case ':': case '{': case '}': diff --git a/custom/4coder_base_commands.cpp b/custom/4coder_base_commands.cpp index da5c9e63..0cb42ebc 100644 --- a/custom/4coder_base_commands.cpp +++ b/custom/4coder_base_commands.cpp @@ -588,8 +588,8 @@ CUSTOM_DOC("Removes trailing whitespace from all lines in the current buffer.") String_Const_u8 text = push_whole_buffer(app, scratch, buffer); - umem whitespace_start = 0; - for (umem i = 0; i < text.size; i += 1){ + u64 whitespace_start = 0; + for (u64 i = 0; i < text.size; i += 1){ u8 v = string_get_character(text, i); if (v == '\n' || i + 1 == text.size){ if (whitespace_start < i){ @@ -752,7 +752,7 @@ CUSTOM_DOC("Queries the user for a number, and jumps the cursor to the correspon u8 string_space[256]; Query_Bar bar = {}; bar.prompt = string_u8_litexpr("Goto Line: "); - bar.string = SCu8(string_space, (umem)0); + bar.string = SCu8(string_space, (u64)0); bar.string_capacity = sizeof(string_space); if (query_user_number(app, &bar)){ i32 line_number = (i32)string_to_integer(bar.string, 10); @@ -797,7 +797,7 @@ isearch(Application_Links *app, Scan_Direction start_scan, i64 first_pos, String_Const_u8 isearch_str = string_u8_litexpr("I-Search: "); String_Const_u8 rsearch_str = string_u8_litexpr("Reverse-I-Search: "); - umem match_size = bar.string.size; + u64 match_size = bar.string.size; User_Input in = {}; for (;;){ @@ -830,7 +830,7 @@ isearch(Application_Links *app, Scan_Direction start_scan, i64 first_pos, block_copy(bar.string.str, previous_isearch_query, bar.string.size); } else{ - umem size = bar.string.size; + u64 size = bar.string.size; size = clamp_top(size, sizeof(previous_isearch_query) - 1); block_copy(previous_isearch_query, bar.string.str, size); previous_isearch_query[size] = 0; @@ -845,7 +845,7 @@ isearch(Application_Links *app, Scan_Direction start_scan, i64 first_pos, } else if (match_key_code(&in, KeyCode_Backspace)){ if (is_unmodified_key(&in.event)){ - umem old_bar_string_size = bar.string.size; + u64 old_bar_string_size = bar.string.size; bar.string = backspace_utf8(bar.string); string_change = (bar.string.size < old_bar_string_size); } @@ -940,7 +940,7 @@ isearch(Application_Links *app, Scan_Direction start_scan, i64 first_pos, view_disable_highlight_range(app, view); if (in.abort){ - umem size = bar.string.size; + u64 size = bar.string.size; size = clamp_top(size, sizeof(previous_isearch_query) - 1); block_copy(previous_isearch_query, bar.string.str, size); previous_isearch_query[size] = 0; @@ -1008,13 +1008,13 @@ query_user_replace_pair(Application_Links *app, Arena *arena){ Query_Bar *replace = push_array(arena, Query_Bar, 1); u8 *replace_space = push_array(arena, u8, KB(1)); replace->prompt = string_u8_litexpr("Replace: "); - replace->string = SCu8(replace_space, (umem)0); + replace->string = SCu8(replace_space, (u64)0); replace->string_capacity = KB(1); Query_Bar *with = push_array(arena, Query_Bar, 1); u8 *with_space = push_array(arena, u8, KB(1)); with->prompt = string_u8_litexpr("With: "); - with->string = SCu8(with_space, (umem)0); + with->string = SCu8(with_space, (u64)0); with->string_capacity = KB(1); String_Pair result = {}; @@ -1127,7 +1127,7 @@ query_replace_parameter(Application_Links *app, String_Const_u8 replace_str, i64 Query_Bar with = {}; u8 with_space[1024]; with.prompt = string_u8_litexpr("With: "); - with.string = SCu8(with_space, (umem)0); + with.string = SCu8(with_space, (u64)0); with.string_capacity = sizeof(with_space); if (query_user_string(app, &with)){ @@ -1156,7 +1156,7 @@ CUSTOM_DOC("Queries the user for two strings, and incrementally replaces every o Query_Bar replace = {}; u8 replace_space[1024]; replace.prompt = string_u8_litexpr("Replace: "); - replace.string = SCu8(replace_space, (umem)0); + replace.string = SCu8(replace_space, (u64)0); replace.string_capacity = sizeof(replace_space); if (query_user_string(app, &replace)){ if (replace.string.size > 0){ @@ -1276,7 +1276,7 @@ CUSTOM_DOC("Queries the user for a file name and saves the contents of the curre u8 name_space[4096]; Query_Bar bar = {}; bar.prompt = push_u8_stringf(scratch, "Save '%.*s' to: ", string_expand(buffer_name)); - bar.string = SCu8(name_space, (umem)0); + bar.string = SCu8(name_space, (u64)0); bar.string_capacity = sizeof(name_space); if (query_user_string(app, &bar)){ if (bar.string.size != 0){ @@ -1311,7 +1311,7 @@ CUSTOM_DOC("Queries the user for a new name and renames the file of the current u8 name_space[4096]; Query_Bar bar = {}; bar.prompt = push_u8_stringf(scratch, "Rename '%.*s' to: ", string_expand(front)); - bar.string = SCu8(name_space, (umem)0); + bar.string = SCu8(name_space, (u64)0); bar.string_capacity = sizeof(name_space); if (query_user_string(app, &bar)){ if (bar.string.size != 0){ @@ -1345,7 +1345,7 @@ CUSTOM_DOC("Queries the user for a name and creates a new directory with the giv u8 name_space[4096]; Query_Bar bar = {}; bar.prompt = push_u8_stringf(scratch, "Make directory at '%.*s': ", string_expand(hot)); - bar.string = SCu8(name_space, (umem)0); + bar.string = SCu8(name_space, (u64)0); bar.string_capacity = sizeof(name_space); if (!query_user_string(app, &bar)) return; diff --git a/custom/4coder_base_types.cpp b/custom/4coder_base_types.cpp index e8e92050..9f7b3483 100644 --- a/custom/4coder_base_types.cpp +++ b/custom/4coder_base_types.cpp @@ -87,18 +87,6 @@ round_up_u64(u64 x, u64 b){ x -= x%b; return(x); } -function imem -round_up_imem(imem x, imem b){ - x += b - 1; - x -= x%b; - return(x); -} -function umem -round_up_umem(umem x, umem b){ - x += b - 1; - x -= x%b; - return(x); -} function i8 round_down_i8(i8 x, i8 b){ @@ -140,16 +128,6 @@ round_down_u64(u64 x, u64 b){ x -= x%b; return(x); } -function imem -round_down_imem(imem x, imem b){ - x -= x%b; - return(x); -} -function umem -round_down_umem(umem x, umem b){ - x -= x%b; - return(x); -} function f32 f32_integer(f32 x){ @@ -171,7 +149,7 @@ round_up_pot_u32(u32 x){ //////////////////////////////// function Data -make_data(void *memory, umem size){ +make_data(void *memory, u64 size){ Data data = {(u8*)memory, size}; return(data); } @@ -188,7 +166,7 @@ global_const Data zero_data = {}; //////////////////////////////// function void -block_zero(void *mem, umem size){ +block_zero(void *mem, u64 size){ for (u8 *p = (u8*)mem, *e = p + size; p < e; p += 1){ *p = 0; } @@ -198,7 +176,7 @@ block_zero(Data data){ block_zero(data.data, data.size); } function void -block_fill_ones(void *mem, umem size){ +block_fill_ones(void *mem, u64 size){ for (u8 *p = (u8*)mem, *e = p + size; p < e; p += 1){ *p = 0xFF; } @@ -208,7 +186,7 @@ block_fill_ones(Data data){ block_fill_ones(data.data, data.size); } function void -block_copy(void *dst, const void *src, umem size){ +block_copy(void *dst, const void *src, u64 size){ u8 *d = (u8*)dst; u8 *s = (u8*)src; if (d < s){ @@ -227,7 +205,7 @@ block_copy(void *dst, const void *src, umem size){ } } function b32 -block_match(void *a, void *b, umem size){ +block_match(void *a, void *b, u64 size){ b32 result = true; for (u8 *pa = (u8*)a, *pb = (u8*)b, *ea = pa + size; pa < ea; pa += 1, pb += 1){ if (*pa != *pb){ @@ -238,7 +216,7 @@ block_match(void *a, void *b, umem size){ return(result); } function i32 -block_compare(void *a, void *b, umem size){ +block_compare(void *a, void *b, u64 size){ i32 result = 0; for (u8 *pa = (u8*)a, *pb = (u8*)b, *ea = pa + size; pa < ea; pa += 1, pb += 1){ i32 dif = (i32)*pa - (i32)*pb; @@ -250,31 +228,31 @@ block_compare(void *a, void *b, umem size){ return(result); } function void -block_fill_u8(void *a, umem size, u8 val){ +block_fill_u8(void *a, u64 size, u8 val){ for (u8 *ptr = (u8*)a, *e = ptr + size; ptr < e; ptr += 1){ *ptr = val; } } function void -block_fill_u16(void *a, umem size, u16 val){ +block_fill_u16(void *a, u64 size, u16 val){ Assert(size%sizeof(u16) == 0); - umem count = size/sizeof(u16); + u64 count = size/sizeof(u16); for (u16 *ptr = (u16*)a, *e = ptr + count; ptr < e; ptr += 1){ *ptr = val; } } function void -block_fill_u32(void *a, umem size, u32 val){ +block_fill_u32(void *a, u64 size, u32 val){ Assert(size%sizeof(u32) == 0); - umem count = size/sizeof(u32); + u64 count = size/sizeof(u32); for (u32 *ptr = (u32*)a, *e = ptr + count; ptr < e; ptr += 1){ *ptr = val; } } function void -block_fill_u64(void *a, umem size, u64 val){ +block_fill_u64(void *a, u64 size, u64 val){ Assert(size%sizeof(u64) == 0); - umem count = size/sizeof(u64); + u64 count = size/sizeof(u64); for (u64 *ptr = (u64*)a, *e = ptr + count; ptr < e; ptr += 1){ *ptr = val; } @@ -292,12 +270,20 @@ block_fill_u64(void *a, umem size, u64 val){ #define block_match_array(a,b) block_match((a), (b), sizeof(a)) function void -block_copy_array_shift__inner(void *dst, void *src, umem it_size, Interval_i64 range, i64 shift){ +block_copy_array_shift__inner(void *dst, void *src, u64 it_size, Range_i64 range, i64 shift){ u8 *dptr = (u8*)dst; u8 *sptr = (u8*)src; dptr += it_size*(range.first + shift); sptr += it_size*range.first; - block_copy(dptr, sptr, it_size*(range.one_past_last - range.first)); + block_copy(dptr, sptr, (u64)(it_size*(range.one_past_last - range.first))); +} +function void +block_copy_array_shift__inner(void *dst, void *src, u64 it_size, Range_i32 range, i64 shift){ + u8 *dptr = (u8*)dst; + u8 *sptr = (u8*)src; + dptr += it_size*(range.first + shift); + sptr += it_size*range.first; + block_copy(dptr, sptr, (u64)(it_size*(range.one_past_last - range.first))); } #define block_copy_array_shift(d,s,r,h) block_copy_array_shift__inner((d),(s),sizeof(*(d)),(r),(h)) @@ -1507,7 +1493,7 @@ lerp(f32 a, f32 t, f32 b){ } function f32 -lerp(f32 t, Interval_f32 x){ +lerp(f32 t, Range_f32 x){ return(x.min + (x.max - x.min)*t); } @@ -1697,36 +1683,36 @@ hsla_to_rgba(Vec4_f32 hsla){ //////////////////////////////// -function Interval_i32 +function Range_i32 Ii32(i32 a, i32 b){ - Interval_i32 interval = {a, b}; + Range_i32 interval = {a, b}; if (b < a){ interval.min = b; interval.max = a; } return(interval); } -function Interval_i64 +function Range_i64 Ii64(i64 a, i64 b){ - Interval_i64 interval = {a, b}; + Range_i64 interval = {a, b}; if (b < a){ interval.min = b; interval.max = a; } return(interval); } -function Interval_u64 +function Range_u64 Iu64(u64 a, u64 b){ - Interval_u64 interval = {a, b}; + Range_u64 interval = {a, b}; if (b < a){ interval.min = b; interval.max = a; } return(interval); } -function Interval_f32 +function Range_f32 If32(f32 a, f32 b){ - Interval_f32 interval = {a, b}; + Range_f32 interval = {a, b}; if (b < a){ interval.min = b; interval.max = a; @@ -1734,84 +1720,84 @@ If32(f32 a, f32 b){ return(interval); } -function Interval_i32 +function Range_i32 Ii32_size(i32 pos, i32 size){ return(Ii32(pos, pos + size)); } -function Interval_i64 +function Range_i64 Ii64_size(i64 pos, i64 size){ return(Ii64(pos, pos + size)); } -function Interval_u64 +function Range_u64 Iu64_size(u64 pos, u64 size){ return(Iu64(pos, pos + size)); } -function Interval_f32 +function Range_f32 If32_size(f32 pos, f32 size){ return(If32(pos, pos + size)); } -function Interval_i32 +function Range_i32 Ii32(i32 a){ - Interval_i32 interval = {a, a}; + Range_i32 interval = {a, a}; return(interval); } -function Interval_i64 +function Range_i64 Ii64(i64 a){ - Interval_i64 interval = {a, a}; + Range_i64 interval = {a, a}; return(interval); } -function Interval_u64 +function Range_u64 Iu64(u64 a){ - Interval_u64 interval = {a, a}; + Range_u64 interval = {a, a}; return(interval); } -function Interval_f32 +function Range_f32 If32(f32 a){ - Interval_f32 interval = {a, a}; + Range_f32 interval = {a, a}; return(interval); } -function Interval_i32 +function Range_i32 Ii32(){ - Interval_i32 interval = {}; + Range_i32 interval = {}; return(interval); } -function Interval_i64 +function Range_i64 Ii64(){ - Interval_i64 interval = {}; + Range_i64 interval = {}; return(interval); } -function Interval_u64 +function Range_u64 Iu64(){ - Interval_u64 interval = {}; + Range_u64 interval = {}; return(interval); } -function Interval_f32 +function Range_f32 If32(){ - Interval_f32 interval = {}; + Range_f32 interval = {}; return(interval); } -global Interval_i32 Ii32_neg_inf = {max_i32, min_i32}; -global Interval_i64 Ii64_neg_inf = {max_i64, min_i64}; -global Interval_u64 Iu64_neg_inf = {max_u64, 0}; -global Interval_f32 If32_neg_inf = {max_f32, -max_f32}; +global Range_i32 Ii32_neg_inf = {max_i32, min_i32}; +global Range_i64 Ii64_neg_inf = {max_i64, min_i64}; +global Range_u64 Iu64_neg_inf = {max_u64, 0}; +global Range_f32 If32_neg_inf = {max_f32, -max_f32}; function b32 -operator==(Interval_i32 a, Interval_i32 b){ +operator==(Range_i32 a, Range_i32 b){ return(a.min == b.min && a.max == b.max); } function b32 -operator==(Interval_i64 a, Interval_i64 b){ +operator==(Range_i64 a, Range_i64 b){ return(a.min == b.min && a.max == b.max); } function b32 -operator==(Interval_u64 a, Interval_u64 b){ +operator==(Range_u64 a, Range_u64 b){ return(a.min == b.min && a.max == b.max); } function b32 -operator==(Interval_f32 a, Interval_f32 b){ +operator==(Range_f32 a, Range_f32 b){ return(a.min == b.min && a.max == b.max); } @@ -1966,185 +1952,185 @@ range_intersect(Range_f32 a, Range_f32 b){ return(result); } -function Interval_i32 -range_union(Interval_i32 a, Interval_i32 b){ +function Range_i32 +range_union(Range_i32 a, Range_i32 b){ return(Ii32(Min(a.min, b.min), Max(a.max, b.max))); } -function Interval_i64 -range_union(Interval_i64 a, Interval_i64 b){ +function Range_i64 +range_union(Range_i64 a, Range_i64 b){ return(Ii64(Min(a.min, b.min), Max(a.max, b.max))); } -function Interval_u64 -range_union(Interval_u64 a, Interval_u64 b){ +function Range_u64 +range_union(Range_u64 a, Range_u64 b){ return(Iu64(Min(a.min, b.min), Max(a.max, b.max))); } -function Interval_f32 -range_union(Interval_f32 a, Interval_f32 b){ +function Range_f32 +range_union(Range_f32 a, Range_f32 b){ return(If32(Min(a.min, b.min), Max(a.max, b.max))); } function b32 -range_contains_inclusive(Interval_i32 a, i32 p){ +range_contains_inclusive(Range_i32 a, i32 p){ return(a.min <= p && p <= a.max); } function b32 -range_contains_inclusive(Interval_i64 a, i64 p){ +range_contains_inclusive(Range_i64 a, i64 p){ return(a.min <= p && p <= a.max); } function b32 -range_contains_inclusive(Interval_u64 a, u64 p){ +range_contains_inclusive(Range_u64 a, u64 p){ return(a.min <= p && p <= a.max); } function b32 -range_inclusive_contains(Interval_f32 a, f32 p){ +range_inclusive_contains(Range_f32 a, f32 p){ return(a.min <= p && p <= a.max); } function b32 -range_contains(Interval_i32 a, i32 p){ +range_contains(Range_i32 a, i32 p){ return(a.min <= p && p < a.max); } function b32 -range_contains(Interval_i64 a, i64 p){ +range_contains(Range_i64 a, i64 p){ return(a.min <= p && p < a.max); } function b32 -range_contains(Interval_u64 a, u64 p){ +range_contains(Range_u64 a, u64 p){ return(a.min <= p && p < a.max); } function b32 -range_contains(Interval_f32 a, f32 p){ +range_contains(Range_f32 a, f32 p){ return(a.min <= p && p < a.max); } function i32 -range_size(Interval_i32 a){ +range_size(Range_i32 a){ i32 size = a.max - a.min; size = clamp_bot(0, size); return(size); } function i64 -range_size(Interval_i64 a){ +range_size(Range_i64 a){ i64 size = a.max - a.min; size = clamp_bot(0, size); return(size); } function u64 -range_size(Interval_u64 a){ +range_size(Range_u64 a){ u64 size = a.max - a.min; size = clamp_bot(0, size); return(size); } function f32 -range_size(Interval_f32 a){ +range_size(Range_f32 a){ f32 size = a.max - a.min; size = clamp_bot(0, size); return(size); } function i32 -range_size_inclusive(Interval_i32 a){ +range_size_inclusive(Range_i32 a){ i32 size = a.max - a.min + 1; size = clamp_bot(0, size); return(size); } function i64 -range_size_inclusive(Interval_i64 a){ +range_size_inclusive(Range_i64 a){ i64 size = a.max - a.min + 1; size = clamp_bot(0, size); return(size); } function u64 -range_size_inclusive(Interval_u64 a){ +range_size_inclusive(Range_u64 a){ u64 size = a.max - a.min + 1; size = clamp_bot(0, size); return(size); } function f32 -range_size_inclusive(Interval_f32 a){ +range_size_inclusive(Range_f32 a){ f32 size = a.max - a.min + 1; size = clamp_bot(0, size); return(size); } -function Interval_i32 -rectify(Interval_i32 a){ +function Range_i32 +rectify(Range_i32 a){ return(Ii32(a.min, a.max)); } -function Interval_i64 -rectify(Interval_i64 a){ +function Range_i64 +rectify(Range_i64 a){ return(Ii64(a.min, a.max)); } -function Interval_u64 -rectify(Interval_u64 a){ +function Range_u64 +rectify(Range_u64 a){ return(Iu64(a.min, a.max)); } -function Interval_f32 -rectify(Interval_f32 a){ +function Range_f32 +rectify(Range_f32 a){ return(If32(a.min, a.max)); } -function Interval_i32 -range_clamp_size(Interval_i32 a, i32 max_size){ +function Range_i32 +range_clamp_size(Range_i32 a, i32 max_size){ i32 max = a.min + max_size; a.max = clamp_top(a.max, max); return(a); } -function Interval_i64 -range_clamp_size(Interval_i64 a, i64 max_size){ +function Range_i64 +range_clamp_size(Range_i64 a, i64 max_size){ i64 max = a.min + max_size; a.max = clamp_top(a.max, max); return(a); } -function Interval_u64 -range_clamp_size(Interval_u64 a, u64 max_size){ +function Range_u64 +range_clamp_size(Range_u64 a, u64 max_size){ u64 max = a.min + max_size; a.max = clamp_top(a.max, max); return(a); } -function Interval_f32 -range_clamp_size(Interval_f32 a, f32 max_size){ +function Range_f32 +range_clamp_size(Range_f32 a, f32 max_size){ f32 max = a.min + max_size; a.max = clamp_top(a.max, max); return(a); } function b32 -range_is_valid(Interval_i32 a){ +range_is_valid(Range_i32 a){ return(a.min <= a.max); } function b32 -range_is_valid(Interval_i64 a){ +range_is_valid(Range_i64 a){ return(a.min <= a.max); } function b32 -range_is_valid(Interval_u64 a){ +range_is_valid(Range_u64 a){ return(a.min <= a.max); } function b32 -range_is_valid(Interval_f32 a){ +range_is_valid(Range_f32 a){ return(a.min <= a.max); } function i32 -range_side(Interval_i32 a, Side side){ +range_side(Range_i32 a, Side side){ return(side == Side_Min?a.min:a.max); } function i64 -range_side(Interval_i64 a, Side side){ +range_side(Range_i64 a, Side side){ return(side == Side_Min?a.min:a.max); } function u64 -range_side(Interval_u64 a, Side side){ +range_side(Range_u64 a, Side side){ return(side == Side_Min?a.min:a.max); } function f32 -range_side(Interval_f32 a, Side side){ +range_side(Range_f32 a, Side side){ return(side == Side_Min?a.min:a.max); } function i32 -range_distance(Interval_i32 a, Interval_i32 b){ +range_distance(Range_i32 a, Range_i32 b){ i32 result = 0; if (!range_overlap(a, b)){ if (a.max < b.min){ @@ -2157,7 +2143,7 @@ range_distance(Interval_i32 a, Interval_i32 b){ return(result); } function i64 -range_distance(Interval_i64 a, Interval_i64 b){ +range_distance(Range_i64 a, Range_i64 b){ i64 result = 0; if (!range_overlap(a, b)){ if (a.max < b.min){ @@ -2170,7 +2156,7 @@ range_distance(Interval_i64 a, Interval_i64 b){ return(result); } function u64 -range_distance(Interval_u64 a, Interval_u64 b){ +range_distance(Range_u64 a, Range_u64 b){ u64 result = 0; if (!range_overlap(a, b)){ if (a.max < b.min){ @@ -2183,7 +2169,7 @@ range_distance(Interval_u64 a, Interval_u64 b){ return(result); } function f32 -range_distance(Interval_f32 a, Interval_f32 b){ +range_distance(Range_f32 a, Range_f32 b){ f32 result = 0; if (!range_overlap(a, b)){ if (a.max < b.min){ @@ -2207,7 +2193,7 @@ replace_range_shift(i32 start, i32 end, i32 insert_length){ return(insert_length - (end - start)); } function i32 -replace_range_shift(Interval_i32 range, i32 insert_length){ +replace_range_shift(Range_i32 range, i32 insert_length){ return(insert_length - (range.end - range.start)); } function i64 @@ -2219,7 +2205,7 @@ replace_range_shift(i64 start, i64 end, i64 insert_length){ return(insert_length - (end - start)); } function i64 -replace_range_shift(Interval_i64 range, i64 insert_length){ +replace_range_shift(Range_i64 range, i64 insert_length){ return(insert_length - (range.end - range.start)); } function i64 @@ -2231,7 +2217,7 @@ replace_range_shift(i64 start, i64 end, u64 insert_length){ return((i64)insert_length - (end - start)); } function i64 -replace_range_shift(Interval_i64 range, u64 insert_length){ +replace_range_shift(Range_i64 range, u64 insert_length){ return((i64)insert_length - (range.end - range.start)); } @@ -2378,19 +2364,19 @@ rect_center(Rect_f32 r){ return((r.p0 + r.p1)*0.5f); } -function Interval_i32 +function Range_i32 rect_range_x(Rect_i32 r){ return(Ii32(r.x0, r.x1)); } -function Interval_i32 +function Range_i32 rect_range_y(Rect_i32 r){ return(Ii32(r.y0, r.y1)); } -function Interval_f32 +function Range_f32 rect_range_x(Rect_f32 r){ return(If32(r.x0, r.x1)); } -function Interval_f32 +function Range_f32 rect_range_y(Rect_f32 r){ return(If32(r.y0, r.y1)); } @@ -2545,54 +2531,54 @@ flip_side(Side side){ //////////////////////////////// -function umem +function u64 cstring_length(char *str){ - umem length = 0; + u64 length = 0; for (;str[length] != 0; length += 1); return(length); } -function umem +function u64 cstring_length(u8 *str){ - umem length = 0; + u64 length = 0; for (;str[length] != 0; length += 1); return(length); } -function umem +function u64 cstring_length(u16 *str){ - umem length = 0; + u64 length = 0; for (;str[length] != 0; length += 1); return(length); } -function umem +function u64 cstring_length(u32 *str){ - umem length = 0; + u64 length = 0; for (;str[length] != 0; length += 1); return(length); } function String_char -Schar(char *str, umem size, umem cap){ +Schar(char *str, u64 size, u64 cap){ String_char string = {str, size, cap}; return(string); } function String_u8 -Su8(u8 *str, umem size, umem cap){ +Su8(u8 *str, u64 size, u64 cap){ String_u8 string = {str, size, cap}; return(string); } function String_u16 -Su16(u16 *str, umem size, umem cap){ +Su16(u16 *str, u64 size, u64 cap){ String_u16 string = {str, size, cap}; return(string); } function String_u32 -Su32(u32 *str, umem size, umem cap){ +Su32(u32 *str, u64 size, u64 cap){ String_u32 string = {str, size, cap}; return(string); } function String_Any -Sany(void *str, umem size, umem cap, String_Encoding encoding){ +Sany(void *str, u64 size, u64 cap, String_Encoding encoding){ String_Any string = {encoding}; switch (encoding){ case StringEncoding_ASCII: string.s_char = Schar((char*)str, size, cap); break; @@ -2604,28 +2590,28 @@ Sany(void *str, umem size, umem cap, String_Encoding encoding){ } function String_char -Schar(char *str, umem size){ +Schar(char *str, u64 size){ String_char string = {str, size, size + 1}; return(string); } function String_u8 -Su8(u8 *str, umem size){ +Su8(u8 *str, u64 size){ String_u8 string = {str, size, size + 1}; return(string); } function String_u16 -Su16(u16 *str, umem size){ +Su16(u16 *str, u64 size){ String_u16 string = {str, size, size + 1}; return(string); } function String_u32 -Su32(u32 *str, umem size){ +Su32(u32 *str, u64 size){ String_u32 string = {str, size, size + 1}; return(string); } function String_Any -Sany(void *str, umem size, String_Encoding encoding){ +Sany(void *str, u64 size, String_Encoding encoding){ String_Any string = {encoding}; switch (encoding){ case StringEncoding_ASCII: string.s_char = Schar((char*)str, size); break; @@ -2638,19 +2624,19 @@ Sany(void *str, umem size, String_Encoding encoding){ function String_char Schar(char *str, char *one_past_last){ - return(Schar(str, (umem)(one_past_last - str))); + return(Schar(str, (u64)(one_past_last - str))); } function String_u8 Su8(u8 *str, u8 *one_past_last){ - return(Su8(str, (umem)(one_past_last - str))); + return(Su8(str, (u64)(one_past_last - str))); } function String_u16 Su16(u16 *str, u16 *one_past_last){ - return(Su16(str, (umem)(one_past_last - str))); + return(Su16(str, (u64)(one_past_last - str))); } function String_u32 Su32(u32 *str, u32 *one_past_last){ - return(Su32(str, (umem)(one_past_last - str))); + return(Su32(str, (u64)(one_past_last - str))); } function String_Any @@ -2667,25 +2653,25 @@ Sany(void *str, void *one_past_last, String_Encoding encoding){ function String_char Schar(char *str){ - umem size = cstring_length(str); + u64 size = cstring_length(str); String_char string = {str, size, size + 1}; return(string); } function String_u8 Su8(u8 *str){ - umem size = cstring_length(str); + u64 size = cstring_length(str); String_u8 string = {str, size, size + 1}; return(string); } function String_u16 Su16(u16 *str){ - umem size = cstring_length(str); + u64 size = cstring_length(str); String_u16 string = {str, size, size + 1}; return(string); } function String_u32 Su32(u32 *str){ - umem size = cstring_length(str); + u64 size = cstring_length(str); String_u32 string = {str, size, size + 1}; return(string); } @@ -2703,22 +2689,22 @@ Sany(void *str, String_Encoding encoding){ } function String_char -Schar(String_Const_char str, umem cap){ +Schar(String_Const_char str, u64 cap){ String_char string = {str.str, str.size, cap}; return(string); } function String_u8 -Su8(String_Const_u8 str, umem cap){ +Su8(String_Const_u8 str, u64 cap){ String_u8 string = {str.str, str.size, cap}; return(string); } function String_u16 -Su16(String_Const_u16 str, umem cap){ +Su16(String_Const_u16 str, u64 cap){ String_u16 string = {str.str, str.size, cap}; return(string); } function String_u32 -Su32(String_Const_u32 str, umem cap){ +Su32(String_Const_u32 str, u64 cap){ String_u32 string = {str.str, str.size, cap}; return(string); } @@ -2749,28 +2735,28 @@ SCany(String_u32 str){ } function String_Const_char -SCchar(char *str, umem size){ +SCchar(char *str, u64 size){ String_Const_char string = {str, size}; return(string); } function String_Const_u8 -SCu8(u8 *str, umem size){ +SCu8(u8 *str, u64 size){ String_Const_u8 string = {str, size}; return(string); } function String_Const_u16 -SCu16(u16 *str, umem size){ +SCu16(u16 *str, u64 size){ String_Const_u16 string = {str, size}; return(string); } function String_Const_u32 -SCu32(u32 *str, umem size){ +SCu32(u32 *str, u64 size){ String_Const_u32 string = {str, size}; return(string); } function String_Const_Any -SCany(void *str, umem size, String_Encoding encoding){ +SCany(void *str, u64 size, String_Encoding encoding){ String_Const_Any string = {encoding}; switch (encoding){ case StringEncoding_ASCII: string.s_char = SCchar((char*)str, size); break; @@ -2804,19 +2790,19 @@ SCu32(void){ function String_Const_char SCchar(char *str, char *one_past_last){ - return(SCchar(str, (umem)(one_past_last - str))); + return(SCchar(str, (u64)(one_past_last - str))); } function String_Const_u8 SCu8(u8 *str, u8 *one_past_last){ - return(SCu8(str, (umem)(one_past_last - str))); + return(SCu8(str, (u64)(one_past_last - str))); } function String_Const_u16 SCu16(u16 *str, u16 *one_past_last){ - return(SCu16(str, (umem)(one_past_last - str))); + return(SCu16(str, (u64)(one_past_last - str))); } function String_Const_u32 SCu32(u32 *str, u32 *one_past_last){ - return(SCu32(str, (umem)(one_past_last - str))); + return(SCu32(str, (u64)(one_past_last - str))); } function String_Const_Any @@ -2833,25 +2819,25 @@ SCany(void *str, void *one_past_last, String_Encoding encoding){ function String_Const_char SCchar(char *str){ - umem size = cstring_length(str); + u64 size = cstring_length(str); String_Const_char string = {str, size}; return(string); } function String_Const_u8 SCu8(u8 *str){ - umem size = cstring_length(str); + u64 size = cstring_length(str); String_Const_u8 string = {str, size}; return(string); } function String_Const_u16 SCu16(u16 *str){ - umem size = cstring_length(str); + u64 size = cstring_length(str); String_Const_u16 string = {str, size}; return(string); } function String_Const_u32 SCu32(u32 *str){ - umem size = cstring_length(str); + u64 size = cstring_length(str); String_Const_u32 string = {str, size}; return(string); } @@ -2866,7 +2852,7 @@ SCu8(String_Const_char str){ } function String_Const_u8 -SCu8(char *str, umem length){ +SCu8(char *str, u64 length){ return(SCu8((u8*)str, length)); } function String_Const_u8 @@ -2884,7 +2870,7 @@ SCu8(Data data){ } function String_Const_u16 -SCu16(wchar_t *str, umem size){ +SCu16(wchar_t *str, u64 size){ return(SCu16((u16*)str, size)); } function String_Const_u16 @@ -2931,9 +2917,9 @@ SCany(String_Const_u32 str){ #define string_litexpr(s) SCchar((s), sizeof(s) - 1) #define string_litinit(s) {(s), sizeof(s) - 1} -#define string_u8_litexpr(s) SCu8((u8*)(s), sizeof(s) - 1) +#define string_u8_litexpr(s) SCu8((u8*)(s), (u64)(sizeof(s) - 1)) #define string_u8_litinit(s) {(u8*)(s), sizeof(s) - 1} -#define string_u16_litexpr(s) SCu16((u16*)(s), sizeof(s)/2 - 1) +#define string_u16_litexpr(s) SCu16((u16*)(s), (u64)(sizeof(s)/2 - 1)) #define string_expand(s) (i32)(s).size, (char*)(s).str @@ -2945,18 +2931,18 @@ function String_Const_u8 string_u8_empty = {(u8*)"", 0}; //////////////////////////////// function void* -base_reserve__noop(void *user_data, umem size, umem *size_out, String_Const_u8 location){ +base_reserve__noop(void *user_data, u64 size, u64 *size_out, String_Const_u8 location){ *size_out = 0; return(0); } function void -base_commit__noop(void *user_data, void *ptr, umem size){} +base_commit__noop(void *user_data, void *ptr, u64 size){} function void -base_uncommit__noop(void *user_data, void *ptr, umem size){} +base_uncommit__noop(void *user_data, void *ptr, u64 size){} function void base_free__noop(void *user_data, void *ptr){} function void -base_set_access__noop(void *user_data, void *ptr, umem size, Access_Flag flags){} +base_set_access__noop(void *user_data, void *ptr, u64 size, Access_Flag flags){} function Base_Allocator make_base_allocator(Base_Allocator_Reserve_Signature *func_reserve, @@ -2991,11 +2977,11 @@ make_base_allocator(Base_Allocator_Reserve_Signature *func_reserve, return(base_allocator); } function Data -base_allocate__inner(Base_Allocator *allocator, umem size, String_Const_u8 location){ - umem full_size = 0; +base_allocate__inner(Base_Allocator *allocator, u64 size, String_Const_u8 location){ + u64 full_size = 0; void *memory = allocator->reserve(allocator->user_data, size, &full_size, location); allocator->commit(allocator->user_data, memory, full_size); - return(make_data(memory, full_size)); + return(make_data(memory, (u64)full_size)); } function void base_free(Base_Allocator *allocator, void *ptr){ @@ -3011,7 +2997,7 @@ base_free(Base_Allocator *allocator, void *ptr){ //////////////////////////////// function Cursor -make_cursor(void *base, umem size){ +make_cursor(void *base, u64 size){ Cursor cursor = {(u8*)base, 0, size}; return(cursor); } @@ -3020,12 +3006,12 @@ make_cursor(Data data){ return(make_cursor(data.data, data.size)); } function Cursor -make_cursor(Base_Allocator *allocator, umem size){ +make_cursor(Base_Allocator *allocator, u64 size){ Data memory = base_allocate(allocator, size); return(make_cursor(memory)); } function Data -linalloc_push(Cursor *cursor, umem size, String_Const_u8 location){ +linalloc_push(Cursor *cursor, u64 size, String_Const_u8 location){ Data result = {}; if (cursor->pos + size <= cursor->cap){ result.data = cursor->base + cursor->pos; @@ -3035,7 +3021,7 @@ linalloc_push(Cursor *cursor, umem size, String_Const_u8 location){ return(result); } function void -linalloc_pop(Cursor *cursor, umem size){ +linalloc_pop(Cursor *cursor, u64 size){ if (cursor->pos > size){ cursor->pos -= size; } @@ -3044,9 +3030,9 @@ linalloc_pop(Cursor *cursor, umem size){ } } function Data -linalloc_align(Cursor *cursor, umem alignment){ - umem pos = round_up_umem(cursor->pos, alignment); - umem new_size = pos - cursor->pos; +linalloc_align(Cursor *cursor, u64 alignment){ + u64 pos = round_up_u64(cursor->pos, alignment); + u64 new_size = pos - cursor->pos; return(linalloc_push(cursor, new_size, file_name_line_number_lit_u8)); } function Temp_Memory_Cursor @@ -3063,12 +3049,12 @@ linalloc_clear(Cursor *cursor){ cursor->pos = 0; } function Arena -make_arena(Base_Allocator *allocator, umem chunk_size, umem alignment){ +make_arena(Base_Allocator *allocator, u64 chunk_size, u64 alignment){ Arena arena = {allocator, 0, chunk_size, alignment}; return(arena); } function Arena -make_arena(Base_Allocator *allocator, umem chunk_size){ +make_arena(Base_Allocator *allocator, u64 chunk_size){ return(make_arena(allocator, chunk_size, 8)); } function Arena @@ -3076,7 +3062,7 @@ make_arena(Base_Allocator *allocator){ return(make_arena(allocator, KB(64), 8)); } function Cursor_Node* -arena__new_node(Arena *arena, umem min_size, String_Const_u8 location){ +arena__new_node(Arena *arena, u64 min_size, String_Const_u8 location){ min_size = clamp_bot(min_size, arena->chunk_size); Data memory = base_allocate__inner(arena->base_allocator, min_size + sizeof(Cursor_Node), location); Cursor_Node *cursor_node = (Cursor_Node*)memory.data; @@ -3085,7 +3071,7 @@ arena__new_node(Arena *arena, umem min_size, String_Const_u8 location){ return(cursor_node); } function Data -linalloc_push(Arena *arena, umem size, String_Const_u8 location){ +linalloc_push(Arena *arena, u64 size, String_Const_u8 location){ Data result = {}; if (size > 0){ Cursor_Node *cursor_node = arena->cursor_node; @@ -3103,7 +3089,7 @@ linalloc_push(Arena *arena, umem size, String_Const_u8 location){ return(result); } function void -linalloc_pop(Arena *arena, umem size){ +linalloc_pop(Arena *arena, u64 size){ Base_Allocator *allocator = arena->base_allocator; Cursor_Node *cursor_node = arena->cursor_node; for (Cursor_Node *prev = 0; @@ -3122,7 +3108,7 @@ linalloc_pop(Arena *arena, umem size){ arena->cursor_node = cursor_node; } function Data -linalloc_align(Arena *arena, umem alignment){ +linalloc_align(Arena *arena, u64 alignment){ arena->alignment = alignment; Data data = {}; Cursor_Node *cursor_node = arena->cursor_node; @@ -3174,7 +3160,7 @@ linalloc_wrap_zero(Data data){ return(data.data); } function void* -linalloc_wrap_write(Data data, umem size, void *src){ +linalloc_wrap_write(Data data, u64 size, void *src){ block_copy(data.data, src, clamp_top(data.size, size)); return(data.data); } @@ -3237,7 +3223,7 @@ thread_ctx_release(Thread_Context *tctx){ } function Arena* -reserve_arena(Thread_Context *tctx, umem chunk_size, umem align){ +reserve_arena(Thread_Context *tctx, u64 chunk_size, u64 align){ Arena_Node *node = tctx->free_arenas; if (node != 0){ sll_stack_pop(tctx->free_arenas); @@ -3250,7 +3236,7 @@ reserve_arena(Thread_Context *tctx, umem chunk_size, umem align){ } function Arena* -reserve_arena(Thread_Context *tctx, umem chunk_size){ +reserve_arena(Thread_Context *tctx, u64 chunk_size){ return(reserve_arena(tctx, chunk_size, 8)); } @@ -3415,7 +3401,7 @@ heap_free_all(Heap *heap){ } function void -heap__extend(Heap *heap, void *memory, umem size){ +heap__extend(Heap *heap, void *memory, u64 size){ heap_assert_good(heap); if (size >= sizeof(Heap_Node)){ Heap_Node *new_node = (Heap_Node*)memory; @@ -3428,18 +3414,18 @@ heap__extend(Heap *heap, void *memory, umem size){ } function void -heap__extend_automatic(Heap *heap, umem size){ +heap__extend_automatic(Heap *heap, u64 size){ void *memory = push_array(heap->arena, u8, size); heap__extend(heap, memory, size); } function void* -heap__reserve_chunk(Heap *heap, Heap_Node *node, umem size){ +heap__reserve_chunk(Heap *heap, Heap_Node *node, u64 size){ u8 *ptr = (u8*)(node + 1); Assert(node->size >= size); - umem left_over_size = node->size - size; + u64 left_over_size = node->size - size; if (left_over_size > sizeof(*node)){ - umem new_node_size = left_over_size - sizeof(*node); + u64 new_node_size = left_over_size - sizeof(*node); Heap_Node *new_node = (Heap_Node*)(ptr + size); heap__insert_next(&node->order, &new_node->order); heap__insert_next(&node->alloc, &new_node->alloc); @@ -3454,12 +3440,12 @@ heap__reserve_chunk(Heap *heap, Heap_Node *node, umem size){ } function void* -heap_allocate(Heap *heap, umem size){ +heap_allocate(Heap *heap, u64 size){ b32 first_try = true; for (;;){ if (heap->in_order.next != 0){ heap_assert_good(heap); - umem aligned_size = (size + sizeof(Heap_Node) - 1); + u64 aligned_size = (size + sizeof(Heap_Node) - 1); aligned_size = aligned_size - (aligned_size%sizeof(Heap_Node)); for (Heap_Basic_Node *n = heap->free_nodes.next; n != &heap->free_nodes; @@ -3475,7 +3461,7 @@ heap_allocate(Heap *heap, umem size){ } if (first_try){ - umem extension_size = clamp_bot(KB(64), size*2); + u64 extension_size = clamp_bot(KB(64), size*2); heap__extend_automatic(heap, extension_size); first_try = false; } @@ -3524,7 +3510,7 @@ heap_free(Heap *heap, void *memory){ //////////////////////////////// function void* -base_reserve__heap(void *user_data, umem size, umem *size_out, String_Const_u8 location){ +base_reserve__heap(void *user_data, u64 size, u64 *size_out, String_Const_u8 location){ Heap *heap = (Heap*)user_data; void *memory = heap_allocate(heap, size); *size_out = size; @@ -3545,7 +3531,7 @@ base_allocator_on_heap(Heap *heap){ //////////////////////////////// function Data -push_data(Arena *arena, umem size){ +push_data(Arena *arena, u64 size){ Data result = {}; result.data = push_array(arena, u8, size); result.size = size; @@ -3847,7 +3833,7 @@ character_is_alpha_numeric_unicode(u32 c){ } function char -string_get_character(String_Const_char str, umem i){ +string_get_character(String_Const_char str, u64 i){ char r = 0; if (i < str.size){ r = str.str[i]; @@ -3855,7 +3841,7 @@ string_get_character(String_Const_char str, umem i){ return(r); } function u8 -string_get_character(String_Const_u8 str, umem i){ +string_get_character(String_Const_u8 str, u64 i){ u8 r = 0; if (i < str.size){ r = str.str[i]; @@ -3863,7 +3849,7 @@ string_get_character(String_Const_u8 str, umem i){ return(r); } function u16 -string_get_character(String_Const_u16 str, umem i){ +string_get_character(String_Const_u16 str, u64 i){ u16 r = 0; if (i < str.size){ r = str.str[i]; @@ -3871,7 +3857,7 @@ string_get_character(String_Const_u16 str, umem i){ return(r); } function u32 -string_get_character(String_Const_u32 str, umem i){ +string_get_character(String_Const_u32 str, u64 i){ u32 r = 0; if (i < str.size){ r = str.str[i]; @@ -3880,32 +3866,32 @@ string_get_character(String_Const_u32 str, umem i){ } function String_Const_char -string_prefix(String_Const_char str, umem size){ +string_prefix(String_Const_char str, u64 size){ size = clamp_top(size, str.size); str.size = size; return(str); } function String_Const_u8 -string_prefix(String_Const_u8 str, umem size){ +string_prefix(String_Const_u8 str, u64 size){ size = clamp_top(size, str.size); str.size = size; return(str); } function String_Const_u16 -string_prefix(String_Const_u16 str, umem size){ +string_prefix(String_Const_u16 str, u64 size){ size = clamp_top(size, str.size); str.size = size; return(str); } function String_Const_u32 -string_prefix(String_Const_u32 str, umem size){ +string_prefix(String_Const_u32 str, u64 size){ size = clamp_top(size, str.size); str.size = size; return(str); } function String_Const_Any -string_prefix(String_Const_Any str, umem size){ +string_prefix(String_Const_Any str, u64 size){ switch (str.encoding){ case StringEncoding_ASCII: str.s_char = string_prefix(str.s_char, size); break; case StringEncoding_UTF8: str.s_u8 = string_prefix(str.s_u8 , size); break; @@ -3916,28 +3902,28 @@ string_prefix(String_Const_Any str, umem size){ } function String_Const_char -string_postfix(String_Const_char str, umem size){ +string_postfix(String_Const_char str, u64 size){ size = clamp_top(size, str.size); str.str += (str.size - size); str.size = size; return(str); } function String_Const_u8 -string_postfix(String_Const_u8 str, umem size){ +string_postfix(String_Const_u8 str, u64 size){ size = clamp_top(size, str.size); str.str += (str.size - size); str.size = size; return(str); } function String_Const_u16 -string_postfix(String_Const_u16 str, umem size){ +string_postfix(String_Const_u16 str, u64 size){ size = clamp_top(size, str.size); str.str += (str.size - size); str.size = size; return(str); } function String_Const_u32 -string_postfix(String_Const_u32 str, umem size){ +string_postfix(String_Const_u32 str, u64 size){ size = clamp_top(size, str.size); str.str += (str.size - size); str.size = size; @@ -3945,7 +3931,7 @@ string_postfix(String_Const_u32 str, umem size){ } function String_Const_Any -string_postfix(String_Const_Any str, umem size){ +string_postfix(String_Const_Any str, u64 size){ switch (str.encoding){ case StringEncoding_ASCII: str.s_char = string_postfix(str.s_char, size); break; case StringEncoding_UTF8: str.s_u8 = string_postfix(str.s_u8 , size); break; @@ -3956,28 +3942,28 @@ string_postfix(String_Const_Any str, umem size){ } function String_Const_char -string_skip(String_Const_char str, umem n){ +string_skip(String_Const_char str, u64 n){ n = clamp_top(n, str.size); str.str += n;; str.size -= n; return(str); } function String_Const_u8 -string_skip(String_Const_u8 str, umem n){ +string_skip(String_Const_u8 str, u64 n){ n = clamp_top(n, str.size); str.str += n;; str.size -= n; return(str); } function String_Const_u16 -string_skip(String_Const_u16 str, umem n){ +string_skip(String_Const_u16 str, u64 n){ n = clamp_top(n, str.size); str.str += n;; str.size -= n; return(str); } function String_Const_u32 -string_skip(String_Const_u32 str, umem n){ +string_skip(String_Const_u32 str, u64 n){ n = clamp_top(n, str.size); str.str += n;; str.size -= n; @@ -3985,7 +3971,7 @@ string_skip(String_Const_u32 str, umem n){ } function String_Const_Any -string_skip(String_Const_Any str, umem n){ +string_skip(String_Const_Any str, u64 n){ switch (str.encoding){ case StringEncoding_ASCII: str.s_char = string_skip(str.s_char, n); break; case StringEncoding_UTF8: str.s_u8 = string_skip(str.s_u8 , n); break; @@ -3996,32 +3982,32 @@ string_skip(String_Const_Any str, umem n){ } function String_Const_char -string_chop(String_Const_char str, umem n){ +string_chop(String_Const_char str, u64 n){ n = clamp_top(n, str.size); str.size -= n; return(str); } function String_Const_u8 -string_chop(String_Const_u8 str, umem n){ +string_chop(String_Const_u8 str, u64 n){ n = clamp_top(n, str.size); str.size -= n; return(str); } function String_Const_u16 -string_chop(String_Const_u16 str, umem n){ +string_chop(String_Const_u16 str, u64 n){ n = clamp_top(n, str.size); str.size -= n; return(str); } function String_Const_u32 -string_chop(String_Const_u32 str, umem n){ +string_chop(String_Const_u32 str, u64 n){ n = clamp_top(n, str.size); str.size -= n; return(str); } function String_Const_Any -string_chop(String_Const_Any str, umem n){ +string_chop(String_Const_Any str, u64 n){ switch (str.encoding){ case StringEncoding_ASCII: str.s_char = string_chop(str.s_char, n); break; case StringEncoding_UTF8: str.s_u8 = string_chop(str.s_u8 , n); break; @@ -4048,232 +4034,232 @@ string_substring(String_Const_u32 str, Range_i64 range){ return(SCu32(str.str + range.min, str.str + range.max)); } -function umem -string_find_first(String_Const_char str, umem start_pos, char c){ - umem i = start_pos; +function u64 +string_find_first(String_Const_char str, u64 start_pos, char c){ + u64 i = start_pos; for (;i < str.size && c != str.str[i]; i += 1); return(i); } -function umem -string_find_first(String_Const_u8 str, umem start_pos, u8 c){ - umem i = start_pos; +function u64 +string_find_first(String_Const_u8 str, u64 start_pos, u8 c){ + u64 i = start_pos; for (;i < str.size && c != str.str[i]; i += 1); return(i); } -function umem -string_find_first(String_Const_u16 str, umem start_pos, u16 c){ - umem i = start_pos; +function u64 +string_find_first(String_Const_u16 str, u64 start_pos, u16 c){ + u64 i = start_pos; for (;i < str.size && c != str.str[i]; i += 1); return(i); } -function umem -string_find_first(String_Const_u32 str, umem start_pos, u32 c){ - umem i = start_pos; +function u64 +string_find_first(String_Const_u32 str, u64 start_pos, u32 c){ + u64 i = start_pos; for (;i < str.size && c != str.str[i]; i += 1); return(i); } -function umem +function u64 string_find_first(String_Const_char str, char c){ return(string_find_first(str, 0, c)); } -function umem +function u64 string_find_first(String_Const_u8 str, u8 c){ return(string_find_first(str, 0, c)); } -function umem +function u64 string_find_first(String_Const_u16 str, u16 c){ return(string_find_first(str, 0, c)); } -function umem +function u64 string_find_first(String_Const_u32 str, u32 c){ return(string_find_first(str, 0, c)); } -function imem +function i64 string_find_last(String_Const_char str, char c){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && c != str.str[i]; i -= 1); return(i); } -function imem +function i64 string_find_last(String_Const_u8 str, u8 c){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && c != str.str[i]; i -= 1); return(i); } -function imem +function i64 string_find_last(String_Const_u16 str, u16 c){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && c != str.str[i]; i -= 1); return(i); } -function imem +function i64 string_find_last(String_Const_u32 str, u32 c){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && c != str.str[i]; i -= 1); return(i); } -function umem +function u64 string_find_first_whitespace(String_Const_char str){ - umem i = 0; + u64 i = 0; for (;i < str.size && !character_is_whitespace(str.str[i]); i += 1); return(i); } -function umem +function u64 string_find_first_whitespace(String_Const_u8 str){ - umem i = 0; + u64 i = 0; for (;i < str.size && !character_is_whitespace(str.str[i]); i += 1); return(i); } -function umem +function u64 string_find_first_whitespace(String_Const_u16 str){ - umem i = 0; + u64 i = 0; for (;i < str.size && !character_is_whitespace(str.str[i]); i += 1); return(i); } -function umem +function u64 string_find_first_whitespace(String_Const_u32 str){ - umem i = 0; + u64 i = 0; for (;i < str.size && !character_is_whitespace(str.str[i]); i += 1); return(i); } -function imem +function i64 string_find_last_whitespace(String_Const_char str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && !character_is_whitespace(str.str[i]); i -= 1); return(i); } -function imem +function i64 string_find_last_whitespace(String_Const_u8 str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && !character_is_whitespace(str.str[i]); i -= 1); return(i); } -function imem +function i64 string_find_last_whitespace(String_Const_u16 str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && !character_is_whitespace(str.str[i]); i -= 1); return(i); } -function imem +function i64 string_find_last_whitespace(String_Const_u32 str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && !character_is_whitespace(str.str[i]); i -= 1); return(i); } -function umem +function u64 string_find_first_non_whitespace(String_Const_char str){ - umem i = 0; + u64 i = 0; for (;i < str.size && character_is_whitespace(str.str[i]); i += 1); return(i); } -function umem +function u64 string_find_first_non_whitespace(String_Const_u8 str){ - umem i = 0; + u64 i = 0; for (;i < str.size && character_is_whitespace(str.str[i]); i += 1); return(i); } -function umem +function u64 string_find_first_non_whitespace(String_Const_u16 str){ - umem i = 0; + u64 i = 0; for (;i < str.size && character_is_whitespace(str.str[i]); i += 1); return(i); } -function umem +function u64 string_find_first_non_whitespace(String_Const_u32 str){ - umem i = 0; + u64 i = 0; for (;i < str.size && character_is_whitespace(str.str[i]); i += 1); return(i); } -function imem +function i64 string_find_last_non_whitespace(String_Const_char str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && character_is_whitespace(str.str[i]); i -= 1); return(i); } -function imem +function i64 string_find_last_non_whitespace(String_Const_u8 str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && character_is_whitespace(str.str[i]); i -= 1); return(i); } -function imem +function i64 string_find_last_non_whitespace(String_Const_u16 str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && character_is_whitespace(str.str[i]); i -= 1); return(i); } -function imem +function i64 string_find_last_non_whitespace(String_Const_u32 str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && character_is_whitespace(str.str[i]); i -= 1); return(i); } -function umem +function u64 string_find_first_slash(String_Const_char str){ - umem i = 0; + u64 i = 0; for (;i < str.size && !character_is_slash(str.str[i]); i += 1); return(i); } -function umem +function u64 string_find_first_slash(String_Const_u8 str){ - umem i = 0; + u64 i = 0; for (;i < str.size && !character_is_slash(str.str[i]); i += 1); return(i); } -function umem +function u64 string_find_first_slash(String_Const_u16 str){ - umem i = 0; + u64 i = 0; for (;i < str.size && !character_is_slash(str.str[i]); i += 1); return(i); } -function umem +function u64 string_find_first_slash(String_Const_u32 str){ - umem i = 0; + u64 i = 0; for (;i < str.size && !character_is_slash(str.str[i]); i += 1); return(i); } -function imem +function i64 string_find_last_slash(String_Const_char str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && !character_is_slash(str.str[i]); i -= 1); return(i); } -function imem +function i64 string_find_last_slash(String_Const_u8 str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && !character_is_slash(str.str[i]); i -= 1); return(i); } -function imem +function i64 string_find_last_slash(String_Const_u16 str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && !character_is_slash(str.str[i]); i -= 1); return(i); } -function imem +function i64 string_find_last_slash(String_Const_u32 str){ - imem size = (imem)str.size; - imem i = size - 1; + i64 size = (i64)str.size; + i64 i = size - 1; for (;i >= 0 && !character_is_slash(str.str[i]); i -= 1); return(i); } @@ -4283,7 +4269,7 @@ string_remove_last_folder(String_Const_char str){ if (str.size > 0){ str.size -= 1; } - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos < 0){ str.size = 0; } @@ -4297,7 +4283,7 @@ string_remove_last_folder(String_Const_u8 str){ if (str.size > 0){ str.size -= 1; } - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos < 0){ str.size = 0; } @@ -4311,7 +4297,7 @@ string_remove_last_folder(String_Const_u16 str){ if (str.size > 0){ str.size -= 1; } - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos < 0){ str.size = 0; } @@ -4325,7 +4311,7 @@ string_remove_last_folder(String_Const_u32 str){ if (str.size > 0){ str.size -= 1; } - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos < 0){ str.size = 0; } @@ -4337,7 +4323,7 @@ string_remove_last_folder(String_Const_u32 str){ function String_Const_char string_remove_front_of_path(String_Const_char str){ - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos < 0){ str.size = 0; } @@ -4348,7 +4334,7 @@ string_remove_front_of_path(String_Const_char str){ } function String_Const_u8 string_remove_front_of_path(String_Const_u8 str){ - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos < 0){ str.size = 0; } @@ -4359,7 +4345,7 @@ string_remove_front_of_path(String_Const_u8 str){ } function String_Const_u16 string_remove_front_of_path(String_Const_u16 str){ - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos < 0){ str.size = 0; } @@ -4370,7 +4356,7 @@ string_remove_front_of_path(String_Const_u16 str){ } function String_Const_u32 string_remove_front_of_path(String_Const_u32 str){ - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos < 0){ str.size = 0; } @@ -4382,7 +4368,7 @@ string_remove_front_of_path(String_Const_u32 str){ function String_Const_char string_front_of_path(String_Const_char str){ - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos >= 0){ str = string_skip(str, slash_pos + 1); } @@ -4390,7 +4376,7 @@ string_front_of_path(String_Const_char str){ } function String_Const_u8 string_front_of_path(String_Const_u8 str){ - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos >= 0){ str = string_skip(str, slash_pos + 1); } @@ -4398,7 +4384,7 @@ string_front_of_path(String_Const_u8 str){ } function String_Const_u16 string_front_of_path(String_Const_u16 str){ - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos >= 0){ str = string_skip(str, slash_pos + 1); } @@ -4406,7 +4392,7 @@ string_front_of_path(String_Const_u16 str){ } function String_Const_u32 string_front_of_path(String_Const_u32 str){ - imem slash_pos = string_find_last_slash(str); + i64 slash_pos = string_find_last_slash(str); if (slash_pos >= 0){ str = string_skip(str, slash_pos + 1); } @@ -4432,7 +4418,7 @@ string_file_extension(String_Const_u32 string){ function String_Const_char string_file_without_extension(String_Const_char string){ - imem pos = string_find_last(string, '.'); + i64 pos = string_find_last(string, '.'); if (pos > 0){ string = string_prefix(string, pos); } @@ -4440,7 +4426,7 @@ string_file_without_extension(String_Const_char string){ } function String_Const_u8 string_file_without_extension(String_Const_u8 string){ - imem pos = string_find_last(string, '.'); + i64 pos = string_find_last(string, '.'); if (pos > 0){ string = string_prefix(string, pos); } @@ -4448,7 +4434,7 @@ string_file_without_extension(String_Const_u8 string){ } function String_Const_u16 string_file_without_extension(String_Const_u16 string){ - imem pos = string_find_last(string, '.'); + i64 pos = string_find_last(string, '.'); if (pos > 0){ string = string_prefix(string, pos); } @@ -4456,7 +4442,7 @@ string_file_without_extension(String_Const_u16 string){ } function String_Const_u32 string_file_without_extension(String_Const_u32 string){ - imem pos = string_find_last(string, '.'); + i64 pos = string_find_last(string, '.'); if (pos > 0){ string = string_prefix(string, pos); } @@ -4465,84 +4451,84 @@ string_file_without_extension(String_Const_u32 string){ function String_Const_char string_skip_whitespace(String_Const_char str){ - umem f = string_find_first_non_whitespace(str); + u64 f = string_find_first_non_whitespace(str); str = string_skip(str, f); return(str); } function String_Const_u8 string_skip_whitespace(String_Const_u8 str){ - umem f = string_find_first_non_whitespace(str); + u64 f = string_find_first_non_whitespace(str); str = string_skip(str, f); return(str); } function String_Const_u16 string_skip_whitespace(String_Const_u16 str){ - umem f = string_find_first_non_whitespace(str); + u64 f = string_find_first_non_whitespace(str); str = string_skip(str, f); return(str); } function String_Const_u32 string_skip_whitespace(String_Const_u32 str){ - umem f = string_find_first_non_whitespace(str); + u64 f = string_find_first_non_whitespace(str); str = string_skip(str, f); return(str); } function String_Const_char string_chop_whitespace(String_Const_char str){ - imem e = string_find_last_non_whitespace(str); - str = string_prefix(str, (umem)(e + 1)); + i64 e = string_find_last_non_whitespace(str); + str = string_prefix(str, (u64)(e + 1)); return(str); } function String_Const_u8 string_chop_whitespace(String_Const_u8 str){ - imem e = string_find_last_non_whitespace(str); - str = string_prefix(str, (umem)(e + 1)); + i64 e = string_find_last_non_whitespace(str); + str = string_prefix(str, (u64)(e + 1)); return(str); } function String_Const_u16 string_chop_whitespace(String_Const_u16 str){ - imem e = string_find_last_non_whitespace(str); - str = string_prefix(str, (umem)(e + 1)); + i64 e = string_find_last_non_whitespace(str); + str = string_prefix(str, (u64)(e + 1)); return(str); } function String_Const_u32 string_chop_whitespace(String_Const_u32 str){ - imem e = string_find_last_non_whitespace(str); - str = string_prefix(str, (umem)(e + 1)); + i64 e = string_find_last_non_whitespace(str); + str = string_prefix(str, (u64)(e + 1)); return(str); } function String_Const_char string_skip_chop_whitespace(String_Const_char str){ - umem f = string_find_first_non_whitespace(str); + u64 f = string_find_first_non_whitespace(str); str = string_skip(str, f); - imem e = string_find_last_non_whitespace(str); - str = string_prefix(str, (umem)(e + 1)); + i64 e = string_find_last_non_whitespace(str); + str = string_prefix(str, (u64)(e + 1)); return(str); } function String_Const_u8 string_skip_chop_whitespace(String_Const_u8 str){ - umem f = string_find_first_non_whitespace(str); + u64 f = string_find_first_non_whitespace(str); str = string_skip(str, f); - imem e = string_find_last_non_whitespace(str); - str = string_prefix(str, (umem)(e + 1)); + i64 e = string_find_last_non_whitespace(str); + str = string_prefix(str, (u64)(e + 1)); return(str); } function String_Const_u16 string_skip_chop_whitespace(String_Const_u16 str){ - umem f = string_find_first_non_whitespace(str); + u64 f = string_find_first_non_whitespace(str); str = string_skip(str, f); - imem e = string_find_last_non_whitespace(str); - str = string_prefix(str, (umem)(e + 1)); + i64 e = string_find_last_non_whitespace(str); + str = string_prefix(str, (u64)(e + 1)); return(str); } function String_Const_u32 string_skip_chop_whitespace(String_Const_u32 str){ - umem f = string_find_first_non_whitespace(str); + u64 f = string_find_first_non_whitespace(str); str = string_skip(str, f); - imem e = string_find_last_non_whitespace(str); - str = string_prefix(str, (umem)(e + 1)); + i64 e = string_find_last_non_whitespace(str); + str = string_prefix(str, (u64)(e + 1)); return(str); } @@ -4551,7 +4537,7 @@ string_match(String_Const_char a, String_Const_char b){ b32 result = false; if (a.size == b.size){ result = true; - for (umem i = 0; i < a.size; i += 1){ + for (u64 i = 0; i < a.size; i += 1){ if (a.str[i] != b.str[i]){ result = false; break; @@ -4565,7 +4551,7 @@ string_match(String_Const_u8 a, String_Const_u8 b){ b32 result = false; if (a.size == b.size){ result = true; - for (umem i = 0; i < a.size; i += 1){ + for (u64 i = 0; i < a.size; i += 1){ if (a.str[i] != b.str[i]){ result = false; break; @@ -4579,7 +4565,7 @@ string_match(String_Const_u16 a, String_Const_u16 b){ b32 result = false; if (a.size == b.size){ result = true; - for (umem i = 0; i < a.size; i += 1){ + for (u64 i = 0; i < a.size; i += 1){ if (a.str[i] != b.str[i]){ result = false; break; @@ -4593,7 +4579,7 @@ string_match(String_Const_u32 a, String_Const_u32 b){ b32 result = false; if (a.size == b.size){ result = true; - for (umem i = 0; i < a.size; i += 1){ + for (u64 i = 0; i < a.size; i += 1){ if (a.str[i] != b.str[i]){ result = false; break; @@ -4622,7 +4608,7 @@ string_match_insensitive(String_Const_char a, String_Const_char b){ b32 result = false; if (a.size == b.size){ result = true; - for (umem i = 0; i < a.size; i += 1){ + for (u64 i = 0; i < a.size; i += 1){ if (character_to_upper(a.str[i]) != character_to_upper(b.str[i])){ result = false; break; @@ -4636,7 +4622,7 @@ string_match_insensitive(String_Const_u8 a, String_Const_u8 b){ b32 result = false; if (a.size == b.size){ result = true; - for (umem i = 0; i < a.size; i += 1){ + for (u64 i = 0; i < a.size; i += 1){ if (character_to_upper(a.str[i]) != character_to_upper(b.str[i])){ result = false; break; @@ -4650,7 +4636,7 @@ string_match_insensitive(String_Const_u16 a, String_Const_u16 b){ b32 result = false; if (a.size == b.size){ result = true; - for (umem i = 0; i < a.size; i += 1){ + for (u64 i = 0; i < a.size; i += 1){ if (character_to_upper(a.str[i]) != character_to_upper(b.str[i])){ result = false; break; @@ -4664,7 +4650,7 @@ string_match_insensitive(String_Const_u32 a, String_Const_u32 b){ b32 result = false; if (a.size == b.size){ result = true; - for (umem i = 0; i < a.size; i += 1){ + for (u64 i = 0; i < a.size; i += 1){ if (character_to_upper(a.str[i]) != character_to_upper(b.str[i])){ result = false; break; @@ -4735,14 +4721,14 @@ string_match(String_Const_u32 a, String_Const_u32 b, String_Match_Rule rule){ return(result); } -function umem +function u64 string_find_first(String_Const_char str, String_Const_char needle, String_Match_Rule rule){ - umem i = 0; + u64 i = 0; if (needle.size > 0){ i = str.size; if (str.size >= needle.size){ i = 0; - umem one_past_last = str.size - needle.size + 1; + u64 one_past_last = str.size - needle.size + 1; for (;i < one_past_last; i += 1){ if (str.str[i] == needle.str[0]){ String_Const_char source_part = string_prefix(string_skip(str, i), needle.size); @@ -4758,14 +4744,14 @@ string_find_first(String_Const_char str, String_Const_char needle, String_Match_ } return(i); } -function umem +function u64 string_find_first(String_Const_u8 str, String_Const_u8 needle, String_Match_Rule rule){ - umem i = 0; + u64 i = 0; if (needle.size > 0){ i = str.size; if (str.size >= needle.size){ i = 0; - umem one_past_last = str.size - needle.size + 1; + u64 one_past_last = str.size - needle.size + 1; for (;i < one_past_last; i += 1){ if (str.str[i] == needle.str[0]){ String_Const_u8 source_part = string_prefix(string_skip(str, i), needle.size); @@ -4781,14 +4767,14 @@ string_find_first(String_Const_u8 str, String_Const_u8 needle, String_Match_Rule } return(i); } -function umem +function u64 string_find_first(String_Const_u16 str, String_Const_u16 needle, String_Match_Rule rule){ - umem i = 0; + u64 i = 0; if (needle.size > 0){ i = str.size; if (str.size >= needle.size){ i = 0; - umem one_past_last = str.size - needle.size + 1; + u64 one_past_last = str.size - needle.size + 1; for (;i < one_past_last; i += 1){ if (str.str[i] == needle.str[0]){ String_Const_u16 source_part = string_prefix(string_skip(str, i), needle.size); @@ -4804,14 +4790,14 @@ string_find_first(String_Const_u16 str, String_Const_u16 needle, String_Match_Ru } return(i); } -function umem +function u64 string_find_first(String_Const_u32 str, String_Const_u32 needle, String_Match_Rule rule){ - umem i = 0; + u64 i = 0; if (needle.size > 0){ i = str.size; if (str.size >= needle.size){ i = 0; - umem one_past_last = str.size - needle.size + 1; + u64 one_past_last = str.size - needle.size + 1; for (;i < one_past_last; i += 1){ if (str.str[i] == needle.str[0]){ String_Const_u32 source_part = string_prefix(string_skip(str, i), needle.size); @@ -4828,35 +4814,35 @@ string_find_first(String_Const_u32 str, String_Const_u32 needle, String_Match_Ru return(i); } -function umem +function u64 string_find_first(String_Const_char str, String_Const_char needle){ return(string_find_first(str, needle, StringMatch_Exact)); } -function umem +function u64 string_find_first(String_Const_u8 str, String_Const_u8 needle){ return(string_find_first(str, needle, StringMatch_Exact)); } -function umem +function u64 string_find_first(String_Const_u16 str, String_Const_u16 needle){ return(string_find_first(str, needle, StringMatch_Exact)); } -function umem +function u64 string_find_first(String_Const_u32 str, String_Const_u32 needle){ return(string_find_first(str, needle, StringMatch_Exact)); } -function umem +function u64 string_find_first_insensitive(String_Const_char str, String_Const_char needle){ return(string_find_first(str, needle, StringMatch_CaseInsensitive)); } -function umem +function u64 string_find_first_insensitive(String_Const_u8 str, String_Const_u8 needle){ return(string_find_first(str, needle, StringMatch_CaseInsensitive)); } -function umem +function u64 string_find_first_insensitive(String_Const_u16 str, String_Const_u16 needle){ return(string_find_first(str, needle, StringMatch_CaseInsensitive)); } -function umem +function u64 string_find_first_insensitive(String_Const_u32 str, String_Const_u32 needle){ return(string_find_first(str, needle, StringMatch_CaseInsensitive)); } @@ -4864,7 +4850,7 @@ string_find_first_insensitive(String_Const_u32 str, String_Const_u32 needle){ function i32 string_compare(String_Const_char a, String_Const_char b){ i32 result = 0; - for (umem i = 0; i < a.size || i < b.size; i += 1){ + for (u64 i = 0; i < a.size || i < b.size; i += 1){ char ca = (i < a.size)?a.str[i]:0; char cb = (i < b.size)?b.str[i]:0; i32 dif = ((ca) - (cb)); @@ -4878,7 +4864,7 @@ string_compare(String_Const_char a, String_Const_char b){ function i32 string_compare(String_Const_u8 a, String_Const_u8 b){ i32 result = 0; - for (umem i = 0; i < a.size || i < b.size; i += 1){ + for (u64 i = 0; i < a.size || i < b.size; i += 1){ u8 ca = (i < a.size)?a.str[i]:0; u8 cb = (i < b.size)?b.str[i]:0; i32 dif = ((ca) - (cb)); @@ -4892,7 +4878,7 @@ string_compare(String_Const_u8 a, String_Const_u8 b){ function i32 string_compare(String_Const_u16 a, String_Const_u16 b){ i32 result = 0; - for (umem i = 0; i < a.size || i < b.size; i += 1){ + for (u64 i = 0; i < a.size || i < b.size; i += 1){ u16 ca = (i < a.size)?a.str[i]:0; u16 cb = (i < b.size)?b.str[i]:0; i32 dif = ((ca) - (cb)); @@ -4906,7 +4892,7 @@ string_compare(String_Const_u16 a, String_Const_u16 b){ function i32 string_compare(String_Const_u32 a, String_Const_u32 b){ i32 result = 0; - for (umem i = 0; i < a.size || i < b.size; i += 1){ + for (u64 i = 0; i < a.size || i < b.size; i += 1){ u32 ca = (i < a.size)?a.str[i]:0; u32 cb = (i < b.size)?b.str[i]:0; i32 dif = ((ca) - (cb)); @@ -4921,7 +4907,7 @@ string_compare(String_Const_u32 a, String_Const_u32 b){ function i32 string_compare_insensitive(String_Const_char a, String_Const_char b){ i32 result = 0; - for (umem i = 0; i < a.size || i < b.size; i += 1){ + for (u64 i = 0; i < a.size || i < b.size; i += 1){ char ca = (i <= a.size)?0:a.str[i]; char cb = (i <= b.size)?0:b.str[i]; i32 dif = character_to_upper(ca) - character_to_upper(cb); @@ -4935,7 +4921,7 @@ string_compare_insensitive(String_Const_char a, String_Const_char b){ function i32 string_compare_insensitive(String_Const_u8 a, String_Const_u8 b){ i32 result = 0; - for (umem i = 0; i < a.size || i < b.size; i += 1){ + for (u64 i = 0; i < a.size || i < b.size; i += 1){ u8 ca = (i <= a.size)?0:a.str[i]; u8 cb = (i <= b.size)?0:b.str[i]; i32 dif = character_to_upper(ca) - character_to_upper(cb); @@ -4949,7 +4935,7 @@ string_compare_insensitive(String_Const_u8 a, String_Const_u8 b){ function i32 string_compare_insensitive(String_Const_u16 a, String_Const_u16 b){ i32 result = 0; - for (umem i = 0; i < a.size || i < b.size; i += 1){ + for (u64 i = 0; i < a.size || i < b.size; i += 1){ u16 ca = (i <= a.size)?0:a.str[i]; u16 cb = (i <= b.size)?0:b.str[i]; i32 dif = character_to_upper(ca) - character_to_upper(cb); @@ -4963,7 +4949,7 @@ string_compare_insensitive(String_Const_u16 a, String_Const_u16 b){ function i32 string_compare_insensitive(String_Const_u32 a, String_Const_u32 b){ i32 result = 0; - for (umem i = 0; i < a.size || i < b.size; i += 1){ + for (u64 i = 0; i < a.size || i < b.size; i += 1){ u32 ca = (i <= a.size)?0:a.str[i]; u32 cb = (i <= b.size)?0:b.str[i]; i32 dif = character_to_upper(ca) - character_to_upper(cb); @@ -4977,56 +4963,56 @@ string_compare_insensitive(String_Const_u32 a, String_Const_u32 b){ function String_Const_char string_mod_upper(String_Const_char str){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ str.str[i] = character_to_upper(str.str[i]); } return(str); } function String_Const_u8 string_mod_upper(String_Const_u8 str){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ str.str[i] = character_to_upper(str.str[i]); } return(str); } function String_Const_u16 string_mod_upper(String_Const_u16 str){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ str.str[i] = character_to_upper(str.str[i]); } return(str); } function String_Const_u32 string_mod_upper(String_Const_u32 str){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ str.str[i] = character_to_upper(str.str[i]); } return(str); } function String_Const_char string_mod_lower(String_Const_char str){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ str.str[i] = character_to_lower(str.str[i]); } return(str); } function String_Const_u8 string_mod_lower(String_Const_u8 str){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ str.str[i] = character_to_lower(str.str[i]); } return(str); } function String_Const_u16 string_mod_lower(String_Const_u16 str){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ str.str[i] = character_to_lower(str.str[i]); } return(str); } function String_Const_u32 string_mod_lower(String_Const_u32 str){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ str.str[i] = character_to_lower(str.str[i]); } return(str); @@ -5034,7 +5020,7 @@ string_mod_lower(String_Const_u32 str){ function String_Const_char string_mod_replace_character(String_Const_char str, char o, char n){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ char c = str.str[i]; str.str[i] = (c == o)?(n):(c); } @@ -5042,7 +5028,7 @@ string_mod_replace_character(String_Const_char str, char o, char n){ } function String_Const_u8 string_mod_replace_character(String_Const_u8 str, u8 o, u8 n){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ u8 c = str.str[i]; str.str[i] = (c == o)?(n):(c); } @@ -5050,7 +5036,7 @@ string_mod_replace_character(String_Const_u8 str, u8 o, u8 n){ } function String_Const_u16 string_mod_replace_character(String_Const_u16 str, u16 o, u16 n){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ u16 c = str.str[i]; str.str[i] = (c == o)?(n):(c); } @@ -5058,7 +5044,7 @@ string_mod_replace_character(String_Const_u16 str, u16 o, u16 n){ } function String_Const_u32 string_mod_replace_character(String_Const_u32 str, u32 o, u32 n){ - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ u32 c = str.str[i]; str.str[i] = (c == o)?(n):(c); } @@ -5068,11 +5054,11 @@ string_mod_replace_character(String_Const_u32 str, u32 o, u32 n){ function b32 string_append(String_char *dst, String_Const_char src){ b32 result = false; - umem available = dst->cap - dst->size; + u64 available = dst->cap - dst->size; if (src.size <= available){ result = true; } - umem copy_size = clamp_top(src.size, available); + u64 copy_size = clamp_top(src.size, available); block_copy(dst->str + dst->size, src.str, copy_size); dst->size += copy_size; return(result); @@ -5080,11 +5066,11 @@ string_append(String_char *dst, String_Const_char src){ function b32 string_append(String_u8 *dst, String_Const_u8 src){ b32 result = false; - umem available = dst->cap - dst->size; + u64 available = dst->cap - dst->size; if (src.size <= available){ result = true; } - umem copy_size = clamp_top(src.size, available); + u64 copy_size = clamp_top(src.size, available); block_copy(dst->str + dst->size, src.str, copy_size); dst->size += copy_size; return(result); @@ -5092,11 +5078,11 @@ string_append(String_u8 *dst, String_Const_u8 src){ function b32 string_append(String_u16 *dst, String_Const_u16 src){ b32 result = false; - umem available = dst->cap - dst->size; + u64 available = dst->cap - dst->size; if (src.size <= available){ result = true; } - umem copy_size = clamp_top(src.size, available); + u64 copy_size = clamp_top(src.size, available); block_copy(dst->str + dst->size, src.str, copy_size); dst->size += copy_size; return(result); @@ -5104,11 +5090,11 @@ string_append(String_u16 *dst, String_Const_u16 src){ function b32 string_append(String_u32 *dst, String_Const_u32 src){ b32 result = false; - umem available = dst->cap - dst->size; + u64 available = dst->cap - dst->size; if (src.size <= available){ result = true; } - umem copy_size = clamp_top(src.size, available); + u64 copy_size = clamp_top(src.size, available); block_copy(dst->str + dst->size, src.str, copy_size); dst->size += copy_size; return(result); @@ -5165,28 +5151,28 @@ string_null_terminate(String_u32 *str){ } function String_char -string_char_push(Arena *arena, umem size){ +string_char_push(Arena *arena, u64 size){ String_char string = {}; string.str = push_array(arena, char, size); string.cap = size; return(string); } function String_u8 -string_u8_push(Arena *arena, umem size){ +string_u8_push(Arena *arena, u64 size){ String_u8 string = {}; string.str = push_array(arena, u8, size); string.cap = size; return(string); } function String_u16 -string_u16_push(Arena *arena, umem size){ +string_u16_push(Arena *arena, u64 size){ String_u16 string = {}; string.str = push_array(arena, u16, size); string.cap = size; return(string); } function String_u32 -string_u32_push(Arena *arena, umem size){ +string_u32_push(Arena *arena, u64 size){ String_u32 string = {}; string.str = push_array(arena, u32, size); string.cap = size; @@ -5194,7 +5180,7 @@ string_u32_push(Arena *arena, umem size){ } function String_Any -string_any_push(Arena *arena, umem size, String_Encoding encoding){ +string_any_push(Arena *arena, u64 size, String_Encoding encoding){ String_Any string = {}; switch (encoding){ case StringEncoding_ASCII: string.s_char = string_char_push(arena, size); break; @@ -5206,28 +5192,28 @@ string_any_push(Arena *arena, umem size, String_Encoding encoding){ } function String_Const_char -string_const_char_push(Arena *arena, umem size){ +string_const_char_push(Arena *arena, u64 size){ String_Const_char string = {}; string.str = push_array(arena, char, size); string.size = size; return(string); } function String_Const_u8 -string_const_u8_push(Arena *arena, umem size){ +string_const_u8_push(Arena *arena, u64 size){ String_Const_u8 string = {}; string.str = push_array(arena, u8, size); string.size = size; return(string); } function String_Const_u16 -string_const_u16_push(Arena *arena, umem size){ +string_const_u16_push(Arena *arena, u64 size){ String_Const_u16 string = {}; string.str = push_array(arena, u16, size); string.size = size; return(string); } function String_Const_u32 -string_const_u32_push(Arena *arena, umem size){ +string_const_u32_push(Arena *arena, u64 size){ String_Const_u32 string = {}; string.str = push_array(arena, u32, size); string.size = size; @@ -5235,7 +5221,7 @@ string_const_u32_push(Arena *arena, umem size){ } function String_Const_Any -string_const_any_push(Arena *arena, umem size, String_Encoding encoding){ +string_const_any_push(Arena *arena, u64 size, String_Encoding encoding){ String_Const_Any string = {}; switch (encoding){ case StringEncoding_ASCII: string.s_char = string_const_char_push(arena, size); break; @@ -5284,7 +5270,7 @@ push_string_copy(Arena *arena, String_Const_u32 src){ } function String_Const_Any -push_string_copy(Arena *arena, umem size, String_Const_Any src){ +push_string_copy(Arena *arena, u64 size, String_Const_Any src){ String_Const_Any string = {}; switch (src.encoding){ case StringEncoding_ASCII: string.s_char = push_string_copy(arena, src.s_char); break; @@ -5521,9 +5507,9 @@ typedef String_Const_u32 String_u32_Mod_Function_Type(String_Const_u32 string); function String_Const_char string_list_flatten(Arena *arena, List_String_Const_char list, String_char_Mod_Function_Type *mod, String_Const_char separator, String_Separator_Flag separator_flags, String_Fill_Terminate_Rule rule){ - umem term_padding = (rule == StringFill_NullTerminate)?(1):(0);b32 before_first = HasFlag(separator_flags, StringSeparator_BeforeFirst); + u64 term_padding = (rule == StringFill_NullTerminate)?(1):(0);b32 before_first = HasFlag(separator_flags, StringSeparator_BeforeFirst); b32 after_last = HasFlag(separator_flags, StringSeparator_AfterLast); - umem separator_size = separator.size*(list.node_count + before_first + after_last - 1); + u64 separator_size = separator.size*(list.node_count + before_first + after_last - 1); String_char string = string_char_push(arena, list.total_size + separator_size + term_padding); if (before_first){ string_append(&string, separator); @@ -5548,9 +5534,9 @@ string_list_flatten(Arena *arena, List_String_Const_char list, String_char_Mod_F } function String_Const_u8 string_list_flatten(Arena *arena, List_String_Const_u8 list, String_u8_Mod_Function_Type *mod, String_Const_u8 separator, String_Separator_Flag separator_flags, String_Fill_Terminate_Rule rule){ - umem term_padding = (rule == StringFill_NullTerminate)?(1):(0);b32 before_first = HasFlag(separator_flags, StringSeparator_BeforeFirst); + u64 term_padding = (rule == StringFill_NullTerminate)?(1):(0);b32 before_first = HasFlag(separator_flags, StringSeparator_BeforeFirst); b32 after_last = HasFlag(separator_flags, StringSeparator_AfterLast); - umem separator_size = separator.size*(list.node_count + before_first + after_last - 1); + u64 separator_size = separator.size*(list.node_count + before_first + after_last - 1); String_u8 string = string_u8_push(arena, list.total_size + separator_size + term_padding); if (before_first){ string_append(&string, separator); @@ -5575,9 +5561,9 @@ string_list_flatten(Arena *arena, List_String_Const_u8 list, String_u8_Mod_Funct } function String_Const_u16 string_list_flatten(Arena *arena, List_String_Const_u16 list, String_u16_Mod_Function_Type *mod, String_Const_u16 separator, String_Separator_Flag separator_flags, String_Fill_Terminate_Rule rule){ - umem term_padding = (rule == StringFill_NullTerminate)?(1):(0);b32 before_first = HasFlag(separator_flags, StringSeparator_BeforeFirst); + u64 term_padding = (rule == StringFill_NullTerminate)?(1):(0);b32 before_first = HasFlag(separator_flags, StringSeparator_BeforeFirst); b32 after_last = HasFlag(separator_flags, StringSeparator_AfterLast); - umem separator_size = separator.size*(list.node_count + before_first + after_last - 1); + u64 separator_size = separator.size*(list.node_count + before_first + after_last - 1); String_u16 string = string_u16_push(arena, list.total_size + separator_size + term_padding); if (before_first){ string_append(&string, separator); @@ -5602,9 +5588,9 @@ string_list_flatten(Arena *arena, List_String_Const_u16 list, String_u16_Mod_Fun } function String_Const_u32 string_list_flatten(Arena *arena, List_String_Const_u32 list, String_u32_Mod_Function_Type *mod, String_Const_u32 separator, String_Separator_Flag separator_flags, String_Fill_Terminate_Rule rule){ - umem term_padding = (rule == StringFill_NullTerminate)?(1):(0);b32 before_first = HasFlag(separator_flags, StringSeparator_BeforeFirst); + u64 term_padding = (rule == StringFill_NullTerminate)?(1):(0);b32 before_first = HasFlag(separator_flags, StringSeparator_BeforeFirst); b32 after_last = HasFlag(separator_flags, StringSeparator_AfterLast); - umem separator_size = separator.size*(list.node_count + before_first + after_last - 1); + u64 separator_size = separator.size*(list.node_count + before_first + after_last - 1); String_u32 string = string_u32_push(arena, list.total_size + separator_size + term_padding); if (before_first){ string_append(&string, separator); @@ -5696,10 +5682,10 @@ function List_String_Const_char string_split(Arena *arena, String_Const_char string, char *split_characters, i32 split_character_count){ List_String_Const_char list = {}; for (;;){ - umem i = string.size; + u64 i = string.size; String_Const_char prefix = string; for (i32 j = 0; j < split_character_count; j += 1){ - umem pos = string_find_first(prefix, split_characters[j]); + u64 pos = string_find_first(prefix, split_characters[j]); prefix = string_prefix(prefix, pos); i = Min(i, pos); } @@ -5717,10 +5703,10 @@ function List_String_Const_u8 string_split(Arena *arena, String_Const_u8 string, u8 *split_characters, i32 split_character_count){ List_String_Const_u8 list = {}; for (;;){ - umem i = string.size; + u64 i = string.size; String_Const_u8 prefix = string; for (i32 j = 0; j < split_character_count; j += 1){ - umem pos = string_find_first(prefix, split_characters[j]); + u64 pos = string_find_first(prefix, split_characters[j]); prefix = string_prefix(prefix, pos); i = Min(i, pos); } @@ -5738,10 +5724,10 @@ function List_String_Const_u16 string_split(Arena *arena, String_Const_u16 string, u16 *split_characters, i32 split_character_count){ List_String_Const_u16 list = {}; for (;;){ - umem i = string.size; + u64 i = string.size; String_Const_u16 prefix = string; for (i32 j = 0; j < split_character_count; j += 1){ - umem pos = string_find_first(prefix, split_characters[j]); + u64 pos = string_find_first(prefix, split_characters[j]); prefix = string_prefix(prefix, pos); i = Min(i, pos); } @@ -5759,10 +5745,10 @@ function List_String_Const_u32 string_split(Arena *arena, String_Const_u32 string, u32 *split_characters, i32 split_character_count){ List_String_Const_u32 list = {}; for (;;){ - umem i = string.size; + u64 i = string.size; String_Const_u32 prefix = string; for (i32 j = 0; j < split_character_count; j += 1){ - umem pos = string_find_first(prefix, split_characters[j]); + u64 pos = string_find_first(prefix, split_characters[j]); prefix = string_prefix(prefix, pos); i = Min(i, pos); } @@ -5781,7 +5767,7 @@ function List_String_Const_char string_split_needle(Arena *arena, String_Const_char string, String_Const_char needle){ List_String_Const_char list = {}; for (;string.size > 0;){ - umem pos = string_find_first(string, needle); + u64 pos = string_find_first(string, needle); String_Const_char prefix = string_prefix(string, pos); if (pos < string.size){ string_list_push(arena, &list, needle); @@ -5797,7 +5783,7 @@ function List_String_Const_u8 string_split_needle(Arena *arena, String_Const_u8 string, String_Const_u8 needle){ List_String_Const_u8 list = {}; for (;string.size > 0;){ - umem pos = string_find_first(string, needle); + u64 pos = string_find_first(string, needle); String_Const_u8 prefix = string_prefix(string, pos); if (pos < string.size){ string_list_push(arena, &list, needle); @@ -5813,7 +5799,7 @@ function List_String_Const_u16 string_split_needle(Arena *arena, String_Const_u16 string, String_Const_u16 needle){ List_String_Const_u16 list = {}; for (;string.size > 0;){ - umem pos = string_find_first(string, needle); + u64 pos = string_find_first(string, needle); String_Const_u16 prefix = string_prefix(string, pos); if (pos < string.size){ string_list_push(arena, &list, needle); @@ -5829,7 +5815,7 @@ function List_String_Const_u32 string_split_needle(Arena *arena, String_Const_u32 string, String_Const_u32 needle){ List_String_Const_u32 list = {}; for (;string.size > 0;){ - umem pos = string_find_first(string, needle); + u64 pos = string_find_first(string, needle); String_Const_u32 prefix = string_prefix(string, pos); if (pos < string.size){ string_list_push(arena, &list, needle); @@ -6085,7 +6071,7 @@ string_wildcard_match(List_String_Const_u8 list, String_Const_u8 string, String_ for (Node_String_Const_u8 *node = list.first->next; node != one_past_last; node = node->next){ - umem position = string_find_first(string, node->string, rule); + u64 position = string_find_first(string, node->string, rule); if (position < string.size){ string = string_skip(string, position + node->string.size); } @@ -6183,7 +6169,7 @@ global_const u8 utf8_class[32] = { }; function Character_Consume_Result -utf8_consume(u8 *str, umem max){ +utf8_consume(u8 *str, u64 max){ Character_Consume_Result result = {1, max_u32}; u8 byte = str[0]; u8 byte_class = utf8_class[byte >> 3]; @@ -6236,7 +6222,7 @@ utf8_consume(u8 *str, umem max){ } function Character_Consume_Result -utf16_consume(u16 *str, umem max){ +utf16_consume(u16 *str, u64 max){ Character_Consume_Result result = {1, max_u32}; result.codepoint = str[0]; result.inc = 1; @@ -6307,7 +6293,7 @@ string_u8_from_string_char(Arena *arena, String_Const_char string, String_Fill_T out.cap += 1; } out.str = push_array(arena, u8, out.cap); - for (umem i = 0; i < string.size; i += 1){ + for (u64 i = 0; i < string.size; i += 1){ out.str[i] = ((u8)string.str[i])&bitmask_7; } out.size = string.size; @@ -6325,7 +6311,7 @@ string_u16_from_string_char(Arena *arena, String_Const_char string, String_Fill_ out.cap += 1; } out.str = push_array(arena, u16, out.cap); - for (umem i = 0; i < string.size; i += 1){ + for (u64 i = 0; i < string.size; i += 1){ out.str[i] = ((u16)string.str[i])&bitmask_7; } out.size = string.size; @@ -6343,7 +6329,7 @@ string_u32_from_string_char(Arena *arena, String_Const_char string, String_Fill_ out.cap += 1; } out.str = push_array(arena, u32, string.size); - for (umem i = 0; i < string.size; i += 1){ + for (u64 i = 0; i < string.size; i += 1){ out.str[i] = ((u32)string.str[i])&bitmask_7; } out.size = string.size; @@ -6363,7 +6349,7 @@ string_char_from_string_u8(Arena *arena, String_Const_u8 string, String_Fill_Ter out.str = push_array(arena, char, out.cap); u8 *ptr = string.str; u8 *one_past_last = ptr + string.size; - umem cap = string.size; + u64 cap = string.size; Character_Consume_Result consume; for (;ptr < one_past_last; ptr += consume.inc, cap -= consume.inc){ consume = utf8_consume(ptr, cap); @@ -6385,7 +6371,7 @@ string_u16_from_string_u8(Arena *arena, String_Const_u8 string, String_Fill_Term out.str = push_array(arena, u16, out.cap); u8 *ptr = string.str; u8 *one_past_last = ptr + string.size; - umem cap = string.size; + u64 cap = string.size; Character_Consume_Result consume; for (;ptr < one_past_last; ptr += consume.inc, cap -= consume.inc){ consume = utf8_consume(ptr, cap); @@ -6407,7 +6393,7 @@ string_u32_from_string_u8(Arena *arena, String_Const_u8 string, String_Fill_Term out.str = push_array(arena, u32, out.cap); u8 *ptr = string.str; u8 *one_past_last = ptr + string.size; - umem cap = string.size; + u64 cap = string.size; Character_Consume_Result consume; for (;ptr < one_past_last; ptr += consume.inc, cap -= consume.inc){ consume = utf8_consume(ptr, cap); @@ -6429,7 +6415,7 @@ string_char_from_string_u16(Arena *arena, String_Const_u16 string, String_Fill_T out.str = push_array(arena, char, out.cap); u16 *ptr = string.str; u16 *one_past_last = ptr + string.size; - umem cap = string.size; + u64 cap = string.size; Character_Consume_Result consume; for (;ptr < one_past_last; ptr += consume.inc, cap -= consume.inc){ consume = utf16_consume(ptr, cap); @@ -6451,7 +6437,7 @@ string_u8_from_string_u16(Arena *arena, String_Const_u16 string, String_Fill_Ter out.str = push_array(arena, u8, out.cap); u16 *ptr = string.str; u16 *one_past_last = ptr + string.size; - umem cap = string.size; + u64 cap = string.size; Character_Consume_Result consume; for (;ptr < one_past_last; ptr += consume.inc, cap -= consume.inc){ consume = utf16_consume(ptr, cap); @@ -6473,7 +6459,7 @@ string_u32_from_string_u16(Arena *arena, String_Const_u16 string, String_Fill_Te out.str = push_array(arena, u32, out.cap); u16 *ptr = string.str; u16 *one_past_last = ptr + string.size; - umem cap = string.size; + u64 cap = string.size; Character_Consume_Result consume; for (;ptr < one_past_last; ptr += consume.inc, cap -= consume.inc){ consume = utf16_consume(ptr, cap); @@ -6699,9 +6685,9 @@ string_list_u32_from_any(Arena *arena, List_String_Const_Any list){ function Line_Ending_Kind string_guess_line_ending_kind(String_Const_u8 string){ b32 looks_like_binary = false; - umem crlf_count = 0; - umem lf_count = 0; - for (umem i = 0; i < string.size; i += 1){ + u64 crlf_count = 0; + u64 lf_count = 0; + for (u64 i = 0; i < string.size; i += 1){ if (string.str[i] == 0){ looks_like_binary = true; break; @@ -6738,7 +6724,7 @@ function List_String_Const_char string_replace_list(Arena *arena, String_Const_char source, String_Const_char needle, String_Const_char replacement){ List_String_Const_char list = {}; for (;;){ - umem i = string_find_first(source, needle); + u64 i = string_find_first(source, needle); string_list_push(arena, &list, string_prefix(source, i)); if (i < source.size){ string_list_push(arena, &list, replacement); @@ -6754,7 +6740,7 @@ function List_String_Const_u8 string_replace_list(Arena *arena, String_Const_u8 source, String_Const_u8 needle, String_Const_u8 replacement){ List_String_Const_u8 list = {}; for (;;){ - umem i = string_find_first(source, needle); + u64 i = string_find_first(source, needle); string_list_push(arena, &list, string_prefix(source, i)); if (i < source.size){ string_list_push(arena, &list, replacement); @@ -6770,7 +6756,7 @@ function List_String_Const_u16 string_replace_list(Arena *arena, String_Const_u16 source, String_Const_u16 needle, String_Const_u16 replacement){ List_String_Const_u16 list = {}; for (;;){ - umem i = string_find_first(source, needle); + u64 i = string_find_first(source, needle); string_list_push(arena, &list, string_prefix(source, i)); if (i < source.size){ string_list_push(arena, &list, replacement); @@ -6786,7 +6772,7 @@ function List_String_Const_u32 string_replace_list(Arena *arena, String_Const_u32 source, String_Const_u32 needle, String_Const_u32 replacement){ List_String_Const_u32 list = {}; for (;;){ - umem i = string_find_first(source, needle); + u64 i = string_find_first(source, needle); string_list_push(arena, &list, string_prefix(source, i)); if (i < source.size){ string_list_push(arena, &list, replacement); @@ -6889,7 +6875,7 @@ string_interpret_escapes(Arena *arena, String_Const_char string){ char *space = push_array(arena, char, string.size + 1); String_char result = Schar(space, 0, string.size); for (;;){ - umem back_slash_pos = string_find_first(string, '\\'); + u64 back_slash_pos = string_find_first(string, '\\'); string_append(&result, string_prefix(string, back_slash_pos)); string = string_skip(string, back_slash_pos + 1); if (string.size == 0){ @@ -6975,9 +6961,9 @@ global_const u8 base64_reverse[128] = { 0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0xFF,0xFF,0xFF,0xFF,0xFF, }; -function umem +function u64 digit_count_from_integer(u64 x, u32 radix){ - umem result = {}; + u64 result = {}; if (radix >= 2 && radix <= 16){ if (x == 0){ result = 1; @@ -7001,13 +6987,13 @@ string_from_integer(Arena *arena, u64 x, u32 radix){ } else{ u8 string_space[64]; - umem length = 0; + u64 length = 0; for (u64 X = x; X > 0; X /= radix, length += 1){ string_space[length] = integer_symbols[X%radix]; } - for (umem j = 0, i = length - 1; + for (u64 j = 0, i = length - 1; j < i; j += 1, i -= 1){ Swap(u8, string_space[i], string_space[j]); @@ -7023,7 +7009,7 @@ string_is_integer(String_Const_u8 string, u32 radix){ b32 is_integer = false; if (radix <= 16){ is_integer = true; - for (umem i = 0; i < string.size; i += 1){ + for (u64 i = 0; i < string.size; i += 1){ if (string.str[i] < 128){ u8 x = integer_symbol_reverse[character_to_upper(string.str[i])]; if (x >= radix){ @@ -7044,7 +7030,7 @@ function u64 string_to_integer(String_Const_u8 string, u32 radix){ u64 x = 0; if (radix <= 16){ - for (umem i = 0; i < string.size; i += 1){ + for (u64 i = 0; i < string.size; i += 1){ x *= radix; if (string.str[i] < 128){ x += integer_symbol_reverse[character_to_upper(string.str[i])]; @@ -7063,9 +7049,9 @@ string_to_integer(String_Const_char string, u32 radix){ } function String_Const_u8 -string_base64_encode_from_binary(Arena *arena, void *data, umem size){ - umem char_count = div_round_up_positive(size*8, 6); - char_count = round_up_umem(char_count, 4); +string_base64_encode_from_binary(Arena *arena, void *data, u64 size){ + u64 char_count = div_round_up_positive(size*8, 6); + char_count = round_up_u64(char_count, 4); String_Const_u8 string = string_const_u8_push(arena, char_count); u8 *s = string.str; u8 *d = (u8*)data; @@ -7102,10 +7088,10 @@ string_base64_encode_from_binary(Arena *arena, void *data, umem size){ } function Data -data_decode_from_base64(Arena *arena, u8 *str, umem size){ +data_decode_from_base64(Arena *arena, u8 *str, u64 size){ Data data = {}; if (size%4 == 0){ - umem data_size = size*6/8; + u64 data_size = size*6/8; if (str[size - 2] == '?'){ data_size -= 2; } diff --git a/custom/4coder_base_types.h b/custom/4coder_base_types.h index 5fd45dfb..3ca3f926 100644 --- a/custom/4coder_base_types.h +++ b/custom/4coder_base_types.h @@ -104,6 +104,9 @@ #if !defined(SHIP_MODE) #define SHIP_MODE 0 +#else +#undef SHIP_MODE +#define SHIP_MODE 1 #endif //////////////////////////////// @@ -154,14 +157,6 @@ typedef i8 b8; typedef i32 b32; typedef i64 b64; -#if ARCH_32BIT -typedef u32 umem; -typedef i32 imem; -#else -typedef u64 umem; -typedef i64 imem; -#endif - typedef float f32; typedef double f64; @@ -722,12 +717,6 @@ union Range_f32{ }; }; -typedef Range_i32 Interval_i32; -typedef Range_i64 Interval_i64; -typedef Range_u64 Interval_u64; -typedef Range_f32 Interval_f32; -typedef Range_i32 Range; - struct Range_i32_Array{ Range_i32 *ranges; i32 count; @@ -744,7 +733,6 @@ struct Range_f32_Array{ Range_f32 *ranges; i32 count; }; -typedef Range_i32_Array Range_Array; union Rect_i32{ struct{ @@ -848,7 +836,7 @@ enum{ struct String_Const_char{ char *str; - u64 size; + u64 size; }; struct String_Const_u8{ union{ @@ -936,25 +924,25 @@ struct Node_String_Const_u32{ struct List_String_Const_char{ Node_String_Const_char *first; Node_String_Const_char *last; - u64 total_size; + u64 total_size; i32 node_count; }; struct List_String_Const_u8{ Node_String_Const_u8 *first; Node_String_Const_u8 *last; - u64 total_size; + u64 total_size; i32 node_count; }; struct List_String_Const_u16{ Node_String_Const_u16 *first; Node_String_Const_u16 *last; - u64 total_size; + u64 total_size; i32 node_count; }; struct List_String_Const_u32{ Node_String_Const_u32 *first; Node_String_Const_u32 *last; - u64 total_size; + u64 total_size; i32 node_count; }; @@ -965,7 +953,7 @@ struct Node_String_Const_Any{ struct List_String_Const_Any{ Node_String_Const_Any *first; Node_String_Const_Any *last; - u64 total_size; + u64 total_size; i32 node_count; }; @@ -974,40 +962,40 @@ struct String_char{ String_Const_char string; struct{ char *str; - umem size; + u64 size; }; }; - umem cap; + u64 cap; }; struct String_u8{ union{ String_Const_u8 string; struct{ u8 *str; - umem size; + u64 size; }; }; - umem cap; + u64 cap; }; struct String_u16{ union{ String_Const_u16 string; struct{ u16 *str; - umem size; + u64 size; }; }; - umem cap; + u64 cap; }; struct String_u32{ union{ String_Const_u32 string; struct{ u32 *str; - umem size; + u64 size; }; }; - umem cap; + u64 cap; }; struct String_Any{ @@ -1015,8 +1003,8 @@ struct String_Any{ union{ struct{ void *str; - umem size; - umem cap; + u64 size; + u64 cap; }; String_char s_char; String_u8 s_u8; @@ -1045,7 +1033,7 @@ global u32 nonchar_max = 0xFDEF; struct Data{ u8 *data; - umem size; + u64 size; }; //////////////////////////////// @@ -1087,11 +1075,11 @@ enum{ //////////////////////////////// -typedef void *Base_Allocator_Reserve_Signature(void *user_data, umem size, umem *size_out, String_Const_u8 location); -typedef void Base_Allocator_Commit_Signature(void *user_data, void *ptr, umem size); -typedef void Base_Allocator_Uncommit_Signature(void *user_data, void *ptr, umem size); +typedef void *Base_Allocator_Reserve_Signature(void *user_data, u64 size, u64 *size_out, String_Const_u8 location); +typedef void Base_Allocator_Commit_Signature(void *user_data, void *ptr, u64 size); +typedef void Base_Allocator_Uncommit_Signature(void *user_data, void *ptr, u64 size); typedef void Base_Allocator_Free_Signature(void *user_data, void *ptr); -typedef void Base_Allocator_Set_Access_Signature(void *user_data, void *ptr, umem size, Access_Flag flags); +typedef void Base_Allocator_Set_Access_Signature(void *user_data, void *ptr, u64 size, Access_Flag flags); struct Base_Allocator{ Base_Allocator_Reserve_Signature *reserve; Base_Allocator_Commit_Signature *commit; @@ -1103,12 +1091,12 @@ struct Base_Allocator{ struct Cursor{ u8 *base; - umem pos; - umem cap; + u64 pos; + u64 cap; }; struct Temp_Memory_Cursor{ Cursor *cursor; - umem pos; + u64 pos; }; struct Cursor_Node{ union{ @@ -1120,13 +1108,13 @@ struct Cursor_Node{ struct Arena{ Base_Allocator *base_allocator; Cursor_Node *cursor_node; - umem chunk_size; - umem alignment; + u64 chunk_size; + u64 alignment; }; struct Temp_Memory_Arena{ Arena *arena; Cursor_Node *cursor_node; - umem pos; + u64 pos; }; typedef i32 Linear_Allocator_Kind; enum{ @@ -1243,7 +1231,7 @@ struct Heap_Node{ struct{ Heap_Basic_Node order; Heap_Basic_Node alloc; - umem size; + u64 size; }; u8 force_size__[64]; }; @@ -1254,8 +1242,8 @@ struct Heap{ Arena *arena; Heap_Basic_Node in_order; Heap_Basic_Node free_nodes; - umem used_space; - umem total_space; + u64 used_space; + u64 total_space; }; #endif diff --git a/custom/4coder_cli_command.cpp b/custom/4coder_cli_command.cpp index 515f10dc..446c4b86 100644 --- a/custom/4coder_cli_command.cpp +++ b/custom/4coder_cli_command.cpp @@ -26,19 +26,19 @@ CUSTOM_DOC("Queries for an output buffer name and system command, runs the syste Query_Bar bar_out = {}; bar_out.prompt = string_u8_litexpr("Output Buffer: "); - bar_out.string = SCu8(out_buffer_space, (umem)0); + bar_out.string = SCu8(out_buffer_space, (u64)0); bar_out.string_capacity = sizeof(out_buffer_space); if (!query_user_string(app, &bar_out)) return; Query_Bar bar_cmd = {}; bar_cmd.prompt = string_u8_litexpr("Command: "); - bar_cmd.string = SCu8(command_space, (umem)0); + bar_cmd.string = SCu8(command_space, (u64)0); bar_cmd.string_capacity = sizeof(command_space); if (!query_user_string(app, &bar_cmd)) return; String_Const_u8 hot = push_hot_directory(app, scratch); { - umem size = clamp_top(hot.size, sizeof(hot_directory_space)); + u64 size = clamp_top(hot.size, sizeof(hot_directory_space)); block_copy(hot_directory_space, hot.str, size); hot_directory_space[hot.size] = 0; } diff --git a/custom/4coder_clipboard.cpp b/custom/4coder_clipboard.cpp index ed283c2f..fdb44353 100644 --- a/custom/4coder_clipboard.cpp +++ b/custom/4coder_clipboard.cpp @@ -278,7 +278,7 @@ CUSTOM_COMMAND_SIG(multi_paste_interactive_quick){ Query_Bar_Group group(app); Query_Bar bar = {}; bar.prompt = string_u8_litexpr("How Many Slots To Paste: "); - bar.string = SCu8(string_space, (umem)0); + bar.string = SCu8(string_space, (u64)0); bar.string_capacity = sizeof(string_space); query_user_number(app, &bar); diff --git a/custom/4coder_code_index.cpp b/custom/4coder_code_index.cpp index 6e971f50..2e7d0fcc 100644 --- a/custom/4coder_code_index.cpp +++ b/custom/4coder_code_index.cpp @@ -157,7 +157,7 @@ code_index_get_nest(Code_Index_File *file, i64 pos){ } function void -index_shift(i64 *ptr, Range_i64 old_range, umem new_size){ +index_shift(i64 *ptr, Range_i64 old_range, u64 new_size){ i64 i = *ptr; if (old_range.min <= i && i < old_range.max){ *ptr = old_range.first; @@ -169,7 +169,7 @@ index_shift(i64 *ptr, Range_i64 old_range, umem new_size){ function void code_index_shift(Code_Index_Nest_Ptr_Array *array, - Range_i64 old_range, umem new_size){ + Range_i64 old_range, u64 new_size){ i32 count = array->count; Code_Index_Nest **nest_ptr = array->ptrs; for (i32 i = 0; i < count; i += 1, nest_ptr += 1){ @@ -185,7 +185,7 @@ code_index_shift(Code_Index_Nest_Ptr_Array *array, } function void -code_index_shift(Code_Index_File *file, Range_i64 old_range, umem new_size){ +code_index_shift(Code_Index_File *file, Range_i64 old_range, u64 new_size){ code_index_shift(&file->nest_array, old_range, new_size); } @@ -841,7 +841,7 @@ layout_index_x_shift(Application_Links *app, Layout_Reflex *reflex, Code_Index_F function void layout_index__emit_chunk(LefRig_TopBot_Layout_Vars *pos_vars, Face_ID face, Arena *arena, u8 *text_str, i64 range_first, u8 *ptr, u8 *end, Layout_Item_List *list){ for (;ptr < end;){ - Character_Consume_Result consume = utf8_consume(ptr, (umem)(end - ptr)); + Character_Consume_Result consume = utf8_consume(ptr, (u64)(end - ptr)); if (consume.codepoint != '\r'){ i64 index = layout_index_from_ptr(ptr, text_str, range_first); if (consume.codepoint != max_u32){ @@ -961,7 +961,7 @@ layout_index__inner(Application_Links *app, Arena *arena, Buffer_ID buffer, Rang f32 word_advance = 0.f; ptr = word.str; for (;ptr < word_end;){ - Character_Consume_Result consume = utf8_consume(ptr, (umem)(word_end - ptr)); + Character_Consume_Result consume = utf8_consume(ptr, (u64)(word_end - ptr)); if (consume.codepoint != max_u32){ word_advance += lr_tb_advance(&pos_vars, face, consume.codepoint); } diff --git a/custom/4coder_config.cpp b/custom/4coder_config.cpp index a4360fd1..7b1b2c40 100644 --- a/custom/4coder_config.cpp +++ b/custom/4coder_config.cpp @@ -9,7 +9,7 @@ parse_extension_line_to_extension_list(Application_Links *app, Arena *arena, String_Const_u8 str){ ProfileScope(app, "parse extension line to extension list"); i32 count = 0; - for (umem i = 0; i < str.size; i += 1){ + for (u64 i = 0; i < str.size; i += 1){ if (str.str[i] == '.'){ count += 1; } @@ -22,7 +22,7 @@ parse_extension_line_to_extension_list(Application_Links *app, push_align(arena, 1); str = string_skip(str, string_find_first(str, '.') + 1); for (i32 i = 0; i < count; i += 1){ - umem next_period = string_find_first(str, '.'); + u64 next_period = string_find_first(str, '.'); String_Const_u8 extension = string_prefix(str, next_period); str = string_skip(str, next_period + 1); array.strings[i] = push_string_copy(arena, extension); @@ -748,11 +748,11 @@ config_string_var(Config *config, char *var_name, i32 subscript, String_Const_u8 } function b32 -config_placed_string_var(Config *config, String_Const_u8 var_name, i32 subscript, String_Const_u8* var_out, u8 *space, umem space_size){ +config_placed_string_var(Config *config, String_Const_u8 var_name, i32 subscript, String_Const_u8* var_out, u8 *space, u64 space_size){ Config_Get_Result result = config_var(config, var_name, subscript); b32 success = (result.success && result.type == ConfigRValueType_String); if (success){ - umem size = result.string.size; + u64 size = result.string.size; size = clamp_top(size, space_size); block_copy(space, result.string.str, size); *var_out = SCu8(space, size); @@ -761,7 +761,7 @@ config_placed_string_var(Config *config, String_Const_u8 var_name, i32 subscript } function b32 -config_placed_string_var(Config *config, char *var_name, i32 subscript, String_Const_u8* var_out, u8 *space, umem space_size){ +config_placed_string_var(Config *config, char *var_name, i32 subscript, String_Const_u8* var_out, u8 *space, u64 space_size){ return(config_placed_string_var(config, SCu8(var_name), subscript, var_out, space, space_size)); } @@ -879,11 +879,11 @@ config_compound_string_member(Config *config, Config_Compound *compound, function b32 config_compound_placed_string_member(Config *config, Config_Compound *compound, - String_Const_u8 var_name, i32 index, String_Const_u8* var_out, u8 *space, umem space_size){ + String_Const_u8 var_name, i32 index, String_Const_u8* var_out, u8 *space, u64 space_size){ Config_Get_Result result = config_compound_member(config, compound, var_name, index); b32 success = (result.success && result.type == ConfigRValueType_String); if (success){ - umem size = result.string.size; + u64 size = result.string.size; size = clamp_top(size, space_size); block_copy(space, result.string.str, size); *var_out = SCu8(space, size); @@ -893,7 +893,7 @@ config_compound_placed_string_member(Config *config, Config_Compound *compound, function b32 config_compound_placed_string_member(Config *config, Config_Compound *compound, - char *var_name, i32 index, String_Const_u8* var_out, u8 *space, umem space_size){ + char *var_name, i32 index, String_Const_u8* var_out, u8 *space, u64 space_size){ return(config_compound_placed_string_member(config, compound, SCu8(var_name), index, var_out, space, space_size)); } @@ -978,11 +978,11 @@ typed_string_array_iteration_step(Config *config, Config_Compound *compound, i32 } function Iteration_Step_Result -typed_placed_string_array_iteration_step(Config *config, Config_Compound *compound, i32 index, String_Const_u8* var_out, u8 *space, umem space_size){ +typed_placed_string_array_iteration_step(Config *config, Config_Compound *compound, i32 index, String_Const_u8* var_out, u8 *space, u64 space_size){ Config_Iteration_Step_Result result = typed_array_iteration_step(config, compound, ConfigRValueType_String, index); b32 success = (result.step == Iteration_Good); if (success){ - umem size = result.get.string.size; + u64 size = result.get.string.size; size = clamp_top(size, space_size); block_copy(space, result.get.string.str, size); *var_out = SCu8(space, size); @@ -1192,11 +1192,11 @@ config_from_text(Application_Links *app, Arena *arena, String_Const_u8 file_name function void config_init_default(Config_Data *config){ - config->user_name = SCu8(config->user_name_space, (umem)0); + config->user_name = SCu8(config->user_name_space, (u64)0); block_zero_struct(&config->code_exts); - config->mode = SCu8(config->mode_space, (umem)0); + config->mode = SCu8(config->mode_space, (u64)0); config->use_scroll_bars = false; config->use_file_bars = true; @@ -1226,19 +1226,19 @@ config_init_default(Config_Data *config){ block_copy(config->default_theme_name.str, "4coder", config->default_theme_name.size); config->highlight_line_at_cursor = true; - config->default_font_name = SCu8(config->default_font_name_space, (umem)0); + config->default_font_name = SCu8(config->default_font_name_space, (u64)0); config->default_font_size = 16; config->default_font_hinting = false; config->default_compiler_bat = SCu8(config->default_compiler_bat_space, 2); block_copy(config->default_compiler_bat.str, "cl", 2); - config->default_flags_bat = SCu8(config->default_flags_bat_space, (umem)0); + config->default_flags_bat = SCu8(config->default_flags_bat_space, (u64)0); config->default_compiler_sh = SCu8(config->default_compiler_sh_space, 3); block_copy(config->default_compiler_sh.str, "g++", 3); - config->default_flags_sh = SCu8(config->default_flags_sh_space, (umem)0); + config->default_flags_sh = SCu8(config->default_flags_sh_space, (u64)0); config->lalt_lctrl_is_altgr = false; } @@ -1484,7 +1484,7 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con print_message(app, string_u8_litexpr("Using default config:\n")); Face_Description description = get_face_description(app, 0); if (description.font.file_name.str != 0){ - umem size = Min(description.font.file_name.size, sizeof(config->default_font_name_space)); + u64 size = Min(description.font.file_name.size, sizeof(config->default_font_name_space)); block_copy(config->default_font_name_space, description.font.file_name.str, size); config->default_font_name.size = size; } diff --git a/custom/4coder_default_hooks.cpp b/custom/4coder_default_hooks.cpp index 5d878c60..76c0db40 100644 --- a/custom/4coder_default_hooks.cpp +++ b/custom/4coder_default_hooks.cpp @@ -482,7 +482,7 @@ BUFFER_NAME_RESOLVER_SIG(default_buffer_name_resolution){ i32 conflict_index = unresolved[i]; Buffer_Name_Conflict_Entry *conflict = &conflicts[conflict_index]; - umem size = conflict->base_name.size; + u64 size = conflict->base_name.size; size = clamp_top(size, conflict->unique_name_capacity); conflict->unique_name_len_in_out = size; block_copy(conflict->unique_name_in_out, conflict->base_name.str, size); @@ -1031,9 +1031,9 @@ BUFFER_EDIT_RANGE_SIG(default_buffer_edit_range){ i64 token_index_resync = relex.first_resync_index; - Interval_i64 head = Ii64(0, token_index_first); - Interval_i64 replaced = Ii64(token_index_first, token_index_resync); - Interval_i64 tail = Ii64(token_index_resync, ptr->count); + Range_i64 head = Ii64(0, token_index_first); + Range_i64 replaced = Ii64(token_index_first, token_index_resync); + Range_i64 tail = Ii64(token_index_resync, ptr->count); i64 resynced_count = (token_index_resync_guess + 1) - token_index_resync; i64 relexed_count = relex_list.total_count - resynced_count; i64 tail_shift = relexed_count - (token_index_resync - token_index_first); diff --git a/custom/4coder_delta_rule.cpp b/custom/4coder_delta_rule.cpp index ce7bf7ef..83a7b1b5 100644 --- a/custom/4coder_delta_rule.cpp +++ b/custom/4coder_delta_rule.cpp @@ -4,8 +4,8 @@ // TOP -function umem -delta_ctx_size(umem base_size){ +function u64 +delta_ctx_size(u64 base_size){ return(base_size + sizeof(Delta_Context_Header)); } @@ -175,12 +175,12 @@ DELTA_RULE_SIG(original_delta){ *velocity = V2f32(step_x.v, step_y.v); return(V2f32(step_x.p, step_y.p)); } -global_const umem original_delta_memory_size = sizeof(Vec2_f32); +global_const u64 original_delta_memory_size = sizeof(Vec2_f32); DELTA_RULE_SIG(snap_delta){ return(pending); } -global_const umem snap_delta_memory_size = 0; +global_const u64 snap_delta_memory_size = 0; function f32 cubic_reinterpolate(f32 t){ @@ -212,7 +212,7 @@ DELTA_RULE_SIG(fixed_time_cubic_delta){ } return(result); } -global_const umem fixed_time_cubic_delta_memory_size = sizeof(f32); +global_const u64 fixed_time_cubic_delta_memory_size = sizeof(f32); // BOTTOM diff --git a/custom/4coder_doc_content_types.h b/custom/4coder_doc_content_types.h index a684a815..3e0f9b78 100644 --- a/custom/4coder_doc_content_types.h +++ b/custom/4coder_doc_content_types.h @@ -97,7 +97,7 @@ struct Doc_Content{ struct Doc_Content_List{ Doc_Content *first; Doc_Content *last; - umem total_size; + u64 total_size; i32 node_count; }; diff --git a/custom/4coder_draw.cpp b/custom/4coder_draw.cpp index aff8b74d..7ee104c6 100644 --- a/custom/4coder_draw.cpp +++ b/custom/4coder_draw.cpp @@ -340,7 +340,7 @@ draw_line_number_margin(Application_Links *app, View_ID view_id, Buffer_ID buffe Rect_f32 prev_clip = draw_set_clip(app, margin); draw_rectangle_fcolor(app, margin, 0.f, fcolor_id(defcolor_line_numbers_back)); - Interval_i64 visible_range = text_layout_get_visible_range(app, text_layout_id); + Range_i64 visible_range = text_layout_get_visible_range(app, text_layout_id); FColor line_color = fcolor_id(defcolor_line_numbers_text); @@ -391,13 +391,13 @@ draw_fps_hud(Application_Links *app, Frame_Info frame_info, Scratch_Block scratch(app); - Range ranges[2]; + Range_i32 ranges[2] = {}; ranges[0].first = wrapped_index; ranges[0].one_past_last = -1; ranges[1].first = fps_history_depth - 1; ranges[1].one_past_last = wrapped_index; for (i32 i = 0; i < 2; i += 1){ - Range r = ranges[i]; + Range_i32 r = ranges[i]; for (i32 j = r.first; j > r.one_past_last; j -= 1, p.y += line_height){ f32 dts[2]; dts[0] = history_literal_dt[j]; @@ -482,7 +482,7 @@ get_token_color_cpp(Token token){ function void draw_cpp_token_colors(Application_Links *app, Text_Layout_ID text_layout_id, Token_Array *array){ - Interval_i64 visible_range = text_layout_get_visible_range(app, text_layout_id); + Range_i64 visible_range = text_layout_get_visible_range(app, text_layout_id); i64 first_index = token_index_from_pos(array, visible_range.first); Token_Iterator_Array it = token_iterator_index(0, array, first_index); for (;;){ @@ -503,7 +503,7 @@ function void draw_comment_highlights(Application_Links *app, Buffer_ID buffer, Text_Layout_ID text_layout_id, Token_Array *array, Comment_Highlight_Pair *pairs, i32 pair_count){ Scratch_Block scratch(app); - Interval_i64 visible_range = text_layout_get_visible_range(app, text_layout_id); + Range_i64 visible_range = text_layout_get_visible_range(app, text_layout_id); i64 first_index = token_index_from_pos(array, visible_range.first); Token_Iterator_Array it = token_iterator_index(buffer, array, first_index); for (;;){ @@ -519,7 +519,7 @@ draw_comment_highlights(Application_Links *app, Buffer_ID buffer, Text_Layout_ID tail = string_skip(tail, 1), index += 1){ Comment_Highlight_Pair *pair = pairs; for (i32 i = 0; i < pair_count; i += 1, pair += 1){ - umem needle_size = pair->needle.size; + u64 needle_size = pair->needle.size; if (needle_size == 0){ continue; } diff --git a/custom/4coder_events.cpp b/custom/4coder_events.cpp index 5e17ef29..83642d20 100644 --- a/custom/4coder_events.cpp +++ b/custom/4coder_events.cpp @@ -335,9 +335,9 @@ stringize_keyboard_event(Arena *arena, Input_Event *event){ case InputEventKind_TextInsert: { string_list_push(arena, &list, string_u8_litexpr("t")); - umem size = event->text.string.size; + u64 size = event->text.string.size; u8 *ptr = event->text.string.str; - for (umem i = 0; i < size; i += 1, ptr += 1){ + for (u64 i = 0; i < size; i += 1, ptr += 1){ string_list_pushf(arena, &list, "%02X", (i32)(*ptr)); } string_list_push(arena, &list, string_u8_litexpr("\n")); @@ -369,14 +369,14 @@ stringize_keyboard_event(Arena *arena, Input_Event *event){ function Input_Event parse_keyboard_event(Arena *arena, String_Const_u8 text){ Input_Event result = {}; - umem pos = 0; + u64 pos = 0; Range_i64 range = {}; if (pos < text.size && text.str[pos] == 't'){ pos += 1; result.kind = InputEventKind_TextInsert; - umem max_size = text.size/2; + u64 max_size = text.size/2; result.text.string.str = push_array(arena, u8, max_size); for (; pos + 1 < text.size; pos += 2){ if (character_is_base16(text.str[pos]) && diff --git a/custom/4coder_file.cpp b/custom/4coder_file.cpp index b3dcaf9b..16ab21b3 100644 --- a/custom/4coder_file.cpp +++ b/custom/4coder_file.cpp @@ -14,7 +14,7 @@ function String_Const_u8 file_load_all(Arena *arena, FILE *file){ fseek(file, 0, SEEK_END); - umem size = ftell(file); + u64 size = ftell(file); fseek(file, 0, SEEK_SET); u8 *buffer = push_array(arena, u8, size + 1); fread(buffer, 1, size, file); diff --git a/custom/4coder_file.h b/custom/4coder_file.h index 035f13b0..92fc95e8 100644 --- a/custom/4coder_file.h +++ b/custom/4coder_file.h @@ -477,7 +477,7 @@ file_dump(Arena *arena, char *name){ fprintf(stdout, "fatal error: not enough memory in partition for file dumping"); exit(1); } - fread(text.str, 1, text.size, file); + fread(text.str, 1, (size_t)text.size, file); text.str[text.size] = 0; fclose(file); } diff --git a/custom/4coder_file_moving.h b/custom/4coder_file_moving.h index 2276209c..b9beb7fe 100644 --- a/custom/4coder_file_moving.h +++ b/custom/4coder_file_moving.h @@ -546,7 +546,7 @@ fm_copy_folder(Arena *arena, char *src_dir, char *dst_dir, char *src_folder){ // List Helpers internal i32 -listsize(void *p, umem item_size){ +listsize(void *p, u64 item_size){ u64 zero = 0; u8 *ptr = (u8*)p; for (;memcmp(ptr, &zero, (size_t)item_size) != 0; ptr += item_size); diff --git a/custom/4coder_hash_functions.cpp b/custom/4coder_hash_functions.cpp index a6aa7c57..58c50eea 100644 --- a/custom/4coder_hash_functions.cpp +++ b/custom/4coder_hash_functions.cpp @@ -13,7 +13,7 @@ #define FCODER_HASH_FUNCTIONS_CPP static u64 -table_hash_u8(u8 *v, umem size){ +table_hash_u8(u8 *v, u64 size){ u64 hash = 0; for (u8 *p = v, *e = v + size; p < e; p += 1){ u8 k = *p; @@ -26,7 +26,7 @@ table_hash_u8(u8 *v, umem size){ return(hash); } static u64 -table_hash_u16(u16 *v, umem size){ +table_hash_u16(u16 *v, u64 size){ u64 hash = 0; for (u16 *p = v, *e = v + size; p < e; p += 1){ u16 k = *p; @@ -39,7 +39,7 @@ table_hash_u16(u16 *v, umem size){ return(hash); } static u64 -table_hash_u32(u32 *v, umem size){ +table_hash_u32(u32 *v, u64 size){ u64 hash = 0; for (u32 *p = v, *e = v + size; p < e; p += 1){ u32 k = *p; @@ -52,7 +52,7 @@ table_hash_u32(u32 *v, umem size){ return(hash); } static u64 -table_hash_u64(u64 *v, umem size){ +table_hash_u64(u64 *v, u64 size){ u64 hash = 0; for (u64 *p = v, *e = v + size; p < e; p += 1){ u64 k = *p; @@ -65,7 +65,7 @@ table_hash_u64(u64 *v, umem size){ return(hash); } static u64 -table_hash(void *v, i32 it_size, umem size){ +table_hash(void *v, i32 it_size, u64 size){ u64 hash = 0; switch (it_size){ case 1: diff --git a/custom/4coder_helper.cpp b/custom/4coder_helper.cpp index 825bf9f7..db627f48 100644 --- a/custom/4coder_helper.cpp +++ b/custom/4coder_helper.cpp @@ -1136,7 +1136,7 @@ line_is_blank(Application_Links *app, Buffer_ID buffer, i64 line_number){ Scratch_Block scratch(app); String_Const_u8 line = push_buffer_line(app, scratch, buffer, line_number); b32 is_blank = true; - for (umem i = 0; i < line.size; i += 1){ + for (u64 i = 0; i < line.size; i += 1){ if (!character_is_whitespace(line.str[i])){ is_blank = false; break; @@ -1206,7 +1206,7 @@ get_indent_info_range(Application_Links *app, Buffer_ID buffer, Range_i64 range, info.first_char_pos = range.end; info.is_blank = true; info.all_space = true; - for (umem i = 0; i < s.size; i += 1){ + for (u64 i = 0; i < s.size; i += 1){ u8 c = s.str[i]; if (!character_is_whitespace(c)){ info.is_blank = false; @@ -1262,7 +1262,7 @@ replace_in_range(Application_Links *app, Buffer_ID buffer, Range_i64 range, Stri i64 new_pos = 0; seek_string_forward(app, buffer, pos, range.end, needle, &new_pos); i64 shift = replace_range_shift(needle.size, string.size); - for (; new_pos + (imem)needle.size <= range.end;){ + for (; new_pos + (i64)needle.size <= range.end;){ Range_i64 needle_range = Ii64(new_pos, new_pos + (i32)needle.size); buffer_replace_range(app, buffer, needle_range, string); range.end += shift; @@ -1399,7 +1399,7 @@ match_core_code(User_Input *in, Key_Code core_code){ internal String_Const_u8 backspace_utf8(String_Const_u8 string){ if (string.size > 0){ - umem i = string.size - 1; + u64 i = string.size - 1; for (; i > 0; --i){ if (string.str[i] <= 0x7F || string.str[i] >= 0xC0){ break; @@ -1773,7 +1773,7 @@ view_look_at_region(Application_Links *app, View_ID view, i64 major_pos, i64 min Rect_f32 region = view_get_buffer_region(app, view); f32 view_height = rect_height(region); f32 skirt_height = view_height*.1f; - Interval_f32 acceptable_y = If32(skirt_height, view_height*.9f); + Range_f32 acceptable_y = If32(skirt_height, view_height*.9f); f32 target_height = view_line_y_difference(app, view, bottom.line + 1, top.line); @@ -1868,7 +1868,7 @@ get_query_string(Application_Links *app, char *query_str, u8 *string_space, i32 Query_Bar_Group group(app); Query_Bar bar = {}; bar.prompt = SCu8((u8*)query_str); - bar.string = SCu8(string_space, (umem)0); + bar.string = SCu8(string_space, (u64)0); bar.string_capacity = space_size; if (!query_user_string(app, &bar)){ bar.string.size = 0; @@ -1897,7 +1897,7 @@ push_token_or_word_under_pos(Application_Links *app, Arena *arena, Buffer_ID buf String_Const_u8 result = {}; Token *token = get_token_from_pos(app, buffer, pos); if (token != 0 && token->size > 0 && token->kind != TokenBaseKind_Whitespace){ - Interval_i64 range = Ii64(token->pos, token->pos + token->size); + Range_i64 range = Ii64(token->pos, token->pos + token->size); result = push_buffer_range(app, arena, buffer, range); } return(result); @@ -1939,11 +1939,11 @@ dump_file_handle(Arena *arena, FILE *file){ Data result = {}; if (file != 0){ fseek(file, 0, SEEK_END); - umem size = ftell(file); + u64 size = ftell(file); char *mem = push_array(arena, char, size); if (mem != 0){ fseek(file, 0, SEEK_SET); - fread(mem, 1, size, file); + fread(mem, 1, (size_t)size, file); result = make_data(mem, size); } } @@ -2053,10 +2053,10 @@ sort_pairs_by_key(Sort_Pair_i32 *pairs, i32 count){ sort_pairs_by_key__quick(pairs, 0, count); } -internal Range_Array +internal Range_i32_Array get_ranges_of_duplicate_keys(Arena *arena, i32 *keys, i32 stride, i32 count){ - Range_Array result = {}; - result.ranges = push_array(arena, Range, count); + Range_i32_Array result = {}; + result.ranges = push_array(arena, Range_i32, count); u8 *ptr = (u8*)keys; i32 start_i = 0; for (i32 i = 1; i <= count; i += 1){ @@ -2068,13 +2068,13 @@ get_ranges_of_duplicate_keys(Arena *arena, i32 *keys, i32 stride, i32 count){ is_end = true; } if (is_end){ - Range *new_range = &result.ranges[result.count++]; + Range_i32 *new_range = &result.ranges[result.count++]; new_range->first = start_i; new_range->one_past_last = i; start_i = i; } } - pop_array(arena, Range, count - result.count); + pop_array(arena, Range_i32, count - result.count); return(result); } @@ -2371,7 +2371,7 @@ select_scope(Application_Links *app, View_ID view, Range_i64 range){ function Line_Ending_Kind guess_line_ending_kind_from_buffer(Application_Links *app, Buffer_ID buffer){ - umem size = buffer_get_size(app, buffer); + u64 size = buffer_get_size(app, buffer); size = clamp_top(size, KB(8)); Scratch_Block scratch(app); String_Const_u8 string = push_buffer_range(app, scratch, buffer, Ii64(0, size)); diff --git a/custom/4coder_insertion.cpp b/custom/4coder_insertion.cpp index dd660868..e548aa29 100644 --- a/custom/4coder_insertion.cpp +++ b/custom/4coder_insertion.cpp @@ -23,7 +23,7 @@ begin_buffer_insertion_at_buffered(Application_Links *app, Buffer_ID buffer_id, } function Buffer_Insertion -begin_buffer_insertion_at_buffered(Application_Links *app, Buffer_ID buffer_id, i64 at, Arena *buffer_memory, umem buffer_memory_size){ +begin_buffer_insertion_at_buffered(Application_Links *app, Buffer_ID buffer_id, i64 at, Arena *buffer_memory, u64 buffer_memory_size){ Cursor *cursor = push_array(buffer_memory, Cursor, 1); *cursor = make_cursor(push_array(buffer_memory, u8, buffer_memory_size), buffer_memory_size); return(begin_buffer_insertion_at_buffered(app, buffer_id, at, cursor)); @@ -47,14 +47,14 @@ insert_string__no_buffering(Buffer_Insertion *insertion, String_Const_u8 string) static void insert__flush(Buffer_Insertion *insertion){ Cursor *cursor = insertion->cursor; - umem pos = insertion->temp.temp_memory_cursor.pos; + u64 pos = insertion->temp.temp_memory_cursor.pos; String_Const_u8 string = SCu8(cursor->base + pos, cursor->pos - pos); insert_string__no_buffering(insertion, string); end_temp(insertion->temp); } static char* -insert__reserve(Buffer_Insertion *insertion, umem size){ +insert__reserve(Buffer_Insertion *insertion, u64 size){ char *space = push_array(insertion->cursor, char, size); if (space == 0){ insert__flush(insertion); @@ -86,7 +86,7 @@ insert_string(Buffer_Insertion *insertion, String_Const_u8 string){ } } -static umem +static u64 insertf(Buffer_Insertion *insertion, char *format, ...){ Scratch_Block scratch(insertion->app); va_list args; diff --git a/custom/4coder_jump_sticky.cpp b/custom/4coder_jump_sticky.cpp index d928fa58..2188af7a 100644 --- a/custom/4coder_jump_sticky.cpp +++ b/custom/4coder_jump_sticky.cpp @@ -106,14 +106,14 @@ init_marker_list(Application_Links *app, Heap *heap, Buffer_ID buffer, Marker_Li Scratch_Block scratch(app); Sticky_Jump_Array jumps = parse_buffer_to_jump_array(app, scratch, buffer); - Range_Array buffer_ranges = get_ranges_of_duplicate_keys(scratch, &jumps.jumps->jump_buffer_id, sizeof(*jumps.jumps), jumps.count); + Range_i32_Array buffer_ranges = get_ranges_of_duplicate_keys(scratch, &jumps.jumps->jump_buffer_id, sizeof(*jumps.jumps), jumps.count); Sort_Pair_i32 *range_index_buffer_id_pairs = push_array(scratch, Sort_Pair_i32, buffer_ranges.count); for (i32 i = 0; i < buffer_ranges.count; i += 1){ range_index_buffer_id_pairs[i].index = i; range_index_buffer_id_pairs[i].key = jumps.jumps[buffer_ranges.ranges[i].first].jump_buffer_id; } sort_pairs_by_key(range_index_buffer_id_pairs, buffer_ranges.count); - Range_Array scoped_buffer_ranges = get_ranges_of_duplicate_keys(scratch, + Range_i32_Array scoped_buffer_ranges = get_ranges_of_duplicate_keys(scratch, &range_index_buffer_id_pairs->key, sizeof(*range_index_buffer_id_pairs), buffer_ranges.count); @@ -124,14 +124,14 @@ init_marker_list(Application_Links *app, Heap *heap, Buffer_ID buffer, Marker_Li scope_array[0] = buffer_get_managed_scope(app, buffer); for (i32 i = 0; i < scoped_buffer_ranges.count; i += 1){ - Range buffer_range_indices = scoped_buffer_ranges.ranges[i]; + Range_i32 buffer_range_indices = scoped_buffer_ranges.ranges[i]; u32 total_jump_count = 0; for (i32 j = buffer_range_indices.first; j < buffer_range_indices.one_past_last; j += 1){ i32 range_index = range_index_buffer_id_pairs[j].index; - Range range = buffer_ranges.ranges[range_index]; + Range_i32 range = buffer_ranges.ranges[range_index]; total_jump_count += range_size(range); } @@ -143,7 +143,7 @@ init_marker_list(Application_Links *app, Heap *heap, Buffer_ID buffer, Marker_Li j < buffer_range_indices.one_past_last; j += 1){ i32 range_index = range_index_buffer_id_pairs[j].index; - Range range = buffer_ranges.ranges[range_index]; + Range_i32 range = buffer_ranges.ranges[range_index]; if (target_buffer_id == 0){ target_buffer_id = jumps.jumps[range.first].jump_buffer_id; } diff --git a/custom/4coder_jumping.cpp b/custom/4coder_jumping.cpp index 654e2cea..24ba23ba 100644 --- a/custom/4coder_jumping.cpp +++ b/custom/4coder_jumping.cpp @@ -5,7 +5,7 @@ // TOP function b32 -ms_style_verify(String_Const_u8 line, umem left_paren_pos, umem right_paren_pos){ +ms_style_verify(String_Const_u8 line, u64 left_paren_pos, u64 right_paren_pos){ i32 result = false; String_Const_u8 line_part = string_skip(line, right_paren_pos); if (string_match(string_prefix(line_part, 4), string_u8_litexpr(") : "))){ @@ -18,7 +18,7 @@ ms_style_verify(String_Const_u8 line, umem left_paren_pos, umem right_paren_pos) String_Const_u8 number = string_skip(string_prefix(line, right_paren_pos - 1), left_paren_pos + 1); if (!string_is_integer(number, 10)){ result = false; - umem comma_pos = string_find_first(number, ','); + u64 comma_pos = string_find_first(number, ','); if (comma_pos < number.size){ String_Const_u8 sub_number0 = string_prefix(number, comma_pos); String_Const_u8 sub_number1 = string_skip(number, comma_pos + 1); @@ -31,24 +31,24 @@ ms_style_verify(String_Const_u8 line, umem left_paren_pos, umem right_paren_pos) return(result); } -function umem +function u64 try_skip_rust_arrow(String_Const_u8 line){ - umem pos = 0; + u64 pos = 0; if (string_match(string_prefix(line, 3), string_u8_litexpr("-->"))){ String_Const_u8 sub = string_skip(line, 3); sub = string_skip_chop_whitespace(sub); - pos = (umem)(sub.str - line.str); + pos = (u64)(sub.str - line.str); } return(pos); } function b32 -check_is_note(String_Const_u8 line, umem colon_pos){ +check_is_note(String_Const_u8 line, u64 colon_pos){ b32 is_note = false; - umem note_pos = colon_pos + string_find_first(string_skip(line, colon_pos), string_u8_litexpr("note")); + u64 note_pos = colon_pos + string_find_first(string_skip(line, colon_pos), string_u8_litexpr("note")); if (note_pos < line.size){ b32 is_all_whitespace = true; - for (umem i = colon_pos + 1; i < note_pos; i += 1){ + for (u64 i = colon_pos + 1; i < note_pos; i += 1){ if (!character_is_whitespace(line.str[i])){ is_all_whitespace = false; break; @@ -67,11 +67,11 @@ parse_jump_location(String_Const_u8 line){ jump.sub_jump_indented = (string_get_character(line, 0) == ' '); String_Const_u8 reduced_line = string_skip_chop_whitespace(line); - umem whitespace_length = (umem)(reduced_line.str - line.str); + u64 whitespace_length = (u64)(reduced_line.str - line.str); line = reduced_line; - umem left_paren_pos = string_find_first(line, '('); - umem right_paren_pos = left_paren_pos + string_find_first(string_skip(line, left_paren_pos), ')'); + u64 left_paren_pos = string_find_first(line, '('); + u64 right_paren_pos = left_paren_pos + string_find_first(string_skip(line, left_paren_pos), ')'); for (;!jump.is_ms_style && right_paren_pos < line.size;){ if (ms_style_verify(line, left_paren_pos, right_paren_pos)){ jump.is_ms_style = true; @@ -96,7 +96,7 @@ parse_jump_location(String_Const_u8 line){ line_number = string_skip_chop_whitespace(line_number); if (line_number.size > 0){ - umem comma_pos = string_find_first(line_number, ','); + u64 comma_pos = string_find_first(line_number, ','); if (comma_pos < line_number.size){ String_Const_u8 column_number = string_skip(line_number, comma_pos + 1); line_number = string_prefix(line_number, comma_pos); @@ -127,15 +127,15 @@ parse_jump_location(String_Const_u8 line){ jump.has_rust_arrow = true; } - umem colon_pos1 = string_find_first(string_skip(line, start), ':') + start; + u64 colon_pos1 = string_find_first(string_skip(line, start), ':') + start; if (line.size > colon_pos1 + 1){ if (character_is_slash(string_get_character(line, colon_pos1 + 1))){ colon_pos1 = string_find_first(string_skip(line, colon_pos1 + 1), ':') + colon_pos1 + 1; } } - umem colon_pos2 = string_find_first(string_skip(line, colon_pos1 + 1), ':') + colon_pos1 + 1; - umem colon_pos3 = string_find_first(string_skip(line, colon_pos2 + 1), ':') + colon_pos2 + 1; + u64 colon_pos2 = string_find_first(string_skip(line, colon_pos1 + 1), ':') + colon_pos1 + 1; + u64 colon_pos3 = string_find_first(string_skip(line, colon_pos2 + 1), ':') + colon_pos2 + 1; if (colon_pos3 < line.size){ if (check_is_note(line, colon_pos3)){ diff --git a/custom/4coder_layout_rule.cpp b/custom/4coder_layout_rule.cpp index dd1be3eb..56056c93 100644 --- a/custom/4coder_layout_rule.cpp +++ b/custom/4coder_layout_rule.cpp @@ -301,7 +301,7 @@ layout_unwrapped_small_blank_lines(Application_Links *app, Arena *arena, Buffer_ Newline_Layout_Vars newline_vars = get_newline_layout_vars(); b32 all_whitespace = true; - for (umem i = 0; i < text.size; i += 1){ + for (u64 i = 0; i < text.size; i += 1){ if (!character_is_whitespace(text.str[i])){ all_whitespace = false; break; @@ -315,7 +315,7 @@ layout_unwrapped_small_blank_lines(Application_Links *app, Arena *arena, Buffer_ u8 *ptr = text.str; u8 *end_ptr = ptr + text.size; for (;ptr < end_ptr;){ - Character_Consume_Result consume = utf8_consume(ptr, (umem)(end_ptr - ptr)); + Character_Consume_Result consume = utf8_consume(ptr, (u64)(end_ptr - ptr)); i64 index = layout_index_from_ptr(ptr, text.str, range.first); switch (consume.codepoint){ @@ -396,7 +396,7 @@ layout_wrap_anywhere(Application_Links *app, Arena *arena, Buffer_ID buffer, Ran u8 *ptr = text.str; u8 *end_ptr = ptr + text.size; for (;ptr < end_ptr;){ - Character_Consume_Result consume = utf8_consume(ptr, (umem)(end_ptr - ptr)); + Character_Consume_Result consume = utf8_consume(ptr, (u64)(end_ptr - ptr)); i64 index = layout_index_from_ptr(ptr, text.str, range.first); switch (consume.codepoint){ default: @@ -469,7 +469,7 @@ layout_unwrapped__inner(Application_Links *app, Arena *arena, Buffer_ID buffer, u8 *ptr = text.str; u8 *end_ptr = ptr + text.size; for (;ptr < end_ptr;){ - Character_Consume_Result consume = utf8_consume(ptr, (umem)(end_ptr - ptr)); + Character_Consume_Result consume = utf8_consume(ptr, (u64)(end_ptr - ptr)); i64 index = layout_index_from_ptr(ptr, text.str, range.first); switch (consume.codepoint){ @@ -572,7 +572,7 @@ layout_wrap_whitespace__inner(Application_Links *app, Arena *arena, Buffer_ID bu ptr = word.str; for (;ptr < word_end;){ Character_Consume_Result consume = - utf8_consume(ptr, (umem)(word_end - ptr)); + utf8_consume(ptr, (u64)(word_end - ptr)); if (consume.codepoint != max_u32){ total_advance += lr_tb_advance(&pos_vars, face, consume.codepoint); } @@ -591,7 +591,7 @@ layout_wrap_whitespace__inner(Application_Links *app, Arena *arena, Buffer_ID bu for (;ptr < word_end;){ Character_Consume_Result consume = - utf8_consume(ptr, (umem)(word_end - ptr)); + utf8_consume(ptr, (u64)(word_end - ptr)); i64 index = layout_index_from_ptr(ptr, text.str, range.first); if (consume.codepoint != max_u32){ diff --git a/custom/4coder_lister_base.cpp b/custom/4coder_lister_base.cpp index 512bbcb9..315ad374 100644 --- a/custom/4coder_lister_base.cpp +++ b/custom/4coder_lister_base.cpp @@ -684,7 +684,7 @@ lister_begin_new_item_set(Application_Links *app, Lister *lister){ } function void* -lister_add_item(Lister *lister, Lister_Prealloced_String string, Lister_Prealloced_String status, void *user_data, umem extra_space){ +lister_add_item(Lister *lister, Lister_Prealloced_String string, Lister_Prealloced_String status, void *user_data, u64 extra_space){ void *base_memory = push_array(lister->arena, u8, sizeof(Lister_Node) + extra_space); Lister_Node *node = (Lister_Node*)base_memory; node->string = string.string; @@ -699,17 +699,17 @@ lister_add_item(Lister *lister, Lister_Prealloced_String string, Lister_Prealloc function void* lister_add_item(Lister *lister, Lister_Prealloced_String string, String_Const_u8 status, - void *user_data, umem extra_space){ + void *user_data, u64 extra_space){ return(lister_add_item(lister, string, lister_prealloced(push_string_copy(lister->arena, status)), user_data, extra_space)); } function void* -lister_add_item(Lister *lister, String_Const_u8 string, Lister_Prealloced_String status, void *user_data, umem extra_space){ +lister_add_item(Lister *lister, String_Const_u8 string, Lister_Prealloced_String status, void *user_data, u64 extra_space){ return(lister_add_item(lister, lister_prealloced(push_string_copy(lister->arena, string)), status, user_data, extra_space)); } function void* -lister_add_item(Lister *lister, String_Const_u8 string, String_Const_u8 status, void *user_data, umem extra_space){ +lister_add_item(Lister *lister, String_Const_u8 string, String_Const_u8 status, void *user_data, u64 extra_space){ return(lister_add_item(lister, lister_prealloced(push_string_copy(lister->arena, string)), lister_prealloced(push_string_copy(lister->arena, status)), @@ -895,7 +895,7 @@ get_choice_from_user(Application_Links *app, String_Const_u8 query, for (Lister_Choice *choice = list.first; choice != 0; choice = choice->next){ - umem code_size = sizeof(choice->key_code); + u64 code_size = sizeof(choice->key_code); void *extra = lister_add_item(lister, choice->string, choice->status, choice, code_size); block_copy(extra, &choice->key_code, code_size); diff --git a/custom/4coder_log_parser.cpp b/custom/4coder_log_parser.cpp index f8564b73..dfbccc96 100644 --- a/custom/4coder_log_parser.cpp +++ b/custom/4coder_log_parser.cpp @@ -173,7 +173,7 @@ make_log_parse(Arena *arena, String_Const_u8 source){ parse.id_to_string_table = make_table_u64_Data(arena->base_allocator, 500); for (;source.size > 0;){ - umem end_of_line = string_find_first(source, '\n'); + u64 end_of_line = string_find_first(source, '\n'); String_Const_u8 line = string_prefix(source, end_of_line); line = string_skip_chop_whitespace(line); source = string_skip(source, end_of_line + 1); @@ -185,11 +185,11 @@ make_log_parse(Arena *arena, String_Const_u8 source){ String_Const_u8 whole_line = line; { - umem colon1 = string_find_first(line, ':'); + u64 colon1 = string_find_first(line, ':'); src_file_name = string_prefix(line, colon1); line = string_skip(line, colon1 + 1); - umem colon2 = string_find_first(line, ':'); + u64 colon2 = string_find_first(line, ':'); src_line_number = string_prefix(line, colon2); line = string_skip(line, colon2 + 1); @@ -201,12 +201,12 @@ make_log_parse(Arena *arena, String_Const_u8 source){ if (!got_source_position){ line = whole_line; - umem colon0 = string_find_first(line, ':'); - umem colon1 = string_find_first(line, colon0 + 1, ':'); + u64 colon0 = string_find_first(line, ':'); + u64 colon1 = string_find_first(line, colon0 + 1, ':'); src_file_name = string_prefix(line, colon1); line = string_skip(line, colon1 + 1); - umem colon2 = string_find_first(line, ':'); + u64 colon2 = string_find_first(line, ':'); src_line_number = string_prefix(line, colon2); line = string_skip(line, colon2 + 1); @@ -216,7 +216,7 @@ make_log_parse(Arena *arena, String_Const_u8 source){ } if (got_source_position){ - umem bracket_open = string_find_first(line, '['); + u64 bracket_open = string_find_first(line, '['); String_Const_u8 event_name = string_prefix(line, bracket_open); event_name = string_skip_chop_whitespace(event_name); line = string_skip(line, bracket_open + 1); @@ -225,13 +225,13 @@ make_log_parse(Arena *arena, String_Const_u8 source){ src_file_name, src_line_number, event_name); for (;line.size > 0;){ - umem bracket_close = string_find_first(line, ']'); + u64 bracket_close = string_find_first(line, ']'); String_Const_u8 tag = string_prefix(line, bracket_close); line = string_skip(line, bracket_close + 1); bracket_open = string_find_first(line, '['); line = string_skip(line, bracket_open + 1); - umem equal_sign = string_find_first(tag, '='); + u64 equal_sign = string_find_first(tag, '='); String_Const_u8 tag_name = string_prefix(tag, equal_sign); String_Const_u8 tag_contents = string_skip(tag, equal_sign + 1); diff --git a/custom/4coder_malloc_allocator.cpp b/custom/4coder_malloc_allocator.cpp index 6eeec41d..a16b7419 100644 --- a/custom/4coder_malloc_allocator.cpp +++ b/custom/4coder_malloc_allocator.cpp @@ -8,9 +8,9 @@ #include internal void* -base_reserve__malloc(void *user_data, umem size, umem *size_out, String_Const_u8 location){ +base_reserve__malloc(void *user_data, u64 size, u64 *size_out, String_Const_u8 location){ *size_out = size; - return(malloc(size)); + return(malloc((size_t)size)); } internal void @@ -35,13 +35,13 @@ get_allocator_malloc(void){ } internal Arena -make_arena_malloc(umem chunk_size, umem align){ +make_arena_malloc(u64 chunk_size, u64 align){ Base_Allocator *allocator = get_allocator_malloc(); return(make_arena(allocator, chunk_size, align)); } internal Arena -make_arena_malloc(umem chunk_size){ +make_arena_malloc(u64 chunk_size){ return(make_arena_malloc(chunk_size, 8)); } diff --git a/custom/4coder_miblo_numbers.cpp b/custom/4coder_miblo_numbers.cpp index a83c4063..a139b95a 100644 --- a/custom/4coder_miblo_numbers.cpp +++ b/custom/4coder_miblo_numbers.cpp @@ -150,7 +150,7 @@ get_timestamp_at_cursor(Application_Links *app, Buffer_ID buffer, i64 pos, Miblo String_Const_u8 string = push_buffer_range(app, scratch, buffer, time_stamp_range); if (string.size > 0){ i32 count_colons = 0; - for (umem i = 0; i < string.size; ++i){ + for (u64 i = 0; i < string.size; ++i){ if (string.str[i] == ':'){ count_colons += 1; } diff --git a/custom/4coder_profile_inspect.h b/custom/4coder_profile_inspect.h index 0855b802..891cb7a0 100644 --- a/custom/4coder_profile_inspect.h +++ b/custom/4coder_profile_inspect.h @@ -94,7 +94,7 @@ struct Memory_Bucket{ Memory_Bucket *next; Memory_Annotation annotation; String_Const_u8 location; - umem total_memory; + u64 total_memory; }; #endif diff --git a/custom/4coder_project_commands.cpp b/custom/4coder_project_commands.cpp index 6aa67f83..8ead13f6 100644 --- a/custom/4coder_project_commands.cpp +++ b/custom/4coder_project_commands.cpp @@ -948,7 +948,7 @@ project_key_strings_query_user(Application_Links *app, if (get_script_file){ script_file_bar.prompt = string_u8_litexpr("Script Name: "); - script_file_bar.string = SCu8(script_file_space, (umem)0); + script_file_bar.string = SCu8(script_file_space, (u64)0); script_file_bar.string_capacity = script_file_cap; if (!query_user_string(app, &script_file_bar)) return(keys); if (script_file_bar.string.size == 0) return(keys); @@ -956,14 +956,14 @@ project_key_strings_query_user(Application_Links *app, if (get_code_file){ code_file_bar.prompt = string_u8_litexpr("Build Target: "); - code_file_bar.string = SCu8(code_file_space, (umem)0); + code_file_bar.string = SCu8(code_file_space, (u64)0); code_file_bar.string_capacity = code_file_cap; if (!query_user_string(app, &code_file_bar)) return(keys); if (code_file_bar.string.size == 0) return(keys); } output_dir_bar.prompt = string_u8_litexpr("Output Directory: "); - output_dir_bar.string = SCu8(output_dir_space, (umem)0); + output_dir_bar.string = SCu8(output_dir_space, (u64)0); output_dir_bar.string_capacity = output_dir_cap; if (!query_user_string(app, &output_dir_bar)) return(keys); if (output_dir_bar.string.size == 0 && output_dir_cap > 0){ @@ -972,7 +972,7 @@ project_key_strings_query_user(Application_Links *app, } binary_file_bar.prompt = string_u8_litexpr("Binary Output: "); - binary_file_bar.string = SCu8(binary_file_space, (umem)0); + binary_file_bar.string = SCu8(binary_file_space, (u64)0); binary_file_bar.string_capacity = binary_file_cap; if (!query_user_string(app, &binary_file_bar)) return(keys); if (binary_file_bar.string.size == 0) return(keys); diff --git a/custom/4coder_stringf.cpp b/custom/4coder_stringf.cpp index 7bfa5446..6e839fbf 100644 --- a/custom/4coder_stringf.cpp +++ b/custom/4coder_stringf.cpp @@ -16,7 +16,7 @@ push_stringfv(Arena *arena, char *format, va_list args){ va_copy(args2, args); i32 size = vsnprintf(0, 0, format, args); String_Const_char result = string_const_char_push(arena, size + 1); - vsnprintf(result.str, result.size, format, args2); + vsnprintf(result.str, (size_t)result.size, format, args2); result.size -= 1; result.str[result.size] = 0; return(result); @@ -45,8 +45,8 @@ push_u8_stringf(Arena *arena, char *format, ...){ static void string_list_pushfv(Arena *arena, List_String_Const_char *list, char *format, va_list args){ String_Const_char string = push_stringfv(arena, format, args); - if (arena->alignment < sizeof(umem)){ - push_align(arena, sizeof(umem)); + if (arena->alignment < sizeof(u64)){ + push_align(arena, sizeof(u64)); } string_list_push(arena, list, string); } @@ -60,8 +60,8 @@ string_list_pushf(Arena *arena, List_String_Const_char *list, char *format, ...) static void string_list_pushfv(Arena *arena, List_String_Const_u8 *list, char *format, va_list args){ String_Const_u8 string = push_u8_stringfv(arena, format, args); - if (arena->alignment < sizeof(umem)){ - push_align(arena, sizeof(umem)); + if (arena->alignment < sizeof(u64)){ + push_align(arena, sizeof(u64)); } string_list_push(arena, list, string); } diff --git a/custom/4coder_system_allocator.cpp b/custom/4coder_system_allocator.cpp index 3e63097f..da81444f 100644 --- a/custom/4coder_system_allocator.cpp +++ b/custom/4coder_system_allocator.cpp @@ -5,29 +5,28 @@ // TOP internal void* -base_reserve__system(void *user_data, umem size, umem *size_out, String_Const_u8 location){ - umem extra_size = 128; - umem increased_size = size + extra_size; - size = round_up_umem(increased_size, KB(4)); +base_reserve__system(void *user_data, u64 size, u64 *size_out, String_Const_u8 location){ + u64 extra_size = 128; + u64 increased_size = size + extra_size; + size = round_up_u64(increased_size, KB(4)); *size_out = size - extra_size; void *ptr = system_memory_allocate(size, location); - *(umem*)ptr = size; + *(u64*)ptr = size; ptr = (u8*)ptr + extra_size; return(ptr); } internal void base_free__system(void *user_data, void *ptr){ - umem extra_size = 128; + u64 extra_size = 128; ptr = (u8*)ptr - extra_size; - umem size = *(umem*)ptr; + u64 size = *(u64*)ptr; system_memory_free(ptr, size); } internal Base_Allocator make_base_allocator_system(void){ - return(make_base_allocator(base_reserve__system, 0, 0, - base_free__system, 0, 0)); + return(make_base_allocator(base_reserve__system, 0, 0, base_free__system, 0, 0)); } global Base_Allocator base_allocator_system = {}; @@ -41,12 +40,12 @@ get_base_allocator_system(void){ } internal Arena -make_arena_system(umem chunk_size, umem align){ +make_arena_system(u64 chunk_size, u64 align){ return(make_arena(get_base_allocator_system(), chunk_size, align)); } internal Arena -make_arena_system(umem chunk_size){ +make_arena_system(u64 chunk_size){ return(make_arena_system(chunk_size, 8)); } diff --git a/custom/4coder_system_types.h b/custom/4coder_system_types.h index f2c791ab..d92bf656 100644 --- a/custom/4coder_system_types.h +++ b/custom/4coder_system_types.h @@ -35,7 +35,7 @@ struct Memory_Annotation_Node{ Memory_Annotation_Node *next; String_Const_u8 location; void *address; - umem size; + u64 size; }; struct Memory_Annotation{ diff --git a/custom/4coder_token.cpp b/custom/4coder_token.cpp index dd4bb111..277e93e7 100644 --- a/custom/4coder_token.cpp +++ b/custom/4coder_token.cpp @@ -4,7 +4,7 @@ // TOP -function Interval_i64 +function Range_i64 Ii64(Token *token){ return(Ii64_size(token->pos, token->size)); } diff --git a/custom/4coder_types.h b/custom/4coder_types.h index f195bc3f..f432316f 100644 --- a/custom/4coder_types.h +++ b/custom/4coder_types.h @@ -475,7 +475,7 @@ api(custom) struct Query_Bar{ String_Const_u8 prompt; String_Const_u8 string; - umem string_capacity; + u64 string_capacity; }; api(custom) @@ -554,7 +554,7 @@ struct Face_Advance_Map{ api(custom) struct Edit{ String_Const_u8 text; - Interval_i64 range; + Range_i64 range; }; api(custom) @@ -660,8 +660,8 @@ struct Buffer_Name_Conflict_Entry{ String_Const_u8 file_name; String_Const_u8 base_name; u8 *unique_name_in_out; - umem unique_name_len_in_out; - umem unique_name_capacity; + u64 unique_name_len_in_out; + u64 unique_name_capacity; }; api(custom) @@ -674,8 +674,8 @@ typedef i32 Buffer_Hook_Function(Application_Links *app, Buffer_ID buffer_id); api(custom) typedef i32 Buffer_Edit_Range_Function(Application_Links *app, Buffer_ID buffer_id, - Range_i64 new_range, umem original_size); -#define BUFFER_EDIT_RANGE_SIG(name) i32 name(Application_Links *app, Buffer_ID buffer_id, Interval_i64 new_range, umem original_size) + Range_i64 new_range, u64 original_size); +#define BUFFER_EDIT_RANGE_SIG(name) i32 name(Application_Links *app, Buffer_ID buffer_id, Range_i64 new_range, u64 original_size) api(custom) typedef Vec2_f32 Delta_Rule_Function(Vec2_f32 pending, b32 is_new_target, f32 dt, void *data); @@ -738,7 +738,7 @@ api(custom) struct View_Context{ Render_Caller_Function *render_caller; Delta_Rule_Function *delta_rule; - umem delta_rule_memory_size; + u64 delta_rule_memory_size; b32 hides_buffer; struct Mapping *mapping; i64 map_id; diff --git a/custom/bin/setup_cl_generic.bat b/custom/bin/setup_cl_generic.bat index 1f503fa5..50246ce1 100644 --- a/custom/bin/setup_cl_generic.bat +++ b/custom/bin/setup_cl_generic.bat @@ -1,9 +1,5 @@ @echo off -REM (allen): quit early if we already have cl -where /q cl -IF %ERRORLEVEL% == 0 (EXIT /b) - SET "LIB=" SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 12.0 diff --git a/custom/bin/setup_cl_x64.bat b/custom/bin/setup_cl_x64.bat index fa31686c..0c30f7df 100644 --- a/custom/bin/setup_cl_x64.bat +++ b/custom/bin/setup_cl_x64.bat @@ -1,5 +1,9 @@ @echo off +REM (allen): quit early if we already have cl +where /q cl +IF %ERRORLEVEL% == 0 (EXIT /b) + SET SCRIPTS_PATH=%~dp0 %SCRIPTS_PATH%\setup_cl_generic.bat amd64 diff --git a/custom/generated/custom_api.h b/custom/generated/custom_api.h index df943b2a..27bb15db 100644 --- a/custom/generated/custom_api.h +++ b/custom/generated/custom_api.h @@ -104,7 +104,7 @@ #define custom_managed_id_group_highest_id_sig() u64 custom_managed_id_group_highest_id(Application_Links* app, String_Const_u8 group) #define custom_managed_id_declare_sig() Managed_ID custom_managed_id_declare(Application_Links* app, String_Const_u8 group, String_Const_u8 name) #define custom_managed_id_get_sig() Managed_ID custom_managed_id_get(Application_Links* app, String_Const_u8 group, String_Const_u8 name) -#define custom_managed_scope_get_attachment_sig() void* custom_managed_scope_get_attachment(Application_Links* app, Managed_Scope scope, Managed_ID id, umem size) +#define custom_managed_scope_get_attachment_sig() void* custom_managed_scope_get_attachment(Application_Links* app, Managed_Scope scope, Managed_ID id, u64 size) #define custom_managed_scope_attachment_erase_sig() b32 custom_managed_scope_attachment_erase(Application_Links* app, Managed_Scope scope, Managed_ID id) #define custom_alloc_managed_memory_in_scope_sig() Managed_Object custom_alloc_managed_memory_in_scope(Application_Links* app, Managed_Scope scope, i32 item_size, i32 count) #define custom_alloc_buffer_markers_on_buffer_sig() Managed_Object custom_alloc_buffer_markers_on_buffer(Application_Links* app, Buffer_ID buffer_id, i32 count, Managed_Scope* optional_extra_scope) @@ -122,7 +122,7 @@ #define custom_set_current_input_sig() void custom_set_current_input(Application_Links* app, User_Input* input) #define custom_leave_current_input_unhandled_sig() void custom_leave_current_input_unhandled(Application_Links* app) #define custom_set_custom_hook_sig() void custom_set_custom_hook(Application_Links* app, Hook_ID hook_id, Void_Func* func_ptr) -#define custom_set_custom_hook_memory_size_sig() b32 custom_set_custom_hook_memory_size(Application_Links* app, Hook_ID hook_id, umem size) +#define custom_set_custom_hook_memory_size_sig() b32 custom_set_custom_hook_memory_size(Application_Links* app, Hook_ID hook_id, u64 size) #define custom_get_mouse_state_sig() Mouse_State custom_get_mouse_state(Application_Links* app) #define custom_get_active_query_bars_sig() b32 custom_get_active_query_bars(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out) #define custom_start_query_bar_sig() b32 custom_start_query_bar(Application_Links* app, Query_Bar* bar, u32 flags) @@ -164,7 +164,7 @@ #define custom_text_layout_get_visible_range_sig() Range_i64 custom_text_layout_get_visible_range(Application_Links* app, Text_Layout_ID text_layout_id) #define custom_text_layout_line_on_screen_sig() Range_f32 custom_text_layout_line_on_screen(Application_Links* app, Text_Layout_ID layout_id, i64 line_number) #define custom_text_layout_character_on_screen_sig() Rect_f32 custom_text_layout_character_on_screen(Application_Links* app, Text_Layout_ID layout_id, i64 pos) -#define custom_paint_text_color_sig() void custom_paint_text_color(Application_Links* app, Text_Layout_ID layout_id, Interval_i64 range, ARGB_Color color) +#define custom_paint_text_color_sig() void custom_paint_text_color(Application_Links* app, Text_Layout_ID layout_id, Range_i64 range, ARGB_Color color) #define custom_text_layout_free_sig() b32 custom_text_layout_free(Application_Links* app, Text_Layout_ID text_layout_id) #define custom_draw_text_layout_sig() void custom_draw_text_layout(Application_Links* app, Text_Layout_ID layout_id, ARGB_Color special_color, ARGB_Color ghost_color) #define custom_open_color_picker_sig() void custom_open_color_picker(Application_Links* app, Color_Picker* picker) @@ -278,7 +278,7 @@ typedef Base_Allocator* custom_managed_scope_allocator_type(Application_Links* a typedef u64 custom_managed_id_group_highest_id_type(Application_Links* app, String_Const_u8 group); typedef Managed_ID custom_managed_id_declare_type(Application_Links* app, String_Const_u8 group, String_Const_u8 name); typedef Managed_ID custom_managed_id_get_type(Application_Links* app, String_Const_u8 group, String_Const_u8 name); -typedef void* custom_managed_scope_get_attachment_type(Application_Links* app, Managed_Scope scope, Managed_ID id, umem size); +typedef void* custom_managed_scope_get_attachment_type(Application_Links* app, Managed_Scope scope, Managed_ID id, u64 size); typedef b32 custom_managed_scope_attachment_erase_type(Application_Links* app, Managed_Scope scope, Managed_ID id); typedef Managed_Object custom_alloc_managed_memory_in_scope_type(Application_Links* app, Managed_Scope scope, i32 item_size, i32 count); typedef Managed_Object custom_alloc_buffer_markers_on_buffer_type(Application_Links* app, Buffer_ID buffer_id, i32 count, Managed_Scope* optional_extra_scope); @@ -296,7 +296,7 @@ typedef User_Input custom_get_current_input_type(Application_Links* app); typedef void custom_set_current_input_type(Application_Links* app, User_Input* input); typedef void custom_leave_current_input_unhandled_type(Application_Links* app); typedef void custom_set_custom_hook_type(Application_Links* app, Hook_ID hook_id, Void_Func* func_ptr); -typedef b32 custom_set_custom_hook_memory_size_type(Application_Links* app, Hook_ID hook_id, umem size); +typedef b32 custom_set_custom_hook_memory_size_type(Application_Links* app, Hook_ID hook_id, u64 size); typedef Mouse_State custom_get_mouse_state_type(Application_Links* app); typedef b32 custom_get_active_query_bars_type(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out); typedef b32 custom_start_query_bar_type(Application_Links* app, Query_Bar* bar, u32 flags); @@ -338,7 +338,7 @@ typedef Buffer_ID custom_text_layout_get_buffer_type(Application_Links* app, Tex typedef Range_i64 custom_text_layout_get_visible_range_type(Application_Links* app, Text_Layout_ID text_layout_id); typedef Range_f32 custom_text_layout_line_on_screen_type(Application_Links* app, Text_Layout_ID layout_id, i64 line_number); typedef Rect_f32 custom_text_layout_character_on_screen_type(Application_Links* app, Text_Layout_ID layout_id, i64 pos); -typedef void custom_paint_text_color_type(Application_Links* app, Text_Layout_ID layout_id, Interval_i64 range, ARGB_Color color); +typedef void custom_paint_text_color_type(Application_Links* app, Text_Layout_ID layout_id, Range_i64 range, ARGB_Color color); typedef b32 custom_text_layout_free_type(Application_Links* app, Text_Layout_ID text_layout_id); typedef void custom_draw_text_layout_type(Application_Links* app, Text_Layout_ID layout_id, ARGB_Color special_color, ARGB_Color ghost_color); typedef void custom_open_color_picker_type(Application_Links* app, Color_Picker* picker); @@ -629,7 +629,7 @@ internal Base_Allocator* managed_scope_allocator(Application_Links* app, Managed internal u64 managed_id_group_highest_id(Application_Links* app, String_Const_u8 group); internal Managed_ID managed_id_declare(Application_Links* app, String_Const_u8 group, String_Const_u8 name); internal Managed_ID managed_id_get(Application_Links* app, String_Const_u8 group, String_Const_u8 name); -internal void* managed_scope_get_attachment(Application_Links* app, Managed_Scope scope, Managed_ID id, umem size); +internal void* managed_scope_get_attachment(Application_Links* app, Managed_Scope scope, Managed_ID id, u64 size); internal b32 managed_scope_attachment_erase(Application_Links* app, Managed_Scope scope, Managed_ID id); internal Managed_Object alloc_managed_memory_in_scope(Application_Links* app, Managed_Scope scope, i32 item_size, i32 count); internal Managed_Object alloc_buffer_markers_on_buffer(Application_Links* app, Buffer_ID buffer_id, i32 count, Managed_Scope* optional_extra_scope); @@ -647,7 +647,7 @@ internal User_Input get_current_input(Application_Links* app); internal void set_current_input(Application_Links* app, User_Input* input); internal void leave_current_input_unhandled(Application_Links* app); internal void set_custom_hook(Application_Links* app, Hook_ID hook_id, Void_Func* func_ptr); -internal b32 set_custom_hook_memory_size(Application_Links* app, Hook_ID hook_id, umem size); +internal b32 set_custom_hook_memory_size(Application_Links* app, Hook_ID hook_id, u64 size); internal Mouse_State get_mouse_state(Application_Links* app); internal b32 get_active_query_bars(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out); internal b32 start_query_bar(Application_Links* app, Query_Bar* bar, u32 flags); @@ -689,7 +689,7 @@ internal Buffer_ID text_layout_get_buffer(Application_Links* app, Text_Layout_ID internal Range_i64 text_layout_get_visible_range(Application_Links* app, Text_Layout_ID text_layout_id); internal Range_f32 text_layout_line_on_screen(Application_Links* app, Text_Layout_ID layout_id, i64 line_number); internal Rect_f32 text_layout_character_on_screen(Application_Links* app, Text_Layout_ID layout_id, i64 pos); -internal void paint_text_color(Application_Links* app, Text_Layout_ID layout_id, Interval_i64 range, ARGB_Color color); +internal void paint_text_color(Application_Links* app, Text_Layout_ID layout_id, Range_i64 range, ARGB_Color color); internal b32 text_layout_free(Application_Links* app, Text_Layout_ID text_layout_id); internal void draw_text_layout(Application_Links* app, Text_Layout_ID layout_id, ARGB_Color special_color, ARGB_Color ghost_color); internal void open_color_picker(Application_Links* app, Color_Picker* picker); diff --git a/custom/generated/custom_api_constructor.cpp b/custom/generated/custom_api_constructor.cpp index 42960d1c..f72a65da 100644 --- a/custom/generated/custom_api_constructor.cpp +++ b/custom/generated/custom_api_constructor.cpp @@ -632,7 +632,7 @@ API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("manage api_param(arena, call, "Application_Links*", "app"); api_param(arena, call, "Managed_Scope", "scope"); api_param(arena, call, "Managed_ID", "id"); -api_param(arena, call, "umem", "size"); +api_param(arena, call, "u64", "size"); } { API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("managed_scope_attachment_erase"), string_u8_litexpr("b32"), string_u8_litexpr("")); @@ -733,7 +733,7 @@ api_param(arena, call, "Void_Func*", "func_ptr"); API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("set_custom_hook_memory_size"), string_u8_litexpr("b32"), string_u8_litexpr("")); api_param(arena, call, "Application_Links*", "app"); api_param(arena, call, "Hook_ID", "hook_id"); -api_param(arena, call, "umem", "size"); +api_param(arena, call, "u64", "size"); } { API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("get_mouse_state"), string_u8_litexpr("Mouse_State"), string_u8_litexpr("")); diff --git a/custom/generated/custom_api_master_list.h b/custom/generated/custom_api_master_list.h index 22c159cb..53c10b50 100644 --- a/custom/generated/custom_api_master_list.h +++ b/custom/generated/custom_api_master_list.h @@ -104,7 +104,7 @@ api(custom) function Base_Allocator* managed_scope_allocator(Application_Links* api(custom) function u64 managed_id_group_highest_id(Application_Links* app, String_Const_u8 group); api(custom) function Managed_ID managed_id_declare(Application_Links* app, String_Const_u8 group, String_Const_u8 name); api(custom) function Managed_ID managed_id_get(Application_Links* app, String_Const_u8 group, String_Const_u8 name); -api(custom) function void* managed_scope_get_attachment(Application_Links* app, Managed_Scope scope, Managed_ID id, umem size); +api(custom) function void* managed_scope_get_attachment(Application_Links* app, Managed_Scope scope, Managed_ID id, u64 size); api(custom) function b32 managed_scope_attachment_erase(Application_Links* app, Managed_Scope scope, Managed_ID id); api(custom) function Managed_Object alloc_managed_memory_in_scope(Application_Links* app, Managed_Scope scope, i32 item_size, i32 count); api(custom) function Managed_Object alloc_buffer_markers_on_buffer(Application_Links* app, Buffer_ID buffer_id, i32 count, Managed_Scope* optional_extra_scope); @@ -122,7 +122,7 @@ api(custom) function User_Input get_current_input(Application_Links* app); api(custom) function void set_current_input(Application_Links* app, User_Input* input); api(custom) function void leave_current_input_unhandled(Application_Links* app); api(custom) function void set_custom_hook(Application_Links* app, Hook_ID hook_id, Void_Func* func_ptr); -api(custom) function b32 set_custom_hook_memory_size(Application_Links* app, Hook_ID hook_id, umem size); +api(custom) function b32 set_custom_hook_memory_size(Application_Links* app, Hook_ID hook_id, u64 size); api(custom) function Mouse_State get_mouse_state(Application_Links* app); api(custom) function b32 get_active_query_bars(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out); api(custom) function b32 start_query_bar(Application_Links* app, Query_Bar* bar, u32 flags); @@ -164,7 +164,7 @@ api(custom) function Buffer_ID text_layout_get_buffer(Application_Links* app, Te api(custom) function Range_i64 text_layout_get_visible_range(Application_Links* app, Text_Layout_ID text_layout_id); api(custom) function Range_f32 text_layout_line_on_screen(Application_Links* app, Text_Layout_ID layout_id, i64 line_number); api(custom) function Rect_f32 text_layout_character_on_screen(Application_Links* app, Text_Layout_ID layout_id, i64 pos); -api(custom) function void paint_text_color(Application_Links* app, Text_Layout_ID layout_id, Interval_i64 range, ARGB_Color color); +api(custom) function void paint_text_color(Application_Links* app, Text_Layout_ID layout_id, Range_i64 range, ARGB_Color color); api(custom) function b32 text_layout_free(Application_Links* app, Text_Layout_ID text_layout_id); api(custom) function void draw_text_layout(Application_Links* app, Text_Layout_ID layout_id, ARGB_Color special_color, ARGB_Color ghost_color); api(custom) function void open_color_picker(Application_Links* app, Color_Picker* picker); diff --git a/custom/generated/lexer_cpp.cpp b/custom/generated/lexer_cpp.cpp index f1a73f7b..150e5fbf 100644 --- a/custom/generated/lexer_cpp.cpp +++ b/custom/generated/lexer_cpp.cpp @@ -2,9 +2,9 @@ #define FCODER_LEX_GEN_HAND_WRITTEN internal u64 -lexeme_hash(u64 seed, u8 *ptr, umem size){ +lexeme_hash(u64 seed, u8 *ptr, u64 size){ u64 result = 0; - for (umem i = 0; i < size; i += 1, ptr += 1){ + for (u64 i = 0; i < size; i += 1, ptr += 1){ result ^= ((*ptr) ^ result*59) + seed; } return(result); @@ -13,7 +13,7 @@ lexeme_hash(u64 seed, u8 *ptr, umem size){ internal Lexeme_Table_Lookup lexeme_table_lookup(u64 *hash_array, String_Const_u8 *key_array, Lexeme_Table_Value *value_array, i32 slot_count, u64 seed, - u8 *ptr, umem size){ + u8 *ptr, u64 size){ Lexeme_Table_Lookup result = {}; u64 hash = lexeme_hash(seed, ptr, size); u64 comparison_hash = hash | 1; @@ -3698,8 +3698,8 @@ goto state_label_47; // raw_string_try_delim } { state_label_47: // raw_string_try_delim -umem delim_length = state.delim_one_past_last - state.delim_first; -umem parse_length = 0; +u64 delim_length = state.delim_one_past_last - state.delim_first; +u64 parse_length = 0; for (;;){ if (parse_length == delim_length){ goto state_label_48; // raw_string_try_quote diff --git a/custom/generated/system_api.h b/custom/generated/system_api.h index 19be05af..ce9536da 100644 --- a/custom/generated/system_api.h +++ b/custom/generated/system_api.h @@ -37,9 +37,9 @@ #define system_condition_variable_wait_sig() void system_condition_variable_wait(System_Condition_Variable cv, System_Mutex mutex) #define system_condition_variable_signal_sig() void system_condition_variable_signal(System_Condition_Variable cv) #define system_condition_variable_free_sig() void system_condition_variable_free(System_Condition_Variable cv) -#define system_memory_allocate_sig() void* system_memory_allocate(umem size, String_Const_u8 location) -#define system_memory_set_protection_sig() b32 system_memory_set_protection(void* ptr, umem size, u32 flags) -#define system_memory_free_sig() void system_memory_free(void* ptr, umem size) +#define system_memory_allocate_sig() void* system_memory_allocate(u64 size, String_Const_u8 location) +#define system_memory_set_protection_sig() b32 system_memory_set_protection(void* ptr, u64 size, u32 flags) +#define system_memory_free_sig() void system_memory_free(void* ptr, u64 size) #define system_memory_annotation_sig() Memory_Annotation system_memory_annotation(Arena* arena) #define system_show_mouse_cursor_sig() void system_show_mouse_cursor(i32 show) #define system_set_fullscreen_sig() b32 system_set_fullscreen(b32 full_screen) @@ -84,9 +84,9 @@ typedef System_Condition_Variable system_condition_variable_make_type(void); typedef void system_condition_variable_wait_type(System_Condition_Variable cv, System_Mutex mutex); typedef void system_condition_variable_signal_type(System_Condition_Variable cv); typedef void system_condition_variable_free_type(System_Condition_Variable cv); -typedef void* system_memory_allocate_type(umem size, String_Const_u8 location); -typedef b32 system_memory_set_protection_type(void* ptr, umem size, u32 flags); -typedef void system_memory_free_type(void* ptr, umem size); +typedef void* system_memory_allocate_type(u64 size, String_Const_u8 location); +typedef b32 system_memory_set_protection_type(void* ptr, u64 size, u32 flags); +typedef void system_memory_free_type(void* ptr, u64 size); typedef Memory_Annotation system_memory_annotation_type(Arena* arena); typedef void system_show_mouse_cursor_type(i32 show); typedef b32 system_set_fullscreen_type(b32 full_screen); @@ -181,9 +181,9 @@ internal System_Condition_Variable system_condition_variable_make(void); internal void system_condition_variable_wait(System_Condition_Variable cv, System_Mutex mutex); internal void system_condition_variable_signal(System_Condition_Variable cv); internal void system_condition_variable_free(System_Condition_Variable cv); -internal void* system_memory_allocate(umem size, String_Const_u8 location); -internal b32 system_memory_set_protection(void* ptr, umem size, u32 flags); -internal void system_memory_free(void* ptr, umem size); +internal void* system_memory_allocate(u64 size, String_Const_u8 location); +internal b32 system_memory_set_protection(void* ptr, u64 size, u32 flags); +internal void system_memory_free(void* ptr, u64 size); internal Memory_Annotation system_memory_annotation(Arena* arena); internal void system_show_mouse_cursor(i32 show); internal b32 system_set_fullscreen(b32 full_screen); diff --git a/custom/generated/system_api_constructor.cpp b/custom/generated/system_api_constructor.cpp index ca22b181..530774fe 100644 --- a/custom/generated/system_api_constructor.cpp +++ b/custom/generated/system_api_constructor.cpp @@ -181,19 +181,19 @@ api_param(arena, call, "System_Condition_Variable", "cv"); } { API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("memory_allocate"), string_u8_litexpr("void*"), string_u8_litexpr("")); -api_param(arena, call, "umem", "size"); +api_param(arena, call, "u64", "size"); api_param(arena, call, "String_Const_u8", "location"); } { API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("memory_set_protection"), string_u8_litexpr("b32"), string_u8_litexpr("")); api_param(arena, call, "void*", "ptr"); -api_param(arena, call, "umem", "size"); +api_param(arena, call, "u64", "size"); api_param(arena, call, "u32", "flags"); } { API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("memory_free"), string_u8_litexpr("void"), string_u8_litexpr("")); api_param(arena, call, "void*", "ptr"); -api_param(arena, call, "umem", "size"); +api_param(arena, call, "u64", "size"); } { API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("memory_annotation"), string_u8_litexpr("Memory_Annotation"), string_u8_litexpr("")); diff --git a/custom/generated/system_api_master_list.h b/custom/generated/system_api_master_list.h index 8332a293..5e49a84d 100644 --- a/custom/generated/system_api_master_list.h +++ b/custom/generated/system_api_master_list.h @@ -37,9 +37,9 @@ api(system) function System_Condition_Variable condition_variable_make(void); api(system) function void condition_variable_wait(System_Condition_Variable cv, System_Mutex mutex); api(system) function void condition_variable_signal(System_Condition_Variable cv); api(system) function void condition_variable_free(System_Condition_Variable cv); -api(system) function void* memory_allocate(umem size, String_Const_u8 location); -api(system) function b32 memory_set_protection(void* ptr, umem size, u32 flags); -api(system) function void memory_free(void* ptr, umem size); +api(system) function void* memory_allocate(u64 size, String_Const_u8 location); +api(system) function b32 memory_set_protection(void* ptr, u64 size, u32 flags); +api(system) function void memory_free(void* ptr, u64 size); api(system) function Memory_Annotation memory_annotation(Arena* arena); api(system) function void show_mouse_cursor(i32 show); api(system) function b32 set_fullscreen(b32 full_screen); diff --git a/custom/lexer_generator/4coder_lex_gen_hand_written.cpp b/custom/lexer_generator/4coder_lex_gen_hand_written.cpp index 0976b05e..5718ca7e 100644 --- a/custom/lexer_generator/4coder_lex_gen_hand_written.cpp +++ b/custom/lexer_generator/4coder_lex_gen_hand_written.cpp @@ -2,9 +2,9 @@ #define FCODER_LEX_GEN_HAND_WRITTEN internal u64 -lexeme_hash(u64 seed, u8 *ptr, umem size){ +lexeme_hash(u64 seed, u8 *ptr, u64 size){ u64 result = 0; - for (umem i = 0; i < size; i += 1, ptr += 1){ + for (u64 i = 0; i < size; i += 1, ptr += 1){ result ^= ((*ptr) ^ result*59) + seed; } return(result); @@ -13,7 +13,7 @@ lexeme_hash(u64 seed, u8 *ptr, umem size){ internal Lexeme_Table_Lookup lexeme_table_lookup(u64 *hash_array, String_Const_u8 *key_array, Lexeme_Table_Value *value_array, i32 slot_count, u64 seed, - u8 *ptr, umem size){ + u8 *ptr, u64 size){ Lexeme_Table_Lookup result = {}; u64 hash = lexeme_hash(seed, ptr, size); u64 comparison_hash = hash | 1; diff --git a/custom/lexer_generator/4coder_lex_gen_main.cpp b/custom/lexer_generator/4coder_lex_gen_main.cpp index 1284f434..357c7273 100644 --- a/custom/lexer_generator/4coder_lex_gen_main.cpp +++ b/custom/lexer_generator/4coder_lex_gen_main.cpp @@ -921,7 +921,7 @@ smi_input_set_construct(Arena *arena, String_Const_u8 characters){ Input_Set result = {}; result.count = (i32)characters.size; result.inputs = push_array_zero(arena, u16, result.count); - for (umem i = 0; i < characters.size; i += 1){ + for (u64 i = 0; i < characters.size; i += 1){ result.inputs[i] = (u16)characters.str[i]; } return(result); @@ -1270,7 +1270,7 @@ internal b32 sm_op(char *lexeme){ String_Const_u8 l = SCu8(lexeme); List_String_Const_u8 name_list = {}; - for (umem i = 0; i < l.size; i += 1){ + for (u64 i = 0; i < l.size; i += 1){ Table_Lookup lookup = table_lookup(&helper_ctx.char_to_name, l.str[i]); // If this fails first check that all the characters in the lexeme are named! Assert(lookup.found_match); @@ -1681,7 +1681,7 @@ smo_remove_ops_without_prefix(Operator_Set *set, char *prefix){ } internal void -smo_ops_string_skip(Operator_Set *set, umem size){ +smo_ops_string_skip(Operator_Set *set, u64 size){ Operator_Set new_set = {}; new_set.lexeme_to_ptr = make_table_Data_u64(helper_ctx.primary_ctx.allocator, set->count*2); @@ -1756,7 +1756,7 @@ smo_op_set_lexer_root(Operator_Set *set, State *machine_root, String_Const_u8 fa node != 0; node = node->next){ String_Const_u8 lexeme = node->op; - for (umem i = 1; i < lexeme.size; i += 1){ + for (u64 i = 1; i < lexeme.size; i += 1){ String_Const_u8 prefix = string_prefix(lexeme, i); Table_Lookup lookup = table_lookup(&string_to_state, make_data(prefix.str, prefix.size)); if (!lookup.found_match){ @@ -1833,7 +1833,7 @@ smo_op_set_lexer_root(Operator_Set *set, State *machine_root, String_Const_u8 fa node != 0; node = node->next){ String_Const_u8 lexeme = node->op; - for (umem i = 1; i < lexeme.size; i += 1){ + for (u64 i = 1; i < lexeme.size; i += 1){ String_Const_u8 prefix = string_prefix(lexeme, i); Table_Lookup lookup = table_lookup(&string_to_state, make_data(prefix.str, prefix.size)); Assert(lookup.found_match); @@ -1924,9 +1924,9 @@ smh_typical_tokens(void){ internal String_Const_u8 string_char_subtract(String_Const_u8 a, String_Const_u8 b){ - for (umem i = 0; i < b.size; i += 1){ + for (u64 i = 0; i < b.size; i += 1){ u8 c = b.str[i]; - for (umem j = 0; j < a.size;){ + for (u64 j = 0; j < a.size;){ if (a.str[j] == c){ a.str[j] = a.str[a.size - 1]; a.size -= 1; @@ -3201,7 +3201,7 @@ gen_keyword_table(Arena *scratch, Token_Kind_Set tokens, Keyword_Set keywords, F fprintf(out, "u8 %.*s_key_array_%d[] = {", string_expand(keywords.pretty_name), i); String_Const_u8 lexeme = key_layout.slots[i]->lexeme; - for (umem j = 0; j < lexeme.size; j += 1){ + for (u64 j = 0; j < lexeme.size; j += 1){ fprintf(out, "0x%02x,", lexeme.str[j]); } fprintf(out, "};\n"); @@ -3744,8 +3744,8 @@ gen_contiguous_control_flow_lexer(Arena *scratch, Token_Kind_Set tokens, Lexer_M Transition *failure_trans = trans->next; Assert(failure_trans->condition.kind == TransitionCaseKind_DelimMatchFail); - fprintf(out, "umem delim_length = state.delim_one_past_last - state.delim_first;\n"); - fprintf(out, "umem parse_length = 0;\n"); + fprintf(out, "u64 delim_length = state.delim_one_past_last - state.delim_first;\n"); + fprintf(out, "u64 parse_length = 0;\n"); fprintf(out, "for (;;){\n"); { fprintf(out, "if (parse_length == delim_length){\n"); diff --git a/docs/4ed_doc_helper.cpp b/docs/4ed_doc_helper.cpp index 4554fc81..5ffd065e 100644 --- a/docs/4ed_doc_helper.cpp +++ b/docs/4ed_doc_helper.cpp @@ -22,9 +22,9 @@ make_doc_function(Arena *arena, Doc_Cluster *cluster, API_Call *call){ string_expand(call->return_type), string_expand(call->name)); - umem indent_size = call->name.size + 1; + u64 indent_size = call->name.size + 1; u8 *buffer = push_array(arena, u8, indent_size); - for (umem i = 0; i < indent_size; i += 1){ + for (u64 i = 0; i < indent_size; i += 1){ buffer[i] = ' '; } String_Const_u8 indent = SCu8(buffer, indent_size); diff --git a/opengl/4ed_opengl_defines.h b/opengl/4ed_opengl_defines.h index 840f560a..be20f65e 100644 --- a/opengl/4ed_opengl_defines.h +++ b/opengl/4ed_opengl_defines.h @@ -224,7 +224,7 @@ typedef void GL_Debug_Function(GLenum src, void *user_data); typedef GL_Debug_Function *GLDEBUGPROC; -#define GL_FUNC(N,R,P) typedef R (N##_Function)P; N##_Function *N = 0; +#define GL_FUNC(N,R,P) typedef R (CALL_CONVENTION N##_Function)P; N##_Function *N = 0; #include "4ed_opengl_funcs.h" #endif diff --git a/opengl/4ed_opengl_render.cpp b/opengl/4ed_opengl_render.cpp index 537a261d..3e83095d 100644 --- a/opengl/4ed_opengl_render.cpp +++ b/opengl/4ed_opengl_render.cpp @@ -55,7 +55,7 @@ gl__fill_texture(Texture_Kind texture_kind, u32 texture, Vec3_i32 p, Vec3_i32 di return(result); } -internal void CALL_CONVENTION +internal void gl__error_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, char *message, void *userParam){ switch (id){ case 131218: @@ -189,7 +189,7 @@ gl__make_program(char *header, char *vertex, char *fragment){ glGetShaderInfoLog(fragment_shader, sizeof(fragment_errors), &ignore, fragment_errors); glGetProgramInfoLog(program, sizeof(program_errors), &ignore, program_errors); #if SHIP_MODE - os_popup_window(string_u8_litexpr("Error"), string_u8_litexpr("Shader compilation failed.")); + os_popup_error("Error", "Shader compilation failed."); #endif InvalidPath; } diff --git a/platform_mac/mac_4ed.cpp b/platform_mac/mac_4ed.cpp index 63e107c3..77b111ec 100644 --- a/platform_mac/mac_4ed.cpp +++ b/platform_mac/mac_4ed.cpp @@ -512,13 +512,13 @@ osx_get_loadable_fonts(Partition *part, Font_Setup_List *list){ #include "4ed_shared_init_logic.cpp" external void* -osx_allocate(umem size){ +osx_allocate(u64 size){ void *result = system_memory_allocate(size); return(result); } external void -osx_free(void *ptr, umem size){ +osx_free(void *ptr, u64 size){ system_memory_free(ptr, size); } diff --git a/platform_mac/osx_objective_c_to_cpp_links.h b/platform_mac/osx_objective_c_to_cpp_links.h index 2c01e2d6..cdc74099 100644 --- a/platform_mac/osx_objective_c_to_cpp_links.h +++ b/platform_mac/osx_objective_c_to_cpp_links.h @@ -49,7 +49,7 @@ typedef struct OSX_Objective_C_Vars{ b32 just_posted_to_clipboard; char *clipboard_space; - umem clipboard_space_max; + u64 clipboard_space_max; b32 full_screen; b32 do_toggle; @@ -73,10 +73,10 @@ typedef struct OSX_Font_Match{ extern OSX_Objective_C_Vars osx_objc; external void* -osx_allocate(umem size); +osx_allocate(u64 size); external void -osx_free(void *ptr, umem size); +osx_free(void *ptr, u64 size); external void osx_resize(int width, int height); diff --git a/platform_unix/unix_4ed_functions.cpp b/platform_unix/unix_4ed_functions.cpp index 5341b3d4..75e121fb 100644 --- a/platform_unix/unix_4ed_functions.cpp +++ b/platform_unix/unix_4ed_functions.cpp @@ -48,7 +48,7 @@ Sys_File_Can_Be_Made_Sig(system_file_can_be_made){ // internal void* -system_memory_allocate_extended(void *base, umem size){ +system_memory_allocate_extended(void *base, u64 size){ // NOTE(allen): This must return the exact base of the vpage. // We will count on the user to keep track of size themselves. void *result = mmap(base, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index a5339f18..0ed48a78 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -595,6 +595,12 @@ system_cli_end_update_sig(){ return(close_me); } +function void +os_popup_error(char *title, char *message){ + MessageBoxA(0, title, message, MB_OK); + ExitProcess(1); +} + #include "4ed_font_provider_freetype.h" #include "4ed_font_provider_freetype.cpp" @@ -815,7 +821,7 @@ system_sleep_sig(){ //////////////////////////////// -internal DWORD +internal DWORD CALL_CONVENTION win32_thread_wrapper(void *ptr){ Win32_Object *object = (Win32_Object*)ptr; Thread_Function *proc = object->thread.proc; @@ -947,7 +953,7 @@ system_condition_variable_free_sig(){ //////////////////////////////// -internal LRESULT +internal LRESULT CALL_CONVENTION win32_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ LRESULT result = 0; Scratch_Block scratch(win32vars.tctx); @@ -1320,7 +1326,7 @@ win32_gl_create_window(HWND *wnd_out, HGLRC *context_out, DWORD style, RECT rect { String_Const_u8 s = string_skip_whitespace(extensions); for (;s.size > 0;){ - umem end = string_find_first_whitespace(s); + u64 end = string_find_first_whitespace(s); String_Const_u8 m = string_prefix(s, end); if (string_match(m, string_u8_litexpr("WGL_EXT_framebuffer_sRGB")) || string_match(m, string_u8_litexpr("WGL_ARB_framebuffer_sRGB"))){ diff --git a/platform_win32/win32_4ed_functions.cpp b/platform_win32/win32_4ed_functions.cpp index 2f7c038e..8e139ea1 100644 --- a/platform_win32/win32_4ed_functions.cpp +++ b/platform_win32/win32_4ed_functions.cpp @@ -28,7 +28,7 @@ struct Memory_Annotation_Tracker_Node{ Memory_Annotation_Tracker_Node *next; Memory_Annotation_Tracker_Node *prev; String_Const_u8 location; - umem size; + u64 size; }; struct Memory_Annotation_Tracker{ @@ -41,9 +41,9 @@ global Memory_Annotation_Tracker memory_tracker = {}; global CRITICAL_SECTION memory_tracker_mutex; internal void* -win32_memory_allocate_extended(void *base, umem size, String_Const_u8 location){ - umem adjusted_size = size + 64; - void *result = VirtualAlloc(base, adjusted_size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); +win32_memory_allocate_extended(void *base, u64 size, String_Const_u8 location){ + u64 adjusted_size = size + 64; + void *result = VirtualAlloc(base, (SIZE_T)adjusted_size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); Memory_Annotation_Tracker_Node *node = (Memory_Annotation_Tracker_Node*)result; EnterCriticalSection(&memory_tracker_mutex); zdll_push_back(memory_tracker.first, memory_tracker.last, node); @@ -89,7 +89,7 @@ system_memory_set_protection_sig(){ node -= 1; DWORD old_protect = 0; - b32 result = VirtualProtect(node, size, protect, &old_protect); + b32 result = VirtualProtect(node, (SIZE_T)size, protect, &old_protect); return(result); } @@ -167,13 +167,13 @@ win32_remove_unc_prefix_characters(String_Const_u8 path){ // ? #endif path.size -= 7; - memmove(path.str, path.str + 7, path.size); + block_copy(path.str, path.str + 7, path.size); path.str[0] = '\\'; } else if (string_match(string_prefix(path, 4), string_u8_litexpr("\\\\?\\"))){ // TODO(allen): Same questions essentially. path.size -= 4; - memmove(path.str, path.str + 4, path.size); + block_copy(path.str, path.str + 4, path.size); } return(path); } diff --git a/project.4coder b/project.4coder index 804b68d8..a4a31ba8 100644 --- a/project.4coder +++ b/project.4coder @@ -24,7 +24,9 @@ load_paths = { }; build_x64_win32 = "echo build: x64 & bin\\build.bat"; +build_x86_win32 = "echo build: x86 & bin\\build.bat /DDEV_BUILD_X86"; build_x64_unix = "echo build: x64 & bin/build.sh"; +build_x86_unix = "echo build: x86 & bin/build.sh -DDEV_BUILD_X86"; command_list = { { .name = "build x64", @@ -33,6 +35,12 @@ command_list = { {build_x64_unix , .os = "linux"}, {build_x64_unix , .os = "mac" }, }, }, + { .name = "build x86", + .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, + .cmd = { {build_x86_win32, .os = "win" }, + {build_x86_unix , .os = "linux"}, + {build_x86_unix , .os = "mac" }, }, }, + { .name = "package", .out = "*compilation*", .footer_panel = false, .save_dirty_files = true, .cmd = { {"echo package & bin\\package.bat", .os = "win" }, diff --git a/site/4ed_site_render_main.cpp b/site/4ed_site_render_main.cpp index a0850af3..a9eade7b 100644 --- a/site/4ed_site_render_main.cpp +++ b/site/4ed_site_render_main.cpp @@ -45,6 +45,7 @@ char html_header[] = R"HTMLFOO( + @@ -416,7 +417,7 @@ int main(){ Thread_Context *tctx = &tctx_; String_Const_u8 self = string_u8_litexpr(__FILE__); - umem code_pos = string_find_first(self, string_u8_litexpr("code")); + u64 code_pos = string_find_first(self, string_u8_litexpr("code")); String_Const_u8 root = string_prefix(self, code_pos + 5); String_Const_u8 outside_root = string_prefix(self, code_pos); String_Const_u8 build_root = push_u8_stringf(&arena, "%.*sbuild/", diff --git a/site/static/home.html b/site/static/home.html index d3a95103..cd63187e 100644 --- a/site/static/home.html +++ b/site/static/home.html @@ -1,6 +1,7 @@ + 4coder