From 8c257c0ae02f9e0e8da229300fe2be2cd630a21d Mon Sep 17 00:00:00 2001 From: Samuel Audet Date: Tue, 6 Jun 2017 22:28:46 +0900 Subject: [PATCH] * Fix `Parser` translation of strings containing the "::" subsequence (issue #184) --- CHANGELOG.md | 1 + .../java/org/bytedeco/javacpp/tools/Parser.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9601c9891..92236c47d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/src/main/java/org/bytedeco/javacpp/tools/Parser.java b/src/main/java/org/bytedeco/javacpp/tools/Parser.java index 8c61f5a94..89d46d0c4 100644 --- a/src/main/java/org/bytedeco/javacpp/tools/Parser.java +++ b/src/main/java/org/bytedeco/javacpp/tools/Parser.java @@ -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;