@@ -116,26 +116,50 @@ public String compose(String packageName, String originalName, List<FunctionNode
116
116
}
117
117
}
118
118
119
- if (options .useErrno ()) {
120
- methodBody .addStatement ("var capturedState = context.allocate(CAPTURED_STATE_LAYOUT)" );
121
- methodBody .addStatement ("var callResult = (int) $T.$L.invoke(capturedState, $L)" , context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
122
- methodBody .addStatement ("processError(callResult, capturedState, $S, $L)" , functionNode .functionName (), CodeBlock .join (arguments , ", " ));
119
+ if (options .nativeReturnType ().carrierClass () == Void .class ) {
120
+ if (options .useErrno ()) {
121
+ methodBody .addStatement ("var capturedState = context.allocate(CAPTURED_STATE_LAYOUT)" );
122
+ methodBody .addStatement ("var callResult = (int) $T.$L.invoke(capturedState, $L)" , context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
123
+ methodBody .addStatement ("processError(callResult, capturedState, $S, $L)" , functionNode .functionName (), CodeBlock .join (arguments , ", " ));
124
+ } else {
125
+ if (returnType .carrierClass ().equals (void .class )) {
126
+ methodBody .addStatement ("$T.$L.invoke($L)" , context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
127
+ } else {
128
+ switch (returnType ) {
129
+ case ArrayOriginalType _ , ObjectOriginalType _ ->
130
+ methodBody .addStatement ("var callResult = ($T) $T.$L.invoke($L)" ,
131
+ functionNode .returnNode ().getNodeType ().isEnum () ? int .class : MemorySegment .class ,
132
+ context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
133
+ default -> methodBody .addStatement ("var callResult = ($T) $T.$L.invoke($L)" ,
134
+ returnType .carrierClass (),
135
+ context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
136
+ }
137
+ }
138
+ }
123
139
} else {
124
- if (returnType .carrierClass ().equals (void .class )) {
125
- methodBody .addStatement ("$T.$L.invoke($L)" , context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
140
+ if (options .useErrno ()) {
141
+ methodBody .addStatement ("var capturedState = context.allocate(CAPTURED_STATE_LAYOUT)" );
142
+ methodBody .addStatement ("var callResult = ($T) $T.$L.invoke(capturedState, $L)" , options .nativeReturnType ().carrierClass (), context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
143
+ methodBody .addStatement ("processError(callResult, capturedState, $S, $L)" , functionNode .functionName (), CodeBlock .join (arguments , ", " ));
126
144
} else {
127
- switch (returnType ) {
128
- case ArrayOriginalType _ , ObjectOriginalType _ ->
129
- methodBody .addStatement ("var callResult = ($T) $T.$L.invoke($L)" ,
130
- functionNode .returnNode ().getNodeType ().isEnum () ? int .class : MemorySegment .class ,
131
- context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
132
- default -> methodBody .addStatement ("var callResult = ($T) $T.$L.invoke($L)" ,
133
- returnType .carrierClass (),
134
- context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
145
+ if (returnType .carrierClass ().equals (void .class )) {
146
+ methodBody .addStatement ("$T.$L.invoke($L)" , context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
147
+ } else {
148
+ switch (returnType ) {
149
+ case ArrayOriginalType _ , ObjectOriginalType _ ->
150
+ methodBody .addStatement ("var callResult = ($T) $T.$L.invoke($L)" ,
151
+ functionNode .returnNode ().getNodeType ().isEnum () ? int .class : MemorySegment .class ,
152
+ context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
153
+ default -> methodBody .addStatement ("var callResult = ($T) $T.$L.invoke($L)" ,
154
+ returnType .carrierClass (),
155
+ context , nativeFunctionNames .get (functionNode ), CodeBlock .join (arguments , ", " ));
156
+ }
135
157
}
136
158
}
137
159
}
138
160
161
+
162
+
139
163
if (!returnType .carrierClass ().equals (void .class ) && functionNode .functionParameters ().stream ().noneMatch (ParameterNode ::returns )) {
140
164
if (returnType instanceof ObjectOriginalType ) {
141
165
if (returnType .carrierClass ().equals (String .class )) {
0 commit comments