eliminated platform layer file exchange
This commit is contained in:
parent
a208c045e3
commit
885e5b424f
|
@ -76,7 +76,7 @@ CUSTOM_COMMAND_SIG(move_down_10){
|
|||
x = view.preferred_x;
|
||||
|
||||
if (view.unwrapped_lines){
|
||||
y = view.cursor.wrapped_y;
|
||||
y = view.cursor.unwrapped_y;
|
||||
}
|
||||
else{
|
||||
y = view.cursor.wrapped_y;
|
||||
|
|
107
4ed.cpp
107
4ed.cpp
|
@ -85,6 +85,9 @@ struct App_Vars{
|
|||
Complete_State complete_state;
|
||||
|
||||
Command_Data command_data;
|
||||
|
||||
File_Slot slots[32];
|
||||
char filename_space[32 * FileNameMax];
|
||||
};
|
||||
|
||||
enum Coroutine_Type{
|
||||
|
@ -3213,6 +3216,41 @@ App_Init_Sig(app_init){
|
|||
partition = &models->mem.part;
|
||||
target->partition = partition;
|
||||
|
||||
{
|
||||
//exchange
|
||||
File_Slot *slots = vars->slots;
|
||||
i32 max = ArrayCount(vars->slots);
|
||||
{
|
||||
char *filename_space;
|
||||
i32 i;
|
||||
|
||||
exchange->file.max = max;
|
||||
exchange->file.available = file_slot_zero();
|
||||
exchange->file.available.next = &exchange->file.available;
|
||||
exchange->file.available.prev = &exchange->file.available;
|
||||
|
||||
exchange->file.active = file_slot_zero();
|
||||
exchange->file.active.next = &exchange->file.active;
|
||||
exchange->file.active.prev = &exchange->file.active;
|
||||
|
||||
exchange->file.free_list = file_slot_zero();
|
||||
exchange->file.free_list.next = &exchange->file.free_list;
|
||||
exchange->file.free_list.prev = &exchange->file.free_list;
|
||||
|
||||
exchange->file.files = slots;
|
||||
memset(slots, 0, sizeof(File_Slot)*max);
|
||||
|
||||
filename_space = vars->filename_space;
|
||||
|
||||
File_Slot *slot = slots;
|
||||
for (i = 0; i < exchange->file.max; ++i, ++slot){
|
||||
ex__file_insert(&exchange->file.available, slot);
|
||||
slot->filename = filename_space;
|
||||
filename_space += FileNameMax;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
i32 i;
|
||||
|
||||
|
@ -4387,6 +4425,73 @@ App_Step_Sig(app_step){
|
|||
|
||||
update_command_data(vars, cmd);
|
||||
|
||||
Temp_Memory file_temp = begin_temp_memory(&models->mem.part);
|
||||
|
||||
// NOTE(allen): Simulate what use to happen on the system side
|
||||
// for processing file exchange.
|
||||
{
|
||||
File_Slot *file;
|
||||
int d = 0;
|
||||
|
||||
for (file = exchange->file.active.next;
|
||||
file != &exchange->file.active;
|
||||
file = file->next){
|
||||
++d;
|
||||
|
||||
if (file->flags & FEx_Save){
|
||||
Assert((file->flags & FEx_Request) == 0);
|
||||
file->flags &= (~FEx_Save);
|
||||
if (system->file_save(file->filename,
|
||||
(char*)file->data, file->size)){
|
||||
file->flags |= FEx_Save_Complete;
|
||||
}
|
||||
else{
|
||||
file->flags |= FEx_Save_Failed;
|
||||
}
|
||||
app_result.animating = 1;
|
||||
}
|
||||
|
||||
if (file->flags & FEx_Request){
|
||||
Assert((file->flags & FEx_Save) == 0);
|
||||
file->flags &= (~FEx_Request);
|
||||
|
||||
File_Loading loading = system->file_load_begin(file->filename);
|
||||
|
||||
if (loading.exists){
|
||||
char *data = push_array(&models->mem.part, char, loading.size);
|
||||
if (system->file_load_end(loading, data)){
|
||||
file->flags |= FEx_Ready;
|
||||
file->data = (byte*)data;
|
||||
file->size = loading.size;
|
||||
}
|
||||
}
|
||||
else{
|
||||
system->file_load_end(loading, 0);
|
||||
file->flags |= FEx_Not_Exist;
|
||||
}
|
||||
|
||||
app_result.animating = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int free_list_count = 0;
|
||||
for (file = exchange->file.free_list.next;
|
||||
file != &exchange->file.free_list;
|
||||
file = file->next){
|
||||
++free_list_count;
|
||||
}
|
||||
|
||||
if (exchange->file.free_list.next != &exchange->file.free_list){
|
||||
Assert(free_list_count != 0);
|
||||
ex__insert_range(exchange->file.free_list.next,
|
||||
exchange->file.free_list.prev,
|
||||
&exchange->file.available);
|
||||
exchange->file.num_active -= free_list_count;
|
||||
}
|
||||
|
||||
ex__check(&exchange->file);
|
||||
}
|
||||
|
||||
// NOTE(allen): processing sys app bindings
|
||||
{
|
||||
Mem_Options *mem = &models->mem;
|
||||
|
@ -4478,6 +4583,8 @@ App_Step_Sig(app_step){
|
|||
}
|
||||
}
|
||||
|
||||
end_temp_memory(file_temp);
|
||||
|
||||
// NOTE(allen): process as many delayed actions as possible
|
||||
if (models->delay1.count > 0){
|
||||
Working_Set *working_set = &models->working_set;
|
||||
|
|
|
@ -17,6 +17,17 @@ ex__file_insert(File_Slot *pos, File_Slot *file){
|
|||
file->prev = pos;
|
||||
}
|
||||
|
||||
void
|
||||
ex__insert_range(File_Slot *start, File_Slot *end, File_Slot *pos){
|
||||
end->next->prev = start->prev;
|
||||
start->prev->next = end->next;
|
||||
|
||||
end->next = pos->next;
|
||||
start->prev = pos;
|
||||
pos->next->prev = end;
|
||||
pos->next = start;
|
||||
}
|
||||
|
||||
internal void
|
||||
ex__file_remove(File_Slot *file){
|
||||
file->next->prev = file->prev;
|
||||
|
|
|
@ -66,6 +66,7 @@ sysshared_filter_real_files(char **files, i32 *file_count){
|
|||
*file_count = j;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
ex__file_insert(File_Slot *pos, File_Slot *file){
|
||||
file->next = pos->next;
|
||||
|
@ -140,6 +141,7 @@ sysshared_init_file_exchange(
|
|||
|
||||
if (filename_space_out) *filename_space_out = filename_space;
|
||||
}
|
||||
#endif
|
||||
|
||||
internal Partition
|
||||
sysshared_scratch_partition(i32 size){
|
||||
|
|
|
@ -1907,8 +1907,10 @@ int main(int argc, char **argv){
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
File_Slot file_slots[32];
|
||||
sysshared_init_file_exchange(&exchange_vars, file_slots, ArrayCount(file_slots), 0);
|
||||
#endif
|
||||
|
||||
win32vars.app.init(win32vars.system, &win32vars.target,
|
||||
&memory_vars, &exchange_vars,
|
||||
|
@ -2056,6 +2058,7 @@ int main(int argc, char **argv){
|
|||
|
||||
win32vars.first = 0;
|
||||
|
||||
#if 0
|
||||
{
|
||||
File_Slot *file;
|
||||
int d = 0;
|
||||
|
@ -2113,6 +2116,7 @@ int main(int argc, char **argv){
|
|||
|
||||
ex__check(&exchange_vars.file);
|
||||
}
|
||||
#endif
|
||||
|
||||
i64 timer_end = system_time();
|
||||
i64 end_target = (timer_start + frame_useconds);
|
||||
|
|
Loading…
Reference in New Issue