Skip to content

Commit

Permalink
* Fix Parser translation of strings containing the "::" subsequenc…
Browse files Browse the repository at this point in the history
…e (issue #184)
  • Loading branch information
saudet committed Jun 6, 2017
1 parent 997201f commit 8c257c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Fix `Parser` translation of strings containing the "::" subsequence ([issue #184](https://github.com/bytedeco/javacpp/issues/184))
* Prevent `Parser` from overwriting target classes when nothing was parsed
* Fix `Parser` error on member variables with initializers plus `Info.skip()` ([issue #179](https://github.com/bytedeco/javacpp/issues/179))
* Fix `Parser` incorrectly recognizing values as pointers when `const` is placed after type ([issue #173](https://github.com/bytedeco/javacpp/issues/173))
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/bytedeco/javacpp/tools/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,19 @@ String translate(String text) {
int namespace = text.lastIndexOf("::");
if (namespace >= 0) {
Info info2 = infoMap.getFirst(text.substring(0, namespace));
text = text.substring(namespace + 2);
String localName = text.substring(namespace + 2);
if (info2 != null && info2.pointerTypes != null) {
text = info2.pointerTypes[0] + "." + text;
text = info2.pointerTypes[0] + "." + localName;
} else if (localName.length() > 0 && Character.isJavaIdentifierStart(localName.charAt(0))) {
for (char c : localName.toCharArray()) {
if (!Character.isJavaIdentifierPart(c)) {
localName = null;
break;
}
}
if (localName != null) {
text = localName;
}
}
}
return text;
Expand Down

0 comments on commit 8c257c0

Please sign in to comment.