From 5b4491f17ba4325ab9783374d4efa7e4aa652a9f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 12 Jan 2025 05:32:58 -0600 Subject: [PATCH] generates generic Append() --- Makefile | 1 + generate.go | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 049a547..9f445bd 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ test: make goimports vet build make -C example testGlobal make -C example testProtoc + make -C example all dryrun: build make -C example dryrun diff --git a/generate.go b/generate.go index 16f2c43..3dc70c7 100644 --- a/generate.go +++ b/generate.go @@ -153,6 +153,12 @@ func (pb *Files) makeNewSortfile(pf *File) error { funcdef += " # is special struct=varname" log.Printf("LEN: %-2d %20s %20s %20s %20s %s\n", i, PARENT, CHILD, VARNAME, LOCK, funcdef) } + if PARENT == VARNAME { + // FUNCNAME := "Append" + msg.simpleAppend(wSort, PARENT, v.VarName, v.VarType) + // funcdef := msg.addAppendBy(wSort, PARENT, FUNCNAME, VARNAME, PARENT, s.VarType) + // log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef) + } } } } @@ -242,7 +248,7 @@ func (pb *Files) makeNewSortfile(pf *File) error { var FUNCNAME string if PARENT == VARNAME { // special case because of the enforced .proto format - FUNCNAME = "Find" + v.VarName + FUNCNAME = "FindBy" + v.VarName } else { FUNCNAME = "Find" + VARNAME + "By" + v.VarName } @@ -276,7 +282,7 @@ func (pb *Files) makeNewSortfile(pf *File) error { var FUNCNAME string if PARENT == VARNAME { // special case because of the enforced .proto format - FUNCNAME = "Delete" + v.VarName + FUNCNAME = "DeleteBy" + v.VarName } else { FUNCNAME = "Delete" + VARNAME + "By" + v.VarName } @@ -289,8 +295,8 @@ func (pb *Files) makeNewSortfile(pf *File) error { log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef) } + // AppendBy() functions. these maybe need to be rethought var ucount int - // append() functions. these need to be rethought for _, v := range msg.Vars { if v.IsRepeated { continue @@ -302,12 +308,12 @@ func (pb *Files) makeNewSortfile(pf *File) error { var FUNCNAME string if PARENT == VARNAME { // special case because of the enforced .proto format - FUNCNAME = "Append" + v.VarName + FUNCNAME = "AppendBy" + v.VarName } else { FUNCNAME = "Append" + VARNAME + "By" + v.VarName + funcdef := msg.addAppendBy(wSort, PARENT, FUNCNAME, VARNAME, v.VarName, s.VarType) + log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef) } - funcdef := msg.addAppendBy(wSort, PARENT, FUNCNAME, VARNAME, v.VarName, s.VarType) - log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef) } if ucount == 1 {