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 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;'>
|
<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(
|
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>
|
||||||
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Parameters</i></b></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='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.
|
<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>
|
This must have a capacity of at least the size of src.</div></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
|
<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>
|
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>
|
<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 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;'>
|
<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(
|
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>
|
||||||
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Parameters</i></b></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='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.
|
<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>
|
This must have a capacity of at least the size of src.</div></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
|
<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>
|
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>
|
<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 IS_FULLSCREEN_SIG(Is_Fullscreen_Function);
|
||||||
typedef SEND_EXIT_SIGNAL_SIG(Send_Exit_Signal_Function);
|
typedef SEND_EXIT_SIGNAL_SIG(Send_Exit_Signal_Function);
|
||||||
struct Application_Links{
|
struct Application_Links{
|
||||||
void *memory;
|
Exec_Command_Function *exec_command;
|
||||||
int32_t memory_size;
|
Exec_System_Command_Function *exec_system_command;
|
||||||
Exec_Command_Function *exec_command;
|
Clipboard_Post_Function *clipboard_post;
|
||||||
Exec_System_Command_Function *exec_system_command;
|
Clipboard_Count_Function *clipboard_count;
|
||||||
Clipboard_Post_Function *clipboard_post;
|
Clipboard_Index_Function *clipboard_index;
|
||||||
Clipboard_Count_Function *clipboard_count;
|
Get_Buffer_Count_Function *get_buffer_count;
|
||||||
Clipboard_Index_Function *clipboard_index;
|
Get_Buffer_First_Function *get_buffer_first;
|
||||||
Get_Buffer_Count_Function *get_buffer_count;
|
Get_Buffer_Next_Function *get_buffer_next;
|
||||||
Get_Buffer_First_Function *get_buffer_first;
|
Get_Buffer_Function *get_buffer;
|
||||||
Get_Buffer_Next_Function *get_buffer_next;
|
Get_Buffer_By_Name_Function *get_buffer_by_name;
|
||||||
Get_Buffer_Function *get_buffer;
|
Buffer_Boundary_Seek_Function *buffer_boundary_seek;
|
||||||
Get_Buffer_By_Name_Function *get_buffer_by_name;
|
Buffer_Read_Range_Function *buffer_read_range;
|
||||||
Buffer_Boundary_Seek_Function *buffer_boundary_seek;
|
Buffer_Replace_Range_Function *buffer_replace_range;
|
||||||
Buffer_Read_Range_Function *buffer_read_range;
|
Buffer_Compute_Cursor_Function *buffer_compute_cursor;
|
||||||
Buffer_Replace_Range_Function *buffer_replace_range;
|
Buffer_Batch_Edit_Function *buffer_batch_edit;
|
||||||
Buffer_Compute_Cursor_Function *buffer_compute_cursor;
|
Buffer_Set_Setting_Function *buffer_set_setting;
|
||||||
Buffer_Batch_Edit_Function *buffer_batch_edit;
|
Buffer_Auto_Indent_Function *buffer_auto_indent;
|
||||||
Buffer_Set_Setting_Function *buffer_set_setting;
|
Create_Buffer_Function *create_buffer;
|
||||||
Buffer_Auto_Indent_Function *buffer_auto_indent;
|
Save_Buffer_Function *save_buffer;
|
||||||
Create_Buffer_Function *create_buffer;
|
Kill_Buffer_Function *kill_buffer;
|
||||||
Save_Buffer_Function *save_buffer;
|
Get_View_First_Function *get_view_first;
|
||||||
Kill_Buffer_Function *kill_buffer;
|
Get_View_Next_Function *get_view_next;
|
||||||
Get_View_First_Function *get_view_first;
|
Get_View_Function *get_view;
|
||||||
Get_View_Next_Function *get_view_next;
|
Get_Active_View_Function *get_active_view;
|
||||||
Get_View_Function *get_view;
|
Open_View_Function *open_view;
|
||||||
Get_Active_View_Function *get_active_view;
|
Close_View_Function *close_view;
|
||||||
Open_View_Function *open_view;
|
Set_Active_View_Function *set_active_view;
|
||||||
Close_View_Function *close_view;
|
View_Set_Setting_Function *view_set_setting;
|
||||||
Set_Active_View_Function *set_active_view;
|
View_Set_Split_Proportion_Function *view_set_split_proportion;
|
||||||
View_Set_Setting_Function *view_set_setting;
|
View_Compute_Cursor_Function *view_compute_cursor;
|
||||||
View_Set_Split_Proportion_Function *view_set_split_proportion;
|
View_Set_Cursor_Function *view_set_cursor;
|
||||||
View_Compute_Cursor_Function *view_compute_cursor;
|
View_Set_Scroll_Function *view_set_scroll;
|
||||||
View_Set_Cursor_Function *view_set_cursor;
|
View_Set_Mark_Function *view_set_mark;
|
||||||
View_Set_Scroll_Function *view_set_scroll;
|
View_Set_Highlight_Function *view_set_highlight;
|
||||||
View_Set_Mark_Function *view_set_mark;
|
View_Set_Buffer_Function *view_set_buffer;
|
||||||
View_Set_Highlight_Function *view_set_highlight;
|
View_Post_Fade_Function *view_post_fade;
|
||||||
View_Set_Buffer_Function *view_set_buffer;
|
Get_User_Input_Function *get_user_input;
|
||||||
View_Post_Fade_Function *view_post_fade;
|
Get_Command_Input_Function *get_command_input;
|
||||||
Get_User_Input_Function *get_user_input;
|
Get_Mouse_State_Function *get_mouse_state;
|
||||||
Get_Command_Input_Function *get_command_input;
|
Start_Query_Bar_Function *start_query_bar;
|
||||||
Get_Mouse_State_Function *get_mouse_state;
|
End_Query_Bar_Function *end_query_bar;
|
||||||
Start_Query_Bar_Function *start_query_bar;
|
Print_Message_Function *print_message;
|
||||||
End_Query_Bar_Function *end_query_bar;
|
Change_Theme_Function *change_theme;
|
||||||
Print_Message_Function *print_message;
|
Change_Font_Function *change_font;
|
||||||
Change_Theme_Function *change_theme;
|
Buffer_Set_Font_Function *buffer_set_font;
|
||||||
Change_Font_Function *change_font;
|
Set_Theme_Colors_Function *set_theme_colors;
|
||||||
Buffer_Set_Font_Function *buffer_set_font;
|
Get_Theme_Colors_Function *get_theme_colors;
|
||||||
Set_Theme_Colors_Function *set_theme_colors;
|
Directory_Get_Hot_Function *directory_get_hot;
|
||||||
Get_Theme_Colors_Function *get_theme_colors;
|
Get_File_List_Function *get_file_list;
|
||||||
Directory_Get_Hot_Function *directory_get_hot;
|
Free_File_List_Function *free_file_list;
|
||||||
Get_File_List_Function *get_file_list;
|
Memory_Allocate_Function *memory_allocate;
|
||||||
Free_File_List_Function *free_file_list;
|
Memory_Set_Protection_Function *memory_set_protection;
|
||||||
Memory_Allocate_Function *memory_allocate;
|
Memory_Free_Function *memory_free;
|
||||||
Memory_Set_Protection_Function *memory_set_protection;
|
File_Exists_Function *file_exists;
|
||||||
Memory_Free_Function *memory_free;
|
Directory_CD_Function *directory_cd;
|
||||||
File_Exists_Function *file_exists;
|
Get_4ed_Path_Function *get_4ed_path;
|
||||||
Directory_CD_Function *directory_cd;
|
Show_Mouse_Cursor_Function *show_mouse_cursor;
|
||||||
Get_4ed_Path_Function *get_4ed_path;
|
Toggle_Fullscreen_Function *toggle_fullscreen;
|
||||||
Show_Mouse_Cursor_Function *show_mouse_cursor;
|
Is_Fullscreen_Function *is_fullscreen;
|
||||||
Toggle_Fullscreen_Function *toggle_fullscreen;
|
Send_Exit_Signal_Function *send_exit_signal;
|
||||||
Is_Fullscreen_Function *is_fullscreen;
|
void *memory;
|
||||||
Send_Exit_Signal_Function *send_exit_signal;
|
int32_t memory_size;
|
||||||
void *cmd_context;
|
void *cmd_context;
|
||||||
void *system_links;
|
void *system_links;
|
||||||
void *current_coroutine;
|
void *current_coroutine;
|
||||||
int32_t type_coroutine;
|
int32_t type_coroutine;
|
||||||
};
|
};
|
||||||
#define FillAppLinksAPI(app_links) do{\
|
#define FillAppLinksAPI(app_links) do{\
|
||||||
app_links->exec_command = Exec_Command;\
|
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->show_mouse_cursor = Show_Mouse_Cursor;\
|
||||||
app_links->toggle_fullscreen = Toggle_Fullscreen;\
|
app_links->toggle_fullscreen = Toggle_Fullscreen;\
|
||||||
app_links->is_fullscreen = Is_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 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 replace_char(String *str, char replace, char with);
|
||||||
FSTRING_LINK void to_lower_cc(char *src, char *dst);
|
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_lower_s(String *str);
|
||||||
FSTRING_LINK void to_upper_cc(char *src, char *dst);
|
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_upper_s(String *str);
|
||||||
FSTRING_LINK void to_camel_cc(char *src, char *dst);
|
FSTRING_LINK void to_camel_cc(char *src, char *dst);
|
||||||
FSTRING_LINK int32_t int_to_str_size(int32_t x);
|
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, String src);
|
||||||
FSTRING_INLINE fstr_bool append(String *dest, char *src);
|
FSTRING_INLINE fstr_bool append(String *dest, char *src);
|
||||||
FSTRING_INLINE void to_lower(char *src, char *dst);
|
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_lower(String *str);
|
||||||
FSTRING_INLINE void to_upper(char *src, char *dst);
|
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_upper(String *str);
|
||||||
FSTRING_INLINE void to_camel(char *src, char *dst);
|
FSTRING_INLINE void to_camel(char *src, char *dst);
|
||||||
FSTRING_INLINE int32_t str_is_int(char *str);
|
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
|
FSTRING_INLINE void
|
||||||
to_lower(char *src, char *dst){(to_lower_cc(src,dst));}
|
to_lower(char *src, char *dst){(to_lower_cc(src,dst));}
|
||||||
FSTRING_INLINE void
|
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
|
FSTRING_INLINE void
|
||||||
to_lower(String *str){(to_lower_s(str));}
|
to_lower(String *str){(to_lower_s(str));}
|
||||||
FSTRING_INLINE void
|
FSTRING_INLINE void
|
||||||
to_upper(char *src, char *dst){(to_upper_cc(src,dst));}
|
to_upper(char *src, char *dst){(to_upper_cc(src,dst));}
|
||||||
FSTRING_INLINE void
|
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
|
FSTRING_INLINE void
|
||||||
to_upper(String *str){(to_upper_s(str));}
|
to_upper(String *str){(to_upper_s(str));}
|
||||||
FSTRING_INLINE void
|
FSTRING_INLINE void
|
||||||
|
@ -1442,16 +1442,17 @@ to_lower_cc(char *src, char *dst){
|
||||||
|
|
||||||
#if defined(FSTRING_IMPLEMENTATION)
|
#if defined(FSTRING_IMPLEMENTATION)
|
||||||
FSTRING_LINK void
|
FSTRING_LINK void
|
||||||
to_lower_ss(String *src, String *dst){
|
to_lower_ss(String *dst, String src){
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t size = src->size;
|
int32_t size = src.size;
|
||||||
char *c = src->str;
|
char *c = src.str;
|
||||||
char *d = dst->str;
|
char *d = dst->str;
|
||||||
|
|
||||||
if (dst->memory_size >= size){
|
if (dst->memory_size >= size){
|
||||||
for (; i < size; ++i){
|
for (; i < size; ++i){
|
||||||
*d++ = char_to_lower(*c++);
|
*d++ = char_to_lower(*c++);
|
||||||
}
|
}
|
||||||
|
dst->size = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1483,16 +1484,17 @@ to_upper_cc(char *src, char *dst){
|
||||||
|
|
||||||
#if defined(FSTRING_IMPLEMENTATION)
|
#if defined(FSTRING_IMPLEMENTATION)
|
||||||
FSTRING_LINK void
|
FSTRING_LINK void
|
||||||
to_upper_ss(String *src, String *dst){
|
to_upper_ss(String *dst, String src){
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t size = src->size;
|
int32_t size = src.size;
|
||||||
char *c = src->str;
|
char *c = src.str;
|
||||||
char *d = dst->str;
|
char *d = dst->str;
|
||||||
|
|
||||||
if (dst->memory_size >= size){
|
if (dst->memory_size >= size){
|
||||||
for (; i < size; ++i){
|
for (; i < size; ++i){
|
||||||
*d++ = char_to_upper(*c++);
|
*d++ = char_to_upper(*c++);
|
||||||
}
|
}
|
||||||
|
dst->size = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
239
4ed_metagen.cpp
239
4ed_metagen.cpp
|
@ -31,10 +31,15 @@ typedef struct Out_Context{
|
||||||
} Out_Context;
|
} Out_Context;
|
||||||
|
|
||||||
static String
|
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));
|
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
|
static int32_t
|
||||||
begin_file_out(Out_Context *out_context, char *filename, String *out){
|
begin_file_out(Out_Context *out_context, char *filename, String *out){
|
||||||
int32_t r = 0;
|
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));
|
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 =
|
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);
|
set_token(context, token+1);
|
||||||
result = true;
|
result = true;
|
||||||
|
@ -1052,7 +1057,7 @@ typedef_parse(Parse_Context *context, Item_Node *item){
|
||||||
String name = get_lexeme(*token_j, context->data);
|
String name = get_lexeme(*token_j, context->data);
|
||||||
|
|
||||||
String type = skip_chop_whitespace(
|
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;
|
item->t = Item_Typedef;
|
||||||
|
@ -1133,7 +1138,7 @@ enum_parse(Partition *part, Parse_Context *context, Item_Node *item){
|
||||||
}
|
}
|
||||||
|
|
||||||
value = skip_chop_whitespace(
|
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);
|
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->name = get_lexeme(*token, context->data);
|
||||||
|
|
||||||
item->ret = chop_whitespace(
|
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)){
|
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){
|
if (token){
|
||||||
item->args =
|
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->t = Item_Function;
|
||||||
item->cpp_name = cpp_name;
|
item->cpp_name = cpp_name;
|
||||||
item->breakdown = parameter_parse(part, context->data, args_start_token, token);
|
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){
|
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);
|
token->start + token->size);
|
||||||
|
|
||||||
item->breakdown = parameter_parse(part, context->data, args_start_token, token);
|
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);
|
token = get_prev_token(context);
|
||||||
|
|
||||||
item->body =
|
item->body =
|
||||||
get_string(context->data, body_start->start,
|
str_start_end(context->data, body_start->start,
|
||||||
token->start + token->size);
|
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;
|
int32_t do_whitespace_print = false;
|
||||||
for (; i < count; ++i, ++token){
|
for (; i < count; ++i, ++token){
|
||||||
if (do_whitespace_print){
|
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);
|
print_str(file, pstr);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -2172,6 +2177,8 @@ generate_custom_headers(){
|
||||||
Partition part_ = make_part(mem, size);
|
Partition part_ = make_part(mem, size);
|
||||||
Partition *part = &part_;
|
Partition *part = &part_;
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE(allen): Parse the internal string file.
|
||||||
static char *string_files[] = {
|
static char *string_files[] = {
|
||||||
"internal_4coder_string.cpp"
|
"internal_4coder_string.cpp"
|
||||||
};
|
};
|
||||||
|
@ -2186,10 +2193,8 @@ generate_custom_headers(){
|
||||||
Meta_Unit string_unit = compile_meta_unit(part, string_files, ArrayCount(string_files),
|
Meta_Unit string_unit = compile_meta_unit(part, string_files, ArrayCount(string_files),
|
||||||
string_keys, ArrayCount(string_keys));
|
string_keys, ArrayCount(string_keys));
|
||||||
|
|
||||||
//
|
|
||||||
// App API parsing
|
|
||||||
//
|
|
||||||
|
|
||||||
|
// NOTE(allen): Parse the customization API files
|
||||||
static char *functions_files[] = {
|
static char *functions_files[] = {
|
||||||
"4ed_api_implementation.cpp",
|
"4ed_api_implementation.cpp",
|
||||||
"win32_api_impl.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),
|
Meta_Unit unit_custom = compile_meta_unit(part, functions_files, ArrayCount(functions_files),
|
||||||
functions_keys, ArrayCount(functions_keys));
|
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);
|
App_API func_4ed_names = allocate_app_api(part, unit_custom.set.count);
|
||||||
|
|
||||||
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
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 *macro = &func_4ed_names.names[i].macro;
|
||||||
String *public_name = &func_4ed_names.names[i].public_name;
|
String *public_name = &func_4ed_names.names[i].public_name;
|
||||||
|
|
||||||
macro->size = 0;
|
*macro = str_alloc(part, name_string.size+4);
|
||||||
macro->memory_size = name_string.size+4;
|
to_upper_ss(macro, name_string);
|
||||||
|
|
||||||
macro->str = (char*)malloc(macro->memory_size);
|
|
||||||
copy_ss(macro, name_string);
|
|
||||||
to_upper_s(macro);
|
|
||||||
append_ss(macro, make_lit_string("_SIG"));
|
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;
|
partition_align(part, 4);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(allen): Header
|
|
||||||
FILE *file = fopen(OS_API_H, "wb");
|
|
||||||
|
|
||||||
int32_t main_api_count = unit_custom.parse[0].item_count;
|
// NOTE(allen): Parse the customization API types
|
||||||
int32_t os_api_count = unit_custom.parse[1].item_count;
|
static char *type_files[] = {
|
||||||
for (int32_t i = main_api_count; i < os_api_count; ++i){
|
"4coder_types.h"
|
||||||
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;
|
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",
|
dump_file_out(context);
|
||||||
macro_string.size, macro_string.str,
|
|
||||||
ret_string.size, ret_string.str,
|
for (int32_t i = main_api_count; i < os_api_count; ++i){
|
||||||
args_string.size, args_string.str);
|
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){
|
if (begin_file_out(&context, API_H, &out)){
|
||||||
String name_string = unit_custom.set.items[i].name;
|
file = context.file;
|
||||||
String macro_string = func_4ed_names.names[i].macro;
|
|
||||||
|
|
||||||
fprintf(file, "typedef %.*s(%.*s_Function);\n",
|
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||||
macro_string.size, macro_string.str,
|
append_sc(&out, "#define ");
|
||||||
name_string.size, name_string.str);
|
append_ss(&out, func_4ed_names.names[i].macro);
|
||||||
}
|
append_sc(&out, "(n) ");
|
||||||
|
append_ss(&out, unit_custom.set.items[i].ret);
|
||||||
fclose(file);
|
append_sc(&out, " n");
|
||||||
|
append_ss(&out, unit_custom.set.items[i].args);
|
||||||
file = fopen(API_H, "wb");
|
append_s_char(&out, '\n');
|
||||||
|
}
|
||||||
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;
|
|
||||||
|
|
||||||
fprintf(file, "#define %.*s(n) %.*s n%.*s\n",
|
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||||
macro_string.size, macro_string.str,
|
append_sc(&out, "typedef ");
|
||||||
ret_string.size, ret_string.str,
|
append_ss(&out, func_4ed_names.names[i].macro);
|
||||||
args_string.size, args_string.str);
|
append_s_char(&out, '(');
|
||||||
}
|
append_ss(&out, unit_custom.set.items[i].name);
|
||||||
|
append_sc(&out, "_Function);\n");
|
||||||
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;
|
|
||||||
|
|
||||||
fprintf(file, "typedef %.*s(%.*s_Function);\n",
|
append_sc(&out,
|
||||||
macro_string.size, macro_string.str,
|
"struct Application_Links{\n");
|
||||||
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;
|
|
||||||
|
|
||||||
fprintf(file, " %.*s_Function *%.*s;\n",
|
for (int32_t i = 0; i < unit_custom.set.count; ++i){
|
||||||
name_string.size, name_string.str,
|
append_ss(&out, unit_custom.set.items[i].name);
|
||||||
public_string.size, public_string.str);
|
append_sc(&out, "_Function *");
|
||||||
}
|
append_ss(&out, func_4ed_names.names[i].public_name);
|
||||||
fprintf(file,
|
append_sc(&out, ";\n");
|
||||||
" 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;
|
|
||||||
|
|
||||||
fprintf(file,
|
append_sc(&out,
|
||||||
"\\\n"
|
"void *memory;\n"
|
||||||
"app_links->%.*s = %.*s;",
|
"int32_t memory_size;\n"
|
||||||
public_string.size, public_string.str,
|
"void *cmd_context;\n"
|
||||||
name.size, name.str
|
"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
|
// 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
|
// Output 4coder_string.h
|
||||||
|
@ -2361,7 +2370,7 @@ generate_custom_headers(){
|
||||||
|
|
||||||
for(++i, ++token; i < count; ++i, ++token){
|
for(++i, ++token; i < count; ++i, ++token){
|
||||||
if (do_whitespace_print){
|
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);
|
print_str(file, pstr);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -2597,7 +2606,7 @@ generate_custom_headers(){
|
||||||
start = token->start + token->size;
|
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);
|
print_str(file, pstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1140,22 +1140,23 @@ string in place.)
|
||||||
|
|
||||||
CPP_NAME(to_lower)
|
CPP_NAME(to_lower)
|
||||||
FSTRING_LINK void
|
FSTRING_LINK void
|
||||||
to_lower_ss(String *src, String *dst)/*
|
to_lower_ss(String *dst, String src)/*
|
||||||
DOC_PARAM(src, The source string to conver to lowercase.)
|
|
||||||
DOC_PARAM(dst, The destination buffer to receive the converted string.
|
DOC_PARAM(dst, The destination buffer to receive the converted string.
|
||||||
This must have a capacity of at least the size of src.)
|
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
|
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.)
|
that src and dst may be exactly equal in order to convert the string in place.)
|
||||||
*/{
|
*/{
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t size = src->size;
|
int32_t size = src.size;
|
||||||
char *c = src->str;
|
char *c = src.str;
|
||||||
char *d = dst->str;
|
char *d = dst->str;
|
||||||
|
|
||||||
if (dst->memory_size >= size){
|
if (dst->memory_size >= size){
|
||||||
for (; i < size; ++i){
|
for (; i < size; ++i){
|
||||||
*d++ = char_to_lower(*c++);
|
*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)
|
CPP_NAME(to_upper)
|
||||||
FSTRING_LINK void
|
FSTRING_LINK void
|
||||||
to_upper_ss(String *src, String *dst)/*
|
to_upper_ss(String *dst, String src)/*
|
||||||
DOC_PARAM(src, The source string to convert to uppercase.)
|
|
||||||
DOC_PARAM(dst, The destination buffer to receive the converted string.
|
DOC_PARAM(dst, The destination buffer to receive the converted string.
|
||||||
This must have a capacity of at least the size of src.)
|
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
|
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.)
|
that src and dst may be exactly equal in order to convert the string in place.)
|
||||||
*/{
|
*/{
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t size = src->size;
|
int32_t size = src.size;
|
||||||
char *c = src->str;
|
char *c = src.str;
|
||||||
char *d = dst->str;
|
char *d = dst->str;
|
||||||
|
|
||||||
if (dst->memory_size >= size){
|
if (dst->memory_size >= size){
|
||||||
for (; i < size; ++i){
|
for (; i < size; ++i){
|
||||||
*d++ = char_to_upper(*c++);
|
*d++ = char_to_upper(*c++);
|
||||||
}
|
}
|
||||||
|
dst->size = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue