Skip to content

Commit 26eb486

Browse files
authored
* Fix Parser failing to pick up Info for constructors with template arguments (pull #739)
1 parent 314f760 commit 26eb486

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
* Fix `Parser` failing to pick up `Info` for constructors with template arguments ([pull #739](https://github.com/bytedeco/javacpp/pull/739))
23
* Fix `MoveAdapter` and `UniquePtrAdapter` causing double free on function calls ([pull #738](https://github.com/bytedeco/javacpp/pull/738))
34
* Fix `Parser` handling of `template` specialization and their `friend` declarations ([pull #733](https://github.com/bytedeco/javacpp/pull/733))
45
* Improve `Parser` capabilities for `operator` and function templates ([pull #732](https://github.com/bytedeco/javacpp/pull/732))

src/main/java/org/bytedeco/javacpp/tools/Parser.java

+11-9
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static String upcastMethodName(String javaName) {
136136
* NS::CN::CN(int)
137137
* Declarator.cppName contains the calling name, and this method returns the declaration name.
138138
* Keys in info map should use the declaration name, because the calling name cannot specify
139-
* arguments in case of constructor templates, and to avoid confusion between classes and constructores info.
139+
* arguments in case of constructor templates, and to avoid confusion between classes and constructors info.
140140
*/
141141
static String constructorName(String cppName) {
142142
String constructorName = Templates.strip(cppName);
@@ -1161,6 +1161,7 @@ else if (cppNameSplit.size() > 1 && groupNameSplit.size() == 1)
11611161
if (cppName.equals(groupName)) {
11621162
type.constructor = !type.destructor && !type.operator
11631163
&& type.indirections == 0 && !type.reference && tokens.get().match('(', ':');
1164+
if (type.constructor) type.cppName = context.cppName; // Fix potential qualification errors
11641165
}
11651166
type.javaName = context.shorten(type.javaName);
11661167
}
@@ -2593,17 +2594,18 @@ boolean function(Context context, DeclarationList declList) throws ParserExcepti
25932594
if (context.namespace != null && !isQualified) {
25942595
dcl.cppName = context.namespace + "::" + dcl.cppName;
25952596
}
2596-
}
25972597

2598-
// use Java names that we may get here but that declarator() did not catch
2599-
for (String name : context.qualify(dcl.cppName, param1)) {
2600-
if ((infoMap.getFirst(name, false)) != null) {
2601-
dcl.cppName = name;
2602-
break;
2603-
} else if (infoMap.getFirst(name) != null) {
2604-
dcl.cppName = name;
2598+
// use Java names that we may get here but that declarator() did not catch
2599+
for (String name : context.qualify(dcl.cppName, param1)) {
2600+
if ((infoMap.getFirst(name, false)) != null) {
2601+
dcl.cppName = name;
2602+
break;
2603+
} else if (infoMap.getFirst(name) != null) {
2604+
dcl.cppName = name;
2605+
}
26052606
}
26062607
}
2608+
26072609
String localName2 = dcl.cppName;
26082610
if (context.namespace != null && localName2.startsWith(context.namespace + "::")) {
26092611
localName2 = dcl.cppName.substring(context.namespace.length() + 2);

0 commit comments

Comments
 (0)