From dc72cc2010bf7f1d2828a156e44fc6783a8e45ad Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 11 Aug 2025 20:59:20 -0400 Subject: [PATCH] generate: Support LSI tags --- generate/generate.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/generate/generate.go b/generate/generate.go index 0f21e37..7d6aa1b 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -307,8 +307,8 @@ func (this *Generator) generateMessage(method uint16, message Message) (n int, e func (this *Generator) generateEncodeValue(typ Type, valueSource, tagSource string) (n int, err error) { switch typ := typ.(type) { case TypeInt: - // SI: (none) - // LI: + // SI: (none) + // LI/LSI: if typ.Bits <= 5 { // SI stores the value in the tag, so we write nothing here break @@ -478,8 +478,8 @@ func (this *Generator) generateEncodeValue(typ Type, valueSource, tagSource stri func (this *Generator) generateDecodeValue(typ Type, typeName, valueSource, tagSource string) (n int, err error) { switch typ := typ.(type) { case TypeInt: - // SI: (none) - // LI: + // SI: (none) + // LI/LSI: if typ.Bits <= 5 { // SI stores the value in the tag nn, err := this.iprintf("*%s = uint8(%s.CN())\n", valueSource, tagSource) @@ -837,6 +837,9 @@ func (this *Generator) generateTag(typ Type, source string) (n int, err error) { if typ.Bits <= 5 { nn, err := this.printf("tape.SI.WithCN(int(%s))", source) n += nn; if err != nil { return n, err } + } else if typ.Signed { + nn, err := this.printf("tape.LSI.WithCN(%d)", bitsToCN(typ.Bits)) + n += nn; if err != nil { return n, err } } else { nn, err := this.printf("tape.LI.WithCN(%d)", bitsToCN(typ.Bits)) n += nn; if err != nil { return n, err } @@ -881,6 +884,9 @@ func (this *Generator) generateTN(typ Type) (n int, err error) { if typ.Bits <= 5 { nn, err := this.printf("tape.SI") n += nn; if err != nil { return n, err } + } else if typ.Signed { + nn, err := this.printf("tape.LSI") + n += nn; if err != nil { return n, err } } else { nn, err := this.printf("tape.LI") n += nn; if err != nil { return n, err }