From 4a415a83ac4814a542ad9057a541c200d73bcaed Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 3 Sep 2016 15:49:47 -0400 Subject: [PATCH] printing all types through same system --- 4coder_API.html | 236 ++++++++++++------------- 4coder_types.h | 21 ++- 4ed_metagen.cpp | 447 +++++++++++++++++++++--------------------------- 3 files changed, 321 insertions(+), 383 deletions(-) diff --git a/4coder_API.html b/4coder_API.html index 7c2b7611..88386023 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -101,17 +101,14 @@ Coming Soon
  • Buffer_ID
  • View_ID
  • Key_Modifier
  • +
  • Key_Modifier_Flag
  • Command_ID
  • +
  • Memory_Protect_Flags
  • User_Input_Type_ID
  • Event_Message_Type_ID
  • Buffer_Batch_Edit_Type
  • Buffer_Setting_ID
  • View_Setting_ID
  • -
  • Mouse_Cursor_Show_Type
  • -
  • Buffer_Seek_Type
  • -
  • View_Split_Position
  • -
  • Key_Modifier_Flag
  • -
  • Memory_Protect_Flags
  • Buffer_Create_Flag
  • Buffer_Kill_Flag
  • Access_Flag
  • @@ -120,6 +117,9 @@ Coming Soon
  • Auto_Indent_Flag
  • Set_Buffer_Flag
  • Input_Type_Flag
  • +
  • Mouse_Cursor_Show_Type
  • +
  • Buffer_Seek_Type
  • +
  • View_Split_Position
  • Generic_Command
  • Key_Event_Data
  • Mouse_State
  • @@ -1218,8 +1218,29 @@ the interval [1,16].

    MDFR_INDEX_COUNT is used to specify the number of modifiers supported.

    +
    +

    §3.4.7: Key_Modifier_Flag

    +
    enum Key_Modifier_Flag;
    +
    Description
    A Key_Modifier_Flag field is used to specify a specific state of modifiers. +Flags can be combined with bit or to specify a state with multiple modifiers.
    Values
    +
    MDFR_NONE = 0x0
    +
    MDFR_NONE specifies that no modifiers are pressed.
    +
    +
    +
    MDFR_CTRL = 0x1
    +
    +
    +
    +
    MDFR_ALT = 0x2
    +
    +
    +
    +
    MDFR_SHIFT = 0x4
    +
    +
    +

    -

    §3.4.7: Command_ID

    +

    §3.4.8: Command_ID

    enum Command_ID;
    Description
    A Command_ID is used as a name for commands implemented internally in 4coder.
    Values
    cmdid_null
    @@ -1294,8 +1315,24 @@ the interval [1,16].


    +
    +

    §3.4.9: Memory_Protect_Flags

    +
    enum Memory_Protect_Flags;
    +
    Description
    TODO
    Values
    +
    MemProtect_Read = 0x1
    +
    TODO
    +
    +
    +
    MemProtect_Write = 0x2
    +
    TODO
    +
    +
    +
    MemProtect_Execute = 0x4
    +
    TODO
    +
    +

    -

    §3.4.8: User_Input_Type_ID

    +

    §3.4.10: User_Input_Type_ID

    enum User_Input_Type_ID;
    Description
    User_Input_Type_ID specifies a type of user input event.
    Values
    UserInputNone
    @@ -1311,7 +1348,7 @@ the interval [1,16].


    -

    §3.4.9: Event_Message_Type_ID

    +

    §3.4.11: Event_Message_Type_ID

    enum Event_Message_Type_ID;
    Description
    Event_Message_Type_ID is a part of an unfinished feature.
    Values
    EventMessage_NoMessage
    @@ -1331,7 +1368,7 @@ the interval [1,16].


    -

    §3.4.10: Buffer_Batch_Edit_Type

    +

    §3.4.12: Buffer_Batch_Edit_Type

    enum Buffer_Batch_Edit_Type;
    Description
    A Buffer_Batch_Edit_Type is a type of batch operation.
    Values
    BatchEdit_Normal
    @@ -1344,7 +1381,7 @@ the interval [1,16].


    -

    §3.4.11: Buffer_Setting_ID

    +

    §3.4.13: Buffer_Setting_ID

    enum Buffer_Setting_ID;
    Description
    A Buffer_Setting_ID names a setting in a buffer.
    Values
    BufferSetting_Null
    @@ -1384,7 +1421,7 @@ the interval [1,16].


    -

    §3.4.12: View_Setting_ID

    +

    §3.4.14: View_Setting_ID

    enum View_Setting_ID;
    Description
    A View_Setting_ID names a setting in a view.
    Values
    ViewSetting_Null
    @@ -1407,101 +1444,10 @@ the interval [1,16].

    attached to a view in it's scrollable section.
    -
    -

    §3.4.13: Mouse_Cursor_Show_Type

    -
    enum Mouse_Cursor_Show_Type;
    -
    Description
    A Mouse_Cursor_Show_Type value specifes a mode for 4coder to handle the mouse cursor.
    Values
    -
    MouseCursorShow_Never
    -
    The MouseCursorShow_Never mode never shows the cursor.
    -
    -
    -
    MouseCursorShow_Always
    -
    The MouseCursorShow_Never mode always shows the cursor.
    -
    -

    -
    -

    §3.4.14: Buffer_Seek_Type

    -
    enum Buffer_Seek_Type;
    -
    Description
    The Buffer_Seek_Type is is used in a Buffer_Seek to identify which -coordinates are suppose to be used for the seek.
    Values
    -
    buffer_seek_pos
    -
    This value indicates absolute positioning where positions are measured as the number of bytes from the start of the file.
    -
    -
    -
    buffer_seek_wrapped_xy
    -
    This value indicates xy positioning with wrapped lines where the x and y values are in pixels.
    -
    -
    -
    buffer_seek_unwrapped_xy
    -
    This value indicates xy positioning with unwrapped lines where the x and y values are in pixels.
    -
    -
    -
    buffer_seek_line_char
    -
    This value indicates line-character, or line-column positioning. These coordinates are 1 based to match standard line numbering.
    -
    -
    See Also
    Buffer_Seek
    4coder_Buffer_Positioning_System

    -
    -

    §3.4.15: View_Split_Position

    -
    enum View_Split_Position;
    -
    Description
    A View_Split_Position specifies where a new view should be placed as a result of -a view split operation.
    Values
    -
    ViewSplit_Top
    -
    This value indicates that the new view should be above the existing view.
    -
    -
    -
    ViewSplit_Bottom
    -
    This value indicates that the new view should be below the existing view.
    -
    -
    -
    ViewSplit_Left
    -
    This value indicates that the new view should be left of the existing view.
    -
    -
    -
    ViewSplit_Right
    -
    This value indicates that the new view should be right of the existing view.
    -
    -

    -
    -

    §3.4.16: Key_Modifier_Flag

    -
    enum Key_Modifier_Flag;
    -
    Description
    A Key_Modifier_Flag field is used to specify a specific state of modifiers. -Flags can be combined with bit or to specify a state with multiple modifiers.
    Flags
    -
    MDFR_NONE = 0x0
    -
    MDFR_NONE specifies that no modifiers are pressed.
    -
    -
    -
    MDFR_CTRL = 0x1
    -
    -
    -
    -
    MDFR_ALT = 0x2
    -
    -
    -
    -
    MDFR_SHIFT = 0x4
    -
    -
    -

    -
    -

    §3.4.17: Memory_Protect_Flags

    -
    enum Memory_Protect_Flags;
    -
    Description
    TODO
    Flags
    -
    MemProtect_Read = 0x1
    -
    TODO
    -
    -
    -
    MemProtect_Write = 0x2
    -
    TODO
    -
    -
    -
    MemProtect_Execute = 0x4
    -
    TODO
    -
    -

    -

    §3.4.18: Buffer_Create_Flag

    +

    §3.4.15: Buffer_Create_Flag

    enum Buffer_Create_Flag;
    -
    Description
    A Buffer_Create_Flag field specifies how a buffer should be created.
    Flags
    +
    Description
    A Buffer_Create_Flag field specifies how a buffer should be created.
    Values
    BufferCreate_Background = 0x1
    BufferCreate_Background is not currently implemented.
    @@ -1517,9 +1463,9 @@ Flags can be combined with bit or to specify a state with multiple modifiers.

    -

    §3.4.19: Buffer_Kill_Flag

    +

    §3.4.16: Buffer_Kill_Flag

    enum Buffer_Kill_Flag;
    -
    Description
    A Buffer_Kill_Flag field specifies how a buffer should be killed.
    Flags
    +
    Description
    A Buffer_Kill_Flag field specifies how a buffer should be killed.
    Values
    BufferKill_Background = 0x1
    BufferKill_Background is not currently implemented.
    @@ -1530,14 +1476,14 @@ Flags can be combined with bit or to specify a state with multiple modifiers.

    -

    §3.4.20: Access_Flag

    +

    §3.4.17: Access_Flag

    enum Access_Flag;
    Description
    An Access_Flag field specifies what sort of permission you grant to an access call. An access call is usually one the returns a summary struct. If a 4coder object has a particular protection flag set and the corresponding bit is not set in the access field, that 4coder object is hidden. On the other hand if a protection flag is set in the access parameter and the object does not have -that protection flag, the object is still returned from the access call.
    Flags
    +that protection flag, the object is still returned from the access call.
    Values
    AccessOpen = 0x0
    AccessOpen does not include any bits, it indicates that the access should only return objects that have no protection flags set.
    @@ -1560,10 +1506,10 @@ that protection flag, the object is still returned from the access call.

    -

    §3.4.21: Seek_Boundary_Flag

    +

    §3.4.18: Seek_Boundary_Flag

    enum Seek_Boundary_Flag;
    Description
    A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the -beginning or end of different types of words.
    Flags
    +beginning or end of different types of words.
    Values
    BoundaryWhitespace = 0x1
    @@ -1581,9 +1527,9 @@ beginning or end of different types of words.
    -

    §3.4.22: Command_Line_Input_Flag

    +

    §3.4.19: Command_Line_Input_Flag

    enum Command_Line_Input_Flag;
    -
    Description
    A Command_Line_Input_Flag field specifies the behavior of a call to a command line interface.
    Flags
    +
    Description
    A Command_Line_Input_Flag field specifies the behavior of a call to a command line interface.
    Values
    CLI_OverlapWithConflict = 0x1
    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 @@ -1602,9 +1548,9 @@ beginning or end of different types of words.
    -

    §3.4.23: Auto_Indent_Flag

    +

    §3.4.20: Auto_Indent_Flag

    enum Auto_Indent_Flag;
    -
    Description
    An Auto_Indent_Flag field specifies the behavior of an auto indentation operation.
    Flags
    +
    Description
    An Auto_Indent_Flag field specifies the behavior of an auto indentation operation.
    Values
    AutoIndent_ClearLine = 0x1
    If AutoIndent_ClearLine is set, then any line that is only whitespace will be cleared to contain nothing at all. otherwise the line is filled with whitespace @@ -1618,9 +1564,9 @@ beginning or end of different types of words.
    -

    §3.4.24: Set_Buffer_Flag

    +

    §3.4.21: Set_Buffer_Flag

    enum Set_Buffer_Flag;
    -
    Description
    A Set_Buffer_Flag field specifies the behavior of an operation that sets the buffer of a view.
    Flags
    +
    Description
    A Set_Buffer_Flag field specifies the behavior of an operation that sets the buffer of a view.
    Values
    SetBuffer_KeepOriginalGUI = 0x1
    If SetBuffer_KeepOriginalGUI then when the file is set, the view will not switch to it if some other GUI was currently up, otherwise any GUI that is up is closed and the view @@ -1628,9 +1574,9 @@ beginning or end of different types of words.
    -

    §3.4.25: Input_Type_Flag

    +

    §3.4.22: Input_Type_Flag

    enum Input_Type_Flag;
    -
    Description
    A Input_Type_Flag field specifies a set of input event types.
    Flags
    +
    Description
    A Input_Type_Flag field specifies a set of input event types.
    Values
    EventOnAnyKey = 0x1
    If EventOnAnyKey is set, all keyboard events are included in the set.
    @@ -1667,6 +1613,60 @@ beginning or end of different types of words.
    EventAll is a catch all name for including all possible events in the set.

    +
    +

    §3.4.23: Mouse_Cursor_Show_Type

    +
    enum Mouse_Cursor_Show_Type;
    +
    Description
    A Mouse_Cursor_Show_Type value specifes a mode for 4coder to handle the mouse cursor.
    Values
    +
    MouseCursorShow_Never
    +
    The MouseCursorShow_Never mode never shows the cursor.
    +
    +
    +
    MouseCursorShow_Always
    +
    The MouseCursorShow_Never mode always shows the cursor.
    +
    +

    +
    +

    §3.4.24: Buffer_Seek_Type

    +
    enum Buffer_Seek_Type;
    +
    Description
    The Buffer_Seek_Type is is used in a Buffer_Seek to identify which +coordinates are suppose to be used for the seek.
    Values
    +
    buffer_seek_pos
    +
    This value indicates absolute positioning where positions are measured as the number of bytes from the start of the file.
    +
    +
    +
    buffer_seek_wrapped_xy
    +
    This value indicates xy positioning with wrapped lines where the x and y values are in pixels.
    +
    +
    +
    buffer_seek_unwrapped_xy
    +
    This value indicates xy positioning with unwrapped lines where the x and y values are in pixels.
    +
    +
    +
    buffer_seek_line_char
    +
    This value indicates line-character, or line-column positioning. These coordinates are 1 based to match standard line numbering.
    +
    +
    See Also

    +
    +

    §3.4.25: View_Split_Position

    +
    enum View_Split_Position;
    +
    Description
    A View_Split_Position specifies where a new view should be placed as a result of +a view split operation.
    Values
    +
    ViewSplit_Top
    +
    This value indicates that the new view should be above the existing view.
    +
    +
    +
    ViewSplit_Bottom
    +
    This value indicates that the new view should be below the existing view.
    +
    +
    +
    ViewSplit_Left
    +
    This value indicates that the new view should be left of the existing view.
    +
    +
    +
    ViewSplit_Right
    +
    This value indicates that the new view should be right of the existing view.
    +
    +

    §3.4.26: Generic_Command

    union Generic_Command {
    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, "

    \n"); + + end_temp_memory(temp); +} + typedef struct App_API_Name{ String macro; String public_name; @@ -2095,7 +2260,6 @@ generate_custom_headers(){ { Item_Set typedef_set = {0}; Item_Set struct_set = {0}; - Item_Set flag_set = {0}; Item_Set enum_set = {0}; Parse type_parse[1]; @@ -2105,15 +2269,13 @@ generate_custom_headers(){ int32_t typedef_count = 0; int32_t struct_count = 0; - int32_t flag_count = 0; int32_t enum_count = 0; static String type_spec_keys[] = { make_lit_string("typedef"), make_lit_string("struct"), make_lit_string("union"), - make_lit_string("ENUM"), - make_lit_string("FLAGENUM"), + make_lit_string("ENUM") }; for (int32_t J = 0; J < file_count; ++J){ @@ -2141,9 +2303,6 @@ generate_custom_headers(){ case 3: //ENUM ++enum_count; break; - - case 4: //FLAGENUM - ++flag_count; break; } } } @@ -2162,13 +2321,8 @@ generate_custom_headers(){ enum_set = allocate_item_set(part, enum_count); } - if (flag_count > 0){ - flag_set = allocate_item_set(part, flag_count); - } - int32_t typedef_index = 0; int32_t struct_index = 0; - int32_t flag_index = 0; int32_t enum_index = 0; for (int32_t J = 0; J < file_count; ++J){ @@ -2193,7 +2347,8 @@ generate_custom_headers(){ case 0: //typedef { set_token(context, token); - if (typedef_parse(context, typedef_set, typedef_index)){ + if (typedef_parse(context, typedef_set.items + typedef_index)){ + Assert(typedef_set.items[typedef_index].t == Item_Typedef); ++typedef_index; } }break; @@ -2203,6 +2358,8 @@ generate_custom_headers(){ set_token(context, token); if (struct_parse(part, (match_index == 1), context, struct_set.items + struct_index)){ + Assert(struct_set.items[struct_index].t == Item_Struct || + struct_set.items[struct_index].t == Item_Union); ++struct_index; } }break; @@ -2210,18 +2367,11 @@ generate_custom_headers(){ case 3: //ENUM { set_token(context, token); - if (enum_parse(part, context, enum_set, enum_index)){ + if (enum_parse(part, context, enum_set.items + enum_index)){ + Assert(enum_set.items[enum_index].t == Item_Enum); ++enum_index; } }break; - - case 4: //FLAGENUM - { - set_token(context, token); - if (enum_parse(part, context, flag_set, flag_index)){ - ++flag_index; - } - }break; } } } @@ -2230,7 +2380,6 @@ generate_custom_headers(){ typedef_count = typedef_index; struct_count = struct_index; enum_count = enum_index; - flag_count = flag_index; } // @@ -2691,17 +2840,6 @@ generate_custom_headers(){ ); } - for (int32_t i = 0; i < flag_count; ++i){ - String name = flag_set.items[i].name; - fprintf(file, - "
  • " - "%.*s" - "
  • \n", - name.size, name.str, - name.size, name.str - ); - } - for (int32_t i = 0; i < struct_count; ++i){ String name = struct_set.items[i].name; fprintf(file, @@ -2744,214 +2882,15 @@ generate_custom_headers(){ fprintf(file, "

    §"SECTION" Type Descriptions

    \n"); int32_t I = 1; for (int32_t i = 0; i < typedef_count; ++i, ++I){ - String name = typedef_set.items[i].name; - String type = typedef_set.items[i].type; - - fprintf(file, - "
    \n" - "

    §"SECTION".%d: %.*s

    \n" - "
    ", - name.size, name.str, I, - name.size, name.str - ); - - // NOTE(allen): Code box - { - fprintf(file, - "typedef %.*s %.*s;", - type.size, type.str, - name.size, name.str - ); - } - - fprintf(file, "
    \n"); - - // NOTE(allen): Descriptive section - { - String doc_string = typedef_set.items[i].doc_string; - Documentation doc = {0}; - perform_doc_parse(part, doc_string, &doc); - - String main_doc = doc.main_doc; - if (main_doc.size != 0){ - fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); - fprintf(file, - DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, - main_doc.size, main_doc.str - ); - } - - print_see_also(file, &doc); - } - - fprintf(file, "

    \n"); + print_item(part, file, typedef_set.items + i, SECTION, I); } for (int32_t i = 0; i < enum_count; ++i, ++I){ - String name = enum_set.items[i].name; - - fprintf(file, - "
    \n" - "

    §"SECTION".%d: %.*s

    \n" - "
    ", - name.size, name.str, I, - name.size, name.str - ); - - // NOTE(allen): Code box - { - fprintf(file, - "enum %.*s;", - name.size, name.str); - } - - fprintf(file, "
    \n"); - - // NOTE(allen): Descriptive section - { - String doc_string = enum_set.items[i].doc_string; - Documentation doc = {0}; - perform_doc_parse(part, doc_string, &doc); - - String main_doc = doc.main_doc; - if (main_doc.size != 0){ - fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); - fprintf(file, - DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, - main_doc.size, main_doc.str - ); - } - - if (enum_set.items[i].first_child){ - fprintf(file, DOC_HEAD_OPEN"Values"DOC_HEAD_CLOSE); - for (Item_Node *member = enum_set.items[i].first_child; - member; - member = member->next_sibling){ - Documentation doc = {0}; - perform_doc_parse(part, member->doc_string, &doc); - - fprintf(file, - "
    \n" - "
    "DOC_ITEM_HEAD_INL_OPEN - "%.*s"DOC_ITEM_HEAD_INL_CLOSE"
    \n" - "
    "DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
    \n" - "
    \n", - member->name.size, member->name.str, - doc.main_doc.size, doc.main_doc.str - ); - } - } - - print_see_also(file, &doc); - } - - fprintf(file, "

    \n"); - } - - for (int32_t i = 0; i < flag_count; ++i, ++I){ - String name = flag_set.items[i].name; - - fprintf(file, - "
    \n" - "

    §"SECTION".%d: %.*s

    \n" - "
    ", - name.size, name.str, I, - name.size, name.str - ); - - // NOTE(allen): Code box - { - fprintf(file, - "enum %.*s;", - name.size, name.str); - } - - fprintf(file, "
    \n"); - - // NOTE(allen): Descriptive section - { - String doc_string = flag_set.items[i].doc_string; - Documentation doc = {0}; - perform_doc_parse(part, doc_string, &doc); - - String main_doc = doc.main_doc; - if (main_doc.size != 0){ - fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); - fprintf(file, - DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, - main_doc.size, main_doc.str - ); - } - - if (flag_set.items[i].first_child){ - fprintf(file, DOC_HEAD_OPEN"Flags"DOC_HEAD_CLOSE); - for (Item_Node *member = flag_set.items[i].first_child; - member; - member = member->next_sibling){ - Documentation doc = {0}; - perform_doc_parse(part, member->doc_string, &doc); - - fprintf(file, - "
    \n" - "
    "DOC_ITEM_HEAD_INL_OPEN - "%.*s"DOC_ITEM_HEAD_INL_CLOSE" = %.*s
    \n" - "
    "DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
    \n" - "
    \n", - member->name.size, member->name.str, - member->value.size, member->value.str, - doc.main_doc.size, doc.main_doc.str - ); - } - } - - print_see_also(file, &doc); - } - - fprintf(file, "

    \n"); + print_item(part, file, enum_set.items + i, SECTION, I); } for (int32_t i = 0; i < struct_count; ++i, ++I){ - Item_Node *member = &struct_set.items[i]; - String name = member->name; - fprintf(file, - "
    \n" - "

    §"SECTION".%d: %.*s

    \n" - "
    ", - name.size, name.str, I, - name.size, name.str - ); - - // NOTE(allen): Code box - { - print_struct_html(file, member); - } - - fprintf(file, "
    \n"); - - // NOTE(allen): Descriptive section - { - String doc_string = member->doc_string; - Documentation doc = {0}; - perform_doc_parse(part, doc_string, &doc); - - String main_doc = doc.main_doc; - if (main_doc.size != 0){ - fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); - fprintf(file, - DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, - main_doc.size, main_doc.str - ); - } - - if (member->first_child){ - fprintf(file, DOC_HEAD_OPEN"Fields"DOC_HEAD_CLOSE); - print_struct_docs(file, part, member); - } - - print_see_also(file, &doc); - } - - fprintf(file, "

    \n"); + print_item(part, file, struct_set.items + i, SECTION, I); } }