Implement DqnInspectEnum_Count function

This commit is contained in:
doyle 2019-04-05 23:18:54 +11:00
parent 3c447706c9
commit 41ac05b401
2 changed files with 15 additions and 1 deletions

View File

@ -45,6 +45,9 @@
// ================================================================================================= // =================================================================================================
// See Data/DqnInspect_TestData.h // See Data/DqnInspect_TestData.h
// TODO(doyle): Make the enum system similar to struct members for consistency?
// TODO(doyle): Handle namespaces .. maybe.
#define DQN_INSPECT #define DQN_INSPECT
#define DQN_INSPECT_META(...) #define DQN_INSPECT_META(...)
#define DQN_INSPECT_GENERATE_PROTOTYPE(...) #define DQN_INSPECT_GENERATE_PROTOTYPE(...)
@ -1744,7 +1747,7 @@ int main(int argc, char *argv[])
} }
// //
// Write InspectEnumString Function // NOTE: Write DqnInspectEnum_Stringify Function
// //
{ {
FprintfIndented(output_file, indent_level, "char const *DqnInspectEnum_Stringify(%.*s val, int *len = nullptr)\n{\n", parsed_enum->name.len, parsed_enum->name.str); FprintfIndented(output_file, indent_level, "char const *DqnInspectEnum_Stringify(%.*s val, int *len = nullptr)\n{\n", parsed_enum->name.len, parsed_enum->name.str);
@ -1809,6 +1812,15 @@ int main(int argc, char *argv[])
} }
} }
//
// NOTE: Write DqnInspectEnum_Count Function
//
{
int count = 0;
for (CPPDeclLinkedList<Slice<char>> *link = parsed_enum->members; link; link = link->next) count++;
FprintfIndented(output_file, indent_level, "int DqnInspectEnum_Count(%.*s) { return %d; }\n\n", parsed_enum->name.len, parsed_enum->name.str, count);
}
// //
// NOTE: Write User Annotated Metadata Getter Functions // NOTE: Write User Annotated Metadata Getter Functions
// //

View File

@ -287,6 +287,8 @@ char const *DqnInspectEnum_Stringify(EnumWithMetadata val, int *len = nullptr)
return nullptr; return nullptr;
} }
int DqnInspectEnum_Count(EnumWithMetadata) { return 3; }
char const * DqnInspectMetadata_FilePath(EnumWithMetadata val) char const * DqnInspectMetadata_FilePath(EnumWithMetadata val)
{ {
if (val == EnumWithMetadata::Rect) { return "Rect.vert"; } if (val == EnumWithMetadata::Rect) { return "Rect.vert"; }