@@ -2145,7 +2145,7 @@ fn transCallExpr(rp: RestorePoint, scope: *Scope, stmt: *const ZigClangCallExpr,
2145
2145
node .rtoken = try appendToken (rp .c , .RParen , ")" );
2146
2146
2147
2147
if (fn_ty ) | ty | {
2148
- const canon = ZigClangQualType_getCanonicalType (ZigClangFunctionProtoType_getReturnType ( ty ));
2148
+ const canon = ZigClangQualType_getCanonicalType (ty . getReturnType ( ));
2149
2149
const ret_ty = ZigClangQualType_getTypePtr (canon );
2150
2150
if (ZigClangType_isVoidType (ret_ty )) {
2151
2151
_ = try appendToken (rp .c , .Semicolon , ";" );
@@ -2156,7 +2156,19 @@ fn transCallExpr(rp: RestorePoint, scope: *Scope, stmt: *const ZigClangCallExpr,
2156
2156
return maybeSuppressResult (rp , scope , result_used , & node .base );
2157
2157
}
2158
2158
2159
- fn qualTypeGetFnProto (qt : ZigClangQualType , is_ptr : * bool ) ? * const ZigClangFunctionProtoType {
2159
+ const ClangFunctionType = union (enum ) {
2160
+ Proto : * const ZigClangFunctionProtoType ,
2161
+ NoProto : * const ZigClangFunctionType ,
2162
+
2163
+ fn getReturnType (self : @This ()) ZigClangQualType {
2164
+ switch (@as (@TagType (@This ()), self )) {
2165
+ .Proto = > return ZigClangFunctionProtoType_getReturnType (self .Proto ),
2166
+ .NoProto = > return ZigClangFunctionType_getReturnType (self .NoProto ),
2167
+ }
2168
+ }
2169
+ };
2170
+
2171
+ fn qualTypeGetFnProto (qt : ZigClangQualType , is_ptr : * bool ) ? ClangFunctionType {
2160
2172
const canon = ZigClangQualType_getCanonicalType (qt );
2161
2173
var ty = ZigClangQualType_getTypePtr (canon );
2162
2174
is_ptr .* = false ;
@@ -2167,7 +2179,10 @@ fn qualTypeGetFnProto(qt: ZigClangQualType, is_ptr: *bool) ?*const ZigClangFunct
2167
2179
ty = ZigClangQualType_getTypePtr (child_qt );
2168
2180
}
2169
2181
if (ZigClangType_getTypeClass (ty ) == .FunctionProto ) {
2170
- return @ptrCast (* const ZigClangFunctionProtoType , ty );
2182
+ return ClangFunctionType { .Proto = @ptrCast (* const ZigClangFunctionProtoType , ty ) };
2183
+ }
2184
+ if (ZigClangType_getTypeClass (ty ) == .FunctionNoProto ) {
2185
+ return ClangFunctionType { .NoProto = @ptrCast (* const ZigClangFunctionType , ty ) };
2171
2186
}
2172
2187
return null ;
2173
2188
}
@@ -2771,7 +2786,10 @@ fn qualTypeChildIsFnProto(qt: ZigClangQualType) bool {
2771
2786
.Paren = > {
2772
2787
const paren_type = @ptrCast (* const ZigClangParenType , ty );
2773
2788
const inner_type = ZigClangParenType_getInnerType (paren_type );
2774
- return ZigClangQualType_getTypeClass (inner_type ) == .FunctionProto ;
2789
+ switch (ZigClangQualType_getTypeClass (inner_type )) {
2790
+ .FunctionProto , .FunctionNoProto = > return true ,
2791
+ else = > return false ,
2792
+ }
2775
2793
},
2776
2794
.Attributed = > {
2777
2795
const attr_type = @ptrCast (* const ZigClangAttributedType , ty );
@@ -3571,11 +3589,16 @@ fn transType(rp: RestorePoint, ty: *const ZigClangType, source_loc: ZigClangSour
3571
3589
else = > return revertAndWarn (rp , error .UnsupportedType , source_loc , "unsupported builtin type" , .{}),
3572
3590
});
3573
3591
},
3574
- .FunctionProto , .FunctionNoProto = > {
3592
+ .FunctionProto = > {
3575
3593
const fn_proto_ty = @ptrCast (* const ZigClangFunctionProtoType , ty );
3576
3594
const fn_proto = try transFnProto (rp , null , fn_proto_ty , source_loc , null , false );
3577
3595
return & fn_proto .base ;
3578
3596
},
3597
+ .FunctionNoProto = > {
3598
+ const fn_no_proto_ty = @ptrCast (* const ZigClangFunctionType , ty );
3599
+ const fn_proto = try transFnNoProto (rp , fn_no_proto_ty , source_loc , null , false );
3600
+ return & fn_proto .base ;
3601
+ },
3579
3602
.Paren = > {
3580
3603
const paren_ty = @ptrCast (* const ZigClangParenType , ty );
3581
3604
return transQualType (rp , ZigClangParenType_getInnerType (paren_ty ), source_loc );
0 commit comments