-
Notifications
You must be signed in to change notification settings - Fork 36
/
piqi_impl_piqi.ml
1627 lines (1524 loc) · 67.5 KB
/
piqi_impl_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 Piqirun = Piqi_piqirun
module rec Piqi_impl_piqi:
sig
type uint = int
type uint32 = int32
type uint64 = int64
type float64 = float
type float32 = float
type protobuf_int32 = int32
type protobuf_int64 = int64
type binary = string
type piqi_any = Piqi_impl_piqi.any
type int32_fixed = int32
type uint32_fixed = Piqi_impl_piqi.uint32
type int64_fixed = int64
type uint64_fixed = Piqi_impl_piqi.uint64
type float = Piqi_impl_piqi.float64
type piq_ast = Piq_ast.ast
type word = string
type name = Piqi_impl_piqi.word
type typename = Piqi_impl_piqi.name
type namespace =
[
| `piqi of Piqi_impl_piqi.piqi
| `import of Piqi_impl_piqi.import
]
type typedef =
[
| `record of Piqi_impl_piqi.record
| `variant of Piqi_impl_piqi.variant
| `enum of Piqi_impl_piqi.enum
| `alias of Piqi_impl_piqi.alias
| `list of Piqi_impl_piqi.piqi_list
]
type piqi_type =
[
| `int
| `float
| `bool
| `string
| `binary
| `any
]
type piqtype =
[
| typedef
| piqi_type
]
type piq_format =
[
| `word
| `text
]
type protobuf_wire_type =
[
| `varint
| `zigzag_varint
| `fixed32
| `fixed64
| `signed_varint
| `signed_fixed32
| `signed_fixed64
| `block
]
type field_mode =
[
| `required
| `optional
| `repeated
]
type function_param =
[
| `name of Piqi_impl_piqi.name
| `record of Piqi_impl_piqi.record
| `variant of Piqi_impl_piqi.variant
| `enum of Piqi_impl_piqi.enum
| `list of Piqi_impl_piqi.piqi_list
| `alias of Piqi_impl_piqi.alias
]
type extend_target =
[
| `typedef of Piqi_impl_piqi.name
| `name of Piqi_impl_piqi.name
| `field of Piqi_impl_piqi.name
| `option of Piqi_impl_piqi.name
| `import of Piqi_impl_piqi.name
| `func of Piqi_impl_piqi.name
]
type pib_typehint = Pib_typehint.t
type record = Record.t
type field = Field.t
type variant = Variant.t
type option = Option.t
type enum = Enum.t
type alias = Alias.t
type piqi_list = Piqi_list.t
type piqi = Piqi.t
type import = Import.t
type any = Any.t
type func = Func.t
type piqi_bundle = Piqi_bundle.t
type includ = Includ.t
type extend = Extend.t
end = Piqi_impl_piqi
and Pib_typehint:
sig
type t = {
mutable piqi_type: string;
mutable typename: Piqi_impl_piqi.typename;
mutable code: Piqi_impl_piqi.uint;
}
end = Pib_typehint
and Record:
sig
type t = {
mutable name: Piqi_impl_piqi.name option;
mutable field: Piqi_impl_piqi.field list;
mutable parent: Piqi_impl_piqi.namespace option;
mutable wire_field: Piqi_impl_piqi.field list;
mutable is_func_param: bool;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
mutable piq_positional: bool option;
mutable piq_allow_unnesting: bool option;
mutable protobuf_name: string option;
mutable protobuf_custom: string list;
mutable json_name: string option;
mutable proto_custom: string list;
mutable proto_name: string option;
}
end = Record
and Field:
sig
type t = {
mutable name: Piqi_impl_piqi.name option;
mutable typename: Piqi_impl_piqi.typename option;
mutable mode: Piqi_impl_piqi.field_mode;
mutable default: Piqi_impl_piqi.piqi_any option;
mutable deprecated: bool;
mutable piqtype: Piqi_impl_piqi.piqtype option;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
mutable piq_format: Piqi_impl_piqi.piq_format option;
mutable piq_positional: bool option;
mutable piq_flag_default: Piqi_impl_piqi.piqi_any option;
mutable piq_alias: Piqi_impl_piqi.name option;
mutable protobuf_name: string option;
mutable code: int32 option;
mutable protobuf_packed: bool;
mutable json_name: string option;
mutable json_omit_missing: bool option;
mutable getopt_letter: Piqi_impl_piqi.word option;
mutable getopt_doc: string option;
mutable internal: bool;
mutable proto_name: string option;
mutable wire_packed: bool;
}
end = Field
and Variant:
sig
type t = {
mutable name: Piqi_impl_piqi.name option;
mutable option: Piqi_impl_piqi.option list;
mutable parent: Piqi_impl_piqi.namespace option;
mutable is_func_param: bool;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
mutable protobuf_name: string option;
mutable protobuf_custom: string list;
mutable protobuf_oneof: string option;
mutable json_name: string option;
mutable proto_custom: string list;
mutable proto_name: string option;
}
end = Variant
and Option:
sig
type t = {
mutable name: Piqi_impl_piqi.name option;
mutable typename: Piqi_impl_piqi.typename option;
mutable deprecated: bool;
mutable piqtype: Piqi_impl_piqi.piqtype option;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
mutable piq_format: Piqi_impl_piqi.piq_format option;
mutable piq_alias: Piqi_impl_piqi.name option;
mutable protobuf_name: string option;
mutable code: int32 option;
mutable json_name: string option;
mutable getopt_letter: Piqi_impl_piqi.word option;
mutable getopt_doc: string option;
mutable proto_name: string option;
}
end = Option
and Enum:
sig
type t = {
mutable name: Piqi_impl_piqi.name option;
mutable option: Piqi_impl_piqi.option list;
mutable parent: Piqi_impl_piqi.namespace option;
mutable is_func_param: bool;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
mutable protobuf_name: string option;
mutable protobuf_custom: string list;
mutable protobuf_prefix: string option;
mutable json_name: string option;
mutable proto_custom: string list;
mutable proto_name: string option;
}
end = Enum
and Alias:
sig
type t = {
mutable name: Piqi_impl_piqi.name option;
mutable typename: Piqi_impl_piqi.typename option;
mutable piqi_type: Piqi_impl_piqi.piqi_type option;
mutable parent: Piqi_impl_piqi.namespace option;
mutable is_func_param: bool;
mutable piqtype: Piqi_impl_piqi.piqtype option;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
mutable piq_format: Piqi_impl_piqi.piq_format option;
mutable protobuf_name: string option;
mutable protobuf_type: string option;
mutable protobuf_wire_type: Piqi_impl_piqi.protobuf_wire_type option;
mutable json_name: string option;
mutable proto_name: string option;
}
end = Alias
and Piqi_list:
sig
type t = {
mutable name: Piqi_impl_piqi.name option;
mutable typename: Piqi_impl_piqi.typename;
mutable parent: Piqi_impl_piqi.namespace option;
mutable is_func_param: bool;
mutable piqtype: Piqi_impl_piqi.piqtype option;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
mutable piq_format: Piqi_impl_piqi.piq_format option;
mutable protobuf_name: string option;
mutable protobuf_custom: string list;
mutable protobuf_packed: bool;
mutable json_name: string option;
mutable proto_custom: string list;
mutable proto_name: string option;
mutable wire_packed: bool;
}
end = Piqi_list
and Piqi:
sig
type t = {
mutable modname: Piqi_impl_piqi.word option;
mutable typedef: Piqi_impl_piqi.typedef list;
mutable import: Piqi_impl_piqi.import list;
mutable func: Piqi_impl_piqi.func list;
mutable custom_field: Piqi_impl_piqi.word list;
mutable extended_typedef: Piqi_impl_piqi.typedef list;
mutable func_typedef: Piqi_impl_piqi.typedef list;
mutable extended_func_typedef: Piqi_impl_piqi.typedef list;
mutable resolved_typedef: Piqi_impl_piqi.typedef list;
mutable imported_typedef: Piqi_impl_piqi.typedef list;
mutable resolved_import: Piqi_impl_piqi.import list;
mutable extended_import: Piqi_impl_piqi.import list;
mutable resolved_func: Piqi_impl_piqi.func list;
mutable extended_func: Piqi_impl_piqi.func list;
mutable included_piqi: Piqi_impl_piqi.piqi list;
mutable original_piqi: Piqi_impl_piqi.piqi option;
mutable ast: Piqi_impl_piqi.piq_ast option;
mutable is_embedded: bool option;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
mutable protobuf_custom: string list;
mutable protobuf_package: string option;
mutable file: string option;
mutable included_file: string list;
mutable includ: Piqi_impl_piqi.includ list;
mutable extend: Piqi_impl_piqi.extend list;
mutable proto_custom: string list;
mutable proto_package: string option;
}
end = Piqi
and Import:
sig
type t = {
mutable modname: Piqi_impl_piqi.word;
mutable name: Piqi_impl_piqi.name option;
mutable piqi: Piqi_impl_piqi.piqi option;
mutable orig_modname: string option;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
}
end = Import
and Any:
sig
type t = {
mutable typename: string option;
mutable protobuf: Piqi_impl_piqi.binary option;
mutable json: string option;
mutable xml: string option;
mutable piq: string option;
mutable ref: int option;
}
end = Any
and Func:
sig
type t = {
mutable name: Piqi_impl_piqi.name;
mutable input: Piqi_impl_piqi.function_param option;
mutable output: Piqi_impl_piqi.function_param option;
mutable error: Piqi_impl_piqi.function_param option;
mutable resolved_input: Piqi_impl_piqi.typedef option;
mutable resolved_output: Piqi_impl_piqi.typedef option;
mutable resolved_error: Piqi_impl_piqi.typedef option;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
}
end = Func
and Piqi_bundle:
sig
type t = {
mutable piqi: Piqi_impl_piqi.piqi list;
}
end = Piqi_bundle
and Includ:
sig
type t = {
mutable modname: Piqi_impl_piqi.word;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
}
end = Includ
and Extend:
sig
type t = {
mutable what: Piqi_impl_piqi.extend_target list;
mutable override: bool;
mutable piqi_with: Piqi_impl_piqi.piqi_any list;
mutable quote: Piqi_impl_piqi.piqi_any list;
mutable unparsed_piq_ast: Piqi_impl_piqi.uint option;
}
end = Extend
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 rec 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_piqtype x =
let code, x = Piqirun.parse_variant x in
let count = next_count() in refer count (
match code with
| 416823115 -> (parse_typedef x :> Piqi_impl_piqi.piqtype)
| 198318774 -> (parse_piqi_type x :> Piqi_impl_piqi.piqtype)
| _ -> 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_pib_typehint x =
let x = Piqirun.parse_record x in
let count = next_count() in refer count (
let _piqi_type, x = Piqirun.parse_required_field 1 parse_string x in
let _typename, x = Piqirun.parse_required_field 2 parse_typename x in
let _code, x = Piqirun.parse_required_field 3 parse_uint x in
Piqirun.check_unparsed_fields x;
{
Pib_typehint.piqi_type = _piqi_type;
Pib_typehint.typename = _typename;
Pib_typehint.code = _code;
})
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_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_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_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_bool x = (fun x -> let count = next_count() in refer count (Piqirun.bool_of_varint x)) x
and packed_parse_bool x = (fun x -> let count = next_count() in refer count (Piqirun.bool_of_packed_varint x)) x
and parse_string x = (fun x -> let count = next_count() in refer count (Piqirun.string_of_block x)) x
and parse_binary x = (fun x -> let count = next_count() in refer count (Piqirun.string_of_block x)) x
and parse_piqi_any x = parse_any 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_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_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_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_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_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_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_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_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_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_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_float x = parse_float64 x
and packed_parse_float x = packed_parse_float64 x
and parse_word x = parse_string x
and parse_name x = parse_word 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_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_typename x = parse_name 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 = [] 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 _piq_allow_unnesting, x = Piqirun.parse_optional_field 172744920 parse_bool x in
let _piq_positional, x = Piqirun.parse_optional_field 197354217 parse_bool x in
let _parent = None in
let _is_func_param = (Piqloc.pause (); let res = parse_bool (Piqirun.parse_default "\b\000") in Piqloc.resume (); res) 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.piq_allow_unnesting = _piq_allow_unnesting;
Record.piq_positional = _piq_positional;
Record.parent = _parent;
Record.is_func_param = _is_func_param;
Record.proto_custom = _proto_custom;
Record.json_name = _json_name;
})
and parse_field 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 = Piqirun.parse_required_field 69402483 parse_bool x ~default:"\b\000" in
let _protobuf_name, x = Piqirun.parse_optional_field 90072013 parse_string x in
let _piq_flag_default, x = Piqirun.parse_optional_field 112451637 parse_piqi_any x in
let _proto_name, x = Piqirun.parse_optional_field 139663632 parse_string x in
let _mode, x = Piqirun.parse_required_field 140563299 parse_field_mode x ~default:"\b\223\162\138\147\001" in
let _internal, x = Piqirun.parse_required_field 141977405 parse_bool x ~default:"\b\000" in
let _name, x = Piqirun.parse_optional_field 150958667 parse_name x in
let _piqtype = None in
let _protobuf_packed, x = Piqirun.parse_required_field 179842426 parse_bool x ~default:"\b\000" in
let _piq_positional, x = Piqirun.parse_optional_field 197354217 parse_bool x in
let _json_omit_missing, x = Piqirun.parse_optional_field 201807079 parse_bool 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 _wire_packed, x = Piqirun.parse_required_field 422905280 parse_bool x ~default:"\b\000" in
let _piq_alias, x = Piqirun.parse_optional_field 434682011 parse_name x in
let _getopt_doc, x = Piqirun.parse_optional_field 442330184 parse_string x in
let _default, x = Piqirun.parse_optional_field 465819841 parse_piqi_any x in
let _json_name, x = Piqirun.parse_optional_field 515275216 parse_string x in
Piqirun.check_unparsed_fields x;
{
Field.unparsed_piq_ast = _unparsed_piq_ast;
Field.code = _code;
Field.deprecated = _deprecated;
Field.protobuf_name = _protobuf_name;
Field.piq_flag_default = _piq_flag_default;
Field.proto_name = _proto_name;
Field.mode = _mode;
Field.internal = _internal;
Field.name = _name;
Field.piqtype = _piqtype;
Field.protobuf_packed = _protobuf_packed;
Field.piq_positional = _piq_positional;
Field.json_omit_missing = _json_omit_missing;
Field.getopt_letter = _getopt_letter;
Field.typename = _typename;
Field.piq_format = _piq_format;
Field.wire_packed = _wire_packed;
Field.piq_alias = _piq_alias;
Field.getopt_doc = _getopt_doc;
Field.default = _default;
Field.json_name = _json_name;
})
and parse_field_mode x =
let count = next_count() in refer count (match Piqirun.int32_of_signed_varint x with
| 308449631l -> `required
| 510570400l -> `optional
| 274054266l -> `repeated
| x -> Piqirun.error_enum_const x
)
and packed_parse_field_mode x =
let count = next_count() in refer count (match Piqirun.int32_of_packed_signed_varint x with
| 308449631l -> `required
| 510570400l -> `optional
| 274054266l -> `repeated
| x -> Piqirun.error_enum_const 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 _protobuf_oneof, x = Piqirun.parse_optional_field 154222907 parse_string x in
let _option, x = Piqirun.parse_repeated_field 192598901 parse_option x in
let _parent = None in
let _is_func_param = (Piqloc.pause (); let res = parse_bool (Piqirun.parse_default "\b\000") in Piqloc.resume (); res) 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.protobuf_oneof = _protobuf_oneof;
Variant.option = _option;
Variant.parent = _parent;
Variant.is_func_param = _is_func_param;
Variant.proto_custom = _proto_custom;
Variant.json_name = _json_name;
})
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 = Piqirun.parse_required_field 69402483 parse_bool x ~default:"\b\000" 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 = None 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 _piq_alias, x = Piqirun.parse_optional_field 434682011 parse_name 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.getopt_letter = _getopt_letter;
Option.typename = _typename;
Option.piq_format = _piq_format;
Option.piq_alias = _piq_alias;
Option.getopt_doc = _getopt_doc;
Option.json_name = _json_name;
})
and parse_enum 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 = None in
let _protobuf_prefix, x = Piqirun.parse_optional_field 366391188 parse_string x in
let _is_func_param = (Piqloc.pause (); let res = parse_bool (Piqirun.parse_default "\b\000") in Piqloc.resume (); res) 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;
{
Enum.unparsed_piq_ast = _unparsed_piq_ast;
Enum.protobuf_name = _protobuf_name;
Enum.protobuf_custom = _protobuf_custom;
Enum.proto_name = _proto_name;
Enum.name = _name;
Enum.option = _option;
Enum.parent = _parent;
Enum.protobuf_prefix = _protobuf_prefix;
Enum.is_func_param = _is_func_param;
Enum.proto_custom = _proto_custom;
Enum.json_name = _json_name;
})
and parse_alias 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 _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 _protobuf_type, x = Piqirun.parse_optional_field 157803580 parse_string x in
let _piqtype = None in
let _protobuf_wire_type, x = Piqirun.parse_optional_field 198202944 parse_protobuf_wire_type x in
let _piqi_type, x = Piqirun.parse_optional_field 198318774 parse_piqi_type x in
let _typename, x = Piqirun.parse_optional_field 218690234 parse_typename x in
let _parent = None in
let _piq_format, x = Piqirun.parse_optional_field 296833484 parse_piq_format x in
let _is_func_param = (Piqloc.pause (); let res = parse_bool (Piqirun.parse_default "\b\000") in Piqloc.resume (); res) in
let _json_name, x = Piqirun.parse_optional_field 515275216 parse_string x in
Piqirun.check_unparsed_fields x;
{
Alias.unparsed_piq_ast = _unparsed_piq_ast;
Alias.protobuf_name = _protobuf_name;
Alias.proto_name = _proto_name;
Alias.name = _name;
Alias.protobuf_type = _protobuf_type;
Alias.piqtype = _piqtype;
Alias.protobuf_wire_type = _protobuf_wire_type;
Alias.piqi_type = _piqi_type;
Alias.typename = _typename;
Alias.parent = _parent;
Alias.piq_format = _piq_format;
Alias.is_func_param = _is_func_param;
Alias.json_name = _json_name;
})
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 = None in
let _protobuf_packed, x = Piqirun.parse_required_field 179842426 parse_bool x ~default:"\b\000" in
let _typename, x = Piqirun.parse_required_field 218690234 parse_typename x in
let _parent = None in
let _piq_format, x = Piqirun.parse_optional_field 296833484 parse_piq_format x in
let _is_func_param = (Piqloc.pause (); let res = parse_bool (Piqirun.parse_default "\b\000") in Piqloc.resume (); res) in
let _proto_custom, x = Piqirun.parse_repeated_field 405875126 parse_string x in
let _wire_packed, x = Piqirun.parse_required_field 422905280 parse_bool x ~default:"\b\000" 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.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_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 = None in
let _modname, x = Piqirun.parse_optional_field 13841580 parse_word x in
let _included_file, x = Piqirun.parse_repeated_field 35129965 parse_string x in
let _imported_typedef = [] in
let _file, x = Piqirun.parse_optional_field 62639740 parse_string x in
let _extended_func = [] in
let _protobuf_custom, x = Piqirun.parse_repeated_field 112352691 parse_string x in
let _resolved_import = [] 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 = [] in
let _extended_typedef = [] in
let _custom_field, x = Piqirun.parse_repeated_field 162247646 parse_word x in
let _is_embedded = None in
let _resolved_func = [] in
let _includ, x = Piqirun.parse_repeated_field 301399592 parse_includ x in
let _func_typedef = [] 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 _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 = [] in
let _resolved_typedef = [] in
let _original_piqi = None in
let _extended_func_typedef = [] in
Piqirun.check_unparsed_fields x;
{
Piqi.unparsed_piq_ast = _unparsed_piq_ast;
Piqi.ast = _ast;
Piqi.modname = _modname;
Piqi.included_file = _included_file;
Piqi.imported_typedef = _imported_typedef;
Piqi.file = _file;
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.is_embedded = _is_embedded;
Piqi.resolved_func = _resolved_func;
Piqi.includ = _includ;
Piqi.func_typedef = _func_typedef;
Piqi.proto_package = _proto_package;
Piqi.func = _func;
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_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 _orig_modname = None in
let _name, x = Piqirun.parse_optional_field 150958667 parse_name x in
let _piqi = None in
Piqirun.check_unparsed_fields x;
{
Import.unparsed_piq_ast = _unparsed_piq_ast;
Import.modname = _modname;
Import.orig_modname = _orig_modname;
Import.name = _name;
Import.piqi = _piqi;
})
and parse_any x =
let x = Piqirun.parse_record x in
let count = next_count() in refer count (
let _piq, x = Piqirun.parse_optional_field 5593176 parse_string x in
let _ref, x = Piqirun.parse_optional_field 5691731 parse_int x in
let _xml, x = Piqirun.parse_optional_field 5991895 parse_string x in
let _protobuf, x = Piqirun.parse_optional_field 6461771 parse_binary x in
let _json, x = Piqirun.parse_optional_field 107495976 parse_string x in
let _typename, x = Piqirun.parse_optional_field 218690234 parse_string x in
Piqirun.check_unparsed_fields x;
{
Any.piq = _piq;
Any.ref = _ref;
Any.xml = _xml;
Any.protobuf = _protobuf;
Any.json = _json;
Any.typename = _typename;
})
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 = None in
let _name, x = Piqirun.parse_required_field 150958667 parse_name x in
let _resolved_output = None 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 _resolved_error = None 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.resolved_error = _resolved_error;
Func.input = _input;
})
and parse_piqi_bundle x =
let x = Piqirun.parse_record x in
let count = next_count() in refer count (
let _piqi, x = Piqirun.parse_repeated_field 1 parse_piqi x in
Piqirun.check_unparsed_fields x;
{
Piqi_bundle.piqi = _piqi;
})
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_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_extend 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 _override, x = Piqirun.parse_required_field 153625164 parse_bool x ~default:"\b\000" in
let _what, x = Piqirun.parse_repeated_field 251110212 parse_extend_target x in
let _piqi_with, x = Piqirun.parse_repeated_field 251164166 parse_piqi_any x in
let _quote, x = Piqirun.parse_repeated_field 365880944 parse_piqi_any x in
Piqirun.check_unparsed_fields x;
{
Extend.unparsed_piq_ast = _unparsed_piq_ast;
Extend.override = _override;
Extend.what = _what;
Extend.piqi_with = _piqi_with;
Extend.quote = _quote;
})
and parse_extend_target x =
let code, x = Piqirun.parse_variant x in
let count = next_count() in refer count (
match code with
| 416823115 ->
let res = let count = curr_count() in refer count (parse_name x) in
`typedef res
| 150958667 ->
let res = let count = curr_count() in refer count (parse_name x) in
`name res
| 9671866 ->
let res = let count = curr_count() in refer count (parse_name x) in
`field res
| 192598901 ->
let res = let count = curr_count() in refer count (parse_name x) in
`option res
| 142778725 ->
let res = let count = curr_count() in refer count (parse_name x) in
`import res
| 340962072 ->
let res = let count = curr_count() in refer count (parse_name x) in
`func res
| _ -> Piqirun.error_variant x code
)
let next_count = Piqloc.next_ocount
let refer obj =
let count = next_count () in
if not (Obj.is_int (Obj.repr obj))
then Piqloc.addref obj count
let reference f code x = refer x; f code x
let reference1 f x = refer x; f x
let rec gen__namespace code (x:Piqi_impl_piqi.namespace) =
refer x;
Piqirun.gen_record code [(match x with
| `piqi x -> gen__piqi 173536529 x
| `import x -> gen__import 142778725 x
)]
and gen__piqtype code (x:Piqi_impl_piqi.piqtype) =
refer x;
Piqirun.gen_record code [(match x with
| (#Piqi_impl_piqi.typedef as x) -> gen__typedef 416823115 x
| (#Piqi_impl_piqi.piqi_type as x) -> gen__piqi_type 198318774 x
)]