@@ -36,6 +36,11 @@ abstract class Compound extends BindingType {
36
36
37
37
ObjCBuiltInFunctions ? objCBuiltInFunctions;
38
38
39
+ /// The way the native type is written in C source code. This isn't always the
40
+ /// same as the originalName, because the type may need to be prefixed with
41
+ /// `struct` or `union` , depending on whether the declaration is a typedef.
42
+ final String nativeType;
43
+
39
44
Compound ({
40
45
super .usr,
41
46
super .originalName,
@@ -47,7 +52,9 @@ abstract class Compound extends BindingType {
47
52
List <Member >? members,
48
53
super .isInternal,
49
54
this .objCBuiltInFunctions,
50
- }) : members = members ?? [];
55
+ String ? nativeType,
56
+ }) : members = members ?? [],
57
+ nativeType = nativeType ?? originalName ?? name;
51
58
52
59
factory Compound .fromType ({
53
60
required CompoundType type,
@@ -59,6 +66,7 @@ abstract class Compound extends BindingType {
59
66
String ? dartDoc,
60
67
List <Member >? members,
61
68
ObjCBuiltInFunctions ? objCBuiltInFunctions,
69
+ String ? nativeType,
62
70
}) {
63
71
switch (type) {
64
72
case CompoundType .struct:
@@ -71,6 +79,7 @@ abstract class Compound extends BindingType {
71
79
dartDoc: dartDoc,
72
80
members: members,
73
81
objCBuiltInFunctions: objCBuiltInFunctions,
82
+ nativeType: nativeType,
74
83
);
75
84
case CompoundType .union:
76
85
return Union (
@@ -82,6 +91,7 @@ abstract class Compound extends BindingType {
82
91
dartDoc: dartDoc,
83
92
members: members,
84
93
objCBuiltInFunctions: objCBuiltInFunctions,
94
+ nativeType: nativeType,
85
95
);
86
96
}
87
97
}
@@ -170,7 +180,7 @@ abstract class Compound extends BindingType {
170
180
String getCType (Writer w) => _isBuiltIn ? '${w .objcPkgPrefix }.$name ' : name;
171
181
172
182
@override
173
- String getNativeType ({String varName = '' }) => '$originalName $varName ' ;
183
+ String getNativeType ({String varName = '' }) => '$nativeType $varName ' ;
174
184
175
185
@override
176
186
bool get sameFfiDartAndCType => true ;
0 commit comments