bool32 app->exec_command(
diff --git a/4coder_string.h b/4coder_string.h
index 21e4f118..fd948ba3 100644
--- a/4coder_string.h
+++ b/4coder_string.h
@@ -47,347 +47,201 @@ typedef struct Offset_String{
#if !defined(FCODER_STRING_H)
#define FCODER_STRING_H
-FSTRING_INLINE fstr_bool char_is_slash(char c);
-FSTRING_INLINE char char_to_upper(char c);
-FSTRING_INLINE char char_to_lower(char c);
-FSTRING_INLINE fstr_bool char_is_whitespace(char c);
-FSTRING_INLINE fstr_bool char_is_alpha_numeric(char c);
-FSTRING_INLINE fstr_bool char_is_alpha_numeric_true(char c);
-FSTRING_INLINE fstr_bool char_is_alpha(char c);
-FSTRING_INLINE fstr_bool char_is_alpha_true(char c);
-FSTRING_INLINE fstr_bool char_is_hex(char c);
-FSTRING_INLINE fstr_bool char_is_numeric(char c);
-FSTRING_INLINE String string_zero(void);
-FSTRING_INLINE String make_string_cap(void *str, int32_t size, int32_t mem_size);
-FSTRING_INLINE String make_string(void *str, int32_t size);
+FSTRING_INLINE fstr_bool char_is_slash(char c);
+FSTRING_INLINE char char_to_upper(char c);
+FSTRING_INLINE char char_to_lower(char c);
+FSTRING_INLINE fstr_bool char_is_whitespace(char c);
+FSTRING_INLINE fstr_bool char_is_alpha_numeric(char c);
+FSTRING_INLINE fstr_bool char_is_alpha_numeric_true(char c);
+FSTRING_INLINE fstr_bool char_is_alpha(char c);
+FSTRING_INLINE fstr_bool char_is_alpha_true(char c);
+FSTRING_INLINE fstr_bool char_is_hex(char c);
+FSTRING_INLINE fstr_bool char_is_numeric(char c);
+FSTRING_INLINE String string_zero(void);
+FSTRING_INLINE String make_string_cap(void *str, int32_t size, int32_t mem_size);
+FSTRING_INLINE String make_string(void *str, int32_t size);
#ifndef make_lit_string
-# define make_lit_string(s) (make_string_cap((char*)(s), sizeof(s)-1, sizeof(s)))
+# define make_lit_string(s) (make_string_cap((char*)(s), sizeof(s)-1, sizeof(s)))
#endif
#ifndef make_fixed_width_string
-# define make_fixed_width_string(s) (make_string_cap((char*)(s), 0, sizeof(s)))
+# define make_fixed_width_string(s) (make_string_cap((char*)(s), 0, sizeof(s)))
#endif
#ifndef expand_str
-# define expand_str(s) ((s).str), ((s).size)
-#endif
-FSTRING_LINK int32_t str_size(char *str);
-FSTRING_INLINE String make_string_slowly(void *str);
-FSTRING_INLINE String substr_tail(String str, int32_t start);
-FSTRING_INLINE String substr(String str, int32_t start, int32_t size);
-FSTRING_LINK String skip_whitespace(String str);
-FSTRING_LINK String chop_whitespace(String str);
-FSTRING_LINK String skip_chop_whitespace(String str);
-FSTRING_INLINE String tailstr(String str);
-FSTRING_LINK fstr_bool match_cc(char *a, char *b);
-FSTRING_LINK fstr_bool match_sc(String a, char *b);
-FSTRING_INLINE fstr_bool match_cs(char *a, String b);
-FSTRING_LINK fstr_bool match_ss(String a, String b);
-FSTRING_LINK fstr_bool match_part_ccl(char *a, char *b, int32_t *len);
-FSTRING_LINK fstr_bool match_part_scl(String a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part_cc(char *a, char *b);
-FSTRING_INLINE fstr_bool match_part_sc(String a, char *b);
-FSTRING_LINK fstr_bool match_part_cs(char *a, String b);
-FSTRING_LINK fstr_bool match_part_ss(String a, String b);
-FSTRING_LINK fstr_bool match_insensitive_cc(char *a, char *b);
-FSTRING_LINK fstr_bool match_insensitive_sc(String a, char *b);
-FSTRING_INLINE fstr_bool match_insensitive_cs(char *a, String b);
-FSTRING_LINK fstr_bool match_insensitive_ss(String a, String b);
-FSTRING_LINK fstr_bool match_part_insensitive_ccl(char *a, char *b, int32_t *len);
-FSTRING_LINK fstr_bool match_part_insensitive_scl(String a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part_insensitive_cc(char *a, char *b);
-FSTRING_INLINE fstr_bool match_part_insensitive_sc(String a, char *b);
-FSTRING_LINK fstr_bool match_part_insensitive_cs(char *a, String b);
-FSTRING_LINK fstr_bool match_part_insensitive_ss(String a, String b);
-FSTRING_LINK int32_t compare_cc(char *a, char *b);
-FSTRING_LINK int32_t compare_sc(String a, char *b);
-FSTRING_INLINE int32_t compare_cs(char *a, String b);
-FSTRING_LINK int32_t compare_ss(String a, String b);
-FSTRING_LINK int32_t find_c_char(char *str, int32_t start, char character);
-FSTRING_LINK int32_t find_s_char(String str, int32_t start, char character);
-FSTRING_LINK int32_t rfind_s_char(String str, int32_t start, char character);
-FSTRING_LINK int32_t find_c_chars(char *str, int32_t start, char *characters);
-FSTRING_LINK int32_t find_s_chars(String str, int32_t start, char *characters);
-FSTRING_LINK int32_t find_substr_c(char *str, int32_t start, String seek);
-FSTRING_LINK int32_t find_substr_s(String str, int32_t start, String seek);
-FSTRING_LINK int32_t rfind_substr_s(String str, int32_t start, String seek);
-FSTRING_LINK int32_t find_substr_insensitive_c(char *str, int32_t start, String seek);
-FSTRING_LINK int32_t find_substr_insensitive_s(String str, int32_t start, String seek);
-FSTRING_INLINE fstr_bool has_substr_c(char *s, String seek);
-FSTRING_INLINE fstr_bool has_substr_s(String s, String seek);
-FSTRING_INLINE fstr_bool has_substr_insensitive_c(char *s, String seek);
-FSTRING_INLINE fstr_bool has_substr_insensitive_s(String s, String seek);
-FSTRING_LINK int32_t copy_fast_unsafe_cc(char *dest, char *src);
-FSTRING_LINK int32_t copy_fast_unsafe_cs(char *dest, String src);
-FSTRING_LINK fstr_bool copy_checked_ss(String *dest, String src);
-FSTRING_LINK fstr_bool copy_partial_sc(String *dest, char *src);
-FSTRING_LINK fstr_bool copy_partial_ss(String *dest, String src);
-FSTRING_INLINE int32_t copy_cc(char *dest, char *src);
-FSTRING_INLINE void copy_ss(String *dest, String src);
-FSTRING_INLINE void copy_sc(String *dest, char *src);
-FSTRING_LINK fstr_bool append_checked_ss(String *dest, String src);
-FSTRING_LINK fstr_bool append_partial_sc(String *dest, char *src);
-FSTRING_LINK fstr_bool append_partial_ss(String *dest, String src);
-FSTRING_LINK fstr_bool append_s_char(String *dest, char c);
-FSTRING_INLINE fstr_bool append_ss(String *dest, String src);
-FSTRING_INLINE fstr_bool append_sc(String *dest, char *src);
-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 *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 *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);
-FSTRING_LINK fstr_bool int_to_str(String *dest, int32_t x);
-FSTRING_LINK fstr_bool append_int_to_str(String *dest, int32_t x);
-FSTRING_LINK int32_t u64_to_str_size(uint64_t x);
-FSTRING_LINK fstr_bool u64_to_str(String *dest, uint64_t x);
-FSTRING_LINK fstr_bool append_u64_to_str(String *dest, uint64_t x);
-FSTRING_LINK int32_t float_to_str_size(float x);
-FSTRING_LINK fstr_bool append_float_to_str(String *dest, float x);
-FSTRING_LINK fstr_bool float_to_str(String *dest, float x);
-FSTRING_LINK int32_t str_is_int_c(char *str);
-FSTRING_LINK fstr_bool str_is_int_s(String str);
-FSTRING_LINK int32_t str_to_int_c(char *str);
-FSTRING_LINK int32_t str_to_int_s(String str);
-FSTRING_LINK int32_t hexchar_to_int(char c);
-FSTRING_LINK char int_to_hexchar(int32_t x);
-FSTRING_LINK uint32_t hexstr_to_int(String str);
-FSTRING_LINK fstr_bool color_to_hexstr(String *s, uint32_t color);
-FSTRING_LINK fstr_bool hexstr_to_color(String s, uint32_t *out);
-FSTRING_LINK int32_t reverse_seek_slash_pos(String str, int32_t pos);
-FSTRING_INLINE int32_t reverse_seek_slash(String str);
-FSTRING_INLINE String front_of_directory(String dir);
-FSTRING_INLINE String path_of_directory(String dir);
-FSTRING_LINK fstr_bool set_last_folder_sc(String *dir, char *folder_name, char slash);
-FSTRING_LINK fstr_bool set_last_folder_ss(String *dir, String folder_name, char slash);
-FSTRING_LINK String file_extension(String str);
-FSTRING_LINK fstr_bool remove_extension(String *str);
-FSTRING_LINK fstr_bool remove_last_folder(String *str);
-FSTRING_LINK fstr_bool string_set_match_table(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index);
-FSTRING_LINK fstr_bool string_set_match(String *str_set, int32_t count, String str, int32_t *match_index);
-
-#if !defined(FSTRING_C)
-
-// NOTE(allen): This section is here to enable nicer names
-// for C++ users who can have overloaded functions. None of
-// these functions add new features.
-FSTRING_INLINE String make_string(void *str, int32_t size, int32_t mem_size);
-FSTRING_INLINE String substr(String str, int32_t start);
-FSTRING_INLINE fstr_bool match(char *a, char *b);
-FSTRING_INLINE fstr_bool match(String a, char *b);
-FSTRING_INLINE fstr_bool match(char *a, String b);
-FSTRING_INLINE fstr_bool match(String a, String b);
-FSTRING_INLINE fstr_bool match_part(char *a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part(String a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part(char *a, char *b);
-FSTRING_INLINE fstr_bool match_part(String a, char *b);
-FSTRING_INLINE fstr_bool match_part(char *a, String b);
-FSTRING_INLINE fstr_bool match_part(String a, String b);
-FSTRING_INLINE fstr_bool match_insensitive(char *a, char *b);
-FSTRING_INLINE fstr_bool match_insensitive(String a, char *b);
-FSTRING_INLINE fstr_bool match_insensitive(char *a, String b);
-FSTRING_INLINE fstr_bool match_insensitive(String a, String b);
-FSTRING_INLINE fstr_bool match_part_insensitive(char *a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part_insensitive(String a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part_insensitive(char *a, char *b);
-FSTRING_INLINE fstr_bool match_part_insensitive(String a, char *b);
-FSTRING_INLINE fstr_bool match_part_insensitive(char *a, String b);
-FSTRING_INLINE fstr_bool match_part_insensitive(String a, String b);
-FSTRING_INLINE int32_t compare(char *a, char *b);
-FSTRING_INLINE int32_t compare(String a, char *b);
-FSTRING_INLINE int32_t compare(char *a, String b);
-FSTRING_INLINE int32_t compare(String a, String b);
-FSTRING_INLINE int32_t find(char *str, int32_t start, char character);
-FSTRING_INLINE int32_t find(String str, int32_t start, char character);
-FSTRING_INLINE int32_t rfind(String str, int32_t start, char character);
-FSTRING_INLINE int32_t find(char *str, int32_t start, char *characters);
-FSTRING_INLINE int32_t find(String str, int32_t start, char *characters);
-FSTRING_INLINE int32_t find_substr(char *str, int32_t start, String seek);
-FSTRING_INLINE int32_t find_substr(String str, int32_t start, String seek);
-FSTRING_INLINE int32_t rfind_substr(String str, int32_t start, String seek);
-FSTRING_INLINE int32_t find_substr_insensitive(char *str, int32_t start, String seek);
-FSTRING_INLINE int32_t find_substr_insensitive(String str, int32_t start, String seek);
-FSTRING_INLINE fstr_bool has_substr(char *s, String seek);
-FSTRING_INLINE fstr_bool has_substr(String s, String seek);
-FSTRING_INLINE fstr_bool has_substr_insensitive(char *s, String seek);
-FSTRING_INLINE fstr_bool has_substr_insensitive(String s, String seek);
-FSTRING_INLINE int32_t copy_fast_unsafe(char *dest, char *src);
-FSTRING_INLINE int32_t copy_fast_unsafe(char *dest, String src);
-FSTRING_INLINE fstr_bool copy_checked(String *dest, String src);
-FSTRING_INLINE fstr_bool copy_partial(String *dest, char *src);
-FSTRING_INLINE fstr_bool copy_partial(String *dest, String src);
-FSTRING_INLINE int32_t copy(char *dest, char *src);
-FSTRING_INLINE void copy(String *dest, String src);
-FSTRING_INLINE void copy(String *dest, char *src);
-FSTRING_INLINE fstr_bool append_checked(String *dest, String src);
-FSTRING_INLINE fstr_bool append_partial(String *dest, char *src);
-FSTRING_INLINE fstr_bool append_partial(String *dest, String src);
-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 *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 *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);
-FSTRING_INLINE fstr_bool str_is_int(String str);
-FSTRING_INLINE int32_t str_to_int(char *str);
-FSTRING_INLINE int32_t str_to_int(String str);
-FSTRING_INLINE int32_t reverse_seek_slash(String str, int32_t pos);
-FSTRING_INLINE fstr_bool set_last_folder(String *dir, char *folder_name, char slash);
-FSTRING_INLINE fstr_bool set_last_folder(String *dir, String folder_name, char slash);
-FSTRING_INLINE fstr_bool string_set_match(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index);
-
+# define expand_str(s) ((s).str), ((s).size)
#endif
+FSTRING_LINK int32_t str_size(char *str);
+FSTRING_INLINE String make_string_slowly(void *str);
+FSTRING_INLINE String substr_tail(String str, int32_t start);
+FSTRING_INLINE String substr(String str, int32_t start, int32_t size);
+FSTRING_LINK String skip_whitespace(String str);
+FSTRING_LINK String chop_whitespace(String str);
+FSTRING_LINK String skip_chop_whitespace(String str);
+FSTRING_INLINE String tailstr(String str);
+FSTRING_LINK fstr_bool match_cc(char *a, char *b);
+FSTRING_LINK fstr_bool match_sc(String a, char *b);
+FSTRING_INLINE fstr_bool match_cs(char *a, String b);
+FSTRING_LINK fstr_bool match_ss(String a, String b);
+FSTRING_LINK fstr_bool match_part_ccl(char *a, char *b, int32_t *len);
+FSTRING_LINK fstr_bool match_part_scl(String a, char *b, int32_t *len);
+FSTRING_INLINE fstr_bool match_part_cc(char *a, char *b);
+FSTRING_INLINE fstr_bool match_part_sc(String a, char *b);
+FSTRING_LINK fstr_bool match_part_cs(char *a, String b);
+FSTRING_LINK fstr_bool match_part_ss(String a, String b);
+FSTRING_LINK fstr_bool match_insensitive_cc(char *a, char *b);
+FSTRING_LINK fstr_bool match_insensitive_sc(String a, char *b);
+FSTRING_INLINE fstr_bool match_insensitive_cs(char *a, String b);
+FSTRING_LINK fstr_bool match_insensitive_ss(String a, String b);
+FSTRING_LINK fstr_bool match_part_insensitive_ccl(char *a, char *b, int32_t *len);
+FSTRING_LINK fstr_bool match_part_insensitive_scl(String a, char *b, int32_t *len);
+FSTRING_INLINE fstr_bool match_part_insensitive_cc(char *a, char *b);
+FSTRING_INLINE fstr_bool match_part_insensitive_sc(String a, char *b);
+FSTRING_LINK fstr_bool match_part_insensitive_cs(char *a, String b);
+FSTRING_LINK fstr_bool match_part_insensitive_ss(String a, String b);
+FSTRING_LINK int32_t compare_cc(char *a, char *b);
+FSTRING_LINK int32_t compare_sc(String a, char *b);
+FSTRING_INLINE int32_t compare_cs(char *a, String b);
+FSTRING_LINK int32_t compare_ss(String a, String b);
+FSTRING_LINK int32_t find_c_char(char *str, int32_t start, char character);
+FSTRING_LINK int32_t find_s_char(String str, int32_t start, char character);
+FSTRING_LINK int32_t rfind_s_char(String str, int32_t start, char character);
+FSTRING_LINK int32_t find_c_chars(char *str, int32_t start, char *characters);
+FSTRING_LINK int32_t find_s_chars(String str, int32_t start, char *characters);
+FSTRING_LINK int32_t find_substr_c(char *str, int32_t start, String seek);
+FSTRING_LINK int32_t find_substr_s(String str, int32_t start, String seek);
+FSTRING_LINK int32_t rfind_substr_s(String str, int32_t start, String seek);
+FSTRING_LINK int32_t find_substr_insensitive_c(char *str, int32_t start, String seek);
+FSTRING_LINK int32_t find_substr_insensitive_s(String str, int32_t start, String seek);
+FSTRING_INLINE fstr_bool has_substr_c(char *s, String seek);
+FSTRING_INLINE fstr_bool has_substr_s(String s, String seek);
+FSTRING_INLINE fstr_bool has_substr_insensitive_c(char *s, String seek);
+FSTRING_INLINE fstr_bool has_substr_insensitive_s(String s, String seek);
+FSTRING_LINK int32_t copy_fast_unsafe_cc(char *dest, char *src);
+FSTRING_LINK int32_t copy_fast_unsafe_cs(char *dest, String src);
+FSTRING_LINK fstr_bool copy_checked_ss(String *dest, String src);
+FSTRING_LINK fstr_bool copy_partial_sc(String *dest, char *src);
+FSTRING_LINK fstr_bool copy_partial_ss(String *dest, String src);
+FSTRING_INLINE int32_t copy_cc(char *dest, char *src);
+FSTRING_INLINE void copy_ss(String *dest, String src);
+FSTRING_INLINE void copy_sc(String *dest, char *src);
+FSTRING_LINK fstr_bool append_checked_ss(String *dest, String src);
+FSTRING_LINK fstr_bool append_partial_sc(String *dest, char *src);
+FSTRING_LINK fstr_bool append_partial_ss(String *dest, String src);
+FSTRING_LINK fstr_bool append_s_char(String *dest, char c);
+FSTRING_INLINE fstr_bool append_ss(String *dest, String src);
+FSTRING_INLINE fstr_bool append_sc(String *dest, char *src);
+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 *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 *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);
+FSTRING_LINK fstr_bool int_to_str(String *dest, int32_t x);
+FSTRING_LINK fstr_bool append_int_to_str(String *dest, int32_t x);
+FSTRING_LINK int32_t u64_to_str_size(uint64_t x);
+FSTRING_LINK fstr_bool u64_to_str(String *dest, uint64_t x);
+FSTRING_LINK fstr_bool append_u64_to_str(String *dest, uint64_t x);
+FSTRING_LINK int32_t float_to_str_size(float x);
+FSTRING_LINK fstr_bool append_float_to_str(String *dest, float x);
+FSTRING_LINK fstr_bool float_to_str(String *dest, float x);
+FSTRING_LINK int32_t str_is_int_c(char *str);
+FSTRING_LINK fstr_bool str_is_int_s(String str);
+FSTRING_LINK int32_t str_to_int_c(char *str);
+FSTRING_LINK int32_t str_to_int_s(String str);
+FSTRING_LINK int32_t hexchar_to_int(char c);
+FSTRING_LINK char int_to_hexchar(int32_t x);
+FSTRING_LINK uint32_t hexstr_to_int(String str);
+FSTRING_LINK fstr_bool color_to_hexstr(String *s, uint32_t color);
+FSTRING_LINK fstr_bool hexstr_to_color(String s, uint32_t *out);
+FSTRING_LINK int32_t reverse_seek_slash_pos(String str, int32_t pos);
+FSTRING_INLINE int32_t reverse_seek_slash(String str);
+FSTRING_INLINE String front_of_directory(String dir);
+FSTRING_INLINE String path_of_directory(String dir);
+FSTRING_LINK fstr_bool set_last_folder_sc(String *dir, char *folder_name, char slash);
+FSTRING_LINK fstr_bool set_last_folder_ss(String *dir, String folder_name, char slash);
+FSTRING_LINK String file_extension(String str);
+FSTRING_LINK fstr_bool remove_extension(String *str);
+FSTRING_LINK fstr_bool remove_last_folder(String *str);
+FSTRING_LINK fstr_bool string_set_match_table(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index);
+FSTRING_LINK fstr_bool string_set_match(String *str_set, int32_t count, String str, int32_t *match_index);
#endif
#if !defined(FSTRING_C) && !defined(FSTRING_GUARD)
-FSTRING_INLINE String
-make_string(void *str, int32_t size, int32_t mem_size){return(make_string_cap(str,size,mem_size));}
-FSTRING_INLINE String
-substr(String str, int32_t start){return(substr_tail(str,start));}
-FSTRING_INLINE fstr_bool
-match(char *a, char *b){return(match_cc(a,b));}
-FSTRING_INLINE fstr_bool
-match(String a, char *b){return(match_sc(a,b));}
-FSTRING_INLINE fstr_bool
-match(char *a, String b){return(match_cs(a,b));}
-FSTRING_INLINE fstr_bool
-match(String a, String b){return(match_ss(a,b));}
-FSTRING_INLINE fstr_bool
-match_part(char *a, char *b, int32_t *len){return(match_part_ccl(a,b,len));}
-FSTRING_INLINE fstr_bool
-match_part(String a, char *b, int32_t *len){return(match_part_scl(a,b,len));}
-FSTRING_INLINE fstr_bool
-match_part(char *a, char *b){return(match_part_cc(a,b));}
-FSTRING_INLINE fstr_bool
-match_part(String a, char *b){return(match_part_sc(a,b));}
-FSTRING_INLINE fstr_bool
-match_part(char *a, String b){return(match_part_cs(a,b));}
-FSTRING_INLINE fstr_bool
-match_part(String a, String b){return(match_part_ss(a,b));}
-FSTRING_INLINE fstr_bool
-match_insensitive(char *a, char *b){return(match_insensitive_cc(a,b));}
-FSTRING_INLINE fstr_bool
-match_insensitive(String a, char *b){return(match_insensitive_sc(a,b));}
-FSTRING_INLINE fstr_bool
-match_insensitive(char *a, String b){return(match_insensitive_cs(a,b));}
-FSTRING_INLINE fstr_bool
-match_insensitive(String a, String b){return(match_insensitive_ss(a,b));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(char *a, char *b, int32_t *len){return(match_part_insensitive_ccl(a,b,len));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(String a, char *b, int32_t *len){return(match_part_insensitive_scl(a,b,len));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(char *a, char *b){return(match_part_insensitive_cc(a,b));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(String a, char *b){return(match_part_insensitive_sc(a,b));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(char *a, String b){return(match_part_insensitive_cs(a,b));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(String a, String b){return(match_part_insensitive_ss(a,b));}
-FSTRING_INLINE int32_t
-compare(char *a, char *b){return(compare_cc(a,b));}
-FSTRING_INLINE int32_t
-compare(String a, char *b){return(compare_sc(a,b));}
-FSTRING_INLINE int32_t
-compare(char *a, String b){return(compare_cs(a,b));}
-FSTRING_INLINE int32_t
-compare(String a, String b){return(compare_ss(a,b));}
-FSTRING_INLINE int32_t
-find(char *str, int32_t start, char character){return(find_c_char(str,start,character));}
-FSTRING_INLINE int32_t
-find(String str, int32_t start, char character){return(find_s_char(str,start,character));}
-FSTRING_INLINE int32_t
-rfind(String str, int32_t start, char character){return(rfind_s_char(str,start,character));}
-FSTRING_INLINE int32_t
-find(char *str, int32_t start, char *characters){return(find_c_chars(str,start,characters));}
-FSTRING_INLINE int32_t
-find(String str, int32_t start, char *characters){return(find_s_chars(str,start,characters));}
-FSTRING_INLINE int32_t
-find_substr(char *str, int32_t start, String seek){return(find_substr_c(str,start,seek));}
-FSTRING_INLINE int32_t
-find_substr(String str, int32_t start, String seek){return(find_substr_s(str,start,seek));}
-FSTRING_INLINE int32_t
-rfind_substr(String str, int32_t start, String seek){return(rfind_substr_s(str,start,seek));}
-FSTRING_INLINE int32_t
-find_substr_insensitive(char *str, int32_t start, String seek){return(find_substr_insensitive_c(str,start,seek));}
-FSTRING_INLINE int32_t
-find_substr_insensitive(String str, int32_t start, String seek){return(find_substr_insensitive_s(str,start,seek));}
-FSTRING_INLINE fstr_bool
-has_substr(char *s, String seek){return(has_substr_c(s,seek));}
-FSTRING_INLINE fstr_bool
-has_substr(String s, String seek){return(has_substr_s(s,seek));}
-FSTRING_INLINE fstr_bool
-has_substr_insensitive(char *s, String seek){return(has_substr_insensitive_c(s,seek));}
-FSTRING_INLINE fstr_bool
-has_substr_insensitive(String s, String seek){return(has_substr_insensitive_s(s,seek));}
-FSTRING_INLINE int32_t
-copy_fast_unsafe(char *dest, char *src){return(copy_fast_unsafe_cc(dest,src));}
-FSTRING_INLINE int32_t
-copy_fast_unsafe(char *dest, String src){return(copy_fast_unsafe_cs(dest,src));}
-FSTRING_INLINE fstr_bool
-copy_checked(String *dest, String src){return(copy_checked_ss(dest,src));}
-FSTRING_INLINE fstr_bool
-copy_partial(String *dest, char *src){return(copy_partial_sc(dest,src));}
-FSTRING_INLINE fstr_bool
-copy_partial(String *dest, String src){return(copy_partial_ss(dest,src));}
-FSTRING_INLINE int32_t
-copy(char *dest, char *src){return(copy_cc(dest,src));}
-FSTRING_INLINE void
-copy(String *dest, String src){(copy_ss(dest,src));}
-FSTRING_INLINE void
-copy(String *dest, char *src){(copy_sc(dest,src));}
-FSTRING_INLINE fstr_bool
-append_checked(String *dest, String src){return(append_checked_ss(dest,src));}
-FSTRING_INLINE fstr_bool
-append_partial(String *dest, char *src){return(append_partial_sc(dest,src));}
-FSTRING_INLINE fstr_bool
-append_partial(String *dest, String src){return(append_partial_ss(dest,src));}
-FSTRING_INLINE fstr_bool
-append(String *dest, char c){return(append_s_char(dest,c));}
-FSTRING_INLINE fstr_bool
-append(String *dest, String src){return(append_ss(dest,src));}
-FSTRING_INLINE fstr_bool
-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 *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 *dst, String src){(to_upper_ss(dst,src));}
-FSTRING_INLINE void
-to_upper(String *str){(to_upper_s(str));}
-FSTRING_INLINE void
-to_camel(char *src, char *dst){(to_camel_cc(src,dst));}
-FSTRING_INLINE int32_t
-str_is_int(char *str){return(str_is_int_c(str));}
-FSTRING_INLINE fstr_bool
-str_is_int(String str){return(str_is_int_s(str));}
-FSTRING_INLINE int32_t
-str_to_int(char *str){return(str_to_int_c(str));}
-FSTRING_INLINE int32_t
-str_to_int(String str){return(str_to_int_s(str));}
-FSTRING_INLINE int32_t
-reverse_seek_slash(String str, int32_t pos){return(reverse_seek_slash_pos(str,pos));}
-FSTRING_INLINE fstr_bool
-set_last_folder(String *dir, char *folder_name, char slash){return(set_last_folder_sc(dir,folder_name,slash));}
-FSTRING_INLINE fstr_bool
-set_last_folder(String *dir, String folder_name, char slash){return(set_last_folder_ss(dir,folder_name,slash));}
-FSTRING_INLINE fstr_bool
-string_set_match(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index){return(string_set_match_table(str_set,item_size,count,str,match_index));}
+FSTRING_INLINE String make_string(void *str, int32_t size, int32_t mem_size){return(make_string_cap(str,size,mem_size));}
+FSTRING_INLINE String substr(String str, int32_t start){return(substr_tail(str,start));}
+FSTRING_INLINE fstr_bool match(char *a, char *b){return(match_cc(a,b));}
+FSTRING_INLINE fstr_bool match(String a, char *b){return(match_sc(a,b));}
+FSTRING_INLINE fstr_bool match(char *a, String b){return(match_cs(a,b));}
+FSTRING_INLINE fstr_bool match(String a, String b){return(match_ss(a,b));}
+FSTRING_INLINE fstr_bool match_part(char *a, char *b, int32_t *len){return(match_part_ccl(a,b,len));}
+FSTRING_INLINE fstr_bool match_part(String a, char *b, int32_t *len){return(match_part_scl(a,b,len));}
+FSTRING_INLINE fstr_bool match_part(char *a, char *b){return(match_part_cc(a,b));}
+FSTRING_INLINE fstr_bool match_part(String a, char *b){return(match_part_sc(a,b));}
+FSTRING_INLINE fstr_bool match_part(char *a, String b){return(match_part_cs(a,b));}
+FSTRING_INLINE fstr_bool match_part(String a, String b){return(match_part_ss(a,b));}
+FSTRING_INLINE fstr_bool match_insensitive(char *a, char *b){return(match_insensitive_cc(a,b));}
+FSTRING_INLINE fstr_bool match_insensitive(String a, char *b){return(match_insensitive_sc(a,b));}
+FSTRING_INLINE fstr_bool match_insensitive(char *a, String b){return(match_insensitive_cs(a,b));}
+FSTRING_INLINE fstr_bool match_insensitive(String a, String b){return(match_insensitive_ss(a,b));}
+FSTRING_INLINE fstr_bool match_part_insensitive(char *a, char *b, int32_t *len){return(match_part_insensitive_ccl(a,b,len));}
+FSTRING_INLINE fstr_bool match_part_insensitive(String a, char *b, int32_t *len){return(match_part_insensitive_scl(a,b,len));}
+FSTRING_INLINE fstr_bool match_part_insensitive(char *a, char *b){return(match_part_insensitive_cc(a,b));}
+FSTRING_INLINE fstr_bool match_part_insensitive(String a, char *b){return(match_part_insensitive_sc(a,b));}
+FSTRING_INLINE fstr_bool match_part_insensitive(char *a, String b){return(match_part_insensitive_cs(a,b));}
+FSTRING_INLINE fstr_bool match_part_insensitive(String a, String b){return(match_part_insensitive_ss(a,b));}
+FSTRING_INLINE int32_t compare(char *a, char *b){return(compare_cc(a,b));}
+FSTRING_INLINE int32_t compare(String a, char *b){return(compare_sc(a,b));}
+FSTRING_INLINE int32_t compare(char *a, String b){return(compare_cs(a,b));}
+FSTRING_INLINE int32_t compare(String a, String b){return(compare_ss(a,b));}
+FSTRING_INLINE int32_t find(char *str, int32_t start, char character){return(find_c_char(str,start,character));}
+FSTRING_INLINE int32_t find(String str, int32_t start, char character){return(find_s_char(str,start,character));}
+FSTRING_INLINE int32_t rfind(String str, int32_t start, char character){return(rfind_s_char(str,start,character));}
+FSTRING_INLINE int32_t find(char *str, int32_t start, char *characters){return(find_c_chars(str,start,characters));}
+FSTRING_INLINE int32_t find(String str, int32_t start, char *characters){return(find_s_chars(str,start,characters));}
+FSTRING_INLINE int32_t find_substr(char *str, int32_t start, String seek){return(find_substr_c(str,start,seek));}
+FSTRING_INLINE int32_t find_substr(String str, int32_t start, String seek){return(find_substr_s(str,start,seek));}
+FSTRING_INLINE int32_t rfind_substr(String str, int32_t start, String seek){return(rfind_substr_s(str,start,seek));}
+FSTRING_INLINE int32_t find_substr_insensitive(char *str, int32_t start, String seek){return(find_substr_insensitive_c(str,start,seek));}
+FSTRING_INLINE int32_t find_substr_insensitive(String str, int32_t start, String seek){return(find_substr_insensitive_s(str,start,seek));}
+FSTRING_INLINE fstr_bool has_substr(char *s, String seek){return(has_substr_c(s,seek));}
+FSTRING_INLINE fstr_bool has_substr(String s, String seek){return(has_substr_s(s,seek));}
+FSTRING_INLINE fstr_bool has_substr_insensitive(char *s, String seek){return(has_substr_insensitive_c(s,seek));}
+FSTRING_INLINE fstr_bool has_substr_insensitive(String s, String seek){return(has_substr_insensitive_s(s,seek));}
+FSTRING_INLINE int32_t copy_fast_unsafe(char *dest, char *src){return(copy_fast_unsafe_cc(dest,src));}
+FSTRING_INLINE int32_t copy_fast_unsafe(char *dest, String src){return(copy_fast_unsafe_cs(dest,src));}
+FSTRING_INLINE fstr_bool copy_checked(String *dest, String src){return(copy_checked_ss(dest,src));}
+FSTRING_INLINE fstr_bool copy_partial(String *dest, char *src){return(copy_partial_sc(dest,src));}
+FSTRING_INLINE fstr_bool copy_partial(String *dest, String src){return(copy_partial_ss(dest,src));}
+FSTRING_INLINE int32_t copy(char *dest, char *src){return(copy_cc(dest,src));}
+FSTRING_INLINE void copy(String *dest, String src){(copy_ss(dest,src));}
+FSTRING_INLINE void copy(String *dest, char *src){(copy_sc(dest,src));}
+FSTRING_INLINE fstr_bool append_checked(String *dest, String src){return(append_checked_ss(dest,src));}
+FSTRING_INLINE fstr_bool append_partial(String *dest, char *src){return(append_partial_sc(dest,src));}
+FSTRING_INLINE fstr_bool append_partial(String *dest, String src){return(append_partial_ss(dest,src));}
+FSTRING_INLINE fstr_bool append(String *dest, char c){return(append_s_char(dest,c));}
+FSTRING_INLINE fstr_bool append(String *dest, String src){return(append_ss(dest,src));}
+FSTRING_INLINE fstr_bool 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 *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 *dst, String src){(to_upper_ss(dst,src));}
+FSTRING_INLINE void to_upper(String *str){(to_upper_s(str));}
+FSTRING_INLINE void to_camel(char *src, char *dst){(to_camel_cc(src,dst));}
+FSTRING_INLINE int32_t str_is_int(char *str){return(str_is_int_c(str));}
+FSTRING_INLINE fstr_bool str_is_int(String str){return(str_is_int_s(str));}
+FSTRING_INLINE int32_t str_to_int(char *str){return(str_to_int_c(str));}
+FSTRING_INLINE int32_t str_to_int(String str){return(str_to_int_s(str));}
+FSTRING_INLINE int32_t reverse_seek_slash(String str, int32_t pos){return(reverse_seek_slash_pos(str,pos));}
+FSTRING_INLINE fstr_bool set_last_folder(String *dir, char *folder_name, char slash){return(set_last_folder_sc(dir,folder_name,slash));}
+FSTRING_INLINE fstr_bool set_last_folder(String *dir, String folder_name, char slash){return(set_last_folder_ss(dir,folder_name,slash));}
+FSTRING_INLINE fstr_bool string_set_match(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index){return(string_set_match_table(str_set,item_size,count,str,match_index));}
#endif
diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp
index e05975b6..27f27655 100644
--- a/4ed_metagen.cpp
+++ b/4ed_metagen.cpp
@@ -406,7 +406,7 @@ typedef struct Item_Node{
typedef struct Item_Set{
Item_Node *items;
int32_t count;
-} Item_Set;
+} Item_Set;
typedef struct Parse{
String code;
@@ -722,7 +722,7 @@ doc_parse_last_parameter(String source, int32_t *pos){
}
*pos = p;
- return(result);
+ return(result);
}
static void
@@ -1587,7 +1587,7 @@ compile_meta_unit(Partition *part, char **files, int32_t file_count,
++index;
}
else{
- fprintf(stderr, "warning : invalid function signature\n");
+ fprintf(stderr, "warning: invalid function signature\n");
}
}break;
@@ -1877,28 +1877,26 @@ print_str(FILE *file, String str){
}
static void
-print_function_body_code(FILE *file, int32_t *index, Cpp_Token **token_ptr, int32_t count, String *code,
- int32_t start){
- int32_t i = *index;
- Cpp_Token *token = *token_ptr;
-
- String pstr = {0};
+print_function_body_code(String *out, Parse_Context *context, int32_t start){
+ String pstr = {0}, lexeme = {0};
+ Cpp_Token *token = 0;
+ int32_t do_print = 0;
int32_t nest_level = 0;
int32_t finish = false;
int32_t do_whitespace_print = false;
- for (; i < count; ++i, ++token){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (do_whitespace_print){
- pstr = str_start_end(code->str, start, token->start);
- print_str(file, pstr);
+ pstr = str_start_end(context->data, start, token->start);
+ append_ss(out, pstr);
}
else{
do_whitespace_print = true;
}
- int32_t do_print = true;
+ do_print = true;
if (token->type == CPP_TOKEN_COMMENT){
- String lexeme = make_string(code->str + token->start, token->size);
+ lexeme = get_lexeme(*token, context->data);
if (check_and_fix_docs(&lexeme)){
do_print = false;
}
@@ -1913,28 +1911,23 @@ print_function_body_code(FILE *file, int32_t *index, Cpp_Token **token_ptr, int3
}
}
- if (i < count){
- if (do_print){
- pstr = make_string(code->str + token->start, token->size);
- print_str(file, pstr);
- }
-
- start = token->start + token->size;
+ if (do_print){
+ pstr = get_lexeme(*token, context->data);
+ append_ss(out, pstr);
}
+ start = token->start + token->size;
+
if (finish){
break;
}
}
-
- *index = i;
- *token_ptr = token;
}
static void
print_function_docs(FILE *file, Partition *part, String name, String doc_string){
if (doc_string.size == 0){
- fprintf(file, "No documentation generated for this function, assume it is non-public.\n");
+ fprintf(file, "No documentation generated for this function.\n");
fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
}
@@ -2264,8 +2257,6 @@ generate_custom_headers(){
append_s_char(&out, '\n');
}
- 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);
@@ -2281,8 +2272,6 @@ generate_custom_headers(){
}
if (begin_file_out(&context, API_H, &out)){
- file = context.file;
-
for (int32_t i = 0; i < unit_custom.set.count; ++i){
append_sc(&out, "#define ");
append_ss(&out, func_4ed_names.names[i].macro);
@@ -2333,345 +2322,282 @@ generate_custom_headers(){
end_file_out(context);
}
+ else{
+ // TODO(allen): warning
+ }
- // NOTE(allen): Documentation
- {
+ // NOTE(allen): String Library
+ if (begin_file_out(&context, STRING_H, &out)){
+ file = context.file;
- //
- // Output 4coder_string.h
- //
+ Cpp_Token *token = 0;
+ int32_t start = 0;
- file = fopen(STRING_H, "wb");
+ Parse parse = string_unit.parse[0];
+ Parse_Context pcontext = setup_parse_context(parse);
- {
- String *code = &string_unit.parse[0].code;
- Cpp_Token_Stack *token_stack = &string_unit.parse[0].tokens;
-
- int32_t start = 0;
-
- int32_t count = token_stack->count;
- Cpp_Token *tokens = token_stack->tokens;
- Cpp_Token *token = tokens;
- int32_t i = 0;
-
- for (i = 0; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_IDENTIFIER &&
- !(token->flags & CPP_TFLAG_PP_BODY)){
- String lexeme = make_string(code->str + token->start, token->size);
- if (match_ss(lexeme, make_lit_string("FSTRING_BEGIN"))){
- start = token->start + token->size;
- break;
- }
- }
- }
-
- String pstr = {0};
- int32_t do_whitespace_print = true;
-
- for(++i, ++token; i < count; ++i, ++token){
- if (do_whitespace_print){
- pstr = str_start_end(code->str, start, token->start);
- print_str(file, pstr);
- }
- else{
- do_whitespace_print = true;
- }
-
- String lexeme = get_lexeme(*token, code->str);
-
- int32_t do_print = true;
- if (match_ss(lexeme, make_lit_string("FSTRING_DECLS"))){
- fprintf(file, "#if !defined(FCODER_STRING_H)\n#define FCODER_STRING_H\n\n");
-
- do_print = false;
-
-#define RETURN_PADDING 16
-#define SIG_PADDING 30
-
- for (int32_t j = 0; j < string_unit.set.count; ++j){
- char line_space[2048];
- String line = make_fixed_width_string(line_space);
-
- Item_Node *item = string_unit.set.items + j;
-
- if (item->t != Item_Macro){
- String marker = item->marker;
- String ret = item->ret;
- String name = item->name;
- String args = item->args;
-
- append_ss(&line, marker);
- append_padding(&line, ' ', RETURN_PADDING);
- append_ss(&line, ret);
- append_padding(&line, ' ', SIG_PADDING);
- append_ss(&line, name);
- append_ss(&line, args);
- terminate_with_null(&line);
-
- fprintf(file, "%s;\n", line.str);
- }
- else{
- String name = item->name;
- String args = item->args;
- String body = item->body;
-
- append_ss(&line, make_lit_string("#ifndef "));
- append_padding(&line, ' ', 10);
- append_ss(&line, name);
- terminate_with_null(&line);
- fprintf(file, "%s\n", line.str);
- line.size = 0;
-
- append_ss(&line, make_lit_string("# define "));
- append_padding(&line, ' ', 10);
- append_ss(&line, name);
- append_ss(&line, args);
- append_s_char(&line, ' ');
- append_ss(&line, body);
- terminate_with_null(&line);
- fprintf(file, "%s\n", line.str);
- line.size = 0;
-
- append_ss(&line, make_lit_string("#endif"));
- terminate_with_null(&line);
- fprintf(file, "%s\n", line.str);
- }
- }
-
- {
- fprintf(file, "\n#if !defined(FSTRING_C)\n\n"
- "// NOTE(allen): This section is here to enable nicer names\n"
- "// for C++ users who can have overloaded functions. None of\n"
- "// these functions add new features.\n");
-
- for (int32_t j = 0; j < string_unit.set.count; ++j){
- char line_space[2048];
- String line = make_fixed_width_string(line_space);
-
- Item_Node *item = &string_unit.set.items[j];
-
- if (item->t != Item_Macro){
- String cpp_name = item->cpp_name;
- if (cpp_name.str != 0){
- String ret = item->ret;
- String args = item->args;
-
- append_ss(&line, make_lit_string("FSTRING_INLINE"));
- append_padding(&line, ' ', RETURN_PADDING);
- append_ss(&line, ret);
- append_padding(&line, ' ', SIG_PADDING);
- append_ss(&line, cpp_name);
- append_ss(&line, args);
- terminate_with_null(&line);
-
- fprintf(file, "%s;\n", line.str);
- }
- }
- }
-
- fprintf(file, "\n#endif\n");
- }
-
- fprintf(file, "\n#endif\n");
-
- {
- fprintf(file, "\n#if !defined(FSTRING_C) && !defined(FSTRING_GUARD)\n\n");
-
- for (int32_t j = 0; j < string_unit.set.count; ++j){
- char line_space[2048];
- String line = make_fixed_width_string(line_space);
-
- Item_Node *item = &string_unit.set.items[j];
-
- if (item->t != Item_Macro){
- String cpp_name = item->cpp_name;
- if (cpp_name.str != 0){
- String name = item->name;
- String ret = item->ret;
- String args = item->args;
- Argument_Breakdown breakdown = item->breakdown;
-
- append_ss(&line, make_lit_string("FSTRING_INLINE"));
- append_s_char(&line, ' ');
- append_ss(&line, ret);
- append_s_char(&line, '\n');
- append_ss(&line, cpp_name);
- append_ss(&line, args);
- if (match_ss(ret, make_lit_string("void"))){
- append_ss(&line, make_lit_string("{("));
- }
- else{
- append_ss(&line, make_lit_string("{return("));
- }
- append_ss(&line, name);
- append_s_char(&line, '(');
-
- if (breakdown.count > 0){
- for (int32_t i = 0; i < breakdown.count; ++i){
- if (i != 0){
- append_s_char(&line, ',');
- }
- append_ss(&line, breakdown.args[i].param_name);
- }
- }
- else{
- append_ss(&line, make_lit_string("void"));
- }
-
- append_ss(&line, make_lit_string("));}"));
- terminate_with_null(&line);
-
- fprintf(file, "%s\n", line.str);
- }
- }
- }
-
- fprintf(file, "\n#endif\n");
- }
- }
- else if (match_ss(lexeme, make_lit_string("DOC_EXPORT"))){
- ++i, ++token;
- if (i < count && token->type == CPP_TOKEN_COMMENT){
- ++i, ++token;
- if (i < count && token->type == CPP_PP_DEFINE){
- ++i, ++token;
- for (; i < count; ++i, ++token){
- if (!(token->flags & CPP_TFLAG_PP_BODY)){
- break;
- }
- }
- --i, --token;
- do_print = false;
- do_whitespace_print = false;
- }
- }
- }
- else if (match_ss(lexeme, make_lit_string("FSTRING_INLINE"))){
- if (!(token->flags & CPP_TFLAG_PP_BODY)){
- fprintf(file, "#if !defined(FSTRING_GUARD)\n");
-
- print_function_body_code(file, &i, &token, count, code, start);
-
- fprintf(file, "\n#endif");
- do_print = false;
- }
- }
- else if (match_ss(lexeme, make_lit_string("FSTRING_LINK"))){
- if (!(token->flags & CPP_TFLAG_PP_BODY)){
- fprintf(file, "#if defined(FSTRING_IMPLEMENTATION)\n");
-
- print_function_body_code(file, &i, &token, count, code, start);
-
- fprintf(file, "\n#endif");
- do_print = false;
- }
- }
- else if (match_ss(lexeme, make_lit_string("CPP_NAME"))){
-
- Cpp_Token *token_start = token;
- int32_t i_start = i;
- int32_t has_cpp_name = false;
-
- ++i, ++token;
- if (token->type == CPP_TOKEN_PARENTHESE_OPEN){
- ++i, ++token;
- if (token->type == CPP_TOKEN_IDENTIFIER){
- ++i, ++token;
- if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
- has_cpp_name = true;
- }
- }
- }
-
- if (!has_cpp_name){
- i = i_start;
- token = token_start;
- }
-
- do_print = false;
- }
- else if (token->type == CPP_TOKEN_COMMENT){
- lexeme = make_string(code->str + token->start, token->size);
- if (check_and_fix_docs(&lexeme)){
- do_print = false;
- }
- }
-
- if (i < count){
- if (do_print){
- pstr = make_string(code->str + token->start, token->size);
- print_str(file, pstr);
- }
-
+ for (; (token = get_token(&pcontext)) != 0; get_next_token(&pcontext)){
+ if (!(token->flags & CPP_TFLAG_PP_BODY) &&
+ token->type == CPP_TOKEN_IDENTIFIER){
+ String lexeme = get_lexeme(*token, pcontext.data);
+ if (match_ss(lexeme, make_lit_string("FSTRING_BEGIN"))){
start = token->start + token->size;
+ break;
}
}
- pstr = str_start_end(code->str, start, code->size);
- print_str(file, pstr);
}
- fclose(file);
+ String pstr = {0};
+ int32_t do_whitespace_print = true;
- //
- // Output Docs
- //
+ for(;(token = get_next_token(&pcontext)) != 0;){
+ if (do_whitespace_print){
+ pstr = str_start_end(pcontext.data, start, token->start);
+ append_ss(&out, pstr);
+ }
+ else{
+ do_whitespace_print = true;
+ }
+
+ String lexeme = get_lexeme(*token, pcontext.data);
+
+ int32_t do_print = true;
+ if (match_ss(lexeme, make_lit_string("FSTRING_DECLS"))){
+ append_sc(&out, "#if !defined(FCODER_STRING_H)\n#define FCODER_STRING_H\n\n");
+ do_print = false;
+
+ static int32_t RETURN_PADDING = 16;
+ static int32_t SIG_PADDING = 27;
+
+ for (int32_t j = 0; j < string_unit.set.count; ++j){
+ char line_[2048];
+ String line = make_fixed_width_string(line_);
+ Item_Node *item = string_unit.set.items + j;
+
+ if (item->t == Item_Function){
+ append_ss (&line, item->marker);
+ append_padding (&line, ' ', RETURN_PADDING);
+ append_ss (&line, item->ret);
+ append_padding (&line, ' ', SIG_PADDING);
+ append_ss (&line, item->name);
+ append_ss (&line, item->args);
+ append_sc (&line, ";\n");
+ }
+ else if (item->t == Item_Macro){
+ append_ss (&line, make_lit_string("#ifndef "));
+ append_padding (&line, ' ', 10);
+ append_ss (&line, item->name);
+ append_s_char (&line, '\n');
+
+ append_ss (&line, make_lit_string("# define "));
+ append_padding (&line, ' ', 10);
+ append_ss (&line, item->name);
+ append_ss (&line, item->args);
+ append_s_char (&line, ' ');
+ append_ss (&line, item->body);
+ append_s_char (&line, '\n');
+
+ append_ss (&line, make_lit_string("#endif"));
+ append_s_char (&line, '\n');
+ }
+ else{
+ InvalidPath;
+ }
+
+ append_ss(&out, line);
+ }
+
+ append_sc(&out, "\n#endif\n");
+
+ // NOTE(allen): C++ overload definitions
+ append_sc(&out, "\n#if !defined(FSTRING_C) && !defined(FSTRING_GUARD)\n\n");
+
+ for (int32_t j = 0; j < string_unit.set.count; ++j){
+ char line_space[2048];
+ String line = make_fixed_width_string(line_space);
+
+ Item_Node *item = &string_unit.set.items[j];
+
+ if (item->t == Item_Function){
+ String cpp_name = item->cpp_name;
+ if (cpp_name.str != 0){
+ Argument_Breakdown breakdown = item->breakdown;
+
+ append_ss (&line, make_lit_string("FSTRING_INLINE"));
+ append_padding(&line, ' ', RETURN_PADDING);
+ append_ss (&line, item->ret);
+ append_padding(&line, ' ', SIG_PADDING);
+ append_ss (&line, cpp_name);
+ append_ss (&line, item->args);
+ if (match_ss(item->ret, make_lit_string("void"))){
+ append_ss(&line, make_lit_string("{("));//}
+ }
+ else{
+ append_ss(&line, make_lit_string("{return("));//}
+ }
+ append_ss (&line, item->name);
+ append_s_char(&line, '(');
+
+ if (breakdown.count > 0){
+ for (int32_t i = 0; i < breakdown.count; ++i){
+ if (i != 0){
+ append_s_char(&line, ',');
+ }
+ append_ss(&line, breakdown.args[i].param_name);
+ }
+ }
+ else{
+ append_ss(&line, make_lit_string("void"));
+ }
+
+ //{
+ append_ss(&line, make_lit_string("));}\n"));
+
+ append_ss(&out, line);
+ }
+ }
+ }
+
+ append_sc(&out, "\n#endif\n");
+ }
+
+ else if (match_ss(lexeme, make_lit_string("DOC_EXPORT"))){
+ token = get_next_token(&pcontext);
+ if (token && token->type == CPP_TOKEN_COMMENT){
+ token = get_next_token(&pcontext);
+ if (token && token->type == CPP_PP_DEFINE){
+ for (;(token = get_next_token(&pcontext)) != 0;){
+ if (!(token->flags & CPP_TFLAG_PP_BODY)){
+ break;
+ }
+ }
+ if (token != 0){
+ get_prev_token(&pcontext);
+ }
+ do_print = false;
+ do_whitespace_print = false;
+ }
+ }
+ }
+
+ else if (match_ss(lexeme, make_lit_string("FSTRING_INLINE")) ||
+ match_ss(lexeme, make_lit_string("FSTRING_LINK"))){
+ if (!(token->flags & CPP_TFLAG_PP_BODY)){
+ if (match_ss(lexeme, make_lit_string("FSTRING_INLINE"))){
+ append_sc(&out, "#if !defined(FSTRING_GUARD)\n");
+ }
+ else{
+ append_sc(&out, "#if defined(FSTRING_IMPLEMENTATION)\n");
+ }
+ print_function_body_code(&out, &pcontext, start);
+ append_sc(&out, "\n#endif");
+ do_print = false;
+ }
+ }
+
+ else if (match_ss(lexeme, make_lit_string("CPP_NAME"))){
+ Cpp_Token *token_start = token;
+ int32_t has_cpp_name = false;
+
+ token = get_next_token(&pcontext);
+ if (token && token->type == CPP_TOKEN_PARENTHESE_OPEN){
+ token = get_next_token(&pcontext);
+ if (token && token->type == CPP_TOKEN_IDENTIFIER){
+ token = get_next_token(&pcontext);
+ if (token && token->type == CPP_TOKEN_PARENTHESE_CLOSE){
+ has_cpp_name = true;
+ do_print = false;
+ }
+ }
+ }
+
+ if (!has_cpp_name){
+ token = set_token(&pcontext, token_start);
+ }
+ }
+
+ else if (token->type == CPP_TOKEN_COMMENT){
+ if (check_and_fix_docs(&lexeme)){
+ do_print = false;
+ }
+ }
+
+ if ((token = get_token(&pcontext)) != 0){
+ if (do_print){
+ pstr = get_lexeme(*token, pcontext.data);
+ append_ss(&out, pstr);
+ }
+ start = token->start + token->size;
+ }
+ }
+ pstr = str_start_end(pcontext.data, start, parse.code.size);
+ append_ss(&out, pstr);
- file = fopen(API_DOC, "wb");
+ end_file_out(context);
+ }
+ else{
+ // TODO(allen): warning
+ }
+
+
+ // Output Docs
+
+ if (begin_file_out(&context, API_DOC, &out)){
- fprintf(file,
- "\n"
- "\n"
- "
4coder API Docs\n"
- "\n"
+ ""
"\n"
- "\n"
+ ""
"
\n"
- "
4coder API
\n"
+ "width: 800px; text-align: justify; line-height: 1.25;'>"
+ "
4coder API
"
);
struct Section{
@@ -2686,149 +2612,136 @@ generate_custom_headers(){
{"string_library", "String Library"}
};
- fprintf(file,
- "
Table of Contents
\n"
- "
\n");
+ append_sc(&out,
+ "Table of Contents
""");
+
+ dump_file_out(context);
int32_t section_count = ArrayCount(sections);
for (int32_t i = 0; i < section_count; ++i){
- fprintf(file,
- "- §%d %s
",
- sections[i].id_string,
- i+1,
- sections[i].display_string);
+ append_sc (&out, "- §");
+ append_int_to_str (&out, i+1);
+ append_s_char (&out, ' ');
+ append_sc (&out, sections[i].display_string);
+ append_sc (&out, "
");
}
- fprintf(file,
- "
\n"
- );
+ append_sc(&out, "
");
#define MAJOR_SECTION "1"
- fprintf(file,
- "
§"MAJOR_SECTION" %s
\n"
- "
\n"
-
- "
\n"
- "This is the documentation for " VERSION " The documentation is still under "
- "construction so some of the links are linking to sections that have not "
- "been written yet. What is here should be correct and I suspect useful "
- "even without some of the other sections. "
- "
\n"
-
- "
\n"
- "If you have questions or discover errors please contact "
- "editor@4coder.net or "
- "to get help from community members you can post on the "
- "4coder forums hosted on handmade.network at "
- "4coder.handmade.network"
- "
\n"
-
- "
\n",
- sections[0].id_string,
- sections[0].display_string
- );
+ append_sc(&out, "\n
§"MAJOR_SECTION" ");
+ append_sc(&out, sections[0].display_string);
+ append_sc(&out,
+ "
"
+ "
"
+ "
This is the documentation for " VERSION " The documentation is still "
+ "under construction so some of the links are linking to sections that "
+ "have not been written yet. What is here should be correct and I suspect "
+ "useful even without some of the other sections.
"
+ "
If you have questions or discover errors please contact "
+ "editor@4coder.net or "
+ "to get help from community members you can post on the "
+ "4coder forums hosted on handmade.network at "
+ "4coder.handmade.network
"
+ "
");
#undef MAJOR_SECTION
#define MAJOR_SECTION "2"
// TODO(allen): Write the 4coder system descriptions.
- fprintf(file,
- "
§"MAJOR_SECTION" %s
\n",
- sections[1].id_string,
- sections[1].display_string);
+ append_sc(&out, "\n
§"MAJOR_SECTION" ");
+ append_sc(&out, sections[1].display_string);
+ append_sc(&out, "
");
- {
- fprintf(file,
- "
\n"
- "Coming Soon"
- "\n");
- }
+ append_sc(&out, "
Coming Soon");
#undef MAJOR_SECTION
#define MAJOR_SECTION "3"
- fprintf(file,
- "
§"MAJOR_SECTION" %s
\n",
- sections[2].id_string,
- sections[2].display_string);
- {
+ append_sc(&out, "\n
§"MAJOR_SECTION" ");
+ append_sc(&out, sections[2].display_string);
+ append_sc(&out, "
");
+
+
#undef SECTION
#define SECTION MAJOR_SECTION".1"
-
- fprintf(file,
- "
§"SECTION" Function List
\n"
- "
\n");
-
- for (int32_t i = 0; i < unit_custom.set.count; ++i){
- String name = func_4ed_names.names[i].public_name;
- fprintf(file,
- "- "
- "%.*s"
- "
\n",
- name.size, name.str,
- name.size, name.str
- );
- }
- fprintf(file, "
\n");
-
+
+ append_sc(&out, "
§"SECTION" Function List
");
+
#undef SECTION
#define SECTION MAJOR_SECTION".2"
-
- fprintf(file,
- "
§"SECTION" Type List
\n"
- "
\n"
- );
-
- for (int32_t i = 0; i < unit.set.count; ++i){
- String name = unit.set.items[i].name;
- fprintf(file,
- "- "
- "%.*s"
- "
\n",
- name.size, name.str,
- name.size, name.str
- );
- }
-
- fprintf(file, "
\n");
-
+
+ append_sc(&out, "
§"SECTION" Type List
");
+
#undef SECTION
#define SECTION MAJOR_SECTION".3"
+
+ append_sc(&out, "
§"SECTION" Function Descriptions
\n");
+ for (int32_t i = 0; i < unit_custom.set.count; ++i){
+ String name = func_4ed_names.names[i].public_name;
- fprintf(file, "
§"SECTION" Function Descriptions
\n");
- for (int32_t i = 0; i < unit_custom.set.count; ++i){
- String name = func_4ed_names.names[i].public_name;
-
- fprintf(file,
- "
\n"
- "
§"SECTION".%d: %.*s
\n"
- "
",
- name.size, name.str, i+1,
- name.size, name.str
- );
- print_function_html(file, unit_custom.set.items[i], name, "app->");
- fprintf(file, "
\n");
-
- String doc_string = unit_custom.set.items[i].doc_string;
- print_function_docs(file, part, name, doc_string);
-
- fprintf(file, "
\n");
- }
+ append_sc (&out, "
§"SECTION".");
+ append_int_to_str(&out, i+1);
+ append_sc (&out, ": ");
+ append_ss (&out, name);
+ append_sc (&out, "
");
+ dump_file_out(context);
+
+ // TODO(allen): Continue converting this to the string system.
+ print_function_html(file, unit_custom.set.items[i], name, "app->");
+ fprintf(file, "
\n");
+
+ String doc_string = unit_custom.set.items[i].doc_string;
+ print_function_docs(file, part, name, doc_string);
+
+ fprintf(file, "
\n");
+ }
+
#undef SECTION
#define SECTION MAJOR_SECTION".4"
-
- fprintf(file, "
§"SECTION" Type Descriptions
\n");
- int32_t I = 1;
- for (int32_t i = 0; i < unit.set.count; ++i, ++I){
- print_item(part, file, unit.set.items + i, SECTION, I);
- }
+
+ fprintf(file, "
§"SECTION" Type Descriptions
\n");
+ int32_t I = 1;
+ for (int32_t i = 0; i < unit.set.count; ++i, ++I){
+ print_item(part, file, unit.set.items + i, SECTION, I);
}
+
#undef MAJOR_SECTION
#define MAJOR_SECTION "4"
- fprintf(file,
+ fprintf(file,
"
§"MAJOR_SECTION" %s
\n",
sections[3].id_string,
sections[3].display_string);
@@ -2936,7 +2849,10 @@ generate_custom_headers(){
"\n"
);
- fclose(file);
+ end_file_out(context);
+ }
+ else{
+ // TODO(allen): warning
}
}