Refactor void handling: add specialized encoder/decoder/type logic, update void-based operations for clarity and correctness

This commit is contained in:
adman
2025-12-27 19:34:27 +01:00
parent 08f265c259
commit 3ddf830d31
9 changed files with 46 additions and 39 deletions
+6 -2
View File
@@ -12,7 +12,7 @@ import (
func DefaultDecoder(_ *Generator, varToSet ast.Expr, _ any, _ string) (s []ast.Stmt, err error) {
s = Stmts(
Assign(
Exprs(varToSet, Ident("err")),
Exprs(Ident("err")),
Exprs(Call(SelectorExprAndStr(varToSet, "Decode"), Ident("r"))),
),
IfErrNil(),
@@ -511,6 +511,10 @@ func VarLongDecoder(g *Generator, varToSet ast.Expr, dataRaw any, name string) (
return
}
func VoidDecoder(g *Generator, varToSet ast.Expr, dataRaw any, name string) (s []ast.Stmt, err error) {
return
}
func (g *Generator) RegisterDecoderNatives() {
g.DecoderNatives = map[string]FunctionGeneratorFunc{
"container": ContainerDecoder,
@@ -523,7 +527,7 @@ func (g *Generator) RegisterDecoderNatives() {
"bitfield": BitFieldDecoder,
"string": StringDecoder,
"void": DefaultDecoder,
"void": VoidDecoder,
"varint": VarIntDecoder,
"varlong": VarLongDecoder,
"anonymousNbt": DefaultDecoder,