From ec27163c48709321be2e4a96838662de052feebd Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sun, 28 Aug 2016 21:03:26 -0400 Subject: [PATCH] removed all occurances of int --- 4coder_API.html | 6 +- 4coder_buffer_types.h | 10 +- 4coder_custom.h | 44 +-- 4coder_custom_api.h | 8 +- 4coder_default_bindings.cpp | 23 +- 4coder_default_building.cpp | 2 +- 4coder_default_include.cpp | 497 +++++++++++++------------- 4coder_gui.h | 4 +- 4coder_helper.h | 117 +++--- 4coder_jump_parsing.cpp | 108 +++--- 4coder_keycodes.h | 2 +- 4coder_mem.h | 14 +- 4coder_rect.h | 22 +- 4coder_search.cpp | 118 +++--- 4coder_string.h | 8 +- 4coder_types.h | 26 +- 4cpp_lexer.h | 164 ++++----- 4cpp_lexer_fsms.h | 50 +-- 4cpp_lexer_tables.c | 84 ++--- 4cpp_lexer_types.h | 32 +- 4ed.cpp | 42 +-- 4ed.h | 2 +- 4ed_api_implementation.cpp | 10 +- 4ed_app_target.cpp | 15 +- 4ed_doubly_linked_list.cpp | 22 ++ 4ed_file_view.cpp | 4 +- 4ed_gui.cpp | 2 +- 4ed_layout.cpp | 6 - 4ed_math.cpp => 4ed_math.h | 0 4ed_metagen.cpp | 468 ++++++++++++------------ 4ed_rendering.cpp | 34 +- 4ed_system.h | 4 +- 4ed_template.cpp | 54 --- build.c | 16 +- fsm_table_generator.cpp | 405 ++++++++++----------- internal_4coder_string.cpp | 10 +- internal_4coder_tests.cpp | 4 +- not_shipping_4coder_default_view.cpp | 10 +- readme_generator.c | 7 +- dll_reader.cpp => test/dll_reader.cpp | 34 +- win32_4ed.cpp | 75 +--- win32_api_impl.cpp | 4 +- 42 files changed, 1205 insertions(+), 1362 deletions(-) create mode 100644 4ed_doubly_linked_list.cpp rename 4ed_math.cpp => 4ed_math.h (100%) delete mode 100644 4ed_template.cpp rename dll_reader.cpp => test/dll_reader.cpp (93%) diff --git a/4coder_API.html b/4coder_API.html index 6f2b4afb..63f3c983 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -991,7 +991,7 @@ when it is no longer in use.

§3.3.54: file_exists

bool32 app->file_exists( -
Application_Links *app,
char *filename,
int len
) +
Application_Links *app,
char *filename,
int32_t len
)
Parameters
filename
@@ -1005,7 +1005,7 @@ when it is no longer in use.

§3.3.55: directory_cd

bool32 app->directory_cd( -
Application_Links *app,
char *dir,
int *len,
int capacity,
char *rel_path,
int rel_len
) +
Application_Links *app,
char *dir,
int32_t *len,
int32_t capacity,
char *rel_path,
int32_t rel_len
)
Parameters
dir
@@ -1290,7 +1290,7 @@ an empty String with the correct size and memory size to operate on the array.

§4.3.16: expand_str

#define expand_str(s)
-
Description
This macro is a helper for any calls that take a char*,int pair to specify a +
Description
This macro is a helper for any calls that take a char*,integer pair to specify a string. This macro expands to both of those parameters from one String struct.

§4.3.17: str_size

