RFR: 7903595: Leverage String templates

Jorn Vernee jvernee at openjdk.org
Mon Nov 27 18:17:47 UTC 2023


Leverage string templates for source code generation. This makes it much easier to see at a glance what the code that is being generated looks like. It's also a very convenient way of writing this kind of code going forward, and is a good test for the new language feature.

Note that I didn't touch the `Constants::emitLayoutField` and `Constants::emitFunctionDescField`, since they do some pretty complex inline generation to render layouts. I didn't feel like this was worth messing with since we are planning to replace the separate constant classes nay way. Though, I did re-write some of the other methods in `Constants` since they were low-hanging fruits.

-------------

Commit messages:
 - leverage string templates in Constants.java in some cases
 - renamed appendIndented
 - WIP - use string templates

Changes: https://git.openjdk.org/jextract/pull/144/files
 Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=144&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903595
  Stats: 513 lines in 6 files changed: 102 ins; 244 del; 167 mod
  Patch: https://git.openjdk.org/jextract/pull/144.diff
  Fetch: git fetch https://git.openjdk.org/jextract.git pull/144/head:pull/144

PR: https://git.openjdk.org/jextract/pull/144


More information about the jextract-dev mailing list