changed function_set in metagen so that it is not structure of arrays any more; introduced item type

master
Allen Webster 2016-09-02 15:39:38 -04:00
parent 2b36821c1e
commit 9a5d57f961
8 changed files with 491 additions and 388 deletions

View File

@ -1176,6 +1176,7 @@ Coming Soon</i><div>
<li><a href='#to_upper_cc_str_doc'>to_upper_cc</a></li>
<li><a href='#to_upper_ss_str_doc'>to_upper_ss</a></li>
<li><a href='#to_upper_s_str_doc'>to_upper_s</a></li>
<li><a href='#to_camel_cc_str_doc'>to_camel_cc</a></li>
<li><a href='#int_to_str_size_str_doc'>int_to_str_size</a></li>
<li><a href='#int_to_str_str_doc'>int_to_str</a></li>
<li><a href='#append_int_to_str_str_doc'>append_int_to_str</a></li>
@ -1967,8 +1968,8 @@ void to_upper_cc(
</div>
<div>
<div style='font-weight: 600;'>dst</div>
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The destination buffer to receive the converted string. This must be large
enough to contain all of src and a null terminator.</div></div>
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The destination buffer to receive the converted string.
This must be large enough to contain all of src and a null terminator.</div></div>
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>Rewrites the string in src into dst. src and dst should not overlap with the exception
that src and dst may be exactly equal in order to convert the string in place.</div></div><hr>
@ -1979,7 +1980,7 @@ void to_upper_ss(
</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 uppercase.</div></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>
@ -1998,153 +1999,170 @@ void to_upper_s(
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The string to be converted to all 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;'>This version of to_upper converts str to uppercase in place.</div></div><hr>
<div id='int_to_str_size_str_doc'><h4>&sect;4.3.86: int_to_str_size</h4>
<div id='to_camel_cc_str_doc'><h4>&sect;4.3.86: to_camel_cc</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>
void to_camel_cc(
<div style='margin-left: 4mm;'>char *src,<br>char *dst<br></div>)
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Parameters</i></b></div><div>
<div style='font-weight: 600;'>src</div>
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The source string to convert to camel case.</div></div>
</div>
<div>
<div style='font-weight: 600;'>dst</div>
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The destination buffer to receive the converted string.
This must be large enough to contain all of src and a null terminator.</div></div>
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>Rewrites the string in src into dst. src and dst should not overlap
with the exception that src and dst may be exactly equal in order to
convert the string in place.</div></div><hr>
<div id='int_to_str_size_str_doc'><h4>&sect;4.3.87: int_to_str_size</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;'>
int32_t int_to_str_size(
<div style='margin-left: 4mm;'>int32_t x<br></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;'>This call returns the number of bytes required to represent x as a string.</div></div><hr>
<div id='int_to_str_str_doc'><h4>&sect;4.3.87: int_to_str</h4>
<div id='int_to_str_str_doc'><h4>&sect;4.3.88: int_to_str</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;'>
fstr_bool int_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>int32_t x<br></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;'>This call writes a string representation of x into dest. If there is enough
space in dest this call returns non-zero.</div></div><hr>
<div id='append_int_to_str_str_doc'><h4>&sect;4.3.88: append_int_to_str</h4>
<div id='append_int_to_str_str_doc'><h4>&sect;4.3.89: append_int_to_str</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;'>
fstr_bool append_int_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>int32_t x<br></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;'>This call appends a string representation of x onto dest. If there is enough
space in dest this call returns non-zero.</div></div><hr>
<div id='u64_to_str_size_str_doc'><h4>&sect;4.3.89: u64_to_str_size</h4>
<div id='u64_to_str_size_str_doc'><h4>&sect;4.3.90: u64_to_str_size</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;'>
int32_t u64_to_str_size(
<div style='margin-left: 4mm;'>uint64_t x<br></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;'>This call returns the number of bytes required to represent x as a string.</div></div><hr>
<div id='u64_to_str_str_doc'><h4>&sect;4.3.90: u64_to_str</h4>
<div id='u64_to_str_str_doc'><h4>&sect;4.3.91: u64_to_str</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;'>
fstr_bool u64_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>uint64_t x<br></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;'>This call writes a string representation of x into dest. If there is enough
space in dest this call returns non-zero.</div></div><hr>
<div id='append_u64_to_str_str_doc'><h4>&sect;4.3.91: append_u64_to_str</h4>
<div id='append_u64_to_str_str_doc'><h4>&sect;4.3.92: append_u64_to_str</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;'>
fstr_bool append_u64_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>uint64_t x<br></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;'>This call appends a string representation of x onto dest. If there is enough
space in dest this call returns non-zero.</div></div><hr>
<div id='float_to_str_size_str_doc'><h4>&sect;4.3.92: float_to_str_size</h4>
<div id='float_to_str_size_str_doc'><h4>&sect;4.3.93: float_to_str_size</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;'>
int32_t float_to_str_size(
<div style='margin-left: 4mm;'>float x<br></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;'>This call returns the number of bytes required to represent x as a string.</div></div><hr>
<div id='append_float_to_str_str_doc'><h4>&sect;4.3.93: append_float_to_str</h4>
<div id='append_float_to_str_str_doc'><h4>&sect;4.3.94: append_float_to_str</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;'>
fstr_bool append_float_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>float x<br></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;'>This call writes a string representation of x into dest. If there is enough
space in dest this call returns non-zero.</div></div><hr>
<div id='float_to_str_str_doc'><h4>&sect;4.3.94: float_to_str</h4>
<div id='float_to_str_str_doc'><h4>&sect;4.3.95: float_to_str</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;'>
fstr_bool float_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>float x<br></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;'>This call appends a string representation of x onto dest. If there is enough
space in dest this call returns non-zero.</div></div><hr>
<div id='str_is_int_c_str_doc'><h4>&sect;4.3.95: str_is_int_c</h4>
<div id='str_is_int_c_str_doc'><h4>&sect;4.3.96: str_is_int_c</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;'>
int32_t str_is_int_c(
<div style='margin-left: 4mm;'>char *str<br></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;'>If str is a valid string representation of an integer, this call returns non-zero</div></div><hr>
<div id='str_is_int_s_str_doc'><h4>&sect;4.3.96: str_is_int_s</h4>
<div id='str_is_int_s_str_doc'><h4>&sect;4.3.97: str_is_int_s</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;'>
fstr_bool str_is_int_s(
<div style='margin-left: 4mm;'>String str<br></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;'>If str is a valid string representation of an integer, this call returns non-zero.</div></div><hr>
<div id='str_to_int_c_str_doc'><h4>&sect;4.3.97: str_to_int_c</h4>
<div id='str_to_int_c_str_doc'><h4>&sect;4.3.98: str_to_int_c</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;'>
int32_t str_to_int_c(
<div style='margin-left: 4mm;'>char *str<br></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;'>If str is a valid string representation of an integer, this call will return
the integer represented by the string. Otherwise this call returns zero.</div></div><hr>
<div id='str_to_int_s_str_doc'><h4>&sect;4.3.98: str_to_int_s</h4>
<div id='str_to_int_s_str_doc'><h4>&sect;4.3.99: str_to_int_s</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;'>
int32_t str_to_int_s(
<div style='margin-left: 4mm;'>String str<br></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;'>If str represents a valid string representation of an integer, this call will return
the integer represented by the string. Otherwise this call returns zero.</div></div><hr>
<div id='hexchar_to_int_str_doc'><h4>&sect;4.3.99: hexchar_to_int</h4>
<div id='hexchar_to_int_str_doc'><h4>&sect;4.3.100: hexchar_to_int</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;'>
int32_t hexchar_to_int(
<div style='margin-left: 4mm;'>char c<br></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;'>If c is a valid hexadecimal digit [0-9a-fA-F] this call returns the value of
the integer value of the digit. Otherwise the return is some nonsense value.</div></div><hr>
<div id='int_to_hexchar_str_doc'><h4>&sect;4.3.100: int_to_hexchar</h4>
<div id='int_to_hexchar_str_doc'><h4>&sect;4.3.101: int_to_hexchar</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;'>
char int_to_hexchar(
<div style='margin-left: 4mm;'>int32_t x<br></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;'>If x is in the range [0,15] this call returns the equivalent lowercase hexadecimal digit.
Otherwise the return is some nonsense value.</div></div><hr>
<div id='hexstr_to_int_str_doc'><h4>&sect;4.3.101: hexstr_to_int</h4>
<div id='hexstr_to_int_str_doc'><h4>&sect;4.3.102: hexstr_to_int</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;'>
uint32_t hexstr_to_int(
<div style='margin-left: 4mm;'>String str<br></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;'>This call interprets str has a hexadecimal representation of an integer and returns
the represented integer value.</div></div><hr>
<div id='color_to_hexstr_str_doc'><h4>&sect;4.3.102: color_to_hexstr</h4>
<div id='color_to_hexstr_str_doc'><h4>&sect;4.3.103: color_to_hexstr</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;'>
fstr_bool color_to_hexstr(
<div style='margin-left: 4mm;'>String *s,<br>uint32_t color<br></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;'>This call fills s with the hexadecimal representation of the color.
If there is enough memory in s to represent the color this call returns non-zero.</div></div><hr>
<div id='hexstr_to_color_str_doc'><h4>&sect;4.3.103: hexstr_to_color</h4>
<div id='hexstr_to_color_str_doc'><h4>&sect;4.3.104: hexstr_to_color</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;'>
fstr_bool hexstr_to_color(
<div style='margin-left: 4mm;'>String s,<br>uint32_t *out<br></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;'>This call interprets s as a color and writes the 32-bit integer representation into out.</div></div><hr>
<div id='reverse_seek_slash_pos_str_doc'><h4>&sect;4.3.104: reverse_seek_slash_pos</h4>
<div id='reverse_seek_slash_pos_str_doc'><h4>&sect;4.3.105: reverse_seek_slash_pos</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;'>
int32_t reverse_seek_slash_pos(
<div style='margin-left: 4mm;'>String str,<br>int32_t pos<br></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;'>This call searches for a slash in str by starting pos bytes from the end and going backwards.</div></div><hr>
<div id='reverse_seek_slash_str_doc'><h4>&sect;4.3.105: reverse_seek_slash</h4>
<div id='reverse_seek_slash_str_doc'><h4>&sect;4.3.106: reverse_seek_slash</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;'>
int32_t reverse_seek_slash(
<div style='margin-left: 4mm;'>String str<br></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;'>This call searches for a slash in str by starting at the end and going backwards.</div></div><hr>
<div id='front_of_directory_str_doc'><h4>&sect;4.3.106: front_of_directory</h4>
<div id='front_of_directory_str_doc'><h4>&sect;4.3.107: front_of_directory</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;'>
String front_of_directory(
<div style='margin-left: 4mm;'>String dir<br></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;'>This call returns a substring of dir containing only the file name or
folder name furthest to the right in the directory.</div><div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>See Also</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'><a href='#substr_doc'>substr</a></div></div><hr>
<div id='path_of_directory_str_doc'><h4>&sect;4.3.107: path_of_directory</h4>
<div id='path_of_directory_str_doc'><h4>&sect;4.3.108: path_of_directory</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;'>
String path_of_directory(
<div style='margin-left: 4mm;'>String dir<br></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;'>This call returns a substring of dir containing the whole path except
for the final file or folder name.</div><div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>See Also</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'><a href='#substr_doc'>substr</a></div></div><hr>
<div id='set_last_folder_sc_str_doc'><h4>&sect;4.3.108: set_last_folder_sc</h4>
<div id='set_last_folder_sc_str_doc'><h4>&sect;4.3.109: set_last_folder_sc</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;'>
fstr_bool set_last_folder_sc(
<div style='margin-left: 4mm;'>String *dir,<br>char *folder_name,<br>char slash<br></div>)
@ -2164,7 +2182,7 @@ at the end of the directory.</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;'>This call deletes the last file name or folder name in the dir string and appends the new provided one.
If there is enough memory in dir this call returns non-zero.</div></div><hr>
<div id='set_last_folder_ss_str_doc'><h4>&sect;4.3.109: set_last_folder_ss</h4>
<div id='set_last_folder_ss_str_doc'><h4>&sect;4.3.110: set_last_folder_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;'>
fstr_bool set_last_folder_ss(
<div style='margin-left: 4mm;'>String *dir,<br>String folder_name,<br>char slash<br></div>)
@ -2183,27 +2201,27 @@ fstr_bool set_last_folder_ss(
</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;'>This call deletes the last file name or folder name in the dir string and appends the new provided one.
If there is enough memory in dir this call returns non-zero.</div></div><hr>
<div id='file_extension_str_doc'><h4>&sect;4.3.110: file_extension</h4>
<div id='file_extension_str_doc'><h4>&sect;4.3.111: file_extension</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;'>
String file_extension(
<div style='margin-left: 4mm;'>String str<br></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;'>This call returns a substring containing only the file extension of the provided filename.</div><div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>See Also</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'><a href='#substr_doc'>substr</a></div></div><hr>
<div id='remove_extension_str_doc'><h4>&sect;4.3.111: remove_extension</h4>
<div id='remove_extension_str_doc'><h4>&sect;4.3.112: remove_extension</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;'>
fstr_bool remove_extension(
<div style='margin-left: 4mm;'>String *str<br></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;'>This call attemps to delete a file extension off the end of a filename.
This call returns non-zero on success.</div></div><hr>
<div id='remove_last_folder_str_doc'><h4>&sect;4.3.112: remove_last_folder</h4>
<div id='remove_last_folder_str_doc'><h4>&sect;4.3.113: remove_last_folder</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;'>
fstr_bool remove_last_folder(
<div style='margin-left: 4mm;'>String *str<br></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;'>This call attemps to delete a folder or filename off the end of a path string.
This call returns non-zero on success.</div></div><hr>
<div id='string_set_match_str_doc'><h4>&sect;4.3.113: string_set_match</h4>
<div id='string_set_match_str_doc'><h4>&sect;4.3.114: string_set_match</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;'>
fstr_bool string_set_match(
<div style='margin-left: 4mm;'>String *str_set,<br>int32_t count,<br>String str,<br>int32_t *match_index<br></div>)

View File

@ -1,4 +1,4 @@
enum Key_Code_Names{
enum{
key_back = 1,
key_up = 2,
key_down = 3,

View File

@ -138,6 +138,7 @@ FSTRING_LINK void to_lower_s(String *str);
FSTRING_LINK void to_upper_cc(char *src, char *dst);
FSTRING_LINK void to_upper_ss(String *src, String *dst);
FSTRING_LINK void to_upper_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);
@ -232,6 +233,7 @@ FSTRING_INLINE void to_lower(String *str);
FSTRING_INLINE void to_upper(char *src, char *dst);
FSTRING_INLINE void to_upper(String *src, String *dst);
FSTRING_INLINE void to_upper(String *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);
@ -366,6 +368,8 @@ FSTRING_INLINE void
to_upper(String *src, String *dst){(to_upper_ss(src,dst));}
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
@ -1503,6 +1507,33 @@ to_upper_s(String *str){
}
#endif
#if defined(FSTRING_IMPLEMENTATION)
FSTRING_LINK void
to_camel_cc(char *src, char *dst){
char *c, ch;
int32_t is_first = 1;
for (c = src; *c != 0; ++c){
ch = *c;
if (char_is_alpha_numeric_true(ch)){
if (is_first){
is_first = 0;
ch = char_to_upper(ch);
}
else{
ch = char_to_lower(ch);
}
}
else{
is_first = 1;
}
*dst++ = ch;
}
*dst = 0;
}
#endif
//
// String <-> Number Conversions
//

View File

@ -57,7 +57,7 @@ uint8_t main_fsm_table[] = {
33,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
24,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,25,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
37,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5,10,10, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,16,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
40,41,42,43,44, 7, 7, 5,10,10, 8,51,52,53,54,55,56,57,19,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
@ -137,7 +137,7 @@ uint8_t pp_macro_fsm_table[] = {
33,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
24,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,25,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
37,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5,10,10, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,16,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
40,41,42,43,44, 7, 7, 5,10,10, 8,51,52,53,54,55,56,57,19,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
@ -177,7 +177,7 @@ uint8_t pp_identifier_fsm_table[] = {
33,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
24,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,25,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
37,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5,10,10, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,16,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
40,41,42,43,44, 7, 7, 5,10,10, 8,51,52,53,54,55,56,57,19,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
@ -217,7 +217,7 @@ uint8_t pp_body_if_fsm_table[] = {
33,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
24,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,25,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
37,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5,10,10, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,16,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
40,41,42,43,44, 7, 7, 5,10,10, 8,51,52,53,54,55,56,57,19,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
@ -257,7 +257,7 @@ uint8_t pp_body_fsm_table[] = {
33,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
24,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,25,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
37,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5,10,10, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,16,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
40,41,42,43,44, 7, 7, 5,10,10, 8,51,52,53,54,55,56,57,19,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
@ -297,7 +297,7 @@ uint8_t pp_number_fsm_table[] = {
33,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
24,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,25,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
37,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5,10,10, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,16,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
40,41,42,43,44, 7, 7, 5,10,10, 8,51,52,53,54,55,56,57,19,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
@ -349,7 +349,7 @@ uint8_t pp_junk_fsm_table[] = {
33,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
24,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,25,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
37,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5,10,10, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
26,41,42,43,44, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,27,67,29,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,16,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
1, 1,42, 4, 4, 5, 6, 5, 8, 9, 8,51,52,53,54,55,56,57,18,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,
40,41,42,43,44, 7, 7, 5,10,10, 8,51,52,53,54,55,56,57,19,18,20,20,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,39,

View File

@ -23,54 +23,39 @@
#include "4coder_mem.h"
struct Struct_Field{
char *type;
char *name;
};
typedef struct Out_Context{
FILE *file;
String *str;
} Out_Context;
void to_camel(char *src, char *dst){
char *c, ch;
int32_t is_first = 1;
for (c = src; *c != 0; ++c){
ch = *c;
if (char_is_alpha_numeric_true(ch)){
if (is_first){
is_first = 0;
ch = char_to_upper(ch);
static int32_t
begin_file_out(Out_Context *out_context, char *filename, String *out){
int32_t r = 0;
out_context->file = fopen(filename, "wb");
out_context->str = out;
out->size = 0;
if (out_context->file){
r = 1;
}
else{
ch = char_to_lower(ch);
}
}
else{
is_first = 1;
}
*dst++ = ch;
}
*dst = 0;
return(r);
}
void struct_begin(FILE *file, char *name){
fprintf(file, "struct %s{\n", name);
static void
end_file_out(Out_Context out_context){
fwrite(out_context.str->str, 1, out_context.str->size, out_context.file);
fclose(out_context.file);
}
void struct_fields(FILE *file, Struct_Field *fields, int32_t count){
int32_t i;
for (i = 0; i < count; ++i){
fprintf(file, " %s %s;\n", fields[i].type, fields[i].name);
}
static String
make_out_string(int32_t x){
String str;
str.size = 0;
str.memory_size = x;
str.str = (char*)malloc(x);
return(str);
}
void struct_end(FILE *file){
fprintf(file, "};\n\n");
}
void enum_begin(FILE *file, char *name){
fprintf(file, "enum %s{\n", name);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
char *keys_that_need_codes[] = {
"back",
"up",
@ -109,14 +94,17 @@ char *keys_that_need_codes[] = {
void
generate_keycode_enum(){
FILE *file;
char *filename_keycodes = "4coder_keycodes.h";
int32_t i, count;
Out_Context context = {0};
int32_t i = 0, count = 0;
unsigned char code = 1;
file = fopen(filename_keycodes, "wb");
fprintf(file, "enum Key_Code_Names{\n");
String out = make_out_string(10 << 20);
if (begin_file_out(&context, filename_keycodes, &out)){
count = ArrayCount(keys_that_need_codes);
append_sc(&out, "enum{\n");
for (i = 0; i < count; i){
if (strcmp(keys_that_need_codes[i], "f1") == 0 && code < 0x7F){
code = 0x7F;
@ -126,37 +114,62 @@ generate_keycode_enum(){
case '\t': code++; break;
case 0x20: code = 0x7F; break;
default:
fprintf(file, "key_%s = %d,\n", keys_that_need_codes[i++], code++);
append_sc(&out, "key_");
append_sc(&out, keys_that_need_codes[i++]);
append_sc(&out, " = ");
append_int_to_str(&out, code++);
append_sc(&out, ",\n");
break;
}
}
fprintf(file, "};\n");
append_sc(&out, "};\n");
fprintf(file,
append_sc(&out,
"static char*\n"
"global_key_name(int32_t key_code, int32_t *size){\n"
"char *result = 0;\n"
"switch(key_code){\n"
);
"switch(key_code){\n");
for (i = 0; i < count; ++i){
fprintf(file,
"case key_%s: result = \"%s\"; *size = sizeof(\"%s\")-1; break;\n",
keys_that_need_codes[i],
keys_that_need_codes[i],
keys_that_need_codes[i]
);
append_sc(&out, "case key_");
append_sc(&out, keys_that_need_codes[i]);
append_sc(&out, ": result = \"");
append_sc(&out, keys_that_need_codes[i]);
append_sc(&out, "\"; *size = sizeof(\"");
append_sc(&out, keys_that_need_codes[i]);
append_sc(&out, "\")-1; break;\n");
}
fprintf(file,
append_sc(&out,
"}\n"
"return(result);\n"
"}\n"
);
"}\n");
fclose(file);
end_file_out(context);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
char* bar_style_fields[] = {
static void
struct_begin(String *str, char *name){
append_sc(str, "struct ");
append_sc(str, name);
append_sc(str, "{\n");
}
static void
enum_begin(String *str, char *name){
append_sc(str, "enum ");
append_sc(str, name);
append_sc(str, "{\n");
}
static void
struct_end(String *str){
append_sc(str, "};\n\n");
}
static char* bar_style_fields[] = {
"bar",
"bar_active",
"base",
@ -164,7 +177,7 @@ char* bar_style_fields[] = {
"pop2",
};
char* main_style_fields[] = {
static char* main_style_fields[] = {
"back",
"margin",
"margin_hover",
@ -199,101 +212,124 @@ make_style_tag(char *tag){
len = (int32_t)strlen(tag);
str = (char*)malloc(len + 1);
to_camel(tag, str);
to_camel_cc(tag, str);
str[len] = 0;
return(str);
}
char style_index_function_start[] =
"inline u32*\n"
"style_index_by_tag(Style_Main_Data *s, u32 tag){\n"
" u32 *result = 0;\n"
" switch (tag){\n";
char style_index_function_end[] =
" }\n"
" return(result);\n"
"}\n\n";
char style_case[] = " case Stag_%s: result = &s->%s_color; break;\n";
char style_info_case[] = " case Stag_%s: result = &s->file_info_style.%s_color; break;\n";
void
static void
generate_style(){
char filename_4coder[] = "4coder_style.h";
char filename_4ed[] = "4ed_style.h";
FILE *file;
char *tag;
int32_t count, i;
char *tag = 0;
int32_t count = 0, i = 0;
file = fopen(filename_4coder, "wb");
enum_begin(file, "Style_Tag");
String out = make_out_string(10 << 20);
Out_Context context = {0};
if (begin_file_out(&context, filename_4coder, &out)){
enum_begin(&out, "Style_Tag");
{
count = ArrayCount(bar_style_fields);
for (i = 0; i < count; ++i){
tag = make_style_tag(bar_style_fields[i]);
fprintf(file, "Stag_%s,\n", tag);
append_sc(&out, "Stag_");
append_sc(&out, tag);
append_sc(&out, ",\n");
free(tag);
}
count = ArrayCount(main_style_fields);
for (i = 0; i < count; ++i){
tag = make_style_tag(main_style_fields[i]);
fprintf(file, "Stag_%s,\n", tag);
append_sc(&out, "Stag_");
append_sc(&out, tag);
append_sc(&out, ",\n");
free(tag);
}
}
struct_end(file);
fclose(file);
struct_end(&out);
file = fopen(filename_4ed, "wb");
struct_begin(file, "Interactive_Style");
end_file_out(context);
}
if (begin_file_out(&context, filename_4ed, &out)){
struct_begin(&out, "Interactive_Style");
{
count = ArrayCount(bar_style_fields);
for (i = 0; i < count; ++i){
fprintf(file, "u32 %s_color;\n", bar_style_fields[i]);
append_sc(&out, "u32 ");
append_sc(&out, bar_style_fields[i]);
append_sc(&out, "_color;\n");
}
}
struct_end(file);
struct_end(&out);
struct_begin(file, "Style_Main_Data");
struct_begin(&out, "Style_Main_Data");
{
count = ArrayCount(main_style_fields);
for (i = 0; i < count; ++i){
fprintf(file, "u32 %s_color;\n", main_style_fields[i]);
append_sc(&out, "u32 ");
append_sc(&out, main_style_fields[i]);
append_sc(&out, "_color;\n");
}
fprintf(file, "Interactive_Style file_info_style;\n");
append_sc(&out, "Interactive_Style file_info_style;\n");
}
struct_end(file);
struct_end(&out);
{
fprintf(file, "%s", style_index_function_start);
append_sc(&out,
"inline u32*\n"
"style_index_by_tag(Style_Main_Data *s, u32 tag){\n"
"u32 *result = 0;\n"
"switch (tag){\n");
count = ArrayCount(bar_style_fields);
for (i = 0; i < count; ++i){
tag = make_style_tag(bar_style_fields[i]);
fprintf(file, style_info_case, tag, bar_style_fields[i]);
append_sc(&out, "case Stag_");
append_sc(&out, tag);
append_sc(&out, ": result = &s->file_info_style.");
append_sc(&out, bar_style_fields[i]);
append_sc(&out, "_color; break;\n");
free(tag);
}
count = ArrayCount(main_style_fields);
for (i = 0; i < count; ++i){
tag = make_style_tag(main_style_fields[i]);
fprintf(file, style_case, tag, main_style_fields[i]);
append_sc(&out, "case Stag_");
append_sc(&out, tag);
append_sc(&out, ": result = &s->");
append_sc(&out, main_style_fields[i]);
append_sc(&out, "_color; break;\n");
free(tag);
}
fprintf(file, "%s", style_index_function_end);
append_sc(&out,
"}\n"
"return(result);\n"
"}\n\n");
}
fclose(file);
end_file_out(context);
}
free(out.str);
}
#if 1
//////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct Argument{
String param_string;
String param_name;
} Argument;
typedef struct Argument_Breakdown{
int32_t count;
String *param_string;
String *param_name;
Argument *args;
} Argument_Breakdown;
typedef struct Documentation{
@ -306,26 +342,32 @@ typedef struct Documentation{
String *see_also;
} Documentation;
typedef struct App_API{
String *macros;
String *public_name;
} App_API;
enum{
Item_Null,
Item_Function,
Item_Macro,
Item_Typedef,
};
typedef struct Item_Node{
int32_t t;
String name;
String ret;
String args;
String body;
String marker;
String cpp_name;
String type;
String doc_string;
Argument_Breakdown breakdown;
Documentation doc;
} Item_Node;
typedef struct Function_Set{
String *name;
String *ret;
String *args;
String *body;
String *marker;
String *cpp_name;
String *doc_string;
int32_t *is_macro;
int32_t *valid;
Argument_Breakdown *breakdown;
Documentation *doc;
Item_Node *funcs;
} Function_Set;
typedef struct Typedef_Set{
@ -361,15 +403,9 @@ typedef struct Enum_Set{
String *doc_string;
} Enum_Set;
void
zero_index(Function_Set fnc_set, int32_t sig_count){
fnc_set.name [sig_count] = string_zero();
fnc_set.ret [sig_count] = string_zero();
fnc_set.args [sig_count] = string_zero();
fnc_set.valid[sig_count] = 0;
}
static Item_Node null_item_node = {0};
String
static String
file_dump(char *filename){
String result = {0};
FILE *file = fopen(filename, "rb");
@ -391,7 +427,7 @@ file_dump(char *filename){
return(result);
}
String
static String
get_first_line(String source){
String line = {0};
int32_t pos = find_s_char(source, 0, '\n');
@ -399,7 +435,7 @@ get_first_line(String source){
return(line);
}
String
static String
get_next_line(String source, String line){
String next = {0};
int32_t pos = (int32_t)(line.str - source.str) + line.size;
@ -455,12 +491,12 @@ check_and_fix_docs(String *lexeme){
return(result);
}
enum Doc_Note_Type{
typedef enum Doc_Note_Type{
DOC_PARAM,
DOC_RETURN,
DOC,
DOC_SEE
};
} Doc_Note_Type;
static String
doc_note_string[] = {
@ -470,7 +506,7 @@ doc_note_string[] = {
make_lit_string("DOC_SEE"),
};
String
static String
doc_parse_note(String source, int32_t *pos){
String result = {0};
@ -490,7 +526,7 @@ doc_parse_note(String source, int32_t *pos){
return(result);
}
String
static String
doc_parse_note_string(String source, int32_t *pos){
String result = {0};
@ -524,7 +560,7 @@ doc_parse_note_string(String source, int32_t *pos){
return(result);
}
String
static String
doc_parse_parameter(String source, int32_t *pos){
String result = {0};
@ -942,7 +978,7 @@ print_struct_html(FILE *file, Struct_Member *member){
static void
print_function_html(FILE *file, Function_Set function_set, int32_t i, String name,
char *function_call_head){
String ret = function_set.ret[i];
String ret = function_set.funcs[i].ret;
fprintf(file,
"%.*s %s%.*s(\n"
"<div style='margin-left: 4mm;'>",
@ -950,10 +986,10 @@ print_function_html(FILE *file, Function_Set function_set, int32_t i, String nam
function_call_head,
name.size, name.str);
Argument_Breakdown *breakdown = &function_set.breakdown[i];
Argument_Breakdown *breakdown = &function_set.funcs[i].breakdown;
int32_t arg_count = breakdown->count;
for (int32_t j = 0; j < arg_count; ++j){
String param_string = breakdown->param_string[j];
String param_string = breakdown->args[j].param_string;
if (j < arg_count - 1){
fprintf(file, "%.*s,<br>", param_string.size, param_string.str);
}
@ -967,7 +1003,7 @@ print_function_html(FILE *file, Function_Set function_set, int32_t i, String nam
static void
print_macro_html(FILE *file, Function_Set function_set, int32_t i, String name){
Argument_Breakdown *breakdown = &function_set.breakdown[i];
Argument_Breakdown *breakdown = &function_set.funcs[i].breakdown;
int32_t arg_count = breakdown->count;
if (arg_count == 0){
fprintf(file,
@ -975,7 +1011,7 @@ print_macro_html(FILE *file, Function_Set function_set, int32_t i, String name){
name.size, name.str);
}
else if (arg_count == 1){
String param_string = breakdown->param_string[0];
String param_string = breakdown->args[0].param_string;
fprintf(file,
"#define %.*s(%.*s)",
name.size, name.str,
@ -988,7 +1024,7 @@ print_macro_html(FILE *file, Function_Set function_set, int32_t i, String name){
name.size, name.str);
for (int32_t j = 0; j < arg_count; ++j){
String param_string = breakdown->param_string[j];
String param_string = breakdown->args[j].param_string;
if (j < arg_count - 1){
fprintf(file, "%.*s,<br>", param_string.size, param_string.str);
}
@ -1186,52 +1222,22 @@ parse_enum(Partition *part, char *data,
return(result);
}
static App_API
allocate_app_api(int32_t count){
App_API app_api = {0};
int32_t memory_size = (sizeof(String)*2)*count;
app_api.macros = (String*)malloc(memory_size);
app_api.public_name = app_api.macros + count;
memset(app_api.macros, 0, memory_size);
return(app_api);
}
static Function_Set
allocate_function_set(int32_t count){
Function_Set function_set = {0};
int32_t memory_size = (sizeof(String)*7 +
sizeof(int32_t)*2 +
sizeof(Argument_Breakdown) +
sizeof(Documentation))*count;
String *str_ptr = (String*)malloc(memory_size);
function_set.name = str_ptr; str_ptr += count;
function_set.ret = str_ptr; str_ptr += count;
function_set.args = str_ptr; str_ptr += count;
function_set.body = str_ptr; str_ptr += count;
function_set.marker = str_ptr; str_ptr += count;
function_set.cpp_name = str_ptr; str_ptr += count;
function_set.doc_string = str_ptr; str_ptr += count;
function_set.is_macro = (int32_t*)(function_set.doc_string + count);
function_set.valid = function_set.is_macro + count;
function_set.breakdown = (Argument_Breakdown*)(function_set.valid + count);
function_set.doc = (Documentation*)(function_set.breakdown + count);
memset(function_set.name, 0, memory_size);
int32_t memory_size = sizeof(Item_Node)*count;
function_set.funcs = (Item_Node*)malloc(memory_size);
memset(function_set.funcs, 0, memory_size);
return(function_set);
}
static Argument_Breakdown
allocate_argument_breakdown(int32_t count){
Argument_Breakdown breakdown = {0};
int32_t memory_size = (sizeof(String)*2)*count;
int32_t memory_size = sizeof(Argument)*count;
breakdown.count = count;
breakdown.param_string = (String*)malloc(memory_size);
breakdown.param_name = breakdown.param_string + count;
memset(breakdown.param_string, 0, memory_size);
breakdown.args = (Argument*)malloc(memory_size);
memset(breakdown.args, 0, memory_size);
return(breakdown);
}
@ -1259,7 +1265,7 @@ do_parameter_parse(char *data, Cpp_Token *args_start_token, Cpp_Token *token){
int32_t size = arg_token->start - param_string_start;
String param_string = make_string(data + param_string_start, size);
param_string = chop_whitespace(param_string);
breakdown.param_string[arg_index] = param_string;
breakdown.args[arg_index].param_string = param_string;
for (Cpp_Token *param_name_token = arg_token - 1;
param_name_token->start > param_string_start;
@ -1267,7 +1273,7 @@ do_parameter_parse(char *data, Cpp_Token *args_start_token, Cpp_Token *token){
if (param_name_token->type == CPP_TOKEN_IDENTIFIER){
int32_t start = param_name_token->start;
int32_t size = param_name_token->size;
breakdown.param_name[arg_index] = make_string(data + start, size);
breakdown.args[arg_index].param_name = make_string(data + start, size);
break;
}
}
@ -1392,12 +1398,12 @@ do_function_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count, Cpp_Toke
Cpp_Token *args_start_token = token+1;
function_set.name[sig_count] = make_string(data + token->start, token->size);
function_set.funcs[sig_count].name = make_string(data + token->start, token->size);
int32_t size = token->start - ret_start_token->start;
String ret = make_string(data + ret_start_token->start, size);
ret = chop_whitespace(ret);
function_set.ret[sig_count] = ret;
function_set.funcs[sig_count].ret = ret;
for (; i < count; ++i, ++token){
if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
@ -1407,15 +1413,15 @@ do_function_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count, Cpp_Toke
if (i < count){
int32_t size = token->start + token->size - args_start_token->start;;
function_set.args[sig_count] =
function_set.funcs[sig_count].args =
make_string(data + args_start_token->start, size);
function_set.valid[sig_count] = true;
function_set.funcs[sig_count].t = Item_Function;
result = true;
Argument_Breakdown *breakdown = &function_set.breakdown[sig_count];
Argument_Breakdown *breakdown = &function_set.funcs[sig_count].breakdown;
*breakdown = do_parameter_parse(data, args_start_token, token);
function_set.cpp_name[sig_count] = cpp_name;
function_set.funcs[sig_count].cpp_name = cpp_name;
}
*index = i;
@ -1433,7 +1439,7 @@ do_full_function_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count, cha
Cpp_Token *token = *token_ptr;
{
function_set.marker[sig_count] = make_string(data + token->start, token->size);
function_set.funcs[sig_count].marker = make_string(data + token->start, token->size);
int32_t j = i;
Cpp_Token *jtoken = token;
@ -1442,7 +1448,7 @@ do_full_function_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count, cha
if (token->type == CPP_TOKEN_IDENTIFIER){
String doc_string = {0};
if (do_function_get_doc(&j, &jtoken, count, data, &doc_string)){
function_set.doc_string[sig_count] = doc_string;
function_set.funcs[sig_count].doc_string = doc_string;
}
}
}
@ -1506,7 +1512,7 @@ do_macro_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count,
String doc_string = make_string(data + doc_token->start, doc_token->size);
if (check_and_fix_docs(&doc_string)){
macro_set.doc_string[sig_count] = doc_string;
macro_set.funcs[sig_count].doc_string = doc_string;
for (; i < count; ++i, ++token){
if (token->type == CPP_TOKEN_IDENTIFIER){
@ -1515,7 +1521,7 @@ do_macro_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count,
}
if (i < count && (token->flags & CPP_TFLAG_PP_BODY)){
macro_set.name[sig_count] = make_string(data + token->start, token->size);
macro_set.funcs[sig_count].name = make_string(data + token->start, token->size);
++i, ++token;
if (i < count){
@ -1529,9 +1535,9 @@ do_macro_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count,
if (i < count){
int32_t start = args_start_token->start;
int32_t end = token->start + token->size;
macro_set.args[sig_count] = make_string(data + start, end - start);
macro_set.funcs[sig_count].args = make_string(data + start, end - start);
Argument_Breakdown *breakdown = &macro_set.breakdown[sig_count];
Argument_Breakdown *breakdown = &macro_set.funcs[sig_count].breakdown;
*breakdown = do_parameter_parse(data, args_start_token, token);
++i, ++token;
@ -1551,12 +1557,11 @@ do_macro_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count,
start = body_start->start;
end = body_end->start + body_end->size;
macro_set.body[sig_count] = make_string(data + start, end - start);
macro_set.funcs[sig_count].body = make_string(data + start, end - start);
}
}
macro_set.is_macro[sig_count] = true;
macro_set.valid[sig_count] = true;
macro_set.funcs[sig_count].t = Item_Macro;
result = true;
}
}
@ -1570,12 +1575,12 @@ do_macro_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count,
return(result);
}
struct String_Function_Marker{
typedef struct String_Function_Marker{
int32_t parse_function;
int32_t is_inline;
int32_t parse_doc;
int32_t cpp_name;
};
} String_Function_Marker;
static String_Function_Marker
do_string_function_marker_check(String lexeme){
@ -1720,7 +1725,25 @@ print_function_docs(FILE *file, Partition *part, String name, String doc_string)
print_see_also(file, doc);
}
void
typedef struct App_API_Name{
String macro;
String public_name;
} App_API_Name;
typedef struct App_API{
App_API_Name *names;
} App_API;
static App_API
allocate_app_api(int32_t count){
App_API app_api = {0};
int32_t memory_size = sizeof(App_API_Name)*count;
app_api.names = (App_API_Name*)malloc(memory_size);
memset(app_api.names, 0, memory_size);
return(app_api);
}
static void
generate_custom_headers(){
#define API_H "4coder_custom_api.h"
#define OS_API_H "4ed_os_custom_api.h"
@ -1869,7 +1892,7 @@ generate_custom_headers(){
}
Function_Set function_set = allocate_function_set(line_count);
App_API app_function_set = allocate_app_api(line_count);
App_API func_4ed_names = allocate_app_api(line_count);
int32_t sig_count = 0;
int32_t sig_count_per_file[2];
@ -1891,8 +1914,8 @@ generate_custom_headers(){
if (match_ss(lexeme, make_lit_string("API_EXPORT"))){
do_full_function_parse(&i, &token, count, data, function_set,
sig_count, string_zero());
if (!function_set.valid[sig_count]){
zero_index(function_set, sig_count);
if (function_set.funcs[sig_count].t == Item_Null){
function_set.funcs[sig_count] = null_item_node;
// TODO(allen): get warning file name and line numbers
fprintf(stderr, "generator warning : invalid function signature\n");
}
@ -1905,9 +1928,9 @@ generate_custom_headers(){
}
for (int32_t i = 0; i < sig_count; ++i){
String name_string = function_set.name[i];
String *macro = app_function_set.macros + i;
String *public_name = app_function_set.public_name + i;
String name_string = function_set.funcs[i].name;
String *macro = &func_4ed_names.names[i].macro;
String *public_name = &func_4ed_names.names[i].public_name;
macro->size = 0;
macro->memory_size = name_string.size+4;
@ -1931,9 +1954,9 @@ generate_custom_headers(){
int32_t main_api_count = sig_count_per_file[0];
for (int32_t i = main_api_count; i < sig_count; ++i){
String ret_string = function_set.ret[i];
String args_string = function_set.args[i];
String macro_string = app_function_set.macros[i];
String ret_string = function_set.funcs[i].ret;
String args_string = function_set.funcs[i].args;
String macro_string = func_4ed_names.names[i].macro;
fprintf(file, "#define %.*s(n) %.*s n%.*s\n",
macro_string.size, macro_string.str,
@ -1942,8 +1965,8 @@ generate_custom_headers(){
}
for (int32_t i = main_api_count; i < sig_count; ++i){
String name_string = function_set.name[i];
String macro_string = app_function_set.macros[i];
String name_string = function_set.funcs[i].name;
String macro_string = func_4ed_names.names[i].macro;
fprintf(file, "typedef %.*s(%.*s_Function);\n",
macro_string.size, macro_string.str,
@ -1955,9 +1978,9 @@ generate_custom_headers(){
file = fopen(API_H, "wb");
for (int32_t i = 0; i < sig_count; ++i){
String ret_string = function_set.ret[i];
String args_string = function_set.args[i];
String macro_string = app_function_set.macros[i];
String ret_string = function_set.funcs[i].ret;
String args_string = function_set.funcs[i].args;
String macro_string = func_4ed_names.names[i].macro;
fprintf(file, "#define %.*s(n) %.*s n%.*s\n",
macro_string.size, macro_string.str,
@ -1966,8 +1989,8 @@ generate_custom_headers(){
}
for (int32_t i = 0; i < sig_count; ++i){
String name_string = function_set.name[i];
String macro_string = app_function_set.macros[i];
String name_string = function_set.funcs[i].name;
String macro_string = func_4ed_names.names[i].macro;
fprintf(file, "typedef %.*s(%.*s_Function);\n",
macro_string.size, macro_string.str,
@ -1980,8 +2003,8 @@ generate_custom_headers(){
" int32_t memory_size;\n"
);
for (int32_t i = 0; i < sig_count; ++i){
String name_string = function_set.name[i];
String public_string = app_function_set.public_name[i];
String name_string = function_set.funcs[i].name;
String public_string = func_4ed_names.names[i].public_name;
fprintf(file, " %.*s_Function *%.*s;\n",
name_string.size, name_string.str,
@ -1997,8 +2020,8 @@ generate_custom_headers(){
fprintf(file, "#define FillAppLinksAPI(app_links) do{");
for (int32_t i = 0; i < sig_count; ++i){
String name = function_set.name[i];
String public_string = app_function_set.public_name[i];
String name = function_set.funcs[i].name;
String public_string = func_4ed_names.names[i].public_name;
fprintf(file,
"\\\n"
@ -2282,11 +2305,11 @@ generate_custom_headers(){
char line_space[2048];
String line = make_fixed_width_string(line_space);
if (!string_function_set.is_macro[j]){
String marker = string_function_set.marker[j];
String ret = string_function_set.ret[j];
String name = string_function_set.name[j];
String args = string_function_set.args[j];
if (string_function_set.funcs[j].t != Item_Macro){
String marker = string_function_set.funcs[j].marker;
String ret = string_function_set.funcs[j].ret;
String name = string_function_set.funcs[j].name;
String args = string_function_set.funcs[j].args;
append_ss(&line, marker);
append_padding(&line, ' ', RETURN_PADDING);
@ -2299,9 +2322,9 @@ generate_custom_headers(){
fprintf(file, "%s;\n", line.str);
}
else{
String name = string_function_set.name[j];
String args = string_function_set.args[j];
String body = string_function_set.body[j];
String name = string_function_set.funcs[j].name;
String args = string_function_set.funcs[j].args;
String body = string_function_set.funcs[j].body;
append_ss(&line, make_lit_string("#ifndef "));
append_padding(&line, ' ', 10);
@ -2336,11 +2359,11 @@ generate_custom_headers(){
char line_space[2048];
String line = make_fixed_width_string(line_space);
if (!string_function_set.is_macro[j]){
String cpp_name = string_function_set.cpp_name[j];
if (string_function_set.funcs[j].t != Item_Macro){
String cpp_name = string_function_set.funcs[j].cpp_name;
if (cpp_name.str != 0){
String ret = string_function_set.ret[j];
String args = string_function_set.args[j];
String ret = string_function_set.funcs[j].ret;
String args = string_function_set.funcs[j].args;
append_ss(&line, make_lit_string("FSTRING_INLINE"));
append_padding(&line, ' ', RETURN_PADDING);
@ -2367,13 +2390,13 @@ generate_custom_headers(){
char line_space[2048];
String line = make_fixed_width_string(line_space);
if (!string_function_set.is_macro[j]){
String cpp_name = string_function_set.cpp_name[j];
if (string_function_set.funcs[j].t != Item_Macro){
String cpp_name = string_function_set.funcs[j].cpp_name;
if (cpp_name.str != 0){
String name = string_function_set.name[j];
String ret = string_function_set.ret[j];
String args = string_function_set.args[j];
Argument_Breakdown breakdown = string_function_set.breakdown[j];
String name = string_function_set.funcs[j].name;
String ret = string_function_set.funcs[j].ret;
String args = string_function_set.funcs[j].args;
Argument_Breakdown breakdown = string_function_set.funcs[j].breakdown;
append_ss(&line, make_lit_string("FSTRING_INLINE"));
append_s_char(&line, ' ');
@ -2395,7 +2418,7 @@ generate_custom_headers(){
if (i != 0){
append_s_char(&line, ',');
}
append_ss(&line, breakdown.param_name[i]);
append_ss(&line, breakdown.args[i].param_name);
}
}
else{
@ -2644,7 +2667,7 @@ generate_custom_headers(){
"<ul>\n");
for (int32_t i = 0; i < sig_count; ++i){
String name = app_function_set.public_name[i];
String name = func_4ed_names.names[i].public_name;
fprintf(file,
"<li>"
"<a href='#%.*s_doc'>%.*s</a>"
@ -2714,7 +2737,7 @@ generate_custom_headers(){
fprintf(file, "<h3>&sect;"SECTION" Function Descriptions</h3>\n");
for (int32_t i = 0; i < sig_count; ++i){
String name = app_function_set.public_name[i];
String name = func_4ed_names.names[i].public_name;
fprintf(file,
"<div id='%.*s_doc' style='margin-bottom: 1cm;'>\n"
@ -2726,7 +2749,7 @@ generate_custom_headers(){
print_function_html(file, function_set, i, name, "app->");
fprintf(file, "</div>\n");
String doc_string = function_set.doc_string[i];
String doc_string = function_set.funcs[i].doc_string;
print_function_docs(file, part, name, doc_string);
fprintf(file, "</div><hr>\n");
@ -2990,7 +3013,7 @@ generate_custom_headers(){
}
for (int32_t i = 0; i < string_sig_count; ++i){
String name = string_function_set.name[i];
String name = string_function_set.funcs[i].name;
int32_t index = 0;
if (!string_set_match(used_strings, used_string_count, name, &index)){
fprintf(file,
@ -3015,7 +3038,7 @@ generate_custom_headers(){
"<ul>\n");
for (int32_t i = 0; i < string_sig_count; ++i){
String name = string_function_set.name[i];
String name = string_function_set.funcs[i].name;
int32_t index = 0;
int32_t do_id = false;
if (!string_set_match(used_strings, used_string_count, name, &index)){
@ -3038,7 +3061,7 @@ generate_custom_headers(){
"<div style='"CODE_STYLE" "DESCRIPT_SECTION_STYLE"'>\n",
i+1, name.size, name.str);
if (string_function_set.is_macro[i]){
if (string_function_set.funcs[i].t == Item_Macro){
print_macro_html(file, string_function_set, i, name);
}
else{
@ -3048,7 +3071,7 @@ generate_custom_headers(){
fprintf(file, "</div>\n");
String doc_string = string_function_set.doc_string[i];
String doc_string = string_function_set.funcs[i].doc_string;
print_function_docs(file, part, name, doc_string);
fprintf(file, "</div><hr>\n");
@ -3064,7 +3087,6 @@ generate_custom_headers(){
fclose(file);
}
}
#endif
int main(int argc, char **argv){
generate_keycode_enum();

View File

@ -264,7 +264,7 @@ buildsuper(char *code_path, char *out_path, char *filename){
static void
standard_build(char *cdir, uint32_t flags){
#if 0
#if 1
{
BEGIN_TIME_SECTION();
build(OPTS, cdir, "fsm_table_generator.cpp",
@ -294,7 +294,7 @@ standard_build(char *cdir, uint32_t flags){
}
#endif
#if 0
#if 1
{
BEGIN_TIME_SECTION();
//buildsuper(cdir, BUILD_DIR, "../code/4coder_default_bindings.cpp");

View File

@ -1178,8 +1178,8 @@ CPP_NAME(to_upper)
FSTRING_LINK void
to_upper_cc(char *src, char *dst)/*
DOC_PARAM(src, The source string to convert to uppercase. This string must be null terminated.)
DOC_PARAM(dst, The destination buffer to receive the converted string. This must be large
enough to contain all of src and a null terminator.)
DOC_PARAM(dst, The destination buffer to receive the converted string.
This must be large enough to contain all of src and a null terminator.)
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.)
*/{
@ -1192,7 +1192,7 @@ that src and dst may be exactly equal in order to convert the string in place.)
CPP_NAME(to_upper)
FSTRING_LINK void
to_upper_ss(String *src, String *dst)/*
DOC_PARAM(src, The source string to conver to uppercase.)
DOC_PARAM(src, The source string to convert to uppercase.)
DOC_PARAM(dst, The destination buffer to receive the converted string.
This must have a capacity of at least the size of src.)
DOC(Rewrites the string in src into dst. src and dst should not overlap with the exception
@ -1224,6 +1224,38 @@ DOC(This version of to_upper converts str to uppercase in place.)
}
}
CPP_NAME(to_camel)
FSTRING_LINK void
to_camel_cc(char *src, char *dst)/*
DOC_PARAM(src, The source string to convert to camel case.)
DOC_PARAM(dst, The destination buffer to receive the converted string.
This must be large enough to contain all of src and a null terminator.)
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.)
*/{
char *c, ch;
int32_t is_first = 1;
for (c = src; *c != 0; ++c){
ch = *c;
if (char_is_alpha_numeric_true(ch)){
if (is_first){
is_first = 0;
ch = char_to_upper(ch);
}
else{
ch = char_to_lower(ch);
}
}
else{
is_first = 1;
}
*dst++ = ch;
}
*dst = 0;
}
//
// String <-> Number Conversions
//