Skip to content

Ghidra is a software reverse engineering (SRE) framework

[ghidra-stubs] Handle void return type

widbergb928046d93c9
diff --git a/GhidraBuild/BuildFiles/Doclets/src/main/java/ghidra/doclets/typestubs/PythonTypeStubMethod.java b/GhidraBuild/BuildFiles/Doclets/src/main/java/ghidra/doclets/typestubs/PythonTypeStubMethod.java
index 62b6a08828..2bd5d33175 100644
--- a/GhidraBuild/BuildFiles/Doclets/src/main/java/ghidra/doclets/typestubs/PythonTypeStubMethod.java
+++ b/GhidraBuild/BuildFiles/Doclets/src/main/java/ghidra/doclets/typestubs/PythonTypeStubMethod.java
@@ -225,6 +225,10 @@ final class PythonTypeStubMethod extends PythonTypeStubElement<ExecutableElement
};
}
+ if (type.getKind() == TypeKind.VOID) {
+ return "None";
+ }
+
if (type instanceof DeclaredType dt) {
Element element = dt.asElement();
if (element instanceof QualifiedNameable nameable) {
@@ -314,15 +318,13 @@ final class PythonTypeStubMethod extends PythonTypeStubElement<ExecutableElement
printer.print(")");
TypeMirror res = el.getReturnType();
- if (res.getKind() != TypeKind.VOID) {
- printer.print(" -> ");
- String convertedType = convertResultType(res);
- if (convertedType != null) {
- printer.print(convertedType);
- }
- else {
- printer.print(sanitizeQualifiedName(res));
- }
+ printer.print(" -> ");
+ String convertedType = convertResultType(res);
+ if (convertedType != null) {
+ printer.print(convertedType);
+ }
+ else {
+ printer.print(sanitizeQualifiedName(res));
}
}