exchange is totally gone

This commit is contained in:
Allen Webster 2016-05-31 12:27:40 -04:00
parent 22dc134db3
commit 0f3f7ce05b
10 changed files with 34 additions and 90 deletions

26
4ed.cpp
View File

@ -33,9 +33,6 @@ struct CLI_List{
i32 count, max; i32 count, max;
}; };
#define SysAppCreateView 0x1
#define SysAppCreateNewBuffer 0x2
struct Complete_State{ struct Complete_State{
Search_Set set; Search_Set set;
Search_Iter iter; Search_Iter iter;
@ -49,7 +46,6 @@ struct Command_Data{
Models *models; Models *models;
struct App_Vars *vars; struct App_Vars *vars;
System_Functions *system; System_Functions *system;
Exchange *exchange;
Live_Views *live_set; Live_Views *live_set;
Panel *panel; Panel *panel;
@ -167,7 +163,6 @@ do_feedback_message(System_Functions *system, Models *models, String value){
#define USE_PANEL(n) Panel *n = command->panel #define USE_PANEL(n) Panel *n = command->panel
#define USE_VIEW(n) View *n = command->view #define USE_VIEW(n) View *n = command->view
#define USE_FILE(n,v) Editing_File *n = (v)->file_data.file #define USE_FILE(n,v) Editing_File *n = (v)->file_data.file
#define USE_EXCHANGE(n) Exchange *n = command->exchange
#define REQ_OPEN_VIEW(n) View *n = command->panel->view; if (view_lock_level(n) > LockLevel_Open) return #define REQ_OPEN_VIEW(n) View *n = command->panel->view; if (view_lock_level(n) > LockLevel_Open) return
#define REQ_READABLE_VIEW(n) View *n = command->panel->view; if (view_lock_level(n) > LockLevel_NoWrite) return #define REQ_READABLE_VIEW(n) View *n = command->panel->view; if (view_lock_level(n) > LockLevel_NoWrite) return
@ -219,7 +214,7 @@ param_stack_end(Partition *part){
} }
internal View* internal View*
panel_make_empty(System_Functions *system, Exchange *exchange, App_Vars *vars, Panel *panel){ panel_make_empty(System_Functions *system, App_Vars *vars, Panel *panel){
Models *models = &vars->models; Models *models = &vars->models;
View_And_ID new_view; View_And_ID new_view;
@ -1160,7 +1155,6 @@ COMMAND_DECL(open_panel_vsplit){
USE_VARS(vars); USE_VARS(vars);
USE_MODELS(models); USE_MODELS(models);
USE_PANEL(panel); USE_PANEL(panel);
USE_EXCHANGE(exchange);
if (models->layout.panel_count < models->layout.panel_max_count){ if (models->layout.panel_count < models->layout.panel_max_count){
Split_Result split = layout_split_panel(&models->layout, panel, 1); Split_Result split = layout_split_panel(&models->layout, panel, 1);
@ -1179,16 +1173,14 @@ COMMAND_DECL(open_panel_vsplit){
panel2->prev_inner = panel2->inner; panel2->prev_inner = panel2->inner;
models->layout.active_panel = (i32)(panel2 - models->layout.panels); models->layout.active_panel = (i32)(panel2 - models->layout.panels);
panel_make_empty(system, exchange, vars, panel2); panel_make_empty(system, vars, panel2);
} }
} }
COMMAND_DECL(open_panel_hsplit){ COMMAND_DECL(open_panel_hsplit){
USE_VARS(vars); USE_VARS(vars);
USE_MODELS(models); USE_MODELS(models);
USE_PANEL(panel); USE_PANEL(panel);
USE_EXCHANGE(exchange);
if (models->layout.panel_count < models->layout.panel_max_count){ if (models->layout.panel_count < models->layout.panel_max_count){
Split_Result split = layout_split_panel(&models->layout, panel, 0); Split_Result split = layout_split_panel(&models->layout, panel, 0);
@ -1207,16 +1199,14 @@ COMMAND_DECL(open_panel_hsplit){
panel2->prev_inner = panel2->inner; panel2->prev_inner = panel2->inner;
models->layout.active_panel = (i32)(panel2 - models->layout.panels); models->layout.active_panel = (i32)(panel2 - models->layout.panels);
panel_make_empty(system, exchange, vars, panel2); panel_make_empty(system, vars, panel2);
} }
} }
COMMAND_DECL(close_panel){ COMMAND_DECL(close_panel){
USE_MODELS(models); USE_MODELS(models);
USE_PANEL(panel); USE_PANEL(panel);
USE_VIEW(view); USE_VIEW(view);
USE_EXCHANGE(exchange);
Panel *panel_ptr, *used_panels; Panel *panel_ptr, *used_panels;
Divider_And_ID div, parent_div, child_div; Divider_And_ID div, parent_div, child_div;
@ -1226,7 +1216,7 @@ COMMAND_DECL(close_panel){
i32 active; i32 active;
if (models->layout.panel_count > 1){ if (models->layout.panel_count > 1){
live_set_free_view(system, exchange, command->live_set, view); live_set_free_view(system, command->live_set, view);
panel->view = 0; panel->view = 0;
div = layout_get_divider(&models->layout, panel->parent); div = layout_get_divider(&models->layout, panel->parent);
@ -3411,7 +3401,7 @@ App_Init_Sig(app_init){
// NOTE(allen): init first panel // NOTE(allen): init first panel
Panel_And_ID p = layout_alloc_panel(&models->layout); Panel_And_ID p = layout_alloc_panel(&models->layout);
panel_make_empty(system, exchange, vars, p.panel); panel_make_empty(system, vars, p.panel);
models->layout.active_panel = p.id; models->layout.active_panel = p.id;
String hdbase = make_fixed_width_string(models->hot_dir_base_); String hdbase = make_fixed_width_string(models->hot_dir_base_);
@ -3733,7 +3723,6 @@ App_Step_Sig(app_step){
cmd->models = models; cmd->models = models;
cmd->vars = vars; cmd->vars = vars;
cmd->system = system; cmd->system = system;
cmd->exchange = exchange;
cmd->live_set = &vars->live_set; cmd->live_set = &vars->live_set;
cmd->panel = models->layout.panels + models->layout.active_panel; cmd->panel = models->layout.panels + models->layout.active_panel;
@ -4066,7 +4055,7 @@ App_Step_Sig(app_step){
GUI_Scroll_Vars *vars = view->current_scroll; GUI_Scroll_Vars *vars = view->current_scroll;
// TODO(allen): I feel like the scroll context should actually not // TODO(allen): I feel like the scroll context should actually not
// be allowed to change in here at all. // be allowed to change in here at all.
result = do_input_file_view(system, exchange, view, panel->inner, active, result = do_input_file_view(system, view, panel->inner, active,
&summary, *vars, view->scroll_region); &summary, *vars, view->scroll_region);
if (result.is_animating){ if (result.is_animating){
app_result.animating = 1; app_result.animating = 1;
@ -4356,7 +4345,8 @@ App_Step_Sig(app_step){
draw_rectangle(target, full, back_color); draw_rectangle(target, full, back_color);
draw_push_clip(target, panel->inner); draw_push_clip(target, panel->inner);
do_render_file_view(system, exchange, view, cmd->view, panel->inner, active, target, &dead_input); do_render_file_view(system, view, cmd->view,
panel->inner, active, target, &dead_input);
draw_pop_clip(target); draw_pop_clip(target);
u32 margin_color; u32 margin_color;

2
4ed.h
View File

@ -86,7 +86,6 @@ typedef App_Read_Command_Line_Sig(App_Read_Command_Line);
name(System_Functions *system, \ name(System_Functions *system, \
Render_Target *target, \ Render_Target *target, \
Application_Memory *memory, \ Application_Memory *memory, \
Exchange *exchange, \
String clipboard, \ String clipboard, \
String current_directory, \ String current_directory, \
Custom_API api) Custom_API api)
@ -124,7 +123,6 @@ struct Application_Step_Input{
name(System_Functions *system, \ name(System_Functions *system, \
Render_Target *target, \ Render_Target *target, \
Application_Memory *memory, \ Application_Memory *memory, \
Exchange *exchange, \
Application_Step_Input *input, \ Application_Step_Input *input, \
Application_Step_Result *result) Application_Step_Result *result)

View File

@ -39,7 +39,6 @@
#include "4ed_style.h" #include "4ed_style.h"
#include "4ed_style.cpp" #include "4ed_style.cpp"
#include "4ed_exchange.cpp"
#include "4ed_command.cpp" #include "4ed_command.cpp"
#include "4ed_file.cpp" #include "4ed_file.cpp"
#include "4ed_gui.cpp" #include "4ed_gui.cpp"

View File

@ -1,35 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 9.12.2015
*
* Exchange stuff
*
*/
// TOP
// NOTE(allen): Uhhh.... is it just me or did it get awkward
// in here when I deleted all the file exchange stuff?
internal b32
queue_job_is_pending(Work_Queue *queue, u32 job_id){
b32 result;
u32 job_index;
Full_Job_Data *full_job;
job_index = job_id % QUEUE_WRAP;
full_job = queue->jobs + job_index;
Assert(full_job->id == job_id);
result = 0;
if (full_job->running_thread != 0){
result = 1;
}
return(result);
}
// BOTTOM

View File

@ -844,8 +844,6 @@ Job_Callback_Sig(job_full_lex){
} }
system->release_lock(FRAME_LOCK); system->release_lock(FRAME_LOCK);
exchange->force_redraw = 1;
// NOTE(allen): These are outside the locked section because I don't // NOTE(allen): These are outside the locked section because I don't
// think getting these out of order will cause critical bugs, and I // think getting these out of order will cause critical bugs, and I
// want to minimize what's done in locked sections. // want to minimize what's done in locked sections.
@ -4459,7 +4457,7 @@ struct Input_Process_Result{
}; };
internal Input_Process_Result internal Input_Process_Result
do_input_file_view(System_Functions *system, Exchange *exchange, do_input_file_view(System_Functions *system,
View *view, i32_Rect rect, b32 is_active, View *view, i32_Rect rect, b32 is_active,
Input_Summary *user_input, Input_Summary *user_input,
GUI_Scroll_Vars vars, i32_Rect region){ GUI_Scroll_Vars vars, i32_Rect region){
@ -5168,8 +5166,8 @@ draw_style_preview(GUI_Target *gui_target, Render_Target *target, View *view, i3
} }
internal i32 internal i32
do_render_file_view(System_Functions *system, Exchange *exchange, do_render_file_view(System_Functions *system, View *view,
View *view, View *active, i32_Rect rect, b32 is_active, View *active, i32_Rect rect, b32 is_active,
Render_Target *target, Input_Summary *user_input){ Render_Target *target, Input_Summary *user_input){
Editing_File *file = view->file_data.file; Editing_File *file = view->file_data.file;
@ -5635,7 +5633,7 @@ live_set_alloc_view(Live_Views *live_set, Panel *panel, Models *models){
} }
inline void inline void
live_set_free_view(System_Functions *system, Exchange *exchange, Live_Views *live_set, View *view){ live_set_free_view(System_Functions *system, Live_Views *live_set, View *view){
Assert(live_set->count > 0); Assert(live_set->count > 0);
--live_set->count; --live_set->count;
file_view_free_buffers(view); file_view_free_buffers(view);

View File

@ -157,9 +157,11 @@ thread_memory_zero(){
struct Thread_Exchange; struct Thread_Exchange;
struct System_Functions; struct System_Functions;
#define Job_Callback_Sig(name) void name( \ #define Job_Callback_Sig(name) void name( \
System_Functions *system, Thread_Context *thread, Thread_Memory *memory, \ System_Functions *system, \
Thread_Exchange *exchange, void *data[2]) Thread_Context *thread, \
Thread_Memory *memory, \
void *data[2])
typedef Job_Callback_Sig(Job_Callback); typedef Job_Callback_Sig(Job_Callback);
struct Job_Data{ struct Job_Data{
@ -189,11 +191,6 @@ struct Work_Queue{
#define JOB_ID_WRAP (ArrayCount(queue->jobs) * 4) #define JOB_ID_WRAP (ArrayCount(queue->jobs) * 4)
#define QUEUE_WRAP (ArrayCount(queue->jobs)) #define QUEUE_WRAP (ArrayCount(queue->jobs))
struct Thread_Exchange{
Work_Queue queues[THREAD_GROUP_COUNT];
volatile u32 force_redraw;
};
#define Sys_Post_Job_Sig(name) u32 name(Thread_Group_ID group_id, Job_Data job) #define Sys_Post_Job_Sig(name) u32 name(Thread_Group_ID group_id, Job_Data job)
typedef Sys_Post_Job_Sig(System_Post_Job); typedef Sys_Post_Job_Sig(System_Post_Job);
@ -267,9 +264,5 @@ struct System_Functions{
char slash; char slash;
}; };
struct Exchange{
Thread_Exchange thread;
};
// BOTTOM // BOTTOM

View File

@ -1,4 +1,4 @@
Distribution Date: 28.5.2016 (dd.mm.yyyy) Distribution Date: 31.5.2016 (dd.mm.yyyy)
Thank you for contributing to the 4coder project! Thank you for contributing to the 4coder project!

View File

@ -1,4 +1,4 @@
Distribution Date: 28.5.2016 (dd.mm.yyyy) Distribution Date: 31.5.2016 (dd.mm.yyyy)
Thank you for contributing to the 4coder project! Thank you for contributing to the 4coder project!

View File

@ -68,10 +68,11 @@
; [X] miblo's off screen cursor thing ; [X] miblo's off screen cursor thing
; [X] new file is messed up for code files, it never finishes parsing! ; [X] new file is messed up for code files, it never finishes parsing!
; [X] key presses that should be consumed in the GUI are now passed to the file! ; [X] key presses that should be consumed in the GUI are now passed to the file!
; [X] paste snaps the cursor back into view!
;
; [] indication on failure to save ; [] indication on failure to save
; [] clean whitespace doesn't appear to be cleaning trailing whitespace anymore??? ; [] clean whitespace doesn't appear to be cleaning trailing whitespace anymore???
; ;
; [] paste snaps the cursor back into view!
; ;
; TODOS ; TODOS

View File

@ -125,6 +125,7 @@ struct Win32_Vars{
Plat_Settings settings; Plat_Settings settings;
Work_Queue queues[THREAD_GROUP_COUNT];
Thread_Group groups[THREAD_GROUP_COUNT]; Thread_Group groups[THREAD_GROUP_COUNT];
CRITICAL_SECTION locks[LOCK_COUNT]; CRITICAL_SECTION locks[LOCK_COUNT];
Thread_Memory *thread_memory; Thread_Memory *thread_memory;
@ -164,7 +165,6 @@ struct Win32_Vars{
globalvar Win32_Vars win32vars; globalvar Win32_Vars win32vars;
globalvar Application_Memory memory_vars; globalvar Application_Memory memory_vars;
globalvar Exchange exchange_vars;
// //
@ -319,8 +319,8 @@ JobThreadProc(LPVOID lpParameter){
thread_memory->size = new_size; thread_memory->size = new_size;
} }
} }
full_job->job.callback(&win32vars.system, thread, thread_memory, full_job->job.callback(&win32vars.system,
&exchange_vars.thread, full_job->job.data); thread, thread_memory, full_job->job.data);
PostMessage(win32vars.window_handle, WM_4coder_ANIMATE, 0, 0); PostMessage(win32vars.window_handle, WM_4coder_ANIMATE, 0, 0);
full_job->running_thread = 0; full_job->running_thread = 0;
thread->running = 0; thread->running = 0;
@ -335,7 +335,7 @@ JobThreadProc(LPVOID lpParameter){
internal internal
Sys_Post_Job_Sig(system_post_job){ Sys_Post_Job_Sig(system_post_job){
Work_Queue *queue = exchange_vars.thread.queues + group_id; Work_Queue *queue = win32vars.queues + group_id;
Assert((queue->write_position + 1) % QUEUE_WRAP != queue->read_position % QUEUE_WRAP); Assert((queue->write_position + 1) % QUEUE_WRAP != queue->read_position % QUEUE_WRAP);
@ -366,7 +366,7 @@ Sys_Post_Job_Sig(system_post_job){
// but I still don't know what exactly I would do without it. // but I still don't know what exactly I would do without it.
internal internal
Sys_Cancel_Job_Sig(system_cancel_job){ Sys_Cancel_Job_Sig(system_cancel_job){
Work_Queue *queue = exchange_vars.thread.queues + group_id; Work_Queue *queue = win32vars.queues + group_id;
Thread_Group *group = win32vars.groups + group_id; Thread_Group *group = win32vars.groups + group_id;
u32 job_index; u32 job_index;
@ -414,7 +414,7 @@ system_grow_thread_memory(Thread_Memory *memory){
#if FRED_INTERNAL #if FRED_INTERNAL
internal void internal void
INTERNAL_get_thread_states(Thread_Group_ID id, bool8 *running, i32 *pending){ INTERNAL_get_thread_states(Thread_Group_ID id, bool8 *running, i32 *pending){
Work_Queue *queue = exchange_vars.thread.queues + id; Work_Queue *queue = win32vars.queues + id;
u32 write = queue->write_position; u32 write = queue->write_position;
u32 read = queue->read_position; u32 read = queue->read_position;
if (write < read) write += JOB_ID_WRAP; if (write < read) write += JOB_ID_WRAP;
@ -1611,7 +1611,6 @@ WinMain(HINSTANCE hInstance,
char **argv = __argv; char **argv = __argv;
memset(&win32vars, 0, sizeof(win32vars)); memset(&win32vars, 0, sizeof(win32vars));
memset(&exchange_vars, 0, sizeof(exchange_vars));
// //
@ -1626,7 +1625,7 @@ WinMain(HINSTANCE hInstance,
Thread_Memory thread_memory[ArrayCount(background)]; Thread_Memory thread_memory[ArrayCount(background)];
win32vars.thread_memory = thread_memory; win32vars.thread_memory = thread_memory;
exchange_vars.thread.queues[BACKGROUND_THREADS].semaphore = win32vars.queues[BACKGROUND_THREADS].semaphore =
Win32Handle(CreateSemaphore(0, 0, Win32Handle(CreateSemaphore(0, 0,
win32vars.groups[BACKGROUND_THREADS].count, 0)); win32vars.groups[BACKGROUND_THREADS].count, 0));
@ -1639,7 +1638,7 @@ WinMain(HINSTANCE hInstance,
*memory = thread_memory_zero(); *memory = thread_memory_zero();
memory->id = thread->id; memory->id = thread->id;
thread->queue = &exchange_vars.thread.queues[BACKGROUND_THREADS]; thread->queue = &win32vars.queues[BACKGROUND_THREADS];
thread->handle = CreateThread(0, 0, JobThreadProc, thread, creation_flag, (LPDWORD)&thread->windows_id); thread->handle = CreateThread(0, 0, JobThreadProc, thread, creation_flag, (LPDWORD)&thread->windows_id);
} }
@ -1955,9 +1954,11 @@ WinMain(HINSTANCE hInstance,
// Main Loop // Main Loop
// //
win32vars.app.init(&win32vars.system, &win32vars.target, win32vars.app.init(&win32vars.system,
&memory_vars, &exchange_vars, &win32vars.target,
win32vars.clipboard_contents, current_directory, &memory_vars,
win32vars.clipboard_contents,
current_directory,
win32vars.custom_api); win32vars.custom_api);
system_free_memory(current_directory.str); system_free_memory(current_directory.str);
@ -2078,7 +2079,6 @@ WinMain(HINSTANCE hInstance,
win32vars.app.step(&win32vars.system, win32vars.app.step(&win32vars.system,
&win32vars.target, &win32vars.target,
&memory_vars, &memory_vars,
&exchange_vars,
&input, &input,
&result); &result);