Skip to content

Commit

Permalink
Fix template instance friend functions
Browse files Browse the repository at this point in the history
  • Loading branch information
HGuillemet committed Jan 2, 2024
1 parent 82f2dd2 commit e3b0d28
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/main/java/org/bytedeco/javacpp/tools/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<types.length; i++) {
if (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;
Expand Down Expand Up @@ -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;
Expand All @@ -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];
}

Expand Down

0 comments on commit e3b0d28

Please sign in to comment.