From 92e5c30663a7e309b5dd8ee2b736fb62c4199da0 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 16 Jun 2017 19:10:50 -0400 Subject: [PATCH] Fixed sticky jump bug; working on 32 bit lexer crash --- 4coder_default_framework.h | 10 +++++----- 4coder_default_hooks.cpp | 5 +++++ 4coder_default_include.cpp | 3 ++- 4coder_sticky_jump.cpp | 2 +- 4ed.cpp | 4 ++-- 4ed_app_target.cpp | 4 +++- 4ed_debug_mem.h | 27 ++++++++++++++++++++------- meta/build.cpp | 29 ++++++++++++++++++++++++++++- project.4coder | 1 + 9 files changed, 67 insertions(+), 18 deletions(-) diff --git a/4coder_default_framework.h b/4coder_default_framework.h index a9c654c8..014ce5f1 100644 --- a/4coder_default_framework.h +++ b/4coder_default_framework.h @@ -850,11 +850,11 @@ process_config_file(Application_Links *app){ } // -// Color Scheme +// Color Theme // static void -process_color_scheme_file(Application_Links *app, char *file_name){ +load_color_theme_file(Application_Links *app, char *file_name){ Partition *part = &global_part; FILE *file = fopen(file_name, "rb"); @@ -957,7 +957,7 @@ process_color_scheme_file(Application_Links *app, char *file_name){ } static void -load_color_themes(Application_Links *app){ +load_themes_folder(Application_Links *app){ char folder_name_space[512]; String folder_name = make_fixed_width_string(folder_name_space); folder_name.size = get_4ed_path(app, folder_name_space, sizeof(folder_name_space)); @@ -975,7 +975,7 @@ load_color_themes(Application_Links *app){ append(&file_name, make_string(info->filename, info->filename_len)); if (file_name.size < file_name.memory_size){ terminate_with_null(&file_name); - process_color_scheme_file(app, file_name.str); + load_color_theme_file(app, file_name.str); } } } @@ -1003,7 +1003,7 @@ static void default_4coder_initialize(Application_Links *app, bool32 use_scrollbars, bool32 use_file_bars){ init_memory(app); process_config_file(app); - load_color_themes(app); + load_themes_folder(app); String theme = get_default_theme_name(); String font = get_default_font_name(); diff --git a/4coder_default_hooks.cpp b/4coder_default_hooks.cpp index b8285286..7e3006c1 100644 --- a/4coder_default_hooks.cpp +++ b/4coder_default_hooks.cpp @@ -328,7 +328,12 @@ set_all_default_hooks(Bind_Helper *context){ set_open_file_hook(context, default_file_settings); set_new_file_hook(context, default_new_file); set_save_file_hook(context, default_file_save); + +#if defined(FCODER_STICKY_JUMP) + set_end_file_hook(context, end_file_close_jump_list); +#else set_end_file_hook(context, default_end_file); +#endif set_command_caller(context, default_command_caller); set_input_filter(context, default_suppress_mouse_filter); diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 59779f96..b280af61 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -27,7 +27,6 @@ TYPE: 'major-system-include' #include "4coder_system_command.cpp" #include "4coder_build_commands.cpp" #include "4coder_project_commands.cpp" -#include "4coder_default_hooks.cpp" #include "4coder_function_list.cpp" #if !defined(USE_OLD_STYLE_JUMPS) @@ -35,6 +34,8 @@ TYPE: 'major-system-include' #include "4coder_sticky_jump.cpp" #endif +#include "4coder_default_hooks.cpp" + #include "4coder_helper/4coder_bind_helper.h" #include "4coder_helper/4coder_helper.h" #include "4coder_helper/4coder_streaming.h" diff --git a/4coder_sticky_jump.cpp b/4coder_sticky_jump.cpp index 42f203fb..e4c6c690 100644 --- a/4coder_sticky_jump.cpp +++ b/4coder_sticky_jump.cpp @@ -9,7 +9,6 @@ TYPE: 'drop-in-command-pack' #if !defined(FCODER_STICKY_JUMP) && !defined(FCODER_JUMP_COMMANDS) #define FCODER_STICKY_JUMP - #define FCODER_JUMP_COMMANDS #include "4coder_default_framework.h" @@ -587,6 +586,7 @@ CUSTOM_COMMAND_SIG(newline_or_goto_position_same_panel){ // End File Hook // +OPEN_FILE_HOOK_SIG(default_end_file); OPEN_FILE_HOOK_SIG(end_file_close_jump_list){ Marker_List *list = get_marker_list_for_buffer(buffer_id); if (list != 0){ diff --git a/4ed.cpp b/4ed.cpp index df5f075b..0d24b0bd 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -582,7 +582,7 @@ setup_command_table(){ // App Functions internal void -app_hardcode_styles(Models *models){ +app_hardcode_default_style(Models *models){ Interactive_Style file_info_style = {0}; Style *styles = models->styles.styles; Style *style = styles + 1; @@ -1140,7 +1140,7 @@ App_Init_Sig(app_init){ // NOTE(allen): style setup models->global_font_id = 1; - app_hardcode_styles(models); + app_hardcode_default_style(models); // NOTE(allen): init first panel Command_Data *cmd = &vars->command_data; diff --git a/4ed_app_target.cpp b/4ed_app_target.cpp index 67eddfd0..6480ae19 100644 --- a/4ed_app_target.cpp +++ b/4ed_app_target.cpp @@ -22,7 +22,9 @@ #include "4ed_system.h" #include "4ed_profile.h" -//#define USE_DEBUG_MEMORY +// TODO(allen): set in compilation line +#define PREFERRED_ALIGNMENT 8 +#define USE_DEBUG_MEMORY #define FSTRING_IMPLEMENTATION #define FSTRING_C diff --git a/4ed_debug_mem.h b/4ed_debug_mem.h index 4f5cbd73..e4a7cff4 100644 --- a/4ed_debug_mem.h +++ b/4ed_debug_mem.h @@ -12,7 +12,7 @@ #ifndef FED_DEBUG_MEM_H #define FED_DEBUG_MEM_H -// NOTE(allen): revent any future instantiation of 4coder_mem.h +// NOTE(allen): Prevent any future instantiation of 4coder_mem.h #define FCODER_MEM_H #if !defined(OS_PAGE_SIZE) @@ -31,17 +31,30 @@ debug_gm_open(System_Functions *system, Debug_GM *general, void *memory, i32 siz static void* debug_gm_allocate(Debug_GM *general, int32_t size){ System_Functions *system = general->system; - local_persist u32 round_val = OS_PAGE_SIZE-1; - size = (size + round_val) & (~round_val); - void *result = system->memory_allocate(size + OS_PAGE_SIZE); - system->memory_set_protection((u8*)result + size, OS_PAGE_SIZE, 0); - return(result); + + local_persist u32 page_round_val = OS_PAGE_SIZE-1; + int32_t page_rounded_size = (size + page_round_val) & (~page_round_val); + u8 *result = (u8*)system->memory_allocate(page_rounded_size + OS_PAGE_SIZE); + system->memory_set_protection(result + page_rounded_size, OS_PAGE_SIZE, 0); + + local_persist u32 align_round_val = PREFERRED_ALIGNMENT-1; + int32_t align_rounded_size = (size + align_round_val) & (~align_round_val); + int32_t offset = page_rounded_size - align_rounded_size; + + return(result + offset); } static void debug_gm_free(Debug_GM *general, void *memory){ + u8 *ptr = (u8*)memory; + umem val = *(umem*)(&ptr); + val &= ~(0xFFF); + ptr = *(u8**)(&val); + + Assert(sizeof(val) == sizeof(ptr)); + System_Functions *system = general->system; - system->memory_free(memory, 0); + system->memory_free(ptr, 0); } static void* diff --git a/meta/build.cpp b/meta/build.cpp index 832586b3..ff51c579 100644 --- a/meta/build.cpp +++ b/meta/build.cpp @@ -574,6 +574,20 @@ get_4coder_dist_name(String *zip_file, b32 OS_specific, char *folder, char *tier slash_fix(zip_file->str); } +static void +copy_folder(char *dst_dir, char *src_folder){ + make_folder_if_missing(dst_dir, src_folder); + + char space[256]; + String copy_name = make_fixed_width_string(space); + append_sc(©_name, dst_dir); + append_s_char(©_name, platform_correct_slash); + append_sc(©_name, src_folder); + terminate_with_null(©_name); + + copy_all(src_folder, "*", copy_name.str); +} + static void package(char *cdir){ char str_space[1024]; @@ -665,6 +679,8 @@ package(char *cdir){ copy_all(pack_fonts_dir, "*", fonts_dir); copy_file(data_dir, "release-config.4coder", dir, 0, "config.4coder"); + copy_folder(dir, "themes"); + get_4coder_dist_name(&str, true, zip_dir, tier, arch, "zip"); zip(par_dir, "4coder", str.str); } @@ -747,11 +763,20 @@ package(char *cdir){ copy_file(0, "buildsuper" BAT, dir, 0, 0); + copy_folder(dir, "4coder_API"); + copy_folder(dir, "4coder_helper"); + copy_folder(dir, "4coder_lib"); + copy_folder(dir, "4cpp"); + copy_folder(dir, "languages"); + copy_folder(dir, "themes"); + +#if 0 DECL_STR(custom_dir, "4coder_API"); DECL_STR(custom_helper_dir, "4coder_helper"); DECL_STR(custom_lib_dir, "4coder_lib"); DECL_STR(fcpp_dir, "4cpp"); DECL_STR(languages, "languages"); + DECL_STR(themes, "themes"); char *dir_array[] = { custom_dir, @@ -759,6 +784,7 @@ package(char *cdir){ custom_lib_dir, fcpp_dir, languages, + themes, }; i32 dir_count = ArrayCount(dir_array); @@ -775,6 +801,7 @@ package(char *cdir){ copy_all(d, "*", copy_name.str); } +#endif get_4coder_dist_name(&str, true, zip_dir, tier, arch, "zip"); zip(par_dir, "4coder", str.str); @@ -835,7 +862,7 @@ int main(int argc, char **argv){ assert(n < sizeof(cdir)); END_TIME_SECTION("current directory"); - u32 floags = DEBUG_INFO | SUPER | INTERNAL | X86 | LOG; + u32 flags = DEBUG_INFO | SUPER | INTERNAL | X86 | LOG; standard_build(cdir, flags); diff --git a/project.4coder b/project.4coder index 9cc72aa1..7484655a 100644 --- a/project.4coder +++ b/project.4coder @@ -4,6 +4,7 @@ open_recursively=true; fkey_command_win[1] = {"echo build: x64 & build.bat", "*compilation*", true , true }; fkey_command_win[2] = {"site\\build.bat", "*site*", false , true }; fkey_command_win[3] = {"string\\build.bat", "*compilation*", true , true }; +fkey_command_win[4] = {"echo build: x86 & build.bat /DDEV_BUILD_X86", "*compilation*", true , true }; fkey_command_win[5] = {"..\\misc\\run.bat", "*run*", false, false }; fkey_command_win[6] = {"run_profile.bat", "*profile*", false, true }; fkey_command_win[12] = {"package.bat", "*package*", false, true };