RFR: Use regex match when looking for unnamed struct/union/enum in doc comment

Jorn Vernee jvernee at openjdk.org
Mon Jan 22 12:50:19 UTC 2024


On Mon, 22 Jan 2024 12:43:32 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> Noticed this small issue when running the samples. We try to look for an anonymous struct in the doc comments we generate. Clang will put the file path of the file containing the struct in the declaration string, which causes all kinds of problems, so we filter it out. A regular expression is used for this, however, it is passed to `String::contains`, which doesn't accept a regex. Switch to `String::matches` so it works.
> 
> - I've added a new test case to TestDocComments
> - I've also renamed the enclosing folder of this test, since it still had the bug id as a name (while the test itself doesn't)
> - I also noticed an issue in the TestGlobalStructAccess test. We access a global variable with a struct type, but this variable is not marked as exported, so the test fails on Windows.

test/testng/org/openjdk/jextract/test/toolprovider/docComments/TestDocComments.java line 183:

> 181:             "Setter for field: long long h",
> 182:             "Getter for field: struct { int l; long long h; } u",
> 183:             "Setter for field: struct { int l; long long h; } u"));

Note that these last 2 comments would contain file paths without the fix.

When I was extracting Windows.h, some file paths contain `*\um*` (which is an include directory in the Windows SDK), and this leads javac to complain about invalid unicode escape sequences.

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

PR Review Comment: https://git.openjdk.org/jextract/pull/190#discussion_r1461808168


More information about the jextract-dev mailing list