@@ -496,6 +496,47 @@ enum ProxyApiTestEnum: Int {
496
496
case two = 1
497
497
case three = 2
498
498
}
499
+ private class ProxyApiTestsPigeonCodecReader : FlutterStandardReader {
500
+ override func readValue( ofType type: UInt8 ) -> Any ? {
501
+ switch type {
502
+ case 129 :
503
+ var enumResult : ProxyApiTestEnum ? = nil
504
+ let enumResultAsInt : Int ? = nilOrValue ( self . readValue ( ) as? Int )
505
+ if let enumResultAsInt = enumResultAsInt {
506
+ enumResult = ProxyApiTestEnum ( rawValue: enumResultAsInt)
507
+ }
508
+ return enumResult
509
+ default :
510
+ return super. readValue ( ofType: type)
511
+ }
512
+ }
513
+ }
514
+
515
+ private class ProxyApiTestsPigeonCodecWriter : FlutterStandardWriter {
516
+ override func writeValue( _ value: Any ) {
517
+ if let value = value as? ProxyApiTestEnum {
518
+ super. writeByte ( 129 )
519
+ super. writeValue ( value. rawValue)
520
+ } else {
521
+ super. writeValue ( value)
522
+ }
523
+ }
524
+ }
525
+
526
+ private class ProxyApiTestsPigeonCodecReaderWriter : FlutterStandardReaderWriter {
527
+ override func reader( with data: Data ) -> FlutterStandardReader {
528
+ return ProxyApiTestsPigeonCodecReader ( data: data)
529
+ }
530
+
531
+ override func writer( with data: NSMutableData ) -> FlutterStandardWriter {
532
+ return ProxyApiTestsPigeonCodecWriter ( data: data)
533
+ }
534
+ }
535
+
536
+ class ProxyApiTestsPigeonCodec : FlutterStandardMessageCodec , @unchecked Sendable {
537
+ static let shared = ProxyApiTestsPigeonCodec ( readerWriter: ProxyApiTestsPigeonCodecReaderWriter ( ) )
538
+ }
539
+
499
540
protocol PigeonDelegateProxyApiTestClass {
500
541
func pigeonDefaultConstructor(
501
542
pigeonApi: PigeonApiProxyApiTestClass , aBool: Bool , anInt: Int64 , aDouble: Double ,
@@ -880,7 +921,7 @@ final class PigeonApiProxyApiTestClass {
880
921
let aUint8ListArg = args [ 5 ] as! FlutterStandardTypedData
881
922
let aListArg = args [ 6 ] as! [ Any ? ]
882
923
let aMapArg = args [ 7 ] as! [ String ? : Any ? ]
883
- let anEnumArg = ProxyApiTestEnum ( rawValue : args [ 8 ] as! Int ) !
924
+ let anEnumArg = args [ 8 ] as! ProxyApiTestEnum
884
925
let aProxyApiArg = args [ 9 ] as! ProxyApiSuperClass
885
926
let aNullableBoolArg : Bool ? = nilOrValue ( args [ 10 ] )
886
927
let aNullableIntArg : Int64 ? =
@@ -891,8 +932,7 @@ final class PigeonApiProxyApiTestClass {
891
932
let aNullableUint8ListArg : FlutterStandardTypedData ? = nilOrValue ( args [ 14 ] )
892
933
let aNullableListArg : [ Any ? ] ? = nilOrValue ( args [ 15 ] )
893
934
let aNullableMapArg : [ String ? : Any ? ] ? = nilOrValue ( args [ 16 ] )
894
- let aNullableEnumArg : ProxyApiTestEnum ? =
895
- isNullish ( args [ 17 ] ) ? nil : ProxyApiTestEnum ( rawValue: args [ 17 ] as! Int ) !
935
+ let aNullableEnumArg : ProxyApiTestEnum ? = nilOrValue ( args [ 17 ] )
896
936
let aNullableProxyApiArg : ProxyApiSuperClass ? = nilOrValue ( args [ 18 ] )
897
937
let boolParamArg = args [ 19 ] as! Bool
898
938
let intParamArg = args [ 20 ] is Int64 ? args [ 20 ] as! Int64 : Int64 ( args [ 20 ] as! Int32 )
@@ -901,7 +941,7 @@ final class PigeonApiProxyApiTestClass {
901
941
let aUint8ListParamArg = args [ 23 ] as! FlutterStandardTypedData
902
942
let listParamArg = args [ 24 ] as! [ Any ? ]
903
943
let mapParamArg = args [ 25 ] as! [ String ? : Any ? ]
904
- let enumParamArg = ProxyApiTestEnum ( rawValue : args [ 26 ] as! Int ) !
944
+ let enumParamArg = args [ 26 ] as! ProxyApiTestEnum
905
945
let proxyApiParamArg = args [ 27 ] as! ProxyApiSuperClass
906
946
let nullableBoolParamArg : Bool ? = nilOrValue ( args [ 28 ] )
907
947
let nullableIntParamArg : Int64 ? =
@@ -912,8 +952,7 @@ final class PigeonApiProxyApiTestClass {
912
952
let nullableUint8ListParamArg : FlutterStandardTypedData ? = nilOrValue ( args [ 32 ] )
913
953
let nullableListParamArg : [ Any ? ] ? = nilOrValue ( args [ 33 ] )
914
954
let nullableMapParamArg : [ String ? : Any ? ] ? = nilOrValue ( args [ 34 ] )
915
- let nullableEnumParamArg : ProxyApiTestEnum ? =
916
- isNullish ( args [ 35 ] ) ? nil : ProxyApiTestEnum ( rawValue: args [ 35 ] as! Int ) !
955
+ let nullableEnumParamArg : ProxyApiTestEnum ? = nilOrValue ( args [ 35 ] )
917
956
let nullableProxyApiParamArg : ProxyApiSuperClass ? = nilOrValue ( args [ 36 ] )
918
957
do {
919
958
api. pigeonRegistrar. instanceManager. addDartCreatedInstance (
@@ -1251,11 +1290,11 @@ final class PigeonApiProxyApiTestClass {
1251
1290
echoEnumChannel. setMessageHandler { message, reply in
1252
1291
let args = message as! [ Any ? ]
1253
1292
let pigeonInstanceArg = args [ 0 ] as! ProxyApiTestClass
1254
- let anEnumArg = ProxyApiTestEnum ( rawValue : args [ 1 ] as! Int ) !
1293
+ let anEnumArg = args [ 1 ] as! ProxyApiTestEnum
1255
1294
do {
1256
1295
let result = try api. pigeonDelegate. echoEnum (
1257
1296
pigeonApi: api, pigeonInstance: pigeonInstanceArg, anEnum: anEnumArg)
1258
- reply ( wrapResult ( result. rawValue ) )
1297
+ reply ( wrapResult ( result) )
1259
1298
} catch {
1260
1299
reply ( wrapError ( error) )
1261
1300
}
@@ -1444,12 +1483,11 @@ final class PigeonApiProxyApiTestClass {
1444
1483
echoNullableEnumChannel. setMessageHandler { message, reply in
1445
1484
let args = message as! [ Any ? ]
1446
1485
let pigeonInstanceArg = args [ 0 ] as! ProxyApiTestClass
1447
- let aNullableEnumArg : ProxyApiTestEnum ? =
1448
- isNullish ( args [ 1 ] ) ? nil : ProxyApiTestEnum ( rawValue: args [ 1 ] as! Int ) !
1486
+ let aNullableEnumArg : ProxyApiTestEnum ? = nilOrValue ( args [ 1 ] )
1449
1487
do {
1450
1488
let result = try api. pigeonDelegate. echoNullableEnum (
1451
1489
pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableEnum: aNullableEnumArg)
1452
- reply ( wrapResult ( result? . rawValue ) )
1490
+ reply ( wrapResult ( result) )
1453
1491
} catch {
1454
1492
reply ( wrapError ( error) )
1455
1493
}
@@ -1679,13 +1717,13 @@ final class PigeonApiProxyApiTestClass {
1679
1717
echoAsyncEnumChannel. setMessageHandler { message, reply in
1680
1718
let args = message as! [ Any ? ]
1681
1719
let pigeonInstanceArg = args [ 0 ] as! ProxyApiTestClass
1682
- let anEnumArg = ProxyApiTestEnum ( rawValue : args [ 1 ] as! Int ) !
1720
+ let anEnumArg = args [ 1 ] as! ProxyApiTestEnum
1683
1721
api. pigeonDelegate. echoAsyncEnum (
1684
1722
pigeonApi: api, pigeonInstance: pigeonInstanceArg, anEnum: anEnumArg
1685
1723
) { result in
1686
1724
switch result {
1687
1725
case . success( let res) :
1688
- reply ( wrapResult ( res. rawValue ) )
1726
+ reply ( wrapResult ( res) )
1689
1727
case . failure( let error) :
1690
1728
reply ( wrapError ( error) )
1691
1729
}
@@ -1941,14 +1979,13 @@ final class PigeonApiProxyApiTestClass {
1941
1979
echoAsyncNullableEnumChannel. setMessageHandler { message, reply in
1942
1980
let args = message as! [ Any ? ]
1943
1981
let pigeonInstanceArg = args [ 0 ] as! ProxyApiTestClass
1944
- let anEnumArg : ProxyApiTestEnum ? =
1945
- isNullish ( args [ 1 ] ) ? nil : ProxyApiTestEnum ( rawValue: args [ 1 ] as! Int ) !
1982
+ let anEnumArg : ProxyApiTestEnum ? = nilOrValue ( args [ 1 ] )
1946
1983
api. pigeonDelegate. echoAsyncNullableEnum (
1947
1984
pigeonApi: api, pigeonInstance: pigeonInstanceArg, anEnum: anEnumArg
1948
1985
) { result in
1949
1986
switch result {
1950
1987
case . success( let res) :
1951
- reply ( wrapResult ( res? . rawValue ) )
1988
+ reply ( wrapResult ( res) )
1952
1989
case . failure( let error) :
1953
1990
reply ( wrapError ( error) )
1954
1991
}
@@ -2276,13 +2313,13 @@ final class PigeonApiProxyApiTestClass {
2276
2313
callFlutterEchoEnumChannel. setMessageHandler { message, reply in
2277
2314
let args = message as! [ Any ? ]
2278
2315
let pigeonInstanceArg = args [ 0 ] as! ProxyApiTestClass
2279
- let anEnumArg = ProxyApiTestEnum ( rawValue : args [ 1 ] as! Int ) !
2316
+ let anEnumArg = args [ 1 ] as! ProxyApiTestEnum
2280
2317
api. pigeonDelegate. callFlutterEchoEnum (
2281
2318
pigeonApi: api, pigeonInstance: pigeonInstanceArg, anEnum: anEnumArg
2282
2319
) { result in
2283
2320
switch result {
2284
2321
case . success( let res) :
2285
- reply ( wrapResult ( res. rawValue ) )
2322
+ reply ( wrapResult ( res) )
2286
2323
case . failure( let error) :
2287
2324
reply ( wrapError ( error) )
2288
2325
}
@@ -2484,14 +2521,13 @@ final class PigeonApiProxyApiTestClass {
2484
2521
callFlutterEchoNullableEnumChannel. setMessageHandler { message, reply in
2485
2522
let args = message as! [ Any ? ]
2486
2523
let pigeonInstanceArg = args [ 0 ] as! ProxyApiTestClass
2487
- let anEnumArg : ProxyApiTestEnum ? =
2488
- isNullish ( args [ 1 ] ) ? nil : ProxyApiTestEnum ( rawValue: args [ 1 ] as! Int ) !
2524
+ let anEnumArg : ProxyApiTestEnum ? = nilOrValue ( args [ 1 ] )
2489
2525
api. pigeonDelegate. callFlutterEchoNullableEnum (
2490
2526
pigeonApi: api, pigeonInstance: pigeonInstanceArg, anEnum: anEnumArg
2491
2527
) { result in
2492
2528
switch result {
2493
2529
case . success( let res) :
2494
- reply ( wrapResult ( res? . rawValue ) )
2530
+ reply ( wrapResult ( res) )
2495
2531
case . failure( let error) :
2496
2532
reply ( wrapError ( error) )
2497
2533
}
@@ -2616,9 +2652,9 @@ final class PigeonApiProxyApiTestClass {
2616
2652
channel. sendMessage (
2617
2653
[
2618
2654
pigeonIdentifierArg, aBoolArg, anIntArg, aDoubleArg, aStringArg, aUint8ListArg, aListArg,
2619
- aMapArg, anEnumArg. rawValue , aProxyApiArg, aNullableBoolArg, aNullableIntArg,
2620
- aNullableDoubleArg , aNullableStringArg, aNullableUint8ListArg, aNullableListArg,
2621
- aNullableMapArg , aNullableEnumArg? . rawValue , aNullableProxyApiArg,
2655
+ aMapArg, anEnumArg, aProxyApiArg, aNullableBoolArg, aNullableIntArg, aNullableDoubleArg ,
2656
+ aNullableStringArg, aNullableUint8ListArg, aNullableListArg, aNullableMapArg ,
2657
+ aNullableEnumArg, aNullableProxyApiArg,
2622
2658
] as [ Any ? ]
2623
2659
) { response in
2624
2660
guard let listResponse = response as? [ Any ? ] else {
@@ -3039,7 +3075,7 @@ final class PigeonApiProxyApiTestClass {
3039
3075
" dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoEnum "
3040
3076
let channel = FlutterBasicMessageChannel (
3041
3077
name: channelName, binaryMessenger: binaryMessenger, codec: codec)
3042
- channel. sendMessage ( [ pigeonInstanceArg, anEnumArg. rawValue ] as [ Any ? ] ) { response in
3078
+ channel. sendMessage ( [ pigeonInstanceArg, anEnumArg] as [ Any ? ] ) { response in
3043
3079
guard let listResponse = response as? [ Any ? ] else {
3044
3080
completion ( . failure( createConnectionError ( withChannelName: channelName) ) )
3045
3081
return
@@ -3056,7 +3092,7 @@ final class PigeonApiProxyApiTestClass {
3056
3092
code: " null-error " ,
3057
3093
message: " Flutter api returned null value for non-null return value. " , details: " " ) ) )
3058
3094
} else {
3059
- let result = ProxyApiTestEnum ( rawValue : listResponse [ 0 ] as! Int ) !
3095
+ let result = listResponse [ 0 ] as! ProxyApiTestEnum
3060
3096
completion ( . success( result) )
3061
3097
}
3062
3098
}
@@ -3307,7 +3343,7 @@ final class PigeonApiProxyApiTestClass {
3307
3343
" dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableEnum "
3308
3344
let channel = FlutterBasicMessageChannel (
3309
3345
name: channelName, binaryMessenger: binaryMessenger, codec: codec)
3310
- channel. sendMessage ( [ pigeonInstanceArg, anEnumArg? . rawValue ] as [ Any ? ] ) { response in
3346
+ channel. sendMessage ( [ pigeonInstanceArg, anEnumArg] as [ Any ? ] ) { response in
3311
3347
guard let listResponse = response as? [ Any ? ] else {
3312
3348
completion ( . failure( createConnectionError ( withChannelName: channelName) ) )
3313
3349
return
@@ -3318,8 +3354,7 @@ final class PigeonApiProxyApiTestClass {
3318
3354
let details : String ? = nilOrValue ( listResponse [ 2 ] )
3319
3355
completion ( . failure( ProxyApiTestsError ( code: code, message: message, details: details) ) )
3320
3356
} else {
3321
- let result : ProxyApiTestEnum ? =
3322
- isNullish ( listResponse [ 0 ] ) ? nil : ProxyApiTestEnum ( rawValue: listResponse [ 0 ] as! Int ) !
3357
+ let result : ProxyApiTestEnum ? = nilOrValue ( listResponse [ 0 ] )
3323
3358
completion ( . success( result) )
3324
3359
}
3325
3360
}
0 commit comments