-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add persistent sections to the generated files #35
Comments
I see that this could be a useful feature. I have some doubts about maintaining these user generated sections in the files which are automatically generated, though. There are some cases where it's advantageous to have a clear separation between generated files and user-edited files. This makes it easier for build systems to determine which files have been modified or which files need regeneration. It also makes it easier to keep a clean history in version control, because autogenerated files don't need to be under version control at all and the build system can take care of them. That's more difficult when there is also manually edited code in there, then you need to check them in and need to somehow deal with who commits the autogenerated code. Not requiring special comments in the code which have semantics beyond what the C++ compiler knows about also would be preferable. I see two options to separate autogenerated files and user-maintained files while still enabling the feature to have more control about the autogeneration and inject user-defined parts there:
|
Many thanks for your feedback! The problem with the 1. approach that it could work for when generating XML with the autogenerated code, but the autogenerated parsers would still offer the base classes. But as you mentioned the second option a combined approach came into my mind: what if we create a lookup file which could tell the kxml_compiler to simply replace a given class with an user written class from a separate file. I thinkking about not including code snippets, but directly including user headers and create the user classes in the parse and writer methods where there is a matching lookup . I think we should include the following info in the lookup file:
|
Inspired from the ST CubeMX tool it would be useful to have code sections in the generated codes which would persist between code generations.
Basically the output files needs to be read and parsed before the code generation and a lookup should be created from the contents between the following style comment pairs:
And when generating the code this lookup has to be checked for the currently generated class and the specific saved section needs to be generated.
At the moment I am thinking about the following sections to be supported:
public|protected|private declaration
implementation
But this list could be extended with pre/post sections of the class fields.
Using this feature it would be easy to add custom formatter methods to the generated codes for e.g.
Any comment on this topic is welcome!
The text was updated successfully, but these errors were encountered: