clparams almost done

This commit is contained in:
Allen Webster 2016-02-04 12:00:58 -05:00
parent 8195020bfd
commit 164a18c4a9
7 changed files with 5301 additions and 5205 deletions

148
4ed.cpp
View File

@ -770,32 +770,28 @@ app_push_file_binding(App_Vars *vars, int sys_id, int app_id){
vars->sys_app_bindings[vars->sys_app_count++] = binding; vars->sys_app_bindings[vars->sys_app_count++] = binding;
} }
internal File_View* struct App_Open_File_Result{
app_open_file(System_Functions *system, App_Vars *vars, Exchange *exchange, Editing_File *file;
Live_Views *live_set, Working_Set *working_set, Panel *panel, b32 is_new;
Command_Data *command_data, char *filename, int len){ };
String filename_str;
internal App_Open_File_Result
app_open_file_background(App_Vars *vars, Exchange *exchange, Working_Set *working_set, String filename){
Get_File_Result file;
i32 file_id; i32 file_id;
File_View *result; App_Open_File_Result result = {};
Mem_Options *mem;
Editing_File *target_file = 0;
b32 created_file = 0;
filename_str = make_string(filename, len); result.file = working_set_contains(working_set, filename);
mem = &vars->mem; if (result.file == 0){
file = working_set_get_available_file(working_set);
result = 0;
target_file = working_set_contains(working_set, filename_str);
if (!target_file){
Get_File_Result file = working_set_get_available_file(working_set);
if (file.file){ if (file.file){
file_id = exchange_request_file(exchange, filename, len); file_id = exchange_request_file(exchange, filename.str, filename.size);
if (file_id){ if (file_id){
created_file = 1; result.is_new = 1;
target_file = file.file; result.file = file.file;
file_set_name(target_file, filename); file_set_name(result.file, filename.str);
file_set_to_loading(target_file); file_set_to_loading(result.file);
table_add(&working_set->table, target_file->name.source_path, file.index); table_add(&working_set->table, result.file->name.source_path, file.index);
app_push_file_binding(vars, file_id, file.index); app_push_file_binding(vars, file_id, file.index);
} }
@ -805,7 +801,20 @@ app_open_file(System_Functions *system, App_Vars *vars, Exchange *exchange,
} }
} }
if (target_file){ return(result);
}
internal File_View*
app_open_file(System_Functions *system, App_Vars *vars, Exchange *exchange,
Live_Views *live_set, Working_Set *working_set, Panel *panel,
Command_Data *command_data, String filename){
App_Open_File_Result file;
Mem_Options *mem = &vars->mem;
File_View *result = 0;
file = app_open_file_background(vars, exchange, working_set, filename);
if (file.file){
Style *style = command_data->style; Style *style = command_data->style;
View *new_view = live_set_alloc_view(live_set, mem); View *new_view = live_set_alloc_view(live_set, mem);
@ -821,7 +830,7 @@ app_open_file(System_Functions *system, App_Vars *vars, Exchange *exchange,
Temp_Memory temp = begin_temp_memory(&mem->part); Temp_Memory temp = begin_temp_memory(&mem->part);
command_data->part = partition_sub_part(&mem->part, Kbytes(16)); command_data->part = partition_sub_part(&mem->part, Kbytes(16));
view_set_file(system, file_view, target_file, vars->font_set, view_set_file(system, file_view, file.file, vars->font_set,
style, vars->hooks[hook_open_file], command_data, style, vars->hooks[hook_open_file], command_data,
&app_links); &app_links);
@ -829,7 +838,7 @@ app_open_file(System_Functions *system, App_Vars *vars, Exchange *exchange,
end_temp_memory(temp); end_temp_memory(temp);
command_data->view = old_view; command_data->view = old_view;
new_view->map = app_get_map(vars, target_file->settings.base_map_id); new_view->map = app_get_map(vars, file.file->settings.base_map_id);
} }
return(result); return(result);
@ -867,7 +876,7 @@ COMMAND_DECL(interactive_open){
String string = make_string(filename, filename_len); String string = make_string(filename, filename_len);
app_open_file(system, vars, exchange, app_open_file(system, vars, exchange,
live_set, working_set, panel, live_set, working_set, panel,
command, string.str, string.size); command, string);
} }
else{ else{
View *new_view = live_set_alloc_view(live_set, mem); View *new_view = live_set_alloc_view(live_set, mem);
@ -909,49 +918,6 @@ COMMAND_DECL(reopen){
else{ else{
// TODO(allen): feedback message // TODO(allen): feedback message
} }
#if 0
ProfileMomentFunction();
REQ_FILE_VIEW(view);
REQ_FILE(file, view);
USE_STYLE(style);
USE_LAYOUT(layout);
USE_MEM(mem);
USE_VARS(vars);
Editing_File temp_file;
if (file_create(system, mem, &temp_file, make_c_str(file->source_path), style->font)){
file_close(system, &mem->general, file);
*file = temp_file;
file->source_path.str = file->source_path_;
file->live_name.str = file->live_name_;
#if BUFFER_EXPERIMENT_SCALPEL <= 0
if (file->tokens_exist)
file_first_lex_parallel(system, &mem->general, file);
#endif
Partition old_part = command->part;
Temp_Memory temp = begin_temp_memory(&vars->mem.part);
command->part = partition_sub_part(&vars->mem.part, 16 << 10);
view_set_file(system, view, file, style,
vars->hooks[hook_open_file], command, app_links);
command->part = old_part;
end_temp_memory(temp);
i32 panel_count = layout->panel_count;
Panel *panels = layout->panels;
for (i32 i = 0; i < panel_count; ++i){
Panel *current_panel = panels + i;
View *current_view_ = current_panel->view;
File_View *current_view = view_to_file_view(current_view_);
if (current_view && current_view != view && current_view->file == file){
view_set_file(system, current_view, current_view->file, style, 0, command, app_links);
}
}
}
#endif
} }
COMMAND_DECL(save){ COMMAND_DECL(save){
@ -2540,7 +2506,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
case 'd': action = CLAct_CustomDLL; strict = 0; break; case 'd': action = CLAct_CustomDLL; strict = 0; break;
case 'D': action = CLAct_CustomDLL; strict = 1; break; case 'D': action = CLAct_CustomDLL; strict = 1; break;
case 'l': action = CLAct_InitialFilePosition; break; case 'i': action = CLAct_InitialFilePosition; break;
case 'w': action = CLAct_WindowSize; break; case 'w': action = CLAct_WindowSize; break;
case 'W': action = CLAct_WindowMaximize; break; case 'W': action = CLAct_WindowMaximize; break;
@ -2634,6 +2600,9 @@ App_Read_Command_Line_Sig(app_read_command_line){
App_Vars *vars = app_setup_memory(memory); App_Vars *vars = app_setup_memory(memory);
init_command_line_settings(&vars->settings, plat_settings, clparams); init_command_line_settings(&vars->settings, plat_settings, clparams);
*files = vars->settings.init_files;
*file_count = &vars->settings.init_files_count;
return(output_size); return(output_size);
} }
@ -3318,12 +3287,23 @@ App_Step_Sig(app_step){
command_data.part.pos = 0; command_data.part.pos = 0;
} }
char *file_name;
i32 i; i32 i;
for (i = 0; i < vars->settings.init_file_count; ++i){ String file_name;
file_name = vars->settings.init_files[i]; Panel *panel = vars->layout.panels;
// TODO(allen): open files, do not attach to view for (i = 0; i < vars->settings.init_files_count; ++i, ++panel){
//app_open_file(system, vars, exchange,live_set, working_set, panel,command, string.str, string.size); file_name = make_string_slowly(vars->settings.init_files[i]);
if (i < vars->layout.panel_count){
app_open_file(system, vars, exchange, &vars->live_set, &vars->working_set, panel,
&command_data, file_name);
if (i == 0){
}
}
else{
app_open_file_background(vars, exchange, &vars->working_set, file_name);
}
} }
} }
@ -3445,7 +3425,7 @@ App_Step_Sig(app_step){
command_data.view = (View*) command_data.view = (View*)
app_open_file(system, vars, exchange, app_open_file(system, vars, exchange,
live_set, working_set, panel, live_set, working_set, panel,
&command_data, string->str, string->size); &command_data, *string);
}break; }break;
case DACT_SAVE_AS: case DACT_SAVE_AS:
@ -3635,6 +3615,7 @@ App_Step_Sig(app_step){
for (i32 i = 0; i < vars->sys_app_count; ++i){ for (i32 i = 0; i < vars->sys_app_count; ++i){
Sys_App_Binding *binding; Sys_App_Binding *binding;
b32 remove = 0; b32 remove = 0;
b32 failed = 0;
binding = vars->sys_app_bindings + i; binding = vars->sys_app_bindings + i;
byte *data; byte *data;
@ -3660,13 +3641,22 @@ App_Step_Sig(app_step){
else{ else{
file_create_empty(system, &vars->mem, ed_file, filename, file_create_empty(system, &vars->mem, ed_file, filename,
vars->font_set, vars->style.font_id); vars->font_set, vars->style.font_id);
//
i32 panel_count = vars->layout.panel_count;
Panel *current_panel = vars->layout.panels;
for (i32 i = 0; i < panel_count; ++i, ++current_panel){
File_View *current_view = view_to_file_view(current_panel->view);
if (current_view && current_view->file == ed_file){
view_measure_wraps(system, &vars->mem.general, current_view);
}
}
} }
exchange_free_file(exchange, binding->sys_id); exchange_free_file(exchange, binding->sys_id);
remove = 1; remove = 1;
} }
if (exchange_file_save_complete(exchange, binding->sys_id, &data, &size, &max)){ if (exchange_file_save_complete(exchange, binding->sys_id, &data, &size, &max, &failed)){
Assert(remove == 0); Assert(remove == 0);
if (data){ if (data){
@ -3681,6 +3671,8 @@ App_Step_Sig(app_step){
exchange_free_file(exchange, binding->sys_id); exchange_free_file(exchange, binding->sys_id);
remove = 1; remove = 1;
// if (failed) { TODO(allen): saving error, now what? }
} }
if (remove){ if (remove){

4
4ed.h
View File

@ -106,7 +106,8 @@ enum File_Exchange_Flag{
FEx_Ready = 0x2, FEx_Ready = 0x2,
FEx_Not_Exist = 0x4, FEx_Not_Exist = 0x4,
FEx_Save = 0x8, FEx_Save = 0x8,
FEx_Save_Complete = 0x10 FEx_Save_Complete = 0x10,
FEx_Save_Failed = 0x20
}; };
struct File_Exchange{ struct File_Exchange{
@ -140,6 +141,7 @@ struct Plat_Settings{
Application_Memory *memory, \ Application_Memory *memory, \
String current_directory, \ String current_directory, \
Plat_Settings *plat_settings, \ Plat_Settings *plat_settings, \
char ***files, i32 **file_count, \
Command_Line_Parameters clparams \ Command_Line_Parameters clparams \
) )

View File

@ -1,217 +1,235 @@
/* /*
* Mr. 4th Dimention - Allen Webster * Mr. 4th Dimention - Allen Webster
* *
* 9.12.2015 * 9.12.2015
* *
* Exchange stuff * Exchange stuff
* *
*/ */
// TOP // TOP
internal void internal void
ex__file_insert(File_Slot *pos, File_Slot *file){ ex__file_insert(File_Slot *pos, File_Slot *file){
pos->next->prev = file; pos->next->prev = file;
file->next = pos->next; file->next = pos->next;
pos->next = file; pos->next = file;
file->prev = pos; file->prev = pos;
} }
internal void internal void
ex__file_remove(File_Slot *file){ ex__file_remove(File_Slot *file){
file->next->prev = file->prev; file->next->prev = file->prev;
file->prev->next = file->next; file->prev->next = file->next;
} }
internal void internal void
ex__check_file(File_Slot *pos){ ex__check_file(File_Slot *pos){
File_Slot *file = pos; File_Slot *file = pos;
Assert(pos == pos->next->prev); Assert(pos == pos->next->prev);
for (pos = pos->next; for (pos = pos->next;
file != pos; file != pos;
pos = pos->next){ pos = pos->next){
Assert(pos == pos->next->prev); Assert(pos == pos->next->prev);
} }
} }
internal void internal void
ex__check(File_Exchange *file_exchange){ ex__check(File_Exchange *file_exchange){
ex__check_file(&file_exchange->available); ex__check_file(&file_exchange->available);
ex__check_file(&file_exchange->active); ex__check_file(&file_exchange->active);
ex__check_file(&file_exchange->free_list); ex__check_file(&file_exchange->free_list);
} }
internal void internal void
ex__clear(File_Slot *file){ ex__clear(File_Slot *file){
file->data = 0; file->data = 0;
file->size = 0; file->size = 0;
file->max = 0; file->max = 0;
file->flags = 0; file->flags = 0;
} }
internal File_Slot* internal File_Slot*
ex__get_file(Exchange *exchange){ ex__get_file(Exchange *exchange){
File_Exchange *files = &exchange->file; File_Exchange *files = &exchange->file;
File_Slot *file; File_Slot *file;
++files->num_active; ++files->num_active;
file = files->available.next; file = files->available.next;
ex__file_remove(file); ex__file_remove(file);
ex__clear(file); ex__clear(file);
ex__file_insert(&files->active, file); ex__file_insert(&files->active, file);
ex__check(files); ex__check(files);
return file; return file;
} }
internal void internal void
ex__set_filename(File_Slot *file, char *filename, int len){ ex__set_filename(File_Slot *file, char *filename, int len){
memcpy(file->filename, filename, len); memcpy(file->filename, filename, len);
file->filename[len] = 0; file->filename[len] = 0;
file->filename_len = len; file->filename_len = len;
} }
internal i32 internal i32
exchange_request_file(Exchange *exchange, char *filename, int len){ exchange_request_file(Exchange *exchange, char *filename, int len){
File_Exchange *files = &exchange->file; File_Exchange *files = &exchange->file;
i32 result = 0; i32 result = 0;
if (len+1 < FileNameMax){ if (len+1 < FileNameMax){
if (files->num_active < files->max){ if (files->num_active < files->max){
File_Slot *file = ex__get_file(exchange); File_Slot *file = ex__get_file(exchange);
ex__set_filename(file, filename, len); ex__set_filename(file, filename, len);
file->flags |= FEx_Request; file->flags |= FEx_Request;
result = (int)(file - files->files) + 1; result = (int)(file - files->files) + 1;
} }
} }
return result; return result;
} }
internal b32 internal b32
exchange_file_ready(Exchange *exchange, i32 file_id, byte **data, int *size, int *max){ exchange_file_ready(Exchange *exchange, i32 file_id, byte **data, int *size, int *max){
File_Exchange *files = &exchange->file; File_Exchange *files = &exchange->file;
b32 result = 0; b32 result = 0;
if (file_id > 0 && file_id <= files->max){ if (file_id > 0 && file_id <= files->max){
File_Slot *file = files->files + file_id - 1; File_Slot *file = files->files + file_id - 1;
if (file->flags & FEx_Ready){ if (file->flags & FEx_Ready){
*data = file->data; *data = file->data;
*size = file->size; *size = file->size;
*max = file->max; *max = file->max;
result = 1; result = 1;
} }
if (file->flags & FEx_Not_Exist){ if (file->flags & FEx_Not_Exist){
*data = 0; *data = 0;
*size = 0; *size = 0;
*max = 0; *max = 0;
result = 1; result = 1;
} }
} }
return result; return result;
} }
internal i32 internal b32
exchange_save_file(Exchange *exchange, char *filename, int len, exchange_file_does_not_exist(Exchange *exchange, i32 file_id){
byte *data, int size, int max){ File_Exchange *files = &exchange->file;
File_Exchange *files = &exchange->file; b32 result = 1;
i32 result = 0; File_Slot *slot;
if (len+1 < FileNameMax){ if (file_id > 0 && file_id <= files->max){
if (files->num_active < files->max){ slot = files->files + file_id - 1;
File_Slot *file = ex__get_file(exchange); if (!(slot->flags & FEx_Not_Exist)){
ex__set_filename(file, filename, len); result = 0;
}
file->flags |= FEx_Save; }
file->data = data;
file->size = size; return result;
file->max = max; }
result = (int)(file - files->files) + 1; internal i32
} exchange_save_file(Exchange *exchange, char *filename, int len,
} byte *data, int size, int max){
File_Exchange *files = &exchange->file;
return result; i32 result = 0;
}
if (len+1 < FileNameMax){
internal b32 if (files->num_active < files->max){
exchange_file_save_complete(Exchange *exchange, i32 file_id, byte **data, int *size, int *max){ File_Slot *file = ex__get_file(exchange);
File_Exchange *files = &exchange->file; ex__set_filename(file, filename, len);
b32 result = 0;
file->flags |= FEx_Save;
if (file_id > 0 && file_id <= files->max){ file->data = data;
File_Slot *file = files->files + file_id - 1; file->size = size;
if (file->flags & FEx_Save_Complete){ file->max = max;
*data = file->data;
*size = file->size; result = (int)(file - files->files) + 1;
*max = file->max; }
result = 1; }
}
} return result;
}
return result;
} internal b32
exchange_file_save_complete(Exchange *exchange, i32 file_id, byte **data, int *size, int *max, int *failed){
internal char* File_Exchange *files = &exchange->file;
exchange_file_filename(Exchange *exchange, i32 file_id, i32 *size = 0){ b32 result = 0;
File_Exchange *files = &exchange->file;
char *result = 0; if (file_id > 0 && file_id <= files->max){
File_Slot *file = files->files + file_id - 1;
if (file_id > 0 && file_id <= files->max){ if (file->flags & FEx_Save_Complete || file->flags & FEx_Save_Failed){
File_Slot *file = files->files + file_id - 1; *data = file->data;
result = file->filename; *size = file->size;
if (size) *size = file->filename_len; *max = file->max;
} result = 1;
return result; *failed = (file->flags & FEx_Save_Complete)?(1):(0);
} }
}
internal void
exchange_free_file(Exchange *exchange, i32 file_id){ return result;
File_Exchange *files = &exchange->file; }
if (file_id > 0 && file_id <= files->max){ internal char*
File_Slot *file = files->files + file_id - 1; exchange_file_filename(Exchange *exchange, i32 file_id, i32 *size = 0){
ex__file_remove(file); File_Exchange *files = &exchange->file;
ex__file_insert(&files->free_list, file); char *result = 0;
ex__check(files);
--files->num_active; if (file_id > 0 && file_id <= files->max){
} File_Slot *file = files->files + file_id - 1;
} result = file->filename;
if (size) *size = file->filename_len;
internal void }
exchange_clear_file(Exchange *exchange, i32 file_id){
File_Exchange *files = &exchange->file; return result;
}
if (file_id > 0 && file_id <= files->max){
File_Slot *file = files->files + file_id - 1; internal void
ex__clear(file); exchange_free_file(Exchange *exchange, i32 file_id){
} File_Exchange *files = &exchange->file;
}
if (file_id > 0 && file_id <= files->max){
internal b32 File_Slot *file = files->files + file_id - 1;
queue_job_is_pending(Work_Queue *queue, u32 job_id){ ex__file_remove(file);
b32 result; ex__file_insert(&files->free_list, file);
u32 job_index; ex__check(files);
Full_Job_Data *full_job; --files->num_active;
}
job_index = job_id % QUEUE_WRAP; }
full_job = queue->jobs + job_index;
internal void
Assert(full_job->id == job_id); exchange_clear_file(Exchange *exchange, i32 file_id){
File_Exchange *files = &exchange->file;
result = 0;
if (full_job->running_thread != 0){ if (file_id > 0 && file_id <= files->max){
result = 1; File_Slot *file = files->files + file_id - 1;
} ex__clear(file);
}
return(result); }
}
internal b32
// BOTTOM 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

File diff suppressed because it is too large Load Diff

View File

@ -1,200 +1,205 @@
/* /*
* Mr. 4th Dimention - Allen Webster * Mr. 4th Dimention - Allen Webster
* *
* 12.12.2014 * 12.12.2014
* *
* Meta setup for project codename "4ed" * Meta setup for project codename "4ed"
* *
*/ */
#ifndef FRED_META_H #ifndef FRED_META_H
#define FRED_META_H #define FRED_META_H
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
typedef uint8_t u8; typedef uint8_t u8;
typedef uint64_t u64; typedef uint64_t u64;
typedef uint32_t u32; typedef uint32_t u32;
typedef uint16_t u16; typedef uint16_t u16;
typedef int8_t i8; typedef int8_t i8;
typedef int64_t i64; typedef int64_t i64;
typedef int32_t i32; typedef int32_t i32;
typedef int16_t i16; typedef int16_t i16;
typedef i32 bool32; typedef i32 bool32;
typedef i8 bool8; typedef i8 bool8;
typedef i32 b32; typedef i32 b32;
typedef i8 b8; typedef i8 b8;
typedef uint8_t byte; typedef uint8_t byte;
typedef float real32; typedef float real32;
typedef double real64; typedef double real64;
typedef float f32; typedef float f32;
typedef double f64; typedef double f64;
struct Data{ struct Data{
byte *data; byte *data;
i32 size; i32 size;
}; };
#define external extern "C" #define external extern "C"
#define internal static #define internal static
#define globalvar static #define globalvar static
#define persist static #define persist static
#define globalconst static const #define globalconst static const
inline i32 #define DrBegin() switch (s.__pc__){ case 0:;
raw_ptr_dif(void *a, void *b) { return (i32)((u8*)a - (u8*)b); } #define DrEnd() default: Assert(!"Invalid __pc__"); }
#define DrYield(pc, n) { s.__pc__ = pc; *state = s; return(n); case pc:; }
#define COMP_ID_(a,b,c,d) (d << 24) | (c << 16) | (b << 8) | a #define DrReturn(n) { s.__pc__ = -1; return(n); }
#define COMPOSE_ID(a,b,c,d) (COMP_ID_((a),(b),(c),(d)))
inline i32
#define S(X) #X raw_ptr_dif(void *a, void *b) { return (i32)((u8*)a - (u8*)b); }
#define S_(X) S(X)
#define S__LINE__ S_(__LINE__) #define COMP_ID_(a,b,c,d) (d << 24) | (c << 16) | (b << 8) | a
#define COMPOSE_ID(a,b,c,d) (COMP_ID_((a),(b),(c),(d)))
#if FRED_PRINT_DEBUG == 1
internal void #define S(X) #X
_OutDbgStr(u8*); #define S_(X) S(X)
# include <stdio.h> #define S__LINE__ S_(__LINE__)
# if FRED_PRINT_DEBUG_FILE_LINE
# define FredDbg(con, size, ...) {_OutDbgStr((u8*)("FILE:"__FILE__"LINE:"S__LINE__"\n")); char msg[size]; sprintf(msg, __VA_ARGS__); _OutDbgStr((u8*)msg);} #if FRED_PRINT_DEBUG == 1
# else internal void
# define FredDbg(con, size, ...) {char msg[size]; sprintf(msg, __VA_ARGS__); _OutDbgStr((u8*)msg);} _OutDbgStr(u8*);
# endif # include <stdio.h>
#elif FRED_PRINT_DEBUG == 2 # if FRED_PRINT_DEBUG_FILE_LINE
# include <stdio.h> # define FredDbg(con, size, ...) {_OutDbgStr((u8*)("FILE:"__FILE__"LINE:"S__LINE__"\n")); char msg[size]; sprintf(msg, __VA_ARGS__); _OutDbgStr((u8*)msg);}
# if FRED_PRINT_DEBUG_FILE_LINE # else
# define FredDbg(con, size, ...) {fprintf((con)->log, ("FILE:"__FILE__"LINE:"S__LINE__"\n")); fprintf(__VA_ARGS__);} # define FredDbg(con, size, ...) {char msg[size]; sprintf(msg, __VA_ARGS__); _OutDbgStr((u8*)msg);}
# else # endif
# define FredDbg(con, size, ...) {fprintf((con)->log, __VA_ARGS__);} #elif FRED_PRINT_DEBUG == 2
# endif # include <stdio.h>
#else # if FRED_PRINT_DEBUG_FILE_LINE
# define FredDbg(con, size, ...) # define FredDbg(con, size, ...) {fprintf((con)->log, ("FILE:"__FILE__"LINE:"S__LINE__"\n")); fprintf(__VA_ARGS__);}
#endif # else
# define FredDbg(con, size, ...) {fprintf((con)->log, __VA_ARGS__);}
#if FRED_INTERNAL && FRED_FULL_ERRORS # endif
# include <stdio.h> #else
# define FatalErrorFormat(alt, size, ...) {char msg[size]; sprintf(msg, __VA_ARGS__); FatalError(msg);} # define FredDbg(con, size, ...)
#else #endif
# define FatalErrorFormat(alt, size, ...) {FatalError(alt);}
#endif #if FRED_INTERNAL && FRED_FULL_ERRORS
# include <stdio.h>
#if FRED_SLOW # define FatalErrorFormat(alt, size, ...) {char msg[size]; sprintf(msg, __VA_ARGS__); FatalError(msg);}
# define Assert(c) assert(c) #else
#else # define FatalErrorFormat(alt, size, ...) {FatalError(alt);}
# define Assert(c) #endif
#endif
#if FRED_SLOW
#define TentativeAssert(c) Assert(c) # define Assert(c) assert(c)
#else
#define FatalError(message) system_fatal_error((u8*)message) # define Assert(c)
#endif
#define AllowLocal(name) (void)name
#define ArrayCount(array) (sizeof(array)/sizeof(array[0])) #define TentativeAssert(c) Assert(c)
#define OffsetOfStruct(S,c) ((i64)(& ((S*)0)->c ))
#define OffsetOfPtr(s,c) ((i64)((char*)(&(s)->c) - (char*)(s))) #define FatalError(message) system_fatal_error((u8*)message)
#define Swap(a,b) {auto t = a; a = b; b = t;} #define AllowLocal(name) (void)name
#define ArrayCount(array) (sizeof(array)/sizeof(array[0]))
#ifndef literal #define OffsetOfStruct(S,c) ((i64)(& ((S*)0)->c ))
#define literal(s) s, (sizeof(s)-1) #define OffsetOfPtr(s,c) ((i64)((char*)(&(s)->c) - (char*)(s)))
#endif
#define Swap(a,b) {auto t = a; a = b; b = t;}
#define Min(a,b) (((a)<(b))?(a):(b))
#define Max(a,b) (((a)>(b))?(a):(b)) #ifndef literal
#define literal(s) s, (sizeof(s)-1)
#define TMax(t,v) globalconst t max_##t = v #endif
TMax(u8, 255);
TMax(u16, 65535); #define Min(a,b) (((a)<(b))?(a):(b))
TMax(u32, 4294967295); #define Max(a,b) (((a)>(b))?(a):(b))
TMax(u64, 18446744073709551615U);
#define TMax(t,v) globalconst t max_##t = v
TMax(i8, 127); TMax(u8, 255);
TMax(i16, 32767); TMax(u16, 65535);
TMax(i32, 2147483647); TMax(u32, 4294967295);
TMax(i64, 9223372036854775807); TMax(u64, 18446744073709551615U);
#undef TMax
TMax(i8, 127);
#define TMin(t) globalconst t min_##t = 0 TMax(i16, 32767);
TMin(u8); TMax(i32, 2147483647);
TMin(u16); TMax(i64, 9223372036854775807);
TMin(u32); #undef TMax
TMin(u64);
#undef TMin #define TMin(t) globalconst t min_##t = 0
TMin(u8);
#define TMin(t,v) globalconst t min_##t = ((t)v) TMin(u16);
TMin(i8, -0xF0); TMin(u32);
TMin(i16, -0xF000); TMin(u64);
TMin(i32, -0xF00000); #undef TMin
TMin(i64, -0xF0000000LL);
#undef TMin #define TMin(t,v) globalconst t min_##t = ((t)v)
TMin(i8, -0xF0);
internal i32 TMin(i16, -0xF000);
LargeRoundUp(i32 x, i32 granularity){ TMin(i32, -0xF00000);
i32 original_x = x; TMin(i64, -0xF0000000LL);
x /= granularity; #undef TMin
x *= granularity;
if (x < original_x){ internal i32
x += granularity; LargeRoundUp(i32 x, i32 granularity){
} i32 original_x = x;
return x; x /= granularity;
} x *= granularity;
if (x < original_x){
#define Bit_0 (1 << 0) x += granularity;
#define Bit_1 (1 << 1) }
#define Bit_2 (1 << 2) return x;
#define Bit_3 (1 << 3) }
#define Bit_4 (1 << 4)
#define Bit_5 (1 << 5) #define Bit_0 (1 << 0)
#define Bit_6 (1 << 6) #define Bit_1 (1 << 1)
#define Bit_7 (1 << 7) #define Bit_2 (1 << 2)
#define Bit_3 (1 << 3)
#define Bit_8 (1 << 8) #define Bit_4 (1 << 4)
#define Bit_9 (1 << 9) #define Bit_5 (1 << 5)
#define Bit_10 (1 << 10) #define Bit_6 (1 << 6)
#define Bit_11 (1 << 11) #define Bit_7 (1 << 7)
#define Bit_12 (1 << 12)
#define Bit_13 (1 << 13) #define Bit_8 (1 << 8)
#define Bit_14 (1 << 14) #define Bit_9 (1 << 9)
#define Bit_15 (1 << 15) #define Bit_10 (1 << 10)
#define Bit_11 (1 << 11)
#define Bit_16 (1 << 16) #define Bit_12 (1 << 12)
#define Bit_17 (1 << 17) #define Bit_13 (1 << 13)
#define Bit_18 (1 << 18) #define Bit_14 (1 << 14)
#define Bit_19 (1 << 19) #define Bit_15 (1 << 15)
#define Bit_20 (1 << 20)
#define Bit_21 (1 << 21) #define Bit_16 (1 << 16)
#define Bit_22 (1 << 22) #define Bit_17 (1 << 17)
#define Bit_23 (1 << 23) #define Bit_18 (1 << 18)
#define Bit_19 (1 << 19)
#define Bit_24 (1 << 24) #define Bit_20 (1 << 20)
#define Bit_25 (1 << 25) #define Bit_21 (1 << 21)
#define Bit_26 (1 << 26) #define Bit_22 (1 << 22)
#define Bit_27 (1 << 27) #define Bit_23 (1 << 23)
#define Bit_28 (1 << 28)
#define Bit_29 (1 << 29) #define Bit_24 (1 << 24)
#define Bit_30 (1 << 30) #define Bit_25 (1 << 25)
#define Bit_31 (1 << 31) #define Bit_26 (1 << 26)
#define Bit_27 (1 << 27)
#define Byte_0 (0xFFU) #define Bit_28 (1 << 28)
#define Byte_1 (0xFFU << 8) #define Bit_29 (1 << 29)
#define Byte_2 (0xFFU << 16) #define Bit_30 (1 << 30)
#define Byte_3 (0xFFU << 24) #define Bit_31 (1 << 31)
#define Byte_4 (0xFFU << 32)
#define Byte_5 (0xFFU << 40) #define Byte_0 (0xFFU)
#define Byte_6 (0xFFU << 48) #define Byte_1 (0xFFU << 8)
#define Byte_7 (0xFFU << 56) #define Byte_2 (0xFFU << 16)
#define Byte_3 (0xFFU << 24)
#define bytes(n) (n) #define Byte_4 (0xFFU << 32)
#define Kbytes(n) ((n) << 10) #define Byte_5 (0xFFU << 40)
#define Mbytes(n) ((n) << 20) #define Byte_6 (0xFFU << 48)
#define Gbytes(n) (((u64)n) << 30) #define Byte_7 (0xFFU << 56)
#define Tbytes(n) (((u64)n) << 40)
#define bytes(n) (n)
#endif #define Kbytes(n) ((n) << 10)
#define Mbytes(n) ((n) << 20)
#define Gbytes(n) (((u64)n) << 30)
#define Tbytes(n) (((u64)n) << 40)
#endif

BIN
vc120.pdb

Binary file not shown.

View File

@ -314,6 +314,21 @@ system_save_file(char *filename, void *data, i32 size){
return 1; return 1;
} }
internal b32
system_file_can_be_made(char *filename){
HANDLE file;
file = CreateFile((char*)filename, GENERIC_WRITE, 0, 0,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (!file || file == INVALID_HANDLE_VALUE){
return 0;
}
CloseHandle(file);
return 1;
}
internal internal
Sys_File_Time_Stamp_Sig(system_file_time_stamp){ Sys_File_Time_Stamp_Sig(system_file_time_stamp){
u64 result; u64 result;
@ -1423,8 +1438,12 @@ UpdateLoop(LPVOID param){
if (file->flags & FEx_Save){ if (file->flags & FEx_Save){
Assert((file->flags & FEx_Request) == 0); Assert((file->flags & FEx_Request) == 0);
file->flags &= (~FEx_Save); file->flags &= (~FEx_Save);
system_save_file(file->filename, file->data, file->size); if (system_save_file(file->filename, file->data, file->size)){
file->flags |= FEx_Save_Complete; file->flags |= FEx_Save_Complete;
}
else{
file->flags |= FEx_Save_Failed;
}
} }
if (file->flags & FEx_Request){ if (file->flags & FEx_Request){
@ -1543,12 +1562,16 @@ WinMain(HINSTANCE hInstance,
Command_Line_Parameters clparams; Command_Line_Parameters clparams;
clparams.argv = __argv; clparams.argv = __argv;
clparams.argc = __argc; clparams.argc = __argc;
char **files;
i32 *file_count;
i32 output_size = i32 output_size =
win32vars.app.read_command_line(system, win32vars.app.read_command_line(system,
&memory_vars, &memory_vars,
current_directory, current_directory,
&win32vars.settings, &win32vars.settings,
&files, &file_count,
clparams); clparams);
// //
@ -1556,6 +1579,18 @@ WinMain(HINSTANCE hInstance,
// TODO // TODO
} }
if (output_size != 0) return 0; if (output_size != 0) return 0;
{
i32 i, j;
i32 end = *file_count;
for (i = 0, j = 0; i < end; ++i){
if (system_file_can_be_made(files[i])){
files[j] = files[i];
++j;
}
}
*file_count = j;
}
LARGE_INTEGER lpf; LARGE_INTEGER lpf;
QueryPerformanceFrequency(&lpf); QueryPerformanceFrequency(&lpf);