-
Notifications
You must be signed in to change notification settings - Fork 19
/
ipldsch_satisfaction.go
8592 lines (8234 loc) · 242 KB
/
ipldsch_satisfaction.go
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
package ipldgit
// Code generated by go-ipld-prime gengo. DO NOT EDIT.
import (
ipld "github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/node/mixins"
"github.com/ipld/go-ipld-prime/schema"
)
func (n Blob) Bytes() []byte {
return n.x
}
func (_Blob__Prototype) FromBytes(v []byte) (Blob, error) {
n := _Blob{v}
return &n, nil
}
type _Blob__Maybe struct {
m schema.Maybe
v _Blob
}
type MaybeBlob = *_Blob__Maybe
func (m MaybeBlob) IsNull() bool {
return m.m == schema.Maybe_Null
}
func (m MaybeBlob) IsAbsent() bool {
return m.m == schema.Maybe_Absent
}
func (m MaybeBlob) Exists() bool {
return m.m == schema.Maybe_Value
}
func (m MaybeBlob) AsNode() ipld.Node {
switch m.m {
case schema.Maybe_Absent:
return ipld.Absent
case schema.Maybe_Null:
return ipld.Null
case schema.Maybe_Value:
return &m.v
default:
panic("unreachable")
}
}
func (m MaybeBlob) Must() Blob {
if !m.Exists() {
panic("unbox of a maybe rejected")
}
return &m.v
}
var _ ipld.Node = (Blob)(&_Blob{})
var _ schema.TypedNode = (Blob)(&_Blob{})
func (Blob) Kind() ipld.Kind {
return ipld.Kind_Bytes
}
func (Blob) LookupByString(string) (ipld.Node, error) {
return mixins.Bytes{TypeName: "ipldgit.Blob"}.LookupByString("")
}
func (Blob) LookupByNode(ipld.Node) (ipld.Node, error) {
return mixins.Bytes{TypeName: "ipldgit.Blob"}.LookupByNode(nil)
}
func (Blob) LookupByIndex(idx int64) (ipld.Node, error) {
return mixins.Bytes{TypeName: "ipldgit.Blob"}.LookupByIndex(0)
}
func (Blob) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
return mixins.Bytes{TypeName: "ipldgit.Blob"}.LookupBySegment(seg)
}
func (Blob) MapIterator() ipld.MapIterator {
return nil
}
func (Blob) ListIterator() ipld.ListIterator {
return nil
}
func (Blob) Length() int64 {
return -1
}
func (Blob) IsAbsent() bool {
return false
}
func (Blob) IsNull() bool {
return false
}
func (Blob) AsBool() (bool, error) {
return mixins.Bytes{TypeName: "ipldgit.Blob"}.AsBool()
}
func (Blob) AsInt() (int64, error) {
return mixins.Bytes{TypeName: "ipldgit.Blob"}.AsInt()
}
func (Blob) AsFloat() (float64, error) {
return mixins.Bytes{TypeName: "ipldgit.Blob"}.AsFloat()
}
func (Blob) AsString() (string, error) {
return mixins.Bytes{TypeName: "ipldgit.Blob"}.AsString()
}
func (n Blob) AsBytes() ([]byte, error) {
return n.x, nil
}
func (Blob) AsLink() (ipld.Link, error) {
return mixins.Bytes{TypeName: "ipldgit.Blob"}.AsLink()
}
func (Blob) Prototype() ipld.NodePrototype {
return _Blob__Prototype{}
}
type _Blob__Prototype struct{}
func (_Blob__Prototype) NewBuilder() ipld.NodeBuilder {
var nb _Blob__Builder
nb.Reset()
return &nb
}
type _Blob__Builder struct {
_Blob__Assembler
}
func (nb *_Blob__Builder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
}
return nb.w
}
func (nb *_Blob__Builder) Reset() {
var w _Blob
var m schema.Maybe
*nb = _Blob__Builder{_Blob__Assembler{w: &w, m: &m}}
}
type _Blob__Assembler struct {
w *_Blob
m *schema.Maybe
}
func (na *_Blob__Assembler) reset() {}
func (_Blob__Assembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
return mixins.BytesAssembler{TypeName: "ipldgit.Blob"}.BeginMap(0)
}
func (_Blob__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
return mixins.BytesAssembler{TypeName: "ipldgit.Blob"}.BeginList(0)
}
func (na *_Blob__Assembler) AssignNull() error {
switch *na.m {
case allowNull:
*na.m = schema.Maybe_Null
return nil
case schema.Maybe_Absent:
return mixins.BytesAssembler{TypeName: "ipldgit.Blob"}.AssignNull()
case schema.Maybe_Value, schema.Maybe_Null:
panic("invalid state: cannot assign into assembler that's already finished")
}
panic("unreachable")
}
func (_Blob__Assembler) AssignBool(bool) error {
return mixins.BytesAssembler{TypeName: "ipldgit.Blob"}.AssignBool(false)
}
func (_Blob__Assembler) AssignInt(int64) error {
return mixins.BytesAssembler{TypeName: "ipldgit.Blob"}.AssignInt(0)
}
func (_Blob__Assembler) AssignFloat(float64) error {
return mixins.BytesAssembler{TypeName: "ipldgit.Blob"}.AssignFloat(0)
}
func (_Blob__Assembler) AssignString(string) error {
return mixins.BytesAssembler{TypeName: "ipldgit.Blob"}.AssignString("")
}
func (na *_Blob__Assembler) AssignBytes(v []byte) error {
switch *na.m {
case schema.Maybe_Value, schema.Maybe_Null:
panic("invalid state: cannot assign into assembler that's already finished")
}
na.w.x = v
*na.m = schema.Maybe_Value
return nil
}
func (_Blob__Assembler) AssignLink(ipld.Link) error {
return mixins.BytesAssembler{TypeName: "ipldgit.Blob"}.AssignLink(nil)
}
func (na *_Blob__Assembler) AssignNode(v ipld.Node) error {
if v.IsNull() {
return na.AssignNull()
}
if v2, ok := v.(*_Blob); ok {
switch *na.m {
case schema.Maybe_Value, schema.Maybe_Null:
panic("invalid state: cannot assign into assembler that's already finished")
}
*na.w = *v2
*na.m = schema.Maybe_Value
return nil
}
if v2, err := v.AsBytes(); err != nil {
return err
} else {
return na.AssignBytes(v2)
}
}
func (_Blob__Assembler) Prototype() ipld.NodePrototype {
return _Blob__Prototype{}
}
func (Blob) Type() schema.Type {
return nil /*TODO:typelit*/
}
func (n Blob) Representation() ipld.Node {
return (*_Blob__Repr)(n)
}
type _Blob__Repr = _Blob
var _ ipld.Node = &_Blob__Repr{}
type _Blob__ReprPrototype = _Blob__Prototype
type _Blob__ReprAssembler = _Blob__Assembler
func (n _Commit) FieldTree() Tree_Link {
return &n.tree
}
func (n _Commit) FieldParents() Commit_Link_List {
return &n.parents
}
func (n _Commit) FieldMessage() String {
return &n.message
}
func (n _Commit) FieldAuthor() MaybePersonInfo {
return &n.author
}
func (n _Commit) FieldCommitter() MaybePersonInfo {
return &n.committer
}
func (n _Commit) FieldEncoding() MaybeString {
return &n.encoding
}
func (n _Commit) FieldSignature() MaybeGpgSig {
return &n.signature
}
func (n _Commit) FieldMergetag() Tag_List {
return &n.mergetag
}
func (n _Commit) FieldOther() String_List {
return &n.other
}
type _Commit__Maybe struct {
m schema.Maybe
v Commit
}
type MaybeCommit = *_Commit__Maybe
func (m MaybeCommit) IsNull() bool {
return m.m == schema.Maybe_Null
}
func (m MaybeCommit) IsAbsent() bool {
return m.m == schema.Maybe_Absent
}
func (m MaybeCommit) Exists() bool {
return m.m == schema.Maybe_Value
}
func (m MaybeCommit) AsNode() ipld.Node {
switch m.m {
case schema.Maybe_Absent:
return ipld.Absent
case schema.Maybe_Null:
return ipld.Null
case schema.Maybe_Value:
return m.v
default:
panic("unreachable")
}
}
func (m MaybeCommit) Must() Commit {
if !m.Exists() {
panic("unbox of a maybe rejected")
}
return m.v
}
var (
fieldName__Commit_Tree = _String{"tree"}
fieldName__Commit_Parents = _String{"parents"}
fieldName__Commit_Message = _String{"message"}
fieldName__Commit_Author = _String{"author"}
fieldName__Commit_Committer = _String{"committer"}
fieldName__Commit_Encoding = _String{"encoding"}
fieldName__Commit_Signature = _String{"signature"}
fieldName__Commit_Mergetag = _String{"mergetag"}
fieldName__Commit_Other = _String{"other"}
)
var _ ipld.Node = (Commit)(&_Commit{})
var _ schema.TypedNode = (Commit)(&_Commit{})
func (Commit) Kind() ipld.Kind {
return ipld.Kind_Map
}
func (n Commit) LookupByString(key string) (ipld.Node, error) {
switch key {
case "tree":
return &n.tree, nil
case "parents":
return &n.parents, nil
case "message":
return &n.message, nil
case "author":
if n.author.m == schema.Maybe_Absent {
return ipld.Absent, nil
}
return n.author.v, nil
case "committer":
if n.committer.m == schema.Maybe_Absent {
return ipld.Absent, nil
}
return n.committer.v, nil
case "encoding":
if n.encoding.m == schema.Maybe_Absent {
return ipld.Absent, nil
}
return &n.encoding.v, nil
case "signature":
if n.signature.m == schema.Maybe_Absent {
return ipld.Absent, nil
}
return &n.signature.v, nil
case "mergetag":
return &n.mergetag, nil
case "other":
return &n.other, nil
default:
return nil, schema.ErrNoSuchField{Type: nil /*TODO*/, Field: ipld.PathSegmentOfString(key)}
}
}
func (n Commit) LookupByNode(key ipld.Node) (ipld.Node, error) {
ks, err := key.AsString()
if err != nil {
return nil, err
}
return n.LookupByString(ks)
}
func (Commit) LookupByIndex(idx int64) (ipld.Node, error) {
return mixins.Map{TypeName: "ipldgit.Commit"}.LookupByIndex(0)
}
func (n Commit) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
return n.LookupByString(seg.String())
}
func (n Commit) MapIterator() ipld.MapIterator {
return &_Commit__MapItr{n, 0}
}
type _Commit__MapItr struct {
n Commit
idx int
}
func (itr *_Commit__MapItr) Next() (k ipld.Node, v ipld.Node, _ error) {
if itr.idx >= 9 {
return nil, nil, ipld.ErrIteratorOverread{}
}
switch itr.idx {
case 0:
k = &fieldName__Commit_Tree
v = &itr.n.tree
case 1:
k = &fieldName__Commit_Parents
v = &itr.n.parents
case 2:
k = &fieldName__Commit_Message
v = &itr.n.message
case 3:
k = &fieldName__Commit_Author
if itr.n.author.m == schema.Maybe_Absent {
v = ipld.Absent
break
}
v = itr.n.author.v
case 4:
k = &fieldName__Commit_Committer
if itr.n.committer.m == schema.Maybe_Absent {
v = ipld.Absent
break
}
v = itr.n.committer.v
case 5:
k = &fieldName__Commit_Encoding
if itr.n.encoding.m == schema.Maybe_Absent {
v = ipld.Absent
break
}
v = &itr.n.encoding.v
case 6:
k = &fieldName__Commit_Signature
if itr.n.signature.m == schema.Maybe_Absent {
v = ipld.Absent
break
}
v = &itr.n.signature.v
case 7:
k = &fieldName__Commit_Mergetag
v = &itr.n.mergetag
case 8:
k = &fieldName__Commit_Other
v = &itr.n.other
default:
panic("unreachable")
}
itr.idx++
return
}
func (itr *_Commit__MapItr) Done() bool {
return itr.idx >= 9
}
func (Commit) ListIterator() ipld.ListIterator {
return nil
}
func (Commit) Length() int64 {
return 9
}
func (Commit) IsAbsent() bool {
return false
}
func (Commit) IsNull() bool {
return false
}
func (Commit) AsBool() (bool, error) {
return mixins.Map{TypeName: "ipldgit.Commit"}.AsBool()
}
func (Commit) AsInt() (int64, error) {
return mixins.Map{TypeName: "ipldgit.Commit"}.AsInt()
}
func (Commit) AsFloat() (float64, error) {
return mixins.Map{TypeName: "ipldgit.Commit"}.AsFloat()
}
func (Commit) AsString() (string, error) {
return mixins.Map{TypeName: "ipldgit.Commit"}.AsString()
}
func (Commit) AsBytes() ([]byte, error) {
return mixins.Map{TypeName: "ipldgit.Commit"}.AsBytes()
}
func (Commit) AsLink() (ipld.Link, error) {
return mixins.Map{TypeName: "ipldgit.Commit"}.AsLink()
}
func (Commit) Prototype() ipld.NodePrototype {
return _Commit__Prototype{}
}
type _Commit__Prototype struct{}
func (_Commit__Prototype) NewBuilder() ipld.NodeBuilder {
var nb _Commit__Builder
nb.Reset()
return &nb
}
type _Commit__Builder struct {
_Commit__Assembler
}
func (nb *_Commit__Builder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
}
return nb.w
}
func (nb *_Commit__Builder) Reset() {
var w _Commit
var m schema.Maybe
*nb = _Commit__Builder{_Commit__Assembler{w: &w, m: &m}}
}
type _Commit__Assembler struct {
w *_Commit
m *schema.Maybe
state maState
s int
f int
cm schema.Maybe
ca_tree _Tree_Link__Assembler
ca_parents _Commit_Link_List__Assembler
ca_message _String__Assembler
ca_author _PersonInfo__Assembler
ca_committer _PersonInfo__Assembler
ca_encoding _String__Assembler
ca_signature _GpgSig__Assembler
ca_mergetag _Tag_List__Assembler
ca_other _String_List__Assembler
}
func (na *_Commit__Assembler) reset() {
na.state = maState_initial
na.s = 0
na.ca_tree.reset()
na.ca_parents.reset()
na.ca_message.reset()
na.ca_author.reset()
na.ca_committer.reset()
na.ca_encoding.reset()
na.ca_signature.reset()
na.ca_mergetag.reset()
na.ca_other.reset()
}
var (
fieldBit__Commit_Tree = 1 << 0
fieldBit__Commit_Parents = 1 << 1
fieldBit__Commit_Message = 1 << 2
fieldBit__Commit_Author = 1 << 3
fieldBit__Commit_Committer = 1 << 4
fieldBit__Commit_Encoding = 1 << 5
fieldBit__Commit_Signature = 1 << 6
fieldBit__Commit_Mergetag = 1 << 7
fieldBit__Commit_Other = 1 << 8
fieldBits__Commit_sufficient = 0 + 1<<0 + 1<<1 + 1<<2 + 1<<7 + 1<<8
)
func (na *_Commit__Assembler) BeginMap(int64) (ipld.MapAssembler, error) {
switch *na.m {
case schema.Maybe_Value, schema.Maybe_Null:
panic("invalid state: cannot assign into assembler that's already finished")
case midvalue:
panic("invalid state: it makes no sense to 'begin' twice on the same assembler!")
}
*na.m = midvalue
if na.w == nil {
na.w = &_Commit{}
}
return na, nil
}
func (_Commit__Assembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
return mixins.MapAssembler{TypeName: "ipldgit.Commit"}.BeginList(0)
}
func (na *_Commit__Assembler) AssignNull() error {
switch *na.m {
case allowNull:
*na.m = schema.Maybe_Null
return nil
case schema.Maybe_Absent:
return mixins.MapAssembler{TypeName: "ipldgit.Commit"}.AssignNull()
case schema.Maybe_Value, schema.Maybe_Null:
panic("invalid state: cannot assign into assembler that's already finished")
case midvalue:
panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
}
panic("unreachable")
}
func (_Commit__Assembler) AssignBool(bool) error {
return mixins.MapAssembler{TypeName: "ipldgit.Commit"}.AssignBool(false)
}
func (_Commit__Assembler) AssignInt(int64) error {
return mixins.MapAssembler{TypeName: "ipldgit.Commit"}.AssignInt(0)
}
func (_Commit__Assembler) AssignFloat(float64) error {
return mixins.MapAssembler{TypeName: "ipldgit.Commit"}.AssignFloat(0)
}
func (_Commit__Assembler) AssignString(string) error {
return mixins.MapAssembler{TypeName: "ipldgit.Commit"}.AssignString("")
}
func (_Commit__Assembler) AssignBytes([]byte) error {
return mixins.MapAssembler{TypeName: "ipldgit.Commit"}.AssignBytes(nil)
}
func (_Commit__Assembler) AssignLink(ipld.Link) error {
return mixins.MapAssembler{TypeName: "ipldgit.Commit"}.AssignLink(nil)
}
func (na *_Commit__Assembler) AssignNode(v ipld.Node) error {
if v.IsNull() {
return na.AssignNull()
}
if v2, ok := v.(*_Commit); ok {
switch *na.m {
case schema.Maybe_Value, schema.Maybe_Null:
panic("invalid state: cannot assign into assembler that's already finished")
case midvalue:
panic("invalid state: cannot assign null into an assembler that's already begun working on recursive structures!")
}
if na.w == nil {
na.w = v2
*na.m = schema.Maybe_Value
return nil
}
*na.w = *v2
*na.m = schema.Maybe_Value
return nil
}
if v.Kind() != ipld.Kind_Map {
return ipld.ErrWrongKind{TypeName: "ipldgit.Commit", MethodName: "AssignNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: v.Kind()}
}
itr := v.MapIterator()
for !itr.Done() {
k, v, err := itr.Next()
if err != nil {
return err
}
if err := na.AssembleKey().AssignNode(k); err != nil {
return err
}
if err := na.AssembleValue().AssignNode(v); err != nil {
return err
}
}
return na.Finish()
}
func (_Commit__Assembler) Prototype() ipld.NodePrototype {
return _Commit__Prototype{}
}
func (ma *_Commit__Assembler) valueFinishTidy() bool {
switch ma.f {
case 0:
switch ma.cm {
case schema.Maybe_Value:
ma.ca_tree.w = nil
ma.cm = schema.Maybe_Absent
ma.state = maState_initial
return true
default:
return false
}
case 1:
switch ma.cm {
case schema.Maybe_Value:
ma.ca_parents.w = nil
ma.cm = schema.Maybe_Absent
ma.state = maState_initial
return true
default:
return false
}
case 2:
switch ma.cm {
case schema.Maybe_Value:
ma.ca_message.w = nil
ma.cm = schema.Maybe_Absent
ma.state = maState_initial
return true
default:
return false
}
case 3:
switch ma.w.author.m {
case schema.Maybe_Value:
ma.w.author.v = ma.ca_author.w
ma.state = maState_initial
return true
default:
return false
}
case 4:
switch ma.w.committer.m {
case schema.Maybe_Value:
ma.w.committer.v = ma.ca_committer.w
ma.state = maState_initial
return true
default:
return false
}
case 5:
switch ma.w.encoding.m {
case schema.Maybe_Value:
ma.state = maState_initial
return true
default:
return false
}
case 6:
switch ma.w.signature.m {
case schema.Maybe_Value:
ma.state = maState_initial
return true
default:
return false
}
case 7:
switch ma.cm {
case schema.Maybe_Value:
ma.ca_mergetag.w = nil
ma.cm = schema.Maybe_Absent
ma.state = maState_initial
return true
default:
return false
}
case 8:
switch ma.cm {
case schema.Maybe_Value:
ma.ca_other.w = nil
ma.cm = schema.Maybe_Absent
ma.state = maState_initial
return true
default:
return false
}
default:
panic("unreachable")
}
}
func (ma *_Commit__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error) {
switch ma.state {
case maState_initial:
// carry on
case maState_midKey:
panic("invalid state: AssembleEntry cannot be called when in the middle of assembling another key")
case maState_expectValue:
panic("invalid state: AssembleEntry cannot be called when expecting start of value assembly")
case maState_midValue:
if !ma.valueFinishTidy() {
panic("invalid state: AssembleEntry cannot be called when in the middle of assembling a value")
} // if tidy success: carry on
case maState_finished:
panic("invalid state: AssembleEntry cannot be called on an assembler that's already finished")
}
switch k {
case "tree":
if ma.s&fieldBit__Commit_Tree != 0 {
return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Tree}
}
ma.s += fieldBit__Commit_Tree
ma.state = maState_midValue
ma.f = 0
ma.ca_tree.w = &ma.w.tree
ma.ca_tree.m = &ma.cm
return &ma.ca_tree, nil
case "parents":
if ma.s&fieldBit__Commit_Parents != 0 {
return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Parents}
}
ma.s += fieldBit__Commit_Parents
ma.state = maState_midValue
ma.f = 1
ma.ca_parents.w = &ma.w.parents
ma.ca_parents.m = &ma.cm
return &ma.ca_parents, nil
case "message":
if ma.s&fieldBit__Commit_Message != 0 {
return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Message}
}
ma.s += fieldBit__Commit_Message
ma.state = maState_midValue
ma.f = 2
ma.ca_message.w = &ma.w.message
ma.ca_message.m = &ma.cm
return &ma.ca_message, nil
case "author":
if ma.s&fieldBit__Commit_Author != 0 {
return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Author}
}
ma.s += fieldBit__Commit_Author
ma.state = maState_midValue
ma.f = 3
ma.ca_author.w = ma.w.author.v
ma.ca_author.m = &ma.w.author.m
return &ma.ca_author, nil
case "committer":
if ma.s&fieldBit__Commit_Committer != 0 {
return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Committer}
}
ma.s += fieldBit__Commit_Committer
ma.state = maState_midValue
ma.f = 4
ma.ca_committer.w = ma.w.committer.v
ma.ca_committer.m = &ma.w.committer.m
return &ma.ca_committer, nil
case "encoding":
if ma.s&fieldBit__Commit_Encoding != 0 {
return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Encoding}
}
ma.s += fieldBit__Commit_Encoding
ma.state = maState_midValue
ma.f = 5
ma.ca_encoding.w = &ma.w.encoding.v
ma.ca_encoding.m = &ma.w.encoding.m
return &ma.ca_encoding, nil
case "signature":
if ma.s&fieldBit__Commit_Signature != 0 {
return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Signature}
}
ma.s += fieldBit__Commit_Signature
ma.state = maState_midValue
ma.f = 6
ma.ca_signature.w = &ma.w.signature.v
ma.ca_signature.m = &ma.w.signature.m
return &ma.ca_signature, nil
case "mergetag":
if ma.s&fieldBit__Commit_Mergetag != 0 {
return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Mergetag}
}
ma.s += fieldBit__Commit_Mergetag
ma.state = maState_midValue
ma.f = 7
ma.ca_mergetag.w = &ma.w.mergetag
ma.ca_mergetag.m = &ma.cm
return &ma.ca_mergetag, nil
case "other":
if ma.s&fieldBit__Commit_Other != 0 {
return nil, ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Other}
}
ma.s += fieldBit__Commit_Other
ma.state = maState_midValue
ma.f = 8
ma.ca_other.w = &ma.w.other
ma.ca_other.m = &ma.cm
return &ma.ca_other, nil
}
return nil, ipld.ErrInvalidKey{TypeName: "ipldgit.Commit", Key: &_String{k}}
}
func (ma *_Commit__Assembler) AssembleKey() ipld.NodeAssembler {
switch ma.state {
case maState_initial:
// carry on
case maState_midKey:
panic("invalid state: AssembleKey cannot be called when in the middle of assembling another key")
case maState_expectValue:
panic("invalid state: AssembleKey cannot be called when expecting start of value assembly")
case maState_midValue:
if !ma.valueFinishTidy() {
panic("invalid state: AssembleKey cannot be called when in the middle of assembling a value")
} // if tidy success: carry on
case maState_finished:
panic("invalid state: AssembleKey cannot be called on an assembler that's already finished")
}
ma.state = maState_midKey
return (*_Commit__KeyAssembler)(ma)
}
func (ma *_Commit__Assembler) AssembleValue() ipld.NodeAssembler {
switch ma.state {
case maState_initial:
panic("invalid state: AssembleValue cannot be called when no key is primed")
case maState_midKey:
panic("invalid state: AssembleValue cannot be called when in the middle of assembling a key")
case maState_expectValue:
// carry on
case maState_midValue:
panic("invalid state: AssembleValue cannot be called when in the middle of assembling another value")
case maState_finished:
panic("invalid state: AssembleValue cannot be called on an assembler that's already finished")
}
ma.state = maState_midValue
switch ma.f {
case 0:
ma.ca_tree.w = &ma.w.tree
ma.ca_tree.m = &ma.cm
return &ma.ca_tree
case 1:
ma.ca_parents.w = &ma.w.parents
ma.ca_parents.m = &ma.cm
return &ma.ca_parents
case 2:
ma.ca_message.w = &ma.w.message
ma.ca_message.m = &ma.cm
return &ma.ca_message
case 3:
ma.ca_author.w = ma.w.author.v
ma.ca_author.m = &ma.w.author.m
return &ma.ca_author
case 4:
ma.ca_committer.w = ma.w.committer.v
ma.ca_committer.m = &ma.w.committer.m
return &ma.ca_committer
case 5:
ma.ca_encoding.w = &ma.w.encoding.v
ma.ca_encoding.m = &ma.w.encoding.m
return &ma.ca_encoding
case 6:
ma.ca_signature.w = &ma.w.signature.v
ma.ca_signature.m = &ma.w.signature.m
return &ma.ca_signature
case 7:
ma.ca_mergetag.w = &ma.w.mergetag
ma.ca_mergetag.m = &ma.cm
return &ma.ca_mergetag
case 8:
ma.ca_other.w = &ma.w.other
ma.ca_other.m = &ma.cm
return &ma.ca_other
default:
panic("unreachable")
}
}
func (ma *_Commit__Assembler) Finish() error {
switch ma.state {
case maState_initial:
// carry on
case maState_midKey:
panic("invalid state: Finish cannot be called when in the middle of assembling a key")
case maState_expectValue:
panic("invalid state: Finish cannot be called when expecting start of value assembly")
case maState_midValue:
if !ma.valueFinishTidy() {
panic("invalid state: Finish cannot be called when in the middle of assembling a value")
} // if tidy success: carry on
case maState_finished:
panic("invalid state: Finish cannot be called on an assembler that's already finished")
}
if ma.s&fieldBits__Commit_sufficient != fieldBits__Commit_sufficient {
err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)}
if ma.s&fieldBit__Commit_Tree == 0 {
err.Missing = append(err.Missing, "tree")
}
if ma.s&fieldBit__Commit_Parents == 0 {
err.Missing = append(err.Missing, "parents")
}
if ma.s&fieldBit__Commit_Message == 0 {
err.Missing = append(err.Missing, "message")
}
if ma.s&fieldBit__Commit_Mergetag == 0 {
err.Missing = append(err.Missing, "mergetag")
}
if ma.s&fieldBit__Commit_Other == 0 {
err.Missing = append(err.Missing, "other")
}
return err
}
ma.state = maState_finished
*ma.m = schema.Maybe_Value
return nil
}
func (ma *_Commit__Assembler) KeyPrototype() ipld.NodePrototype {
return _String__Prototype{}
}
func (ma *_Commit__Assembler) ValuePrototype(k string) ipld.NodePrototype {
panic("todo structbuilder mapassembler valueprototype")
}
type _Commit__KeyAssembler _Commit__Assembler
func (_Commit__KeyAssembler) BeginMap(sizeHint int64) (ipld.MapAssembler, error) {
return mixins.StringAssembler{TypeName: "ipldgit.Commit.KeyAssembler"}.BeginMap(0)
}
func (_Commit__KeyAssembler) BeginList(sizeHint int64) (ipld.ListAssembler, error) {
return mixins.StringAssembler{TypeName: "ipldgit.Commit.KeyAssembler"}.BeginList(0)
}
func (na *_Commit__KeyAssembler) AssignNull() error {
return mixins.StringAssembler{TypeName: "ipldgit.Commit.KeyAssembler"}.AssignNull()
}
func (_Commit__KeyAssembler) AssignBool(bool) error {
return mixins.StringAssembler{TypeName: "ipldgit.Commit.KeyAssembler"}.AssignBool(false)
}
func (_Commit__KeyAssembler) AssignInt(int64) error {
return mixins.StringAssembler{TypeName: "ipldgit.Commit.KeyAssembler"}.AssignInt(0)
}
func (_Commit__KeyAssembler) AssignFloat(float64) error {
return mixins.StringAssembler{TypeName: "ipldgit.Commit.KeyAssembler"}.AssignFloat(0)
}
func (ka *_Commit__KeyAssembler) AssignString(k string) error {
if ka.state != maState_midKey {
panic("misuse: KeyAssembler held beyond its valid lifetime")
}
switch k {
case "tree":
if ka.s&fieldBit__Commit_Tree != 0 {
return ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Tree}
}
ka.s += fieldBit__Commit_Tree
ka.state = maState_expectValue
ka.f = 0
return nil
case "parents":
if ka.s&fieldBit__Commit_Parents != 0 {
return ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Parents}
}
ka.s += fieldBit__Commit_Parents
ka.state = maState_expectValue
ka.f = 1
return nil
case "message":
if ka.s&fieldBit__Commit_Message != 0 {
return ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Message}
}
ka.s += fieldBit__Commit_Message
ka.state = maState_expectValue
ka.f = 2
return nil
case "author":
if ka.s&fieldBit__Commit_Author != 0 {
return ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Author}
}
ka.s += fieldBit__Commit_Author
ka.state = maState_expectValue
ka.f = 3
return nil
case "committer":
if ka.s&fieldBit__Commit_Committer != 0 {
return ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Committer}
}
ka.s += fieldBit__Commit_Committer
ka.state = maState_expectValue
ka.f = 4
return nil
case "encoding":
if ka.s&fieldBit__Commit_Encoding != 0 {
return ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Encoding}
}
ka.s += fieldBit__Commit_Encoding
ka.state = maState_expectValue
ka.f = 5
return nil
case "signature":
if ka.s&fieldBit__Commit_Signature != 0 {
return ipld.ErrRepeatedMapKey{Key: &fieldName__Commit_Signature}
}
ka.s += fieldBit__Commit_Signature
ka.state = maState_expectValue
ka.f = 6