converted api header printing to using the Out_Context
parent
a1afaa0e40
commit
8fdff026af
|
@ -3185,17 +3185,17 @@ string in place.</div></div><hr>
|
|||
<div id='to_lower_ss_str_doc'><h4>§4.3.81: to_lower_ss</h4>
|
||||
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>
|
||||
void to_lower_ss(
|
||||
<div style='margin-left: 4mm;'>String *src,<br>String *dst<br></div>)
|
||||
<div style='margin-left: 4mm;'>String *dst,<br>String src<br></div>)
|
||||
</div>
|
||||
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Parameters</i></b></div><div>
|
||||
<div style='font-weight: 600;'>src</div>
|
||||
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The source string to conver to lowercase.</div></div>
|
||||
</div>
|
||||
<div>
|
||||
<div style='font-weight: 600;'>dst</div>
|
||||
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The destination buffer to receive the converted string.
|
||||
This must have a capacity of at least the size of src.</div></div>
|
||||
</div>
|
||||
<div>
|
||||
<div style='font-weight: 600;'>src</div>
|
||||
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The source string to conver to lowercase.</div></div>
|
||||
</div>
|
||||
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>Rewrites the string in src into dst. src and dst should not overlap with the exception
|
||||
that src and dst may be exactly equal in order to convert the string in place.</div></div><hr>
|
||||
<div id='to_lower_s_str_doc'><h4>§4.3.82: to_lower_s</h4>
|
||||
|
@ -3227,17 +3227,17 @@ that src and dst may be exactly equal in order to convert the string in place.</
|
|||
<div id='to_upper_ss_str_doc'><h4>§4.3.84: to_upper_ss</h4>
|
||||
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>
|
||||
void to_upper_ss(
|
||||
<div style='margin-left: 4mm;'>String *src,<br>String *dst<br></div>)
|
||||
<div style='margin-left: 4mm;'>String *dst,<br>String src<br></div>)
|
||||
</div>
|
||||
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Parameters</i></b></div><div>
|
||||
<div style='font-weight: 600;'>src</div>
|
||||
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The source string to convert to uppercase.</div></div>
|
||||
</div>
|
||||
<div>
|
||||
<div style='font-weight: 600;'>dst</div>
|
||||
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The destination buffer to receive the converted string.
|
||||
This must have a capacity of at least the size of src.</div></div>
|
||||
</div>
|
||||
<div>
|
||||
<div style='font-weight: 600;'>src</div>
|
||||
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The source string to convert to uppercase.</div></div>
|
||||
</div>
|
||||
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>Rewrites the string in src into dst. src and dst should not overlap with the exception
|
||||
that src and dst may be exactly equal in order to convert the string in place.</div></div><hr>
|
||||
<div id='to_upper_s_str_doc'><h4>§4.3.85: to_upper_s</h4>
|
||||
|
|
|
@ -119,72 +119,72 @@ typedef TOGGLE_FULLSCREEN_SIG(Toggle_Fullscreen_Function);
|
|||
typedef IS_FULLSCREEN_SIG(Is_Fullscreen_Function);
|
||||
typedef SEND_EXIT_SIGNAL_SIG(Send_Exit_Signal_Function);
|
||||
struct Application_Links{
|
||||
void *memory;
|
||||
int32_t memory_size;
|
||||
Exec_Command_Function *exec_command;
|
||||
Exec_System_Command_Function *exec_system_command;
|
||||
Clipboard_Post_Function *clipboard_post;
|
||||
Clipboard_Count_Function *clipboard_count;
|
||||
Clipboard_Index_Function *clipboard_index;
|
||||
Get_Buffer_Count_Function *get_buffer_count;
|
||||
Get_Buffer_First_Function *get_buffer_first;
|
||||
Get_Buffer_Next_Function *get_buffer_next;
|
||||
Get_Buffer_Function *get_buffer;
|
||||
Get_Buffer_By_Name_Function *get_buffer_by_name;
|
||||
Buffer_Boundary_Seek_Function *buffer_boundary_seek;
|
||||
Buffer_Read_Range_Function *buffer_read_range;
|
||||
Buffer_Replace_Range_Function *buffer_replace_range;
|
||||
Buffer_Compute_Cursor_Function *buffer_compute_cursor;
|
||||
Buffer_Batch_Edit_Function *buffer_batch_edit;
|
||||
Buffer_Set_Setting_Function *buffer_set_setting;
|
||||
Buffer_Auto_Indent_Function *buffer_auto_indent;
|
||||
Create_Buffer_Function *create_buffer;
|
||||
Save_Buffer_Function *save_buffer;
|
||||
Kill_Buffer_Function *kill_buffer;
|
||||
Get_View_First_Function *get_view_first;
|
||||
Get_View_Next_Function *get_view_next;
|
||||
Get_View_Function *get_view;
|
||||
Get_Active_View_Function *get_active_view;
|
||||
Open_View_Function *open_view;
|
||||
Close_View_Function *close_view;
|
||||
Set_Active_View_Function *set_active_view;
|
||||
View_Set_Setting_Function *view_set_setting;
|
||||
View_Set_Split_Proportion_Function *view_set_split_proportion;
|
||||
View_Compute_Cursor_Function *view_compute_cursor;
|
||||
View_Set_Cursor_Function *view_set_cursor;
|
||||
View_Set_Scroll_Function *view_set_scroll;
|
||||
View_Set_Mark_Function *view_set_mark;
|
||||
View_Set_Highlight_Function *view_set_highlight;
|
||||
View_Set_Buffer_Function *view_set_buffer;
|
||||
View_Post_Fade_Function *view_post_fade;
|
||||
Get_User_Input_Function *get_user_input;
|
||||
Get_Command_Input_Function *get_command_input;
|
||||
Get_Mouse_State_Function *get_mouse_state;
|
||||
Start_Query_Bar_Function *start_query_bar;
|
||||
End_Query_Bar_Function *end_query_bar;
|
||||
Print_Message_Function *print_message;
|
||||
Change_Theme_Function *change_theme;
|
||||
Change_Font_Function *change_font;
|
||||
Buffer_Set_Font_Function *buffer_set_font;
|
||||
Set_Theme_Colors_Function *set_theme_colors;
|
||||
Get_Theme_Colors_Function *get_theme_colors;
|
||||
Directory_Get_Hot_Function *directory_get_hot;
|
||||
Get_File_List_Function *get_file_list;
|
||||
Free_File_List_Function *free_file_list;
|
||||
Memory_Allocate_Function *memory_allocate;
|
||||
Memory_Set_Protection_Function *memory_set_protection;
|
||||
Memory_Free_Function *memory_free;
|
||||
File_Exists_Function *file_exists;
|
||||
Directory_CD_Function *directory_cd;
|
||||
Get_4ed_Path_Function *get_4ed_path;
|
||||
Show_Mouse_Cursor_Function *show_mouse_cursor;
|
||||
Toggle_Fullscreen_Function *toggle_fullscreen;
|
||||
Is_Fullscreen_Function *is_fullscreen;
|
||||
Send_Exit_Signal_Function *send_exit_signal;
|
||||
void *cmd_context;
|
||||
void *system_links;
|
||||
void *current_coroutine;
|
||||
int32_t type_coroutine;
|
||||
Exec_Command_Function *exec_command;
|
||||
Exec_System_Command_Function *exec_system_command;
|
||||
Clipboard_Post_Function *clipboard_post;
|
||||
Clipboard_Count_Function *clipboard_count;
|
||||
Clipboard_Index_Function *clipboard_index;
|
||||
Get_Buffer_Count_Function *get_buffer_count;
|
||||
Get_Buffer_First_Function *get_buffer_first;
|
||||
Get_Buffer_Next_Function *get_buffer_next;
|
||||
Get_Buffer_Function *get_buffer;
|
||||
Get_Buffer_By_Name_Function *get_buffer_by_name;
|
||||
Buffer_Boundary_Seek_Function *buffer_boundary_seek;
|
||||
Buffer_Read_Range_Function *buffer_read_range;
|
||||
Buffer_Replace_Range_Function *buffer_replace_range;
|
||||
Buffer_Compute_Cursor_Function *buffer_compute_cursor;
|
||||
Buffer_Batch_Edit_Function *buffer_batch_edit;
|
||||
Buffer_Set_Setting_Function *buffer_set_setting;
|
||||
Buffer_Auto_Indent_Function *buffer_auto_indent;
|
||||
Create_Buffer_Function *create_buffer;
|
||||
Save_Buffer_Function *save_buffer;
|
||||
Kill_Buffer_Function *kill_buffer;
|
||||
Get_View_First_Function *get_view_first;
|
||||
Get_View_Next_Function *get_view_next;
|
||||
Get_View_Function *get_view;
|
||||
Get_Active_View_Function *get_active_view;
|
||||
Open_View_Function *open_view;
|
||||
Close_View_Function *close_view;
|
||||
Set_Active_View_Function *set_active_view;
|
||||
View_Set_Setting_Function *view_set_setting;
|
||||
View_Set_Split_Proportion_Function *view_set_split_proportion;
|
||||
View_Compute_Cursor_Function *view_compute_cursor;
|
||||
View_Set_Cursor_Function *view_set_cursor;
|
||||
View_Set_Scroll_Function *view_set_scroll;
|
||||
View_Set_Mark_Function *view_set_mark;
|
||||
View_Set_Highlight_Function *view_set_highlight;
|
||||
View_Set_Buffer_Function *view_set_buffer;
|
||||
View_Post_Fade_Function *view_post_fade;
|
||||
Get_User_Input_Function *get_user_input;
|
||||
Get_Command_Input_Function *get_command_input;
|
||||
Get_Mouse_State_Function *get_mouse_state;
|
||||
Start_Query_Bar_Function *start_query_bar;
|
||||
End_Query_Bar_Function *end_query_bar;
|
||||
Print_Message_Function *print_message;
|
||||
Change_Theme_Function *change_theme;
|
||||
Change_Font_Function *change_font;
|
||||
Buffer_Set_Font_Function *buffer_set_font;
|
||||
Set_Theme_Colors_Function *set_theme_colors;
|
||||
Get_Theme_Colors_Function *get_theme_colors;
|
||||
Directory_Get_Hot_Function *directory_get_hot;
|
||||
Get_File_List_Function *get_file_list;
|
||||
Free_File_List_Function *free_file_list;
|
||||
Memory_Allocate_Function *memory_allocate;
|
||||
Memory_Set_Protection_Function *memory_set_protection;
|
||||
Memory_Free_Function *memory_free;
|
||||
File_Exists_Function *file_exists;
|
||||
Directory_CD_Function *directory_cd;
|
||||
Get_4ed_Path_Function *get_4ed_path;
|
||||
Show_Mouse_Cursor_Function *show_mouse_cursor;
|
||||
Toggle_Fullscreen_Function *toggle_fullscreen;
|
||||
Is_Fullscreen_Function *is_fullscreen;
|
||||
Send_Exit_Signal_Function *send_exit_signal;
|
||||
void *memory;
|
||||
int32_t memory_size;
|
||||
void *cmd_context;
|
||||
void *system_links;
|
||||
void *current_coroutine;
|
||||
int32_t type_coroutine;
|
||||
};
|
||||
#define FillAppLinksAPI(app_links) do{\
|
||||
app_links->exec_command = Exec_Command;\
|
||||
|
@ -246,4 +246,4 @@ app_links->get_4ed_path = Get_4ed_Path;\
|
|||
app_links->show_mouse_cursor = Show_Mouse_Cursor;\
|
||||
app_links->toggle_fullscreen = Toggle_Fullscreen;\
|
||||
app_links->is_fullscreen = Is_Fullscreen;\
|
||||
app_links->send_exit_signal = Send_Exit_Signal; } while(false)
|
||||
app_links->send_exit_signal = Send_Exit_Signal;} while(false)
|
||||
|
|
|
@ -133,10 +133,10 @@ FSTRING_LINK fstr_bool terminate_with_null(String *str);
|
|||
FSTRING_LINK fstr_bool append_padding(String *dest, char c, int32_t target_size);
|
||||
FSTRING_LINK void replace_char(String *str, char replace, char with);
|
||||
FSTRING_LINK void to_lower_cc(char *src, char *dst);
|
||||
FSTRING_LINK void to_lower_ss(String *src, String *dst);
|
||||
FSTRING_LINK void to_lower_ss(String *dst, String src);
|
||||
FSTRING_LINK void to_lower_s(String *str);
|
||||
FSTRING_LINK void to_upper_cc(char *src, char *dst);
|
||||
FSTRING_LINK void to_upper_ss(String *src, String *dst);
|
||||
FSTRING_LINK void to_upper_ss(String *dst, String src);
|
||||
FSTRING_LINK void to_upper_s(String *str);
|
||||
FSTRING_LINK void to_camel_cc(char *src, char *dst);
|
||||
FSTRING_LINK int32_t int_to_str_size(int32_t x);
|
||||
|
@ -229,10 +229,10 @@ FSTRING_INLINE fstr_bool append(String *dest, char c);
|
|||
FSTRING_INLINE fstr_bool append(String *dest, String src);
|
||||
FSTRING_INLINE fstr_bool append(String *dest, char *src);
|
||||
FSTRING_INLINE void to_lower(char *src, char *dst);
|
||||
FSTRING_INLINE void to_lower(String *src, String *dst);
|
||||
FSTRING_INLINE void to_lower(String *dst, String src);
|
||||
FSTRING_INLINE void to_lower(String *str);
|
||||
FSTRING_INLINE void to_upper(char *src, char *dst);
|
||||
FSTRING_INLINE void to_upper(String *src, String *dst);
|
||||
FSTRING_INLINE void to_upper(String *dst, String src);
|
||||
FSTRING_INLINE void to_upper(String *str);
|
||||
FSTRING_INLINE void to_camel(char *src, char *dst);
|
||||
FSTRING_INLINE int32_t str_is_int(char *str);
|
||||
|
@ -361,13 +361,13 @@ append(String *dest, char *src){return(append_sc(dest,src));}
|
|||
FSTRING_INLINE void
|
||||
to_lower(char *src, char *dst){(to_lower_cc(src,dst));}
|
||||
FSTRING_INLINE void
|
||||
to_lower(String *src, String *dst){(to_lower_ss(src,dst));}
|
||||
to_lower(String *dst, String src){(to_lower_ss(dst,src));}
|
||||
FSTRING_INLINE void
|
||||
to_lower(String *str){(to_lower_s(str));}
|
||||
FSTRING_INLINE void
|
||||
to_upper(char *src, char *dst){(to_upper_cc(src,dst));}
|
||||
FSTRING_INLINE void
|
||||
to_upper(String *src, String *dst){(to_upper_ss(src,dst));}
|
||||
to_upper(String *dst, String src){(to_upper_ss(dst,src));}
|
||||
FSTRING_INLINE void
|
||||
to_upper(String *str){(to_upper_s(str));}
|
||||
FSTRING_INLINE void
|
||||
|
@ -1442,16 +1442,17 @@ to_lower_cc(char *src, char *dst){
|
|||
|
||||
#if defined(FSTRING_IMPLEMENTATION)
|
||||
FSTRING_LINK void
|
||||
to_lower_ss(String *src, String *dst){
|
||||
to_lower_ss(String *dst, String src){
|
||||
int32_t i = 0;
|
||||
int32_t size = src->size;
|
||||
char *c = src->str;
|
||||
int32_t size = src.size;
|
||||
char *c = src.str;
|
||||
char *d = dst->str;
|
||||
|
||||
if (dst->memory_size >= size){
|
||||
for (; i < size; ++i){
|
||||
*d++ = char_to_lower(*c++);
|
||||
}
|
||||
dst->size = size;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1483,16 +1484,17 @@ to_upper_cc(char *src, char *dst){
|
|||
|
||||
#if defined(FSTRING_IMPLEMENTATION)
|
||||
FSTRING_LINK void
|
||||
to_upper_ss(String *src, String *dst){
|
||||
to_upper_ss(String *dst, String src){
|
||||
int32_t i = 0;
|
||||
int32_t size = src->size;
|
||||
char *c = src->str;
|
||||
int32_t size = src.size;
|
||||
char *c = src.str;
|
||||
char *d = dst->str;
|
||||
|
||||
if (dst->memory_size >= size){
|
||||
for (; i < size; ++i){
|
||||
*d++ = char_to_upper(*c++);
|
||||
}
|
||||
dst->size = size;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
239
4ed_metagen.cpp
239
4ed_metagen.cpp
|
@ -31,10 +31,15 @@ typedef struct Out_Context{
|
|||
} Out_Context;
|
||||
|
||||
static String
|
||||
get_string(char *data, int32_t start, int32_t end){
|
||||
str_start_end(char *data, int32_t start, int32_t end){
|
||||
return(make_string(data + start, end - start));
|
||||
}
|
||||
|
||||
static String
|
||||
str_alloc(Partition *part, int32_t cap){
|
||||
return(make_string_cap(push_array(part, char, cap), 0, cap));
|
||||
}
|
||||
|
||||
static int32_t
|
||||
begin_file_out(Out_Context *out_context, char *filename, String *out){
|
||||
int32_t r = 0;
|
||||
|
@ -872,10 +877,10 @@ struct_parse_member(Partition *part, Parse_Context *context, Item_Node *member){
|
|||
|
||||
name = skip_chop_whitespace(get_lexeme(*token_j, context->data));
|
||||
|
||||
String type = skip_chop_whitespace(get_string(context->data, start_token->start, token_j->start));
|
||||
String type = skip_chop_whitespace(str_start_end(context->data, start_token->start, token_j->start));
|
||||
|
||||
String type_postfix =
|
||||
skip_chop_whitespace(get_string(context->data, token_j->start + token_j->size, token->start));
|
||||
skip_chop_whitespace(str_start_end(context->data, token_j->start + token_j->size, token->start));
|
||||
|
||||
set_token(context, token+1);
|
||||
result = true;
|
||||
|
@ -1052,7 +1057,7 @@ typedef_parse(Parse_Context *context, Item_Node *item){
|
|||
String name = get_lexeme(*token_j, context->data);
|
||||
|
||||
String type = skip_chop_whitespace(
|
||||
get_string(context->data, start_token->start + start_token->size, token_j->start)
|
||||
str_start_end(context->data, start_token->start + start_token->size, token_j->start)
|
||||
);
|
||||
|
||||
item->t = Item_Typedef;
|
||||
|
@ -1133,7 +1138,7 @@ enum_parse(Partition *part, Parse_Context *context, Item_Node *item){
|
|||
}
|
||||
|
||||
value = skip_chop_whitespace(
|
||||
get_string(context->data, start_token->start + start_token->size, token->start)
|
||||
str_start_end(context->data, start_token->start + start_token->size, token->start)
|
||||
);
|
||||
|
||||
get_prev_token(context);
|
||||
|
@ -1354,7 +1359,7 @@ function_sig_parse(Partition *part, Parse_Context *context, Item_Node *item, Str
|
|||
item->name = get_lexeme(*token, context->data);
|
||||
|
||||
item->ret = chop_whitespace(
|
||||
get_string(context->data, ret_token->start, token->start)
|
||||
str_start_end(context->data, ret_token->start, token->start)
|
||||
);
|
||||
|
||||
for (; (token = get_token(context)) != 0; get_next_token(context)){
|
||||
|
@ -1365,7 +1370,7 @@ function_sig_parse(Partition *part, Parse_Context *context, Item_Node *item, Str
|
|||
|
||||
if (token){
|
||||
item->args =
|
||||
get_string(context->data, args_start_token->start, token->start + token->size);
|
||||
str_start_end(context->data, args_start_token->start, token->start + token->size);
|
||||
item->t = Item_Function;
|
||||
item->cpp_name = cpp_name;
|
||||
item->breakdown = parameter_parse(part, context->data, args_start_token, token);
|
||||
|
@ -1474,7 +1479,7 @@ macro_parse(Partition *part, Parse_Context *context, Item_Node *item){
|
|||
}
|
||||
|
||||
if (token){
|
||||
item->args = get_string(context->data, args_start_token->start,
|
||||
item->args = str_start_end(context->data, args_start_token->start,
|
||||
token->start + token->size);
|
||||
|
||||
item->breakdown = parameter_parse(part, context->data, args_start_token, token);
|
||||
|
@ -1492,7 +1497,7 @@ macro_parse(Partition *part, Parse_Context *context, Item_Node *item){
|
|||
token = get_prev_token(context);
|
||||
|
||||
item->body =
|
||||
get_string(context->data, body_start->start,
|
||||
str_start_end(context->data, body_start->start,
|
||||
token->start + token->size);
|
||||
}
|
||||
}
|
||||
|
@ -1884,7 +1889,7 @@ print_function_body_code(FILE *file, int32_t *index, Cpp_Token **token_ptr, int3
|
|||
int32_t do_whitespace_print = false;
|
||||
for (; i < count; ++i, ++token){
|
||||
if (do_whitespace_print){
|
||||
pstr = get_string(code->str, start, token->start);
|
||||
pstr = str_start_end(code->str, start, token->start);
|
||||
print_str(file, pstr);
|
||||
}
|
||||
else{
|
||||
|
@ -2172,6 +2177,8 @@ generate_custom_headers(){
|
|||
Partition part_ = make_part(mem, size);
|
||||
Partition *part = &part_;
|
||||
|
||||
|
||||
// NOTE(allen): Parse the internal string file.
|
||||
static char *string_files[] = {
|
||||
"internal_4coder_string.cpp"
|
||||
};
|
||||
|
@ -2186,10 +2193,8 @@ generate_custom_headers(){
|
|||
Meta_Unit string_unit = compile_meta_unit(part, string_files, ArrayCount(string_files),
|
||||
string_keys, ArrayCount(string_keys));
|
||||
|
||||
//
|
||||
// App API parsing
|
||||
//
|
||||
|
||||
// NOTE(allen): Parse the customization API files
|
||||
static char *functions_files[] = {
|
||||
"4ed_api_implementation.cpp",
|
||||
"win32_api_impl.cpp"
|
||||
|
@ -2202,6 +2207,8 @@ generate_custom_headers(){
|
|||
Meta_Unit unit_custom = compile_meta_unit(part, functions_files, ArrayCount(functions_files),
|
||||
functions_keys, ArrayCount(functions_keys));
|
||||
|
||||
|
||||
// NOTE(allen): Compute and store variations of the function names
|
||||
App_API func_4ed_names = allocate_app_api(part, unit_custom.set.count);
|
||||
|
||||
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||
|
@ -2209,124 +2216,126 @@ generate_custom_headers(){
|
|||
String *macro = &func_4ed_names.names[i].macro;
|
||||
String *public_name = &func_4ed_names.names[i].public_name;
|
||||
|
||||
macro->size = 0;
|
||||
macro->memory_size = name_string.size+4;
|
||||
|
||||
macro->str = (char*)malloc(macro->memory_size);
|
||||
copy_ss(macro, name_string);
|
||||
to_upper_s(macro);
|
||||
*macro = str_alloc(part, name_string.size+4);
|
||||
to_upper_ss(macro, name_string);
|
||||
append_ss(macro, make_lit_string("_SIG"));
|
||||
|
||||
*public_name = str_alloc(part, name_string.size);
|
||||
to_lower_ss(public_name, name_string);
|
||||
|
||||
public_name->size = 0;
|
||||
public_name->memory_size = name_string.size;
|
||||
|
||||
public_name->str = (char*)malloc(public_name->memory_size);
|
||||
copy_ss(public_name, name_string);
|
||||
to_lower_s(public_name);
|
||||
partition_align(part, 4);
|
||||
}
|
||||
|
||||
// NOTE(allen): Header
|
||||
FILE *file = fopen(OS_API_H, "wb");
|
||||
|
||||
int32_t main_api_count = unit_custom.parse[0].item_count;
|
||||
int32_t os_api_count = unit_custom.parse[1].item_count;
|
||||
for (int32_t i = main_api_count; i < os_api_count; ++i){
|
||||
String ret_string = unit_custom.set.items[i].ret;
|
||||
String args_string = unit_custom.set.items[i].args;
|
||||
String macro_string = func_4ed_names.names[i].macro;
|
||||
// NOTE(allen): Parse the customization API types
|
||||
static char *type_files[] = {
|
||||
"4coder_types.h"
|
||||
};
|
||||
|
||||
static Meta_Keywords type_keys[] = {
|
||||
{make_lit_string("typedef") , Item_Typedef } ,
|
||||
{make_lit_string("struct") , Item_Struct } ,
|
||||
{make_lit_string("union") , Item_Union } ,
|
||||
{make_lit_string("ENUM") , Item_Enum } ,
|
||||
};
|
||||
|
||||
Meta_Unit unit = compile_meta_unit(part, type_files, ArrayCount(type_files),
|
||||
type_keys, ArrayCount(type_keys));
|
||||
|
||||
|
||||
// NOTE(allen): Output
|
||||
String out = str_alloc(part, 10 << 20);
|
||||
Out_Context context = {0};
|
||||
|
||||
// TODO(allen): delete this ASAP
|
||||
FILE *file = 0;
|
||||
|
||||
// NOTE(allen): Custom API headers
|
||||
if (begin_file_out(&context, OS_API_H, &out)){
|
||||
int32_t main_api_count = unit_custom.parse[0].item_count;
|
||||
int32_t os_api_count = unit_custom.parse[1].item_count;
|
||||
for (int32_t i = main_api_count; i < os_api_count; ++i){
|
||||
append_sc(&out, "#define ");
|
||||
append_ss(&out, func_4ed_names.names[i].macro);
|
||||
append_sc(&out, "(n) ");
|
||||
append_ss(&out, unit_custom.set.items[i].ret);
|
||||
append_sc(&out, " n");
|
||||
append_ss(&out, unit_custom.set.items[i].args);
|
||||
append_s_char(&out, '\n');
|
||||
}
|
||||
|
||||
fprintf(file, "#define %.*s(n) %.*s n%.*s\n",
|
||||
macro_string.size, macro_string.str,
|
||||
ret_string.size, ret_string.str,
|
||||
args_string.size, args_string.str);
|
||||
dump_file_out(context);
|
||||
|
||||
for (int32_t i = main_api_count; i < os_api_count; ++i){
|
||||
append_sc(&out, "typedef ");
|
||||
append_ss(&out, func_4ed_names.names[i].macro);
|
||||
append_s_char(&out, '(');
|
||||
append_ss(&out, unit_custom.set.items[i].name);
|
||||
append_sc(&out, "_Function);\n");
|
||||
}
|
||||
|
||||
end_file_out(context);
|
||||
}
|
||||
else{
|
||||
// TODO(allen): warning
|
||||
}
|
||||
|
||||
for (int32_t i = main_api_count; i < os_api_count; ++i){
|
||||
String name_string = unit_custom.set.items[i].name;
|
||||
String macro_string = func_4ed_names.names[i].macro;
|
||||
if (begin_file_out(&context, API_H, &out)){
|
||||
file = context.file;
|
||||
|
||||
fprintf(file, "typedef %.*s(%.*s_Function);\n",
|
||||
macro_string.size, macro_string.str,
|
||||
name_string.size, name_string.str);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
file = fopen(API_H, "wb");
|
||||
|
||||
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||
String ret_string = unit_custom.set.items[i].ret;
|
||||
String args_string = unit_custom.set.items[i].args;
|
||||
String macro_string = func_4ed_names.names[i].macro;
|
||||
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||
append_sc(&out, "#define ");
|
||||
append_ss(&out, func_4ed_names.names[i].macro);
|
||||
append_sc(&out, "(n) ");
|
||||
append_ss(&out, unit_custom.set.items[i].ret);
|
||||
append_sc(&out, " n");
|
||||
append_ss(&out, unit_custom.set.items[i].args);
|
||||
append_s_char(&out, '\n');
|
||||
}
|
||||
|
||||
fprintf(file, "#define %.*s(n) %.*s n%.*s\n",
|
||||
macro_string.size, macro_string.str,
|
||||
ret_string.size, ret_string.str,
|
||||
args_string.size, args_string.str);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||
String name_string = unit_custom.set.items[i].name;
|
||||
String macro_string = func_4ed_names.names[i].macro;
|
||||
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||
append_sc(&out, "typedef ");
|
||||
append_ss(&out, func_4ed_names.names[i].macro);
|
||||
append_s_char(&out, '(');
|
||||
append_ss(&out, unit_custom.set.items[i].name);
|
||||
append_sc(&out, "_Function);\n");
|
||||
}
|
||||
|
||||
fprintf(file, "typedef %.*s(%.*s_Function);\n",
|
||||
macro_string.size, macro_string.str,
|
||||
name_string.size, name_string.str);
|
||||
}
|
||||
|
||||
fprintf(file, "struct Application_Links{\n");
|
||||
fprintf(file,
|
||||
" void *memory;\n"
|
||||
" int32_t memory_size;\n"
|
||||
);
|
||||
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||
String name_string = unit_custom.set.items[i].name;
|
||||
String public_string = func_4ed_names.names[i].public_name;
|
||||
append_sc(&out,
|
||||
"struct Application_Links{\n");
|
||||
|
||||
fprintf(file, " %.*s_Function *%.*s;\n",
|
||||
name_string.size, name_string.str,
|
||||
public_string.size, public_string.str);
|
||||
}
|
||||
fprintf(file,
|
||||
" void *cmd_context;\n"
|
||||
" void *system_links;\n"
|
||||
" void *current_coroutine;\n"
|
||||
" int32_t type_coroutine;\n"
|
||||
);
|
||||
fprintf(file, "};\n");
|
||||
|
||||
fprintf(file, "#define FillAppLinksAPI(app_links) do{");
|
||||
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||
String name = unit_custom.set.items[i].name;
|
||||
String public_string = func_4ed_names.names[i].public_name;
|
||||
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||
append_ss(&out, unit_custom.set.items[i].name);
|
||||
append_sc(&out, "_Function *");
|
||||
append_ss(&out, func_4ed_names.names[i].public_name);
|
||||
append_sc(&out, ";\n");
|
||||
}
|
||||
|
||||
fprintf(file,
|
||||
"\\\n"
|
||||
"app_links->%.*s = %.*s;",
|
||||
public_string.size, public_string.str,
|
||||
name.size, name.str
|
||||
);
|
||||
append_sc(&out,
|
||||
"void *memory;\n"
|
||||
"int32_t memory_size;\n"
|
||||
"void *cmd_context;\n"
|
||||
"void *system_links;\n"
|
||||
"void *current_coroutine;\n"
|
||||
"int32_t type_coroutine;\n"
|
||||
"};\n");
|
||||
|
||||
append_sc(&out, "#define FillAppLinksAPI(app_links) do{");
|
||||
|
||||
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||
append_sc(&out, "\\\napp_links->");
|
||||
append_ss(&out, func_4ed_names.names[i].public_name);
|
||||
append_sc(&out, " = ");
|
||||
append_ss(&out, unit_custom.set.items[i].name);
|
||||
append_s_char(&out, ';');
|
||||
}
|
||||
append_sc(&out, "} while(false)\n");
|
||||
|
||||
end_file_out(context);
|
||||
}
|
||||
fprintf(file, " } while(false)\n");
|
||||
|
||||
fclose(file);
|
||||
|
||||
// NOTE(allen): Documentation
|
||||
{
|
||||
static char *type_files[] = {
|
||||
"4coder_types.h"
|
||||
};
|
||||
|
||||
static Meta_Keywords type_spec_keys[] = {
|
||||
{make_lit_string("typedef") , Item_Typedef } ,
|
||||
{make_lit_string("struct") , Item_Struct } ,
|
||||
{make_lit_string("union") , Item_Union } ,
|
||||
{make_lit_string("ENUM") , Item_Enum } ,
|
||||
};
|
||||
|
||||
Meta_Unit unit = compile_meta_unit(part, type_files, ArrayCount(type_files),
|
||||
type_spec_keys, ArrayCount(type_spec_keys));
|
||||
|
||||
//
|
||||
// Output 4coder_string.h
|
||||
|
@ -2361,7 +2370,7 @@ generate_custom_headers(){
|
|||
|
||||
for(++i, ++token; i < count; ++i, ++token){
|
||||
if (do_whitespace_print){
|
||||
pstr = get_string(code->str, start, token->start);
|
||||
pstr = str_start_end(code->str, start, token->start);
|
||||
print_str(file, pstr);
|
||||
}
|
||||
else{
|
||||
|
@ -2597,7 +2606,7 @@ generate_custom_headers(){
|
|||
start = token->start + token->size;
|
||||
}
|
||||
}
|
||||
pstr = get_string(code->str, start, code->size);
|
||||
pstr = str_start_end(code->str, start, code->size);
|
||||
print_str(file, pstr);
|
||||
}
|
||||
|
||||
|
|
|
@ -1140,22 +1140,23 @@ string in place.)
|
|||
|
||||
CPP_NAME(to_lower)
|
||||
FSTRING_LINK void
|
||||
to_lower_ss(String *src, String *dst)/*
|
||||
DOC_PARAM(src, The source string to conver to lowercase.)
|
||||
to_lower_ss(String *dst, String src)/*
|
||||
DOC_PARAM(dst, The destination buffer to receive the converted string.
|
||||
This must have a capacity of at least the size of src.)
|
||||
DOC_PARAM(src, The source string to conver to lowercase.)
|
||||
DOC(Rewrites the string in src into dst. src and dst should not overlap with the exception
|
||||
that src and dst may be exactly equal in order to convert the string in place.)
|
||||
*/{
|
||||
int32_t i = 0;
|
||||
int32_t size = src->size;
|
||||
char *c = src->str;
|
||||
int32_t size = src.size;
|
||||
char *c = src.str;
|
||||
char *d = dst->str;
|
||||
|
||||
if (dst->memory_size >= size){
|
||||
for (; i < size; ++i){
|
||||
*d++ = char_to_lower(*c++);
|
||||
}
|
||||
dst->size = size;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1190,22 +1191,23 @@ that src and dst may be exactly equal in order to convert the string in place.)
|
|||
|
||||
CPP_NAME(to_upper)
|
||||
FSTRING_LINK void
|
||||
to_upper_ss(String *src, String *dst)/*
|
||||
DOC_PARAM(src, The source string to convert to uppercase.)
|
||||
to_upper_ss(String *dst, String src)/*
|
||||
DOC_PARAM(dst, The destination buffer to receive the converted string.
|
||||
This must have a capacity of at least the size of src.)
|
||||
DOC_PARAM(src, The source string to convert to uppercase.)
|
||||
DOC(Rewrites the string in src into dst. src and dst should not overlap with the exception
|
||||
that src and dst may be exactly equal in order to convert the string in place.)
|
||||
*/{
|
||||
int32_t i = 0;
|
||||
int32_t size = src->size;
|
||||
char *c = src->str;
|
||||
int32_t size = src.size;
|
||||
char *c = src.str;
|
||||
char *d = dst->str;
|
||||
|
||||
if (dst->memory_size >= size){
|
||||
for (; i < size; ++i){
|
||||
*d++ = char_to_upper(*c++);
|
||||
}
|
||||
dst->size = size;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue