Skip to content

Commit 5433bff

Browse files
committed
If a type is mapped to Pointer, it is not struct by value
This condition was not checked in ConvertedType.isStructByValue(), and methods we can generate got mistakenly ignored.
1 parent 18ceea2 commit 5433bff

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/gir2java/ConvertedType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public boolean isStructByValue() {
7474
return false;
7575
}
7676

77-
if ( (getJType() != null) && getJType().isPrimitive() ) {
77+
if ( (getJType() != null) && (getJType().isPrimitive() || getJType().erasure().name().equals("Pointer")) ) {
7878
return false;
7979
}
8080

src/gir2java/GirParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,14 +717,18 @@ private boolean checkUndefined(Element root, ParsingContext context) {
717717

718718
private boolean checkStructByValue(ConvertedType returnType, List<ParameterDescriptor> parametersList) {
719719
if (returnType.isStructByValue()) {
720+
System.out.println("Struct by value found as return type: " + returnType.toString());
720721
return true;
721722
}
722723

724+
int i = 0;
723725
if (parametersList != null) {
724726
for (ParameterDescriptor param : parametersList) {
725727
if ((param.getType()) != null && param.getType().isStructByValue()) {
728+
System.out.println("Struct by value found as parameter no. " + i + ":" + param.getType());
726729
return true;
727730
}
731+
i++;
728732
}
729733
}
730734

@@ -759,6 +763,7 @@ private void parseMethodOrFunction(Element root, ParsingContext context) {
759763
}
760764

761765
if (checkStructByValue(returnType, parametersList)) {
766+
System.out.println("Skipped " + nativeName + "() because it takes or returns struct by value");
762767
return;
763768
}
764769

0 commit comments

Comments
 (0)