@@ -7,8 +7,8 @@ use wit_bindgen_c::{
7
7
CTypeNameInfo ,
8
8
} ;
9
9
use wit_bindgen_core:: wit_parser:: {
10
- Field , Function , FunctionKind , Handle , InterfaceId , LiveTypes , Resolve , Type , TypeDefKind ,
11
- TypeId , TypeOwner , WorldKey ,
10
+ Docs , Enum , Field , Flags , Function , FunctionKind , Handle , InterfaceId , LiveTypes , Record ,
11
+ Resolve , Result_ , Tuple , Type , TypeDefKind , TypeId , TypeOwner , Variant , WorldKey ,
12
12
} ;
13
13
use wit_bindgen_core:: { uwriteln, Direction , InterfaceGenerator as _, Source } ;
14
14
@@ -1008,13 +1008,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {
1008
1008
self . resolve
1009
1009
}
1010
1010
1011
- fn type_record (
1012
- & mut self ,
1013
- _id : wit_bindgen_core:: wit_parser:: TypeId ,
1014
- name : & str ,
1015
- record : & wit_bindgen_core:: wit_parser:: Record ,
1016
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1017
- ) {
1011
+ fn type_record ( & mut self , _id : TypeId , name : & str , record : & Record , _docs : & Docs ) {
1018
1012
let name = self . type_name ( name, true ) ;
1019
1013
self . src . push_str ( & format ! ( "type {name} struct {{\n " , ) ) ;
1020
1014
for field in record. fields . iter ( ) {
@@ -1025,12 +1019,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {
1025
1019
self . src . push_str ( "}\n \n " ) ;
1026
1020
}
1027
1021
1028
- fn type_resource (
1029
- & mut self ,
1030
- id : TypeId ,
1031
- name : & str ,
1032
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1033
- ) {
1022
+ fn type_resource ( & mut self , id : TypeId , name : & str , _docs : & Docs ) {
1034
1023
let type_name = self . type_name ( name, true ) ;
1035
1024
let private_type_name = type_name. to_snake_case ( ) ;
1036
1025
// for imports, generate a `int32` type for resource handle representation.
@@ -1166,13 +1155,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {
1166
1155
} ;
1167
1156
}
1168
1157
1169
- fn type_flags (
1170
- & mut self ,
1171
- _id : wit_bindgen_core:: wit_parser:: TypeId ,
1172
- name : & str ,
1173
- flags : & wit_bindgen_core:: wit_parser:: Flags ,
1174
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1175
- ) {
1158
+ fn type_flags ( & mut self , _id : TypeId , name : & str , flags : & Flags , _docs : & Docs ) {
1176
1159
let name = self . type_name ( name, true ) ;
1177
1160
1178
1161
// TODO: use flags repr to determine how many flags are needed
@@ -1198,13 +1181,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {
1198
1181
self . src . push_str ( ")\n \n " ) ;
1199
1182
}
1200
1183
1201
- fn type_tuple (
1202
- & mut self ,
1203
- _id : wit_bindgen_core:: wit_parser:: TypeId ,
1204
- name : & str ,
1205
- tuple : & wit_bindgen_core:: wit_parser:: Tuple ,
1206
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1207
- ) {
1184
+ fn type_tuple ( & mut self , _id : TypeId , name : & str , tuple : & Tuple , _docs : & Docs ) {
1208
1185
let name = self . type_name ( name, true ) ;
1209
1186
self . src . push_str ( & format ! ( "type {name} struct {{\n " , ) ) ;
1210
1187
for ( i, case) in tuple. types . iter ( ) . enumerate ( ) {
@@ -1214,13 +1191,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {
1214
1191
self . src . push_str ( "}\n \n " ) ;
1215
1192
}
1216
1193
1217
- fn type_variant (
1218
- & mut self ,
1219
- _id : wit_bindgen_core:: wit_parser:: TypeId ,
1220
- name : & str ,
1221
- variant : & wit_bindgen_core:: wit_parser:: Variant ,
1222
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1223
- ) {
1194
+ fn type_variant ( & mut self , _id : TypeId , name : & str , variant : & Variant , _docs : & Docs ) {
1224
1195
let name = self . type_name ( name, true ) ;
1225
1196
// TODO: use variant's tag to determine how many cases are needed
1226
1197
// this will help to optmize the Kind type.
@@ -1251,33 +1222,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {
1251
1222
}
1252
1223
}
1253
1224
1254
- fn type_option (
1255
- & mut self ,
1256
- id : wit_bindgen_core:: wit_parser:: TypeId ,
1257
- _name : & str ,
1258
- _payload : & wit_bindgen_core:: wit_parser:: Type ,
1259
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1260
- ) {
1261
- self . get_ty ( & Type :: Id ( id) ) ;
1262
- }
1263
-
1264
- fn type_result (
1265
- & mut self ,
1266
- id : wit_bindgen_core:: wit_parser:: TypeId ,
1267
- _name : & str ,
1268
- _result : & wit_bindgen_core:: wit_parser:: Result_ ,
1269
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1270
- ) {
1271
- self . get_ty ( & Type :: Id ( id) ) ;
1272
- }
1273
-
1274
- fn type_enum (
1275
- & mut self ,
1276
- _id : wit_bindgen_core:: wit_parser:: TypeId ,
1277
- name : & str ,
1278
- enum_ : & wit_bindgen_core:: wit_parser:: Enum ,
1279
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1280
- ) {
1225
+ fn type_enum ( & mut self , _id : TypeId , name : & str , enum_ : & Enum , _docs : & Docs ) {
1281
1226
let name = self . type_name ( name, true ) ;
1282
1227
// TODO: use variant's tag to determine how many cases are needed
1283
1228
// this will help to optmize the Kind type.
@@ -1302,37 +1247,25 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {
1302
1247
}
1303
1248
}
1304
1249
1305
- fn type_alias (
1306
- & mut self ,
1307
- _id : wit_bindgen_core:: wit_parser:: TypeId ,
1308
- name : & str ,
1309
- ty : & wit_bindgen_core:: wit_parser:: Type ,
1310
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1311
- ) {
1250
+ fn type_alias ( & mut self , _id : TypeId , name : & str , ty : & Type , _docs : & Docs ) {
1312
1251
let name = self . type_name ( name, true ) ;
1313
1252
let ty = self . get_ty ( ty) ;
1314
1253
self . src . push_str ( & format ! ( "type {name} = {ty}\n " ) ) ;
1315
1254
}
1316
1255
1317
- fn type_list (
1318
- & mut self ,
1319
- _id : wit_bindgen_core:: wit_parser:: TypeId ,
1320
- name : & str ,
1321
- ty : & wit_bindgen_core:: wit_parser:: Type ,
1322
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1323
- ) {
1324
- let name = self . type_name ( name, true ) ;
1325
- let ty = self . get_ty ( ty) ;
1326
- self . src . push_str ( & format ! ( "type {name} = {ty}\n " ) ) ;
1256
+ fn type_list ( & mut self , _id : TypeId , _name : & str , _ty : & Type , _docs : & Docs ) {
1257
+ // no impl since these types are generated as anonymous types
1327
1258
}
1328
1259
1329
- fn type_builtin (
1330
- & mut self ,
1331
- _id : wit_bindgen_core:: wit_parser:: TypeId ,
1332
- _name : & str ,
1333
- _ty : & wit_bindgen_core:: wit_parser:: Type ,
1334
- _docs : & wit_bindgen_core:: wit_parser:: Docs ,
1335
- ) {
1260
+ fn type_option ( & mut self , _id : TypeId , _name : & str , _payload : & Type , _docs : & Docs ) {
1261
+ // no impl since these types are generated as anonymous types
1262
+ }
1263
+
1264
+ fn type_result ( & mut self , _id : TypeId , _name : & str , _result : & Result_ , _docs : & Docs ) {
1265
+ // no impl since these types are generated as anonymous types
1266
+ }
1267
+
1268
+ fn type_builtin ( & mut self , _id : TypeId , _name : & str , _ty : & Type , _docs : & Docs ) {
1336
1269
todo ! ( "type_builtin" )
1337
1270
}
1338
1271
}
0 commit comments