v3.0.0
Backwards-incompatible changes
-
The
Builder.X.reader_t
andReader.X.builder_t
types have gone (to avoid confusion with the genericreader_t
andbuilder_t
types). UseX.struct_t reader_t
andX.struct_t builder_t
instead.
Builder.X.t
is still defined (as an alias forstruct_t builder_t
), and similarly forReader.X.t
. -
StructStorage.t
now takes an extra type parameter. This is a phantom type, used to indicate what kind of struct it represents. This extra parameter has also been added toObject.t
. -
In the generated files, the unique types names (e.g.
reader_t_Foo_14133145859926553711
) have gone. If you need to refer to these directly for some reason, use the replacement polymorphic type instead (e.g.Foo_c42305476bb4746f reader_t
).
New features
-
RPC support (#35 and #36).
The compiler now generates readers and builders for parameters and results, interface and method IDs, and a dispatch method for services. There is a newMakeRPC
functor in the generated files that takes an extended version ofMessageSig
. The originalMake
is still provided - it is now a convenience wrapper aroundMakeRPC
that passes some dummy functions.
An RPC provider is available at https://github.com/mirage/capnp-rpc. -
Capability references can now be attached to messages.
The getters and setters that previously tookUint32.t
indexes can now take capabilities, as defined by an RPC provider library. The defaultRPC.None
provider exposes the raw descriptor index, as before. -
Better AnyPointer support (#11). The new
of_pointer
andinit_pointer
functions can be used to read and add structs of any type to AnyPointer fields. The newpointer_set_reader
can be used to set a pointer by copying from a reader. -
Replace camlp4 includes with flambda inlining (#23).
The-inc.ml
files that were previously copied into each generated file are now regular modules in the library, making them available to other code too. This makes the generated files much smaller. There is no performance penalty (when using flambda). -
Port to jbuilder (#24).
Also, the required schema files are now included in the repository rather than being downloaded by the build scripts, which was fragile. -
Add support for cycles (#29).
Before, the compiler would abort if a schema file contained cycles, but this is very common (especially with interfaces). It now generates forward references where needed. -
Add parameterised
reader_t
andbuilder_t
types (#32 and #33).
Instead of providingReader.Foo.t
andBuilder.Foo.t
as abstract types, provide a singleFoo.struct_t
and usestruct_t reader_t
andstruct_t builder_t
for its reader and builder.
This makes it possible to define generic functions that work on all readers or builders, without having to generate a separate function for each one. The types are shared between files, so you can write generic code to work with schema files you haven't seen (needed for the RPC system). -
Use polymorphic variants for phantom types (#34).
Instead of declaring a load of unique type names at the start of the file, use polymorphic variants. These don't need to be declared before use. The node ID is now formatted as hex, to make it shorter and to match the format used in the schema files. There are new genericreader_of_builder
andmessage_of_builder
functions inStructStorage
.
Other changes
-
All uses of
Obj.magic
have been removed from the generated code. -
Update to latest core_kernel (#26).
Avoids conflict with newer sexplib. -
Fix some compiler warnings (#28). Jbuilder turns on more warnings by default.
-
Add missing test dependency on ounit (#30).
-
Fix code generation bug in 2.1.1 (#10).
A missing space prevented the generated files from compiling.
Added Travis CI tests to detect this kind of thing automatically.