/
types_gen.dart
2059 lines (1912 loc) · 61.9 KB
/
types_gen.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// FILE GENERATED FROM WIT
// ignore: lines_longer_than_80_chars
// ignore_for_file: require_trailing_commas, unnecessary_raw_strings, unnecessary_non_null_assertion, unused_element, avoid_returning_null_for_void
import 'dart:async';
// ignore: unused_import
import 'dart:typed_data';
import 'package:wasm_wit_component/wasm_wit_component.dart';
// CUSTOM FILE HEADER
const objectComparator = ObjectComparator();
/// values of this type will be one of the specified cases
sealed class HumanTypesInterface implements ToJsonSerializable {
/// Returns a new instance from a JSON value.
/// May throw if the value does not have the expected structure.
factory HumanTypesInterface.fromJson(Object? json_) {
Object? json = json_;
if (json is Map) {
final MapEntry(:key, :value) =
json.entries.firstWhere((e) => e.key != 'runtimeType');
json = (
key is int ? key : _spec.cases.indexWhere((c) => c.label == key),
value,
);
}
return switch (json) {
(0, null) || [0, null] => const HumanTypesInterfaceBaby(),
(1, final value) ||
[1, final value] =>
HumanTypesInterfaceChild(value! as int),
(2, null) || [2, null] => const HumanTypesInterfaceAdult(),
_ => throw Exception('Invalid JSON $json_'),
};
}
const factory HumanTypesInterface.baby() = HumanTypesInterfaceBaby;
const factory HumanTypesInterface.child(int /*U32*/ value) =
HumanTypesInterfaceChild;
const factory HumanTypesInterface.adult() = HumanTypesInterfaceAdult;
@override
Map<String, Object?> toJson();
/// Returns this as a WASM canonical abi value.
(int, Object?) toWasm();
static const _spec =
Variant([Case('baby', null), Case('child', U32()), Case('adult', null)]);
}
class HumanTypesInterfaceBaby implements HumanTypesInterface {
const HumanTypesInterfaceBaby();
@override
Map<String, Object?> toJson() =>
{'runtimeType': 'HumanTypesInterfaceBaby', 'baby': null};
/// Returns this as a WASM canonical abi value.
@override
(int, Object?) toWasm() => (0, null);
@override
String toString() => 'HumanTypesInterfaceBaby()';
@override
bool operator ==(Object other) => other is HumanTypesInterfaceBaby;
@override
int get hashCode => (HumanTypesInterfaceBaby).hashCode;
}
/// type payload
class HumanTypesInterfaceChild implements HumanTypesInterface {
final int /*U32*/ value;
/// type payload
const HumanTypesInterfaceChild(this.value);
@override
Map<String, Object?> toJson() =>
{'runtimeType': 'HumanTypesInterfaceChild', 'child': value};
/// Returns this as a WASM canonical abi value.
@override
(int, Object?) toWasm() => (1, value);
@override
String toString() => 'HumanTypesInterfaceChild($value)';
@override
bool operator ==(Object other) =>
other is HumanTypesInterfaceChild &&
objectComparator.areEqual(other.value, value);
@override
int get hashCode => objectComparator.hashValue(value);
}
class HumanTypesInterfaceAdult implements HumanTypesInterface {
const HumanTypesInterfaceAdult();
@override
Map<String, Object?> toJson() =>
{'runtimeType': 'HumanTypesInterfaceAdult', 'adult': null};
/// Returns this as a WASM canonical abi value.
@override
(int, Object?) toWasm() => (2, null);
@override
String toString() => 'HumanTypesInterfaceAdult()';
@override
bool operator ==(Object other) => other is HumanTypesInterfaceAdult;
@override
int get hashCode => (HumanTypesInterfaceAdult).hashCode;
}
/// similar to `variant`, but no type payloads
enum ErrnoTypesInterface implements ToJsonSerializable {
tooBig,
tooSmall,
tooFast,
tooSlow;
/// Returns a new instance from a JSON value.
/// May throw if the value does not have the expected structure.
factory ErrnoTypesInterface.fromJson(Object? json) {
return ToJsonSerializable.enumFromJson(json, values, _spec);
}
@override
Map<String, Object?> toJson() =>
{'runtimeType': 'ErrnoTypesInterface', _spec.labels[index]: null};
/// Returns this as a WASM canonical abi value.
int toWasm() => index;
static const _spec =
EnumType(['too-big', 'too-small', 'too-fast', 'too-slow']);
}
/// similar to `variant`, but doesn't require naming cases and all variants
/// have a type payload -- note that this is not a C union, it still has a
/// discriminant
sealed class Input implements ToJsonSerializable {
/// Returns a new instance from a JSON value.
/// May throw if the value does not have the expected structure.
factory Input.fromJson(Object? json_) {
Object? json = json_;
if (json is Map) {
final rt = json['runtimeType'];
if (rt is String) {
json = (const ['InputIntU64', 'InputString'].indexOf(rt), json);
} else {
final MapEntry(:key, :value) = json.entries.first;
json = (key is int ? key : int.parse(key! as String), value);
}
}
return switch (json) {
(0, final value) || [0, final value] => InputIntU64(value! as int),
(1, final value) ||
[1, final value] =>
InputString(value is String ? value : (value! as ParsedString).value),
_ => throw Exception('Invalid JSON $json_'),
};
}
const factory Input.intU64(int /*U64*/ value) = InputIntU64;
const factory Input.string(String value) = InputString;
@override
Map<String, Object?> toJson();
/// Returns this as a WASM canonical abi value.
static (int, Object?) toWasm(Input value) => switch (value) {
InputIntU64() => value.toWasm(),
InputString() => value.toWasm(),
};
// ignore: unused_field
static const _spec = Union([U64(), StringType()]);
}
class InputIntU64 implements Input {
final int /*U64*/ value;
const InputIntU64(this.value);
@override
Map<String, Object?> toJson() => {'runtimeType': 'InputIntU64', '0': value};
/// Returns this as a WASM canonical abi value.
(int, Object?) toWasm() => (0, value);
@override
String toString() => 'InputIntU64($value)';
@override
bool operator ==(Object other) =>
other is InputIntU64 && objectComparator.areEqual(other.value, value);
@override
int get hashCode => objectComparator.hashValue(value);
}
class InputString implements Input {
final String value;
const InputString(this.value);
@override
Map<String, Object?> toJson() => {'runtimeType': 'InputString', '1': value};
/// Returns this as a WASM canonical abi value.
(int, Object?) toWasm() => (1, value);
@override
String toString() => 'InputString($value)';
@override
bool operator ==(Object other) =>
other is InputString && objectComparator.areEqual(other.value, value);
@override
int get hashCode => objectComparator.hashValue(value);
}
/// a bitflags type
class Permissions implements ToJsonSerializable {
/// The flags represented as a set of bits.
final FlagsBits flagsBits;
/// Creates an instance where the flags are represented by [flagsBits].
/// The number of flags must match the number of flags in the type (3).
Permissions(this.flagsBits) : assert(flagsBits.numFlags == 3);
/// An instance where all flags are set to `false`.
Permissions.none() : flagsBits = FlagsBits.none(numFlags: 3);
/// An instance where all flags are set to `true`.
Permissions.all() : flagsBits = FlagsBits.all(numFlags: 3);
/// Creates an instance with flags booleans passed as arguments.
factory Permissions.fromBool(
{bool read = false, bool write = false, bool exec = false}) {
final value_ = Permissions.none();
if (read) value_.read = true;
if (write) value_.write = true;
if (exec) value_.exec = true;
return value_;
}
/// Returns a new instance from a JSON value.
/// May throw if the value does not have the expected structure.
factory Permissions.fromJson(Object? json) {
final flagsBits = FlagsBits.fromJson(json, flagsKeys: _spec.labels);
return Permissions(flagsBits);
}
@override
Map<String, Object?> toJson() =>
flagsBits.toJson()..['runtimeType'] = 'Permissions';
/// Returns this as a WASM canonical abi value.
Uint32List toWasm() => Uint32List.sublistView(flagsBits.data);
@override
String toString() => 'Permissions(${[
if (read) 'read',
if (write) 'write',
if (exec) 'exec',
].join(', ')})';
@override
bool operator ==(Object other) =>
other is Permissions &&
objectComparator.areEqual(flagsBits, other.flagsBits);
@override
int get hashCode => objectComparator.hashValue(flagsBits);
/// Returns the bitwise AND of the flags in this and [other].
Permissions operator &(Permissions other) =>
Permissions(flagsBits & other.flagsBits);
/// Returns the bitwise OR of the flags in this and [other].
Permissions operator |(Permissions other) =>
Permissions(flagsBits | other.flagsBits);
/// Returns the bitwise XOR of the flags in this and [other].
Permissions operator ^(Permissions other) =>
Permissions(flagsBits ^ other.flagsBits);
/// Returns the flags inverted (negated).
Permissions operator ~() => Permissions(~flagsBits);
bool get read => flagsBits[0];
set read(bool enable) => flagsBits[0] = enable;
bool get write => flagsBits[1];
set write(bool enable) => flagsBits[1] = enable;
bool get exec => flagsBits[2];
set exec(bool enable) => flagsBits[2] = enable;
static const _spec = Flags(['read', 'write', 'exec']);
}
class ManyFlags implements ToJsonSerializable {
/// The flags represented as a set of bits.
final FlagsBits flagsBits;
/// Creates an instance where the flags are represented by [flagsBits].
/// The number of flags must match the number of flags in the type (33).
ManyFlags(this.flagsBits) : assert(flagsBits.numFlags == 33);
/// An instance where all flags are set to `false`.
ManyFlags.none() : flagsBits = FlagsBits.none(numFlags: 33);
/// An instance where all flags are set to `true`.
ManyFlags.all() : flagsBits = FlagsBits.all(numFlags: 33);
/// Creates an instance with flags booleans passed as arguments.
factory ManyFlags.fromBool(
{bool f1 = false,
bool f2 = false,
bool f3 = false,
bool f4 = false,
bool f5 = false,
bool f6 = false,
bool f7 = false,
bool f8 = false,
bool f9 = false,
bool f10 = false,
bool f11 = false,
bool f12 = false,
bool f13 = false,
bool f14 = false,
bool f15 = false,
bool f16 = false,
bool f17 = false,
bool f18 = false,
bool f19 = false,
bool f20 = false,
bool f21 = false,
bool f22 = false,
bool f23 = false,
bool f24 = false,
bool f25 = false,
bool f26 = false,
bool f27 = false,
bool f28 = false,
bool f29 = false,
bool f30 = false,
bool f31 = false,
bool f32 = false,
bool f33 = false}) {
final value_ = ManyFlags.none();
if (f1) value_.f1 = true;
if (f2) value_.f2 = true;
if (f3) value_.f3 = true;
if (f4) value_.f4 = true;
if (f5) value_.f5 = true;
if (f6) value_.f6 = true;
if (f7) value_.f7 = true;
if (f8) value_.f8 = true;
if (f9) value_.f9 = true;
if (f10) value_.f10 = true;
if (f11) value_.f11 = true;
if (f12) value_.f12 = true;
if (f13) value_.f13 = true;
if (f14) value_.f14 = true;
if (f15) value_.f15 = true;
if (f16) value_.f16 = true;
if (f17) value_.f17 = true;
if (f18) value_.f18 = true;
if (f19) value_.f19 = true;
if (f20) value_.f20 = true;
if (f21) value_.f21 = true;
if (f22) value_.f22 = true;
if (f23) value_.f23 = true;
if (f24) value_.f24 = true;
if (f25) value_.f25 = true;
if (f26) value_.f26 = true;
if (f27) value_.f27 = true;
if (f28) value_.f28 = true;
if (f29) value_.f29 = true;
if (f30) value_.f30 = true;
if (f31) value_.f31 = true;
if (f32) value_.f32 = true;
if (f33) value_.f33 = true;
return value_;
}
/// Returns a new instance from a JSON value.
/// May throw if the value does not have the expected structure.
factory ManyFlags.fromJson(Object? json) {
final flagsBits = FlagsBits.fromJson(json, flagsKeys: _spec.labels);
return ManyFlags(flagsBits);
}
@override
Map<String, Object?> toJson() =>
flagsBits.toJson()..['runtimeType'] = 'ManyFlags';
/// Returns this as a WASM canonical abi value.
Uint32List toWasm() => Uint32List.sublistView(flagsBits.data);
@override
String toString() => 'ManyFlags(${[
if (f1) 'f1',
if (f2) 'f2',
if (f3) 'f3',
if (f4) 'f4',
if (f5) 'f5',
if (f6) 'f6',
if (f7) 'f7',
if (f8) 'f8',
if (f9) 'f9',
if (f10) 'f10',
if (f11) 'f11',
if (f12) 'f12',
if (f13) 'f13',
if (f14) 'f14',
if (f15) 'f15',
if (f16) 'f16',
if (f17) 'f17',
if (f18) 'f18',
if (f19) 'f19',
if (f20) 'f20',
if (f21) 'f21',
if (f22) 'f22',
if (f23) 'f23',
if (f24) 'f24',
if (f25) 'f25',
if (f26) 'f26',
if (f27) 'f27',
if (f28) 'f28',
if (f29) 'f29',
if (f30) 'f30',
if (f31) 'f31',
if (f32) 'f32',
if (f33) 'f33',
].join(', ')})';
@override
bool operator ==(Object other) =>
other is ManyFlags &&
objectComparator.areEqual(flagsBits, other.flagsBits);
@override
int get hashCode => objectComparator.hashValue(flagsBits);
/// Returns the bitwise AND of the flags in this and [other].
ManyFlags operator &(ManyFlags other) =>
ManyFlags(flagsBits & other.flagsBits);
/// Returns the bitwise OR of the flags in this and [other].
ManyFlags operator |(ManyFlags other) =>
ManyFlags(flagsBits | other.flagsBits);
/// Returns the bitwise XOR of the flags in this and [other].
ManyFlags operator ^(ManyFlags other) =>
ManyFlags(flagsBits ^ other.flagsBits);
/// Returns the flags inverted (negated).
ManyFlags operator ~() => ManyFlags(~flagsBits);
bool get f1 => flagsBits[0];
set f1(bool enable) => flagsBits[0] = enable;
bool get f2 => flagsBits[1];
set f2(bool enable) => flagsBits[1] = enable;
bool get f3 => flagsBits[2];
set f3(bool enable) => flagsBits[2] = enable;
bool get f4 => flagsBits[3];
set f4(bool enable) => flagsBits[3] = enable;
bool get f5 => flagsBits[4];
set f5(bool enable) => flagsBits[4] = enable;
bool get f6 => flagsBits[5];
set f6(bool enable) => flagsBits[5] = enable;
bool get f7 => flagsBits[6];
set f7(bool enable) => flagsBits[6] = enable;
bool get f8 => flagsBits[7];
set f8(bool enable) => flagsBits[7] = enable;
bool get f9 => flagsBits[8];
set f9(bool enable) => flagsBits[8] = enable;
bool get f10 => flagsBits[9];
set f10(bool enable) => flagsBits[9] = enable;
bool get f11 => flagsBits[10];
set f11(bool enable) => flagsBits[10] = enable;
bool get f12 => flagsBits[11];
set f12(bool enable) => flagsBits[11] = enable;
bool get f13 => flagsBits[12];
set f13(bool enable) => flagsBits[12] = enable;
bool get f14 => flagsBits[13];
set f14(bool enable) => flagsBits[13] = enable;
bool get f15 => flagsBits[14];
set f15(bool enable) => flagsBits[14] = enable;
bool get f16 => flagsBits[15];
set f16(bool enable) => flagsBits[15] = enable;
bool get f17 => flagsBits[16];
set f17(bool enable) => flagsBits[16] = enable;
bool get f18 => flagsBits[17];
set f18(bool enable) => flagsBits[17] = enable;
bool get f19 => flagsBits[18];
set f19(bool enable) => flagsBits[18] = enable;
bool get f20 => flagsBits[19];
set f20(bool enable) => flagsBits[19] = enable;
bool get f21 => flagsBits[20];
set f21(bool enable) => flagsBits[20] = enable;
bool get f22 => flagsBits[21];
set f22(bool enable) => flagsBits[21] = enable;
bool get f23 => flagsBits[22];
set f23(bool enable) => flagsBits[22] = enable;
bool get f24 => flagsBits[23];
set f24(bool enable) => flagsBits[23] = enable;
bool get f25 => flagsBits[24];
set f25(bool enable) => flagsBits[24] = enable;
bool get f26 => flagsBits[25];
set f26(bool enable) => flagsBits[25] = enable;
bool get f27 => flagsBits[26];
set f27(bool enable) => flagsBits[26] = enable;
bool get f28 => flagsBits[27];
set f28(bool enable) => flagsBits[27] = enable;
bool get f29 => flagsBits[28];
set f29(bool enable) => flagsBits[28] = enable;
bool get f30 => flagsBits[29];
set f30(bool enable) => flagsBits[29] = enable;
bool get f31 => flagsBits[30];
set f31(bool enable) => flagsBits[30] = enable;
bool get f32 => flagsBits[31];
set f32(bool enable) => flagsBits[31] = enable;
bool get f33 => flagsBits[32];
set f33(bool enable) => flagsBits[32] = enable;
static const _spec = Flags([
'f1',
'f2',
'f3',
'f4',
'f5',
'f6',
'f7',
'f8',
'f9',
'f10',
'f11',
'f12',
'f13',
'f14',
'f15',
'f16',
'f17',
'f18',
'f19',
'f20',
'f21',
'f22',
'f23',
'f24',
'f25',
'f26',
'f27',
'f28',
'f29',
'f30',
'f31',
'f32',
'f33'
]);
}
typedef T1 = int /*U32*/;
typedef T2 = (
int /*U32*/,
int /*U64*/,
);
typedef T3 = String;
typedef T4 = Option<int /*U32*/ >;
/// "package of named fields"
class R implements ToJsonSerializable {
final int /*U32*/ a;
final String b;
final List<
(
String,
Option<T4>,
)> c;
final Option<
Option<
(
List<int /*S64*/ >,
Option<Option<int /*U64*/ >>,
)>> d;
final ErrnoTypesInterface e;
final Input i;
final Permissions p;
final ManyFlags f;
/// "package of named fields"
const R({
required this.a,
required this.b,
required this.c,
this.d = const None(),
required this.e,
required this.i,
required this.p,
required this.f,
});
/// Returns a new instance from a JSON value.
/// May throw if the value does not have the expected structure.
factory R.fromJson(Object? json_) {
final json = json_ is Map
? _spec.fields.map((f) => json_[f.label]).toList(growable: false)
: json_;
return switch (json) {
[
final a,
final b,
final c,
final d,
final e,
final i,
final p,
final f
] ||
(
final a,
final b,
final c,
final d,
final e,
final i,
final p,
final f
) =>
R(
a: a! as int,
b: b is String ? b : (b! as ParsedString).value,
c: (c! as Iterable)
.map((e) => (() {
final l = e is Map
? List.generate(2, (i) => e[i.toString()],
growable: false)
: e;
return switch (l) {
[final v0, final v1] || (final v0, final v1) => (
v0 is String ? v0 : (v0! as ParsedString).value,
Option.fromJson(
v1,
(some) => Option.fromJson(
some, (some) => some! as int)),
),
_ => throw Exception('Invalid JSON $e')
};
})())
.toList(),
d: Option.fromJson(
d,
(some) => Option.fromJson(
some,
(some) => (() {
final l = some is Map
? List.generate(2, (i) => some[i.toString()],
growable: false)
: some;
return switch (l) {
[final v0, final v1] || (final v0, final v1) => (
(v0! as Iterable).map((e) => e! as int).toList(),
Option.fromJson(
v1,
(some) => Option.fromJson(
some, (some) => some! as int)),
),
_ => throw Exception('Invalid JSON $some')
};
})())),
e: ErrnoTypesInterface.fromJson(e),
i: Input.fromJson(i),
p: Permissions.fromJson(p),
f: ManyFlags.fromJson(f),
),
_ => throw Exception('Invalid JSON $json_')
};
}
@override
Map<String, Object?> toJson() => {
'runtimeType': 'R',
'a': a,
'b': b,
'c':
c.map((e) => [e.$1, e.$2.toJson((some) => some.toJson())]).toList(),
'd': d.toJson((some) => some.toJson((some) =>
[some.$1.toList(), some.$2.toJson((some) => some.toJson())])),
'e': e.toJson(),
'i': i.toJson(),
'p': p.toJson(),
'f': f.toJson(),
};
/// Returns this as a WASM canonical abi value.
List<Object?> toWasm() => [
a,
b,
c
.map((e) => [e.$1, e.$2.toWasm((some) => some.toWasm())])
.toList(growable: false),
d.toWasm((some) => some.toWasm(
(some) => [some.$1, some.$2.toWasm((some) => some.toWasm())])),
e.toWasm(),
Input.toWasm(i),
p.toWasm(),
f.toWasm()
];
@override
String toString() =>
'R${Map.fromIterables(_spec.fields.map((f) => f.label), _props)}';
/// Returns a new instance by overriding the values passed as arguments
R copyWith({
int /*U32*/ ? a,
String? b,
List<
(
String,
Option<T4>,
)>?
c,
Option<
Option<
(
List<int /*S64*/ >,
Option<Option<int /*U64*/ >>,
)>>?
d,
ErrnoTypesInterface? e,
Input? i,
Permissions? p,
ManyFlags? f,
}) =>
R(
a: a ?? this.a,
b: b ?? this.b,
c: c ?? this.c,
d: d ?? this.d,
e: e ?? this.e,
i: i ?? this.i,
p: p ?? this.p,
f: f ?? this.f);
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is R && objectComparator.arePropsEqual(_props, other._props);
@override
int get hashCode => objectComparator.hashProps(_props);
// ignore: unused_field
List<Object?> get _props => [a, b, c, d, e, i, p, f];
static const _spec = RecordType([
(label: 'a', t: U32()),
(label: 'b', t: StringType()),
(
label: 'c',
t: ListType(Tuple([StringType(), OptionType(OptionType(U32()))]))
),
(
label: 'd',
t: OptionType(
OptionType(Tuple([ListType(S64()), OptionType(OptionType(U64()))])))
),
(label: 'e', t: ErrnoTypesInterface._spec),
(label: 'i', t: Input._spec),
(label: 'p', t: Permissions._spec),
(label: 'f', t: ManyFlags._spec)
]);
}
/// no "ok" type
typedef T5TypesInterface = Result<void, ErrnoTypesInterface>;
typedef T6 = Result<String, void>;
typedef T7 = Result<String /*Char*/, ErrnoTypesInterface>;
typedef T8 = Result<void, void>;
typedef T9 = List<String>;
typedef T10 = T9;
class RoundTripNumbersData implements ToJsonSerializable {
final int /*U8*/ un8;
final int /*U16*/ un16;
final int /*U32*/ un32;
final int /*U64*/ un64;
final int /*S8*/ si8;
final int /*S16*/ si16;
final int /*S32*/ si32;
final int /*S64*/ si64;
final double /*F32*/ f32;
final double /*F64*/ f64;
const RoundTripNumbersData({
required this.un8,
required this.un16,
required this.un32,
required this.un64,
required this.si8,
required this.si16,
required this.si32,
required this.si64,
required this.f32,
required this.f64,
});
/// Returns a new instance from a JSON value.
/// May throw if the value does not have the expected structure.
factory RoundTripNumbersData.fromJson(Object? json_) {
final json = json_ is Map
? _spec.fields.map((f) => json_[f.label]).toList(growable: false)
: json_;
return switch (json) {
[
final un8,
final un16,
final un32,
final un64,
final si8,
final si16,
final si32,
final si64,
final f32,
final f64
] ||
(
final un8,
final un16,
final un32,
final un64,
final si8,
final si16,
final si32,
final si64,
final f32,
final f64
) =>
RoundTripNumbersData(
un8: un8! as int,
un16: un16! as int,
un32: un32! as int,
un64: un64! as int,
si8: si8! as int,
si16: si16! as int,
si32: si32! as int,
si64: si64! as int,
f32: f32! as double,
f64: f64! as double,
),
_ => throw Exception('Invalid JSON $json_')
};
}
@override
Map<String, Object?> toJson() => {
'runtimeType': 'RoundTripNumbersData',
'un8': un8,
'un16': un16,
'un32': un32,
'un64': un64,
'si8': si8,
'si16': si16,
'si32': si32,
'si64': si64,
'f32': f32,
'f64': f64,
};
/// Returns this as a WASM canonical abi value.
List<Object?> toWasm() =>
[un8, un16, un32, un64, si8, si16, si32, si64, f32, f64];
@override
String toString() =>
'RoundTripNumbersData${Map.fromIterables(_spec.fields.map((f) => f.label), _props)}';
/// Returns a new instance by overriding the values passed as arguments
RoundTripNumbersData copyWith({
int /*U8*/ ? un8,
int /*U16*/ ? un16,
int /*U32*/ ? un32,
int /*U64*/ ? un64,
int /*S8*/ ? si8,
int /*S16*/ ? si16,
int /*S32*/ ? si32,
int /*S64*/ ? si64,
double /*F32*/ ? f32,
double /*F64*/ ? f64,
}) =>
RoundTripNumbersData(
un8: un8 ?? this.un8,
un16: un16 ?? this.un16,
un32: un32 ?? this.un32,
un64: un64 ?? this.un64,
si8: si8 ?? this.si8,
si16: si16 ?? this.si16,
si32: si32 ?? this.si32,
si64: si64 ?? this.si64,
f32: f32 ?? this.f32,
f64: f64 ?? this.f64);
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is RoundTripNumbersData &&
objectComparator.arePropsEqual(_props, other._props);
@override
int get hashCode => objectComparator.hashProps(_props);
// ignore: unused_field
List<Object?> get _props =>
[un8, un16, un32, un64, si8, si16, si32, si64, f32, f64];
static const _spec = RecordType([
(label: 'un8', t: U8()),
(label: 'un16', t: U16()),
(label: 'un32', t: U32()),
(label: 'un64', t: U64()),
(label: 'si8', t: S8()),
(label: 'si16', t: S16()),
(label: 'si32', t: S32()),
(label: 'si64', t: S64()),
(label: 'f32', t: Float32()),
(label: 'f64', t: Float64())
]);
}
class RoundTripNumbersListData implements ToJsonSerializable {
final List<int /*U8*/ > un8;
final List<int /*U16*/ > un16;
final List<int /*U32*/ > un32;
final List<int /*U64*/ > un64;
final List<int /*S8*/ > si8;
final List<int /*S16*/ > si16;
final List<int /*S32*/ > si32;
final List<int /*S64*/ > si64;
final List<List<int /*S64*/ >> si64List;
final List<List<int /*U64*/ >> un64List;
final List<List<int /*U8*/ >> un8List;
final List<double /*F32*/ > f32;
final List<double /*F64*/ > f64;
const RoundTripNumbersListData({
required this.un8,
required this.un16,
required this.un32,
required this.un64,
required this.si8,
required this.si16,
required this.si32,
required this.si64,
required this.si64List,
required this.un64List,
required this.un8List,
required this.f32,
required this.f64,
});
/// Returns a new instance from a JSON value.
/// May throw if the value does not have the expected structure.
factory RoundTripNumbersListData.fromJson(Object? json_) {
final json = json_ is Map
? _spec.fields.map((f) => json_[f.label]).toList(growable: false)
: json_;
return switch (json) {
[
final un8,
final un16,
final un32,
final un64,
final si8,
final si16,
final si32,
final si64,
final si64List,
final un64List,
final un8List,
final f32,
final f64
] ||
(
final un8,
final un16,
final un32,
final un64,
final si8,
final si16,
final si32,
final si64,
final si64List,
final un64List,
final un8List,
final f32,
final f64
) =>
RoundTripNumbersListData(
un8: (un8! as Iterable).map((e) => e! as int).toList(),
un16: (un16! as Iterable).map((e) => e! as int).toList(),
un32: (un32! as Iterable).map((e) => e! as int).toList(),
un64: (un64! as Iterable).map((e) => e! as int).toList(),
si8: (si8! as Iterable).map((e) => e! as int).toList(),
si16: (si16! as Iterable).map((e) => e! as int).toList(),
si32: (si32! as Iterable).map((e) => e! as int).toList(),
si64: (si64! as Iterable).map((e) => e! as int).toList(),
si64List: (si64List! as Iterable)
.map((e) => (e! as Iterable).map((e) => e! as int).toList())
.toList(),
un64List: (un64List! as Iterable)
.map((e) => (e! as Iterable).map((e) => e! as int).toList())
.toList(),
un8List: (un8List! as Iterable)
.map((e) => (e! as Iterable).map((e) => e! as int).toList())
.toList(),
f32: (f32! as Iterable).map((e) => e! as double).toList(),
f64: (f64! as Iterable).map((e) => e! as double).toList(),
),
_ => throw Exception('Invalid JSON $json_')
};
}
@override
Map<String, Object?> toJson() => {
'runtimeType': 'RoundTripNumbersListData',
'un8': un8.toList(),
'un16': un16.toList(),
'un32': un32.toList(),
'un64': un64.toList(),
'si8': si8.toList(),
'si16': si16.toList(),
'si32': si32.toList(),
'si64': si64.toList(),
'si64-list': si64List.map((e) => e.toList()).toList(),
'un64-list': un64List.map((e) => e.toList()).toList(),
'un8-list': un8List.map((e) => e.toList()).toList(),
'f32': f32.toList(),
'f64': f64.toList(),
};
/// Returns this as a WASM canonical abi value.