This call returns non-zero on success.
A call to exec_system_command executes a command as if called from the command line, and sends the output to
+
4coder API Docs
+
4coder API
Table of Contents
+
§1 Introduction
This is the documentation for alpha 4.0.11 The documentation is still under construction so some of the links are linking to sections that have not been written yet. What is here should be correct and I suspect useful even without some of the other sections.
If you have questions or discover errors please contact editor@4coder.net or to get help from community members you can post on the 4coder forums hosted on handmade.network at 4coder.handmade.network
+
§2 4coder Systems
Coming Soon
+
§3 Types and Functions
§3.1 Function List
§3.2 Type List
§3.3 Function Descriptions
§3.3.1: exec_command
bool32 app->exec_command(
Application_Links *app,
Command_ID command_id
)
Parameters
command_id
The command_id parameter specifies which internal command to execute.
Return
This call returns non-zero if command_id named a valid internal command.
Description
A call to exec_command executes an internal command.
+If command_id is invalid a warning is posted to *messages*.
See Also
§3.3.2: exec_system_command
bool32 app->exec_system_command(
Application_Links *app,
View_Summary *view,
Buffer_Identifier buffer,
char *path,
int32_t path_len,
char *command,
int32_t command_len,
Command_Line_Input_Flag flags
)
Parameters
view
If the view parameter is non-null it specifies a view to display the command's output buffer.
buffer
The buffer the command will output to is specified by the buffer parameter.
+See Buffer_Identifier for information on how this type specifies a buffer.
path
The path parameter specifies the path in which the command shall be executed. The string need not be null terminated.
path_len
The parameter path_len specifies the length of the path string.
command
The command parameter specifies the command that shall be executed. The string need not be null terminated.
command_len
The parameter command_len specifies the length of the command string.
flags
Flags for the behavior of the call are specified in the flags parameter.
Return
This call returns non-zero on success.
Description
A call to exec_system_command executes a command as if called from the command line, and sends the output to
a buffer. The buffer identifier can either name a new buffer that does not exist, name a buffer that does
exist, or provide the id of a buffer that does exist.
If the buffer is not already in an open view and the view parameter is not NULL,
then the provided view will display the output buffer.
-If the view parameter is NULL, no view will switch to the output.
See Also
-
-
§3.3.3: clipboard_post
-
void app->clipboard_post(
-
Application_Links *app,
int32_t clipboard_id,
char *str,
int32_t len
)
-
-
Parameters
-
clipboard_id
-
This parameter is set up to prepare for future features, it should always be 0 for now.
-
-
-
str
-
The str parameter specifies the string to be posted to the clipboard, it need not be null terminated.
-
-
-
len
-
The len parameter specifies the length of the str string.
-
-
Description
Stores the string str in the clipboard initially with index 0.
+If the view parameter is NULL, no view will switch to the output.
See Also
§3.3.3: clipboard_post
void app->clipboard_post(
Application_Links *app,
int32_t clipboard_id,
char *str,
int32_t len
)
Parameters
clipboard_id
This parameter is set up to prepare for future features, it should always be 0 for now.
str
The str parameter specifies the string to be posted to the clipboard, it need not be null terminated.
len
The len parameter specifies the length of the str string.
Description
Stores the string str in the clipboard initially with index 0.
Also reports the copy to the operating system, so that it may
-be pasted into other applications.
See Also
-
-
§3.3.4: clipboard_count
-
int32_t app->clipboard_count(
-
Application_Links *app,
int32_t clipboard_id
)
-
-
Parameters
-
clipboard_id
-
This parameter is set up to prepare for future features, it should always be 0 for now.
-
-
Description
This call returns the number of items in the clipboard.
See Also
-
-
§3.3.5: clipboard_index
-
int32_t app->clipboard_index(
-
Application_Links *app,
int32_t clipboard_id,
int32_t item_index,
char *out,
int32_t len
)
-
-
Parameters
-
clipboard_id
-
This parameter is set up to prepare for future features, it should always be 0 for now.
-
-
-
item_index
-
This parameter specifies which item to read, 0 is the most recent copy, 1 is the second most recent copy, etc.
-
-
-
out
-
This parameter provides a buffer where the clipboard contents are written. This parameter may be NULL.
-
-
-
len
-
This parameter specifies the length of the out buffer.
-
-
Return
This call returns the size of the item associated with item_index.
Description
This function always returns the size of the item even if the output buffer is NULL.
+be pasted into other applications.
See Also
§3.3.4: clipboard_count
int32_t app->clipboard_count(
Application_Links *app,
int32_t clipboard_id
)
Parameters
clipboard_id
This parameter is set up to prepare for future features, it should always be 0 for now.
Description
This call returns the number of items in the clipboard.
See Also
§3.3.5: clipboard_index
int32_t app->clipboard_index(
Application_Links *app,
int32_t clipboard_id,
int32_t item_index,
char *out,
int32_t len
)
Parameters
clipboard_id
This parameter is set up to prepare for future features, it should always be 0 for now.
item_index
This parameter specifies which item to read, 0 is the most recent copy, 1 is the second most recent copy, etc.
out
This parameter provides a buffer where the clipboard contents are written. This parameter may be NULL.
len
This parameter specifies the length of the out buffer.
Return
This call returns the size of the item associated with item_index.
Description
This function always returns the size of the item even if the output buffer is NULL.
If the output buffer is too small to contain the whole string, it is filled with the
-first len character of the clipboard contents. The output string is not null terminated.
See Also
-
-
§3.3.6: get_buffer_count
-
int32_t app->get_buffer_count(
-
Application_Links *app
)
-
-
Description
TODO
-
-
§3.3.7: get_buffer_first
-
Buffer_Summary app->get_buffer_first(
-
Application_Links *app,
Access_Flag access
)
-
-
Parameters
-
access
-
The access parameter determines what levels of protection this call can access.
-
-
Return
This call returns the summary of the first buffer in a buffer loop.
Description
This call begins a loop across all the buffers.
+first len character of the clipboard contents. The output string is not null terminated.
See Also
§3.3.6: get_buffer_count
int32_t app->get_buffer_count(
Application_Links *app
)
Description
TODO
§3.3.7: get_buffer_first
Buffer_Summary app->get_buffer_first(
Application_Links *app,
Access_Flag access
)
Parameters
access
The access parameter determines what levels of protection this call can access.
Return
This call returns the summary of the first buffer in a buffer loop.
Description
This call begins a loop across all the buffers.
If the buffer returned does not exist, the loop is finished.
-Buffers should not be killed durring a buffer loop.
See Also
-
-
§3.3.8: get_buffer_next
-
void app->get_buffer_next(
-
Application_Links *app,
Buffer_Summary *buffer,
Access_Flag access
)
-
-
Parameters
-
buffer
-
The Buffer_Summary pointed to by buffer is iterated to the next buffer or to a null summary if this is the last buffer.
-
-
-
access
-
The access parameter determines what levels of protection this call can access. The buffer outputted will be the next buffer that is accessible.
-
-
Description
This call steps a Buffer_Summary to the next buffer in the global buffer order.
+Buffers should not be killed durring a buffer loop.
See Also
§3.3.8: get_buffer_next
void app->get_buffer_next(
Application_Links *app,
Buffer_Summary *buffer,
Access_Flag access
)
Parameters
buffer
The Buffer_Summary pointed to by buffer is iterated to the next buffer or to a null summary if this is the last buffer.
access
The access parameter determines what levels of protection this call can access. The buffer outputted will be the next buffer that is accessible.
Description
This call steps a Buffer_Summary to the next buffer in the global buffer order.
The global buffer order is kept roughly in the order of most recently used to least recently used.
If the buffer outputted does not exist, the loop is finished.
-Buffers should not be killed or created durring a buffer loop.
See Also
-
-
§3.3.9: get_buffer
-
Buffer_Summary app->get_buffer(
-
Application_Links *app,
Buffer_ID buffer_id,
Access_Flag access
)
-
-
Parameters
-
buffer_id
-
The parameter buffer_id specifies which buffer to try to get.
-
-
-
access
-
The access parameter determines what levels of protection this call can access.
-
-
Return
This call returns a summary that describes the indicated buffer if it exists and is accessible.
See Also
-
-
§3.3.10: get_buffer_by_name
-
Buffer_Summary app->get_buffer_by_name(
-
Application_Links *app,
char *name,
int32_t len,
Access_Flag access
)
-
-
Parameters
-
name
-
The name parameter specifies the buffer name to try to get. The string need not be null terminated.
-
-
-
len
-
The len parameter specifies the length of the name string.
-
-
-
access
-
The access parameter determines what levels of protection this call can access.
-
-
Return
This call returns a summary that describes the indicated buffer if it exists and is accessible.
See Also
-
-
§3.3.11: buffer_boundary_seek
-
int32_t app->buffer_boundary_seek(
-
Application_Links *app,
Buffer_Summary *buffer,
int32_t start_pos,
bool32 seek_forward,
Seek_Boundary_Flag flags
)
-
-
Parameters
-
buffer
-
The buffer parameter specifies the buffer through which to seek.
-
-
-
start_pos
-
The beginning position of the seek is specified by start_pos measured in absolute position.
-
-
-
seek_forward
-
If this parameter is non-zero it indicates that the seek should move foward through the buffer.
-
-
-
flags
-
This field specifies the types of boundaries at which the seek should stop.
-
-
Return
This call returns the absolute position where the seek stopped.
+Buffers should not be killed or created durring a buffer loop.
See Also
§3.3.9: get_buffer
Buffer_Summary app->get_buffer(
Application_Links *app,
Buffer_ID buffer_id,
Access_Flag access
)
Parameters
buffer_id
The parameter buffer_id specifies which buffer to try to get.
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the indicated buffer if it exists and is accessible.
See Also
§3.3.10: get_buffer_by_name
Buffer_Summary app->get_buffer_by_name(
Application_Links *app,
char *name,
int32_t len,
Access_Flag access
)
Parameters
name
The name parameter specifies the buffer name to try to get. The string need not be null terminated.
len
The len parameter specifies the length of the name string.
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the indicated buffer if it exists and is accessible.
See Also
§3.3.11: buffer_boundary_seek
int32_t app->buffer_boundary_seek(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start_pos,
bool32 seek_forward,
Seek_Boundary_Flag flags
)
Parameters
buffer
The buffer parameter specifies the buffer through which to seek.
start_pos
The beginning position of the seek is specified by start_pos measured in absolute position.
seek_forward
If this parameter is non-zero it indicates that the seek should move foward through the buffer.
flags
This field specifies the types of boundaries at which the seek should stop.
Return
This call returns the absolute position where the seek stopped.
If the seek goes below 0 the returned value is -1.
-If the seek goes past the end the returned value is the size of the buffer.
See Also
-
-
§3.3.12: buffer_read_range
-
bool32 app->buffer_read_range(
-
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
char *out
)
-
-
Parameters
-
buffer
-
This parameter specifies the buffer to read.
-
-
-
start
-
This parameter specifies absolute position of the first character in the read range.
-
-
-
end
-
This parameter specifies the absolute position of the the character one past the end of the read range.
-
-
-
out
-
This paramter provides the output character buffer to fill with the result of the read.
-
-
Return
This call returns non-zero if the read succeeds.
Description
The output buffer must have a capacity of at least (end - start).
+If the seek goes past the end the returned value is the size of the buffer.
See Also
§3.3.12: buffer_read_range
bool32 app->buffer_read_range(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
char *out
)
Parameters
buffer
This parameter specifies the buffer to read.
start
This parameter specifies absolute position of the first character in the read range.
end
This parameter specifies the absolute position of the the character one past the end of the read range.
out
This paramter provides the output character buffer to fill with the result of the read.
Return
This call returns non-zero if the read succeeds.
Description
The output buffer must have a capacity of at least (end - start).
The output is not null terminated.
This call fails if the buffer does not exist,
-or if the read range is not within the bounds of the buffer.
See Also
-
-
§3.3.13: buffer_replace_range
-
bool32 app->buffer_replace_range(
-
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
char *str,
int32_t len
)
-
-
Parameters
-
buffer
-
This parameter specifies the buffer to edit.
-
-
-
start
-
This parameter specifies absolute position of the first character in the replace range.
-
-
-
end
-
This parameter specifies the absolute position of the the character one past the end of the replace range.
-
-
-
str
-
This parameter specifies the the string to write into the range; it need not be null terminated.
-
-
-
len
-
This parameter specifies the length of the str string.
-
-
Return
This call returns non-zero if the replacement succeeds.
Description
If this call succeeds it deletes the range from start to end
+or if the read range is not within the bounds of the buffer.
See Also
§3.3.13: buffer_replace_range
bool32 app->buffer_replace_range(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
char *str,
int32_t len
)
Parameters
buffer
This parameter specifies the buffer to edit.
start
This parameter specifies absolute position of the first character in the replace range.
end
This parameter specifies the absolute position of the the character one past the end of the replace range.
str
This parameter specifies the the string to write into the range; it need not be null terminated.
len
This parameter specifies the length of the str string.
Return
This call returns non-zero if the replacement succeeds.
Description
If this call succeeds it deletes the range from start to end
and writes str in the same position. If end == start then
this call is equivalent to inserting the string at start.
If len == 0 this call is equivalent to deleteing the range
from start to end.
This call fails if the buffer does not exist, or if the replace
-range is not within the bounds of the buffer.
See Also
-
-
§3.3.14: buffer_compute_cursor
-
bool32 app->buffer_compute_cursor(
-
Application_Links *app,
Buffer_Summary *buffer,
Buffer_Seek seek,
Partial_Cursor *cursor_out
)
-
-
Parameters
-
buffer
-
The buffer parameter specifies the buffer on which to run the cursor computation.
-
-
-
seek
-
The seek parameter specifies the target position for the seek.
-
-
-
cursor_out
-
On success this struct is filled with the result of the seek.
-
-
Return
This call returns non-zero on success.
Description
Computes a Partial_Cursor for the given seek position with no side effects.
+range is not within the bounds of the buffer.
See Also
§3.3.14: buffer_compute_cursor
bool32 app->buffer_compute_cursor(
Application_Links *app,
Buffer_Summary *buffer,
Buffer_Seek seek,
Partial_Cursor *cursor_out
)
Parameters
buffer
The buffer parameter specifies the buffer on which to run the cursor computation.
seek
The seek parameter specifies the target position for the seek.
cursor_out
On success this struct is filled with the result of the seek.
Return
This call returns non-zero on success.
Description
Computes a Partial_Cursor for the given seek position with no side effects.
The seek position must be one of the types supported by Partial_Cursor. Those
-types are absolute position and line,column position.
See Also
-
-
§3.3.15: buffer_batch_edit
-
bool32 app->buffer_batch_edit(
-
Application_Links *app,
Buffer_Summary *buffer,
char *str,
int32_t str_len,
Buffer_Edit *edits,
int32_t edit_count,
Buffer_Batch_Edit_Type type
)
-
-
Parameters
-
str
-
This parameter provides all of the source string for the edits in the batch.
-
-
-
str_len
-
This parameter specifies the length of the str string.
-
-
-
edits
-
This parameter provides about the source string and destination range of each edit as an array.
-
-
-
edit_count
-
This parameter specifies the number of Buffer_Edit structs in edits.
-
-
-
type
-
This prameter specifies what type of batch edit to execute.
-
-
Return
This call returns non-zero if the batch edit succeeds.
Description
TODO
See Also
-
-
§3.3.16: buffer_set_setting
-
bool32 app->buffer_set_setting(
-
Application_Links *app,
Buffer_Summary *buffer,
Buffer_Setting_ID setting,
int32_t value
)
-
-
Parameters
-
buffer
-
The buffer parameter specifies the buffer on which to set a setting.
-
-
-
setting
-
The setting parameter identifies the setting that shall be changed.
-
-
-
value
-
The value parameter specifies the value to which the setting shall be changed.
-
-
See Also
-
-
§3.3.17: buffer_auto_indent
-
bool32 app->buffer_auto_indent(
-
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
int32_t tab_width,
Auto_Indent_Flag flags
)
-
-
Parameters
-
buffer
-
The buffer specifies the buffer in which to apply auto indentation.
-
-
-
start
-
This parameter specifies the absolute position of the start of the indentation range.
-
-
-
end
-
This parameter specifies the absolute position of the end of the indentation range.
-
-
-
tab_width
-
The tab_width parameter specifies how many spaces should be used for one indentation in space mode.
-
-
-
flags
-
This parameter specifies behaviors for the indentation.
-
-
Return
This call returns non-zero when the call succeeds.
Description
Applies the built in auto-indentation rule to the code in the range from
+types are absolute position and line,column position.
See Also
§3.3.15: buffer_batch_edit
bool32 app->buffer_batch_edit(
Application_Links *app,
Buffer_Summary *buffer,
char *str,
int32_t str_len,
Buffer_Edit *edits,
int32_t edit_count,
Buffer_Batch_Edit_Type type
)
Parameters
str
This parameter provides all of the source string for the edits in the batch.
str_len
This parameter specifies the length of the str string.
edits
This parameter provides about the source string and destination range of each edit as an array.
edit_count
This parameter specifies the number of Buffer_Edit structs in edits.
type
This prameter specifies what type of batch edit to execute.
Return
This call returns non-zero if the batch edit succeeds.
Description
TODO
See Also
§3.3.16: buffer_set_setting
bool32 app->buffer_set_setting(
Application_Links *app,
Buffer_Summary *buffer,
Buffer_Setting_ID setting,
int32_t value
)
Parameters
buffer
The buffer parameter specifies the buffer on which to set a setting.
setting
The setting parameter identifies the setting that shall be changed.
value
The value parameter specifies the value to which the setting shall be changed.
See Also
§3.3.17: buffer_auto_indent
bool32 app->buffer_auto_indent(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
int32_t tab_width,
Auto_Indent_Flag flags
)
Parameters
buffer
The buffer specifies the buffer in which to apply auto indentation.
start
This parameter specifies the absolute position of the start of the indentation range.
end
This parameter specifies the absolute position of the end of the indentation range.
tab_width
The tab_width parameter specifies how many spaces should be used for one indentation in space mode.
flags
This parameter specifies behaviors for the indentation.
Return
This call returns non-zero when the call succeeds.
Description
Applies the built in auto-indentation rule to the code in the range from
start to end by inserting spaces or tabs at the beginning of the lines.
If the buffer does not have lexing enabled or the lexing job has not
-completed this function will fail.
See Also
-
-
§3.3.18: create_buffer
-
Buffer_Summary app->create_buffer(
-
Application_Links *app,
char *filename,
int32_t filename_len,
Buffer_Create_Flag flags
)
-
-
Parameters
-
filename
-
The filename parameter specifies the name of the file to be opened or created; it need not be null terminated.
-
-
-
filename_len
-
The filename_len parameter spcifies the length of the filename string.
-
-
-
flags
-
The flags parameter specifies behaviors for buffer creation.
-
-
Return
This call returns the summary of the created buffer.
Description
Tries to create a new buffer and associate it to the given filename. If such a buffer already
+completed this function will fail.
See Also
§3.3.18: create_buffer
Buffer_Summary app->create_buffer(
Application_Links *app,
char *filename,
int32_t filename_len,
Buffer_Create_Flag flags
)
Parameters
filename
The filename parameter specifies the name of the file to be opened or created; it need not be null terminated.
filename_len
The filename_len parameter spcifies the length of the filename string.
flags
The flags parameter specifies behaviors for buffer creation.
Return
This call returns the summary of the created buffer.
Description
Tries to create a new buffer and associate it to the given filename. If such a buffer already
exists the existing buffer is returned in the Buffer_Summary and no new buffer is created.
If the buffer does not exist a new buffer is created and named after the given filename. If
the filename corresponds to a file on the disk that file is loaded and put into buffer, if
-the filename does not correspond to a file on disk the buffer is created empty.
See Also
-
-
§3.3.19: save_buffer
-
bool32 app->save_buffer(
-
Application_Links *app,
Buffer_Summary *buffer,
char *filename,
int32_t filename_len,
uint32_t flags
)
-
-
Parameters
-
buffer
-
The buffer parameter specifies the buffer to save to a file.
-
-
-
filename
-
The filename parameter specifies the name of the file to associated to the buffer; it need not be null terminated.
-
-
-
filename_len
-
The filename_len parameter specifies the length of the filename string.
-
-
-
flags
-
This parameter is not currently used and should be set to 0 for now.
-
-
Return
This call returns non-zero on success.
-
-
§3.3.20: kill_buffer
-
bool32 app->kill_buffer(
-
Application_Links *app,
Buffer_Identifier buffer,
View_ID view_id,
Buffer_Kill_Flag flags
)
-
-
Parameters
-
buffer
-
The buffer parameter specifies the buffer to try to kill.
-
-
-
view_id
-
The view_id parameter specifies the view that will contain the "are you sure" dialogue if the buffer is dirty.
-
-
-
flags
-
The flags parameter specifies behaviors for the buffer kill.
-
-
Return
This call returns non-zero if the buffer is killed.
Description
Tries to kill the idenfied buffer. If the buffer is dirty and the "are you sure"
+the filename does not correspond to a file on disk the buffer is created empty.
See Also
§3.3.19: save_buffer
bool32 app->save_buffer(
Application_Links *app,
Buffer_Summary *buffer,
char *filename,
int32_t filename_len,
uint32_t flags
)
Parameters
buffer
The buffer parameter specifies the buffer to save to a file.
filename
The filename parameter specifies the name of the file to associated to the buffer; it need not be null terminated.
filename_len
The filename_len parameter specifies the length of the filename string.
flags
This parameter is not currently used and should be set to 0 for now.
Return
This call returns non-zero on success.
§3.3.20: kill_buffer
bool32 app->kill_buffer(
Application_Links *app,
Buffer_Identifier buffer,
View_ID view_id,
Buffer_Kill_Flag flags
)
Parameters
buffer
The buffer parameter specifies the buffer to try to kill.
view_id
The view_id parameter specifies the view that will contain the "are you sure" dialogue if the buffer is dirty.
flags
The flags parameter specifies behaviors for the buffer kill.
Return
This call returns non-zero if the buffer is killed.
Description
Tries to kill the idenfied buffer. If the buffer is dirty and the "are you sure"
dialogue needs to be displayed the provided view is used to show the dialogue.
-If the view is not open the kill fails.
See Also
-
-
§3.3.21: get_view_first
-
View_Summary app->get_view_first(
-
Application_Links *app,
Access_Flag access
)
-
-
Parameters
-
access
-
The access parameter determines what levels of protection this call can access.
-
-
Return
This call returns the summary of the first view in a view loop.
Description
This call begins a loop across all the open views.
+If the view is not open the kill fails.
See Also
§3.3.21: get_view_first
View_Summary app->get_view_first(
Application_Links *app,
Access_Flag access
)
Parameters
access
The access parameter determines what levels of protection this call can access.
Return
This call returns the summary of the first view in a view loop.
Description
This call begins a loop across all the open views.
If the View_Summary returned is a null summary, the loop is finished.
-Views should not be closed or opened durring a view loop.
See Also
-
-
§3.3.22: get_view_next
-
void app->get_view_next(
-
Application_Links *app,
View_Summary *view,
Access_Flag access
)
-
-
Parameters
-
view
-
The View_Summary pointed to by view is iterated to the next view or to a null summary if this is the last view.
-
-
-
access
-
The access parameter determines what levels of protection this call can access. The view outputted will be the next view that is accessible.
-
-
Description
This call steps a View_Summary to the next view in the global view order.
+Views should not be closed or opened durring a view loop.
See Also
§3.3.22: get_view_next
void app->get_view_next(
Application_Links *app,
View_Summary *view,
Access_Flag access
)
Parameters
view
The View_Summary pointed to by view is iterated to the next view or to a null summary if this is the last view.
access
The access parameter determines what levels of protection this call can access. The view outputted will be the next view that is accessible.
Description
This call steps a View_Summary to the next view in the global view order.
If the view outputted does not exist, the loop is finished.
-Views should not be closed or opened durring a view loop.
See Also
-
-
§3.3.23: get_view
-
View_Summary app->get_view(
-
Application_Links *app,
View_ID view_id,
Access_Flag access
)
-
-
Parameters
-
view_id
-
The view_id specifies the view to try to get.
-
-
-
access
-
The access parameter determines what levels of protection this call can access.
-
-
Return
This call returns a summary that describes the indicated view if it is open and accessible.
See Also
-
-
§3.3.24: get_active_view
-
View_Summary app->get_active_view(
-
Application_Links *app,
Access_Flag access
)
-
-
Parameters
-
access
-
The access parameter determines what levels of protection this call can access.
-
-
Return
This call returns a summary that describes the active view.
See Also
-
-
§3.3.25: open_view
-
View_Summary app->open_view(
-
Application_Links *app,
View_Summary *view_location,
View_Split_Position position
)
-
-
Parameters
-
view_location
-
The view_location parameter specifies the view to split to open the new view.
-
-
-
position
-
The position parameter specifies how to split the view and where to place the new view.
-
-
Return
If this call succeeds it returns a View_Summary describing the newly created view, if it fails it
+Views should not be closed or opened durring a view loop.
See Also
§3.3.23: get_view
View_Summary app->get_view(
Application_Links *app,
View_ID view_id,
Access_Flag access
)
Parameters
view_id
The view_id specifies the view to try to get.
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the indicated view if it is open and accessible.
See Also
§3.3.24: get_active_view
View_Summary app->get_active_view(
Application_Links *app,
Access_Flag access
)
Parameters
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the active view.
See Also
§3.3.25: open_view
View_Summary app->open_view(
Application_Links *app,
View_Summary *view_location,
View_Split_Position position
)
Parameters
view_location
The view_location parameter specifies the view to split to open the new view.
position
The position parameter specifies how to split the view and where to place the new view.
Return
If this call succeeds it returns a View_Summary describing the newly created view, if it fails it
returns a null summary.
Description
4coder is built with a limit of 16 views. If 16 views are already open when this is called the
-call will fail.
See Also
-
-
§3.3.26: close_view
-
bool32 app->close_view(
-
Application_Links *app,
View_Summary *view
)
-
-
Parameters
-
view
-
The view parameter specifies which view to close.
-
-
Return
This call returns non-zero on success.
Description
If the given view is open and is not the last view, it will be closed.
+call will fail.
See Also
§3.3.26: close_view
bool32 app->close_view(
Application_Links *app,
View_Summary *view
)
Parameters
view
The view parameter specifies which view to close.
Return
This call returns non-zero on success.
Description
If the given view is open and is not the last view, it will be closed.
If the given view is the active view, the next active view in the global
order of view will be made active.
-If the given view is the last open view in the system, the call will fail.
-
-
§3.3.27: set_active_view
-
bool32 app->set_active_view(
-
Application_Links *app,
View_Summary *view
)
-
-
Parameters
-
view
-
The view parameter specifies which view to make active.
-
-
Return
This call returns non-zero on success.
Description
If the given view is open, it is set as the
+If the given view is the last open view in the system, the call will fail.
§3.3.27: set_active_view
bool32 app->set_active_view(
Application_Links *app,
View_Summary *view
)
Parameters
view
The view parameter specifies which view to make active.
Return
This call returns non-zero on success.
Description
If the given view is open, it is set as the
active view, and takes subsequent commands and is returned
-from get_active_view.
See Also
-
-
§3.3.28: view_set_setting
-
bool32 app->view_set_setting(
-
Application_Links *app,
View_Summary *view,
View_Setting_ID setting,
int32_t value
)
-
-
Parameters
-
view
-
The view parameter specifies the view on which to set a setting.
-
-
-
setting
-
The setting parameter identifies the setting that shall be changed.
-
-
-
value
-
The value parameter specifies the value to which the setting shall be changed.
-
-
Return
This call returns non-zero on success.
See Also
-
-
§3.3.29: view_set_split_proportion
-
bool32 app->view_set_split_proportion(
-
Application_Links *app,
View_Summary *view,
float t
)
-
-
Parameters
-
view
-
The view parameter specifies which view shall have it's size adjusted.
-
-
-
t
-
The t parameter specifies the proportion of the containing box that the view should occupy. t should be in [0,1].
-
-
Return
This call returns non-zero on success.
-
-
§3.3.30: view_compute_cursor
-
bool32 app->view_compute_cursor(
-
Application_Links *app,
View_Summary *view,
Buffer_Seek seek,
Full_Cursor *cursor_out
)
-
-
Parameters
-
view
-
The view parameter specifies the view on which to run the cursor computation.
-
-
-
seek
-
The seek parameter specifies the target position for the seek.
-
-
-
cursor_out
-
On success this struct is filled with the result of the seek.
-
-
Return
This call returns non-zero on success.
Description
Computes a Full_Cursor for the given seek position with no side effects.
See Also
-
-
§3.3.31: view_set_cursor
-
bool32 app->view_set_cursor(
-
Application_Links *app,
View_Summary *view,
Buffer_Seek seek,
bool32 set_preferred_x
)
-
-
Parameters
-
view
-
The view parameter specifies the view in which to set the cursor.
-
-
-
seek
-
The seek parameter specifies the target position for the seek.
-
-
-
set_preferred_x
-
If this parameter is true the preferred x is updated to match the new cursor x.
-
-
Return
This call returns non-zero on success.
Description
This call sets the the view's cursor position. set_preferred_x should usually be true
+from get_active_view.
See Also
§3.3.28: view_set_setting
bool32 app->view_set_setting(
Application_Links *app,
View_Summary *view,
View_Setting_ID setting,
int32_t value
)
Parameters
view
The view parameter specifies the view on which to set a setting.
setting
The setting parameter identifies the setting that shall be changed.
value
The value parameter specifies the value to which the setting shall be changed.
Return
This call returns non-zero on success.
See Also
§3.3.29: view_set_split_proportion
bool32 app->view_set_split_proportion(
Application_Links *app,
View_Summary *view,
float t
)
Parameters
view
The view parameter specifies which view shall have it's size adjusted.
t
The t parameter specifies the proportion of the containing box that the view should occupy. t should be in [0,1].
Return
This call returns non-zero on success.
§3.3.30: view_compute_cursor
bool32 app->view_compute_cursor(
Application_Links *app,
View_Summary *view,
Buffer_Seek seek,
Full_Cursor *cursor_out
)
Parameters
view
The view parameter specifies the view on which to run the cursor computation.
seek
The seek parameter specifies the target position for the seek.
cursor_out
On success this struct is filled with the result of the seek.
Return
This call returns non-zero on success.
Description
Computes a Full_Cursor for the given seek position with no side effects.
See Also
§3.3.31: view_set_cursor
bool32 app->view_set_cursor(
Application_Links *app,
View_Summary *view,
Buffer_Seek seek,
bool32 set_preferred_x
)
Parameters
view
The view parameter specifies the view in which to set the cursor.
seek
The seek parameter specifies the target position for the seek.
set_preferred_x
If this parameter is true the preferred x is updated to match the new cursor x.
Return
This call returns non-zero on success.
Description
This call sets the the view's cursor position. set_preferred_x should usually be true
unless the change in cursor position is is a vertical motion that tries to keep the
-cursor in the same column or x position.
See Also
-
-
-
§3.3.33: view_set_mark
-
bool32 app->view_set_mark(
-
Application_Links *app,
View_Summary *view,
Buffer_Seek seek
)
-
-
Parameters
-
view
-
The view parameter specifies the view in which to set the mark.
-
-
-
seek
-
The seek parameter specifies the target position for the seek.
-
-
Return
This call returns non-zero on success.
Description
This call sets the the view's mark position.
See Also
-
-
§3.3.34: view_set_highlight
-
bool32 app->view_set_highlight(
-
Application_Links *app,
View_Summary *view,
int32_t start,
int32_t end,
bool32 turn_on
)
-
-
Parameters
-
view
-
The view parameter specifies the view in which to set the highlight.
-
-
-
start
-
This parameter specifies the absolute position of the first character of the highlight range.
-
-
-
end
-
This parameter specifies the absolute position of the character one past the end of the highlight range.
-
-
-
turn_on
-
This parameter indicates whether the highlight is being turned on or off.
-
-
Return
This call returns non-zero on success.
Description
The highlight is mutually exclusive to the cursor. When the turn_on parameter
+cursor in the same column or x position.
See Also
§3.3.33: view_set_mark
bool32 app->view_set_mark(
Application_Links *app,
View_Summary *view,
Buffer_Seek seek
)
Parameters
view
The view parameter specifies the view in which to set the mark.
seek
The seek parameter specifies the target position for the seek.
Return
This call returns non-zero on success.
Description
This call sets the the view's mark position.
See Also
§3.3.34: view_set_highlight
bool32 app->view_set_highlight(
Application_Links *app,
View_Summary *view,
int32_t start,
int32_t end,
bool32 turn_on
)
Parameters
view
The view parameter specifies the view in which to set the highlight.
start
This parameter specifies the absolute position of the first character of the highlight range.
end
This parameter specifies the absolute position of the character one past the end of the highlight range.
turn_on
This parameter indicates whether the highlight is being turned on or off.
Return
This call returns non-zero on success.
Description
The highlight is mutually exclusive to the cursor. When the turn_on parameter
is set to true the highlight will be shown and the cursor will be hidden. After
that either setting the cursor with view_set_cursor or calling view_set_highlight
-and the turn_on set to false, will switch back to showing the cursor.
-
-
§3.3.35: view_set_buffer
-
bool32 app->view_set_buffer(
-
Application_Links *app,
View_Summary *view,
Buffer_ID buffer_id,
Set_Buffer_Flag flags
)
-
-
Parameters
-
view
-
The view parameter specifies the view in which to display the buffer.
-
-
-
buffer_id
-
The buffer_id parameter specifies which buffer to show in the view.
-
-
-
flags
-
The flags parameter specifies behaviors for setting the buffer.
-
-
Return
This call returns non-zero on success.
Description
On success view_set_buffer sets the specified view's current buffer and
-cancels and dialogue shown in the view and displays the file.
See Also
-
-
§3.3.36: view_post_fade
-
bool32 app->view_post_fade(
-
Application_Links *app,
View_Summary *view,
float seconds,
int32_t start,
int32_t end,
int_color color
)
-
-
Parameters
-
view
-
The view parameter specifies the view onto which the fade effect shall be posted.
-
-
-
seconds
-
This parameter specifies the number of seconds the fade effect should last.
-
-
-
start
-
This parameter specifies the absolute position of the first character of the fade range.
-
-
-
end
-
This parameter specifies the absolute position of the character one past the end of the fdae range.
-
-
-
color
-
The color parameter specifies the initial color of the text before it fades to it's natural color.
-
-
Return
This call returns non-zero on success.
See Also
-
§3.3.35: view_set_buffer
bool32 app->view_set_buffer(
Application_Links *app,
View_Summary *view,
Buffer_ID buffer_id,
Set_Buffer_Flag flags
)
Parameters
view
The view parameter specifies the view in which to display the buffer.
buffer_id
The buffer_id parameter specifies which buffer to show in the view.
flags
The flags parameter specifies behaviors for setting the buffer.
Return
This call returns non-zero on success.
Description
On success view_set_buffer sets the specified view's current buffer and
+cancels and dialogue shown in the view and displays the file.
See Also
§3.3.36: view_post_fade
bool32 app->view_post_fade(
Application_Links *app,
View_Summary *view,
float seconds,
int32_t start,
int32_t end,
int_color color
)
Parameters
view
The view parameter specifies the view onto which the fade effect shall be posted.
seconds
This parameter specifies the number of seconds the fade effect should last.
start
This parameter specifies the absolute position of the first character of the fade range.
end
This parameter specifies the absolute position of the character one past the end of the fdae range.
color
The color parameter specifies the initial color of the text before it fades to it's natural color.
Return
This call returns non-zero on success.
See Also
-
-
-
§3.3.39: get_mouse_state
-
Mouse_State app->get_mouse_state(
-
Application_Links *app
)
-
-
Return
This call returns the current mouse state as of the beginning of the frame.
See Also
-
-
§3.3.40: start_query_bar
-
bool32 app->start_query_bar(
-
Application_Links *app,
Query_Bar *bar,
uint32_t flags
)
-
-
Parameters
-
bar
-
This parameter provides a Query_Bar that should remain in valid memory
+If a get condition is met the user input is returned.
See Also
§3.3.39: get_mouse_state
Mouse_State app->get_mouse_state(
Application_Links *app
)
Return
This call returns the current mouse state as of the beginning of the frame.
See Also
§3.3.40: start_query_bar
bool32 app->start_query_bar(
Application_Links *app,
Query_Bar *bar,
uint32_t flags
)
Parameters
bar
This parameter provides a Query_Bar that should remain in valid memory
until end_query_bar or the end of the command. It is commonly a good idea to make
-this a pointer to a Query_Bar stored on the stack.
-
-
-
flags
-
This parameter is not currently used and should be 0 for now.
-
-
Return
This call returns non-zero on success.
Description
This call tells the active view to begin displaying a "Query_Bar" which is a small
+this a pointer to a Query_Bar stored on the stack.
flags
This parameter is not currently used and should be 0 for now.
Return
This call returns non-zero on success.
Description
This call tells the active view to begin displaying a "Query_Bar" which is a small
GUI element that can overlap a buffer or other 4coder GUI. The contents of the bar
can be changed after the call to start_query_bar and the query bar shown by 4coder
will reflect the change. Since the bar stops showing when the command exits the
-only use for this call is in an interactive command that makes calls to get_user_input.
-
-
§3.3.41: end_query_bar
-
void app->end_query_bar(
-
Application_Links *app,
Query_Bar *bar,
uint32_t flags
)
-
-
Parameters
-
bar
-
This parameter should be a bar pointer of a currently active query bar.
-
-
-
flags
-
This parameter is not currently used and should be 0 for now.
-
-
Description
Stops showing the particular query bar specified by the bar parameter.
-
-
§3.3.42: print_message
-
void app->print_message(
-
Application_Links *app,
char *str,
int32_t len
)
-
-
Parameters
-
str
-
The str parameter specifies the string to post to *messages*; it need not be null terminated.
-
-
-
len
-
The len parameter specifies the length of the str string.
-
-
Description
This call posts a string to the *messages* buffer.
-
-
§3.3.43: change_theme
-
void app->change_theme(
-
Application_Links *app,
char *name,
int32_t len
)
-
-
Parameters
-
name
-
The name parameter specifies the name of the theme to begin using; it need not be null terminated.
-
-
-
len
-
The len parameter specifies the length of the name string.
-
-
Description
This call changes 4coder's color pallet to one of the built in themes.
-
-
§3.3.44: change_font
-
void app->change_font(
-
Application_Links *app,
char *name,
int32_t len,
bool32 apply_to_all_files
)
-
-
Parameters
-
name
-
The name parameter specifies the name of the font to begin using; it need not be null terminated.
-
-
-
len
-
The len parameter specifies the length of the name string.
-
-
-
apply_to_all_files
-
If this is set all open files change to this font. Usually this should be true
-durring the start hook because several files already exist at that time.
-
-
Description
This call changes 4coder's default font to one of the built in fonts.
-
-
§3.3.45: buffer_set_font
-
void app->buffer_set_font(
-
Application_Links *app,
Buffer_Summary *buffer,
char *name,
int32_t len
)
-
-
Parameters
-
buffer
-
This parameter the buffer that shall have it's font changed
-
-
-
name
-
The name parameter specifies the name of the font to begin using; it need not be null terminated.
-
-
-
len
-
The len parameter specifies the length of the name string.
-
-
Description
This call sets the display font of a particular buffer.
-
-
§3.3.46: set_theme_colors
-
void app->set_theme_colors(
-
Application_Links *app,
Theme_Color *colors,
int32_t count
)
-
-
Parameters
-
colors
-
The colors pointer provides an array of color structs pairing differet style tags to color codes.
-
-
-
count
-
The count parameter specifies the number of Theme_Color structs in the colors array.
-
-
Description
For each struct in the array, the slot in the main color pallet specified by the
+only use for this call is in an interactive command that makes calls to get_user_input.
§3.3.41: end_query_bar
void app->end_query_bar(
Application_Links *app,
Query_Bar *bar,
uint32_t flags
)
Parameters
bar
This parameter should be a bar pointer of a currently active query bar.
flags
This parameter is not currently used and should be 0 for now.
Description
Stops showing the particular query bar specified by the bar parameter.
§3.3.42: print_message
void app->print_message(
Application_Links *app,
char *str,
int32_t len
)
Parameters
str
The str parameter specifies the string to post to *messages*; it need not be null terminated.
len
The len parameter specifies the length of the str string.
Description
This call posts a string to the *messages* buffer.
§3.3.43: change_theme
void app->change_theme(
Application_Links *app,
char *name,
int32_t len
)
Parameters
name
The name parameter specifies the name of the theme to begin using; it need not be null terminated.
len
The len parameter specifies the length of the name string.
Description
This call changes 4coder's color pallet to one of the built in themes.
§3.3.44: change_font
void app->change_font(
Application_Links *app,
char *name,
int32_t len,
bool32 apply_to_all_files
)
Parameters
name
The name parameter specifies the name of the font to begin using; it need not be null terminated.
len
The len parameter specifies the length of the name string.
apply_to_all_files
If this is set all open files change to this font. Usually this should be true
+durring the start hook because several files already exist at that time.
Description
This call changes 4coder's default font to one of the built in fonts.
§3.3.45: buffer_set_font
void app->buffer_set_font(
Application_Links *app,
Buffer_Summary *buffer,
char *name,
int32_t len
)
Parameters
buffer
This parameter the buffer that shall have it's font changed
name
The name parameter specifies the name of the font to begin using; it need not be null terminated.
len
The len parameter specifies the length of the name string.
Description
This call sets the display font of a particular buffer.
§3.3.46: set_theme_colors
void app->set_theme_colors(
Application_Links *app,
Theme_Color *colors,
int32_t count
)
Parameters
colors
The colors pointer provides an array of color structs pairing differet style tags to color codes.
count
The count parameter specifies the number of Theme_Color structs in the colors array.
Description
For each struct in the array, the slot in the main color pallet specified by the
struct's tag is set to the color code in the struct. If the tag value is invalid
-no change is made to the color pallet.
-
-
§3.3.47: get_theme_colors
-
void app->get_theme_colors(
-
Application_Links *app,
Theme_Color *colors,
int32_t count
)
-
-
Parameters
-
colors
-
an array of color structs listing style tags to get color values for
-
-
-
count
-
the number of color structs in the colors array
-
-
Description
For each struct in the array, the color field of the struct is filled with the
+no change is made to the color pallet.
§3.3.47: get_theme_colors
void app->get_theme_colors(
Application_Links *app,
Theme_Color *colors,
int32_t count
)
Parameters
colors
an array of color structs listing style tags to get color values for
count
the number of color structs in the colors array
Description
For each struct in the array, the color field of the struct is filled with the
color from the slot in the main color pallet specified by the tag. If the tag
-value is invalid the color is filled with black.
-
-
§3.3.48: directory_get_hot
-
int32_t app->directory_get_hot(
-
Application_Links *app,
char *out,
int32_t capacity
)
-
-
Parameters
-
out
-
This parameter provides a character buffer that receives the 4coder 'hot directory'.
-
-
-
capacity
-
This parameter specifies the maximum size to be output to the out buffer.
-
-
Return
This call returns the size of the string written into the buffer.
Description
4coder has a concept of a 'hot directory' which is the directory most recently
+value is invalid the color is filled with black.
§3.3.48: directory_get_hot
int32_t app->directory_get_hot(
Application_Links *app,
char *out,
int32_t capacity
)
Parameters
out
This parameter provides a character buffer that receives the 4coder 'hot directory'.
capacity
This parameter specifies the maximum size to be output to the out buffer.
Return
This call returns the size of the string written into the buffer.
Description
4coder has a concept of a 'hot directory' which is the directory most recently
accessed in the GUI. Whenever the GUI is opened it shows the hot directory.
In the future this will be deprecated and eliminated in favor of more flexible
-directories controlled on the custom side.
-
-
§3.3.49: get_file_list
-
File_List app->get_file_list(
-
Application_Links *app,
char *dir,
int32_t len
)
-
-
Parameters
-
dir
-
This parameter specifies the directory whose files will be enumerated in the returned list; it need not be null terminated.
-
-
-
len
-
This parameter the length of the dir string.
-
-
Return
This call returns a File_List struct containing pointers to the names of the files in
+directories controlled on the custom side.
§3.3.49: get_file_list
File_List app->get_file_list(
Application_Links *app,
char *dir,
int32_t len
)
Parameters
dir
This parameter specifies the directory whose files will be enumerated in the returned list; it need not be null terminated.
len
This parameter the length of the dir string.
Return
This call returns a File_List struct containing pointers to the names of the files in
the specified directory. The File_List returned should be passed to free_file_list
-when it is no longer in use.
-
-
§3.3.50: free_file_list
-
void app->free_file_list(
-
Application_Links *app,
File_List list
)
-
-
Parameters
-
list
-
This parameter provides the file list to be freed.
-
-
Description
After this call the file list passed in should not be read or written to.
-
-
§3.3.51: memory_allocate
-
void* app->memory_allocate(
-
Application_Links *app,
int32_t size
)
-
-
Parameters
-
size
-
The size in bytes of the block that should be returned.
-
-
Description
This calls to a low level OS allocator which means it is best used
+when it is no longer in use.
§3.3.50: free_file_list
void app->free_file_list(
Application_Links *app,
File_List list
)
Parameters
list
This parameter provides the file list to be freed.
Description
After this call the file list passed in should not be read or written to.
§3.3.51: memory_allocate
void* app->memory_allocate(
Application_Links *app,
int32_t size
)
Parameters
size
The size in bytes of the block that should be returned.
Description
This calls to a low level OS allocator which means it is best used
for infrequent, large allocations. The size of the block must be remembered
-if it will be freed or if it's mem protection status will be changed.
See Also
-
-
§3.3.52: memory_set_protection
-
bool32 app->memory_set_protection(
-
Application_Links *app,
void *ptr,
int32_t size,
Memory_Protect_Flags flags
)
-
-
Parameters
-
ptr
-
The base of the block on which to set memory protection flags.
-
-
-
size
-
The size that was originally used to allocate this block.
-
-
-
flags
-
The new memory protection flags.
-
-
Description
This call sets the memory protection flags of a block of memory that was previously
-allocate by memory_allocate.
See Also
-
-
§3.3.53: memory_free
-
void app->memory_free(
-
Application_Links *app,
void *ptr,
int32_t size
)
-
-
Parameters
-
mem
-
The base of a block to free.
-
-
-
size
-
The size that was originally used to allocate this block.
-
-
Description
This call frees a block of memory that was previously allocated by
-memory_allocate.
See Also
-
-
§3.3.54: file_exists
-
bool32 app->file_exists(
-
Application_Links *app,
char *filename,
int32_t len
)
-
-
Parameters
-
filename
-
This parameter specifies the full path to a file; it need not be null terminated.
-
-
-
len
-
This parameter specifies the length of the filename string.
-
-
Return
This call returns non-zero if and only if the file exists.
-
-
§3.3.55: directory_cd
-
bool32 app->directory_cd(
-
Application_Links *app,
char *dir,
int32_t *len,
int32_t capacity,
char *rel_path,
int32_t rel_len
)
-
-
Parameters
-
dir
-
This parameter provides a character buffer that stores a directory; it need not be null terminated.
-
-
-
len
-
This parameter specifies the length of the dir string.
-
-
-
capacity
-
This parameter specifies the maximum size of the dir string.
-
-
-
rel_path
-
This parameter specifies the path to change to, may include '.' or '..'; it need not be null terminated.
-
-
-
rel_len
-
This parameter specifies the length of the rel_path string.
-
-
Return
This call returns non-zero if the call succeeds.
Description
This call succeeds if the new directory exists and the it fits inside the
+if it will be freed or if it's mem protection status will be changed.
See Also
§3.3.52: memory_set_protection
bool32 app->memory_set_protection(
Application_Links *app,
void *ptr,
int32_t size,
Memory_Protect_Flags flags
)
Parameters
ptr
The base of the block on which to set memory protection flags.
size
The size that was originally used to allocate this block.
flags
The new memory protection flags.
Description
This call sets the memory protection flags of a block of memory that was previously
+allocate by memory_allocate.
See Also
§3.3.53: memory_free
void app->memory_free(
Application_Links *app,
void *ptr,
int32_t size
)
Parameters
mem
The base of a block to free.
size
The size that was originally used to allocate this block.
Description
This call frees a block of memory that was previously allocated by
+memory_allocate.
See Also
§3.3.54: file_exists
bool32 app->file_exists(
Application_Links *app,
char *filename,
int32_t len
)
Parameters
filename
This parameter specifies the full path to a file; it need not be null terminated.
len
This parameter specifies the length of the filename string.
Return
This call returns non-zero if and only if the file exists.
§3.3.55: directory_cd
bool32 app->directory_cd(
Application_Links *app,
char *dir,
int32_t *len,
int32_t capacity,
char *rel_path,
int32_t rel_len
)
Parameters
dir
This parameter provides a character buffer that stores a directory; it need not be null terminated.
len
This parameter specifies the length of the dir string.
capacity
This parameter specifies the maximum size of the dir string.
rel_path
This parameter specifies the path to change to, may include '.' or '..'; it need not be null terminated.
rel_len
This parameter specifies the length of the rel_path string.
Return
This call returns non-zero if the call succeeds.
Description
This call succeeds if the new directory exists and the it fits inside the
dir buffer. If the call succeeds the dir buffer is filled with the new
directory and len is overwritten with the length of the new string in the buffer.
For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer
will contain "C:/Users/MySelf/Documents" and len will contain the length of that
string. This call can also be used with rel set to ".." to traverse to parent
-folders.
-
-
§3.3.56: get_4ed_path
-
bool32 app->get_4ed_path(
-
Application_Links *app,
char *out,
int32_t capacity
)
-
-
Parameters
-
out
-
This parameter provides a character buffer that receives the path to the 4ed executable file.
-
-
-
capacity
-
This parameter specifies the maximum capacity of the out buffer.
-
-
Return
This call returns non-zero on success.
-
-
§3.3.57: show_mouse_cursor
-
void app->show_mouse_cursor(
-
Application_Links *app,
Mouse_Cursor_Show_Type show
)
-
-
Parameters
-
show
-
This parameter specifies the new state of the mouse cursor.
-
-
See Also
-
-
§3.3.58: toggle_fullscreen
-
void app->toggle_fullscreen(
-
Application_Links *app
)
-
-
Description
This call tells 4coder to switch into or out of full screen mode.
+folders.
§3.3.56: get_4ed_path
bool32 app->get_4ed_path(
Application_Links *app,
char *out,
int32_t capacity
)
Parameters
out
This parameter provides a character buffer that receives the path to the 4ed executable file.
capacity
This parameter specifies the maximum capacity of the out buffer.
Return
This call returns non-zero on success.
§3.3.57: show_mouse_cursor
void app->show_mouse_cursor(
Application_Links *app,
Mouse_Cursor_Show_Type show
)
Parameters
show
This parameter specifies the new state of the mouse cursor.
See Also
§3.3.58: toggle_fullscreen
void app->toggle_fullscreen(
Application_Links *app
)
Description
This call tells 4coder to switch into or out of full screen mode.
The changes of full screen mode do not take effect until the end of the current frame.
On Windows this call will not work unless 4coder was started in "stream mode".
-Stream mode can be enabled with -S or -F flags on the command line to 4ed.
-
-
§3.3.59: is_fullscreen
-
bool32 app->is_fullscreen(
-
Application_Links *app
)
-
-
See Also
-
-
§3.3.60: send_exit_signal
-
void app->send_exit_signal(
-
Application_Links *app
)
-
-
See Also
-
§3.4 Type Descriptions
-
-
§3.4.1: bool32
-
typedef int32_t bool32;
-
Description
bool32 is an alias name to signal that an integer parameter or field is for
-true/false vales.
-
-
§3.4.2: int_color
-
typedef uint32_t int_color;
-
Description
int_color is an alias name to signal that an integer parameter or field is for
-a color value, colors are specified as 24 bit integers in 3 channels: 0xRRGGBB.
-
-
§3.4.3: Key_Code
-
typedef unsigned char Key_Code;
-
Description
Key_Code is the alias for key codes including raw codes and codes translated
-to textual input that takes modifiers into account.
-
-
§3.4.4: Buffer_ID
-
typedef int32_t Buffer_ID;
-
Description
Buffer_ID is used to name a 4coder buffer. Each buffer has a unique id but
-when a buffer is closed it's id may be recycled by future, different buffers.
-
-
§3.4.5: View_ID
-
typedef int32_t View_ID;
-
Description
View_ID is used to name a 4coder view. Each view has a unique id in
-the interval [1,16].
-
-
§3.4.6: Key_Modifier
-
enum Key_Modifier;
-
Description
A Key_Modifier acts as an index for specifying modifiers in arrays.
Values
-
-
-
-
-
-
MDFR_INDEX_COUNT
-
MDFR_INDEX_COUNT is used to specify the number of modifiers supported.
-
-
-
-
§3.4.7: Command_ID
-
enum Command_ID;
-
Description
A Command_ID is used as a name for commands implemented internally in 4coder.
Values
-
cmdid_null
-
cmdid_null is set aside to always be zero and is not associated with any command.
-
-
-
cmdid_undo
-
cmdid_undo performs a standard undo behavior.
-
-
-
cmdid_redo
-
cmdid_redo reperforms an edit that was undone.
-
-
-
cmdid_history_backward
-
cmdid_history_backward performs a step backwards through the file history, which includes previously lost redo branches.
-
-
-
cmdid_history_forward
-
cmdid_history_forward unperforms the previous cmdid_history_backward step if possib.e
-
-
-
cmdid_interactive_new
-
cmdid_interactive_new begins an interactive dialogue to create a new buffer.
-
-
-
cmdid_interactive_open
-
cmdid_interactive_open begins an interactive dialogue to open a file into a buffer.
-
-
-
cmdid_save_as
-
cmdid_save_as does not currently work and is likely to be removed rather that fixed.
-
-
-
cmdid_interactive_switch_buffer
-
cmdid_interactive_switch_buffer begins an interactive dialogue to choose an open buffer to swap into the active view.
-
-
-
cmdid_interactive_kill_buffer
-
cmdid_interactive_kill_buffer begins an interactive dialogue to choose an open buffer to kill.
-
-
-
cmdid_reopen
-
cmdid_reopen reloads the active buffer's associated file and discards the old buffer contents for the reloaded file.
-
-
-
cmdid_save
-
cmdid_save saves the buffer's contents into the associated file.
-
-
-
cmdid_kill_buffer
-
cmdid_kill_buffer tries to kill the active buffer.
-
-
-
cmdid_open_color_tweaker
-
cmdid_open_color_tweaker opens the theme editing GUI.
-
-
-
cmdid_open_config
-
cmdid_open_config opens the configuration menu.
-
-
-
cmdid_open_menu
-
cmdid_open_menu opens the top level menu.
-
-
-
cmdid_open_debug
-
cmdid_open_debug opens the debug information viewer mode.
-
-
-
-
-
-
§3.4.9: Event_Message_Type_ID
-
enum Event_Message_Type_ID;
-
Description
Event_Message_Type_ID is a part of an unfinished feature.
Values
-
EventMessage_NoMessage
-
-
-
-
EventMessage_OpenView
-
-
-
-
-
EventMessage_CloseView
-
-
-
-
-
§3.4.10: Buffer_Batch_Edit_Type
-
enum Buffer_Batch_Edit_Type;
-
Description
A Buffer_Batch_Edit_Type is a type of batch operation.
Values
-
BatchEdit_Normal
-
The BatchEdit_Normal operation is always correct but does the most work.
-
-
-
BatchEdit_PreserveTokens
-
The BatchEdit_PreserveTokens operation is one in which none of the edits add, delete, or change any tokens.
- This usually applies when whitespace is being replaced with whitespace.
-
-
-
-
§3.4.11: Buffer_Setting_ID
-
enum Buffer_Setting_ID;
-
Description
A Buffer_Setting_ID names a setting in a buffer.
Values
-
BufferSetting_Null
-
BufferSetting_Null is not a valid setting, it is reserved to detect errors.
-
-
-
BufferSetting_Lex
-
The BufferSetting_Lex setting is used to determine whether to store C++ tokens
- from with the buffer.
-
-
-
BufferSetting_WrapLine
-
The BufferSetting_WrapLine setting is used to determine whether a buffer prefers
+files this triggers a dialogue ensuring you're okay with closing.
§3.4 Type Descriptions
§3.4.1: bool32
typedef int32_t bool32;
Description
bool32 is an alias name to signal that an integer parameter or field is for
+true/false vales.
§3.4.2: int_color
typedef uint32_t int_color;
Description
int_color is an alias name to signal that an integer parameter or field is for
+a color value, colors are specified as 24 bit integers in 3 channels: 0xRRGGBB.
§3.4.3: Key_Code
typedef unsigned char Key_Code;
Description
Key_Code is the alias for key codes including raw codes and codes translated
+to textual input that takes modifiers into account.
§3.4.4: Buffer_ID
typedef int32_t Buffer_ID;
Description
Buffer_ID is used to name a 4coder buffer. Each buffer has a unique id but
+when a buffer is closed it's id may be recycled by future, different buffers.
§3.4.5: View_ID
typedef int32_t View_ID;
Description
View_ID is used to name a 4coder view. Each view has a unique id in
+the interval [1,16].
§3.4.6: Key_Modifier
enum Key_Modifier;
Description
A Key_Modifier acts as an index for specifying modifiers in arrays.
Values
MDFR_INDEX_COUNT
MDFR_INDEX_COUNT is used to specify the number of modifiers supported.
§3.4.7: Key_Modifier_Flag
enum Key_Modifier_Flag;
Description
A Key_Modifier_Flag field is used to specify a specific state of modifiers.
+Flags can be combined with bit or to specify a state with multiple modifiers.
Values
MDFR_NONE = 0x0
MDFR_NONE specifies that no modifiers are pressed.
§3.4.8: Command_ID
enum Command_ID;
Description
A Command_ID is used as a name for commands implemented internally in 4coder.
Values
cmdid_null
cmdid_null is set aside to always be zero and is not associated with any command.
cmdid_undo
cmdid_undo performs a standard undo behavior.
cmdid_redo
cmdid_redo reperforms an edit that was undone.
cmdid_history_backward
cmdid_history_backward performs a step backwards through the file history, which includes previously lost redo branches.
cmdid_history_forward
cmdid_history_forward unperforms the previous cmdid_history_backward step if possib.e
cmdid_interactive_new
cmdid_interactive_new begins an interactive dialogue to create a new buffer.
cmdid_interactive_open
cmdid_interactive_open begins an interactive dialogue to open a file into a buffer.
cmdid_save_as
cmdid_save_as does not currently work and is likely to be removed rather that fixed.
cmdid_interactive_switch_buffer
cmdid_interactive_switch_buffer begins an interactive dialogue to choose an open buffer to swap into the active view.
cmdid_interactive_kill_buffer
cmdid_interactive_kill_buffer begins an interactive dialogue to choose an open buffer to kill.
cmdid_reopen
cmdid_reopen reloads the active buffer's associated file and discards the old buffer contents for the reloaded file.
cmdid_save
cmdid_save saves the buffer's contents into the associated file.
cmdid_kill_buffer
cmdid_kill_buffer tries to kill the active buffer.
cmdid_open_color_tweaker
cmdid_open_color_tweaker opens the theme editing GUI.
cmdid_open_config
cmdid_open_config opens the configuration menu.
cmdid_open_menu
cmdid_open_menu opens the top level menu.
cmdid_open_debug
cmdid_open_debug opens the debug information viewer mode.
§3.4.9: Memory_Protect_Flags
enum Memory_Protect_Flags;
Description
TODO
Values
§3.4.11: Event_Message_Type_ID
enum Event_Message_Type_ID;
Description
Event_Message_Type_ID is a part of an unfinished feature.
Values
§3.4.12: Buffer_Batch_Edit_Type
enum Buffer_Batch_Edit_Type;
Description
A Buffer_Batch_Edit_Type is a type of batch operation.
Values
BatchEdit_Normal
The BatchEdit_Normal operation is always correct but does the most work.
BatchEdit_PreserveTokens
The BatchEdit_PreserveTokens operation is one in which none of the edits add, delete, or change any tokens.
+ This usually applies when whitespace is being replaced with whitespace.
§3.4.13: Buffer_Setting_ID
enum Buffer_Setting_ID;
Description
A Buffer_Setting_ID names a setting in a buffer.
Values
BufferSetting_Null
BufferSetting_Null is not a valid setting, it is reserved to detect errors.
BufferSetting_Lex
The BufferSetting_Lex setting is used to determine whether to store C++ tokens
+ from with the buffer.
BufferSetting_WrapLine
The BufferSetting_WrapLine setting is used to determine whether a buffer prefers
to be viewed with wrapped lines, individual views can be set to override this value after
- being tied to the buffer.
-
-
-
BufferSetting_MapID
-
The BufferSetting_MapID setting specifies the id of the command map that should be
- active when a buffer is active.
-
-
-
BufferSetting_Eol
-
The BufferSetting_Eol setting specifies how line ends should be saved to the backing file.
- A 1 indicates dos endings "\r\n" and a 0 indicates nix endings "\n".
-
-
-
BufferSetting_Unimportant
-
The BufferSetting_Unimportant setting marks a buffer so that it's dirty state will be completely
+ being tied to the buffer.
BufferSetting_MapID
The BufferSetting_MapID setting specifies the id of the command map that should be
+ active when a buffer is active.
BufferSetting_Eol
The BufferSetting_Eol setting specifies how line ends should be saved to the backing file.
+ A 1 indicates dos endings "\r\n" and a 0 indicates nix endings "\n".
BufferSetting_Unimportant
The BufferSetting_Unimportant setting marks a buffer so that it's dirty state will be completely
ignored. This means the "dirty" star is hidden and the buffer can be closed without presenting an
- "are you sure" dialogue screen.
-
-
-
BufferSetting_ReadOnly
-
The BufferSetting_ReadOnly setting marks a buffer so that it can only be returned from buffer
- access calls that include an AccessProtected flag.
-
-
-
-
§3.4.12: View_Setting_ID
-
enum View_Setting_ID;
-
Description
A View_Setting_ID names a setting in a view.
Values
-
ViewSetting_Null
-
ViewSetting_Null is not a valid setting, it is reserved to detect errors.
-
-
-
ViewSetting_WrapLine
-
The ViewSetting_WrapLine setting determines whether the view applies line wrapping
+ "are you sure" dialogue screen.
BufferSetting_ReadOnly
The BufferSetting_ReadOnly setting marks a buffer so that it can only be returned from buffer
+ access calls that include an AccessProtected flag.
§3.4.14: View_Setting_ID
enum View_Setting_ID;
Description
A View_Setting_ID names a setting in a view.
Values
ViewSetting_Null
ViewSetting_Null is not a valid setting, it is reserved to detect errors.
ViewSetting_WrapLine
The ViewSetting_WrapLine setting determines whether the view applies line wrapping
at the border of the panel for long lines. Whenever the view switches to a new buffer it
- will reset this setting to match the 'preferred' line wrapping setting of the buffer.
-
-
-
ViewSetting_ShowWhitespace
-
The ViewSetting_ShowWhitespace setting determines whether the view highlights
- whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.
-
-
-
ViewSetting_ShowScrollbar
-
The ViewSetting_ShowScrollbar setting determines whether a scroll bar is
- attached to a view in it's scrollable section.
-
-
-
-
§3.4.13: Mouse_Cursor_Show_Type
-
enum Mouse_Cursor_Show_Type;
-
Description
A Mouse_Cursor_Show_Type value specifes a mode for 4coder to handle the mouse cursor.
Values
-
MouseCursorShow_Never
-
The MouseCursorShow_Never mode never shows the cursor.
-
-
-
MouseCursorShow_Always
-
The MouseCursorShow_Never mode always shows the cursor.
-
-
-
-
§3.4.14: Buffer_Seek_Type
-
enum Buffer_Seek_Type;
-
Description
The Buffer_Seek_Type is is used in a Buffer_Seek to identify which
-coordinates are suppose to be used for the seek.
Values
-
buffer_seek_pos
-
This value indicates absolute positioning where positions are measured as the number of bytes from the start of the file.
-
-
-
buffer_seek_wrapped_xy
-
This value indicates xy positioning with wrapped lines where the x and y values are in pixels.
-
-
-
buffer_seek_unwrapped_xy
-
This value indicates xy positioning with unwrapped lines where the x and y values are in pixels.
-
-
-
buffer_seek_line_char
-
This value indicates line-character, or line-column positioning. These coordinates are 1 based to match standard line numbering.
-
-
See Also
-
-
§3.4.15: View_Split_Position
-
enum View_Split_Position;
-
Description
A View_Split_Position specifies where a new view should be placed as a result of
-a view split operation.
Values
-
ViewSplit_Top
-
This value indicates that the new view should be above the existing view.
-
-
-
ViewSplit_Bottom
-
This value indicates that the new view should be below the existing view.
-
-
-
ViewSplit_Left
-
This value indicates that the new view should be left of the existing view.
-
-
-
ViewSplit_Right
-
This value indicates that the new view should be right of the existing view.
-
-
-
-
§3.4.16: Key_Modifier_Flag
-
enum Key_Modifier_Flag;
-
Description
A Key_Modifier_Flag field is used to specify a specific state of modifiers.
-Flags can be combined with bit or to specify a state with multiple modifiers.
Flags
-
MDFR_NONE = 0x0
-
MDFR_NONE specifies that no modifiers are pressed.
-
-
-
-
-
-
-
§3.4.17: Memory_Protect_Flags
-
enum Memory_Protect_Flags;
-
Description
TODO
Flags
-
MemProtect_Read = 0x1
-
-
-
-
MemProtect_Write = 0x2
-
-
-
-
MemProtect_Execute = 0x4
-
-
-
-
-
§3.4.18: Buffer_Create_Flag
-
enum Buffer_Create_Flag;
-
Description
A Buffer_Create_Flag field specifies how a buffer should be created.
Flags
-
BufferCreate_Background = 0x1
-
BufferCreate_Background is not currently implemented.
-
-
-
BufferCreate_AlwaysNew = 0x2
-
When BufferCreate_AlwaysNew is set it indicates the buffer should be
- cleared to empty even if it's associated file already has content.
-
-
-
BufferCreate_NeverNew = 0x4
-
When BufferCreate_NeverNew is set it indicates that the buffer should
- only be created if it is an existing file or an open buffer.
-
-
-
-
§3.4.19: Buffer_Kill_Flag
-
enum Buffer_Kill_Flag;
-
Description
A Buffer_Kill_Flag field specifies how a buffer should be killed.
Flags
-
BufferKill_Background = 0x1
-
BufferKill_Background is not currently implemented.
-
-
-
BufferKill_AlwaysKill = 0x2
-
When BufferKill_AlwaysKill is set it indicates the buffer should be killed
- without asking, even when the buffer is dirty.
-
-
-
-
§3.4.20: Access_Flag
-
enum Access_Flag;
-
Description
An Access_Flag field specifies what sort of permission you grant to an
+ will reset this setting to match the 'preferred' line wrapping setting of the buffer.
ViewSetting_ShowWhitespace
The ViewSetting_ShowWhitespace setting determines whether the view highlights
+ whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.
ViewSetting_ShowScrollbar
The ViewSetting_ShowScrollbar setting determines whether a scroll bar is
+ attached to a view in it's scrollable section.
§3.4.15: Buffer_Create_Flag
enum Buffer_Create_Flag;
Description
A Buffer_Create_Flag field specifies how a buffer should be created.
Values
BufferCreate_Background = 0x1
BufferCreate_Background is not currently implemented.
BufferCreate_AlwaysNew = 0x2
When BufferCreate_AlwaysNew is set it indicates the buffer should be
+ cleared to empty even if it's associated file already has content.
BufferCreate_NeverNew = 0x4
When BufferCreate_NeverNew is set it indicates that the buffer should
+ only be created if it is an existing file or an open buffer.
§3.4.16: Buffer_Kill_Flag
enum Buffer_Kill_Flag;
Description
A Buffer_Kill_Flag field specifies how a buffer should be killed.
Values
BufferKill_Background = 0x1
BufferKill_Background is not currently implemented.
BufferKill_AlwaysKill = 0x2
When BufferKill_AlwaysKill is set it indicates the buffer should be killed
+ without asking, even when the buffer is dirty.
§3.4.17: Access_Flag
enum Access_Flag;
Description
An Access_Flag field specifies what sort of permission you grant to an
access call. An access call is usually one the returns a summary struct. If a
4coder object has a particular protection flag set and the corresponding bit is
not set in the access field, that 4coder object is hidden. On the other hand if
a protection flag is set in the access parameter and the object does not have
-that protection flag, the object is still returned from the access call.
Flags
-
AccessOpen = 0x0
-
AccessOpen does not include any bits, it indicates that the access should
- only return objects that have no protection flags set.
-
-
-
AccessProtected = 0x1
-
AccessProtected is set on buffers and views that are "read only" such as
+that protection flag, the object is still returned from the access call.
Values
AccessOpen = 0x0
AccessOpen does not include any bits, it indicates that the access should
+ only return objects that have no protection flags set.
AccessProtected = 0x1
AccessProtected is set on buffers and views that are "read only" such as
the output from an app->exec_system_command call such as *build*. This is to prevent
- the user from accidentally editing output that they might prefer to keep in tact.
-
-
-
AccessHidden = 0x2
-
AccessHidden is set on any view that is not currently showing it's file, for
- instance because it is navigating the file system to open a file.
-
-
-
AccessAll = 0xFF
-
AccessAll is a catchall access for cases where an access call should always
- return an object no matter what it's protection flags are.
-
-
-
-
§3.4.21: Seek_Boundary_Flag
-
enum Seek_Boundary_Flag;
-
Description
A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the
-beginning or end of different types of words.
Flags
-
BoundaryWhitespace = 0x1
-
-
-
-
-
BoundaryAlphanumeric = 0x4
-
-
-
-
BoundaryCamelCase = 0x8
-
-
-
-
§3.4.18: Seek_Boundary_Flag
enum Seek_Boundary_Flag;
Description
A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the
+beginning or end of different types of words.
Values
BoundaryAlphanumeric = 0x4
-
-
§3.4.23: Auto_Indent_Flag
-
enum Auto_Indent_Flag;
-
Description
An Auto_Indent_Flag field specifies the behavior of an auto indentation operation.
Flags
-
AutoIndent_ClearLine = 0x1
-
If AutoIndent_ClearLine is set, then any line that is only whitespace will
+ the buffer.
CLI_AlwaysBindToView = 0x2
If CLI_AlwaysBindToView is set the output buffer will always be set in the active
+ view even if it is already set in another open view.
CLI_CursorAtEnd = 0x4
If CLI_CursorAtEnd is set the cursor will be kept at the end of the output buffer,
+ otherwise the cursor is kept at the beginning.
§3.4.20: Auto_Indent_Flag
enum Auto_Indent_Flag;
Description
An Auto_Indent_Flag field specifies the behavior of an auto indentation operation.
Values
AutoIndent_ClearLine = 0x1
If AutoIndent_ClearLine is set, then any line that is only whitespace will
be cleared to contain nothing at all. otherwise the line is filled with whitespace
- to match the nearby indentation.
-
-
-
AutoIndent_UseTab = 0x2
-
If AutoIndent_UseTab is set, then when putting in leading whitespace to align
+ to match the nearby indentation.
AutoIndent_UseTab = 0x2
If AutoIndent_UseTab is set, then when putting in leading whitespace to align
code, as many tabs will be used as possible until the fine grained control of spaces
- is needed to finish the alignment.
-
-
-
-
§3.4.24: Set_Buffer_Flag
-
enum Set_Buffer_Flag;
-
Description
A Set_Buffer_Flag field specifies the behavior of an operation that sets the buffer of a view.
Flags
-
SetBuffer_KeepOriginalGUI = 0x1
-
If SetBuffer_KeepOriginalGUI then when the file is set, the view will not switch to it
+ is needed to finish the alignment.
§3.4.21: Set_Buffer_Flag
enum Set_Buffer_Flag;
Description
A Set_Buffer_Flag field specifies the behavior of an operation that sets the buffer of a view.
Values
SetBuffer_KeepOriginalGUI = 0x1
If SetBuffer_KeepOriginalGUI then when the file is set, the view will not switch to it
if some other GUI was currently up, otherwise any GUI that is up is closed and the view
- switches to the file.
-
-
-
-
-
§3.4.26: Generic_Command
-
union Generic_Command {
-
-Command_ID cmdid;
-Custom_Command_Function * command;
-
-};
-
-
Description
Generic_Command acts as a name for a command, and can name an
-internal command or a custom command.
Fields
-
cmdid
-
If this Generic_Command represents an internal command the cmdid field
- will have a value less than cmdid_count, and this field is the command id for the command.
-
-
-
command
-
If this Generic_Command does not represent an internal command the command
- field is the pointer to the custom command..
-
-
-
-
§3.4.27: Key_Event_Data
-
struct Key_Event_Data {
-
-Key_Code keycode;
-Key_Code character;
-Key_Code character_no_caps_lock;
-char modifiers[MDFR_INDEX_COUNT];
-
-};
-
-
Description
Key_Event_Data describes a key event, including the
+ switches to the file.
§3.4.23: Mouse_Cursor_Show_Type
enum Mouse_Cursor_Show_Type;
Description
A Mouse_Cursor_Show_Type value specifes a mode for 4coder to handle the mouse cursor.
Values
MouseCursorShow_Never
The MouseCursorShow_Never mode never shows the cursor.
MouseCursorShow_Always
The MouseCursorShow_Never mode always shows the cursor.
§3.4.24: Buffer_Seek_Type
enum Buffer_Seek_Type;
Description
The Buffer_Seek_Type is is used in a Buffer_Seek to identify which
+coordinates are suppose to be used for the seek.
Values
buffer_seek_pos
This value indicates absolute positioning where positions are measured as the number of bytes from the start of the file.
buffer_seek_wrapped_xy
This value indicates xy positioning with wrapped lines where the x and y values are in pixels.
buffer_seek_unwrapped_xy
This value indicates xy positioning with unwrapped lines where the x and y values are in pixels.
buffer_seek_line_char
This value indicates line-character, or line-column positioning. These coordinates are 1 based to match standard line numbering.
See Also
§3.4.25: View_Split_Position
enum View_Split_Position;
Description
A View_Split_Position specifies where a new view should be placed as a result of
+a view split operation.
Values
ViewSplit_Top
This value indicates that the new view should be above the existing view.
ViewSplit_Bottom
This value indicates that the new view should be below the existing view.
ViewSplit_Left
This value indicates that the new view should be left of the existing view.
ViewSplit_Right
This value indicates that the new view should be right of the existing view.
§3.4.26: Generic_Command
union Generic_Command {
Command_ID cmdid;
Custom_Command_Function * command;
};
Description
Generic_Command acts as a name for a command, and can name an
+internal command or a custom command.
Fields
cmdid
If this Generic_Command represents an internal command the cmdid field
+ will have a value less than cmdid_count, and this field is the command id for the command.
command
If this Generic_Command does not represent an internal command the command
+ field is the pointer to the custom command..
§3.4.27: Key_Event_Data
struct Key_Event_Data {
Key_Code keycode;
Key_Code character;
Key_Code character_no_caps_lock;
char modifiers[MDFR_INDEX_COUNT];
};
Description
Key_Event_Data describes a key event, including the
translation to a character, the translation to
a character ignoring the state of caps lock, and
an array of all the modifiers that were pressed
-at the time of the event.
Fields
-
keycode
-
This field is the raw keycode which is always non-zero in valid key events.
-
-
-
character
-
This field is the keycode after translation to a character, this is 0 if there is no translation.
-
-
-
character_no_caps_lock
-
This field is like the field character, except that the state of caps lock is ignored in the translation.
-
-
-
modifiers
-
This field is an array indicating the state of modifiers at the time of the key press.
+at the time of the event.
Fields
keycode
This field is the raw keycode which is always non-zero in valid key events.
character
This field is the keycode after translation to a character, this is 0 if there is no translation.
character_no_caps_lock
This field is like the field character, except that the state of caps lock is ignored in the translation.
modifiers
This field is an array indicating the state of modifiers at the time of the key press.
The array is indexed using the values of Key_Modifier. A 1 indicates that the corresponding
- modifier was held, and a 0 indicates that it was not held.
-
-
-
-
§3.4.28: Mouse_State
-
struct Mouse_State {
-
-char l;
-char r;
-char press_l;
-char press_r;
-char release_l;
-char release_r;
-char wheel;
-char out_of_window;
-int32_t x;
-int32_t y;
-
-};
-
-
Description
Mouse_State describes an entire mouse state complete with the position,
+ modifier was held, and a 0 indicates that it was not held.
§3.4.28: Mouse_State
struct Mouse_State {
char l;
char r;
char press_l;
char press_r;
char release_l;
char release_r;
char wheel;
char out_of_window;
int32_t x;
int32_t y;
};
Description
Mouse_State describes an entire mouse state complete with the position,
left and right button states, the wheel state, and whether or not the
-mouse if in the window.
Fields
-
l
-
This field indicates that the left button is held.
-
-
-
r
-
This field indicates that the right button is held.
-
-
-
press_l
-
This field indicates that the left button was pressed this frame.
-
-
-
press_r
-
This field indicates that the right button was pressed this frame.
-
-
-
release_l
-
This field indicates that the left button was released this frame.
-
-
-
release_r
-
This field indicates that the right button was released this frame.
-
-
-
wheel
-
This field is 0 when the wheel has not moved, it is 1 for a downward motion and -1 for an upward motion.
-
-
-
out_of_window
-
This field indicates that the mouse is outside of the window.
-
-
-
x
-
This field contains the x position of the mouse relative to the window where the left side is 0.
-
-
-
y
-
This field contains the y position of the mouse relative to the window where the top side is 0.
-
-
-
-
§3.4.29: Range
-
union Range {
-
-struct {
-
-int32_t min;
-int32_t max;
-
-};
-struct {
-
-int32_t start;
-int32_t end;
-
-};
-
-};
-
-
Description
Range describes an integer range typically used for ranges within a buffer.
+mouse if in the window.
Fields
l
This field indicates that the left button is held.
r
This field indicates that the right button is held.
press_l
This field indicates that the left button was pressed this frame.
press_r
This field indicates that the right button was pressed this frame.
release_l
This field indicates that the left button was released this frame.
release_r
This field indicates that the right button was released this frame.
wheel
This field is 0 when the wheel has not moved, it is 1 for a downward motion and -1 for an upward motion.
out_of_window
This field indicates that the mouse is outside of the window.
x
This field contains the x position of the mouse relative to the window where the left side is 0.
y
This field contains the y position of the mouse relative to the window where the top side is 0.
§3.4.29: Range
union Range {
struct {
int32_t min;
int32_t max;
};
struct {
int32_t start;
int32_t end;
};
};
Description
Range describes an integer range typically used for ranges within a buffer.
Ranges tend are usually not passed as a Range struct into the API, but this
struct is used to return ranges.
-Throughout the API ranges are thought of in the form [min,max
Fields
-
min
-
This is the smaller value in the range, it is also the 'start'.
-
-
-
max
-
This is the larger value in the range, it is also the 'end'.
-
-
-
start
-
This is the start of the range, it is also the 'min'.
-
-
-
end
-
This is the end of the range, it is also the 'max'.
-
-
-
-
§3.4.30: File_Info
-
struct File_Info {
-
-char * filename;
-int32_t filename_len;
-int32_t folder;
-
-};
-
-
Description
File_Info describes the name and type of a file.
Fields
-
filename
-
This field is a null terminated string specifying the name of the file.
-
-
-
filename_len
-
This field specifies the length of the filename string not counting the null terminator.
-
-
-
folder
-
This field indicates that the description is for a folder not a file.
-
-
See Also
-
-
§3.4.31: File_List
-
struct File_List {
-
-void * block;
-File_Info * infos;
-int32_t count;
-int32_t block_size;
-
-};
-
-
Description
File_List is a list of File_Info structs.
Fields
-
block
-
This field is for inernal use.
-
-
-
infos
-
This field is an array of File_Info structs.
-
-
-
count
-
This field specifies the number of struts in the info array.
-
-
-
block_size
-
This field is for internal use.
-
-
-
-
§3.4.32: Buffer_Identifier
-
struct Buffer_Identifier {
-
-char * name;
-int32_t name_len;
-int32_t id;
-
-};
-
-
Description
Buffer_Identifier acts as a loosely typed description of a buffer that
-can either be a name or an id. If the
Fields
-
name
-
This field is the name of the buffer; it need not be null terminated.
- If id is specified this pointer should be NULL.
-
-
-
name_len
-
This field specifies the length of the name string.
-
-
-
id
-
This field is the id of the buffer. If name is specified this should be 0.
-
-
-
-
-
§3.4.34: Full_Cursor
-
struct Full_Cursor {
-
-int32_t pos;
-int32_t line;
-int32_t character;
-float unwrapped_x;
-float unwrapped_y;
-float wrapped_x;
-float wrapped_y;
-
-};
-
-
Description
Full_Cursor describes the position of a cursor in every buffer
+Throughout the API ranges are thought of in the form [min,max
Fields
min
This is the smaller value in the range, it is also the 'start'.
max
This is the larger value in the range, it is also the 'end'.
start
This is the start of the range, it is also the 'min'.
end
This is the end of the range, it is also the 'max'.
§3.4.30: File_Info
struct File_Info {
char * filename;
int32_t filename_len;
int32_t folder;
};
Description
File_Info describes the name and type of a file.
Fields
filename
This field is a null terminated string specifying the name of the file.
filename_len
This field specifies the length of the filename string not counting the null terminator.
folder
This field indicates that the description is for a folder not a file.
See Also
§3.4.31: File_List
struct File_List {
void * block;
File_Info * infos;
int32_t count;
int32_t block_size;
};
Description
File_List is a list of File_Info structs.
Fields
block
This field is for inernal use.
infos
This field is an array of File_Info structs.
count
This field specifies the number of struts in the info array.
block_size
This field is for internal use.
§3.4.32: Buffer_Identifier
struct Buffer_Identifier {
char * name;
int32_t name_len;
int32_t id;
};
Description
Buffer_Identifier acts as a loosely typed description of a buffer that
+can either be a name or an id. If the
Fields
name
This field is the name of the buffer; it need not be null terminated.
+ If id is specified this pointer should be NULL.
name_len
This field specifies the length of the name string.
id
This field is the id of the buffer. If name is specified this should be 0.
§3.4.34: Full_Cursor
struct Full_Cursor {
int32_t pos;
int32_t line;
int32_t character;
float unwrapped_x;
float unwrapped_y;
float wrapped_x;
float wrapped_y;
};
Description
Full_Cursor describes the position of a cursor in every buffer
coordinate system supported by 4coder. This cursor type requires that
-the buffer is associated with a view to give the x/y values meaning.
Fields
-
pos
-
This field contains the cursor's position in absolute positioning.
-
-
-
line
-
This field contains the number of the line where the cursor is located. This field is one based.
-
-
-
character
-
This field contains the number of the column where the cursor is located. This field is one based.
-
-
-
unwrapped_x
-
This field contains the x position measured with unwrapped lines.
-
-
-
unwrapped_y
-
This field contains the y position measured with unwrapped lines.
-
-
-
wrapped_x
-
This field contains the x position measured with wrapped lines.
-
-
-
wrapped_y
-
This field contains the y position measured with wrapped lines.
-
-
See Also
-
-
§3.4.35: Partial_Cursor
-
struct Partial_Cursor {
-
-int32_t pos;
-int32_t line;
-int32_t character;
-
-};
-
-
Description
Partial_Cursor describes the position of a cursor in all of
+the buffer is associated with a view to give the x/y values meaning.
Fields
pos
This field contains the cursor's position in absolute positioning.
line
This field contains the number of the line where the cursor is located. This field is one based.
character
This field contains the number of the column where the cursor is located. This field is one based.
unwrapped_x
This field contains the x position measured with unwrapped lines.
unwrapped_y
This field contains the y position measured with unwrapped lines.
wrapped_x
This field contains the x position measured with wrapped lines.
wrapped_y
This field contains the y position measured with wrapped lines.
See Also
§3.4.35: Partial_Cursor
struct Partial_Cursor {
int32_t pos;
int32_t line;
int32_t character;
};
Description
Partial_Cursor describes the position of a cursor in all of
the coordinate systems that a invariant to the View. In other words
the coordinate systems available here can be used on a buffer that is
-not currently associated with a View.
Fields
-
pos
-
This field contains the cursor's position in absolute positioning.
-
-
-
line
-
This field contains the number of the line where the cursor is located. This field is one based.
-
-
-
character
-
This field contains the number of the column where the cursor is located. This field is one based.
-
-
See Also
-
-
§3.4.36: Buffer_Seek
-
struct Buffer_Seek {
-
-Buffer_Seek_Type type;
-union {
-
-struct {
-
-int32_t pos;
-
-};
-struct {
-
-bool32 round_down;
-float x;
-float y;
-
-};
-struct {
-
-int32_t line;
-int32_t character;
-
-};
-
-};
-
-};
-
-
Description
Buffer_Seek describes the destination of a seek operation. There are helpers
-for concisely creating Buffer_Seek structs. They can be found in 4coder_buffer_types.h.
Fields
-
type
-
The type field determines the coordinate system of the seek operation.
-
-
-
pos
-
The pos field specified the pos when the seek is in absolute position.
-
-
-
round_down
-
For xy coordinate seeks, rounding down means that any x in the box of the
+not currently associated with a View.
Fields
pos
This field contains the cursor's position in absolute positioning.
line
This field contains the number of the line where the cursor is located. This field is one based.
character
This field contains the number of the column where the cursor is located. This field is one based.
See Also
§3.4.36: Buffer_Seek
struct Buffer_Seek {
Buffer_Seek_Type type;
union {
struct {
int32_t pos;
};
struct {
bool32 round_down;
float x;
float y;
};
struct {
int32_t line;
int32_t character;
};
};
};
Description
Buffer_Seek describes the destination of a seek operation. There are helpers
+for concisely creating Buffer_Seek structs. They can be found in 4coder_buffer_types.h.
Fields
type
The type field determines the coordinate system of the seek operation.
pos
The pos field specified the pos when the seek is in absolute position.
round_down
For xy coordinate seeks, rounding down means that any x in the box of the
character lands on that character. For instance when clicking rounding down is the
user's expected behavior. Not rounding down means that the right hand portion of
the character's box, which is closer to the next character, will land on that next
character. The unrounded behavior is the expected behavior when moving vertically
- and keeping the preferred x.
-
-
-
x
-
The x coordinate for xy type seeks.
-
-
-
y
-
The y coordinate for xy type seeks.
-
-
-
line
-
The line number of a line-character type seek.
-
-
-
character
-
The character number of a line-character type seek.
-
-
See Also
-
-
§3.4.37: Buffer_Edit
-
struct Buffer_Edit {
-
-int32_t str_start;
-int32_t len;
-int32_t start;
-int32_t end;
-
-};
-
-
Description
Buffer_Edit describes a range of a buffer and string to replace that range.
+ and keeping the preferred x.
x
The x coordinate for xy type seeks.
y
The y coordinate for xy type seeks.
line
The line number of a line-character type seek.
character
The character number of a line-character type seek.
See Also
§3.4.37: Buffer_Edit
struct Buffer_Edit {
int32_t str_start;
int32_t len;
int32_t start;
int32_t end;
};
Description
Buffer_Edit describes a range of a buffer and string to replace that range.
A Buffer_Edit has to be paired with a string that contains the actual text that
-will be replaced into the buffer.
Fields
-
str_start
-
The str_start field specifies the first character in the accompanying string that corresponds with this edit.
-
-
-
len
-
The len field specifies the length of the string being written into the buffer.
-
-
-
start
-
The start field specifies the start of the range in the buffer to replace in absolute position.
-
-
-
end
-
The end field specifies one past the end of the range in the buffer to replace in absolute position.
-
-
-
-
§3.4.38: Buffer_Summary
-
struct Buffer_Summary {
-
-bool32 exists;
-bool32 ready;
-int32_t buffer_id;
-Access_Flag lock_flags;
-int32_t size;
-int32_t line_count;
-char * file_name;
-int32_t file_name_len;
-char * buffer_name;
-int32_t buffer_name_len;
-bool32 is_lexed;
-int32_t map_id;
-bool32 unwrapped_lines;
-
-};
-
-
Description
Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.
Fields
-
exists
-
This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder.
- When this field is false the summary is referred to as a "null summary".
-
-
-
ready
-
If this is not a null summary, this field indicates whether the buffer has finished loading.
-
-
-
buffer_id
-
If this is not a null summary this field is the id of the associated buffer.
- If this is a null summary then buffer_id is 0.
-
-
-
lock_flags
-
If this is not a null summary, this field contains flags describing the protection status of the buffer.
-
-
-
size
-
If this is not a null summary, this field specifies the size of the text in the buffer.
-
-
-
line_count
-
If this is not a null summary, this field specifies the number of lines in the buffer.
-
-
-
file_name
-
If this is not a null summary, this field specifies the file name associated to this buffer.
-
-
-
file_name_len
-
This field specifies the length of the file_name string.
-
-
-
buffer_name
-
If this is not a null summary, this field specifies the name of the buffer.
-
-
-
buffer_name_len
-
This field specifies the length of the buffer_name string.
-
-
-
is_lexed
-
If this is not a null summary, this field indicates whether the buffer is set to lex tokens.
-
-
-
map_id
-
If this is not a null summary, this field specifies the id of the command map for this buffer.
-
-
-
unwrapped_lines
-
If this is not a null summary, this field indicates whether the buffer 'prefers' wrapped lines.
-
-
See Also
-
-
§3.4.39: View_Summary
-
struct View_Summary {
-
-bool32 exists;
-int32_t view_id;
-int32_t buffer_id;
-Access_Flag lock_flags;
-Full_Cursor cursor;
-Full_Cursor mark;
-float preferred_x;
-float line_height;
-bool32 unwrapped_lines;
-bool32 show_whitespace;
-i32_Rect file_region;
-GUI_Scroll_Vars scroll_vars;
-
-};
-
-
Description
View_Summary acts as a handle to a view and describes the state of the view.
Fields
-
exists
-
This field indicates whether the View_Summary describes a view that is open in 4coder.
- When this field is false the summary is referred to as a "null summary".
-
-
-
view_id
-
If this is not a null summary, this field is the id of the associated view.
- If this is a null summary then view_id is 0.
-
-
-
buffer_id
-
If this is not a null summary, and this view looks at a buffer, this is the id of the buffer.
-
-
-
lock_flags
-
If this is not a null summary, this field contains flags describing the protection status of the view.
-
-
-
cursor
-
If this is not a null summary, this describes the position of the cursor.
-
-
-
mark
-
If this is not a null summary, this describes the position of the mark.
-
-
-
preferred_x
-
If this is not a null summary, this is the x position that is maintained in vertical navigation.
-
-
-
line_height
-
If this is not a null summary, this specifies the height of a line rendered in the view.
-
-
-
unwrapped_lines
-
If this is not a null summary, this indicates that the view is set to render with unwrapped lines.
-
-
-
show_whitespace
-
If this is not a null summary, this indicates that the view is set to highlight white space.
-
-
-
file_region
-
If this is not a null summary, this describes the screen position in which this view's buffer is displayed.
-
-
-
scroll_vars
-
If this is not a null summary, this describes the scrolling position inside the view.
-
-
See Also
-
-
-
§3.4.41: Query_Bar
-
struct Query_Bar {
-
-String prompt;
-String string;
-
-};
-
-
Description
Query_Bar is a struct used to store information in the user's control
-that will be displayed as a drop down bar durring an interactive command.
Fields
-
prompt
-
This specifies the prompt portion of the drop down bar.
-
-
-
string
-
This specifies the main string portion of the drop down bar.
-
-
-
-
§3.4.42: Event_Message
-
struct Event_Message {
-
-int32_t type;
-
-};
-
-
Description
This feature is not implemented.
Fields
-
type
-
This feature is not implemented.
-
-
-
-
§3.4.43: Theme_Color
-
struct Theme_Color {
-
-Style_Tag tag;
-int_color color;
-
-};
-
-
Description
Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme .
Fields
-
-
See Also
-
§4 String Library
-
§4.1 String Intro
-
-
-Coming Soon
-
§4.2 String Function List
-
-
§4.3 String Function Descriptions
-
-§4.3.1: char_is_slash
-
-fstr_bool char_is_slash(
-
char c
)
-
-
Description
This call returns non-zero if c is \ or /.
-§4.3.2: char_to_upper
-
-char char_to_upper(
-
char c
)
-
-
Description
If c is a lowercase letter this call returns the uppercase equivalent, otherwise it returns c.
-§4.3.3: char_to_lower
-
-char char_to_lower(
-
char c
)
-
-
Description
If c is an uppercase letter this call returns the lowercase equivalent, otherwise it returns c.
-§4.3.4: char_is_whitespace
-
-fstr_bool char_is_whitespace(
-
char c
)
-
-
Description
This call returns non-zero if c is whitespace.
-§4.3.5: char_is_alpha_numeric
-
-fstr_bool char_is_alpha_numeric(
-
char c
)
-
-
Description
This call returns non-zero if c is any alphanumeric character including underscore.
-§4.3.6: char_is_alpha_numeric_true
-
-fstr_bool char_is_alpha_numeric_true(
-
char c
)
-
-
Description
This call returns non-zero if c is any alphanumeric character no including underscore.
-§4.3.7: char_is_alpha
-
-fstr_bool char_is_alpha(
-
char c
)
-
-
Description
This call returns non-zero if c is any alphabetic character including underscore.
-§4.3.8: char_is_alpha_true
-
-fstr_bool char_is_alpha_true(
-
char c
)
-
-
Description
This call returns non-zero if c is any alphabetic character.
-§4.3.9: char_is_hex
-
-fstr_bool char_is_hex(
-
char c
)
-
-
Description
This call returns non-zero if c is any valid hexadecimal digit.
-§4.3.10: char_is_numeric
-
-fstr_bool char_is_numeric(
-
char c
)
-
-
Description
This call returns non-zero if c is any valid decimal digit.
-§4.3.11: string_zero
-
-String string_zero(
-
void
)
-
-
Description
This call returns a String struct of zeroed members.
-§4.3.12: make_string_cap
-
-String make_string_cap(
-
void *str,
int32_t size,
int32_t mem_size
)
-
-
Parameters
-
str
-
The str parameter provides the of memory with which the string shall operate.
-
-
-
size
-
The size parameter expresses the initial size of the string.
-If the memory does not already contain a useful string this should be zero.
-
-
-
mem_size
-
The mem_size parameter expresses the full size of the memory provided by str.
-
-
Description
This call returns the String created from the parameters.
-§4.3.13: make_string
-
-String make_string(
-
void *str,
int32_t size
)
-
-
Parameters
-
str
-
The str parameter provides the of memory with which the string shall operate.
-
-
-
size
-
The size parameter expresses the initial size of the string.
+will be replaced into the buffer.
Fields
str_start
The str_start field specifies the first character in the accompanying string that corresponds with this edit.
len
The len field specifies the length of the string being written into the buffer.
start
The start field specifies the start of the range in the buffer to replace in absolute position.
end
The end field specifies one past the end of the range in the buffer to replace in absolute position.
§3.4.38: Buffer_Summary
struct Buffer_Summary {
bool32 exists;
bool32 ready;
int32_t buffer_id;
Access_Flag lock_flags;
int32_t size;
int32_t line_count;
char * file_name;
int32_t file_name_len;
char * buffer_name;
int32_t buffer_name_len;
bool32 is_lexed;
int32_t map_id;
bool32 unwrapped_lines;
};
Description
Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.
Fields
exists
This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder.
+ When this field is false the summary is referred to as a "null summary".
ready
If this is not a null summary, this field indicates whether the buffer has finished loading.
buffer_id
If this is not a null summary this field is the id of the associated buffer.
+ If this is a null summary then buffer_id is 0.
lock_flags
If this is not a null summary, this field contains flags describing the protection status of the buffer.
size
If this is not a null summary, this field specifies the size of the text in the buffer.
line_count
If this is not a null summary, this field specifies the number of lines in the buffer.
file_name
If this is not a null summary, this field specifies the file name associated to this buffer.
file_name_len
This field specifies the length of the file_name string.
buffer_name
If this is not a null summary, this field specifies the name of the buffer.
buffer_name_len
This field specifies the length of the buffer_name string.
is_lexed
If this is not a null summary, this field indicates whether the buffer is set to lex tokens.
map_id
If this is not a null summary, this field specifies the id of the command map for this buffer.
unwrapped_lines
If this is not a null summary, this field indicates whether the buffer 'prefers' wrapped lines.
See Also
§3.4.39: View_Summary
struct View_Summary {
bool32 exists;
int32_t view_id;
int32_t buffer_id;
Access_Flag lock_flags;
Full_Cursor cursor;
Full_Cursor mark;
float preferred_x;
float line_height;
bool32 unwrapped_lines;
bool32 show_whitespace;
i32_Rect file_region;
GUI_Scroll_Vars scroll_vars;
};
Description
View_Summary acts as a handle to a view and describes the state of the view.
Fields
exists
This field indicates whether the View_Summary describes a view that is open in 4coder.
+ When this field is false the summary is referred to as a "null summary".
view_id
If this is not a null summary, this field is the id of the associated view.
+ If this is a null summary then view_id is 0.
buffer_id
If this is not a null summary, then this is the id of the buffer this view currently sees.
lock_flags
If this is not a null summary, this field contains flags describing the protection status of the view.
cursor
If this is not a null summary, this describes the position of the cursor.
mark
If this is not a null summary, this describes the position of the mark.
preferred_x
If this is not a null summary, this is the x position that is maintained in vertical navigation.
line_height
If this is not a null summary, this specifies the height of a line rendered in the view.
unwrapped_lines
If this is not a null summary, this indicates that the view is set to render with unwrapped lines.
show_whitespace
If this is not a null summary, this indicates that the view is set to highlight white space.
file_region
If this is not a null summary, this describes the screen position in which this view's buffer is displayed.
scroll_vars
If this is not a null summary, this describes the scrolling position inside the view.
See Also
§3.4.41: Query_Bar
struct Query_Bar {
String prompt;
String string;
};
Description
Query_Bar is a struct used to store information in the user's control
+that will be displayed as a drop down bar durring an interactive command.
Fields
prompt
This specifies the prompt portion of the drop down bar.
string
This specifies the main string portion of the drop down bar.
§3.4.42: Event_Message
struct Event_Message {
int32_t type;
};
Description
This feature is not implemented.
Fields
type
This feature is not implemented.
§3.4.43: Theme_Color
struct Theme_Color {
Style_Tag tag;
int_color color;
};
Description
Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme .
Fields
See Also
§3.4.44: Cpp_Token_Type
enum Cpp_Token_Type;
Description
A Cpp_Token_Type classifies a token to make parsing easier. Some types are not
+actually output by the lexer, but exist because parsers will also make use of token
+types in their own output.
Values
CPP_TOKEN_KEY_OPERATOR
This type is not stored in token output from the lexer.
CPP_TOKEN_KEY_CONTROL_FLOW
CPP_TOKEN_KEY_TYPE_DECLARATION
CPP_TOKEN_INTEGER_CONSTANT
CPP_TOKEN_CHARACTER_CONSTANT
CPP_TOKEN_FLOATING_CONSTANT
CPP_TOKEN_STRING_CONSTANT
CPP_TOKEN_BOOLEAN_CONSTANT
CPP_TOKEN_PARENTHESE_OPEN
CPP_TOKEN_PARENTHESE_CLOSE
CPP_TOKEN_STAR
This is an 'ambiguous' token type because it requires
+ parsing to determine the full nature of the token.
CPP_TOKEN_AMPERSAND
This is an 'ambiguous' token type because it requires
+ parsing to determine the full nature of the token.
CPP_TOKEN_TILDE
This is an 'ambiguous' token type because it requires
+ parsing to determine the full nature of the token.
CPP_TOKEN_PLUS
This is an 'ambiguous' token type because it requires
+ parsing to determine the full nature of the token.
CPP_TOKEN_MINUS
This is an 'ambiguous' token type because it requires
+ parsing to determine the full nature of the token.
CPP_TOKEN_INCREMENT
This is an 'ambiguous' token type because it requires
+ parsing to determine the full nature of the token.
CPP_TOKEN_DECREMENT
This is an 'ambiguous' token type because it requires
+ parsing to determine the full nature of the token.
CPP_TOKEN_POSTINC
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_POSTDEC
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_FUNC_STYLE_CAST
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_CALL
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_INDEX
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_PREINC
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_PREDEC
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_POSITIVE
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_NEGAITVE
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_BIT_NOT
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_CAST
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DEREF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_PTR
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_ADDRESS
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_REF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_NEW_ARRAY
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DELETE_ARRAY
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_MUL
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_ADD
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_SUB
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_BIT_AND
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_EOF
This type is for parser use, it is not output by the lexer.
§3.4.45: Cpp_Token
struct Cpp_Token {
Cpp_Token_Type type;
int32_t start, size;
uint16_t state_flags;
uint16_t flags;
};
Fields
§3.4.46: Cpp_Token_Flag
enum Cpp_Token_Flag;
Values
CPP_TFLAG_PP_DIRECTIVE = 0x2
CPP_TFLAG_BAD_ENDING = 0x8
CPP_TFLAG_MULTILINE = 0x10
CPP_TFLAG_PARAMETERIZED = 0x20
CPP_TFLAG_IS_OPERATOR = 0x40
CPP_TFLAG_IS_KEYWORD = 0x80
§3.4.47: Cpp_Preprocessor_State
enum Cpp_Preprocessor_State;
Values
CPP_LEX_PP_MACRO_IDENTIFIER
§3.4.48: Cpp_Token_Stack
struct Cpp_Token_Stack {
Cpp_Token * tokens;
int32_t count, max_count;
};
Fields
§3.4.49: Cpp_Get_Token_Result
struct Cpp_Get_Token_Result {
int32_t token_index;
int32_t in_whitespace;
};
Fields
§3.4.50: Cpp_Relex_State
struct Cpp_Relex_State {
char * data;
int32_t size;
Cpp_Token_Stack * stack;
int32_t start, end, amount;
int32_t start_token_i;
int32_t end_token_i;
int32_t relex_start;
int32_t tolerance;
int32_t space_request;
};
Fields
+
§4 String Library
§4.1 String Intro
Coming Soon§4.2 String Function List
§4.3 String Function Descriptions
§4.3.1: char_is_slash
fstr_bool char_is_slash(
char c
)
Description
This call returns non-zero if c is \ or /.
§4.3.2: char_to_upper
char char_to_upper(
char c
)
Description
If c is a lowercase letter this call returns the uppercase equivalent, otherwise it returns c.
§4.3.3: char_to_lower
char char_to_lower(
char c
)
Description
If c is an uppercase letter this call returns the lowercase equivalent, otherwise it returns c.
§4.3.4: char_is_whitespace
fstr_bool char_is_whitespace(
char c
)
Description
This call returns non-zero if c is whitespace.
§4.3.5: char_is_alpha_numeric
fstr_bool char_is_alpha_numeric(
char c
)
Description
This call returns non-zero if c is any alphanumeric character including underscore.
§4.3.6: char_is_alpha_numeric_true
fstr_bool char_is_alpha_numeric_true(
char c
)
Description
This call returns non-zero if c is any alphanumeric character no including underscore.
§4.3.7: char_is_alpha
fstr_bool char_is_alpha(
char c
)
Description
This call returns non-zero if c is any alphabetic character including underscore.
§4.3.8: char_is_alpha_true
fstr_bool char_is_alpha_true(
char c
)
Description
This call returns non-zero if c is any alphabetic character.
§4.3.9: char_is_hex
fstr_bool char_is_hex(
char c
)
Description
This call returns non-zero if c is any valid hexadecimal digit.
§4.3.10: char_is_numeric
fstr_bool char_is_numeric(
char c
)
Description
This call returns non-zero if c is any valid decimal digit.
§4.3.11: make_string_cap
String make_string_cap(
void *str,
int32_t size,
int32_t mem_size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string.
+If the memory does not already contain a useful string this should be zero.
mem_size
The mem_size parameter expresses the full size of the memory provided by str.
Description
This call returns the String created from the parameters.
§4.3.12: make_string
String make_string(
void *str,
int32_t size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string.
If the memory does not already contain a useful string this should be zero. Since this version
does not specify the size of the memory it is also assumed that this size is the maximum size
-of the memory.
-
-
Description
This call returns the String created from the parameters.
-
§4.3.14: make_lit_string
-
-#define make_lit_string(s)
-
Description
This macro takes a literal string in quotes and uses it to create a String
-with the correct size and memory size. Strings created this way should usually not be mutated.
-
§4.3.15: make_fixed_width_string
-
-#define make_fixed_width_string(s)
-
Description
This macro takes a local char array with a fixed width and uses it to create
-an empty String with the correct size and memory size to operate on the array.
-
§4.3.16: expand_str
-
-#define expand_str(s)
-
Description
This macro is a helper for any calls that take a char*,integer pair to specify a
-string. This macro expands to both of those parameters from one String struct.
-
§4.3.17: str_size
-
-int32_t str_size(
-
char *str
)
-
-
Description
This call returns the number of bytes before a null terminator starting at str.
-
§4.3.18: make_string_slowly
-
-String make_string_slowly(
-
void *str
)
-
-
Description
This call makes a string by counting the number of bytes before a null terminator and
-treating that as the size and memory size of the string.
-
§4.3.19: substr_tail
-
-String substr_tail(
-
String str,
int32_t start
)
-
-
Description
This call creates a substring of str that starts with an offset from str's base.
+of the memory.
Description
This call returns the String created from the parameters.
§4.3.13: make_lit_string
#define make_lit_string(s)
Description
This macro takes a literal string in quotes and uses it to create a String
+with the correct size and memory size. Strings created this way should usually not be mutated.
§4.3.14: make_fixed_width_string
#define make_fixed_width_string(s)
Description
This macro takes a local char array with a fixed width and uses it to create
+an empty String with the correct size and memory size to operate on the array.
§4.3.15: expand_str
#define expand_str(s)
Description
This macro is a helper for any calls that take a char*,integer pair to specify a
+string. This macro expands to both of those parameters from one String struct.
§4.3.16: str_size
int32_t str_size(
char *str
)
Description
This call returns the number of bytes before a null terminator starting at str.
§4.3.17: make_string_slowly
String make_string_slowly(
void *str
)
Description
This call makes a string by counting the number of bytes before a null terminator and
+treating that as the size and memory size of the string.
§4.3.18: substr_tail
String substr_tail(
String str,
int32_t start
)
Description
This call creates a substring of str that starts with an offset from str's base.
The new string uses the same underlying memory so both strings will see changes.
-Usually strings created this way should only go through immutable calls.
-
§4.3.20: substr
-
-String substr(
-
String str,
int32_t start,
int32_t size
)
-
-
Description
This call creates a substring of str that starts with an offset from str's base,
+Usually strings created this way should only go through immutable calls.
§4.3.19: substr
String substr(
String str,
int32_t start,
int32_t size
)
Description
This call creates a substring of str that starts with an offset from str's base,
and has a fixed size. The new string uses the same underlying memory so both strings
-will see changes. Usually strings created this way should only go through immutable calls.
-
§4.3.21: skip_whitespace
-
-String skip_whitespace(
-
String str
)
-
-
Description
This call creates a substring that starts with the first non-whitespace character of str.
+will see changes. Usually strings created this way should only go through immutable calls.
§4.3.20: skip_whitespace
String skip_whitespace(
String str
)
Description
This call creates a substring that starts with the first non-whitespace character of str.
Like other substr calls, the new string uses the underlying memory and so should usually be
-considered immutable.
See Also
-
§4.3.22: chop_whitespace
-
-String chop_whitespace(
-
String str
)
-
-
Description
This call creates a substring that ends with the last non-whitespace character of str.
+considered immutable.
See Also
§4.3.21: chop_whitespace
String chop_whitespace(
String str
)
Description
This call creates a substring that ends with the last non-whitespace character of str.
Like other substr calls, the new string uses the underlying memory and so should usually be
-considered immutable.
See Also
-
§4.3.23: skip_chop_whitespace
-
-String skip_chop_whitespace(
-
String str
)
-
-
Description
This call is equivalent to calling skip_whitespace and chop_whitespace together.
See Also
-
§4.3.24: tailstr
-
-String tailstr(
-
String str
)
-
-
Description
This call returns an empty String with underlying memory taken from
-the portion of str's memory that is not used.
-
§4.3.25: match_cc
-
-fstr_bool match_cc(
-
char *a,
char *b
)
-
-
Description
This call returns non-zero if a and b are equivalent.
-
§4.3.26: match_sc
-
-fstr_bool match_sc(
-
String a,
char *b
)
-
-
Description
This call returns non-zero if a and b are equivalent.
-
§4.3.27: match_cs
-
-fstr_bool match_cs(
-
char *a,
String b
)
-
-
Description
This call returns non-zero if a and b are equivalent.
-
§4.3.28: match_ss
-
-fstr_bool match_ss(
-
String a,
String b
)
-
-
Description
This call returns non-zero if a and b are equivalent.
-
§4.3.29: match_part_ccl
-
-fstr_bool match_part_ccl(
-
char *a,
char *b,
int32_t *len
)
-
-
Parameters
-
len
-
If this call returns non-zero this parameter is used to output the length of b.
-
-
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
-In other words this call returns non-zero if b is a prefix of a.
-
§4.3.30: match_part_scl
-
-fstr_bool match_part_scl(
-
String a,
char *b,
int32_t *len
)
-
-
Parameters
-
len
-
If this call returns non-zero this parameter is used to output the length of b.
-
-
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
-In other words this call returns non-zero if b is a prefix of a.
-
§4.3.31: match_part_cc
-
-fstr_bool match_part_cc(
-
char *a,
char *b
)
-
-
Parameters
-
len
-
If this call returns non-zero this parameter is used to output the length of b.
-
-
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
-In other words this call returns non-zero if b is a prefix of a.
-
§4.3.32: match_part_sc
-
-fstr_bool match_part_sc(
-
String a,
char *b
)
-
-
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
-In other words this call returns non-zero if b is a prefix of a.
-
§4.3.33: match_part_cs
-
-fstr_bool match_part_cs(
-
char *a,
String b
)
-
-
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
-In other words this call returns non-zero if b is a prefix of a.
-
§4.3.34: match_part_ss
-
-fstr_bool match_part_ss(
-
String a,
String b
)
-
-
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
-In other words this call returns non-zero if b is a prefix of a.
-
§4.3.35: match_insensitive_cc
-
-fstr_bool match_insensitive_cc(
-
char *a,
char *b
)
-
-
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.
-
§4.3.36: match_insensitive_sc
-
-fstr_bool match_insensitive_sc(
-
String a,
char *b
)
-
-
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.
-
§4.3.37: match_insensitive_cs
-
-fstr_bool match_insensitive_cs(
-
char *a,
String b
)
-
-
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.
-
§4.3.38: match_insensitive_ss
-
-fstr_bool match_insensitive_ss(
-
String a,
String b
)
-
-
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.
-
§4.3.39: match_part_insensitive_ccl
-
-fstr_bool match_part_insensitive_ccl(
-
char *a,
char *b,
int32_t *len
)
-
-
Parameters
-
len
-
If this call returns non-zero this parameter is used to output the length of b.
-
-
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
-
§4.3.40: match_part_insensitive_scl
-
-fstr_bool match_part_insensitive_scl(
-
String a,
char *b,
int32_t *len
)
-
-
Parameters
-
len
-
If this call returns non-zero this parameter is used to output the length of b.
-
-
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
-
§4.3.41: match_part_insensitive_cc
-
-fstr_bool match_part_insensitive_cc(
-
char *a,
char *b
)
-
-
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
-
§4.3.42: match_part_insensitive_sc
-
-fstr_bool match_part_insensitive_sc(
-
String a,
char *b
)
-
-
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
-
§4.3.43: match_part_insensitive_cs
-
-fstr_bool match_part_insensitive_cs(
-
char *a,
String b
)
-
-
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
-
§4.3.44: match_part_insensitive_ss
-
-fstr_bool match_part_insensitive_ss(
-
String a,
String b
)
-
-
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
-
§4.3.45: compare_cc
-
-int32_t compare_cc(
-
char *a,
char *b
)
-
-
Description
This call returns zero if a and b are equivalent,
+considered immutable.
See Also
§4.3.22: skip_chop_whitespace
String skip_chop_whitespace(
String str
)
Description
This call is equivalent to calling skip_whitespace and chop_whitespace together.
See Also
§4.3.23: tailstr
String tailstr(
String str
)
Description
This call returns an empty String with underlying memory taken from
+the portion of str's memory that is not used.
§4.3.24: match_cc
fstr_bool match_cc(
char *a,
char *b
)
Description
This call returns non-zero if a and b are equivalent.
§4.3.25: match_sc
fstr_bool match_sc(
String a,
char *b
)
Description
This call returns non-zero if a and b are equivalent.
§4.3.26: match_cs
fstr_bool match_cs(
char *a,
String b
)
Description
This call returns non-zero if a and b are equivalent.
§4.3.27: match_ss
fstr_bool match_ss(
String a,
String b
)
Description
This call returns non-zero if a and b are equivalent.
§4.3.28: match_part_ccl
fstr_bool match_part_ccl(
char *a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
+In other words this call returns non-zero if b is a prefix of a.
§4.3.29: match_part_scl
fstr_bool match_part_scl(
String a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
+In other words this call returns non-zero if b is a prefix of a.
§4.3.30: match_part_cc
fstr_bool match_part_cc(
char *a,
char *b
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
+In other words this call returns non-zero if b is a prefix of a.
§4.3.31: match_part_sc
fstr_bool match_part_sc(
String a,
char *b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
+In other words this call returns non-zero if b is a prefix of a.
§4.3.32: match_part_cs
fstr_bool match_part_cs(
char *a,
String b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
+In other words this call returns non-zero if b is a prefix of a.
§4.3.33: match_part_ss
fstr_bool match_part_ss(
String a,
String b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b.
+In other words this call returns non-zero if b is a prefix of a.
§4.3.34: match_insensitive_cc
fstr_bool match_insensitive_cc(
char *a,
char *b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.
§4.3.35: match_insensitive_sc
fstr_bool match_insensitive_sc(
String a,
char *b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.
§4.3.36: match_insensitive_cs
fstr_bool match_insensitive_cs(
char *a,
String b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.
§4.3.37: match_insensitive_ss
fstr_bool match_insensitive_ss(
String a,
String b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.
§4.3.38: match_part_insensitive_ccl
fstr_bool match_part_insensitive_ccl(
char *a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
§4.3.39: match_part_insensitive_scl
fstr_bool match_part_insensitive_scl(
String a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
§4.3.40: match_part_insensitive_cc
fstr_bool match_part_insensitive_cc(
char *a,
char *b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
§4.3.41: match_part_insensitive_sc
fstr_bool match_part_insensitive_sc(
String a,
char *b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
§4.3.42: match_part_insensitive_cs
fstr_bool match_part_insensitive_cs(
char *a,
String b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
§4.3.43: match_part_insensitive_ss
fstr_bool match_part_insensitive_ss(
String a,
String b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also
§4.3.44: compare_cc
int32_t compare_cc(
char *a,
char *b
)
Description
This call returns zero if a and b are equivalent,
it returns negative if a sorts before b alphabetically,
-and positive if a sorts after b alphabetically.
-
§4.3.46: compare_sc
-
-int32_t compare_sc(
-
String a,
char *b
)
-
-
Description
This call returns zero if a and b are equivalent,
+and positive if a sorts after b alphabetically.
§4.3.45: compare_sc
int32_t compare_sc(
String a,
char *b
)
Description
This call returns zero if a and b are equivalent,
it returns negative if a sorts before b alphabetically,
-and positive if a sorts after b alphabetically.
-
§4.3.47: compare_cs
-
-int32_t compare_cs(
-
char *a,
String b
)
-
-
Description
This call returns zero if a and b are equivalent,
+and positive if a sorts after b alphabetically.
§4.3.46: compare_cs
int32_t compare_cs(
char *a,
String b
)
Description
This call returns zero if a and b are equivalent,
it returns negative if a sorts before b alphabetically,
-and positive if a sorts after b alphabetically.
-
§4.3.48: compare_ss
-
-int32_t compare_ss(
-
String a,
String b
)
-
-
Description
This call returns zero if a and b are equivalent,
+and positive if a sorts after b alphabetically.
§4.3.47: compare_ss
int32_t compare_ss(
String a,
String b
)
Description
This call returns zero if a and b are equivalent,
it returns negative if a sorts before b alphabetically,
-and positive if a sorts after b alphabetically.
-
§4.3.49: find_c_char
-
-int32_t find_c_char(
-
char *str,
int32_t start,
char character
)
-
-
Parameters
-
str
-
The str parameter provides a null terminated string to search.
-
-
-
start
-
The start parameter provides the index of the first character in str to search.
-
-
-
character
-
The character parameter provides the character for which to search.
-
-
Description
This call returns the index of the first occurance of character, or the size of the string
-if the character is not found.
-
§4.3.50: find_s_char
-
-int32_t find_s_char(
-
String str,
int32_t start,
char character
)
-
-
Parameters
-
str
-
The str parameter provides a string to search.
-
-
-
start
-
The start parameter provides the index of the first character in str to search.
-
-
-
character
-
The character parameter provides the character for which to search.
-
-
Description
This call returns the index of the first occurance of character, or the size of the string
-if the character is not found.
-
§4.3.51: rfind_s_char
-
-int32_t rfind_s_char(
-
String str,
int32_t start,
char character
)
-
-
Parameters
-
str
-
The str parameter provides a string to search.
-
-
-
start
-
The start parameter provides the index of the first character in str to search.
-
-
-
character
-
The character parameter provides the character for which to search.
-
-
Description
This call looks for the largest index less than or equal to the start position where
-the given character occurs. If the index is found it is returned otherwise -1 is returned.
-
§4.3.52: find_c_chars
-
-int32_t find_c_chars(
-
char *str,
int32_t start,
char *characters
)
-
-
Parameters
-
str
-
The str parameter provides a null terminated string to search.
-
-
-
start
-
The start parameter provides the index of the first character in str to search.
-
-
-
character
-
The characters parameter provides a null terminated array of characters for which to search.
-
-
Description
This call returns the index of the first occurance of a character in the characters array,
-or the size of the string if no such character is not found.
-
§4.3.53: find_s_chars
-
-int32_t find_s_chars(
-
String str,
int32_t start,
char *characters
)
-
-
Parameters
-
str
-
The str parameter provides a string to search.
-
-
-
start
-
The start parameter provides the index of the first character in str to search.
-
-
-
character
-
The characters parameter provides a null terminated array of characters for which to search.
-
-
Description
This call returns the index of the first occurance of a character in the characters array,
-or the size of the string if no such character is not found.
-
§4.3.54: find_substr_c
-
-int32_t find_substr_c(
-
char *str,
int32_t start,
String seek
)
-
-
Parameters
-
str
-
The str parameter provides a null terminated string to search.
-
-
-
start
-
The start parameter provides the index of the first character in str to search.
-
-
-
seek
-
The seek parameter provides a string to find in str.
-
-
Description
This call returns the index of the first occurance of the seek substring in str or the
-size of str if no such substring in str is found.
-
§4.3.55: find_substr_s
-
-int32_t find_substr_s(
-
String str,
int32_t start,
String seek
)
-
-
Parameters
-
str
-
The str parameter provides a string to search.
-
-
-
start
-
The start parameter provides the index of the first character in str to search.
-
-
-
seek
-
The seek parameter provides a string to find in str.
-
-
Description
This call returns the index of the first occurance of the seek substring in str or the
-size of str if no such substring in str is found.
-
§4.3.56: rfind_substr_s
-
-int32_t rfind_substr_s(
-
String str,
int32_t start,
String seek
)
-
-
Parameters
-
str
-
The str parameter provides a string to search.
-
-
-
start
-
The start parameter provides the index of the first character in str to search.
-
-
-
seek
-
The seek parameter provides a string to find in str.
-
-
Description
This call returns the index of the last occurance of the seek substring in str
-or -1 if no such substring in str is found.
-
§4.3.57: find_substr_insensitive_c
-
-int32_t find_substr_insensitive_c(
-
char *str,
int32_t start,
String seek
)
-
-
Parameters
-
str
-
The str parameter provides a null terminated string to search.
-
-
-
start
-
The start parameter provides the index of the first character in str to search.
-
-
-
seek
-
The seek parameter provides a string to find in str.
-
-
Description
This call acts as find_substr under case insensitive comparison.
See Also
-
§4.3.58: find_substr_insensitive_s
-
-int32_t find_substr_insensitive_s(
-
String str,
int32_t start,
String seek
)
-
-
Parameters
-
str
-
The str parameter provides a string to search.
-
-
-
start
-
The start parameter provides the index of the first character in str to search.
-
-
-
seek
-
The seek parameter provides a string to find in str.
-
-
Description
This call acts as find_substr under case insensitive comparison.
See Also
-
§4.3.59: has_substr_c
-
-fstr_bool has_substr_c(
-
char *s,
String seek
)
-
-
Description
This call returns non-zero if the string s contains a substring equivalent to seek.
-
§4.3.60: has_substr_s
-
-fstr_bool has_substr_s(
-
String s,
String seek
)
-
-
Description
This call returns non-zero if the string s contains a substring equivalent to seek.
-
§4.3.61: has_substr_insensitive_c
-
-fstr_bool has_substr_insensitive_c(
-
char *s,
String seek
)
-
-
Description
This call returns non-zero if the string s contains a substring equivalent to seek
-under case insensitive comparison.
-
§4.3.62: has_substr_insensitive_s
-
-fstr_bool has_substr_insensitive_s(
-
String s,
String seek
)
-
-
Description
This call returns non-zero if the string s contains a substring equivalent to seek
-under case insensitive comparison.
-
§4.3.63: copy_fast_unsafe_cc
-
-int32_t copy_fast_unsafe_cc(
-
char *dest,
char *src
)
-
-
Description
This call performs a copy from the src buffer to the dest buffer.
+and positive if a sorts after b alphabetically.
§4.3.48: find_c_char
int32_t find_c_char(
char *str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call returns the index of the first occurance of character, or the size of the string
+if the character is not found.
§4.3.49: find_s_char
int32_t find_s_char(
String str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call returns the index of the first occurance of character, or the size of the string
+if the character is not found.
§4.3.50: rfind_s_char
int32_t rfind_s_char(
String str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call looks for the largest index less than or equal to the start position where
+the given character occurs. If the index is found it is returned otherwise -1 is returned.
§4.3.51: find_c_chars
int32_t find_c_chars(
char *str,
int32_t start,
char *characters
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
character
The characters parameter provides a null terminated array of characters for which to search.
Description
This call returns the index of the first occurance of a character in the characters array,
+or the size of the string if no such character is not found.
§4.3.52: find_s_chars
int32_t find_s_chars(
String str,
int32_t start,
char *characters
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The characters parameter provides a null terminated array of characters for which to search.
Description
This call returns the index of the first occurance of a character in the characters array,
+or the size of the string if no such character is not found.
§4.3.53: find_substr_c
int32_t find_substr_c(
char *str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the first occurance of the seek substring in str or the
+size of str if no such substring in str is found.
§4.3.54: find_substr_s
int32_t find_substr_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the first occurance of the seek substring in str or the
+size of str if no such substring in str is found.
§4.3.55: rfind_substr_s
int32_t rfind_substr_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the last occurance of the seek substring in str
+or -1 if no such substring in str is found.
§4.3.56: find_substr_insensitive_c
int32_t find_substr_insensitive_c(
char *str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call acts as find_substr under case insensitive comparison.
See Also
§4.3.57: find_substr_insensitive_s
int32_t find_substr_insensitive_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call acts as find_substr under case insensitive comparison.
See Also
§4.3.58: has_substr_c
fstr_bool has_substr_c(
char *s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek.
§4.3.59: has_substr_s
fstr_bool has_substr_s(
String s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek.
§4.3.60: has_substr_insensitive_c
fstr_bool has_substr_insensitive_c(
char *s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek
+under case insensitive comparison.
§4.3.61: has_substr_insensitive_s
fstr_bool has_substr_insensitive_s(
String s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek
+under case insensitive comparison.
§4.3.62: copy_fast_unsafe_cc
int32_t copy_fast_unsafe_cc(
char *dest,
char *src
)
Description
This call performs a copy from the src buffer to the dest buffer.
The copy does not stop until a null terminator is found in src. There
is no safety against overrun so dest must be large enough to contain src.
The null terminator is not written to dest. This call returns the number
-of bytes coppied to dest.
-
§4.3.64: copy_fast_unsafe_cs
-
-int32_t copy_fast_unsafe_cs(
-
char *dest,
String src
)
-
-
Description
This call performs a copy from the src string to the dest buffer.
+of bytes coppied to dest.
§4.3.63: copy_fast_unsafe_cs
int32_t copy_fast_unsafe_cs(
char *dest,
String src
)
Description
This call performs a copy from the src string to the dest buffer.
The copy does not stop until src.size characters are coppied. There
is no safety against overrun so dest must be large enough to contain src.
The null terminator is not written to dest. This call returns the number
-of bytes coppied to dest.
-
§4.3.65: copy_checked_ss
-
-fstr_bool copy_checked_ss(
-
String *dest,
String src
)
-
-
Description
This call performs a copy from the src string to the dest string.
+of bytes coppied to dest.
§4.3.64: copy_checked_ss
fstr_bool copy_checked_ss(
String *dest,
String src
)
Description
This call performs a copy from the src string to the dest string.
The memory_size of dest is checked before any coppying is done.
-This call returns non-zero on a successful copy.
-
§4.3.66: copy_partial_sc
-
-fstr_bool copy_partial_sc(
-
String *dest,
char *src
)
-
-
Description
This call performs a copy from the src buffer to the dest string.
+This call returns non-zero on a successful copy.
§4.3.65: copy_partial_sc
fstr_bool copy_partial_sc(
String *dest,
char *src
)
Description
This call performs a copy from the src buffer to the dest string.
The memory_size of dest is checked if the entire copy cannot be performed,
as many bytes as possible are coppied to dest. This call returns non-zero
-if the entire string is coppied to dest.
-
§4.3.67: copy_partial_ss
-
-fstr_bool copy_partial_ss(
-
String *dest,
String src
)
-
-
Description
This call performs a copy from the src string to the dest string.
+if the entire string is coppied to dest.
§4.3.66: copy_partial_ss
fstr_bool copy_partial_ss(
String *dest,
String src
)
Description
This call performs a copy from the src string to the dest string.
The memory_size of dest is checked if the entire copy cannot be performed,
as many bytes as possible are coppied to dest. This call returns non-zero
-if the entire string is coppied to dest.
-
§4.3.68: copy_cc
-
-int32_t copy_cc(
-
char *dest,
char *src
)
-
-
Description
This call performs a copy from src to dest equivalent to copy_fast_unsafe.
See Also
-
§4.3.69: copy_ss
-
-void copy_ss(
-
String *dest,
String src
)
-
-
Description
This call performs a copy from src to dest equivalent to copy_checked.
See Also
-
§4.3.70: copy_sc
-
-void copy_sc(
-
String *dest,
char *src
)
-
-
Description
This call performs a copy from src to dest equivalent to copy_partial.
See Also
-
§4.3.71: append_checked_ss
-
-fstr_bool append_checked_ss(
-
String *dest,
String src
)
-
-
Description
This call checks if there is enough space in dest's underlying memory
-to append src onto dest. If there is src is appended and the call returns non-zero.
-
§4.3.72: append_partial_sc
-
-fstr_bool append_partial_sc(
-
String *dest,
char *src
)
-
-
Description
This call attemps to append as much of src into the space in dest's underlying memory
-as possible. If the entire string is appended the call returns non-zero.
-
§4.3.73: append_partial_ss
-
-fstr_bool append_partial_ss(
-
String *dest,
String src
)
-
-
Description
This call attemps to append as much of src into the space in dest's underlying memory
-as possible. If the entire string is appended the call returns non-zero.
-
§4.3.74: append_s_char
-
-fstr_bool append_s_char(
-
String *dest,
char c
)
-
-
Description
This call attemps to append c onto dest. If there is space left in dest's underlying
-memory the character is appended and the call returns non-zero.
-
§4.3.75: append_ss
-
-fstr_bool append_ss(
-
String *dest,
String src
)
-
-
Description
This call is equivalent to append_partial.
See Also
-
§4.3.76: append_sc
-
-fstr_bool append_sc(
-
String *dest,
char *src
)
-
-
Description
This call is equivalent to append_partial.
See Also
-
§4.3.77: terminate_with_null
-
-fstr_bool terminate_with_null(
-
String *str
)
-
-
Description
This call attemps to append a null terminator onto str without effecting the
+if the entire string is coppied to dest.
§4.3.67: copy_cc
int32_t copy_cc(
char *dest,
char *src
)
Description
This call performs a copy from src to dest equivalent to copy_fast_unsafe.
See Also
§4.3.68: copy_ss
void copy_ss(
String *dest,
String src
)
Description
This call performs a copy from src to dest equivalent to copy_checked.
See Also
§4.3.69: copy_sc
void copy_sc(
String *dest,
char *src
)
Description
This call performs a copy from src to dest equivalent to copy_partial.
See Also
§4.3.70: append_checked_ss
fstr_bool append_checked_ss(
String *dest,
String src
)
Description
This call checks if there is enough space in dest's underlying memory
+to append src onto dest. If there is src is appended and the call returns non-zero.
§4.3.71: append_partial_sc
fstr_bool append_partial_sc(
String *dest,
char *src
)
Description
This call attemps to append as much of src into the space in dest's underlying memory
+as possible. If the entire string is appended the call returns non-zero.
§4.3.72: append_partial_ss
fstr_bool append_partial_ss(
String *dest,
String src
)
Description
This call attemps to append as much of src into the space in dest's underlying memory
+as possible. If the entire string is appended the call returns non-zero.
§4.3.73: append_s_char
fstr_bool append_s_char(
String *dest,
char c
)
Description
This call attemps to append c onto dest. If there is space left in dest's underlying
+memory the character is appended and the call returns non-zero.
§4.3.74: append_ss
fstr_bool append_ss(
String *dest,
String src
)
Description
This call is equivalent to append_partial.
See Also
§4.3.75: append_sc
fstr_bool append_sc(
String *dest,
char *src
)
Description
This call is equivalent to append_partial.
See Also
§4.3.76: terminate_with_null
fstr_bool terminate_with_null(
String *str
)
Description
This call attemps to append a null terminator onto str without effecting the
size of str. This is usually called when the time comes to pass the the string to an
API that requires a null terminator. This call returns non-zero if there was a spare
-byte in the strings underlying memory.
-
§4.3.78: append_padding
-
-fstr_bool append_padding(
-
String *dest,
char c,
int32_t target_size
)
-
-
Description
This call pads out dest so that it has a size of target_size by appending
+byte in the strings underlying memory.
§4.3.77: append_padding
fstr_bool append_padding(
String *dest,
char c,
int32_t target_size
)
Description
This call pads out dest so that it has a size of target_size by appending
the padding character c until the target size is achieved. This call returns
-non-zero if dest does not run out of space in the underlying memory.
-
§4.3.79: replace_char
-
-void replace_char(
-
String *str,
char replace,
char with
)
-
-
Parameters
-
str
-
The str parameter provides the string in which replacement shall be performed.
-
-
-
replace
-
The replace character specifies which character should be replaced.
-
-
-
with
-
The with character specifies what to write into the positions where replacement occurs.
-
-
Description
This call replaces all occurances of character in str with another character.
-
§4.3.80: to_lower_cc
-
-void to_lower_cc(
-
char *src,
char *dst
)
-
-
Parameters
-
src
-
The source string to conver to lowercase. This string must be null terminated.
-
-
-
dst
-
The destination buffer to receive the converted string. This must be large
-enough to contain all of src and a null terminator.
-
-
Description
Rewrites the string in src into dst with all letters lowercased. src and dst should not
+non-zero if dest does not run out of space in the underlying memory.
§4.3.78: replace_char
void replace_char(
String *str,
char replace,
char with
)
Parameters
str
The str parameter provides the string in which replacement shall be performed.
replace
The replace character specifies which character should be replaced.
with
The with character specifies what to write into the positions where replacement occurs.
Description
This call replaces all occurances of character in str with another character.
§4.3.79: to_lower_cc
void to_lower_cc(
char *src,
char *dst
)
Parameters
src
The source string to conver to lowercase. This string must be null terminated.
dst
The destination buffer to receive the converted string. This must be large
+enough to contain all of src and a null terminator.
Description
Rewrites the string in src into dst with all letters lowercased. 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.
-
§4.3.81: to_lower_ss
-
-void to_lower_ss(
-
String *src,
String *dst
)
-
-
Parameters
-
src
-
The source string to conver to lowercase.
-
-
-
dst
-
The destination buffer to receive the converted string.
-This must have a capacity of at least the size of src.
-
-
Description
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.
-
§4.3.82: to_lower_s
-
-void to_lower_s(
-
String *str
)
-
-
Parameters
-
str
-
The string to be converted to all lowercase.
-
-
Description
This version of to_lower converts str to lowercase in place.
-
§4.3.83: to_upper_cc
-
-void to_upper_cc(
-
char *src,
char *dst
)
-
-
Parameters
-
src
-
The source string to convert to uppercase. This string must be null terminated.
-
-
-
dst
-
The destination buffer to receive the converted string.
-This must be large enough to contain all of src and a null terminator.
-
-
Description
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.
-
§4.3.84: to_upper_ss
-
-void to_upper_ss(
-
String *src,
String *dst
)
-
-
Parameters
-
src
-
The source string to convert to uppercase.
-
-
-
dst
-
The destination buffer to receive the converted string.
-This must have a capacity of at least the size of src.
-
-
Description
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.
-
§4.3.85: to_upper_s
-
-void to_upper_s(
-
String *str
)
-
-
Parameters
-
str
-
The string to be converted to all uppercase.
-
-
Description
This version of to_upper converts str to uppercase in place.
-
§4.3.86: to_camel_cc
-
-void to_camel_cc(
-
char *src,
char *dst
)
-
-
Parameters
-
src
-
The source string to convert to camel case.
-
-
-
dst
-
The destination buffer to receive the converted string.
-This must be large enough to contain all of src and a null terminator.
-
-
Description
Rewrites the string in src into dst. src and dst should not overlap
+string in place.
§4.3.80: to_lower_ss
void to_lower_ss(
String *dst,
String src
)
Parameters
dst
The destination buffer to receive the converted string.
+This must have a capacity of at least the size of src.
src
The source string to conver to lowercase.
Description
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.
§4.3.81: to_lower_s
void to_lower_s(
String *str
)
Parameters
str
The string to be converted to all lowercase.
Description
This version of to_lower converts str to lowercase in place.
§4.3.82: to_upper_cc
void to_upper_cc(
char *src,
char *dst
)
Parameters
src
The source string to convert to uppercase. This string must be null terminated.
dst
The destination buffer to receive the converted string.
+This must be large enough to contain all of src and a null terminator.
Description
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.
§4.3.83: to_upper_ss
void to_upper_ss(
String *dst,
String src
)
Parameters
dst
The destination buffer to receive the converted string.
+This must have a capacity of at least the size of src.
src
The source string to convert to uppercase.
Description
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.
§4.3.84: to_upper_s
void to_upper_s(
String *str
)
Parameters
str
The string to be converted to all uppercase.
Description
This version of to_upper converts str to uppercase in place.
§4.3.85: to_camel_cc
void to_camel_cc(
char *src,
char *dst
)
Parameters
src
The source string to convert to camel case.
dst
The destination buffer to receive the converted string.
+This must be large enough to contain all of src and a null terminator.
Description
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.
-
§4.3.87: int_to_str_size
-
-int32_t int_to_str_size(
-
int32_t x
)
-
-
Description
This call returns the number of bytes required to represent x as a string.
-
§4.3.88: int_to_str
-
-fstr_bool int_to_str(
-
String *dest,
int32_t x
)
-
-
Description
This call writes a string representation of x into dest. If there is enough
-space in dest this call returns non-zero.
-
§4.3.89: append_int_to_str
-
-fstr_bool append_int_to_str(
-
String *dest,
int32_t x
)
-
-
Description
This call appends a string representation of x onto dest. If there is enough
-space in dest this call returns non-zero.
-
§4.3.90: u64_to_str_size
-
-int32_t u64_to_str_size(
-
uint64_t x
)
-
-
Description
This call returns the number of bytes required to represent x as a string.
-
§4.3.91: u64_to_str
-
-fstr_bool u64_to_str(
-
String *dest,
uint64_t x
)
-
-
Description
This call writes a string representation of x into dest. If there is enough
-space in dest this call returns non-zero.
-
§4.3.92: append_u64_to_str
-
-fstr_bool append_u64_to_str(
-
String *dest,
uint64_t x
)
-
-
Description
This call appends a string representation of x onto dest. If there is enough
-space in dest this call returns non-zero.
-
§4.3.93: float_to_str_size
-
-int32_t float_to_str_size(
-
float x
)
-
-
Description
This call returns the number of bytes required to represent x as a string.
-
§4.3.94: append_float_to_str
-
-fstr_bool append_float_to_str(
-
String *dest,
float x
)
-
-
Description
This call writes a string representation of x into dest. If there is enough
-space in dest this call returns non-zero.
-
§4.3.95: float_to_str
-
-fstr_bool float_to_str(
-
String *dest,
float x
)
-
-
Description
This call appends a string representation of x onto dest. If there is enough
-space in dest this call returns non-zero.
-
§4.3.96: str_is_int_c
-
-int32_t str_is_int_c(
-
char *str
)
-
-
Description
If str is a valid string representation of an integer, this call returns non-zero
-
§4.3.97: str_is_int_s
-
-fstr_bool str_is_int_s(
-
String str
)
-
-
Description
If str is a valid string representation of an integer, this call returns non-zero.
-
§4.3.98: str_to_int_c
-
-int32_t str_to_int_c(
-
char *str
)
-
-
Description
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.
-
§4.3.99: str_to_int_s
-
-int32_t str_to_int_s(
-
String str
)
-
-
Description
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.
-
§4.3.100: hexchar_to_int
-
-int32_t hexchar_to_int(
-
char c
)
-
-
Description
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.
-
§4.3.101: int_to_hexchar
-
-char int_to_hexchar(
-
int32_t x
)
-
-
Description
If x is in the range [0,15] this call returns the equivalent lowercase hexadecimal digit.
-Otherwise the return is some nonsense value.
-
§4.3.102: hexstr_to_int
-
-uint32_t hexstr_to_int(
-
String str
)
-
-
Description
This call interprets str has a hexadecimal representation of an integer and returns
-the represented integer value.
-
§4.3.103: color_to_hexstr
-
-fstr_bool color_to_hexstr(
-
String *s,
uint32_t color
)
-
-
Description
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.
-
§4.3.104: hexstr_to_color
-
-fstr_bool hexstr_to_color(
-
String s,
uint32_t *out
)
-
-
Description
This call interprets s as a color and writes the 32-bit integer representation into out.
-
§4.3.105: reverse_seek_slash_pos
-
-int32_t reverse_seek_slash_pos(
-
String str,
int32_t pos
)
-
-
Description
This call searches for a slash in str by starting pos bytes from the end and going backwards.
-
§4.3.106: reverse_seek_slash
-
-int32_t reverse_seek_slash(
-
String str
)
-
-
Description
This call searches for a slash in str by starting at the end and going backwards.
-
§4.3.107: front_of_directory
-
-String front_of_directory(
-
String dir
)
-
-
Description
This call returns a substring of dir containing only the file name or
-folder name furthest to the right in the directory.
See Also
-
§4.3.108: path_of_directory
-
-String path_of_directory(
-
String dir
)
-
-
Description
This call returns a substring of dir containing the whole path except
-for the final file or folder name.
See Also
-
§4.3.109: set_last_folder_sc
-
-fstr_bool set_last_folder_sc(
-
String *dir,
char *folder_name,
char slash
)
-
-
Parameters
-
dir
-
The dir parameter is the directory string in which to set the last folder in the directory.
-
-
-
folder_name
-
The folder_name parameter is a null terminated string specifying the name to set
-at the end of the directory.
-
-
-
slash
-
The slash parameter specifies what slash to use between names in the directory.
-
-
Description
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.
-
§4.3.110: set_last_folder_ss
-
-fstr_bool set_last_folder_ss(
-
String *dir,
String folder_name,
char slash
)
-
-
Parameters
-
dir
-
The dir parameter is the directory string in which to set the last folder in the directory.
-
-
-
folder_name
-
The folder_name parameter is a string specifying the name to set at the end of the directory.
-
-
-
slash
-
The slash parameter specifies what slash to use between names in the directory.
-
-
Description
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.
-
§4.3.111: file_extension
-
-String file_extension(
-
String str
)
-
-
Description
This call returns a substring containing only the file extension of the provided filename.
See Also
-
§4.3.112: remove_extension
-
-fstr_bool remove_extension(
-
String *str
)
-
-
Description
This call attemps to delete a file extension off the end of a filename.
-This call returns non-zero on success.
-
§4.3.113: remove_last_folder
-
-fstr_bool remove_last_folder(
-
String *str
)
-
-
Description
This call attemps to delete a folder or filename off the end of a path string.
-This call returns non-zero on success.
-
§4.3.114: string_set_match
-
-fstr_bool string_set_match(
-
String *str_set,
int32_t count,
String str,
int32_t *match_index
)
-
-
Parameters
-
str_set
-
The str_set parameter is an array of String structs specifying matchable strings.
-
-
-
count
-
The count parameter specifies the number of String structs in the str_set array.
-
-
-
str
-
The str parameter specifies the string to match against the str_set.
-
-
-
match_index
-
If this call succeeds match_index is filled with the index into str_set where the match occurred.
-
-
Description
This call tries to see if str matches any of the strings in str_set. If there is a match the call
-succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.
See Also
-
-
-
+convert the string in place.
§4.3.86: int_to_str_size
int32_t int_to_str_size(
int32_t x
)
Description
This call returns the number of bytes required to represent x as a string.
§4.3.87: int_to_str
fstr_bool int_to_str(
String *dest,
int32_t x
)
Description
This call writes a string representation of x into dest. If there is enough
+space in dest this call returns non-zero.
§4.3.88: append_int_to_str
fstr_bool append_int_to_str(
String *dest,
int32_t x
)
Description
This call appends a string representation of x onto dest. If there is enough
+space in dest this call returns non-zero.
§4.3.89: u64_to_str_size
int32_t u64_to_str_size(
uint64_t x
)
Description
This call returns the number of bytes required to represent x as a string.
§4.3.90: u64_to_str
fstr_bool u64_to_str(
String *dest,
uint64_t x
)
Description
This call writes a string representation of x into dest. If there is enough
+space in dest this call returns non-zero.
§4.3.91: append_u64_to_str
fstr_bool append_u64_to_str(
String *dest,
uint64_t x
)
Description
This call appends a string representation of x onto dest. If there is enough
+space in dest this call returns non-zero.
§4.3.92: float_to_str_size
int32_t float_to_str_size(
float x
)
Description
This call returns the number of bytes required to represent x as a string.
§4.3.93: append_float_to_str
fstr_bool append_float_to_str(
String *dest,
float x
)
Description
This call writes a string representation of x into dest. If there is enough
+space in dest this call returns non-zero.
§4.3.94: float_to_str
fstr_bool float_to_str(
String *dest,
float x
)
Description
This call appends a string representation of x onto dest. If there is enough
+space in dest this call returns non-zero.
§4.3.95: str_is_int_c
int32_t str_is_int_c(
char *str
)
Description
If str is a valid string representation of an integer, this call returns non-zero
§4.3.96: str_is_int_s
fstr_bool str_is_int_s(
String str
)
Description
If str is a valid string representation of an integer, this call returns non-zero.
§4.3.97: str_to_int_c
int32_t str_to_int_c(
char *str
)
Description
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.
§4.3.98: str_to_int_s
int32_t str_to_int_s(
String str
)
Description
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.
§4.3.99: hexchar_to_int
int32_t hexchar_to_int(
char c
)
Description
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.
§4.3.100: int_to_hexchar
char int_to_hexchar(
int32_t x
)
Description
If x is in the range [0,15] this call returns the equivalent lowercase hexadecimal digit.
+Otherwise the return is some nonsense value.
§4.3.101: hexstr_to_int
uint32_t hexstr_to_int(
String str
)
Description
This call interprets str has a hexadecimal representation of an integer and returns
+the represented integer value.
§4.3.102: color_to_hexstr
fstr_bool color_to_hexstr(
String *s,
uint32_t color
)
Description
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.
§4.3.103: hexstr_to_color
fstr_bool hexstr_to_color(
String s,
uint32_t *out
)
Description
This call interprets s as a color and writes the 32-bit integer representation into out.
§4.3.104: reverse_seek_slash_pos
int32_t reverse_seek_slash_pos(
String str,
int32_t pos
)
Description
This call searches for a slash in str by starting pos bytes from the end and going backwards.
§4.3.105: reverse_seek_slash
int32_t reverse_seek_slash(
String str
)
Description
This call searches for a slash in str by starting at the end and going backwards.
§4.3.106: front_of_directory
String front_of_directory(
String dir
)
Description
This call returns a substring of dir containing only the file name or
+folder name furthest to the right in the directory.
See Also
§4.3.107: path_of_directory
String path_of_directory(
String dir
)
Description
This call returns a substring of dir containing the whole path except
+for the final file or folder name.
See Also
§4.3.108: set_last_folder_sc
fstr_bool set_last_folder_sc(
String *dir,
char *folder_name,
char slash
)
Parameters
dir
The dir parameter is the directory string in which to set the last folder in the directory.
folder_name
The folder_name parameter is a null terminated string specifying the name to set
+at the end of the directory.
slash
The slash parameter specifies what slash to use between names in the directory.
Description
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.
§4.3.109: set_last_folder_ss
fstr_bool set_last_folder_ss(
String *dir,
String folder_name,
char slash
)
Parameters
dir
The dir parameter is the directory string in which to set the last folder in the directory.
folder_name
The folder_name parameter is a string specifying the name to set at the end of the directory.
slash
The slash parameter specifies what slash to use between names in the directory.
Description
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.
§4.3.110: file_extension
String file_extension(
String str
)
Description
This call returns a substring containing only the file extension of the provided filename.
See Also
§4.3.111: remove_extension
fstr_bool remove_extension(
String *str
)
Description
This call attemps to delete a file extension off the end of a filename.
+This call returns non-zero on success.
§4.3.112: remove_last_folder
fstr_bool remove_last_folder(
String *str
)
Description
This call attemps to delete a folder or filename off the end of a path string.
+This call returns non-zero on success.
§4.3.113: string_set_match_table
fstr_bool string_set_match_table(
void *str_set,
int32_t item_size,
int32_t count,
String str,
int32_t *match_index
)
Parameters
str_set
The str_set parameter is an array of String structs specifying matchable strings.
count
The count parameter specifies the number of String structs in the str_set array.
str
The str parameter specifies the string to match against the str_set.
match_index
If this call succeeds match_index is filled with the index into str_set where the match occurred.
Description
This call tries to see if str matches any of the strings in str_set. If there is a match the call
+succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.
See Also
§4.3.114: string_set_match
fstr_bool string_set_match(
String *str_set,
int32_t count,
String str,
int32_t *match_index
)
Parameters
str_set
The str_set parameter is an array of String structs specifying matchable strings.
count
The count parameter specifies the number of String structs in the str_set array.
str
The str parameter specifies the string to match against the str_set.
match_index
If this call succeeds match_index is filled with the index into str_set where the match occurred.
Description
This call tries to see if str matches any of the strings in str_set. If there is a match the call
+succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.
See Also
\ No newline at end of file
diff --git a/4coder_custom_api.h b/4coder_custom_api.h
index 8d30bb89..64dd0a0e 100644
--- a/4coder_custom_api.h
+++ b/4coder_custom_api.h
@@ -119,72 +119,72 @@ typedef TOGGLE_FULLSCREEN_SIG(Toggle_Fullscreen_Function);
typedef IS_FULLSCREEN_SIG(Is_Fullscreen_Function);
typedef SEND_EXIT_SIGNAL_SIG(Send_Exit_Signal_Function);
struct Application_Links{
- void *memory;
- int32_t memory_size;
- Exec_Command_Function *exec_command;
- Exec_System_Command_Function *exec_system_command;
- Clipboard_Post_Function *clipboard_post;
- Clipboard_Count_Function *clipboard_count;
- Clipboard_Index_Function *clipboard_index;
- Get_Buffer_Count_Function *get_buffer_count;
- Get_Buffer_First_Function *get_buffer_first;
- Get_Buffer_Next_Function *get_buffer_next;
- Get_Buffer_Function *get_buffer;
- Get_Buffer_By_Name_Function *get_buffer_by_name;
- Buffer_Boundary_Seek_Function *buffer_boundary_seek;
- Buffer_Read_Range_Function *buffer_read_range;
- Buffer_Replace_Range_Function *buffer_replace_range;
- Buffer_Compute_Cursor_Function *buffer_compute_cursor;
- Buffer_Batch_Edit_Function *buffer_batch_edit;
- Buffer_Set_Setting_Function *buffer_set_setting;
- Buffer_Auto_Indent_Function *buffer_auto_indent;
- Create_Buffer_Function *create_buffer;
- Save_Buffer_Function *save_buffer;
- Kill_Buffer_Function *kill_buffer;
- Get_View_First_Function *get_view_first;
- Get_View_Next_Function *get_view_next;
- Get_View_Function *get_view;
- Get_Active_View_Function *get_active_view;
- Open_View_Function *open_view;
- Close_View_Function *close_view;
- Set_Active_View_Function *set_active_view;
- View_Set_Setting_Function *view_set_setting;
- View_Set_Split_Proportion_Function *view_set_split_proportion;
- View_Compute_Cursor_Function *view_compute_cursor;
- View_Set_Cursor_Function *view_set_cursor;
- View_Set_Scroll_Function *view_set_scroll;
- View_Set_Mark_Function *view_set_mark;
- View_Set_Highlight_Function *view_set_highlight;
- View_Set_Buffer_Function *view_set_buffer;
- View_Post_Fade_Function *view_post_fade;
- Get_User_Input_Function *get_user_input;
- Get_Command_Input_Function *get_command_input;
- Get_Mouse_State_Function *get_mouse_state;
- Start_Query_Bar_Function *start_query_bar;
- End_Query_Bar_Function *end_query_bar;
- Print_Message_Function *print_message;
- Change_Theme_Function *change_theme;
- Change_Font_Function *change_font;
- Buffer_Set_Font_Function *buffer_set_font;
- Set_Theme_Colors_Function *set_theme_colors;
- Get_Theme_Colors_Function *get_theme_colors;
- Directory_Get_Hot_Function *directory_get_hot;
- Get_File_List_Function *get_file_list;
- Free_File_List_Function *free_file_list;
- Memory_Allocate_Function *memory_allocate;
- Memory_Set_Protection_Function *memory_set_protection;
- Memory_Free_Function *memory_free;
- File_Exists_Function *file_exists;
- Directory_CD_Function *directory_cd;
- Get_4ed_Path_Function *get_4ed_path;
- Show_Mouse_Cursor_Function *show_mouse_cursor;
- Toggle_Fullscreen_Function *toggle_fullscreen;
- Is_Fullscreen_Function *is_fullscreen;
- Send_Exit_Signal_Function *send_exit_signal;
- void *cmd_context;
- void *system_links;
- void *current_coroutine;
- int32_t type_coroutine;
+Exec_Command_Function *exec_command;
+Exec_System_Command_Function *exec_system_command;
+Clipboard_Post_Function *clipboard_post;
+Clipboard_Count_Function *clipboard_count;
+Clipboard_Index_Function *clipboard_index;
+Get_Buffer_Count_Function *get_buffer_count;
+Get_Buffer_First_Function *get_buffer_first;
+Get_Buffer_Next_Function *get_buffer_next;
+Get_Buffer_Function *get_buffer;
+Get_Buffer_By_Name_Function *get_buffer_by_name;
+Buffer_Boundary_Seek_Function *buffer_boundary_seek;
+Buffer_Read_Range_Function *buffer_read_range;
+Buffer_Replace_Range_Function *buffer_replace_range;
+Buffer_Compute_Cursor_Function *buffer_compute_cursor;
+Buffer_Batch_Edit_Function *buffer_batch_edit;
+Buffer_Set_Setting_Function *buffer_set_setting;
+Buffer_Auto_Indent_Function *buffer_auto_indent;
+Create_Buffer_Function *create_buffer;
+Save_Buffer_Function *save_buffer;
+Kill_Buffer_Function *kill_buffer;
+Get_View_First_Function *get_view_first;
+Get_View_Next_Function *get_view_next;
+Get_View_Function *get_view;
+Get_Active_View_Function *get_active_view;
+Open_View_Function *open_view;
+Close_View_Function *close_view;
+Set_Active_View_Function *set_active_view;
+View_Set_Setting_Function *view_set_setting;
+View_Set_Split_Proportion_Function *view_set_split_proportion;
+View_Compute_Cursor_Function *view_compute_cursor;
+View_Set_Cursor_Function *view_set_cursor;
+View_Set_Scroll_Function *view_set_scroll;
+View_Set_Mark_Function *view_set_mark;
+View_Set_Highlight_Function *view_set_highlight;
+View_Set_Buffer_Function *view_set_buffer;
+View_Post_Fade_Function *view_post_fade;
+Get_User_Input_Function *get_user_input;
+Get_Command_Input_Function *get_command_input;
+Get_Mouse_State_Function *get_mouse_state;
+Start_Query_Bar_Function *start_query_bar;
+End_Query_Bar_Function *end_query_bar;
+Print_Message_Function *print_message;
+Change_Theme_Function *change_theme;
+Change_Font_Function *change_font;
+Buffer_Set_Font_Function *buffer_set_font;
+Set_Theme_Colors_Function *set_theme_colors;
+Get_Theme_Colors_Function *get_theme_colors;
+Directory_Get_Hot_Function *directory_get_hot;
+Get_File_List_Function *get_file_list;
+Free_File_List_Function *free_file_list;
+Memory_Allocate_Function *memory_allocate;
+Memory_Set_Protection_Function *memory_set_protection;
+Memory_Free_Function *memory_free;
+File_Exists_Function *file_exists;
+Directory_CD_Function *directory_cd;
+Get_4ed_Path_Function *get_4ed_path;
+Show_Mouse_Cursor_Function *show_mouse_cursor;
+Toggle_Fullscreen_Function *toggle_fullscreen;
+Is_Fullscreen_Function *is_fullscreen;
+Send_Exit_Signal_Function *send_exit_signal;
+void *memory;
+int32_t memory_size;
+void *cmd_context;
+void *system_links;
+void *current_coroutine;
+int32_t type_coroutine;
};
#define FillAppLinksAPI(app_links) do{\
app_links->exec_command = Exec_Command;\
@@ -246,4 +246,4 @@ app_links->get_4ed_path = Get_4ed_Path;\
app_links->show_mouse_cursor = Show_Mouse_Cursor;\
app_links->toggle_fullscreen = Toggle_Fullscreen;\
app_links->is_fullscreen = Is_Fullscreen;\
-app_links->send_exit_signal = Send_Exit_Signal; } while(false)
+app_links->send_exit_signal = Send_Exit_Signal;} while(false)
diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp
index dff873d4..78133f09 100644
--- a/4coder_default_include.cpp
+++ b/4coder_default_include.cpp
@@ -1916,7 +1916,7 @@ CUSTOM_COMMAND_SIG(query_replace){
int32_t pos, new_pos;
bar.prompt = make_lit_string("Replace? (y)es, (n)ext, (esc)\n");
- bar.string = string_zero();
+ bar.string = null_string;
app->start_query_bar(app, &bar, 0);
diff --git a/4cpp_lexer_types.h b/4coder_lexer_types.h
similarity index 58%
rename from 4cpp_lexer_types.h
rename to 4coder_lexer_types.h
index a7954c2c..8d58de15 100644
--- a/4cpp_lexer_types.h
+++ b/4coder_lexer_types.h
@@ -4,12 +4,14 @@
#ifndef FCPP_LEXER_TYPES_INC
#define FCPP_LEXER_TYPES_INC
-#if 0
+#ifndef ENUM
+#define ENUM(type,name) typedef type name; enum name##_
+#endif
/* DOC(A Cpp_Token_Type classifies a token to make parsing easier. Some types are not
actually output by the lexer, but exist because parsers will also make use of token
types in their own output.) */
-ENUM(int32_t, Cpp_Token_Type){
+ENUM(uint32_t, Cpp_Token_Type){
CPP_TOKEN_JUNK,
CPP_TOKEN_COMMENT,
@@ -222,177 +224,6 @@ ENUM(int32_t, Cpp_Token_Type){
CPP_TOKEN_TYPE_COUNT
};
-#endif
-
-
-#if 1
-enum Cpp_Token_Type{
- CPP_TOKEN_JUNK,
- CPP_TOKEN_COMMENT,
-
- CPP_PP_INCLUDE,
- CPP_PP_DEFINE,
- CPP_PP_UNDEF,
- CPP_PP_IF,
- CPP_PP_IFDEF,
- CPP_PP_IFNDEF,
- CPP_PP_ELSE,
- CPP_PP_ELIF,
- CPP_PP_ENDIF,
- CPP_PP_ERROR,
- CPP_PP_IMPORT,
- CPP_PP_USING,
- CPP_PP_LINE,
- CPP_PP_PRAGMA,
- CPP_PP_STRINGIFY,
- CPP_PP_CONCAT,
- CPP_PP_UNKNOWN,
-
- CPP_TOKEN_KEY_TYPE,
- CPP_TOKEN_KEY_MODIFIER,
- CPP_TOKEN_KEY_QUALIFIER,
- CPP_TOKEN_KEY_OPERATOR, // NOTE(allen): This type is not actually stored in tokens
- CPP_TOKEN_KEY_CONTROL_FLOW,
- CPP_TOKEN_KEY_CAST,
- CPP_TOKEN_KEY_TYPE_DECLARATION,
- CPP_TOKEN_KEY_ACCESS,
- CPP_TOKEN_KEY_LINKAGE,
- CPP_TOKEN_KEY_OTHER,
-
- CPP_TOKEN_IDENTIFIER,
- CPP_TOKEN_INTEGER_CONSTANT,
- CPP_TOKEN_CHARACTER_CONSTANT,
- CPP_TOKEN_FLOATING_CONSTANT,
- CPP_TOKEN_STRING_CONSTANT,
- CPP_TOKEN_BOOLEAN_CONSTANT,
-
- CPP_TOKEN_STATIC_ASSERT,
-
- CPP_TOKEN_BRACKET_OPEN,
- CPP_TOKEN_BRACKET_CLOSE,
- CPP_TOKEN_PARENTHESE_OPEN,
- CPP_TOKEN_PARENTHESE_CLOSE,
- CPP_TOKEN_BRACE_OPEN,
- CPP_TOKEN_BRACE_CLOSE,
- CPP_TOKEN_SEMICOLON,
- CPP_TOKEN_ELLIPSIS,
-
- // NOTE(allen): Ambiguous tokens, lexer only,
- // parser figures out the real meaning
- CPP_TOKEN_STAR,
- CPP_TOKEN_AMPERSAND,
- CPP_TOKEN_TILDE,
- CPP_TOKEN_PLUS,
- CPP_TOKEN_MINUS,
- CPP_TOKEN_INCREMENT,
- CPP_TOKEN_DECREMENT,
-
- // NOTE(allen): Precedence 1, LtoR
- CPP_TOKEN_SCOPE,
-
- // NOTE(allen): Precedence 2, LtoR
- CPP_TOKEN_POSTINC, // from increment, parser only
- CPP_TOKEN_POSTDEC, // from decrement, parser only
- CPP_TOKEN_FUNC_STYLE_CAST, // parser only
- CPP_TOKEN_CPP_STYLE_CAST,
- CPP_TOKEN_CALL, // from open paren, parser only
- CPP_TOKEN_INDEX, // from bracket open, parser only
- CPP_TOKEN_DOT,
- CPP_TOKEN_ARROW,
-
- // NOTE(allen): Precedence 3, RtoL
- CPP_TOKEN_PREINC, // from increment, parser only
- CPP_TOKEN_PREDEC, // from decrement, parser only
- CPP_TOKEN_POSITIVE, // from plus, parser only
- CPP_TOKEN_NEGAITVE, // from minus, parser only
- CPP_TOKEN_NOT,
- CPP_TOKEN_BIT_NOT, // from tilde, direct from 'compl'
- CPP_TOKEN_CAST, // from open paren, parser only
- CPP_TOKEN_DEREF, // from star, parser only
- CPP_TOKEN_TYPE_PTR, // from star, parser only
- CPP_TOKEN_ADDRESS, // from ampersand, parser only
- CPP_TOKEN_TYPE_REF, // from ampersand, parser only
- CPP_TOKEN_SIZEOF,
- CPP_TOKEN_ALIGNOF,
- CPP_TOKEN_DECLTYPE,
- CPP_TOKEN_TYPEID,
- CPP_TOKEN_NEW,
- CPP_TOKEN_DELETE,
- CPP_TOKEN_NEW_ARRAY, // from new and bracket open, parser only
- CPP_TOKEN_DELETE_ARRAY, // from delete and bracket open, parser only
-
- // NOTE(allen): Precedence 4, LtoR
- CPP_TOKEN_PTRDOT,
- CPP_TOKEN_PTRARROW,
-
- // NOTE(allen): Precedence 5, LtoR
- CPP_TOKEN_MUL, // from start, parser only
- CPP_TOKEN_DIV,
- CPP_TOKEN_MOD,
-
- // NOTE(allen): Precedence 6, LtoR
- CPP_TOKEN_ADD, // from plus, parser only
- CPP_TOKEN_SUB, // from minus, parser only
-
- // NOTE(allen): Precedence 7, LtoR
- CPP_TOKEN_LSHIFT,
- CPP_TOKEN_RSHIFT,
-
- // NOTE(allen): Precedence 8, LtoR
- CPP_TOKEN_LESS,
- CPP_TOKEN_GRTR,
- CPP_TOKEN_GRTREQ,
- CPP_TOKEN_LESSEQ,
-
- // NOTE(allen): Precedence 9, LtoR
- CPP_TOKEN_EQEQ,
- CPP_TOKEN_NOTEQ,
-
- // NOTE(allen): Precedence 10, LtoR
- CPP_TOKEN_BIT_AND, // from ampersand, direct from 'bitand'
-
- // NOTE(allen): Precedence 11, LtoR
- CPP_TOKEN_BIT_XOR,
-
- // NOTE(allen): Precedence 12, LtoR
- CPP_TOKEN_BIT_OR,
-
- // NOTE(allen): Precedence 13, LtoR
- CPP_TOKEN_AND,
-
- // NOTE(allen): Precedence 14, LtoR
- CPP_TOKEN_OR,
-
- // NOTE(allen): Precedence 15, RtoL
- CPP_TOKEN_TERNARY_QMARK,
- CPP_TOKEN_COLON,
- CPP_TOKEN_THROW,
- CPP_TOKEN_EQ,
- CPP_TOKEN_ADDEQ,
- CPP_TOKEN_SUBEQ,
- CPP_TOKEN_MULEQ,
- CPP_TOKEN_DIVEQ,
- CPP_TOKEN_MODEQ,
- CPP_TOKEN_LSHIFTEQ,
- CPP_TOKEN_RSHIFTEQ,
- CPP_TOKEN_ANDEQ,
- CPP_TOKEN_OREQ,
- CPP_TOKEN_XOREQ,
-
- // NOTE(allen): Precedence 16, LtoR
- CPP_TOKEN_COMMA,
-
- CPP_TOKEN_DEFINED,
- CPP_TOKEN_INCLUDE_FILE,
- CPP_TOKEN_ERROR_MESSAGE,
-
- // NOTE(allen): used in the parser
- CPP_TOKEN_EOF,
-
- CPP_TOKEN_TYPE_COUNT
-};
-#endif
-
struct Cpp_Token{
Cpp_Token_Type type;
int32_t start, size;
@@ -400,18 +231,18 @@ struct Cpp_Token{
uint16_t flags;
};
-enum Cpp_Token_Flag{
- CPP_TFLAG_IGNORE = 1 << 0,
- CPP_TFLAG_PP_DIRECTIVE = 1 << 1,
- CPP_TFLAG_PP_BODY = 1 << 2,
- CPP_TFLAG_BAD_ENDING = 1 << 3,
- CPP_TFLAG_MULTILINE = 1 << 4,
- CPP_TFLAG_PARAMETERIZED = 1 << 5,
- CPP_TFLAG_IS_OPERATOR = 1 << 6,
- CPP_TFLAG_IS_KEYWORD = 1 << 7
+ENUM(uint16_t, Cpp_Token_Flag){
+ CPP_TFLAG_IGNORE = 0x1,
+ CPP_TFLAG_PP_DIRECTIVE = 0x2,
+ CPP_TFLAG_PP_BODY = 0x4,
+ CPP_TFLAG_BAD_ENDING = 0x8,
+ CPP_TFLAG_MULTILINE = 0x10,
+ CPP_TFLAG_PARAMETERIZED = 0x20,
+ CPP_TFLAG_IS_OPERATOR = 0x40,
+ CPP_TFLAG_IS_KEYWORD = 0x80
};
-enum Cpp_Preprocessor_State{
+ENUM(uint16_t, Cpp_Preprocessor_State){
CPP_LEX_PP_DEFAULT,
CPP_LEX_PP_IDENTIFIER,
CPP_LEX_PP_MACRO_IDENTIFIER,
@@ -421,7 +252,6 @@ enum Cpp_Preprocessor_State{
CPP_LEX_PP_NUMBER,
CPP_LEX_PP_ERROR,
CPP_LEX_PP_JUNK,
- // NEVER ADD BELOW THIS
CPP_LEX_PP_COUNT
};
@@ -429,23 +259,7 @@ struct Cpp_Token_Stack{
Cpp_Token *tokens;
int32_t count, max_count;
};
-inline Cpp_Token_Stack
-cpp_token_stack_zero(){
- Cpp_Token_Stack stack={0};
- return(stack);
-}
-
-#if 0
-struct Cpp_Token_Merge{
- Cpp_Token new_token;
- int32_t did_merge;
-};
-#endif
-
-struct Seek_Result{
- int32_t pos;
- int32_t new_line;
-};
+static Cpp_Token_Stack null_cpp_token_stack = {0};
struct Cpp_Get_Token_Result{
int32_t token_index;
diff --git a/4coder_string.h b/4coder_string.h
index bf954f63..d521319c 100644
--- a/4coder_string.h
+++ b/4coder_string.h
@@ -47,347 +47,208 @@ typedef struct Offset_String{
#if !defined(FCODER_STRING_H)
#define FCODER_STRING_H
-FSTRING_INLINE fstr_bool char_is_slash(char c);
-FSTRING_INLINE char char_to_upper(char c);
-FSTRING_INLINE char char_to_lower(char c);
-FSTRING_INLINE fstr_bool char_is_whitespace(char c);
-FSTRING_INLINE fstr_bool char_is_alpha_numeric(char c);
-FSTRING_INLINE fstr_bool char_is_alpha_numeric_true(char c);
-FSTRING_INLINE fstr_bool char_is_alpha(char c);
-FSTRING_INLINE fstr_bool char_is_alpha_true(char c);
-FSTRING_INLINE fstr_bool char_is_hex(char c);
-FSTRING_INLINE fstr_bool char_is_numeric(char c);
-FSTRING_INLINE String string_zero(void);
-FSTRING_INLINE String make_string_cap(void *str, int32_t size, int32_t mem_size);
-FSTRING_INLINE String make_string(void *str, int32_t size);
+FSTRING_INLINE fstr_bool char_is_slash(char c);
+FSTRING_INLINE char char_to_upper(char c);
+FSTRING_INLINE char char_to_lower(char c);
+FSTRING_INLINE fstr_bool char_is_whitespace(char c);
+FSTRING_INLINE fstr_bool char_is_alpha_numeric(char c);
+FSTRING_INLINE fstr_bool char_is_alpha_numeric_true(char c);
+FSTRING_INLINE fstr_bool char_is_alpha(char c);
+FSTRING_INLINE fstr_bool char_is_alpha_true(char c);
+FSTRING_INLINE fstr_bool char_is_hex(char c);
+FSTRING_INLINE fstr_bool char_is_numeric(char c);
+FSTRING_INLINE String make_string_cap(void *str, int32_t size, int32_t mem_size);
+FSTRING_INLINE String make_string(void *str, int32_t size);
#ifndef make_lit_string
-# define make_lit_string(s) (make_string_cap((char*)(s), sizeof(s)-1, sizeof(s)))
+# define make_lit_string(s) (make_string_cap((char*)(s), sizeof(s)-1, sizeof(s)))
#endif
#ifndef make_fixed_width_string
-# define make_fixed_width_string(s) (make_string_cap((char*)(s), 0, sizeof(s)))
+# define make_fixed_width_string(s) (make_string_cap((char*)(s), 0, sizeof(s)))
#endif
#ifndef expand_str
-# define expand_str(s) ((s).str), ((s).size)
-#endif
-FSTRING_LINK int32_t str_size(char *str);
-FSTRING_INLINE String make_string_slowly(void *str);
-FSTRING_INLINE String substr_tail(String str, int32_t start);
-FSTRING_INLINE String substr(String str, int32_t start, int32_t size);
-FSTRING_LINK String skip_whitespace(String str);
-FSTRING_LINK String chop_whitespace(String str);
-FSTRING_LINK String skip_chop_whitespace(String str);
-FSTRING_INLINE String tailstr(String str);
-FSTRING_LINK fstr_bool match_cc(char *a, char *b);
-FSTRING_LINK fstr_bool match_sc(String a, char *b);
-FSTRING_INLINE fstr_bool match_cs(char *a, String b);
-FSTRING_LINK fstr_bool match_ss(String a, String b);
-FSTRING_LINK fstr_bool match_part_ccl(char *a, char *b, int32_t *len);
-FSTRING_LINK fstr_bool match_part_scl(String a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part_cc(char *a, char *b);
-FSTRING_INLINE fstr_bool match_part_sc(String a, char *b);
-FSTRING_LINK fstr_bool match_part_cs(char *a, String b);
-FSTRING_LINK fstr_bool match_part_ss(String a, String b);
-FSTRING_LINK fstr_bool match_insensitive_cc(char *a, char *b);
-FSTRING_LINK fstr_bool match_insensitive_sc(String a, char *b);
-FSTRING_INLINE fstr_bool match_insensitive_cs(char *a, String b);
-FSTRING_LINK fstr_bool match_insensitive_ss(String a, String b);
-FSTRING_LINK fstr_bool match_part_insensitive_ccl(char *a, char *b, int32_t *len);
-FSTRING_LINK fstr_bool match_part_insensitive_scl(String a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part_insensitive_cc(char *a, char *b);
-FSTRING_INLINE fstr_bool match_part_insensitive_sc(String a, char *b);
-FSTRING_LINK fstr_bool match_part_insensitive_cs(char *a, String b);
-FSTRING_LINK fstr_bool match_part_insensitive_ss(String a, String b);
-FSTRING_LINK int32_t compare_cc(char *a, char *b);
-FSTRING_LINK int32_t compare_sc(String a, char *b);
-FSTRING_INLINE int32_t compare_cs(char *a, String b);
-FSTRING_LINK int32_t compare_ss(String a, String b);
-FSTRING_LINK int32_t find_c_char(char *str, int32_t start, char character);
-FSTRING_LINK int32_t find_s_char(String str, int32_t start, char character);
-FSTRING_LINK int32_t rfind_s_char(String str, int32_t start, char character);
-FSTRING_LINK int32_t find_c_chars(char *str, int32_t start, char *characters);
-FSTRING_LINK int32_t find_s_chars(String str, int32_t start, char *characters);
-FSTRING_LINK int32_t find_substr_c(char *str, int32_t start, String seek);
-FSTRING_LINK int32_t find_substr_s(String str, int32_t start, String seek);
-FSTRING_LINK int32_t rfind_substr_s(String str, int32_t start, String seek);
-FSTRING_LINK int32_t find_substr_insensitive_c(char *str, int32_t start, String seek);
-FSTRING_LINK int32_t find_substr_insensitive_s(String str, int32_t start, String seek);
-FSTRING_INLINE fstr_bool has_substr_c(char *s, String seek);
-FSTRING_INLINE fstr_bool has_substr_s(String s, String seek);
-FSTRING_INLINE fstr_bool has_substr_insensitive_c(char *s, String seek);
-FSTRING_INLINE fstr_bool has_substr_insensitive_s(String s, String seek);
-FSTRING_LINK int32_t copy_fast_unsafe_cc(char *dest, char *src);
-FSTRING_LINK int32_t copy_fast_unsafe_cs(char *dest, String src);
-FSTRING_LINK fstr_bool copy_checked_ss(String *dest, String src);
-FSTRING_LINK fstr_bool copy_partial_sc(String *dest, char *src);
-FSTRING_LINK fstr_bool copy_partial_ss(String *dest, String src);
-FSTRING_INLINE int32_t copy_cc(char *dest, char *src);
-FSTRING_INLINE void copy_ss(String *dest, String src);
-FSTRING_INLINE void copy_sc(String *dest, char *src);
-FSTRING_LINK fstr_bool append_checked_ss(String *dest, String src);
-FSTRING_LINK fstr_bool append_partial_sc(String *dest, char *src);
-FSTRING_LINK fstr_bool append_partial_ss(String *dest, String src);
-FSTRING_LINK fstr_bool append_s_char(String *dest, char c);
-FSTRING_INLINE fstr_bool append_ss(String *dest, String src);
-FSTRING_INLINE fstr_bool append_sc(String *dest, char *src);
-FSTRING_LINK fstr_bool terminate_with_null(String *str);
-FSTRING_LINK fstr_bool append_padding(String *dest, char c, int32_t target_size);
-FSTRING_LINK void replace_char(String *str, char replace, char with);
-FSTRING_LINK void to_lower_cc(char *src, char *dst);
-FSTRING_LINK void to_lower_ss(String *src, String *dst);
-FSTRING_LINK void to_lower_s(String *str);
-FSTRING_LINK void to_upper_cc(char *src, char *dst);
-FSTRING_LINK void to_upper_ss(String *src, String *dst);
-FSTRING_LINK void to_upper_s(String *str);
-FSTRING_LINK void to_camel_cc(char *src, char *dst);
-FSTRING_LINK int32_t int_to_str_size(int32_t x);
-FSTRING_LINK fstr_bool int_to_str(String *dest, int32_t x);
-FSTRING_LINK fstr_bool append_int_to_str(String *dest, int32_t x);
-FSTRING_LINK int32_t u64_to_str_size(uint64_t x);
-FSTRING_LINK fstr_bool u64_to_str(String *dest, uint64_t x);
-FSTRING_LINK fstr_bool append_u64_to_str(String *dest, uint64_t x);
-FSTRING_LINK int32_t float_to_str_size(float x);
-FSTRING_LINK fstr_bool append_float_to_str(String *dest, float x);
-FSTRING_LINK fstr_bool float_to_str(String *dest, float x);
-FSTRING_LINK int32_t str_is_int_c(char *str);
-FSTRING_LINK fstr_bool str_is_int_s(String str);
-FSTRING_LINK int32_t str_to_int_c(char *str);
-FSTRING_LINK int32_t str_to_int_s(String str);
-FSTRING_LINK int32_t hexchar_to_int(char c);
-FSTRING_LINK char int_to_hexchar(int32_t x);
-FSTRING_LINK uint32_t hexstr_to_int(String str);
-FSTRING_LINK fstr_bool color_to_hexstr(String *s, uint32_t color);
-FSTRING_LINK fstr_bool hexstr_to_color(String s, uint32_t *out);
-FSTRING_LINK int32_t reverse_seek_slash_pos(String str, int32_t pos);
-FSTRING_INLINE int32_t reverse_seek_slash(String str);
-FSTRING_INLINE String front_of_directory(String dir);
-FSTRING_INLINE String path_of_directory(String dir);
-FSTRING_LINK fstr_bool set_last_folder_sc(String *dir, char *folder_name, char slash);
-FSTRING_LINK fstr_bool set_last_folder_ss(String *dir, String folder_name, char slash);
-FSTRING_LINK String file_extension(String str);
-FSTRING_LINK fstr_bool remove_extension(String *str);
-FSTRING_LINK fstr_bool remove_last_folder(String *str);
-FSTRING_LINK fstr_bool string_set_match(String *str_set, int32_t count, String str, int32_t *match_index);
-
-#if !defined(FSTRING_C)
-
-// NOTE(allen): This section is here to enable nicer names
-// for C++ users who can have overloaded functions. None of
-// these functions add new features.
-FSTRING_INLINE String make_string(void *str, int32_t size, int32_t mem_size);
-FSTRING_INLINE String substr(String str, int32_t start);
-FSTRING_INLINE fstr_bool match(char *a, char *b);
-FSTRING_INLINE fstr_bool match(String a, char *b);
-FSTRING_INLINE fstr_bool match(char *a, String b);
-FSTRING_INLINE fstr_bool match(String a, String b);
-FSTRING_INLINE fstr_bool match_part(char *a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part(String a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part(char *a, char *b);
-FSTRING_INLINE fstr_bool match_part(String a, char *b);
-FSTRING_INLINE fstr_bool match_part(char *a, String b);
-FSTRING_INLINE fstr_bool match_part(String a, String b);
-FSTRING_INLINE fstr_bool match_insensitive(char *a, char *b);
-FSTRING_INLINE fstr_bool match_insensitive(String a, char *b);
-FSTRING_INLINE fstr_bool match_insensitive(char *a, String b);
-FSTRING_INLINE fstr_bool match_insensitive(String a, String b);
-FSTRING_INLINE fstr_bool match_part_insensitive(char *a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part_insensitive(String a, char *b, int32_t *len);
-FSTRING_INLINE fstr_bool match_part_insensitive(char *a, char *b);
-FSTRING_INLINE fstr_bool match_part_insensitive(String a, char *b);
-FSTRING_INLINE fstr_bool match_part_insensitive(char *a, String b);
-FSTRING_INLINE fstr_bool match_part_insensitive(String a, String b);
-FSTRING_INLINE int32_t compare(char *a, char *b);
-FSTRING_INLINE int32_t compare(String a, char *b);
-FSTRING_INLINE int32_t compare(char *a, String b);
-FSTRING_INLINE int32_t compare(String a, String b);
-FSTRING_INLINE int32_t find(char *str, int32_t start, char character);
-FSTRING_INLINE int32_t find(String str, int32_t start, char character);
-FSTRING_INLINE int32_t rfind(String str, int32_t start, char character);
-FSTRING_INLINE int32_t find(char *str, int32_t start, char *characters);
-FSTRING_INLINE int32_t find(String str, int32_t start, char *characters);
-FSTRING_INLINE int32_t find_substr(char *str, int32_t start, String seek);
-FSTRING_INLINE int32_t find_substr(String str, int32_t start, String seek);
-FSTRING_INLINE int32_t rfind_substr(String str, int32_t start, String seek);
-FSTRING_INLINE int32_t find_substr_insensitive(char *str, int32_t start, String seek);
-FSTRING_INLINE int32_t find_substr_insensitive(String str, int32_t start, String seek);
-FSTRING_INLINE fstr_bool has_substr(char *s, String seek);
-FSTRING_INLINE fstr_bool has_substr(String s, String seek);
-FSTRING_INLINE fstr_bool has_substr_insensitive(char *s, String seek);
-FSTRING_INLINE fstr_bool has_substr_insensitive(String s, String seek);
-FSTRING_INLINE int32_t copy_fast_unsafe(char *dest, char *src);
-FSTRING_INLINE int32_t copy_fast_unsafe(char *dest, String src);
-FSTRING_INLINE fstr_bool copy_checked(String *dest, String src);
-FSTRING_INLINE fstr_bool copy_partial(String *dest, char *src);
-FSTRING_INLINE fstr_bool copy_partial(String *dest, String src);
-FSTRING_INLINE int32_t copy(char *dest, char *src);
-FSTRING_INLINE void copy(String *dest, String src);
-FSTRING_INLINE void copy(String *dest, char *src);
-FSTRING_INLINE fstr_bool append_checked(String *dest, String src);
-FSTRING_INLINE fstr_bool append_partial(String *dest, char *src);
-FSTRING_INLINE fstr_bool append_partial(String *dest, String src);
-FSTRING_INLINE fstr_bool append(String *dest, char c);
-FSTRING_INLINE fstr_bool append(String *dest, String src);
-FSTRING_INLINE fstr_bool append(String *dest, char *src);
-FSTRING_INLINE void to_lower(char *src, char *dst);
-FSTRING_INLINE void to_lower(String *src, String *dst);
-FSTRING_INLINE void to_lower(String *str);
-FSTRING_INLINE void to_upper(char *src, char *dst);
-FSTRING_INLINE void to_upper(String *src, String *dst);
-FSTRING_INLINE void to_upper(String *str);
-FSTRING_INLINE void to_camel(char *src, char *dst);
-FSTRING_INLINE int32_t str_is_int(char *str);
-FSTRING_INLINE fstr_bool str_is_int(String str);
-FSTRING_INLINE int32_t str_to_int(char *str);
-FSTRING_INLINE int32_t str_to_int(String str);
-FSTRING_INLINE int32_t reverse_seek_slash(String str, int32_t pos);
-FSTRING_INLINE fstr_bool set_last_folder(String *dir, char *folder_name, char slash);
-FSTRING_INLINE fstr_bool set_last_folder(String *dir, String folder_name, char slash);
-
+# define expand_str(s) ((s).str), ((s).size)
#endif
+FSTRING_LINK int32_t str_size(char *str);
+FSTRING_INLINE String make_string_slowly(void *str);
+FSTRING_INLINE String substr_tail(String str, int32_t start);
+FSTRING_INLINE String substr(String str, int32_t start, int32_t size);
+FSTRING_LINK String skip_whitespace(String str);
+FSTRING_LINK String chop_whitespace(String str);
+FSTRING_LINK String skip_chop_whitespace(String str);
+FSTRING_INLINE String tailstr(String str);
+FSTRING_LINK fstr_bool match_cc(char *a, char *b);
+FSTRING_LINK fstr_bool match_sc(String a, char *b);
+FSTRING_INLINE fstr_bool match_cs(char *a, String b);
+FSTRING_LINK fstr_bool match_ss(String a, String b);
+FSTRING_LINK fstr_bool match_part_ccl(char *a, char *b, int32_t *len);
+FSTRING_LINK fstr_bool match_part_scl(String a, char *b, int32_t *len);
+FSTRING_INLINE fstr_bool match_part_cc(char *a, char *b);
+FSTRING_INLINE fstr_bool match_part_sc(String a, char *b);
+FSTRING_LINK fstr_bool match_part_cs(char *a, String b);
+FSTRING_LINK fstr_bool match_part_ss(String a, String b);
+FSTRING_LINK fstr_bool match_insensitive_cc(char *a, char *b);
+FSTRING_LINK fstr_bool match_insensitive_sc(String a, char *b);
+FSTRING_INLINE fstr_bool match_insensitive_cs(char *a, String b);
+FSTRING_LINK fstr_bool match_insensitive_ss(String a, String b);
+FSTRING_LINK fstr_bool match_part_insensitive_ccl(char *a, char *b, int32_t *len);
+FSTRING_LINK fstr_bool match_part_insensitive_scl(String a, char *b, int32_t *len);
+FSTRING_INLINE fstr_bool match_part_insensitive_cc(char *a, char *b);
+FSTRING_INLINE fstr_bool match_part_insensitive_sc(String a, char *b);
+FSTRING_LINK fstr_bool match_part_insensitive_cs(char *a, String b);
+FSTRING_LINK fstr_bool match_part_insensitive_ss(String a, String b);
+FSTRING_LINK int32_t compare_cc(char *a, char *b);
+FSTRING_LINK int32_t compare_sc(String a, char *b);
+FSTRING_INLINE int32_t compare_cs(char *a, String b);
+FSTRING_LINK int32_t compare_ss(String a, String b);
+FSTRING_LINK int32_t find_c_char(char *str, int32_t start, char character);
+FSTRING_LINK int32_t find_s_char(String str, int32_t start, char character);
+FSTRING_LINK int32_t rfind_s_char(String str, int32_t start, char character);
+FSTRING_LINK int32_t find_c_chars(char *str, int32_t start, char *characters);
+FSTRING_LINK int32_t find_s_chars(String str, int32_t start, char *characters);
+FSTRING_LINK int32_t find_substr_c(char *str, int32_t start, String seek);
+FSTRING_LINK int32_t find_substr_s(String str, int32_t start, String seek);
+FSTRING_LINK int32_t rfind_substr_s(String str, int32_t start, String seek);
+FSTRING_LINK int32_t find_substr_insensitive_c(char *str, int32_t start, String seek);
+FSTRING_LINK int32_t find_substr_insensitive_s(String str, int32_t start, String seek);
+FSTRING_INLINE fstr_bool has_substr_c(char *s, String seek);
+FSTRING_INLINE fstr_bool has_substr_s(String s, String seek);
+FSTRING_INLINE fstr_bool has_substr_insensitive_c(char *s, String seek);
+FSTRING_INLINE fstr_bool has_substr_insensitive_s(String s, String seek);
+FSTRING_LINK int32_t copy_fast_unsafe_cc(char *dest, char *src);
+FSTRING_LINK int32_t copy_fast_unsafe_cs(char *dest, String src);
+FSTRING_LINK fstr_bool copy_checked_ss(String *dest, String src);
+FSTRING_LINK fstr_bool copy_partial_sc(String *dest, char *src);
+FSTRING_LINK fstr_bool copy_partial_ss(String *dest, String src);
+FSTRING_INLINE int32_t copy_cc(char *dest, char *src);
+FSTRING_INLINE void copy_ss(String *dest, String src);
+FSTRING_INLINE void copy_sc(String *dest, char *src);
+FSTRING_LINK fstr_bool append_checked_ss(String *dest, String src);
+FSTRING_LINK fstr_bool append_partial_sc(String *dest, char *src);
+FSTRING_LINK fstr_bool append_partial_ss(String *dest, String src);
+FSTRING_LINK fstr_bool append_s_char(String *dest, char c);
+FSTRING_INLINE fstr_bool append_ss(String *dest, String src);
+FSTRING_INLINE fstr_bool append_sc(String *dest, char *src);
+FSTRING_LINK fstr_bool terminate_with_null(String *str);
+FSTRING_LINK fstr_bool append_padding(String *dest, char c, int32_t target_size);
+FSTRING_LINK void replace_char(String *str, char replace, char with);
+FSTRING_LINK void to_lower_cc(char *src, char *dst);
+FSTRING_LINK void to_lower_ss(String *dst, String src);
+FSTRING_LINK void to_lower_s(String *str);
+FSTRING_LINK void to_upper_cc(char *src, char *dst);
+FSTRING_LINK void to_upper_ss(String *dst, String src);
+FSTRING_LINK void to_upper_s(String *str);
+FSTRING_LINK void to_camel_cc(char *src, char *dst);
+FSTRING_LINK int32_t int_to_str_size(int32_t x);
+FSTRING_LINK fstr_bool int_to_str(String *dest, int32_t x);
+FSTRING_LINK fstr_bool append_int_to_str(String *dest, int32_t x);
+FSTRING_LINK int32_t u64_to_str_size(uint64_t x);
+FSTRING_LINK fstr_bool u64_to_str(String *dest, uint64_t x);
+FSTRING_LINK fstr_bool append_u64_to_str(String *dest, uint64_t x);
+FSTRING_LINK int32_t float_to_str_size(float x);
+FSTRING_LINK fstr_bool append_float_to_str(String *dest, float x);
+FSTRING_LINK fstr_bool float_to_str(String *dest, float x);
+FSTRING_LINK int32_t str_is_int_c(char *str);
+FSTRING_LINK fstr_bool str_is_int_s(String str);
+FSTRING_LINK int32_t str_to_int_c(char *str);
+FSTRING_LINK int32_t str_to_int_s(String str);
+FSTRING_LINK int32_t hexchar_to_int(char c);
+FSTRING_LINK char int_to_hexchar(int32_t x);
+FSTRING_LINK uint32_t hexstr_to_int(String str);
+FSTRING_LINK fstr_bool color_to_hexstr(String *s, uint32_t color);
+FSTRING_LINK fstr_bool hexstr_to_color(String s, uint32_t *out);
+FSTRING_LINK int32_t reverse_seek_slash_pos(String str, int32_t pos);
+FSTRING_INLINE int32_t reverse_seek_slash(String str);
+FSTRING_INLINE String front_of_directory(String dir);
+FSTRING_INLINE String path_of_directory(String dir);
+FSTRING_LINK fstr_bool set_last_folder_sc(String *dir, char *folder_name, char slash);
+FSTRING_LINK fstr_bool set_last_folder_ss(String *dir, String folder_name, char slash);
+FSTRING_LINK String file_extension(String str);
+FSTRING_LINK fstr_bool remove_extension(String *str);
+FSTRING_LINK fstr_bool remove_last_folder(String *str);
+FSTRING_LINK fstr_bool string_set_match_table(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index);
+FSTRING_LINK fstr_bool string_set_match(String *str_set, int32_t count, String str, int32_t *match_index);
#endif
#if !defined(FSTRING_C) && !defined(FSTRING_GUARD)
-FSTRING_INLINE String
-make_string(void *str, int32_t size, int32_t mem_size){return(make_string_cap(str,size,mem_size));}
-FSTRING_INLINE String
-substr(String str, int32_t start){return(substr_tail(str,start));}
-FSTRING_INLINE fstr_bool
-match(char *a, char *b){return(match_cc(a,b));}
-FSTRING_INLINE fstr_bool
-match(String a, char *b){return(match_sc(a,b));}
-FSTRING_INLINE fstr_bool
-match(char *a, String b){return(match_cs(a,b));}
-FSTRING_INLINE fstr_bool
-match(String a, String b){return(match_ss(a,b));}
-FSTRING_INLINE fstr_bool
-match_part(char *a, char *b, int32_t *len){return(match_part_ccl(a,b,len));}
-FSTRING_INLINE fstr_bool
-match_part(String a, char *b, int32_t *len){return(match_part_scl(a,b,len));}
-FSTRING_INLINE fstr_bool
-match_part(char *a, char *b){return(match_part_cc(a,b));}
-FSTRING_INLINE fstr_bool
-match_part(String a, char *b){return(match_part_sc(a,b));}
-FSTRING_INLINE fstr_bool
-match_part(char *a, String b){return(match_part_cs(a,b));}
-FSTRING_INLINE fstr_bool
-match_part(String a, String b){return(match_part_ss(a,b));}
-FSTRING_INLINE fstr_bool
-match_insensitive(char *a, char *b){return(match_insensitive_cc(a,b));}
-FSTRING_INLINE fstr_bool
-match_insensitive(String a, char *b){return(match_insensitive_sc(a,b));}
-FSTRING_INLINE fstr_bool
-match_insensitive(char *a, String b){return(match_insensitive_cs(a,b));}
-FSTRING_INLINE fstr_bool
-match_insensitive(String a, String b){return(match_insensitive_ss(a,b));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(char *a, char *b, int32_t *len){return(match_part_insensitive_ccl(a,b,len));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(String a, char *b, int32_t *len){return(match_part_insensitive_scl(a,b,len));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(char *a, char *b){return(match_part_insensitive_cc(a,b));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(String a, char *b){return(match_part_insensitive_sc(a,b));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(char *a, String b){return(match_part_insensitive_cs(a,b));}
-FSTRING_INLINE fstr_bool
-match_part_insensitive(String a, String b){return(match_part_insensitive_ss(a,b));}
-FSTRING_INLINE int32_t
-compare(char *a, char *b){return(compare_cc(a,b));}
-FSTRING_INLINE int32_t
-compare(String a, char *b){return(compare_sc(a,b));}
-FSTRING_INLINE int32_t
-compare(char *a, String b){return(compare_cs(a,b));}
-FSTRING_INLINE int32_t
-compare(String a, String b){return(compare_ss(a,b));}
-FSTRING_INLINE int32_t
-find(char *str, int32_t start, char character){return(find_c_char(str,start,character));}
-FSTRING_INLINE int32_t
-find(String str, int32_t start, char character){return(find_s_char(str,start,character));}
-FSTRING_INLINE int32_t
-rfind(String str, int32_t start, char character){return(rfind_s_char(str,start,character));}
-FSTRING_INLINE int32_t
-find(char *str, int32_t start, char *characters){return(find_c_chars(str,start,characters));}
-FSTRING_INLINE int32_t
-find(String str, int32_t start, char *characters){return(find_s_chars(str,start,characters));}
-FSTRING_INLINE int32_t
-find_substr(char *str, int32_t start, String seek){return(find_substr_c(str,start,seek));}
-FSTRING_INLINE int32_t
-find_substr(String str, int32_t start, String seek){return(find_substr_s(str,start,seek));}
-FSTRING_INLINE int32_t
-rfind_substr(String str, int32_t start, String seek){return(rfind_substr_s(str,start,seek));}
-FSTRING_INLINE int32_t
-find_substr_insensitive(char *str, int32_t start, String seek){return(find_substr_insensitive_c(str,start,seek));}
-FSTRING_INLINE int32_t
-find_substr_insensitive(String str, int32_t start, String seek){return(find_substr_insensitive_s(str,start,seek));}
-FSTRING_INLINE fstr_bool
-has_substr(char *s, String seek){return(has_substr_c(s,seek));}
-FSTRING_INLINE fstr_bool
-has_substr(String s, String seek){return(has_substr_s(s,seek));}
-FSTRING_INLINE fstr_bool
-has_substr_insensitive(char *s, String seek){return(has_substr_insensitive_c(s,seek));}
-FSTRING_INLINE fstr_bool
-has_substr_insensitive(String s, String seek){return(has_substr_insensitive_s(s,seek));}
-FSTRING_INLINE int32_t
-copy_fast_unsafe(char *dest, char *src){return(copy_fast_unsafe_cc(dest,src));}
-FSTRING_INLINE int32_t
-copy_fast_unsafe(char *dest, String src){return(copy_fast_unsafe_cs(dest,src));}
-FSTRING_INLINE fstr_bool
-copy_checked(String *dest, String src){return(copy_checked_ss(dest,src));}
-FSTRING_INLINE fstr_bool
-copy_partial(String *dest, char *src){return(copy_partial_sc(dest,src));}
-FSTRING_INLINE fstr_bool
-copy_partial(String *dest, String src){return(copy_partial_ss(dest,src));}
-FSTRING_INLINE int32_t
-copy(char *dest, char *src){return(copy_cc(dest,src));}
-FSTRING_INLINE void
-copy(String *dest, String src){(copy_ss(dest,src));}
-FSTRING_INLINE void
-copy(String *dest, char *src){(copy_sc(dest,src));}
-FSTRING_INLINE fstr_bool
-append_checked(String *dest, String src){return(append_checked_ss(dest,src));}
-FSTRING_INLINE fstr_bool
-append_partial(String *dest, char *src){return(append_partial_sc(dest,src));}
-FSTRING_INLINE fstr_bool
-append_partial(String *dest, String src){return(append_partial_ss(dest,src));}
-FSTRING_INLINE fstr_bool
-append(String *dest, char c){return(append_s_char(dest,c));}
-FSTRING_INLINE fstr_bool
-append(String *dest, String src){return(append_ss(dest,src));}
-FSTRING_INLINE fstr_bool
-append(String *dest, char *src){return(append_sc(dest,src));}
-FSTRING_INLINE void
-to_lower(char *src, char *dst){(to_lower_cc(src,dst));}
-FSTRING_INLINE void
-to_lower(String *src, String *dst){(to_lower_ss(src,dst));}
-FSTRING_INLINE void
-to_lower(String *str){(to_lower_s(str));}
-FSTRING_INLINE void
-to_upper(char *src, char *dst){(to_upper_cc(src,dst));}
-FSTRING_INLINE void
-to_upper(String *src, String *dst){(to_upper_ss(src,dst));}
-FSTRING_INLINE void
-to_upper(String *str){(to_upper_s(str));}
-FSTRING_INLINE void
-to_camel(char *src, char *dst){(to_camel_cc(src,dst));}
-FSTRING_INLINE int32_t
-str_is_int(char *str){return(str_is_int_c(str));}
-FSTRING_INLINE fstr_bool
-str_is_int(String str){return(str_is_int_s(str));}
-FSTRING_INLINE int32_t
-str_to_int(char *str){return(str_to_int_c(str));}
-FSTRING_INLINE int32_t
-str_to_int(String str){return(str_to_int_s(str));}
-FSTRING_INLINE int32_t
-reverse_seek_slash(String str, int32_t pos){return(reverse_seek_slash_pos(str,pos));}
-FSTRING_INLINE fstr_bool
-set_last_folder(String *dir, char *folder_name, char slash){return(set_last_folder_sc(dir,folder_name,slash));}
-FSTRING_INLINE fstr_bool
-set_last_folder(String *dir, String folder_name, char slash){return(set_last_folder_ss(dir,folder_name,slash));}
+FSTRING_INLINE String make_string(void *str, int32_t size, int32_t mem_size){return(make_string_cap(str,size,mem_size));}
+FSTRING_INLINE String substr(String str, int32_t start){return(substr_tail(str,start));}
+FSTRING_INLINE fstr_bool match(char *a, char *b){return(match_cc(a,b));}
+FSTRING_INLINE fstr_bool match(String a, char *b){return(match_sc(a,b));}
+FSTRING_INLINE fstr_bool match(char *a, String b){return(match_cs(a,b));}
+FSTRING_INLINE fstr_bool match(String a, String b){return(match_ss(a,b));}
+FSTRING_INLINE fstr_bool match_part(char *a, char *b, int32_t *len){return(match_part_ccl(a,b,len));}
+FSTRING_INLINE fstr_bool match_part(String a, char *b, int32_t *len){return(match_part_scl(a,b,len));}
+FSTRING_INLINE fstr_bool match_part(char *a, char *b){return(match_part_cc(a,b));}
+FSTRING_INLINE fstr_bool match_part(String a, char *b){return(match_part_sc(a,b));}
+FSTRING_INLINE fstr_bool match_part(char *a, String b){return(match_part_cs(a,b));}
+FSTRING_INLINE fstr_bool match_part(String a, String b){return(match_part_ss(a,b));}
+FSTRING_INLINE fstr_bool match_insensitive(char *a, char *b){return(match_insensitive_cc(a,b));}
+FSTRING_INLINE fstr_bool match_insensitive(String a, char *b){return(match_insensitive_sc(a,b));}
+FSTRING_INLINE fstr_bool match_insensitive(char *a, String b){return(match_insensitive_cs(a,b));}
+FSTRING_INLINE fstr_bool match_insensitive(String a, String b){return(match_insensitive_ss(a,b));}
+FSTRING_INLINE fstr_bool match_part_insensitive(char *a, char *b, int32_t *len){return(match_part_insensitive_ccl(a,b,len));}
+FSTRING_INLINE fstr_bool match_part_insensitive(String a, char *b, int32_t *len){return(match_part_insensitive_scl(a,b,len));}
+FSTRING_INLINE fstr_bool match_part_insensitive(char *a, char *b){return(match_part_insensitive_cc(a,b));}
+FSTRING_INLINE fstr_bool match_part_insensitive(String a, char *b){return(match_part_insensitive_sc(a,b));}
+FSTRING_INLINE fstr_bool match_part_insensitive(char *a, String b){return(match_part_insensitive_cs(a,b));}
+FSTRING_INLINE fstr_bool match_part_insensitive(String a, String b){return(match_part_insensitive_ss(a,b));}
+FSTRING_INLINE int32_t compare(char *a, char *b){return(compare_cc(a,b));}
+FSTRING_INLINE int32_t compare(String a, char *b){return(compare_sc(a,b));}
+FSTRING_INLINE int32_t compare(char *a, String b){return(compare_cs(a,b));}
+FSTRING_INLINE int32_t compare(String a, String b){return(compare_ss(a,b));}
+FSTRING_INLINE int32_t find(char *str, int32_t start, char character){return(find_c_char(str,start,character));}
+FSTRING_INLINE int32_t find(String str, int32_t start, char character){return(find_s_char(str,start,character));}
+FSTRING_INLINE int32_t rfind(String str, int32_t start, char character){return(rfind_s_char(str,start,character));}
+FSTRING_INLINE int32_t find(char *str, int32_t start, char *characters){return(find_c_chars(str,start,characters));}
+FSTRING_INLINE int32_t find(String str, int32_t start, char *characters){return(find_s_chars(str,start,characters));}
+FSTRING_INLINE int32_t find_substr(char *str, int32_t start, String seek){return(find_substr_c(str,start,seek));}
+FSTRING_INLINE int32_t find_substr(String str, int32_t start, String seek){return(find_substr_s(str,start,seek));}
+FSTRING_INLINE int32_t rfind_substr(String str, int32_t start, String seek){return(rfind_substr_s(str,start,seek));}
+FSTRING_INLINE int32_t find_substr_insensitive(char *str, int32_t start, String seek){return(find_substr_insensitive_c(str,start,seek));}
+FSTRING_INLINE int32_t find_substr_insensitive(String str, int32_t start, String seek){return(find_substr_insensitive_s(str,start,seek));}
+FSTRING_INLINE fstr_bool has_substr(char *s, String seek){return(has_substr_c(s,seek));}
+FSTRING_INLINE fstr_bool has_substr(String s, String seek){return(has_substr_s(s,seek));}
+FSTRING_INLINE fstr_bool has_substr_insensitive(char *s, String seek){return(has_substr_insensitive_c(s,seek));}
+FSTRING_INLINE fstr_bool has_substr_insensitive(String s, String seek){return(has_substr_insensitive_s(s,seek));}
+FSTRING_INLINE int32_t copy_fast_unsafe(char *dest, char *src){return(copy_fast_unsafe_cc(dest,src));}
+FSTRING_INLINE int32_t copy_fast_unsafe(char *dest, String src){return(copy_fast_unsafe_cs(dest,src));}
+FSTRING_INLINE fstr_bool copy_checked(String *dest, String src){return(copy_checked_ss(dest,src));}
+FSTRING_INLINE fstr_bool copy_partial(String *dest, char *src){return(copy_partial_sc(dest,src));}
+FSTRING_INLINE fstr_bool copy_partial(String *dest, String src){return(copy_partial_ss(dest,src));}
+FSTRING_INLINE int32_t copy(char *dest, char *src){return(copy_cc(dest,src));}
+FSTRING_INLINE void copy(String *dest, String src){(copy_ss(dest,src));}
+FSTRING_INLINE void copy(String *dest, char *src){(copy_sc(dest,src));}
+FSTRING_INLINE fstr_bool append_checked(String *dest, String src){return(append_checked_ss(dest,src));}
+FSTRING_INLINE fstr_bool append_partial(String *dest, char *src){return(append_partial_sc(dest,src));}
+FSTRING_INLINE fstr_bool append_partial(String *dest, String src){return(append_partial_ss(dest,src));}
+FSTRING_INLINE fstr_bool append(String *dest, char c){return(append_s_char(dest,c));}
+FSTRING_INLINE fstr_bool append(String *dest, String src){return(append_ss(dest,src));}
+FSTRING_INLINE fstr_bool append(String *dest, char *src){return(append_sc(dest,src));}
+FSTRING_INLINE void to_lower(char *src, char *dst){(to_lower_cc(src,dst));}
+FSTRING_INLINE void to_lower(String *dst, String src){(to_lower_ss(dst,src));}
+FSTRING_INLINE void to_lower(String *str){(to_lower_s(str));}
+FSTRING_INLINE void to_upper(char *src, char *dst){(to_upper_cc(src,dst));}
+FSTRING_INLINE void to_upper(String *dst, String src){(to_upper_ss(dst,src));}
+FSTRING_INLINE void to_upper(String *str){(to_upper_s(str));}
+FSTRING_INLINE void to_camel(char *src, char *dst){(to_camel_cc(src,dst));}
+FSTRING_INLINE int32_t str_is_int(char *str){return(str_is_int_c(str));}
+FSTRING_INLINE fstr_bool str_is_int(String str){return(str_is_int_s(str));}
+FSTRING_INLINE int32_t str_to_int(char *str){return(str_to_int_c(str));}
+FSTRING_INLINE int32_t str_to_int(String str){return(str_to_int_s(str));}
+FSTRING_INLINE int32_t reverse_seek_slash(String str, int32_t pos){return(reverse_seek_slash_pos(str,pos));}
+FSTRING_INLINE fstr_bool set_last_folder(String *dir, char *folder_name, char slash){return(set_last_folder_sc(dir,folder_name,slash));}
+FSTRING_INLINE fstr_bool set_last_folder(String *dir, String folder_name, char slash){return(set_last_folder_ss(dir,folder_name,slash));}
+FSTRING_INLINE fstr_bool string_set_match(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index){return(string_set_match_table(str_set,item_size,count,str,match_index));}
#endif
+#if !defined(FSTRING_GUARD)
+static String null_string = {0};
+#endif
+
//
// Character Helpers
//
@@ -460,7 +321,7 @@ char_is_alpha_true(char c)
FSTRING_INLINE fstr_bool
char_is_hex(char c)
{
- return c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f';
+ return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f');
}
#endif
@@ -477,25 +338,15 @@ char_is_numeric(char c)
// String Making Functions
//
-#if !defined(FSTRING_GUARD)
-FSTRING_INLINE String
-string_zero(void)
-{
- String str={0};
- return(str);
-}
-#endif
-
#if !defined(FSTRING_GUARD)
FSTRING_INLINE String
-make_string_cap(void *str, int32_t size, int32_t mem_size)
-{
+make_string_cap(void *str, int32_t size, int32_t mem_size){
String result;
result.str = (char*)str;
result.size = size;
result.memory_size = mem_size;
- return result;
+ return(result);
}
#endif
@@ -506,7 +357,7 @@ make_string(void *str, int32_t size){
result.str = (char*)str;
result.size = size;
result.memory_size = size;
- return result;
+ return(result);
}
#endif
@@ -516,7 +367,7 @@ str_size(char *str)
{
int32_t i = 0;
while (str[i]) ++i;
- return i;
+ return(i);
}
#endif
@@ -528,7 +379,7 @@ make_string_slowly(void *str)
result.str = (char*)str;
result.size = str_size((char*)str);
result.memory_size = result.size;
- return result;
+ return(result);
}
#endif
@@ -1439,16 +1290,17 @@ to_lower_cc(char *src, char *dst){
#if defined(FSTRING_IMPLEMENTATION)
FSTRING_LINK void
-to_lower_ss(String *src, String *dst){
+to_lower_ss(String *dst, String src){
int32_t i = 0;
- int32_t size = src->size;
- char *c = src->str;
+ int32_t size = src.size;
+ char *c = src.str;
char *d = dst->str;
if (dst->memory_size >= size){
for (; i < size; ++i){
*d++ = char_to_lower(*c++);
}
+ dst->size = size;
}
}
#endif
@@ -1480,16 +1332,17 @@ to_upper_cc(char *src, char *dst){
#if defined(FSTRING_IMPLEMENTATION)
FSTRING_LINK void
-to_upper_ss(String *src, String *dst){
+to_upper_ss(String *dst, String src){
int32_t i = 0;
- int32_t size = src->size;
- char *c = src->str;
+ int32_t size = src.size;
+ char *c = src.str;
char *d = dst->str;
if (dst->memory_size >= size){
for (; i < size; ++i){
*d++ = char_to_upper(*c++);
}
+ dst->size = size;
}
}
#endif
@@ -2022,13 +1875,15 @@ remove_last_folder(String *str){
#endif
// TODO(allen): Add hash-table extension to string sets.
+
#if defined(FSTRING_IMPLEMENTATION)
FSTRING_LINK fstr_bool
-string_set_match(String *str_set, int32_t count, String str, int32_t *match_index){
+string_set_match_table(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index){
fstr_bool result = 0;
int32_t i = 0;
- for (; i < count; ++i, ++str_set){
- if (match_ss(*str_set, str)){
+ uint8_t *ptr = (uint8_t*)str_set;
+ for (; i < count; ++i, ptr += item_size){
+ if (match_ss(*(String*)ptr, str)){
*match_index = i;
result = 1;
break;
@@ -2038,6 +1893,15 @@ string_set_match(String *str_set, int32_t count, String str, int32_t *match_inde
}
#endif
+#if defined(FSTRING_IMPLEMENTATION)
+FSTRING_LINK fstr_bool
+string_set_match(String *str_set, int32_t count, String str, int32_t *match_index){
+ fstr_bool result = string_set_match_table(str_set, sizeof(String), count, str, match_index);
+ return(result);
+}
+#endif
+
+
#ifndef FSTRING_EXPERIMENTAL
#define FSTRING_EXPERIMENTAL
diff --git a/4coder_types.h b/4coder_types.h
index 3033b9b5..94b6b285 100644
--- a/4coder_types.h
+++ b/4coder_types.h
@@ -1,7 +1,8 @@
+#ifndef ENUM
#define ENUM(type,name) typedef type name; enum name##_
-#define FLAGENUM(name) typedef uint32_t name; enum name##_
+#endif
/* DOC(bool32 is an alias name to signal that an integer parameter or field is for
true/false vales.) */
@@ -37,7 +38,7 @@ ENUM(int32_t, Key_Modifier){
/* DOC(A Key_Modifier_Flag field is used to specify a specific state of modifiers.
Flags can be combined with bit or to specify a state with multiple modifiers.) */
-FLAGENUM(Key_Modifier_Flag){
+ENUM(uint32_t, Key_Modifier_Flag){
/* DOC(MDFR_NONE specifies that no modifiers are pressed.) */
MDFR_NONE = 0x0,
MDFR_CTRL = 0x1,
@@ -91,7 +92,7 @@ ENUM(uint64_t, Command_ID){
};
/* DOC(TODO) */
-FLAGENUM(Memory_Protect_Flags){
+ENUM(uint32_t, Memory_Protect_Flags){
/* DOC(TODO) */
MemProtect_Read = 0x1,
/* DOC(TODO) */
@@ -183,7 +184,7 @@ ENUM(int32_t, View_Setting_ID){
};
/* DOC(A Buffer_Create_Flag field specifies how a buffer should be created.) */
-FLAGENUM(Buffer_Create_Flag){
+ENUM(uint32_t, Buffer_Create_Flag){
/* DOC(BufferCreate_Background is not currently implemented.) */
BufferCreate_Background = 0x1,
/* DOC(When BufferCreate_AlwaysNew is set it indicates the buffer should be
@@ -195,7 +196,7 @@ FLAGENUM(Buffer_Create_Flag){
};
/* DOC(A Buffer_Kill_Flag field specifies how a buffer should be killed.) */
-FLAGENUM(Buffer_Kill_Flag){
+ENUM(uint32_t, Buffer_Kill_Flag){
/* DOC(BufferKill_Background is not currently implemented.) */
BufferKill_Background = 0x1,
/* DOC(When BufferKill_AlwaysKill is set it indicates the buffer should be killed
@@ -209,7 +210,7 @@ access call. An access call is usually one the returns a summary struct. If a
not set in the access field, that 4coder object is hidden. On the other hand if
a protection flag is set in the access parameter and the object does not have
that protection flag, the object is still returned from the access call.) TODO */
-FLAGENUM(Access_Flag){
+ENUM(uint32_t, Access_Flag){
/* DOC(AccessOpen does not include any bits, it indicates that the access should
only return objects that have no protection flags set.) */
AccessOpen = 0x0,
@@ -227,7 +228,7 @@ FLAGENUM(Access_Flag){
/* DOC(A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the
beginning or end of different types of words.) */
-FLAGENUM(Seek_Boundary_Flag){
+ENUM(uint32_t, Seek_Boundary_Flag){
BoundaryWhitespace = 0x1,
BoundaryToken = 0x2,
BoundaryAlphanumeric = 0x4,
@@ -235,7 +236,7 @@ FLAGENUM(Seek_Boundary_Flag){
};
/* DOC(A Command_Line_Input_Flag field specifies the behavior of a call to a command line interface.) */
-FLAGENUM(Command_Line_Input_Flag){
+ENUM(uint32_t, Command_Line_Input_Flag){
/* DOC(If CLI_OverlapWithConflict is set if output buffer of the new command is already
in use by another command which is still executing, the older command relinquishes control
of the buffer and both operate simultaneously with only the newer command outputting to
@@ -250,7 +251,7 @@ FLAGENUM(Command_Line_Input_Flag){
};
/* DOC(An Auto_Indent_Flag field specifies the behavior of an auto indentation operation.) */
-FLAGENUM(Auto_Indent_Flag){
+ENUM(uint32_t, Auto_Indent_Flag){
/* DOC(If AutoIndent_ClearLine is set, then any line that is only whitespace will
be cleared to contain nothing at all. otherwise the line is filled with whitespace
to match the nearby indentation.) */
@@ -262,7 +263,7 @@ FLAGENUM(Auto_Indent_Flag){
};
/* DOC(A Set_Buffer_Flag field specifies the behavior of an operation that sets the buffer of a view.) */
-FLAGENUM(Set_Buffer_Flag){
+ENUM(uint32_t, Set_Buffer_Flag){
/* DOC(If SetBuffer_KeepOriginalGUI then when the file is set, the view will not switch to it
if some other GUI was currently up, otherwise any GUI that is up is closed and the view
switches to the file.) */
@@ -270,7 +271,7 @@ FLAGENUM(Set_Buffer_Flag){
};
/* DOC(A Input_Type_Flag field specifies a set of input event types.) */
-FLAGENUM(Input_Type_Flag){
+ENUM(uint32_t, Input_Type_Flag){
/* DOC(If EventOnAnyKey is set, all keyboard events are included in the set.) */
EventOnAnyKey = 0x1,
/* DOC(If EventOnEsc is set, any press of the escape key is included in the set.) */
@@ -614,8 +615,7 @@ struct Buffer_Summary{
/* DOC(View_Summary acts as a handle to a view and describes the state of the view.)
DOC_SEE(Access_Flag)
-DOC_SEE(Full_Cursor)
-*/
+DOC_SEE(Full_Cursor) */
struct View_Summary{
/* DOC(
This field indicates whether the View_Summary describes a view that is open in 4coder.
@@ -627,7 +627,7 @@ struct View_Summary{
If this is a null summary then view_id is 0.
) */
int32_t view_id;
- /* DOC(If this is not a null summary, and this view looks at a buffer, this is the id of the buffer.) */
+ /* DOC(If this is not a null summary, then this is the id of the buffer this view currently sees.) */
int32_t buffer_id;
/*
DOC(If this is not a null summary, this field contains flags describing the protection status of the view.)
diff --git a/4cpp_lexer.h b/4cpp_lexer.h
index ec591a7a..0f29a128 100644
--- a/4cpp_lexer.h
+++ b/4cpp_lexer.h
@@ -12,7 +12,7 @@
# define FCPP_LINK static
#endif
-#include "4cpp_lexer_types.h"
+#include "4coder_lexer_types.h"
#include "4cpp_lexer_fsms.h"
#include "4cpp_lexer_tables.c"
diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp
index 333df2ad..2ff9ee7f 100644
--- a/4ed_file_view.cpp
+++ b/4ed_file_view.cpp
@@ -1225,7 +1225,7 @@ file_kill_tokens(System_Functions *system,
general_memory_free(general, file->state.token_stack.tokens);
}
file->state.tokens_complete = 0;
- file->state.token_stack = cpp_token_stack_zero();
+ file->state.token_stack = null_cpp_token_stack;
}
#if BUFFER_EXPERIMENT_SCALPEL <= 0
@@ -3153,7 +3153,7 @@ internal void
init_read_only_file(System_Functions *system, Models *models, Editing_File *file){
General_Memory *general = &models->mem.general;
- String val = string_zero();
+ String val = null_string;
file_create_from_string(system, models, file, val, 1);
if (file->settings.tokens_exist && file->state.token_stack.tokens == 0){
@@ -3671,7 +3671,7 @@ get_exhaustive_info(System_Functions *system, Working_Set *working_set, Exhausti
result.name_match = (filename_match(loop->front_name, &loop->absolutes, filename, 0) != 0);
result.is_loaded = (file != 0 && file_is_ready(file));
- result.message = string_zero();
+ result.message = null_string;
if (result.is_loaded){
switch (file_get_sync(file)){
case SYNC_GOOD: result.message = message_loaded; break;
@@ -3869,7 +3869,7 @@ show_gui_line(GUI_Target *target, String *string,
append_s_char(string, ' ');
append_sc(string, follow_up);
}
- gui_do_text_field(target, *string, string_zero());
+ gui_do_text_field(target, *string, null_string);
}
internal void
@@ -3880,7 +3880,7 @@ show_gui_int(GUI_Target *target, String *string,
append_padding(string, '-', h_align);
append_s_char(string, ' ');
append_int_to_str(string, x);
- gui_do_text_field(target, *string, string_zero());
+ gui_do_text_field(target, *string, null_string);
}
internal void
@@ -3891,7 +3891,7 @@ show_gui_u64(GUI_Target *target, String *string,
append_padding(string, '-', h_align);
append_s_char(string, ' ');
append_u64_to_str(string, x);
- gui_do_text_field(target, *string, string_zero());
+ gui_do_text_field(target, *string, null_string);
}
internal void
@@ -3904,7 +3904,7 @@ show_gui_int_int(GUI_Target *target, String *string,
append_int_to_str(string, x);
append_s_char(string, '/');
append_int_to_str(string, m);
- gui_do_text_field(target, *string, string_zero());
+ gui_do_text_field(target, *string, null_string);
}
internal void
@@ -3918,7 +3918,7 @@ show_gui_id(GUI_Target *target, String *string,
append_padding(string, ' ', h_align + 26);
append_ss(string, make_lit_string(" [1]: "));
append_u64_to_str(string, id.id[1]);
- gui_do_text_field(target, *string, string_zero());
+ gui_do_text_field(target, *string, null_string);
}
internal void
@@ -3929,7 +3929,7 @@ show_gui_float(GUI_Target *target, String *string,
append_padding(string, '-', h_align);
append_s_char(string, ' ');
append_float_to_str(string, x);
- gui_do_text_field(target, *string, string_zero());
+ gui_do_text_field(target, *string, null_string);
}
internal void
@@ -3985,7 +3985,7 @@ gui_show_mouse(GUI_Target *target, String *string, i32 mx, i32 my){
append_int_to_str(string, my);
append_s_char(string, ')');
- gui_do_text_field(target, *string, string_zero());
+ gui_do_text_field(target, *string, null_string);
}
internal View_Step_Result
@@ -4491,7 +4491,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
reserved_files[reserved_top++] = file;
}
else{
- message = string_zero();
+ message = null_string;
if (!file->settings.unimportant){
switch (file_get_sync(file)){
case SYNC_BEHIND_OS: message = message_unsynced; break;
@@ -4512,7 +4512,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
for (i = 0; i < reserved_top; ++i){
Editing_File *file = reserved_files[i];
- message = string_zero();
+ message = null_string;
if (!file->settings.unimportant){
switch (file_get_sync(file)){
case SYNC_BEHIND_OS: message = message_unsynced; break;
@@ -4623,7 +4623,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
// - Command maps inspection
// - Clipboard inspection
- String empty_str = string_zero();
+ String empty_str = null_string;
char space1[512];
String string = make_fixed_width_string(space1);
diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp
index f5c9ce9a..8cb0a5fa 100644
--- a/4ed_metagen.cpp
+++ b/4ed_metagen.cpp
@@ -23,11 +23,23 @@
#include "4coder_mem.h"
+#define InvalidPath Assert(!"Invalid path of execution")
+
typedef struct Out_Context{
FILE *file;
String *str;
} Out_Context;
+static String
+str_start_end(char *data, int32_t start, int32_t end){
+ return(make_string(data + start, end - start));
+}
+
+static String
+str_alloc(Partition *part, int32_t cap){
+ return(make_string_cap(push_array(part, char, cap), 0, cap));
+}
+
static int32_t
begin_file_out(Out_Context *out_context, char *filename, String *out){
int32_t r = 0;
@@ -328,6 +340,14 @@ generate_style(){
}
//////////////////////////////////////////////////////////////////////////////////////////////////
+
+typedef struct Parse_Context{
+ Cpp_Token *token_s;
+ Cpp_Token *token_e;
+ Cpp_Token *token;
+ char *data;
+} Parse_Context;
+
typedef struct Argument{
String param_string;
String param_name;
@@ -351,10 +371,14 @@ typedef struct Documentation{
typedef enum Item_Type{
Item_Null,
Item_Function,
+ Item_CppName,
Item_Macro,
Item_Typedef,
Item_Struct,
Item_Union,
+ Item_Enum,
+ Item_Type_Count,
+#define Item_Type_User0 Item_Type_Count
} Item_Type;
typedef struct Item_Node{
@@ -381,15 +405,106 @@ typedef struct Item_Node{
typedef struct Item_Set{
Item_Node *items;
-} Item_Set;
+ int32_t count;
+} Item_Set;
typedef struct Parse{
String code;
Cpp_Token_Stack tokens;
+ int32_t item_count;
} Parse;
+typedef struct Meta_Unit{
+ Item_Set set;
+
+ Parse *parse;
+ int32_t count;
+} Meta_Unit;
+
+typedef struct Meta_Keywords{
+ String key;
+ Item_Type type;
+} Meta_Keywords;
+
static Item_Node null_item_node = {0};
+static String
+get_lexeme(Cpp_Token token, char *code){
+ String str = make_string(code + token.start, token.size);
+ return(str);
+}
+
+static Parse_Context
+setup_parse_context(char *data, Cpp_Token_Stack stack){
+ Parse_Context context;
+ context.token_s = stack.tokens;
+ context.token_e = stack.tokens + stack.count;
+ context.token = context.token_s;
+ context.data = data;
+ return(context);
+}
+
+static Parse_Context
+setup_parse_context(Parse parse){
+ Parse_Context context;
+ context.token_s = parse.tokens.tokens;
+ context.token_e = parse.tokens.tokens + parse.tokens.count;
+ context.token = context.token_s;
+ context.data = parse.code.str;
+ return(context);
+}
+
+static Cpp_Token*
+get_token(Parse_Context *context){
+ Cpp_Token *result = context->token;
+ if (result >= context->token_e){
+ result = 0;
+ }
+ return(result);
+}
+
+static Cpp_Token*
+get_next_token(Parse_Context *context){
+ Cpp_Token *result = context->token+1;
+ context->token = result;
+ if (result >= context->token_e){
+ result = 0;
+ context->token = context->token_e;
+ }
+ return(result);
+}
+
+static Cpp_Token*
+get_prev_token(Parse_Context *context){
+ Cpp_Token *result = context->token-1;
+ if (result < context->token_s){
+ result = 0;
+ }
+ else{
+ context->token = result;
+ }
+ return(result);
+}
+
+static Cpp_Token*
+can_back_step(Parse_Context *context){
+ Cpp_Token *result = context->token-1;
+ if (result < context->token_s){
+ result = 0;
+ }
+ return(result);
+}
+
+static Cpp_Token*
+set_token(Parse_Context *context, Cpp_Token *token){
+ Cpp_Token *result = 0;
+ if (token >= context->token_s && token < context->token_e){
+ context->token = token;
+ result = token;
+ }
+ return(result);
+}
+
static String
file_dump(char *filename){
String result = {0};
@@ -413,7 +528,7 @@ file_dump(char *filename){
}
static Parse
-meta_parse(char *filename){
+meta_lex(char *filename){
Parse result = {0};
result.code = file_dump(filename);
result.tokens = cpp_make_token_stack(1024);
@@ -468,17 +583,17 @@ typedef enum Doc_Note_Type{
} Doc_Note_Type;
static int32_t
-check_and_fix_docs(String *lexeme){
+check_and_fix_docs(String *doc_string){
int32_t result = false;
- if (lexeme->size > 4){
- if (lexeme->str[0] == '/'){
- if (lexeme->str[1] == '*'){
- if (lexeme->str[lexeme->size - 2] == '*'){
- if (lexeme->str[lexeme->size - 1] == '/'){
+ if (doc_string->size > 4){
+ if (doc_string->str[0] == '/'){
+ if (doc_string->str[1] == '*'){
+ if (doc_string->str[doc_string->size - 2] == '*'){
+ if (doc_string->str[doc_string->size - 1] == '/'){
result = true;
- lexeme->str += 2;
- lexeme->size -= 4;
+ doc_string->str += 2;
+ doc_string->size -= 4;
}
}
}
@@ -488,6 +603,26 @@ check_and_fix_docs(String *lexeme){
return(result);
}
+static int32_t
+get_doc_string_from_prev(Parse_Context *context, String *doc_string){
+ int32_t result = false;
+
+ if (can_back_step(context)){
+ Cpp_Token *prev_token = get_token(context) - 1;
+ if (prev_token->type == CPP_TOKEN_COMMENT){
+ *doc_string = get_lexeme(*prev_token, context->data);
+ if (check_and_fix_docs(doc_string)){
+ result = true;
+ }
+ else{
+ *doc_string = null_string;
+ }
+ }
+ }
+
+ return(result);
+}
+
static String
doc_note_string[] = {
make_lit_string("DOC_PARAM"),
@@ -590,7 +725,7 @@ doc_parse_last_parameter(String source, int32_t *pos){
}
*pos = p;
- return(result);
+ return(result);
}
static void
@@ -682,153 +817,56 @@ perform_doc_parse(Partition *part, String doc_string, Documentation *doc){
}while(keep_parsing);
}
-static String
-get_lexeme(Cpp_Token token, char *code){
- String str = make_string(code + token.start, token.size);
- return(str);
-}
-
-static int32_t
-get_type_doc_string(char *data, Cpp_Token *tokens, Cpp_Token *token,
- String *doc_string){
- int32_t result = false;
-
- if (token > tokens){
- Cpp_Token *prev_token = token - 1;
- if (prev_token->type == CPP_TOKEN_COMMENT){
- *doc_string = get_lexeme(*prev_token, data);
- if (check_and_fix_docs(doc_string)){
- result = true;
- }
- }
- }
-
- return(result);
-}
-
static Item_Set
allocate_item_set(Partition *part, int32_t count){
Item_Set item_set = {0};
if (count > 0){
- int32_t memory_size = sizeof(Item_Node)*count;
item_set.items = push_array(part, Item_Node, count);
- memset(item_set.items, 0, memory_size);
+ item_set.count = count;
+ memset(item_set.items, 0, sizeof(Item_Node)*count);
}
return(item_set);
}
-typedef struct Parse_Context{
- Cpp_Token *token_s;
- Cpp_Token *token_e;
- Cpp_Token *token;
-} Parse_Context;
-static Parse_Context
-setup_parse_context(Cpp_Token_Stack stack){
- Parse_Context context;
- context.token_s = stack.tokens;
- context.token_e = stack.tokens + stack.count;
- context.token = context.token_s;
- return(context);
-}
-
-static Cpp_Token*
-get_token(Parse_Context *context){
- Cpp_Token *result = context->token;
- return(result);
-}
-
-static Cpp_Token*
-get_next_token(Parse_Context *context){
- Cpp_Token *result = context->token+1;
- if (result >= context->token_e){
- result = 0;
- }
- else{
- context->token = result;
- }
- return(result);
-}
-
-static Cpp_Token*
-get_prev_token(Parse_Context *context){
- Cpp_Token *result = context->token-1;
- if (result < context->token_s){
- result = 0;
- }
- else{
- context->token = result;
- }
- return(result);
-}
-
-static Cpp_Token*
-set_token(Parse_Context *context, Cpp_Token *token){
- Cpp_Token *result = 0;
- if (token >= context->token_s && token < context->token_e){
- context->token = token;
- result = token;
- }
- return(result);
-}
-
-// NOTE(allen): This should not be here any more. It was written
-// simply to transition the system to the Parse_Context.
-static int32_t TRANSITIONAL_INDEX;
-static int32_t*
-get_index(Parse_Context *context, Cpp_Token *token){
- if (token) set_token(context, token);
- TRANSITIONAL_INDEX = (int32_t)(context->token - context->token_s);
- return(&TRANSITIONAL_INDEX);
-}
+//
+// Meta Parse Rules
+//
static int32_t
-get_count(Parse_Context *context){
- int32_t result = (int32_t)(context->token_e - context->token_s);
- return(result);
-}
+struct_parse(Partition *part, int32_t is_struct,
+ Parse_Context *context, Item_Node *top_member);
static int32_t
-parse_struct(Partition *part, int32_t is_struct,
- char *data, Cpp_Token *tokens, int32_t count,
- Cpp_Token **token_ptr,
- Item_Node *top_member);
-
-static int32_t
-parse_struct_member(Partition *part,
- char *data, Cpp_Token *tokens, int32_t count,
- Cpp_Token **token_ptr,
- Item_Node *member){
+struct_parse_member(Partition *part, Parse_Context *context, Item_Node *member){
int32_t result = false;
- Cpp_Token *token = *token_ptr;
- int32_t i = (int32_t)(token - tokens);
+ Cpp_Token *token = get_token(context);
String doc_string = {0};
- get_type_doc_string(data, tokens, token, &doc_string);
+ get_doc_string_from_prev(context, &doc_string);
- int32_t start_i = i;
Cpp_Token *start_token = token;
- for (; i < count; ++i, ++token){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (token->type == CPP_TOKEN_SEMICOLON){
break;
}
}
- if (i < count){
- Cpp_Token *token_j = token;
-
+ if (token){
+ String name = {0};
+ Cpp_Token *token_j = 0;
int32_t nest_level = 0;
- for (int32_t j = i; j > start_i; --j, --token_j){
+
+ for (; (token_j = get_token(context)) > start_token; get_prev_token(context)){
if (token_j->type == CPP_TOKEN_BRACKET_CLOSE){
++nest_level;
}
else if (token_j->type == CPP_TOKEN_BRACKET_OPEN){
--nest_level;
if (nest_level < 0){
- j = start_i;
break;
}
}
@@ -840,21 +878,14 @@ parse_struct_member(Partition *part,
}
}
- String name = make_string(data + token_j->start, token_j->size);
- name = skip_chop_whitespace(name);
+ name = skip_chop_whitespace(get_lexeme(*token_j, context->data));
- int32_t type_start = start_token->start;
- int32_t type_end = token_j->start;
- String type = make_string(data + type_start, type_end - type_start);
- type = skip_chop_whitespace(type);
+ String type = skip_chop_whitespace(str_start_end(context->data, start_token->start, token_j->start));
- type_start = token_j->start + token_j->size;
- type_end = token->start;
+ String type_postfix =
+ skip_chop_whitespace(str_start_end(context->data, token_j->start + token_j->size, token->start));
- String type_postfix = make_string(data + type_start, type_end - type_start);
- type_postfix = skip_chop_whitespace(type_postfix);
-
- ++token;
+ set_token(context, token+1);
result = true;
member->name = name;
@@ -865,28 +896,23 @@ parse_struct_member(Partition *part,
member->next_sibling = 0;
}
- *token_ptr = token;
-
return(result);
}
static Item_Node*
-parse_struct_next_member(Partition *part,
- char *data, Cpp_Token *tokens, int32_t count,
- Cpp_Token **token_ptr){
+struct_parse_next_member(Partition *part, Parse_Context *context){
Item_Node *result = 0;
- Cpp_Token *token = *token_ptr;
- int32_t i = (int32_t)(token - tokens);
+ Cpp_Token *token = 0;
- for (; i < count; ++i, ++token){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (token->type == CPP_TOKEN_IDENTIFIER ||
(token->flags & CPP_TFLAG_IS_KEYWORD)){
- String lexeme = make_string(data + token->start, token->size);
+ String lexeme = get_lexeme(*token, context->data);
if (match_ss(lexeme, make_lit_string("struct"))){
Item_Node *member = push_struct(part, Item_Node);
- if (parse_struct(part, true, data, tokens, count, &token, member)){
+ if (struct_parse(part, true, context, member)){
result = member;
break;
}
@@ -896,7 +922,7 @@ parse_struct_next_member(Partition *part,
}
else if (match_ss(lexeme, make_lit_string("union"))){
Item_Node *member = push_struct(part, Item_Node);
- if (parse_struct(part, false, data, tokens, count, &token, member)){
+ if (struct_parse(part, false, context, member)){
result = member;
break;
}
@@ -906,7 +932,7 @@ parse_struct_next_member(Partition *part,
}
else{
Item_Node *member = push_struct(part, Item_Node);
- if (parse_struct_member(part, data, tokens, count, &token, member)){
+ if (struct_parse_member(part, context, member)){
result = member;
break;
}
@@ -914,54 +940,45 @@ parse_struct_next_member(Partition *part,
assert(!"unhandled error");
}
}
+
}
else if (token->type == CPP_TOKEN_BRACE_CLOSE){
break;
}
}
- *token_ptr = token;
-
return(result);
}
static int32_t
-parse_struct(Partition *part, int32_t is_struct,
- char *data, Cpp_Token *tokens, int32_t count,
- Cpp_Token **token_ptr,
- Item_Node *top_member){
+struct_parse(Partition *part, int32_t is_struct, Parse_Context *context, Item_Node *top_member){
int32_t result = false;
- Cpp_Token *token = *token_ptr;
- int32_t i = (int32_t)(token - tokens);
+ Cpp_Token *start_token = get_token(context);
+ Cpp_Token *token = 0;
String doc_string = {0};
- get_type_doc_string(data, tokens, token, &doc_string);
+ get_doc_string_from_prev(context, &doc_string);
- int32_t start_i = i;
-
- for (; i < count; ++i, ++token){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (token->type == CPP_TOKEN_BRACE_OPEN){
break;
}
}
- if (i < count){
+ if (token){
Cpp_Token *token_j = token;
- int32_t j = i;
- for (; j > start_i; --j, --token_j){
+ for (; (token_j = get_token(context)) > start_token; get_prev_token(context)){
if (token_j->type == CPP_TOKEN_IDENTIFIER){
break;
}
}
String name = {0};
-
- if (j != start_i){
- name = make_string(data + token_j->start, token_j->size);
- name = skip_chop_whitespace(name);
+ if (token_j != start_token){
+ name = skip_chop_whitespace(get_lexeme(*token_j, context->data));
}
String type = {0};
@@ -972,17 +989,15 @@ parse_struct(Partition *part, int32_t is_struct,
type = make_lit_string("union");
}
- ++token;
- Item_Node *new_member =
- parse_struct_next_member(part, data, tokens, count, &token);
+ set_token(context, token+1);
+ Item_Node *new_member = struct_parse_next_member(part, context);
if (new_member){
top_member->first_child = new_member;
Item_Node *head_member = new_member;
for(;;){
- new_member =
- parse_struct_next_member(part, data, tokens, count, &token);
+ new_member = struct_parse_next_member(part, context);
if (new_member){
head_member->next_sibling = new_member;
head_member = new_member;
@@ -993,14 +1008,19 @@ parse_struct(Partition *part, int32_t is_struct,
}
}
- i = (int32_t)(token - tokens);
- for (; i < count; ++i, ++token){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (token->type == CPP_TOKEN_SEMICOLON){
break;
}
}
++token;
+ if (is_struct){
+ top_member->t = Item_Struct;
+ }
+ else{
+ top_member->t = Item_Union;
+ }
top_member->name = name;
top_member->type = type;
top_member->doc_string = doc_string;
@@ -1009,140 +1029,126 @@ parse_struct(Partition *part, int32_t is_struct,
result = true;
}
- *token_ptr = token;
-
return(result);
}
static int32_t
-parse_typedef(char *data, Cpp_Token *tokens, int32_t count,
- Cpp_Token **token_ptr, Item_Set item_set, int32_t item_index){
+typedef_parse(Parse_Context *context, Item_Node *item){
int32_t result = false;
- Cpp_Token *token = *token_ptr;
- int32_t i = (int32_t)(token - tokens);
+ Cpp_Token *token = get_token(context);
String doc_string = {0};
- get_type_doc_string(data, tokens, token, &doc_string);
+ get_doc_string_from_prev(context, &doc_string);
- int32_t start_i = i;
Cpp_Token *start_token = token;
- for (; i < count; ++i, ++token){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (token->type == CPP_TOKEN_SEMICOLON){
break;
}
}
- if (i < count){
+ if (token){
Cpp_Token *token_j = token;
- for (int32_t j = i; j > start_i; --j, --token_j){
+ for (; (token_j = get_token(context)) > start_token; get_prev_token(context)){
if (token_j->type == CPP_TOKEN_IDENTIFIER){
break;
}
}
- String name = make_string(data + token_j->start, token_j->size);
- name = skip_chop_whitespace(name);
+ String name = get_lexeme(*token_j, context->data);
- int32_t type_start = start_token->start + start_token->size;
- int32_t type_end = token_j->start;
- String type = make_string(data + type_start, type_end - type_start);
- type = skip_chop_whitespace(type);
+ String type = skip_chop_whitespace(
+ str_start_end(context->data, start_token->start + start_token->size, token_j->start)
+ );
+ item->t = Item_Typedef;
+ item->type = type;
+ item->name = name;
+ item->doc_string = doc_string;
result = true;
- item_set.items[item_index].type = type;
- item_set.items[item_index].name = name;
- item_set.items[item_index].doc_string = doc_string;
}
- *token_ptr = token;
+ set_token(context, token);
return(result);
}
static int32_t
-parse_enum(Partition *part, char *data,
- Cpp_Token *tokens, int32_t count,
- Cpp_Token **token_ptr,
- Item_Set item_set, int32_t item_index){
+enum_parse(Partition *part, Parse_Context *context, Item_Node *item){
int32_t result = false;
- Cpp_Token *token = *token_ptr;
- int32_t i = (int32_t)(token - tokens);
-
String doc_string = {0};
- get_type_doc_string(data, tokens, token, &doc_string);
+ get_doc_string_from_prev(context, &doc_string);
- int32_t start_i = i;
+ Cpp_Token *start_token = get_token(context);
+ Cpp_Token *token = 0;
- for (; i < count; ++i, ++token){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (token->type == CPP_TOKEN_BRACE_OPEN){
break;
}
}
- if (i < count){
- Cpp_Token *token_j = token;
+ if (token){
+ String name = {0};
+ Cpp_Token *token_j = 0;
- for (int32_t j = i; j > start_i; --j, --token_j){
+ for (; (token_j = get_token(context)) != 0; get_prev_token(context)){
if (token_j->type == CPP_TOKEN_IDENTIFIER){
break;
}
}
- String name = make_string(data + token_j->start, token_j->size);
- name = skip_chop_whitespace(name);
+ name = get_lexeme(*token_j, context->data);
- for (; i < count; ++i, ++token){
+ set_token(context, token);
+ for (; (token = get_token(context)) > start_token; get_next_token(context)){
if (token->type == CPP_TOKEN_BRACE_OPEN){
break;
}
}
- if (i < count){
+ if (token){
Item_Node *first_member = 0;
Item_Node *head_member = 0;
- for (; i < count; ++i, ++token){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (token->type == CPP_TOKEN_BRACE_CLOSE){
break;
}
else if (token->type == CPP_TOKEN_IDENTIFIER){
String doc_string = {0};
- get_type_doc_string(data, tokens, token, &doc_string);
-
- String name = make_string(data + token->start, token->size);
- name = skip_chop_whitespace(name);
-
+ String name = {0};
String value = {0};
+ get_doc_string_from_prev(context, &doc_string);
- ++i;
- ++token;
+ name = get_lexeme(*token, context->data);
- if (token->type == CPP_TOKEN_EQ){
- Cpp_Token *start_token = token;
-
- for (; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_COMMA ||
- token->type == CPP_TOKEN_BRACE_CLOSE){
- break;
+ token = get_next_token(context);
+
+ if (token){
+ if (token->type == CPP_TOKEN_EQ){
+ Cpp_Token *start_token = token;
+
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
+ if (token->type == CPP_TOKEN_COMMA ||
+ token->type == CPP_TOKEN_BRACE_CLOSE){
+ break;
+ }
}
+
+ value = skip_chop_whitespace(
+ str_start_end(context->data, start_token->start + start_token->size, token->start)
+ );
+
+ get_prev_token(context);
+ }
+ else{
+ get_prev_token(context);
}
-
- int32_t val_start = start_token->start + start_token->size;
- int32_t val_end = token->start;
-
- value = make_string(data + val_start, val_end - val_start);
- value = skip_chop_whitespace(value);
-
- --i;
- --token;
- }
- else{
- --i;
- --token;
}
Item_Node *new_member = push_struct(part, Item_Node);
@@ -1162,56 +1168,60 @@ parse_enum(Partition *part, char *data,
}
}
- if (i < count){
- for (; i < count; ++i, ++token){
+ if ((token = get_token(context)) != 0){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (token->type == CPP_TOKEN_BRACE_CLOSE){
break;
}
}
- ++i;
- ++token;
+ get_next_token(context);
+ item->t = Item_Enum;
+ item->name = name;
+ item->doc_string = doc_string;
+ item->first_child = first_member;
result = true;
- item_set.items[item_index].name = name;
- item_set.items[item_index].doc_string = doc_string;
- item_set.items[item_index].first_child = first_member;
}
}
}
- *token_ptr = token;
-
return(result);
}
static Argument_Breakdown
-allocate_argument_breakdown(int32_t count){
+allocate_argument_breakdown(Partition *part, int32_t count){
Argument_Breakdown breakdown = {0};
- int32_t memory_size = sizeof(Argument)*count;
- breakdown.count = count;
- breakdown.args = (Argument*)malloc(memory_size);
- memset(breakdown.args, 0, memory_size);
+ if (count > 0){
+ breakdown.count = count;
+ breakdown.args = push_array(part, Argument, count);
+ memset(breakdown.args, 0, sizeof(Argument)*count);
+ }
return(breakdown);
}
+/*
+Parse arguments by giving pointers to the tokens:
+foo(a, ... , z)
+ ^ ^
+*/
static Argument_Breakdown
-parameter_parse(char *data, Cpp_Token *args_start_token, Cpp_Token *token){
+parameter_parse(Partition *part, char *data, Cpp_Token *args_start_token, Cpp_Token *args_end_token){
int32_t arg_index = 0;
Cpp_Token *arg_token = args_start_token + 1;
int32_t param_string_start = arg_token->start;
int32_t arg_count = 1;
arg_token = args_start_token;
- for (; arg_token < token; ++arg_token){
+ for (; arg_token < args_end_token; ++arg_token){
if (arg_token->type == CPP_TOKEN_COMMA){
++arg_count;
}
}
- Argument_Breakdown breakdown = allocate_argument_breakdown(arg_count);
+ Argument_Breakdown breakdown = allocate_argument_breakdown(part, arg_count);
arg_token = args_start_token + 1;
- for (; arg_token <= token; ++arg_token){
+ for (; arg_token <= args_end_token; ++arg_token){
if (arg_token->type == CPP_TOKEN_COMMA ||
arg_token->type == CPP_TOKEN_PARENTHESE_CLOSE){
@@ -1233,34 +1243,37 @@ parameter_parse(char *data, Cpp_Token *args_start_token, Cpp_Token *token){
++arg_index;
- ++arg_token;
- if (arg_token <= token){
- param_string_start = arg_token->start;
+ if (arg_token+1 <= args_end_token){
+ param_string_start = arg_token[1].start;
}
- --arg_token;
}
}
return(breakdown);
}
+/*
+Moves the context in the following way:
+~~~~~~~ name( ~~~~~~~
+ ^ -> ^
+*/
static int32_t
-function_parse_check(int32_t *index, Cpp_Token **token_ptr, int32_t count){
+function_parse_goto_name(Parse_Context *context){
int32_t result = false;
- int32_t i = *index;
- Cpp_Token *token = *token_ptr;
+ Cpp_Token *token = 0;
{
- for (; i < count; ++i, ++token){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (token->type == CPP_TOKEN_PARENTHESE_OPEN){
break;
}
}
- if (i < count){
- --i;
- --token;
+ if (get_token(context)){
+ do{
+ token = get_prev_token(context);
+ }while(token->type == CPP_TOKEN_COMMENT);
if (token->type == CPP_TOKEN_IDENTIFIER){
result = true;
@@ -1268,142 +1281,157 @@ function_parse_check(int32_t *index, Cpp_Token **token_ptr, int32_t count){
}
}
- *index = i;
- *token_ptr = token;
-
return(result);
}
+/*
+Moves the context in the following way:
+~~~~~~~ name( ~~~~~~~ /* XXX //
+ ^ ---------------> ^
+*/
static int32_t
-function_get_doc(int32_t *index, Cpp_Token **token_ptr, int32_t count,
- char *data, String *doc_string){
+function_get_doc(Parse_Context *context, char *data, String *doc_string){
int32_t result = false;
- int32_t i = *index;
- Cpp_Token *token = *token_ptr;
+ Cpp_Token *token = get_token(context);
+ String lexeme = {0};
- for (; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_COMMENT){
- String lexeme = make_string(data + token->start, token->size);
- if (check_and_fix_docs(&lexeme)){
- *doc_string = lexeme;
- result = true;
- break;
+ if (function_parse_goto_name(context)){
+ if (token->type == CPP_TOKEN_IDENTIFIER){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
+ if (token->type == CPP_TOKEN_COMMENT){
+ lexeme = get_lexeme(*token, data);
+ if (check_and_fix_docs(&lexeme)){
+ *doc_string = lexeme;
+ result = true;
+ break;
+ }
+ }
+ else if (token->type == CPP_TOKEN_BRACE_OPEN){
+ break;
+ }
}
}
- else if (token->type == CPP_TOKEN_BRACE_OPEN){
- break;
- }
}
- *index = i;
- *token_ptr = token;
-
return(result);
}
static int32_t
-parse_cpp_name(int32_t *i_ptr, Cpp_Token **token_ptr, int32_t count, char *data, String *name){
+cpp_name_parse(Parse_Context *context, String *name){
int32_t result = false;
- int32_t i = *i_ptr;
- Cpp_Token *token = *token_ptr;
+ Cpp_Token *token = 0;
+ Cpp_Token *token_start = get_token(context);
- int32_t i_start = i;
- Cpp_Token *token_start = token;
-
- ++i, ++token;
- if (i < count && token->type == CPP_TOKEN_PARENTHESE_OPEN){
- ++i, ++token;
- if (i < count && token->type == CPP_TOKEN_IDENTIFIER){
- ++i, ++token;
- if (i < count && token->type == CPP_TOKEN_PARENTHESE_CLOSE){
- *name = get_lexeme(*(token-1), data);
+ token = get_next_token(context);
+ if (token && token->type == CPP_TOKEN_PARENTHESE_OPEN){
+ token = get_next_token(context);
+ if (token && token->type == CPP_TOKEN_IDENTIFIER){
+ token = get_next_token(context);
+ if (token && token->type == CPP_TOKEN_PARENTHESE_CLOSE){
+ *name = get_lexeme(*(token-1), context->data);
result = true;
}
}
}
if (!result){
- i = i_start;
- token = token_start;
+ set_token(context, token_start);
}
- *i_ptr = i;
- *token_ptr = token;
-
return(result);
}
+/*
+Moves the context in the following way:
+ RETTY~ name( ~~~~~~~ )
+ ^ ---------------> ^
+*/
static int32_t
-function_sig_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count, Cpp_Token *ret_start_token,
- char *data, Item_Set item_set, int32_t sig_count, String cpp_name){
+function_sig_parse(Partition *part, Parse_Context *context, Item_Node *item, String cpp_name){
int32_t result = false;
- int32_t i = *index;
- Cpp_Token *token = *token_ptr;
+ Cpp_Token *token = 0;
+ Cpp_Token *args_start_token = 0;
+ Cpp_Token *ret_token = get_token(context);
- Cpp_Token *args_start_token = token+1;
-
- item_set.items[sig_count].name = get_lexeme(*token, data);
-
- int32_t size = token->start - ret_start_token->start;
- String ret = make_string(data + ret_start_token->start, size);
- ret = chop_whitespace(ret);
- item_set.items[sig_count].ret = ret;
-
- for (; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
- break;
- }
- }
-
- if (i < count){
- int32_t size = token->start + token->size - args_start_token->start;;
- item_set.items[sig_count].args =
- make_string(data + args_start_token->start, size);
- item_set.items[sig_count].t = Item_Function;
- item_set.items[sig_count].cpp_name = cpp_name;
+ if (function_parse_goto_name(context)){
+ token = get_token(context);
+ args_start_token = token+1;
+ item->name = get_lexeme(*token, context->data);
- Argument_Breakdown *breakdown = &item_set.items[sig_count].breakdown;
- *breakdown = parameter_parse(data, args_start_token, token);
+ item->ret = chop_whitespace(
+ str_start_end(context->data, ret_token->start, token->start)
+ );
- result = true;
- }
-
- *index = i;
- *token_ptr = token;
-
- return(result);
-}
-
-static int32_t
-function_parse(Parse_Context *context, char *data,
- Item_Set item_set, int32_t sig_count, String cpp_name){
- int32_t result = false;
-
- Cpp_Token *token = 0, *jtoken = 0;
-
- token = get_token(context);
- item_set.items[sig_count].marker = get_lexeme(*token, data);
- jtoken = token;
-
- if (function_parse_check(get_index(context, jtoken), &jtoken, get_count(context))){
- if (token->type == CPP_TOKEN_IDENTIFIER){
- String doc_string = {0};
- if (function_get_doc(get_index(context, jtoken), &jtoken,
- get_count(context), data, &doc_string)){
- item_set.items[sig_count].doc_string = doc_string;
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
+ if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
+ break;
}
}
+
+ if (token){
+ item->args =
+ str_start_end(context->data, args_start_token->start, token->start + token->size);
+ item->t = Item_Function;
+ item->cpp_name = cpp_name;
+ item->breakdown = parameter_parse(part, context->data, args_start_token, token);
+
+ Assert(get_token(context)->type == CPP_TOKEN_PARENTHESE_CLOSE);
+ result = true;
+ }
}
+ return(result);
+}
+
+/*
+Moves the context in the following way:
+ MARKER ~~~ name( ~~~~~~~ )
+ ^ -------------------> ^
+*/
+static int32_t
+function_parse(Partition *part, Parse_Context *context, Item_Node *item, String cpp_name){
+ int32_t result = false;
+
+ String doc_string = {0};
+ Cpp_Token *token = get_token(context);
+
+ item->marker = get_lexeme(*token, context->data);
+
+ if (function_get_doc(context, context->data, &doc_string)){
+ item->doc_string = doc_string;
+ }
+
+ set_token(context, token);
if (get_next_token(context)){
- Cpp_Token *ret_start_token = token;
- if (function_parse_check(get_index(context, token), &token, get_count(context))){
- if (function_sig_parse(get_index(context, token), &token, get_count(context), ret_start_token,
- data, item_set, sig_count, cpp_name)){
- result = true;
+ if (function_sig_parse(part, context, item, cpp_name)){
+ Assert(get_token(context)->type == CPP_TOKEN_PARENTHESE_CLOSE);
+ result = true;
+ }
+ }
+
+ return(result);
+}
+
+/*
+Moves the context in the following way:
+ /* ~~~ // #define
+ ^ ----> ^
+*/
+static int32_t
+macro_parse_check(Parse_Context *context){
+ int32_t result = false;
+
+ Cpp_Token *token = 0;
+
+ if ((token = get_next_token(context)) != 0){
+ if (token->type == CPP_TOKEN_COMMENT){
+ if ((token = get_next_token(context)) != 0){
+ if (token->type == CPP_PP_DEFINE){
+ result = true;
+ }
}
}
}
@@ -1411,203 +1439,315 @@ function_parse(Parse_Context *context, char *data,
return(result);
}
+/*
+Moves the context in the following way:
+ /* ~~~ // #define ~~~~~~~~~~~~~~~~~ NOT_IN_MACRO_BODY
+ ^ ----------------------------> ^
+*/
static int32_t
-macro_parse_check(int32_t *index, Cpp_Token **token_ptr, int32_t count){
+macro_parse(Partition *part, Parse_Context *context, Item_Node *item){
int32_t result = false;
- int32_t i = *index;
- Cpp_Token *token = *token_ptr;
+ Cpp_Token *token = 0;
+ Cpp_Token *doc_token = 0;
+ Cpp_Token *args_start_token = 0;
- {
- ++i, ++token;
- if (i < count){
- if (token->type == CPP_TOKEN_COMMENT){
- ++i, ++token;
- if (i < count){
- if (token->type == CPP_PP_DEFINE){
- result = true;
- }
- }
- }
- }
- }
+ String doc_string = {0};
- *index = i;
- *token_ptr = token;
-
- return(result);
-}
-
-static int32_t
-macro_parse(int32_t *index, Cpp_Token **token_ptr, int32_t count,
- char *data, Item_Set macro_set, int32_t sig_count){
- int32_t result = false;
-
- int32_t i = *index;
- Cpp_Token *token = *token_ptr;
-
- if (i > 0){
- Cpp_Token *doc_token = token-1;
-
- String doc_string = make_string(data + doc_token->start, doc_token->size);
-
- if (check_and_fix_docs(&doc_string)){
- macro_set.items[sig_count].doc_string = doc_string;
+ if (macro_parse_check(context)){
+ token = get_token(context);
+ if (can_back_step(context)){
+ doc_token = token-1;
- for (; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_IDENTIFIER){
- break;
- }
- }
+ doc_string = get_lexeme(*doc_token, context->data);
- if (i < count && (token->flags & CPP_TFLAG_PP_BODY)){
- macro_set.items[sig_count].name = make_string(data + token->start, token->size);
+ if (check_and_fix_docs(&doc_string)){
+ item->doc_string = doc_string;
- ++i, ++token;
- if (i < count){
- Cpp_Token *args_start_token = token;
- for (; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
- break;
- }
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
+ if (token->type == CPP_TOKEN_IDENTIFIER){
+ break;
}
+ }
+
+ if (get_token(context) && (token->flags & CPP_TFLAG_PP_BODY)){
+ item->name = get_lexeme(*token, context->data);
- if (i < count){
- int32_t start = args_start_token->start;
- int32_t end = token->start + token->size;
- macro_set.items[sig_count].args = make_string(data + start, end - start);
-
- Argument_Breakdown *breakdown = ¯o_set.items[sig_count].breakdown;
- *breakdown = parameter_parse(data, args_start_token, token);
-
- ++i, ++token;
- if (i < count){
- Cpp_Token *body_start = token;
-
- if (body_start->flags & CPP_TFLAG_PP_BODY){
- for (; i < count; ++i, ++token){
- if (!(token->flags & CPP_TFLAG_PP_BODY)){
- break;
- }
- }
-
- --i, --token;
-
- Cpp_Token *body_end = token;
-
- start = body_start->start;
- end = body_end->start + body_end->size;
- macro_set.items[sig_count].body = make_string(data + start, end - start);
+ if ((token = get_next_token(context)) != 0){
+ args_start_token = token;
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
+ if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
+ break;
}
}
- macro_set.items[sig_count].t = Item_Macro;
- result = true;
+ if (token){
+ item->args = str_start_end(context->data, args_start_token->start,
+ token->start + token->size);
+
+ item->breakdown = parameter_parse(part, context->data, args_start_token, token);
+
+ if ((token = get_next_token(context)) != 0){
+ Cpp_Token *body_start = token;
+
+ if (body_start->flags & CPP_TFLAG_PP_BODY){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
+ if (!(token->flags & CPP_TFLAG_PP_BODY)){
+ break;
+ }
+ }
+
+ token = get_prev_token(context);
+
+ item->body =
+ str_start_end(context->data, body_start->start,
+ token->start + token->size);
+ }
+ }
+
+ item->t = Item_Macro;
+ result = true;
+ }
}
}
}
}
}
- *index = i;
- *token_ptr = token;
-
return(result);
}
+static Meta_Unit
+compile_meta_unit(Partition *part, char **files, int32_t file_count,
+ Meta_Keywords *keywords, int32_t key_count){
+ Meta_Unit unit = {0};
+ int32_t i = 0;
+
+ unit.count = file_count;
+ unit.parse = push_array(part, Parse, file_count);
+
+ for (i = 0; i < file_count; ++i){
+ unit.parse[i] = meta_lex(files[i]);
+ }
+
+ // TODO(allen): This stage counts nested structs
+ // and unions which is not correct. Luckily it only
+ // means we over allocate by a few items, but fixing it
+ // to be exactly correct would be nice.
+ for (int32_t J = 0; J < unit.count; ++J){
+ Cpp_Token *token = 0;
+ Parse_Context context_ = setup_parse_context(unit.parse[J]);
+ Parse_Context *context = &context_;
+
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
+ if (!(token->flags & CPP_TFLAG_PP_BODY)){
+
+ String lexeme = get_lexeme(*token, context->data);
+ int32_t match_index = 0;
+ if (string_set_match_table(keywords, sizeof(*keywords), key_count, lexeme, &match_index)){
+ Item_Type type = keywords[match_index].type;
+
+ if (type > Item_Null && type < Item_Type_Count){
+ ++unit.set.count;
+ }
+ else{
+ // TODO(allen): Convert this to a duff's routine and return
+ // this result to the user so that they may do whatever it
+ // is they want to do.
+ }
+ }
+ }
+ }
+ }
+
+ if (unit.set.count > 0){
+ unit.set = allocate_item_set(part, unit.set.count);
+ }
+
+ int32_t index = 0;
+
+ for (int32_t J = 0; J < unit.count; ++J){
+ Cpp_Token *token = 0;
+ Parse_Context context_ = setup_parse_context(unit.parse[J]);
+ Parse_Context *context = &context_;
+
+ String cpp_name = {0};
+ int32_t has_cpp_name = 0;
+
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
+ if (!(token->flags & CPP_TFLAG_PP_BODY)){
+
+ String lexeme = get_lexeme(*token, context->data);
+ int32_t match_index = 0;
+ if (string_set_match_table(keywords, sizeof(*keywords), key_count, lexeme, &match_index)){
+ Item_Type type = keywords[match_index].type;
+
+ switch (type){
+ case Item_Function:
+ {
+ if (function_parse(part, context, unit.set.items + index, cpp_name)){
+ Assert(unit.set.items[index].t == Item_Function);
+ ++index;
+ }
+ else{
+ fprintf(stderr, "warning: invalid function signature\n");
+ }
+ }break;
+
+ case Item_CppName:
+ {
+ if (cpp_name_parse(context, &cpp_name)){
+ has_cpp_name = 1;
+ }
+ else{
+ // TODO(allen): warning message
+ }
+ }break;
+
+ case Item_Macro:
+ {
+ if (macro_parse(part, context, unit.set.items + index)){
+ Assert(unit.set.items[index].t == Item_Macro);
+ ++index;
+ }
+ else{
+ // TODO(allen): warning message
+ }
+ }break;
+
+ case Item_Typedef: //typedef
+ {
+ if (typedef_parse(context, unit.set.items + index)){
+ Assert(unit.set.items[index].t == Item_Typedef);
+ ++index;
+ }
+ else{
+ // TODO(allen): warning message
+ }
+ }break;
+
+ case Item_Struct: case Item_Union: //struct/union
+ {
+ if (struct_parse(part, (type == Item_Struct), context, unit.set.items + index)){
+ Assert(unit.set.items[index].t == Item_Struct ||
+ unit.set.items[index].t == Item_Union);
+ ++index;
+ }
+ else{
+ // TODO(allen): warning message
+ }
+ }break;
+
+ case Item_Enum: //ENUM
+ {
+ if (enum_parse(part, context, unit.set.items + index)){
+ Assert(unit.set.items[index].t == Item_Enum);
+ ++index;
+ }
+ else{
+ // TODO(allen): warning message
+ }
+ }break;
+
+ }
+ }
+ }
+
+ if (has_cpp_name){
+ has_cpp_name = 0;
+ }
+ else{
+ cpp_name = null_string;
+ }
+
+ unit.parse[J].item_count = index;
+ }
+
+ // NOTE(allen): This is necessary for now because
+ // the original count is slightly overestimated thanks
+ // to nested structs and unions.
+ unit.set.count = index;
+ }
+
+ return(unit);
+}
+
static void
-print_struct_html(FILE *file, Item_Node *member){
+print_struct_html(String *out, Item_Node *member){
String name = member->name;
String type = member->type;
String type_postfix = member->type_postfix;
+ append_ss (out, type);
+ append_s_char (out, ' ');
+ append_ss (out, name);
+ append_ss (out, type_postfix);
+
if (match_ss(type, make_lit_string("struct")) ||
match_ss(type, make_lit_string("union"))){
- fprintf(file,
- "%.*s %.*s {
\n"
- "\n",
- type.size, type.str,
- name.size, name.str);
+ append_sc(out, " {
");
for (Item_Node *member_iter = member->first_child;
member_iter != 0;
member_iter = member_iter->next_sibling){
- print_struct_html(file, member_iter);
+ print_struct_html(out, member_iter);
}
- fprintf(file,
- "
\n"
- "};
\n");
+ append_sc(out, "
};
");
}
else{
- fprintf(file,
- "%.*s %.*s%.*s;
\n",
- type.size, type.str,
- name.size, name.str,
- type_postfix.size, type_postfix.str
- );
+ append_sc(out, ";
");
}
}
static void
-print_function_html(FILE *file, Item_Node item, String name,
- char *function_call_head){
- String ret = item.ret;
- fprintf(file,
- "%.*s %s%.*s(\n"
- "",
- ret.size, ret.str,
- function_call_head,
- name.size, name.str);
+print_function_html(String *out, String ret, char *function_call_head, String name, Argument_Breakdown breakdown){
+ append_ss (out, ret);
+ append_s_char (out, ' ');
+ append_sc (out, function_call_head);
+ append_ss (out, name);
+ append_sc (out, "(
");
- Argument_Breakdown breakdown = item.breakdown;
- int32_t arg_count = breakdown.count;
- for (int32_t j = 0; j < arg_count; ++j){
- String param_string = breakdown.args[j].param_string;
- if (j < arg_count - 1){
- fprintf(file, "%.*s,
", param_string.size, param_string.str);
- }
- else{
- fprintf(file, "%.*s
", param_string.size, param_string.str);
+ for (int32_t j = 0; j < breakdown.count; ++j){
+ append_ss(out, breakdown.args[j].param_string);
+ if (j < breakdown.count - 1){
+ append_s_char(out, ',');
}
+ append_sc(out, "
");
}
- fprintf(file, "
)\n");
+ append_sc(out, "
)");
}
static void
-print_macro_html(FILE *file, Item_Node item, String name){
- Argument_Breakdown breakdown = item.breakdown;
- int32_t arg_count = breakdown.count;
- if (arg_count == 0){
- fprintf(file,
- "#define %.*s()",
- name.size, name.str);
+print_macro_html(String *out, String name, Argument_Breakdown breakdown){
+
+ if (breakdown.count == 0){
+ append_sc(out, "#define ");
+ append_ss(out, name);
+ append_sc(out, "()");
}
- else if (arg_count == 1){
- String param_string = breakdown.args[0].param_string;
- fprintf(file,
- "#define %.*s(%.*s)",
- name.size, name.str,
- param_string.size, param_string.str);
+ else if (breakdown.count == 1){
+ append_sc (out, "#define ");
+ append_ss (out, name);
+ append_s_char (out, '(');
+ append_ss (out, breakdown.args[0].param_string);
+ append_s_char (out, ')');
}
else{
- fprintf(file,
- "#define %.*s(\n"
- "",
- name.size, name.str);
+ append_sc (out, "#define ");
+ append_ss (out, name);
+ append_sc (out, "(
");
- for (int32_t j = 0; j < arg_count; ++j){
- String param_string = breakdown.args[j].param_string;
- if (j < arg_count - 1){
- fprintf(file, "%.*s,
", param_string.size, param_string.str);
- }
- else{
- fprintf(file, "%.*s
", param_string.size, param_string.str);
+ for (int32_t j = 0; j < breakdown.count; ++j){
+ append_ss(out, breakdown.args[j].param_string);
+ if (j < breakdown.count - 1){
+ append_s_char(out, ',');
}
+ append_sc(out, "
");
}
- fprintf(file, "
)\n");
+ append_sc(out, ")
)");
}
}
@@ -1642,28 +1782,47 @@ print_macro_html(FILE *file, Item_Node item, String name){
#define DOC_ITEM_CLOSE "
"
static void
-print_struct_docs(FILE *file, Partition *part, Item_Node *member){
+print_struct_docs(String *out, Partition *part, Item_Node *member){
for (Item_Node *member_iter = member->first_child;
member_iter != 0;
member_iter = member_iter->next_sibling){
String type = member_iter->type;
if (match_ss(type, make_lit_string("struct")) ||
match_ss(type, make_lit_string("union"))){
- print_struct_docs(file, part, member_iter);
+ print_struct_docs(out, part, member_iter);
}
else{
Documentation doc = {0};
perform_doc_parse(part, member_iter->doc_string, &doc);
- fprintf(file,
- "
\n"
- "
"DOC_ITEM_HEAD_INL_OPEN
- "%.*s"DOC_ITEM_HEAD_INL_CLOSE"
\n"
- "
"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
\n"
- "
\n",
- member_iter->name.size, member_iter->name.str,
- doc.main_doc.size, doc.main_doc.str
- );
+ append_sc(out, "
");
+
+ append_sc(out, "
"DOC_ITEM_HEAD_INL_OPEN);
+ append_ss(out, member_iter->name);
+ append_sc(out, DOC_ITEM_HEAD_INL_CLOSE"
");
+
+ append_sc(out, "
"DOC_ITEM_OPEN);
+ append_ss(out, doc.main_doc);
+ append_sc(out, DOC_ITEM_CLOSE"
");
+
+ append_sc(out, "
");
+ }
+ }
+}
+
+static void
+print_see_also(String *out, Documentation *doc){
+ int32_t doc_see_count = doc->see_also_count;
+ if (doc_see_count > 0){
+ append_sc(out, DOC_HEAD_OPEN"See Also"DOC_HEAD_CLOSE);
+
+ for (int32_t j = 0; j < doc_see_count; ++j){
+ String see_also = doc->see_also[j];
+ append_sc(out, DOC_ITEM_OPEN"
");
+ append_ss(out, see_also);
+ append_sc(out, ""DOC_ITEM_CLOSE);
}
}
}
@@ -1685,39 +1844,6 @@ print_see_also(FILE *file, Documentation *doc){
}
}
-typedef struct String_Function_Marker{
- int32_t parse_function;
- int32_t is_inline;
- int32_t parse_doc;
- int32_t cpp_name;
-} String_Function_Marker;
-
-static String_Function_Marker
-string_function_marker_check(String lexeme){
- String_Function_Marker result = {0};
-
- if (match_ss(lexeme, make_lit_string("FSTRING_INLINE"))){
- result.is_inline = true;
- result.parse_function = true;
- }
- else if (match_ss(lexeme, make_lit_string("FSTRING_LINK"))){
- result.parse_function = true;
- }
- else if (match_ss(lexeme, make_lit_string("DOC_EXPORT"))){
- result.parse_doc = true;
- }
- else if (match_ss(lexeme, make_lit_string("CPP_NAME"))){
- result.cpp_name = true;
- }
-
- return(result);
-}
-
-static String
-get_string(char *data, int32_t start, int32_t end){
- return(make_string(data + start, end - start));
-}
-
static void
print_str(FILE *file, String str){
if (str.size > 0){
@@ -1726,28 +1852,26 @@ print_str(FILE *file, String str){
}
static void
-print_function_body_code(FILE *file, int32_t *index, Cpp_Token **token_ptr, int32_t count, String *code,
- int32_t start){
- int32_t i = *index;
- Cpp_Token *token = *token_ptr;
-
- String pstr = {0};
+print_function_body_code(String *out, Parse_Context *context, int32_t start){
+ String pstr = {0}, lexeme = {0};
+ Cpp_Token *token = 0;
+ int32_t do_print = 0;
int32_t nest_level = 0;
int32_t finish = false;
int32_t do_whitespace_print = false;
- for (; i < count; ++i, ++token){
+ for (; (token = get_token(context)) != 0; get_next_token(context)){
if (do_whitespace_print){
- pstr = get_string(code->str, start, token->start);
- print_str(file, pstr);
+ pstr = str_start_end(context->data, start, token->start);
+ append_ss(out, pstr);
}
else{
do_whitespace_print = true;
}
- int32_t do_print = true;
+ do_print = true;
if (token->type == CPP_TOKEN_COMMENT){
- String lexeme = make_string(code->str + token->start, token->size);
+ lexeme = get_lexeme(*token, context->data);
if (check_and_fix_docs(&lexeme)){
do_print = false;
}
@@ -1762,77 +1886,263 @@ print_function_body_code(FILE *file, int32_t *index, Cpp_Token **token_ptr, int3
}
}
- if (i < count){
- if (do_print){
- pstr = make_string(code->str + token->start, token->size);
- print_str(file, pstr);
- }
-
- start = token->start + token->size;
+ if (do_print){
+ pstr = get_lexeme(*token, context->data);
+ append_ss(out, pstr);
}
+ start = token->start + token->size;
+
if (finish){
break;
}
}
-
- *index = i;
- *token_ptr = token;
}
static void
-print_function_docs(FILE *file, Partition *part, String name, String doc_string){
+print_function_docs(String *out, Partition *part, String name, String doc_string){
if (doc_string.size == 0){
- fprintf(file, "No documentation generated for this function, assume it is non-public.\n");
+ append_sc(out, "No documentation generated for this function.");
fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
}
- Documentation doc_ = {0};
- Documentation *doc = &doc_;
+ Temp_Memory temp = begin_temp_memory(part);
- perform_doc_parse(part, doc_string, doc);
+ Documentation doc = {0};
- int32_t doc_param_count = doc->param_count;
+ perform_doc_parse(part, doc_string, &doc);
+
+ int32_t doc_param_count = doc.param_count;
if (doc_param_count > 0){
- fprintf(file, DOC_HEAD_OPEN"Parameters"DOC_HEAD_CLOSE);
+ append_sc(out, DOC_HEAD_OPEN"Parameters"DOC_HEAD_CLOSE);
for (int32_t j = 0; j < doc_param_count; ++j){
- String param_name = doc->param_name[j];
- String param_docs = doc->param_docs[j];
+ String param_name = doc.param_name[j];
+ String param_docs = doc.param_docs[j];
// TODO(allen): check that param_name is actually
// a parameter to this function!
- fprintf(file,
- "
\n"
- DOC_ITEM_HEAD_OPEN"%.*s"DOC_ITEM_HEAD_CLOSE"\n"
- "
"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
\n"
- "
\n",
- param_name.size, param_name.str,
- param_docs.size, param_docs.str
- );
+ append_sc(out, "
"DOC_ITEM_HEAD_OPEN);
+ append_ss(out, param_name);
+ append_sc(out, DOC_ITEM_HEAD_CLOSE"
"DOC_ITEM_OPEN);
+ append_ss(out, param_docs);
+ append_sc(out, DOC_ITEM_CLOSE"
");
}
}
- String ret_doc = doc->return_doc;
+ String ret_doc = doc.return_doc;
if (ret_doc.size != 0){
- fprintf(file, DOC_HEAD_OPEN"Return"DOC_HEAD_CLOSE);
- fprintf(file,
- DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
- ret_doc.size, ret_doc.str
- );
+ append_sc(out, DOC_HEAD_OPEN"Return"DOC_HEAD_CLOSE DOC_ITEM_OPEN);
+ append_ss(out, ret_doc);
+ append_sc(out, DOC_ITEM_CLOSE);
}
- String main_doc = doc->main_doc;
+ String main_doc = doc.main_doc;
if (main_doc.size != 0){
- fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
- fprintf(file,
- DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
- main_doc.size, main_doc.str
- );
+ append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE DOC_ITEM_OPEN);
+ append_ss(out, main_doc);
+ append_sc(out, DOC_ITEM_CLOSE);
}
- print_see_also(file, doc);
+ print_see_also(out, &doc);
+
+ end_temp_memory(temp);
+}
+
+static void
+print_item_in_list(String *out, String name, char *id_postfix){
+ append_sc(out, "
");
+ append_ss(out, name);
+ append_sc(out, "");
+}
+
+static void
+print_item(String *out, Partition *part, Item_Node *item,
+ char *id_postfix, char *function_prefix,
+ char *section, int32_t I){
+ Temp_Memory temp = begin_temp_memory(part);
+
+ String name = item->name;
+ /* NOTE(allen):
+ Open a div for the whole item.
+ Put a heading in it with the name and section.
+ Open a "descriptive" box for the display of the code interface.
+ */
+ append_sc(out, "
");
+
+ append_sc (out, "
§");
+ append_sc (out, section);
+ append_s_char (out, '.');
+ append_int_to_str (out, I);
+ append_sc (out, ": ");
+ append_ss (out, name);
+ append_sc (out, "
");
+
+ append_sc(out, "
");
+
+ switch (item->t){
+ case Item_Function:
+ {
+ // NOTE(allen): Code box
+ Assert(function_prefix != 0);
+ print_function_html(out, item->ret, function_prefix, item->name, item->breakdown);
+
+ // NOTE(allen): Close the code box
+ append_sc(out, "
");
+
+ // NOTE(allen): Descriptive section
+ print_function_docs(out, part, item->name, item->doc_string);
+ }break;
+
+ case Item_Macro:
+ {
+ // NOTE(allen): Code box
+ print_macro_html(out, item->name, item->breakdown);
+
+ // NOTE(allen): Close the code box
+ append_sc(out, "
");
+
+ // NOTE(allen): Descriptive section
+ print_function_docs(out, part, item->name, item->doc_string);
+ }break;
+
+ case Item_Typedef:
+ {
+ String type = item->type;
+
+ // NOTE(allen): Code box
+ append_sc (out, "typedef ");
+ append_ss (out, type);
+ append_s_char (out, ' ');
+ append_ss (out, name);
+ append_s_char (out, ';');
+
+ // NOTE(allen): Close the code box
+ append_sc(out, "
");
+
+ // NOTE(allen): Descriptive section
+ String doc_string = item->doc_string;
+ Documentation doc = {0};
+ perform_doc_parse(part, doc_string, &doc);
+
+ String main_doc = doc.main_doc;
+ if (main_doc.size != 0){
+ append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
+
+ append_sc(out, DOC_ITEM_OPEN);
+ append_ss(out, main_doc);
+ append_sc(out, DOC_ITEM_CLOSE);
+ }
+
+ print_see_also(out, &doc);
+
+ }break;
+
+ case Item_Enum:
+ {
+ // NOTE(allen): Code box
+ append_sc (out, "enum ");
+ append_ss (out, name);
+ append_s_char (out, ';');
+
+ // NOTE(allen): Close the code box
+ append_sc(out, "
");
+
+ // NOTE(allen): Descriptive section
+ String doc_string = item->doc_string;
+ Documentation doc = {0};
+ perform_doc_parse(part, doc_string, &doc);
+
+ String main_doc = doc.main_doc;
+ if (main_doc.size != 0){
+ append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
+
+ append_sc(out, DOC_ITEM_OPEN);
+ append_ss(out, main_doc);
+ append_sc(out, DOC_ITEM_CLOSE);
+ }
+
+ if (item->first_child){
+ append_sc(out, DOC_HEAD_OPEN"Values"DOC_HEAD_CLOSE);
+
+ for (Item_Node *member = item->first_child;
+ member;
+ member = member->next_sibling){
+ Documentation doc = {0};
+ perform_doc_parse(part, member->doc_string, &doc);
+
+ append_sc(out, "
");
+
+ // NOTE(allen): Dafuq is this all?
+ append_sc(out, "
"DOC_ITEM_HEAD_INL_OPEN);
+ append_ss(out, member->name);
+ append_sc(out, DOC_ITEM_HEAD_INL_CLOSE);
+
+ if (member->value.str){
+ append_sc(out, " = ");
+ append_ss(out, member->value);
+ }
+
+ append_sc(out, "
");
+
+ append_sc(out, "
"DOC_ITEM_OPEN);
+ append_ss(out, doc.main_doc);
+ append_sc(out, DOC_ITEM_CLOSE"
");
+
+ append_sc(out, "
");
+ }
+ }
+
+ print_see_also(out, &doc);
+
+ }break;
+
+ case Item_Struct: case Item_Union:
+ {
+ Item_Node *member = item;
+
+ // NOTE(allen): Code box
+ print_struct_html(out, member);
+
+ // NOTE(allen): Close the code box
+ append_sc(out, "
");
+
+ // NOTE(allen): Descriptive section
+ {
+ String doc_string = member->doc_string;
+ Documentation doc = {0};
+ perform_doc_parse(part, doc_string, &doc);
+
+ String main_doc = doc.main_doc;
+ if (main_doc.size != 0){
+ append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
+
+ append_sc(out, DOC_ITEM_OPEN);
+ append_ss(out, main_doc);
+ append_sc(out, DOC_ITEM_CLOSE);
+ }
+
+ if (member->first_child){
+ append_sc(out, DOC_HEAD_OPEN"Fields"DOC_HEAD_CLOSE);
+ print_struct_docs(out, part, member);
+ }
+
+ print_see_also(out, &doc);
+ }
+ }break;
+ }
+
+ // NOTE(allen): Close the item box
+ append_sc(out, "
");
+
+ end_temp_memory(temp);
}
typedef struct App_API_Name{
@@ -1845,11 +2155,10 @@ typedef struct App_API{
} App_API;
static App_API
-allocate_app_api(int32_t count){
+allocate_app_api(Partition *part, 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);
+ app_api.names = push_array(part, App_API_Name, count);
+ memset(app_api.names, 0, sizeof(App_API_Name)*count);
return(app_api);
}
@@ -1867,752 +2176,430 @@ generate_custom_headers(){
Partition part_ = make_part(mem, size);
Partition *part = &part_;
- Parse string_parse = meta_parse("internal_4coder_string.cpp");
- int32_t string_function_count = 0;
+ // NOTE(allen): Parse the internal string file.
+ static char *string_files[] = {
+ "internal_4coder_string.cpp"
+ };
- {
- char *data = string_parse.code.str;
-
- int32_t count = string_parse.tokens.count;
- Cpp_Token *tokens = string_parse.tokens.tokens;
- Cpp_Token *token = tokens;
-
- for (int32_t i = 0; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_IDENTIFIER &&
- !(token->flags & CPP_TFLAG_PP_BODY)){
- String lexeme = make_string(data + token->start, token->size);
-
- String_Function_Marker marker =
- string_function_marker_check(lexeme);
-
- if (marker.parse_function){
- if (function_parse_check(&i, &token, count)){
- ++string_function_count;
- }
- }
- else if (marker.parse_doc){
- if (macro_parse_check(&i, &token, count)){
- ++string_function_count;
- }
- }
- }
- }
- }
+ static Meta_Keywords string_keys[] = {
+ {make_lit_string("FSTRING_INLINE") , Item_Function } ,
+ {make_lit_string("FSTRING_LINK") , Item_Function } ,
+ {make_lit_string("DOC_EXPORT") , Item_Macro } ,
+ {make_lit_string("CPP_NAME") , Item_CppName } ,
+ };
- Item_Set string_function_set = allocate_item_set(part, string_function_count);
- int32_t string_sig_count = 0;
+ Meta_Unit string_unit = compile_meta_unit(part, string_files, ArrayCount(string_files),
+ string_keys, ArrayCount(string_keys));
- {
- String *code = &string_parse.code;
- Cpp_Token_Stack *token_stack = &string_parse.tokens;
-
- char *data = code->str;
-
- int32_t count = token_stack->count;
- Cpp_Token *tokens = token_stack->tokens;
- Cpp_Token *token = tokens;
-
- Parse_Context context_ = setup_parse_context(*token_stack);
- Parse_Context *context = &context_;
-
- String cpp_name = {0};
- int32_t has_cpp_name = 0;
-
- for (int32_t i = 0; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_IDENTIFIER &&
- !(token->flags & CPP_TFLAG_PP_BODY)){
- String lexeme = make_string(data + token->start, token->size);
-
- String_Function_Marker marker =
- string_function_marker_check(lexeme);
-
- if (marker.cpp_name){
- if (parse_cpp_name(&i, &token, count, data, &cpp_name)){
- has_cpp_name = 1;
- }
- }
- else if (marker.parse_function){
- set_token(context, token);
- if (function_parse(context, data,
- string_function_set, string_sig_count,
- cpp_name)){
- ++string_sig_count;
- }
- }
- else if (marker.parse_doc){
- if (macro_parse_check(&i, &token, count)){
- macro_parse(&i, &token, count, data,
- string_function_set, string_sig_count);
- ++string_sig_count;
- }
- }
-
- if (has_cpp_name){
- has_cpp_name = 0;
- }
- else{
- cpp_name = string_zero();
- }
- }
- }
- }
- //
- // App API parsing
- //
+ // NOTE(allen): Parse the customization API files
+ static char *functions_files[] = {
+ "4ed_api_implementation.cpp",
+ "win32_api_impl.cpp"
+ };
- Parse parses[2];
- parses[0] = meta_parse("4ed_api_implementation.cpp");
- parses[1] = meta_parse("win32_api_impl.cpp");
+ static Meta_Keywords functions_keys[] = {
+ {make_lit_string("API_EXPORT"), Item_Function},
+ };
- int32_t line_count = 0;
+ Meta_Unit unit_custom = compile_meta_unit(part, functions_files, ArrayCount(functions_files),
+ functions_keys, ArrayCount(functions_keys));
- for (int32_t J = 0; J < 2; ++J){
- Parse *parse = &parses[J];
-
- char *data = parse->code.str;
-
- int32_t count = parse->tokens.count;
- Cpp_Token *tokens = parse->tokens.tokens;
- Cpp_Token *token = tokens;
-
- for (int32_t i = 0; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_IDENTIFIER &&
- !(token->flags & CPP_TFLAG_PP_BODY)){
- String lexeme = make_string(data + token->start, token->size);
- if (match_ss(lexeme, make_lit_string("API_EXPORT"))){
- if (function_parse_check(&i, &token, count)){
- ++line_count;
- }
- }
- }
- }
- }
- Item_Set function_set = allocate_item_set(part, line_count);
- App_API func_4ed_names = allocate_app_api(line_count);
- int32_t sig_count = 0;
- int32_t sig_count_per_file[2];
+ // NOTE(allen): Compute and store variations of the function names
+ App_API func_4ed_names = allocate_app_api(part, unit_custom.set.count);
- for (int32_t J = 0; J < 2; ++J){
- Parse *parse = &parses[J];
-
- char *data = parse->code.str;
-
- int32_t count = parse->tokens.count;
- Cpp_Token *tokens = parse->tokens.tokens;
-
- Parse_Context context_ = setup_parse_context(parse->tokens);
- Parse_Context *context = &context_;
-
- // NOTE(allen): Header Parse
- Cpp_Token *token = tokens;
- for (int32_t i = 0; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_IDENTIFIER &&
- !(token->flags & CPP_TFLAG_PP_BODY)){
- String lexeme = make_string(data + token->start, token->size);
- if (match_ss(lexeme, make_lit_string("API_EXPORT"))){
- set_token(context, token);
- function_parse(context, data, function_set,
- sig_count, string_zero());
- if (function_set.items[sig_count].t == Item_Null){
- function_set.items[sig_count] = null_item_node;
- // TODO(allen): get warning file name and line numbers
- fprintf(stderr, "generator warning : invalid function signature\n");
- }
- ++sig_count;
- }
- }
- }
-
- ++sig_count_per_file[J] = sig_count;
- }
-
- for (int32_t i = 0; i < sig_count; ++i){
- String name_string = function_set.items[i].name;
+ for (int32_t i = 0; i < unit_custom.set.count; ++i){
+ String name_string = unit_custom.set.items[i].name;
String *macro = &func_4ed_names.names[i].macro;
String *public_name = &func_4ed_names.names[i].public_name;
- macro->size = 0;
- macro->memory_size = name_string.size+4;
-
- macro->str = (char*)malloc(macro->memory_size);
- copy_ss(macro, name_string);
- to_upper_s(macro);
+ *macro = str_alloc(part, name_string.size+4);
+ to_upper_ss(macro, name_string);
append_ss(macro, make_lit_string("_SIG"));
+ *public_name = str_alloc(part, name_string.size);
+ to_lower_ss(public_name, name_string);
- public_name->size = 0;
- public_name->memory_size = name_string.size;
-
- public_name->str = (char*)malloc(public_name->memory_size);
- copy_ss(public_name, name_string);
- to_lower_s(public_name);
+ partition_align(part, 4);
}
- // NOTE(allen): Header
- FILE *file = fopen(OS_API_H, "wb");
- int32_t main_api_count = sig_count_per_file[0];
- for (int32_t i = main_api_count; i < sig_count; ++i){
- String ret_string = function_set.items[i].ret;
- String args_string = function_set.items[i].args;
- String macro_string = func_4ed_names.names[i].macro;
-
- fprintf(file, "#define %.*s(n) %.*s n%.*s\n",
- macro_string.size, macro_string.str,
- ret_string.size, ret_string.str,
- args_string.size, args_string.str);
- }
+ // NOTE(allen): Parse the customization API types
+ static char *type_files[] = {
+ "4coder_types.h",
+ "4coder_lexer_types.h",
+ };
- for (int32_t i = main_api_count; i < sig_count; ++i){
- String name_string = function_set.items[i].name;
- String macro_string = func_4ed_names.names[i].macro;
-
- fprintf(file, "typedef %.*s(%.*s_Function);\n",
- macro_string.size, macro_string.str,
- name_string.size, name_string.str);
- }
+ static Meta_Keywords type_keys[] = {
+ {make_lit_string("typedef") , Item_Typedef } ,
+ {make_lit_string("struct") , Item_Struct } ,
+ {make_lit_string("union") , Item_Union } ,
+ {make_lit_string("ENUM") , Item_Enum } ,
+ };
- fclose(file);
+ Meta_Unit unit = compile_meta_unit(part, type_files, ArrayCount(type_files),
+ type_keys, ArrayCount(type_keys));
- file = fopen(API_H, "wb");
- for (int32_t i = 0; i < sig_count; ++i){
- String ret_string = function_set.items[i].ret;
- String args_string = function_set.items[i].args;
- String macro_string = func_4ed_names.names[i].macro;
-
- fprintf(file, "#define %.*s(n) %.*s n%.*s\n",
- macro_string.size, macro_string.str,
- ret_string.size, ret_string.str,
- args_string.size, args_string.str);
- }
+ // NOTE(allen): Output
+ String out = str_alloc(part, 10 << 20);
+ Out_Context context = {0};
- for (int32_t i = 0; i < sig_count; ++i){
- String name_string = function_set.items[i].name;
- String macro_string = func_4ed_names.names[i].macro;
-
- fprintf(file, "typedef %.*s(%.*s_Function);\n",
- macro_string.size, macro_string.str,
- name_string.size, name_string.str);
- }
-
- fprintf(file, "struct Application_Links{\n");
- fprintf(file,
- " void *memory;\n"
- " int32_t memory_size;\n"
- );
- for (int32_t i = 0; i < sig_count; ++i){
- String name_string = function_set.items[i].name;
- String public_string = func_4ed_names.names[i].public_name;
-
- fprintf(file, " %.*s_Function *%.*s;\n",
- name_string.size, name_string.str,
- public_string.size, public_string.str);
- }
- fprintf(file,
- " void *cmd_context;\n"
- " void *system_links;\n"
- " void *current_coroutine;\n"
- " int32_t type_coroutine;\n"
- );
- fprintf(file, "};\n");
-
- fprintf(file, "#define FillAppLinksAPI(app_links) do{");
- for (int32_t i = 0; i < sig_count; ++i){
- String name = function_set.items[i].name;
- String public_string = func_4ed_names.names[i].public_name;
-
- fprintf(file,
- "\\\n"
- "app_links->%.*s = %.*s;",
- public_string.size, public_string.str,
- name.size, name.str
- );
- }
- fprintf(file, " } while(false)\n");
-
- fclose(file);
-
- // NOTE(allen): Documentation
- {
- Item_Set typedef_set = {0};
- Item_Set struct_set = {0};
- Item_Set flag_set = {0};
- Item_Set enum_set = {0};
-
- Parse type_parse[1];
- type_parse[0] = meta_parse("4coder_types.h");
-
- int32_t file_count = ArrayCount(type_parse);
-
- int32_t typedef_count = 0;
- int32_t struct_count = 0;
- int32_t flag_count = 0;
- int32_t enum_count = 0;
-
- static String type_spec_keys[] = {
- make_lit_string("typedef"),
- make_lit_string("struct"),
- make_lit_string("union"),
- make_lit_string("ENUM"),
- make_lit_string("FLAGENUM"),
- };
-
- for (int32_t J = 0; J < file_count; ++J){
- char *data = type_parse[J].code.str;
-
- int32_t count = type_parse[J].tokens.count;
- Cpp_Token *tokens = type_parse[J].tokens.tokens;
- Cpp_Token *token = tokens;
-
- for (int32_t i = 0; i < count; ++i, ++token){
- if (!(token->flags & CPP_TFLAG_PP_BODY) &&
- (token->type == CPP_TOKEN_KEY_TYPE_DECLARATION ||
- token->type == CPP_TOKEN_IDENTIFIER)){
-
- String lexeme = make_string(data + token->start, token->size);
- int32_t match_index = 0;
- if (string_set_match(type_spec_keys, ArrayCount(type_spec_keys),
- lexeme, &match_index)){
- switch (match_index){
- case 0: //typedef
- ++typedef_count; break;
-
- case 1: case 2: //struct/union
- ++struct_count; break;
-
- case 3: //ENUM
- ++enum_count; break;
-
- case 4: //FLAGENUM
- ++flag_count; break;
- }
- }
- }
- }
+ // NOTE(allen): Custom API headers
+ if (begin_file_out(&context, OS_API_H, &out)){
+ int32_t main_api_count = unit_custom.parse[0].item_count;
+ int32_t os_api_count = unit_custom.parse[1].item_count;
+ for (int32_t i = main_api_count; i < os_api_count; ++i){
+ append_sc(&out, "#define ");
+ append_ss(&out, func_4ed_names.names[i].macro);
+ append_sc(&out, "(n) ");
+ append_ss(&out, unit_custom.set.items[i].ret);
+ append_sc(&out, " n");
+ append_ss(&out, unit_custom.set.items[i].args);
+ append_s_char(&out, '\n');
}
- if (typedef_count > 0){
- typedef_set = allocate_item_set(part, typedef_count);
+ for (int32_t i = main_api_count; i < os_api_count; ++i){
+ append_sc(&out, "typedef ");
+ append_ss(&out, func_4ed_names.names[i].macro);
+ append_s_char(&out, '(');
+ append_ss(&out, unit_custom.set.items[i].name);
+ append_sc(&out, "_Function);\n");
}
- if (struct_count > 0){
- struct_set = allocate_item_set(part, struct_count);
+ end_file_out(context);
+ }
+ else{
+ // TODO(allen): warning
+ }
+
+ if (begin_file_out(&context, API_H, &out)){
+ for (int32_t i = 0; i < unit_custom.set.count; ++i){
+ append_sc(&out, "#define ");
+ append_ss(&out, func_4ed_names.names[i].macro);
+ append_sc(&out, "(n) ");
+ append_ss(&out, unit_custom.set.items[i].ret);
+ append_sc(&out, " n");
+ append_ss(&out, unit_custom.set.items[i].args);
+ append_s_char(&out, '\n');
}
- if (enum_count > 0){
- enum_set = allocate_item_set(part, enum_count);
+ for (int32_t i = 0; i < unit_custom.set.count; ++i){
+ append_sc(&out, "typedef ");
+ append_ss(&out, func_4ed_names.names[i].macro);
+ append_s_char(&out, '(');
+ append_ss(&out, unit_custom.set.items[i].name);
+ append_sc(&out, "_Function);\n");
}
- if (flag_count > 0){
- flag_set = allocate_item_set(part, flag_count);
+ append_sc(&out,
+ "struct Application_Links{\n");
+
+ for (int32_t i = 0; i < unit_custom.set.count; ++i){
+ append_ss(&out, unit_custom.set.items[i].name);
+ append_sc(&out, "_Function *");
+ append_ss(&out, func_4ed_names.names[i].public_name);
+ append_sc(&out, ";\n");
}
- int32_t typedef_index = 0;
- int32_t struct_index = 0;
- int32_t flag_index = 0;
- int32_t enum_index = 0;
+ append_sc(&out,
+ "void *memory;\n"
+ "int32_t memory_size;\n"
+ "void *cmd_context;\n"
+ "void *system_links;\n"
+ "void *current_coroutine;\n"
+ "int32_t type_coroutine;\n"
+ "};\n");
- for (int32_t J = 0; J < file_count; ++J){
- char *data = type_parse[J].code.str;
- Cpp_Token_Stack types_tokens = type_parse[J].tokens;
-
- int32_t count = types_tokens.count;
- Cpp_Token *tokens = types_tokens.tokens;
- Cpp_Token *token = tokens;
-
- for (int32_t i = 0; i < count; ++i, ++token){
- Assert(i == (int32_t)(token - tokens));
- if (!(token->flags & CPP_TFLAG_PP_BODY) &&
- (token->type == CPP_TOKEN_KEY_TYPE_DECLARATION ||
- token->type == CPP_TOKEN_IDENTIFIER)){
-
- String lexeme = make_string(data + token->start, token->size);
- int32_t match_index = 0;
- if (string_set_match(type_spec_keys, ArrayCount(type_spec_keys),
- lexeme, &match_index)){
- switch (match_index){
- case 0: //typedef
- {
- if (parse_typedef(data, tokens, count, &token,
- typedef_set, typedef_index)){
- ++typedef_index;
- }
- i = (int32_t)(token - tokens);
- }break;
-
- case 1: case 2: //struct/union
- {
- if (parse_struct(part, (match_index == 1),
- data, tokens, count, &token,
- struct_set.items + struct_index)){
- ++struct_index;
- }
- i = (int32_t)(token - tokens);
- }break;
-
- case 3: //ENUM
- {
- if (parse_enum(part, data,
- tokens, count, &token,
- enum_set, enum_index)){
- ++enum_index;
- }
- i = (int32_t)(token - tokens);
- }break;
-
- case 4: //FLAGENUM
- {
- if (parse_enum(part, data,
- tokens, count, &token,
- flag_set, flag_index)){
- ++flag_index;
- }
- i = (int32_t)(token - tokens);
- }break;
- }
- }
- }
- }
-
- typedef_count = typedef_index;
- struct_count = struct_index;
- enum_count = enum_index;
- flag_count = flag_index;
+ append_sc(&out, "#define FillAppLinksAPI(app_links) do{");
+
+ for (int32_t i = 0; i < unit_custom.set.count; ++i){
+ append_sc(&out, "\\\napp_links->");
+ append_ss(&out, func_4ed_names.names[i].public_name);
+ append_sc(&out, " = ");
+ append_ss(&out, unit_custom.set.items[i].name);
+ append_s_char(&out, ';');
}
+ append_sc(&out, "} while(false)\n");
- //
- // Output 4coder_string.h
- //
+ end_file_out(context);
+ }
+ else{
+ // TODO(allen): warning
+ }
+
+ // NOTE(allen): String Library
+ if (begin_file_out(&context, STRING_H, &out)){
+ Cpp_Token *token = 0;
+ int32_t start = 0;
- file = fopen(STRING_H, "wb");
+ Parse parse = string_unit.parse[0];
+ Parse_Context pcontext = setup_parse_context(parse);
- {
- String *code = &string_parse.code;
- Cpp_Token_Stack *token_stack = &string_parse.tokens;
-
- int32_t start = 0;
-
- int32_t count = token_stack->count;
- Cpp_Token *tokens = token_stack->tokens;
- Cpp_Token *token = tokens;
- int32_t i = 0;
-
- for (i = 0; i < count; ++i, ++token){
- if (token->type == CPP_TOKEN_IDENTIFIER &&
- !(token->flags & CPP_TFLAG_PP_BODY)){
- String lexeme = make_string(code->str + token->start, token->size);
- if (match_ss(lexeme, make_lit_string("FSTRING_BEGIN"))){
- start = token->start + token->size;
- break;
- }
- }
- }
-
- String pstr = {0};
- int32_t do_whitespace_print = true;
-
- for(++i, ++token; i < count; ++i, ++token){
- if (do_whitespace_print){
- pstr = get_string(code->str, start, token->start);
- print_str(file, pstr);
- }
- else{
- do_whitespace_print = true;
- }
-
- String lexeme = get_lexeme(*token, code->str);
-
- int32_t do_print = true;
- if (match_ss(lexeme, make_lit_string("FSTRING_DECLS"))){
- fprintf(file, "#if !defined(FCODER_STRING_H)\n#define FCODER_STRING_H\n\n");
-
- do_print = false;
-
-#define RETURN_PADDING 16
-#define SIG_PADDING 30
-
- for (int32_t j = 0; j < string_sig_count; ++j){
- char line_space[2048];
- String line = make_fixed_width_string(line_space);
-
- if (string_function_set.items[j].t != Item_Macro){
- String marker = string_function_set.items[j].marker;
- String ret = string_function_set.items[j].ret;
- String name = string_function_set.items[j].name;
- String args = string_function_set.items[j].args;
-
- append_ss(&line, marker);
- append_padding(&line, ' ', RETURN_PADDING);
- append_ss(&line, ret);
- append_padding(&line, ' ', SIG_PADDING);
- append_ss(&line, name);
- append_ss(&line, args);
- terminate_with_null(&line);
-
- fprintf(file, "%s;\n", line.str);
- }
- else{
- String name = string_function_set.items[j].name;
- String args = string_function_set.items[j].args;
- String body = string_function_set.items[j].body;
-
- append_ss(&line, make_lit_string("#ifndef "));
- append_padding(&line, ' ', 10);
- append_ss(&line, name);
- terminate_with_null(&line);
- fprintf(file, "%s\n", line.str);
- line.size = 0;
-
- append_ss(&line, make_lit_string("# define "));
- append_padding(&line, ' ', 10);
- append_ss(&line, name);
- append_ss(&line, args);
- append_s_char(&line, ' ');
- append_ss(&line, body);
- terminate_with_null(&line);
- fprintf(file, "%s\n", line.str);
- line.size = 0;
-
- append_ss(&line, make_lit_string("#endif"));
- terminate_with_null(&line);
- fprintf(file, "%s\n", line.str);
- }
- }
-
- {
- fprintf(file, "\n#if !defined(FSTRING_C)\n\n"
- "// NOTE(allen): This section is here to enable nicer names\n"
- "// for C++ users who can have overloaded functions. None of\n"
- "// these functions add new features.\n");
-
- for (int32_t j = 0; j < string_sig_count; ++j){
- char line_space[2048];
- String line = make_fixed_width_string(line_space);
-
- if (string_function_set.items[j].t != Item_Macro){
- String cpp_name = string_function_set.items[j].cpp_name;
- if (cpp_name.str != 0){
- String ret = string_function_set.items[j].ret;
- String args = string_function_set.items[j].args;
-
- append_ss(&line, make_lit_string("FSTRING_INLINE"));
- append_padding(&line, ' ', RETURN_PADDING);
- append_ss(&line, ret);
- append_padding(&line, ' ', SIG_PADDING);
- append_ss(&line, cpp_name);
- append_ss(&line, args);
- terminate_with_null(&line);
-
- fprintf(file, "%s;\n", line.str);
- }
- }
- }
-
- fprintf(file, "\n#endif\n");
- }
-
- fprintf(file, "\n#endif\n");
-
- {
- fprintf(file, "\n#if !defined(FSTRING_C) && !defined(FSTRING_GUARD)\n\n");
-
- for (int32_t j = 0; j < string_sig_count; ++j){
- char line_space[2048];
- String line = make_fixed_width_string(line_space);
-
- if (string_function_set.items[j].t != Item_Macro){
- String cpp_name = string_function_set.items[j].cpp_name;
- if (cpp_name.str != 0){
- String name = string_function_set.items[j].name;
- String ret = string_function_set.items[j].ret;
- String args = string_function_set.items[j].args;
- Argument_Breakdown breakdown = string_function_set.items[j].breakdown;
-
- append_ss(&line, make_lit_string("FSTRING_INLINE"));
- append_s_char(&line, ' ');
- append_ss(&line, ret);
- append_s_char(&line, '\n');
- append_ss(&line, cpp_name);
- append_ss(&line, args);
- if (match_ss(ret, make_lit_string("void"))){
- append_ss(&line, make_lit_string("{("));
- }
- else{
- append_ss(&line, make_lit_string("{return("));
- }
- append_ss(&line, name);
- append_s_char(&line, '(');
-
- if (breakdown.count > 0){
- for (int32_t i = 0; i < breakdown.count; ++i){
- if (i != 0){
- append_s_char(&line, ',');
- }
- append_ss(&line, breakdown.args[i].param_name);
- }
- }
- else{
- append_ss(&line, make_lit_string("void"));
- }
-
- append_ss(&line, make_lit_string("));}"));
- terminate_with_null(&line);
-
- fprintf(file, "%s\n", line.str);
- }
- }
- }
-
- fprintf(file, "\n#endif\n");
- }
- }
- else if (match_ss(lexeme, make_lit_string("DOC_EXPORT"))){
- ++i, ++token;
- if (i < count && token->type == CPP_TOKEN_COMMENT){
- ++i, ++token;
- if (i < count && token->type == CPP_PP_DEFINE){
- ++i, ++token;
- for (; i < count; ++i, ++token){
- if (!(token->flags & CPP_TFLAG_PP_BODY)){
- break;
- }
- }
- --i, --token;
- do_print = false;
- do_whitespace_print = false;
- }
- }
- }
- else if (match_ss(lexeme, make_lit_string("FSTRING_INLINE"))){
- if (!(token->flags & CPP_TFLAG_PP_BODY)){
- fprintf(file, "#if !defined(FSTRING_GUARD)\n");
-
- print_function_body_code(file, &i, &token, count, code, start);
-
- fprintf(file, "\n#endif");
- do_print = false;
- }
- }
- else if (match_ss(lexeme, make_lit_string("FSTRING_LINK"))){
- if (!(token->flags & CPP_TFLAG_PP_BODY)){
- fprintf(file, "#if defined(FSTRING_IMPLEMENTATION)\n");
-
- print_function_body_code(file, &i, &token, count, code, start);
-
- fprintf(file, "\n#endif");
- do_print = false;
- }
- }
- else if (match_ss(lexeme, make_lit_string("CPP_NAME"))){
-
- Cpp_Token *token_start = token;
- int32_t i_start = i;
- int32_t has_cpp_name = false;
-
- ++i, ++token;
- if (token->type == CPP_TOKEN_PARENTHESE_OPEN){
- ++i, ++token;
- if (token->type == CPP_TOKEN_IDENTIFIER){
- ++i, ++token;
- if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){
- has_cpp_name = true;
- }
- }
- }
-
- if (!has_cpp_name){
- i = i_start;
- token = token_start;
- }
-
- do_print = false;
- }
- else if (token->type == CPP_TOKEN_COMMENT){
- lexeme = make_string(code->str + token->start, token->size);
- if (check_and_fix_docs(&lexeme)){
- do_print = false;
- }
- }
-
- if (i < count){
- if (do_print){
- pstr = make_string(code->str + token->start, token->size);
- print_str(file, pstr);
- }
-
+ for (; (token = get_token(&pcontext)) != 0; get_next_token(&pcontext)){
+ if (!(token->flags & CPP_TFLAG_PP_BODY) &&
+ token->type == CPP_TOKEN_IDENTIFIER){
+ String lexeme = get_lexeme(*token, pcontext.data);
+ if (match_ss(lexeme, make_lit_string("FSTRING_BEGIN"))){
start = token->start + token->size;
+ break;
}
}
- pstr = get_string(code->str, start, code->size);
- print_str(file, pstr);
}
- fclose(file);
+ String pstr = {0};
+ int32_t do_whitespace_print = true;
- //
- // Output Docs
- //
+ for(;(token = get_next_token(&pcontext)) != 0;){
+ if (do_whitespace_print){
+ pstr = str_start_end(pcontext.data, start, token->start);
+ append_ss(&out, pstr);
+ }
+ else{
+ do_whitespace_print = true;
+ }
+
+ String lexeme = get_lexeme(*token, pcontext.data);
+
+ int32_t do_print = true;
+ if (match_ss(lexeme, make_lit_string("FSTRING_DECLS"))){
+ append_sc(&out, "#if !defined(FCODER_STRING_H)\n#define FCODER_STRING_H\n\n");
+ do_print = false;
+
+ static int32_t RETURN_PADDING = 16;
+ static int32_t SIG_PADDING = 27;
+
+ for (int32_t j = 0; j < string_unit.set.count; ++j){
+ char line_[2048];
+ String line = make_fixed_width_string(line_);
+ Item_Node *item = string_unit.set.items + j;
+
+ if (item->t == Item_Function){
+ append_ss (&line, item->marker);
+ append_padding (&line, ' ', RETURN_PADDING);
+ append_ss (&line, item->ret);
+ append_padding (&line, ' ', SIG_PADDING);
+ append_ss (&line, item->name);
+ append_ss (&line, item->args);
+ append_sc (&line, ";\n");
+ }
+ else if (item->t == Item_Macro){
+ append_ss (&line, make_lit_string("#ifndef "));
+ append_padding (&line, ' ', 10);
+ append_ss (&line, item->name);
+ append_s_char (&line, '\n');
+
+ append_ss (&line, make_lit_string("# define "));
+ append_padding (&line, ' ', 10);
+ append_ss (&line, item->name);
+ append_ss (&line, item->args);
+ append_s_char (&line, ' ');
+ append_ss (&line, item->body);
+ append_s_char (&line, '\n');
+
+ append_ss (&line, make_lit_string("#endif"));
+ append_s_char (&line, '\n');
+ }
+ else{
+ InvalidPath;
+ }
+
+ append_ss(&out, line);
+ }
+
+ append_sc(&out, "\n#endif\n");
+
+ // NOTE(allen): C++ overload definitions
+ append_sc(&out, "\n#if !defined(FSTRING_C) && !defined(FSTRING_GUARD)\n\n");
+
+ for (int32_t j = 0; j < string_unit.set.count; ++j){
+ char line_space[2048];
+ String line = make_fixed_width_string(line_space);
+
+ Item_Node *item = &string_unit.set.items[j];
+
+ if (item->t == Item_Function){
+ String cpp_name = item->cpp_name;
+ if (cpp_name.str != 0){
+ Argument_Breakdown breakdown = item->breakdown;
+
+ append_ss (&line, make_lit_string("FSTRING_INLINE"));
+ append_padding(&line, ' ', RETURN_PADDING);
+ append_ss (&line, item->ret);
+ append_padding(&line, ' ', SIG_PADDING);
+ append_ss (&line, cpp_name);
+ append_ss (&line, item->args);
+ if (match_ss(item->ret, make_lit_string("void"))){
+ append_ss(&line, make_lit_string("{("));//}
+ }
+ else{
+ append_ss(&line, make_lit_string("{return("));//}
+ }
+ append_ss (&line, item->name);
+ append_s_char(&line, '(');
+
+ if (breakdown.count > 0){
+ for (int32_t i = 0; i < breakdown.count; ++i){
+ if (i != 0){
+ append_s_char(&line, ',');
+ }
+ append_ss(&line, breakdown.args[i].param_name);
+ }
+ }
+ else{
+ append_ss(&line, make_lit_string("void"));
+ }
+
+ //{
+ append_ss(&line, make_lit_string("));}\n"));
+
+ append_ss(&out, line);
+ }
+ }
+ }
+
+ append_sc(&out, "\n#endif\n");
+ }
+
+ else if (match_ss(lexeme, make_lit_string("DOC_EXPORT"))){
+ token = get_next_token(&pcontext);
+ if (token && token->type == CPP_TOKEN_COMMENT){
+ token = get_next_token(&pcontext);
+ if (token && token->type == CPP_PP_DEFINE){
+ for (;(token = get_next_token(&pcontext)) != 0;){
+ if (!(token->flags & CPP_TFLAG_PP_BODY)){
+ break;
+ }
+ }
+ if (token != 0){
+ get_prev_token(&pcontext);
+ }
+ do_print = false;
+ do_whitespace_print = false;
+ }
+ }
+ }
+
+ else if (match_ss(lexeme, make_lit_string("FSTRING_INLINE")) ||
+ match_ss(lexeme, make_lit_string("FSTRING_LINK"))){
+ if (!(token->flags & CPP_TFLAG_PP_BODY)){
+ if (match_ss(lexeme, make_lit_string("FSTRING_INLINE"))){
+ append_sc(&out, "#if !defined(FSTRING_GUARD)\n");
+ }
+ else{
+ append_sc(&out, "#if defined(FSTRING_IMPLEMENTATION)\n");
+ }
+ print_function_body_code(&out, &pcontext, start);
+ append_sc(&out, "\n#endif");
+ do_print = false;
+ }
+ }
+
+ else if (match_ss(lexeme, make_lit_string("CPP_NAME"))){
+ Cpp_Token *token_start = token;
+ int32_t has_cpp_name = false;
+
+ token = get_next_token(&pcontext);
+ if (token && token->type == CPP_TOKEN_PARENTHESE_OPEN){
+ token = get_next_token(&pcontext);
+ if (token && token->type == CPP_TOKEN_IDENTIFIER){
+ token = get_next_token(&pcontext);
+ if (token && token->type == CPP_TOKEN_PARENTHESE_CLOSE){
+ has_cpp_name = true;
+ do_print = false;
+ }
+ }
+ }
+
+ if (!has_cpp_name){
+ token = set_token(&pcontext, token_start);
+ }
+ }
+
+ else if (token->type == CPP_TOKEN_COMMENT){
+ if (check_and_fix_docs(&lexeme)){
+ do_print = false;
+ }
+ }
+
+ if ((token = get_token(&pcontext)) != 0){
+ if (do_print){
+ pstr = get_lexeme(*token, pcontext.data);
+ append_ss(&out, pstr);
+ }
+ start = token->start + token->size;
+ }
+ }
+ pstr = str_start_end(pcontext.data, start, parse.code.size);
+ append_ss(&out, pstr);
- file = fopen(API_DOC, "wb");
+ end_file_out(context);
+ }
+ else{
+ // TODO(allen): warning
+ }
+
+
+ // Output Docs
+
+ if (begin_file_out(&context, API_DOC, &out)){
- fprintf(file,
- "\n"
- "\n"
- "
4coder API Docs\n"
- "\n"
+ ""
"\n"
- "\n"
+ ""
"
\n"
- "
4coder API
\n"
+ "width: 800px; text-align: justify; line-height: 1.25;'>"
+ "
4coder API
"
);
struct Section{
@@ -2627,498 +2614,155 @@ generate_custom_headers(){
{"string_library", "String Library"}
};
- fprintf(file,
- "
Table of Contents
\n"
- "
\n");
+ append_sc(&out,
+ "Table of Contents
""");
int32_t section_count = ArrayCount(sections);
for (int32_t i = 0; i < section_count; ++i){
- fprintf(file,
- "- §%d %s
",
- sections[i].id_string,
- i+1,
- sections[i].display_string);
+ append_sc (&out, "- §");
+ append_int_to_str (&out, i+1);
+ append_s_char (&out, ' ');
+ append_sc (&out, sections[i].display_string);
+ append_sc (&out, "
");
}
- fprintf(file,
- "
\n"
- );
+ append_sc(&out, "
");
#define MAJOR_SECTION "1"
- fprintf(file,
- "
§"MAJOR_SECTION" %s
\n"
- "
\n"
-
- "
\n"
- "This is the documentation for " VERSION " The documentation is still under "
- "construction so some of the links are linking to sections that have not "
- "been written yet. What is here should be correct and I suspect useful "
- "even without some of the other sections. "
- "
\n"
-
- "
\n"
- "If you have questions or discover errors please contact "
- "editor@4coder.net or "
- "to get help from community members you can post on the "
- "4coder forums hosted on handmade.network at "
- "4coder.handmade.network"
- "
\n"
-
- "
\n",
- sections[0].id_string,
- sections[0].display_string
- );
+ append_sc(&out, "\n
§"MAJOR_SECTION" ");
+ append_sc(&out, sections[0].display_string);
+ append_sc(&out,
+ "
"
+ "
"
+ "
This is the documentation for " VERSION " The documentation is still "
+ "under construction so some of the links are linking to sections that "
+ "have not been written yet. What is here should be correct and I suspect "
+ "useful even without some of the other sections.
"
+ "
If you have questions or discover errors please contact "
+ "editor@4coder.net or "
+ "to get help from community members you can post on the "
+ "4coder forums hosted on handmade.network at "
+ "4coder.handmade.network
"
+ "
");
#undef MAJOR_SECTION
#define MAJOR_SECTION "2"
// TODO(allen): Write the 4coder system descriptions.
- fprintf(file,
- "
§"MAJOR_SECTION" %s
\n",
- sections[1].id_string,
- sections[1].display_string);
+ append_sc(&out, "\n
§"MAJOR_SECTION" ");
+ append_sc(&out, sections[1].display_string);
+ append_sc(&out, "
");
- {
- fprintf(file,
- "
\n"
- "Coming Soon"
- "\n");
- }
+ append_sc(&out, "
Coming Soon");
#undef MAJOR_SECTION
#define MAJOR_SECTION "3"
- fprintf(file,
- "
§"MAJOR_SECTION" %s
\n",
- sections[2].id_string,
- sections[2].display_string);
- {
+ append_sc(&out, "\n
§"MAJOR_SECTION" ");
+ append_sc(&out, sections[2].display_string);
+ append_sc(&out, "
");
+
#undef SECTION
#define SECTION MAJOR_SECTION".1"
-
- fprintf(file,
- "
§"SECTION" Function List
\n"
- "
\n");
-
- for (int32_t i = 0; i < sig_count; ++i){
- String name = func_4ed_names.names[i].public_name;
- fprintf(file,
- "- "
- "%.*s"
- "
\n",
- name.size, name.str,
- name.size, name.str
- );
- }
- fprintf(file, "
\n");
-
+
+ append_sc(&out, "
§"SECTION" Function List
");
+ for (int32_t i = 0; i < unit_custom.set.count; ++i){
+ print_item_in_list(&out, func_4ed_names.names[i].public_name, "_doc");
+ }
+ append_sc(&out, "
");
+
#undef SECTION
#define SECTION MAJOR_SECTION".2"
-
- fprintf(file,
- "
§"SECTION" Type List
\n"
- "
\n"
- );
-
- for (int32_t i = 0; i < typedef_count; ++i){
- String name = typedef_set.items[i].name;
- fprintf(file,
- "- "
- "%.*s"
- "
\n",
- name.size, name.str,
- name.size, name.str
- );
- }
-
- for (int32_t i = 0; i < enum_count; ++i){
- String name = enum_set.items[i].name;
- fprintf(file,
- "- "
- "%.*s"
- "
\n",
- name.size, name.str,
- name.size, name.str
- );
- }
-
- for (int32_t i = 0; i < flag_count; ++i){
- String name = flag_set.items[i].name;
- fprintf(file,
- "- "
- "%.*s"
- "
\n",
- name.size, name.str,
- name.size, name.str
- );
- }
-
- for (int32_t i = 0; i < struct_count; ++i){
- String name = struct_set.items[i].name;
- fprintf(file,
- "- "
- "%.*s"
- "
\n",
- name.size, name.str,
- name.size, name.str
- );
- }
-
- fprintf(file, "
\n");
-
+
+ append_sc(&out, "
§"SECTION" Type List
");
+ for (int32_t i = 0; i < unit.set.count; ++i){
+ print_item_in_list(&out, unit.set.items[i].name, "_doc");
+ }
+ append_sc(&out, "
");
+
#undef SECTION
#define SECTION MAJOR_SECTION".3"
+
+ append_sc(&out, "
§"SECTION" Function Descriptions
");
+ for (int32_t i = 0; i < unit_custom.set.count; ++i){
+ Item_Node *item = &unit_custom.set.items[i];
+ String name = func_4ed_names.names[i].public_name;
- fprintf(file, "
§"SECTION" Function Descriptions
\n");
- for (int32_t i = 0; i < sig_count; ++i){
- String name = func_4ed_names.names[i].public_name;
-
- fprintf(file,
- "
\n"
- "
§"SECTION".%d: %.*s
\n"
- "
",
- name.size, name.str, i+1,
- name.size, name.str
- );
- print_function_html(file, function_set.items[i], name, "app->");
- fprintf(file, "
\n");
-
- String doc_string = function_set.items[i].doc_string;
- print_function_docs(file, part, name, doc_string);
-
- fprintf(file, "
\n");
- }
+ append_sc (&out, "
§"SECTION".");
+ append_int_to_str(&out, i+1);
+ append_sc (&out, ": ");
+ append_ss (&out, name);
+ append_sc (&out, "
");
+ print_function_html(&out, item->ret, "app->", name, item->breakdown);
+ append_sc(&out, "
");
+
+ print_function_docs(&out, part, name, item->doc_string);
+
+ append_sc(&out, "
");
+ }
+
#undef SECTION
#define SECTION MAJOR_SECTION".4"
-
- fprintf(file, "
§"SECTION" Type Descriptions
\n");
- int32_t I = 1;
- for (int32_t i = 0; i < typedef_count; ++i, ++I){
- String name = typedef_set.items[i].name;
- String type = typedef_set.items[i].type;
-
- fprintf(file,
- "
\n"
- "
§"SECTION".%d: %.*s
\n"
- "
",
- name.size, name.str, I,
- name.size, name.str
- );
-
- // NOTE(allen): Code box
- {
- fprintf(file,
- "typedef %.*s %.*s;",
- type.size, type.str,
- name.size, name.str
- );
- }
-
- fprintf(file, "
\n");
-
- // NOTE(allen): Descriptive section
- {
- String doc_string = typedef_set.items[i].doc_string;
- Documentation doc = {0};
- perform_doc_parse(part, doc_string, &doc);
-
- String main_doc = doc.main_doc;
- if (main_doc.size != 0){
- fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
- fprintf(file,
- DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
- main_doc.size, main_doc.str
- );
- }
-
- print_see_also(file, &doc);
- }
-
- fprintf(file, "
\n");
- }
-
- for (int32_t i = 0; i < enum_count; ++i, ++I){
- String name = enum_set.items[i].name;
-
- fprintf(file,
- "
\n"
- "
§"SECTION".%d: %.*s
\n"
- "
",
- name.size, name.str, I,
- name.size, name.str
- );
-
- // NOTE(allen): Code box
- {
- fprintf(file,
- "enum %.*s;",
- name.size, name.str);
- }
-
- fprintf(file, "
\n");
-
- // NOTE(allen): Descriptive section
- {
- String doc_string = enum_set.items[i].doc_string;
- Documentation doc = {0};
- perform_doc_parse(part, doc_string, &doc);
-
- String main_doc = doc.main_doc;
- if (main_doc.size != 0){
- fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
- fprintf(file,
- DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
- main_doc.size, main_doc.str
- );
- }
-
- if (enum_set.items[i].first_child){
- fprintf(file, DOC_HEAD_OPEN"Values"DOC_HEAD_CLOSE);
- for (Item_Node *member = enum_set.items[i].first_child;
- member;
- member = member->next_sibling){
- Documentation doc = {0};
- perform_doc_parse(part, member->doc_string, &doc);
-
- fprintf(file,
- "
\n"
- "
"DOC_ITEM_HEAD_INL_OPEN
- "%.*s"DOC_ITEM_HEAD_INL_CLOSE"
\n"
- "
"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
\n"
- "
\n",
- member->name.size, member->name.str,
- doc.main_doc.size, doc.main_doc.str
- );
- }
- }
-
- print_see_also(file, &doc);
- }
-
- fprintf(file, "
\n");
- }
-
- for (int32_t i = 0; i < flag_count; ++i, ++I){
- String name = flag_set.items[i].name;
-
- fprintf(file,
- "
\n"
- "
§"SECTION".%d: %.*s
\n"
- "
",
- name.size, name.str, I,
- name.size, name.str
- );
-
- // NOTE(allen): Code box
- {
- fprintf(file,
- "enum %.*s;",
- name.size, name.str);
- }
-
- fprintf(file, "
\n");
-
- // NOTE(allen): Descriptive section
- {
- String doc_string = flag_set.items[i].doc_string;
- Documentation doc = {0};
- perform_doc_parse(part, doc_string, &doc);
-
- String main_doc = doc.main_doc;
- if (main_doc.size != 0){
- fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
- fprintf(file,
- DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
- main_doc.size, main_doc.str
- );
- }
-
- if (flag_set.items[i].first_child){
- fprintf(file, DOC_HEAD_OPEN"Flags"DOC_HEAD_CLOSE);
- for (Item_Node *member = flag_set.items[i].first_child;
- member;
- member = member->next_sibling){
- Documentation doc = {0};
- perform_doc_parse(part, member->doc_string, &doc);
-
- fprintf(file,
- "
\n"
- "
"DOC_ITEM_HEAD_INL_OPEN
- "%.*s"DOC_ITEM_HEAD_INL_CLOSE" = %.*s
\n"
- "
"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
\n"
- "
\n",
- member->name.size, member->name.str,
- member->value.size, member->value.str,
- doc.main_doc.size, doc.main_doc.str
- );
- }
- }
-
- print_see_also(file, &doc);
- }
-
- fprintf(file, "
\n");
- }
-
- for (int32_t i = 0; i < struct_count; ++i, ++I){
- Item_Node *member = &struct_set.items[i];
- String name = member->name;
- fprintf(file,
- "
\n"
- "
§"SECTION".%d: %.*s
\n"
- "
",
- name.size, name.str, I,
- name.size, name.str
- );
-
- // NOTE(allen): Code box
- {
- print_struct_html(file, member);
- }
-
- fprintf(file, "
\n");
-
- // NOTE(allen): Descriptive section
- {
- String doc_string = member->doc_string;
- Documentation doc = {0};
- perform_doc_parse(part, doc_string, &doc);
-
- String main_doc = doc.main_doc;
- if (main_doc.size != 0){
- fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
- fprintf(file,
- DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
- main_doc.size, main_doc.str
- );
- }
-
- if (member->first_child){
- fprintf(file, DOC_HEAD_OPEN"Fields"DOC_HEAD_CLOSE);
- print_struct_docs(file, part, member);
- }
-
- print_see_also(file, &doc);
- }
-
- fprintf(file, "
\n");
- }
+
+ append_sc(&out, "
§"SECTION" Type Descriptions
");
+
+ int32_t I = 1;
+ for (int32_t i = 0; i < unit.set.count; ++i, ++I){
+ print_item(&out, part, unit.set.items + i, "_doc", 0, SECTION, I);
}
#undef MAJOR_SECTION
#define MAJOR_SECTION "4"
- fprintf(file,
- "
§"MAJOR_SECTION" %s
\n",
- sections[3].id_string,
- sections[3].display_string);
+ append_sc(&out, "\n
§"MAJOR_SECTION" ");
+ append_sc(&out, sections[3].display_string);
+ append_sc(&out, "
");
- {
-
#undef SECTION
#define SECTION MAJOR_SECTION".1"
-
- fprintf(file,
- "
§"SECTION" String Intro
\n"
- "
\n");
-
- {
- fprintf(file,
- "\n"
- "Coming Soon"
- "\n");
- }
-
+
+ append_sc(&out, "
§"SECTION" String Intro
");
+
+ append_sc(&out, "
Coming Soon");
+
#undef SECTION
#define SECTION MAJOR_SECTION".2"
-
- fprintf(file,
- "
§"SECTION" String Function List
\n"
- "
\n");
-
- String *used_strings = 0;
- int32_t used_string_count = 0;
-
- {
- int32_t memory_size = sizeof(String)*(string_sig_count);
- used_strings = (String*)malloc(memory_size);
- memset(used_strings, 0, memory_size);
- }
-
- for (int32_t i = 0; i < string_sig_count; ++i){
- String name = string_function_set.items[i].name;
- int32_t index = 0;
- if (!string_set_match(used_strings, used_string_count, name, &index)){
- fprintf(file,
- "- "
- "%.*s"
- "
\n",
- name.size, name.str,
- name.size, name.str
- );
- used_strings[used_string_count++] = name;
- }
- }
- fprintf(file, "
\n");
-
- used_string_count = 0;
-
+
+ append_sc(&out, "
§"SECTION" String Function List
");
+
+ append_sc(&out, "
");
+ for (int32_t i = 0; i < string_unit.set.count; ++i){
+ print_item_in_list(&out, string_unit.set.items[i].name, "_str_doc");
+ }
+ append_sc(&out, "
");
+
#undef SECTION
#define SECTION MAJOR_SECTION".3"
-
- fprintf(file,
- "
§"SECTION" String Function Descriptions
\n"
- "
\n");
-
- for (int32_t i = 0; i < string_sig_count; ++i){
- String name = string_function_set.items[i].name;
- int32_t index = 0;
- int32_t do_id = false;
- if (!string_set_match(used_strings, used_string_count, name, &index)){
- do_id = true;
- used_strings[used_string_count++] = name;
- }
-
- if (do_id){
- fprintf(file,
- "",
- name.size, name.str
- );
- }
- else{
- fprintf(file, "
");
- }
-
- fprintf(file,
- "
§"SECTION".%d: %.*s
\n"
- "
\n",
- i+1, name.size, name.str);
-
- if (string_function_set.items[i].t == Item_Macro){
- print_macro_html(file, string_function_set.items[i], name);
- }
- else{
- print_function_html(file, string_function_set.items[i], name, "");
- }
-
- fprintf(file, "
\n");
-
-
- String doc_string = string_function_set.items[i].doc_string;
- print_function_docs(file, part, name, doc_string);
-
- fprintf(file, "
\n");
- }
+
+ append_sc(&out, "
§"SECTION" String Function Descriptions
");
+
+ for (int32_t i = 0; i < string_unit.set.count; ++i){
+ print_item(&out, part, string_unit.set.items+i, "_str_doc", "", SECTION, i+1);
}
- fprintf(file,
- "
\n"
- "\n"
- "\n"
- );
-
- fclose(file);
+ append_sc(&out, "