Skip to content

Commit

Permalink
* Fix TokenIndexer failure on macros using the concat ## operato…
Browse files Browse the repository at this point in the history
…r with empty arguments (issue #525)
  • Loading branch information
saudet committed Dec 19, 2021
1 parent 1c72e35 commit ed47300
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Fix `TokenIndexer` failure on macros using the concat `##` operator with empty arguments ([issue #525](https://github.com/bytedeco/javacpp/issues/525))
* Let `Parser` support arrays of anonymous `struct` or `union` containing another one ([discussion #528](https://github.com/bytedeco/javacpp/discussions/528))
* Prevent `Parser` from outputting duplicate `Pointer` constructors for basic containers
* Fix `Generator` compiler errors on callback functions returning objects without default constructors
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/org/bytedeco/javacpp/tools/TokenIndexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,16 @@ Token[] expand(Token[] array, int index) {
}
// concatenate tokens as required
for (int i = startToken; i < tokens.size(); i++) {
if (tokens.get(i).match("##") && i > 0 && i + 1 < tokens.size()) {
tokens.get(i - 1).value += tokens.get(i + 1).value;
tokens.remove(i);
tokens.remove(i);
i--;
if (tokens.get(i).match("##")) {
if (i > 0 && i + 1 < tokens.size()) {
tokens.get(i - 1).value += tokens.get(i + 1).value;
tokens.remove(i);
tokens.remove(i);
i--;
} else {
// missing arguments, simply remove the "##" token
tokens.remove(i);
}
}
}
// copy the rest of the tokens from this point on
Expand Down

0 comments on commit ed47300

Please sign in to comment.