Skip to content
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

Feature/c code generation tagged unions #168

Merged
merged 18 commits into from
Jun 23, 2020

Conversation

chrisdutz
Copy link
Contributor

This is the new approach using tagged unions instead of separate types for every sub-type.

…nality into a new BaseFreemarkerLanguageTemplateHelper

- Finished support of array fields
- Finished supporting static function calls in expressions
- Finished supporting enum properties in expressions
…ava version

- Introduced a BaseFreemarkerLanguageTemplateHelper which contains methods usable for multiple code generations
- Updated the mspec definitions to now use the discriminators directly
-- Fixed a lot of little issues.
-- Cleaned up the usage of pointers and no-pointers
@chrisdutz chrisdutz marked this pull request as draft June 16, 2020 19:38
@@ -436,8 +476,45 @@ private String toExpression(Field field, Term term, Function<Term, String> varia
}
}

public String toVariableParseExpression(Field field, Term term, Argument[] parserArguments) {
public String toVariableParseExpression(ComplexTypeDefinition baseType, Field field, Term term, Argument[] parserArguments) {
VariableLiteral vl = (VariableLiteral) term;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"CAST" could be a constant. If there are other things you could do that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah ... correct ... but I think there's only one place where it's used ...

@ottobackwards
Copy link
Contributor

that is too much to look through all of it.
It looks good. A couple of things that come to mind:

  • can we run clang-format after generation?
  • should we be generating some logging?
  • _message as a parameter is strange to me
  • so many (*_message)-> everywhere, can we use a typedef or something?

None of these things are for this PR

@chrisdutz
Copy link
Contributor Author

that is too much to look through all of it.
It looks good. A couple of things that come to mind:

  • can we run clang-format after generation?
  • should we be generating some logging?
  • _message as a parameter is strange to me
  • so many (*_message)-> everywhere, can we use a typedef or something?

None of these things are for this PR

Well I would rather have the code generated in a way that it doesn't require formatting ...

I didn't generate any logging as I didn't know of any logging framework to use ... we could whip up a skeleton of functions that we can use for logging and plug in a "printf" logger or whatever we like to do the actual logging ... that might be a good idea.

As I mentioned before ... I wanted to ensure the internal variable names don't clash with the ones a user can use in mspec ... people tent to get anoyed if they have to use other named due to internal stuff.

Why do we need to typedef that ... It's not that anyone is ever going to write that code ... but if you like, of course that's probably a really simple change.

@ottobackwards
Copy link
Contributor

@chrisdutz that is fair enough. no reason not to keep it like it is

- Fixed the generation of the padding code (which used the "serializer"-arg "lastItem")
- Added skeletons for the lengthInBytes code.
- Made the switch type also save a reference to the enum constant for that type
@chrisdutz chrisdutz marked this pull request as ready for review June 23, 2020 08:15
@chrisdutz chrisdutz merged commit 694c97c into develop Jun 23, 2020
@asfgit asfgit deleted the feature/c-code-generation-tagged-unions branch July 1, 2020 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants