package protocell

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

Source file google_protobuf_compiler_plugin_pc.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
[@@@ocaml.warning "-39"]

let (>>=) = Runtime.Result.(>>=)

let (>>|) = Runtime.Result.(>>|)

module Field' = Runtime.Field_value

module Bin' = Runtime.Binary_format

module Text' = Runtime.Text_format

module rec Version : sig
  type t = {
    major : int option;
    minor : int option;
    patch : int option;
    suffix : string option;
  }
  [@@deriving eq, show]

  val to_binary : t -> (string, [> Bin'.serialization_error]) result

  val of_binary : string -> (t, [> Bin'.deserialization_error]) result

  val to_text : t -> (string, [> Text'.serialization_error]) result

  val of_text : string -> (t, [> Text'.deserialization_error]) result
end = struct
  type t = {
    major : int option;
    minor : int option;
    patch : int option;
    suffix : string option;
  }
  [@@deriving eq, show]

  let rec to_binary =
    fun { major; minor; patch; suffix } ->
      let _o = Runtime.Byte_output.create () in
      Bin'.serialize_optional_field 1 Field'.Int32_t major _o >>= fun () ->
      Bin'.serialize_optional_field 2 Field'.Int32_t minor _o >>= fun () ->
      Bin'.serialize_optional_field 3 Field'.Int32_t patch _o >>= fun () ->
      Bin'.serialize_optional_field 4 Field'.String_t suffix _o >>= fun () ->
      Ok (Runtime.Byte_output.contents _o)

  let rec of_binary =
    fun input' ->
      Ok (Runtime.Byte_input.create input') >>=
      Bin'.deserialize_message >>= fun _m ->
      Bin'.decode_optional_field 1 Field'.Int32_t _m >>= fun major ->
      Bin'.decode_optional_field 2 Field'.Int32_t _m >>= fun minor ->
      Bin'.decode_optional_field 3 Field'.Int32_t _m >>= fun patch ->
      Bin'.decode_optional_field 4 Field'.String_t _m >>= fun suffix ->
      Ok { major; minor; patch; suffix }

  let rec to_text =
    fun { major; minor; patch; suffix } ->
      let _o = Runtime.Byte_output.create () in
      Text'.serialize_optional_field "major" Field'.Int32_t major _o >>= fun () ->
      Text'.serialize_optional_field "minor" Field'.Int32_t minor _o >>= fun () ->
      Text'.serialize_optional_field "patch" Field'.Int32_t patch _o >>= fun () ->
      Text'.serialize_optional_field "suffix" Field'.String_t suffix _o >>= fun () ->
      Ok (Runtime.Byte_output.contents _o)

  let rec of_text =
    fun input' ->
      Ok (Runtime.Byte_input.create input') >>=
      Text'.deserialize_message >>= fun _m ->
      Text'.decode_optional_field "major" Field'.Int32_t _m >>= fun major ->
      Text'.decode_optional_field "minor" Field'.Int32_t _m >>= fun minor ->
      Text'.decode_optional_field "patch" Field'.Int32_t _m >>= fun patch ->
      Text'.decode_optional_field "suffix" Field'.String_t _m >>= fun suffix ->
      Ok { major; minor; patch; suffix }
end

and Code_generator_request : sig
  type t = {
    file_to_generate : string list;
    parameter : string option;
    proto_file : Google_protobuf_descriptor_pc.File_descriptor_proto.t list;
    compiler_version : Version.t option;
  }
  [@@deriving eq, show]

  val to_binary : t -> (string, [> Bin'.serialization_error]) result

  val of_binary : string -> (t, [> Bin'.deserialization_error]) result

  val to_text : t -> (string, [> Text'.serialization_error]) result

  val of_text : string -> (t, [> Text'.deserialization_error]) result
end = struct
  type t = {
    file_to_generate : string list;
    parameter : string option;
    proto_file : Google_protobuf_descriptor_pc.File_descriptor_proto.t list;
    compiler_version : Version.t option;
  }
  [@@deriving eq, show]

  let rec to_binary =
    fun { file_to_generate; parameter; proto_file; compiler_version } ->
      let _o = Runtime.Byte_output.create () in
      Bin'.serialize_repeated_field 1 Field'.String_t file_to_generate _o >>= fun () ->
      Bin'.serialize_optional_field 2 Field'.String_t parameter _o >>= fun () ->
      Bin'.serialize_repeated_user_field 15 Google_protobuf_descriptor_pc.File_descriptor_proto.to_binary proto_file _o >>= fun () ->
      Bin'.serialize_user_field 3 Version.to_binary compiler_version _o >>= fun () ->
      Ok (Runtime.Byte_output.contents _o)

  let rec of_binary =
    fun input' ->
      Ok (Runtime.Byte_input.create input') >>=
      Bin'.deserialize_message >>= fun _m ->
      Bin'.decode_repeated_field 1 Field'.String_t _m >>= fun file_to_generate ->
      Bin'.decode_optional_field 2 Field'.String_t _m >>= fun parameter ->
      Bin'.decode_repeated_user_field 15 Google_protobuf_descriptor_pc.File_descriptor_proto.of_binary _m >>= fun proto_file ->
      Bin'.decode_user_field 3 Version.of_binary _m >>= fun compiler_version ->
      Ok { file_to_generate; parameter; proto_file; compiler_version }

  let rec to_text =
    fun { file_to_generate; parameter; proto_file; compiler_version } ->
      let _o = Runtime.Byte_output.create () in
      Text'.serialize_repeated_field "file_to_generate" Field'.String_t file_to_generate _o >>= fun () ->
      Text'.serialize_optional_field "parameter" Field'.String_t parameter _o >>= fun () ->
      Text'.serialize_repeated_user_field "proto_file" Google_protobuf_descriptor_pc.File_descriptor_proto.to_text proto_file _o >>= fun () ->
      Text'.serialize_user_field "compiler_version" Version.to_text compiler_version _o >>= fun () ->
      Ok (Runtime.Byte_output.contents _o)

  let rec of_text =
    fun input' ->
      Ok (Runtime.Byte_input.create input') >>=
      Text'.deserialize_message >>= fun _m ->
      Text'.decode_repeated_field "file_to_generate" Field'.String_t _m >>= fun file_to_generate ->
      Text'.decode_optional_field "parameter" Field'.String_t _m >>= fun parameter ->
      Text'.decode_repeated_user_field "proto_file" Google_protobuf_descriptor_pc.File_descriptor_proto.of_text _m >>= fun proto_file ->
      Text'.decode_user_field "compiler_version" Version.of_text _m >>= fun compiler_version ->
      Ok { file_to_generate; parameter; proto_file; compiler_version }
end

and Code_generator_response : sig
  module rec File : sig
    type t = {
      name : string option;
      insertion_point : string option;
      content : string option;
    }
    [@@deriving eq, show]
  
    val to_binary : t -> (string, [> Bin'.serialization_error]) result
  
    val of_binary : string -> (t, [> Bin'.deserialization_error]) result
  
    val to_text : t -> (string, [> Text'.serialization_error]) result
  
    val of_text : string -> (t, [> Text'.deserialization_error]) result
  end

  type t = {
    error : string option;
    file : Code_generator_response.File.t list;
  }
  [@@deriving eq, show]

  val to_binary : t -> (string, [> Bin'.serialization_error]) result

  val of_binary : string -> (t, [> Bin'.deserialization_error]) result

  val to_text : t -> (string, [> Text'.serialization_error]) result

  val of_text : string -> (t, [> Text'.deserialization_error]) result
end = struct
  module rec File : sig
    type t = {
      name : string option;
      insertion_point : string option;
      content : string option;
    }
    [@@deriving eq, show]
  
    val to_binary : t -> (string, [> Bin'.serialization_error]) result
  
    val of_binary : string -> (t, [> Bin'.deserialization_error]) result
  
    val to_text : t -> (string, [> Text'.serialization_error]) result
  
    val of_text : string -> (t, [> Text'.deserialization_error]) result
  end = struct
    type t = {
      name : string option;
      insertion_point : string option;
      content : string option;
    }
    [@@deriving eq, show]
  
    let rec to_binary =
      fun { name; insertion_point; content } ->
        let _o = Runtime.Byte_output.create () in
        Bin'.serialize_optional_field 1 Field'.String_t name _o >>= fun () ->
        Bin'.serialize_optional_field 2 Field'.String_t insertion_point _o >>= fun () ->
        Bin'.serialize_optional_field 15 Field'.String_t content _o >>= fun () ->
        Ok (Runtime.Byte_output.contents _o)
  
    let rec of_binary =
      fun input' ->
        Ok (Runtime.Byte_input.create input') >>=
        Bin'.deserialize_message >>= fun _m ->
        Bin'.decode_optional_field 1 Field'.String_t _m >>= fun name ->
        Bin'.decode_optional_field 2 Field'.String_t _m >>= fun insertion_point ->
        Bin'.decode_optional_field 15 Field'.String_t _m >>= fun content ->
        Ok { name; insertion_point; content }
  
    let rec to_text =
      fun { name; insertion_point; content } ->
        let _o = Runtime.Byte_output.create () in
        Text'.serialize_optional_field "name" Field'.String_t name _o >>= fun () ->
        Text'.serialize_optional_field "insertion_point" Field'.String_t insertion_point _o >>= fun () ->
        Text'.serialize_optional_field "content" Field'.String_t content _o >>= fun () ->
        Ok (Runtime.Byte_output.contents _o)
  
    let rec of_text =
      fun input' ->
        Ok (Runtime.Byte_input.create input') >>=
        Text'.deserialize_message >>= fun _m ->
        Text'.decode_optional_field "name" Field'.String_t _m >>= fun name ->
        Text'.decode_optional_field "insertion_point" Field'.String_t _m >>= fun insertion_point ->
        Text'.decode_optional_field "content" Field'.String_t _m >>= fun content ->
        Ok { name; insertion_point; content }
  end

  type t = {
    error : string option;
    file : Code_generator_response.File.t list;
  }
  [@@deriving eq, show]

  let rec to_binary =
    fun { error; file } ->
      let _o = Runtime.Byte_output.create () in
      Bin'.serialize_optional_field 1 Field'.String_t error _o >>= fun () ->
      Bin'.serialize_repeated_user_field 15 Code_generator_response.File.to_binary file _o >>= fun () ->
      Ok (Runtime.Byte_output.contents _o)

  let rec of_binary =
    fun input' ->
      Ok (Runtime.Byte_input.create input') >>=
      Bin'.deserialize_message >>= fun _m ->
      Bin'.decode_optional_field 1 Field'.String_t _m >>= fun error ->
      Bin'.decode_repeated_user_field 15 Code_generator_response.File.of_binary _m >>= fun file ->
      Ok { error; file }

  let rec to_text =
    fun { error; file } ->
      let _o = Runtime.Byte_output.create () in
      Text'.serialize_optional_field "error" Field'.String_t error _o >>= fun () ->
      Text'.serialize_repeated_user_field "file" Code_generator_response.File.to_text file _o >>= fun () ->
      Ok (Runtime.Byte_output.contents _o)

  let rec of_text =
    fun input' ->
      Ok (Runtime.Byte_input.create input') >>=
      Text'.deserialize_message >>= fun _m ->
      Text'.decode_optional_field "error" Field'.String_t _m >>= fun error ->
      Text'.decode_repeated_user_field "file" Code_generator_response.File.of_text _m >>= fun file ->
      Ok { error; file }
end
OCaml

Innovation. Community. Security.