From e3b0d2849d212fdd7f3a1d2ba8910e9054804061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Guillemet?= Date: Tue, 2 Jan 2024 20:24:04 +0100 Subject: [PATCH] Fix template instance friend functions --- .../org/bytedeco/javacpp/tools/Parser.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/bytedeco/javacpp/tools/Parser.java b/src/main/java/org/bytedeco/javacpp/tools/Parser.java index f4dfe088..9973917f 100644 --- a/src/main/java/org/bytedeco/javacpp/tools/Parser.java +++ b/src/main/java/org/bytedeco/javacpp/tools/Parser.java @@ -1381,18 +1381,14 @@ Declarator declarator(Context context, String defaultName, int infoNumber, boole } } else if (token.match('<')) { // template arguments - dcl.cppName += token; - int count2 = 0; - for (token = tokens.next(); !token.match(Token.EOF); token = tokens.next()) { - dcl.cppName += token; - if (count2 == 0 && token.match('>')) { - break; - } else if (token.match('<')) { - count2++; - } else if (token.match('>')) { - count2--; - } - } + Type[] types = templateArguments(context); + dcl.cppName += "<"; + for (int i = 0; i 0) dcl.cppName += ","; + dcl.cppName += types[i].cppName; + } + if (dcl.cppName.endsWith(">")) dcl.cppName += " "; + dcl.cppName += ">"; } else if (token.match(Token.IDENTIFIER) && (dcl.cppName.length() == 0 || dcl.cppName.endsWith("::"))) { dcl.cppName += token; @@ -1624,12 +1620,14 @@ Declarator declarator(Context context, String defaultName, int infoNumber, boole // initialize shorten Java name and get fully qualified C++ name info = null; + boolean partial = true; dcl.javaName = attr != null ? attr.arguments : dcl.cppName; if (defaultName == null) { // get Info for fully qualified C++ names only, which function arguments cannot have for (String name : context.qualify(dcl.cppName)) { if ((info = infoMap.getFirst(name, false)) != null) { dcl.cppName = name; + partial = false; break; } else if (infoMap.getFirst(name) != null) { dcl.cppName = name; @@ -1640,7 +1638,7 @@ Declarator declarator(Context context, String defaultName, int infoNumber, boole // pick the Java name from the InfoMap if appropriate String originalName = fieldPointer ? groupInfo.pointerTypes[0] : dcl.javaName; if (attr == null && defaultName == null && info != null && info.javaNames != null && info.javaNames.length > 0 - && (dcl.operator || Templates.notExists(info.cppNames[0]) || (context.templateMap != null && context.templateMap.type == null))) { + && !partial) { dcl.javaName = info.javaNames[0]; }