33
44The goal of Ocaml protoc plugin is to create plugin for
55the google protobuf compiler (` protoc ` ) to generate Ocaml types and
6- serialization and de-serialization functions from a ` .proto `
6+ serialization and deserialization functions from a ` .proto `
77file. Ocaml-protoc-plugin aims to be a fully compliant implementation
8- of the google protobuffer standard and guidelines.
8+ of the Google protobuf standard and guidelines.
99
1010The main features include:
1111* Messages are mapped to idiomatic OCaml types, using modules
@@ -18,6 +18,8 @@ The main features include:
1818* Configurable annotations for all generated types
1919* Json serialization and deserialization based on protobuf
2020 specification
21+ * Implemented in pure Ocaml. making the library usable with ` js-of-ocaml ` , ` melange ` , etc.
22+
2123
2224## Comparison with other OCaml protobuf handlers.
2325
@@ -138,7 +140,7 @@ protoc --plugin=protoc-gen-ocaml=../plugin/ocaml-protocol-plugin.exe --ocaml_out
138140### Json serialization and deserialization
139141Ocaml-proto-plugin can serialize and deserialize to/from
140142json. Using the function ` to_json ` , ` from_json ` and
141- ` from_json_exn ` similar to regular protobuffer serialization and
143+ ` from_json_exn ` similar to regular protobuf serialization and
142144deserialization.
143145
144146Json serialization can be controlled using optional arguments:
@@ -153,7 +155,7 @@ to limit number of dependencies.
153155
154156
155157The ` options ` argument allows finer grained control over json
156- serialization. The followin options are supported:
158+ serialization. The following options are supported:
157159
158160| argument | comment | default |
159161| ---| ---| ---|
@@ -183,7 +185,7 @@ as close as possible:
183185| google.protobuf.Any | | Not handled, as the ocaml-protobuf-plugin does not support dynamic protobuf parsing |
184186
185187
186- Json serialization and deserializaiton is not well optimized and
188+ Json serialization and deserialization is not well optimized and
187189should not be used in performance critical applications.
188190
189191### Older versions of protoc
@@ -202,7 +204,7 @@ into somewhat more Ocaml idiomatic names. When this option is set (see
202204below), names are mangled to snake case as described in the table
203205below:
204206
205- | Protobyf type | Protobuf name | Ocaml name |
207+ | Protobuf type | Protobuf name | Ocaml name |
206208| :--------------| :-------------------------| :-------------------------|
207209| package | ` CapitalizedSnakeCase ` | ` Capitalized_snake_case ` |
208210| message | ` CapitalizedSnakeCase ` | ` Capitalized_snake_case ` |
@@ -220,14 +222,14 @@ name to make sure names are unique.
220222
221223The algorithm for converting CamelCased names to snake_case is done by
222224injecting an underscore between any lowercase and uppercase character
223- and then lowercasing the result.
225+ and then lowercase the result.
224226
225227### Setting mangle option
226228Name mangling option can only be controlled from within the protobuf
227229specification file. This is needed as protobuf files may reference each
228230other and it its important to make sure that included names are
229231referenced correctly across compilation units (and invocations of
230- protoc).
232+ ` protoc ` ).
231233
232234To set the option use:
233235``` protobuf
@@ -247,11 +249,11 @@ message MyProtoMessage { }
247249```
248250
249251### Deprecation annotations in proto files
250- Protobug specification (.proto file) allow for deprecating * files* ,
252+ Protobuf specification (.proto file) allow for deprecating * files* ,
251253* enums* , * enum values* , * messages* , * message fields* , * services* and
252254* methods* .
253255
254- These deprecations are kept in the ocaml mapping to generate
256+ Deprecation annotations are preserved in the ocaml mapping to generate
255257[ alerts] ( https://ocaml.org/manual/alerts.html ) for alert category
256258'protobuf'.
257259
@@ -346,12 +348,12 @@ serializing and deserializing the embedded message.
346348
347349## Proto3 Optional fields
348350Proto3 optional fields are handled in the same way as proto2 optional
349- fields; The type is an option type, and always transmissted when set.
351+ fields; The type is an option type, and always transmitted when set.
350352
351- ## Imported protofiles
353+ ## Imported proto-files
352354The generated code assumes that imported modules (generated from proto
353355files) are available in the compilation scope. If the modules
354- generated from imported protofiles resides in different a different
356+ generated from imported proto-files resides in different a different
355357scope (e.g. is compiled with ` wrapped true ` , they need to be made
356358available by adding parameter ` open=<module name> ` to make the modules
357359available for the compilation.
@@ -364,7 +366,7 @@ be used by linking with the package `ocaml-protoc-plugin.google_types`, and addi
364366option ` open=Google_types ` to the list of parameters
365367
366368The distributed google types are compiled using default parameters,
367- i.e. without any ppx annotations.
369+ i.e. without any ` ppx ` annotations.
368370
369371If you want to change this, or add type annotations, you can copy the
370372[ dune] ( https://github.com/andersfugmann/ocaml-protoc-plugin/tree/main/src/google_types/dune )
@@ -465,7 +467,9 @@ More examples can be found under
465467
466468# Benchmarks
467469
468- ocaml-protoc-plugin has been optimized for speec, and is comparable [ ocaml-protoc] ( https://github.com/mransan/ocaml-protoc )
470+ ocaml-protoc-plugin has been optimized for speed, and is comparable
471+ [ ocaml-protoc] ( https://github.com/mransan/ocaml-protoc ) in terms of
472+ performance.
469473
470474Numbers below shows benchmark comparing encoding and decoding speed to
471475` ocaml-protoc ` . The benchmark is run with flambda settings: ` -O3 -unbox-closures -unboxed-types -remove-unused-arguments -rounds 4 -inline 100.00 -inline-max-depth 5 -inline-max-unroll 5 -unsafe ` . Benchmarks are made on a Intel i5, i5-5257U CPU
0 commit comments