RFR: 7903595: Leverage String templates [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Nov 27 22:08:34 UTC 2023
On Mon, 27 Nov 2023 18:24:51 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> 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.
>
> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
>
> use string templates in SourceFileBuilder too
Overall looks good - much easier to read!
Do we need build changes to enable preview?
src/main/java/org/openjdk/jextract/impl/Constants.java line 431:
> 429: private Constant emitConstantString(Object value) {
> 430: NamedConstant segConstant = new NamedConstant(MemorySegment.class);
> 431: appendIndentedLines(STR."""
the `emitLayoutString` method could use a similar treatment - at least for some aspects?
-------------
Marked as reviewed by mcimadamore (Committer).
PR Review: https://git.openjdk.org/jextract/pull/144#pullrequestreview-1751476212
PR Comment: https://git.openjdk.org/jextract/pull/144#issuecomment-1828698915
PR Review Comment: https://git.openjdk.org/jextract/pull/144#discussion_r1406814462
More information about the jextract-dev
mailing list