package ocaml-protoc

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

Module Ocaml_protoc_compiler_lib.Pb_field_typeSource

Protobuffer Field type

Sourcetype type_path = string list

Scope path of a type used for a message field.

For instance in the following field defintion:

required foo.bar.Msg1 f = 1

The type_path would be ["foo"; "bar"]

Sourcetype unresolved = {
  1. type_path : type_path;
  2. type_name : string;
  3. from_root : bool;
    (*

    from_root indicates that the scope for the type is from the root of the type system. (ie starts with '.')

    *)
}

In the first phase of the compilation the field of message type are not resolved but only properly parsed.

The following type summarizes the information of a field type.

In the following field definition:

required foo.bar.Msg1 f = 1

The unresolved type would be: { scope=["foo";"bar"]; type_name="Msg1"; from_root = false }

Sourcetype resolved = int

After phase 2 compilation the field type is resolved to an known message which can be uniquely identified by its id.

Sourcetype builtin_type_floating_point = [
  1. | `Double
  2. | `Float
]

Floating point builtin types

Sourcetype builtin_type_unsigned_int = [
  1. | `Uint32
  2. | `Uint64
]

Unsigned integer builtin types

Sourcetype builtin_type_signed_int = [
  1. | `Int32
  2. | `Int64
  3. | `Sint32
  4. | `Sint64
  5. | `Fixed32
  6. | `Fixed64
  7. | `Sfixed32
  8. | `Sfixed64
]

Signed integer builtin types

Integer builtin types

Sourcetype map_key_type = [
  1. | builtin_type_int
  2. | `Bool
  3. | `String
]
Sourcetype builtin_type = [
  1. | builtin_type_floating_point
  2. | builtin_type_int
  3. | `Bool
  4. | `String
  5. | `Bytes
]

Builtin type defined in protobuf

Sourcetype 'a t = [
  1. | builtin_type
  2. | `User_defined of 'a
]

field type.

The 'a type is for re-using the same type definition for the 2 compilation phases.

After Phase 1 'a is unresolved while after Phase2 'a is resolved.

Sourcetype unresolved_t = unresolved t
Sourcetype resolved_t = resolved t
Sourceval parse : string -> unresolved_t