removed all occurances of int

This commit is contained in:
Allen Webster 2016-08-28 21:03:26 -04:00
parent e7216b80c6
commit ec27163c48
42 changed files with 1205 additions and 1362 deletions

View File

@ -991,7 +991,7 @@ when it is no longer in use.</div></div><hr>
<div id='file_exists_doc' style='margin-bottom: 1cm;'>
<h4>&sect;3.3.54: file_exists</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>bool32 app->file_exists(
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *filename,<br>int len<br></div>)
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *filename,<br>int32_t len<br></div>)
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Parameters</i></b></div><div>
<div style='font-weight: 600;'>filename</div>
@ -1005,7 +1005,7 @@ when it is no longer in use.</div></div><hr>
<div id='directory_cd_doc' style='margin-bottom: 1cm;'>
<h4>&sect;3.3.55: directory_cd</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>bool32 app->directory_cd(
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *dir,<br>int *len,<br>int capacity,<br>char *rel_path,<br>int rel_len<br></div>)
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *dir,<br>int32_t *len,<br>int32_t capacity,<br>char *rel_path,<br>int32_t rel_len<br></div>)
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Parameters</i></b></div><div>
<div style='font-weight: 600;'>dir</div>
@ -1290,7 +1290,7 @@ an empty String with the correct size and memory size to operate on the array.</
<div id='expand_str_str_doc'><h4>&sect;4.3.16: expand_str</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>
#define expand_str(s)</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>This macro is a helper for any calls that take a char*,int pair to specify a
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>This 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.</div></div><hr>
<div id='str_size_str_doc'><h4>&sect;4.3.17: str_size</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>

View File

