Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of functions parameters in template arguments #693

Merged
merged 3 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Fix `Parser` for function parameters contained in template arguments ([pull #693](https://github.com/bytedeco/javacpp/pull/693))
* 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
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/org/bytedeco/javacpp/tools/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,43 @@ Type[] templateArguments(Context context) throws ParserException {
Type type = type(context);
arguments.add(type);
token = tokens.get();
if (token.match('(')) {
Parameters p = parameters(context, 0, false);
if (p != null) {
// Build prototype string, without space after comma
type.cppName += "(";
String separator = "";
for (Declarator d : p.declarators) {
if (d != null) {
String s = d.type.cppName;
if (d.type.constValue && !s.startsWith("const ")) {
s = "const " + s;
}
for (int i = 0; i < d.indirections; i++) {
s += "*";
}
if (d.reference) {
s += "&";
}
if (d.rvalue) {
s += "&&";
}
if (d.type.constPointer && !s.endsWith(" const")) {
s = s + " const";
}
type.cppName += separator + s;
separator = ",";
}
}
type.cppName += ")";
token = tokens.get();
if (token.match('<')) {
// probably an actual less than, skip.
tokens.next();
token = tokens.get();
}
}
}
if (!token.match(',', '>') && type != null) {
// may not actually be a type
int count = 0;
Expand Down