diff --git a/4coder_buffer_types.h b/4coder_buffer_types.h index 77eed529..2f010e6d 100644 --- a/4coder_buffer_types.h +++ b/4coder_buffer_types.h @@ -13,7 +13,7 @@ #define FRED_BUFFER_TYPES_H static Buffer_Seek -seek_pos(int pos){ +seek_pos(int32_t pos){ Buffer_Seek result; result.type = buffer_seek_pos; result.pos = pos; @@ -21,7 +21,7 @@ seek_pos(int pos){ } static Buffer_Seek -seek_wrapped_xy(float x, float y, int round_down){ +seek_wrapped_xy(float x, float y, int32_t round_down){ Buffer_Seek result; result.type = buffer_seek_wrapped_xy; result.x = x; @@ -31,7 +31,7 @@ seek_wrapped_xy(float x, float y, int round_down){ } static Buffer_Seek -seek_unwrapped_xy(float x, float y, int round_down){ +seek_unwrapped_xy(float x, float y, int32_t round_down){ Buffer_Seek result; result.type = buffer_seek_unwrapped_xy; result.x = x; @@ -41,7 +41,7 @@ seek_unwrapped_xy(float x, float y, int round_down){ } static Buffer_Seek -seek_xy(float x, float y, int round_down, int unwrapped){ +seek_xy(float x, float y, int32_t round_down, int32_t unwrapped){ Buffer_Seek result; result.type = unwrapped?buffer_seek_unwrapped_xy:buffer_seek_wrapped_xy; result.x = x; @@ -51,7 +51,7 @@ seek_xy(float x, float y, int round_down, int unwrapped){ } static Buffer_Seek -seek_line_char(int line, int character){ +seek_line_char(int32_t line, int32_t character){ Buffer_Seek result; result.type = buffer_seek_line_char; result.line = line; diff --git a/4coder_custom.h b/4coder_custom.h index 2c24c1cb..222202cf 100644 --- a/4coder_custom.h +++ b/4coder_custom.h @@ -14,13 +14,13 @@ #define FSTRING_STRUCT typedef struct String{ char *str; - int size; - int memory_size; + int32_t size; + int32_t memory_size; } String; typedef struct Offset_String{ - int offset; - int size; + int32_t offset; + int32_t size; } Offset_String; #endif @@ -52,7 +52,7 @@ typedef CUSTOM_COMMAND_SIG(Custom_Command_Function); #include "4coder_buffer_types.h" #include "4coder_gui.h" -#define COMMAND_CALLER_HOOK(name) int name(struct Application_Links *app, Generic_Command cmd) +#define COMMAND_CALLER_HOOK(name) int32_t name(struct Application_Links *app, Generic_Command cmd) typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function); inline Key_Event_Data @@ -66,7 +66,7 @@ mouse_state_zero(){ return(data); } inline Range -make_range(int p1, int p2){ +make_range(int32_t p1, int32_t p2){ Range range; if (p1 < p2){ range.min = p1; @@ -89,11 +89,11 @@ view_summary_zero(){ return(summary); } -#define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int view_id) -#define GET_BINDING_DATA(name) int name(void *data, int size) -#define HOOK_SIG(name) int name(struct Application_Links *app) -#define OPEN_FILE_HOOK_SIG(name) int name(struct Application_Links *app, int buffer_id) -#define SCROLL_RULE_SIG(name) int name(float target_x, float target_y, float *scroll_x, float *scroll_y, int view_id, int is_new_target, float dt) +#define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int32_t view_id) +#define GET_BINDING_DATA(name) int32_t name(void *data, int32_t size) +#define HOOK_SIG(name) int32_t name(struct Application_Links *app) +#define OPEN_FILE_HOOK_SIG(name) int32_t name(struct Application_Links *app, int32_t buffer_id) +#define SCROLL_RULE_SIG(name) int32_t name(float target_x, float target_y, float *scroll_x, float *scroll_y, int32_t view_id, int32_t is_new_target, float dt) #define INPUT_FILTER_SIG(name) void name(Mouse_State *mouse) typedef VIEW_ROUTINE_SIG(View_Routine_Function); @@ -113,11 +113,11 @@ struct Application_Links; -#define _GET_VERSION_SIG(n) int n(int maj, int min, int patch) +#define _GET_VERSION_SIG(n) int32_t n(int32_t maj, int32_t min, int32_t patch) typedef _GET_VERSION_SIG(_Get_Version_Function); extern "C" _GET_VERSION_SIG(get_alpha_4coder_version){ - int result = (maj == MAJOR && min == MINOR && patch == PATCH); + int32_t result = (maj == MAJOR && min == MINOR && patch == PATCH); return(result); } @@ -151,22 +151,22 @@ enum Map_ID{ struct Binding_Unit{ Binding_Unit_Type type; union{ - struct{ int total_size; int user_map_count; int error; } header; + struct{ int32_t total_size; int32_t user_map_count; int32_t error; } header; - struct{ int mapid; int replace; int bind_count; } map_begin; - struct{ int mapid; } map_inherit; + struct{ int32_t mapid; int32_t replace; int32_t bind_count; } map_begin; + struct{ int32_t mapid; } map_inherit; struct{ - short code; - unsigned char modifiers; - int command_id; + int16_t code; + uint8_t modifiers; + int32_t command_id; } binding; struct{ - short code; - unsigned char modifiers; + int16_t code; + uint8_t modifiers; Custom_Command_Function *func; } callback; struct{ - int hook_id; + int32_t hook_id; void *func; } hook; }; diff --git a/4coder_custom_api.h b/4coder_custom_api.h index bb6da8ff..6ed7e63d 100644 --- a/4coder_custom_api.h +++ b/4coder_custom_api.h @@ -51,8 +51,8 @@ #define MEMORY_ALLOCATE_SIG(n) void* n(Application_Links *app, int32_t size) #define MEMORY_SET_PROTECTION_SIG(n) bool32 n(Application_Links *app, void *ptr, int32_t size, Memory_Protect_Flags flags) #define MEMORY_FREE_SIG(n) void n(Application_Links *app, void *mem, int32_t size) -#define FILE_EXISTS_SIG(n) bool32 n(Application_Links *app, char *filename, int len) -#define DIRECTORY_CD_SIG(n) bool32 n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len) +#define FILE_EXISTS_SIG(n) bool32 n(Application_Links *app, char *filename, int32_t len) +#define DIRECTORY_CD_SIG(n) bool32 n(Application_Links *app, char *dir, int32_t *len, int32_t capacity, char *rel_path, int32_t rel_len) #define GET_4ED_PATH_SIG(n) bool32 n(Application_Links *app, char *out, int32_t capacity) #define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show) extern "C"{ @@ -116,7 +116,7 @@ extern "C"{ } struct Application_Links{ void *memory; - int memory_size; + int32_t memory_size; Exec_Command_Function *exec_command; Exec_System_Command_Function *exec_system_command; Clipboard_Post_Function *clipboard_post; @@ -177,7 +177,7 @@ struct Application_Links{ void *cmd_context; void *system_links; void *current_coroutine; - int type_coroutine; + int32_t type_coroutine; }; #define FillAppLinksAPI(app_links) do{\ app_links->exec_command = Exec_Command;\ diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index e215a8de..663f5e2c 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -44,9 +44,9 @@ CUSTOM_COMMAND_SIG(write_capital){ CUSTOM_COMMAND_SIG(switch_to_compilation){ char name[] = "*compilation*"; - int name_size = sizeof(name)-1; + int32_t name_size = sizeof(name)-1; - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer_by_name(app, name, name_size, access); @@ -54,7 +54,7 @@ CUSTOM_COMMAND_SIG(switch_to_compilation){ } CUSTOM_COMMAND_SIG(rewrite_as_single_caps){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Full_Cursor cursor = view.cursor; @@ -77,8 +77,8 @@ CUSTOM_COMMAND_SIG(rewrite_as_single_caps){ Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); app->buffer_read_range(app, &buffer, range.min, range.max, string.str); - int is_first = true; - for (int i = 0; i < string.size; ++i){ + int32_t is_first = true; + for (int32_t i = 0; i < string.size; ++i){ if (char_is_alpha_true(string.str[i])){ if (is_first){ is_first = false; @@ -100,13 +100,13 @@ CUSTOM_COMMAND_SIG(rewrite_as_single_caps){ } CUSTOM_COMMAND_SIG(open_my_files){ - unsigned int access = AccessAll; + uint32_t access = AccessAll; View_Summary view = app->get_active_view(app, access); view_open_file(app, &view, literal("w:/4ed/data/test/basic.cpp"), false); } CUSTOM_COMMAND_SIG(build_at_launch_location){ - unsigned int access = AccessAll; + uint32_t access = AccessAll; View_Summary view = app->get_active_view(app, access); app->exec_system_command(app, &view, buffer_identifier(literal("*compilation*")), @@ -171,12 +171,12 @@ OPEN_FILE_HOOK_SIG(my_file_settings){ // NOTE(allen|a4.0.8): The app->get_parameter_buffer was eliminated // and instead the buffer is passed as an explicit parameter through // the function call. That is where buffer_id comes from here. - unsigned int access = AccessProtected|AccessHidden; + uint32_t access = AccessProtected|AccessHidden; Buffer_Summary buffer = app->get_buffer(app, buffer_id, access); assert(buffer.exists); - int treat_as_code = 0; - int wrap_lines = 1; + int32_t treat_as_code = 0; + int32_t wrap_lines = 1; if (buffer.file_name && buffer.size < (16 << 20)){ String ext = file_extension(make_string(buffer.file_name, buffer.file_name_len)); @@ -195,7 +195,8 @@ OPEN_FILE_HOOK_SIG(my_file_settings){ app->buffer_set_setting(app, &buffer, BufferSetting_Lex, treat_as_code); app->buffer_set_setting(app, &buffer, BufferSetting_WrapLine, wrap_lines); - app->buffer_set_setting(app, &buffer, BufferSetting_MapID, (treat_as_code)?((int)my_code_map):((int)mapid_file)); + app->buffer_set_setting(app, &buffer, BufferSetting_MapID, + (treat_as_code)?((int32_t)my_code_map):((int32_t)mapid_file)); // no meaning for return return(0); diff --git a/4coder_default_building.cpp b/4coder_default_building.cpp index e61c468d..8a83011d 100644 --- a/4coder_default_building.cpp +++ b/4coder_default_building.cpp @@ -92,7 +92,7 @@ CUSTOM_COMMAND_SIG(change_active_panel_build){ View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id); View_Summary view = app->get_active_view(app, AccessAll); - int prev_view_id = view.view_id; + int32_t prev_view_id = view.view_id; exec_command(app, change_active_panel_regular); view = app->get_active_view(app, AccessAll); diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index afd7b6ef..bfb287d3 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -29,8 +29,8 @@ static General_Memory global_general; void init_memory(Application_Links *app){ - int part_size = (1 << 20); - int general_size = (1 << 20); + int32_t part_size = (1 << 20); + int32_t general_size = (1 << 20); void *part_mem = app->memory_allocate(app, part_size); @@ -49,25 +49,25 @@ struct Stream_Chunk{ Buffer_Summary *buffer; char *base_data; - int start, end; - int min_start, max_end; - int data_size; + int32_t start, end; + int32_t min_start, max_end; + int32_t data_size; char *data; }; -int -round_down(int x, int b){ - int r = 0; +int32_t +round_down(int32_t x, int32_t b){ + int32_t r = 0; if (x >= 0){ r = x - (x % b); } return(r); } -int -round_up(int x, int b){ - int r = 0; +int32_t +round_up(int32_t x, int32_t b){ + int32_t r = 0; if (x >= 0){ r = x - (x % b) + b; } @@ -84,11 +84,11 @@ refresh_view(Application_Links *app, View_Summary *view){ *view = app->get_view(app, view->view_id, AccessAll); } -int +int32_t init_stream_chunk(Stream_Chunk *chunk, Application_Links *app, Buffer_Summary *buffer, - int pos, char *data, int size){ - int result = false; + int32_t pos, char *data, int32_t size){ + int32_t result = false; refresh_buffer(app, buffer); if (pos >= 0 && pos < buffer->size && size > 0){ @@ -120,11 +120,11 @@ init_stream_chunk(Stream_Chunk *chunk, return(result); } -int +int32_t forward_stream_chunk(Stream_Chunk *chunk){ Application_Links *app = chunk->app; Buffer_Summary *buffer = chunk->buffer; - int result = false; + int32_t result = false; refresh_buffer(app, buffer); if (chunk->end < buffer->size){ @@ -147,11 +147,11 @@ forward_stream_chunk(Stream_Chunk *chunk){ return(result); } -int +int32_t backward_stream_chunk(Stream_Chunk *chunk){ Application_Links *app = chunk->app; Buffer_Summary *buffer = chunk->buffer; - int result = false; + int32_t result = false; refresh_buffer(app, buffer); if (chunk->start > 0){ @@ -176,14 +176,14 @@ backward_stream_chunk(Stream_Chunk *chunk){ void buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, - int pos, char delim, int *result){ + int32_t pos, char delim, int32_t *result){ if (buffer->exists){ char chunk[1024]; - int size = sizeof(chunk); + int32_t size = sizeof(chunk); Stream_Chunk stream = {0}; if (init_stream_chunk(&stream, app, buffer, pos, chunk, size)){ - int still_looping = 1; + int32_t still_looping = 1; do{ for(; pos < stream.end; ++pos){ char at_pos = stream.data[pos]; @@ -204,14 +204,14 @@ buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, void buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, - int pos, char delim, int *result){ + int32_t pos, char delim, int32_t *result){ if (buffer->exists){ char chunk[1024]; - int size = sizeof(chunk); + int32_t size = sizeof(chunk); Stream_Chunk stream = {0}; if (init_stream_chunk(&stream, app, buffer, pos, chunk, size)){ - int still_looping = 1; + int32_t still_looping = 1; do{ for(; pos >= stream.start; --pos){ char at_pos = stream.data[pos]; @@ -238,7 +238,7 @@ buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, // replacing char read_buffer[512]; with more memory. void buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, - int pos, int end, char *str, int size, int *result){ + int32_t pos, int32_t end, char *str, int32_t size, int32_t *result){ char read_buffer[512]; if (size <= 0){ @@ -256,12 +256,12 @@ buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, read_str.size = size; char chunk[1024]; - int chunk_size = sizeof(chunk); + int32_t chunk_size = sizeof(chunk); Stream_Chunk stream = {0}; stream.max_end = end; if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){ - int still_looping = 1; + int32_t still_looping = 1; do{ for(; pos < stream.end; ++pos){ char at_pos = stream.data[pos]; @@ -294,7 +294,7 @@ buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer, // replacing char read_buffer[512]; with more memory. void buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, - int pos, int min, char *str, int size, int *result){ + int32_t pos, int32_t min, char *str, int32_t size, int32_t *result){ char read_buffer[512]; if (size <= 0){ *result = min-1; @@ -311,12 +311,12 @@ buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, read_str.size = size; char chunk[1024]; - int chunk_size = sizeof(chunk); + int32_t chunk_size = sizeof(chunk); Stream_Chunk stream = {0}; stream.min_start = min; if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){ - int still_looping = 1; + int32_t still_looping = 1; do{ for(; pos >= stream.start; --pos){ char at_pos = stream.data[pos]; @@ -344,10 +344,10 @@ buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer, // replacing char read_buffer[512]; with more memory. void buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *buffer, - int pos, int end, char *str, int size, int *result){ + int32_t pos, int32_t end, char *str, int32_t size, int32_t *result){ char read_buffer[512]; char chunk[1024]; - int chunk_size = sizeof(chunk); + int32_t chunk_size = sizeof(chunk); Stream_Chunk stream = {0}; stream.max_end = end; @@ -366,7 +366,7 @@ buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *b read_str.size = size; if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){ - int still_looping = 1; + int32_t still_looping = 1; do{ for(; pos < stream.end; ++pos){ char at_pos = char_to_upper(stream.data[pos]); @@ -394,10 +394,10 @@ buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_Summary *b // replacing char read_buffer[512]; with more memory. void buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary *buffer, - int pos, int min, char *str, int size, int *result){ + int32_t pos, int32_t min, char *str, int32_t size, int32_t *result){ char read_buffer[512]; char chunk[1024]; - int chunk_size = sizeof(chunk); + int32_t chunk_size = sizeof(chunk); Stream_Chunk stream = {0}; stream.min_start = min; @@ -416,7 +416,7 @@ buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary * read_str.size = size; if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){ - int still_looping = 1; + int32_t still_looping = 1; do{ for(; pos >= stream.start; --pos){ char at_pos = char_to_upper(stream.data[pos]); @@ -462,7 +462,7 @@ get_view_x(View_Summary view){ } CUSTOM_COMMAND_SIG(write_character){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); User_Input in = app->get_command_input(app); @@ -475,8 +475,8 @@ CUSTOM_COMMAND_SIG(write_character){ if (character != 0){ Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int pos = view.cursor.pos; - int next_pos = pos + 1; + int32_t pos = view.cursor.pos; + int32_t next_pos = pos + 1; app->buffer_replace_range(app, &buffer, pos, pos, &character, 1); app->view_set_cursor(app, &view, seek_pos(next_pos), true); @@ -484,11 +484,11 @@ CUSTOM_COMMAND_SIG(write_character){ } CUSTOM_COMMAND_SIG(delete_char){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int pos = view.cursor.pos; + int32_t pos = view.cursor.pos; if (0 < buffer.size && pos < buffer.size){ app->buffer_replace_range(app, &buffer, pos, pos+1, 0, 0); @@ -496,11 +496,11 @@ CUSTOM_COMMAND_SIG(delete_char){ } CUSTOM_COMMAND_SIG(backspace_char){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int pos = view.cursor.pos; + int32_t pos = view.cursor.pos; if (0 < pos && pos <= buffer.size){ app->buffer_replace_range(app, &buffer, pos-1, pos, 0, 0); @@ -510,7 +510,7 @@ CUSTOM_COMMAND_SIG(backspace_char){ } CUSTOM_COMMAND_SIG(set_mark){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); app->view_set_mark(app, &view, seek_pos(view.cursor.pos)); @@ -519,18 +519,18 @@ CUSTOM_COMMAND_SIG(set_mark){ } CUSTOM_COMMAND_SIG(cursor_mark_swap){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); - int cursor = view.cursor.pos; - int mark = view.mark.pos; + int32_t cursor = view.cursor.pos; + int32_t mark = view.mark.pos; app->view_set_cursor(app, &view, seek_pos(mark), true); app->view_set_mark(app, &view, seek_pos(cursor)); } CUSTOM_COMMAND_SIG(delete_range){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); @@ -569,18 +569,18 @@ CUSTOM_COMMAND_SIG(left_adjust_view){ app->view_set_scroll(app, &view, scroll); } -int -get_relative_xy(View_Summary *view, int x, int y, float *x_out, float *y_out){ - int result = false; +int32_t +get_relative_xy(View_Summary *view, int32_t x, int32_t y, float *x_out, float *y_out){ + int32_t result = false; i32_Rect region = view->file_region; - int max_x = (region.x1 - region.x0); - int max_y = (region.y1 - region.y0); + int32_t max_x = (region.x1 - region.x0); + int32_t max_y = (region.y1 - region.y0); GUI_Scroll_Vars scroll_vars = view->scroll_vars; - int rx = x - region.x0; - int ry = y - region.y0; + int32_t rx = x - region.x0; + int32_t ry = y - region.y0; if (ry >= 0){ if (rx >= 0 && rx < max_x && ry >= 0 && ry < max_y){ @@ -595,7 +595,7 @@ get_relative_xy(View_Summary *view, int x, int y, float *x_out, float *y_out){ } CUSTOM_COMMAND_SIG(click_set_cursor){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); Mouse_State mouse = app->get_mouse_state(app); @@ -609,7 +609,7 @@ CUSTOM_COMMAND_SIG(click_set_cursor){ } CUSTOM_COMMAND_SIG(click_set_mark){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); Mouse_State mouse = app->get_mouse_state(app); @@ -624,7 +624,7 @@ CUSTOM_COMMAND_SIG(click_set_mark){ inline void move_vertical(Application_Links *app, float line_multiplier){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); float new_y = get_view_y(view) + line_multiplier*view.line_height; @@ -668,14 +668,14 @@ get_page_jump(View_Summary *view){ } CUSTOM_COMMAND_SIG(page_up){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); float page_jump = get_page_jump(&view); move_vertical(app, -page_jump); } CUSTOM_COMMAND_SIG(page_down){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); float page_jump = get_page_jump(&view); move_vertical(app, page_jump); @@ -683,18 +683,18 @@ CUSTOM_COMMAND_SIG(page_down){ CUSTOM_COMMAND_SIG(move_left){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); - int new_pos = view.cursor.pos - 1; + int32_t new_pos = view.cursor.pos - 1; app->view_set_cursor(app, &view, seek_pos(new_pos), true); } CUSTOM_COMMAND_SIG(move_right){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); - int new_pos = view.cursor.pos + 1; + int32_t new_pos = view.cursor.pos + 1; app->view_set_cursor(app, &view, seek_pos(new_pos), true); @@ -704,13 +704,13 @@ CUSTOM_COMMAND_SIG(move_right){ // Auto Indenting and Whitespace // -static int -seek_line_end(Application_Links *app, Buffer_Summary *buffer, int pos){ +static int32_t +seek_line_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ char chunk[1024]; - int chunk_size = sizeof(chunk); + int32_t chunk_size = sizeof(chunk); Stream_Chunk stream = {0}; - int still_looping; + int32_t still_looping; char at_pos; if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){ @@ -734,13 +734,13 @@ seek_line_end(Application_Links *app, Buffer_Summary *buffer, int pos){ return(pos); } -static int -seek_line_beginning(Application_Links *app, Buffer_Summary *buffer, int pos){ +static int32_t +seek_line_beginning(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ char chunk[1024]; - int chunk_size = sizeof(chunk); + int32_t chunk_size = sizeof(chunk); Stream_Chunk stream = {0}; - int still_looping; + int32_t still_looping; char at_pos; --pos; @@ -772,12 +772,12 @@ static void move_past_lead_whitespace(Application_Links *app, View_Summary *view, Buffer_Summary *buffer){ refresh_view(app, view); - int new_pos = seek_line_beginning(app, buffer, view->cursor.pos); + int32_t new_pos = seek_line_beginning(app, buffer, view->cursor.pos); char space[1024]; Stream_Chunk chunk = {0}; - int still_looping = false; + int32_t still_looping = false; - int i = new_pos; + int32_t i = new_pos; if (init_stream_chunk(&chunk, app, buffer, i, space, sizeof(space))){ do{ for (; i < chunk.end; ++i){ @@ -797,7 +797,7 @@ move_past_lead_whitespace(Application_Links *app, View_Summary *view, Buffer_Sum } CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); @@ -809,7 +809,7 @@ CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor){ } CUSTOM_COMMAND_SIG(auto_tab_whole_file){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); @@ -820,7 +820,7 @@ CUSTOM_COMMAND_SIG(auto_tab_whole_file){ } CUSTOM_COMMAND_SIG(auto_tab_range){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); Range range = get_range(&view); @@ -844,8 +844,8 @@ CUSTOM_COMMAND_SIG(clean_all_lines){ View_Summary view = app->get_active_view(app, AccessOpen); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen); - int line_count = buffer.line_count; - int edit_max = line_count; + int32_t line_count = buffer.line_count; + int32_t edit_max = line_count; if (edit_max*sizeof(Buffer_Edit) < app->memory_size){ Buffer_Edit *edits = (Buffer_Edit*)app->memory; @@ -853,14 +853,14 @@ CUSTOM_COMMAND_SIG(clean_all_lines){ char data[1024]; Stream_Chunk chunk = {0}; - int i = 0; + int32_t i = 0; if (init_stream_chunk(&chunk, app, &buffer, i, data, sizeof(data))){ Buffer_Edit *edit = edits; - int buffer_size = buffer.size; - int still_looping = true; - int last_hard = buffer_size; + int32_t buffer_size = buffer.size; + int32_t still_looping = true; + int32_t last_hard = buffer_size; do{ for (; i < chunk.end; ++i){ char at_pos = chunk.data[i]; @@ -893,7 +893,7 @@ CUSTOM_COMMAND_SIG(clean_all_lines){ ++edit; } - int edit_count = (int)(edit - edits); + int32_t edit_count = (int32_t)(edit - edits); app->buffer_batch_edit(app, &buffer, 0, 0, edits, edit_count, BatchEdit_PreserveTokens); } } @@ -903,16 +903,16 @@ CUSTOM_COMMAND_SIG(clean_all_lines){ // Clipboard // -static int -clipboard_copy(Application_Links *app, int start, int end, Buffer_Summary *buffer_out, - unsigned int access){ +static int32_t +clipboard_copy(Application_Links *app, int32_t start, int32_t end, Buffer_Summary *buffer_out, + uint32_t access){ View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int result = false; + int32_t result = false; if (buffer.exists){ if (0 <= start && start <= end && end <= buffer.size){ - int size = (end - start); + int32_t size = (end - start); char *str = (char*)app->memory; if (size <= app->memory_size){ @@ -927,11 +927,11 @@ clipboard_copy(Application_Links *app, int start, int end, Buffer_Summary *buffe return(result); } -static int -clipboard_cut(Application_Links *app, int start, int end, Buffer_Summary *buffer_out, - unsigned int access){ +static int32_t +clipboard_cut(Application_Links *app, int32_t start, int32_t end, Buffer_Summary *buffer_out, + uint32_t access){ Buffer_Summary buffer = {0}; - int result = false; + int32_t result = false; if (clipboard_copy(app, start, end, &buffer, access)){ app->buffer_replace_range(app, &buffer, start, end, 0, 0); @@ -942,14 +942,14 @@ clipboard_cut(Application_Links *app, int start, int end, Buffer_Summary *buffer } CUSTOM_COMMAND_SIG(copy){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); Range range = get_range(&view); clipboard_copy(app, range.min, range.max, 0, access); } CUSTOM_COMMAND_SIG(cut){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Range range = get_range(&view); clipboard_cut(app, range.min, range.max, 0, access); @@ -962,26 +962,26 @@ enum Rewrite_Type{ }; struct View_Paste_Index{ - int rewrite; - int next_rewrite; - int index; + int32_t rewrite; + int32_t next_rewrite; + int32_t index; }; View_Paste_Index view_paste_index_[16]; View_Paste_Index *view_paste_index = view_paste_index_ - 1; CUSTOM_COMMAND_SIG(paste){ - unsigned int access = AccessOpen; - int count = app->clipboard_count(app, 0); + uint32_t access = AccessOpen; + int32_t count = app->clipboard_count(app, 0); if (count > 0){ View_Summary view = app->get_active_view(app, access); view_paste_index[view.view_id].next_rewrite = RewritePaste; - int paste_index = 0; + int32_t paste_index = 0; view_paste_index[view.view_id].index = paste_index; - int len = app->clipboard_index(app, 0, paste_index, 0, 0); + int32_t len = app->clipboard_index(app, 0, paste_index, 0, 0); char *str = 0; if (len <= app->memory_size){ @@ -992,7 +992,7 @@ CUSTOM_COMMAND_SIG(paste){ app->clipboard_index(app, 0, paste_index, str, len); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int pos = view.cursor.pos; + int32_t pos = view.cursor.pos; app->buffer_replace_range(app, &buffer, pos, pos, str, len); app->view_set_mark(app, &view, seek_pos(pos)); app->view_set_cursor(app, &view, seek_pos(pos + len), true); @@ -1007,18 +1007,18 @@ CUSTOM_COMMAND_SIG(paste){ } CUSTOM_COMMAND_SIG(paste_next){ - unsigned int access = AccessOpen; - int count = app->clipboard_count(app, 0); + uint32_t access = AccessOpen; + int32_t count = app->clipboard_count(app, 0); if (count > 0){ View_Summary view = app->get_active_view(app, access); if (view_paste_index[view.view_id].rewrite == RewritePaste){ view_paste_index[view.view_id].next_rewrite = RewritePaste; - int paste_index = view_paste_index[view.view_id].index + 1; + int32_t paste_index = view_paste_index[view.view_id].index + 1; view_paste_index[view.view_id].index = paste_index; - int len = app->clipboard_index(app, 0, paste_index, 0, 0); + int32_t len = app->clipboard_index(app, 0, paste_index, 0, 0); char *str = 0; if (len <= app->memory_size){ @@ -1030,7 +1030,7 @@ CUSTOM_COMMAND_SIG(paste_next){ Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); Range range = get_range(&view); - int pos = range.min; + int32_t pos = range.min; app->buffer_replace_range(app, &buffer, range.min, range.max, str, len); app->view_set_cursor(app, &view, seek_pos(pos + len), true); @@ -1067,12 +1067,12 @@ CUSTOM_COMMAND_SIG(to_uppercase){ Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen); Range range = get_range(&view); - int size = range.max - range.min; + int32_t size = range.max - range.min; if (size <= app->memory_size){ char *mem = (char*)app->memory; app->buffer_read_range(app, &buffer, range.min, range.max, mem); - for (int i = 0; i < size; ++i){ + for (int32_t i = 0; i < size; ++i){ mem[i] = char_to_upper(mem[i]); } app->buffer_replace_range(app, &buffer, range.min, range.max, mem, size); @@ -1085,12 +1085,12 @@ CUSTOM_COMMAND_SIG(to_lowercase){ Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen); Range range = get_range(&view); - int size = range.max - range.min; + int32_t size = range.max - range.min; if (size <= app->memory_size){ char *mem = (char*)app->memory; app->buffer_read_range(app, &buffer, range.min, range.max, mem); - for (int i = 0; i < size; ++i){ + for (int32_t i = 0; i < size; ++i){ mem[i] = char_to_lower(mem[i]); } app->buffer_replace_range(app, &buffer, range.min, range.max, mem, size); @@ -1102,14 +1102,14 @@ CUSTOM_COMMAND_SIG(to_lowercase){ // Various Forms of Seek // -static int -buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int pos){ +static int32_t +buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ char chunk[1024]; - int chunk_size = sizeof(chunk); + int32_t chunk_size = sizeof(chunk); Stream_Chunk stream = {0}; - int no_hard; - int still_looping; + int32_t no_hard; + int32_t still_looping; char at_pos; --pos; @@ -1161,19 +1161,19 @@ buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int po return(pos); } -static int -buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int pos){ +static int32_t +buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ char chunk[1024]; - int chunk_size = sizeof(chunk); + int32_t chunk_size = sizeof(chunk); Stream_Chunk stream = {0}; - int no_hard; - int prev_endline; - int still_looping; + int32_t no_hard; + int32_t prev_endline; + int32_t still_looping; char at_pos; if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){ - // Step 1: Find the first non-whitespace character + // step 1: find the first non-whitespace character // ahead of the current position. still_looping = true; do{ @@ -1187,9 +1187,9 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int } while(still_looping); double_break_1:; - // Step 2: Continue scanning forward, at each '\n' + // step 2: continue scanning forward, at each '\n' // mark it as the beginning of a new line by updating - // the prev_endline value. If another '\n' is found + // the prev_endline value. if another '\n' is found // with non-whitespace then the previous line was // all whitespace. no_hard = false; @@ -1226,82 +1226,82 @@ buffer_seek_whitespace_down(Application_Links *app, Buffer_Summary *buffer, int } CUSTOM_COMMAND_SIG(seek_whitespace_up){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int new_pos = buffer_seek_whitespace_up(app, &buffer, view.cursor.pos); + int32_t new_pos = buffer_seek_whitespace_up(app, &buffer, view.cursor.pos); app->view_set_cursor(app, &view, seek_pos(new_pos), true); } CUSTOM_COMMAND_SIG(seek_whitespace_down){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int new_pos = buffer_seek_whitespace_down(app, &buffer, view.cursor.pos); + int32_t new_pos = buffer_seek_whitespace_down(app, &buffer, view.cursor.pos); app->view_set_cursor(app, &view, seek_pos(new_pos), true); } CUSTOM_COMMAND_SIG(seek_end_of_line){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int new_pos = seek_line_end(app, &buffer, view.cursor.pos); + int32_t new_pos = seek_line_end(app, &buffer, view.cursor.pos); app->view_set_cursor(app, &view, seek_pos(new_pos), true); } CUSTOM_COMMAND_SIG(seek_beginning_of_line){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int new_pos = seek_line_beginning(app, &buffer, view.cursor.pos); + int32_t new_pos = seek_line_beginning(app, &buffer, view.cursor.pos); app->view_set_cursor(app, &view, seek_pos(new_pos), true); } static void -basic_seek(Application_Links *app, int seek_type, unsigned int flags){ - unsigned int access = AccessProtected; +basic_seek(Application_Links *app, int32_t seek_type, uint32_t flags){ + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int pos = app->buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags); + int32_t pos = app->buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags); app->view_set_cursor(app, &view, seek_pos(pos), true); } -#define SEEK_COMMAND(n, dir, flags)\ +#define seek_command(n, dir, flags)\ CUSTOM_COMMAND_SIG(seek_##n##_##dir){ basic_seek(app, dir, flags); } #define right true #define left false -SEEK_COMMAND(whitespace, right, BoundaryWhitespace) -SEEK_COMMAND(whitespace, left, BoundaryWhitespace) -SEEK_COMMAND(token, right, BoundaryToken) -SEEK_COMMAND(token, left, BoundaryToken) -SEEK_COMMAND(white_or_token, right, BoundaryToken | BoundaryWhitespace) -SEEK_COMMAND(white_or_token, left, BoundaryToken | BoundaryWhitespace) -SEEK_COMMAND(alphanumeric, right, BoundaryAlphanumeric) -SEEK_COMMAND(alphanumeric, left, BoundaryAlphanumeric) -SEEK_COMMAND(alphanumeric_or_camel, right, BoundaryAlphanumeric | BoundaryCamelCase) -SEEK_COMMAND(alphanumeric_or_camel, left, BoundaryAlphanumeric | BoundaryCamelCase) +seek_command(whitespace, right, BoundaryWhitespace) +seek_command(whitespace, left, BoundaryWhitespace) +seek_command(token, right, BoundaryToken) +seek_command(token, left, BoundaryToken) +seek_command(white_or_token, right, BoundaryToken | BoundaryWhitespace) +seek_command(white_or_token, left, BoundaryToken | BoundaryWhitespace) +seek_command(alphanumeric, right, BoundaryAlphanumeric) +seek_command(alphanumeric, left, BoundaryAlphanumeric) +seek_command(alphanumeric_or_camel, right, BoundaryAlphanumeric | BoundaryCamelCase) +seek_command(alphanumeric_or_camel, left, BoundaryAlphanumeric | BoundaryCamelCase) #undef right #undef left // -// Special string writing commands +// special string writing commands // static void write_string(Application_Links *app, String string){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); app->buffer_replace_range(app, &buffer, @@ -1315,11 +1315,11 @@ CUSTOM_COMMAND_SIG(write_increment){ } static void -long_braces(Application_Links *app, char *text, int size){ - unsigned int access = AccessOpen; +long_braces(Application_Links *app, char *text, int32_t size){ + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int pos = view.cursor.pos; + int32_t pos = view.cursor.pos; app->buffer_replace_range(app, &buffer, pos, pos, text, size); app->view_set_cursor(app, &view, seek_pos(pos + 2), true); @@ -1333,30 +1333,30 @@ long_braces(Application_Links *app, char *text, int size){ CUSTOM_COMMAND_SIG(open_long_braces){ char text[] = "{\n\n}"; - int size = sizeof(text) - 1; + int32_t size = sizeof(text) - 1; long_braces(app, text, size); } CUSTOM_COMMAND_SIG(open_long_braces_semicolon){ char text[] = "{\n\n};"; - int size = sizeof(text) - 1; + int32_t size = sizeof(text) - 1; long_braces(app, text, size); } CUSTOM_COMMAND_SIG(open_long_braces_break){ char text[] = "{\n\n}break;"; - int size = sizeof(text) - 1; + int32_t size = sizeof(text) - 1; long_braces(app, text, size); } -// TODO(allen): Have this thing check if it is on +// TODO(allen): have this thing check if it is on // a blank line and insert newlines as needed. CUSTOM_COMMAND_SIG(if0_off){ char text1[] = "\n#if 0"; - int size1 = sizeof(text1) - 1; + int32_t size1 = sizeof(text1) - 1; char text2[] = "#endif\n"; - int size2 = sizeof(text2) - 1; + int32_t size2 = sizeof(text2) - 1; View_Summary view = app->get_active_view(app, AccessOpen); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen); @@ -1370,14 +1370,14 @@ CUSTOM_COMMAND_SIG(if0_off){ str = push_array(&global_part, char, size1); memcpy(str, text1, size1); - edits[0].str_start = (int)(str - base); + edits[0].str_start = (int32_t)(str - base); edits[0].len = size1; edits[0].start = range.min; edits[0].end = range.min; str = push_array(&global_part, char, size2); memcpy(str, text2, size2); - edits[1].str_start = (int)(str - base); + edits[1].str_start = (int32_t)(str - base); edits[1].len = size2; edits[1].start = range.max; edits[1].end = range.max; @@ -1412,31 +1412,31 @@ CUSTOM_COMMAND_SIG(if0_off){ // CUSTOM_COMMAND_SIG(backspace_word){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); if (buffer.exists){ - int pos2 = 0, pos1 = 0; + int32_t pos2 = 0, pos1 = 0; pos2 = view.cursor.pos; exec_command(app, seek_alphanumeric_left); refresh_view(app, &view); pos1 = view.cursor.pos; - + app->buffer_replace_range(app, &buffer, pos1, pos2, 0, 0); } } CUSTOM_COMMAND_SIG(delete_word){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); if (buffer.exists){ - int pos2 = 0, pos1 = 0; + int32_t pos2 = 0, pos1 = 0; pos1 = view.cursor.pos; exec_command(app, seek_alphanumeric_right); @@ -1448,17 +1448,16 @@ CUSTOM_COMMAND_SIG(delete_word){ } CUSTOM_COMMAND_SIG(snipe_token_or_word){ - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view; Buffer_Summary buffer; - int pos1, pos2; + int32_t pos1, pos2; view = app->get_active_view(app, access); buffer = app->get_buffer(app, view.buffer_id, access); pos1 = app->buffer_boundary_seek(app, &buffer, view.cursor.pos, false, BoundaryToken | BoundaryWhitespace); - pos2 = app->buffer_boundary_seek(app, &buffer, pos1, true, BoundaryToken | BoundaryWhitespace); Range range = make_range(pos1, pos2); @@ -1532,15 +1531,15 @@ CUSTOM_COMMAND_SIG(open_panel_hsplit){ // Open File In Quotes // -static int +static int32_t file_name_in_quotes(Application_Links *app, String *file_name){ - int result = false; - unsigned int access = AccessProtected; + int32_t result = false; + uint32_t access = AccessProtected; View_Summary view; Buffer_Summary buffer; char short_file_name[128]; - int pos, start, end, size; + int32_t pos, start, end, size; view = app->get_active_view(app, access); buffer = app->get_buffer(app, view.buffer_id, access); @@ -1622,7 +1621,7 @@ CUSTOM_COMMAND_SIG(save_as){ } CUSTOM_COMMAND_SIG(goto_line){ - unsigned int access = AccessProtected; + uint32_t access = AccessProtected; Query_Bar bar = {0}; char string_space[256]; @@ -1631,7 +1630,7 @@ CUSTOM_COMMAND_SIG(goto_line){ bar.string = make_fixed_width_string(string_space); if (query_user_number(app, &bar)){ - int line_number = str_to_int_s(bar.string); + int32_t line_number = str_to_int_s(bar.string); active_view_to_line(app, access, line_number); } } @@ -1640,8 +1639,8 @@ CUSTOM_COMMAND_SIG(search); CUSTOM_COMMAND_SIG(reverse_search); static void -isearch(Application_Links *app, int start_reversed){ - unsigned int access = AccessProtected; +isearch(Application_Links *app, int32_t start_reversed){ + uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); @@ -1651,10 +1650,10 @@ isearch(Application_Links *app, int start_reversed){ Query_Bar bar = {0}; if (app->start_query_bar(app, &bar, 0) == 0) return; - int reverse = start_reversed; - int pos = view.cursor.pos; - int start_pos = pos; - int first_pos = pos; + int32_t reverse = start_reversed; + int32_t pos = view.cursor.pos; + int32_t start_pos = pos; + int32_t first_pos = pos; Range match = make_range(pos, pos); char bar_string_space[256]; @@ -1679,7 +1678,7 @@ isearch(Application_Links *app, int start_reversed){ assert(in.type == UserInputKey); - int made_change = 0; + int32_t made_change = 0; if (in.key.keycode == '\n' || in.key.keycode == '\t'){ break; } @@ -1694,8 +1693,8 @@ isearch(Application_Links *app, int start_reversed){ } } - int step_forward = 0; - int step_backward = 0; + int32_t step_forward = 0; + int32_t step_backward = 0; if ((in.command.command == search) || in.key.keycode == key_page_down || in.key.keycode == key_down) step_forward = 1; @@ -1717,7 +1716,7 @@ isearch(Application_Links *app, int start_reversed){ } if (in.key.keycode != key_back){ - int new_pos; + int32_t new_pos; if (reverse){ buffer_seek_string_insensitive_backward(app, &buffer, start_pos - 1, 0, bar.string.str, bar.string.size, &new_pos); @@ -1792,13 +1791,13 @@ CUSTOM_COMMAND_SIG(replace_in_range){ r = replace.string; w = with.string; - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); Range range = get_range(&view); - int pos, new_pos; + int32_t pos, new_pos; pos = range.min; buffer_seek_string_forward(app, &buffer, pos, 0, r.str, r.size, &new_pos); @@ -1835,14 +1834,14 @@ CUSTOM_COMMAND_SIG(query_replace){ Query_Bar bar; Buffer_Summary buffer; View_Summary view; - int pos, new_pos; + int32_t pos, new_pos; bar.prompt = make_lit_string("Replace? (y)es, (n)ext, (esc)\n"); - bar.string = empty_string(); + bar.string = string_zero(); app->start_query_bar(app, &bar, 0); - unsigned int access = AccessOpen; + uint32_t access = AccessOpen; view = app->get_active_view(app, access); buffer = app->get_buffer(app, view.buffer_id, access); @@ -1887,10 +1886,10 @@ CUSTOM_COMMAND_SIG(close_all_code){ // TODO(allen): Get better memory constructs to the custom layer // so that it doesn't have to rely on arbitrary limits like this one. - int buffers_to_close[2048]; - int buffers_to_close_count = 0; + int32_t buffers_to_close[2048]; + int32_t buffers_to_close_count = 0; - unsigned int access = AccessAll; + uint32_t access = AccessAll; for (buffer = app->get_buffer_first(app, access); buffer.exists; app->get_buffer_next(app, &buffer, access)){ @@ -1906,7 +1905,7 @@ CUSTOM_COMMAND_SIG(close_all_code){ } } - for (int i = 0; i < buffers_to_close_count; ++i){ + for (int32_t i = 0; i < buffers_to_close_count; ++i){ app->kill_buffer(app, buffer_identifier(buffers_to_close[i]), true, 0); } } @@ -1919,13 +1918,13 @@ CUSTOM_COMMAND_SIG(open_all_code){ // stack, so I am phasing that idea out now. String dir = make_string_cap(app->memory, 0, app->memory_size); dir.size = app->directory_get_hot(app, dir.str, dir.memory_size); - int dir_size = dir.size; + int32_t dir_size = dir.size; // NOTE(allen|a3.4.4): Here we get the list of files in this directory. // Notice that we free_file_list at the end. File_List list = app->get_file_list(app, dir.str, dir.size); - for (int i = 0; i < list.count; ++i){ + for (int32_t i = 0; i < list.count; ++i){ File_Info *info = list.infos + i; if (!info->folder){ String extension = make_string_cap(info->filename, info->filename_len, info->filename_len+1); @@ -1968,7 +1967,7 @@ CUSTOM_COMMAND_SIG(execute_any_cli){ String hot_directory = make_fixed_width_string(hot_directory_space); hot_directory.size = app->directory_get_hot(app, hot_directory.str, hot_directory.memory_size); - unsigned int access = AccessAll; + uint32_t access = AccessAll; View_Summary view = app->get_active_view(app, access); app->exec_system_command(app, &view, @@ -1984,7 +1983,7 @@ CUSTOM_COMMAND_SIG(execute_previous_cli){ String hot_directory = make_string_slowly(hot_directory_space); if (out_buffer.size > 0 && cmd.size > 0 && hot_directory.size > 0){ - unsigned int access = AccessAll; + uint32_t access = AccessAll; View_Summary view = app->get_active_view(app, access); app->exec_system_command(app, &view, @@ -2012,9 +2011,9 @@ enum Get_Build_Directory_Result{ BuildDir_AtHot }; -static int +static int32_t get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_out){ - int result = BuildDir_None; + int32_t result = BuildDir_None; if (buffer && buffer->file_name){ if (!match_cc(buffer->file_name, buffer->buffer_name)){ @@ -2028,7 +2027,7 @@ get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_ } if (!result){ - int len = app->directory_get_hot(app, dir_out->str, + int32_t len = app->directory_get_hot(app, dir_out->str, dir_out->memory_size - dir_out->size); if (len + dir_out->size < dir_out->memory_size){ dir_out->size += len; @@ -2039,19 +2038,19 @@ get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_ return(result); } -static int +static int32_t standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary *active_buffer, String *dir, String *command, - int perform_backup, - int use_path_in_command, + int32_t perform_backup, + int32_t use_path_in_command, String filename, String commandname){ - int result = false; + int32_t result = false; for(;;){ - int old_size = dir->size; + int32_t old_size = dir->size; append_ss(dir, filename); if (app->file_exists(app, dir->str, dir->size)){ @@ -2108,31 +2107,31 @@ standard_build_search(Application_Links *app, #if defined(_WIN32) // NOTE(allen): Build search rule for windows. -static int +static int32_t execute_standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary *active_buffer, - String *dir, String *command, int perform_backup){ - int result = standard_build_search(app, view, - active_buffer, - dir, command, perform_backup, true, - make_lit_string("build.bat"), - make_lit_string("build")); + String *dir, String *command, int32_t perform_backup){ + int32_t result = standard_build_search(app, view, + active_buffer, + dir, command, perform_backup, true, + make_lit_string("build.bat"), + make_lit_string("build")); return(result); } #elif defined(__linux__) // NOTE(allen): Build search rule for linux. -static int +static int32_t execute_standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary *active_buffer, - String *dir, String *command, int perform_backup){ + String *dir, String *command, int32_t perform_backup){ char dir_space[512]; String dir_copy = make_fixed_width_string(dir_space); copy(&dir_copy, *dir); - int result = standard_build_search(app, view, + int32_t result = standard_build_search(app, view, active_buffer, dir, command, false, true, make_lit_string("build.sh"), @@ -2163,7 +2162,7 @@ execute_standard_build(Application_Links *app, View_Summary *view, char command_str_space[512]; String command = make_fixed_width_string(command_str_space); - int build_dir_type = get_build_directory(app, active_buffer, &dir); + int32_t build_dir_type = get_build_directory(app, active_buffer, &dir); if (build_dir_type == BuildDir_AtFile){ if (!execute_standard_build_search(app, view, active_buffer, @@ -2181,7 +2180,7 @@ execute_standard_build(Application_Links *app, View_Summary *view, } CUSTOM_COMMAND_SIG(build_search_regular){ - unsigned int access = AccessAll; + uint32_t access = AccessAll; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); execute_standard_build(app, &view, &buffer); @@ -2245,7 +2244,7 @@ CUSTOM_COMMAND_SIG(eol_nixify){ static void generic_search_all_buffers(Application_Links *app, General_Memory *general, Partition *part, - unsigned int match_flags){ + uint32_t match_flags){ Query_Bar string; char string_space[1024]; @@ -2261,7 +2260,7 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part search_iter_init(general, &iter, string.string.size); copy_ss(&iter.word, string.string); - int buffer_count = app->get_buffer_count(app); + int32_t buffer_count = app->get_buffer_count(app); search_set_init(general, &set, buffer_count); Search_Range *ranges = set.ranges; @@ -2281,7 +2280,7 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part View_Summary view = app->get_active_view(app, AccessProtected); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessProtected); - int j = 0; + int32_t j = 0; if (buffer.exists){ if (buffer.buffer_id != search_buffer.buffer_id){ ranges[0].type = SearchRange_FrontToBack; @@ -2313,23 +2312,23 @@ generic_search_all_buffers(Application_Links *app, General_Memory *general, Part Temp_Memory temp = begin_temp_memory(part); Partition line_part = partition_sub_part(part, (4 << 10)); char *str = (char*)partition_current(part); - int part_size = 0; - int size = 0; + int32_t part_size = 0; + int32_t size = 0; for (;;){ Search_Match match = search_next_match(app, &set, &iter); if (match.found_match){ Partial_Cursor word_pos = {0}; if (app->buffer_compute_cursor(app, &match.buffer, seek_pos(match.start), &word_pos)){ - int file_len = match.buffer.file_name_len; - int line_num_len = int_to_str_size(word_pos.line); - int column_num_len = int_to_str_size(word_pos.character); + int32_t file_len = match.buffer.file_name_len; + int32_t line_num_len = int_to_str_size(word_pos.line); + int32_t column_num_len = int_to_str_size(word_pos.character); Temp_Memory line_temp = begin_temp_memory(&line_part); String line_str = {0}; read_line(app, &line_part, &match.buffer, word_pos.line, &line_str); line_str = skip_chop_whitespace(line_str); - int str_len = file_len + 1 + line_num_len + 1 + column_num_len + 1 + 1 + line_str.size + 1; + int32_t str_len = file_len + 1 + line_num_len + 1 + column_num_len + 1 + 1 + line_str.size + 1; char *spare = push_array(part, char, str_len); @@ -2395,9 +2394,9 @@ struct Word_Complete_State{ Search_Iter iter; Table hits; String_Space str; - int word_start; - int word_end; - int initialized; + int32_t word_start; + int32_t word_end; + int32_t initialized; }; static Word_Complete_State complete_state = {0}; @@ -2409,7 +2408,7 @@ CUSTOM_COMMAND_SIG(word_complete){ // NOTE(allen): I just do this because this command is a lot of work // and there is no point in doing any of it if nothing will happen anyway. if (buffer.exists){ - int do_init = false; + int32_t do_init = false; if (view_paste_index[view.view_id].rewrite != RewriteWordComplete){ do_init = true; @@ -2419,10 +2418,10 @@ CUSTOM_COMMAND_SIG(word_complete){ do_init = true; } - int word_end = 0; - int word_start = 0; - int cursor_pos = 0; - int size = 0; + int32_t word_end = 0; + int32_t word_start = 0; + int32_t cursor_pos = 0; + int32_t size = 0; if (do_init){ // NOTE(allen): Get the range where the @@ -2435,7 +2434,7 @@ CUSTOM_COMMAND_SIG(word_complete){ Stream_Chunk chunk = {0}; if (init_stream_chunk(&chunk, app, &buffer, cursor_pos, space, sizeof(space))){ - int still_looping = true; + int32_t still_looping = true; do{ for (; cursor_pos >= chunk.start; --cursor_pos){ char c = chunk.data[cursor_pos]; @@ -2467,7 +2466,7 @@ CUSTOM_COMMAND_SIG(word_complete){ complete_state.iter.word.size = size; // NOTE(allen): Initialize the set of ranges to be searched. - int buffer_count = app->get_buffer_count(app); + int32_t buffer_count = app->get_buffer_count(app); search_set_init(&global_general, &complete_state.set, buffer_count); Search_Range *ranges = complete_state.set.ranges; @@ -2479,7 +2478,7 @@ CUSTOM_COMMAND_SIG(word_complete){ ranges[0].mid_start = word_start; ranges[0].mid_size = size; - int j = 1; + int32_t j = 1; for (Buffer_Summary buffer_it = app->get_buffer_first(app, AccessAll); buffer_it.exists; app->get_buffer_next(app, &buffer_it, AccessAll)){ @@ -2513,7 +2512,7 @@ CUSTOM_COMMAND_SIG(word_complete){ // NOTE(allen): Iterate through matches. if (size > 0){ for (;;){ - int match_size = 0; + int32_t match_size = 0; Search_Match match = search_next_match(app, &complete_state.set, &complete_state.iter); @@ -2648,9 +2647,9 @@ struct Scroll_Velocity{ Scroll_Velocity scroll_velocity_[16] = {0}; Scroll_Velocity *scroll_velocity = scroll_velocity_ - 1; -static int +static int32_t smooth_camera_step(float target, float *current, float *vel, float S, float T){ - int result = 0; + int32_t result = 0; float curr = *current; float v = *vel; if (curr != target){ @@ -2660,28 +2659,28 @@ smooth_camera_step(float target, float *current, float *vel, float S, float T){ } else{ float L = curr + T*(target - curr); - - int sign = (target > curr) - (target < curr); + + int32_t sign = (target > curr) - (target < curr); float V = curr + sign*v; - + if (sign > 0) curr = (LV)?(L):(V); - + if (curr == V){ v *= S; } } - + *current = curr; *vel = v; result = 1; } - return result; + return(result); } SCROLL_RULE_SIG(smooth_scroll_rule){ Scroll_Velocity *velocity = scroll_velocity + view_id; - int result = 0; + int32_t result = 0; if (velocity->x == 0.f){ velocity->x = 1.f; velocity->y = 1.f; diff --git a/4coder_gui.h b/4coder_gui.h index 4a1c378e..5b91baa2 100644 --- a/4coder_gui.h +++ b/4coder_gui.h @@ -24,10 +24,10 @@ typedef struct GUI GUI; // down a little more? I think maybe we do. #define GUI_GET_SCROLL_VARS_SIG(n) void n(GUI *gui, GUI_id scroll_id, GUI_Scroll_Vars *vars, i32_Rect *region) -#define GUI_BEGIN_SCROLLABLE_SIG(n) int n(GUI *gui, GUI_id scroll_id, GUI_Scroll_Vars vars, float delta, int show_scrollbar) +#define GUI_BEGIN_SCROLLABLE_SIG(n) int32_t n(GUI *gui, GUI_id scroll_id, GUI_Scroll_Vars vars, float delta, int32_t show_scrollbar) #define GUI_END_SCROLLABLE_SIG(n) void n(GUI *gui) -#define GUI_FILE_SIG(n) void n(GUI *gui, int buffer_id) +#define GUI_FILE_SIG(n) void n(GUI *gui, int32_t buffer_id) typedef GUI_BEGIN_SIG(GUI_Begin_Function); typedef GUI_END_SIG(GUI_End_Function); diff --git a/4coder_helper.h b/4coder_helper.h index c0903809..76150d5e 100644 --- a/4coder_helper.h +++ b/4coder_helper.h @@ -8,8 +8,8 @@ struct Bind_Helper{ Binding_Unit *cursor, *start, *end; Binding_Unit *header, *group; - int write_total; - int error; + int32_t write_total; + int32_t error; }; #define BH_ERR_NONE 0 @@ -17,13 +17,6 @@ struct Bind_Helper{ #define BH_ERR_MISSING_BEGIN 2 #define BH_ERR_OUT_OF_MEMORY 3 -inline void -copy(char *dest, const char *src, int len){ - for (int i = 0; i < len; ++i){ - *dest++ = *src++; - } -} - inline Binding_Unit* write_unit(Bind_Helper *helper, Binding_Unit unit){ Binding_Unit *p = 0; @@ -35,28 +28,8 @@ write_unit(Bind_Helper *helper, Binding_Unit unit){ return p; } -inline char* -write_inline_string(Bind_Helper *helper, char *value, int len){ - char *dest = 0; - helper->write_total += len; - if (helper->error == 0){ - dest = (char*)helper->cursor; - int cursor_advance = len + sizeof(*helper->cursor) - 1; - cursor_advance /= sizeof(*helper->cursor); - cursor_advance *= sizeof(*helper->cursor); - helper->cursor += cursor_advance; - if (helper->cursor < helper->end){ - copy(dest, value, len); - } - else{ - helper->error = BH_ERR_OUT_OF_MEMORY; - } - } - return dest; -} - inline Bind_Helper -begin_bind_helper(void *data, int size){ +begin_bind_helper(void *data, int32_t size){ Bind_Helper result; result.header = 0; @@ -78,7 +51,7 @@ begin_bind_helper(void *data, int size){ } inline void -begin_map_(Bind_Helper *helper, int mapid, int replace){ +begin_map_(Bind_Helper *helper, int32_t mapid, int32_t replace){ if (helper->group != 0 && helper->error == 0) helper->error = BH_ERR_MISSING_END; if (!helper->error && mapid < mapid_global) ++helper->header->header.user_map_count; @@ -91,12 +64,12 @@ begin_map_(Bind_Helper *helper, int mapid, int replace){ } inline void -begin_map(Bind_Helper *helper, int mapid){ +begin_map(Bind_Helper *helper, int32_t mapid){ begin_map_(helper, mapid, 0); } inline void -restart_map(Bind_Helper *helper, int mapid){ +restart_map(Bind_Helper *helper, int32_t mapid){ begin_map_(helper, mapid, 1); } @@ -107,7 +80,7 @@ end_map(Bind_Helper *helper){ } inline void -bind(Bind_Helper *helper, short code, unsigned char modifiers, int cmdid){ +bind(Bind_Helper *helper, short code, unsigned char modifiers, int32_t cmdid){ if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN; if (!helper->error) ++helper->group->map_begin.bind_count; @@ -135,7 +108,7 @@ bind(Bind_Helper *helper, short code, unsigned char modifiers, Custom_Command_Fu } inline void -bind_vanilla_keys(Bind_Helper *helper, int cmdid){ +bind_vanilla_keys(Bind_Helper *helper, int32_t cmdid){ bind(helper, 0, 0, cmdid); } @@ -145,7 +118,7 @@ bind_vanilla_keys(Bind_Helper *helper, Custom_Command_Function *func){ } inline void -bind_vanilla_keys(Bind_Helper *helper, unsigned char modifiers, int cmdid){ +bind_vanilla_keys(Bind_Helper *helper, unsigned char modifiers, int32_t cmdid){ bind(helper, 0, modifiers, cmdid); } @@ -155,7 +128,7 @@ bind_vanilla_keys(Bind_Helper *helper, unsigned char modifiers, Custom_Command_F } inline void -inherit_map(Bind_Helper *helper, int mapid){ +inherit_map(Bind_Helper *helper, int32_t mapid){ if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN; if (!helper->error && mapid < mapid_global) ++helper->header->header.user_map_count; @@ -167,7 +140,7 @@ inherit_map(Bind_Helper *helper, int mapid){ } inline void -set_hook(Bind_Helper *helper, int hook_id, Hook_Function *func){ +set_hook(Bind_Helper *helper, int32_t hook_id, Hook_Function *func){ Binding_Unit unit; unit.type = unit_hook; unit.hook.hook_id = hook_id; @@ -226,11 +199,11 @@ set_scroll_rule(Bind_Helper *helper, Scroll_Rule_Function *func){ write_unit(helper, unit); } -inline int +inline int32_t end_bind_helper(Bind_Helper *helper){ - int result; + int32_t result; if (helper->header){ - helper->header->header.total_size = (int)(helper->cursor - helper->start); + helper->header->header.total_size = (int32_t)(helper->cursor - helper->start); helper->header->header.error = helper->error; } result = helper->write_total; @@ -245,8 +218,8 @@ get_range(View_Summary *view){ } struct Buffer_Rect{ - int char0,line0; - int char1,line1; + int32_t char0,line0; + int32_t char1,line1; }; #ifndef Swap @@ -259,15 +232,15 @@ get_rect(View_Summary *view){ rect.char0 = view->mark.character; rect.line0 = view->mark.line; - + rect.char1 = view->cursor.character; rect.line1 = view->cursor.line; if (rect.line0 > rect.line1){ - Swap(int, rect.line0, rect.line1); + Swap(int32_t, rect.line0, rect.line1); } if (rect.char0 > rect.char1){ - Swap(int, rect.char0, rect.char1); + Swap(int32_t, rect.char0, rect.char1); } return(rect); @@ -294,7 +267,7 @@ exec_command(Application_Links *app, Generic_Command cmd){ } inline void -active_view_to_line(Application_Links *app, unsigned int access, int line_number){ +active_view_to_line(Application_Links *app, uint32_t access, int32_t line_number){ View_Summary view; view = app->get_active_view(app, access); @@ -305,12 +278,12 @@ active_view_to_line(Application_Links *app, unsigned int access, int line_number } inline View_Summary -get_first_view_with_buffer(Application_Links *app, int buffer_id){ +get_first_view_with_buffer(Application_Links *app, int32_t buffer_id){ View_Summary result = {}; View_Summary test = {}; if (buffer_id != 0){ - unsigned int access = AccessAll; + uint32_t access = AccessAll; for(test = app->get_view_first(app, access); test.exists; app->get_view_next(app, &test, access)){ @@ -323,22 +296,22 @@ get_first_view_with_buffer(Application_Links *app, int buffer_id){ } } } - + return(result); } -inline int +inline int32_t key_is_unmodified(Key_Event_Data *key){ char *mods = key->modifiers; - int unmodified = !mods[MDFR_CONTROL_INDEX] && !mods[MDFR_ALT_INDEX]; + int32_t unmodified = !mods[MDFR_CONTROL_INDEX] && !mods[MDFR_ALT_INDEX]; return(unmodified); } -static int -query_user_general(Application_Links *app, Query_Bar *bar, int force_number){ +static int32_t +query_user_general(Application_Links *app, Query_Bar *bar, int32_t force_number){ User_Input in; - int success = 1; - int good_character = 0; + int32_t success = 1; + int32_t good_character = 0; // NOTE(allen|a3.4.4): It will not cause an *error* if we continue on after failing to. // start a query bar, but it will be unusual behavior from the point of view of the @@ -398,29 +371,27 @@ query_user_general(Application_Links *app, Query_Bar *bar, int force_number){ return(success); } -inline int +inline int32_t query_user_string(Application_Links *app, Query_Bar *bar){ - int success = query_user_general(app, bar, 0); + int32_t success = query_user_general(app, bar, 0); return(success); } -inline int +inline int32_t query_user_number(Application_Links *app, Query_Bar *bar){ - int success = query_user_general(app, bar, 1); + int32_t success = query_user_general(app, bar, 1); return(success); } -inline String empty_string() {String Result = {}; return(Result);} - inline Buffer_Summary -get_active_buffer(Application_Links *app, unsigned int access){ +get_active_buffer(Application_Links *app, uint32_t access){ View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); return(buffer); } inline char -buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int pos){ +buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ char result = ' '; *buffer = app->get_buffer(app, buffer->buffer_id, AccessAll); if (pos >= 0 && pos < buffer->size){ @@ -430,7 +401,7 @@ buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int pos){ } inline Buffer_Identifier -buffer_identifier(char *str, int len){ +buffer_identifier(char *str, int32_t len){ Buffer_Identifier identifier; identifier.name = str; identifier.name_len = len; @@ -439,7 +410,7 @@ buffer_identifier(char *str, int len){ } inline Buffer_Identifier -buffer_identifier(int id){ +buffer_identifier(int32_t id){ Buffer_Identifier identifier; identifier.name = 0; identifier.name_len = 0; @@ -447,10 +418,10 @@ buffer_identifier(int id){ return(identifier); } -static int +static int32_t view_open_file(Application_Links *app, View_Summary *view, - char *filename, int filename_len, int do_in_background){ - int result = false; + char *filename, int32_t filename_len, int32_t do_in_background){ + int32_t result = false; Buffer_Summary buffer = app->get_buffer_by_name(app, filename, filename_len, AccessProtected|AccessHidden); if (buffer.exists){ if (!do_in_background){ @@ -474,17 +445,17 @@ view_open_file(Application_Links *app, View_Summary *view, return(result); } -static int +static int32_t read_line(Application_Links *app, Partition *part, Buffer_Summary *buffer, - int line, + int32_t line, String *str){ Partial_Cursor begin = {0}; Partial_Cursor end = {0}; - int success = false; + int32_t success = false; if (app->buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &begin)){ @@ -492,7 +463,7 @@ read_line(Application_Links *app, seek_line_char(line, 65536), &end)){ if (begin.line == line){ if (0 <= begin.pos && begin.pos <= end.pos && end.pos <= buffer->size){ - int size = (end.pos - begin.pos); + int32_t size = (end.pos - begin.pos); *str = make_string(push_array(part, char, size+1), size+1); if (str->str){ success = true; diff --git a/4coder_jump_parsing.cpp b/4coder_jump_parsing.cpp index 246e2484..8230b67c 100644 --- a/4coder_jump_parsing.cpp +++ b/4coder_jump_parsing.cpp @@ -4,8 +4,8 @@ struct Jump_Location{ String file; - int line; - int column; + int32_t line; + int32_t column; }; static void @@ -14,30 +14,30 @@ jump_to_location(Application_Links *app, View_Summary *view, Jump_Location *l){ app->view_set_cursor(app, view, seek_line_char(l->line, l->column), true); } -static int -ms_style_verify(String line, int paren_pos){ - int result = false; +static int32_t +ms_style_verify(String line, int32_t paren_pos){ + int32_t result = false; String line_part = substr_tail(line, paren_pos); if (match_part_sc(line_part, ") : ")){ - result = true; - } + result = true; + } else if (match_part_sc(line_part, "): ")){ - result = true; - } - - return(result); -} - -static int + result = true; + } + + return(result); +} + +static int32_t parse_error(String line, Jump_Location *location, - int skip_sub_errors, int *colon_char){ - int result = false; - + int32_t skip_sub_errors, int32_t *colon_char){ + int32_t result = false; + String original_line = line; line = skip_chop_whitespace(line); - int colon_pos = find_s_char(line, 0, ')'); + int32_t colon_pos = find_s_char(line, 0, ')'); if (ms_style_verify(line, colon_pos)){ colon_pos = find_s_char(line, colon_pos, ':'); if (colon_pos < line.size){ @@ -46,12 +46,12 @@ parse_error(String line, Jump_Location *location, if (!(skip_sub_errors && original_line.str[0] == ' ')){ location_str = skip_chop_whitespace(location_str); - int paren_pos = find_s_char(location_str, 0, '('); + int32_t paren_pos = find_s_char(location_str, 0, '('); if (paren_pos < location_str.size){ String file = substr(location_str, 0, paren_pos); file = skip_chop_whitespace(file); - int close_pos = find_s_char(location_str, 0, ')') + 1; + int32_t close_pos = find_s_char(location_str, 0, ')') + 1; if (close_pos == location_str.size && file.size > 0){ String line_number = substr(location_str, paren_pos+1, @@ -61,9 +61,9 @@ parse_error(String line, Jump_Location *location, if (line_number.size > 0){ location->file = file; - int comma_pos = find_s_char(line_number, 0, ','); + int32_t comma_pos = find_s_char(line_number, 0, ','); if (comma_pos < line_number.size){ - int start = comma_pos+1; + int32_t start = comma_pos+1; String column_number = substr(line_number, start, line_number.size-start); line_number = substr(line_number, 0, comma_pos); @@ -85,15 +85,15 @@ parse_error(String line, Jump_Location *location, } else{ - int colon_pos1 = find_s_char(line, 0, ':'); + int32_t colon_pos1 = find_s_char(line, 0, ':'); if (line.size > colon_pos1+1){ if (char_is_slash(line.str[colon_pos1+1])){ colon_pos1 = find_s_char(line, colon_pos1+1, ':'); } } - int colon_pos2 = find_s_char(line, colon_pos1+1, ':'); - int colon_pos3 = find_s_char(line, colon_pos2+1, ':'); + int32_t colon_pos2 = find_s_char(line, colon_pos1+1, ':'); + int32_t colon_pos3 = find_s_char(line, colon_pos2+1, ':'); if (colon_pos3 < line.size){ String filename = substr(line, 0, colon_pos1); @@ -140,18 +140,18 @@ parse_error(String line, Jump_Location *location, return(result); } -static int +static int32_t goto_error(Application_Links *app, Partition *part, - View_Summary *view, int line, + View_Summary *view, int32_t line, Jump_Location *location, - int skip_sub_errors){ + int32_t skip_sub_errors){ - int result = false; + int32_t result = false; String line_str = {0}; Buffer_Summary buffer = app->get_buffer(app, view->buffer_id, AccessAll); if (read_line(app, part, &buffer, line, &line_str)){ - int colon_char = 0; + int32_t colon_char = 0; if (parse_error(line_str, location, skip_sub_errors, &colon_char)){ result = true; } @@ -183,25 +183,25 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor){ // struct Prev_Jump{ - int buffer_id; - int line; + int32_t buffer_id; + int32_t line; }; static Prev_Jump null_location = {0}; static Prev_Jump prev_location = {0}; // TODO(allen): GIVE THESE THINGS NAMES I CAN FUCKING UNDERSTAND -static int +static int32_t next_error(Application_Links *app, Partition *part, - View_Summary *comp_out, int *start_line, + View_Summary *comp_out, int32_t *start_line, Jump_Location *location, - int skip_sub_errors, - int direction, - int *colon_char){ + int32_t skip_sub_errors, + int32_t direction, + int32_t *colon_char){ - int result = false; - int line = *start_line + direction; + int32_t result = false; + int32_t line = *start_line + direction; String line_str = {0}; Buffer_Summary buffer = app->get_buffer(app, comp_out->buffer_id, AccessAll); for (;;){ @@ -240,18 +240,18 @@ jump_location_store(Application_Links *app, Jump_Location loc){ return(result); } -static int +static int32_t seek_error_internal(Application_Links *app, Partition *part, - int skip_sub_errors, int dir, Jump_Location *loc){ - int result = false; + int32_t skip_sub_errors, int32_t dir, Jump_Location *loc){ + int32_t result = false; Jump_Location location = {0}; Buffer_Summary buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll); if (buffer.exists){ View_Summary view = get_first_view_with_buffer(app, buffer.buffer_id); - int line = view.cursor.line; + int32_t line = view.cursor.line; - int colon_char = 0; + int32_t colon_char = 0; if (next_error(app, part, &view, &line, &location, skip_sub_errors, dir, &colon_char)){ @@ -274,9 +274,9 @@ seek_error_internal(Application_Links *app, Partition *part, } -static int +static int32_t skip_this_jump(Prev_Jump prev, Prev_Jump jump){ - int result = false; + int32_t result = false; if (prev.buffer_id != 0 && prev.buffer_id == jump.buffer_id && prev.line == jump.line){ result = true; @@ -284,10 +284,10 @@ skip_this_jump(Prev_Jump prev, Prev_Jump jump){ return(result); } -static int +static int32_t seek_error_skip_repeats(Application_Links *app, Partition *part, - int skip_sub_error, int dir){ - int result = true; + int32_t skip_sub_error, int32_t dir){ + int32_t result = true; Jump_Location location = {0}; Prev_Jump jump = {0}; do{ @@ -306,10 +306,10 @@ seek_error_skip_repeats(Application_Links *app, Partition *part, return(result); } -static int +static int32_t seek_error_no_skip(Application_Links *app, Partition *part, - int skip_sub_error, int dir){ - int result = true; + int32_t skip_sub_error, int32_t dir){ + int32_t result = true; Jump_Location location = {0}; Prev_Jump jump = {0}; @@ -327,9 +327,9 @@ seek_error_no_skip(Application_Links *app, Partition *part, return(result); } -static int +static int32_t seek_error(Application_Links *app, Partition *part, - int skip_sub_error, int skip_same_line, int dir){ + int32_t skip_sub_error, int32_t skip_same_line, int32_t dir){ if (skip_same_line){ seek_error_skip_repeats(app, part, skip_sub_error, dir); } diff --git a/4coder_keycodes.h b/4coder_keycodes.h index 4a947483..484b40d7 100644 --- a/4coder_keycodes.h +++ b/4coder_keycodes.h @@ -31,7 +31,7 @@ key_f15 = 141, key_f16 = 142, }; static char* -global_key_name(int key_code, int *size){ +global_key_name(int32_t key_code, int32_t *size){ char *result = 0; switch(key_code){ case key_back: result = "back"; *size = sizeof("back")-1; break; diff --git a/4coder_mem.h b/4coder_mem.h index 2d481a0d..35f98b3c 100644 --- a/4coder_mem.h +++ b/4coder_mem.h @@ -4,16 +4,16 @@ struct Partition{ char *base; - int pos, max; + int32_t pos, max; }; struct Temp_Memory{ void *handle; - int pos; + int32_t pos; }; inline Partition -make_part(void *memory, int size){ +make_part(void *memory, int32_t size){ Partition partition; partition.base = (char*)memory; partition.pos = 0; @@ -22,7 +22,7 @@ make_part(void *memory, int size){ } inline void* -partition_allocate(Partition *data, int size){ +partition_allocate(Partition *data, int32_t size){ void *ret = 0; if (size > 0 && data->pos + size <= data->max){ ret = data->base + data->pos; @@ -32,7 +32,7 @@ partition_allocate(Partition *data, int size){ } inline void -partition_align(Partition *data, unsigned int boundary){ +partition_align(Partition *data, uint32_t boundary){ --boundary; data->pos = (data->pos + boundary) & (~boundary); } @@ -42,13 +42,13 @@ partition_current(Partition *data){ return data->base + data->pos; } -inline int +inline int32_t partition_remaining(Partition *data){ return data->max - data->pos; } inline Partition -partition_sub_part(Partition *data, int size){ +partition_sub_part(Partition *data, int32_t size){ Partition result = {}; void *d = partition_allocate(data, size); if (d) result = make_part(d, size); diff --git a/4coder_rect.h b/4coder_rect.h index 9ca23027..fd0f0de3 100644 --- a/4coder_rect.h +++ b/4coder_rect.h @@ -78,36 +78,36 @@ f32XYWH(float x, float y, float w, float h){ return(rect); } -inline int +inline int32_t rect_equal(i32_Rect r1, i32_Rect r2){ - int result = (r1.x0 == r2.x0 && - r1.y0 == r2.y0 && - r1.x1 == r2.x1 && - r1.y1 == r2.y1); + int32_t result = (r1.x0 == r2.x0 && + r1.y0 == r2.y0 && + r1.x1 == r2.x1 && + r1.y1 == r2.y1); return(result); } -inline int +inline int32_t hit_check(int32_t x, int32_t y, int32_t x0, int32_t y0, int32_t x1, int32_t y1){ return (x >= x0 && x < x1 && y >= y0 && y < y1); } -inline int +inline int32_t hit_check(int32_t x, int32_t y, i32_Rect rect){ return (hit_check(x, y, rect.x0, rect.y0, rect.x1, rect.y1)); } -inline int +inline int32_t hit_check(int32_t x, int32_t y, float x0, float y0, float x1, float y1){ return (x >= x0 && x < x1 && y >= y0 && y < y1); } -inline int +inline int32_t hit_check(int32_t x, int32_t y, f32_Rect rect){ return (hit_check(x, y, rect.x0, rect.y0, rect.x1, rect.y1)); } -inline int +inline int32_t positive_area(i32_Rect rect){ return (rect.x0 < rect.x1 && rect.y0 < rect.y1); } @@ -122,7 +122,7 @@ get_inner_rect(i32_Rect outer, int32_t margin){ return r; } -inline int +inline int32_t fits_inside(i32_Rect rect, i32_Rect outer){ return (rect.x0 >= outer.x0 && rect.x1 <= outer.x1 && rect.y0 >= outer.y0 && rect.y1 <= outer.y1); diff --git a/4coder_search.cpp b/4coder_search.cpp index 743fe61b..24496893 100644 --- a/4coder_search.cpp +++ b/4coder_search.cpp @@ -17,39 +17,39 @@ enum Search_Range_Flag{ }; struct Search_Range{ - int type; - unsigned int flags; - int buffer; - int start; - int size; - int mid_start; - int mid_size; + int32_t type; + uint32_t flags; + int32_t buffer; + int32_t start; + int32_t size; + int32_t mid_start; + int32_t mid_size; }; struct Search_Set{ Search_Range *ranges; - int count; - int max; + int32_t count; + int32_t max; }; struct Search_Iter{ String word; - int pos; - int back_pos; - int i; - int range_initialized; + int32_t pos; + int32_t back_pos; + int32_t i; + int32_t range_initialized; }; struct Search_Match{ Buffer_Summary buffer; - int start; - int end; - int found_match; + int32_t start; + int32_t end; + int32_t found_match; }; static void -search_iter_init(General_Memory *general, Search_Iter *iter, int size){ - int str_max = size*2; +search_iter_init(General_Memory *general, Search_Iter *iter, int32_t size){ + int32_t str_max = size*2; if (iter->word.str == 0){ iter->word.str = (char*)general_memory_allocate(general, str_max); iter->word.memory_size = str_max; @@ -63,8 +63,8 @@ search_iter_init(General_Memory *general, Search_Iter *iter, int size){ } static void -search_set_init(General_Memory *general, Search_Set *set, int range_count){ - int max = range_count*2; +search_set_init(General_Memory *general, Search_Set *set, int32_t range_count){ + int32_t max = range_count*2; if (set->ranges == 0){ set->ranges = (Search_Range*)general_memory_allocate(general, sizeof(Search_Range)*max); @@ -80,9 +80,9 @@ search_set_init(General_Memory *general, Search_Set *set, int range_count){ } static void -search_hits_table_alloc(General_Memory *general, Table *hits, int table_size){ +search_hits_table_alloc(General_Memory *general, Table *hits, int32_t table_size){ void *mem = 0; - int mem_size = table_required_mem_size(table_size, sizeof(Offset_String)); + int32_t mem_size = table_required_mem_size(table_size, sizeof(Offset_String)); if (hits->hash_array == 0){ mem = general_memory_allocate(general, mem_size); } @@ -93,12 +93,12 @@ search_hits_table_alloc(General_Memory *general, Table *hits, int table_size){ } static void -search_hits_init(General_Memory *general, Table *hits, String_Space *str, int table_size, int str_size){ +search_hits_init(General_Memory *general, Table *hits, String_Space *str, int32_t table_size, int32_t str_size){ if (hits->hash_array == 0){ search_hits_table_alloc(general, hits, table_size); } else{ - int mem_size = table_required_mem_size(table_size, sizeof(Offset_String)); + int32_t mem_size = table_required_mem_size(table_size, sizeof(Offset_String)); void *mem = general_memory_reallocate_nocopy(general, hits->hash_array, mem_size); table_init_memory(hits, mem, table_size, sizeof(Offset_String)); } @@ -116,15 +116,15 @@ search_hits_init(General_Memory *general, Table *hits, String_Space *str, int ta table_clear(hits); } -static int -search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *str, int len){ - int result = false; +static int32_t +search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *str, int32_t len){ + int32_t result = false; assert(len != 0); Offset_String ostring = strspace_append(space, str, len); if (ostring.size == 0){ - int new_size = space->max*2; + int32_t new_size = space->max*2; if (new_size < space->max + len){ new_size = space->max + len; } @@ -155,12 +155,12 @@ search_hit_add(General_Memory *general, Table *hits, String_Space *space, char * return(result); } -static int -buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, int pos){ +static int32_t +buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ char space[1024]; Stream_Chunk chunk = {0}; if (init_stream_chunk(&chunk, app, buffer, pos, space, sizeof(space))){ - int still_looping = true; + int32_t still_looping = true; do{ for (; pos < chunk.end; ++pos){ char at_pos = chunk.data[pos]; @@ -187,14 +187,14 @@ enum{ FindResult_PastEnd }; -static int -match_check(Application_Links *app, Search_Range *range, int *pos, Search_Match *result_ptr, String word){ - int found_match = FindResult_None; +static int32_t +match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Match *result_ptr, String word){ + int32_t found_match = FindResult_None; Search_Match result = *result_ptr; - int end_pos = range->start + range->size; + int32_t end_pos = range->start + range->size; - int type = (range->flags & SearchFlag_MatchMask); + int32_t type = (range->flags & SearchFlag_MatchMask); switch (type){ case SearchFlag_MatchWholeWord: @@ -263,24 +263,24 @@ match_check(Application_Links *app, Search_Range *range, int *pos, Search_Match return(found_match); } -static int +static int32_t search_front_to_back_step(Application_Links *app, Search_Range *range, String word, - int *pos, + int32_t *pos, Search_Match *result_ptr){ - int found_match = FindResult_None; + int32_t found_match = FindResult_None; Search_Match result = *result_ptr; - int end_pos = range->start + range->size; + int32_t end_pos = range->start + range->size; if (*pos + word.size < end_pos){ - int start_pos = *pos; + int32_t start_pos = *pos; if (start_pos < range->start){ start_pos = range->start; } - int case_insensitive = (range->flags & SearchFlag_CaseInsensitive); + int32_t case_insensitive = (range->flags & SearchFlag_CaseInsensitive); result.buffer = app->get_buffer(app, range->buffer, AccessAll); if (case_insensitive){ @@ -318,31 +318,31 @@ search_front_to_back_step(Application_Links *app, return(found_match); } -static int +static int32_t search_front_to_back(Application_Links *app, Search_Range *range, String word, - int *pos, + int32_t *pos, Search_Match *result_ptr){ - int found_match = FindResult_None; + int32_t found_match = FindResult_None; for (;found_match == FindResult_None;){ found_match = search_front_to_back_step(app, range, word, pos, result_ptr); } return(found_match); } -static int +static int32_t search_back_to_front_step(Application_Links *app, Search_Range *range, String word, - int *pos, + int32_t *pos, Search_Match *result_ptr){ - int found_match = FindResult_None; + int32_t found_match = FindResult_None; Search_Match result = *result_ptr; if (*pos > range->start){ - int start_pos = *pos; + int32_t start_pos = *pos; result.buffer = app->get_buffer(app, range->buffer, AccessAll); buffer_seek_string_backward(app, &result.buffer, @@ -371,13 +371,13 @@ search_back_to_front_step(Application_Links *app, return(found_match); } -static int +static int32_t search_back_to_front(Application_Links *app, Search_Range *range, String word, - int *pos, + int32_t *pos, Search_Match *result_ptr){ - int found_match = FindResult_None; + int32_t found_match = FindResult_None; for (;found_match == FindResult_None;){ found_match = search_back_to_front_step(app, range, word, pos, result_ptr); } @@ -389,11 +389,11 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){ Search_Match result = {0}; Search_Iter iter = *it_ptr; - int count = set->count; + int32_t count = set->count; for (; iter.i < count;){ Search_Range *range = set->ranges + iter.i; - int find_result = FindResult_None; + int32_t find_result = FindResult_None; if (!iter.range_initialized){ iter.range_initialized = true; @@ -435,8 +435,8 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){ Search_Match forward_match = {0}; Search_Match backward_match = {0}; - int forward_result = FindResult_PastEnd; - int backward_result = FindResult_PastEnd; + int32_t forward_result = FindResult_PastEnd; + int32_t backward_result = FindResult_PastEnd; if (iter.pos < range->start + range->size){ forward_result = search_front_to_back(app, range, @@ -456,9 +456,9 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){ if (backward_result == FindResult_FoundMatch){ find_result = FindResult_FoundMatch; - int forward_start = range->mid_start + range->mid_size; - int forward_distance = (forward_match.start - forward_start); - int backward_distance = (range->mid_start - backward_match.end); + int32_t forward_start = range->mid_start + range->mid_size; + int32_t forward_distance = (forward_match.start - forward_start); + int32_t backward_distance = (range->mid_start - backward_match.end); if (backward_distance < forward_distance){ iter.pos = forward_match.start; diff --git a/4coder_string.h b/4coder_string.h index c232dd80..8d8ecbcc 100644 --- a/4coder_string.h +++ b/4coder_string.h @@ -532,7 +532,7 @@ FSTRING_LINK String skip_whitespace(String str) { String result = {0}; - int i = 0; + int32_t i = 0; for (; i < str.size && char_is_whitespace(str.str[i]); ++i); result = substr(str, i, str.size - i); return(result); @@ -544,7 +544,7 @@ FSTRING_LINK String chop_whitespace(String str) { String result = {0}; - int i = str.size; + int32_t i = str.size; for (; i > 0 && char_is_whitespace(str.str[i-1]); --i); result = substr(str, 0, i); return(result); @@ -1729,13 +1729,13 @@ hexstr_to_color(String s, uint32_t *out){ uint32_t color = 0; if (s.size == 6){ result = 1; - color = (unsigned int)hexstr_to_int(s); + color = (uint32_t)hexstr_to_int(s); color |= (0xFF << 24); *out = color; } else if (s.size == 8){ result = 1; - color = (unsigned int)hexstr_to_int(s); + color = (uint32_t)hexstr_to_int(s); *out = color; } return(result); diff --git a/4coder_types.h b/4coder_types.h index 49c34180..a3883934 100644 --- a/4coder_types.h +++ b/4coder_types.h @@ -395,9 +395,9 @@ struct Mouse_State{ /* DOC(This field indicates that the mouse is outside of the window.) */ char out_of_window; /* DOC(This field contains the x position of the mouse relative to the window where the left side is 0.) */ - int x; + int32_t x; /* DOC(This field contains the y position of the mouse relative to the window where the top side is 0.) */ - int y; + int32_t y; }; /* DOC( @@ -411,15 +411,15 @@ Throughout the API ranges are thought of in the form [min,max) where max is union Range{ struct{ /* DOC(This is the smaller value in the range, it is also the 'start'.) */ - int min; + int32_t min; /* DOC(This is the larger value in the range, it is also the 'end'.) */ - int max; + int32_t max; }; struct{ /* DOC(This is the start of the range, it is also the 'min'.) */ - int start; + int32_t start; /* DOC(This is the end of the range, it is also the 'max'.) */ - int end; + int32_t end; }; }; @@ -432,10 +432,10 @@ struct File_Info{ char *filename; /* DOC(This field specifies the length of the filename string not counting the null terminator.) */ - int filename_len; + int32_t filename_len; /* DOC(This field indicates that the description is for a folder not a file.) */ - int folder; + int32_t folder; }; /* DOC(File_List is a list of File_Info structs.) */ @@ -445,9 +445,9 @@ struct File_List{ /* DOC(This field is an array of File_Info structs.) */ File_Info *infos; /* DOC(This field specifies the number of struts in the info array.) */ - int count; + int32_t count; /* DOC(This field is for internal use.) */ - int block_size; + int32_t block_size; }; /* DOC( @@ -462,10 +462,10 @@ struct Buffer_Identifier{ char *name; /* DOC(This field specifies the length of the name string.) */ - int name_len; + int32_t name_len; /* DOC(This field is the id of the buffer. If name is specified this should be 0.) */ - int id; + int32_t id; }; /* DOC(This struct is a part of an incomplete feature.) */ @@ -692,7 +692,7 @@ struct Query_Bar{ /* DOC(This feature is not implemented.) */ struct Event_Message{ /* DOC(This feature is not implemented.) */ - int type; + int32_t type; }; /* diff --git a/4cpp_lexer.h b/4cpp_lexer.h index 2bc6cbda..784f0ac9 100644 --- a/4cpp_lexer.h +++ b/4cpp_lexer.h @@ -12,27 +12,28 @@ #include "4cpp_lexer_fsms.h" #include "4cpp_lexer_tables.c" -#define lexer_link static - // TODO(allen): revisit this keyword data declaration system +struct String_And_Flag{ + char *str; + uint32_t flags; +}; + struct String_List{ String_And_Flag *data; - int count; + int32_t count; }; struct Sub_Match_List_Result{ - int index; + int32_t index; int32_t new_pos; }; -#define lexer_string_list(x) {x, (sizeof(x)/sizeof(*x))} - -static String_And_Flag bool_lit_strings[] = { - {"true"}, {"false"} -}; -static String_List bool_lits = lexer_string_list(bool_lit_strings); +#define lexer_string_list(x) {x, (sizeof(x)/sizeof(*(x)))} static String_And_Flag keyword_strings[] = { + {"true", CPP_TOKEN_BOOLEAN_CONSTANT}, + {"false", CPP_TOKEN_BOOLEAN_CONSTANT}, + {"and", CPP_TOKEN_AND}, {"and_eq", CPP_TOKEN_ANDEQ}, {"bitand", CPP_TOKEN_BIT_AND}, @@ -120,12 +121,12 @@ static String_And_Flag keyword_strings[] = { }; static String_List keywords = lexer_string_list(keyword_strings); -lexer_link Sub_Match_List_Result -sub_match_list(char *chunk, int size, int pos, String_List list, int sub_size){ +FCPP_LINK Sub_Match_List_Result +sub_match_list(char *chunk, int32_t size, int32_t pos, String_List list, int32_t sub_size){ Sub_Match_List_Result result; String str_main; char *str_check; - int i,l; + int32_t i,l; result.index = -1; result.new_pos = pos; @@ -155,15 +156,15 @@ sub_match_list(char *chunk, int size, int pos, String_List list, int sub_size){ } -lexer_link Cpp_Get_Token_Result -cpp_get_token(Cpp_Token_Stack *token_stack, int pos){ +FCPP_LINK Cpp_Get_Token_Result +cpp_get_token(Cpp_Token_Stack *token_stack, int32_t pos){ Cpp_Get_Token_Result result = {}; Cpp_Token *token_array = token_stack->tokens; Cpp_Token *token = 0; - int first = 0; - int count = token_stack->count; - int last = count; - int this_start = 0, next_start = 0; + int32_t first = 0; + int32_t count = token_stack->count; + int32_t last = count; + int32_t this_start = 0, next_start = 0; if (count > 0){ for (;;){ @@ -211,10 +212,10 @@ cpp_get_token(Cpp_Token_Stack *token_stack, int pos){ return(result); } -lexer_link void -cpp_shift_token_starts(Cpp_Token_Stack *stack, int from_token_i, int shift_amount){ +FCPP_LINK void +cpp_shift_token_starts(Cpp_Token_Stack *stack, int32_t from_token_i, int32_t shift_amount){ Cpp_Token *token = stack->tokens + from_token_i; - int count = stack->count, i; + int32_t count = stack->count, i; for (i = from_token_i; i < count; ++i, ++token){ token->start += shift_amount; @@ -226,7 +227,7 @@ enum Pos_Update_Rule{ PUR_back_one, }; -lexer_link Lex_PP_State +FCPP_LINK Lex_PP_State cpp_pp_directive_to_state(Cpp_Token_Type type){ Lex_PP_State result = LSPP_default; switch (type){ @@ -272,7 +273,7 @@ cpp_pp_directive_to_state(Cpp_Token_Type type){ return(result); } -lexer_link Cpp_Token_Merge +FCPP_LINK Cpp_Token_Merge cpp_attempt_token_merge(Cpp_Token prev_token, Cpp_Token next_token){ Cpp_Token_Merge result = {(Cpp_Token_Type)0}; if (next_token.type == CPP_TOKEN_COMMENT && prev_token.type == CPP_TOKEN_COMMENT && @@ -290,8 +291,8 @@ cpp_attempt_token_merge(Cpp_Token prev_token, Cpp_Token next_token){ return result; } -lexer_link int -cpp_place_token_nonalloc(Cpp_Token *out_tokens, int token_i, Cpp_Token token){ +FCPP_LINK int32_t +cpp_place_token_nonalloc(Cpp_Token *out_tokens, int32_t token_i, Cpp_Token token){ Cpp_Token_Merge merge = {(Cpp_Token_Type)0}; Cpp_Token prev_token = {(Cpp_Token_Type)0}; @@ -310,7 +311,7 @@ cpp_place_token_nonalloc(Cpp_Token *out_tokens, int token_i, Cpp_Token token){ return(token_i); } -lexer_link bool +FCPP_LINK bool cpp_push_token_nonalloc(Cpp_Token_Stack *out_tokens, Cpp_Token token){ bool result = 0; if (out_tokens->count == out_tokens->max_count){ @@ -323,12 +324,12 @@ cpp_push_token_nonalloc(Cpp_Token_Stack *out_tokens, Cpp_Token token){ struct Lex_Data{ char *tb; - int tb_pos; - int token_start; + int32_t tb_pos; + int32_t token_start; - int pos; - int pos_overide; - int chunk_pos; + int32_t pos; + int32_t pos_overide; + int32_t chunk_pos; Lex_FSM fsm; Whitespace_FSM wfsm; @@ -337,9 +338,10 @@ struct Lex_Data{ Cpp_Token token; - int __pc__; + int32_t __pc__; }; -inline Lex_Data + +FCPP_LINK Lex_Data lex_data_init(char *tb){ Lex_Data data = {0}; data.tb = tb; @@ -364,21 +366,21 @@ enum Lex_Result{ LexHitTokenLimit }; -lexer_link int +FCPP_LINK int32_t cpp_lex_nonalloc(Lex_Data *S_ptr, - char *chunk, int size, + char *chunk, int32_t size, Cpp_Token_Stack *token_stack_out){ Lex_Data S = *S_ptr; Cpp_Token *out_tokens = token_stack_out->tokens; - int token_i = token_stack_out->count; - int max_token_i = token_stack_out->max_count; + int32_t token_i = token_stack_out->count; + int32_t max_token_i = token_stack_out->max_count; Pos_Update_Rule pos_update_rule = PUR_none; char c = 0; - int end_pos = size + S.chunk_pos; + int32_t end_pos = size + S.chunk_pos; chunk -= S.chunk_pos; switch (S.__pc__){ @@ -397,7 +399,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, for(;;){ for (; S.wfsm.pp_state < LSPP_count && S.pos < end_pos;){ c = chunk[S.pos++]; - int i = S.wfsm.pp_state + whitespace_fsm_eq_classes[c]; + int32_t i = S.wfsm.pp_state + whitespace_fsm_eq_classes[c]; S.wfsm.pp_state = whitespace_fsm_table[i]; } S.wfsm.white_done = (S.wfsm.pp_state >= LSPP_count); @@ -428,7 +430,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, c = chunk[S.pos++]; S.tb[S.tb_pos++] = c; - int i = S.fsm.state + eq_classes[c]; + int32_t i = S.fsm.state + eq_classes[c]; S.fsm.state = fsm_table[i]; S.fsm.multi_line |= multiline_state_table[S.fsm.state]; } @@ -531,7 +533,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, { --S.pos; - int word_size = S.pos - S.token_start; + int32_t word_size = S.pos - S.token_start; if (S.pp_state == LSPP_body_if){ if (match_ss(make_string(S.tb, word_size), make_lit_string("defined"))){ @@ -542,24 +544,16 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, } Sub_Match_List_Result sub_match; - sub_match = sub_match_list(S.tb, S.tb_pos, 0, bool_lits, word_size); + sub_match = sub_match_list(S.tb, S.tb_pos, 0, keywords, word_size); if (sub_match.index != -1){ - S.token.type = CPP_TOKEN_BOOLEAN_CONSTANT; + String_And_Flag data = keywords.data[sub_match.index]; + S.token.type = (Cpp_Token_Type)data.flags; S.token.flags = CPP_TFLAG_IS_KEYWORD; } else{ - sub_match = sub_match_list(S.tb, S.tb_pos, 0, keywords, word_size); - - if (sub_match.index != -1){ - String_And_Flag data = keywords.data[sub_match.index]; - S.token.type = (Cpp_Token_Type)data.flags; - S.token.flags = CPP_TFLAG_IS_KEYWORD; - } - else{ - S.token.type = CPP_TOKEN_IDENTIFIER; - S.token.flags = 0; - } + S.token.type = CPP_TOKEN_IDENTIFIER; + S.token.flags = 0; } }break; @@ -992,16 +986,16 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, #undef DrReturn #undef DrCase -lexer_link int +FCPP_LINK int32_t cpp_lex_nonalloc(Lex_Data *S_ptr, - char *chunk, int size, - Cpp_Token_Stack *token_stack_out, int max_tokens){ + char *chunk, int32_t size, + Cpp_Token_Stack *token_stack_out, int32_t max_tokens){ Cpp_Token_Stack temp_stack = *token_stack_out; if (temp_stack.max_count > temp_stack.count + max_tokens){ temp_stack.max_count = temp_stack.count + max_tokens; } - int result = cpp_lex_nonalloc(S_ptr, chunk, size, &temp_stack); + int32_t result = cpp_lex_nonalloc(S_ptr, chunk, size, &temp_stack); token_stack_out->count = temp_stack.count; @@ -1014,11 +1008,11 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, return(result); } -lexer_link int +FCPP_LINK int32_t cpp_lex_size_nonalloc(Lex_Data *S_ptr, - char *chunk, int size, int full_size, + char *chunk, int32_t size, int32_t full_size, Cpp_Token_Stack *token_stack_out){ - int result = 0; + int32_t result = 0; if (S_ptr->pos >= full_size){ char end_null = 0; result = cpp_lex_nonalloc(S_ptr, &end_null, 1, token_stack_out); @@ -1035,17 +1029,17 @@ cpp_lex_size_nonalloc(Lex_Data *S_ptr, return(result); } -lexer_link int +FCPP_LINK int32_t cpp_lex_size_nonalloc(Lex_Data *S_ptr, - char *chunk, int size, int full_size, - Cpp_Token_Stack *token_stack_out, int max_tokens){ + char *chunk, int32_t size, int32_t full_size, + Cpp_Token_Stack *token_stack_out, int32_t max_tokens){ Cpp_Token_Stack temp_stack = *token_stack_out; if (temp_stack.max_count > temp_stack.count + max_tokens){ temp_stack.max_count = temp_stack.count + max_tokens; } - int result = cpp_lex_size_nonalloc(S_ptr, chunk, size, full_size, - &temp_stack); + int32_t result = cpp_lex_size_nonalloc(S_ptr, chunk, size, full_size, + &temp_stack); token_stack_out->count = temp_stack.count; @@ -1058,9 +1052,9 @@ cpp_lex_size_nonalloc(Lex_Data *S_ptr, return(result); } -lexer_link Cpp_Relex_State -cpp_relex_nonalloc_start(char *data, int size, Cpp_Token_Stack *stack, - int start, int end, int amount, int tolerance){ +FCPP_LINK Cpp_Relex_State +cpp_relex_nonalloc_start(char *data, int32_t size, Cpp_Token_Stack *stack, + int32_t start, int32_t end, int32_t amount, int32_t tolerance){ Cpp_Relex_State state; state.data = data; state.size = size; @@ -1097,15 +1091,15 @@ cpp_relex_nonalloc_start(char *data, int size, Cpp_Token_Stack *stack, return(state); } -inline char +FCPP_LINK char cpp_token_get_pp_state(uint16_t bitfield){ return (char)(bitfield); } // TODO(allen): Eliminate this once we actually store the EOF token // in the token stack. -inline Cpp_Token -cpp__get_token(Cpp_Token_Stack *stack, Cpp_Token *tokens, int size, int index){ +FCPP_LINK Cpp_Token +cpp__get_token(Cpp_Token_Stack *stack, Cpp_Token *tokens, int32_t size, int32_t index){ Cpp_Token result; if (index < stack->count){ result = tokens[index]; @@ -1120,10 +1114,10 @@ cpp__get_token(Cpp_Token_Stack *stack, Cpp_Token *tokens, int size, int index){ return result; } -FCPP_LINK int +FCPP_LINK int32_t cpp_relex_nonalloc_main(Cpp_Relex_State *state, Cpp_Token_Stack *relex_stack, - int *relex_end, + int32_t *relex_end, char *spare){ Cpp_Token_Stack *stack = state->stack; Cpp_Token *tokens = stack->tokens; @@ -1134,14 +1128,14 @@ cpp_relex_nonalloc_main(Cpp_Relex_State *state, lex.pp_state = cpp_token_get_pp_state(tokens[state->start_token_i].state_flags); lex.pos = state->relex_start; - int relex_end_i = state->end_token_i; + int32_t relex_end_i = state->end_token_i; Cpp_Token match_token = cpp__get_token(stack, tokens, state->size, relex_end_i); Cpp_Token end_token = match_token; - int went_too_far = false; + int32_t went_too_far = false; // TODO(allen): This can be better I suspect. for (;;){ - int result = + int32_t result = cpp_lex_size_nonalloc(&lex, state->data, state->size, @@ -1217,7 +1211,7 @@ cpp_relex_nonalloc_main(Cpp_Relex_State *state, #include FCPP_LINK Cpp_Token_Stack -cpp_make_token_stack(int starting_max){ +cpp_make_token_stack(int32_t starting_max){ Cpp_Token_Stack token_stack; token_stack.count = 0; token_stack.max_count = starting_max; @@ -1231,7 +1225,7 @@ cpp_free_token_stack(Cpp_Token_Stack token_stack){ } FCPP_LINK void -cpp_resize_token_stack(Cpp_Token_Stack *token_stack, int new_max){ +cpp_resize_token_stack(Cpp_Token_Stack *token_stack, int32_t new_max){ Cpp_Token *new_tokens = (Cpp_Token*)malloc(sizeof(Cpp_Token)*new_max); if (new_tokens){ @@ -1245,21 +1239,21 @@ cpp_resize_token_stack(Cpp_Token_Stack *token_stack, int new_max){ FCPP_LINK void cpp_push_token(Cpp_Token_Stack *token_stack, Cpp_Token token){ if (!cpp_push_token_nonalloc(token_stack, token)){ - int new_max = 2*token_stack->max_count + 1; + int32_t new_max = 2*token_stack->max_count + 1; cpp_resize_token_stack(token_stack, new_max); cpp_push_token_nonalloc(token_stack, token); } } FCPP_LINK void -cpp_lex_file(char *data, int size, Cpp_Token_Stack *token_stack_out){ +cpp_lex_file(char *data, int32_t size, Cpp_Token_Stack *token_stack_out){ Lex_Data S = {0}; S.tb = (char*)malloc(size); - int quit = 0; + int32_t quit = 0; token_stack_out->count = 0; for (;!quit;){ - int result = cpp_lex_nonalloc(&S, data, size, token_stack_out); + int32_t result = cpp_lex_nonalloc(&S, data, size, token_stack_out); switch (result){ case LexFinished: { @@ -1275,7 +1269,7 @@ cpp_lex_file(char *data, int size, Cpp_Token_Stack *token_stack_out){ case LexNeedTokenMemory: { - int new_max = 2*token_stack_out->max_count + 1; + int32_t new_max = 2*token_stack_out->max_count + 1; cpp_resize_token_stack(token_stack_out, new_max); }break; } diff --git a/4cpp_lexer_fsms.h b/4cpp_lexer_fsms.h index 698b1f5d..e4ea2d0b 100644 --- a/4cpp_lexer_fsms.h +++ b/4cpp_lexer_fsms.h @@ -1,38 +1,14 @@ /* - * FSMs for 4c++ lexer + * FSMs for 4cpp lexer * * 23.03.2016 (dd.mm.yyyy) - - - - - - - - - - - - - - - - - - - - - - - + * */ // TOP -struct String_And_Flag{ - char *str; - unsigned int flags; -}; +#if !defined(FCPP_LEXER_FSMS_H) +#define FCPP_LEXER_FSMS_H enum Lex_State{ LS_default, @@ -113,19 +89,19 @@ enum Lex_PP_State{ }; struct Whitespace_FSM{ - unsigned char pp_state; - unsigned char white_done; + uint8_t pp_state; + uint8_t white_done; }; struct Lex_FSM{ - unsigned char state; + uint8_t state; union{ - unsigned char int_state; - unsigned char directive_state; - unsigned char sub_machine; + uint8_t int_state; + uint8_t directive_state; + uint8_t sub_machine; }; - unsigned char emit_token; - unsigned char multi_line; + uint8_t emit_token; + uint8_t multi_line; }; inline Lex_FSM zero_lex_fsm(){ @@ -133,6 +109,8 @@ zero_lex_fsm(){ return(fsm); } +#endif + // BOTTOM diff --git a/4cpp_lexer_tables.c b/4cpp_lexer_tables.c index 24f15227..e178ae8a 100644 --- a/4cpp_lexer_tables.c +++ b/4cpp_lexer_tables.c @@ -1,39 +1,39 @@ -unsigned short whitespace_fsm_eq_classes[] = { +uint16_t whitespace_fsm_eq_classes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,18, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const int num_whitespace_fsm_eq_classes = 3; +const int32_t num_whitespace_fsm_eq_classes = 3; -unsigned char whitespace_fsm_table[] = { +uint8_t whitespace_fsm_table[] = { 9,10,11,12,13,14,15,16,17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -unsigned short int_fsm_eq_classes[] = { +uint16_t int_fsm_eq_classes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0, 0, 0, 0, 0, 0,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const int num_int_fsm_eq_classes = 4; +const int32_t num_int_fsm_eq_classes = 4; -unsigned char int_fsm_table[] = { +uint8_t int_fsm_table[] = { 8, 9,10,11,12,13,14,15, 3, 5,10, 6,12, 7,14,15, 1, 9, 7, 7,12,13, 7,15, 2, 4, 6,11, 7,13,14,15, }; -unsigned char multiline_state_table[] = { +uint8_t multiline_state_table[] = { 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -unsigned short main_fsm_eq_classes[] = { +uint16_t main_fsm_eq_classes[] = { 0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39, }; -const int num_main_fsm_eq_classes = 29; +const int32_t num_main_fsm_eq_classes = 29; -unsigned char main_fsm_table[] = { +uint8_t main_fsm_table[] = { 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77, 0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, 0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, @@ -65,13 +65,13 @@ unsigned char main_fsm_table[] = { 30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, }; -unsigned short pp_include_fsm_eq_classes[] = { +uint16_t pp_include_fsm_eq_classes[] = { 0,39,39,39,39,39,39,39,39,39,78,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,39,195,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39, }; -const int num_pp_include_fsm_eq_classes = 6; +const int32_t num_pp_include_fsm_eq_classes = 6; -unsigned char pp_include_fsm_table[] = { +uint8_t pp_include_fsm_table[] = { 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38, 3,42,42,42, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38, @@ -80,13 +80,13 @@ unsigned char pp_include_fsm_table[] = { 3, 1,41, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38, }; -unsigned short pp_macro_fsm_eq_classes[] = { +uint16_t pp_macro_fsm_eq_classes[] = { 0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39, }; -const int num_pp_macro_fsm_eq_classes = 29; +const int32_t num_pp_macro_fsm_eq_classes = 29; -unsigned char pp_macro_fsm_table[] = { +uint8_t pp_macro_fsm_table[] = { 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77, 0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, 0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, @@ -118,13 +118,13 @@ unsigned char pp_macro_fsm_table[] = { 30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, }; -unsigned short pp_identifier_fsm_eq_classes[] = { +uint16_t pp_identifier_fsm_eq_classes[] = { 0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39, }; -const int num_pp_identifier_fsm_eq_classes = 29; +const int32_t num_pp_identifier_fsm_eq_classes = 29; -unsigned char pp_identifier_fsm_table[] = { +uint8_t pp_identifier_fsm_table[] = { 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77, 0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, 0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, @@ -156,13 +156,13 @@ unsigned char pp_identifier_fsm_table[] = { 30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, }; -unsigned short pp_body_if_fsm_eq_classes[] = { +uint16_t pp_body_if_fsm_eq_classes[] = { 0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39, }; -const int num_pp_body_if_fsm_eq_classes = 29; +const int32_t num_pp_body_if_fsm_eq_classes = 29; -unsigned char pp_body_if_fsm_table[] = { +uint8_t pp_body_if_fsm_table[] = { 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77, 0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, 0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, @@ -194,13 +194,13 @@ unsigned char pp_body_if_fsm_table[] = { 30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, }; -unsigned short pp_body_fsm_eq_classes[] = { +uint16_t pp_body_fsm_eq_classes[] = { 0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39, }; -const int num_pp_body_fsm_eq_classes = 29; +const int32_t num_pp_body_fsm_eq_classes = 29; -unsigned char pp_body_fsm_table[] = { +uint8_t pp_body_fsm_table[] = { 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77, 0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, 0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, @@ -232,13 +232,13 @@ unsigned char pp_body_fsm_table[] = { 30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, }; -unsigned short pp_number_fsm_eq_classes[] = { +uint16_t pp_number_fsm_eq_classes[] = { 0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39, }; -const int num_pp_number_fsm_eq_classes = 29; +const int32_t num_pp_number_fsm_eq_classes = 29; -unsigned char pp_number_fsm_table[] = { +uint8_t pp_number_fsm_table[] = { 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77, 0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, 0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, @@ -270,25 +270,25 @@ unsigned char pp_number_fsm_table[] = { 30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, }; -unsigned short pp_error_fsm_eq_classes[] = { +uint16_t pp_error_fsm_eq_classes[] = { 0,39,39,39,39,39,39,39,39,39,78,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39, }; -const int num_pp_error_fsm_eq_classes = 3; +const int32_t num_pp_error_fsm_eq_classes = 3; -unsigned char pp_error_fsm_table[] = { +uint8_t pp_error_fsm_table[] = { 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77, 38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38, 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, }; -unsigned short pp_junk_fsm_eq_classes[] = { +uint16_t pp_junk_fsm_eq_classes[] = { 0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39, }; -const int num_pp_junk_fsm_eq_classes = 29; +const int32_t num_pp_junk_fsm_eq_classes = 29; -unsigned char pp_junk_fsm_table[] = { +uint8_t pp_junk_fsm_table[] = { 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77, 0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, 0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, @@ -320,7 +320,7 @@ unsigned char pp_junk_fsm_table[] = { 30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38, }; -unsigned short * get_eq_classes[] = { +uint16_t * get_eq_classes[] = { main_fsm_eq_classes, pp_include_fsm_eq_classes, pp_macro_fsm_eq_classes, @@ -332,7 +332,7 @@ pp_error_fsm_eq_classes, pp_junk_fsm_eq_classes, }; -unsigned char * get_table[] = { +uint8_t * get_table[] = { main_fsm_table, pp_include_fsm_table, pp_macro_fsm_table, @@ -344,13 +344,13 @@ pp_error_fsm_table, pp_junk_fsm_table, }; -unsigned short pp_directive_eq_classes[] = { +uint16_t pp_directive_eq_classes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0,119, 0,119,119,119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,238, 0,357,476,595,714,833, 0,952, 0, 0,1071,1190,1309,1428,1547, 0,1666,1785,1904,2023, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,2142, 0,2261,2380,2499,2618,2737, 0,2856, 0, 0,2975,3094,3213,3332,3451, 0,3570,3689,3808,3927, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const int num_pp_directive_eq_classes = 34; +const int32_t num_pp_directive_eq_classes = 34; -unsigned char pp_directive_table[] = { +uint8_t pp_directive_table[] = { 200,200,200,200,200,200,200,200,200,200,200,200,200,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,200,200,200,203,200,200,200,200,203,200,200,200,200,215,200,200,200,200,215,200,200,200,200,204,200,200,213,200,200,200,200,204,200,200,213,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,214,200,200,214, 0,200,200,200,200,200,200,200,200,200,200,200,200,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,200,200,200,203,200,200,200,200,203,200,200,200,200,215,200,200,200,200,215,200,200,200,200,204,200,200,213,200,200,200,200,204,200,200,213,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,214,200,200,214, 200,200,200,200,200,200,200,200,200,200,200,200,200,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,200,200,200,203,200,200,200,200,203,200,200,200,200,215,67,200,200,70,215,200,200,200,200,204,200,200,213,200,200,200,200,204,200,200,213,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,214,200,200,214, @@ -387,9 +387,9 @@ unsigned char pp_directive_table[] = { 7,200,200,200,200,200,200,200,200,200,200,200,200,200,205,200,200,18,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,200,200,200,203,200,200,200,200,203,200,200,200,200,215,200,200,200,200,215,200,200,200,200,204,200,200,213,200,200,200,200,204,200,200,213,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,214,200,200,214, }; -unsigned char LSDIR_default = 0; +uint8_t LSDIR_default = 0; -unsigned char LSDIR_count = 119; +uint8_t LSDIR_count = 119; -unsigned char pp_directive_terminal_base = 200; +uint8_t pp_directive_terminal_base = 200; diff --git a/4cpp_lexer_types.h b/4cpp_lexer_types.h index 89a431a7..2ef65fa8 100644 --- a/4cpp_lexer_types.h +++ b/4cpp_lexer_types.h @@ -172,9 +172,9 @@ enum Cpp_Token_Type{ struct Cpp_Token{ Cpp_Token_Type type; - int start, size; - unsigned short state_flags; - unsigned short flags; + int32_t start, size; + uint16_t state_flags; + uint16_t flags; }; enum Cpp_Token_Flag{ @@ -204,7 +204,7 @@ enum Cpp_Preprocessor_State{ struct Cpp_Token_Stack{ Cpp_Token *tokens; - int count, max_count; + int32_t count, max_count; }; inline Cpp_Token_Stack cpp_token_stack_zero(){ @@ -214,30 +214,30 @@ cpp_token_stack_zero(){ struct Cpp_Token_Merge{ Cpp_Token new_token; - int did_merge; + int32_t did_merge; }; struct Seek_Result{ - int pos; - int new_line; + int32_t pos; + int32_t new_line; }; struct Cpp_Get_Token_Result{ - int token_index; - int in_whitespace; + int32_t token_index; + int32_t in_whitespace; }; struct Cpp_Relex_State{ char *data; - int size; + int32_t size; Cpp_Token_Stack *stack; - int start, end, amount; - int start_token_i; - int end_token_i; - int relex_start; - int tolerance; - int space_request; + int32_t start, end, amount; + int32_t start_token_i; + int32_t end_token_i; + int32_t relex_start; + int32_t tolerance; + int32_t space_request; }; #endif diff --git a/4ed.cpp b/4ed.cpp index d2c79a59..ab1d8478 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -172,7 +172,7 @@ enum Coroutine_Type{ }; struct App_Coroutine_State{ void *co; - int type; + i32 type; }; inline App_Coroutine_State get_state(Application_Links *app){ @@ -764,7 +764,7 @@ view_caller(Coroutine *coroutine){ } internal void -app_links_init(System_Functions *system, Application_Links *app_links, void *data, int size){ +app_links_init(System_Functions *system, Application_Links *app_links, void *data, i32 size){ app_links->memory = data; app_links->memory_size = size; @@ -1077,26 +1077,6 @@ app_hardcode_styles(Models *models){ style_copy(main_style(models), models->styles.styles + 1); } -char *_4coder_get_extension(const char *filename, int len, int *extension_len){ - char *c = (char*)(filename + len - 1); - char *end = c; - while (*c != '.' && c > filename) --c; - *extension_len = (int)(end - c); - return c+1; -} - -bool _4coder_str_match(const char *a, int len_a, const char *b, int len_b){ - bool result = 0; - if (len_a == len_b){ - char *end = (char*)(a + len_a); - while (a < end && *a == *b){ - ++a; ++b; - } - if (a == end) result = 1; - } - return result; -} - enum Command_Line_Action{ CLAct_Nothing, CLAct_Ignore, @@ -1271,7 +1251,7 @@ App_Read_Command_Line_Sig(app_read_command_line){ } extern "C" SCROLL_RULE_SIG(fallback_scroll_rule){ - int result = 0; + i32 result = 0; if (target_x != *scroll_x){ *scroll_x = target_x; @@ -1403,8 +1383,8 @@ App_Init_Sig(app_init){ switch (unit->type){ case unit_map_begin: { - int mapid = unit->map_begin.mapid; - int count = map_get_count(models, mapid); + i32 mapid = unit->map_begin.mapid; + i32 count = map_get_count(models, mapid); if (unit->map_begin.replace){ map_set_count(models, mapid, unit->map_begin.bind_count); } @@ -1420,9 +1400,9 @@ App_Init_Sig(app_init){ switch (unit->type){ case unit_map_begin: { - int mapid = unit->map_begin.mapid; - int count = map_get_max_count(models, mapid); - int table_max = count * 3 / 2; + i32 mapid = unit->map_begin.mapid; + i32 count = map_get_max_count(models, mapid); + i32 table_max = count * 3 / 2; if (mapid == mapid_global){ map_ptr = &models->map_top; map_init(map_ptr, &models->mem.part, table_max, global); @@ -1449,7 +1429,7 @@ App_Init_Sig(app_init){ case unit_inherit: if (map_ptr){ Command_Map *parent = 0; - int mapid = unit->map_inherit.mapid; + i32 mapid = unit->map_inherit.mapid; if (mapid == mapid_global) parent = &models->map_top; else if (mapid == mapid_file) parent = &models->map_file; else if (mapid < mapid_global){ @@ -1495,7 +1475,7 @@ App_Init_Sig(app_init){ case unit_hook: { - int hook_id = unit->hook.hook_id; + i32 hook_id = unit->hook.hook_id; if (hook_id >= 0){ if (hook_id < hook_type_count){ models->hooks[hook_id] = (Hook_Function*)unit->hook.func; @@ -1551,7 +1531,7 @@ App_Init_Sig(app_init){ i32 pt_size; }; - int font_size = models->settings.font_size; + i32 font_size = models->settings.font_size; if (font_size < 8) font_size = 8; diff --git a/4ed.h b/4ed.h index 7997ba11..ef8402a2 100644 --- a/4ed.h +++ b/4ed.h @@ -61,7 +61,7 @@ struct Input_Summary{ struct Command_Line_Parameters{ char **argv; - int argc; + int32_t argc; }; struct Plat_Settings{ diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 11d3dc47..a23d5111 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -57,7 +57,7 @@ fill_view_summary(View_Summary *view, View *vptr, Live_Views *live_set, Working_ if (vptr->in_use){ view->exists = 1; - view->view_id = (int)(vptr - live_set->views) + 1; + view->view_id = (int32_t)(vptr - live_set->views) + 1; view->line_height = (float)(vptr->line_height); view->unwrapped_lines = vptr->file_data.unwrapped_lines; view->show_whitespace = vptr->file_data.show_whitespace; @@ -800,7 +800,7 @@ DOC_SEE(Buffer_Batch_Edit_Type) Assert(inverse_edits); char *inv_str = (char*)part->base + part->pos; - int inv_str_max = part->max - part->pos; + int32_t inv_str_max = part->max - part->pos; Edit_Spec spec = file_compute_edit(mem, file, @@ -1112,7 +1112,7 @@ DOC_SEE(Buffer_Identifier) Working_Set *working_set = &models->working_set; View *vptr = imp_get_view(cmd, view_id); Editing_File *file = get_file_from_identifier(system, working_set, buffer); - int result = false; + int32_t result = false; if (file){ if (flags & BufferKill_AlwaysKill){ @@ -1155,7 +1155,7 @@ internal void internal_get_view_next(Command_Data *cmd, View_Summary *view){ Editing_Layout *layout = &cmd->models->layout; Live_Views *live_set = &cmd->vars->live_set; - int index = view->view_id - 1; + int32_t index = view->view_id - 1; View *vptr = 0; Panel *panel = 0; @@ -1749,7 +1749,7 @@ DOC_SEE(int_color) bool32 result = false; - int size = end - start; + int32_t size = end - start; if (vptr){ if (size > 0){ result = true; diff --git a/4ed_app_target.cpp b/4ed_app_target.cpp index 2644a602..48506258 100644 --- a/4ed_app_target.cpp +++ b/4ed_app_target.cpp @@ -11,24 +11,25 @@ #include "4coder_custom.h" +#define FSTRING_IMPLEMENTATION +#define FSTRING_C +#include "4coder_string.h" + #define BUFFER_EXPERIMENT_SCALPEL 0 #include "4ed_meta.h" -#define FSTRING_IMPLEMENTATION -#include "4coder_string.h" - -#include "4ed_math.cpp" +#include "4ed_math.h" #include "4ed_system.h" #include "4ed_rendering.h" #include "4ed.h" -#include "4coder_table.cpp" - #include "4cpp_lexer.h" -#include "4ed_template.cpp" +#include "4coder_table.cpp" + +#include "4ed_doubly_linked_list.cpp" #include "4ed_font_set.cpp" #include "4ed_rendering_helper.cpp" diff --git a/4ed_doubly_linked_list.cpp b/4ed_doubly_linked_list.cpp new file mode 100644 index 00000000..9ff3b768 --- /dev/null +++ b/4ed_doubly_linked_list.cpp @@ -0,0 +1,22 @@ +/* + * Mr. 4th Dimention - Allen Webster + * + * 01.03.2016 + * + * generic dynamically linked list + * + */ + +// NOTE(allen): These macros are setup to work on structs +// with a next and prev pointer where the type of the struct +// is the same as the type of the next/prev pointers. + +#define dll_init_sentinel(s) do{ (s)->next=(s); (s)->prev=(s); }while(0) +#define dll_insert(p,v) do{ (v)->next=(p)->next; (v)->prev=(p); (p)->next=(v); (v)->next->prev=(v); }while(0) +#define dll_remove(v) do{ (v)->next->prev = (v)->prev; (v)->prev->next = (v)->next; }while(0) + +// for(dll_items(iterator, sentinel_ptr)){...} +#define dll_items(it, st) ((it) = (st)->next); ((it) != (st)); ((it) = (it)->next) + +// BOTTOM + diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 810218de..f9e0c02b 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -2547,7 +2547,7 @@ get_first_token_at_line(Buffer *buffer, Cpp_Token_Stack tokens, i32 line){ internal Cpp_Token* seek_matching_token_backwards(Cpp_Token_Stack tokens, Cpp_Token *token, Cpp_Token_Type open_type, Cpp_Token_Type close_type){ - int nesting_level = 0; + int32_t nesting_level = 0; if (token <= tokens.tokens){ token = tokens.tokens; } @@ -2712,7 +2712,7 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke } } else{ - int close = 0; + int32_t close = 0; for (token = brace_token; token > start_token; --token){ switch(token->type){ diff --git a/4ed_gui.cpp b/4ed_gui.cpp index 5cbf559b..7514d4c1 100644 --- a/4ed_gui.cpp +++ b/4ed_gui.cpp @@ -23,7 +23,7 @@ struct Query_Set{ internal void init_query_set(Query_Set *set){ Query_Slot *slot = set->slots; - int i; + int32_t i; set->free_slot = slot; set->used_slot = 0; for (i = 0; i+1 < ArrayCount(set->slots); ++i, ++slot){ diff --git a/4ed_layout.cpp b/4ed_layout.cpp index 3b5463b6..c3d3da64 100644 --- a/4ed_layout.cpp +++ b/4ed_layout.cpp @@ -33,8 +33,6 @@ struct Panel{ i32 parent; i32 which_child; - int ALLOCED; - union{ struct{ i32_Rect full; @@ -140,8 +138,6 @@ layout_alloc_panel(Editing_Layout *layout){ result.id = (i32)(result.panel - layout->panels); - result.panel->ALLOCED = 1; - return(result); } @@ -150,8 +146,6 @@ layout_free_panel(Editing_Layout *layout, Panel *panel){ dll_remove(panel); dll_insert(&layout->free_sentinel, panel); --layout->panel_count; - - panel->ALLOCED = 0; } internal Divider_And_ID diff --git a/4ed_math.cpp b/4ed_math.h similarity index 100% rename from 4ed_math.cpp rename to 4ed_math.h diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp index 0e6d2afa..3a7e1ad7 100644 --- a/4ed_metagen.cpp +++ b/4ed_metagen.cpp @@ -37,8 +37,8 @@ void to_lower(char *src, char *dst){ void to_lower(String *str){ char *c; - int i = 0; - int size = str->size; + int32_t i = 0; + int32_t size = str->size; for (c = str->str; i < size; ++c, ++i){ *c = char_to_lower(*c); } @@ -55,8 +55,8 @@ void to_upper(char *src, char *dst){ void to_upper(String *str){ char *c; - int i = 0; - int size = str->size; + int32_t i = 0; + int32_t size = str->size; for (c = str->str; i < size; ++c, ++i){ *c = char_to_upper(*c); } @@ -64,7 +64,7 @@ void to_upper(String *str){ void to_camel(char *src, char *dst){ char *c, ch; - int is_first = 1; + int32_t is_first = 1; for (c = src; *c != 0; ++c){ ch = *c; if (char_is_alpha_numeric_true(ch)){ @@ -93,8 +93,8 @@ void struct_begin(FILE *file, char *name){ fprintf(file, "struct %s{\n", name); } -void struct_fields(FILE *file, Struct_Field *fields, int count){ - int i; +void struct_fields(FILE *file, Struct_Field *fields, int32_t count){ + int32_t i; for (i = 0; i < count; ++i){ fprintf(file, " %s %s;\n", fields[i].type, fields[i].name); } @@ -149,7 +149,7 @@ char *keys_that_need_codes[] = { char* generate_keycode_enum(){ FILE *file; char *filename = "4coder_keycodes.h"; - int i, count; + int32_t i, count; unsigned char code = 1; file = fopen(filename, "wb"); @@ -172,7 +172,7 @@ char* generate_keycode_enum(){ fprintf(file, "static char*\n" - "global_key_name(int key_code, int *size){\n" + "global_key_name(int32_t key_code, int32_t *size){\n" "char *result = 0;\n" "switch(key_code){\n" ); @@ -234,9 +234,9 @@ char* main_style_fields[] = { static char* make_style_tag(char *tag){ char *str; - int len; + int32_t len; - len = (int)strlen(tag); + len = (int32_t)strlen(tag); str = (char*)malloc(len + 1); to_camel(tag, str); str[len] = 0; @@ -264,7 +264,7 @@ char* generate_style(){ char filename_4ed[] = "4ed_style.h"; FILE *file; char *tag; - int count, i; + int32_t count, i; file = fopen(filename_4coder, "wb"); enum_begin(file, "Style_Tag"); @@ -331,18 +331,18 @@ char* generate_style(){ ////////////////////////////////////////////////////////////////////////////////////////////////// typedef struct Argument_Breakdown{ - int count; + int32_t count; String *param_string; String *param_name; } Argument_Breakdown; typedef struct Documentation{ - int param_count; + int32_t param_count; String *param_name; String *param_docs; String return_doc; String main_doc; - int see_also_count; + int32_t see_also_count; String *see_also; } Documentation; @@ -361,8 +361,8 @@ struct Function_Set{ String *doc_string; - int *is_macro; - int *valid; + int32_t *is_macro; + int32_t *valid; Argument_Breakdown *breakdown; Documentation *doc; @@ -402,7 +402,7 @@ struct Enum_Set{ }; void -zero_index(Function_Set fnc_set, int sig_count){ +zero_index(Function_Set fnc_set, int32_t sig_count){ fnc_set.name [sig_count] = string_zero(); fnc_set.ret [sig_count] = string_zero(); fnc_set.args [sig_count] = string_zero(); @@ -434,7 +434,7 @@ file_dump(char *filename){ String get_first_line(String source){ String line = {0}; - int pos = find_s_char(source, 0, '\n'); + int32_t pos = find_s_char(source, 0, '\n'); line = substr(source, 0, pos); @@ -444,8 +444,8 @@ get_first_line(String source){ String get_next_line(String source, String line){ String next = {0}; - int pos = (int)(line.str - source.str) + line.size; - int start = 0; + int32_t pos = (int32_t)(line.str - source.str) + line.size; + int32_t start = 0; if (pos < source.size){ assert(source.str[pos] == '\n'); @@ -460,9 +460,9 @@ get_next_line(String source, String line){ return(next); } -int +static int32_t is_comment(String str){ - int result = 0; + int32_t result = 0; if (str.size >= 2){ if (str.str[0] == '/' && str.str[1] == '/'){ @@ -476,9 +476,9 @@ struct Parse{ Cpp_Token_Stack tokens; }; -int +static int32_t check_and_fix_docs(String *lexeme){ - int result = false; + int32_t result = false; if (lexeme->size > 4){ if (lexeme->str[0] == '/'){ @@ -513,11 +513,11 @@ doc_note_string[] = { }; String -doc_parse_note(String source, int *pos){ +doc_parse_note(String source, int32_t *pos){ String result = {0}; - int p = *pos; - int start = p; + int32_t p = *pos; + int32_t start = p; for (; p < source.size; ++p){ if (source.str[p] == '('){ break; @@ -533,15 +533,15 @@ doc_parse_note(String source, int *pos){ } String -doc_parse_note_string(String source, int *pos){ +doc_parse_note_string(String source, int32_t *pos){ String result = {0}; assert(source.str[*pos] == '('); - int p = *pos + 1; - int start = p; + int32_t p = *pos + 1; + int32_t start = p; - int nest_level = 0; + int32_t nest_level = 0; for (; p < source.size; ++p){ if (source.str[p] == ')'){ @@ -567,11 +567,11 @@ doc_parse_note_string(String source, int *pos){ } String -doc_parse_parameter(String source, int *pos){ +doc_parse_parameter(String source, int32_t *pos){ String result = {0}; - int p = *pos; - int start = p; + int32_t p = *pos; + int32_t start = p; for (; p < source.size; ++p){ if (source.str[p] == ','){ @@ -589,11 +589,11 @@ doc_parse_parameter(String source, int *pos){ } String -doc_parse_last_parameter(String source, int *pos){ +doc_parse_last_parameter(String source, int32_t *pos){ String result = {0}; - int p = *pos; - int start = p; + int32_t p = *pos; + int32_t start = p; for (; p < source.size; ++p){ if (source.str[p] == ')'){ @@ -611,11 +611,11 @@ doc_parse_last_parameter(String source, int *pos){ void perform_doc_parse(Partition *part, String doc_string, Documentation *doc){ - int keep_parsing = true; - int pos = 0; + int32_t keep_parsing = true; + int32_t pos = 0; - int param_count = 0; - int see_count = 0; + int32_t param_count = 0; + int32_t see_count = 0; do{ String doc_note = doc_parse_note(doc_string, &pos); @@ -623,7 +623,7 @@ perform_doc_parse(Partition *part, String doc_string, Documentation *doc){ keep_parsing = false; } else{ - int doc_note_type; + int32_t doc_note_type; if (string_set_match(doc_note_string, ArrayCount(doc_note_string), doc_note, &doc_note_type)){ doc_parse_note_string(doc_string, &pos); @@ -642,7 +642,7 @@ perform_doc_parse(Partition *part, String doc_string, Documentation *doc){ }while(keep_parsing); if (param_count + see_count > 0){ - int memory_size = sizeof(String)*(2*param_count + see_count); + int32_t memory_size = sizeof(String)*(2*param_count + see_count); doc->param_name = push_array(part, String, memory_size); doc->param_docs = doc->param_name + param_count; doc->see_also = doc->param_docs + param_count; @@ -651,8 +651,8 @@ perform_doc_parse(Partition *part, String doc_string, Documentation *doc){ doc->see_also_count = see_count; } - int param_index = 0; - int see_index = 0; + int32_t param_index = 0; + int32_t see_index = 0; keep_parsing = true; pos = 0; @@ -662,7 +662,7 @@ perform_doc_parse(Partition *part, String doc_string, Documentation *doc){ keep_parsing = false; } else{ - int doc_note_type; + int32_t doc_note_type; if (string_set_match(doc_note_string, ArrayCount(doc_note_string), doc_note, &doc_note_type)){ String doc_note_string = doc_parse_note_string(doc_string, &pos); @@ -671,7 +671,7 @@ perform_doc_parse(Partition *part, String doc_string, Documentation *doc){ case DOC_PARAM: { assert(param_index < param_count); - int param_pos = 0; + int32_t param_pos = 0; String param_name = doc_parse_parameter(doc_note_string, ¶m_pos); String param_docs = doc_parse_last_parameter(doc_note_string, ¶m_pos); doc->param_name[param_index] = param_name; @@ -703,10 +703,10 @@ perform_doc_parse(Partition *part, String doc_string, Documentation *doc){ }while(keep_parsing); } -static int -get_type_doc_string(char *data, Cpp_Token *tokens, int i, +static int32_t +get_type_doc_string(char *data, Cpp_Token *tokens, int32_t i, String *doc_string){ - int result = false; + int32_t result = false; if (i > 0){ Cpp_Token *prev_token = tokens + i - 1; @@ -721,27 +721,27 @@ get_type_doc_string(char *data, Cpp_Token *tokens, int i, return(result); } -static int -parse_struct(Partition *part, int is_struct, - char *data, Cpp_Token *tokens, int count, +static int32_t +parse_struct(Partition *part, int32_t is_struct, + char *data, Cpp_Token *tokens, int32_t count, Cpp_Token **token_ptr, Struct_Member *top_member); -static int +static int32_t parse_struct_member(Partition *part, - char *data, Cpp_Token *tokens, int count, + char *data, Cpp_Token *tokens, int32_t count, Cpp_Token **token_ptr, Struct_Member *member){ - int result = false; + int32_t result = false; Cpp_Token *token = *token_ptr; - int i = (int)(token - tokens); + int32_t i = (int32_t)(token - tokens); String doc_string = {0}; get_type_doc_string(data, tokens, i, &doc_string); - int start_i = i; + int32_t start_i = i; Cpp_Token *start_token = token; for (; i < count; ++i, ++token){ @@ -753,8 +753,8 @@ parse_struct_member(Partition *part, if (i < count){ Cpp_Token *token_j = token; - int nest_level = 0; - for (int j = i; j > start_i; --j, --token_j){ + int32_t nest_level = 0; + for (int32_t j = i; j > start_i; --j, --token_j){ if (token_j->type == CPP_TOKEN_BRACKET_CLOSE){ ++nest_level; } @@ -776,8 +776,8 @@ parse_struct_member(Partition *part, String name = make_string(data + token_j->start, token_j->size); name = skip_chop_whitespace(name); - int type_start = start_token->start; - int type_end = token_j->start; + int32_t type_start = start_token->start; + int32_t type_end = token_j->start; String type = make_string(data + type_start, type_end - type_start); type = skip_chop_whitespace(type); @@ -805,12 +805,12 @@ parse_struct_member(Partition *part, static Struct_Member* parse_struct_next_member(Partition *part, - char *data, Cpp_Token *tokens, int count, + char *data, Cpp_Token *tokens, int32_t count, Cpp_Token **token_ptr){ Struct_Member *result = 0; Cpp_Token *token = *token_ptr; - int i = (int)(token - tokens); + int32_t i = (int32_t)(token - tokens); for (; i < count; ++i, ++token){ if (token->type == CPP_TOKEN_IDENTIFIER || @@ -858,21 +858,21 @@ parse_struct_next_member(Partition *part, return(result); } -static int -parse_struct(Partition *part, int is_struct, - char *data, Cpp_Token *tokens, int count, +static int32_t +parse_struct(Partition *part, int32_t is_struct, + char *data, Cpp_Token *tokens, int32_t count, Cpp_Token **token_ptr, Struct_Member *top_member){ - int result = false; + int32_t result = false; Cpp_Token *token = *token_ptr; - int i = (int)(token - tokens); + int32_t i = (int32_t)(token - tokens); String doc_string = {0}; get_type_doc_string(data, tokens, i, &doc_string); - int start_i = i; + int32_t start_i = i; for (; i < count; ++i, ++token){ if (token->type == CPP_TOKEN_BRACE_OPEN){ @@ -882,7 +882,7 @@ parse_struct(Partition *part, int is_struct, if (i < count){ Cpp_Token *token_j = token; - int j = i; + int32_t j = i; for (; j > start_i; --j, --token_j){ if (token_j->type == CPP_TOKEN_IDENTIFIER){ @@ -926,7 +926,7 @@ parse_struct(Partition *part, int is_struct, } } - i = (int)(token - tokens); + i = (int32_t)(token - tokens); for (; i < count; ++i, ++token){ if (token->type == CPP_TOKEN_SEMICOLON){ break; @@ -982,7 +982,7 @@ print_struct_html(FILE *file, Struct_Member *member){ } static void -print_function_html(FILE *file, Function_Set function_set, int i, String name, +print_function_html(FILE *file, Function_Set function_set, int32_t i, String name, char *function_call_head){ String ret = function_set.ret[i]; fprintf(file, @@ -993,8 +993,8 @@ print_function_html(FILE *file, Function_Set function_set, int i, String name, name.size, name.str); Argument_Breakdown *breakdown = &function_set.breakdown[i]; - int arg_count = breakdown->count; - for (int j = 0; j < arg_count; ++j){ + int32_t arg_count = breakdown->count; + for (int32_t j = 0; j < arg_count; ++j){ String param_string = breakdown->param_string[j]; if (j < arg_count - 1){ fprintf(file, "%.*s,
", param_string.size, param_string.str); @@ -1008,9 +1008,9 @@ print_function_html(FILE *file, Function_Set function_set, int i, String name, } static void -print_macro_html(FILE *file, Function_Set function_set, int i, String name){ +print_macro_html(FILE *file, Function_Set function_set, int32_t i, String name){ Argument_Breakdown *breakdown = &function_set.breakdown[i]; - int arg_count = breakdown->count; + int32_t arg_count = breakdown->count; if (arg_count == 0){ fprintf(file, "#define %.*s()", @@ -1029,7 +1029,7 @@ print_macro_html(FILE *file, Function_Set function_set, int i, String name){ "
", name.size, name.str); - for (int j = 0; j < arg_count; ++j){ + for (int32_t j = 0; j < arg_count; ++j){ String param_string = breakdown->param_string[j]; if (j < arg_count - 1){ fprintf(file, "%.*s,
", param_string.size, param_string.str); @@ -1102,11 +1102,11 @@ print_struct_docs(FILE *file, Partition *part, Struct_Member *member){ static void print_see_also(FILE *file, Documentation *doc){ - int doc_see_count = doc->see_also_count; + int32_t doc_see_count = doc->see_also_count; if (doc_see_count > 0){ fprintf(file, DOC_HEAD_OPEN"See Also"DOC_HEAD_CLOSE); - for (int j = 0; j < doc_see_count; ++j){ + for (int32_t j = 0; j < doc_see_count; ++j){ String see_also = doc->see_also[j]; fprintf(file, DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, @@ -1117,21 +1117,21 @@ print_see_also(FILE *file, Documentation *doc){ } } -static int +static int32_t parse_enum(Partition *part, char *data, - Cpp_Token *tokens, int count, - Cpp_Token **token_ptr, int start_i, - Enum_Set flag_set, int flag_index){ + Cpp_Token *tokens, int32_t count, + Cpp_Token **token_ptr, int32_t start_i, + Enum_Set flag_set, int32_t flag_index){ - int result = false; + int32_t result = false; Cpp_Token *token = *token_ptr; - int i = (int)(token - tokens); + int32_t i = (int32_t)(token - tokens); if (i < count){ Cpp_Token *token_j = token; - for (int j = i; j > start_i; --j, --token_j){ + for (int32_t j = i; j > start_i; --j, --token_j){ if (token_j->type == CPP_TOKEN_IDENTIFIER){ break; } @@ -1176,8 +1176,8 @@ parse_enum(Partition *part, char *data, } } - int val_start = start_token->start + start_token->size; - int val_end = token->start; + int32_t val_start = start_token->start + start_token->size; + int32_t val_end = token->start; value = make_string(data + val_start, val_end - val_start); value = skip_chop_whitespace(value); @@ -1229,9 +1229,9 @@ parse_enum(Partition *part, char *data, } static App_API -allocate_app_api(int count){ +allocate_app_api(int32_t count){ App_API app_api = {0}; - int memory_size = (sizeof(String)*2)*count; + int32_t memory_size = (sizeof(String)*2)*count; app_api.macros = (String*)malloc(memory_size); app_api.public_name = app_api.macros + count; memset(app_api.macros, 0, memory_size); @@ -1239,12 +1239,12 @@ allocate_app_api(int count){ } static Function_Set -allocate_function_set(int count){ +allocate_function_set(int32_t count){ Function_Set function_set = {0}; - int memory_size = (sizeof(String)*7 + - sizeof(int)*2 + - sizeof(Argument_Breakdown) + - sizeof(Documentation))*count; + int32_t memory_size = (sizeof(String)*7 + + sizeof(int32_t)*2 + + sizeof(Argument_Breakdown) + + sizeof(Documentation))*count; String *str_ptr = (String*)malloc(memory_size); function_set.name = str_ptr; str_ptr += count; @@ -1255,7 +1255,7 @@ allocate_function_set(int count){ function_set.cpp_name = str_ptr; str_ptr += count; function_set.doc_string = str_ptr; str_ptr += count; - function_set.is_macro = (int*)(function_set.doc_string + count); + function_set.is_macro = (int32_t*)(function_set.doc_string + count); function_set.valid = function_set.is_macro + count; function_set.breakdown = (Argument_Breakdown*)(function_set.valid + count); @@ -1267,9 +1267,9 @@ allocate_function_set(int count){ } static Argument_Breakdown -allocate_argument_breakdown(int count){ +allocate_argument_breakdown(int32_t count){ Argument_Breakdown breakdown = {0}; - int memory_size = (sizeof(String)*2)*count; + int32_t memory_size = (sizeof(String)*2)*count; breakdown.count = count; breakdown.param_string = (String*)malloc(memory_size); breakdown.param_name = breakdown.param_string + count; @@ -1279,11 +1279,11 @@ allocate_argument_breakdown(int count){ static Argument_Breakdown do_parameter_parse(char *data, Cpp_Token *args_start_token, Cpp_Token *token){ - int arg_index = 0; + int32_t arg_index = 0; Cpp_Token *arg_token = args_start_token + 1; - int param_string_start = arg_token->start; + int32_t param_string_start = arg_token->start; - int arg_count = 1; + int32_t arg_count = 1; arg_token = args_start_token; for (; arg_token < token; ++arg_token){ if (arg_token->type == CPP_TOKEN_COMMA){ @@ -1298,7 +1298,7 @@ do_parameter_parse(char *data, Cpp_Token *args_start_token, Cpp_Token *token){ if (arg_token->type == CPP_TOKEN_COMMA || arg_token->type == CPP_TOKEN_PARENTHESE_CLOSE){ - int size = arg_token->start - param_string_start; + int32_t size = arg_token->start - param_string_start; String param_string = make_string(data + param_string_start, size); param_string = chop_whitespace(param_string); breakdown.param_string[arg_index] = param_string; @@ -1307,8 +1307,8 @@ do_parameter_parse(char *data, Cpp_Token *args_start_token, Cpp_Token *token){ param_name_token->start > param_string_start; --param_name_token){ if (param_name_token->type == CPP_TOKEN_IDENTIFIER){ - int start = param_name_token->start; - int size = param_name_token->size; + int32_t start = param_name_token->start; + int32_t size = param_name_token->size; breakdown.param_name[arg_index] = make_string(data + start, size); break; } @@ -1327,11 +1327,11 @@ do_parameter_parse(char *data, Cpp_Token *args_start_token, Cpp_Token *token){ return(breakdown); } -static int -do_function_parse_check(int *index, Cpp_Token **token_ptr, int count){ - int result = false; +static int32_t +do_function_parse_check(int32_t *index, Cpp_Token **token_ptr, int32_t count){ + int32_t result = false; - int i = *index; + int32_t i = *index; Cpp_Token *token = *token_ptr; { @@ -1357,12 +1357,12 @@ do_function_parse_check(int *index, Cpp_Token **token_ptr, int count){ return(result); } -static int -do_function_get_doc(int *index, Cpp_Token **token_ptr, int count, +static int32_t +do_function_get_doc(int32_t *index, Cpp_Token **token_ptr, int32_t count, char *data, String *doc_string){ - int result = false; + int32_t result = false; - int i = *index; + int32_t i = *index; Cpp_Token *token = *token_ptr; for (; i < count; ++i, ++token){ @@ -1391,14 +1391,14 @@ get_lexeme(Cpp_Token token, char *code){ return(str); } -static int -do_parse_cpp_name(int *i_ptr, Cpp_Token **token_ptr, int count, char *data, String *name){ - int result = false; +static int32_t +do_parse_cpp_name(int32_t *i_ptr, Cpp_Token **token_ptr, int32_t count, char *data, String *name){ + int32_t result = false; - int i = *i_ptr; + int32_t i = *i_ptr; Cpp_Token *token = *token_ptr; - int i_start = i; + int32_t i_start = i; Cpp_Token *token_start = token; ++i, ++token; @@ -1424,19 +1424,19 @@ do_parse_cpp_name(int *i_ptr, Cpp_Token **token_ptr, int count, char *data, Stri return(result); } -static int -do_function_parse(int *index, Cpp_Token **token_ptr, int count, Cpp_Token *ret_start_token, - char *data, Function_Set function_set, int sig_count, String cpp_name){ - int result = false; +static int32_t +do_function_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count, Cpp_Token *ret_start_token, + char *data, Function_Set function_set, int32_t sig_count, String cpp_name){ + int32_t result = false; - int i = *index; + int32_t i = *index; Cpp_Token *token = *token_ptr; Cpp_Token *args_start_token = token+1; function_set.name[sig_count] = make_string(data + token->start, token->size); - int size = token->start - ret_start_token->start; + int32_t size = token->start - ret_start_token->start; String ret = make_string(data + ret_start_token->start, size); ret = chop_whitespace(ret); function_set.ret[sig_count] = ret; @@ -1448,7 +1448,7 @@ do_function_parse(int *index, Cpp_Token **token_ptr, int count, Cpp_Token *ret_s } if (i < count){ - int size = token->start + token->size - args_start_token->start;; + int32_t size = token->start + token->size - args_start_token->start;; function_set.args[sig_count] = make_string(data + args_start_token->start, size); function_set.valid[sig_count] = true; @@ -1466,18 +1466,18 @@ do_function_parse(int *index, Cpp_Token **token_ptr, int count, Cpp_Token *ret_s return(result); } -static int -do_full_function_parse(int *index, Cpp_Token **token_ptr, int count, char *data, - Function_Set function_set, int sig_count, String cpp_name){ - int result = false; +static int32_t +do_full_function_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count, char *data, + Function_Set function_set, int32_t sig_count, String cpp_name){ + int32_t result = false; - int i = *index; + int32_t i = *index; Cpp_Token *token = *token_ptr; { function_set.marker[sig_count] = make_string(data + token->start, token->size); - int j = i; + int32_t j = i; Cpp_Token *jtoken = token; if (do_function_parse_check(&j, &jtoken, count)){ @@ -1507,11 +1507,11 @@ do_full_function_parse(int *index, Cpp_Token **token_ptr, int count, char *data, return(result); } -static int -do_macro_parse_check(int *index, Cpp_Token **token_ptr, int count){ - int result = false; +static int32_t +do_macro_parse_check(int32_t *index, Cpp_Token **token_ptr, int32_t count){ + int32_t result = false; - int i = *index; + int32_t i = *index; Cpp_Token *token = *token_ptr; { @@ -1534,12 +1534,12 @@ do_macro_parse_check(int *index, Cpp_Token **token_ptr, int count){ return(result); } -static int -do_macro_parse(int *index, Cpp_Token **token_ptr, int count, - char *data, Function_Set macro_set, int sig_count){ - int result = false; +static int32_t +do_macro_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count, + char *data, Function_Set macro_set, int32_t sig_count){ + int32_t result = false; - int i = *index; + int32_t i = *index; Cpp_Token *token = *token_ptr; if (i > 0){ @@ -1569,8 +1569,8 @@ do_macro_parse(int *index, Cpp_Token **token_ptr, int count, } if (i < count){ - int start = args_start_token->start; - int end = token->start + token->size; + int32_t start = args_start_token->start; + int32_t end = token->start + token->size; macro_set.args[sig_count] = make_string(data + start, end - start); Argument_Breakdown *breakdown = ¯o_set.breakdown[sig_count]; @@ -1613,10 +1613,10 @@ do_macro_parse(int *index, Cpp_Token **token_ptr, int count, } struct String_Function_Marker{ - int parse_function; - int is_inline; - int parse_doc; - int cpp_name; + int32_t parse_function; + int32_t is_inline; + int32_t parse_doc; + int32_t cpp_name; }; static String_Function_Marker @@ -1641,7 +1641,7 @@ do_string_function_marker_check(String lexeme){ } static String -get_string(char *data, int start, int end){ +get_string(char *data, int32_t start, int32_t end){ return(make_string(data + start, end - start)); } @@ -1653,16 +1653,16 @@ print_str(FILE *file, String str){ } static void -print_function_body_code(FILE *file, int *index, Cpp_Token **token_ptr, int count, String *code, - int start){ - int i = *index; +print_function_body_code(FILE *file, int32_t *index, Cpp_Token **token_ptr, int32_t count, String *code, + int32_t start){ + int32_t i = *index; Cpp_Token *token = *token_ptr; String pstr = {0}; - int nest_level = 0; - int finish = false; - int do_whitespace_print = false; + int32_t nest_level = 0; + int32_t finish = false; + int32_t do_whitespace_print = false; for (; i < count; ++i, ++token){ if (do_whitespace_print){ pstr = get_string(code->str, start, token->start); @@ -1672,7 +1672,7 @@ print_function_body_code(FILE *file, int *index, Cpp_Token **token_ptr, int coun do_whitespace_print = true; } - int do_print = true; + int32_t do_print = true; if (token->type == CPP_TOKEN_COMMENT){ String lexeme = make_string(code->str + token->start, token->size); if (check_and_fix_docs(&lexeme)){ @@ -1719,11 +1719,11 @@ print_function_docs(FILE *file, Partition *part, String name, String doc_string) perform_doc_parse(part, doc_string, doc); - int doc_param_count = doc->param_count; + int32_t doc_param_count = doc->param_count; if (doc_param_count > 0){ fprintf(file, DOC_HEAD_OPEN"Parameters"DOC_HEAD_CLOSE); - for (int j = 0; j < doc_param_count; ++j){ + for (int32_t j = 0; j < doc_param_count; ++j){ String param_name = doc->param_name[j]; String param_docs = doc->param_docs[j]; @@ -1768,7 +1768,7 @@ generate_custom_headers(){ #define API_DOC "4coder_API.html" #define STRING_H "4coder_string.h" - int size = Mbytes(512); + int32_t size = Mbytes(512); void *mem = malloc(size); memset(mem, 0, size); @@ -1780,24 +1780,24 @@ generate_custom_headers(){ String string_code = file_dump("internal_4coder_string.cpp"); Cpp_Token_Stack string_tokens = {0}; - int string_function_count = 0; + int32_t string_function_count = 0; { String *code = &string_code; Cpp_Token_Stack *token_stack = &string_tokens; char *data = code->str; - int size = code->size; + int32_t size = code->size; *token_stack = cpp_make_token_stack(1024); cpp_lex_file(data, size, token_stack); - int count = token_stack->count; + int32_t count = token_stack->count; Cpp_Token *tokens = token_stack->tokens; Cpp_Token *token = tokens; - for (int i = 0; i < count; ++i, ++token){ + for (int32_t i = 0; i < count; ++i, ++token){ if (token->type == CPP_TOKEN_IDENTIFIER && !(token->flags & CPP_TFLAG_PP_BODY)){ String lexeme = make_string(data + token->start, token->size); @@ -1820,7 +1820,7 @@ generate_custom_headers(){ } Function_Set string_function_set = allocate_function_set(string_function_count); - int string_sig_count = 0; + int32_t string_sig_count = 0; { String *code = &string_code; @@ -1828,14 +1828,14 @@ generate_custom_headers(){ char *data = code->str; - int count = token_stack->count; + int32_t count = token_stack->count; Cpp_Token *tokens = token_stack->tokens; Cpp_Token *token = tokens; String cpp_name = {0}; - int has_cpp_name = 0; + int32_t has_cpp_name = 0; - for (int i = 0; i < count; ++i, ++token){ + for (int32_t i = 0; i < count; ++i, ++token){ if (token->type == CPP_TOKEN_IDENTIFIER && !(token->flags & CPP_TFLAG_PP_BODY)){ String lexeme = make_string(data + token->start, token->size); @@ -1882,23 +1882,23 @@ generate_custom_headers(){ code_data[1] = file_dump("win32_api_impl.cpp"); Parse parses[2]; - int line_count = 0; + int32_t line_count = 0; - for (int J = 0; J < 2; ++J){ + for (int32_t J = 0; J < 2; ++J){ String *code = &code_data[J]; Parse *parse = &parses[J]; char *data = code->str; - int size = code->size; + int32_t size = code->size; parse->tokens = cpp_make_token_stack(512); cpp_lex_file(data, size, &parse->tokens); - int count = parse->tokens.count; + int32_t count = parse->tokens.count; Cpp_Token *tokens = parse->tokens.tokens; Cpp_Token *token = tokens; - for (int i = 0; i < count; ++i, ++token){ + for (int32_t i = 0; i < count; ++i, ++token){ if (token->type == CPP_TOKEN_IDENTIFIER && !(token->flags & CPP_TFLAG_PP_BODY)){ String lexeme = make_string(data + token->start, token->size); @@ -1913,20 +1913,20 @@ generate_custom_headers(){ Function_Set function_set = allocate_function_set(line_count); App_API app_function_set = allocate_app_api(line_count); - int sig_count = 0; + int32_t sig_count = 0; - for (int J = 0; J < 2; ++J){ + for (int32_t J = 0; J < 2; ++J){ String *code = &code_data[J]; Parse *parse = &parses[J]; char *data = code->str; - int count = parse->tokens.count; + int32_t count = parse->tokens.count; Cpp_Token *tokens = parse->tokens.tokens; // NOTE(allen): Header Parse Cpp_Token *token = tokens; - for (int i = 0; i < count; ++i, ++token){ + for (int32_t i = 0; i < count; ++i, ++token){ if (token->type == CPP_TOKEN_IDENTIFIER && !(token->flags & CPP_TFLAG_PP_BODY)){ String lexeme = make_string(data + token->start, token->size); @@ -1944,7 +1944,7 @@ generate_custom_headers(){ } } - for (int i = 0; i < sig_count; ++i){ + for (int32_t i = 0; i < sig_count; ++i){ String name_string = function_set.name[i]; String *macro = app_function_set.macros + i; String *public_name = app_function_set.public_name + i; @@ -1969,7 +1969,7 @@ generate_custom_headers(){ // NOTE(allen): Header FILE *file = fopen(API_H, "wb"); - for (int i = 0; i < sig_count; ++i){ + for (int32_t i = 0; i < sig_count; ++i){ String ret_string = function_set.ret[i]; String args_string = function_set.args[i]; String macro_string = app_function_set.macros[i]; @@ -1982,7 +1982,7 @@ generate_custom_headers(){ } fprintf(file, "extern \"C\"{\n"); - for (int i = 0; i < sig_count; ++i){ + for (int32_t i = 0; i < sig_count; ++i){ String name_string = function_set.name[i]; String macro_string = app_function_set.macros[i]; @@ -1995,9 +1995,9 @@ generate_custom_headers(){ fprintf(file, "struct Application_Links{\n"); fprintf(file, " void *memory;\n" - " int memory_size;\n" + " int32_t memory_size;\n" ); - for (int i = 0; i < sig_count; ++i){ + for (int32_t i = 0; i < sig_count; ++i){ String name_string = function_set.name[i]; String public_string = app_function_set.public_name[i]; @@ -2009,12 +2009,12 @@ generate_custom_headers(){ " void *cmd_context;\n" " void *system_links;\n" " void *current_coroutine;\n" - " int type_coroutine;\n" + " int32_t type_coroutine;\n" ); fprintf(file, "};\n"); fprintf(file, "#define FillAppLinksAPI(app_links) do{"); - for (int i = 0; i < sig_count; ++i){ + for (int32_t i = 0; i < sig_count; ++i){ String name = function_set.name[i]; String public_string = app_function_set.public_name[i]; @@ -2041,10 +2041,10 @@ generate_custom_headers(){ Cpp_Token_Stack types_token_array[1]; - int typedef_count = 0; - int struct_count = 0; - int flag_count = 0; - int enum_count = 0; + int32_t typedef_count = 0; + int32_t struct_count = 0; + int32_t flag_count = 0; + int32_t enum_count = 0; static String type_spec_keys[] = { make_lit_string("typedef"), @@ -2056,23 +2056,23 @@ generate_custom_headers(){ for (int32_t J = 0; J < 1; ++J){ char *data = type_code[J].str; - int size = type_code[J].size; + int32_t size = type_code[J].size; Cpp_Token_Stack types_tokens = cpp_make_token_stack(512); cpp_lex_file(data, size, &types_tokens); types_token_array[J] = types_tokens; - int count = types_tokens.count; + int32_t count = types_tokens.count; Cpp_Token *tokens = types_tokens.tokens; Cpp_Token *token = tokens; - for (int i = 0; i < count; ++i, ++token){ + for (int32_t i = 0; i < count; ++i, ++token){ if (!(token->flags & CPP_TFLAG_PP_BODY) && (token->type == CPP_TOKEN_KEY_TYPE_DECLARATION || token->type == CPP_TOKEN_IDENTIFIER)){ String lexeme = make_string(data + token->start, token->size); - int match_index = 0; + int32_t match_index = 0; if (string_set_match(type_spec_keys, ArrayCount(type_spec_keys), lexeme, &match_index)){ switch (match_index){ @@ -2116,28 +2116,28 @@ generate_custom_headers(){ flag_set.doc_string = push_array(part, String, flag_count); } - int typedef_index = 0; - int struct_index = 0; - int flag_index = 0; - int enum_index = 0; + int32_t typedef_index = 0; + int32_t struct_index = 0; + int32_t flag_index = 0; + int32_t enum_index = 0; for (int32_t J = 0; J < 1; ++J){ char *data = type_code[J].str; Cpp_Token_Stack types_tokens = types_token_array[J]; - int count = types_tokens.count; + int32_t count = types_tokens.count; Cpp_Token *tokens = types_tokens.tokens; Cpp_Token *token = tokens; - for (int i = 0; i < count; ++i, ++token){ + for (int32_t i = 0; i < count; ++i, ++token){ Assert(i == (i32)(token - tokens)); if (!(token->flags & CPP_TFLAG_PP_BODY) && (token->type == CPP_TOKEN_KEY_TYPE_DECLARATION || token->type == CPP_TOKEN_IDENTIFIER)){ String lexeme = make_string(data + token->start, token->size); - int match_index = 0; + int32_t match_index = 0; if (string_set_match(type_spec_keys, ArrayCount(type_spec_keys), lexeme, &match_index)){ switch (match_index){ @@ -2146,7 +2146,7 @@ generate_custom_headers(){ String doc_string = {0}; get_type_doc_string(data, tokens, i, &doc_string); - int start_i = i; + int32_t start_i = i; Cpp_Token *start_token = token; for (; i < count; ++i, ++token){ @@ -2158,7 +2158,7 @@ generate_custom_headers(){ if (i < count){ Cpp_Token *token_j = token; - for (int j = i; j > start_i; --j, --token_j){ + for (int32_t j = i; j > start_i; --j, --token_j){ if (token_j->type == CPP_TOKEN_IDENTIFIER){ break; } @@ -2167,8 +2167,8 @@ generate_custom_headers(){ String name = make_string(data + token_j->start, token_j->size); name = skip_chop_whitespace(name); - int type_start = start_token->start + start_token->size; - int type_end = token_j->start; + int32_t type_start = start_token->start + start_token->size; + int32_t type_end = token_j->start; String type = make_string(data + type_start, type_end - type_start); type = skip_chop_whitespace(type); @@ -2186,7 +2186,7 @@ generate_custom_headers(){ struct_set.structs + struct_index)){ ++struct_index; } - i = (int)(token - tokens); + i = (int32_t)(token - tokens); }break; case 3: //ENUM @@ -2194,7 +2194,7 @@ generate_custom_headers(){ String doc_string = {0}; get_type_doc_string(data, tokens, i, &doc_string); - int start_i = i; + int32_t start_i = i; for (; i < count; ++i, ++token){ if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){ @@ -2217,7 +2217,7 @@ generate_custom_headers(){ String doc_string = {0}; get_type_doc_string(data, tokens, i, &doc_string); - int start_i = i; + int32_t start_i = i; for (; i < count; ++i, ++token){ if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){ @@ -2255,12 +2255,12 @@ generate_custom_headers(){ String *code = &string_code; Cpp_Token_Stack *token_stack = &string_tokens; - int start = 0; + int32_t start = 0; - int count = token_stack->count; + int32_t count = token_stack->count; Cpp_Token *tokens = token_stack->tokens; Cpp_Token *token = tokens; - int i = 0; + int32_t i = 0; for (i = 0; i < count; ++i, ++token){ if (token->type == CPP_TOKEN_IDENTIFIER && @@ -2274,7 +2274,7 @@ generate_custom_headers(){ } String pstr = {0}; - int do_whitespace_print = true; + int32_t do_whitespace_print = true; for(++i, ++token; i < count; ++i, ++token){ if (do_whitespace_print){ @@ -2287,7 +2287,7 @@ generate_custom_headers(){ String lexeme = get_lexeme(*token, code->str); - int do_print = true; + int32_t do_print = true; if (match_ss(lexeme, make_lit_string("FSTRING_DECLS"))){ fprintf(file, "#if !defined(FCODER_STRING_H)\n#define FCODER_STRING_H\n\n"); @@ -2296,7 +2296,7 @@ generate_custom_headers(){ #define RETURN_PADDING 16 #define SIG_PADDING 30 - for (int j = 0; j < string_sig_count; ++j){ + for (int32_t j = 0; j < string_sig_count; ++j){ char line_space[2048]; String line = make_fixed_width_string(line_space); @@ -2350,7 +2350,7 @@ generate_custom_headers(){ "// for C++ users who can have overloaded functions. None of\n" "// these functions add new features.\n"); - for (int j = 0; j < string_sig_count; ++j){ + for (int32_t j = 0; j < string_sig_count; ++j){ char line_space[2048]; String line = make_fixed_width_string(line_space); @@ -2381,7 +2381,7 @@ generate_custom_headers(){ { fprintf(file, "\n#if !defined(FSTRING_C) && !defined(FSTRING_GUARD)\n\n"); - for (int j = 0; j < string_sig_count; ++j){ + for (int32_t j = 0; j < string_sig_count; ++j){ char line_space[2048]; String line = make_fixed_width_string(line_space); @@ -2471,8 +2471,8 @@ generate_custom_headers(){ else if (match_ss(lexeme, make_lit_string("CPP_NAME"))){ Cpp_Token *token_start = token; - int i_start = i; - int has_cpp_name = false; + int32_t i_start = i; + int32_t has_cpp_name = false; ++i, ++token; if (token->type == CPP_TOKEN_PARENTHESE_OPEN){ @@ -2592,8 +2592,8 @@ generate_custom_headers(){ "

Table of Contents

\n" "
    \n"); - int section_count = ArrayCount(sections); - for (int i = 0; i < section_count; ++i){ + int32_t section_count = ArrayCount(sections); + for (int32_t i = 0; i < section_count; ++i){ fprintf(file, "
  • §%d %s
  • ", sections[i].id_string, @@ -2661,7 +2661,7 @@ generate_custom_headers(){ "

    §"SECTION" Function List

    \n" "
      \n"); - for (int i = 0; i < sig_count; ++i){ + for (int32_t i = 0; i < sig_count; ++i){ String name = app_function_set.public_name[i]; fprintf(file, "
    • " @@ -2681,7 +2681,7 @@ generate_custom_headers(){ "
        \n" ); - for (int i = 0; i < typedef_count; ++i){ + for (int32_t i = 0; i < typedef_count; ++i){ String name = typedef_set.name[i]; fprintf(file, "
      • " @@ -2692,7 +2692,7 @@ generate_custom_headers(){ ); } - for (int i = 0; i < enum_count; ++i){ + for (int32_t i = 0; i < enum_count; ++i){ String name = enum_set.name[i]; fprintf(file, "
      • " @@ -2703,7 +2703,7 @@ generate_custom_headers(){ ); } - for (int i = 0; i < flag_count; ++i){ + for (int32_t i = 0; i < flag_count; ++i){ String name = flag_set.name[i]; fprintf(file, "
      • " @@ -2714,7 +2714,7 @@ generate_custom_headers(){ ); } - for (int i = 0; i < struct_count; ++i){ + for (int32_t i = 0; i < struct_count; ++i){ String name = struct_set.structs[i].name; fprintf(file, "
      • " @@ -2731,7 +2731,7 @@ generate_custom_headers(){ #define SECTION MAJOR_SECTION".3" fprintf(file, "

        §"SECTION" Function Descriptions

        \n"); - for (int i = 0; i < sig_count; ++i){ + for (int32_t i = 0; i < sig_count; ++i){ String name = app_function_set.public_name[i]; fprintf(file, @@ -2754,8 +2754,8 @@ generate_custom_headers(){ #define SECTION MAJOR_SECTION".4" fprintf(file, "

        §"SECTION" Type Descriptions

        \n"); - int I = 1; - for (int i = 0; i < typedef_count; ++i, ++I){ + int32_t I = 1; + for (int32_t i = 0; i < typedef_count; ++i, ++I){ String name = typedef_set.name[i]; String type = typedef_set.type[i]; @@ -2799,7 +2799,7 @@ generate_custom_headers(){ fprintf(file, "

\n"); } - for (int i = 0; i < enum_count; ++i, ++I){ + for (int32_t i = 0; i < enum_count; ++i, ++I){ String name = enum_set.name[i]; fprintf(file, @@ -2860,7 +2860,7 @@ generate_custom_headers(){ fprintf(file, "

\n"); } - for (int i = 0; i < flag_count; ++i, ++I){ + for (int32_t i = 0; i < flag_count; ++i, ++I){ String name = flag_set.name[i]; fprintf(file, @@ -2922,7 +2922,7 @@ generate_custom_headers(){ fprintf(file, "

\n"); } - for (int i = 0; i < struct_count; ++i, ++I){ + for (int32_t i = 0; i < struct_count; ++i, ++I){ Struct_Member *member = &struct_set.structs[i]; String name = member->name; fprintf(file, @@ -2999,17 +2999,17 @@ generate_custom_headers(){ "
    \n"); String *used_strings = 0; - int used_string_count = 0; + int32_t used_string_count = 0; { - int memory_size = sizeof(String)*(string_sig_count); + int32_t memory_size = sizeof(String)*(string_sig_count); used_strings = (String*)malloc(memory_size); memset(used_strings, 0, memory_size); } - for (int i = 0; i < string_sig_count; ++i){ + for (int32_t i = 0; i < string_sig_count; ++i){ String name = string_function_set.name[i]; - int index = 0; + int32_t index = 0; if (!string_set_match(used_strings, used_string_count, name, &index)){ fprintf(file, "
  • " @@ -3032,10 +3032,10 @@ generate_custom_headers(){ "

    §"SECTION" String Function Descriptions

    \n" "
      \n"); - for (int i = 0; i < string_sig_count; ++i){ + for (int32_t i = 0; i < string_sig_count; ++i){ String name = string_function_set.name[i]; - int index = 0; - int do_id = false; + int32_t index = 0; + int32_t do_id = false; if (!string_set_match(used_strings, used_string_count, name, &index)){ do_id = true; used_strings[used_string_count++] = name; diff --git a/4ed_rendering.cpp b/4ed_rendering.cpp index fa9d1a67..20cd79b4 100644 --- a/4ed_rendering.cpp +++ b/4ed_rendering.cpp @@ -171,7 +171,7 @@ struct Render_Quad{ }; inline Render_Quad -get_render_quad(Glyph_Data *b, int pw, int ph, float xpos, float ypos){ +get_render_quad(Glyph_Data *b, i32 pw, i32 ph, float xpos, float ypos){ Render_Quad q; float ipw = 1.0f / pw, iph = 1.0f / ph; @@ -190,7 +190,7 @@ get_render_quad(Glyph_Data *b, int pw, int ph, float xpos, float ypos){ } inline Render_Quad -get_exact_render_quad(Glyph_Data *b, int pw, int ph, float xpos, float ypos){ +get_exact_render_quad(Glyph_Data *b, i32 pw, i32 ph, float xpos, float ypos){ Render_Quad q; float ipw = 1.0f / pw, iph = 1.0f / ph; @@ -342,7 +342,7 @@ launch_rendering(Render_Target *target){ #undef ExtractStruct internal void* -part_alloc(int size, void *context){ +part_alloc(i32 size, void *context){ Partition *part = (Partition*)context; void *result = push_block(part, size); return(result); @@ -561,10 +561,10 @@ font_load_freetype(Partition *part, rf->height -= rf->line_skip; rf->line_skip = 0; - int max_glyph_w = face->size->metrics.x_ppem; - int max_glyph_h = rf->height; - int tex_width = 64; - int tex_height = 0; + i32 max_glyph_w = face->size->metrics.x_ppem; + i32 max_glyph_h = rf->height; + i32 tex_width = 64; + i32 tex_height = 0; // estimate upper bound on texture width do { @@ -576,8 +576,8 @@ font_load_freetype(Partition *part, tex_height = next_pow_of_2(tex_height); - int pen_x = 0; - int pen_y = 0; + i32 pen_x = 0; + i32 pen_y = 0; u32* pixels = push_array(part, u32, tex_width * tex_height); memset(pixels, 0, tex_width * tex_height * sizeof(u32)); @@ -597,11 +597,11 @@ font_load_freetype(Partition *part, } } - for(int i = 0; i < NUM_GLYPHS; ++i){ + for(i32 i = 0; i < NUM_GLYPHS; ++i){ if(FT_Load_Char(face, i, FT_LOAD_RENDER | ft_extra_flags) != 0) continue; - int w = face->glyph->bitmap.width; - int h = face->glyph->bitmap.rows; + i32 w = face->glyph->bitmap.width; + i32 h = face->glyph->bitmap.rows; // lcd filter produces RGB bitmaps, need to account for the extra components if(use_lcd_filter){ @@ -635,13 +635,13 @@ font_load_freetype(Partition *part, rf->glyphs[i].exists = 1; - int pitch = face->glyph->bitmap.pitch; + i32 pitch = face->glyph->bitmap.pitch; // write to texture atlas - for(int j = 0; j < h; ++j){ - for(int i = 0; i < w; ++i){ - int x = pen_x + i; - int y = pen_y + j; + for(i32 j = 0; j < h; ++j){ + for(i32 i = 0; i < w; ++i){ + i32 x = pen_x + i; + i32 y = pen_y + j; if(use_lcd_filter){ #if 1 diff --git a/4ed_system.h b/4ed_system.h index 826d21d5..b458829e 100644 --- a/4ed_system.h +++ b/4ed_system.h @@ -19,9 +19,9 @@ handle_zero(void){ return(result); } -inline int +inline int32_t handle_equal(Plat_Handle a, Plat_Handle b){ - int result = (memcmp(&a, &b, sizeof(a)) == 0); + int32_t result = (memcmp(&a, &b, sizeof(a)) == 0); return(result); } diff --git a/4ed_template.cpp b/4ed_template.cpp deleted file mode 100644 index fc1abfcf..00000000 --- a/4ed_template.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 01.03.2016 - * - * Templated code. - * - */ - -// TOP - -// NOTE(allen): This is an experiment, BUT remember a lot of people shit on templates. -// So if you start getting a wiff of stupidity from this back out immediately! -// -// experience 1: no badness, haven't seen any annoying template errors -// ... - -template -inline void -dll_init_sentinel(T *sentinel){ - sentinel->next = sentinel; - sentinel->prev = sentinel; -} - -template -inline void -dll_insert(T *pos, T *v){ - v->next = pos->next; - v->prev = pos; - pos->next = v; - v->next->prev = v; -} - -template -inline void -dll_insert_back(T *pos, T *v){ - v->prev = pos->prev; - v->next = pos; - pos->prev = v; - v->prev->next = v; -} - -template -inline void -dll_remove(T *v){ - v->next->prev = v->prev; - v->prev->next = v->next; -} - -// for(dll_items(iterator, sentinel_ptr)){...} -#define dll_items(it, st) ((it) = (st)->next); ((it) != (st)); ((it) = (it)->next) - -// BOTTOM - diff --git a/build.c b/build.c index df7c2c5d..3a3facd2 100644 --- a/build.c +++ b/build.c @@ -33,7 +33,7 @@ #endif static char cmd[1024]; -static int error_state = 0; +static int32_t error_state = 0; #define systemf(...) do{\ int32_t n = snprintf(cmd, sizeof(cmd), __VA_ARGS__);\ @@ -269,6 +269,20 @@ int main(int argc, char **argv){ #define META_DIR "../meta" #define BUILD_DIR "../build" +#if 0 + { + BEGIN_TIME_SECTION(); + build(OPTS, cdir, "fsm_table_generator.cpp", + BUILD_DIR, "fsmgen", 0); + END_TIME_SECTION("build fsm generator"); + } + { + BEGIN_TIME_SECTION(); + execute(cdir, BUILD_DIR"/fsmgen"); + END_TIME_SECTION("run fsm generator"); + } +#endif + { BEGIN_TIME_SECTION(); build(OPTS | DEBUG_INFO, cdir, "4ed_metagen.cpp", diff --git a/fsm_table_generator.cpp b/fsm_table_generator.cpp index 3a400ac4..0a02481b 100644 --- a/fsm_table_generator.cpp +++ b/fsm_table_generator.cpp @@ -9,11 +9,8 @@ /* TODO(allen): -Next Time: -Finish linking from one FSM to the next in the keyword recognizer. - -1. Make sure each FSM follows the rules about state types correctly. -2. Make a look up table from final states to resulting token types. +1. Eliminate the complicated preprocessor directive parsing tables +2. Establish a clean systematic way of maintaining whatever is left */ @@ -21,12 +18,18 @@ Finish linking from one FSM to the next in the keyword recognizer. #include #include #include +#include #define ArrayCount(a) (sizeof(a)/sizeof(*a)) -#include "../4cpp_lexer_types.h" +#include "4cpp_lexer_types.h" #include "4cpp_lexer_fsms.h" +struct String_And_Flag{ + char *str; + uint32_t flags; +}; + static String_And_Flag preprop_strings[] = { {"include", CPP_PP_INCLUDE}, {"INCLUDE", CPP_PP_INCLUDE}, @@ -147,12 +150,12 @@ static String_And_Flag keyword_strings[] = { {"thread_local", CPP_TOKEN_KEY_OTHER}, }; -struct FSM_State{ - unsigned int transition_rule[256]; - unsigned char override; -}; +typedef struct FSM_State{ + uint32_t transition_rule[256]; + uint8_t override; +} FSM_State; -struct FSM{ +typedef struct FSM{ FSM_State *states; unsigned short count, max; @@ -162,47 +165,47 @@ struct FSM{ unsigned char terminal_base; char *comment; -}; +} FSM; -struct FSM_Stack{ +typedef struct FSM_Stack{ FSM *fsms; - int count, max; + int32_t count, max; - unsigned char table_transition_state; - unsigned char final_state; -}; + uint8_t table_transition_state; + uint8_t final_state; +} FSM_Stack; -struct Match_Node{ +typedef struct Match_Node{ Match_Node *first_child; Match_Node *next_sibling; - int *words; - int count, max; - int index; + int32_t *words; + int32_t count, max; + int32_t index; FSM_State *state; -}; +} Match_Node; -struct Match_Tree{ +typedef struct Match_Tree{ Match_Node *nodes; - int count, max; -}; + int32_t count, max; +} Match_Tree; -struct Match_Tree_Stack{ +typedef struct Match_Tree_Stack{ Match_Tree *trees; - int count, max; -}; + int32_t count, max; +} Match_Tree_Stack; -struct Future_FSM{ +typedef struct Future_FSM{ Match_Node *source; -}; +} Future_FSM; -struct Future_FSM_Stack{ +typedef struct Future_FSM_Stack{ Future_FSM *futures; - int count, max; -}; + int32_t count, max; +} Future_FSM_Stack; -FSM* +static FSM* get_fsm(FSM_Stack *stack){ FSM* result = 0; assert(stack->count < stack->max); @@ -211,7 +214,7 @@ get_fsm(FSM_Stack *stack){ return(result); } -Match_Tree* +static Match_Tree* get_tree(Match_Tree_Stack *stack){ Match_Tree* result = 0; assert(stack->count < stack->max); @@ -219,10 +222,10 @@ get_tree(Match_Tree_Stack *stack){ return(result); } -FSM -fsm_init(unsigned short max, unsigned char terminal_base){ +static FSM +fsm_init(uint16_t max, uint8_t terminal_base){ FSM fsm; - int memsize; + int32_t memsize; fsm.max = max; fsm.count = 0; memsize = sizeof(FSM_State)*fsm.max; @@ -238,18 +241,18 @@ fsm_init(unsigned short max, unsigned char terminal_base){ return(fsm); } -void +static void fsm_add_comment(FSM *fsm, char *str){ - int comment_len; - int str_len; + int32_t comment_len; + int32_t str_len; char *new_comment; - str_len = (int)strlen(str); + str_len = (int32_t)strlen(str); if (fsm->comment != 0){ - comment_len = (int)strlen(fsm->comment); + comment_len = (int32_t)strlen(fsm->comment); new_comment = (char*)malloc(str_len + comment_len + 1); - + memcpy(new_comment, fsm->comment, comment_len); memcpy(new_comment + comment_len, str, str_len); new_comment[comment_len + str_len] = 0; @@ -264,10 +267,10 @@ fsm_add_comment(FSM *fsm, char *str){ } } -Match_Tree -tree_init(unsigned short max){ +static Match_Tree +tree_init(uint16_t max){ Match_Tree tree; - int memsize; + int32_t memsize; tree.max = max; tree.count = 0; memsize = sizeof(Match_Node)*tree.max; @@ -275,19 +278,19 @@ tree_init(unsigned short max){ return(tree); } -unsigned char +static uint8_t push_future_fsm(Future_FSM_Stack *stack, Match_Node *node){ - unsigned char index = 0; + uint8_t index = 0; Future_FSM *future = 0; assert(stack->count < stack->max); assert(stack->max < 256); - index = (unsigned char)(stack->count++); + index = (uint8_t)(stack->count++); future = &stack->futures[index]; future->source = node; return(index); } -Match_Node* +static Match_Node* match_get_node(Match_Tree *tree){ Match_Node *result; assert(tree->count < tree->max); @@ -295,33 +298,33 @@ match_get_node(Match_Tree *tree){ return(result); } -void -match_init_node(Match_Node *node, int match_count){ +static void +match_init_node(Match_Node *node, int32_t match_count){ *node = {}; - node->words = (int*)malloc(sizeof(int)*match_count); + node->words = (int32_t*)malloc(sizeof(int32_t)*match_count); node->max = match_count; } -void +static void match_copy_init_node(Match_Node *node, Match_Node *source){ *node = {}; node->max = source->count; node->count = source->count; - node->words = (int*)malloc(sizeof(int)*source->count); + node->words = (int32_t*)malloc(sizeof(int32_t)*source->count); node->index = source->index; - memcpy(node->words, source->words, sizeof(int)*source->count); + memcpy(node->words, source->words, sizeof(int32_t)*source->count); } -void -match_add_word(Match_Node *node, int word){ +static void +match_add_word(Match_Node *node, int32_t word){ assert(node->count < node->max); node->words[node->count++] = word; } -FSM_State* -fsm_get_state(FSM *fsm, unsigned int terminal_base){ +static FSM_State* +fsm_get_state(FSM *fsm, uint32_t terminal_base){ FSM_State *result; - unsigned short i; + uint16_t i; assert(fsm->count < fsm->max); result = &fsm->states[fsm->count++]; for (i = 0; i < 256; ++i){ @@ -331,13 +334,13 @@ fsm_get_state(FSM *fsm, unsigned int terminal_base){ return(result); } -FSM_State* +static FSM_State* fsm_get_state(FSM *fsm){ FSM_State *result = fsm_get_state(fsm, fsm->terminal_base); return(result); } -FSM_State* +static FSM_State* fsm_get_term_state(FSM *fsm, unsigned char override){ FSM_State *result; assert(fsm->term_count < fsm->term_max); @@ -346,52 +349,52 @@ fsm_get_term_state(FSM *fsm, unsigned char override){ return(result); } -unsigned char +static uint8_t fsm_index(FSM *fsm, FSM_State *s){ - unsigned char result; - result = (unsigned char)(unsigned long long)(s - fsm->states); + uint8_t result; + result = (uint8_t)(uint64_t)(s - fsm->states); if (s->override){ result = fsm->terminal_base + s->override; } return(result); } -void +static void fsm_add_transition(FSM_State *state, char c, unsigned char dest){ state->transition_rule[c] = dest; } struct Terminal_Lookup_Table{ - unsigned int state_to_type[60]; - unsigned char type_to_state[CPP_TOKEN_TYPE_COUNT]; - unsigned char state_count; + uint32_t state_to_type[60]; + uint8_t type_to_state[CPP_TOKEN_TYPE_COUNT]; + uint8_t state_count; }; -void +static void process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, FSM *fsm){ - int next_index = node->index + 1; - int match_count = node->count; + int32_t next_index = node->index + 1; + int32_t match_count = node->count; FSM_State *this_state = node->state; - unsigned char terminal_base = fsm->terminal_base; + uint8_t terminal_base = fsm->terminal_base; - int i, j, *words = node->words; + int32_t i, j, *words = node->words; String_And_Flag saf; - int l; + int32_t l; char c; Match_Node *next_nodes[256]; Match_Node *newest_child = 0; Match_Node *n; - unsigned char unjunkify = 0; + uint8_t unjunkify = 0; memset(next_nodes, 0, sizeof(next_nodes)); for (i = 0; i < match_count; ++i){ j = words[i]; saf = input[j]; - l = (int)strlen(saf.str); + l = (int32_t)strlen(saf.str); if (next_index < l){ c = saf.str[next_index]; @@ -436,13 +439,13 @@ process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, F } } -FSM +static FSM generate_pp_directive_fsm(){ Match_Tree tree; FSM fsm; Match_Node *root_node; FSM_State *root_state; - int i; + int32_t i; fsm = fsm_init(200, 200); tree = tree_init(200); @@ -480,9 +483,9 @@ Each state needs a full set of transition rules. Most transitions should go int #define RealTerminateBase 65536 -int +static int32_t char_is_alphanumeric(char x){ - int result = 0; + int32_t result = 0; if ((x >= '0' && x <= '9') || (x >= 'A' && x <= 'Z') || (x >= 'a' && x <= 'z') || @@ -492,20 +495,20 @@ char_is_alphanumeric(char x){ return(result); } -void +static void process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, FSM *fsm, - Terminal_Lookup_Table *terminal_table, int levels_to_go, + Terminal_Lookup_Table *terminal_table, int32_t levels_to_go, Future_FSM_Stack *unfinished_fsms){ - int next_index = node->index + 1; - int match_count = node->count; - int *words = node->words; + int32_t next_index = node->index + 1; + int32_t match_count = node->count; + int32_t *words = node->words; FSM_State *this_state = node->state; - int word_index = 0; - int good_transition = 0; - int len = 0; - int i = 0; + int32_t word_index = 0; + int32_t good_transition = 0; + int32_t len = 0; + int32_t i = 0; String_And_Flag saf = {0}; @@ -514,15 +517,15 @@ process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, F Match_Node *n = 0; char c = 0; - unsigned char override = 0; + uint8_t override = 0; memset(next_nodes, 0, sizeof(next_nodes)); - + for (i = 0; i < match_count; ++i){ word_index = words[i]; saf = input[word_index]; - len = (int)strlen(saf.str); + len = (int32_t)strlen(saf.str); if (next_index < len){ c = saf.str[next_index]; @@ -1041,73 +1044,73 @@ main_fsm(Lex_FSM fsm, unsigned char pp_state, unsigned char c){ return(fsm); } -void +static void begin_table(FILE *file, char *type, char *group_name, char *table_name){ - fprintf(file, "unsigned %s %s_%s[] = {\n", type, group_name, table_name); + fprintf(file, "%s %s_%s[] = {\n", type, group_name, table_name); } -void +static void begin_table(FILE *file, char *type, char *table_name){ - fprintf(file, "unsigned %s %s[] = {\n", type, table_name); + fprintf(file, "%s %s[] = {\n", type, table_name); } -void +static void begin_ptr_table(FILE *file, char *type, char *table_name){ - fprintf(file, "unsigned %s * %s[] = {\n", type, table_name); + fprintf(file, "%s * %s[] = {\n", type, table_name); } -void -do_table_item(FILE *file, unsigned short item){ - fprintf(file, "%2d,", (int)item); +static void +do_table_item(FILE *file, uint16_t item){ + fprintf(file, "%2d,", (int32_t)item); } -void +static void do_table_item_direct(FILE *file, char *item, char *tail){ fprintf(file, "%s%s,", item, tail); } -void +static void end_row(FILE *file){ fprintf(file, "\n"); } -void +static void end_table(FILE *file){ fprintf(file, "};\n\n"); } -struct FSM_Tables{ - unsigned char *full_transition_table; - unsigned char *marks; - unsigned char *eq_class; - unsigned char *eq_class_rep; - unsigned char *reduced_transition_table; +typedef struct FSM_Tables{ + uint8_t *full_transition_table; + uint8_t *marks; + uint8_t *eq_class; + uint8_t *eq_class_rep; + uint8_t *reduced_transition_table; + + uint8_t eq_class_counter; + uint16_t state_count; +} FSM_Tables; - unsigned char eq_class_counter; - unsigned short state_count; -}; - -void -allocate_full_tables(FSM_Tables *table, unsigned char state_count){ - table->full_transition_table = (unsigned char*)malloc(state_count * 256); - table->marks = (unsigned char*)malloc(state_count * 256); - table->eq_class = (unsigned char*)malloc(state_count * 256); - table->eq_class_rep = (unsigned char*)malloc(state_count * 256); +static void +allocate_full_tables(FSM_Tables *table, uint8_t state_count){ + table->full_transition_table = (uint8_t*)malloc(state_count * 256); + table->marks = (uint8_t*)malloc(state_count * 256); + table->eq_class = (uint8_t*)malloc(state_count * 256); + table->eq_class_rep = (uint8_t*)malloc(state_count * 256); table->state_count = state_count; memset(table->marks, 0, 256); } -void -do_table_reduction(FSM_Tables *table, unsigned short state_count){ +static void +do_table_reduction(FSM_Tables *table, uint16_t state_count){ { table->eq_class_counter = 0; - unsigned char *c_line = table->full_transition_table; - for (unsigned short c = 0; c < 256; ++c){ + uint8_t *c_line = table->full_transition_table; + for (uint16_t c = 0; c < 256; ++c){ if (table->marks[c] == 0){ table->eq_class[c] = table->eq_class_counter; - table->eq_class_rep[table->eq_class_counter] = (unsigned char)c; - unsigned char *c2_line = c_line + state_count; - for (unsigned short c2 = c + 1; c2 < 256; ++c2){ + table->eq_class_rep[table->eq_class_counter] = (uint8_t)c; + uint8_t *c2_line = c_line + state_count; + for (uint16_t c2 = c + 1; c2 < 256; ++c2){ if (memcmp(c_line, c2_line, state_count) == 0){ table->marks[c2] = 1; table->eq_class[c2] = table->eq_class_counter; @@ -1119,102 +1122,102 @@ do_table_reduction(FSM_Tables *table, unsigned short state_count){ c_line += state_count; } } - - table->reduced_transition_table = (unsigned char*)malloc(state_count * table->eq_class_counter); + + table->reduced_transition_table = (uint8_t*)malloc(state_count * table->eq_class_counter); { - unsigned char *r_line = table->reduced_transition_table; - for (unsigned short eq = 0; eq < table->eq_class_counter; ++eq){ - unsigned char *u_line = table->full_transition_table + state_count * table->eq_class_rep[eq]; + uint8_t *r_line = table->reduced_transition_table; + for (uint16_t eq = 0; eq < table->eq_class_counter; ++eq){ + uint8_t *u_line = table->full_transition_table + state_count * table->eq_class_rep[eq]; memcpy(r_line, u_line, state_count); r_line += state_count; } } } -FSM_Tables +static FSM_Tables generate_whitespace_skip_table(){ - unsigned char state_count = LSPP_count; + uint8_t state_count = LSPP_count; FSM_Tables table; allocate_full_tables(&table, state_count); - - int i = 0; + + int32_t i = 0; Whitespace_FSM wfsm = {0}; Whitespace_FSM new_wfsm; - for (unsigned short c = 0; c < 256; ++c){ - for (unsigned char state = 0; state < state_count; ++state){ + for (uint16_t c = 0; c < 256; ++c){ + for (uint8_t state = 0; state < state_count; ++state){ wfsm.pp_state = state; wfsm.white_done = 0; - new_wfsm = whitespace_skip_fsm(wfsm, (unsigned char)c); + new_wfsm = whitespace_skip_fsm(wfsm, (uint8_t)c); table.full_transition_table[i++] = new_wfsm.pp_state + state_count*new_wfsm.white_done; } } - + do_table_reduction(&table, state_count); - + return(table); } -FSM_Tables +static FSM_Tables generate_int_table(){ - unsigned char state_count = LSINT_count; + uint8_t state_count = LSINT_count; FSM_Tables table; allocate_full_tables(&table, state_count); - - int i = 0; + + int32_t i = 0; Lex_FSM fsm = {0}; Lex_FSM new_fsm; - for (unsigned short c = 0; c < 256; ++c){ - for (unsigned char state = 0; state < state_count; ++state){ + for (uint16_t c = 0; c < 256; ++c){ + for (uint8_t state = 0; state < state_count; ++state){ fsm.int_state = state; fsm.emit_token = 0; - new_fsm = int_fsm(fsm, (unsigned char)c); + new_fsm = int_fsm(fsm, (uint8_t)c); table.full_transition_table[i++] = new_fsm.int_state + state_count*new_fsm.emit_token; } } - + do_table_reduction(&table, state_count); - + return(table); } -FSM_Tables -generate_fsm_table(unsigned char pp_state){ - unsigned char state_count = LS_count; +static FSM_Tables +generate_fsm_table(uint8_t pp_state){ + uint8_t state_count = LS_count; FSM_Tables table; allocate_full_tables(&table, state_count); - - int i = 0; + + int32_t i = 0; Lex_FSM fsm = {0}; Lex_FSM new_fsm; - for (unsigned short c = 0; c < 256; ++c){ - for (unsigned char state = 0; state < state_count; ++state){ + for (uint16_t c = 0; c < 256; ++c){ + for (uint8_t state = 0; state < state_count; ++state){ fsm.state = state; fsm.emit_token = 0; - new_fsm = main_fsm(fsm, pp_state, (unsigned char)c); + new_fsm = main_fsm(fsm, pp_state, (uint8_t)c); table.full_transition_table[i++] = new_fsm.state + state_count*new_fsm.emit_token; } } - + do_table_reduction(&table, state_count); - + return(table); } -void +static void render_fsm_table(FILE *file, FSM_Tables tables, char *group_name){ - begin_table(file, "short", group_name, "eq_classes"); - for (unsigned short c = 0; c < 256; ++c){ + begin_table(file, "uint16_t", group_name, "eq_classes"); + for (uint16_t c = 0; c < 256; ++c){ do_table_item(file, tables.eq_class[c]*tables.state_count); } end_row(file); end_table(file); - - fprintf(file, "const int num_%s_eq_classes = %d;\n\n", group_name, tables.eq_class_counter); - - int i = 0; - begin_table(file, "char", group_name, "table"); - for (unsigned short c = 0; c < tables.eq_class_counter; ++c){ - for (unsigned char state = 0; state < tables.state_count; ++state){ + + fprintf(file, "const int32_t num_%s_eq_classes = %d;\n\n", group_name, tables.eq_class_counter); + + int32_t i = 0; + begin_table(file, "uint8_t", group_name, "table"); + for (uint16_t c = 0; c < tables.eq_class_counter; ++c){ + for (uint8_t state = 0; state < tables.state_count; ++state){ do_table_item(file, tables.reduced_transition_table[i++]); } end_row(file); @@ -1222,22 +1225,22 @@ render_fsm_table(FILE *file, FSM_Tables tables, char *group_name){ end_table(file); } -void -render_variable(FILE *file, char *type, char *variable, unsigned int x){ +static void +render_variable(FILE *file, char *type, char *variable, uint32_t x){ fprintf(file, "%s %s = %d;\n\n", type, variable, x); } -void +static void render_comment(FILE *file, char *comment){ fprintf(file, "/*\n%s*/\n", comment); } -struct PP_Names{ - unsigned char pp_state; +typedef struct PP_Names{ + uint8_t pp_state; char *name; -}; +} PP_Names; -PP_Names pp_names[] = { +static PP_Names pp_names[] = { {LSPP_default, "main_fsm"}, {LSPP_include, "pp_include_fsm"}, {LSPP_macro_identifier, "pp_macro_fsm"}, @@ -1249,25 +1252,25 @@ PP_Names pp_names[] = { {LSPP_junk, "pp_junk_fsm"}, }; -FSM_Tables -generate_table_from_abstract_fsm(FSM fsm, unsigned char real_term_base){ - unsigned char state_count = (unsigned char)fsm.count; +static FSM_Tables +generate_table_from_abstract_fsm(FSM fsm, uint8_t real_term_base){ + uint8_t state_count = (uint8_t )fsm.count; FSM_Tables table; allocate_full_tables(&table, state_count); - - int i = 0; - unsigned int new_state; - for (unsigned short c = 0; c < 256; ++c){ - for (unsigned char state = 0; state < state_count; ++state){ + + int32_t i = 0; + uint32_t new_state; + for (uint16_t c = 0; c < 256; ++c){ + for (uint8_t state = 0; state < state_count; ++state){ new_state = fsm.states[state].transition_rule[c]; if (new_state >= RealTerminateBase){ new_state = new_state - RealTerminateBase + real_term_base; } - table.full_transition_table[i++] = (unsigned char)new_state; + table.full_transition_table[i++] = (uint8_t)new_state; } } - + do_table_reduction(&table, state_count); return(table); @@ -1284,28 +1287,28 @@ main(){ FSM_Tables itables = generate_int_table(); render_fsm_table(file, itables, "int_fsm"); - begin_table(file, "char", "multiline_state_table"); - for (unsigned char state = 0; state < LS_count; ++state){ + begin_table(file, "uint8_t", "multiline_state_table"); + for (uint8_t state = 0; state < LS_count; ++state){ do_table_item(file, (state == LS_string_multiline || state == LS_char_multiline)); } end_row(file); end_table(file); - for (int i = 0; i < ArrayCount(pp_names); ++i){ + for (int32_t i = 0; i < ArrayCount(pp_names); ++i){ assert(i == pp_names[i].pp_state); FSM_Tables tables = generate_fsm_table(pp_names[i].pp_state); render_fsm_table(file, tables, pp_names[i].name); } - begin_ptr_table(file, "short", "get_eq_classes"); - for (int i = 0; i < ArrayCount(pp_names); ++i){ + begin_ptr_table(file, "uint16_t", "get_eq_classes"); + for (int32_t i = 0; i < ArrayCount(pp_names); ++i){ do_table_item_direct(file, pp_names[i].name, "_eq_classes"); end_row(file); } end_table(file); - begin_ptr_table(file, "char", "get_table"); - for (int i = 0; i < ArrayCount(pp_names); ++i){ + begin_ptr_table(file, "uint8_t", "get_table"); + for (int32_t i = 0; i < ArrayCount(pp_names); ++i){ do_table_item_direct(file, pp_names[i].name, "_table"); end_row(file); } @@ -1315,10 +1318,10 @@ main(){ FSM_Tables pp_directive_tables = generate_table_from_abstract_fsm(pp_directive_fsm, 0); render_fsm_table(file, pp_directive_tables, "pp_directive"); - render_variable(file, "unsigned char", "LSDIR_default", 0); - render_variable(file, "unsigned char", "LSDIR_count", pp_directive_fsm.count); - render_variable(file, "unsigned char", "pp_directive_terminal_base", pp_directive_fsm.terminal_base); - + render_variable(file, "uint8_t", "LSDIR_default", 0); + render_variable(file, "uint8_t", "LSDIR_count", pp_directive_fsm.count); + render_variable(file, "uint8_t", "pp_directive_terminal_base", pp_directive_fsm.terminal_base); + fclose(file); return(0); } diff --git a/internal_4coder_string.cpp b/internal_4coder_string.cpp index f456e71e..dd3339b6 100644 --- a/internal_4coder_string.cpp +++ b/internal_4coder_string.cpp @@ -170,7 +170,7 @@ DOC_EXPORT /* DOC(This macro takes a local char array with a fixed width and use an empty String with the correct size and memory size to operate on the array.) */ #define make_fixed_width_string(s) (make_string_cap((char*)(s), 0, sizeof(s))) -DOC_EXPORT /* DOC(This macro is a helper for any calls that take a char*,int pair to specify a +DOC_EXPORT /* DOC(This macro is a helper for any calls that take a char*,integer pair to specify a string. This macro expands to both of those parameters from one String struct.) */ #define expand_str(s) ((s).str), ((s).size) @@ -227,7 +227,7 @@ skip_whitespace(String str) Like other substr calls, the new string uses the underlying memory and so should usually be considered immutable.) DOC_SEE(substr) */{ String result = {0}; - int i = 0; + int32_t i = 0; for (; i < str.size && char_is_whitespace(str.str[i]); ++i); result = substr(str, i, str.size - i); return(result); @@ -239,7 +239,7 @@ chop_whitespace(String str) Like other substr calls, the new string uses the underlying memory and so should usually be considered immutable.) DOC_SEE(substr) */{ String result = {0}; - int i = str.size; + int32_t i = str.size; for (; i > 0 && char_is_whitespace(str.str[i-1]); --i); result = substr(str, 0, i); return(result); @@ -1452,13 +1452,13 @@ DOC(This call interprets s as a color and writes the 32-bit integer representati uint32_t color = 0; if (s.size == 6){ result = 1; - color = (unsigned int)hexstr_to_int(s); + color = (uint32_t)hexstr_to_int(s); color |= (0xFF << 24); *out = color; } else if (s.size == 8){ result = 1; - color = (unsigned int)hexstr_to_int(s); + color = (uint32_t)hexstr_to_int(s); *out = color; } return(result); diff --git a/internal_4coder_tests.cpp b/internal_4coder_tests.cpp index 2279e73d..60154809 100644 --- a/internal_4coder_tests.cpp +++ b/internal_4coder_tests.cpp @@ -43,9 +43,9 @@ CUSTOM_COMMAND_SIG(load_lots_of_files){ String str = make_fixed_width_string(space); append_ss(&str, make_lit_string(LOTS_OF_FILES)); append_s_char(&str, '/'); - int size = str.size; + int32_t size = str.size; - for (int i = 0; i < list.count; ++i, ++info){ + for (int32_t i = 0; i < list.count; ++i, ++info){ if (!info->folder){ append_ss(&str, make_string(info->filename, info->filename_len)); Buffer_Summary buffer = app->create_buffer(app, str.str, str.size, diff --git a/not_shipping_4coder_default_view.cpp b/not_shipping_4coder_default_view.cpp index 122a2da3..b8112091 100644 --- a/not_shipping_4coder_default_view.cpp +++ b/not_shipping_4coder_default_view.cpp @@ -1,6 +1,6 @@ struct Custom_Vars{ - int initialized; + int32_t initialized; Partition part; }; @@ -9,13 +9,13 @@ enum View_Mode{ }; struct View_Vars{ - int id; + int32_t id; View_Mode mode; GUI_Scroll_Vars scroll; i32_Rect scroll_region; - int buffer_id; + int32_t buffer_id; }; inline View_Vars view_vars_zero(){ @@ -24,12 +24,12 @@ view_vars_zero(){ } extern "C" void -view_routine(Application_Links *app, int view_id){ +view_routine(Application_Links *app, int32_t view_id){ Custom_Vars *vars = (Custom_Vars*)app->memory; View_Vars view = {0}; view.id = view_id; - int show_scrollbar = 1; + int32_t show_scrollbar = 1; if (!vars->initialized){ vars->initialized = 1; diff --git a/readme_generator.c b/readme_generator.c index 5ff48b0b..5e5ddbe6 100644 --- a/readme_generator.c +++ b/readme_generator.c @@ -12,6 +12,7 @@ #include #include #include +#include char *header = "Distribution Date: %d.%d.%d (dd.mm.yyyy)\n" @@ -25,13 +26,13 @@ char *header = ; typedef struct Readme_Variables{ - int day, month, year; + int32_t day, month, year; } Readme_Variables; typedef struct File_Data{ char *data; - int size; - int file_exists; + int32_t size; + int32_t file_exists; } File_Data; File_Data diff --git a/dll_reader.cpp b/test/dll_reader.cpp similarity index 93% rename from dll_reader.cpp rename to test/dll_reader.cpp index 11bfeaa7..3871d591 100644 --- a/dll_reader.cpp +++ b/test/dll_reader.cpp @@ -6,7 +6,7 @@ * Application layer for project codename "4ed" * */ - + // TOP #include "4ed_meta.h" @@ -17,7 +17,7 @@ i32 compare(char *a, char *b, i32 len){ i32 result; char *e; - + result = 0; e = a + len; for (;a < e && *a == *b; ++a, ++b); @@ -25,7 +25,7 @@ compare(char *a, char *b, i32 len){ if (*a < *b) result = -1; else result = 1; } - + return(result); } @@ -37,7 +37,7 @@ Data load_file(char *filename){ Data result; FILE * file; - + result = {}; file = fopen(filename, "rb"); if (!file){ @@ -63,11 +63,11 @@ show_reloc_block(Data file, DLL_Data *dll, PE_Section_Definition *reloc_section) u32 cursor; u32 bytes_in_table; u32 block_end; - + base = file.data + reloc_section->disk_location; if (dll->is_64bit) bytes_in_table = dll->opt_header_64->data_directory[image_dir_base_reloc_table].size; else bytes_in_table = dll->opt_header_32->data_directory[image_dir_base_reloc_table].size; - + for (cursor = 0; cursor < bytes_in_table;){ header = (Relocation_Block_Header*)(base + cursor); block_end = cursor + header->block_size; @@ -86,7 +86,7 @@ show_reloc_block(Data file, DLL_Data *dll, PE_Section_Definition *reloc_section) } } -typedef int (Function)(int a, int b); +typedef int32_t (Function)(int a, int b); #include @@ -104,9 +104,9 @@ main(int argc, char **argv){ printf("usage: dll_reader \n"); exit(1); } - + module = LoadLibraryA(argv[1]); - + if (!module){ printf("failed to load file %s\n", argv[1]); exit(1); @@ -126,9 +126,9 @@ main(int argc, char **argv){ printf("usage: dll_reader \n"); exit(1); } - + file = load_file(argv[1]); - + if (!file.data){ printf("failed to load file %s\n", argv[1]); exit(1); @@ -140,7 +140,7 @@ main(int argc, char **argv){ } printf("this appears to be a dll\n"); - + printf("symbol-count: %d symbol-addr: %d\n", dll.coff_header->number_of_symbols, dll.coff_header->pointer_to_symbol_table); @@ -149,7 +149,7 @@ main(int argc, char **argv){ else printf("32bit\n"); printf("built for machine: %s\n", dll_machine_type_str(dll.coff_header->machine, 0)); - + if (dll.is_64bit){ printf("number of directories: %d\n", dll.opt_header_64->number_of_rva_and_sizes); } @@ -158,7 +158,7 @@ main(int argc, char **argv){ } printf("\nbeginning section decode now\n"); - + section_def = dll.section_defs; for (i = 0; i < dll.coff_header->number_of_sections; ++i, ++section_def){ if (section_def->name[7] == 0){ @@ -170,12 +170,12 @@ main(int argc, char **argv){ printf("img-size: %d img-loc: %d\ndisk-size: %d disk-loc: %d\n", section_def->loaded_size, section_def->loaded_location, section_def->disk_size, section_def->disk_location); - + if (compare(section_def->name, ".reloc", 6) == 0){ show_reloc_block(file, &dll, section_def); } } - + img.size = dll_total_loaded_size(&dll); printf("image size: %d\n", img.size); @@ -184,7 +184,7 @@ main(int argc, char **argv){ MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); dll_load(img, &dll_loaded, file, &dll); - + DWORD _extra; VirtualProtect(img.data + dll_loaded.text_start, dll_loaded.text_size, diff --git a/win32_4ed.cpp b/win32_4ed.cpp index fe8e109e..773661cd 100644 --- a/win32_4ed.cpp +++ b/win32_4ed.cpp @@ -15,13 +15,13 @@ # include "4coder_default_bindings.cpp" #endif -#include "4ed_meta.h" - #define FSTRING_IMPLEMENTATION #define FSTRING_C #include "4coder_string.h" -#include "4ed_math.cpp" +#include "4ed_meta.h" + +#include "4ed_math.h" #include "4ed_system.h" #include "4ed_rendering.h" @@ -31,31 +31,22 @@ #include #include -#include "filetrack/4tech_file_track.h" #include "filetrack/4tech_file_track_win32.c" #include "system_shared.h" #define SUPPORT_DPI 1 -#define USE_WIN32_FONTS 0 #define USE_FT_FONTS 1 #define FPS 60 #define frame_useconds (1000000 / FPS) -#define WM_4coder_ANIMATE (WM_USER + 1) +#define WM_4coder_ANIMATE (WM_USER + 0) // // Win32_Vars structs // -#if FRED_INTERNAL -struct Debug_Log_Entry{ - u64 time; - i64 message; -}; -#endif - struct Thread_Context{ u32 job_id; b32 running; @@ -78,13 +69,6 @@ struct Thread_Group{ i32 cancel_cv0; }; -#define UseWinDll 1 - -#if UseWinDll == 0 -#include "4ed_dll_reader.h" -#include "4ed_dll_reader.cpp" -#endif - struct Control_Keys{ b8 l_ctrl; b8 r_ctrl; @@ -127,7 +111,7 @@ struct Win32_Input_Chunk{ struct Win32_Coroutine{ Coroutine coroutine; Win32_Coroutine *next; - int done; + i32 done; }; #if FRED_INTERNAL @@ -158,13 +142,8 @@ struct Win32_Vars{ System_Functions system; App_Functions app; Custom_API custom_api; -#if UseWinDll HMODULE app_code; HMODULE custom; -#else - DLL_Loaded app_dll; - DLL_Loaded custom_dll; -#endif Plat_Settings settings; @@ -1627,8 +1606,6 @@ internal b32 Win32LoadAppCode(){ b32 result = 0; App_Get_Functions *get_funcs = 0; - -#if UseWinDll win32vars.app_code = LoadLibraryA("4ed_app.dll"); if (win32vars.app_code){ @@ -1636,44 +1613,6 @@ Win32LoadAppCode(){ GetProcAddress(win32vars.app_code, "app_get_functions"); } -#else - - File_Data file = system_load_file("4ed_app.dll"); - - if (file.got_file){ - i32 error; - DLL_Data dll_data; - if (dll_parse_headers(file.data, &dll_data, &error)){ - Data img; - img.size = dll_total_loaded_size(&dll_data); - img.data = (byte*) - VirtualAlloc((LPVOID)Tbytes(3), img.size, - MEM_COMMIT | MEM_RESERVE, - PAGE_READWRITE); - - dll_load(img, &win32vars.app_dll, file.data, &dll_data); - - DWORD extra_; - VirtualProtect(img.data + win32vars.app_dll.text_start, - win32vars.app_dll.text_size, - PAGE_EXECUTE_READ, - &extra_); - - get_funcs = (App_Get_Functions*) - dll_load_function(&win32vars.app_dll, "app_get_functions", 17); - } - else{ - // TODO(allen): file loading error - } - - Win32FreeMemory(file.data.data); - } - else{ - // TODO(allen): file loading error - } - -#endif - if (get_funcs){ result = 1; win32vars.app = get_funcs(); @@ -2085,7 +2024,7 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ win32vars.input_chunk.pers.mouse_r = 0; b8 *control_keys = win32vars.input_chunk.pers.control_keys; - for (int i = 0; i < MDFR_INDEX_COUNT; ++i) control_keys[i] = 0; + for (i32 i = 0; i < MDFR_INDEX_COUNT; ++i) control_keys[i] = 0; win32vars.input_chunk.pers.controls = control_keys_zero(); }break; @@ -2149,7 +2088,7 @@ WinMain(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow){ - int argc = __argc; + i32 argc = __argc; char **argv = __argv; memset(&win32vars, 0, sizeof(win32vars)); diff --git a/win32_api_impl.cpp b/win32_api_impl.cpp index 6b5595a0..7c86a66a 100644 --- a/win32_api_impl.cpp +++ b/win32_api_impl.cpp @@ -63,7 +63,7 @@ DOC(TODO) } API_EXPORT bool32 -File_Exists(Application_Links *app, char *filename, int len)/* +File_Exists(Application_Links *app, char *filename, int32_t len)/* DOC_PARAM(filename, This parameter specifies the full path to a file; it need not be null terminated.) DOC_PARAM(len, This parameter specifies the length of the filename string.) DOC_RETURN(This call returns non-zero if and only if the file exists.) @@ -91,7 +91,7 @@ DOC_RETURN(This call returns non-zero if and only if the file exists.) } API_EXPORT bool32 -Directory_CD(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)/* +Directory_CD(Application_Links *app, char *dir, int32_t *len, int32_t capacity, char *rel_path, int32_t rel_len)/* DOC_PARAM(dir, This parameter provides a character buffer that stores a directory; it need not be null terminated.) DOC_PARAM(len, This parameter specifies the length of the dir string.) DOC_PARAM(capacity, This parameter specifies the maximum size of the dir string.)