Skip to content

Commit

Permalink
* Fix Parser for basic containers like `std::optional<std::pair<in…
Browse files Browse the repository at this point in the history
…t,int> >` (issue #718)
  • Loading branch information
saudet committed Oct 15, 2023
1 parent 7227ec6 commit 78f0203
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 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` for basic containers like `std::optional<std::pair<int,int> >` ([issue #718](https://github.com/bytedeco/javacpp/issues/718))
* Add support for `std::basic_string` basic container ([issue bytedeco/javacpp-presets#1311](https://github.com/bytedeco/javacpp-presets/issues/1311))
* Enhance `Parser` by adding downcast constructors for polymorphic classes ([pull #700](https://github.com/bytedeco/javacpp/pull/700))
* Let `Generator` pick up `@Name` annotations on `allocate()` as well ([pull #700](https://github.com/bytedeco/javacpp/pull/700))
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/bytedeco/javacpp/tools/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void containers(Context context, DeclarationList declList) throws ParserExceptio
if (containerName.toLowerCase().endsWith("pair")) {
firstType = containerType.arguments[0];
secondType = containerType.arguments[1];
} else if (valueTemplate >= 0 && valueType.cppName.substring(0, valueTemplate).toLowerCase().endsWith("pair")) {
} else if (dim > 0 && valueTemplate >= 0 && valueType.cppName.substring(0, valueTemplate).toLowerCase().endsWith("pair")) {
firstType = valueType.arguments[0];
secondType = valueType.arguments[1];
}
Expand Down Expand Up @@ -3408,9 +3408,9 @@ String downcast(Type derived, Type base) {
if (!s.startsWith("@Name")) annotations += s + " ";
}
}
String res = "";
res += " /** Downcast constructor. */\n" +
" public " + derived.javaName + "(" + base.javaName + " pointer) { super((Pointer)null); allocate(pointer); }\n";
String shortName = derived.javaName.substring(derived.javaName.lastIndexOf('.') + 1);
String res = " /** Downcast constructor. */\n"
+ " public " + shortName + "(" + base.javaName + " pointer) { super((Pointer)null); allocate(pointer); }\n";
if (annotations.isEmpty()) {
res += " @Namespace private native @Name(\"" + downcastType + "_cast<" + derived.cppName + "*>\") void allocate(" + base.javaName + " pointer);\n";
} else {
Expand Down

0 comments on commit 78f0203

Please sign in to comment.