Assemberist / cppRpg

0 stars 0 forks source link

Create generator for enums #33

Closed Assemberist closed 7 months ago

Assemberist commented 8 months ago

There is seweral enums in project that can be printed. Now const char* arrays are used for them. But it requre to keep source files fith string values for them.

The strings are same as enum values most times.

New generator should analyse values of the enums and generate .cpp files with function that returns string values for every enum value.

Also it allow to unificate access to enum name and possibly simplify interface functions.

Assemberist commented 8 months ago

Blocked by #34.

Assemberist commented 8 months ago

Generator ready, next steps are:

1) Merge changes from #34 2) Include the generator to common build system 3) Change using of arrays with strings to functions get_enum_name(); 4) Improve text fields: they can use get_enum_name() function to get name of enum. So the functions can be part of a class which can be child of common parent class. And so name of every enum can be received through the parent class.

Assemberist commented 8 months ago

The variant with generation from text files is done, but one issue was observed: make rebuild all files that uses generated files. The generator can be changed: it can use .hpp files with enums instead of test files.

It allow perform recompilation only when .hpp file is changed, decrease scope of generation and also simplify it.

Assemberist commented 8 months ago

Work branch merged with ISSUE_034.

Assemberist commented 7 months ago

New generator (builds .cpp files on base .hpp) was implemented and integrated into common build system. Recompilation of enums executed only if some files (build targets) changed.