From 369ebd7a62dc3ff0e90b8b68030f79c7dfd1c50a Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sun, 21 Mar 2021 20:40:43 -0700 Subject: [PATCH] [docs] catch up to new map integration; change function forward declarations for map --- docs/{md_docs.mc => md_docs.md} | 32 ++++++++++--------- .../static_site_generator.c | 2 +- source/md.h | 4 +-- 3 files changed, 20 insertions(+), 18 deletions(-) rename docs/{md_docs.mc => md_docs.md} (97%) diff --git a/docs/md_docs.mc b/docs/md_docs.md similarity index 97% rename from docs/md_docs.mc rename to docs/md_docs.md index e050ef6..85a6cc2 100644 --- a/docs/md_docs.mc +++ b/docs/md_docs.md @@ -131,27 +131,29 @@ //~ Message Levels @enum MD_MessageKind: { - Error, + None, Warning, + Error, } //////////////////////////////// //~ String-To-Node table -@enum MD_NodeTableCollisionRule: { +@enum MD_MapCollisionRule: { Chain, Overwrite, } -@struct MD_NodeTableSlot: { - next: *MD_NodeTableSlot, +@struct MD_MapSlot: { + next: *MD_MapSlot, hash: MD_u64, - node: *MD_Node, + key: *void; + value: *void; }; -@struct MD_NodeTable: { +@struct MD_Map: { table_size: MD_u64, - table: **MD_NodeTableSlot, + table: **MD_MapSlot, }; //////////////////////////////// @@ -198,7 +200,7 @@ Newline, WhitespaceMax, - MD_TokenKind_NonASCII, + MD_TokenKind_BadCharacter, MAX, }; @@ -237,7 +239,7 @@ at: *MD_u8, filename: MD_String8, file_contents: MD_String8, - namespace_table: MD_NodeTable, + namespace_table: MD_Map, selected_namespace: *MD_Node, catastrophic_error: MD_b32, }; @@ -647,15 +649,15 @@ //////////////////////////////// //~ String-To-Node-List Table -@func MD_NodeTable_Lookup: { - table: *MD_NodeTable, +@func MD_Map_Lookup: { + table: *MD_Map, string: MD_String8, - return: *MD_NodeTableSlot, + return: *MD_MapSlot, }; -@func MD_NodeTable_Insert: { - table: *MD_NodeTable, - collision_rule: MD_NodeTableCollisionRule, +@func MD_Map_Insert: { + table: *MD_Map, + collision_rule: MD_MapCollisionRule, string: MD_String8, node: *MD_Node, return: MD_b32, diff --git a/samples/static_site_generator/static_site_generator.c b/samples/static_site_generator/static_site_generator.c index 6c57b80..2f81d74 100644 --- a/samples/static_site_generator/static_site_generator.c +++ b/samples/static_site_generator/static_site_generator.c @@ -513,7 +513,7 @@ GeneratePageContent(MD_Map *index_table, SiteInfo *site_info, PageInfo *page_inf MD_Node *index_string = 0; for(MD_u64 idx = 0; !MD_NodeIsNil(index_string = MD_ChildFromIndex(node, idx)); idx += 1) { - for(MD_MapSlot *slot = MD_NodeTable_Lookup(index_table, index_string->string); + for(MD_MapSlot *slot = MD_Map_Lookup(index_table, index_string->string); slot; slot = slot->next) { if(slot->value) diff --git a/source/md.h b/source/md.h index 45b3951..7ce784e 100644 --- a/source/md.h +++ b/source/md.h @@ -698,8 +698,8 @@ MD_FUNCTION MD_String8 MD_S8FromS32(MD_String32 str); MD_FUNCTION MD_String32 MD_S32FromS8(MD_String8 str); //~ String-To-Node-List Table -MD_FUNCTION MD_MapSlot *MD_NodeTable_Lookup(MD_Map *table, MD_String8 string); -MD_FUNCTION MD_b32 MD_NodeTable_Insert(MD_Map *table, MD_MapCollisionRule collision_rule, MD_String8 string, MD_Node *node); +MD_FUNCTION MD_MapSlot *MD_Map_Lookup(MD_Map *table, MD_String8 string); +MD_FUNCTION MD_b32 MD_Map_Insert(MD_Map *table, MD_MapCollisionRule collision_rule, MD_String8 string, MD_Node *node); //~ Parsing MD_FUNCTION MD_b32 MD_TokenKindIsWhitespace(MD_TokenKind kind);