generate: Use new option type
This commit is contained in:
parent
62e3c7814c
commit
5d5ee9c644
@ -222,6 +222,12 @@ func (this *Protocol) unmarshalMessage(out io.Writer, message Message) error {
|
||||
fmt.Fprintf(out,
|
||||
"func (msg *Message%s) UnmarshalBinary(buffer []byte) error {\n",
|
||||
message.Name)
|
||||
if len(message.Fields) < 1 {
|
||||
fmt.Fprintf(out, "\t// no fields\n")
|
||||
fmt.Fprintf(out, "\treturn nil\n")
|
||||
fmt.Fprintf(out, "}\n\n")
|
||||
return nil
|
||||
}
|
||||
fmt.Fprintf(out, "\tpairs, err := tape.DecodePairs(buffer)\n")
|
||||
fmt.Fprintf(out, "\tif err != nil { return err }\n")
|
||||
requiredTotal := 0
|
||||
@ -243,7 +249,7 @@ func (this *Protocol) unmarshalMessage(out io.Writer, message Message) error {
|
||||
fmt.Fprintf(out, "\n")
|
||||
fmt.Fprintf(out, "\t\t\tif err != nil { return err }\n")
|
||||
if field.Optional {
|
||||
fmt.Fprintf(out, "\t\t\tmsg.%s.Set(value)\n", field.Name)
|
||||
fmt.Fprintf(out, "\t\t\tmsg.%s = hopp.O(value)\n", field.Name)
|
||||
} else {
|
||||
fmt.Fprintf(out, "\t\t\tmsg.%s = value\n", field.Name)
|
||||
if requiredTotal > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user