From 33338daab748d644068f57fde344e80c50ace686 Mon Sep 17 00:00:00 2001 From: Peter Slattery Date: Sat, 1 Feb 2020 19:15:04 -0800 Subject: [PATCH] Working on Meta System Attempted to tag all panel related procedures --- gs_libs/gs_string_builder.h | 12 ++ meta/foldhaus_meta.cpp | 93 ++++++---- meta/gs_meta_type_table.h | 161 ++++++++++++++++-- project.4coder | 2 +- src/foldhaus_app.h | 12 ++ src/generated/foldhaus_nodes_generated.h | 21 +++ src/generated/foldhaus_panels_generated.h | 10 -- src/node/foldhaus_node_interface.cpp | 18 +- .../foldhaus_panel_animation_timeline.h | 13 +- src/panels/foldhaus_panel_dmx_view.h | 12 +- src/panels/foldhaus_panel_hierarchy.h | 12 +- src/panels/foldhaus_panel_node_graph.h | 13 +- src/panels/foldhaus_panel_profiler.h | 12 +- src/panels/foldhaus_panel_sculpture_view.h | 9 +- todo.txt | 11 +- 15 files changed, 330 insertions(+), 81 deletions(-) diff --git a/gs_libs/gs_string_builder.h b/gs_libs/gs_string_builder.h index aa230b3..e6e5df0 100644 --- a/gs_libs/gs_string_builder.h +++ b/gs_libs/gs_string_builder.h @@ -98,6 +98,18 @@ WriteStringBuilderToFile(string_builder StringBuilder, FILE* WriteFile) } } +internal void +StdPrintStringBuilder(string_builder StringBuilder) +{ + string_builder_buffer* BufferAt = StringBuilder.Buffers; + while (BufferAt) + { + string String = BufferAt->String; + printf("%.*s", StringExpand(String)); + BufferAt = BufferAt->Next; + } +} + #endif // GS_STRING_BUILDER_NO_STDIO #define GS_STRING_BUILDER_H diff --git a/meta/foldhaus_meta.cpp b/meta/foldhaus_meta.cpp index 0c67490..36e66e6 100644 --- a/meta/foldhaus_meta.cpp +++ b/meta/foldhaus_meta.cpp @@ -8,6 +8,62 @@ #include "gs_meta.cpp" #include "gs_meta_typeinfo_generator.h" +internal void +GenerateNodeMetaInfo (gsm_code_generator* NodeTypeGen, string_builder* CallNodeProcGen, gs_meta_preprocessor Meta) +{ + // TODO(Peter): Create a FilterTypesByTag function to create a contiguous array + // of type_definition** + + WriteF(CallNodeProcGen, "void CallNodeProc(node_type Type, u8* NodeData)\n{\n"); + WriteF(CallNodeProcGen, " switch(Type) { \n"); + for (u32 b = 0; b < Meta.TypeTable.TypeBucketsCount; b++) + { + type_table_hash_bucket Bucket = Meta.TypeTable.Types[b]; + for (u32 i = 0; i < TYPE_TABLE_BUCKET_MAX; i++) + { + if (Bucket.Keys[i] == 0) { continue; } + + type_definition* Decl = Bucket.Values + i; + if (HasTag(MakeStringLiteral("node_proc"), Decl->MetaTags) && + Decl->Type == TypeDef_Function) + { + if (Decl->Function.Parameters.Used > 1) + { + WriteF(CallNodeProcGen, "ERROR: Procedure tagged with node_proc has more than one parameter\n"); + continue; + } + + AddEnumElement(NodeTypeGen, Decl->Identifier); + + type_table_handle ReturnTypeHandle = Decl->Function.ReturnTypeHandle; + type_definition* ReturnType = GetTypeDefinition(ReturnTypeHandle, Meta.TypeTable); + + WriteF(CallNodeProcGen, " case NodeType_%.*s:\n", StringExpand(Decl->Identifier)); + WriteF(CallNodeProcGen, " {\n"); + WriteF(CallNodeProcGen, " %.*s(", StringExpand(Decl->Identifier)); + + for (u32 j = 0; j < Decl->Function.Parameters.Used; j++) + { + variable_decl* Param = Decl->Function.Parameters.GetElementAtIndex(j); + type_table_handle ParamTypeHandle = Param->TypeHandle; + type_definition* ParamType = GetTypeDefinition(ParamTypeHandle, Meta.TypeTable); + WriteF(CallNodeProcGen, "(%.*s*)NodeData", StringExpand(ParamType->Identifier)); + if (j + 1 < Decl->Function.Parameters.Used) + { + WriteF(CallNodeProcGen, ", "); + } + } + WriteF(CallNodeProcGen, ");\n"); + WriteF(CallNodeProcGen, " } break;\n"); + } + } + } + WriteF(CallNodeProcGen, " }\n"); + WriteF(CallNodeProcGen, "}\n\n"); + + FinishEnumGeneration(NodeTypeGen); +} + int main(int ArgCount, char* Args[]) { if (ArgCount <= 1) @@ -24,39 +80,10 @@ int main(int ArgCount, char* Args[]) FinishGeneratingTypes(&TypeGenerator); gsm_code_generator NodeTypeGen = BeginEnumGeneration("node_type", "NodeType", false, true); - // TODO(Peter): Create a FilterTypesByTag function to create a contiguous array - // of type_definition** - printf("\n\n"); - for (u32 b = 0; b < Meta.TypeTable.TypeBucketsCount; b++) - { - type_table_hash_bucket Bucket = Meta.TypeTable.Types[b]; - for (u32 i = 0; i < TYPE_TABLE_BUCKET_MAX; i++) - { - if (!Bucket.Keys[i] == 0) { continue; } - - type_definition* Decl = Bucket.Values + i; - if (HasTag(MakeStringLiteral("node_proc"), Decl->MetaTags) && - Decl->Type == TypeDef_Function) - { - AddEnumElement(&NodeTypeGen, Decl->Identifier); - - type_table_handle ReturnTypeHandle = Decl->Function.ReturnTypeHandle; - type_definition* ReturnType = GetTypeDefinition(ReturnTypeHandle, Meta.TypeTable); - printf("%.*s %.*s(\n", StringExpand(ReturnType->Identifier), StringExpand(Decl->Identifier)); - for (u32 j = 0; j < Decl->Function.Parameters.Used; j++) - { - variable_decl* Param = Decl->Function.Parameters.GetElementAtIndex(j); - type_table_handle ParamTypeHandle = Param->TypeHandle; - type_definition* ParamType = GetTypeDefinition(ParamTypeHandle, Meta.TypeTable); - printf(" %.*s %.*s,\n", StringExpand(ParamType->Identifier), StringExpand(Param->Identifier)); - } - printf(");\n\n"); - } - } - } - printf("\n\n"); + string_builder CallNodeProcGen = {0}; + GenerateNodeMetaInfo(&NodeTypeGen, &CallNodeProcGen, Meta); - FinishEnumGeneration(&NodeTypeGen); + string_builder PanelInfoGen = {0}; FILE* TypeInfoH = fopen("C:\\projects\\foldhaus\\src\\generated\\gs_meta_generated_typeinfo.h", "w"); if (TypeInfoH) @@ -71,10 +98,12 @@ int main(int ArgCount, char* Args[]) if (NodeInfoH) { WriteStringBuilderToFile(*NodeTypeGen.Builder, NodeInfoH); + WriteStringBuilderToFile(CallNodeProcGen, NodeInfoH); fclose(NodeInfoH); } FinishMetaprogram(&Meta); + //__debugbreak(); return 0; } diff --git a/meta/gs_meta_type_table.h b/meta/gs_meta_type_table.h index 3b3faad..5d15204 100644 --- a/meta/gs_meta_type_table.h +++ b/meta/gs_meta_type_table.h @@ -21,6 +21,18 @@ enum type_definition_type TypeDef_Count, }; +char* TypeDefinitionTypeStrings[] = { + "TypeDef_Invalid", + "TypeDef_Unknown", + "TypeDef_Enum", + "TypeDef_Struct", + "TypeDef_Union", + "TypeDef_BasicType", + "TypeDef_FunctionPointer", + "TypeDef_Function", + "TypeDef_Count", +}; + struct type_table_handle { s32 BucketIndex; @@ -100,7 +112,7 @@ struct type_definition b32 Pointer; }; -#define TYPE_TABLE_BUCKET_MAX 1024 +#define TYPE_TABLE_BUCKET_MAX 1023 struct type_table_hash_bucket { u32* Keys; @@ -171,11 +183,9 @@ HashIdentifier(string Identifier) } internal type_table_handle -PushTypeOnHashTable(type_definition TypeDef, type_table* TypeTable) +FindSlotForTypeIdentifier(u32 IdentHash, type_table* TypeTable) { type_table_handle Result = InvalidTypeTableHandle; - - u32 IdentHash = HashIdentifier(TypeDef.Identifier); u32 Index = IdentHash % TYPE_TABLE_BUCKET_MAX; for (u32 b = 0; b < TypeTable->TypeBucketsCount; b++) @@ -183,11 +193,9 @@ PushTypeOnHashTable(type_definition TypeDef, type_table* TypeTable) type_table_hash_bucket* Bucket = TypeTable->Types + b; if (Bucket->Keys[Index] == 0) { - Bucket->Keys[Index] = IdentHash; - Bucket->Values[Index] = TypeDef; - Result.BucketIndex = b; Result.IndexInBucket = Index; + break; } } @@ -204,13 +212,32 @@ PushTypeOnHashTable(type_definition TypeDef, type_table* TypeTable) GSZeroMemory((u8*)NewBucket->Keys, sizeof(u32) * TYPE_TABLE_BUCKET_MAX); GSZeroMemory((u8*)NewBucket->Values, sizeof(type_definition) * TYPE_TABLE_BUCKET_MAX); - NewBucket->Keys[Index] = IdentHash; - NewBucket->Values[Index] = TypeDef; - Result.BucketIndex = NewTypeBucketIndex; Result.IndexInBucket = Index; } + // NOTE(Peter): Because we are growing the hashtable, this should never be an invalid + // type handle + Assert(TypeHandleIsValid(Result)); + return Result; +} + +internal type_table_handle +PushTypeOnHashTable(type_definition TypeDef, type_table* TypeTable) +{ + u32 IdentHash = HashIdentifier(TypeDef.Identifier); + type_table_handle Result = FindSlotForTypeIdentifier(IdentHash, TypeTable); + + type_table_hash_bucket* Bucket = TypeTable->Types + Result.BucketIndex; + Bucket->Keys[Result.IndexInBucket] = IdentHash; + Bucket->Values[Result.IndexInBucket] = TypeDef; + +#if PRINT_DIAGNOSTIC_INFO + printf("Registering Type\n"); + printf(" %.*s\n", StringExpand(TypeDef.Identifier)); + printf(" Type: %s\n\n", TypeDefinitionTypeStrings[TypeDef.Type]); +#endif + return Result; } @@ -594,5 +621,119 @@ PopulateTableWithDefaultCPPTypes(type_table* TypeTable) } } +internal void +PrintTypeDefinition(type_definition TypeDef, type_table TypeTable) +{ + printf("Type: %.*s\n", StringExpand(TypeDef.Identifier)); + printf(" Size: %d\n", TypeDef.Size); + + printf(" Meta Tags: "); + for (u32 m = 0; m < TypeDef.MetaTags.Used; m++) + { + meta_tag* Tag = TypeDef.MetaTags.GetElementAtIndex(m); + printf("%.*s ", StringExpand(Tag->Identifier)); + } + printf("\n"); + + printf(" Type: %s\n", TypeDefinitionTypeStrings[TypeDef.Type]); + + switch(TypeDef.Type) + { + case TypeDef_Unknown: + { + } break; + + case TypeDef_Enum: + { + } break; + + case TypeDef_Struct: + { + } break; + + case TypeDef_Union: + { + } break; + + case TypeDef_BasicType: + { + } break; + + case TypeDef_FunctionPointer: + { + } break; + + case TypeDef_Function: + { + type_definition* ReturnType = GetTypeDefinition(TypeDef.Function.ReturnTypeHandle, TypeTable); + printf(" Returns: %.*s\n", StringExpand(ReturnType->Identifier)); + + printf(" Parameters: "); + for (u32 p = 0; p < TypeDef.Function.Parameters.Used; p++) + { + variable_decl* Param = TypeDef.Function.Parameters.GetElementAtIndex(p); + type_definition* ParamType = GetTypeDefinition(Param->TypeHandle, TypeTable); + printf("%.*s %.*s, ", StringExpand(ParamType->Identifier), StringExpand(Param->Identifier)); + } + } break; + + case TypeDef_Invalid: + case TypeDef_Count: + { + printf("???\n"); + } break; + } +} + +internal void +PrintTypeTable(type_table TypeTable) +{ + for (u32 b = 0; b < TypeTable.TypeBucketsCount; b++) + { + type_table_hash_bucket Bucket = TypeTable.Types[b]; + for (u32 i = 0; i < TYPE_TABLE_BUCKET_MAX; i++) + { + if (Bucket.Keys[i] != 0) + { + PrintTypeDefinition(Bucket.Values[i], TypeTable); + } + } + } +} + +internal void +DEBUGPrintTypeTableMembership(type_table TypeTable) +{ + printf("\n--- Type Table Membership --\n"); + u32 SlotsAvailable = 0; + u32 SlotsFilled = 0; + u32 TotalSlots = TypeTable.TypeBucketsCount * TYPE_TABLE_BUCKET_MAX; + for (u32 b = 0; b < TypeTable.TypeBucketsCount; b++) + { + type_table_hash_bucket Bucket = TypeTable.Types[b]; + for (u32 i = 0; i < TYPE_TABLE_BUCKET_MAX; i++) + { + if (Bucket.Keys[i] != 0) + { + SlotsFilled++; + printf("[x] "); + } + else + { + SlotsAvailable++; + printf("[ ] "); + } + } + printf("\n"); + } + + r32 PercentUsed = (r32)SlotsFilled / (r32)TotalSlots; + printf("Slots Available: %d\n", SlotsAvailable); + printf("Slots Filled: %d\n", SlotsFilled); + printf("Total Slots: %d\n", TotalSlots); + printf("Percent Used: %f\n", PercentUsed); + printf("\n"); +} + #define FOLDHAUS_META_TYPE_TABLE_H #endif // FOLDHAUS_META_TYPE_TABLE_H \ No newline at end of file diff --git a/project.4coder b/project.4coder index bca8b25..f551652 100644 --- a/project.4coder +++ b/project.4coder @@ -15,7 +15,7 @@ blacklist_patterns = { load_paths_base = { { "src", .relative = true, .recursive = true, }, { "meta", .relative = true, .recursive = true, }, - { "C:\programs-dev\gs_libs\src", .relative = false, .recursive = true, } + { "gs_libs", .relative = true, .recursive = true, }, }; load_paths = { { load_paths_base, .os = "win", }, diff --git a/src/foldhaus_app.h b/src/foldhaus_app.h index 015ae51..b9f2728 100644 --- a/src/foldhaus_app.h +++ b/src/foldhaus_app.h @@ -233,6 +233,17 @@ typedef PANEL_CLEANUP_PROC(panel_cleanup_proc); #define PANEL_RENDER_PROC(name) void name(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) typedef PANEL_RENDER_PROC(panel_render_proc); +// NOTE(Peter): This is used by the meta system to generate panel type info +struct panel_definition +{ + char* PanelName; + s32 PanelNameLength; + panel_init_proc* Init; + panel_cleanup_proc* Cleanup; + panel_render_proc* Render; + input_command* InputCommands; +}; + #include "panels/foldhaus_panel_sculpture_view.h" #include "panels/foldhaus_panel_profiler.h" #include "panels/foldhaus_panel_dmx_view.h" @@ -241,6 +252,7 @@ typedef PANEL_RENDER_PROC(panel_render_proc); #include "panels/foldhaus_panel_node_graph.h" #include "generated/foldhaus_panels_generated.h" +#include "generated/foldhaus_nodes_generated.h" #include "foldhaus_interface.cpp" diff --git a/src/generated/foldhaus_nodes_generated.h b/src/generated/foldhaus_nodes_generated.h index 6d6566b..9446c20 100644 --- a/src/generated/foldhaus_nodes_generated.h +++ b/src/generated/foldhaus_nodes_generated.h @@ -1,5 +1,26 @@ enum node_type { + NodeType_RevolvingDiscs, + NodeType_VerticalColorFadeProc, + NodeType_SolidColorProc, NodeType_Count, }; +void CallNodeProc(node_type Type, u8* NodeData) +{ + switch(Type) { + case NodeType_RevolvingDiscs: + { + RevolvingDiscs((revolving_discs_data*)NodeData); + } break; + case NodeType_VerticalColorFadeProc: + { + VerticalColorFadeProc((vertical_color_fade_data*)NodeData); + } break; + case NodeType_SolidColorProc: + { + SolidColorProc((solid_color_data*)NodeData); + } break; + } +} + diff --git a/src/generated/foldhaus_panels_generated.h b/src/generated/foldhaus_panels_generated.h index 18cf897..d7ce453 100644 --- a/src/generated/foldhaus_panels_generated.h +++ b/src/generated/foldhaus_panels_generated.h @@ -1,13 +1,3 @@ -struct panel_definition -{ - char* PanelName; - s32 PanelNameLength; - panel_init_proc* Init; - panel_cleanup_proc* Cleanup; - panel_render_proc* Render; - input_command* InputCommands; -}; - global_variable s32 GlobalPanelDefsCount = 6; global_variable panel_definition GlobalPanelDefs[] = { { "Sculpture View", 14, SculptureView_Init, SculptureView_Cleanup, SculptureView_Render, SculptureView_Commands}, diff --git a/src/node/foldhaus_node_interface.cpp b/src/node/foldhaus_node_interface.cpp index ccb1fe2..0764eb8 100644 --- a/src/node/foldhaus_node_interface.cpp +++ b/src/node/foldhaus_node_interface.cpp @@ -17,7 +17,8 @@ struct node_lister_operation_state v2 ListPosition; }; -OPERATION_RENDER_PROC(RenderNodeLister) +internal void +RenderNodeLister(panel Panel, rect PanelBounds, render_command_buffer* RenderBufer, app_state* State, context Context, mouse_state Mouse) { node_lister_operation_state* OpState = (node_lister_operation_state*)Operation.OpStateMemory; @@ -132,7 +133,8 @@ FOLDHAUS_INPUT_COMMAND_PROC(CloseColorPickerCommand) CloseColorPicker(State); } -OPERATION_RENDER_PROC(RenderColorPicker) +internal void +RenderColorPicker(panel Panel, rect PanelBounds, render_command_buffer* RenderBufer, app_state* State, context Context, mouse_state Mouse) { color_picker_operation_state* OpState = (color_picker_operation_state*)Operation.OpStateMemory; @@ -200,7 +202,8 @@ struct drag_node_port_operation_state node_interaction Interaction; }; -OPERATION_RENDER_PROC(RenderDraggingNodePort) +internal void +RenderDraggingNodePort(panel Panel, rect PanelBounds, render_command_buffer* RenderBufer, app_state* State, context Context, mouse_state Mouse) { drag_node_port_operation_state* OpState = (drag_node_port_operation_state*)Operation.OpStateMemory; UpdateDraggingNodePort(Mouse.Pos, OpState->Interaction, State->NodeList, @@ -239,7 +242,8 @@ BeginDraggingNodePort(app_state* State, node_interaction Interaction) // /////////////////////////////////////// -OPERATION_RENDER_PROC(RenderDragNodeField) +internal void +RenderDragNodeField(panel Panel, rect PanelBounds, render_command_buffer* RenderBufer, app_state* State, context Context, mouse_state Mouse) { // TODO(Peter): //UpdateDraggingNodeValue(Mouse.Pos, Mouse.OldPos, OpState->Interaction, State->NodeList, State->NodeRenderSettings, State); @@ -262,7 +266,8 @@ struct drag_node_operation_state node_interaction Interaction; }; -OPERATION_RENDER_PROC(RenderDraggingNode) +internal void +RenderDraggingNode(panel Panel, rect PanelBounds, render_command_buffer* RenderBufer, app_state* State, context Context, mouse_state Mouse) { drag_node_operation_state* OpState = GetCurrentOperationState(State->Modes, drag_node_operation_state); UpdateDraggingNode(Mouse.Pos, OpState->Interaction, State->NodeList, @@ -363,7 +368,8 @@ FOLDHAUS_INPUT_COMMAND_PROC(NodeViewBeginMouseSelectInteraction) } } -OPERATION_RENDER_PROC(RenderNodeView) +internal void +RenderNodeView(panel Panel, rect PanelBounds, render_command_buffer* RenderBufer, app_state* State, context Context, mouse_state Mouse) { node_view_operation_state* OpState = (node_view_operation_state*)Operation.OpStateMemory; diff --git a/src/panels/foldhaus_panel_animation_timeline.h b/src/panels/foldhaus_panel_animation_timeline.h index e5f38ea..f477128 100644 --- a/src/panels/foldhaus_panel_animation_timeline.h +++ b/src/panels/foldhaus_panel_animation_timeline.h @@ -213,12 +213,17 @@ input_command AnimationTimeline_Commands[] = { { KeyCode_A, KeyCode_Invalid, Command_Began, AddAnimationBlockCommand }, }; -PANEL_INIT_PROC(AnimationTimeline_Init) + +GSMetaTag(panel_init); +internal void +AnimationTimeline_Init(panel* Panel, app_state* State) { } -PANEL_CLEANUP_PROC(AnimationTimeline_Cleanup) +GSMetaTag(panel_cleanup); +internal void +AnimationTimeline_Cleanup(panel* Panel, app_state* State) { } @@ -419,7 +424,9 @@ DrawAnimationClipsList(rect PanelBounds, mouse_state Mouse, render_command_buffe } -PANEL_RENDER_PROC(AnimationTimeline_Render) +GSMetaTag(panel_render); +internal void +AnimationTimeline_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) { gs_list_handle SelectedBlockHandle = State->SelectedAnimationBlockHandle; diff --git a/src/panels/foldhaus_panel_dmx_view.h b/src/panels/foldhaus_panel_dmx_view.h index ec4de0c..4d9258b 100644 --- a/src/panels/foldhaus_panel_dmx_view.h +++ b/src/panels/foldhaus_panel_dmx_view.h @@ -5,17 +5,23 @@ // #ifndef FOLDHAUS_PANEL_DMX_VIEW_H -PANEL_INIT_PROC(DMXView_Init) +GSMetaTag(panel_init); +internal void +DMXView_Init(panel* Panel, app_state* State) { } -PANEL_CLEANUP_PROC(DMXView_Cleanup) +GSMetaTag(panel_cleanup); +internal void +DMXView_Cleanup(panel* Panel, app_state* State) { } -PANEL_RENDER_PROC(DMXView_Render) +GSMetaTag(panel_render); +internal void +DMXView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) { #if 0 DEBUG_TRACK_SCOPE(DrawUniverseOutputDisplay); diff --git a/src/panels/foldhaus_panel_hierarchy.h b/src/panels/foldhaus_panel_hierarchy.h index c1b53b3..b349d84 100644 --- a/src/panels/foldhaus_panel_hierarchy.h +++ b/src/panels/foldhaus_panel_hierarchy.h @@ -5,17 +5,23 @@ // #ifndef FOLDHAUS_PANEL_HIERARCHY_H -PANEL_INIT_PROC(HierarchyView_Init) +GSMetaTag(panel_init) +internal void +HierarchyView_Init(panel* Panel, app_state* State) { } -PANEL_CLEANUP_PROC(HierarchyView_Cleanup) +GSMetaTag(panel_cleanup); +internal void +HierarchyView_Cleanup(panel* Panel, app_state* State) { } -PANEL_RENDER_PROC(HierarchyView_Render) +GSMetaTag(panel_render); +internal void +HierarchyView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) { r32 PanelWidth = PanelBounds.Max.x - PanelBounds.Min.x; r32 PanelHeight = PanelBounds.Max.y - PanelBounds.Min.y; diff --git a/src/panels/foldhaus_panel_node_graph.h b/src/panels/foldhaus_panel_node_graph.h index 14ce62e..1e478e6 100644 --- a/src/panels/foldhaus_panel_node_graph.h +++ b/src/panels/foldhaus_panel_node_graph.h @@ -172,7 +172,9 @@ input_command NodeGraph_Commands[] = { { 0 } }; -PANEL_INIT_PROC(NodeGraph_Init) +GSMetaTag(panel_init); +internal void +NodeGraph_Init(panel* Panel, app_state* State) { // TODO(Peter): We aren't able to free this memory. We need a system for // taking fixed size chunks off the Memory stack and then reusing them. THis @@ -182,7 +184,9 @@ PANEL_INIT_PROC(NodeGraph_Init) GraphState->LayoutIsDirty = true; } -PANEL_CLEANUP_PROC(NodeGraph_Cleanup) +GSMetaTag(panel_cleanup); +internal void +NodeGraph_Cleanup(panel* Panel, app_state* State) { node_graph_state* GraphState = (node_graph_state*)Panel->PanelStateMemory; FreeMemoryArena(&GraphState->LayoutMemory); @@ -389,8 +393,9 @@ ArrangeNodes(pattern_node_workspace Workspace, r32 NodeWidth, r32 LayerDistance, return Result; } -internal -PANEL_RENDER_PROC(NodeGraph_Render) +GSMetaTag(panel_render); +internal void +NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) { node_graph_state* GraphState = (node_graph_state*)Panel.PanelStateMemory; b32 MouseHandled = false; diff --git a/src/panels/foldhaus_panel_profiler.h b/src/panels/foldhaus_panel_profiler.h index 5cd9c07..c0f5ade 100644 --- a/src/panels/foldhaus_panel_profiler.h +++ b/src/panels/foldhaus_panel_profiler.h @@ -5,12 +5,16 @@ // #ifndef FOLDHAUS_PANEL_PROFILER_H -PANEL_INIT_PROC(ProfilerView_Init) +GSMetaTag(panel_init); +internal void +ProfilerView_Init(panel* Panel, app_state* State) { } -PANEL_CLEANUP_PROC(ProfilerView_Cleanup) +GSMetaTag(panel_cleanup); +internal void +ProfilerView_Cleanup(panel* Panel, app_state* State) { } @@ -114,7 +118,9 @@ RenderProfiler_ListVisualization(render_command_buffer* RenderBuffer, } } -PANEL_RENDER_PROC(ProfilerView_Render) +GSMetaTag(panel_render); +internal void +ProfilerView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) { memory_arena* Memory = &State->Transient; string String = InitializeEmptyString(PushArray(Memory, char, 256), 256); diff --git a/src/panels/foldhaus_panel_sculpture_view.h b/src/panels/foldhaus_panel_sculpture_view.h index 420208f..cbbc4b5 100644 --- a/src/panels/foldhaus_panel_sculpture_view.h +++ b/src/panels/foldhaus_panel_sculpture_view.h @@ -49,12 +49,14 @@ input_command SculptureView_Commands[] = { { KeyCode_MouseLeftButton, KeyCode_Invalid, Command_Began, Begin3DViewMouseRotate }, }; -PANEL_INIT_PROC(SculptureView_Init) +internal void +SculptureView_Init(panel* Panel, app_state* State) { } -PANEL_CLEANUP_PROC(SculptureView_Cleanup) +internal void +SculptureView_Cleanup(panel* Panel, app_state* State) { } @@ -122,7 +124,8 @@ DrawLEDsInBufferRangeJob (s32 ThreadID, void* JobData) } } -PANEL_RENDER_PROC(SculptureView_Render) +internal void +SculptureView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) { DEBUG_TRACK_SCOPE(RenderSculpture); diff --git a/todo.txt b/todo.txt index 07eafd3..5a128f6 100644 --- a/todo.txt +++ b/todo.txt @@ -2,10 +2,15 @@ TODO FOLDHAUS Ground Up Reengineering - Metaprogramming - - refactor for speed - - use #include statements to crawl through the codebase - - generalize the system + x refactor for speed + x use #include statements to crawl through the codebase + x generalize the system - panels metaprogramming + - fix memory layout (remeber to profile before and after) + +- Buckets & Lists + - Allow them to use memory arenas + - Zero is initialization - Rendering - OpenGL 3