The compiled message: three deftypes implementing protobuf-java's
Message, Message.Builder and Parser interfaces over the compiler's slot
layout, so that everything downstream — the generated code's
.newBuilderForType / .build, core/encode and core/decode, grpc
marshallers, TextFormat and JsonFormat — keeps working, with none of
DynamicMessage's FieldSet behind it.
A CompiledMessage is a compiled type, an Object[] of slots and an UnknownFieldSet (nil when empty). It is immutable; its serialized size is memoized. A CompiledBuilder is the same, mutable. Collections in slots are never mutated in place once a message may share them: a builder that has built, or was made by toBuilder, copies a collection before touching it. The parser owns fresh slots, so parsing mutates freely.
The reflective API returns what protobuf-java's does — EnumValueDescriptor for enums, a list of entry messages for maps, the nested default instance for an unset message field — and equals/hashCode follow AbstractMessage's algorithm exactly, so a compiled message equals and hashes like a DynamicMessage of the same descriptor and value. Descriptors from another pool (a generated class) are never equal, by protobuf-java's own rule.
The compiled message: three deftypes implementing protobuf-java's Message, Message.Builder and Parser interfaces over the compiler's slot layout, so that everything downstream — the generated code's `.newBuilderForType` / `.build`, `core/encode` and `core/decode`, grpc marshallers, TextFormat and JsonFormat — keeps working, with none of DynamicMessage's FieldSet behind it. A CompiledMessage is a compiled type, an Object[] of slots and an UnknownFieldSet (nil when empty). It is immutable; its serialized size is memoized. A CompiledBuilder is the same, mutable. Collections in slots are never mutated in place once a message may share them: a builder that has built, or was made by toBuilder, copies a collection before touching it. The parser owns fresh slots, so parsing mutates freely. The reflective API returns what protobuf-java's does — EnumValueDescriptor for enums, a list of entry messages for maps, the nested default instance for an unset message field — and equals/hashCode follow AbstractMessage's algorithm exactly, so a compiled message equals and hashes like a DynamicMessage of the same descriptor and value. Descriptors from another pool (a generated class) are never equal, by protobuf-java's own rule.
Descriptor -> CompiledType, with this layer's parser for nested types.
Descriptor -> CompiledType, with this layer's parser for nested types.
(message-slot m slot)The raw slot value of a compiled message: nil when absent (or, without presence, default).
The raw slot value of a compiled message: nil when absent (or, without presence, default).
(parser-for t)The one Parser for a compiled type.
The one Parser for a compiled type.
(prototype d)The default instance for a descriptor: what rt/message returns on the compiled arm.
The default instance for a descriptor: what rt/message returns on the compiled arm.
(set-slot! b slot v)Store a slot-representation value on a compiled builder: a default on a field without presence is stored as nil, and a oneof member clears its siblings — the same rules setField applies.
Store a slot-representation value on a compiled builder: a default on a field without presence is stored as nil, and a oneof member clears its siblings — the same rules setField applies.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |