diff --git a/src/main/java/org/bytedeco/javacpp/tools/InfoMap.java b/src/main/java/org/bytedeco/javacpp/tools/InfoMap.java index d889a167..54b83f9d 100644 --- a/src/main/java/org/bytedeco/javacpp/tools/InfoMap.java +++ b/src/main/java/org/bytedeco/javacpp/tools/InfoMap.java @@ -209,7 +209,7 @@ String normalize(String name, boolean unconst, boolean untemplate) { name += " " + tokens[i].value; } } else if (untemplate) { - int count = 0, lastColon = -1, template = -1, parameters = -1; + int count = 0, lastColon = -1, template = -1, parameters = n; for (int i = 0; i < n; i++) { if (tokens[i].match('<')) { count++; @@ -218,9 +218,12 @@ String normalize(String name, boolean unconst, boolean untemplate) { } if (count == 0 && tokens[i].match("::")) { lastColon = i; + } else if (count == 0 && tokens[i].match('(')) { + parameters = i; + break; } } - for (int i = 0; i < n; i++) { + for (int i = 0; i < parameters; i++) { if (i > lastColon && tokens[i].match('<')) { if (count == 0) { template = i; @@ -228,8 +231,8 @@ String normalize(String name, boolean unconst, boolean untemplate) { count++; } else if (i > lastColon && tokens[i].match('>')) { count--; - if (count == 0) { - parameters = i + 1; + if (count == 0 && i + 1 != parameters) { + template = -1; } } } diff --git a/src/main/java/org/bytedeco/javacpp/tools/Parser.java b/src/main/java/org/bytedeco/javacpp/tools/Parser.java index 5b6c7abd..41dc2e34 100644 --- a/src/main/java/org/bytedeco/javacpp/tools/Parser.java +++ b/src/main/java/org/bytedeco/javacpp/tools/Parser.java @@ -1606,7 +1606,9 @@ Declarator declarator(Context context, String defaultName, int infoNumber, boole if (context.namespace != null && localName.startsWith(context.namespace + "::")) { localName = dcl.cppName.substring(context.namespace.length() + 2); } - if (!localName.equals(dcl.javaName) && (!localName.contains("::") || context.javaName == null)) { + int template = localName.lastIndexOf('<'); + String simpleName = template >= 0 ? localName.substring(0, template) : localName; + if (!localName.equals(dcl.javaName) && (!simpleName.contains("::") || context.javaName == null)) { type.annotations += "@Name(\"" + localName + "\") "; } } @@ -2360,7 +2362,9 @@ boolean function(Context context, DeclarationList declList) throws ParserExcepti if (fullInfo != null && fullInfo.javaNames != null && fullInfo.javaNames.length > 0) { dcl.javaName = fullInfo.javaNames[0]; dcl.signature = dcl.javaName + dcl.parameters.signature; - if (!localName2.equals(dcl.javaName) && (!localName2.contains("::") || context.javaName == null)) { + int template = localName2.lastIndexOf('<'); + String simpleName = template >= 0 ? localName2.substring(0, template) : localName2; + if (!localName2.equals(dcl.javaName) && (!simpleName.contains("::") || context.javaName == null)) { type.annotations = type.annotations.replaceAll("@Name\\(.*\\) ", ""); type.annotations += "@Name(\"" + localName2 + "\") "; }