From nbenalla at openjdk.org Sat Jun 1 18:46:23 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Sat, 1 Jun 2024 18:46:23 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v3] In-Reply-To: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: > This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. > I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: Added number references to arguments ------------- Changes: - all: https://git.openjdk.org/jextract/pull/244/files - new: https://git.openjdk.org/jextract/pull/244/files/6adcab3e..40517b4a Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=02 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=01-02 Stats: 241 lines in 5 files changed: 11 ins; 30 del; 200 mod Patch: https://git.openjdk.org/jextract/pull/244.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/244/head:pull/244 PR: https://git.openjdk.org/jextract/pull/244 From nbenalla at openjdk.org Sat Jun 1 18:50:13 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Sat, 1 Jun 2024 18:50:13 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v3] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Sat, 1 Jun 2024 18:46:23 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > Added number references to arguments I hope this approach is more readable. I used `MessageFormat` sparsely, only when the same argument was references multiple times. As code fragments have a lot of curly braces, having to escape them each time it hurt readability. ------------- PR Comment: https://git.openjdk.org/jextract/pull/244#issuecomment-2143546945 From mcimadamore at openjdk.org Tue Jun 4 09:22:36 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Tue, 4 Jun 2024 09:22:36 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v3] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Sat, 1 Jun 2024 18:46:23 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > Added number references to arguments src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 110: > 108: extendsExpr = " extends " + superName; > 109: } > 110: appendLines("%s %s %s%s {", modifiers, kind.kindName, className, extendsExpr); no numbers here? ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625663906 From nbenalla at openjdk.org Tue Jun 4 10:07:40 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Tue, 4 Jun 2024 10:07:40 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v4] In-Reply-To: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: <8aJ6_WJG614w2n2ssyF9UUlgDqGeRv9YK8qzJyECM7o=.c05f237b-f2a4-44be-a6c0-9f1e9716c225@github.com> > This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. > I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: Added more number references ------------- Changes: - all: https://git.openjdk.org/jextract/pull/244/files - new: https://git.openjdk.org/jextract/pull/244/files/40517b4a..8507b053 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=03 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=02-03 Stats: 7 lines in 2 files changed: 0 ins; 0 del; 7 mod Patch: https://git.openjdk.org/jextract/pull/244.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/244/head:pull/244 PR: https://git.openjdk.org/jextract/pull/244 From nbenalla at openjdk.org Tue Jun 4 10:13:12 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Tue, 4 Jun 2024 10:13:12 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: > This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. > I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: Remove space, to not appear in the diff ------------- Changes: - all: https://git.openjdk.org/jextract/pull/244/files - new: https://git.openjdk.org/jextract/pull/244/files/8507b053..1b7ae7cf Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=04 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=03-04 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jextract/pull/244.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/244/head:pull/244 PR: https://git.openjdk.org/jextract/pull/244 From nbenalla at openjdk.org Tue Jun 4 10:13:14 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Tue, 4 Jun 2024 10:13:14 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v3] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: <2beqZ0WB1Is2N-EW-SQzu9rBNWfQFVCBSBmqw_EbUsY=.7514770f-a94b-40ca-bca4-371470afd67d@github.com> On Tue, 4 Jun 2024 09:19:15 GMT, Maurizio Cimadamore wrote: >> Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: >> >> Added number references to arguments > > src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 110: > >> 108: extendsExpr = " extends " + superName; >> 109: } >> 110: appendLines("%s %s %s%s {", modifiers, kind.kindName, className, extendsExpr); > > no numbers here? Fixed in [8507b05](https://github.com/openjdk/jextract/pull/244/commits/8507b0533a46d54cfbd8b040aeddcead3aa70e6d), thanks ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625731028 From jvernee at openjdk.org Tue Jun 4 11:52:30 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Tue, 4 Jun 2024 11:52:30 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v3] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Sat, 1 Jun 2024 18:48:03 GMT, Nizar Benalla wrote: >> Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: >> >> Added number references to arguments > > I hope this approach is more readable. > I used `MessageFormat` sparsely, only when the same argument was references multiple times. As code fragments have a lot of curly braces, having to escape them each time it hurt readability. > Also, I didn't indices when the number of argument was small (1-3) as it was easy to read know which argument was referenced. @nizarbenalla Could you enable github actions for your fork? Then automatic testing can run ------------- PR Comment: https://git.openjdk.org/jextract/pull/244#issuecomment-2147334901 From jvernee at openjdk.org Tue Jun 4 12:33:17 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Tue, 4 Jun 2024 12:33:17 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Tue, 4 Jun 2024 10:13:12 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > Remove space, to not appear in the diff src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 134: > 132: } > 133: void appendLines(String s, String... args) { > 134: sb.appendLines(String.format(s, (Object []) args)); Why is this `Object[]` cast needed here? src/main/java/org/openjdk/jextract/impl/FunctionalInterfaceBuilder.java line 105: > 103: String paramStr = methodType.parameterCount() != 0 ? String.format(",%s", paramExprs()) : ""; > 104: appendIndentedLines(""" > 105: private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); The indentation was changed here it looks like Suggestion: private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 319: > 317: > 318: static { > 319: """); Please keep the indentation, here and in other places. src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 447: > 445: MemorySegment.copy(varValue, 0L, %s.SEGMENT, 0L, %s.LAYOUT.byteSize()); > 446: } > 447: """, javaName, holderClass, holderClass); I suggest using numbers here too, since the param is repeated src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 467: > 465: } > 466: } > 467: """, javaName, indexList.decl(), holderClass, holderClass, indexList.use()); Param is repeated here too, so could re-use `%3$s` src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 491: > 489: MemorySegment.copy(varValue, 0L, {0}({2}), 0L, {3}.byteSize()); > 490: '}' > 491: """, javaName, indexList.decl(), indexList.use(), layoutString(elemType))); Is this the only place where MessageFormat is used? Why just here? (also, indentation was dropped here) src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 583: > 581: runtimeHelperName(), > 582: Utils.quote(Objects.toString(value)), > 583: constantName); Numbers would be nice here to avoid repetition of parameters. src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 591: > 589: constantName, > 590: constantValue(javaType, value)); > 591: emitDocComment(declaration); Suggestion: emitDocComment(declaration); src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 599: > 597: javaType.getSimpleName(), > 598: constantName, > 599: constantName); Numbers here too I think. src/main/java/org/openjdk/jextract/impl/StructBuilder.java line 230: > 228: String valueParam = safeParameterName("fieldValue"); > 229: appendIndentedLines(""" > 230: public static void %1$s(MemorySegment %2$s, MemorySegment %3$s) { Suggestion: public static void %1$s(MemorySegment %2$s, MemorySegment %3$s) { src/main/java/org/openjdk/jextract/impl/StructBuilder.java line 315: > 313: return {0}.asSlice(layout().byteSize() * index); > 314: '}' > 315: """, arrayParam)); This doesn't look right. The javadoc should not be changed here. src/main/java/org/openjdk/jextract/impl/StructBuilder.java line 332: > 330: > 331: /** > 332: * Allocate a segment of size '{'@code layout().byteSize()'}' using {0} Same here, we need to `@code` tag still. src/main/java/org/openjdk/jextract/impl/ToplevelBuilder.java line 106: > 104: files.add(header.toFile(currentSuffix, > 105: s -> s.replace("#{SUFFIX}", currentSuffix) > 106: .replace("#{PREV_SUFFIX}", prevSuffix))); Suggestion: .replace("#{PREV_SUFFIX}", prevSuffix))); ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625844539 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625861003 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625879043 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625873827 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625874986 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625876072 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625895046 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625896344 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625898155 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625901000 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625910948 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625913102 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625864211 From nbenalla at openjdk.org Tue Jun 4 16:31:40 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Tue, 4 Jun 2024 16:31:40 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Tue, 4 Jun 2024 10:13:12 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > Remove space, to not appear in the diff Thanks for the second round of review, I will fix these carefully today. And I have enabled github actions. ------------- PR Comment: https://git.openjdk.org/jextract/pull/244#issuecomment-2147486663 From mcimadamore at openjdk.org Tue Jun 4 16:31:40 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Tue, 4 Jun 2024 16:31:40 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: <3ZxF_WTo3VRgW0amcXUrkuy_8HGp8yOh3NHX3IK0Ud4=.434cd87d-95f5-4452-863b-ddf129e834da@github.com> On Tue, 4 Jun 2024 10:13:12 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > Remove space, to not appear in the diff Overall, it seems to me that we need to decide on a policy on when to use numbering, as the current patch seems inconsistent. I see three options: 1. don't use numbering 2. only use numbering when there are repeated occurrences of same format argument 3. use numbering everywhere I think (1) is where we started from. The current patch seems to be a mix between (2) and (3). In general, (2) might be enough, as it avoids repetition on very long format calls, while not making readability of simple cases overly complex. But I'm also ok with (3) if we prefer keeping same style for all calls. ------------- PR Comment: https://git.openjdk.org/jextract/pull/244#issuecomment-2147496012 From mcimadamore at openjdk.org Tue Jun 4 16:31:46 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Tue, 4 Jun 2024 16:31:46 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: <8F5NEbkLiDgy2-lnXr5_1mgiYgk6lZUetGsLgYv7JEQ=.f58497c3-ea1b-462f-8948-980ed7ba3fa7@github.com> On Tue, 4 Jun 2024 12:24:46 GMT, Jorn Vernee wrote: >> Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: >> >> Remove space, to not appear in the diff > > src/main/java/org/openjdk/jextract/impl/StructBuilder.java line 315: > >> 313: return {0}.asSlice(layout().byteSize() * index); >> 314: '}' >> 315: """, arrayParam)); > > This doesn't look right. The javadoc should not be changed here. The quoting of the `{` also seems suspicious? ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625970832 From nbenalla at openjdk.org Tue Jun 4 16:31:46 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Tue, 4 Jun 2024 16:31:46 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: <8F5NEbkLiDgy2-lnXr5_1mgiYgk6lZUetGsLgYv7JEQ=.f58497c3-ea1b-462f-8948-980ed7ba3fa7@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> <8F5NEbkLiDgy2-lnXr5_1mgiYgk6lZUetGsLgYv7JEQ=.f58497c3-ea1b-462f-8948-980ed7ba3fa7@github.com> Message-ID: <0SQMaZ2ttqT6dWjUJH0raye4REuOLGCOqGktyUyHQL8=.9ea93433-9770-4306-aad6-d1ef22f14c74@github.com> On Tue, 4 Jun 2024 13:05:26 GMT, Maurizio Cimadamore wrote: >> src/main/java/org/openjdk/jextract/impl/StructBuilder.java line 315: >> >>> 313: return {0}.asSlice(layout().byteSize() * index); >>> 314: '}' >>> 315: """, arrayParam)); >> >> This doesn't look right. The javadoc should not be changed here. > > The quoting of the `{` also seems suspicious? This was one of the couple of times where I used `MessageFormat`, so I had to escape the `{` ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625974107 From nbenalla at openjdk.org Tue Jun 4 16:31:46 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Tue, 4 Jun 2024 16:31:46 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: <0SQMaZ2ttqT6dWjUJH0raye4REuOLGCOqGktyUyHQL8=.9ea93433-9770-4306-aad6-d1ef22f14c74@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> <8F5NEbkLiDgy2-lnXr5_1mgiYgk6lZUetGsLgYv7JEQ=.f58497c3-ea1b-462f-8948-980ed7ba3fa7@github.com> <0SQMaZ2ttqT6dWjUJH0raye4REuOLGCOqGktyUyHQL8=.9ea93433-9770-4306-aad6-d1ef22f14c74@github.com> Message-ID: <6Q5oyzlux7sRZpTp2p8ieWGSoSAkttCsFDH4m7F5OLw=.10fb31d2-42b8-4b64-b00e-ec264c671838@github.com> On Tue, 4 Jun 2024 13:07:35 GMT, Nizar Benalla wrote: >> The quoting of the `{` also seems suspicious? > > This was one of the couple of times where I used `MessageFormat`, so I had to escape the `{` This was one of the couple of times where I used MessageFormat, so I had to escape the { ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625974473 From mcimadamore at openjdk.org Tue Jun 4 16:31:55 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Tue, 4 Jun 2024 16:31:55 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: <6Q5oyzlux7sRZpTp2p8ieWGSoSAkttCsFDH4m7F5OLw=.10fb31d2-42b8-4b64-b00e-ec264c671838@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> <8F5NEbkLiDgy2-lnXr5_1mgiYgk6lZUetGsLgYv7JEQ=.f58497c3-ea1b-462f-8948-980ed7ba3fa7@github.com> <0SQMaZ2ttqT6dWjUJH0raye4REuOLGCOqGktyUyHQL8=.9ea93433-9770-4306-aad6-d1ef22f14c74@github.com> <6Q5oyzlux7sRZpTp2p8ieWGSoSAkttCsFDH4m7F5OLw=.10fb31d2-42b8-4b64-b00e-ec264c671838@github.com> Message-ID: On Tue, 4 Jun 2024 13:07:51 GMT, Nizar Benalla wrote: >> This was one of the couple of times where I used `MessageFormat`, so I had to escape the `{` > > This was one of the couple of times where I used MessageFormat, so I had to escape the { I presume we can just drop the call to `Message::format` here and keep `appendIndentedLines`, right? ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625983773 From nbenalla at openjdk.org Tue Jun 4 16:31:55 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Tue, 4 Jun 2024 16:31:55 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> <8F5NEbkLiDgy2-lnXr5_1mgiYgk6lZUetGsLgYv7JEQ=.f58497c3-ea1b-462f-8948-980ed7ba3fa7@github.com> <0SQMaZ2ttqT6dWjUJH0raye4REuOLGCOqGktyUyHQL8=.9ea93433-9770-4306-aad6-d1ef22f14c74@github.com> <6Q5oyzlux7sRZpTp2p8ieWGSoSAkttCsFDH4m7F5OLw=.10fb31d2-42b8-4b64-b00e-ec264c671838@github.com> Message-ID: <4vDjOtcxbTZfihS1XHwdtzmD3YESamQ9BL3n754Q0qI=.d6f6f35d-b4ec-4c5f-a7da-79192dba8adb@github.com> On Tue, 4 Jun 2024 13:13:41 GMT, Maurizio Cimadamore wrote: >> This was one of the couple of times where I used MessageFormat, so I had to escape the { > > I presume we can just drop the call to `Message::format` here and keep `appendIndentedLines`, right? Sure, I will do that. I will try to cover all the suggested fixes in one patch ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1625992079 From jvernee at openjdk.org Tue Jun 4 17:37:09 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Tue, 4 Jun 2024 17:37:09 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: <3ZxF_WTo3VRgW0amcXUrkuy_8HGp8yOh3NHX3IK0Ud4=.434cd87d-95f5-4452-863b-ddf129e834da@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> <3ZxF_WTo3VRgW0amcXUrkuy_8HGp8yOh3NHX3IK0Ud4=.434cd87d-95f5-4452-863b-ddf129e834da@github.com> Message-ID: On Tue, 4 Jun 2024 13:08:46 GMT, Maurizio Cimadamore wrote: > Overall, it seems to me that we need to decide on a policy on when to use numbering, as the current patch seems inconsistent. I see three options: > > 1. don't use numbering > > 2. only use numbering when there are repeated occurrences of same format argument > > 3. use numbering everywhere > > > I think (1) is where we started from. The current patch seems to be a mix between (2) and (3). In general, (2) might be enough, as it avoids repetition on very long format calls, while not making readability of simple cases overly complex. But I'm also ok with (3) if we prefer keeping same style for all calls. I think it makes sense to use numbering for repeated values as well as longer snippets (more than 1-2 lines). Probably for consistency it's better to use numbers everywhere then ------------- PR Comment: https://git.openjdk.org/jextract/pull/244#issuecomment-2148064596 From nbenalla at openjdk.org Wed Jun 5 01:37:07 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 01:37:07 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v5] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Tue, 4 Jun 2024 11:38:24 GMT, Jorn Vernee wrote: >> Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: >> >> Remove space, to not appear in the diff > > src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 134: > >> 132: } >> 133: void appendLines(String s, String... args) { >> 134: sb.appendLines(String.format(s, (Object []) args)); > > Why is this `Object[]` cast needed here? Short answer is that I would get a warning src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java:134: warning: non-varargs call of varargs method with inexact argument type for last parameter; sb.appendLines(String.format(s, args)); ^ cast to Object for a varargs call cast to Object[] for a non-varargs call and to suppress this warning 1 warning Without the cast, javac treats `args` as a simple argument of type `String []` while this is the signature for `String.format` public static String format(String format,Object... args) ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1626812243 From nbenalla at openjdk.org Wed Jun 5 11:15:34 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 11:15:34 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v6] In-Reply-To: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: > This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. > I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: Use numbering everywhere ------------- Changes: - all: https://git.openjdk.org/jextract/pull/244/files - new: https://git.openjdk.org/jextract/pull/244/files/1b7ae7cf..23fdea33 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=05 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=04-05 Stats: 149 lines in 9 files changed: 1 ins; 9 del; 139 mod Patch: https://git.openjdk.org/jextract/pull/244.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/244/head:pull/244 PR: https://git.openjdk.org/jextract/pull/244 From nbenalla at openjdk.org Wed Jun 5 11:26:38 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 11:26:38 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v7] In-Reply-To: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: > This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. > I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: - remove whitespace - fix doc comment ------------- Changes: - all: https://git.openjdk.org/jextract/pull/244/files - new: https://git.openjdk.org/jextract/pull/244/files/23fdea33..042cc415 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=06 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=05-06 Stats: 4 lines in 3 files changed: 0 ins; 0 del; 4 mod Patch: https://git.openjdk.org/jextract/pull/244.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/244/head:pull/244 PR: https://git.openjdk.org/jextract/pull/244 From nbenalla at openjdk.org Wed Jun 5 11:30:09 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 11:30:09 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v7] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Wed, 5 Jun 2024 11:26:38 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > - remove whitespace > - fix doc comment I went with option 3 and simply added numbering everywhere. ------------- PR Comment: https://git.openjdk.org/jextract/pull/244#issuecomment-2149594951 From jvernee at openjdk.org Wed Jun 5 11:39:08 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Wed, 5 Jun 2024 11:39:08 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v7] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Wed, 5 Jun 2024 11:26:38 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > - remove whitespace > - fix doc comment Looks good, thanks. ------------- Marked as reviewed by jvernee (Committer). PR Review: https://git.openjdk.org/jextract/pull/244#pullrequestreview-2098877296 From nbenalla at openjdk.org Wed Jun 5 11:44:13 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 11:44:13 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v7] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Wed, 5 Jun 2024 11:26:38 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > - remove whitespace > - fix doc comment Thanks Jorn for the review, I will wait a bit and see if Maurizio wants any additional changes. ------------- PR Comment: https://git.openjdk.org/jextract/pull/244#issuecomment-2149621165 From mcimadamore at openjdk.org Wed Jun 5 13:28:11 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 5 Jun 2024 13:28:11 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v7] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: <-YjxBZ8t-WJN8vUlr-tvOD5zKAzfk7AZKm-4oo6DMiA=.53eb73c1-8ea5-46ed-9049-ad21a4a7845b@github.com> On Wed, 5 Jun 2024 11:26:38 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > - remove whitespace > - fix doc comment src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 172: > 170: * } > 171: */ > 172: """, !header.isEmpty() ? String.format(" * %1$s\n", header) : "", declarationComment(decl)); optional comment: we could add a `format` method (which just calls String::format) and then implement `appendIndentedLines` on top. I guess what I wonder is if, at some point (not in this PR), it might make sense to create a more specialized format syntax for jextract use to make `%1$s` a bit more readable. ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627783065 From mcimadamore at openjdk.org Wed Jun 5 13:31:20 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 5 Jun 2024 13:31:20 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v7] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Wed, 5 Jun 2024 11:26:38 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > - remove whitespace > - fix doc comment src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 243: > 241: private String primitiveLayoutString(Primitive primitiveType, long align) { > 242: return switch (primitiveType.kind()) { > 243: case Bool -> String.format("%1$s.C_BOOL", runtimeHelperName()); is this more readable than `runtimeHelperName() + ".C_BOOL"` ? I know this is all subjective, but we have a lot of "simple" concatenation which now is using `String::format`. Perhaps worth cleaning up in a separate PR. ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627788190 From nbenalla at openjdk.org Wed Jun 5 14:57:26 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 14:57:26 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v8] In-Reply-To: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: > This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. > I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: remove String::format for simple concatenation ------------- Changes: - all: https://git.openjdk.org/jextract/pull/244/files - new: https://git.openjdk.org/jextract/pull/244/files/042cc415..32a3b6cd Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=07 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=06-07 Stats: 5 lines in 2 files changed: 0 ins; 0 del; 5 mod Patch: https://git.openjdk.org/jextract/pull/244.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/244/head:pull/244 PR: https://git.openjdk.org/jextract/pull/244 From nbenalla at openjdk.org Wed Jun 5 14:57:26 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 14:57:26 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v8] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: <9tc54pQu-acMCU9pGWarPeoWldn8RujcPDnnCrcT3dE=.6bacf2ed-b60e-4fc8-9b10-d79dd3f17a8d@github.com> On Wed, 5 Jun 2024 14:54:56 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > remove String::format for simple concatenation src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 243: > 241: private String primitiveLayoutString(Primitive primitiveType, long align) { > 242: return switch (primitiveType.kind()) { > 243: case Bool -> runtimeHelperName() + ".C_BOOL"; Tiny change to avoid additional fixes in the future src/main/java/org/openjdk/jextract/impl/StructBuilder.java line 390: > 388: > 389: private String emitOffsetFieldDecl(Declaration.Variable field, String javaName) { > 390: String offsetFieldName = javaName + "$OFFSET"; Here too ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627944605 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627944917 From mcimadamore at openjdk.org Wed Jun 5 15:05:12 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 5 Jun 2024 15:05:12 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v7] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Wed, 5 Jun 2024 11:26:38 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > - remove whitespace > - fix doc comment src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 219: > 217: traceDowncall(%5$s); > 218: } > 219: %6$s mh$.invokeExact(%7$s); extra space here? src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 420: > 418: %3$s.SEGMENT.set(%4$s.LAYOUT, 0L, varValue); > 419: } > 420: """, javaName, type.getSimpleName(), holderClass, holderClass); repeated `holderClass` src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 490: > 488: MemorySegment.copy(varValue, 0L, %1$s(%3$s), 0L, %4$s.byteSize()); > 489: } > 490: """, javaName, indexList.decl(), indexList.use(), layoutString(elemType)); changed indentation? src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 512: > 510: Type elemType = Utils.typeOrElemType(varType); > 511: String accessHandle = Utils.isStructOrUnion(elemType) ? > 512: "public static final MethodHandle HANDLE = LAYOUT.sliceHandle(" + path + ");" : I note that here we're using string concat ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627951515 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627953609 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627956498 PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627957334 From nbenalla at openjdk.org Wed Jun 5 15:09:27 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 15:09:27 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v9] In-Reply-To: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: > This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. > I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: -create a new `format` method -fix some indetation/spaces ------------- Changes: - all: https://git.openjdk.org/jextract/pull/244/files - new: https://git.openjdk.org/jextract/pull/244/files/32a3b6cd..fae689a3 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=08 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=07-08 Stats: 10 lines in 2 files changed: 4 ins; 0 del; 6 mod Patch: https://git.openjdk.org/jextract/pull/244.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/244/head:pull/244 PR: https://git.openjdk.org/jextract/pull/244 From nbenalla at openjdk.org Wed Jun 5 15:09:27 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 15:09:27 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v9] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Wed, 5 Jun 2024 15:06:45 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > -create a new `format` method > -fix some indetation/spaces src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 129: > 127: } > 128: > 129: String format(String s, String... args) { I added this method here, then I use it in both `appendLines` and `appendIndentedLines` ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627964301 From mcimadamore at openjdk.org Wed Jun 5 15:16:12 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 5 Jun 2024 15:16:12 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v7] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Wed, 5 Jun 2024 11:26:38 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > - remove whitespace > - fix doc comment Looks good. I'm not too sure about readability of some cases e.g. when we have `String.format("%s %s", a, b)` and add indices (even thought parameters are used in order. But (a) we can address this in a separate PR and (b) for bigger snippets one might argue that it's hard to keep rack of the position at which an argument appears, so having the number in there is handy (so my objection only really applies to the small format strings) and (c) maybe the best way to resolve that is to (as suggested otherwise) use some other kind of custom formatting. ------------- Marked as reviewed by mcimadamore (Reviewer). PR Review: https://git.openjdk.org/jextract/pull/244#pullrequestreview-2099510164 From mcimadamore at openjdk.org Wed Jun 5 15:16:13 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 5 Jun 2024 15:16:13 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v8] In-Reply-To: <9tc54pQu-acMCU9pGWarPeoWldn8RujcPDnnCrcT3dE=.6bacf2ed-b60e-4fc8-9b10-d79dd3f17a8d@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> <9tc54pQu-acMCU9pGWarPeoWldn8RujcPDnnCrcT3dE=.6bacf2ed-b60e-4fc8-9b10-d79dd3f17a8d@github.com> Message-ID: On Wed, 5 Jun 2024 14:54:32 GMT, Nizar Benalla wrote: >> Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: >> >> remove String::format for simple concatenation > > src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 243: > >> 241: private String primitiveLayoutString(Primitive primitiveType, long align) { >> 242: return switch (primitiveType.kind()) { >> 243: case Bool -> runtimeHelperName() + ".C_BOOL"; > > Tiny change to avoid additional fixes in the future If you fix these, shouldn't you fix also the other cases in this switch, for consistency? ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627974691 From mcimadamore at openjdk.org Wed Jun 5 15:16:13 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 5 Jun 2024 15:16:13 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v8] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> <9tc54pQu-acMCU9pGWarPeoWldn8RujcPDnnCrcT3dE=.6bacf2ed-b60e-4fc8-9b10-d79dd3f17a8d@github.com> Message-ID: On Wed, 5 Jun 2024 15:13:23 GMT, Maurizio Cimadamore wrote: >> src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 243: >> >>> 241: private String primitiveLayoutString(Primitive primitiveType, long align) { >>> 242: return switch (primitiveType.kind()) { >>> 243: case Bool -> runtimeHelperName() + ".C_BOOL"; >> >> Tiny change to avoid additional fixes in the future > > If you fix these, shouldn't you fix also the other cases in this switch, for consistency? Ah ok, alignIfNeeded assumes formatting... but, is that a self-inflicted wound? ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627975566 From nbenalla at openjdk.org Wed Jun 5 15:30:16 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 15:30:16 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v9] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Wed, 5 Jun 2024 15:09:27 GMT, Nizar Benalla wrote: >> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. >> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > -create a new `format` method > -fix some indetation/spaces I'm not sure if this project is the best place but we can maybe experiment with different formatters? If no more changes are needed I'll integrate ------------- PR Comment: https://git.openjdk.org/jextract/pull/244#issuecomment-2150356108 From nbenalla at openjdk.org Wed Jun 5 15:42:18 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 15:42:18 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v8] In-Reply-To: References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> <9tc54pQu-acMCU9pGWarPeoWldn8RujcPDnnCrcT3dE=.6bacf2ed-b60e-4fc8-9b10-d79dd3f17a8d@github.com> Message-ID: On Wed, 5 Jun 2024 15:14:01 GMT, Maurizio Cimadamore wrote: >> If you fix these, shouldn't you fix also the other cases in this switch, for consistency? > > Ah ok, alignIfNeeded assumes formatting... but, is that a self-inflicted wound? Let me see. With it being used only 10 times in the codebase, I could rework it. I'd like to avoid an overload. ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1628012648 From nbenalla at openjdk.org Wed Jun 5 15:50:23 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 15:50:23 GMT Subject: RFR: 7903727: Remove the reliance on String Templates feature [v10] In-Reply-To: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: <506z0-pZMB9BPA5vHjOYMvNzLyaE1voqdG7mST3SGJg=.5e735de3-d92a-4b52-9673-e3c839cb5573@github.com> > This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. > I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: revert alignifneed, use simple string concat ------------- Changes: - all: https://git.openjdk.org/jextract/pull/244/files - new: https://git.openjdk.org/jextract/pull/244/files/fae689a3..8fce3e12 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=09 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=244&range=08-09 Stats: 12 lines in 1 file changed: 0 ins; 1 del; 11 mod Patch: https://git.openjdk.org/jextract/pull/244.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/244/head:pull/244 PR: https://git.openjdk.org/jextract/pull/244 From nbenalla at openjdk.org Wed Jun 5 17:38:09 2024 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 5 Jun 2024 17:38:09 GMT Subject: Integrated: 7903727: Remove the reliance on String Templates feature In-Reply-To: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> References: <4Kshzn9LqSROMDpKW6keTHiToz_0C1rkDsQWVHwAjxI=.f1865549-488e-4488-82a2-09c768663c53@github.com> Message-ID: On Mon, 20 May 2024 09:17:22 GMT, Nizar Benalla wrote: > This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23. > I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier. This pull request has now been integrated. Changeset: a6991482 Author: Nizar Benalla Committer: Maurizio Cimadamore URL: https://git.openjdk.org/jextract/commit/a699148238fad919390d67eeb73805e780a518e8 Stats: 324 lines in 9 files changed: 38 ins; 3 del; 283 mod 7903727: Remove the reliance on String Templates feature Reviewed-by: mcimadamore, jvernee ------------- PR: https://git.openjdk.org/jextract/pull/244 From duke at openjdk.org Wed Jun 12 19:56:24 2024 From: duke at openjdk.org (Brayan Munoz V.) Date: Wed, 12 Jun 2024 19:56:24 GMT Subject: RFR: Reference latest JEP of FFM API. In-Reply-To: References: Message-ID: On Tue, 14 May 2024 17:15:37 GMT, Brayan Munoz V. wrote: > Let's reference the JEP 454 which is the latest for FFM API instead of the JEP 442 of the third preview. > > In the README.md the 454 is already being referenced. https://github.com/openjdk/jextract/blob/b4da3284d41863af47d4a36b5829849b27cd47f4/README.md?plain=1#L3 > > Please add the following to the description of the pull request: > > 1. A brief recap of the status quo, as it relates to the subject of the pull request. > 2. A description of why the status quo is problematic. > 3. A description of how this pull request addresses this issue. > 4. If you ran into issues while making changes in the code that you had to work around, > please mention these as well, as this helps reviewers understand the changes that have been made. > > For 1 and 2 it is also okay to refer to the JBS ticket, if that already contains a comprehensive > problem description. > > Please test your pull request before submitting it by running `./gradlew jtreg`. If you're > not able to test locally on your machine, please indicate this in the pull request description, > and indicate which testing has been done instead (or indicate that no testing has been done). > > It is possible to run tests through Github actions if you enable them for your fork (this is free). > Github actions can be enabled for your fork from the 'Actions' tab. The tests will then run > automatically after the pull request has been created. OK. ------------- PR Comment: https://git.openjdk.org/jextract/pull/243#issuecomment-2163791088 From jvernee at openjdk.org Wed Jun 12 20:12:24 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Wed, 12 Jun 2024 20:12:24 GMT Subject: RFR: Reference latest JEP of FFM API. In-Reply-To: References: Message-ID: <_0iApK8D4vQyWcXrThRX2U1Vc_Luk2i5J2OzqHKC7MQ=.216041f3-1457-4b12-941b-74ab88478cdb@github.com> On Wed, 12 Jun 2024 19:53:39 GMT, Brayan Munoz V. wrote: >> Let's reference the JEP 454 which is the latest for FFM API instead of the JEP 442 of the third preview. >> >> In the README.md the 454 is already being referenced. https://github.com/openjdk/jextract/blob/b4da3284d41863af47d4a36b5829849b27cd47f4/README.md?plain=1#L3 >> >> Please add the following to the description of the pull request: >> >> 1. A brief recap of the status quo, as it relates to the subject of the pull request. >> 2. A description of why the status quo is problematic. >> 3. A description of how this pull request addresses this issue. >> 4. If you ran into issues while making changes in the code that you had to work around, >> please mention these as well, as this helps reviewers understand the changes that have been made. >> >> For 1 and 2 it is also okay to refer to the JBS ticket, if that already contains a comprehensive >> problem description. >> >> Please test your pull request before submitting it by running `./gradlew jtreg`. If you're >> not able to test locally on your machine, please indicate this in the pull request description, >> and indicate which testing has been done instead (or indicate that no testing has been done). >> >> It is possible to run tests through Github actions if you enable them for your fork (this is free). >> Github actions can be enabled for your fork from the 'Actions' tab. The tests will then run >> automatically after the pull request has been created. > > OK. @BrayanMnz Please note that you have to initiate the integration yourself by typing `/integrate` (see the instruction in the automated comment above: https://github.com/openjdk/jextract/pull/243#issuecomment-2110743017) ------------- PR Comment: https://git.openjdk.org/jextract/pull/243#issuecomment-2163814784 From duke at openjdk.org Wed Jun 12 22:06:26 2024 From: duke at openjdk.org (Brayan Munoz V.) Date: Wed, 12 Jun 2024 22:06:26 GMT Subject: Integrated: Typo in word directory In-Reply-To: References: Message-ID: On Mon, 29 Apr 2024 18:03:12 GMT, Brayan Munoz V. wrote: > This commit just fix a typo in the word directory. > > Please add the following to the description of the pull request: > > 1. A brief recap of the status quo, as it relates to the subject of the pull request. > 2. A description of why the status quo is problematic. > 3. A description of how this pull request addresses this issue. > 4. If you ran into issues while making changes in the code that you had to work around, > please mention these as well, as this helps reviewers understand the changes that have been made. > > For 1 and 2 it is also okay to refer to the JBS ticket, if that already contains a comprehensive > problem description. > > Please test your pull request before submitting it by running `./gradlew jtreg`. If you're > not able to test locally on your machine, please indicate this in the pull request description, > and indicate which testing has been done instead (or indicate that no testing has been done). > > It is possible to run tests through Github actions if you enable them for your fork (this is free). > Github actions can be enabled for your fork from the 'Actions' tab. The tests will then run > automatically after the pull request has been created. This pull request has now been integrated. Changeset: 5375adf4 Author: Brayan Munoz Vargas <61812255+BrayanMnz at users.noreply.github.com> Committer: Jorn Vernee URL: https://git.openjdk.org/jextract/commit/5375adf4094a0ba8b29bb53d374f2c396e739734 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Typo in word directory Reviewed-by: mcimadamore ------------- PR: https://git.openjdk.org/jextract/pull/240 From duke at openjdk.org Wed Jun 12 22:06:26 2024 From: duke at openjdk.org (Brayan Munoz V.) Date: Wed, 12 Jun 2024 22:06:26 GMT Subject: Integrated: Reference latest JEP of FFM API. In-Reply-To: References: Message-ID: On Tue, 14 May 2024 17:15:37 GMT, Brayan Munoz V. wrote: > Let's reference the JEP 454 which is the latest for FFM API instead of the JEP 442 of the third preview. > > In the README.md the 454 is already being referenced. https://github.com/openjdk/jextract/blob/b4da3284d41863af47d4a36b5829849b27cd47f4/README.md?plain=1#L3 > > Please add the following to the description of the pull request: > > 1. A brief recap of the status quo, as it relates to the subject of the pull request. > 2. A description of why the status quo is problematic. > 3. A description of how this pull request addresses this issue. > 4. If you ran into issues while making changes in the code that you had to work around, > please mention these as well, as this helps reviewers understand the changes that have been made. > > For 1 and 2 it is also okay to refer to the JBS ticket, if that already contains a comprehensive > problem description. > > Please test your pull request before submitting it by running `./gradlew jtreg`. If you're > not able to test locally on your machine, please indicate this in the pull request description, > and indicate which testing has been done instead (or indicate that no testing has been done). > > It is possible to run tests through Github actions if you enable them for your fork (this is free). > Github actions can be enabled for your fork from the 'Actions' tab. The tests will then run > automatically after the pull request has been created. This pull request has now been integrated. Changeset: 5715737b Author: Brayan Munoz V <61812255+BrayanMnz at users.noreply.github.com> Committer: Jorn Vernee URL: https://git.openjdk.org/jextract/commit/5715737be0a1a9de24cce3ee7190881cfc8b1350 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Reference latest JEP of FFM API. Reviewed-by: mcimadamore ------------- PR: https://git.openjdk.org/jextract/pull/243 From sundar at openjdk.org Wed Jun 19 10:05:46 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 10:05:46 GMT Subject: RFR: 7903755: multi header support and special syntax for header file Message-ID: jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. With the current change, jextract supports more than one header file in the command line. When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. ------------- Commit messages: - 7903755: multi header support and special syntax for header file Changes: https://git.openjdk.org/jextract/pull/249/files Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=00 Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903755 Stats: 142 lines in 22 files changed: 76 ins; 29 del; 37 mod Patch: https://git.openjdk.org/jextract/pull/249.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/249/head:pull/249 PR: https://git.openjdk.org/jextract/pull/249 From mcimadamore at openjdk.org Wed Jun 19 10:22:21 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 19 Jun 2024 10:22:21 GMT Subject: RFR: 7903755: multi header support and special syntax for header file In-Reply-To: References: Message-ID: On Wed, 19 Jun 2024 10:01:08 GMT, Athijegannathan Sundararajan wrote: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. src/main/java/org/openjdk/jextract/JextractTool.java line 89: > 87: } > 88: > 89: private static Path generateTmpSource(List headers) { This creates a temp file. It would be good to avoid this and maybe use clang APIs to parse in-memory files? ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1645871770 From mcimadamore at openjdk.org Wed Jun 19 10:26:23 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 19 Jun 2024 10:26:23 GMT Subject: RFR: 7903755: multi header support and special syntax for header file In-Reply-To: References: Message-ID: <9jmDxIr7Z_C-M_GN4Gxg2PXJx65yIHY_sxcPbnclQpA=.e95b79d8-9559-4ace-b74f-8813d34a6b9d@github.com> On Wed, 19 Jun 2024 10:01:08 GMT, Athijegannathan Sundararajan wrote: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. Samples are much better - all the scripts are easier to understand. I think we need to update the guide - as some of the command line option have changed: * e.g. we now accept multiple headers * headers can be provided with two different syntax (e.g. plain and "<>") * if there's multiple headers, then the header class name option *must* be used ------------- PR Review: https://git.openjdk.org/jextract/pull/249#pullrequestreview-2127796808 From sundar at openjdk.org Wed Jun 19 15:13:39 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 15:13:39 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v2] In-Reply-To: References: Message-ID: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: fixed tests for Windows. ------------- Changes: - all: https://git.openjdk.org/jextract/pull/249/files - new: https://git.openjdk.org/jextract/pull/249/files/bc6d050c..63a3f508 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=01 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=00-01 Stats: 78 lines in 2 files changed: 52 ins; 0 del; 26 mod Patch: https://git.openjdk.org/jextract/pull/249.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/249/head:pull/249 PR: https://git.openjdk.org/jextract/pull/249 From sundar at openjdk.org Wed Jun 19 15:13:39 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 15:13:39 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v2] In-Reply-To: References: Message-ID: <-00SPbghDpFCwhegacUHwPDCQ1dnEf7OaZ4fb1cUoAo=.4820203d-2f4a-4a83-a95b-895023e69840@github.com> On Wed, 19 Jun 2024 10:20:11 GMT, Maurizio Cimadamore wrote: >> Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: >> >> fixed tests for Windows. > > src/main/java/org/openjdk/jextract/JextractTool.java line 89: > >> 87: } >> 88: >> 89: private static Path generateTmpSource(List headers) { > > This creates a temp file. It would be good to avoid this and maybe use clang APIs to parse in-memory files? we're using the same trick for macro re-parser. I'll try to revisit this in a future PR ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646369595 From sundar at openjdk.org Wed Jun 19 15:23:49 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 15:23:49 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v3] In-Reply-To: References: Message-ID: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: updated GUIDE.md ------------- Changes: - all: https://git.openjdk.org/jextract/pull/249/files - new: https://git.openjdk.org/jextract/pull/249/files/63a3f508..3edaadad Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=02 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=01-02 Stats: 16 lines in 1 file changed: 15 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jextract/pull/249.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/249/head:pull/249 PR: https://git.openjdk.org/jextract/pull/249 From sundar at openjdk.org Wed Jun 19 15:29:34 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 15:29:34 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v4] In-Reply-To: References: Message-ID: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. Athijegannathan Sundararajan has updated the pull request incrementally with three additional commits since the last revision: - Merge pull request #1 from JornVernee/MultiHeaders_Windows Windows script fixes - update sample scripts - add pwsh script ------------- Changes: - all: https://git.openjdk.org/jextract/pull/249/files - new: https://git.openjdk.org/jextract/pull/249/files/3edaadad..0f0afe91 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=03 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=02-03 Stats: 20 lines in 12 files changed: 8 ins; 2 del; 10 mod Patch: https://git.openjdk.org/jextract/pull/249.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/249/head:pull/249 PR: https://git.openjdk.org/jextract/pull/249 From sundar at openjdk.org Wed Jun 19 16:00:38 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 16:00:38 GMT Subject: RFR: 7903755: multi header support and special syntax for header file Message-ID: jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. With the current change, jextract supports more than one header file in the command line. When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. ------------- Commit messages: - Merge pull request #1 from JornVernee/MultiHeaders_Windows - update sample scripts - add pwsh script - updated GUIDE.md - fixed tests for Windows. - 7903755: multi header support and special syntax for header file Changes: https://git.openjdk.org/jextract/pull/249/files Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=00 Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903755 Stats: 230 lines in 35 files changed: 151 ins; 31 del; 48 mod Patch: https://git.openjdk.org/jextract/pull/249.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/249/head:pull/249 PR: https://git.openjdk.org/jextract/pull/249 From mcimadamore at openjdk.org Wed Jun 19 16:00:38 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 19 Jun 2024 16:00:38 GMT Subject: RFR: 7903755: multi header support and special syntax for header file In-Reply-To: References: Message-ID: <9jmDxIr7Z_C-M_GN4Gxg2PXJx65yIHY_sxcPbnclQpA=.14919fb2-dc6d-48ee-851c-9bc90c553019@github.com> On Wed, 19 Jun 2024 10:01:08 GMT, Athijegannathan Sundararajan wrote: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. Samples are much better - all the scripts are easier to understand. I think we need to update the guide - as some of the command line option have changed: * e.g. we now accept multiple headers * headers can be provided with two different syntax (e.g. plain and "<>") * if there's multiple headers, then the header class name option *must* be used doc/GUIDE.md line 989: > 987: | `--version` | print version information and exit | > 988: > 989: jextract accepts one or more header files. When multiple header files are specified, Suggestion: Jextract accepts one or more header files. When multiple header files are specified, doc/GUIDE.md line 990: > 988: > 989: jextract accepts one or more header files. When multiple header files are specified, > 990: --header-class-name option is mandatory. Header files can be specified in two different ways. Suggestion: the `--header-class-name` option is mandatory. Header files can be specified in two different ways: doc/GUIDE.md line 992: > 990: --header-class-name option is mandatory. Header files can be specified in two different ways. > 991: > 992: 1. simple header file name like "foo.h" or header file path like "bar/foo.h" Suggestion: 1. Simple header file name like "foo.h" or header file path like "bar/foo.h" src/main/java/org/openjdk/jextract/JextractTool.java line 89: > 87: } > 88: > 89: private static Path generateTmpSource(List headers) { This creates a temp file. It would be good to avoid this and maybe use clang APIs to parse in-memory files? ------------- PR Review: https://git.openjdk.org/jextract/pull/249#pullrequestreview-2127796808 PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646454470 PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646454942 PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646455393 PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1645871770 From sundar at openjdk.org Wed Jun 19 16:00:38 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 16:00:38 GMT Subject: RFR: 7903755: multi header support and special syntax for header file In-Reply-To: <9jmDxIr7Z_C-M_GN4Gxg2PXJx65yIHY_sxcPbnclQpA=.14919fb2-dc6d-48ee-851c-9bc90c553019@github.com> References: <9jmDxIr7Z_C-M_GN4Gxg2PXJx65yIHY_sxcPbnclQpA=.14919fb2-dc6d-48ee-851c-9bc90c553019@github.com> Message-ID: <-00SPbghDpFCwhegacUHwPDCQ1dnEf7OaZ4fb1cUoAo=.c648a49b-28f0-4c0b-a98d-97a7acbc43fa@github.com> On Wed, 19 Jun 2024 10:20:11 GMT, Maurizio Cimadamore wrote: >> jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. >> >> With the current change, jextract supports more than one header file in the command line. >> When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. >> >> In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. >> >> jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. > > src/main/java/org/openjdk/jextract/JextractTool.java line 89: > >> 87: } >> 88: >> 89: private static Path generateTmpSource(List headers) { > > This creates a temp file. It would be good to avoid this and maybe use clang APIs to parse in-memory files? we're using the same trick for macro re-parser. I'll try to revisit this in a future PR ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646369595 From mcimadamore at openjdk.org Wed Jun 19 16:04:22 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 19 Jun 2024 16:04:22 GMT Subject: RFR: 7903755: multi header support and special syntax for header file In-Reply-To: References: Message-ID: On Wed, 19 Jun 2024 10:01:08 GMT, Athijegannathan Sundararajan wrote: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. doc/GUIDE.md line 994: > 992: 1. simple header file name like "foo.h" or header file path like "bar/foo.h" > 993: > 994: 2. Special header file path or file name like "", "". Suggestion: 2. Special header file path or file name like ``, ``. doc/GUIDE.md line 995: > 993: > 994: 2. Special header file path or file name like "", "". > 995: With this syntax, the header full or relative path is not required. The usual C compiler I think we should say something like: With this syntax, the header path is considered to be relative to one of the paths in the C compiler include path. doc/GUIDE.md line 997: > 995: With this syntax, the header full or relative path is not required. The usual C compiler > 996: include path search is used in this case. This simplifies the extraction of header files > 997: from standard include paths and include paths specified by -I options. Suggestion: from standard include paths and include paths specified by `-I` options. doc/GUIDE.md line 1000: > 998: > 999: Note that '>' and '<' are special characters in OS Shells and therefore those > 1000: need to be escaped appropriately. On Unix platforms, simple quoting like "" Suggestion: need to be escaped appropriately. On Unix platforms, simple quoting like `""` ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646461940 PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646460308 PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646460673 PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646461392 From mcimadamore at openjdk.org Wed Jun 19 16:07:22 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 19 Jun 2024 16:07:22 GMT Subject: RFR: 7903755: multi header support and special syntax for header file In-Reply-To: References: Message-ID: <6LHGHAkWXsLU3VcxmqxNwpenbK7hXxIGEvLG6DGjQC0=.884c4700-d37a-43ff-be87-7f2f42372a6c@github.com> On Wed, 19 Jun 2024 10:01:08 GMT, Athijegannathan Sundararajan wrote: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. Note: the jextract guide starts off with an example like this: $ jextract \ --include-dir /path/to/mylib/include \ --output src \ --target-package org.jextract.mylib \ --library mylib \ /path/to/mylib/include/mylib.h I think we should either update the example or (maybe preferred, to keep things simple) add a simple para where we say that the command line can be simplified by having jextract look for headers in include paths (link to option section). ------------- PR Review: https://git.openjdk.org/jextract/pull/249#pullrequestreview-2128681819 From sundar at openjdk.org Wed Jun 19 16:39:31 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 16:39:31 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v2] In-Reply-To: References: Message-ID: <5xXhTsdYJugxqkqdJQG_ejJ8xu-2chQsq19_xwIkMnM=.9795ac86-8ed6-46bb-bace-4352b594e2ca@github.com> > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. Athijegannathan Sundararajan has updated the pull request incrementally with six additional commits since the last revision: - Update doc/GUIDE.md Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com> - Update doc/GUIDE.md Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com> - Update doc/GUIDE.md Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com> - Update doc/GUIDE.md Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com> - Update doc/GUIDE.md Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com> - Update doc/GUIDE.md Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com> ------------- Changes: - all: https://git.openjdk.org/jextract/pull/249/files - new: https://git.openjdk.org/jextract/pull/249/files/0f0afe91..2086a6bf Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=01 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=00-01 Stats: 6 lines in 1 file changed: 0 ins; 0 del; 6 mod Patch: https://git.openjdk.org/jextract/pull/249.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/249/head:pull/249 PR: https://git.openjdk.org/jextract/pull/249 From sundar at openjdk.org Wed Jun 19 16:50:33 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 16:50:33 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v3] In-Reply-To: References: Message-ID: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: fixed comment for syntax based on review comments ------------- Changes: - all: https://git.openjdk.org/jextract/pull/249/files - new: https://git.openjdk.org/jextract/pull/249/files/2086a6bf..86a42466 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=02 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=01-02 Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jextract/pull/249.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/249/head:pull/249 PR: https://git.openjdk.org/jextract/pull/249 From sundar at openjdk.org Wed Jun 19 16:58:39 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 16:58:39 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v4] In-Reply-To: References: Message-ID: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: updated section on basic jextract usage for multiple header files and special header syntax with a link to command line option reference based on review comment. ------------- Changes: - all: https://git.openjdk.org/jextract/pull/249/files - new: https://git.openjdk.org/jextract/pull/249/files/86a42466..dfc21574 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=03 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=02-03 Stats: 6 lines in 1 file changed: 2 ins; 0 del; 4 mod Patch: https://git.openjdk.org/jextract/pull/249.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/249/head:pull/249 PR: https://git.openjdk.org/jextract/pull/249 From nlisker at openjdk.org Wed Jun 19 17:08:22 2024 From: nlisker at openjdk.org (Nir Lisker) Date: Wed, 19 Jun 2024 17:08:22 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v4] In-Reply-To: References: Message-ID: On Wed, 19 Jun 2024 16:58:39 GMT, Athijegannathan Sundararajan wrote: >> jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. >> >> With the current change, jextract supports more than one header file in the command line. >> When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. >> >> In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. >> >> jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. > > Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: > > updated section on basic jextract usage for multiple header files and special header syntax > with a link to command line option reference based on review comment. Maybe the command line options table entry for `--header-class-name ` should be updated regarding the mandatory use of it. Currently it says "If this option is not specified", but this is not always valid anymore. ------------- PR Comment: https://git.openjdk.org/jextract/pull/249#issuecomment-2179161760 From mcimadamore at openjdk.org Wed Jun 19 17:08:22 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 19 Jun 2024 17:08:22 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v4] In-Reply-To: References: Message-ID: <1BnFUDHk17Bme3RB2gvI6prS-uuFLzcZM-Uss6TDNHA=.5c4b7dfd-05ce-4d97-8a1d-cb4707047e24@github.com> On Wed, 19 Jun 2024 16:58:39 GMT, Athijegannathan Sundararajan wrote: >> jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. >> >> With the current change, jextract supports more than one header file in the command line. >> When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. >> >> In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. >> >> jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. > > Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: > > updated section on basic jextract usage for multiple header files and special header syntax > with a link to command line option reference based on review comment. doc/GUIDE.md line 1001: > 999: from standard include paths and include paths specified by `-I` options. > 1000: > 1001: Note that '>' and '<' are special characters in OS Shells and therefore those Suggestion: Note that `>` and `<` are special characters in OS Shells and therefore those ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646524068 From sundar at openjdk.org Wed Jun 19 17:12:51 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 17:12:51 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v5] In-Reply-To: References: Message-ID: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. Athijegannathan Sundararajan has updated the pull request incrementally with three additional commits since the last revision: - Update doc/GUIDE.md Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com> - Update doc/GUIDE.md Co-authored-by: Jorn Vernee - updated --header-class-name doc comment in option reference section as per review comment. ------------- Changes: - all: https://git.openjdk.org/jextract/pull/249/files - new: https://git.openjdk.org/jextract/pull/249/files/dfc21574..fcf513f7 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=04 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=249&range=03-04 Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod Patch: https://git.openjdk.org/jextract/pull/249.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/249/head:pull/249 PR: https://git.openjdk.org/jextract/pull/249 From jvernee at openjdk.org Wed Jun 19 17:12:51 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Wed, 19 Jun 2024 17:12:51 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v4] In-Reply-To: References: Message-ID: On Wed, 19 Jun 2024 16:58:39 GMT, Athijegannathan Sundararajan wrote: >> jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. >> >> With the current change, jextract supports more than one header file in the command line. >> When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. >> >> In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. >> >> jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. > > Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: > > updated section on basic jextract usage for multiple header files and special header syntax > with a link to command line option reference based on review comment. doc/GUIDE.md line 63: > 61: should be included. This is also the header file that should be passed to jextract. > 62: > 63: If a library has multiple main header files, they can be passed to jextract in the command line. Suggestion: If a library has multiple main header files, they can be passed to jextract on the command line. doc/GUIDE.md line 991: > 989: | `--version` | print version information and exit | > 990: > 991: Jextract accepts one or more header files. When multiple header files are specified, I suggest adding a header above this section to separate it from the table (like we currently have for the section on clang arguments below) ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646521698 PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646526497 From sundar at openjdk.org Wed Jun 19 17:15:29 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Wed, 19 Jun 2024 17:15:29 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v4] In-Reply-To: References: Message-ID: <9kMEdZjsA7HvTo-6qrFCHrfFKLJBMU-euXPHwSudGjM=.c7436321-e6d5-4724-8a4f-d213bfe9c291@github.com> On Wed, 19 Jun 2024 17:09:21 GMT, Jorn Vernee wrote: >> Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: >> >> updated section on basic jextract usage for multiple header files and special header syntax >> with a link to command line option reference based on review comment. > > doc/GUIDE.md line 991: > >> 989: | `--version` | print version information and exit | >> 990: >> 991: Jextract accepts one or more header files. When multiple header files are specified, > > I suggest adding a header above this section to separate it from the table (like we currently have for the section on clang arguments below) Hmm.. not sure what would be the name. Perhaps move this para above the table? ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646528959 From jvernee at openjdk.org Wed Jun 19 17:23:22 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Wed, 19 Jun 2024 17:23:22 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v5] In-Reply-To: References: Message-ID: <8sUIJ6bdI0WW9a8ly5U6UD2GD_UlleYhJjRtpZVGKo0=.2036e4c1-6029-46d7-ac39-e50ea48dcd6b@github.com> On Wed, 19 Jun 2024 17:12:51 GMT, Athijegannathan Sundararajan wrote: >> jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. >> >> With the current change, jextract supports more than one header file in the command line. >> When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. >> >> In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. >> >> jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. > > Athijegannathan Sundararajan has updated the pull request incrementally with three additional commits since the last revision: > > - Update doc/GUIDE.md > > Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com> > - Update doc/GUIDE.md > > Co-authored-by: Jorn Vernee > - updated --header-class-name doc comment in option reference section as per review comment. Marked as reviewed by jvernee (Committer). ------------- PR Review: https://git.openjdk.org/jextract/pull/249#pullrequestreview-2128790455 From jvernee at openjdk.org Wed Jun 19 17:23:22 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Wed, 19 Jun 2024 17:23:22 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v4] In-Reply-To: <9kMEdZjsA7HvTo-6qrFCHrfFKLJBMU-euXPHwSudGjM=.c7436321-e6d5-4724-8a4f-d213bfe9c291@github.com> References: <9kMEdZjsA7HvTo-6qrFCHrfFKLJBMU-euXPHwSudGjM=.c7436321-e6d5-4724-8a4f-d213bfe9c291@github.com> Message-ID: On Wed, 19 Jun 2024 17:12:46 GMT, Athijegannathan Sundararajan wrote: >> doc/GUIDE.md line 991: >> >>> 989: | `--version` | print version information and exit | >>> 990: >>> 991: Jextract accepts one or more header files. When multiple header files are specified, >> >> I suggest adding a header above this section to separate it from the table (like we currently have for the section on clang arguments below) > > Hmm.. not sure what would be the name. Perhaps move this para above the table? Discussed offline: let's keep it like this ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/249#discussion_r1646534537 From mcimadamore at openjdk.org Wed Jun 19 18:22:21 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 19 Jun 2024 18:22:21 GMT Subject: RFR: 7903755: multi header support and special syntax for header file [v5] In-Reply-To: References: Message-ID: <6Tg3JJaS04VkaYAOVilcprFi5uUU5XAwYSdGzJRJja4=.d7315a76-e0b4-425e-bd0d-e0ef12f3f8f9@github.com> On Wed, 19 Jun 2024 17:12:51 GMT, Athijegannathan Sundararajan wrote: >> jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. >> >> With the current change, jextract supports more than one header file in the command line. >> When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. >> >> In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. >> >> jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. > > Athijegannathan Sundararajan has updated the pull request incrementally with three additional commits since the last revision: > > - Update doc/GUIDE.md > > Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com> > - Update doc/GUIDE.md > > Co-authored-by: Jorn Vernee > - updated --header-class-name doc comment in option reference section as per review comment. Marked as reviewed by mcimadamore (Reviewer). ------------- PR Review: https://git.openjdk.org/jextract/pull/249#pullrequestreview-2128866001 From sundar at openjdk.org Thu Jun 20 03:17:21 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Thu, 20 Jun 2024 03:17:21 GMT Subject: Integrated: 7903755: multi header support and special syntax for header file In-Reply-To: References: Message-ID: On Wed, 19 Jun 2024 10:01:08 GMT, Athijegannathan Sundararajan wrote: > jextract currently supports only one header file. If the user wants to extract more than one header file, s/he has to create a containing header that includes multiple headers and jextract the containing header. > > With the current change, jextract supports more than one header file in the command line. > When multiple headers are specified in command line, --header-class-name option is mandatory and it is enforced. > > In addition to normal file names for header file names, a special syntax such as "" is also supported. With this, user does not have to write long file name including directories such as /usr/include/stdio.h. > > jextract generates multiple headers by generating a temporary header file. If the command line argument is of the form "" then jextract generates "#include " in the auto-generated containing header. If the header specified in of the normal/existing form (say foo.h), then containing header will have #include "foo.h" line. This pull request has now been integrated. Changeset: ffb7c1c1 Author: Athijegannathan Sundararajan URL: https://git.openjdk.org/jextract/commit/ffb7c1c1a9eef65f633a37c2cfcb40eac44611b6 Stats: 237 lines in 35 files changed: 153 ins; 31 del; 53 mod 7903755: multi header support and special syntax for header file Co-authored-by: Jorn Vernee Reviewed-by: mcimadamore, jvernee ------------- PR: https://git.openjdk.org/jextract/pull/249 From sundar at openjdk.org Thu Jun 20 13:38:44 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Thu, 20 Jun 2024 13:38:44 GMT Subject: RFR: 7903758: jextract can avoid temporary file creation for single simple header case Message-ID: <2pkPloCJUs4Kc5Q25-88iLaU-LF0gmwAsTSBf2LedRs=.2e1497b7-91d0-4793-962a-1ab46d23a09f@github.com> jextract creates a temporary file to support multiple headers and special header syntax . But, temporary file creation can be avoided for single, simple header file/path case. ------------- Commit messages: - 7903758: jextract can avoid temporary file creation for single simple header case Changes: https://git.openjdk.org/jextract/pull/250/files Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=250&range=00 Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903758 Stats: 33 lines in 2 files changed: 25 ins; 5 del; 3 mod Patch: https://git.openjdk.org/jextract/pull/250.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/250/head:pull/250 PR: https://git.openjdk.org/jextract/pull/250 From sundar at openjdk.org Thu Jun 20 14:38:24 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Thu, 20 Jun 2024 14:38:24 GMT Subject: Withdrawn: 7903758: jextract can avoid temporary file creation for single simple header case In-Reply-To: <2pkPloCJUs4Kc5Q25-88iLaU-LF0gmwAsTSBf2LedRs=.2e1497b7-91d0-4793-962a-1ab46d23a09f@github.com> References: <2pkPloCJUs4Kc5Q25-88iLaU-LF0gmwAsTSBf2LedRs=.2e1497b7-91d0-4793-962a-1ab46d23a09f@github.com> Message-ID: <5n21KhHYEfEZQuayF4bPUZMsTz7srBW5thvC2BsIBQ8=.2ec41d84-762b-49c6-ae5e-53a7af55e5c7@github.com> On Thu, 20 Jun 2024 13:33:36 GMT, Athijegannathan Sundararajan wrote: > jextract creates a temporary file to support multiple headers and special header syntax . But, temporary file creation can be avoided for single, simple header file/path case. This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.org/jextract/pull/250 From sundar at openjdk.org Tue Jun 25 11:27:49 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 11:27:49 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation Message-ID: jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile ------------- Commit messages: - trailing whitespace removed - 7903758: jextract should avoid temporary file creation Changes: https://git.openjdk.org/jextract/pull/251/files Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=00 Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903758 Stats: 3378 lines in 13 files changed: 2466 ins; 66 del; 846 mod Patch: https://git.openjdk.org/jextract/pull/251.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/251/head:pull/251 PR: https://git.openjdk.org/jextract/pull/251 From sundar at openjdk.org Tue Jun 25 11:35:34 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 11:35:34 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v2] In-Reply-To: References: Message-ID: <7rHYGbRsTOxuIlG3psIEMzJ6NS9vK2hER-RJnR_RIIk=.f7b8eef5-3a32-482c-bb09-52835dec365e@github.com> > jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: fixed Windows clang dll name. ------------- Changes: - all: https://git.openjdk.org/jextract/pull/251/files - new: https://git.openjdk.org/jextract/pull/251/files/82011879..ed14dea8 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=01 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=00-01 Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jextract/pull/251.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/251/head:pull/251 PR: https://git.openjdk.org/jextract/pull/251 From sundar at openjdk.org Tue Jun 25 12:18:33 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 12:18:33 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v3] In-Reply-To: References: Message-ID: > jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: whitespace issue in codegenerator. Regenerated clang binding ------------- Changes: - all: https://git.openjdk.org/jextract/pull/251/files - new: https://git.openjdk.org/jextract/pull/251/files/ed14dea8..8ca6c525 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=02 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=01-02 Stats: 1073 lines in 11 files changed: 8 ins; 1056 del; 9 mod Patch: https://git.openjdk.org/jextract/pull/251.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/251/head:pull/251 PR: https://git.openjdk.org/jextract/pull/251 From jvernee at openjdk.org Tue Jun 25 12:32:22 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Tue, 25 Jun 2024 12:32:22 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v3] In-Reply-To: References: Message-ID: On Tue, 25 Jun 2024 12:18:33 GMT, Athijegannathan Sundararajan wrote: >> jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile > > Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: > > whitespace issue in codegenerator. Regenerated clang binding src/main/java/org/openjdk/jextract/clang/Index.java line 130: > 128: return rv; > 129: } > 130: } Can't we use `clang_parseTranslationUnit2`? It also supports unsaved files, but also supports returning error codes. I suppose `clang_createTranslationUnitFromSourceFile` returns `NULL` if parsing fails. ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/251#discussion_r1652720144 From jvernee at openjdk.org Tue Jun 25 12:35:24 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Tue, 25 Jun 2024 12:35:24 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v3] In-Reply-To: References: Message-ID: On Tue, 25 Jun 2024 12:27:48 GMT, Jorn Vernee wrote: >> Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: >> >> whitespace issue in codegenerator. Regenerated clang binding > > src/main/java/org/openjdk/jextract/clang/Index.java line 130: > >> 128: return rv; >> 129: } >> 130: } > > Can't we use `clang_parseTranslationUnit2`? It also supports unsaved files, but also supports returning error codes. I suppose `clang_createTranslationUnitFromSourceFile` returns `NULL` if parsing fails. I suggest trying to extend the existing `parseTU` to also accept a list of `Index.UnsavedFile` ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/251#discussion_r1652730586 From sundar at openjdk.org Tue Jun 25 14:02:47 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 14:02:47 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v4] In-Reply-To: References: Message-ID: <_WQNdmloQUTdoHoaFRtJMuA0XL9fMOl58o6SWUUzehw=.bd9c6029-54fa-4c6a-9b31-ec65d829ab31@github.com> > jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: Using clang_parseTranslationUnit2 instead of clang_createTranslationUnitFromSourceFile. ------------- Changes: - all: https://git.openjdk.org/jextract/pull/251/files - new: https://git.openjdk.org/jextract/pull/251/files/8ca6c525..267c889d Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=03 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=02-03 Stats: 116 lines in 3 files changed: 17 ins; 85 del; 14 mod Patch: https://git.openjdk.org/jextract/pull/251.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/251/head:pull/251 PR: https://git.openjdk.org/jextract/pull/251 From jvernee at openjdk.org Tue Jun 25 14:13:34 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Tue, 25 Jun 2024 14:13:34 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v4] In-Reply-To: <_WQNdmloQUTdoHoaFRtJMuA0XL9fMOl58o6SWUUzehw=.bd9c6029-54fa-4c6a-9b31-ec65d829ab31@github.com> References: <_WQNdmloQUTdoHoaFRtJMuA0XL9fMOl58o6SWUUzehw=.bd9c6029-54fa-4c6a-9b31-ec65d829ab31@github.com> Message-ID: On Tue, 25 Jun 2024 14:02:47 GMT, Athijegannathan Sundararajan wrote: >> jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile > > Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: > > Using clang_parseTranslationUnit2 instead of clang_createTranslationUnitFromSourceFile. src/main/java/org/openjdk/jextract/impl/Parser.java line 111: > 109: } > 110: > 111: public Declaration.Scoped parse(String name, String content, Collection args) { The only use of this method seems to be in `JextractTool`, so I think the old version can just be removed? ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/251#discussion_r1652899192 From sundar at openjdk.org Tue Jun 25 14:25:56 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 14:25:56 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v5] In-Reply-To: References: Message-ID: > jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: removed unused Parser.parse overload as suggested in review ------------- Changes: - all: https://git.openjdk.org/jextract/pull/251/files - new: https://git.openjdk.org/jextract/pull/251/files/267c889d..76709f6e Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=04 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=03-04 Stats: 14 lines in 1 file changed: 0 ins; 14 del; 0 mod Patch: https://git.openjdk.org/jextract/pull/251.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/251/head:pull/251 PR: https://git.openjdk.org/jextract/pull/251 From sundar at openjdk.org Tue Jun 25 14:25:56 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 14:25:56 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v4] In-Reply-To: <_WQNdmloQUTdoHoaFRtJMuA0XL9fMOl58o6SWUUzehw=.bd9c6029-54fa-4c6a-9b31-ec65d829ab31@github.com> References: <_WQNdmloQUTdoHoaFRtJMuA0XL9fMOl58o6SWUUzehw=.bd9c6029-54fa-4c6a-9b31-ec65d829ab31@github.com> Message-ID: On Tue, 25 Jun 2024 14:02:47 GMT, Athijegannathan Sundararajan wrote: >> jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile > > Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: > > Using clang_parseTranslationUnit2 instead of clang_createTranslationUnitFromSourceFile. Evolution of this PR: * We thought we eeded a new clang function clang_createTranslationUnitFromSourceFile * Regenerated the clang bindings with the extra function * When doing that realized the generated bindings contained an issue in javadoc comments (extra whitespace and extra "}") * Then, realised that we can make use of existing clang binding clang_parseTranslationUnit2 (code review comment by @JornVernee ) * Dropped the new clang function clang_createTranslationUnitFromSourceFile in binding * But we're keeping regenerated clang bindings along with the codegen fix (as these are nice to have) - even though this is not strictly related to the current PR. ------------- PR Comment: https://git.openjdk.org/jextract/pull/251#issuecomment-2189103005 From sundar at openjdk.org Tue Jun 25 14:25:56 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 14:25:56 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v4] In-Reply-To: References: <_WQNdmloQUTdoHoaFRtJMuA0XL9fMOl58o6SWUUzehw=.bd9c6029-54fa-4c6a-9b31-ec65d829ab31@github.com> Message-ID: On Tue, 25 Jun 2024 14:10:50 GMT, Jorn Vernee wrote: >> Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: >> >> Using clang_parseTranslationUnit2 instead of clang_createTranslationUnitFromSourceFile. > > src/main/java/org/openjdk/jextract/impl/Parser.java line 111: > >> 109: } >> 110: >> 111: public Declaration.Scoped parse(String name, String content, Collection args) { > > The only use of this method seems to be in `JextractTool`, so I think the old version can just be removed? Will remove it. ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/251#discussion_r1652933467 From jvernee at openjdk.org Tue Jun 25 14:51:27 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Tue, 25 Jun 2024 14:51:27 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v5] In-Reply-To: References: Message-ID: <3NBNAhccpv5UpCwpS0bvk-eRiqkS4NwgkTokgPgb1B4=.803b6eef-c4bd-4348-8c13-3e8074cbbfcc@github.com> On Tue, 25 Jun 2024 14:25:56 GMT, Athijegannathan Sundararajan wrote: >> jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile > > Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: > > removed unused Parser.parse overload as suggested in review src/main/java/org/openjdk/jextract/clang/Index.java line 68: > 66: } > 67: > 68: public ParsingFailedException(String srcFile, ErrorCode code) { Where is this new constructor being used? src/main/java/org/openjdk/jextract/clang/Index.java line 119: > 117: > 118: > 119: public TranslationUnit parseTU(String file, Consumer dh, int options, String... args) Can't the methods here that _don't_ take a file content be cleaned up as well now? ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/251#discussion_r1652978284 PR Review Comment: https://git.openjdk.org/jextract/pull/251#discussion_r1652979400 From sundar at openjdk.org Tue Jun 25 14:58:56 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 14:58:56 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v6] In-Reply-To: References: Message-ID: > jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: removed temporary empty file usage in MacroParserImpl ------------- Changes: - all: https://git.openjdk.org/jextract/pull/251/files - new: https://git.openjdk.org/jextract/pull/251/files/76709f6e..6b22878d Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=05 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=04-05 Stats: 9 lines in 2 files changed: 0 ins; 2 del; 7 mod Patch: https://git.openjdk.org/jextract/pull/251.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/251/head:pull/251 PR: https://git.openjdk.org/jextract/pull/251 From sundar at openjdk.org Tue Jun 25 15:03:31 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 15:03:31 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v5] In-Reply-To: <3NBNAhccpv5UpCwpS0bvk-eRiqkS4NwgkTokgPgb1B4=.803b6eef-c4bd-4348-8c13-3e8074cbbfcc@github.com> References: <3NBNAhccpv5UpCwpS0bvk-eRiqkS4NwgkTokgPgb1B4=.803b6eef-c4bd-4348-8c13-3e8074cbbfcc@github.com> Message-ID: On Tue, 25 Jun 2024 14:48:34 GMT, Jorn Vernee wrote: >> Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: >> >> removed unused Parser.parse overload as suggested in review > > src/main/java/org/openjdk/jextract/clang/Index.java line 119: > >> 117: >> 118: >> 119: public TranslationUnit parseTU(String file, Consumer dh, int options, String... args) > > Can't the methods here that _don't_ take a file content be cleaned up as well now? It was used in macro parser. But with changes in macro parse implementation, these may not be. Will remove. ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/251#discussion_r1653000385 From sundar at openjdk.org Tue Jun 25 15:09:48 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 15:09:48 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v7] In-Reply-To: References: Message-ID: <_-Wfc2mhRx8T2KOWiam3rwJN0QGKRIPOmaExKD5TisQ=.35f580b7-231e-4a39-8c81-d5f688ad63eb@github.com> > jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: removed parseTU, parse variants that do not accept file content (review comments) ------------- Changes: - all: https://git.openjdk.org/jextract/pull/251/files - new: https://git.openjdk.org/jextract/pull/251/files/6b22878d..ba2104f1 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=06 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=05-06 Stats: 32 lines in 1 file changed: 0 ins; 24 del; 8 mod Patch: https://git.openjdk.org/jextract/pull/251.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/251/head:pull/251 PR: https://git.openjdk.org/jextract/pull/251 From sundar at openjdk.org Tue Jun 25 15:12:26 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 15:12:26 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v5] In-Reply-To: <3NBNAhccpv5UpCwpS0bvk-eRiqkS4NwgkTokgPgb1B4=.803b6eef-c4bd-4348-8c13-3e8074cbbfcc@github.com> References: <3NBNAhccpv5UpCwpS0bvk-eRiqkS4NwgkTokgPgb1B4=.803b6eef-c4bd-4348-8c13-3e8074cbbfcc@github.com> Message-ID: On Tue, 25 Jun 2024 14:47:52 GMT, Jorn Vernee wrote: >> Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: >> >> removed unused Parser.parse overload as suggested in review > > src/main/java/org/openjdk/jextract/clang/Index.java line 68: > >> 66: } >> 67: >> 68: public ParsingFailedException(String srcFile, ErrorCode code) { > > Where is this new constructor being used? will check and remove one of the constructors ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/251#discussion_r1653013992 From sundar at openjdk.org Tue Jun 25 15:21:48 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 15:21:48 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v8] In-Reply-To: References: Message-ID: > jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: avoid Path in ParsingFailedException. ------------- Changes: - all: https://git.openjdk.org/jextract/pull/251/files - new: https://git.openjdk.org/jextract/pull/251/files/ba2104f1..5575e8f2 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=07 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=251&range=06-07 Stats: 6 lines in 1 file changed: 0 ins; 5 del; 1 mod Patch: https://git.openjdk.org/jextract/pull/251.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/251/head:pull/251 PR: https://git.openjdk.org/jextract/pull/251 From jvernee at openjdk.org Tue Jun 25 15:21:48 2024 From: jvernee at openjdk.org (Jorn Vernee) Date: Tue, 25 Jun 2024 15:21:48 GMT Subject: RFR: 7903758: jextract should avoid temporary file creation [v8] In-Reply-To: References: Message-ID: On Tue, 25 Jun 2024 15:18:28 GMT, Athijegannathan Sundararajan wrote: >> jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile > > Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision: > > avoid Path in ParsingFailedException. Marked as reviewed by jvernee (Committer). ------------- PR Review: https://git.openjdk.org/jextract/pull/251#pullrequestreview-2139008079 From sundar at openjdk.org Tue Jun 25 15:30:26 2024 From: sundar at openjdk.org (Athijegannathan Sundararajan) Date: Tue, 25 Jun 2024 15:30:26 GMT Subject: Integrated: 7903758: jextract should avoid temporary file creation In-Reply-To: References: Message-ID: <92SXrHSEbJJPxWYcHh2nfm1RS4oTrRbPXMt4Ex0JsI8=.46e26211-2d74-4073-8d5a-4709f4457026@github.com> On Tue, 25 Jun 2024 11:16:44 GMT, Athijegannathan Sundararajan wrote: > jextract creates a temporary file to support multiple headers and special header syntax . This patch avoids that temporary file creation by using clang's in-memory parsing API clang_createTranslationUnitFromSourceFile This pull request has now been integrated. Changeset: 26dee164 Author: Athijegannathan Sundararajan URL: https://git.openjdk.org/jextract/commit/26dee164ede28e02b398147871e410b2d854c0f6 Stats: 2245 lines in 8 files changed: 1313 ins; 73 del; 859 mod 7903758: jextract should avoid temporary file creation Reviewed-by: jvernee ------------- PR: https://git.openjdk.org/jextract/pull/251