union Generic_Command {
diff --git a/4coder_types.h b/4coder_types.h
index e2d88aac..3a4cf296 100644
--- a/4coder_types.h
+++ b/4coder_types.h
@@ -1,7 +1,6 @@
#define ENUM(type,name) typedef type name; enum name##_
-#define FLAGENUM(name) typedef uint32_t name; enum name##_
/* DOC(bool32 is an alias name to signal that an integer parameter or field is for
true/false vales.) */
@@ -37,7 +36,7 @@ ENUM(int32_t, Key_Modifier){
/* DOC(A Key_Modifier_Flag field is used to specify a specific state of modifiers.
Flags can be combined with bit or to specify a state with multiple modifiers.) */
-FLAGENUM(Key_Modifier_Flag){
+ENUM(uint32_t, Key_Modifier_Flag){
/* DOC(MDFR_NONE specifies that no modifiers are pressed.) */
MDFR_NONE = 0x0,
MDFR_CTRL = 0x1,
@@ -91,7 +90,7 @@ ENUM(uint64_t, Command_ID){
};
/* DOC(TODO) */
-FLAGENUM(Memory_Protect_Flags){
+ENUM(uint32_t, Memory_Protect_Flags){
/* DOC(TODO) */
MemProtect_Read = 0x1,
/* DOC(TODO) */
@@ -183,7 +182,7 @@ ENUM(int32_t, View_Setting_ID){
};
/* DOC(A Buffer_Create_Flag field specifies how a buffer should be created.) */
-FLAGENUM(Buffer_Create_Flag){
+ENUM(uint32_t, Buffer_Create_Flag){
/* DOC(BufferCreate_Background is not currently implemented.) */
BufferCreate_Background = 0x1,
/* DOC(When BufferCreate_AlwaysNew is set it indicates the buffer should be
@@ -195,7 +194,7 @@ FLAGENUM(Buffer_Create_Flag){
};
/* DOC(A Buffer_Kill_Flag field specifies how a buffer should be killed.) */
-FLAGENUM(Buffer_Kill_Flag){
+ENUM(uint32_t, Buffer_Kill_Flag){
/* DOC(BufferKill_Background is not currently implemented.) */
BufferKill_Background = 0x1,
/* DOC(When BufferKill_AlwaysKill is set it indicates the buffer should be killed
@@ -209,7 +208,7 @@ access call. An access call is usually one the returns a summary struct. If a
not set in the access field, that 4coder object is hidden. On the other hand if
a protection flag is set in the access parameter and the object does not have
that protection flag, the object is still returned from the access call.) TODO */
-FLAGENUM(Access_Flag){
+ENUM(uint32_t, Access_Flag){
/* DOC(AccessOpen does not include any bits, it indicates that the access should
only return objects that have no protection flags set.) */
AccessOpen = 0x0,
@@ -227,7 +226,7 @@ FLAGENUM(Access_Flag){
/* DOC(A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the
beginning or end of different types of words.) */
-FLAGENUM(Seek_Boundary_Flag){
+ENUM(uint32_t, Seek_Boundary_Flag){
BoundaryWhitespace = 0x1,
BoundaryToken = 0x2,
BoundaryAlphanumeric = 0x4,
@@ -235,7 +234,7 @@ FLAGENUM(Seek_Boundary_Flag){
};
/* DOC(A Command_Line_Input_Flag field specifies the behavior of a call to a command line interface.) */
-FLAGENUM(Command_Line_Input_Flag){
+ENUM(uint32_t, Command_Line_Input_Flag){
/* DOC(If CLI_OverlapWithConflict is set if output buffer of the new command is already
in use by another command which is still executing, the older command relinquishes control
of the buffer and both operate simultaneously with only the newer command outputting to
@@ -250,7 +249,7 @@ FLAGENUM(Command_Line_Input_Flag){
};
/* DOC(An Auto_Indent_Flag field specifies the behavior of an auto indentation operation.) */
-FLAGENUM(Auto_Indent_Flag){
+ENUM(uint32_t, Auto_Indent_Flag){
/* DOC(If AutoIndent_ClearLine is set, then any line that is only whitespace will
be cleared to contain nothing at all. otherwise the line is filled with whitespace
to match the nearby indentation.) */
@@ -262,7 +261,7 @@ FLAGENUM(Auto_Indent_Flag){
};
/* DOC(A Set_Buffer_Flag field specifies the behavior of an operation that sets the buffer of a view.) */
-FLAGENUM(Set_Buffer_Flag){
+ENUM(uint32_t, Set_Buffer_Flag){
/* DOC(If SetBuffer_KeepOriginalGUI then when the file is set, the view will not switch to it
if some other GUI was currently up, otherwise any GUI that is up is closed and the view
switches to the file.) */
@@ -270,7 +269,7 @@ FLAGENUM(Set_Buffer_Flag){
};
/* DOC(A Input_Type_Flag field specifies a set of input event types.) */
-FLAGENUM(Input_Type_Flag){
+ENUM(uint32_t, Input_Type_Flag){
/* DOC(If EventOnAnyKey is set, all keyboard events are included in the set.) */
EventOnAnyKey = 0x1,
/* DOC(If EventOnEsc is set, any press of the escape key is included in the set.) */
diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp
index e5f5df21..6265777e 100644
--- a/4ed_metagen.cpp
+++ b/4ed_metagen.cpp
@@ -789,6 +789,11 @@ get_doc_string_from_prev(Parse_Context *context, String *doc_string){
return(result);
}
+
+//
+// Meta Parse Rules
+//
+
static int32_t
struct_parse(Partition *part, int32_t is_struct,
Parse_Context *context, Item_Node *top_member);
@@ -896,6 +901,7 @@ struct_parse_next_member(Partition *part, Parse_Context *context){
assert(!"unhandled error");
}
}
+
}
else if (token->type == CPP_TOKEN_BRACE_CLOSE){
break;
@@ -989,7 +995,7 @@ struct_parse(Partition *part, int32_t is_struct,
}
static int32_t
-typedef_parse(Parse_Context *context, Item_Set item_set, int32_t item_index){
+typedef_parse(Parse_Context *context, Item_Node *item){
int32_t result = false;
Cpp_Token *token = get_token(context);
@@ -1019,10 +1025,10 @@ typedef_parse(Parse_Context *context, Item_Set item_set, int32_t item_index){
get_string(context->data, start_token->start + start_token->size, token_j->start)
);
- item_set.items[item_index].t = Item_Typedef;
- item_set.items[item_index].type = type;
- item_set.items[item_index].name = name;
- item_set.items[item_index].doc_string = doc_string;
+ item->t = Item_Typedef;
+ item->type = type;
+ item->name = name;
+ item->doc_string = doc_string;
result = true;
}
@@ -1032,8 +1038,7 @@ typedef_parse(Parse_Context *context, Item_Set item_set, int32_t item_index){
}
static int32_t
-enum_parse(Partition *part, Parse_Context *context,
- Item_Set item_set, int32_t item_index){
+enum_parse(Partition *part, Parse_Context *context, Item_Node *item){
int32_t result = false;
@@ -1133,10 +1138,10 @@ enum_parse(Partition *part, Parse_Context *context,
}
get_next_token(context);
- item_set.items[item_index].t = Item_Enum;
- item_set.items[item_index].name = name;
- item_set.items[item_index].doc_string = doc_string;
- item_set.items[item_index].first_child = first_member;
+ item->t = Item_Enum;
+ item->name = name;
+ item->doc_string = doc_string;
+ item->first_child = first_member;
result = true;
}
}
@@ -1408,7 +1413,7 @@ Moves the context in the following way:
*/
static int32_t
macro_parse(Partition *part, Parse_Context *context,
- char *data, Item_Set macro_set, int32_t sig_count){
+ char *data, Item_Set item_set, int32_t sig_count){
int32_t result = false;
Cpp_Token *token = 0;
@@ -1425,7 +1430,7 @@ macro_parse(Partition *part, Parse_Context *context,
doc_string = get_lexeme(*doc_token, data);
if (check_and_fix_docs(&doc_string)){
- macro_set.items[sig_count].doc_string = doc_string;
+ item_set.items[sig_count].doc_string = doc_string;
for (; (token = get_token(context)) != 0; get_next_token(context)){
if (token->type == CPP_TOKEN_IDENTIFIER){
@@ -1434,7 +1439,7 @@ macro_parse(Partition *part, Parse_Context *context,
}
if (get_token(context) && (token->flags & CPP_TFLAG_PP_BODY)){
- macro_set.items[sig_count].name = get_lexeme(*token, data);
+ item_set.items[sig_count].name = get_lexeme(*token, data);
if ((token = get_next_token(context)) != 0){
args_start_token = token;
@@ -1447,9 +1452,9 @@ macro_parse(Partition *part, Parse_Context *context,
if (token){
int32_t start = args_start_token->start;
int32_t end = token->start + token->size;
- macro_set.items[sig_count].args = make_string(data + start, end - start);
+ item_set.items[sig_count].args = make_string(data + start, end - start);
- macro_set.items[sig_count].breakdown =
+ item_set.items[sig_count].breakdown =
parameter_parse(part, data, args_start_token, token);
if ((token = get_next_token(context)) != 0){
@@ -1466,11 +1471,11 @@ macro_parse(Partition *part, Parse_Context *context,
start = body_start->start;
end = token->start + token->size;
- macro_set.items[sig_count].body = make_string(data + start, end - start);
+ item_set.items[sig_count].body = make_string(data + start, end - start);
}
}
- macro_set.items[sig_count].t = Item_Macro;
+ item_set.items[sig_count].t = Item_Macro;
result = true;
}
}
@@ -1797,6 +1802,166 @@ print_function_docs(FILE *file, Partition *part, String name, String doc_string)
print_see_also(file, doc);
}
+static void
+print_item(Partition *part, FILE *file, Item_Node *item, char *section, int32_t I){
+ String name = item->name;
+ /* NOTE(allen):
+ Open a div for the whole item.
+ Put a heading in it with the name and section.
+ Open a "descriptive" box for the display of the code interface.
+ */
+ fprintf(file,
+ "
\n"
+ "
§%s.%d: %.*s
\n"
+ "
",
+ name.size, name.str, section, I, name.size, name.str);
+
+ Temp_Memory temp = begin_temp_memory(part);
+
+ switch (item->t){
+ case Item_Typedef:
+ {
+ String type = item->type;
+
+ // NOTE(allen): Code box
+ {
+ fprintf(file,
+ "typedef %.*s %.*s;",
+ type.size, type.str,
+ name.size, name.str
+ );
+ }
+
+ // NOTE(allen): Close the descriptive box
+ fprintf(file, "
\n");
+
+ // NOTE(allen): Descriptive section
+ {
+ String doc_string = item->doc_string;
+ Documentation doc = {0};
+ perform_doc_parse(part, doc_string, &doc);
+
+ String main_doc = doc.main_doc;
+ if (main_doc.size != 0){
+ fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
+ fprintf(file,
+ DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
+ main_doc.size, main_doc.str
+ );
+ }
+
+ print_see_also(file, &doc);
+ }
+ }break;
+
+ case Item_Enum:
+ {
+ // NOTE(allen): Code box
+ {
+ fprintf(file,
+ "enum %.*s;",
+ name.size, name.str);
+ }
+
+ // NOTE(allen): Close the descriptive box
+ fprintf(file, "
\n");
+
+ // NOTE(allen): Descriptive section
+ {
+ String doc_string = item->doc_string;
+ Documentation doc = {0};
+ perform_doc_parse(part, doc_string, &doc);
+
+ String main_doc = doc.main_doc;
+ if (main_doc.size != 0){
+ fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
+ fprintf(file,
+ DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
+ main_doc.size, main_doc.str
+ );
+ }
+
+ if (item->first_child){
+ fprintf(file, DOC_HEAD_OPEN"Values"DOC_HEAD_CLOSE);
+ for (Item_Node *member = item->first_child;
+ member;
+ member = member->next_sibling){
+ Documentation doc = {0};
+ perform_doc_parse(part, member->doc_string, &doc);
+
+ if (member->value.str){
+ fprintf(file,
+ "
\n"
+ "
"DOC_ITEM_HEAD_INL_OPEN
+ "%.*s"DOC_ITEM_HEAD_INL_CLOSE" = %.*s
\n"
+ "
"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
\n"
+ "
\n",
+ member->name.size, member->name.str,
+ member->value.size, member->value.str,
+ doc.main_doc.size, doc.main_doc.str
+ );
+ }
+ else{
+ fprintf(file,
+ "
\n"
+ "
"DOC_ITEM_HEAD_INL_OPEN
+ "%.*s"DOC_ITEM_HEAD_INL_CLOSE"
\n"
+ "
"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
\n"
+ "
\n",
+ member->name.size, member->name.str,
+ doc.main_doc.size, doc.main_doc.str
+ );
+ }
+ }
+ }
+
+ print_see_also(file, &doc);
+ }
+ }break;
+
+ case Item_Struct: case Item_Union:
+ {
+ Item_Node *member = item;
+
+ // NOTE(allen): Code box
+ {
+ print_struct_html(file, member);
+ }
+
+ // NOTE(allen): Close the descriptive box
+ fprintf(file, "
\n");
+
+ // NOTE(allen): Descriptive section
+ {
+ String doc_string = member->doc_string;
+ Documentation doc = {0};
+ perform_doc_parse(part, doc_string, &doc);
+
+ String main_doc = doc.main_doc;
+ if (main_doc.size != 0){
+ fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
+ fprintf(file,
+ DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE,
+ main_doc.size, main_doc.str
+ );
+ }
+
+ if (member->first_child){
+ fprintf(file, DOC_HEAD_OPEN"Fields"DOC_HEAD_CLOSE);
+ print_struct_docs(file, part, member);
+ }
+
+ print_see_also(file, &doc);
+ }
+ }break;
+ }
+
+ // NOTE(allen): Close the item box
+ fprintf(file, "