@ -13,7 +13,7 @@
#define FRED_BUFFER_TYPES_H
static Buffer_Seek
seek_pos(int pos){
seek_pos(int32_t pos){
Buffer_Seek result;
result.type = buffer_seek_pos;
result.pos = pos;
@ -21,7 +21,7 @@ seek_pos(int pos){
}
static Buffer_Seek
seek_wrapped_xy(float x, float y, int round_down){
seek_wrapped_xy(float x, float y, int32_t round_down){
Buffer_Seek result;
result.type = buffer_seek_wrapped_xy;
result.x = x;
@ -31,7 +31,7 @@ seek_wrapped_xy(float x, float y, int round_down){
}
static Buffer_Seek
seek_unwrapped_xy(float x, float y, int round_down){
seek_unwrapped_xy(float x, float y, int32_t round_down){
Buffer_Seek result;
result.type = buffer_seek_unwrapped_xy;
result.x = x;
@ -41,7 +41,7 @@ seek_unwrapped_xy(float x, float y, int round_down){
}
static Buffer_Seek
seek_xy(float x, float y, int round_down, int unwrapped){
seek_xy(float x, float y, int32_t round_down, int32_t unwrapped){
Buffer_Seek result;
result.type = unwrapped?buffer_seek_unwrapped_xy:buffer_seek_wrapped_xy;
result.x = x;
@ -51,7 +51,7 @@ seek_xy(float x, float y, int round_down, int unwrapped){
}
static Buffer_Seek
seek_line_char(int line, int character){
seek_line_char(int32_t line, int32_t character){
Buffer_Seek result;
result.type = buffer_seek_line_char;
result.line = line;

View File

@ -14,13 +14,13 @@
#define FSTRING_STRUCT
typedef struct String{
char *str;
int size;
int memory_size;
int32_t size;
int32_t memory_size;
} String;
typedef struct Offset_String{
int offset;
int size;
int32_t offset;
int32_t size;
} Offset_String;
#endif
@ -52,7 +52,7 @@ typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
#include "4coder_buffer_types.h"
#include "4coder_gui.h"
#define COMMAND_CALLER_HOOK(name) int name(struct Application_Links *app, Generic_Command cmd)
#define COMMAND_CALLER_HOOK(name) int32_t name(struct Application_Links *app, Generic_Command cmd)
typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function);
inline Key_Event_Data
@ -66,7 +66,7 @@ mouse_state_zero(){
return(data);
}
inline Range
make_range(int p1, int p2){
make_range(int32_t p1, int32_t p2){
Range range;
if (p1 < p2){
range.min = p1;
@ -89,11 +89,11 @@ view_summary_zero(){
return(summary);
}
#define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int view_id)
#define GET_BINDING_DATA(name) int name(void *data, int size)
#define HOOK_SIG(name) int name(struct Application_Links *app)
#define OPEN_FILE_HOOK_SIG(name) int name(struct Application_Links *app, int buffer_id)
#define SCROLL_RULE_SIG(name) int name(float target_x, float target_y, float *scroll_x, float *scroll_y, int view_id, int is_new_target, float dt)
#define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int32_t view_id)
#define GET_BINDING_DATA(name) int32_t name(void *data, int32_t size)
#define HOOK_SIG(name) int32_t name(struct Application_Links *app)
#define OPEN_FILE_HOOK_SIG(name) int32_t name(struct Application_Links *app, int32_t buffer_id)
#define SCROLL_RULE_SIG(name) int32_t name(float target_x, float target_y, float *scroll_x, float *scroll_y, int32_t view_id, int32_t is_new_target, float dt)
#define INPUT_FILTER_SIG(name) void name(Mouse_State *mouse)
typedef VIEW_ROUTINE_SIG(View_Routine_Function);
@ -113,11 +113,11 @@ struct Application_Links;
#define _GET_VERSION_SIG(n) int n(int maj, int min, int patch)
#define _GET_VERSION_SIG(n) int32_t n(int32_t maj, int32_t min, int32_t patch)
typedef _GET_VERSION_SIG(_Get_Version_Function);
extern "C" _GET_VERSION_SIG(get_alpha_4coder_version){
int result = (maj == MAJOR && min == MINOR && patch == PATCH);
int32_t result = (maj == MAJOR && min == MINOR && patch == PATCH);
return(result);
}
@ -151,22 +151,22 @@ enum Map_ID{
struct Binding_Unit{
Binding_Unit_Type type;
union{
struct{ int total_size; int user_map_count; int error; } header;
struct{ int32_t total_size; int32_t user_map_count; int32_t error; } header;
struct{ int mapid; int replace; int bind_count; } map_begin;
struct{ int mapid; } map_inherit;
struct{ int32_t mapid; int32_t replace; int32_t bind_count; } map_begin;
struct{ int32_t mapid; } map_inherit;
struct{
short code;
unsigned char modifiers;
int command_id;
int16_t code;
uint8_t modifiers;
int32_t command_id;
} binding;
struct{
short code;
unsigned char modifiers;
int16_t code;
uint8_t modifiers;
Custom_Command_Function *func;
} callback;
struct{
int hook_id;
int32_t hook_id;
void *func;
} hook;
};

View File

@ -51,8 +51,8 @@
#define MEMORY_ALLOCATE_SIG(n) void* n(Application_Links *app, int32_t size)
#define MEMORY_SET_PROTECTION_SIG(n) bool32 n(Application_Links *app, void *ptr, int32_t size, Memory_Protect_Flags flags)
#define MEMORY_FREE_SIG(n) void n(Application_Links *app, void *mem, int32_t size)
#define FILE_EXISTS_SIG(n) bool32 n(Application_Links *app, char *filename, int len)
#define DIRECTORY_CD_SIG(n) bool32 n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)
#define FILE_EXISTS_SIG(n) bool32 n(Application_Links *app, char *filename, int32_t len)
#define DIRECTORY_CD_SIG(n) bool32 n(Application_Links *app, char *dir, int32_t *len, int32_t capacity, char *rel_path, int32_t rel_len)
#define GET_4ED_PATH_SIG(n) bool32 n(Application_Links *app, char *out, int32_t capacity)
#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show)
extern "C"{
@ -116,7 +116,7 @@ extern "C"{
}
struct Application_Links{
void *memory;
int memory_size;
int32_t memory_size;
Exec_Command_Function *exec_command;
Exec_System_Command_Function *exec_system_command;
Clipboard_Post_Function *clipboard_post;
@ -177,7 +177,7 @@ struct Application_Links{
void *cmd_context;
void *system_links;
void *current_coroutine;
int type_coroutine;
int32_t type_coroutine;
};
#define FillAppLinksAPI(app_links) do{\
app_links->exec_command = Exec_Command;\

View File

@ -44,9 +44,9 @@ CUSTOM_COMMAND_SIG(write_capital){
CUSTOM_COMMAND_SIG(switch_to_compilation){
char name[] = "*compilation*";
int name_size = sizeof(name)-1;
int32_t name_size = sizeof(name)-1;
unsigned int access = AccessOpen;
uint32_t access = AccessOpen;
View_Summary view = app->get_active_view(app, access);
Buffer_Summary buffer = app->get_buffer_by_name(app, name, name_size, access);
@ -54,7 +54,7 @@ CUSTOM_COMMAND_SIG(switch_to_compilation){
}
CUSTOM_COMMAND_SIG(rewrite_as_single_caps){
unsigned int access = AccessOpen;
uint32_t access = AccessOpen;
View_Summary view = app->get_active_view(app, access);
Full_Cursor cursor = view.cursor;
@ -77,8 +77,8 @@ CUSTOM_COMMAND_SIG(rewrite_as_single_caps){
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
app->buffer_read_range(app, &buffer, range.min, range.max, string.str);
int is_first = true;
for (int i = 0; i < string.size; ++i){
int32_t is_first = true;
for (int32_t i = 0; i < string.size; ++i){
if (char_is_alpha_true(string.str[i])){
if (is_first){
is_first = false;
@ -100,13 +100,13 @@ CUSTOM_COMMAND_SIG(rewrite_as_single_caps){
}
CUSTOM_COMMAND_SIG(open_my_files){
unsigned int access = AccessAll;
uint32_t access = AccessAll;
View_Summary view = app->get_active_view(app, access);
view_open_file(app, &view, literal("w:/4ed/data/test/basic.cpp"), false);
}
CUSTOM_COMMAND_SIG(build_at_launch_location){
unsigned int access = AccessAll;
uint32_t access = AccessAll;
View_Summary view = app->get_active_view(app, access);
app->exec_system_command(app, &view,
buffer_identifier(literal("*compilation*")),
@ -171,12 +171,12 @@ OPEN_FILE_HOOK_SIG(my_file_settings){
// NOTE(allen|a4.0.8): The app->get_parameter_buffer was eliminated
// and instead the buffer is passed as an explicit parameter through
// the function call. That is where buffer_id comes from here.
unsigned int access = AccessProtected|AccessHidden;
uint32_t access = AccessProtected|AccessHidden;
Buffer_Summary buffer = app->get_buffer(app, buffer_id, access);
assert(buffer.exists);
int treat_as_code = 0;
int wrap_lines = 1;
int32_t treat_as_code = 0;
int32_t wrap_lines = 1;
if (buffer.file_name && buffer.size < (16 << 20)){
String ext = file_extension(make_string(buffer.file_name, buffer.file_name_len));
@ -195,7 +195,8 @@ OPEN_FILE_HOOK_SIG(my_file_settings){
app->buffer_set_setting(app, &buffer, BufferSetting_Lex, treat_as_code);
app->buffer_set_setting(app, &buffer, BufferSetting_WrapLine, wrap_lines);
app->buffer_set_setting(app, &buffer, BufferSetting_MapID, (treat_as_code)?((int)my_code_map):((int)mapid_file));
app->buffer_set_setting(app, &buffer, BufferSetting_MapID,
(treat_as_code)?((int32_t)my_code_map):((int32_t)mapid_file));
// no meaning for return
return(0);

View File

@ -92,7 +92,7 @@ CUSTOM_COMMAND_SIG(change_active_panel_build){
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
View_Summary view = app->get_active_view(app, AccessAll);
int prev_view_id = view.view_id;
int32_t prev_view_id = view.view_id;
exec_command(app, change_active_panel_regular);
view = app->get_active_view(app, AccessAll);

File diff suppressed because it is too large Load Diff

View File

@ -24,10 +24,10 @@ typedef struct GUI GUI;
// down a little more? I think maybe we do.
#define GUI_GET_SCROLL_VARS_SIG(n) void n(GUI *gui, GUI_id scroll_id, GUI_Scroll_Vars *vars, i32_Rect *region)
#define GUI_BEGIN_SCROLLABLE_SIG(n) int n(GUI *gui, GUI_id scroll_id, GUI_Scroll_Vars vars, float delta, int show_scrollbar)
#define GUI_BEGIN_SCROLLABLE_SIG(n) int32_t n(GUI *gui, GUI_id scroll_id, GUI_Scroll_Vars vars, float delta, int32_t show_scrollbar)
#define GUI_END_SCROLLABLE_SIG(n) void n(GUI *gui)
#define GUI_FILE_SIG(n) void n(GUI *gui, int buffer_id)
#define GUI_FILE_SIG(n) void n(GUI *gui, int32_t buffer_id)
typedef GUI_BEGIN_SIG(GUI_Begin_Function);
typedef GUI_END_SIG(GUI_End_Function);

View File

@ -8,8 +8,8 @@
struct Bind_Helper{
Binding_Unit *cursor, *start, *end;
Binding_Unit *header, *group;
int write_total;
int error;
int32_t write_total;
int32_t error;
};
#define BH_ERR_NONE 0
@ -17,13 +17,6 @@ struct Bind_Helper{
#define BH_ERR_MISSING_BEGIN 2
#define BH_ERR_OUT_OF_MEMORY 3
inline void
copy(char *dest, const char *src, int len){
for (int i = 0; i < len; ++i){
*dest++ = *src++;
}
}
inline Binding_Unit*
write_unit(Bind_Helper *helper, Binding_Unit unit){
Binding_Unit *p = 0;
@ -35,28 +28,8 @@ write_unit(Bind_Helper *helper, Binding_Unit unit){
return p;
}
inline char*
write_inline_string(Bind_Helper *helper, char *value, int len){
char *dest = 0;
helper->write_total += len;
if (helper->error == 0){
dest = (char*)helper->cursor;
int cursor_advance = len + sizeof(*helper->cursor) - 1;
cursor_advance /= sizeof(*helper->cursor);
cursor_advance *= sizeof(*helper->cursor);
helper->cursor += cursor_advance;
if (helper->cursor < helper->end){
copy(dest, value, len);
}
else{
helper->error = BH_ERR_OUT_OF_MEMORY;
}
}
return dest;
}
inline Bind_Helper
begin_bind_helper(void *data, int size){
begin_bind_helper(void *data, int32_t size){
Bind_Helper result;
result.header = 0;
@ -78,7 +51,7 @@ begin_bind_helper(void *data, int size){
}
inline void
begin_map_(Bind_Helper *helper, int mapid, int replace){
begin_map_(Bind_Helper *helper, int32_t mapid, int32_t replace){
if (helper->group != 0 && helper->error == 0) helper->error = BH_ERR_MISSING_END;
if (!helper->error && mapid < mapid_global) ++helper->header->header.user_map_count;
@ -91,12 +64,12 @@ begin_map_(Bind_Helper *helper, int mapid, int replace){
}
inline void
begin_map(Bind_Helper *helper, int mapid){
begin_map(Bind_Helper *helper, int32_t mapid){
begin_map_(helper, mapid, 0);
}
inline void
restart_map(Bind_Helper *helper, int mapid){
restart_map(Bind_Helper *helper, int32_t mapid){
begin_map_(helper, mapid, 1);
}
@ -107,7 +80,7 @@ end_map(Bind_Helper *helper){
}
inline void
bind(Bind_Helper *helper, short code, unsigned char modifiers, int cmdid){
bind(Bind_Helper *helper, short code, unsigned char modifiers, int32_t cmdid){
if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN;
if (!helper->error) ++helper->group->map_begin.bind_count;
@ -135,7 +108,7 @@ bind(Bind_Helper *helper, short code, unsigned char modifiers, Custom_Command_Fu
}
inline void
bind_vanilla_keys(Bind_Helper *helper, int cmdid){
bind_vanilla_keys(Bind_Helper *helper, int32_t cmdid){
bind(helper, 0, 0, cmdid);
}
@ -145,7 +118,7 @@ bind_vanilla_keys(Bind_Helper *helper, Custom_Command_Function *func){
}
inline void
bind_vanilla_keys(Bind_Helper *helper, unsigned char modifiers, int cmdid){
bind_vanilla_keys(Bind_Helper *helper, unsigned char modifiers, int32_t cmdid){
bind(helper, 0, modifiers, cmdid);
}
@ -155,7 +128,7 @@ bind_vanilla_keys(Bind_Helper *helper, unsigned char modifiers, Custom_Command_F
}
inline void
inherit_map(Bind_Helper *helper, int mapid){
inherit_map(Bind_Helper *helper, int32_t mapid){
if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN;
if (!helper->error && mapid < mapid_global) ++helper->header->header.user_map_count;
@ -167,7 +140,7 @@ inherit_map(Bind_Helper *helper, int mapid){
}
inline void
set_hook(Bind_Helper *helper, int hook_id, Hook_Function *func){
set_hook(Bind_Helper *helper, int32_t hook_id, Hook_Function *func){
Binding_Unit unit;
unit.type = unit_hook;
unit.hook.hook_id = hook_id;
@ -226,11 +199,11 @@ set_scroll_rule(Bind_Helper *helper, Scroll_Rule_Function *func){
write_unit(helper, unit);
}
inline int
inline int32_t
end_bind_helper(Bind_Helper *helper){
int result;
int32_t result;
if (helper->header){
helper->header->header.total_size = (int)(helper->cursor - helper->start);
helper->header->header.total_size = (int32_t)(helper->cursor - helper->start);
helper->header->header.error = helper->error;
}
result = helper->write_total;
@ -245,8 +218,8 @@ get_range(View_Summary *view){
}
struct Buffer_Rect{
int char0,line0;
int char1,line1;
int32_t char0,line0;
int32_t char1,line1;
};
#ifndef Swap
@ -259,15 +232,15 @@ get_rect(View_Summary *view){
rect.char0 = view->mark.character;
rect.line0 = view->mark.line;
rect.char1 = view->cursor.character;
rect.line1 = view->cursor.line;
if (rect.line0 > rect.line1){
Swap(int, rect.line0, rect.line1);
Swap(int32_t, rect.line0, rect.line1);
}
if (rect.char0 > rect.char1){
Swap(int, rect.char0, rect.char1);
Swap(int32_t, rect.char0, rect.char1);
}
return(rect);
@ -294,7 +267,7 @@ exec_command(Application_Links *app, Generic_Command cmd){
}
inline void
active_view_to_line(Application_Links *app, unsigned int access, int line_number){
active_view_to_line(Application_Links *app, uint32_t access, int32_t line_number){
View_Summary view;
view = app->get_active_view(app, access);
@ -305,12 +278,12 @@ active_view_to_line(Application_Links *app, unsigned int access, int line_number
}
inline View_Summary
get_first_view_with_buffer(Application_Links *app, int buffer_id){
get_first_view_with_buffer(Application_Links *app, int32_t buffer_id){
View_Summary result = {};
View_Summary test = {};
if (buffer_id != 0){
unsigned int access = AccessAll;
uint32_t access = AccessAll;
for(test = app->get_view_first(app, access);
test.exists;
app->get_view_next(app, &test, access)){
@ -323,22 +296,22 @@ get_first_view_with_buffer(Application_Links *app, int buffer_id){
}
}
}
return(result);
}
inline int
inline int32_t
key_is_unmodified(Key_Event_Data *key){
char *mods = key->modifiers;
int unmodified = !mods[MDFR_CONTROL_INDEX] && !mods[MDFR_ALT_INDEX];
int32_t unmodified = !mods[MDFR_CONTROL_INDEX] && !mods[MDFR_ALT_INDEX];
return(unmodified);
}
static int
query_user_general(Application_Links *app, Query_Bar *bar, int force_number){
static int32_t
query_user_general(Application_Links *app, Query_Bar *bar, int32_t force_number){
User_Input in;
int success = 1;
int good_character = 0;
int32_t success = 1;
int32_t good_character = 0;
// NOTE(allen|a3.4.4): It will not cause an *error* if we continue on after failing to.
// start a query bar, but it will be unusual behavior from the point of view of the
@ -398,29 +371,27 @@ query_user_general(Application_Links *app, Query_Bar *bar, int force_number){
return(success);
}
inline int
inline int32_t
query_user_string(Application_Links *app, Query_Bar *bar){
int success = query_user_general(app, bar, 0);
int32_t success = query_user_general(app, bar, 0);
return(success);
}
inline int
inline int32_t
query_user_number(Application_Links *app, Query_Bar *bar){
int success = query_user_general(app, bar, 1);
int32_t success = query_user_general(app, bar, 1);
return(success);
}
inline String empty_string() {String Result = {}; return(Result);}
inline Buffer_Summary
get_active_buffer(Application_Links *app, unsigned int access){
get_active_buffer(Application_Links *app, uint32_t access){
View_Summary view = app->get_active_view(app, access);
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
return(buffer);
}
inline char
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int pos){
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char result = ' ';
*buffer = app->get_buffer(app, buffer->buffer_id, AccessAll);
if (pos >= 0 && pos < buffer->size){
@ -430,7 +401,7 @@ buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int pos){
}
inline Buffer_Identifier
buffer_identifier(char *str, int len){
buffer_identifier(char *str, int32_t len){
Buffer_Identifier identifier;
identifier.name = str;
identifier.name_len = len;
@ -439,7 +410,7 @@ buffer_identifier(char *str, int len){
}
inline Buffer_Identifier
buffer_identifier(int id){
buffer_identifier(int32_t id){
Buffer_Identifier identifier;
identifier.name = 0;
identifier.name_len = 0;
@ -447,10 +418,10 @@ buffer_identifier(int id){
return(identifier);
}
static int
static int32_t
view_open_file(Application_Links *app, View_Summary *view,
char *filename, int filename_len, int do_in_background){
int result = false;
char *filename, int32_t filename_len, int32_t do_in_background){
int32_t result = false;
Buffer_Summary buffer = app->get_buffer_by_name(app, filename, filename_len, AccessProtected|AccessHidden);
if (buffer.exists){
if (!do_in_background){
@ -474,17 +445,17 @@ view_open_file(Application_Links *app, View_Summary *view,
return(result);
}
static int
static int32_t
read_line(Application_Links *app,
Partition *part,
Buffer_Summary *buffer,
int line,
int32_t line,
String *str){
Partial_Cursor begin = {0};
Partial_Cursor end = {0};
int success = false;
int32_t success = false;
if (app->buffer_compute_cursor(app, buffer,
seek_line_char(line, 1), &begin)){
@ -492,7 +463,7 @@ read_line(Application_Links *app,
seek_line_char(line, 65536), &end)){
if (begin.line == line){
if (0 <= begin.pos && begin.pos <= end.pos && end.pos <= buffer->size){
int size = (end.pos - begin.pos);
int32_t size = (end.pos - begin.pos);
*str = make_string(push_array(part, char, size+1), size+1);
if (str->str){
success = true;

View File

@ -4,8 +4,8 @@
struct Jump_Location{
String file;
int line;
int column;
int32_t line;
int32_t column;
};
static void
@ -14,30 +14,30 @@ jump_to_location(Application_Links *app, View_Summary *view, Jump_Location *l){
app->view_set_cursor(app, view, seek_line_char(l->line, l->column), true);
}
static int
ms_style_verify(String line, int paren_pos){
int result = false;
static int32_t
ms_style_verify(String line, int32_t paren_pos){
int32_t result = false;
String line_part = substr_tail(line, paren_pos);
if (match_part_sc(line_part, ") : ")){
result = true;
}
result = true;
}
else if (match_part_sc(line_part, "): ")){
result = true;
}
return(result);
}
static int
result = true;
}
return(result);
}
static int32_t
parse_error(String line, Jump_Location *location,
int skip_sub_errors, int *colon_char){
int result = false;
int32_t skip_sub_errors, int32_t *colon_char){
int32_t result = false;
String original_line = line;
line = skip_chop_whitespace(line);
int colon_pos = find_s_char(line, 0, ')');
int32_t colon_pos = find_s_char(line, 0, ')');
if (ms_style_verify(line, colon_pos)){
colon_pos = find_s_char(line, colon_pos, ':');
if (colon_pos < line.size){
@ -46,12 +46,12 @@ parse_error(String line, Jump_Location *location,
if (!(skip_sub_errors && original_line.str[0] == ' ')){
location_str = skip_chop_whitespace(location_str);
int paren_pos = find_s_char(location_str, 0, '(');
int32_t paren_pos = find_s_char(location_str, 0, '(');
if (paren_pos < location_str.size){
String file = substr(location_str, 0, paren_pos);
file = skip_chop_whitespace(file);
int close_pos = find_s_char(location_str, 0, ')') + 1;
int32_t close_pos = find_s_char(location_str, 0, ')') + 1;
if (close_pos == location_str.size && file.size > 0){
String line_number = substr(location_str,
paren_pos+1,
@ -61,9 +61,9 @@ parse_error(String line, Jump_Location *location,
if (line_number.size > 0){
location->file = file;
int comma_pos = find_s_char(line_number, 0, ',');
int32_t comma_pos = find_s_char(line_number, 0, ',');
if (comma_pos < line_number.size){
int start = comma_pos+1;
int32_t start = comma_pos+1;
String column_number = substr(line_number, start, line_number.size-start);
line_number = substr(line_number, 0, comma_pos);
@ -85,15 +85,15 @@ parse_error(String line, Jump_Location *location,
}
else{
int colon_pos1 = find_s_char(line, 0, ':');
int32_t colon_pos1 = find_s_char(line, 0, ':');
if (line.size > colon_pos1+1){
if (char_is_slash(line.str[colon_pos1+1])){
colon_pos1 = find_s_char(line, colon_pos1+1, ':');
}
}
int colon_pos2 = find_s_char(line, colon_pos1+1, ':');
int colon_pos3 = find_s_char(line, colon_pos2+1, ':');
int32_t colon_pos2 = find_s_char(line, colon_pos1+1, ':');
int32_t colon_pos3 = find_s_char(line, colon_pos2+1, ':');
if (colon_pos3 < line.size){
String filename = substr(line, 0, colon_pos1);
@ -140,18 +140,18 @@ parse_error(String line, Jump_Location *location,
return(result);
}
static int
static int32_t
goto_error(Application_Links *app,
Partition *part,
View_Summary *view, int line,
View_Summary *view, int32_t line,
Jump_Location *location,
int skip_sub_errors){
int32_t skip_sub_errors){
int result = false;
int32_t result = false;
String line_str = {0};
Buffer_Summary buffer = app->get_buffer(app, view->buffer_id, AccessAll);
if (read_line(app, part, &buffer, line, &line_str)){
int colon_char = 0;
int32_t colon_char = 0;
if (parse_error(line_str, location, skip_sub_errors, &colon_char)){
result = true;
}
@ -183,25 +183,25 @@ CUSTOM_COMMAND_SIG(goto_jump_at_cursor){
//
struct Prev_Jump{
int buffer_id;
int line;
int32_t buffer_id;
int32_t line;
};
static Prev_Jump null_location = {0};
static Prev_Jump prev_location = {0};
// TODO(allen): GIVE THESE THINGS NAMES I CAN FUCKING UNDERSTAND
static int
static int32_t
next_error(Application_Links *app,
Partition *part,
View_Summary *comp_out, int *start_line,
View_Summary *comp_out, int32_t *start_line,
Jump_Location *location,
int skip_sub_errors,
int direction,
int *colon_char){
int32_t skip_sub_errors,
int32_t direction,
int32_t *colon_char){
int result = false;
int line = *start_line + direction;
int32_t result = false;
int32_t line = *start_line + direction;
String line_str = {0};
Buffer_Summary buffer = app->get_buffer(app, comp_out->buffer_id, AccessAll);
for (;;){
@ -240,18 +240,18 @@ jump_location_store(Application_Links *app, Jump_Location loc){
return(result);
}
static int
static int32_t
seek_error_internal(Application_Links *app, Partition *part,
int skip_sub_errors, int dir, Jump_Location *loc){
int result = false;
int32_t skip_sub_errors, int32_t dir, Jump_Location *loc){
int32_t result = false;
Jump_Location location = {0};
Buffer_Summary buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
if (buffer.exists){
View_Summary view = get_first_view_with_buffer(app, buffer.buffer_id);
int line = view.cursor.line;
int32_t line = view.cursor.line;
int colon_char = 0;
int32_t colon_char = 0;
if (next_error(app, part, &view, &line, &location,
skip_sub_errors, dir, &colon_char)){
@ -274,9 +274,9 @@ seek_error_internal(Application_Links *app, Partition *part,
}
static int
static int32_t
skip_this_jump(Prev_Jump prev, Prev_Jump jump){
int result = false;
int32_t result = false;
if (prev.buffer_id != 0 && prev.buffer_id == jump.buffer_id &&
prev.line == jump.line){
result = true;
@ -284,10 +284,10 @@ skip_this_jump(Prev_Jump prev, Prev_Jump jump){
return(result);
}
static int
static int32_t
seek_error_skip_repeats(Application_Links *app, Partition *part,
int skip_sub_error, int dir){
int result = true;
int32_t skip_sub_error, int32_t dir){
int32_t result = true;
Jump_Location location = {0};
Prev_Jump jump = {0};
do{
@ -306,10 +306,10 @@ seek_error_skip_repeats(Application_Links *app, Partition *part,
return(result);
}
static int
static int32_t
seek_error_no_skip(Application_Links *app, Partition *part,
int skip_sub_error, int dir){
int result = true;
int32_t skip_sub_error, int32_t dir){
int32_t result = true;
Jump_Location location = {0};
Prev_Jump jump = {0};
@ -327,9 +327,9 @@ seek_error_no_skip(Application_Links *app, Partition *part,
return(result);
}
static int
static int32_t
seek_error(Application_Links *app, Partition *part,
int skip_sub_error, int skip_same_line, int dir){
int32_t skip_sub_error, int32_t skip_same_line, int32_t dir){
if (skip_same_line){
seek_error_skip_repeats(app, part, skip_sub_error, dir);
}

View File

@ -31,7 +31,7 @@ key_f15 = 141,
key_f16 = 142,
};
static char*
global_key_name(int key_code, int *size){
global_key_name(int32_t key_code, int32_t *size){
char *result = 0;
switch(key_code){
case key_back: result = "back"; *size = sizeof("back")-1; break;

View File

@ -4,16 +4,16 @@
struct Partition{
char *base;
int pos, max;
int32_t pos, max;
};
struct Temp_Memory{
void *handle;
int pos;
int32_t pos;
};
inline Partition
make_part(void *memory, int size){
make_part(void *memory, int32_t size){
Partition partition;
partition.base = (char*)memory;
partition.pos = 0;
@ -22,7 +22,7 @@ make_part(void *memory, int size){
}
inline void*
partition_allocate(Partition *data, int size){
partition_allocate(Partition *data, int32_t size){
void *ret = 0;
if (size > 0 && data->pos + size <= data->max){
ret = data->base + data->pos;
@ -32,7 +32,7 @@ partition_allocate(Partition *data, int size){
}
inline void
partition_align(Partition *data, unsigned int boundary){
partition_align(Partition *data, uint32_t boundary){
--boundary;
data->pos = (data->pos + boundary) & (~boundary);
}
@ -42,13 +42,13 @@ partition_current(Partition *data){
return data->base + data->pos;
}
inline int
inline int32_t
partition_remaining(Partition *data){
return data->max - data->pos;
}
inline Partition
partition_sub_part(Partition *data, int size){
partition_sub_part(Partition *data, int32_t size){
Partition result = {};
void *d = partition_allocate(data, size);
if (d) result = make_part(d, size);

View File

@ -78,36 +78,36 @@ f32XYWH(float x, float y, float w, float h){
return(rect);
}
inline int
inline int32_t
rect_equal(i32_Rect r1, i32_Rect r2){
int result = (r1.x0 == r2.x0 &&
r1.y0 == r2.y0 &&
r1.x1 == r2.x1 &&
r1.y1 == r2.y1);
int32_t result = (r1.x0 == r2.x0 &&
r1.y0 == r2.y0 &&
r1.x1 == r2.x1 &&
r1.y1 == r2.y1);
return(result);
}
inline int
inline int32_t
hit_check(int32_t x, int32_t y, int32_t x0, int32_t y0, int32_t x1, int32_t y1){
return (x >= x0 && x < x1 && y >= y0 && y < y1);
}
inline int
inline int32_t
hit_check(int32_t x, int32_t y, i32_Rect rect){
return (hit_check(x, y, rect.x0, rect.y0, rect.x1, rect.y1));
}
inline int
inline int32_t
hit_check(int32_t x, int32_t y, float x0, float y0, float x1, float y1){
return (x >= x0 && x < x1 && y >= y0 && y < y1);
}
inline int
inline int32_t
hit_check(int32_t x, int32_t y, f32_Rect rect){
return (hit_check(x, y, rect.x0, rect.y0, rect.x1, rect.y1));
}
inline int
inline int32_t
positive_area(i32_Rect rect){
return (rect.x0 < rect.x1 && rect.y0 < rect.y1);
}
@ -122,7 +122,7 @@ get_inner_rect(i32_Rect outer, int32_t margin){
return r;
}
inline int
inline int32_t
fits_inside(i32_Rect rect, i32_Rect outer){
return (rect.x0 >= outer.x0 && rect.x1 <= outer.x1 &&
rect.y0 >= outer.y0 && rect.y1 <= outer.y1);

View File

@ -17,39 +17,39 @@ enum Search_Range_Flag{
};
struct Search_Range{
int type;
unsigned int flags;
int buffer;
int start;
int size;
int mid_start;
int mid_size;
int32_t type;
uint32_t flags;
int32_t buffer;
int32_t start;
int32_t size;
int32_t mid_start;
int32_t mid_size;
};
struct Search_Set{
Search_Range *ranges;
int count;
int max;
int32_t count;
int32_t max;
};
struct Search_Iter{
String word;
int pos;
int back_pos;
int i;
int range_initialized;
int32_t pos;
int32_t back_pos;
int32_t i;
int32_t range_initialized;
};
struct Search_Match{
Buffer_Summary buffer;
int start;
int end;
int found_match;
int32_t start;
int32_t end;
int32_t found_match;
};
static void
search_iter_init(General_Memory *general, Search_Iter *iter, int size){
int str_max = size*2;
search_iter_init(General_Memory *general, Search_Iter *iter, int32_t size){
int32_t str_max = size*2;
if (iter->word.str == 0){
iter->word.str = (char*)general_memory_allocate(general, str_max);
iter->word.memory_size = str_max;
@ -63,8 +63,8 @@ search_iter_init(General_Memory *general, Search_Iter *iter, int size){
}
static void
search_set_init(General_Memory *general, Search_Set *set, int range_count){
int max = range_count*2;
search_set_init(General_Memory *general, Search_Set *set, int32_t range_count){
int32_t max = range_count*2;
if (set->ranges == 0){
set->ranges = (Search_Range*)general_memory_allocate(general, sizeof(Search_Range)*max);
@ -80,9 +80,9 @@ search_set_init(General_Memory *general, Search_Set *set, int range_count){
}
static void
search_hits_table_alloc(General_Memory *general, Table *hits, int table_size){
search_hits_table_alloc(General_Memory *general, Table *hits, int32_t table_size){
void *mem = 0;
int mem_size = table_required_mem_size(table_size, sizeof(Offset_String));
int32_t mem_size = table_required_mem_size(table_size, sizeof(Offset_String));
if (hits->hash_array == 0){
mem = general_memory_allocate(general, mem_size);
}
@ -93,12 +93,12 @@ search_hits_table_alloc(General_Memory *general, Table *hits, int table_size){
}
static void
search_hits_init(General_Memory *general, Table *hits, String_Space *str, int table_size, int str_size){
search_hits_init(General_Memory *general, Table *hits, String_Space *str, int32_t table_size, int32_t str_size){
if (hits->hash_array == 0){
search_hits_table_alloc(general, hits, table_size);
}
else{
int mem_size = table_required_mem_size(table_size, sizeof(Offset_String));
int32_t mem_size = table_required_mem_size(table_size, sizeof(Offset_String));
void *mem = general_memory_reallocate_nocopy(general, hits->hash_array, mem_size);
table_init_memory(hits, mem, table_size, sizeof(Offset_String));
}
@ -116,15 +116,15 @@ search_hits_init(General_Memory *general, Table *hits, String_Space *str, int ta
table_clear(hits);
}
static int
search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *str, int len){
int result = false;
static int32_t
search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *str, int32_t len){
int32_t result = false;
assert(len != 0);
Offset_String ostring = strspace_append(space, str, len);
if (ostring.size == 0){
int new_size = space->max*2;
int32_t new_size = space->max*2;
if (new_size < space->max + len){
new_size = space->max + len;
}
@ -155,12 +155,12 @@ search_hit_add(General_Memory *general, Table *hits, String_Space *space, char *
return(result);
}
static int
buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, int pos){
static int32_t
buffer_seek_alpha_numeric_end(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char space[1024];
Stream_Chunk chunk = {0};
if (init_stream_chunk(&chunk, app, buffer, pos, space, sizeof(space))){
int still_looping = true;
int32_t still_looping = true;
do{
for (; pos < chunk.end; ++pos){
char at_pos = chunk.data[pos];
@ -187,14 +187,14 @@ enum{
FindResult_PastEnd
};
static int
match_check(Application_Links *app, Search_Range *range, int *pos, Search_Match *result_ptr, String word){
int found_match = FindResult_None;
static int32_t
match_check(Application_Links *app, Search_Range *range, int32_t *pos, Search_Match *result_ptr, String word){
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
int end_pos = range->start + range->size;
int32_t end_pos = range->start + range->size;
int type = (range->flags & SearchFlag_MatchMask);
int32_t type = (range->flags & SearchFlag_MatchMask);
switch (type){
case SearchFlag_MatchWholeWord:
@ -263,24 +263,24 @@ match_check(Application_Links *app, Search_Range *range, int *pos, Search_Match
return(found_match);
}
static int
static int32_t
search_front_to_back_step(Application_Links *app,
Search_Range *range,
String word,
int *pos,
int32_t *pos,
Search_Match *result_ptr){
int found_match = FindResult_None;
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
int end_pos = range->start + range->size;
int32_t end_pos = range->start + range->size;
if (*pos + word.size < end_pos){
int start_pos = *pos;
int32_t start_pos = *pos;
if (start_pos < range->start){
start_pos = range->start;
}
int case_insensitive = (range->flags & SearchFlag_CaseInsensitive);
int32_t case_insensitive = (range->flags & SearchFlag_CaseInsensitive);
result.buffer = app->get_buffer(app, range->buffer, AccessAll);
if (case_insensitive){
@ -318,31 +318,31 @@ search_front_to_back_step(Application_Links *app,
return(found_match);
}
static int
static int32_t
search_front_to_back(Application_Links *app,
Search_Range *range,
String word,
int *pos,
int32_t *pos,
Search_Match *result_ptr){
int found_match = FindResult_None;
int32_t found_match = FindResult_None;
for (;found_match == FindResult_None;){
found_match = search_front_to_back_step(app, range, word, pos, result_ptr);
}
return(found_match);
}
static int
static int32_t
search_back_to_front_step(Application_Links *app,
Search_Range *range,
String word,
int *pos,
int32_t *pos,
Search_Match *result_ptr){
int found_match = FindResult_None;
int32_t found_match = FindResult_None;
Search_Match result = *result_ptr;
if (*pos > range->start){
int start_pos = *pos;
int32_t start_pos = *pos;
result.buffer = app->get_buffer(app, range->buffer, AccessAll);
buffer_seek_string_backward(app, &result.buffer,
@ -371,13 +371,13 @@ search_back_to_front_step(Application_Links *app,
return(found_match);
}
static int
static int32_t
search_back_to_front(Application_Links *app,
Search_Range *range,
String word,
int *pos,
int32_t *pos,
Search_Match *result_ptr){
int found_match = FindResult_None;
int32_t found_match = FindResult_None;
for (;found_match == FindResult_None;){
found_match = search_back_to_front_step(app, range, word, pos, result_ptr);
}
@ -389,11 +389,11 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
Search_Match result = {0};
Search_Iter iter = *it_ptr;
int count = set->count;
int32_t count = set->count;
for (; iter.i < count;){
Search_Range *range = set->ranges + iter.i;
int find_result = FindResult_None;
int32_t find_result = FindResult_None;
if (!iter.range_initialized){
iter.range_initialized = true;
@ -435,8 +435,8 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
Search_Match forward_match = {0};
Search_Match backward_match = {0};
int forward_result = FindResult_PastEnd;
int backward_result = FindResult_PastEnd;
int32_t forward_result = FindResult_PastEnd;
int32_t backward_result = FindResult_PastEnd;
if (iter.pos < range->start + range->size){
forward_result = search_front_to_back(app, range,
@ -456,9 +456,9 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
if (backward_result == FindResult_FoundMatch){
find_result = FindResult_FoundMatch;
int forward_start = range->mid_start + range->mid_size;
int forward_distance = (forward_match.start - forward_start);
int backward_distance = (range->mid_start - backward_match.end);
int32_t forward_start = range->mid_start + range->mid_size;
int32_t forward_distance = (forward_match.start - forward_start);
int32_t backward_distance = (range->mid_start - backward_match.end);
if (backward_distance < forward_distance){
iter.pos = forward_match.start;

View File

@ -532,7 +532,7 @@ FSTRING_LINK String
skip_whitespace(String str)
{
String result = {0};
int i = 0;
int32_t i = 0;
for (; i < str.size && char_is_whitespace(str.str[i]); ++i);
result = substr(str, i, str.size - i);
return(result);
@ -544,7 +544,7 @@ FSTRING_LINK String
chop_whitespace(String str)
{
String result = {0};
int i = str.size;
int32_t i = str.size;
for (; i > 0 && char_is_whitespace(str.str[i-1]); --i);
result = substr(str, 0, i);
return(result);
@ -1729,13 +1729,13 @@ hexstr_to_color(String s, uint32_t *out){
uint32_t color = 0;
if (s.size == 6){
result = 1;
color = (unsigned int)hexstr_to_int(s);
color = (uint32_t)hexstr_to_int(s);
color |= (0xFF << 24);
*out = color;
}
else if (s.size == 8){
result = 1;
color = (unsigned int)hexstr_to_int(s);
color = (uint32_t)hexstr_to_int(s);
*out = color;
}
return(result);

View File

@ -395,9 +395,9 @@ struct Mouse_State{
/* DOC(This field indicates that the mouse is outside of the window.) */
char out_of_window;
/* DOC(This field contains the x position of the mouse relative to the window where the left side is 0.) */
int x;
int32_t x;
/* DOC(This field contains the y position of the mouse relative to the window where the top side is 0.) */
int y;
int32_t y;
};
/* DOC(
@ -411,15 +411,15 @@ Throughout the API ranges are thought of in the form [min,max) where max is
union Range{
struct{
/* DOC(This is the smaller value in the range, it is also the 'start'.) */
int min;
int32_t min;
/* DOC(This is the larger value in the range, it is also the 'end'.) */
int max;
int32_t max;
};
struct{
/* DOC(This is the start of the range, it is also the 'min'.) */
int start;
int32_t start;
/* DOC(This is the end of the range, it is also the 'max'.) */
int end;
int32_t end;
};
};
@ -432,10 +432,10 @@ struct File_Info{
char *filename;
/* DOC(This field specifies the length of the filename string not counting the null terminator.) */
int filename_len;
int32_t filename_len;
/* DOC(This field indicates that the description is for a folder not a file.) */
int folder;
int32_t folder;
};
/* DOC(File_List is a list of File_Info structs.) */
@ -445,9 +445,9 @@ struct File_List{
/* DOC(This field is an array of File_Info structs.) */
File_Info *infos;
/* DOC(This field specifies the number of struts in the info array.) */
int count;
int32_t count;
/* DOC(This field is for internal use.) */
int block_size;
int32_t block_size;
};
/* DOC(
@ -462,10 +462,10 @@ struct Buffer_Identifier{
char *name;
/* DOC(This field specifies the length of the name string.) */
int name_len;
int32_t name_len;
/* DOC(This field is the id of the buffer. If name is specified this should be 0.) */
int id;
int32_t id;
};
/* DOC(This struct is a part of an incomplete feature.) */
@ -692,7 +692,7 @@ struct Query_Bar{
/* DOC(This feature is not implemented.) */
struct Event_Message{
/* DOC(This feature is not implemented.) */
int type;
int32_t type;
};
/*

View File

@ -12,27 +12,28 @@
#include "4cpp_lexer_fsms.h"
#include "4cpp_lexer_tables.c"
#define lexer_link static
// TODO(allen): revisit this keyword data declaration system
struct String_And_Flag{
char *str;
uint32_t flags;
};
struct String_List{
String_And_Flag *data;
int count;
int32_t count;
};
struct Sub_Match_List_Result{
int index;
int32_t index;
int32_t new_pos;
};
#define lexer_string_list(x) {x, (sizeof(x)/sizeof(*x))}
static String_And_Flag bool_lit_strings[] = {
{"true"}, {"false"}
};
static String_List bool_lits = lexer_string_list(bool_lit_strings);
#define lexer_string_list(x) {x, (sizeof(x)/sizeof(*(x)))}
static String_And_Flag keyword_strings[] = {
{"true", CPP_TOKEN_BOOLEAN_CONSTANT},
{"false", CPP_TOKEN_BOOLEAN_CONSTANT},
{"and", CPP_TOKEN_AND},
{"and_eq", CPP_TOKEN_ANDEQ},
{"bitand", CPP_TOKEN_BIT_AND},
@ -120,12 +121,12 @@ static String_And_Flag keyword_strings[] = {
};
static String_List keywords = lexer_string_list(keyword_strings);
lexer_link Sub_Match_List_Result
sub_match_list(char *chunk, int size, int pos, String_List list, int sub_size){
FCPP_LINK Sub_Match_List_Result
sub_match_list(char *chunk, int32_t size, int32_t pos, String_List list, int32_t sub_size){
Sub_Match_List_Result result;
String str_main;
char *str_check;
int i,l;
int32_t i,l;
result.index = -1;
result.new_pos = pos;
@ -155,15 +156,15 @@ sub_match_list(char *chunk, int size, int pos, String_List list, int sub_size){
}
lexer_link Cpp_Get_Token_Result
cpp_get_token(Cpp_Token_Stack *token_stack, int pos){
FCPP_LINK Cpp_Get_Token_Result
cpp_get_token(Cpp_Token_Stack *token_stack, int32_t pos){
Cpp_Get_Token_Result result = {};
Cpp_Token *token_array = token_stack->tokens;
Cpp_Token *token = 0;
int first = 0;
int count = token_stack->count;
int last = count;
int this_start = 0, next_start = 0;
int32_t first = 0;
int32_t count = token_stack->count;
int32_t last = count;
int32_t this_start = 0, next_start = 0;
if (count > 0){
for (;;){
@ -211,10 +212,10 @@ cpp_get_token(Cpp_Token_Stack *token_stack, int pos){
return(result);
}
lexer_link void
cpp_shift_token_starts(Cpp_Token_Stack *stack, int from_token_i, int shift_amount){
FCPP_LINK void
cpp_shift_token_starts(Cpp_Token_Stack *stack, int32_t from_token_i, int32_t shift_amount){
Cpp_Token *token = stack->tokens + from_token_i;
int count = stack->count, i;
int32_t count = stack->count, i;
for (i = from_token_i; i < count; ++i, ++token){
token->start += shift_amount;
@ -226,7 +227,7 @@ enum Pos_Update_Rule{
PUR_back_one,
};
lexer_link Lex_PP_State
FCPP_LINK Lex_PP_State
cpp_pp_directive_to_state(Cpp_Token_Type type){
Lex_PP_State result = LSPP_default;
switch (type){
@ -272,7 +273,7 @@ cpp_pp_directive_to_state(Cpp_Token_Type type){
return(result);
}
lexer_link Cpp_Token_Merge
FCPP_LINK Cpp_Token_Merge
cpp_attempt_token_merge(Cpp_Token prev_token, Cpp_Token next_token){
Cpp_Token_Merge result = {(Cpp_Token_Type)0};
if (next_token.type == CPP_TOKEN_COMMENT && prev_token.type == CPP_TOKEN_COMMENT &&
@ -290,8 +291,8 @@ cpp_attempt_token_merge(Cpp_Token prev_token, Cpp_Token next_token){
return result;
}
lexer_link int
cpp_place_token_nonalloc(Cpp_Token *out_tokens, int token_i, Cpp_Token token){
FCPP_LINK int32_t
cpp_place_token_nonalloc(Cpp_Token *out_tokens, int32_t token_i, Cpp_Token token){
Cpp_Token_Merge merge = {(Cpp_Token_Type)0};
Cpp_Token prev_token = {(Cpp_Token_Type)0};
@ -310,7 +311,7 @@ cpp_place_token_nonalloc(Cpp_Token *out_tokens, int token_i, Cpp_Token token){
return(token_i);
}
lexer_link bool
FCPP_LINK bool
cpp_push_token_nonalloc(Cpp_Token_Stack *out_tokens, Cpp_Token token){
bool result = 0;
if (out_tokens->count == out_tokens->max_count){
@ -323,12 +324,12 @@ cpp_push_token_nonalloc(Cpp_Token_Stack *out_tokens, Cpp_Token token){
struct Lex_Data{
char *tb;
int tb_pos;
int token_start;
int32_t tb_pos;
int32_t token_start;
int pos;
int pos_overide;
int chunk_pos;
int32_t pos;
int32_t pos_overide;
int32_t chunk_pos;
Lex_FSM fsm;
Whitespace_FSM wfsm;
@ -337,9 +338,10 @@ struct Lex_Data{
Cpp_Token token;
int __pc__;
int32_t __pc__;
};
inline Lex_Data
FCPP_LINK Lex_Data
lex_data_init(char *tb){
Lex_Data data = {0};
data.tb = tb;
@ -364,21 +366,21 @@ enum Lex_Result{
LexHitTokenLimit
};
lexer_link int
FCPP_LINK int32_t
cpp_lex_nonalloc(Lex_Data *S_ptr,
char *chunk, int size,
char *chunk, int32_t size,
Cpp_Token_Stack *token_stack_out){
Lex_Data S = *S_ptr;
Cpp_Token *out_tokens = token_stack_out->tokens;
int token_i = token_stack_out->count;
int max_token_i = token_stack_out->max_count;
int32_t token_i = token_stack_out->count;
int32_t max_token_i = token_stack_out->max_count;
Pos_Update_Rule pos_update_rule = PUR_none;
char c = 0;
int end_pos = size + S.chunk_pos;
int32_t end_pos = size + S.chunk_pos;
chunk -= S.chunk_pos;
switch (S.__pc__){
@ -397,7 +399,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr,
for(;;){
for (; S.wfsm.pp_state < LSPP_count && S.pos < end_pos;){
c = chunk[S.pos++];
int i = S.wfsm.pp_state + whitespace_fsm_eq_classes[c];
int32_t i = S.wfsm.pp_state + whitespace_fsm_eq_classes[c];
S.wfsm.pp_state = whitespace_fsm_table[i];
}
S.wfsm.white_done = (S.wfsm.pp_state >= LSPP_count);
@ -428,7 +430,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr,
c = chunk[S.pos++];
S.tb[S.tb_pos++] = c;
int i = S.fsm.state + eq_classes[c];
int32_t i = S.fsm.state + eq_classes[c];
S.fsm.state = fsm_table[i];
S.fsm.multi_line |= multiline_state_table[S.fsm.state];
}
@ -531,7 +533,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr,
{
--S.pos;
int word_size = S.pos - S.token_start;
int32_t word_size = S.pos - S.token_start;
if (S.pp_state == LSPP_body_if){
if (match_ss(make_string(S.tb, word_size), make_lit_string("defined"))){
@ -542,24 +544,16 @@ cpp_lex_nonalloc(Lex_Data *S_ptr,
}
Sub_Match_List_Result sub_match;
sub_match = sub_match_list(S.tb, S.tb_pos, 0, bool_lits, word_size);
sub_match = sub_match_list(S.tb, S.tb_pos, 0, keywords, word_size);
if (sub_match.index != -1){
S.token.type = CPP_TOKEN_BOOLEAN_CONSTANT;
String_And_Flag data = keywords.data[sub_match.index];
S.token.type = (Cpp_Token_Type)data.flags;
S.token.flags = CPP_TFLAG_IS_KEYWORD;
}
else{
sub_match = sub_match_list(S.tb, S.tb_pos, 0, keywords, word_size);
if (sub_match.index != -1){
String_And_Flag data = keywords.data[sub_match.index];
S.token.type = (Cpp_Token_Type)data.flags;
S.token.flags = CPP_TFLAG_IS_KEYWORD;
}
else{
S.token.type = CPP_TOKEN_IDENTIFIER;
S.token.flags = 0;
}
S.token.type = CPP_TOKEN_IDENTIFIER;
S.token.flags = 0;
}
}break;
@ -992,16 +986,16 @@ cpp_lex_nonalloc(Lex_Data *S_ptr,
#undef DrReturn
#undef DrCase
lexer_link int
FCPP_LINK int32_t
cpp_lex_nonalloc(Lex_Data *S_ptr,
char *chunk, int size,
Cpp_Token_Stack *token_stack_out, int max_tokens){
char *chunk, int32_t size,
Cpp_Token_Stack *token_stack_out, int32_t max_tokens){
Cpp_Token_Stack temp_stack = *token_stack_out;
if (temp_stack.max_count > temp_stack.count + max_tokens){
temp_stack.max_count = temp_stack.count + max_tokens;
}
int result = cpp_lex_nonalloc(S_ptr, chunk, size, &temp_stack);
int32_t result = cpp_lex_nonalloc(S_ptr, chunk, size, &temp_stack);
token_stack_out->count = temp_stack.count;
@ -1014,11 +1008,11 @@ cpp_lex_nonalloc(Lex_Data *S_ptr,
return(result);
}
lexer_link int
FCPP_LINK int32_t
cpp_lex_size_nonalloc(Lex_Data *S_ptr,
char *chunk, int size, int full_size,
char *chunk, int32_t size, int32_t full_size,
Cpp_Token_Stack *token_stack_out){
int result = 0;
int32_t result = 0;
if (S_ptr->pos >= full_size){
char end_null = 0;
result = cpp_lex_nonalloc(S_ptr, &end_null, 1, token_stack_out);
@ -1035,17 +1029,17 @@ cpp_lex_size_nonalloc(Lex_Data *S_ptr,
return(result);
}
lexer_link int
FCPP_LINK int32_t
cpp_lex_size_nonalloc(Lex_Data *S_ptr,
char *chunk, int size, int full_size,
Cpp_Token_Stack *token_stack_out, int max_tokens){
char *chunk, int32_t size, int32_t full_size,
Cpp_Token_Stack *token_stack_out, int32_t max_tokens){
Cpp_Token_Stack temp_stack = *token_stack_out;
if (temp_stack.max_count > temp_stack.count + max_tokens){
temp_stack.max_count = temp_stack.count + max_tokens;
}
int result = cpp_lex_size_nonalloc(S_ptr, chunk, size, full_size,
&temp_stack);
int32_t result = cpp_lex_size_nonalloc(S_ptr, chunk, size, full_size,
&temp_stack);
token_stack_out->count = temp_stack.count;
@ -1058,9 +1052,9 @@ cpp_lex_size_nonalloc(Lex_Data *S_ptr,
return(result);
}
lexer_link Cpp_Relex_State
cpp_relex_nonalloc_start(char *data, int size, Cpp_Token_Stack *stack,
int start, int end, int amount, int tolerance){
FCPP_LINK Cpp_Relex_State
cpp_relex_nonalloc_start(char *data, int32_t size, Cpp_Token_Stack *stack,
int32_t start, int32_t end, int32_t amount, int32_t tolerance){
Cpp_Relex_State state;
state.data = data;
state.size = size;
@ -1097,15 +1091,15 @@ cpp_relex_nonalloc_start(char *data, int size, Cpp_Token_Stack *stack,
return(state);
}
inline char
FCPP_LINK char
cpp_token_get_pp_state(uint16_t bitfield){
return (char)(bitfield);
}
// TODO(allen): Eliminate this once we actually store the EOF token
// in the token stack.
inline Cpp_Token
cpp__get_token(Cpp_Token_Stack *stack, Cpp_Token *tokens, int size, int index){
FCPP_LINK Cpp_Token
cpp__get_token(Cpp_Token_Stack *stack, Cpp_Token *tokens, int32_t size, int32_t index){
Cpp_Token result;
if (index < stack->count){
result = tokens[index];
@ -1120,10 +1114,10 @@ cpp__get_token(Cpp_Token_Stack *stack, Cpp_Token *tokens, int size, int index){
return result;
}
FCPP_LINK int
FCPP_LINK int32_t
cpp_relex_nonalloc_main(Cpp_Relex_State *state,
Cpp_Token_Stack *relex_stack,
int *relex_end,
int32_t *relex_end,
char *spare){
Cpp_Token_Stack *stack = state->stack;
Cpp_Token *tokens = stack->tokens;
@ -1134,14 +1128,14 @@ cpp_relex_nonalloc_main(Cpp_Relex_State *state,
lex.pp_state = cpp_token_get_pp_state(tokens[state->start_token_i].state_flags);
lex.pos = state->relex_start;
int relex_end_i = state->end_token_i;
int32_t relex_end_i = state->end_token_i;
Cpp_Token match_token = cpp__get_token(stack, tokens, state->size, relex_end_i);
Cpp_Token end_token = match_token;
int went_too_far = false;
int32_t went_too_far = false;
// TODO(allen): This can be better I suspect.
for (;;){
int result =
int32_t result =
cpp_lex_size_nonalloc(&lex,
state->data,
state->size,
@ -1217,7 +1211,7 @@ cpp_relex_nonalloc_main(Cpp_Relex_State *state,
#include <string.h>
FCPP_LINK Cpp_Token_Stack
cpp_make_token_stack(int starting_max){
cpp_make_token_stack(int32_t starting_max){
Cpp_Token_Stack token_stack;
token_stack.count = 0;
token_stack.max_count = starting_max;
@ -1231,7 +1225,7 @@ cpp_free_token_stack(Cpp_Token_Stack token_stack){
}
FCPP_LINK void
cpp_resize_token_stack(Cpp_Token_Stack *token_stack, int new_max){
cpp_resize_token_stack(Cpp_Token_Stack *token_stack, int32_t new_max){
Cpp_Token *new_tokens = (Cpp_Token*)malloc(sizeof(Cpp_Token)*new_max);
if (new_tokens){
@ -1245,21 +1239,21 @@ cpp_resize_token_stack(Cpp_Token_Stack *token_stack, int new_max){
FCPP_LINK void
cpp_push_token(Cpp_Token_Stack *token_stack, Cpp_Token token){
if (!cpp_push_token_nonalloc(token_stack, token)){
int new_max = 2*token_stack->max_count + 1;
int32_t new_max = 2*token_stack->max_count + 1;
cpp_resize_token_stack(token_stack, new_max);
cpp_push_token_nonalloc(token_stack, token);
}
}
FCPP_LINK void
cpp_lex_file(char *data, int size, Cpp_Token_Stack *token_stack_out){
cpp_lex_file(char *data, int32_t size, Cpp_Token_Stack *token_stack_out){
Lex_Data S = {0};
S.tb = (char*)malloc(size);
int quit = 0;
int32_t quit = 0;
token_stack_out->count = 0;
for (;!quit;){
int result = cpp_lex_nonalloc(&S, data, size, token_stack_out);
int32_t result = cpp_lex_nonalloc(&S, data, size, token_stack_out);
switch (result){
case LexFinished:
{
@ -1275,7 +1269,7 @@ cpp_lex_file(char *data, int size, Cpp_Token_Stack *token_stack_out){
case LexNeedTokenMemory:
{
int new_max = 2*token_stack_out->max_count + 1;
int32_t new_max = 2*token_stack_out->max_count + 1;
cpp_resize_token_stack(token_stack_out, new_max);
}break;
}

View File

@ -1,38 +1,14 @@
/*
* FSMs for 4c++ lexer
* FSMs for 4cpp lexer
*
* 23.03.2016 (dd.mm.yyyy)
*
*/
// TOP
struct String_And_Flag{
char *str;
unsigned int flags;
};
#if !defined(FCPP_LEXER_FSMS_H)
#define FCPP_LEXER_FSMS_H
enum Lex_State{
LS_default,
@ -113,19 +89,19 @@ enum Lex_PP_State{
};
struct Whitespace_FSM{
unsigned char pp_state;
unsigned char white_done;
uint8_t pp_state;
uint8_t white_done;
};
struct Lex_FSM{
unsigned char state;
uint8_t state;
union{
unsigned char int_state;
unsigned char directive_state;
unsigned char sub_machine;
uint8_t int_state;
uint8_t directive_state;
uint8_t sub_machine;
};
unsigned char emit_token;
unsigned char multi_line;
uint8_t emit_token;
uint8_t multi_line;
};
inline Lex_FSM
zero_lex_fsm(){
@ -133,6 +109,8 @@ zero_lex_fsm(){
return(fsm);
}
#endif
// BOTTOM

View File

@ -1,39 +1,39 @@
unsigned short whitespace_fsm_eq_classes[] = {
uint16_t whitespace_fsm_eq_classes[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 9,18, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
const int num_whitespace_fsm_eq_classes = 3;
const int32_t num_whitespace_fsm_eq_classes = 3;
unsigned char whitespace_fsm_table[] = {
uint8_t whitespace_fsm_table[] = {
9,10,11,12,13,14,15,16,17,
0, 1, 2, 3, 4, 5, 6, 7, 8,
0, 0, 0, 0, 0, 0, 0, 0, 0,
};
unsigned short int_fsm_eq_classes[] = {
uint16_t int_fsm_eq_classes[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0, 0, 0, 0, 0, 0,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
const int num_int_fsm_eq_classes = 4;
const int32_t num_int_fsm_eq_classes = 4;
unsigned char int_fsm_table[] = {
uint8_t int_fsm_table[] = {
8, 9,10,11,12,13,14,15,
3, 5,10, 6,12, 7,14,15,
1, 9, 7, 7,12,13, 7,15,
2, 4, 6,11, 7,13,14,15,
};
unsigned char multiline_state_table[] = {
uint8_t multiline_state_table[] = {
0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
unsigned short main_fsm_eq_classes[] = {
uint16_t main_fsm_eq_classes[] = {
0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
};
const int num_main_fsm_eq_classes = 29;
const int32_t num_main_fsm_eq_classes = 29;
unsigned char main_fsm_table[] = {
uint8_t main_fsm_table[] = {
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,
0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
@ -65,13 +65,13 @@ unsigned char main_fsm_table[] = {
30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
};
unsigned short pp_include_fsm_eq_classes[] = {
uint16_t pp_include_fsm_eq_classes[] = {
0,39,39,39,39,39,39,39,39,39,78,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,39,195,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
};
const int num_pp_include_fsm_eq_classes = 6;
const int32_t num_pp_include_fsm_eq_classes = 6;
unsigned char pp_include_fsm_table[] = {
uint8_t pp_include_fsm_table[] = {
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,
3, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,
3,42,42,42, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,
@ -80,13 +80,13 @@ unsigned char pp_include_fsm_table[] = {
3, 1,41, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,
};
unsigned short pp_macro_fsm_eq_classes[] = {
uint16_t pp_macro_fsm_eq_classes[] = {
0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
};
const int num_pp_macro_fsm_eq_classes = 29;
const int32_t num_pp_macro_fsm_eq_classes = 29;
unsigned char pp_macro_fsm_table[] = {
uint8_t pp_macro_fsm_table[] = {
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,
0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
@ -118,13 +118,13 @@ unsigned char pp_macro_fsm_table[] = {
30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
};
unsigned short pp_identifier_fsm_eq_classes[] = {
uint16_t pp_identifier_fsm_eq_classes[] = {
0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
};
const int num_pp_identifier_fsm_eq_classes = 29;
const int32_t num_pp_identifier_fsm_eq_classes = 29;
unsigned char pp_identifier_fsm_table[] = {
uint8_t pp_identifier_fsm_table[] = {
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,
0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
@ -156,13 +156,13 @@ unsigned char pp_identifier_fsm_table[] = {
30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
};
unsigned short pp_body_if_fsm_eq_classes[] = {
uint16_t pp_body_if_fsm_eq_classes[] = {
0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
};
const int num_pp_body_if_fsm_eq_classes = 29;
const int32_t num_pp_body_if_fsm_eq_classes = 29;
unsigned char pp_body_if_fsm_table[] = {
uint8_t pp_body_if_fsm_table[] = {
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,
0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
@ -194,13 +194,13 @@ unsigned char pp_body_if_fsm_table[] = {
30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
};
unsigned short pp_body_fsm_eq_classes[] = {
uint16_t pp_body_fsm_eq_classes[] = {
0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
};
const int num_pp_body_fsm_eq_classes = 29;
const int32_t num_pp_body_fsm_eq_classes = 29;
unsigned char pp_body_fsm_table[] = {
uint8_t pp_body_fsm_table[] = {
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,
0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
@ -232,13 +232,13 @@ unsigned char pp_body_fsm_table[] = {
30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
};
unsigned short pp_number_fsm_eq_classes[] = {
uint16_t pp_number_fsm_eq_classes[] = {
0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
};
const int num_pp_number_fsm_eq_classes = 29;
const int32_t num_pp_number_fsm_eq_classes = 29;
unsigned char pp_number_fsm_table[] = {
uint8_t pp_number_fsm_table[] = {
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,
0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
@ -270,25 +270,25 @@ unsigned char pp_number_fsm_table[] = {
30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
};
unsigned short pp_error_fsm_eq_classes[] = {
uint16_t pp_error_fsm_eq_classes[] = {
0,39,39,39,39,39,39,39,39,39,78,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
};
const int num_pp_error_fsm_eq_classes = 3;
const int32_t num_pp_error_fsm_eq_classes = 3;
unsigned char pp_error_fsm_table[] = {
uint8_t pp_error_fsm_table[] = {
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,
38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,
77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,
};
unsigned short pp_junk_fsm_eq_classes[] = {
uint16_t pp_junk_fsm_eq_classes[] = {
0,39,39,39,39,39,39,39,39,39,78,117,117,117,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,156,195,234,273,312,351,390,273,273,429,468,273,507,546,585,624,663,663,663,663,663,663,663,663,663,702,273,741,780,819,273,273,858,858,858,858,858,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,273,936,273,975,897,39,858,858,858,858,1014,858,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,897,1053,897,897,273,1092,273,273,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,
};
const int num_pp_junk_fsm_eq_classes = 29;
const int32_t num_pp_junk_fsm_eq_classes = 29;
unsigned char pp_junk_fsm_table[] = {
uint8_t pp_junk_fsm_table[] = {
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,
0,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
0,40,41, 3,43,44, 5,46,47, 8,49,50,51,52,53,54,55,56,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
@ -320,7 +320,7 @@ unsigned char pp_junk_fsm_table[] = {
30,40,41, 3, 4, 5, 4, 7, 8, 7,49,50,51,52,53,54,55,17,17,19,19,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,38,
};
unsigned short * get_eq_classes[] = {
uint16_t * get_eq_classes[] = {
main_fsm_eq_classes,
pp_include_fsm_eq_classes,
pp_macro_fsm_eq_classes,
@ -332,7 +332,7 @@ pp_error_fsm_eq_classes,
pp_junk_fsm_eq_classes,
};
unsigned char * get_table[] = {
uint8_t * get_table[] = {
main_fsm_table,
pp_include_fsm_table,
pp_macro_fsm_table,
@ -344,13 +344,13 @@ pp_error_fsm_table,
pp_junk_fsm_table,
};
unsigned short pp_directive_eq_classes[] = {
uint16_t pp_directive_eq_classes[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0,119, 0,119,119,119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,238, 0,357,476,595,714,833, 0,952, 0, 0,1071,1190,1309,1428,1547, 0,1666,1785,1904,2023, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,2142, 0,2261,2380,2499,2618,2737, 0,2856, 0, 0,2975,3094,3213,3332,3451, 0,3570,3689,3808,3927, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
const int num_pp_directive_eq_classes = 34;
const int32_t num_pp_directive_eq_classes = 34;
unsigned char pp_directive_table[] = {
uint8_t pp_directive_table[] = {
200,200,200,200,200,200,200,200,200,200,200,200,200,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,200,200,200,203,200,200,200,200,203,200,200,200,200,215,200,200,200,200,215,200,200,200,200,204,200,200,213,200,200,200,200,204,200,200,213,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,214,200,200,214,
0,200,200,200,200,200,200,200,200,200,200,200,200,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,200,200,200,203,200,200,200,200,203,200,200,200,200,215,200,200,200,200,215,200,200,200,200,204,200,200,213,200,200,200,200,204,200,200,213,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,214,200,200,214,
200,200,200,200,200,200,200,200,200,200,200,200,200,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,200,200,200,203,200,200,200,200,203,200,200,200,200,215,67,200,200,70,215,200,200,200,200,204,200,200,213,200,200,200,200,204,200,200,213,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,214,200,200,214,
@ -387,9 +387,9 @@ unsigned char pp_directive_table[] = {
7,200,200,200,200,200,200,200,200,200,200,200,200,200,205,200,200,18,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,205,200,200,200,200,200,202,200,200,200,200,207,200,206,200,200,200,212,200,200,200,200,203,200,200,200,200,203,200,200,200,200,215,200,200,200,200,215,200,200,200,200,204,200,200,213,200,200,200,200,204,200,200,213,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,200,200,200,210,200,200,211,200,200,208,209,200,200,214,200,200,214,
};
unsigned char LSDIR_default = 0;
uint8_t LSDIR_default = 0;
unsigned char LSDIR_count = 119;
uint8_t LSDIR_count = 119;
unsigned char pp_directive_terminal_base = 200;
uint8_t pp_directive_terminal_base = 200;

View File

@ -172,9 +172,9 @@ enum Cpp_Token_Type{
struct Cpp_Token{
Cpp_Token_Type type;
int start, size;
unsigned short state_flags;
unsigned short flags;
int32_t start, size;
uint16_t state_flags;
uint16_t flags;
};
enum Cpp_Token_Flag{
@ -204,7 +204,7 @@ enum Cpp_Preprocessor_State{
struct Cpp_Token_Stack{
Cpp_Token *tokens;
int count, max_count;
int32_t count, max_count;
};
inline Cpp_Token_Stack
cpp_token_stack_zero(){
@ -214,30 +214,30 @@ cpp_token_stack_zero(){
struct Cpp_Token_Merge{
Cpp_Token new_token;
int did_merge;
int32_t did_merge;
};
struct Seek_Result{
int pos;
int new_line;
int32_t pos;
int32_t new_line;
};
struct Cpp_Get_Token_Result{
int token_index;
int in_whitespace;
int32_t token_index;
int32_t in_whitespace;
};
struct Cpp_Relex_State{
char *data;
int size;
int32_t size;
Cpp_Token_Stack *stack;
int start, end, amount;
int start_token_i;
int end_token_i;
int relex_start;
int tolerance;
int space_request;
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;
};
#endif

42
4ed.cpp
View File

@ -172,7 +172,7 @@ enum Coroutine_Type{
};
struct App_Coroutine_State{
void *co;
int type;
i32 type;
};
inline App_Coroutine_State
get_state(Application_Links *app){
@ -764,7 +764,7 @@ view_caller(Coroutine *coroutine){
}
internal void
app_links_init(System_Functions *system, Application_Links *app_links, void *data, int size){
app_links_init(System_Functions *system, Application_Links *app_links, void *data, i32 size){
app_links->memory = data;
app_links->memory_size = size;
@ -1077,26 +1077,6 @@ app_hardcode_styles(Models *models){
style_copy(main_style(models), models->styles.styles + 1);
}
char *_4coder_get_extension(const char *filename, int len, int *extension_len){
char *c = (char*)(filename + len - 1);
char *end = c;
while (*c != '.' && c > filename) --c;
*extension_len = (int)(end - c);
return c+1;
}
bool _4coder_str_match(const char *a, int len_a, const char *b, int len_b){
bool result = 0;
if (len_a == len_b){
char *end = (char*)(a + len_a);
while (a < end && *a == *b){
++a; ++b;
}
if (a == end) result = 1;
}
return result;
}
enum Command_Line_Action{
CLAct_Nothing,
CLAct_Ignore,
@ -1271,7 +1251,7 @@ App_Read_Command_Line_Sig(app_read_command_line){
}
extern "C" SCROLL_RULE_SIG(fallback_scroll_rule){
int result = 0;
i32 result = 0;
if (target_x != *scroll_x){
*scroll_x = target_x;
@ -1403,8 +1383,8 @@ App_Init_Sig(app_init){
switch (unit->type){
case unit_map_begin:
{
int mapid = unit->map_begin.mapid;
int count = map_get_count(models, mapid);
i32 mapid = unit->map_begin.mapid;
i32 count = map_get_count(models, mapid);
if (unit->map_begin.replace){
map_set_count(models, mapid, unit->map_begin.bind_count);
}
@ -1420,9 +1400,9 @@ App_Init_Sig(app_init){
switch (unit->type){
case unit_map_begin:
{
int mapid = unit->map_begin.mapid;
int count = map_get_max_count(models, mapid);
int table_max = count * 3 / 2;
i32 mapid = unit->map_begin.mapid;
i32 count = map_get_max_count(models, mapid);
i32 table_max = count * 3 / 2;
if (mapid == mapid_global){
map_ptr = &models->map_top;
map_init(map_ptr, &models->mem.part, table_max, global);
@ -1449,7 +1429,7 @@ App_Init_Sig(app_init){
case unit_inherit:
if (map_ptr){
Command_Map *parent = 0;
int mapid = unit->map_inherit.mapid;
i32 mapid = unit->map_inherit.mapid;
if (mapid == mapid_global) parent = &models->map_top;
else if (mapid == mapid_file) parent = &models->map_file;
else if (mapid < mapid_global){
@ -1495,7 +1475,7 @@ App_Init_Sig(app_init){
case unit_hook:
{
int hook_id = unit->hook.hook_id;
i32 hook_id = unit->hook.hook_id;
if (hook_id >= 0){
if (hook_id < hook_type_count){
models->hooks[hook_id] = (Hook_Function*)unit->hook.func;
@ -1551,7 +1531,7 @@ App_Init_Sig(app_init){
i32 pt_size;
};
int font_size = models->settings.font_size;
i32 font_size = models->settings.font_size;
if (font_size < 8) font_size = 8;

2
4ed.h
View File

@ -61,7 +61,7 @@ struct Input_Summary{
struct Command_Line_Parameters{
char **argv;
int argc;
int32_t argc;
};
struct Plat_Settings{

View File

@ -57,7 +57,7 @@ fill_view_summary(View_Summary *view, View *vptr, Live_Views *live_set, Working_
if (vptr->in_use){
view->exists = 1;
view->view_id = (int)(vptr - live_set->views) + 1;
view->view_id = (int32_t)(vptr - live_set->views) + 1;
view->line_height = (float)(vptr->line_height);
view->unwrapped_lines = vptr->file_data.unwrapped_lines;
view->show_whitespace = vptr->file_data.show_whitespace;
@ -800,7 +800,7 @@ DOC_SEE(Buffer_Batch_Edit_Type)
Assert(inverse_edits);
char *inv_str = (char*)part->base + part->pos;
int inv_str_max = part->max - part->pos;
int32_t inv_str_max = part->max - part->pos;
Edit_Spec spec =
file_compute_edit(mem, file,
@ -1112,7 +1112,7 @@ DOC_SEE(Buffer_Identifier)
Working_Set *working_set = &models->working_set;
View *vptr = imp_get_view(cmd, view_id);
Editing_File *file = get_file_from_identifier(system, working_set, buffer);
int result = false;
int32_t result = false;
if (file){
if (flags & BufferKill_AlwaysKill){
@ -1155,7 +1155,7 @@ internal void
internal_get_view_next(Command_Data *cmd, View_Summary *view){
Editing_Layout *layout = &cmd->models->layout;
Live_Views *live_set = &cmd->vars->live_set;
int index = view->view_id - 1;
int32_t index = view->view_id - 1;
View *vptr = 0;
Panel *panel = 0;
@ -1749,7 +1749,7 @@ DOC_SEE(int_color)
bool32 result = false;
int size = end - start;
int32_t size = end - start;
if (vptr){
if (size > 0){
result = true;

View File

@ -11,24 +11,25 @@
#include "4coder_custom.h"
#define FSTRING_IMPLEMENTATION
#define FSTRING_C
#include "4coder_string.h"
#define BUFFER_EXPERIMENT_SCALPEL 0
#include "4ed_meta.h"
#define FSTRING_IMPLEMENTATION
#include "4coder_string.h"
#include "4ed_math.cpp"
#include "4ed_math.h"
#include "4ed_system.h"
#include "4ed_rendering.h"
#include "4ed.h"
#include "4coder_table.cpp"
#include "4cpp_lexer.h"
#include "4ed_template.cpp"
#include "4coder_table.cpp"
#include "4ed_doubly_linked_list.cpp"
#include "4ed_font_set.cpp"
#include "4ed_rendering_helper.cpp"

View File

@ -0,0 +1,22 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 01.03.2016
*
* generic dynamically linked list
*
*/
// NOTE(allen): These macros are setup to work on structs
// with a next and prev pointer where the type of the struct
// is the same as the type of the next/prev pointers.
#define dll_init_sentinel(s) do{ (s)->next=(s); (s)->prev=(s); }while(0)
#define dll_insert(p,v) do{ (v)->next=(p)->next; (v)->prev=(p); (p)->next=(v); (v)->next->prev=(v); }while(0)
#define dll_remove(v) do{ (v)->next->prev = (v)->prev; (v)->prev->next = (v)->next; }while(0)
// for(dll_items(iterator, sentinel_ptr)){...}
#define dll_items(it, st) ((it) = (st)->next); ((it) != (st)); ((it) = (it)->next)
// BOTTOM

View File

@ -2547,7 +2547,7 @@ get_first_token_at_line(Buffer *buffer, Cpp_Token_Stack tokens, i32 line){
internal Cpp_Token*
seek_matching_token_backwards(Cpp_Token_Stack tokens, Cpp_Token *token,
Cpp_Token_Type open_type, Cpp_Token_Type close_type){
int nesting_level = 0;
int32_t nesting_level = 0;
if (token <= tokens.tokens){
token = tokens.tokens;
}
@ -2712,7 +2712,7 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke
}
}
else{
int close = 0;
int32_t close = 0;
for (token = brace_token; token > start_token; --token){
switch(token->type){

View File

@ -23,7 +23,7 @@ struct Query_Set{
internal void
init_query_set(Query_Set *set){
Query_Slot *slot = set->slots;
int i;
int32_t i;
set->free_slot = slot;
set->used_slot = 0;
for (i = 0; i+1 < ArrayCount(set->slots); ++i, ++slot){

View File

@ -33,8 +33,6 @@ struct Panel{
i32 parent;
i32 which_child;
int ALLOCED;
union{
struct{
i32_Rect full;
@ -140,8 +138,6 @@ layout_alloc_panel(Editing_Layout *layout){
result.id = (i32)(result.panel - layout->panels);
result.panel->ALLOCED = 1;
return(result);
}
@ -150,8 +146,6 @@ layout_free_panel(Editing_Layout *layout, Panel *panel){
dll_remove(panel);
dll_insert(&layout->free_sentinel, panel);
--layout->panel_count;
panel->ALLOCED = 0;
}
internal Divider_And_ID

File diff suppressed because it is too large Load Diff

View File

@ -171,7 +171,7 @@ struct Render_Quad{
};
inline Render_Quad
get_render_quad(Glyph_Data *b, int pw, int ph, float xpos, float ypos){
get_render_quad(Glyph_Data *b, i32 pw, i32 ph, float xpos, float ypos){
Render_Quad q;
float ipw = 1.0f / pw, iph = 1.0f / ph;
@ -190,7 +190,7 @@ get_render_quad(Glyph_Data *b, int pw, int ph, float xpos, float ypos){
}
inline Render_Quad
get_exact_render_quad(Glyph_Data *b, int pw, int ph, float xpos, float ypos){
get_exact_render_quad(Glyph_Data *b, i32 pw, i32 ph, float xpos, float ypos){
Render_Quad q;
float ipw = 1.0f / pw, iph = 1.0f / ph;
@ -342,7 +342,7 @@ launch_rendering(Render_Target *target){
#undef ExtractStruct
internal void*
part_alloc(int size, void *context){
part_alloc(i32 size, void *context){
Partition *part = (Partition*)context;
void *result = push_block(part, size);
return(result);
@ -561,10 +561,10 @@ font_load_freetype(Partition *part,
rf->height -= rf->line_skip;
rf->line_skip = 0;
int max_glyph_w = face->size->metrics.x_ppem;
int max_glyph_h = rf->height;
int tex_width = 64;
int tex_height = 0;
i32 max_glyph_w = face->size->metrics.x_ppem;
i32 max_glyph_h = rf->height;
i32 tex_width = 64;
i32 tex_height = 0;
// estimate upper bound on texture width
do {
@ -576,8 +576,8 @@ font_load_freetype(Partition *part,
tex_height = next_pow_of_2(tex_height);
int pen_x = 0;
int pen_y = 0;
i32 pen_x = 0;
i32 pen_y = 0;
u32* pixels = push_array(part, u32, tex_width * tex_height);
memset(pixels, 0, tex_width * tex_height * sizeof(u32));
@ -597,11 +597,11 @@ font_load_freetype(Partition *part,
}
}
for(int i = 0; i < NUM_GLYPHS; ++i){
for(i32 i = 0; i < NUM_GLYPHS; ++i){
if(FT_Load_Char(face, i, FT_LOAD_RENDER | ft_extra_flags) != 0) continue;
int w = face->glyph->bitmap.width;
int h = face->glyph->bitmap.rows;
i32 w = face->glyph->bitmap.width;
i32 h = face->glyph->bitmap.rows;
// lcd filter produces RGB bitmaps, need to account for the extra components
if(use_lcd_filter){
@ -635,13 +635,13 @@ font_load_freetype(Partition *part,
rf->glyphs[i].exists = 1;
int pitch = face->glyph->bitmap.pitch;
i32 pitch = face->glyph->bitmap.pitch;
// write to texture atlas
for(int j = 0; j < h; ++j){
for(int i = 0; i < w; ++i){
int x = pen_x + i;
int y = pen_y + j;
for(i32 j = 0; j < h; ++j){
for(i32 i = 0; i < w; ++i){
i32 x = pen_x + i;
i32 y = pen_y + j;
if(use_lcd_filter){
#if 1

View File

@ -19,9 +19,9 @@ handle_zero(void){
return(result);
}
inline int
inline int32_t
handle_equal(Plat_Handle a, Plat_Handle b){
int result = (memcmp(&a, &b, sizeof(a)) == 0);
int32_t result = (memcmp(&a, &b, sizeof(a)) == 0);
return(result);
}

View File

@ -1,54 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 01.03.2016
*
* Templated code.
*
*/
// TOP
// NOTE(allen): This is an experiment, BUT remember a lot of people shit on templates.
// So if you start getting a wiff of stupidity from this back out immediately!
//
// experience 1: no badness, haven't seen any annoying template errors
// ...
template<typename T>
inline void
dll_init_sentinel(T *sentinel){
sentinel->next = sentinel;
sentinel->prev = sentinel;
}
template<typename T>
inline void
dll_insert(T *pos, T *v){
v->next = pos->next;
v->prev = pos;
pos->next = v;
v->next->prev = v;
}
template<typename T>
inline void
dll_insert_back(T *pos, T *v){
v->prev = pos->prev;
v->next = pos;
pos->prev = v;
v->prev->next = v;
}
template<typename T>
inline void
dll_remove(T *v){
v->next->prev = v->prev;
v->prev->next = v->next;
}
// for(dll_items(iterator, sentinel_ptr)){...}
#define dll_items(it, st) ((it) = (st)->next); ((it) != (st)); ((it) = (it)->next)
// BOTTOM

16
build.c
View File

@ -33,7 +33,7 @@
#endif
static char cmd[1024];
static int error_state = 0;
static int32_t error_state = 0;
#define systemf(...) do{\
int32_t n = snprintf(cmd, sizeof(cmd), __VA_ARGS__);\
@ -269,6 +269,20 @@ int main(int argc, char **argv){
#define META_DIR "../meta"
#define BUILD_DIR "../build"
#if 0
{
BEGIN_TIME_SECTION();
build(OPTS, cdir, "fsm_table_generator.cpp",
BUILD_DIR, "fsmgen", 0);
END_TIME_SECTION("build fsm generator");
}
{
BEGIN_TIME_SECTION();
execute(cdir, BUILD_DIR"/fsmgen");
END_TIME_SECTION("run fsm generator");
}
#endif
{
BEGIN_TIME_SECTION();
build(OPTS | DEBUG_INFO, cdir, "4ed_metagen.cpp",

View File

@ -9,11 +9,8 @@
/* TODO(allen):
Next Time:
Finish linking from one FSM to the next in the keyword recognizer.
1. Make sure each FSM follows the rules about state types correctly.
2. Make a look up table from final states to resulting token types.
1. Eliminate the complicated preprocessor directive parsing tables
2. Establish a clean systematic way of maintaining whatever is left
*/
@ -21,12 +18,18 @@ Finish linking from one FSM to the next in the keyword recognizer.
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdint.h>
#define ArrayCount(a) (sizeof(a)/sizeof(*a))
#include "../4cpp_lexer_types.h"
#include "4cpp_lexer_types.h"
#include "4cpp_lexer_fsms.h"
struct String_And_Flag{
char *str;
uint32_t flags;
};
static String_And_Flag preprop_strings[] = {
{"include", CPP_PP_INCLUDE},
{"INCLUDE", CPP_PP_INCLUDE},
@ -147,12 +150,12 @@ static String_And_Flag keyword_strings[] = {
{"thread_local", CPP_TOKEN_KEY_OTHER},
};
struct FSM_State{
unsigned int transition_rule[256];
unsigned char override;
};
typedef struct FSM_State{
uint32_t transition_rule[256];
uint8_t override;
} FSM_State;
struct FSM{
typedef struct FSM{
FSM_State *states;
unsigned short count, max;
@ -162,47 +165,47 @@ struct FSM{
unsigned char terminal_base;
char *comment;
};
} FSM;
struct FSM_Stack{
typedef struct FSM_Stack{
FSM *fsms;
int count, max;
int32_t count, max;
unsigned char table_transition_state;
unsigned char final_state;
};
uint8_t table_transition_state;
uint8_t final_state;
} FSM_Stack;
struct Match_Node{
typedef struct Match_Node{
Match_Node *first_child;
Match_Node *next_sibling;
int *words;
int count, max;
int index;
int32_t *words;
int32_t count, max;
int32_t index;
FSM_State *state;
};
} Match_Node;
struct Match_Tree{
typedef struct Match_Tree{
Match_Node *nodes;
int count, max;
};
int32_t count, max;
} Match_Tree;
struct Match_Tree_Stack{
typedef struct Match_Tree_Stack{
Match_Tree *trees;
int count, max;
};
int32_t count, max;
} Match_Tree_Stack;
struct Future_FSM{
typedef struct Future_FSM{
Match_Node *source;
};
} Future_FSM;
struct Future_FSM_Stack{
typedef struct Future_FSM_Stack{
Future_FSM *futures;
int count, max;
};
int32_t count, max;
} Future_FSM_Stack;
FSM*
static FSM*
get_fsm(FSM_Stack *stack){
FSM* result = 0;
assert(stack->count < stack->max);
@ -211,7 +214,7 @@ get_fsm(FSM_Stack *stack){
return(result);
}
Match_Tree*
static Match_Tree*
get_tree(Match_Tree_Stack *stack){
Match_Tree* result = 0;
assert(stack->count < stack->max);
@ -219,10 +222,10 @@ get_tree(Match_Tree_Stack *stack){
return(result);
}
FSM
fsm_init(unsigned short max, unsigned char terminal_base){
static FSM
fsm_init(uint16_t max, uint8_t terminal_base){
FSM fsm;
int memsize;
int32_t memsize;
fsm.max = max;
fsm.count = 0;
memsize = sizeof(FSM_State)*fsm.max;
@ -238,18 +241,18 @@ fsm_init(unsigned short max, unsigned char terminal_base){
return(fsm);
}
void
static void
fsm_add_comment(FSM *fsm, char *str){
int comment_len;
int str_len;
int32_t comment_len;
int32_t str_len;
char *new_comment;
str_len = (int)strlen(str);
str_len = (int32_t)strlen(str);
if (fsm->comment != 0){
comment_len = (int)strlen(fsm->comment);
comment_len = (int32_t)strlen(fsm->comment);
new_comment = (char*)malloc(str_len + comment_len + 1);
memcpy(new_comment, fsm->comment, comment_len);
memcpy(new_comment + comment_len, str, str_len);
new_comment[comment_len + str_len] = 0;
@ -264,10 +267,10 @@ fsm_add_comment(FSM *fsm, char *str){
}
}
Match_Tree
tree_init(unsigned short max){
static Match_Tree
tree_init(uint16_t max){
Match_Tree tree;
int memsize;
int32_t memsize;
tree.max = max;
tree.count = 0;
memsize = sizeof(Match_Node)*tree.max;
@ -275,19 +278,19 @@ tree_init(unsigned short max){
return(tree);
}
unsigned char
static uint8_t
push_future_fsm(Future_FSM_Stack *stack, Match_Node *node){
unsigned char index = 0;
uint8_t index = 0;
Future_FSM *future = 0;
assert(stack->count < stack->max);
assert(stack->max < 256);
index = (unsigned char)(stack->count++);
index = (uint8_t)(stack->count++);
future = &stack->futures[index];
future->source = node;
return(index);
}
Match_Node*
static Match_Node*
match_get_node(Match_Tree *tree){
Match_Node *result;
assert(tree->count < tree->max);
@ -295,33 +298,33 @@ match_get_node(Match_Tree *tree){
return(result);
}
void
match_init_node(Match_Node *node, int match_count){
static void
match_init_node(Match_Node *node, int32_t match_count){
*node = {};
node->words = (int*)malloc(sizeof(int)*match_count);
node->words = (int32_t*)malloc(sizeof(int32_t)*match_count);
node->max = match_count;
}
void
static void
match_copy_init_node(Match_Node *node, Match_Node *source){
*node = {};
node->max = source->count;
node->count = source->count;
node->words = (int*)malloc(sizeof(int)*source->count);
node->words = (int32_t*)malloc(sizeof(int32_t)*source->count);
node->index = source->index;
memcpy(node->words, source->words, sizeof(int)*source->count);
memcpy(node->words, source->words, sizeof(int32_t)*source->count);
}
void
match_add_word(Match_Node *node, int word){
static void
match_add_word(Match_Node *node, int32_t word){
assert(node->count < node->max);
node->words[node->count++] = word;
}
FSM_State*
fsm_get_state(FSM *fsm, unsigned int terminal_base){
static FSM_State*
fsm_get_state(FSM *fsm, uint32_t terminal_base){
FSM_State *result;
unsigned short i;
uint16_t i;
assert(fsm->count < fsm->max);
result = &fsm->states[fsm->count++];
for (i = 0; i < 256; ++i){
@ -331,13 +334,13 @@ fsm_get_state(FSM *fsm, unsigned int terminal_base){
return(result);
}
FSM_State*
static FSM_State*
fsm_get_state(FSM *fsm){
FSM_State *result = fsm_get_state(fsm, fsm->terminal_base);
return(result);
}
FSM_State*
static FSM_State*
fsm_get_term_state(FSM *fsm, unsigned char override){
FSM_State *result;
assert(fsm->term_count < fsm->term_max);
@ -346,52 +349,52 @@ fsm_get_term_state(FSM *fsm, unsigned char override){
return(result);
}
unsigned char
static uint8_t
fsm_index(FSM *fsm, FSM_State *s){
unsigned char result;
result = (unsigned char)(unsigned long long)(s - fsm->states);
uint8_t result;
result = (uint8_t)(uint64_t)(s - fsm->states);
if (s->override){
result = fsm->terminal_base + s->override;
}
return(result);
}
void
static void
fsm_add_transition(FSM_State *state, char c, unsigned char dest){
state->transition_rule[c] = dest;
}
struct Terminal_Lookup_Table{
unsigned int state_to_type[60];
unsigned char type_to_state[CPP_TOKEN_TYPE_COUNT];
unsigned char state_count;
uint32_t state_to_type[60];
uint8_t type_to_state[CPP_TOKEN_TYPE_COUNT];
uint8_t state_count;
};
void
static void
process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, FSM *fsm){
int next_index = node->index + 1;
int match_count = node->count;
int32_t next_index = node->index + 1;
int32_t match_count = node->count;
FSM_State *this_state = node->state;
unsigned char terminal_base = fsm->terminal_base;
uint8_t terminal_base = fsm->terminal_base;
int i, j, *words = node->words;
int32_t i, j, *words = node->words;
String_And_Flag saf;
int l;
int32_t l;
char c;
Match_Node *next_nodes[256];
Match_Node *newest_child = 0;
Match_Node *n;
unsigned char unjunkify = 0;
uint8_t unjunkify = 0;
memset(next_nodes, 0, sizeof(next_nodes));
for (i = 0; i < match_count; ++i){
j = words[i];
saf = input[j];
l = (int)strlen(saf.str);
l = (int32_t)strlen(saf.str);
if (next_index < l){
c = saf.str[next_index];
@ -436,13 +439,13 @@ process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, F
}
}
FSM
static FSM
generate_pp_directive_fsm(){
Match_Tree tree;
FSM fsm;
Match_Node *root_node;
FSM_State *root_state;
int i;
int32_t i;
fsm = fsm_init(200, 200);
tree = tree_init(200);
@ -480,9 +483,9 @@ Each state needs a full set of transition rules. Most transitions should go int
#define RealTerminateBase 65536
int
static int32_t
char_is_alphanumeric(char x){
int result = 0;
int32_t result = 0;
if ((x >= '0' && x <= '9') ||
(x >= 'A' && x <= 'Z') ||
(x >= 'a' && x <= 'z') ||
@ -492,20 +495,20 @@ char_is_alphanumeric(char x){
return(result);
}
void
static void
process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, FSM *fsm,
Terminal_Lookup_Table *terminal_table, int levels_to_go,
Terminal_Lookup_Table *terminal_table, int32_t levels_to_go,
Future_FSM_Stack *unfinished_fsms){
int next_index = node->index + 1;
int match_count = node->count;
int *words = node->words;
int32_t next_index = node->index + 1;
int32_t match_count = node->count;
int32_t *words = node->words;
FSM_State *this_state = node->state;
int word_index = 0;
int good_transition = 0;
int len = 0;
int i = 0;
int32_t word_index = 0;
int32_t good_transition = 0;
int32_t len = 0;
int32_t i = 0;
String_And_Flag saf = {0};
@ -514,15 +517,15 @@ process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, F
Match_Node *n = 0;
char c = 0;
unsigned char override = 0;
uint8_t override = 0;
memset(next_nodes, 0, sizeof(next_nodes));
for (i = 0; i < match_count; ++i){
word_index = words[i];
saf = input[word_index];
len = (int)strlen(saf.str);
len = (int32_t)strlen(saf.str);
if (next_index < len){
c = saf.str[next_index];
@ -1041,73 +1044,73 @@ main_fsm(Lex_FSM fsm, unsigned char pp_state, unsigned char c){
return(fsm);
}
void
static void
begin_table(FILE *file, char *type, char *group_name, char *table_name){
fprintf(file, "unsigned %s %s_%s[] = {\n", type, group_name, table_name);
fprintf(file, "%s %s_%s[] = {\n", type, group_name, table_name);
}
void
static void
begin_table(FILE *file, char *type, char *table_name){
fprintf(file, "unsigned %s %s[] = {\n", type, table_name);
fprintf(file, "%s %s[] = {\n", type, table_name);
}
void
static void
begin_ptr_table(FILE *file, char *type, char *table_name){
fprintf(file, "unsigned %s * %s[] = {\n", type, table_name);
fprintf(file, "%s * %s[] = {\n", type, table_name);
}
void
do_table_item(FILE *file, unsigned short item){
fprintf(file, "%2d,", (int)item);
static void
do_table_item(FILE *file, uint16_t item){
fprintf(file, "%2d,", (int32_t)item);
}
void
static void
do_table_item_direct(FILE *file, char *item, char *tail){
fprintf(file, "%s%s,", item, tail);
}
void
static void
end_row(FILE *file){
fprintf(file, "\n");
}
void
static void
end_table(FILE *file){
fprintf(file, "};\n\n");
}
struct FSM_Tables{
unsigned char *full_transition_table;
unsigned char *marks;
unsigned char *eq_class;
unsigned char *eq_class_rep;
unsigned char *reduced_transition_table;
typedef struct FSM_Tables{
uint8_t *full_transition_table;
uint8_t *marks;
uint8_t *eq_class;
uint8_t *eq_class_rep;
uint8_t *reduced_transition_table;
uint8_t eq_class_counter;
uint16_t state_count;
} FSM_Tables;
unsigned char eq_class_counter;
unsigned short state_count;
};
void
allocate_full_tables(FSM_Tables *table, unsigned char state_count){
table->full_transition_table = (unsigned char*)malloc(state_count * 256);
table->marks = (unsigned char*)malloc(state_count * 256);
table->eq_class = (unsigned char*)malloc(state_count * 256);
table->eq_class_rep = (unsigned char*)malloc(state_count * 256);
static void
allocate_full_tables(FSM_Tables *table, uint8_t state_count){
table->full_transition_table = (uint8_t*)malloc(state_count * 256);
table->marks = (uint8_t*)malloc(state_count * 256);
table->eq_class = (uint8_t*)malloc(state_count * 256);
table->eq_class_rep = (uint8_t*)malloc(state_count * 256);
table->state_count = state_count;
memset(table->marks, 0, 256);
}
void
do_table_reduction(FSM_Tables *table, unsigned short state_count){
static void
do_table_reduction(FSM_Tables *table, uint16_t state_count){
{
table->eq_class_counter = 0;
unsigned char *c_line = table->full_transition_table;
for (unsigned short c = 0; c < 256; ++c){
uint8_t *c_line = table->full_transition_table;
for (uint16_t c = 0; c < 256; ++c){
if (table->marks[c] == 0){
table->eq_class[c] = table->eq_class_counter;
table->eq_class_rep[table->eq_class_counter] = (unsigned char)c;
unsigned char *c2_line = c_line + state_count;
for (unsigned short c2 = c + 1; c2 < 256; ++c2){
table->eq_class_rep[table->eq_class_counter] = (uint8_t)c;
uint8_t *c2_line = c_line + state_count;
for (uint16_t c2 = c + 1; c2 < 256; ++c2){
if (memcmp(c_line, c2_line, state_count) == 0){
table->marks[c2] = 1;
table->eq_class[c2] = table->eq_class_counter;
@ -1119,102 +1122,102 @@ do_table_reduction(FSM_Tables *table, unsigned short state_count){
c_line += state_count;
}
}
table->reduced_transition_table = (unsigned char*)malloc(state_count * table->eq_class_counter);
table->reduced_transition_table = (uint8_t*)malloc(state_count * table->eq_class_counter);
{
unsigned char *r_line = table->reduced_transition_table;
for (unsigned short eq = 0; eq < table->eq_class_counter; ++eq){
unsigned char *u_line = table->full_transition_table + state_count * table->eq_class_rep[eq];
uint8_t *r_line = table->reduced_transition_table;
for (uint16_t eq = 0; eq < table->eq_class_counter; ++eq){
uint8_t *u_line = table->full_transition_table + state_count * table->eq_class_rep[eq];
memcpy(r_line, u_line, state_count);
r_line += state_count;
}
}
}
FSM_Tables
static FSM_Tables
generate_whitespace_skip_table(){
unsigned char state_count = LSPP_count;
uint8_t state_count = LSPP_count;
FSM_Tables table;
allocate_full_tables(&table, state_count);
int i = 0;
int32_t i = 0;
Whitespace_FSM wfsm = {0};
Whitespace_FSM new_wfsm;
for (unsigned short c = 0; c < 256; ++c){
for (unsigned char state = 0; state < state_count; ++state){
for (uint16_t c = 0; c < 256; ++c){
for (uint8_t state = 0; state < state_count; ++state){
wfsm.pp_state = state;
wfsm.white_done = 0;
new_wfsm = whitespace_skip_fsm(wfsm, (unsigned char)c);
new_wfsm = whitespace_skip_fsm(wfsm, (uint8_t)c);
table.full_transition_table[i++] = new_wfsm.pp_state + state_count*new_wfsm.white_done;
}
}
do_table_reduction(&table, state_count);
return(table);
}
FSM_Tables
static FSM_Tables
generate_int_table(){
unsigned char state_count = LSINT_count;
uint8_t state_count = LSINT_count;
FSM_Tables table;
allocate_full_tables(&table, state_count);
int i = 0;
int32_t i = 0;
Lex_FSM fsm = {0};
Lex_FSM new_fsm;
for (unsigned short c = 0; c < 256; ++c){
for (unsigned char state = 0; state < state_count; ++state){
for (uint16_t c = 0; c < 256; ++c){
for (uint8_t state = 0; state < state_count; ++state){
fsm.int_state = state;
fsm.emit_token = 0;
new_fsm = int_fsm(fsm, (unsigned char)c);
new_fsm = int_fsm(fsm, (uint8_t)c);
table.full_transition_table[i++] = new_fsm.int_state + state_count*new_fsm.emit_token;
}
}
do_table_reduction(&table, state_count);
return(table);
}
FSM_Tables
generate_fsm_table(unsigned char pp_state){
unsigned char state_count = LS_count;
static FSM_Tables
generate_fsm_table(uint8_t pp_state){
uint8_t state_count = LS_count;
FSM_Tables table;
allocate_full_tables(&table, state_count);
int i = 0;
int32_t i = 0;
Lex_FSM fsm = {0};
Lex_FSM new_fsm;
for (unsigned short c = 0; c < 256; ++c){
for (unsigned char state = 0; state < state_count; ++state){
for (uint16_t c = 0; c < 256; ++c){
for (uint8_t state = 0; state < state_count; ++state){
fsm.state = state;
fsm.emit_token = 0;
new_fsm = main_fsm(fsm, pp_state, (unsigned char)c);
new_fsm = main_fsm(fsm, pp_state, (uint8_t)c);
table.full_transition_table[i++] = new_fsm.state + state_count*new_fsm.emit_token;
}
}
do_table_reduction(&table, state_count);
return(table);
}
void
static void
render_fsm_table(FILE *file, FSM_Tables tables, char *group_name){
begin_table(file, "short", group_name, "eq_classes");
for (unsigned short c = 0; c < 256; ++c){
begin_table(file, "uint16_t", group_name, "eq_classes");
for (uint16_t c = 0; c < 256; ++c){
do_table_item(file, tables.eq_class[c]*tables.state_count);
}
end_row(file);
end_table(file);
fprintf(file, "const int num_%s_eq_classes = %d;\n\n", group_name, tables.eq_class_counter);
int i = 0;
begin_table(file, "char", group_name, "table");
for (unsigned short c = 0; c < tables.eq_class_counter; ++c){
for (unsigned char state = 0; state < tables.state_count; ++state){
fprintf(file, "const int32_t num_%s_eq_classes = %d;\n\n", group_name, tables.eq_class_counter);
int32_t i = 0;
begin_table(file, "uint8_t", group_name, "table");
for (uint16_t c = 0; c < tables.eq_class_counter; ++c){
for (uint8_t state = 0; state < tables.state_count; ++state){
do_table_item(file, tables.reduced_transition_table[i++]);
}
end_row(file);
@ -1222,22 +1225,22 @@ render_fsm_table(FILE *file, FSM_Tables tables, char *group_name){
end_table(file);
}
void
render_variable(FILE *file, char *type, char *variable, unsigned int x){
static void
render_variable(FILE *file, char *type, char *variable, uint32_t x){
fprintf(file, "%s %s = %d;\n\n", type, variable, x);
}
void
static void
render_comment(FILE *file, char *comment){
fprintf(file, "/*\n%s*/\n", comment);
}
struct PP_Names{
unsigned char pp_state;
typedef struct PP_Names{
uint8_t pp_state;
char *name;
};
} PP_Names;
PP_Names pp_names[] = {
static PP_Names pp_names[] = {
{LSPP_default, "main_fsm"},
{LSPP_include, "pp_include_fsm"},
{LSPP_macro_identifier, "pp_macro_fsm"},
@ -1249,25 +1252,25 @@ PP_Names pp_names[] = {
{LSPP_junk, "pp_junk_fsm"},
};
FSM_Tables
generate_table_from_abstract_fsm(FSM fsm, unsigned char real_term_base){
unsigned char state_count = (unsigned char)fsm.count;
static FSM_Tables
generate_table_from_abstract_fsm(FSM fsm, uint8_t real_term_base){
uint8_t state_count = (uint8_t )fsm.count;
FSM_Tables table;
allocate_full_tables(&table, state_count);
int i = 0;
unsigned int new_state;
for (unsigned short c = 0; c < 256; ++c){
for (unsigned char state = 0; state < state_count; ++state){
int32_t i = 0;
uint32_t new_state;
for (uint16_t c = 0; c < 256; ++c){
for (uint8_t state = 0; state < state_count; ++state){
new_state = fsm.states[state].transition_rule[c];
if (new_state >= RealTerminateBase){
new_state = new_state - RealTerminateBase + real_term_base;
}
table.full_transition_table[i++] = (unsigned char)new_state;
table.full_transition_table[i++] = (uint8_t)new_state;
}
}
do_table_reduction(&table, state_count);
return(table);
@ -1284,28 +1287,28 @@ main(){
FSM_Tables itables = generate_int_table();
render_fsm_table(file, itables, "int_fsm");
begin_table(file, "char", "multiline_state_table");
for (unsigned char state = 0; state < LS_count; ++state){
begin_table(file, "uint8_t", "multiline_state_table");
for (uint8_t state = 0; state < LS_count; ++state){
do_table_item(file, (state == LS_string_multiline || state == LS_char_multiline));
}
end_row(file);
end_table(file);
for (int i = 0; i < ArrayCount(pp_names); ++i){
for (int32_t i = 0; i < ArrayCount(pp_names); ++i){
assert(i == pp_names[i].pp_state);
FSM_Tables tables = generate_fsm_table(pp_names[i].pp_state);
render_fsm_table(file, tables, pp_names[i].name);
}
begin_ptr_table(file, "short", "get_eq_classes");
for (int i = 0; i < ArrayCount(pp_names); ++i){
begin_ptr_table(file, "uint16_t", "get_eq_classes");
for (int32_t i = 0; i < ArrayCount(pp_names); ++i){
do_table_item_direct(file, pp_names[i].name, "_eq_classes");
end_row(file);
}
end_table(file);
begin_ptr_table(file, "char", "get_table");
for (int i = 0; i < ArrayCount(pp_names); ++i){
begin_ptr_table(file, "uint8_t", "get_table");
for (int32_t i = 0; i < ArrayCount(pp_names); ++i){
do_table_item_direct(file, pp_names[i].name, "_table");
end_row(file);
}
@ -1315,10 +1318,10 @@ main(){
FSM_Tables pp_directive_tables = generate_table_from_abstract_fsm(pp_directive_fsm, 0);
render_fsm_table(file, pp_directive_tables, "pp_directive");
render_variable(file, "unsigned char", "LSDIR_default", 0);
render_variable(file, "unsigned char", "LSDIR_count", pp_directive_fsm.count);
render_variable(file, "unsigned char", "pp_directive_terminal_base", pp_directive_fsm.terminal_base);
render_variable(file, "uint8_t", "LSDIR_default", 0);
render_variable(file, "uint8_t", "LSDIR_count", pp_directive_fsm.count);
render_variable(file, "uint8_t", "pp_directive_terminal_base", pp_directive_fsm.terminal_base);
fclose(file);
return(0);
}

View File

@ -170,7 +170,7 @@ DOC_EXPORT /* DOC(This macro takes a local char array with a fixed width and use
an empty String with the correct size and memory size to operate on the array.) */
#define make_fixed_width_string(s) (make_string_cap((char*)(s), 0, sizeof(s)))
DOC_EXPORT /* DOC(This macro is a helper for any calls that take a char*,int pair to specify a
DOC_EXPORT /* DOC(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.) */
#define expand_str(s) ((s).str), ((s).size)
@ -227,7 +227,7 @@ skip_whitespace(String str)
Like other substr calls, the new string uses the underlying memory and so should usually be
considered immutable.) DOC_SEE(substr) */{
String result = {0};
int i = 0;
int32_t i = 0;
for (; i < str.size && char_is_whitespace(str.str[i]); ++i);
result = substr(str, i, str.size - i);
return(result);
@ -239,7 +239,7 @@ chop_whitespace(String str)
Like other substr calls, the new string uses the underlying memory and so should usually be
considered immutable.) DOC_SEE(substr) */{
String result = {0};
int i = str.size;
int32_t i = str.size;
for (; i > 0 && char_is_whitespace(str.str[i-1]); --i);
result = substr(str, 0, i);
return(result);
@ -1452,13 +1452,13 @@ DOC(This call interprets s as a color and writes the 32-bit integer representati
uint32_t color = 0;
if (s.size == 6){
result = 1;
color = (unsigned int)hexstr_to_int(s);
color = (uint32_t)hexstr_to_int(s);
color |= (0xFF << 24);
*out = color;
}
else if (s.size == 8){
result = 1;
color = (unsigned int)hexstr_to_int(s);
color = (uint32_t)hexstr_to_int(s);
*out = color;
}
return(result);

View File

@ -43,9 +43,9 @@ CUSTOM_COMMAND_SIG(load_lots_of_files){
String str = make_fixed_width_string(space);
append_ss(&str, make_lit_string(LOTS_OF_FILES));
append_s_char(&str, '/');
int size = str.size;
int32_t size = str.size;
for (int i = 0; i < list.count; ++i, ++info){
for (int32_t i = 0; i < list.count; ++i, ++info){
if (!info->folder){
append_ss(&str, make_string(info->filename, info->filename_len));
Buffer_Summary buffer = app->create_buffer(app, str.str, str.size,

View File

@ -1,6 +1,6 @@
struct Custom_Vars{
int initialized;
int32_t initialized;
Partition part;
};
@ -9,13 +9,13 @@ enum View_Mode{
};
struct View_Vars{
int id;
int32_t id;
View_Mode mode;
GUI_Scroll_Vars scroll;
i32_Rect scroll_region;
int buffer_id;
int32_t buffer_id;
};
inline View_Vars
view_vars_zero(){
@ -24,12 +24,12 @@ view_vars_zero(){
}
extern "C" void
view_routine(Application_Links *app, int view_id){
view_routine(Application_Links *app, int32_t view_id){
Custom_Vars *vars = (Custom_Vars*)app->memory;
View_Vars view = {0};
view.id = view_id;
int show_scrollbar = 1;
int32_t show_scrollbar = 1;
if (!vars->initialized){
vars->initialized = 1;

View File

@ -12,6 +12,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <stdint.h>
char *header =
"Distribution Date: %d.%d.%d (dd.mm.yyyy)\n"
@ -25,13 +26,13 @@ char *header =
;
typedef struct Readme_Variables{
int day, month, year;
int32_t day, month, year;
} Readme_Variables;
typedef struct File_Data{
char *data;
int size;
int file_exists;
int32_t size;
int32_t file_exists;
} File_Data;
File_Data

View File

@ -6,7 +6,7 @@
* Application layer for project codename "4ed"
*
*/
// TOP
#include "4ed_meta.h"
@ -17,7 +17,7 @@ i32
compare(char *a, char *b, i32 len){
i32 result;
char *e;
result = 0;
e = a + len;
for (;a < e && *a == *b; ++a, ++b);
@ -25,7 +25,7 @@ compare(char *a, char *b, i32 len){
if (*a < *b) result = -1;
else result = 1;
}
return(result);
}
@ -37,7 +37,7 @@ Data
load_file(char *filename){
Data result;
FILE * file;
result = {};
file = fopen(filename, "rb");
if (!file){
@ -63,11 +63,11 @@ show_reloc_block(Data file, DLL_Data *dll, PE_Section_Definition *reloc_section)
u32 cursor;
u32 bytes_in_table;
u32 block_end;
base = file.data + reloc_section->disk_location;
if (dll->is_64bit) bytes_in_table = dll->opt_header_64->data_directory[image_dir_base_reloc_table].size;
else bytes_in_table = dll->opt_header_32->data_directory[image_dir_base_reloc_table].size;
for (cursor = 0; cursor < bytes_in_table;){
header = (Relocation_Block_Header*)(base + cursor);
block_end = cursor + header->block_size;
@ -86,7 +86,7 @@ show_reloc_block(Data file, DLL_Data *dll, PE_Section_Definition *reloc_section)
}
}
typedef int (Function)(int a, int b);
typedef int32_t (Function)(int a, int b);
#include <Windows.h>
@ -104,9 +104,9 @@ main(int argc, char **argv){
printf("usage: dll_reader <dll-file>\n");
exit(1);
}
module = LoadLibraryA(argv[1]);
if (!module){
printf("failed to load file %s\n", argv[1]);
exit(1);
@ -126,9 +126,9 @@ main(int argc, char **argv){
printf("usage: dll_reader <dll-file>\n");
exit(1);
}
file = load_file(argv[1]);
if (!file.data){
printf("failed to load file %s\n", argv[1]);
exit(1);
@ -140,7 +140,7 @@ main(int argc, char **argv){
}
printf("this appears to be a dll\n");
printf("symbol-count: %d symbol-addr: %d\n",
dll.coff_header->number_of_symbols,
dll.coff_header->pointer_to_symbol_table);
@ -149,7 +149,7 @@ main(int argc, char **argv){
else printf("32bit\n");
printf("built for machine: %s\n", dll_machine_type_str(dll.coff_header->machine, 0));
if (dll.is_64bit){
printf("number of directories: %d\n", dll.opt_header_64->number_of_rva_and_sizes);
}
@ -158,7 +158,7 @@ main(int argc, char **argv){
}
printf("\nbeginning section decode now\n");
section_def = dll.section_defs;
for (i = 0; i < dll.coff_header->number_of_sections; ++i, ++section_def){
if (section_def->name[7] == 0){
@ -170,12 +170,12 @@ main(int argc, char **argv){
printf("img-size: %d img-loc: %d\ndisk-size: %d disk-loc: %d\n",
section_def->loaded_size, section_def->loaded_location,
section_def->disk_size, section_def->disk_location);
if (compare(section_def->name, ".reloc", 6) == 0){
show_reloc_block(file, &dll, section_def);
}
}
img.size = dll_total_loaded_size(&dll);
printf("image size: %d\n", img.size);
@ -184,7 +184,7 @@ main(int argc, char **argv){
MEM_COMMIT | MEM_RESERVE,
PAGE_READWRITE);
dll_load(img, &dll_loaded, file, &dll);
DWORD _extra;
VirtualProtect(img.data + dll_loaded.text_start,
dll_loaded.text_size,

View File

@ -15,13 +15,13 @@
# include "4coder_default_bindings.cpp"
#endif
#include "4ed_meta.h"
#define FSTRING_IMPLEMENTATION
#define FSTRING_C
#include "4coder_string.h"
#include "4ed_math.cpp"
#include "4ed_meta.h"
#include "4ed_math.h"
#include "4ed_system.h"
#include "4ed_rendering.h"
@ -31,31 +31,22 @@
#include <GL/gl.h>
#include <GL/glext.h>
#include "filetrack/4tech_file_track.h"
#include "filetrack/4tech_file_track_win32.c"
#include "system_shared.h"
#define SUPPORT_DPI 1
#define USE_WIN32_FONTS 0
#define USE_FT_FONTS 1
#define FPS 60
#define frame_useconds (1000000 / FPS)
#define WM_4coder_ANIMATE (WM_USER + 1)
#define WM_4coder_ANIMATE (WM_USER + 0)
//
// Win32_Vars structs
//
#if FRED_INTERNAL
struct Debug_Log_Entry{
u64 time;
i64 message;
};
#endif
struct Thread_Context{
u32 job_id;
b32 running;
@ -78,13 +69,6 @@ struct Thread_Group{
i32 cancel_cv0;
};
#define UseWinDll 1
#if UseWinDll == 0
#include "4ed_dll_reader.h"
#include "4ed_dll_reader.cpp"
#endif
struct Control_Keys{
b8 l_ctrl;
b8 r_ctrl;
@ -127,7 +111,7 @@ struct Win32_Input_Chunk{
struct Win32_Coroutine{
Coroutine coroutine;
Win32_Coroutine *next;
int done;
i32 done;
};
#if FRED_INTERNAL
@ -158,13 +142,8 @@ struct Win32_Vars{
System_Functions system;
App_Functions app;
Custom_API custom_api;
#if UseWinDll
HMODULE app_code;
HMODULE custom;
#else
DLL_Loaded app_dll;
DLL_Loaded custom_dll;
#endif
Plat_Settings settings;
@ -1627,8 +1606,6 @@ internal b32
Win32LoadAppCode(){
b32 result = 0;
App_Get_Functions *get_funcs = 0;
#if UseWinDll
win32vars.app_code = LoadLibraryA("4ed_app.dll");
if (win32vars.app_code){
@ -1636,44 +1613,6 @@ Win32LoadAppCode(){
GetProcAddress(win32vars.app_code, "app_get_functions");
}
#else
File_Data file = system_load_file("4ed_app.dll");
if (file.got_file){
i32 error;
DLL_Data dll_data;
if (dll_parse_headers(file.data, &dll_data, &error)){
Data img;
img.size = dll_total_loaded_size(&dll_data);
img.data = (byte*)
VirtualAlloc((LPVOID)Tbytes(3), img.size,
MEM_COMMIT | MEM_RESERVE,
PAGE_READWRITE);
dll_load(img, &win32vars.app_dll, file.data, &dll_data);
DWORD extra_;
VirtualProtect(img.data + win32vars.app_dll.text_start,
win32vars.app_dll.text_size,
PAGE_EXECUTE_READ,
&extra_);
get_funcs = (App_Get_Functions*)
dll_load_function(&win32vars.app_dll, "app_get_functions", 17);
}
else{
// TODO(allen): file loading error
}
Win32FreeMemory(file.data.data);
}
else{
// TODO(allen): file loading error
}
#endif
if (get_funcs){
result = 1;
win32vars.app = get_funcs();
@ -2085,7 +2024,7 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
win32vars.input_chunk.pers.mouse_r = 0;
b8 *control_keys = win32vars.input_chunk.pers.control_keys;
for (int i = 0; i < MDFR_INDEX_COUNT; ++i) control_keys[i] = 0;
for (i32 i = 0; i < MDFR_INDEX_COUNT; ++i) control_keys[i] = 0;
win32vars.input_chunk.pers.controls = control_keys_zero();
}break;
@ -2149,7 +2088,7 @@ WinMain(HINSTANCE hInstance,
LPSTR lpCmdLine,
int nCmdShow){
int argc = __argc;
i32 argc = __argc;
char **argv = __argv;
memset(&win32vars, 0, sizeof(win32vars));

View File

@ -63,7 +63,7 @@ DOC(TODO)
}
API_EXPORT bool32
File_Exists(Application_Links *app, char *filename, int len)/*
File_Exists(Application_Links *app, char *filename, int32_t len)/*
DOC_PARAM(filename, This parameter specifies the full path to a file; it need not be null terminated.)
DOC_PARAM(len, This parameter specifies the length of the filename string.)
DOC_RETURN(This call returns non-zero if and only if the file exists.)
@ -91,7 +91,7 @@ DOC_RETURN(This call returns non-zero if and only if the file exists.)
}
API_EXPORT bool32
Directory_CD(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)/*
Directory_CD(Application_Links *app, char *dir, int32_t *len, int32_t capacity, char *rel_path, int32_t rel_len)/*
DOC_PARAM(dir, This parameter provides a character buffer that stores a directory; it need not be null terminated.)
DOC_PARAM(len, This parameter specifies the length of the dir string.)
DOC_PARAM(capacity, This parameter specifies the maximum size of the dir string.)