Skip to content

Conversation

@backkem
Copy link

@backkem backkem commented Nov 4, 2024

As mentioned in #8 this PR adds support for structs & enums. I needed a couple of out-of-spec things to get an ergonomic result for my file, I tried to create generic abstractions to support those needs as a library user:

  • Architecture: allows you to choose between generating int, int32, int64 etc.
  • IdentifierPrefix: Allows you to prefix all types, this is handy when the code needs to live in a larger repo.
  • FieldTagName: allows you to choose the name of the struct tag. For example I need codec for ugorji/go/codec.
  • IdentifierFormatter: Allows you to override identifier formatting. In my case the CDDL file uses integer keys but I can generate better names using the trailing comments.
  • CommentHandler: allows you to provide custom handling for comments. This allows me to gather the type key from my file.

Hopefully the result isn't overly opinionated.

I'm sorry for the big PR but I probably won't find the time to land it in smaller chunks. Happy to address concerns though.

closes #8

@HannesKimara HannesKimara self-requested a review November 7, 2024 14:41
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.

Code generation: struct & enum

1 participant