4coder/code/custom/generated/system_api_master_list.h

60 lines
4.1 KiB
C
Raw Normal View History

A user reported on the handmade network discord an issue where when you change the font size (e.g. ctrl + scroll up/down) 4coder was crashing. They were using the D3D11 renderer. The crash is caused by dereferencing a invalid pointer to a texture. The D3D11 renderer as a arbitrary limit of 32 textures (there is normally no reason to have more than 2 or 3 textures in 4coder) because it needs to keep track of a few pointer in its state, while OpenGL doesn't (it just uses the id returned by `glGenTexture`). The code that recreate the texture atlas when changing the font size, never frees the previous texture, so both DirectX and OpenGL are leaking texture. So this fix just frees the previous texture after 4coder successfully creates a new one. If for some reason the new texture can't be created, we continue using the last one. This is better than crashing as we can still use 4coder, but since we can't change font size anymore the editor might be stuck with a uncomfortable font size. Unfortunately 4coder doesn't expose a way to delete texture outside the platform layer, and the font size code is not in the platform layer. So I had to expose a `free texture` function, which lead me to understand how 4coder generates API in the `generated` folder. I updated the README to keep that information somewhere since it's not clear from the get go. The basic idea is that there are a few files that you can compile as a small standalone program and run to generate the files. For the graphics api, you need to compile `4ed_graphics_api.cpp`. I took some time to also modify a little the generator so that the generated file contains the name of the file that generated them, and added a bit of indentation to make the file a bit more readable (even if we're not supposed to modify them).
2025-01-06 17:37:44 +00:00
/* Generated by "4ed_system_api.cpp" */
2021-01-17 00:14:12 +00:00
api(system) function void error_box(char* msg);
2019-10-07 03:09:21 +00:00
api(system) function String_Const_u8 get_path(Arena* arena, System_Path_Code path_code);
api(system) function String_Const_u8 get_canonical(Arena* arena, String_Const_u8 name);
api(system) function File_List get_file_list(Arena* arena, String_Const_u8 directory);
api(system) function File_Attributes quick_file_attributes(Arena* scratch, String_Const_u8 file_name);
api(system) function b32 load_handle(Arena* scratch, char* file_name, Plat_Handle* out);
api(system) function File_Attributes load_attributes(Plat_Handle handle);
api(system) function b32 load_file(Plat_Handle handle, char* buffer, u32 size);
api(system) function b32 load_close(Plat_Handle handle);
api(system) function File_Attributes save_file(Arena* scratch, char* file_name, String_Const_u8 data);
api(system) function b32 load_library(Arena* scratch, String_Const_u8 file_name, System_Library* out);
api(system) function b32 release_library(System_Library handle);
api(system) function Void_Func* get_proc(System_Library handle, char* proc_name);
api(system) function u64 now_time(void);
api(system) function Date_Time now_date_time_universal(void);
api(system) function Date_Time local_date_time_from_universal(Date_Time* date_time);
api(system) function Date_Time universal_date_time_from_local(Date_Time* date_time);
2019-10-07 03:09:21 +00:00
api(system) function Plat_Handle wake_up_timer_create(void);
api(system) function void wake_up_timer_release(Plat_Handle handle);
api(system) function void wake_up_timer_set(Plat_Handle handle, u32 time_milliseconds);
api(system) function void signal_step(u32 code);
api(system) function void sleep(u64 microseconds);
api(system) function String_Const_u8 get_clipboard(Arena* arena, i32 index);
api(system) function void post_clipboard(String_Const_u8 str, i32 index);
2020-02-08 00:50:35 +00:00
api(system) function void set_clipboard_catch_all(b32 enabled);
api(system) function b32 get_clipboard_catch_all(void);
2019-10-07 03:09:21 +00:00
api(system) function b32 cli_call(Arena* scratch, char* path, char* script, CLI_Handles* cli_out);
api(system) function void cli_begin_update(CLI_Handles* cli);
api(system) function b32 cli_update_step(CLI_Handles* cli, char* dest, u32 max, u32* amount);
api(system) function b32 cli_end_update(CLI_Handles* cli);
api(system) function void open_color_picker(Color_Picker* picker);
api(system) function f32 get_screen_scale_factor(void);
api(system) function System_Thread thread_launch(Thread_Function* proc, void* ptr);
api(system) function void thread_join(System_Thread thread);
api(system) function void thread_free(System_Thread thread);
api(system) function i32 thread_get_id(void);
2019-10-21 02:02:58 +00:00
api(system) function void acquire_global_frame_mutex(Thread_Context* tctx);
api(system) function void release_global_frame_mutex(Thread_Context* tctx);
2019-10-07 03:09:21 +00:00
api(system) function System_Mutex mutex_make(void);
api(system) function void mutex_acquire(System_Mutex mutex);
api(system) function void mutex_release(System_Mutex mutex);
api(system) function void mutex_free(System_Mutex mutex);
api(system) function System_Condition_Variable condition_variable_make(void);
api(system) function void condition_variable_wait(System_Condition_Variable cv, System_Mutex mutex);
api(system) function void condition_variable_signal(System_Condition_Variable cv);
api(system) function void condition_variable_free(System_Condition_Variable cv);
api(system) function void* memory_allocate(u64 size, String_Const_u8 location);
api(system) function b32 memory_set_protection(void* ptr, u64 size, u32 flags);
api(system) function void memory_free(void* ptr, u64 size);
api(system) function Memory_Annotation memory_annotation(Arena* arena);
2019-10-07 03:09:21 +00:00
api(system) function void show_mouse_cursor(i32 show);
api(system) function b32 set_fullscreen(b32 full_screen);
api(system) function b32 is_fullscreen(void);
api(system) function Input_Modifier_Set get_keyboard_modifiers(Arena* arena);
api(system) function void set_key_mode(Key_Mode mode);
api(system) function void set_source_mixer(void* ctx, Audio_Mix_Sources_Function* mix_func);
api(system) function void set_destination_mixer(Audio_Mix_Destination_Function* mix_func);