/
piqi_piqi.ml
2139 lines (2023 loc) · 118 KB
/
piqi_piqi.ml
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
module rec Piqtype :
sig
type uint64 = int64
type uint32 = int32
type uint = int
type float64 = float
type float32 = float
type uint64_fixed = Piqtype.uint64
type uint32_fixed = Piqtype.uint32
type protobuf_int64 = int64
type protobuf_int32 = int32
type piqi_any = Piqtype.any
type int64_fixed = int64
type int32_fixed = int32
type float = Piqtype.float64
type binary = string
type word = string
type typename = Piqtype.name
type piq_ast = Piq_ast.ast
type name = Piqtype.word
type typedef =
[
| `record of Piqtype.record
| `variant of Piqtype.variant
| `enum of Piqtype.enum
| `alias of Piqtype.alias
| `list of Piqtype.piqi_list
]
type protobuf_wire_type =
[
| `varint
| `zigzag_varint
| `fixed32
| `fixed64
| `signed_varint
| `signed_fixed32
| `signed_fixed64
| `block
]
type piqi_type =
[ | `int | `float | `bool | `string | `binary | `any
]
type piqtype = [ | typedef | piqi_type ]
type piq_format = [ | `word | `text ]
type namespace =
[ | `piqi of Piqtype.piqi | `import of Piqtype.import
]
type function_param =
[
| `name of Piqtype.name
| `record of Piqtype.record
| `variant of Piqtype.variant
| `enum of Piqtype.enum
| `list of Piqtype.piqi_list
| `alias of Piqtype.alias
]
type field_mode = [ | `required | `optional | `repeated ]
type extend_target =
[
| `typedef of Piqtype.name
| `name of Piqtype.name
| `field of Piqtype.name
| `option of Piqtype.name
| `import of Piqtype.name
| `func of Piqtype.name
]
type variant = Variant.t
type record = Record.t
type piqi = Piqi.t
type option = Option.t
type piqi_list = Piqi_list.t
type includ = Includ.t
type import = Import.t
type func = Func.t
type field = Field.t
type extend = Extend.t
type enum = Enum.t
type any = Any.t
type alias = Alias.t
end = Piqtype
and
Variant :
sig
type t =
{ mutable name : Piqtype.name option;
mutable option : Piqtype.option list;
mutable protobuf_name : string option;
mutable proto_name : string option;
mutable protobuf_custom : string list;
mutable proto_custom : string list;
mutable json_name : string option;
mutable parent : Piqtype.namespace option;
mutable is_func_param : bool;
mutable unparsed_piq_ast : Piqtype.uint option;
mutable ocaml_name : string option
}
end = Variant
and
Record :
sig
type t =
{ mutable name : Piqtype.name option;
mutable field : Piqtype.field list;
mutable protobuf_name : string option;
mutable proto_name : string option;
mutable protobuf_custom : string list;
mutable proto_custom : string list;
mutable json_name : string option;
mutable parent : Piqtype.namespace option;
mutable wire_field : Piqtype.field list;
mutable is_func_param : bool;
mutable unparsed_piq_ast : Piqtype.uint option;
mutable ocaml_name : string option
}
end = Record
and
Piqi :
sig
type t =
{ mutable modname : Piqtype.word option;
mutable typedef : Piqtype.typedef list;
mutable import : Piqtype.import list;
mutable func : Piqtype.func list;
mutable protobuf_custom : string list;
mutable proto_custom : string list;
mutable protobuf_package : string option;
mutable proto_package : string option;
mutable custom_field : Piqtype.word list;
mutable includ : Piqtype.includ list;
mutable extend : Piqtype.extend list;
mutable extended_typedef : Piqtype.typedef list;
mutable func_typedef : Piqtype.typedef list;
mutable extended_func_typedef : Piqtype.typedef list;
mutable resolved_typedef : Piqtype.typedef list;
mutable imported_typedef : Piqtype.typedef list;
mutable resolved_import : Piqtype.import list;
mutable extended_import : Piqtype.import list;
mutable resolved_func : Piqtype.func list;
mutable extended_func : Piqtype.func list;
mutable included_piqi : Piqtype.piqi list;
mutable original_piqi : Piqtype.piqi option;
mutable ast : Piqtype.piq_ast option;
mutable unparsed_piq_ast : Piqtype.uint option;
mutable ocaml_module : string option
}
end = Piqi
and
Option :
sig
type t =
{ mutable name : Piqtype.name option;
mutable typename : Piqtype.typename option;
mutable deprecated : bool;
mutable piq_format : Piqtype.piq_format option;
mutable protobuf_name : string option;
mutable proto_name : string option; mutable code : int32 option;
mutable json_name : string option;
mutable getopt_letter : Piqtype.word option;
mutable getopt_doc : string option;
mutable piqtype : Piqtype.piqtype option;
mutable alt_name : Piqtype.word option;
mutable unparsed_piq_ast : Piqtype.uint option;
mutable ocaml_name : string option
}
end = Option
and
Piqi_list :
sig
type t =
{ mutable name : Piqtype.name option;
mutable typename : Piqtype.typename;
mutable piq_format : Piqtype.piq_format option;
mutable protobuf_name : string option;
mutable proto_name : string option;
mutable protobuf_custom : string list;
mutable proto_custom : string list; mutable protobuf_packed : bool;
mutable wire_packed : bool; mutable json_name : string option;
mutable parent : Piqtype.namespace option;
mutable is_func_param : bool;
mutable piqtype : Piqtype.piqtype option;
mutable unparsed_piq_ast : Piqtype.uint option;
mutable ocaml_name : string option; mutable ocaml_array : bool
}
end = Piqi_list
and
Includ :
sig
type t =
{ mutable modname : Piqtype.word;
mutable unparsed_piq_ast : Piqtype.uint option
}
end = Includ
and
Import :
sig
type t =
{ mutable modname : Piqtype.word; mutable name : Piqtype.name option;
mutable piqi : Piqtype.piqi option;
mutable unparsed_piq_ast : Piqtype.uint option;
mutable ocaml_name : string option
}
end = Import
and
Func :
sig
type t =
{ mutable name : Piqtype.name;
mutable input : Piqtype.function_param option;
mutable output : Piqtype.function_param option;
mutable error : Piqtype.function_param option;
mutable resolved_input : Piqtype.typedef option;
mutable resolved_output : Piqtype.typedef option;
mutable resolved_error : Piqtype.typedef option;
mutable unparsed_piq_ast : Piqtype.uint option;
mutable ocaml_name : string option
}
end = Func
and
Field :
sig
type t =
{ mutable name : Piqtype.name option;
mutable typename : Piqtype.typename option;
mutable mode : Piqtype.field_mode;
mutable default : Piqtype.piqi_any option;
mutable deprecated : bool;
mutable piq_format : Piqtype.piq_format option;
mutable protobuf_name : string option;
mutable proto_name : string option; mutable code : int32 option;
mutable protobuf_packed : bool; mutable wire_packed : bool;
mutable json_name : string option;
mutable getopt_letter : Piqtype.word option;
mutable getopt_doc : string option;
mutable piqtype : Piqtype.piqtype option;
mutable alt_name : Piqtype.word option;
mutable unparsed_piq_ast : Piqtype.uint option;
mutable ocaml_name : string option; mutable ocaml_array : bool;
mutable ocaml_optional : bool
}
end = Field
and
Extend :
sig
type t =
{ mutable what : Piqtype.extend_target list; mutable override : bool;
mutable piqi_with : Piqtype.piqi_any list;
mutable quote : Piqtype.piqi_any list;
mutable unparsed_piq_ast : Piqtype.uint option
}
end = Extend
and
Enum :
sig
type t =
{ mutable name : Piqtype.name option;
mutable option : Piqtype.option list;
mutable protobuf_name : string option;
mutable proto_name : string option;
mutable protobuf_custom : string list;
mutable proto_custom : string list;
mutable json_name : string option;
mutable parent : Piqtype.namespace option;
mutable is_func_param : bool;
mutable unparsed_piq_ast : Piqtype.uint option;
mutable ocaml_name : string option
}
end = Enum
and
Any :
sig
type t =
{ mutable typename : string option;
mutable protobuf : Piqtype.binary option; mutable ref : int option
}
end = Any
and
Alias :
sig
type t =
{ mutable name : Piqtype.name option;
mutable typename : Piqtype.typename option;
mutable piqi_type : Piqtype.piqi_type option;
mutable piq_format : Piqtype.piq_format option;
mutable protobuf_name : string option;
mutable proto_name : string option;
mutable protobuf_type : string option;
mutable protobuf_wire_type : Piqtype.protobuf_wire_type option;
mutable json_name : string option;
mutable parent : Piqtype.namespace option;
mutable is_func_param : bool;
mutable piqtype : Piqtype.piqtype option;
mutable unparsed_piq_ast : Piqtype.uint option;
mutable ocaml_name : string option;
mutable ocaml_type : string option
}
end = Alias
include Piqtype
let next_count = Piqloc.next_icount
let curr_count () = !Piqloc.icount
let refer ref obj =
if not (Obj.is_int (Obj.repr obj)) then Piqloc.addrefret ref obj else obj
let incr_count_if_true (((obj, _) as res)) =
(if obj then ignore (next_count ()) else (); res)
let rec parse_word x = parse_string x
and parse_variant x =
let x = Piqirun.parse_record x in
let count = next_count ()
in
refer count
(let (_unparsed_piq_ast, x) =
Piqirun.parse_optional_field 1 parse_uint x in
let (_protobuf_name, x) =
Piqirun.parse_optional_field 90072013 parse_string x in
let (_protobuf_custom, x) =
Piqirun.parse_repeated_field 112352691 parse_string x in
let (_proto_name, x) =
Piqirun.parse_optional_field 139663632 parse_string x in
let (_name, x) =
Piqirun.parse_optional_field 150958667 parse_name x in
let (_option, x) =
Piqirun.parse_repeated_field 192598901 parse_option x in
let (_parent, x) =
Piqirun.parse_optional_field 226362666 parse_namespace x in
let (_ocaml_name, x) =
Piqirun.parse_optional_field 351856652 parse_string x in
let (_is_func_param, x) =
incr_count_if_true (Piqirun.parse_flag 367658567 x) in
let (_proto_custom, x) =
Piqirun.parse_repeated_field 405875126 parse_string x in
let (_json_name, x) =
Piqirun.parse_optional_field 515275216 parse_string x
in
(Piqirun.check_unparsed_fields x;
{
Variant.unparsed_piq_ast = _unparsed_piq_ast;
Variant.protobuf_name = _protobuf_name;
Variant.protobuf_custom = _protobuf_custom;
Variant.proto_name = _proto_name;
Variant.name = _name;
Variant.option = _option;
Variant.parent = _parent;
Variant.ocaml_name = _ocaml_name;
Variant.is_func_param = _is_func_param;
Variant.proto_custom = _proto_custom;
Variant.json_name = _json_name;
}))
and parse_uint64_fixed x =
(fun x ->
let count = next_count () in refer count (Piqirun.int64_of_fixed64 x))
x
and packed_parse_uint64_fixed x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int64_of_packed_fixed64 x))
x
and parse_uint64 x =
(fun x ->
let count = next_count () in refer count (Piqirun.int64_of_varint x))
x
and packed_parse_uint64 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int64_of_packed_varint x))
x
and parse_uint32_fixed x =
(fun x ->
let count = next_count () in refer count (Piqirun.int32_of_fixed32 x))
x
and packed_parse_uint32_fixed x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int32_of_packed_fixed32 x))
x
and parse_uint32 x =
(fun x ->
let count = next_count () in refer count (Piqirun.int32_of_varint x))
x
and packed_parse_uint32 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int32_of_packed_varint x))
x
and parse_uint x =
(fun x ->
let count = next_count () in refer count (Piqirun.int_of_varint x))
x
and packed_parse_uint x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int_of_packed_varint x))
x
and parse_typedef x =
let (code, x) = Piqirun.parse_variant x in
let count = next_count ()
in
refer count
(match code with
| 502036113 ->
let res =
let count = curr_count () in refer count (parse_record x)
in `record res
| 484589701 ->
let res =
let count = curr_count () in refer count (parse_variant x)
in `variant res
| 51800833 ->
let res = let count = curr_count () in refer count (parse_enum x)
in `enum res
| 26300816 ->
let res = let count = curr_count () in refer count (parse_alias x)
in `alias res
| 129178718 ->
let res =
let count = curr_count () in refer count (parse_piqi_list x)
in `list res
| _ -> Piqirun.error_variant x code)
and parse_typename x = parse_name x
and parse_string x =
(fun x ->
let count = next_count () in refer count (Piqirun.string_of_block x))
x
and parse_record x =
let x = Piqirun.parse_record x in
let count = next_count ()
in
refer count
(let (_unparsed_piq_ast, x) =
Piqirun.parse_optional_field 1 parse_uint x in
let (_field, x) =
Piqirun.parse_repeated_field 9671866 parse_field x in
let (_protobuf_name, x) =
Piqirun.parse_optional_field 90072013 parse_string x in
let (_protobuf_custom, x) =
Piqirun.parse_repeated_field 112352691 parse_string x in
let (_wire_field, x) =
Piqirun.parse_repeated_field 112412530 parse_field x in
let (_proto_name, x) =
Piqirun.parse_optional_field 139663632 parse_string x in
let (_name, x) =
Piqirun.parse_optional_field 150958667 parse_name x in
let (_parent, x) =
Piqirun.parse_optional_field 226362666 parse_namespace x in
let (_ocaml_name, x) =
Piqirun.parse_optional_field 351856652 parse_string x in
let (_is_func_param, x) =
incr_count_if_true (Piqirun.parse_flag 367658567 x) in
let (_proto_custom, x) =
Piqirun.parse_repeated_field 405875126 parse_string x in
let (_json_name, x) =
Piqirun.parse_optional_field 515275216 parse_string x
in
(Piqirun.check_unparsed_fields x;
{
Record.unparsed_piq_ast = _unparsed_piq_ast;
Record.field = _field;
Record.protobuf_name = _protobuf_name;
Record.protobuf_custom = _protobuf_custom;
Record.wire_field = _wire_field;
Record.proto_name = _proto_name;
Record.name = _name;
Record.parent = _parent;
Record.ocaml_name = _ocaml_name;
Record.is_func_param = _is_func_param;
Record.proto_custom = _proto_custom;
Record.json_name = _json_name;
}))
and parse_protobuf_wire_type x =
let count = next_count ()
in
refer count
(match Piqirun.int32_of_signed_varint x with
| 329594984l -> `varint
| 99211597l -> `zigzag_varint
| 136997651l -> `fixed32
| 136998322l -> `fixed64
| 441915897l -> `signed_varint
| 488499298l -> `signed_fixed32
| 488499969l -> `signed_fixed64
| 352089421l -> `block
| x -> Piqirun.error_enum_const x)
and packed_parse_protobuf_wire_type x =
let count = next_count ()
in
refer count
(match Piqirun.int32_of_packed_signed_varint x with
| 329594984l -> `varint
| 99211597l -> `zigzag_varint
| 136997651l -> `fixed32
| 136998322l -> `fixed64
| 441915897l -> `signed_varint
| 488499298l -> `signed_fixed32
| 488499969l -> `signed_fixed64
| 352089421l -> `block
| x -> Piqirun.error_enum_const x)
and parse_protobuf_int64 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int64_of_signed_varint x))
x
and packed_parse_protobuf_int64 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int64_of_packed_signed_varint x))
x
and parse_protobuf_int32 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int32_of_signed_varint x))
x
and packed_parse_protobuf_int32 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int32_of_packed_signed_varint x))
x
and parse_piqtype x =
let (code, x) = Piqirun.parse_variant x in
let count = next_count ()
in
refer count
(match code with
| 416823115 -> (parse_typedef x :> piqtype)
| 198318774 -> (parse_piqi_type x :> piqtype)
| _ -> Piqirun.error_variant x code)
and parse_piqi_type x =
let count = next_count ()
in
refer count
(match Piqirun.int32_of_signed_varint x with
| 5246191l -> `int
| 43435420l -> `float
| 18580522l -> `bool
| 288368849l -> `string
| 218872833l -> `binary
| 4848364l -> `any
| x -> Piqirun.error_enum_const x)
and packed_parse_piqi_type x =
let count = next_count ()
in
refer count
(match Piqirun.int32_of_packed_signed_varint x with
| 5246191l -> `int
| 43435420l -> `float
| 18580522l -> `bool
| 288368849l -> `string
| 218872833l -> `binary
| 4848364l -> `any
| x -> Piqirun.error_enum_const x)
and parse_piqi_any x = parse_any x
and parse_piqi x =
let x = Piqirun.parse_record x in
let count = next_count ()
in
refer count
(let (_unparsed_piq_ast, x) =
Piqirun.parse_optional_field 1 parse_uint x in
let (_ast, x) =
Piqirun.parse_optional_field 4849474 parse_piq_ast x in
let (_modname, x) =
Piqirun.parse_optional_field 13841580 parse_word x in
let (_imported_typedef, x) =
Piqirun.parse_repeated_field 43698114 parse_typedef x in
let (_extended_func, x) =
Piqirun.parse_repeated_field 79393432 parse_func x in
let (_protobuf_custom, x) =
Piqirun.parse_repeated_field 112352691 parse_string x in
let (_resolved_import, x) =
Piqirun.parse_repeated_field 114029658 parse_import x in
let (_extend, x) =
Piqirun.parse_repeated_field 119198170 parse_extend x in
let (_import, x) =
Piqirun.parse_repeated_field 142778725 parse_import x in
let (_included_piqi, x) =
Piqirun.parse_repeated_field 146026754 parse_piqi x in
let (_extended_typedef, x) =
Piqirun.parse_repeated_field 150338679 parse_typedef x in
let (_custom_field, x) =
Piqirun.parse_repeated_field 162247646 parse_word x in
let (_resolved_func, x) =
Piqirun.parse_repeated_field 268445433 parse_func x in
let (_includ, x) =
Piqirun.parse_repeated_field 301399592 parse_includ x in
let (_func_typedef, x) =
Piqirun.parse_repeated_field 301864450 parse_typedef x in
let (_proto_package, x) =
Piqirun.parse_optional_field 333467105 parse_string x in
let (_func, x) =
Piqirun.parse_repeated_field 340962072 parse_func x in
let (_ocaml_module, x) =
Piqirun.parse_optional_field 375807149 parse_string x in
let (_protobuf_package, x) =
Piqirun.parse_optional_field 376215364 parse_string x in
let (_proto_custom, x) =
Piqirun.parse_repeated_field 405875126 parse_string x in
let (_typedef, x) =
Piqirun.parse_repeated_field 416823115 parse_typedef x in
let (_extended_import, x) =
Piqirun.parse_repeated_field 430482873 parse_import x in
let (_resolved_typedef, x) =
Piqirun.parse_repeated_field 448232118 parse_typedef x in
let (_original_piqi, x) =
Piqirun.parse_optional_field 455316941 parse_piqi x in
let (_extended_func_typedef, x) =
Piqirun.parse_repeated_field 512364886 parse_typedef x
in
(Piqirun.check_unparsed_fields x;
{
Piqi.unparsed_piq_ast = _unparsed_piq_ast;
Piqi.ast = _ast;
Piqi.modname = _modname;
Piqi.imported_typedef = _imported_typedef;
Piqi.extended_func = _extended_func;
Piqi.protobuf_custom = _protobuf_custom;
Piqi.resolved_import = _resolved_import;
Piqi.extend = _extend;
Piqi.import = _import;
Piqi.included_piqi = _included_piqi;
Piqi.extended_typedef = _extended_typedef;
Piqi.custom_field = _custom_field;
Piqi.resolved_func = _resolved_func;
Piqi.includ = _includ;
Piqi.func_typedef = _func_typedef;
Piqi.proto_package = _proto_package;
Piqi.func = _func;
Piqi.ocaml_module = _ocaml_module;
Piqi.protobuf_package = _protobuf_package;
Piqi.proto_custom = _proto_custom;
Piqi.typedef = _typedef;
Piqi.extended_import = _extended_import;
Piqi.resolved_typedef = _resolved_typedef;
Piqi.original_piqi = _original_piqi;
Piqi.extended_func_typedef = _extended_func_typedef;
}))
and parse_piq_format x =
let (code, x) = Piqirun.parse_variant x in
let count = next_count ()
in
refer count
(match code with
| 251462090 when x = (Piqirun.Varint 1) ->
let count = next_count () in refer count `word
| 217697453 when x = (Piqirun.Varint 1) ->
let count = next_count () in refer count `text
| _ -> Piqirun.error_variant x code)
and parse_piq_ast x = Piq_ast.ast_of_bool (parse_bool x)
and packed_parse_piq_ast x = Piq_ast.ast_of_bool (packed_parse_bool x)
and parse_option x =
let x = Piqirun.parse_record x in
let count = next_count ()
in
refer count
(let (_unparsed_piq_ast, x) =
Piqirun.parse_optional_field 1 parse_uint x in
let (_code, x) =
Piqirun.parse_optional_field 29667629 parse_int32 x in
let (_deprecated, x) =
incr_count_if_true (Piqirun.parse_flag 69402483 x) in
let (_protobuf_name, x) =
Piqirun.parse_optional_field 90072013 parse_string x in
let (_proto_name, x) =
Piqirun.parse_optional_field 139663632 parse_string x in
let (_name, x) =
Piqirun.parse_optional_field 150958667 parse_name x in
let (_piqtype, x) =
Piqirun.parse_optional_field 170743570 parse_piqtype x in
let (_alt_name, x) =
Piqirun.parse_optional_field 177782575 parse_word x in
let (_getopt_letter, x) =
Piqirun.parse_optional_field 215188758 parse_word x in
let (_typename, x) =
Piqirun.parse_optional_field 218690234 parse_typename x in
let (_piq_format, x) =
Piqirun.parse_optional_field 296833484 parse_piq_format x in
let (_ocaml_name, x) =
Piqirun.parse_optional_field 351856652 parse_string x in
let (_getopt_doc, x) =
Piqirun.parse_optional_field 442330184 parse_string x in
let (_json_name, x) =
Piqirun.parse_optional_field 515275216 parse_string x
in
(Piqirun.check_unparsed_fields x;
{
Option.unparsed_piq_ast = _unparsed_piq_ast;
Option.code = _code;
Option.deprecated = _deprecated;
Option.protobuf_name = _protobuf_name;
Option.proto_name = _proto_name;
Option.name = _name;
Option.piqtype = _piqtype;
Option.alt_name = _alt_name;
Option.getopt_letter = _getopt_letter;
Option.typename = _typename;
Option.piq_format = _piq_format;
Option.ocaml_name = _ocaml_name;
Option.getopt_doc = _getopt_doc;
Option.json_name = _json_name;
}))
and parse_namespace x =
let (code, x) = Piqirun.parse_variant x in
let count = next_count ()
in
refer count
(match code with
| 173536529 ->
let res = let count = curr_count () in refer count (parse_piqi x)
in `piqi res
| 142778725 ->
let res =
let count = curr_count () in refer count (parse_import x)
in `import res
| _ -> Piqirun.error_variant x code)
and parse_name x = parse_word x
and parse_piqi_list x =
let x = Piqirun.parse_record x in
let count = next_count ()
in
refer count
(let (_unparsed_piq_ast, x) =
Piqirun.parse_optional_field 1 parse_uint x in
let (_protobuf_name, x) =
Piqirun.parse_optional_field 90072013 parse_string x in
let (_protobuf_custom, x) =
Piqirun.parse_repeated_field 112352691 parse_string x in
let (_proto_name, x) =
Piqirun.parse_optional_field 139663632 parse_string x in
let (_name, x) =
Piqirun.parse_optional_field 150958667 parse_name x in
let (_piqtype, x) =
Piqirun.parse_optional_field 170743570 parse_piqtype x in
let (_protobuf_packed, x) =
incr_count_if_true (Piqirun.parse_flag 179842426 x) in
let (_typename, x) =
Piqirun.parse_required_field 218690234 parse_typename x in
let (_parent, x) =
Piqirun.parse_optional_field 226362666 parse_namespace x in
let (_piq_format, x) =
Piqirun.parse_optional_field 296833484 parse_piq_format x in
let (_ocaml_array, x) =
incr_count_if_true (Piqirun.parse_flag 333250744 x) in
let (_ocaml_name, x) =
Piqirun.parse_optional_field 351856652 parse_string x in
let (_is_func_param, x) =
incr_count_if_true (Piqirun.parse_flag 367658567 x) in
let (_proto_custom, x) =
Piqirun.parse_repeated_field 405875126 parse_string x in
let (_wire_packed, x) =
incr_count_if_true (Piqirun.parse_flag 422905280 x) in
let (_json_name, x) =
Piqirun.parse_optional_field 515275216 parse_string x
in
(Piqirun.check_unparsed_fields x;
{
Piqi_list.unparsed_piq_ast = _unparsed_piq_ast;
Piqi_list.protobuf_name = _protobuf_name;
Piqi_list.protobuf_custom = _protobuf_custom;
Piqi_list.proto_name = _proto_name;
Piqi_list.name = _name;
Piqi_list.piqtype = _piqtype;
Piqi_list.protobuf_packed = _protobuf_packed;
Piqi_list.typename = _typename;
Piqi_list.parent = _parent;
Piqi_list.piq_format = _piq_format;
Piqi_list.ocaml_array = _ocaml_array;
Piqi_list.ocaml_name = _ocaml_name;
Piqi_list.is_func_param = _is_func_param;
Piqi_list.proto_custom = _proto_custom;
Piqi_list.wire_packed = _wire_packed;
Piqi_list.json_name = _json_name;
}))
and parse_int64_fixed x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int64_of_signed_fixed64 x))
x
and packed_parse_int64_fixed x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int64_of_packed_signed_fixed64 x))
x
and parse_int64 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int64_of_zigzag_varint x))
x
and packed_parse_int64 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int64_of_packed_zigzag_varint x))
x
and parse_int32_fixed x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int32_of_signed_fixed32 x))
x
and packed_parse_int32_fixed x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int32_of_packed_signed_fixed32 x))
x
and parse_int32 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int32_of_zigzag_varint x))
x
and packed_parse_int32 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int32_of_packed_zigzag_varint x))
x
and parse_int x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int_of_zigzag_varint x))
x
and packed_parse_int x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.int_of_packed_zigzag_varint x))
x
and parse_includ x =
let x = Piqirun.parse_record x in
let count = next_count ()
in
refer count
(let (_unparsed_piq_ast, x) =
Piqirun.parse_optional_field 1 parse_uint x in
let (_modname, x) = Piqirun.parse_required_field 13841580 parse_word x
in
(Piqirun.check_unparsed_fields x;
{
Includ.unparsed_piq_ast = _unparsed_piq_ast;
Includ.modname = _modname;
}))
and parse_import x =
let x = Piqirun.parse_record x in
let count = next_count ()
in
refer count
(let (_unparsed_piq_ast, x) =
Piqirun.parse_optional_field 1 parse_uint x in
let (_modname, x) =
Piqirun.parse_required_field 13841580 parse_word x in
let (_name, x) =
Piqirun.parse_optional_field 150958667 parse_name x in
let (_piqi, x) =
Piqirun.parse_optional_field 173536529 parse_piqi x in
let (_ocaml_name, x) =
Piqirun.parse_optional_field 351856652 parse_string x
in
(Piqirun.check_unparsed_fields x;
{
Import.unparsed_piq_ast = _unparsed_piq_ast;
Import.modname = _modname;
Import.name = _name;
Import.piqi = _piqi;
Import.ocaml_name = _ocaml_name;
}))
and parse_function_param x =
let (code, x) = Piqirun.parse_variant x in
let count = next_count ()
in
refer count
(match code with
| 150958667 ->
let res = let count = curr_count () in refer count (parse_name x)
in `name res
| 502036113 ->
let res =
let count = curr_count () in refer count (parse_record x)
in `record res
| 484589701 ->
let res =
let count = curr_count () in refer count (parse_variant x)
in `variant res
| 51800833 ->
let res = let count = curr_count () in refer count (parse_enum x)
in `enum res
| 129178718 ->
let res =
let count = curr_count () in refer count (parse_piqi_list x)
in `list res
| 26300816 ->
let res = let count = curr_count () in refer count (parse_alias x)
in `alias res
| _ -> Piqirun.error_variant x code)
and parse_func x =
let x = Piqirun.parse_record x in
let count = next_count ()
in
refer count
(let (_unparsed_piq_ast, x) =
Piqirun.parse_optional_field 1 parse_uint x in
let (_resolved_input, x) =
Piqirun.parse_optional_field 95864501 parse_typedef x in
let (_name, x) =
Piqirun.parse_required_field 150958667 parse_name x in
let (_resolved_output, x) =
Piqirun.parse_optional_field 181035510 parse_typedef x in
let (_output, x) =
Piqirun.parse_optional_field 209784577 parse_function_param x in
let (_error, x) =
Piqirun.parse_optional_field 321506248 parse_function_param x in
let (_ocaml_name, x) =
Piqirun.parse_optional_field 351856652 parse_string x in
let (_resolved_error, x) =
Piqirun.parse_optional_field 448974451 parse_typedef x in
let (_input, x) =
Piqirun.parse_optional_field 505267210 parse_function_param x
in
(Piqirun.check_unparsed_fields x;
{
Func.unparsed_piq_ast = _unparsed_piq_ast;
Func.resolved_input = _resolved_input;
Func.name = _name;
Func.resolved_output = _resolved_output;
Func.output = _output;
Func.error = _error;
Func.ocaml_name = _ocaml_name;
Func.resolved_error = _resolved_error;
Func.input = _input;
}))
and parse_float64 x =
(fun x ->
let count = next_count () in refer count (Piqirun.float_of_fixed64 x))
x
and packed_parse_float64 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.float_of_packed_fixed64 x))
x
and parse_float32 x =
(fun x ->
let count = next_count () in refer count (Piqirun.float_of_fixed32 x))
x
and packed_parse_float32 x =
(fun x ->
let count = next_count ()
in refer count (Piqirun.float_of_packed_fixed32 x))
x
and parse_float x = parse_float64 x
and packed_parse_float x = packed_parse_float64 x
and parse_field_mode x =