Skip to content

Commit

Permalink
* Fix Parser failing to pick up Info for constructors with templ…
Browse files Browse the repository at this point in the history
…ate arguments (pull #739)
  • Loading branch information
HGuillemet authored Jan 22, 2024
1 parent 314f760 commit 26eb486
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Fix `Parser` failing to pick up `Info` for constructors with template arguments ([pull #739](https://github.com/bytedeco/javacpp/pull/739))
* Fix `MoveAdapter` and `UniquePtrAdapter` causing double free on function calls ([pull #738](https://github.com/bytedeco/javacpp/pull/738))
* Fix `Parser` handling of `template` specialization and their `friend` declarations ([pull #733](https://github.com/bytedeco/javacpp/pull/733))
* Improve `Parser` capabilities for `operator` and function templates ([pull #732](https://github.com/bytedeco/javacpp/pull/732))
Expand Down
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 26eb486

Please sign in to comment.