package ocaml-protoc

  1. Overview
  2. Docs

Protobuf typed tree.

The typetree type is parametrized to allow for 2 phase compilation.

type ('a, 'b) field = {
  1. field_parsed : 'b Pt.field;
  2. field_type : 'a Pb_field_type.t;
  3. field_default : Pb_option.constant option;
  4. field_options : Pb_option.set;
}

Field definition.

  • 'a is for unresolved or resolved
  • 'b is for field_label to account for both normal and one of fields.
type 'a oneof_field = ('a, Pt.oneof_field_label) field
type 'a message_field = ('a, Pt.message_field_label) field
type 'a map_field = {
  1. map_name : string;
  2. map_number : int;
  3. map_key_type : Pb_field_type.map_key_type;
  4. map_value_type : 'a Pb_field_type.t;
  5. map_options : Pb_option.set;
}

Map definition

type 'a oneof = {
  1. oneof_name : string;
  2. oneof_fields : 'a oneof_field list;
}

Oneof definition

type type_scope = {
  1. packages : string list;
  2. message_names : string list;
}

Type scope

The scope of a type (message or enum) is defined by the package (defined in the top of the proto file as well as the messages above it since a message definition can be nested

type 'a message_body_content =
  1. | Message_field of 'a message_field
  2. | Message_oneof_field of 'a oneof
  3. | Message_map_field of 'a map_field

item for the message body

and 'a message = {
  1. extensions : Pt.extension_range list;
  2. message_options : Pb_option.set;
  3. message_name : string;
  4. message_body : 'a message_body_content list;
}
type enum_value = {
  1. enum_value_name : string;
  2. enum_value_int : int;
}
type enum = {
  1. enum_name : string;
  2. enum_values : enum_value list;
  3. enum_options : Pb_option.set;
}
type 'a proto_type_spec =
  1. | Enum of enum
  2. | Message of 'a message
type 'a proto_type = {
  1. scope : type_scope;
  2. id : int;
  3. file_name : string;
  4. file_options : Pb_option.set;
  5. spec : 'a proto_type_spec;
}
type 'a proto = 'a proto_type list
OCaml

Innovation. Community. Security.