package ocaml-protoc-plugin

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file type.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
(************************************************)
(*       AUTOGENERATED FILE - DO NOT EDIT!      *)
(************************************************)
(* Generated by: ocaml-protoc-plugin            *)
(* https://github.com/issuu/ocaml-protoc-plugin *)
(************************************************)
(*
   Source: google/protobuf/type.proto
   Syntax: proto3 
   Parameters:
     annot=''
     debug=false
     opens=[]
     int64_as_int=true
     int32_as_int=true
     fixed_as_int=false
     singleton_record=false
*)
module Google = struct
  module Protobuf = struct
    module rec Syntax : sig
      type t = SYNTAX_PROTO2 | SYNTAX_PROTO3 
      val to_int: t -> int
      val from_int: int -> t Ocaml_protoc_plugin.Result.t
    end = struct 
      type t = SYNTAX_PROTO2 | SYNTAX_PROTO3 
      let to_int = function
        | SYNTAX_PROTO2 -> 0
        | SYNTAX_PROTO3 -> 1
      
      let from_int = function
        | 0 -> Ok SYNTAX_PROTO2
        | 1 -> Ok SYNTAX_PROTO3
        | n -> Error (`Unknown_enum_value n)
      
    end
    and Type : sig
      val name': unit -> string
      type t = { name: string; fields: Field.t list; oneofs: string list; options: Option.t list; source_context: Source_context.Google.Protobuf.SourceContext.t option; syntax: Syntax.t } 
      val to_proto: t -> Ocaml_protoc_plugin.Writer.t
      val from_proto: Ocaml_protoc_plugin.Reader.t -> t Ocaml_protoc_plugin.Result.t
    end = struct 
      let name' () = "Type.google.protobuf.Type"
      type t = { name: string; fields: Field.t list; oneofs: string list; options: Option.t list; source_context: Source_context.Google.Protobuf.SourceContext.t option; syntax: Syntax.t } 
      let to_proto = 
        let apply = fun ~f:f' { name; fields; oneofs; options; source_context; syntax } -> f' name fields oneofs options source_context syntax in
        let spec = Ocaml_protoc_plugin.Serialize.C.( basic (1, string, proto3) ^:: repeated (2, (message Field.to_proto), not_packed) ^:: repeated (3, string, packed) ^:: repeated (4, (message Option.to_proto), not_packed) ^:: basic_opt (5, (message Source_context.Google.Protobuf.SourceContext.to_proto)) ^:: basic (6, (enum Syntax.to_int), proto3) ^:: nil ) in
        let serialize = Ocaml_protoc_plugin.Serialize.serialize (spec) in
        fun t -> apply ~f:(serialize ()) t
      
      let from_proto = 
        let constructor = fun name fields oneofs options source_context syntax -> { name; fields; oneofs; options; source_context; syntax } in
        let spec = Ocaml_protoc_plugin.Deserialize.C.( basic (1, string, proto3) ^:: repeated (2, (message Field.from_proto), not_packed) ^:: repeated (3, string, packed) ^:: repeated (4, (message Option.from_proto), not_packed) ^:: basic_opt (5, (message Source_context.Google.Protobuf.SourceContext.from_proto)) ^:: basic (6, (enum Syntax.from_int), proto3) ^:: nil ) in
        let deserialize = Ocaml_protoc_plugin.Deserialize.deserialize (spec) constructor in
        fun writer -> deserialize writer
      
    end
    and Field : sig
      module rec Kind : sig
        type t = TYPE_UNKNOWN | TYPE_DOUBLE | TYPE_FLOAT | TYPE_INT64 | TYPE_UINT64 | TYPE_INT32 | TYPE_FIXED64 | TYPE_FIXED32 | TYPE_BOOL | TYPE_STRING | TYPE_GROUP | TYPE_MESSAGE | TYPE_BYTES | TYPE_UINT32 | TYPE_ENUM | TYPE_SFIXED32 | TYPE_SFIXED64 | TYPE_SINT32 | TYPE_SINT64 
        val to_int: t -> int
        val from_int: int -> t Ocaml_protoc_plugin.Result.t
      end
      and Cardinality : sig
        type t = CARDINALITY_UNKNOWN | CARDINALITY_OPTIONAL | CARDINALITY_REQUIRED | CARDINALITY_REPEATED 
        val to_int: t -> int
        val from_int: int -> t Ocaml_protoc_plugin.Result.t
      end
      val name': unit -> string
      type t = { kind: Kind.t; cardinality: Cardinality.t; number: int; name: string; type_url: string; oneof_index: int; packed: bool; options: Option.t list; json_name: string; default_value: string } 
      val to_proto: t -> Ocaml_protoc_plugin.Writer.t
      val from_proto: Ocaml_protoc_plugin.Reader.t -> t Ocaml_protoc_plugin.Result.t
    end = struct 
      module rec Kind : sig
        type t = TYPE_UNKNOWN | TYPE_DOUBLE | TYPE_FLOAT | TYPE_INT64 | TYPE_UINT64 | TYPE_INT32 | TYPE_FIXED64 | TYPE_FIXED32 | TYPE_BOOL | TYPE_STRING | TYPE_GROUP | TYPE_MESSAGE | TYPE_BYTES | TYPE_UINT32 | TYPE_ENUM | TYPE_SFIXED32 | TYPE_SFIXED64 | TYPE_SINT32 | TYPE_SINT64 
        val to_int: t -> int
        val from_int: int -> t Ocaml_protoc_plugin.Result.t
      end = struct 
        type t = TYPE_UNKNOWN | TYPE_DOUBLE | TYPE_FLOAT | TYPE_INT64 | TYPE_UINT64 | TYPE_INT32 | TYPE_FIXED64 | TYPE_FIXED32 | TYPE_BOOL | TYPE_STRING | TYPE_GROUP | TYPE_MESSAGE | TYPE_BYTES | TYPE_UINT32 | TYPE_ENUM | TYPE_SFIXED32 | TYPE_SFIXED64 | TYPE_SINT32 | TYPE_SINT64 
        let to_int = function
          | TYPE_UNKNOWN -> 0
          | TYPE_DOUBLE -> 1
          | TYPE_FLOAT -> 2
          | TYPE_INT64 -> 3
          | TYPE_UINT64 -> 4
          | TYPE_INT32 -> 5
          | TYPE_FIXED64 -> 6
          | TYPE_FIXED32 -> 7
          | TYPE_BOOL -> 8
          | TYPE_STRING -> 9
          | TYPE_GROUP -> 10
          | TYPE_MESSAGE -> 11
          | TYPE_BYTES -> 12
          | TYPE_UINT32 -> 13
          | TYPE_ENUM -> 14
          | TYPE_SFIXED32 -> 15
          | TYPE_SFIXED64 -> 16
          | TYPE_SINT32 -> 17
          | TYPE_SINT64 -> 18
        
        let from_int = function
          | 0 -> Ok TYPE_UNKNOWN
          | 1 -> Ok TYPE_DOUBLE
          | 2 -> Ok TYPE_FLOAT
          | 3 -> Ok TYPE_INT64
          | 4 -> Ok TYPE_UINT64
          | 5 -> Ok TYPE_INT32
          | 6 -> Ok TYPE_FIXED64
          | 7 -> Ok TYPE_FIXED32
          | 8 -> Ok TYPE_BOOL
          | 9 -> Ok TYPE_STRING
          | 10 -> Ok TYPE_GROUP
          | 11 -> Ok TYPE_MESSAGE
          | 12 -> Ok TYPE_BYTES
          | 13 -> Ok TYPE_UINT32
          | 14 -> Ok TYPE_ENUM
          | 15 -> Ok TYPE_SFIXED32
          | 16 -> Ok TYPE_SFIXED64
          | 17 -> Ok TYPE_SINT32
          | 18 -> Ok TYPE_SINT64
          | n -> Error (`Unknown_enum_value n)
        
      end
      and Cardinality : sig
        type t = CARDINALITY_UNKNOWN | CARDINALITY_OPTIONAL | CARDINALITY_REQUIRED | CARDINALITY_REPEATED 
        val to_int: t -> int
        val from_int: int -> t Ocaml_protoc_plugin.Result.t
      end = struct 
        type t = CARDINALITY_UNKNOWN | CARDINALITY_OPTIONAL | CARDINALITY_REQUIRED | CARDINALITY_REPEATED 
        let to_int = function
          | CARDINALITY_UNKNOWN -> 0
          | CARDINALITY_OPTIONAL -> 1
          | CARDINALITY_REQUIRED -> 2
          | CARDINALITY_REPEATED -> 3
        
        let from_int = function
          | 0 -> Ok CARDINALITY_UNKNOWN
          | 1 -> Ok CARDINALITY_OPTIONAL
          | 2 -> Ok CARDINALITY_REQUIRED
          | 3 -> Ok CARDINALITY_REPEATED
          | n -> Error (`Unknown_enum_value n)
        
      end
      let name' () = "Type.google.protobuf.Field"
      type t = { kind: Kind.t; cardinality: Cardinality.t; number: int; name: string; type_url: string; oneof_index: int; packed: bool; options: Option.t list; json_name: string; default_value: string } 
      let to_proto = 
        let apply = fun ~f:f' { kind; cardinality; number; name; type_url; oneof_index; packed; options; json_name; default_value } -> f' kind cardinality number name type_url oneof_index packed options json_name default_value in
        let spec = Ocaml_protoc_plugin.Serialize.C.( basic (1, (enum Kind.to_int), proto3) ^:: basic (2, (enum Cardinality.to_int), proto3) ^:: basic (3, int32_int, proto3) ^:: basic (4, string, proto3) ^:: basic (6, string, proto3) ^:: basic (7, int32_int, proto3) ^:: basic (8, bool, proto3) ^:: repeated (9, (message Option.to_proto), not_packed) ^:: basic (10, string, proto3) ^:: basic (11, string, proto3) ^:: nil ) in
        let serialize = Ocaml_protoc_plugin.Serialize.serialize (spec) in
        fun t -> apply ~f:(serialize ()) t
      
      let from_proto = 
        let constructor = fun kind cardinality number name type_url oneof_index packed options json_name default_value -> { kind; cardinality; number; name; type_url; oneof_index; packed; options; json_name; default_value } in
        let spec = Ocaml_protoc_plugin.Deserialize.C.( basic (1, (enum Kind.from_int), proto3) ^:: basic (2, (enum Cardinality.from_int), proto3) ^:: basic (3, int32_int, proto3) ^:: basic (4, string, proto3) ^:: basic (6, string, proto3) ^:: basic (7, int32_int, proto3) ^:: basic (8, bool, proto3) ^:: repeated (9, (message Option.from_proto), not_packed) ^:: basic (10, string, proto3) ^:: basic (11, string, proto3) ^:: nil ) in
        let deserialize = Ocaml_protoc_plugin.Deserialize.deserialize (spec) constructor in
        fun writer -> deserialize writer
      
    end
    and Enum : sig
      val name': unit -> string
      type t = { name: string; enumvalue: EnumValue.t list; options: Option.t list; source_context: Source_context.Google.Protobuf.SourceContext.t option; syntax: Syntax.t } 
      val to_proto: t -> Ocaml_protoc_plugin.Writer.t
      val from_proto: Ocaml_protoc_plugin.Reader.t -> t Ocaml_protoc_plugin.Result.t
    end = struct 
      let name' () = "Type.google.protobuf.Enum"
      type t = { name: string; enumvalue: EnumValue.t list; options: Option.t list; source_context: Source_context.Google.Protobuf.SourceContext.t option; syntax: Syntax.t } 
      let to_proto = 
        let apply = fun ~f:f' { name; enumvalue; options; source_context; syntax } -> f' name enumvalue options source_context syntax in
        let spec = Ocaml_protoc_plugin.Serialize.C.( basic (1, string, proto3) ^:: repeated (2, (message EnumValue.to_proto), not_packed) ^:: repeated (3, (message Option.to_proto), not_packed) ^:: basic_opt (4, (message Source_context.Google.Protobuf.SourceContext.to_proto)) ^:: basic (5, (enum Syntax.to_int), proto3) ^:: nil ) in
        let serialize = Ocaml_protoc_plugin.Serialize.serialize (spec) in
        fun t -> apply ~f:(serialize ()) t
      
      let from_proto = 
        let constructor = fun name enumvalue options source_context syntax -> { name; enumvalue; options; source_context; syntax } in
        let spec = Ocaml_protoc_plugin.Deserialize.C.( basic (1, string, proto3) ^:: repeated (2, (message EnumValue.from_proto), not_packed) ^:: repeated (3, (message Option.from_proto), not_packed) ^:: basic_opt (4, (message Source_context.Google.Protobuf.SourceContext.from_proto)) ^:: basic (5, (enum Syntax.from_int), proto3) ^:: nil ) in
        let deserialize = Ocaml_protoc_plugin.Deserialize.deserialize (spec) constructor in
        fun writer -> deserialize writer
      
    end
    and EnumValue : sig
      val name': unit -> string
      type t = { name: string; number: int; options: Option.t list } 
      val to_proto: t -> Ocaml_protoc_plugin.Writer.t
      val from_proto: Ocaml_protoc_plugin.Reader.t -> t Ocaml_protoc_plugin.Result.t
    end = struct 
      let name' () = "Type.google.protobuf.EnumValue"
      type t = { name: string; number: int; options: Option.t list } 
      let to_proto = 
        let apply = fun ~f:f' { name; number; options } -> f' name number options in
        let spec = Ocaml_protoc_plugin.Serialize.C.( basic (1, string, proto3) ^:: basic (2, int32_int, proto3) ^:: repeated (3, (message Option.to_proto), not_packed) ^:: nil ) in
        let serialize = Ocaml_protoc_plugin.Serialize.serialize (spec) in
        fun t -> apply ~f:(serialize ()) t
      
      let from_proto = 
        let constructor = fun name number options -> { name; number; options } in
        let spec = Ocaml_protoc_plugin.Deserialize.C.( basic (1, string, proto3) ^:: basic (2, int32_int, proto3) ^:: repeated (3, (message Option.from_proto), not_packed) ^:: nil ) in
        let deserialize = Ocaml_protoc_plugin.Deserialize.deserialize (spec) constructor in
        fun writer -> deserialize writer
      
    end
    and Option : sig
      val name': unit -> string
      type t = { name: string; value: Any.Google.Protobuf.Any.t option } 
      val to_proto: t -> Ocaml_protoc_plugin.Writer.t
      val from_proto: Ocaml_protoc_plugin.Reader.t -> t Ocaml_protoc_plugin.Result.t
    end = struct 
      let name' () = "Type.google.protobuf.Option"
      type t = { name: string; value: Any.Google.Protobuf.Any.t option } 
      let to_proto = 
        let apply = fun ~f:f' { name; value } -> f' name value in
        let spec = Ocaml_protoc_plugin.Serialize.C.( basic (1, string, proto3) ^:: basic_opt (2, (message Any.Google.Protobuf.Any.to_proto)) ^:: nil ) in
        let serialize = Ocaml_protoc_plugin.Serialize.serialize (spec) in
        fun t -> apply ~f:(serialize ()) t
      
      let from_proto = 
        let constructor = fun name value -> { name; value } in
        let spec = Ocaml_protoc_plugin.Deserialize.C.( basic (1, string, proto3) ^:: basic_opt (2, (message Any.Google.Protobuf.Any.from_proto)) ^:: nil ) in
        let deserialize = Ocaml_protoc_plugin.Deserialize.deserialize (spec) constructor in
        fun writer -> deserialize writer
      
    end
  end
end
OCaml

Innovation. Community. Security.