Skip to content

Commit

Permalink
Ensure constructor cppName is class name
Browse files Browse the repository at this point in the history
  • Loading branch information
HGuillemet committed Jan 20, 2024
1 parent 314f760 commit efa011d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main/java/org/bytedeco/javacpp/tools/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static String upcastMethodName(String javaName) {
* NS::CN::CN(int)
* Declarator.cppName contains the calling name, and this method returns the declaration name.
* Keys in info map should use the declaration name, because the calling name cannot specify
* arguments in case of constructor templates, and to avoid confusion between classes and constructores info.
* arguments in case of constructor templates, and to avoid confusion between classes and constructors info.
*/
static String constructorName(String cppName) {
String constructorName = Templates.strip(cppName);
Expand Down Expand Up @@ -1161,6 +1161,7 @@ else if (cppNameSplit.size() > 1 && groupNameSplit.size() == 1)
if (cppName.equals(groupName)) {
type.constructor = !type.destructor && !type.operator
&& type.indirections == 0 && !type.reference && tokens.get().match('(', ':');
if (type.constructor) type.cppName = context.cppName; // Fix potential qualification errors
}
type.javaName = context.shorten(type.javaName);
}
Expand Down Expand Up @@ -2593,17 +2594,18 @@ boolean function(Context context, DeclarationList declList) throws ParserExcepti
if (context.namespace != null && !isQualified) {
dcl.cppName = context.namespace + "::" + dcl.cppName;
}
}

// use Java names that we may get here but that declarator() did not catch
for (String name : context.qualify(dcl.cppName, param1)) {
if ((infoMap.getFirst(name, false)) != null) {
dcl.cppName = name;
break;
} else if (infoMap.getFirst(name) != null) {
dcl.cppName = name;
// use Java names that we may get here but that declarator() did not catch
for (String name : context.qualify(dcl.cppName, param1)) {
if ((infoMap.getFirst(name, false)) != null) {
dcl.cppName = name;
break;
} else if (infoMap.getFirst(name) != null) {
dcl.cppName = name;
}
}
}

String localName2 = dcl.cppName;
if (context.namespace != null && localName2.startsWith(context.namespace + "::")) {
localName2 = dcl.cppName.substring(context.namespace.length() + 2);
Expand Down

0 comments on commit efa011d

Please sign in to comment.