From b9f91d7f41e99f0f209fbc5ef318ef2217c89dc8 Mon Sep 17 00:00:00 2001 From: Samuel Audet Date: Sat, 10 Jun 2023 19:37:06 +0900 Subject: [PATCH] * Fix `Parser` on function pointer declarations starting with `typedef struct` (pull bytedeco/javacpp-presets#1361) --- CHANGELOG.md | 2 ++ src/main/java/org/bytedeco/javacpp/tools/Parser.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04576d03..b5fd5634 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ + * Fix `Parser` on function pointer declarations starting with `typedef struct` ([pull bytedeco/javacpp-presets#1361](https://github.com/bytedeco/javacpp-presets/pull/1361)) + ### June 6, 2023 version 1.5.9 * Fix `Loader.extractResource()` for nested JAR files from Spring Boot ([pull #685](https://github.com/bytedeco/javacpp/pull/685)) * Have `Parser` desugar `...` varargs to array `[]` for return types as well ([pull #682](https://github.com/bytedeco/javacpp/pull/682)) diff --git a/src/main/java/org/bytedeco/javacpp/tools/Parser.java b/src/main/java/org/bytedeco/javacpp/tools/Parser.java index 77fca4e0..7f6125cf 100644 --- a/src/main/java/org/bytedeco/javacpp/tools/Parser.java +++ b/src/main/java/org/bytedeco/javacpp/tools/Parser.java @@ -3396,6 +3396,11 @@ boolean group(Context context, DeclarationList declList) throws ParserException } } } + if (typedef && tokens.get().match('(')) { + // this is probably a function pointer declaration + tokens.index = backIndex; + return false; + } if (typedef && type.indirections > 0) { // skip pointer typedef while (!tokens.get().match(';', Token.EOF)) {