Big nasty commit to add code generation for encoding
This commit is contained in:
@@ -56,20 +56,27 @@ static section.
|
||||
|
||||
For each defined type, the compiler shall generate a Go type with the same name
|
||||
as written in its definition. The Go type shall be encodable, and shall have
|
||||
`Encode` and `Decode` methods as described below.
|
||||
`EncodeValue`, `DecodeValue`, and `Tag` methods as described below.
|
||||
|
||||
## Encoding and Decoding Methods
|
||||
|
||||
Each encodable type shall be given an `Encode` method and a `Decode` method,
|
||||
which will take in a `codec.Encoder` and a `codec.Decoder` respectively. Both
|
||||
Each message shall be given an `Encode` method and a `Decode` method,
|
||||
which shall take in a `codec.Encoder` and a `codec.Decoder` respectively. Both
|
||||
return an `(int, error)` pair describing the amount of bytes written and an
|
||||
error if the write stopped early. `Encode` will encode the data within the
|
||||
message to the given encoder, and `Decode` will decode data from the given
|
||||
error if the write stopped early. `Encode` shall encode the data within the
|
||||
message to the given encoder, and `Decode` shall decode data from the given
|
||||
decoder and place it in the type's value. The methods shall not retain or close
|
||||
any encoders or decoders they are given. Both methods shall have pointer
|
||||
receivers. In effect, these methods will satisfy `codec.Encodable` and
|
||||
receivers. In effect, these methods shall satisfy `codec.Encodable` and
|
||||
`codec.Decodable`.
|
||||
|
||||
Each defined type shall be given an `EncodeValue` method and a `DecodeValue`
|
||||
method, which shall both take in a `tape.Tag`, then a `codec.Encoder` and a
|
||||
`codec.Decoder` respectively. These methods shall encode and decode the value
|
||||
according to the CN given by the tag. The TN shall be ignored. The message shall
|
||||
also have a method `Tag` that takes no arguments and returns the preferred tag
|
||||
of the type including the TN and CN.
|
||||
|
||||
## Connection
|
||||
|
||||
The compiler shall generate a `Conn` struct which embeds a `hopp.Conn`, which
|
||||
|
||||
Reference in New Issue
Block a user