|
|
|
@ -67,6 +67,7 @@ type Generator struct {
|
|
|
|
type decodeBranchRequest struct {
|
|
|
|
type decodeBranchRequest struct {
|
|
|
|
hash [16]byte
|
|
|
|
hash [16]byte
|
|
|
|
typ Type
|
|
|
|
typ Type
|
|
|
|
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (this *Generator) Generate(protocol *Protocol) (n int, err error) {
|
|
|
|
func (this *Generator) Generate(protocol *Protocol) (n int, err error) {
|
|
|
|
@ -102,9 +103,9 @@ func (this *Generator) Generate(protocol *Protocol) (n int, err error) {
|
|
|
|
|
|
|
|
|
|
|
|
// request queue
|
|
|
|
// request queue
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
hash, typ, ok := this.pullDecodeBranchRequest()
|
|
|
|
hash, typ, name, ok := this.pullDecodeBranchRequest()
|
|
|
|
if !ok { break }
|
|
|
|
if !ok { break }
|
|
|
|
nn, err := this.generateDecodeBranch(hash, typ)
|
|
|
|
nn, err := this.generateDecodeBranch(hash, typ, name)
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -193,7 +194,7 @@ func (this *Generator) generateTypedef(name string, typ Type) (n int, err error)
|
|
|
|
nn, err = this.iprintf("}\n")
|
|
|
|
nn, err = this.iprintf("}\n")
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
|
|
|
|
|
|
|
|
nn, err = this.generateDecodeValue(typ, "this", "tag")
|
|
|
|
nn, err = this.generateDecodeValue(typ, name, "this", "tag")
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
nn, err = this.iprintf("return n, nil\n")
|
|
|
|
nn, err = this.iprintf("return n, nil\n")
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
@ -282,7 +283,7 @@ func (this *Generator) generateMessage(method uint16, message Message) (n int, e
|
|
|
|
nn, err = this.iprintf("}\n")
|
|
|
|
nn, err = this.iprintf("}\n")
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
|
|
|
|
|
|
|
|
nn, err = this.generateDecodeValue(message.Type, "this", "tag")
|
|
|
|
nn, err = this.generateDecodeValue(message.Type, this.resolveMessageName(message.Name), "this", "tag")
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
nn, err = this.iprintf("return n, nil\n")
|
|
|
|
nn, err = this.iprintf("return n, nil\n")
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
@ -471,7 +472,10 @@ func (this *Generator) generateEncodeValue(typ Type, valueSource, tagSource stri
|
|
|
|
// - n int
|
|
|
|
// - n int
|
|
|
|
// - err error
|
|
|
|
// - err error
|
|
|
|
// - nn int
|
|
|
|
// - nn int
|
|
|
|
func (this *Generator) generateDecodeValue(typ Type, valueSource, tagSource string) (n int, err error) {
|
|
|
|
//
|
|
|
|
|
|
|
|
// The typeName paramterer is handled in the way described in the documentation
|
|
|
|
|
|
|
|
// for [Generator.generateDecodeBranch].
|
|
|
|
|
|
|
|
func (this *Generator) generateDecodeValue(typ Type, typeName, valueSource, tagSource string) (n int, err error) {
|
|
|
|
switch typ := typ.(type) {
|
|
|
|
switch typ := typ.(type) {
|
|
|
|
case TypeInt:
|
|
|
|
case TypeInt:
|
|
|
|
// SI: (none)
|
|
|
|
// SI: (none)
|
|
|
|
@ -537,7 +541,7 @@ func (this *Generator) generateDecodeValue(typ Type, valueSource, tagSource stri
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case TypeArray:
|
|
|
|
case TypeArray:
|
|
|
|
// OTA: <length: UN> <elementTag: tape.Tag> <values>*
|
|
|
|
// OTA: <length: UN> <elementTag: tape.Tag> <values>*
|
|
|
|
nn, err := this.generateDecodeBranchCall(typ, valueSource, tagSource)
|
|
|
|
nn, err := this.generateDecodeBranchCall(typ, typeName, valueSource, tagSource)
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
n += nn; if err != nil { return n, err }
|
|
|
|
case TypeTable:
|
|
|
|
case TypeTable:
|
|
|
|
// KTV: <length: UN> (<key: U16> <tag: Tag> <value>)*
|
|
|
|
// KTV: <length: UN> (<key: U16> <tag: Tag> <value>)*
|
|
|