summaryrefslogtreecommitdiff
path: root/generate.go
diff options
context:
space:
mode:
Diffstat (limited to 'generate.go')
-rw-r--r--generate.go50
1 files changed, 29 insertions, 21 deletions
diff --git a/generate.go b/generate.go
index a1f7ca9..fbb1943 100644
--- a/generate.go
+++ b/generate.go
@@ -107,13 +107,14 @@ func (pb *Files) makeNewSortfile(pf *File) error {
// func newSortBy(w io.Writer, STRUCT, ITER, SORTNAME, SORTBY, SELECT string) string {
if PARENT == VARNAME {
sortby = "SortBy" + v.VarName
+ sortname := s.VarType + v.VarName
+ selectName := "selectAll" + VARNAME
+ funcdef := newSortBy(wSort, PARENT, s.VarType, sortname, sortby, selectName, v.VarName)
+ log.Printf("Adding %s\n", funcdef)
} else {
+ // deprecate this THIS DOES NOT MAKE SENSE TO DO
sortby = "Sort" + VARNAME + "By" + v.VarName
}
- sortname := s.VarType + v.VarName
- selectName := "selectAll" + VARNAME
- funcdef := newSortBy(wSort, PARENT, s.VarType, sortname, sortby, selectName, v.VarName)
- log.Printf("Adding %s\n", funcdef)
} else {
// funcdef := "func (x *" + FUNCTYPE + ") SortBy" + v.VarName + "(" + v.VarType + ") *[]iter" + s.VarType + " # can not do this yet"
}
@@ -124,7 +125,7 @@ func (pb *Files) makeNewSortfile(pf *File) error {
fmt.Fprintf(wSort, "\n")
fmt.Fprintf(wSort, "// END SORT\n")
- // make Len()
+ // make Len() and Append()
for _, msg := range pf.allMsg() {
PARENT := msg.Name
LOCK := msg.Lockname
@@ -142,14 +143,14 @@ func (pb *Files) makeNewSortfile(pf *File) error {
}
if PARENT == VARNAME {
// FUNCNAME := "Append"
- msg.simpleAppend(wSort, PARENT, v.VarName, v.VarType)
+ funcdef := msg.simpleAppend(wSort, PARENT, v.VarName, v.VarType)
+ log.Printf("Adding %s\n", funcdef)
// funcdef := msg.addAppendBy(wSort, PARENT, FUNCNAME, VARNAME, PARENT, s.VarType)
// log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef)
}
}
}
}
- log.Printf("\n")
// add All()
for _, s := range pf.ToSort {
@@ -202,13 +203,14 @@ func (pb *Files) makeNewSortfile(pf *File) error {
if PARENT == VARNAME {
// special case because of the enforced .proto format
FUNCNAME = "FindBy" + v.VarName
+ funcdef := msg.generateFindBy(wSort, FUNCNAME, PARENT, VARNAME, s.VarType, v.VarName)
+ // func (msg *MsgName) generateFindBy(w io.Writer, FUNCNAME, STRUCT, VARNAME, VARTYPE, COLOR string) string {
+ log.Printf("Adding %s\n", funcdef)
} else {
+ // deprecate these
FUNCNAME = "Find" + VARNAME + "By" + v.VarName
}
- funcdef := msg.generateFindBy(wSort, FUNCNAME, PARENT, VARNAME, s.VarType, v.VarName)
- // func (msg *MsgName) generateFindBy(w io.Writer, FUNCNAME, STRUCT, VARNAME, VARTYPE, COLOR string) string {
- log.Printf("Adding %s\n", funcdef)
} else {
if v.VarType == "string" {
// probably dumb. move to a database if you need this
@@ -234,18 +236,19 @@ func (pb *Files) makeNewSortfile(pf *File) error {
COLOR := v.VarType
var FUNCNAME string
if PARENT == VARNAME {
- // special case because of the enforced .proto format
+ // special case because of the enforced .proto format // ONLY USE CASE THAT MAKES SENSE
FUNCNAME = "DeleteBy" + v.VarName
+ var funcdef string
+ if argv.Delete {
+ funcdef = msg.deleteByWithCopy(wSort, FRUIT, APPLES, APPLE, COLOR, FUNCNAME, v.VarName)
+ } else {
+ funcdef = msg.deleteBy(wSort, FRUIT, APPLES, APPLE, COLOR, FUNCNAME, v.VarName)
+ }
+ log.Printf("Adding %s\n", funcdef)
} else {
+ // deprecate these
FUNCNAME = "Delete" + VARNAME + "By" + v.VarName
}
- var funcdef string
- if argv.Delete {
- funcdef = msg.deleteByWithCopy(wSort, FRUIT, APPLES, APPLE, COLOR, FUNCNAME, v.VarName)
- } else {
- funcdef = msg.deleteBy(wSort, FRUIT, APPLES, APPLE, COLOR, FUNCNAME, v.VarName)
- }
- log.Printf("Adding %s\n", funcdef)
}
// AppendBy() functions. todo: fix these so Append() is for simple things and Insert() is for unique keys
@@ -260,12 +263,17 @@ func (pb *Files) makeNewSortfile(pf *File) error {
ucount += 1
var FUNCNAME string
if PARENT == VARNAME {
- // special case because of the enforced .proto format
+ // special case because of the enforced .proto format // ONLY SUPPORT THIS
FUNCNAME = "AppendBy" + v.VarName
- } else {
- FUNCNAME = "Append" + VARNAME + "By" + v.VarName
funcdef := msg.addAppendBy(wSort, PARENT, FUNCNAME, VARNAME, v.VarName, s.VarType)
log.Printf("Adding %s\n", funcdef)
+ } else {
+ // deprecate this
+ /*
+ FUNCNAME = "Append" + VARNAME + "By" + v.VarName
+ funcdef := msg.addAppendBy(wSort, PARENT, FUNCNAME, VARNAME, v.VarName, s.VarType)
+ log.Printf("Adding %s\n", funcdef)
+ */
}
}