diff options
| -rw-r--r-- | generate.go | 16 | ||||
| -rw-r--r-- | generateAppend.go | 15 |
2 files changed, 12 insertions, 19 deletions
diff --git a/generate.go b/generate.go index 739e87e..c2287b9 100644 --- a/generate.go +++ b/generate.go @@ -166,7 +166,6 @@ func (pb *Files) makeNewSortfile(pf *File) error { log.Printf("Adding %s\n", funcdef) } if PARENT == VARNAME { - // FUNCNAME := "Append" funcdef := msg.simpleAppend(wSort, PARENT, v.VarName, v.VarType) log.Printf("Adding %s\n", funcdef) @@ -237,7 +236,7 @@ func (pb *Files) makeNewSortfile(pf *File) error { } } - // add Find() Delete() Append() Insert() + // add Find() Delete() Insert() for _, s := range pf.ToSort { PARENT := s.MsgName VARNAME := s.VarName @@ -326,7 +325,7 @@ func (pb *Files) makeNewSortfile(pf *File) error { } } - // AppendBy() functions. todo: fix these so Append() is for simple things and Insert() is for unique keys + // AppendBy() functions. todo: make Insert() for unique var ucount int for _, v := range msg.Vars { if v.VarType != "string" { @@ -394,14 +393,3 @@ func (pf *File) allMsg() []*MsgName { } return all } - -/* -func (pf *File) specialBases(wFind io.Writer) { - var FRUIT string = cases.Title(language.English, cases.NoLower).String(pf.Bases.Name) - var APPLES string = cases.Title(language.English, cases.NoLower).String(pf.Bases.Name) - var APPLE string = cases.Title(language.English, cases.NoLower).String(pf.Base.Name) - - pf.Bases.simpleAppend(wFind, FRUIT, APPLES, APPLE) - -} -*/ diff --git a/generateAppend.go b/generateAppend.go index 4c2dda6..d011ea9 100644 --- a/generateAppend.go +++ b/generateAppend.go @@ -14,7 +14,7 @@ import ( func (msg *MsgName) simpleAppend(w io.Writer, FRUIT, APPLES, APPLE string) string { LOCK := msg.getLockname("x") - funcdef := "func (x *" + FRUIT + ") Append(y *" + APPLE + ") *" + APPLE + funcdef := "func (x *" + FRUIT + ") Append(y *" + APPLE + ")" // log.Printf("\t\t(x %s) APPEND(%s)\n", FRUIT, APPLE) // append -- no check at all @@ -23,10 +23,12 @@ func (msg *MsgName) simpleAppend(w io.Writer, FRUIT, APPLES, APPLE string) strin fmt.Fprintln(w, " "+LOCK+".Lock()") fmt.Fprintln(w, " defer "+LOCK+".Unlock()") fmt.Fprintln(w, "") - fmt.Fprintln(w, " z := proto.Clone(y).(*"+APPLE+")") - fmt.Fprintln(w, " x."+APPLES+" = append(x."+APPLES+", z)") + fmt.Fprintln(w, " // append was doing Clone() and that was poorly named.") + fmt.Fprintln(w, " // now autogenpb makes Clone() for that") + fmt.Fprintln(w, " // z := proto.Clone(y).(*"+APPLE+")") + fmt.Fprintln(w, " x."+APPLES+" = append(x."+APPLES+", y)") fmt.Fprintln(w, "") - fmt.Fprintln(w, " return z") + fmt.Fprintln(w, " // return z") fmt.Fprintln(w, "}") fmt.Fprintln(w, "") @@ -51,7 +53,10 @@ func (msg *MsgName) simpleAppendBy(w io.Writer, STRUCT, FUNCNAME, STRUCTVAR, VAR fmt.Fprintln(w, " }") fmt.Fprintln(w, " }") fmt.Fprintln(w, "") - fmt.Fprintln(w, " x."+STRUCTVAR+" = append(x."+STRUCTVAR+", proto.Clone(y).(*"+VARTYPE+"))") + fmt.Fprintln(w, " // append was doing Clone() and that was poorly named.") + fmt.Fprintln(w, " // now autogenpb makes Clone() for that") + fmt.Fprintln(w, " // x."+STRUCTVAR+" = append(x."+STRUCTVAR+", proto.Clone(y).(*"+VARTYPE+"))") + fmt.Fprintln(w, " x."+STRUCTVAR+" = append(x."+STRUCTVAR+", y)") fmt.Fprintln(w, " return true") fmt.Fprintln(w, "}") fmt.Fprintln(w, "") |
