Module ecapnpc

The Erlang Cap'n Proto Compiler plugin.

Copyright 2013, Andreas Stenius

Authors: Andreas Stenius (kaos@astekk.se).

Description

The Erlang Cap'n Proto Compiler plugin.

This module takes a CodeGeneratorRequest message and compiles the requested schema files into Erlang header files.

Thus, a my_schema.capnp will be compiled to my_schema.capnp.hrl, implementing my_schema/N functions for reading and writing Cap'n Proto messages using my_schema.

Schema functions

The schema functions implemented in a compiled schema header file are:
fun((root, schema_type(), message()) -> {ok, object()})
Get a reference to the root object in message.
fun((root, schema_type()) -> {ok, object()})
Set root object type for a new message.
fun((get, field_name(), object()) -> field_value())
Read object field value.
fun((get, object()) -> (field_name() | {field_name(), field_value()}))
Read unnamed union value of object.
fun((set, field_name(), field_value(), object()) -> ok)
Write value to object field.
fun((set, {field_name(), field_value()} | field_name(), object()) -> ok)
Write unnamed union value.
fun((to_struct, schema_type(), object()) -> object())
Type cast object to another struct type.
fun((to_list, schema_type(), object()) -> list())
Type cast object to list.
fun((to_text | to_data, object()) -> binary())
Type cast object to text or data.
fun((schema) -> schema())
Get the compiled schema definition.
Where fun is named after the basename of the schema file (refer to the my_schema.capnp example in the Description section).

Data Types

message()

message() = ecapnp:message()

Function Index

compile_data/1Compile the CodeGeneratorRequest message (unpacked) in Data.
compile_file/1Read a CodeGeneratorRequest message (unpacked) from FileName and compile it.
compile_message/1Compile the CodeGeneratorRequest message.

Function Details

compile_data/1

compile_data(Data::binary()) -> ok

Compile the CodeGeneratorRequest message (unpacked) in Data.

compile_file/1

compile_file(FileName::file:name_all()) -> ok

Read a CodeGeneratorRequest message (unpacked) from FileName and compile it.

compile_message/1

compile_message(Message::message()) -> ok

Compile the CodeGeneratorRequest message. The Message argument holds the raw segments data to process, no futher processing on the message itself will be carried out prior to the compilation step.


Generated by EDoc, May 30 2014, 12:56:29.