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_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_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_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_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='#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> <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> <div>
<div style='font-weight: 600;'>dst</div> <div style='font-weight: 600;'>dst</div>
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The destination buffer to receive the converted string. This must be large <div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The destination buffer to receive the converted string.
enough to contain all of src and a null terminator.</div></div> This must be large enough to contain all of src and a null terminator.</div></div>
</div> </div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>Rewrites the string in src into dst. src and dst should not overlap with the exception <div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>Rewrites the string in src into dst. src and dst should not overlap with the exception
that src and dst may be exactly equal in order to convert the string in place.</div></div><hr> that src and dst may be exactly equal in order to convert the string in place.</div></div><hr>
@ -1979,7 +1980,7 @@ void to_upper_ss(
</div> </div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Parameters</i></b></div><div> <div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Parameters</i></b></div><div>
<div style='font-weight: 600;'>src</div> <div style='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> <div>
<div style='font-weight: 600;'>dst</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 style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>The string to be converted to all uppercase.</div></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 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;'> <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( int32_t int_to_str_size(
<div style='margin-left: 4mm;'>int32_t x<br></div>) <div style='margin-left: 4mm;'>int32_t x<br></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 returns the number of bytes required to represent x as a string.</div></div><hr> <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;'> <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( fstr_bool int_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>int32_t x<br></div>) <div style='margin-left: 4mm;'>String *dest,<br>int32_t x<br></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 writes a string representation of x into dest. If there is enough <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> 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;'> <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( fstr_bool append_int_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>int32_t x<br></div>) <div style='margin-left: 4mm;'>String *dest,<br>int32_t x<br></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 appends a string representation of x onto dest. If there is enough <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> 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;'> <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( int32_t u64_to_str_size(
<div style='margin-left: 4mm;'>uint64_t x<br></div>) <div style='margin-left: 4mm;'>uint64_t x<br></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 returns the number of bytes required to represent x as a string.</div></div><hr> <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;'> <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( fstr_bool u64_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>uint64_t x<br></div>) <div style='margin-left: 4mm;'>String *dest,<br>uint64_t x<br></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 writes a string representation of x into dest. If there is enough <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> 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;'> <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( fstr_bool append_u64_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>uint64_t x<br></div>) <div style='margin-left: 4mm;'>String *dest,<br>uint64_t x<br></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 appends a string representation of x onto dest. If there is enough <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> 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;'> <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( int32_t float_to_str_size(
<div style='margin-left: 4mm;'>float x<br></div>) <div style='margin-left: 4mm;'>float x<br></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 returns the number of bytes required to represent x as a string.</div></div><hr> <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;'> <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( fstr_bool append_float_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>float x<br></div>) <div style='margin-left: 4mm;'>String *dest,<br>float x<br></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 writes a string representation of x into dest. If there is enough <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> 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;'> <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( fstr_bool float_to_str(
<div style='margin-left: 4mm;'>String *dest,<br>float x<br></div>) <div style='margin-left: 4mm;'>String *dest,<br>float x<br></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 appends a string representation of x onto dest. If there is enough <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> 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;'> <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( int32_t str_is_int_c(
<div style='margin-left: 4mm;'>char *str<br></div>) <div style='margin-left: 4mm;'>char *str<br></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;'>If str is a valid string representation of an integer, this call returns non-zero</div></div><hr> <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;'> <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( fstr_bool str_is_int_s(
<div style='margin-left: 4mm;'>String str<br></div>) <div style='margin-left: 4mm;'>String str<br></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;'>If str is a valid string representation of an integer, this call returns non-zero.</div></div><hr> <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;'> <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( int32_t str_to_int_c(
<div style='margin-left: 4mm;'>char *str<br></div>) <div style='margin-left: 4mm;'>char *str<br></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;'>If str is a valid string representation of an integer, this call will return <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> 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;'> <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( int32_t str_to_int_s(
<div style='margin-left: 4mm;'>String str<br></div>) <div style='margin-left: 4mm;'>String str<br></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;'>If str represents a valid string representation of an integer, this call will return <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> 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;'> <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( int32_t hexchar_to_int(
<div style='margin-left: 4mm;'>char c<br></div>) <div style='margin-left: 4mm;'>char c<br></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;'>If c is a valid hexadecimal digit [0-9a-fA-F] this call returns the value of <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> 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;'> <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( char int_to_hexchar(
<div style='margin-left: 4mm;'>int32_t x<br></div>) <div style='margin-left: 4mm;'>int32_t x<br></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;'>If x is in the range [0,15] this call returns the equivalent lowercase hexadecimal digit. <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> 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;'> <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( uint32_t hexstr_to_int(
<div style='margin-left: 4mm;'>String str<br></div>) <div style='margin-left: 4mm;'>String str<br></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 interprets str has a hexadecimal representation of an integer and returns <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> 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;'> <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( fstr_bool color_to_hexstr(
<div style='margin-left: 4mm;'>String *s,<br>uint32_t color<br></div>) <div style='margin-left: 4mm;'>String *s,<br>uint32_t color<br></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 fills s with the hexadecimal representation of the color. <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> 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;'> <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( fstr_bool hexstr_to_color(
<div style='margin-left: 4mm;'>String s,<br>uint32_t *out<br></div>) <div style='margin-left: 4mm;'>String s,<br>uint32_t *out<br></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 interprets s as a color and writes the 32-bit integer representation into out.</div></div><hr> <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;'> <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( int32_t reverse_seek_slash_pos(
<div style='margin-left: 4mm;'>String str,<br>int32_t pos<br></div>) <div style='margin-left: 4mm;'>String str,<br>int32_t pos<br></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 searches for a slash in str by starting pos bytes from the end and going backwards.</div></div><hr> <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;'> <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( int32_t reverse_seek_slash(
<div style='margin-left: 4mm;'>String str<br></div>) <div style='margin-left: 4mm;'>String str<br></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 searches for a slash in str by starting at the end and going backwards.</div></div><hr> <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;'> <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( String front_of_directory(
<div style='margin-left: 4mm;'>String dir<br></div>) <div style='margin-left: 4mm;'>String dir<br></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 returns a substring of dir containing only the file name or <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> 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;'> <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( String path_of_directory(
<div style='margin-left: 4mm;'>String dir<br></div>) <div style='margin-left: 4mm;'>String dir<br></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 returns a substring of dir containing the whole path except <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> 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;'> <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( fstr_bool set_last_folder_sc(
<div style='margin-left: 4mm;'>String *dir,<br>char *folder_name,<br>char slash<br></div>) <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>
<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. <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> 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;'> <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( fstr_bool set_last_folder_ss(
<div style='margin-left: 4mm;'>String *dir,<br>String folder_name,<br>char slash<br></div>) <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>
<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. <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> 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;'> <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( String file_extension(
<div style='margin-left: 4mm;'>String str<br></div>) <div style='margin-left: 4mm;'>String str<br></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 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 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;'> <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( fstr_bool remove_extension(
<div style='margin-left: 4mm;'>String *str<br></div>) <div style='margin-left: 4mm;'>String *str<br></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 attemps to delete a file extension off the end of a filename. <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> 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;'> <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( fstr_bool remove_last_folder(
<div style='margin-left: 4mm;'>String *str<br></div>) <div style='margin-left: 4mm;'>String *str<br></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 attemps to delete a folder or filename off the end of a path string. <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> 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;'> <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( 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>) <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_back = 1,
key_up = 2, key_up = 2,
key_down = 3, 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_cc(char *src, char *dst);
FSTRING_LINK void to_upper_ss(String *src, String *dst); FSTRING_LINK void to_upper_ss(String *src, String *dst);
FSTRING_LINK void to_upper_s(String *str); FSTRING_LINK void to_upper_s(String *str);
FSTRING_LINK void to_camel_cc(char *src, char *dst);
FSTRING_LINK int32_t int_to_str_size(int32_t x); 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 int_to_str(String *dest, int32_t x);
FSTRING_LINK fstr_bool append_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(char *src, char *dst);
FSTRING_INLINE void to_upper(String *src, String *dst); FSTRING_INLINE void to_upper(String *src, String *dst);
FSTRING_INLINE void to_upper(String *str); FSTRING_INLINE void to_upper(String *str);
FSTRING_INLINE void to_camel(char *src, char *dst);
FSTRING_INLINE int32_t str_is_int(char *str); FSTRING_INLINE int32_t str_is_int(char *str);
FSTRING_INLINE fstr_bool str_is_int(String 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(char *str);
@ -366,6 +368,8 @@ FSTRING_INLINE void
to_upper(String *src, String *dst){(to_upper_ss(src,dst));} to_upper(String *src, String *dst){(to_upper_ss(src,dst));}
FSTRING_INLINE void FSTRING_INLINE void
to_upper(String *str){(to_upper_s(str));} to_upper(String *str){(to_upper_s(str));}
FSTRING_INLINE void
to_camel(char *src, char *dst){(to_camel_cc(src,dst));}
FSTRING_INLINE int32_t FSTRING_INLINE int32_t
str_is_int(char *str){return(str_is_int_c(str));} str_is_int(char *str){return(str_is_int_c(str));}
FSTRING_INLINE fstr_bool FSTRING_INLINE fstr_bool
@ -1503,6 +1507,33 @@ to_upper_s(String *str){
} }
#endif #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 // 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, 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, 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, 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,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, 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, 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, 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, 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, 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,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, 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, 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, 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, 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, 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,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, 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, 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, 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, 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, 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,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, 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, 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, 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, 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, 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,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, 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, 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, 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, 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, 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,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, 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, 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, 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, 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, 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,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, 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, 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" #include "4coder_mem.h"
struct Struct_Field{ typedef struct Out_Context{
char *type; FILE *file;
char *name; String *str;
}; } Out_Context;
void to_camel(char *src, char *dst){ static int32_t
char *c, ch; begin_file_out(Out_Context *out_context, char *filename, String *out){
int32_t is_first = 1; int32_t r = 0;
for (c = src; *c != 0; ++c){ out_context->file = fopen(filename, "wb");
ch = *c; out_context->str = out;
if (char_is_alpha_numeric_true(ch)){ out->size = 0;
if (is_first){ if (out_context->file){
is_first = 0; r = 1;
ch = char_to_upper(ch);
} }
else{ return(r);
ch = char_to_lower(ch);
}
}
else{
is_first = 1;
}
*dst++ = ch;
}
*dst = 0;
} }
void struct_begin(FILE *file, char *name){ static void
fprintf(file, "struct %s{\n", name); 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){ static String
int32_t i; make_out_string(int32_t x){
for (i = 0; i < count; ++i){ String str;
fprintf(file, " %s %s;\n", fields[i].type, fields[i].name); 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[] = { char *keys_that_need_codes[] = {
"back", "back",
"up", "up",
@ -109,14 +94,17 @@ char *keys_that_need_codes[] = {
void void
generate_keycode_enum(){ generate_keycode_enum(){
FILE *file;
char *filename_keycodes = "4coder_keycodes.h"; char *filename_keycodes = "4coder_keycodes.h";
int32_t i, count; Out_Context context = {0};
int32_t i = 0, count = 0;
unsigned char code = 1; unsigned char code = 1;
file = fopen(filename_keycodes, "wb"); String out = make_out_string(10 << 20);
fprintf(file, "enum Key_Code_Names{\n");
if (begin_file_out(&context, filename_keycodes, &out)){
count = ArrayCount(keys_that_need_codes); count = ArrayCount(keys_that_need_codes);
append_sc(&out, "enum{\n");
for (i = 0; i < count; i){ for (i = 0; i < count; i){
if (strcmp(keys_that_need_codes[i], "f1") == 0 && code < 0x7F){ if (strcmp(keys_that_need_codes[i], "f1") == 0 && code < 0x7F){
code = 0x7F; code = 0x7F;
@ -126,37 +114,62 @@ generate_keycode_enum(){
case '\t': code++; break; case '\t': code++; break;
case 0x20: code = 0x7F; break; case 0x20: code = 0x7F; break;
default: 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; break;
} }
} }
fprintf(file, "};\n"); append_sc(&out, "};\n");
fprintf(file, append_sc(&out,
"static char*\n" "static char*\n"
"global_key_name(int32_t key_code, int32_t *size){\n" "global_key_name(int32_t key_code, int32_t *size){\n"
"char *result = 0;\n" "char *result = 0;\n"
"switch(key_code){\n" "switch(key_code){\n");
);
for (i = 0; i < count; ++i){ for (i = 0; i < count; ++i){
fprintf(file, append_sc(&out, "case key_");
"case key_%s: result = \"%s\"; *size = sizeof(\"%s\")-1; break;\n", append_sc(&out, keys_that_need_codes[i]);
keys_that_need_codes[i], append_sc(&out, ": result = \"");
keys_that_need_codes[i], append_sc(&out, keys_that_need_codes[i]);
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" "}\n"
"return(result);\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",
"bar_active", "bar_active",
"base", "base",
@ -164,7 +177,7 @@ char* bar_style_fields[] = {
"pop2", "pop2",
}; };
char* main_style_fields[] = { static char* main_style_fields[] = {
"back", "back",
"margin", "margin",
"margin_hover", "margin_hover",
@ -199,101 +212,124 @@ make_style_tag(char *tag){
len = (int32_t)strlen(tag); len = (int32_t)strlen(tag);
str = (char*)malloc(len + 1); str = (char*)malloc(len + 1);
to_camel(tag, str); to_camel_cc(tag, str);
str[len] = 0; str[len] = 0;
return(str); return(str);
} }
char style_index_function_start[] = static void
"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
generate_style(){ generate_style(){
char filename_4coder[] = "4coder_style.h"; char filename_4coder[] = "4coder_style.h";
char filename_4ed[] = "4ed_style.h"; char filename_4ed[] = "4ed_style.h";
FILE *file; char *tag = 0;
char *tag; int32_t count = 0, i = 0;
int32_t count, i;
file = fopen(filename_4coder, "wb"); String out = make_out_string(10 << 20);
enum_begin(file, "Style_Tag"); Out_Context context = {0};
if (begin_file_out(&context, filename_4coder, &out)){
enum_begin(&out, "Style_Tag");
{ {
count = ArrayCount(bar_style_fields); count = ArrayCount(bar_style_fields);
for (i = 0; i < count; ++i){ for (i = 0; i < count; ++i){
tag = make_style_tag(bar_style_fields[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); free(tag);
} }
count = ArrayCount(main_style_fields); count = ArrayCount(main_style_fields);
for (i = 0; i < count; ++i){ for (i = 0; i < count; ++i){
tag = make_style_tag(main_style_fields[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); free(tag);
} }
} }
struct_end(file); struct_end(&out);
fclose(file);
file = fopen(filename_4ed, "wb"); end_file_out(context);
struct_begin(file, "Interactive_Style"); }
if (begin_file_out(&context, filename_4ed, &out)){
struct_begin(&out, "Interactive_Style");
{ {
count = ArrayCount(bar_style_fields); count = ArrayCount(bar_style_fields);
for (i = 0; i < count; ++i){ 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); count = ArrayCount(main_style_fields);
for (i = 0; i < count; ++i){ 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); count = ArrayCount(bar_style_fields);
for (i = 0; i < count; ++i){ for (i = 0; i < count; ++i){
tag = make_style_tag(bar_style_fields[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); free(tag);
} }
count = ArrayCount(main_style_fields); count = ArrayCount(main_style_fields);
for (i = 0; i < count; ++i){ for (i = 0; i < count; ++i){
tag = make_style_tag(main_style_fields[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); 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{ typedef struct Argument_Breakdown{
int32_t count; int32_t count;
String *param_string; Argument *args;
String *param_name;
} Argument_Breakdown; } Argument_Breakdown;
typedef struct Documentation{ typedef struct Documentation{
@ -306,26 +342,32 @@ typedef struct Documentation{
String *see_also; String *see_also;
} Documentation; } Documentation;
typedef struct App_API{ enum{
String *macros; Item_Null,
String *public_name; Item_Function,
} App_API; 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{ typedef struct Function_Set{
String *name; Item_Node *funcs;
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;
} Function_Set; } Function_Set;
typedef struct Typedef_Set{ typedef struct Typedef_Set{
@ -361,15 +403,9 @@ typedef struct Enum_Set{
String *doc_string; String *doc_string;
} Enum_Set; } Enum_Set;
void static Item_Node null_item_node = {0};
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;
}
String static String
file_dump(char *filename){ file_dump(char *filename){
String result = {0}; String result = {0};
FILE *file = fopen(filename, "rb"); FILE *file = fopen(filename, "rb");
@ -391,7 +427,7 @@ file_dump(char *filename){
return(result); return(result);
} }
String static String
get_first_line(String source){ get_first_line(String source){
String line = {0}; String line = {0};
int32_t pos = find_s_char(source, 0, '\n'); int32_t pos = find_s_char(source, 0, '\n');
@ -399,7 +435,7 @@ get_first_line(String source){
return(line); return(line);
} }
String static String
get_next_line(String source, String line){ get_next_line(String source, String line){
String next = {0}; String next = {0};
int32_t pos = (int32_t)(line.str - source.str) + line.size; int32_t pos = (int32_t)(line.str - source.str) + line.size;
@ -455,12 +491,12 @@ check_and_fix_docs(String *lexeme){
return(result); return(result);
} }
enum Doc_Note_Type{ typedef enum Doc_Note_Type{
DOC_PARAM, DOC_PARAM,
DOC_RETURN, DOC_RETURN,
DOC, DOC,
DOC_SEE DOC_SEE
}; } Doc_Note_Type;
static String static String
doc_note_string[] = { doc_note_string[] = {
@ -470,7 +506,7 @@ doc_note_string[] = {
make_lit_string("DOC_SEE"), make_lit_string("DOC_SEE"),
}; };
String static String
doc_parse_note(String source, int32_t *pos){ doc_parse_note(String source, int32_t *pos){
String result = {0}; String result = {0};
@ -490,7 +526,7 @@ doc_parse_note(String source, int32_t *pos){
return(result); return(result);
} }
String static String
doc_parse_note_string(String source, int32_t *pos){ doc_parse_note_string(String source, int32_t *pos){
String result = {0}; String result = {0};
@ -524,7 +560,7 @@ doc_parse_note_string(String source, int32_t *pos){
return(result); return(result);
} }
String static String
doc_parse_parameter(String source, int32_t *pos){ doc_parse_parameter(String source, int32_t *pos){
String result = {0}; String result = {0};
@ -942,7 +978,7 @@ print_struct_html(FILE *file, Struct_Member *member){
static void static void
print_function_html(FILE *file, Function_Set function_set, int32_t i, String name, print_function_html(FILE *file, Function_Set function_set, int32_t i, String name,
char *function_call_head){ char *function_call_head){
String ret = function_set.ret[i]; String ret = function_set.funcs[i].ret;
fprintf(file, fprintf(file,
"%.*s %s%.*s(\n" "%.*s %s%.*s(\n"
"<div style='margin-left: 4mm;'>", "<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, function_call_head,
name.size, name.str); 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; int32_t arg_count = breakdown->count;
for (int32_t j = 0; j < arg_count; ++j){ 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){ if (j < arg_count - 1){
fprintf(file, "%.*s,<br>", param_string.size, param_string.str); 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 static void
print_macro_html(FILE *file, Function_Set function_set, int32_t i, String name){ 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; int32_t arg_count = breakdown->count;
if (arg_count == 0){ if (arg_count == 0){
fprintf(file, fprintf(file,
@ -975,7 +1011,7 @@ print_macro_html(FILE *file, Function_Set function_set, int32_t i, String name){
name.size, name.str); name.size, name.str);
} }
else if (arg_count == 1){ else if (arg_count == 1){
String param_string = breakdown->param_string[0]; String param_string = breakdown->args[0].param_string;
fprintf(file, fprintf(file,
"#define %.*s(%.*s)", "#define %.*s(%.*s)",
name.size, name.str, 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); name.size, name.str);
for (int32_t j = 0; j < arg_count; ++j){ 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){ if (j < arg_count - 1){
fprintf(file, "%.*s,<br>", param_string.size, param_string.str); fprintf(file, "%.*s,<br>", param_string.size, param_string.str);
} }
@ -1186,52 +1222,22 @@ parse_enum(Partition *part, char *data,
return(result); 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 static Function_Set
allocate_function_set(int32_t count){ allocate_function_set(int32_t count){
Function_Set function_set = {0}; Function_Set function_set = {0};
int32_t memory_size = (sizeof(String)*7 + int32_t memory_size = sizeof(Item_Node)*count;
sizeof(int32_t)*2 + function_set.funcs = (Item_Node*)malloc(memory_size);
sizeof(Argument_Breakdown) + memset(function_set.funcs, 0, memory_size);
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);
return(function_set); return(function_set);
} }
static Argument_Breakdown static Argument_Breakdown
allocate_argument_breakdown(int32_t count){ allocate_argument_breakdown(int32_t count){
Argument_Breakdown breakdown = {0}; Argument_Breakdown breakdown = {0};
int32_t memory_size = (sizeof(String)*2)*count; int32_t memory_size = sizeof(Argument)*count;
breakdown.count = count; breakdown.count = count;
breakdown.param_string = (String*)malloc(memory_size); breakdown.args = (Argument*)malloc(memory_size);
breakdown.param_name = breakdown.param_string + count; memset(breakdown.args, 0, memory_size);
memset(breakdown.param_string, 0, memory_size);
return(breakdown); 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; int32_t size = arg_token->start - param_string_start;
String param_string = make_string(data + param_string_start, size); String param_string = make_string(data + param_string_start, size);
param_string = chop_whitespace(param_string); 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; for (Cpp_Token *param_name_token = arg_token - 1;
param_name_token->start > param_string_start; 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){ if (param_name_token->type == CPP_TOKEN_IDENTIFIER){
int32_t start = param_name_token->start; int32_t start = param_name_token->start;
int32_t size = param_name_token->size; 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; 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; 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; int32_t size = token->start - ret_start_token->start;
String ret = make_string(data + ret_start_token->start, size); String ret = make_string(data + ret_start_token->start, size);
ret = chop_whitespace(ret); ret = chop_whitespace(ret);
function_set.ret[sig_count] = ret; function_set.funcs[sig_count].ret = ret;
for (; i < count; ++i, ++token){ for (; i < count; ++i, ++token){
if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){ 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){ if (i < count){
int32_t size = token->start + token->size - args_start_token->start;; 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); make_string(data + args_start_token->start, size);
function_set.valid[sig_count] = true; function_set.funcs[sig_count].t = Item_Function;
result = true; 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); *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; *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; 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; int32_t j = i;
Cpp_Token *jtoken = token; 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){ if (token->type == CPP_TOKEN_IDENTIFIER){
String doc_string = {0}; String doc_string = {0};
if (do_function_get_doc(&j, &jtoken, count, data, &doc_string)){ 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); String doc_string = make_string(data + doc_token->start, doc_token->size);
if (check_and_fix_docs(&doc_string)){ 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){ for (; i < count; ++i, ++token){
if (token->type == CPP_TOKEN_IDENTIFIER){ 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)){ 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; ++i, ++token;
if (i < count){ if (i < count){
@ -1529,9 +1535,9 @@ do_macro_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count,
if (i < count){ if (i < count){
int32_t start = args_start_token->start; int32_t start = args_start_token->start;
int32_t end = token->start + token->size; 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); *breakdown = do_parameter_parse(data, args_start_token, token);
++i, ++token; ++i, ++token;
@ -1551,12 +1557,11 @@ do_macro_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count,
start = body_start->start; start = body_start->start;
end = body_end->start + body_end->size; 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.funcs[sig_count].t = Item_Macro;
macro_set.valid[sig_count] = true;
result = true; result = true;
} }
} }
@ -1570,12 +1575,12 @@ do_macro_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count,
return(result); return(result);
} }
struct String_Function_Marker{ typedef struct String_Function_Marker{
int32_t parse_function; int32_t parse_function;
int32_t is_inline; int32_t is_inline;
int32_t parse_doc; int32_t parse_doc;
int32_t cpp_name; int32_t cpp_name;
}; } String_Function_Marker;
static String_Function_Marker static String_Function_Marker
do_string_function_marker_check(String lexeme){ 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); 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(){ generate_custom_headers(){
#define API_H "4coder_custom_api.h" #define API_H "4coder_custom_api.h"
#define OS_API_H "4ed_os_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); 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 = 0;
int32_t sig_count_per_file[2]; int32_t sig_count_per_file[2];
@ -1891,8 +1914,8 @@ generate_custom_headers(){
if (match_ss(lexeme, make_lit_string("API_EXPORT"))){ if (match_ss(lexeme, make_lit_string("API_EXPORT"))){
do_full_function_parse(&i, &token, count, data, function_set, do_full_function_parse(&i, &token, count, data, function_set,
sig_count, string_zero()); sig_count, string_zero());
if (!function_set.valid[sig_count]){ if (function_set.funcs[sig_count].t == Item_Null){
zero_index(function_set, sig_count); function_set.funcs[sig_count] = null_item_node;
// TODO(allen): get warning file name and line numbers // TODO(allen): get warning file name and line numbers
fprintf(stderr, "generator warning : invalid function signature\n"); fprintf(stderr, "generator warning : invalid function signature\n");
} }
@ -1905,9 +1928,9 @@ generate_custom_headers(){
} }
for (int32_t i = 0; i < sig_count; ++i){ for (int32_t i = 0; i < sig_count; ++i){
String name_string = function_set.name[i]; String name_string = function_set.funcs[i].name;
String *macro = app_function_set.macros + i; String *macro = &func_4ed_names.names[i].macro;
String *public_name = app_function_set.public_name + i; String *public_name = &func_4ed_names.names[i].public_name;
macro->size = 0; macro->size = 0;
macro->memory_size = name_string.size+4; macro->memory_size = name_string.size+4;
@ -1931,9 +1954,9 @@ generate_custom_headers(){
int32_t main_api_count = sig_count_per_file[0]; int32_t main_api_count = sig_count_per_file[0];
for (int32_t i = main_api_count; i < sig_count; ++i){ for (int32_t i = main_api_count; i < sig_count; ++i){
String ret_string = function_set.ret[i]; String ret_string = function_set.funcs[i].ret;
String args_string = function_set.args[i]; String args_string = function_set.funcs[i].args;
String macro_string = app_function_set.macros[i]; String macro_string = func_4ed_names.names[i].macro;
fprintf(file, "#define %.*s(n) %.*s n%.*s\n", fprintf(file, "#define %.*s(n) %.*s n%.*s\n",
macro_string.size, macro_string.str, macro_string.size, macro_string.str,
@ -1942,8 +1965,8 @@ generate_custom_headers(){
} }
for (int32_t i = main_api_count; i < sig_count; ++i){ for (int32_t i = main_api_count; i < sig_count; ++i){
String name_string = function_set.name[i]; String name_string = function_set.funcs[i].name;
String macro_string = app_function_set.macros[i]; String macro_string = func_4ed_names.names[i].macro;
fprintf(file, "typedef %.*s(%.*s_Function);\n", fprintf(file, "typedef %.*s(%.*s_Function);\n",
macro_string.size, macro_string.str, macro_string.size, macro_string.str,
@ -1955,9 +1978,9 @@ generate_custom_headers(){
file = fopen(API_H, "wb"); file = fopen(API_H, "wb");
for (int32_t i = 0; i < sig_count; ++i){ for (int32_t i = 0; i < sig_count; ++i){
String ret_string = function_set.ret[i]; String ret_string = function_set.funcs[i].ret;
String args_string = function_set.args[i]; String args_string = function_set.funcs[i].args;
String macro_string = app_function_set.macros[i]; String macro_string = func_4ed_names.names[i].macro;
fprintf(file, "#define %.*s(n) %.*s n%.*s\n", fprintf(file, "#define %.*s(n) %.*s n%.*s\n",
macro_string.size, macro_string.str, macro_string.size, macro_string.str,
@ -1966,8 +1989,8 @@ generate_custom_headers(){
} }
for (int32_t i = 0; i < sig_count; ++i){ for (int32_t i = 0; i < sig_count; ++i){
String name_string = function_set.name[i]; String name_string = function_set.funcs[i].name;
String macro_string = app_function_set.macros[i]; String macro_string = func_4ed_names.names[i].macro;
fprintf(file, "typedef %.*s(%.*s_Function);\n", fprintf(file, "typedef %.*s(%.*s_Function);\n",
macro_string.size, macro_string.str, macro_string.size, macro_string.str,
@ -1980,8 +2003,8 @@ generate_custom_headers(){
" int32_t memory_size;\n" " int32_t memory_size;\n"
); );
for (int32_t i = 0; i < sig_count; ++i){ for (int32_t i = 0; i < sig_count; ++i){
String name_string = function_set.name[i]; String name_string = function_set.funcs[i].name;
String public_string = app_function_set.public_name[i]; String public_string = func_4ed_names.names[i].public_name;
fprintf(file, " %.*s_Function *%.*s;\n", fprintf(file, " %.*s_Function *%.*s;\n",
name_string.size, name_string.str, name_string.size, name_string.str,
@ -1997,8 +2020,8 @@ generate_custom_headers(){
fprintf(file, "#define FillAppLinksAPI(app_links) do{"); fprintf(file, "#define FillAppLinksAPI(app_links) do{");
for (int32_t i = 0; i < sig_count; ++i){ for (int32_t i = 0; i < sig_count; ++i){
String name = function_set.name[i]; String name = function_set.funcs[i].name;
String public_string = app_function_set.public_name[i]; String public_string = func_4ed_names.names[i].public_name;
fprintf(file, fprintf(file,
"\\\n" "\\\n"
@ -2282,11 +2305,11 @@ generate_custom_headers(){
char line_space[2048]; char line_space[2048];
String line = make_fixed_width_string(line_space); String line = make_fixed_width_string(line_space);
if (!string_function_set.is_macro[j]){ if (string_function_set.funcs[j].t != Item_Macro){
String marker = string_function_set.marker[j]; String marker = string_function_set.funcs[j].marker;
String ret = string_function_set.ret[j]; String ret = string_function_set.funcs[j].ret;
String name = string_function_set.name[j]; String name = string_function_set.funcs[j].name;
String args = string_function_set.args[j]; String args = string_function_set.funcs[j].args;
append_ss(&line, marker); append_ss(&line, marker);
append_padding(&line, ' ', RETURN_PADDING); append_padding(&line, ' ', RETURN_PADDING);
@ -2299,9 +2322,9 @@ generate_custom_headers(){
fprintf(file, "%s;\n", line.str); fprintf(file, "%s;\n", line.str);
} }
else{ else{
String name = string_function_set.name[j]; String name = string_function_set.funcs[j].name;
String args = string_function_set.args[j]; String args = string_function_set.funcs[j].args;
String body = string_function_set.body[j]; String body = string_function_set.funcs[j].body;
append_ss(&line, make_lit_string("#ifndef ")); append_ss(&line, make_lit_string("#ifndef "));
append_padding(&line, ' ', 10); append_padding(&line, ' ', 10);
@ -2336,11 +2359,11 @@ generate_custom_headers(){
char line_space[2048]; char line_space[2048];
String line = make_fixed_width_string(line_space); String line = make_fixed_width_string(line_space);
if (!string_function_set.is_macro[j]){ if (string_function_set.funcs[j].t != Item_Macro){
String cpp_name = string_function_set.cpp_name[j]; String cpp_name = string_function_set.funcs[j].cpp_name;
if (cpp_name.str != 0){ if (cpp_name.str != 0){
String ret = string_function_set.ret[j]; String ret = string_function_set.funcs[j].ret;
String args = string_function_set.args[j]; String args = string_function_set.funcs[j].args;
append_ss(&line, make_lit_string("FSTRING_INLINE")); append_ss(&line, make_lit_string("FSTRING_INLINE"));
append_padding(&line, ' ', RETURN_PADDING); append_padding(&line, ' ', RETURN_PADDING);
@ -2367,13 +2390,13 @@ generate_custom_headers(){
char line_space[2048]; char line_space[2048];
String line = make_fixed_width_string(line_space); String line = make_fixed_width_string(line_space);
if (!string_function_set.is_macro[j]){ if (string_function_set.funcs[j].t != Item_Macro){
String cpp_name = string_function_set.cpp_name[j]; String cpp_name = string_function_set.funcs[j].cpp_name;
if (cpp_name.str != 0){ if (cpp_name.str != 0){
String name = string_function_set.name[j]; String name = string_function_set.funcs[j].name;
String ret = string_function_set.ret[j]; String ret = string_function_set.funcs[j].ret;
String args = string_function_set.args[j]; String args = string_function_set.funcs[j].args;
Argument_Breakdown breakdown = string_function_set.breakdown[j]; Argument_Breakdown breakdown = string_function_set.funcs[j].breakdown;
append_ss(&line, make_lit_string("FSTRING_INLINE")); append_ss(&line, make_lit_string("FSTRING_INLINE"));
append_s_char(&line, ' '); append_s_char(&line, ' ');
@ -2395,7 +2418,7 @@ generate_custom_headers(){
if (i != 0){ if (i != 0){
append_s_char(&line, ','); append_s_char(&line, ',');
} }
append_ss(&line, breakdown.param_name[i]); append_ss(&line, breakdown.args[i].param_name);
} }
} }
else{ else{
@ -2644,7 +2667,7 @@ generate_custom_headers(){
"<ul>\n"); "<ul>\n");
for (int32_t i = 0; i < sig_count; ++i){ 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, fprintf(file,
"<li>" "<li>"
"<a href='#%.*s_doc'>%.*s</a>" "<a href='#%.*s_doc'>%.*s</a>"
@ -2714,7 +2737,7 @@ generate_custom_headers(){
fprintf(file, "<h3>&sect;"SECTION" Function Descriptions</h3>\n"); fprintf(file, "<h3>&sect;"SECTION" Function Descriptions</h3>\n");
for (int32_t i = 0; i < sig_count; ++i){ 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, fprintf(file,
"<div id='%.*s_doc' style='margin-bottom: 1cm;'>\n" "<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->"); print_function_html(file, function_set, i, name, "app->");
fprintf(file, "</div>\n"); 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); print_function_docs(file, part, name, doc_string);
fprintf(file, "</div><hr>\n"); fprintf(file, "</div><hr>\n");
@ -2990,7 +3013,7 @@ generate_custom_headers(){
} }
for (int32_t i = 0; i < string_sig_count; ++i){ 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 index = 0;
if (!string_set_match(used_strings, used_string_count, name, &index)){ if (!string_set_match(used_strings, used_string_count, name, &index)){
fprintf(file, fprintf(file,
@ -3015,7 +3038,7 @@ generate_custom_headers(){
"<ul>\n"); "<ul>\n");
for (int32_t i = 0; i < string_sig_count; ++i){ 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 index = 0;
int32_t do_id = false; int32_t do_id = false;
if (!string_set_match(used_strings, used_string_count, name, &index)){ 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", "<div style='"CODE_STYLE" "DESCRIPT_SECTION_STYLE"'>\n",
i+1, name.size, name.str); 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); print_macro_html(file, string_function_set, i, name);
} }
else{ else{
@ -3048,7 +3071,7 @@ generate_custom_headers(){
fprintf(file, "</div>\n"); 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); print_function_docs(file, part, name, doc_string);
fprintf(file, "</div><hr>\n"); fprintf(file, "</div><hr>\n");
@ -3064,7 +3087,6 @@ generate_custom_headers(){
fclose(file); fclose(file);
} }
} }
#endif
int main(int argc, char **argv){ int main(int argc, char **argv){
generate_keycode_enum(); generate_keycode_enum();

View File

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

View File

@ -1178,8 +1178,8 @@ CPP_NAME(to_upper)
FSTRING_LINK void FSTRING_LINK void
to_upper_cc(char *src, char *dst)/* 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(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 DOC_PARAM(dst, The destination buffer to receive the converted string.
enough to contain all of src and a null terminator.) 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 DOC(Rewrites the string in src into dst. src and dst should not overlap with the exception
that src and dst may be exactly equal in order to convert the string in place.) that src and dst may be exactly equal in order to convert the string in place.)
*/{ */{
@ -1192,7 +1192,7 @@ that src and dst may be exactly equal in order to convert the string in place.)
CPP_NAME(to_upper) CPP_NAME(to_upper)
FSTRING_LINK void FSTRING_LINK void
to_upper_ss(String *src, String *dst)/* to_upper_ss(String *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. DOC_PARAM(dst, The destination buffer to receive the converted string.
This must have a capacity of at least the size of src.) This must have a capacity of at least the size of src.)
DOC(Rewrites the string in src into dst. src and dst should not overlap with the exception DOC(Rewrites the string in src into dst. src and dst should not overlap with the exception
@ -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 // String <-> Number Conversions
// //