Skip to content

Commit 8c257c0

Browse files
committed
* Fix Parser translation of strings containing the "::" subsequence (issue #184)
1 parent 997201f commit 8c257c0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
* Fix `Parser` translation of strings containing the "::" subsequence ([issue #184](https://github.com/bytedeco/javacpp/issues/184))
23
* Prevent `Parser` from overwriting target classes when nothing was parsed
34
* Fix `Parser` error on member variables with initializers plus `Info.skip()` ([issue #179](https://github.com/bytedeco/javacpp/issues/179))
45
* Fix `Parser` incorrectly recognizing values as pointers when `const` is placed after type ([issue #173](https://github.com/bytedeco/javacpp/issues/173))

src/main/java/org/bytedeco/javacpp/tools/Parser.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,19 @@ String translate(String text) {
9090
int namespace = text.lastIndexOf("::");
9191
if (namespace >= 0) {
9292
Info info2 = infoMap.getFirst(text.substring(0, namespace));
93-
text = text.substring(namespace + 2);
93+
String localName = text.substring(namespace + 2);
9494
if (info2 != null && info2.pointerTypes != null) {
95-
text = info2.pointerTypes[0] + "." + text;
95+
text = info2.pointerTypes[0] + "." + localName;
96+
} else if (localName.length() > 0 && Character.isJavaIdentifierStart(localName.charAt(0))) {
97+
for (char c : localName.toCharArray()) {
98+
if (!Character.isJavaIdentifierPart(c)) {
99+
localName = null;
100+
break;
101+
}
102+
}
103+
if (localName != null) {
104+
text = localName;
105+
}
96106
}
97107
}
98108
return text;

0 commit comments

Comments
 (0)