Rip out the super annoying Data String_Const_u8 distinction

master
Allen Webster 2020-12-30 16:55:11 -08:00
parent 7b7b7df7b8
commit 5ace38f37d
29 changed files with 368 additions and 385 deletions

View File

@ -275,10 +275,10 @@ App_Init_Sig(app_init){
// NOTE(allen): init baked in buffers
File_Init init_files[] = {
{ string_u8_litinit("*messages*"), &models->message_buffer , true , },
{ string_u8_litinit("*scratch*") , &models->scratch_buffer , false, },
{ string_u8_litinit("*log*") , &models->log_buffer , true , },
{ string_u8_litinit("*keyboard*"), &models->keyboard_buffer, true , },
{ str8_lit("*messages*"), &models->message_buffer , true , },
{ str8_lit("*scratch*") , &models->scratch_buffer , false, },
{ str8_lit("*log*") , &models->log_buffer , true , },
{ str8_lit("*keyboard*"), &models->keyboard_buffer, true , },
};
Buffer_Hook_Function *begin_buffer_func = models->begin_buffer;

View File

@ -1726,12 +1726,12 @@ view_current_context(Application_Links *app, View_ID view_id){
return(result);
}
api(custom) function Data
api(custom) function String_Const_u8
view_current_context_hook_memory(Application_Links *app, View_ID view_id,
Hook_ID hook_id){
Models *models = (Models*)app->cmd_context;
View *view = imp_get_view(models, view_id);
Data result = {};
String_Const_u8 result = {};
if (api_check_view(view)){
View_Context_Node *ctx = view_current_context_node(view);
if (ctx != 0){
@ -1969,9 +1969,9 @@ managed_scope_get_attachment(Application_Links *app, Managed_Scope scope, Manage
void *result = 0;
if (workspace != 0){
Dynamic_Variable_Block *var_block = &workspace->var_block;
Data data = dynamic_variable_get(var_block, id, size);
String_Const_u8 data = dynamic_variable_get(var_block, id, size);
if (data.size >= size){
result = data.data;
result = data.str;
}
else{
#define M \

View File

@ -194,8 +194,8 @@ buffer_init(Gap_Buffer *buffer, u8 *data, u64 size, Base_Allocator *allocator){
buffer->allocator = allocator;
u64 capacity = round_up_u64(size*2, KB(4));
Data memory = base_allocate(allocator, capacity);
buffer->data = (u8*)memory.data;
String_Const_u8 memory = base_allocate(allocator, capacity);
buffer->data = (u8*)memory.str;
buffer->size1 = size/2;
buffer->gap_size = capacity - size;
buffer->size2 = size - buffer->size1;
@ -215,8 +215,8 @@ buffer_replace_range(Gap_Buffer *buffer, Range_i64 range, String_Const_u8 text,
if (shift_amount + size > buffer->max){
i64 new_max = round_up_i64(2*(shift_amount + size), KB(4));
i64 new_gap_size = new_max - size;
Data new_memory_data = base_allocate(buffer->allocator, new_max);
u8 *new_memory = (u8*)new_memory_data.data;
String_Const_u8 new_memory_data = base_allocate(buffer->allocator, new_max);
u8 *new_memory = (u8*)new_memory_data.str;
block_copy(new_memory, buffer->data, buffer->size1);
block_copy(new_memory + buffer->size1 + new_gap_size, buffer->data + buffer->size1 + buffer->gap_size,
buffer->size2);
@ -364,8 +364,8 @@ internal void
buffer_starts__ensure_max_size(Gap_Buffer *buffer, i64 max_size){
if (max_size > buffer->line_start_max){
i64 new_max = round_up_i64(max_size*2, KB(1));
Data memory = base_allocate(buffer->allocator, sizeof(*buffer->line_starts)*new_max);
i64 *new_line_starts = (i64*)memory.data;
String_Const_u8 memory = base_allocate(buffer->allocator, sizeof(*buffer->line_starts)*new_max);
i64 *new_line_starts = (i64*)memory.str;
block_copy_dynamic_array(new_line_starts, buffer->line_starts, buffer->line_start_count);
buffer->line_start_max = new_max;
base_free(buffer->allocator, buffer->line_starts);

View File

@ -13,12 +13,12 @@ internal void
managed_ids_init(Base_Allocator *allocator, Managed_ID_Set *set){
set->arena = make_arena(allocator, KB(4), 8);
set->name_to_group_table = make_table_Data_u64(allocator, 20);
}
}
internal Managed_ID
managed_ids_group_highest_id(Managed_ID_Set *set, String_Const_u8 group_name){
Managed_ID result = 0;
Data data = make_data(group_name.str, group_name.size);
String_Const_u8 data = make_data(group_name.str, group_name.size);
Table_Lookup lookup = table_lookup(&set->name_to_group_table, data);
if (lookup.found_match){
u64 val = 0;
@ -32,8 +32,8 @@ managed_ids_group_highest_id(Managed_ID_Set *set, String_Const_u8 group_name){
internal Managed_ID
managed_ids_declare(Managed_ID_Set *set, String_Const_u8 group_name, String_Const_u8 name){
Managed_ID_Group *group = 0;
{
Data data = make_data(group_name.str, group_name.size);
{
String_Const_u8 data = make_data(group_name.str, group_name.size);
Table_Lookup lookup = table_lookup(&set->name_to_group_table, data);
if (lookup.found_match){
u64 val = 0;
@ -50,7 +50,7 @@ managed_ids_declare(Managed_ID_Set *set, String_Const_u8 group_name, String_Cons
}
Managed_ID result = 0;
{
Data data = make_data(name.str, name.size);
String_Const_u8 data = make_data(name.str, name.size);
Table_Lookup lookup = table_lookup(&group->name_to_id_table, data);
if (lookup.found_match){
table_read(&group->name_to_id_table, lookup, &result);
@ -69,7 +69,7 @@ function Managed_ID
managed_ids_get(Managed_ID_Set *set, String_Const_u8 group_name, String_Const_u8 name){
Managed_ID_Group *group = 0;
{
Data data = make_data(group_name.str, group_name.size);
String_Const_u8 data = make_data(group_name.str, group_name.size);
Table_Lookup lookup = table_lookup(&set->name_to_group_table, data);
if (lookup.found_match){
u64 val = 0;
@ -79,7 +79,7 @@ managed_ids_get(Managed_ID_Set *set, String_Const_u8 group_name, String_Const_u8
}
Managed_ID result = 0;
if (group != 0){
Data data = make_data(name.str, name.size);
String_Const_u8 data = make_data(name.str, name.size);
Table_Lookup lookup = table_lookup(&group->name_to_id_table, data);
if (lookup.found_match){
table_read(&group->name_to_id_table, lookup, &result);
@ -96,9 +96,9 @@ dynamic_variable_block_init(Base_Allocator *allocator, Dynamic_Variable_Block *b
block->id_to_data_table = make_table_u64_Data(allocator, 20);
}
internal Data
internal String_Const_u8
dynamic_variable_get(Dynamic_Variable_Block *block, Managed_ID id, u64 size){
Data result = {};
String_Const_u8 result = {};
Table_Lookup lookup = table_lookup(&block->id_to_data_table, id);
if (lookup.found_match){
table_read(&block->id_to_data_table, lookup, &result);
@ -194,12 +194,12 @@ dynamic_workspace_get_pointer(Dynamic_Workspace *workspace, u32 id){
////////////////////////////////
internal Data
internal String_Const_u8
lifetime__key_as_data(Lifetime_Object **members, i32 count){
return(make_data(members, sizeof(*members)*count));
}
internal Data
internal String_Const_u8
lifetime__key_as_data(Lifetime_Key *key){
return(lifetime__key_as_data(key->members, key->count));
}
@ -249,7 +249,7 @@ lifetime__free_key(Lifetime_Allocator *lifetime_allocator, Lifetime_Key *key, Li
}
// Free
Data key_data = lifetime__key_as_data(key);
String_Const_u8 key_data = lifetime__key_as_data(key);
table_erase(&lifetime_allocator->key_table, key_data);
table_erase(&lifetime_allocator->key_check_table, (u64)PtrAsInt(key));
base_free(lifetime_allocator->allocator, key->members);
@ -398,7 +398,7 @@ lifetime_sort_and_dedup_object_set(Lifetime_Object **ptr_array, i32 count){
internal Lifetime_Key*
lifetime_get_or_create_intersection_key(Lifetime_Allocator *lifetime_allocator, Lifetime_Object **object_ptr_array, i32 count){
{
Data key_data = lifetime__key_as_data(object_ptr_array, count);
String_Const_u8 key_data = lifetime__key_as_data(object_ptr_array, count);
Table_Lookup lookup = table_lookup(&lifetime_allocator->key_table, key_data);
if (lookup.found_match){
u64 val = 0;
@ -426,8 +426,8 @@ lifetime_get_or_create_intersection_key(Lifetime_Allocator *lifetime_allocator,
// Initialize
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;
String_Const_u8 new_memory = base_allocate(lifetime_allocator->allocator, new_memory_size);
new_key->members = (Lifetime_Object**)new_memory.str;
block_copy_dynamic_array(new_key->members, object_ptr_array, count);
new_key->count = count;
dynamic_workspace_init(lifetime_allocator,
@ -435,7 +435,7 @@ lifetime_get_or_create_intersection_key(Lifetime_Allocator *lifetime_allocator,
&new_key->dynamic_workspace);
{
Data key_data = lifetime__key_as_data(new_key);
String_Const_u8 key_data = lifetime__key_as_data(new_key);
u64 new_key_val = (u64)PtrAsInt(new_key);
table_insert(&lifetime_allocator->key_table, key_data, new_key_val);
table_insert(&lifetime_allocator->key_check_table, new_key_val, new_key_val);
@ -471,8 +471,8 @@ get_dynamic_object_memory_ptr(Managed_Object_Standard_Header *header){
internal Managed_Object
managed_object_alloc_managed_memory(Dynamic_Workspace *workspace, i32 item_size, i32 count, void **ptr_out){
i32 size = item_size*count;
Data new_memory = base_allocate(&workspace->heap_wrapper, sizeof(Managed_Memory_Header) + size);
void *ptr = new_memory.data;
String_Const_u8 new_memory = base_allocate(&workspace->heap_wrapper, sizeof(Managed_Memory_Header) + size);
void *ptr = new_memory.str;
Managed_Memory_Header *header = (Managed_Memory_Header*)ptr;
header->std_header.type = ManagedObjectType_Memory;
header->std_header.item_size = item_size;
@ -487,8 +487,8 @@ managed_object_alloc_managed_memory(Dynamic_Workspace *workspace, i32 item_size,
internal Managed_Object
managed_object_alloc_buffer_markers(Dynamic_Workspace *workspace, Buffer_ID buffer_id, i32 count, Marker **markers_out){
i32 size = count*sizeof(Marker);
Data new_memory = base_allocate(&workspace->heap_wrapper, size + sizeof(Managed_Buffer_Markers_Header));
void *ptr = new_memory.data;
String_Const_u8 new_memory = base_allocate(&workspace->heap_wrapper, size + sizeof(Managed_Buffer_Markers_Header));
void *ptr = new_memory.str;
Managed_Buffer_Markers_Header *header = (Managed_Buffer_Markers_Header*)ptr;
header->std_header.type = ManagedObjectType_Markers;
header->std_header.item_size = sizeof(Marker);

View File

@ -295,7 +295,7 @@ file_get_line_layout(Thread_Context *tctx, Models *models, Editing_File *file,
key.width = width;
key.line_number = line_number;
Data key_data = make_data_struct(&key);
String_Const_u8 key_data = make_data_struct(&key);
Layout_Item_List *list = 0;

View File

@ -28,8 +28,8 @@ internal void
history__push_back_record_ptr(Base_Allocator *allocator, Record_Ptr_Lookup_Table *lookup, Record *record){
if (lookup->records == 0 || lookup->count == lookup->max){
i32 new_max = clamp_bot(1024, lookup->max*2);
Data new_memory = base_allocate(allocator, sizeof(Record*)*new_max);
Record **new_records = (Record**)new_memory.data;
String_Const_u8 new_memory = base_allocate(allocator, sizeof(Record*)*new_max);
Record **new_records = (Record**)new_memory.str;
block_copy(new_records, lookup->records, sizeof(*new_records)*lookup->count);
if (lookup->records != 0){
base_free(allocator, lookup->records);
@ -83,8 +83,8 @@ history__allocate_record(History *history){
Node *new_node = sentinel->next;
if (new_node == sentinel){
i32 new_record_count = 1024;
Data new_memory = base_allocate(&history->heap_wrapper, sizeof(Record)*new_record_count);
void *memory = new_memory.data;
String_Const_u8 new_memory = base_allocate(&history->heap_wrapper, sizeof(Record)*new_record_count);
void *memory = new_memory.str;
Record *new_record = (Record*)memory;
sentinel->next = &new_record->node;

View File

@ -25,8 +25,7 @@ async_pop_node(Async_System *async_system){
}
function Async_Node*
async_push_node__inner(Async_System *async_system, Async_Task_Function_Type *func,
Data data){
async_push_node__inner(Async_System *async_system, Async_Task_Function_Type *func, String_Const_u8 data){
Async_Task result = async_system->task_id_counter;
async_system->task_id_counter += 1;
@ -40,8 +39,8 @@ async_push_node__inner(Async_System *async_system, Async_Task_Function_Type *fun
node->task = result;
node->thread = 0;
node->func = func;
node->data.data = (u8*)heap_allocate(&async_system->node_heap, data.size);
block_copy(node->data.data, data.data, data.size);
node->data.str = (u8*)heap_allocate(&async_system->node_heap, data.size);
block_copy(node->data.str, data.str, data.size);
node->data.size = data.size;
dll_insert_back(&async_system->task_sent, &node->node);
async_system->task_count += 1;
@ -51,14 +50,14 @@ async_push_node__inner(Async_System *async_system, Async_Task_Function_Type *fun
}
function Async_Task
async_push_node(Async_System *async_system, Async_Task_Function_Type *func, Data data){
async_push_node(Async_System *async_system, Async_Task_Function_Type *func, String_Const_u8 data){
Async_Node *node = async_push_node__inner(async_system, func, data);
return(node->task);
}
function void
async_free_node(Async_System *async_system, Async_Node *node){
heap_free(&async_system->node_heap, node->data.data);
heap_free(&async_system->node_heap, node->data.str);
sll_stack_push(async_system->free_nodes, node);
}
@ -150,8 +149,7 @@ async_task_handler_init(Application_Links *app, Async_System *async_system){
}
function Async_Task
async_task_no_dep(Async_System *async_system, Async_Task_Function_Type *func,
Data data){
async_task_no_dep(Async_System *async_system, Async_Task_Function_Type *func, String_Const_u8 data){
system_mutex_acquire(async_system->mutex);
Async_Task result = async_push_node(async_system, func, data);
system_mutex_release(async_system->mutex);

View File

@ -7,7 +7,7 @@
#if !defined(FCODER_ASYNC_TASKS_H)
#define FCODER_ASYNC_TASKS_H
typedef void Async_Task_Function_Type(struct Async_Context *actx, Data data);
typedef void Async_Task_Function_Type(struct Async_Context *actx, String_Const_u8 data);
typedef u64 Async_Task;
struct Async_Thread{
@ -26,7 +26,7 @@ struct Async_Node{
Async_Task task;
Async_Thread *thread;
Async_Task_Function_Type *func;
Data data;
String_Const_u8 data;
};
struct Async_System{

View File

@ -148,15 +148,15 @@ round_up_pot_u32(u32 x){
////////////////////////////////
function Data
function String_Const_u8
make_data(void *memory, u64 size){
Data data = {(u8*)memory, size};
String_Const_u8 data = {(u8*)memory, size};
return(data);
}
#define make_data_struct(s) make_data((s), sizeof(*(s)))
global_const Data zero_data = {};
global_const String_Const_u8 zero_data = {};
#define data_initr(m,s) {(u8*)(m), (s)}
#define data_initr_struct(s) {(u8*)(s), sizeof(*(s))}
@ -172,8 +172,8 @@ block_zero(void *mem, u64 size){
}
}
function void
block_zero(Data data){
block_zero(data.data, data.size);
block_zero(String_Const_u8 data){
block_zero(data.str, data.size);
}
function void
block_fill_ones(void *mem, u64 size){
@ -182,8 +182,8 @@ block_fill_ones(void *mem, u64 size){
}
}
function void
block_fill_ones(Data data){
block_fill_ones(data.data, data.size);
block_fill_ones(String_Const_u8 data){
block_fill_ones(data.str, data.size);
}
function void
block_copy(void *dst, const void *src, u64 size){
@ -2933,11 +2933,6 @@ SCu8(char *str){
return(SCu8((u8*)str));
}
function String_Const_u8
SCu8(Data data){
return(SCu8((u8*)data.data, data.size));
}
function String_Const_u16
SCu16(wchar_t *str, u64 size){
return(SCu16((u16*)str, size));
@ -3043,7 +3038,7 @@ make_base_allocator(Base_Allocator_Reserve_Signature *func_reserve,
};
return(base_allocator);
}
function Data
function String_Const_u8
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);
@ -3058,7 +3053,7 @@ base_free(Base_Allocator *allocator, void *ptr){
}
#define base_allocate(a,s) base_allocate__inner((a), (s), file_name_line_number_lit_u8)
#define base_array_loc(a,T,c,l) (T*)(base_allocate__inner((a), sizeof(T)*(c), (l)).data)
#define base_array_loc(a,T,c,l) (T*)(base_allocate__inner((a), sizeof(T)*(c), (l)).str)
#define base_array(a,T,c) base_array_loc(a,T,c, file_name_line_number_lit_u8)
////////////////////////////////
@ -3069,19 +3064,19 @@ make_cursor(void *base, u64 size){
return(cursor);
}
function Cursor
make_cursor(Data data){
return(make_cursor(data.data, data.size));
make_cursor(String_Const_u8 data){
return(make_cursor(data.str, data.size));
}
function Cursor
make_cursor(Base_Allocator *allocator, u64 size){
Data memory = base_allocate(allocator, size);
String_Const_u8 memory = base_allocate(allocator, size);
return(make_cursor(memory));
}
function Data
function String_Const_u8
linalloc_push(Cursor *cursor, u64 size, String_Const_u8 location){
Data result = {};
String_Const_u8 result = {};
if (cursor->pos + size <= cursor->cap){
result.data = cursor->base + cursor->pos;
result.str = cursor->base + cursor->pos;
result.size = size;
cursor->pos += size;
}
@ -3096,7 +3091,7 @@ linalloc_pop(Cursor *cursor, u64 size){
cursor->pos = 0;
}
}
function Data
function String_Const_u8
linalloc_align(Cursor *cursor, u64 alignment){
u64 pos = round_up_u64(cursor->pos, alignment);
u64 new_size = pos - cursor->pos;
@ -3131,26 +3126,26 @@ make_arena(Base_Allocator *allocator){
function Cursor_Node*
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;
String_Const_u8 memory = base_allocate__inner(arena->base_allocator, min_size + sizeof(Cursor_Node), location);
Cursor_Node *cursor_node = (Cursor_Node*)memory.str;
cursor_node->cursor = make_cursor(cursor_node + 1, memory.size - sizeof(Cursor_Node));
sll_stack_push(arena->cursor_node, cursor_node);
return(cursor_node);
}
function Data
function String_Const_u8
linalloc_push(Arena *arena, u64 size, String_Const_u8 location){
Data result = {};
String_Const_u8 result = {};
if (size > 0){
Cursor_Node *cursor_node = arena->cursor_node;
if (cursor_node == 0){
cursor_node = arena__new_node(arena, size, location);
}
result = linalloc_push(&cursor_node->cursor, size, location);
if (result.data == 0){
if (result.str == 0){
cursor_node = arena__new_node(arena, size, location);
result = linalloc_push(&cursor_node->cursor, size, location);
}
Data alignment_data = linalloc_align(&cursor_node->cursor, arena->alignment);
String_Const_u8 alignment_data = linalloc_align(&cursor_node->cursor, arena->alignment);
result.size += alignment_data.size;
}
return(result);
@ -3174,10 +3169,10 @@ linalloc_pop(Arena *arena, u64 size){
}
arena->cursor_node = cursor_node;
}
function Data
function String_Const_u8
linalloc_align(Arena *arena, u64 alignment){
arena->alignment = alignment;
Data data = {};
String_Const_u8 data = {};
Cursor_Node *cursor_node = arena->cursor_node;
if (cursor_node != 0){
data = linalloc_align(&cursor_node->cursor, arena->alignment);
@ -3218,18 +3213,18 @@ linalloc_clear(Arena *arena){
linalloc_end_temp(temp);
}
function void*
linalloc_wrap_unintialized(Data data){
return(data.data);
linalloc_wrap_unintialized(String_Const_u8 data){
return(data.str);
}
function void*
linalloc_wrap_zero(Data data){
block_zero(data.data, data.size);
return(data.data);
linalloc_wrap_zero(String_Const_u8 data){
block_zero(data.str, data.size);
return(data.str);
}
function void*
linalloc_wrap_write(Data data, u64 size, void *src){
block_copy(data.data, src, clamp_top(data.size, size));
return(data.data);
linalloc_wrap_write(String_Const_u8 data, u64 size, void *src){
block_copy(data.str, src, clamp_top(data.size, size));
return(data.str);
}
#define push_array(a,T,c) ((T*)linalloc_wrap_unintialized(linalloc_push((a), sizeof(T)*(c), file_name_line_number_lit_u8)))
#define push_array_zero(a,T,c) ((T*)linalloc_wrap_zero(linalloc_push((a), sizeof(T)*(c), file_name_line_number_lit_u8)))
@ -3642,25 +3637,25 @@ base_allocator_on_heap(Heap *heap){
////////////////////////////////
function Data
function String_Const_u8
push_data(Arena *arena, u64 size){
Data result = {};
result.data = push_array(arena, u8, size);
String_Const_u8 result = {};
result.str = push_array(arena, u8, size);
result.size = size;
return(result);
}
function Data
push_data_copy(Arena *arena, Data data){
Data result = {};
result.data = push_array_write(arena, u8, data.size, data.data);
function String_Const_u8
push_data_copy(Arena *arena, String_Const_u8 data){
String_Const_u8 result = {};
result.str = push_array_write(arena, u8, data.size, data.str);
result.size = data.size;
return(result);
}
function b32
data_match(Data a, Data b){
return(a.size == b.size && block_match(a.data, b.data, a.size));
data_match(String_Const_u8 a, String_Const_u8 b){
return(a.size == b.size && block_match(a.str, b.str, a.size));
}
////////////////////////////////
@ -7004,8 +6999,8 @@ byte_is_ascii(u8 byte){
}
function b32
data_is_ascii(Data data){
u8 *ptr = (u8*)data.data;
data_is_ascii(String_Const_u8 data){
u8 *ptr = data.str;
u8 *one_past_last = ptr + data.size;
b32 result = true;
for (;ptr < one_past_last; ptr += 1){
@ -7260,9 +7255,9 @@ string_base64_encode_from_binary(Arena *arena, void *data, u64 size){
return(string);
}
function Data
function String_Const_u8
data_decode_from_base64(Arena *arena, u8 *str, u64 size){
Data data = {};
String_Const_u8 data = {};
if (size%4 == 0){
u64 data_size = size*6/8;
if (str[size - 2] == '?'){
@ -7274,7 +7269,7 @@ data_decode_from_base64(Arena *arena, u8 *str, u64 size){
data = push_data(arena, data_size);
u8 *s = str;
u8 *se = s + size;
u8 *d = (u8*)data.data;
u8 *d = data.str;
u8 *de = d + data_size;
for (;s < se; d += 3, s += 4){
u8 *D = d;

View File

@ -901,10 +901,7 @@ struct String_Const_char{
u64 size;
};
struct String_Const_u8{
union{
void *data;
u8 *str;
};
u64 size;
};
struct String_Const_u16{
@ -967,7 +964,8 @@ struct String_Const_Any{
};
};
#define string_litinit(s) {(s), sizeof(s) - 1}
#define str8_lit(s) {(u8*)(s), sizeof(s) - 1}
#define string_litinit(s) {(u8*)(s), sizeof(s) - 1}
#define string_u8_litinit(s) {(u8*)(s), sizeof(s) - 1}
struct Node_String_Const_char{
@ -1096,11 +1094,6 @@ global u32 surrogate_max = 0xDFFF;
global u32 nonchar_min = 0xFDD0;
global u32 nonchar_max = 0xFDEF;
struct Data{
u8 *data;
u64 size;
};
////////////////////////////////
typedef u32 Access_Flag;
@ -1151,136 +1144,136 @@ struct Date_Time{
};
global String_Const_u8 month_full_name[] = {
string_u8_litinit("January"),
string_u8_litinit("February"),
string_u8_litinit("March"),
string_u8_litinit("April"),
string_u8_litinit("May"),
string_u8_litinit("June"),
string_u8_litinit("July"),
string_u8_litinit("August"),
string_u8_litinit("September"),
string_u8_litinit("October"),
string_u8_litinit("November"),
string_u8_litinit("December"),
str8_lit("January"),
str8_lit("February"),
str8_lit("March"),
str8_lit("April"),
str8_lit("May"),
str8_lit("June"),
str8_lit("July"),
str8_lit("August"),
str8_lit("September"),
str8_lit("October"),
str8_lit("November"),
str8_lit("December"),
};
global String_Const_u8 month_abrev_name[] = {
string_u8_litinit("Jan"),
string_u8_litinit("Feb"),
string_u8_litinit("Mar"),
string_u8_litinit("Apr"),
string_u8_litinit("May"),
string_u8_litinit("Jun"),
string_u8_litinit("Jul"),
string_u8_litinit("Aug"),
string_u8_litinit("Sep"),
string_u8_litinit("Oct"),
string_u8_litinit("Nov"),
string_u8_litinit("Dec"),
str8_lit("Jan"),
str8_lit("Feb"),
str8_lit("Mar"),
str8_lit("Apr"),
str8_lit("May"),
str8_lit("Jun"),
str8_lit("Jul"),
str8_lit("Aug"),
str8_lit("Sep"),
str8_lit("Oct"),
str8_lit("Nov"),
str8_lit("Dec"),
};
global String_Const_u8 ordinal_numeric_name[] = {
string_u8_litinit("1st"),
string_u8_litinit("2nd"),
string_u8_litinit("3rd"),
string_u8_litinit("4th"),
string_u8_litinit("5th"),
string_u8_litinit("6th"),
string_u8_litinit("7th"),
string_u8_litinit("8th"),
string_u8_litinit("9th"),
string_u8_litinit("10th"),
string_u8_litinit("11th"),
string_u8_litinit("12th"),
string_u8_litinit("13th"),
string_u8_litinit("14th"),
string_u8_litinit("15th"),
string_u8_litinit("16th"),
string_u8_litinit("17th"),
string_u8_litinit("18th"),
string_u8_litinit("19th"),
string_u8_litinit("20th"),
string_u8_litinit("21st"),
string_u8_litinit("22nd"),
string_u8_litinit("23rd"),
string_u8_litinit("24th"),
string_u8_litinit("25th"),
string_u8_litinit("26th"),
string_u8_litinit("27th"),
string_u8_litinit("28th"),
string_u8_litinit("29th"),
string_u8_litinit("30th"),
string_u8_litinit("31st"),
string_u8_litinit("32nd"),
string_u8_litinit("33rd"),
string_u8_litinit("34th"),
string_u8_litinit("35th"),
string_u8_litinit("36th"),
string_u8_litinit("37th"),
string_u8_litinit("38th"),
string_u8_litinit("39th"),
string_u8_litinit("40th"),
string_u8_litinit("41st"),
string_u8_litinit("42nd"),
string_u8_litinit("43rd"),
string_u8_litinit("44th"),
string_u8_litinit("45th"),
string_u8_litinit("46th"),
string_u8_litinit("47th"),
string_u8_litinit("48th"),
string_u8_litinit("49th"),
string_u8_litinit("50th"),
string_u8_litinit("51st"),
string_u8_litinit("52nd"),
string_u8_litinit("53rd"),
string_u8_litinit("54th"),
string_u8_litinit("55th"),
string_u8_litinit("56th"),
string_u8_litinit("57th"),
string_u8_litinit("58th"),
string_u8_litinit("59th"),
string_u8_litinit("60th"),
string_u8_litinit("61st"),
string_u8_litinit("62nd"),
string_u8_litinit("63rd"),
string_u8_litinit("64th"),
string_u8_litinit("65th"),
string_u8_litinit("66th"),
string_u8_litinit("67th"),
string_u8_litinit("68th"),
string_u8_litinit("69th"),
string_u8_litinit("70th"),
string_u8_litinit("71st"),
string_u8_litinit("72nd"),
string_u8_litinit("73rd"),
string_u8_litinit("74th"),
string_u8_litinit("75th"),
string_u8_litinit("76th"),
string_u8_litinit("77th"),
string_u8_litinit("78th"),
string_u8_litinit("79th"),
string_u8_litinit("80th"),
string_u8_litinit("81st"),
string_u8_litinit("82nd"),
string_u8_litinit("83rd"),
string_u8_litinit("84th"),
string_u8_litinit("85th"),
string_u8_litinit("86th"),
string_u8_litinit("87th"),
string_u8_litinit("88th"),
string_u8_litinit("89th"),
string_u8_litinit("90th"),
string_u8_litinit("91st"),
string_u8_litinit("92nd"),
string_u8_litinit("93rd"),
string_u8_litinit("94th"),
string_u8_litinit("95th"),
string_u8_litinit("96th"),
string_u8_litinit("97th"),
string_u8_litinit("98th"),
string_u8_litinit("99th"),
string_u8_litinit("100th"),
str8_lit("1st"),
str8_lit("2nd"),
str8_lit("3rd"),
str8_lit("4th"),
str8_lit("5th"),
str8_lit("6th"),
str8_lit("7th"),
str8_lit("8th"),
str8_lit("9th"),
str8_lit("10th"),
str8_lit("11th"),
str8_lit("12th"),
str8_lit("13th"),
str8_lit("14th"),
str8_lit("15th"),
str8_lit("16th"),
str8_lit("17th"),
str8_lit("18th"),
str8_lit("19th"),
str8_lit("20th"),
str8_lit("21st"),
str8_lit("22nd"),
str8_lit("23rd"),
str8_lit("24th"),
str8_lit("25th"),
str8_lit("26th"),
str8_lit("27th"),
str8_lit("28th"),
str8_lit("29th"),
str8_lit("30th"),
str8_lit("31st"),
str8_lit("32nd"),
str8_lit("33rd"),
str8_lit("34th"),
str8_lit("35th"),
str8_lit("36th"),
str8_lit("37th"),
str8_lit("38th"),
str8_lit("39th"),
str8_lit("40th"),
str8_lit("41st"),
str8_lit("42nd"),
str8_lit("43rd"),
str8_lit("44th"),
str8_lit("45th"),
str8_lit("46th"),
str8_lit("47th"),
str8_lit("48th"),
str8_lit("49th"),
str8_lit("50th"),
str8_lit("51st"),
str8_lit("52nd"),
str8_lit("53rd"),
str8_lit("54th"),
str8_lit("55th"),
str8_lit("56th"),
str8_lit("57th"),
str8_lit("58th"),
str8_lit("59th"),
str8_lit("60th"),
str8_lit("61st"),
str8_lit("62nd"),
str8_lit("63rd"),
str8_lit("64th"),
str8_lit("65th"),
str8_lit("66th"),
str8_lit("67th"),
str8_lit("68th"),
str8_lit("69th"),
str8_lit("70th"),
str8_lit("71st"),
str8_lit("72nd"),
str8_lit("73rd"),
str8_lit("74th"),
str8_lit("75th"),
str8_lit("76th"),
str8_lit("77th"),
str8_lit("78th"),
str8_lit("79th"),
str8_lit("80th"),
str8_lit("81st"),
str8_lit("82nd"),
str8_lit("83rd"),
str8_lit("84th"),
str8_lit("85th"),
str8_lit("86th"),
str8_lit("87th"),
str8_lit("88th"),
str8_lit("89th"),
str8_lit("90th"),
str8_lit("91st"),
str8_lit("92nd"),
str8_lit("93rd"),
str8_lit("94th"),
str8_lit("95th"),
str8_lit("96th"),
str8_lit("97th"),
str8_lit("98th"),
str8_lit("99th"),
str8_lit("100th"),
};
////////////////////////////////

View File

@ -21,21 +21,21 @@ push_build_directory_at_file(Application_Links *app, Arena *arena, Buffer_ID buf
#if OS_WINDOWS
global String_Const_u8 standard_build_file_name_array[] = {
string_u8_litinit("build.bat"),
str8_lit("build.bat"),
};
global String_Const_u8 standard_build_cmd_string_array[] = {
string_u8_litinit("build"),
str8_lit("build"),
};
#elif OS_LINUX || OS_MAC
global String_Const_u8 standard_build_file_name_array[] = {
string_u8_litinit("build.sh"),
string_u8_litinit("Makefile"),
str8_lit("build.sh"),
str8_lit("Makefile"),
};
global String_Const_u8 standard_build_cmd_string_array[] = {
string_u8_litinit("build.sh"),
string_u8_litinit("make"),
str8_lit("build.sh"),
str8_lit("make"),
};
#else

View File

@ -269,7 +269,7 @@ def_config_parser_top(Config_Parser *ctx){
function i32*
def_config_parser_version(Config_Parser *ctx){
require(def_config_parser_match_text(ctx, string_u8_litinit("version")));
require(def_config_parser_match_text(ctx, str8_lit("version")));
if (!def_config_parser_match_cpp_kind(ctx, TokenCppKind_ParenOp)){
def_config_parser_push_error_here(ctx, "expected token '(' for version specifier: 'version(#)'");
@ -632,10 +632,10 @@ def_var_dump_rvalue(Application_Links *app, Config *config, Variable_Handle dst,
if (boolean != 0){
String_ID val = 0;
if (*boolean){
val = vars_save_string(string_litinit("true"));
val = vars_save_string(str8_lit("true"));
}
else{
val = vars_save_string(string_litinit("false"));
val = vars_save_string(str8_lit("false"));
}
vars_new_variable(dst, l_value, val);
}
@ -745,10 +745,10 @@ global String_ID def_config_lookup_table[def_config_lookup_count] = {};
function void
_def_config_table_init(void){
if (def_config_lookup_table[0] == 0){
def_config_lookup_table[0] = vars_save_string(string_u8_litinit("ses_config"));
def_config_lookup_table[1] = vars_save_string(string_u8_litinit("prj_config"));
def_config_lookup_table[2] = vars_save_string(string_u8_litinit("usr_config"));
def_config_lookup_table[3] = vars_save_string(string_u8_litinit("def_config"));
def_config_lookup_table[0] = vars_save_string(str8_lit("ses_config"));
def_config_lookup_table[1] = vars_save_string(str8_lit("prj_config"));
def_config_lookup_table[2] = vars_save_string(str8_lit("usr_config"));
def_config_lookup_table[3] = vars_save_string(str8_lit("def_config"));
}
}
@ -1354,9 +1354,9 @@ change_mode(Application_Links *app, String_Const_u8 mode){
function Config*
config_parse__file_handle(Application_Links *app, Arena *arena, String_Const_u8 file_name, FILE *file){
Config *parsed = 0;
Data data = dump_file_handle(arena, file);
if (data.data != 0){
parsed = def_config_from_text(app, arena, file_name, SCu8(data));
String_Const_u8 data = dump_file_handle(arena, file);
if (data.str != 0){
parsed = def_config_from_text(app, arena, file_name, data);
}
return(parsed);
}
@ -1366,10 +1366,10 @@ config_parse__file_name(Application_Links *app, Arena *arena, char *file_name){
Config *parsed = 0;
FILE *file = open_file_try_current_path_then_binary_path(app, file_name);
if (file != 0){
Data data = dump_file_handle(arena, file);
String_Const_u8 data = dump_file_handle(arena, file);
fclose(file);
if (data.data != 0){
parsed = def_config_from_text(app, arena, SCu8(file_name), SCu8(data));
if (data.str != 0){
parsed = def_config_from_text(app, arena, SCu8(file_name), data);
}
}
return(parsed);
@ -1435,10 +1435,10 @@ theme_parse__buffer(Application_Links *app, Arena *arena, Buffer_ID buffer, Aren
function Config*
theme_parse__file_handle(Application_Links *app, Arena *arena, String_Const_u8 file_name, FILE *file, Arena *color_arena, Color_Table *color_table){
Data data = dump_file_handle(arena, file);
String_Const_u8 data = dump_file_handle(arena, file);
Config *parsed = 0;
if (data.data != 0){
parsed = theme_parse__data(app, arena, file_name, SCu8(data), color_arena, color_table);
if (data.str != 0){
parsed = theme_parse__data(app, arena, file_name, data, color_arena, color_table);
}
return(parsed);
}
@ -1448,9 +1448,9 @@ theme_parse__file_name(Application_Links *app, Arena *arena, char *file_name, Ar
Config *parsed = 0;
FILE *file = open_file_try_current_path_then_binary_path(app, file_name);
if (file != 0){
Data data = dump_file_handle(arena, file);
String_Const_u8 data = dump_file_handle(arena, file);
fclose(file);
parsed = theme_parse__data(app, arena, SCu8(file_name), SCu8(data), color_arena, color_table);
parsed = theme_parse__data(app, arena, SCu8(file_name), data, color_arena, color_table);
}
if (parsed == 0){
Scratch_Block scratch(app, arena);

View File

@ -733,9 +733,9 @@ do_full_lex_async__inner(Async_Context *actx, Buffer_ID buffer_id){
}
function void
do_full_lex_async(Async_Context *actx, Data data){
do_full_lex_async(Async_Context *actx, String_Const_u8 data){
if (data.size == sizeof(Buffer_ID)){
Buffer_ID buffer = *(Buffer_ID*)data.data;
Buffer_ID buffer = *(Buffer_ID*)data.str;
do_full_lex_async__inner(actx, buffer);
}
}

View File

@ -10,19 +10,19 @@ delta_ctx_size(u64 base_size){
}
function Delta_Context_Header*
delta_ctx_get_header(Data delta_ctx){
return((Delta_Context_Header*)delta_ctx.data);
delta_ctx_get_header(String_Const_u8 delta_ctx){
return((Delta_Context_Header*)delta_ctx.str);
}
function void*
delta_ctx_get_user_data(Data delta_ctx){
Delta_Context_Header *ctx = (Delta_Context_Header*)delta_ctx.data;
delta_ctx_get_user_data(String_Const_u8 delta_ctx){
Delta_Context_Header *ctx = (Delta_Context_Header*)delta_ctx.str;
return(ctx + 1);
}
function Buffer_Point_Delta_Result
delta_apply(Application_Links *app, View_ID view,
Delta_Rule_Function *func, Data delta_ctx,
Delta_Rule_Function *func, String_Const_u8 delta_ctx,
f32 dt, Buffer_Point position, Buffer_Point target){
Buffer_Point_Delta_Result result = {};
Vec2_f32 pending = view_point_difference(app, view, target, position);
@ -54,7 +54,7 @@ delta_apply(Application_Links *app, View_ID view,
function Buffer_Point_Delta_Result
delta_apply(Application_Links *app, View_ID view,
Delta_Rule_Function *func, Data delta_ctx,
Delta_Rule_Function *func, String_Const_u8 delta_ctx,
f32 dt, Buffer_Scroll scroll){
return(delta_apply(app, view, func, delta_ctx,
dt, scroll.position, scroll.target));
@ -64,7 +64,7 @@ function Buffer_Point_Delta_Result
delta_apply(Application_Links *app, View_ID view,
f32 dt, Buffer_Point position, Buffer_Point target){
View_Context ctx = view_current_context(app, view);
Data delta_ctx = view_current_context_hook_memory(app, view, HookID_DeltaRule);
String_Const_u8 delta_ctx = view_current_context_hook_memory(app, view, HookID_DeltaRule);
return(delta_apply(app, view, ctx.delta_rule, delta_ctx,
dt, position, target));
}
@ -73,14 +73,14 @@ function Buffer_Point_Delta_Result
delta_apply(Application_Links *app, View_ID view,
f32 dt, Buffer_Scroll scroll){
View_Context ctx = view_current_context(app, view);
Data delta_ctx = view_current_context_hook_memory(app, view, HookID_DeltaRule);
String_Const_u8 delta_ctx = view_current_context_hook_memory(app, view, HookID_DeltaRule);
return(delta_apply(app, view, ctx.delta_rule, delta_ctx,
dt, scroll.position, scroll.target));
}
function Vec2_f32_Delta_Result
delta_apply(Application_Links *app, View_ID view,
Delta_Rule_Function *func, Data delta_ctx,
Delta_Rule_Function *func, String_Const_u8 delta_ctx,
f32 dt, Vec2_f32 position, Vec2_f32 target){
Vec2_f32_Delta_Result result = {};
Vec2_f32 pending = target - position;
@ -112,7 +112,7 @@ delta_apply(Application_Links *app, View_ID view,
function Vec2_f32_Delta_Result
delta_apply(Application_Links *app, View_ID view,
Delta_Rule_Function *func, Data delta_ctx,
Delta_Rule_Function *func, String_Const_u8 delta_ctx,
f32 dt, Basic_Scroll scroll){
return(delta_apply(app, view, func, delta_ctx,
dt, scroll.position, scroll.target));
@ -122,7 +122,7 @@ function Vec2_f32_Delta_Result
delta_apply(Application_Links *app, View_ID view,
f32 dt, Vec2_f32 position, Vec2_f32 target){
View_Context ctx = view_current_context(app, view);
Data delta_ctx = view_current_context_hook_memory(app, view, HookID_DeltaRule);
String_Const_u8 delta_ctx = view_current_context_hook_memory(app, view, HookID_DeltaRule);
return(delta_apply(app, view, ctx.delta_rule, delta_ctx,
dt, position, target));
}
@ -131,7 +131,7 @@ function Vec2_f32_Delta_Result
delta_apply(Application_Links *app, View_ID view,
f32 dt, Basic_Scroll scroll){
View_Context ctx = view_current_context(app, view);
Data delta_ctx = view_current_context_hook_memory(app, view, HookID_DeltaRule);
String_Const_u8 delta_ctx = view_current_context_hook_memory(app, view, HookID_DeltaRule);
return(delta_apply(app, view, ctx.delta_rule, delta_ctx,
dt, scroll.position, scroll.target));
}

View File

@ -26,8 +26,8 @@ dynamic_binding_load_from_file(Application_Links *app, Mapping *mapping, String_
String_Const_u8 filename_copied = push_string_copy(scratch, filename);
FILE *file = open_file_try_current_path_then_binary_path(app, (char*)filename_copied.str);
if (file != 0){
Data data = dump_file_handle(scratch, file);
Config *parsed = def_config_from_text(app, scratch, filename, SCu8(data));
String_Const_u8 data = dump_file_handle(scratch, file);
Config *parsed = def_config_from_text(app, scratch, filename, data);
fclose(file);
if (parsed != 0){

View File

@ -2011,9 +2011,9 @@ file_exists_and_is_folder(Application_Links *app, String_Const_u8 file_name){
return(attributes.last_write_time > 0 && HasFlag(attributes.flags, FileAttribute_IsDirectory));
}
function Data
function String_Const_u8
dump_file_handle(Arena *arena, FILE *file){
Data result = {};
String_Const_u8 result = {};
if (file != 0){
fseek(file, 0, SEEK_END);
u64 size = ftell(file);

View File

@ -9,7 +9,7 @@
struct File_Name_Data{
String_Const_u8 file_name;
Data data;
String_Const_u8 data;
};
struct View_Context_Block{

View File

@ -13,7 +13,7 @@ internal u64
log_parse__string_code(Log_Parse *parse, String_Const_u8 string, Log_String_Source string_source){
u64 result = 0;
if (string.size > 0){
Data data = make_data(string.str, string.size);
String_Const_u8 data = make_data(string.str, string.size);
Table_Lookup lookup = table_lookup(&parse->string_to_id_table, data);
if (lookup.found_match){
table_read(&parse->string_to_id_table, lookup, &result);
@ -36,9 +36,7 @@ log_parse__get_string(Log_Parse *parse, u64 code){
Table_Lookup lookup = table_lookup(&parse->id_to_string_table, code);
String_Const_u8 result = {};
if (lookup.found_match){
Data val = {};
table_read(&parse->id_to_string_table, lookup, &val);
result = SCu8(val.data, val.size);
table_read(&parse->id_to_string_table, lookup, &result);
}
return(result);
}
@ -121,7 +119,7 @@ internal Log_Event_List*
log_parse__get_or_make_list_tag_value(Log_Parse *parse, Log_Tag *tag){
Log_Event_List *result = 0;
Log_Tag_Name_Value key = {tag->name, tag->value};
Data data_key = make_data_struct(&key);
String_Const_u8 data_key = make_data_struct(&key);
Table_Lookup lookup = table_lookup(&parse->tag_value_to_event_list_table, data_key);
if (lookup.found_match){
u64 val = 0;

View File

@ -742,7 +742,7 @@ profile_render(Application_Links *app, Frame_Info frame_info, View_ID view){
node != 0;
node = next){
next = node->next;
Data key = make_data(node->location.str, node->location.size);
String_Const_u8 key = make_data(node->location.str, node->location.size);
Table_Lookup lookup = table_lookup(&table, key);
Memory_Bucket *bucket = 0;
if (lookup.found_match){

View File

@ -552,26 +552,26 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj
Scratch_Block scratch(app);
String_ID project_id = vars_save_string_lit("prj_config");
String_ID version_id = vars_save_string(string_litinit("version"));
String_ID project_name_id = vars_save_string(string_litinit("project_name"));
String_ID patterns_id = vars_save_string(string_litinit("patterns"));
String_ID blacklist_patterns_id = vars_save_string(string_litinit("blacklist_patterns"));
String_ID version_id = vars_save_string(str8_lit("version"));
String_ID project_name_id = vars_save_string(str8_lit("project_name"));
String_ID patterns_id = vars_save_string(str8_lit("patterns"));
String_ID blacklist_patterns_id = vars_save_string(str8_lit("blacklist_patterns"));
String_ID load_paths_id = vars_save_string(string_litinit("load_paths"));
String_ID path_id = vars_save_string(string_litinit("path"));
String_ID recursive_id = vars_save_string(string_litinit("recursive"));
String_ID relative_id = vars_save_string(string_litinit("relative"));
String_ID true_id = vars_save_string(string_litinit("true"));
String_ID false_id = vars_save_string(string_litinit("false"));
String_ID load_paths_id = vars_save_string(str8_lit("load_paths"));
String_ID path_id = vars_save_string(str8_lit("path"));
String_ID recursive_id = vars_save_string(str8_lit("recursive"));
String_ID relative_id = vars_save_string(str8_lit("relative"));
String_ID true_id = vars_save_string(str8_lit("true"));
String_ID false_id = vars_save_string(str8_lit("false"));
String_ID out_id = vars_save_string(string_litinit("out"));
String_ID footer_panel_id = vars_save_string(string_litinit("footer_panel"));
String_ID save_dirty_files_id = vars_save_string(string_litinit("save_dirty_files"));
String_ID cursor_at_end_id = vars_save_string(string_litinit("cursor_at_end"));
String_ID out_id = vars_save_string(str8_lit("out"));
String_ID footer_panel_id = vars_save_string(str8_lit("footer_panel"));
String_ID save_dirty_files_id = vars_save_string(str8_lit("save_dirty_files"));
String_ID cursor_at_end_id = vars_save_string(str8_lit("cursor_at_end"));
String_ID fkey_command_id = vars_save_string(string_litinit("fkey_command"));
String_ID fkey_command_id = vars_save_string(str8_lit("fkey_command"));
String_ID os_id = vars_save_string(string_litinit(OS_NAME));;
String_ID os_id = vars_save_string(str8_lit(OS_NAME));;
Variable_Handle proj_var = vars_new_variable(vars_get_root(), project_id, vars_save_string(parsed->file_name));
@ -797,12 +797,12 @@ CUSTOM_DOC("Looks for a project.4coder file in the current directory and tries t
}
else{
File_Name_Data dump = dump_file_search_up_path(app, scratch, project_path, string_u8_litexpr("project.4coder"));
if (dump.data.data != 0){
if (dump.data.str != 0){
String_Const_u8 project_root = string_remove_last_folder(dump.file_name);
Token_Array array = token_array_from_text(app, scratch, SCu8(dump.data));
Token_Array array = token_array_from_text(app, scratch, dump.data);
if (array.tokens != 0){
project_parse.parsed = def_config_parse(app, scratch, dump.file_name, SCu8(dump.data), array);
project_parse.parsed = def_config_parse(app, scratch, dump.file_name, dump.data, array);
if (project_parse.parsed != 0){
i32 version = 0;
if (project_parse.parsed->version != 0){

View File

@ -294,12 +294,11 @@ word_complete_list_extend_from_raw(Application_Links *app, Arena *arena, String_
node != 0;
node = node->next){
String_Const_u8 s = push_buffer_range(app, scratch, node->buffer, node->range);
Data data = make_data(s.str, s.size);
Table_Lookup lookup = table_lookup(used_table, data);
Table_Lookup lookup = table_lookup(used_table, s);
if (!lookup.found_match){
data = push_data_copy(arena, data);
String_Const_u8 data = push_data_copy(arena, s);
table_insert(used_table, data, 1);
string_list_push(arena, list, SCu8(data.data, data.size));
string_list_push(arena, list, data);
}
}
}

View File

@ -5,8 +5,8 @@
// TOP
internal u64
table_hash(Data key){
return(table_hash_u8((u8*)key.data, key.size) | bit_64);
table_hash(String_Const_u8 key){
return(table_hash_u8((u8*)key.str, key.size) | bit_64);
}
global_const u64 table_empty_slot = 0;
@ -25,9 +25,9 @@ make_table_u64_u64__inner(Base_Allocator *allocator, u32 slot_count, String_Cons
Table_u64_u64 table = {};
table.allocator = allocator;
slot_count = clamp_bot(8, slot_count);
Data mem = base_allocate__inner(allocator, slot_count*(sizeof(*table.keys) + sizeof(*table.vals)), location);
block_zero(mem.data, mem.size);
table.memory = mem.data;
String_Const_u8 mem = base_allocate__inner(allocator, slot_count*(sizeof(*table.keys) + sizeof(*table.vals)), location);
block_zero(mem.str, mem.size);
table.memory = mem.str;
table.keys = (u64*)table.memory;
table.vals = (u64*)(table.keys + slot_count);
table.slot_count = slot_count;
@ -192,9 +192,9 @@ make_table_u32_u16__inner(Base_Allocator *allocator, u32 slot_count, String_Cons
Table_u32_u16 table = {};
table.allocator = allocator;
slot_count = clamp_bot(8, slot_count);
Data mem = base_allocate__inner(allocator, slot_count*(sizeof(*table.keys) + sizeof(*table.vals)), location);
block_zero(mem.data, mem.size);
table.memory = mem.data;
String_Const_u8 mem = base_allocate__inner(allocator, slot_count*(sizeof(*table.keys) + sizeof(*table.vals)), location);
block_zero(mem.str, mem.size);
table.memory = mem.str;
table.keys = (u32*)table.memory;
table.vals = (u16*)(table.keys + slot_count);
table.slot_count = slot_count;
@ -355,11 +355,11 @@ make_table_Data_u64__inner(Base_Allocator *allocator, u32 slot_count, String_Con
Table_Data_u64 table = {};
table.allocator = allocator;
slot_count = clamp_bot(8, slot_count);
Data mem = base_allocate__inner(allocator, slot_count*(sizeof(*table.hashes) + sizeof(*table.keys) + sizeof(*table.vals)), location);
block_zero(mem.data, mem.size);
table.memory = mem.data;
String_Const_u8 mem = base_allocate__inner(allocator, slot_count*(sizeof(*table.hashes) + sizeof(*table.keys) + sizeof(*table.vals)), location);
block_zero(mem.str, mem.size);
table.memory = mem.str;
table.hashes = (u64*)table.memory;
table.keys = (Data*)(table.hashes + slot_count);
table.keys = (String_Const_u8*)(table.hashes + slot_count);
table.vals = (u64*)(table.keys + slot_count);
table.slot_count = slot_count;
table.used_count = 0;
@ -376,7 +376,7 @@ table_free(Table_Data_u64 *table){
}
internal Table_Lookup
table_lookup(Table_Data_u64 *table, Data key){
table_lookup(Table_Data_u64 *table, String_Const_u8 key){
Table_Lookup result = {};
if (table->slot_count > 0){
@ -434,7 +434,7 @@ table_read(Table_Data_u64 *table, Table_Lookup lookup, u64 *val_out){
}
internal b32
table_read_key(Table_Data_u64 *table, Table_Lookup lookup, Data *key_out){
table_read_key(Table_Data_u64 *table, Table_Lookup lookup, String_Const_u8 *key_out){
b32 result = false;
if (lookup.found_match){
*key_out = table->keys[lookup.index];
@ -444,13 +444,13 @@ table_read_key(Table_Data_u64 *table, Table_Lookup lookup, Data *key_out){
}
internal b32
table_read(Table_Data_u64 *table, Data key, u64 *val_out){
table_read(Table_Data_u64 *table, String_Const_u8 key, u64 *val_out){
Table_Lookup lookup = table_lookup(table, key);
return(table_read(table, lookup, val_out));
}
internal void
table_insert__inner(Table_Data_u64 *table, Table_Lookup lookup, Data key, u64 val){
table_insert__inner(Table_Data_u64 *table, Table_Lookup lookup, String_Const_u8 key, u64 val){
Assert(lookup.found_empty_slot || lookup.found_erased_slot);
table->hashes[lookup.index] = lookup.hash;
table->keys[lookup.index] = key;
@ -469,7 +469,7 @@ table_rehash(Table_Data_u64 *dst, Table_Data_u64 *src){
u64 *src_hashes = src->hashes;
for (u32 i = 0; i < src_slot_count; i += 1){
if (HasFlag(src_hashes[i], bit_64)){
Data key = src->keys[i];
String_Const_u8 key = src->keys[i];
Table_Lookup lookup = table_lookup(dst, key);
table_insert__inner(dst, lookup, key, src->vals[i]);
}
@ -480,9 +480,9 @@ table_rehash(Table_Data_u64 *dst, Table_Data_u64 *src){
}
internal b32
table_insert(Table_Data_u64 *table, Data key, u64 val){
table_insert(Table_Data_u64 *table, String_Const_u8 key, u64 val){
b32 result = false;
if (key.data != 0){
if (key.str != 0){
Table_Lookup lookup = table_lookup(table, key);
if (!lookup.found_match){
if ((table->dirty_count + 1)*8 >= table->slot_count*7){
@ -505,7 +505,7 @@ table_insert(Table_Data_u64 *table, Data key, u64 val){
}
internal b32
table_erase(Table_Data_u64 *table, Data key){
table_erase(Table_Data_u64 *table, String_Const_u8 key){
b32 result = false;
Table_Lookup lookup = table_lookup(table, key);
if (lookup.found_match){
@ -534,11 +534,11 @@ make_table_u64_Data__inner(Base_Allocator *allocator, u32 slot_count, String_Con
Table_u64_Data table = {};
table.allocator = allocator;
slot_count = clamp_bot(8, slot_count);
Data mem = base_allocate__inner(allocator, slot_count*(sizeof(*table.keys) + sizeof(*table.vals)), location);
block_zero(mem.data, mem.size);
table.memory = mem.data;
String_Const_u8 mem = base_allocate__inner(allocator, slot_count*(sizeof(*table.keys) + sizeof(*table.vals)), location);
block_zero(mem.str, mem.size);
table.memory = mem.str;
table.keys = (u64*)table.memory;
table.vals = (Data*)(table.keys + slot_count);
table.vals = (String_Const_u8*)(table.keys + slot_count);
table.slot_count = slot_count;
table.used_count = 0;
table.dirty_count = 0;
@ -600,7 +600,7 @@ table_lookup(Table_u64_Data *table, u64 key){
}
internal b32
table_read(Table_u64_Data *table, Table_Lookup lookup, Data *val_out){
table_read(Table_u64_Data *table, Table_Lookup lookup, String_Const_u8 *val_out){
b32 result = false;
if (lookup.found_match){
*val_out = table->vals[lookup.index];
@ -610,13 +610,13 @@ table_read(Table_u64_Data *table, Table_Lookup lookup, Data *val_out){
}
internal b32
table_read(Table_u64_Data *table, u64 key, Data *val_out){
table_read(Table_u64_Data *table, u64 key, String_Const_u8 *val_out){
Table_Lookup lookup = table_lookup(table, key);
return(table_read(table, lookup, val_out));
}
internal void
table_insert__inner(Table_u64_Data *table, Table_Lookup lookup, Data val){
table_insert__inner(Table_u64_Data *table, Table_Lookup lookup, String_Const_u8 val){
Assert(lookup.found_empty_slot || lookup.found_erased_slot);
table->keys[lookup.index] = lookup.hash;
table->vals[lookup.index] = val;
@ -646,7 +646,7 @@ table_rehash(Table_u64_Data *dst, Table_u64_Data *src){
}
internal b32
table_insert(Table_u64_Data *table, u64 key, Data val){
table_insert(Table_u64_Data *table, u64 key, String_Const_u8 val){
b32 result = false;
if (key != table_empty_key && table_erased_key){
Table_Lookup lookup = table_lookup(table, key);
@ -703,12 +703,12 @@ make_table_Data_Data__inner(Base_Allocator *allocator, u32 slot_count, String_Co
Table_Data_Data table = {};
table.allocator = allocator;
slot_count = clamp_bot(8, slot_count);
Data mem = base_allocate__inner(allocator, slot_count*(sizeof(*table.hashes) + sizeof(*table.keys) + sizeof(*table.vals)), location);
block_zero(mem.data, mem.size);
table.memory = mem.data;
String_Const_u8 mem = base_allocate__inner(allocator, slot_count*(sizeof(*table.hashes) + sizeof(*table.keys) + sizeof(*table.vals)), location);
block_zero(mem.str, mem.size);
table.memory = mem.str;
table.hashes = (u64*)table.memory;
table.keys = (Data*)(table.hashes + slot_count);
table.vals = (Data*)(table.keys + slot_count);
table.keys = (String_Const_u8*)(table.hashes + slot_count);
table.vals = (String_Const_u8*)(table.keys + slot_count);
table.slot_count = slot_count;
table.used_count = 0;
table.dirty_count = 0;
@ -724,7 +724,7 @@ table_free(Table_Data_Data *table){
}
internal Table_Lookup
table_lookup(Table_Data_Data *table, Data key){
table_lookup(Table_Data_Data *table, String_Const_u8 key){
Table_Lookup result = {};
if (table->slot_count > 0){
@ -770,7 +770,7 @@ table_lookup(Table_Data_Data *table, Data key){
}
internal b32
table_read(Table_Data_Data *table, Table_Lookup lookup, Data *val_out){
table_read(Table_Data_Data *table, Table_Lookup lookup, String_Const_u8 *val_out){
b32 result = false;
if (lookup.found_match){
*val_out = table->vals[lookup.index];
@ -780,7 +780,7 @@ table_read(Table_Data_Data *table, Table_Lookup lookup, Data *val_out){
}
internal b32
table_read_key(Table_Data_Data *table, Table_Lookup lookup, Data *key_out){
table_read_key(Table_Data_Data *table, Table_Lookup lookup, String_Const_u8 *key_out){
b32 result = false;
if (lookup.found_match){
*key_out = table->keys[lookup.index];
@ -790,13 +790,13 @@ table_read_key(Table_Data_Data *table, Table_Lookup lookup, Data *key_out){
}
internal b32
table_read(Table_Data_Data *table, Data key, Data *val_out){
table_read(Table_Data_Data *table, String_Const_u8 key, String_Const_u8 *val_out){
Table_Lookup lookup = table_lookup(table, key);
return(table_read(table, lookup, val_out));
}
internal void
table_insert__inner(Table_Data_Data *table, Table_Lookup lookup, Data key, Data val){
table_insert__inner(Table_Data_Data *table, Table_Lookup lookup, String_Const_u8 key, String_Const_u8 val){
Assert(lookup.found_empty_slot || lookup.found_erased_slot);
table->hashes[lookup.index] = lookup.hash;
table->keys[lookup.index] = key;
@ -815,7 +815,7 @@ table_rehash(Table_Data_Data *dst, Table_Data_Data *src){
u64 *src_hashes = src->hashes;
for (u32 i = 0; i < src_slot_count; i += 1){
if (HasFlag(src_hashes[i], bit_64)){
Data key = src->keys[i];
String_Const_u8 key = src->keys[i];
Table_Lookup lookup = table_lookup(dst, key);
table_insert__inner(dst, lookup, key, src->vals[i]);
}
@ -826,9 +826,9 @@ table_rehash(Table_Data_Data *dst, Table_Data_Data *src){
}
internal b32
table_insert(Table_Data_Data *table, Data key, Data val){
table_insert(Table_Data_Data *table, String_Const_u8 key, String_Const_u8 val){
b32 result = false;
if (key.data != 0){
if (key.str != 0){
Table_Lookup lookup = table_lookup(table, key);
if (!lookup.found_match){
if ((table->dirty_count + 1)*8 >= table->slot_count*7){
@ -851,7 +851,7 @@ table_insert(Table_Data_Data *table, Data key, Data val){
}
internal b32
table_erase(Table_Data_Data *table, Data key){
table_erase(Table_Data_Data *table, String_Const_u8 key){
b32 result = false;
Table_Lookup lookup = table_lookup(table, key);
if (lookup.found_match){

View File

@ -39,7 +39,7 @@ struct Table_Data_u64{
Base_Allocator *allocator;
void *memory;
u64 *hashes;
Data *keys;
String_Const_u8 *keys;
u64 *vals;
u32 slot_count;
u32 used_count;
@ -50,7 +50,7 @@ struct Table_u64_Data{
Base_Allocator *allocator;
void *memory;
u64 *keys;
Data *vals;
String_Const_u8 *vals;
u32 slot_count;
u32 used_count;
u32 dirty_count;
@ -60,8 +60,8 @@ struct Table_Data_Data{
Base_Allocator *allocator;
void *memory;
u64 *hashes;
Data *keys;
Data *vals;
String_Const_u8 *keys;
String_Const_u8 *vals;
u32 slot_count;
u32 used_count;
u32 dirty_count;

View File

@ -29,7 +29,7 @@ vars_save_string(String_Const_u8 string){
_vars_init();
String_ID result = 0;
Data string_data = make_data(string.str, string.size);
String_Const_u8 string_data = make_data(string.str, string.size);
Table_Lookup location = table_lookup(&vars_string_to_id, string_data);
if (location.found_match){
table_read(&vars_string_to_id, location, &result);
@ -51,10 +51,10 @@ vars_read_string(Arena *arena, String_ID id){
String_Const_u8 result = {};
Table_Lookup location = table_lookup(&vars_id_to_string, id);
if (location.found_match){
Data data = {};
String_Const_u8 data = {};
table_read(&vars_id_to_string, location, &data);
result.str = push_array(arena, u8 , data.size);
block_copy(result.str, data.data, data.size);
block_copy(result.str, data.str, data.size);
result.size = data.size;
}
return(result);
@ -158,7 +158,7 @@ vars_u64_from_var(Application_Links *app, Variable_Handle var){
String_ID val = vars_string_id_from_var(var);
String_Const_u8 string = vars_read_string(scratch, val);
u64 result = 0;
if (string_match(string_prefix(string, 2), string_u8_litinit("0x"))){
if (string_match(string_prefix(string, 2), str8_lit("0x"))){
String_Const_u8 string_hex = string_skip(string, 2);
if (string_is_integer(string_hex, 0x10)){
result = string_to_integer(string_hex, 0x10);

View File

@ -483,7 +483,7 @@ static Command_Metadata fcoder_metacmd_table[250] = {
{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1297 },
{ PROC_LINKS(show_filebar, 0), false, "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 697 },
{ PROC_LINKS(show_scrollbar, 0), false, "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 683 },
{ PROC_LINKS(show_the_log_graph, 0), true, "show_the_log_graph", 18, "Parses *log* and displays the 'log graph' UI", 44, "W:\\4ed\\code\\custom\\4coder_log_parser.cpp", 40, 993 },
{ PROC_LINKS(show_the_log_graph, 0), true, "show_the_log_graph", 18, "Parses *log* and displays the 'log graph' UI", 44, "W:\\4ed\\code\\custom\\4coder_log_parser.cpp", 40, 991 },
{ PROC_LINKS(snipe_backward_whitespace_or_token_boundary, 0), false, "snipe_backward_whitespace_or_token_boundary", 43, "Delete a single, whole token on or to the left of the cursor and post it to the clipboard.", 90, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 177 },
{ PROC_LINKS(snipe_forward_whitespace_or_token_boundary, 0), false, "snipe_forward_whitespace_or_token_boundary", 42, "Delete a single, whole token on or to the right of the cursor and post it to the clipboard.", 91, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 185 },
{ PROC_LINKS(snippet_lister, 0), true, "snippet_lister", 14, "Opens a snippet lister for inserting whole pre-written snippets of text.", 72, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 237 },
@ -511,8 +511,8 @@ static Command_Metadata fcoder_metacmd_table[250] = {
{ PROC_LINKS(undo_all_buffers, 0), false, "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1912 },
{ PROC_LINKS(view_buffer_other_panel, 0), false, "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1672 },
{ PROC_LINKS(view_jump_list_with_lister, 0), false, "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "W:\\4ed\\code\\custom\\4coder_jump_lister.cpp", 41, 59 },
{ PROC_LINKS(word_complete, 0), false, "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 434 },
{ PROC_LINKS(word_complete_drop_down, 0), false, "word_complete_drop_down", 23, "Word complete with drop down menu.", 34, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 680 },
{ PROC_LINKS(word_complete, 0), false, "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 433 },
{ PROC_LINKS(word_complete_drop_down, 0), false, "word_complete_drop_down", 23, "Word complete with drop down menu.", 34, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 679 },
{ PROC_LINKS(write_block, 0), false, "write_block", 11, "At the cursor, insert a block comment.", 38, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 94 },
{ PROC_LINKS(write_hack, 0), false, "write_hack", 10, "At the cursor, insert a '// HACK' comment, includes user name if it was specified in config.4coder.", 99, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 82 },
{ PROC_LINKS(write_note, 0), false, "write_note", 10, "At the cursor, insert a '// NOTE' comment, includes user name if it was specified in config.4coder.", 99, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 88 },

View File

@ -93,7 +93,7 @@
#define custom_view_pop_context_sig() b32 custom_view_pop_context(Application_Links* app, View_ID view_id)
#define custom_view_alter_context_sig() b32 custom_view_alter_context(Application_Links* app, View_ID view_id, View_Context* ctx)
#define custom_view_current_context_sig() View_Context custom_view_current_context(Application_Links* app, View_ID view_id)
#define custom_view_current_context_hook_memory_sig() Data custom_view_current_context_hook_memory(Application_Links* app, View_ID view_id, Hook_ID hook_id)
#define custom_view_current_context_hook_memory_sig() String_Const_u8 custom_view_current_context_hook_memory(Application_Links* app, View_ID view_id, Hook_ID hook_id)
#define custom_create_user_managed_scope_sig() Managed_Scope custom_create_user_managed_scope(Application_Links* app)
#define custom_destroy_user_managed_scope_sig() b32 custom_destroy_user_managed_scope(Application_Links* app, Managed_Scope scope)
#define custom_get_global_managed_scope_sig() Managed_Scope custom_get_global_managed_scope(Application_Links* app)
@ -272,7 +272,7 @@ typedef b32 custom_view_push_context_type(Application_Links* app, View_ID view_i
typedef b32 custom_view_pop_context_type(Application_Links* app, View_ID view_id);
typedef b32 custom_view_alter_context_type(Application_Links* app, View_ID view_id, View_Context* ctx);
typedef View_Context custom_view_current_context_type(Application_Links* app, View_ID view_id);
typedef Data custom_view_current_context_hook_memory_type(Application_Links* app, View_ID view_id, Hook_ID hook_id);
typedef String_Const_u8 custom_view_current_context_hook_memory_type(Application_Links* app, View_ID view_id, Hook_ID hook_id);
typedef Managed_Scope custom_create_user_managed_scope_type(Application_Links* app);
typedef b32 custom_destroy_user_managed_scope_type(Application_Links* app, Managed_Scope scope);
typedef Managed_Scope custom_get_global_managed_scope_type(Application_Links* app);
@ -633,7 +633,7 @@ internal b32 view_push_context(Application_Links* app, View_ID view_id, View_Con
internal b32 view_pop_context(Application_Links* app, View_ID view_id);
internal b32 view_alter_context(Application_Links* app, View_ID view_id, View_Context* ctx);
internal View_Context view_current_context(Application_Links* app, View_ID view_id);
internal Data view_current_context_hook_memory(Application_Links* app, View_ID view_id, Hook_ID hook_id);
internal String_Const_u8 view_current_context_hook_memory(Application_Links* app, View_ID view_id, Hook_ID hook_id);
internal Managed_Scope create_user_managed_scope(Application_Links* app);
internal b32 destroy_user_managed_scope(Application_Links* app, Managed_Scope scope);
internal Managed_Scope get_global_managed_scope(Application_Links* app);

View File

@ -575,7 +575,7 @@ api_param(arena, call, "Application_Links*", "app");
api_param(arena, call, "View_ID", "view_id");
}
{
API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("view_current_context_hook_memory"), string_u8_litexpr("Data"), string_u8_litexpr(""));
API_Call *call = api_call_with_location(arena, result, string_u8_litexpr("view_current_context_hook_memory"), string_u8_litexpr("String_Const_u8"), string_u8_litexpr(""));
api_param(arena, call, "Application_Links*", "app");
api_param(arena, call, "View_ID", "view_id");
api_param(arena, call, "Hook_ID", "hook_id");

View File

@ -93,7 +93,7 @@ api(custom) function b32 view_push_context(Application_Links* app, View_ID view_
api(custom) function b32 view_pop_context(Application_Links* app, View_ID view_id);
api(custom) function b32 view_alter_context(Application_Links* app, View_ID view_id, View_Context* ctx);
api(custom) function View_Context view_current_context(Application_Links* app, View_ID view_id);
api(custom) function Data view_current_context_hook_memory(Application_Links* app, View_ID view_id, Hook_ID hook_id);
api(custom) function String_Const_u8 view_current_context_hook_memory(Application_Links* app, View_ID view_id, Hook_ID hook_id);
api(custom) function Managed_Scope create_user_managed_scope(Application_Links* app);
api(custom) function b32 destroy_user_managed_scope(Application_Links* app, Managed_Scope scope);
api(custom) function Managed_Scope get_global_managed_scope(Application_Links* app);

View File

@ -1274,7 +1274,7 @@ sm_op(char *lexeme){
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);
Data name_data = {};
String_Const_u8 name_data = {};
table_read(&helper_ctx.char_to_name, lookup, &name_data);
string_list_push(helper_ctx.arena, &name_list, SCu8(name_data.data, name_data.size));
}