strom: fix generator for pointer-receiver Encode, use nbt.Tag for named NBT
- Delete raw_capture subcommand (use tcpflow + raw-to-tmcpr instead) - Fix DefaultEncoder to use temp variable for non-addressable value encoding, eliminating manual post-generation patches - Map nbt and optionalNbt types to nbt.Tag (named NBT) instead of nbt.Anon (anonymous NBT) — 1.8 uses named NBT with root tag names
This commit is contained in:
+1130
-567
File diff suppressed because it is too large
Load Diff
+1050
-527
File diff suppressed because it is too large
Load Diff
+1130
-567
File diff suppressed because it is too large
Load Diff
+306
-155
File diff suppressed because it is too large
Load Diff
+1140
-572
File diff suppressed because it is too large
Load Diff
+1142
-573
File diff suppressed because it is too large
Load Diff
@@ -11,15 +11,16 @@ import (
|
||||
"github.com/go-viper/mapstructure/v2"
|
||||
)
|
||||
|
||||
func DefaultEncoder(_ *Generator, varToSet ast.Expr, _ any, _ string) (s []ast.Stmt, err error) {
|
||||
func DefaultEncoder(_ *Generator, varToSet ast.Expr, _ any, name string) (s []ast.Stmt, err error) {
|
||||
tmpName := name + "EncTmp"
|
||||
s = Stmts(
|
||||
Define121(Ident(tmpName), varToSet),
|
||||
Assign121(
|
||||
Ident("err"),
|
||||
Call(SelectorExprAndStr(varToSet, "Encode"), Ident("w")),
|
||||
Call(SelectorExprAndStr(Ident(tmpName), "Encode"), Ident("w")),
|
||||
),
|
||||
IfErrNil(),
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -200,8 +200,8 @@ func (g *Generator) RegisterNatives() {
|
||||
"native": VisitDontGenerateType,
|
||||
"anonymousNbt": MakeSelectorVisitor("nbt", "Anon"),
|
||||
"anonOptionalNbt": MakeSelectorVisitor("nbt", "Anon"), // I have no idea what the difference is between these two
|
||||
"optionalNbt": MakeSelectorVisitor("nbt", "Anon"),
|
||||
"nbt": MakeSelectorVisitor("nbt", "Anon"),
|
||||
"optionalNbt": MakeSelectorVisitor("nbt", "Tag"),
|
||||
"nbt": MakeSelectorVisitor("nbt", "Tag"),
|
||||
"void": VoidType,
|
||||
"bool": MakeIdentVisitor("bool"),
|
||||
"u8": MakeIdentVisitor("uint8"),
|
||||
|
||||
Reference in New Issue
Block a user