summaryrefslogtreecommitdiff
path: root/generate.go
diff options
context:
space:
mode:
Diffstat (limited to 'generate.go')
-rw-r--r--generate.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/generate.go b/generate.go
index 43a86d4..3bc74f1 100644
--- a/generate.go
+++ b/generate.go
@@ -64,12 +64,13 @@ func (pf *File) specialBases(wFind io.Writer) {
// FRUIT == the string name of the message in the protobuf file
// APPLE == the type of the repeated variable
// APPLES == the variable name of the repeated struct
-func (pf *File) processMessage(msg *MsgName, wSort, wFind io.Writer) error {
- var FRUIT string = cases.Title(language.English, cases.NoLower).String(msg.Name)
+func (pf *File) processMessage(parent *MsgName, wSort, wFind io.Writer) error {
+ var FRUIT string = cases.Title(language.English, cases.NoLower).String(parent.Name)
+ var LOCK string = parent.Lockname
log.Printf("Generating functions for %s\n", FRUIT)
- for _, v := range msg.Vars {
+ for _, v := range parent.Vars {
if !v.IsRepeated {
log.Printf("\tSKIP %s %s\n", v.VarName, v.VarType)
continue
@@ -96,7 +97,7 @@ func (pf *File) processMessage(msg *MsgName, wSort, wFind io.Writer) error {
log.Printf("FOUND: %s %s for %s\n", APPLES, APPLE, FRUIT)
- found.addFindByMsg(wFind, FRUIT, APPLES, APPLE)
+ found.addFindByMsg(wFind, FRUIT, APPLES, APPLE, LOCK)
found.addAppendByMsg(wFind, FRUIT, APPLES, APPLE)
found.addDeleteByMsg(wFind, FRUIT, APPLES, APPLE)
found.addInsertByMsg(wFind, FRUIT, APPLES, APPLE) // new idea
@@ -106,13 +107,13 @@ func (pf *File) processMessage(msg *MsgName, wSort, wFind io.Writer) error {
return nil
}
-func (parent *MsgName) addFindByMsg(w io.Writer, FRUIT, APPLES, APPLE string) {
+func (parent *MsgName) addFindByMsg(w io.Writer, FRUIT, APPLES, APPLE, LOCK string) {
log.Printf("\tINSERT: %s %s for %s\n", APPLES, APPLE, FRUIT)
for _, v := range parent.Vars {
if v.HasUnique {
var COLOR string = cases.Title(language.English, cases.NoLower).String(v.VarName)
log.Printf("\t\t(x %s) InsertBy%s(string) *%s\n", FRUIT, COLOR, APPLE)
- parent.findBy(w, FRUIT, APPLES, APPLE, COLOR)
+ parent.findBy(w, FRUIT, APPLES, APPLE, COLOR, LOCK)
}
}
}
@@ -157,7 +158,7 @@ func (parent *MsgName) addAppendByMsg(w io.Writer, FRUIT, APPLES, APPLE string)
COLORS = append(COLORS, COLOR)
log.Printf("\t\t(x %s) AppendUniqueBy%s(%s)\n", FRUIT, COLOR, APPLE)
- parent.appendUniqueBy(w, FRUIT, APPLES, APPLE, COLOR)
+ parent.appendUniqueCOLOR(w, FRUIT, APPLES, APPLE, COLOR)
}
}
if len(COLORS) > 0 {