cleanup output
This commit is contained in:
parent
d38f5dda75
commit
4e0b3b8f38
83
generate.go
83
generate.go
|
@ -22,20 +22,14 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
fmt.Fprintf(wSort, "// START SORT\n")
|
fmt.Fprintf(wSort, "// START SORT\n")
|
||||||
fmt.Fprintf(wSort, "\n")
|
fmt.Fprintf(wSort, "\n")
|
||||||
|
|
||||||
log.Printf("START ITERATORS\n")
|
|
||||||
// add iterators for all the structs to be used
|
// add iterators for all the structs to be used
|
||||||
for i, msg := range pf.allMsg() {
|
for _, msg := range pf.allMsg() {
|
||||||
PARENT := msg.Name
|
|
||||||
LOCK := msg.Lockname
|
|
||||||
|
|
||||||
funcdef := newIter(wSort, msg)
|
funcdef := newIter(wSort, msg)
|
||||||
log.Printf("ITER: %-2d %20s %20s %20s %20s %s\n", i, PARENT, "", "", LOCK, funcdef)
|
log.Printf("%20s %s\n", "", funcdef)
|
||||||
}
|
}
|
||||||
log.Printf("END ITERATORS\n")
|
|
||||||
log.Printf("\n")
|
|
||||||
|
|
||||||
log.Printf("START COMPARE\n")
|
// log.Printf("START COMPARE\n")
|
||||||
for i, msg := range pf.allMsg() {
|
for _, msg := range pf.allMsg() {
|
||||||
PARENT := msg.Name
|
PARENT := msg.Name
|
||||||
for _, v := range msg.Vars {
|
for _, v := range msg.Vars {
|
||||||
if !v.HasSort {
|
if !v.HasSort {
|
||||||
|
@ -47,14 +41,12 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
}
|
}
|
||||||
VARNAME := v.VarName
|
VARNAME := v.VarName
|
||||||
funcdef := newSortType(wSort, PARENT, VARNAME)
|
funcdef := newSortType(wSort, PARENT, VARNAME)
|
||||||
log.Printf("TYPE: %-2d %20s %20s %20s %10s %s\n", i, PARENT, "", "", "", funcdef)
|
log.Printf("%20s %s\n", "", funcdef)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Printf("END COMPARE\n")
|
|
||||||
log.Printf("\n")
|
|
||||||
|
|
||||||
// add selectAll() functions for all the sort combinations that will be used
|
// add selectAll() functions for all the sort combinations that will be used
|
||||||
for i, s := range pf.ToSort {
|
for _, s := range pf.ToSort {
|
||||||
// log.Printf("SORT: %-2d %20s %20s %20s %20s\n", i, s.MsgName, s.VarType, s.VarName, s.Lockname)
|
// log.Printf("SORT: %-2d %20s %20s %20s %20s\n", i, s.MsgName, s.VarType, s.VarName, s.Lockname)
|
||||||
FRUIT := s.MsgName
|
FRUIT := s.MsgName
|
||||||
APPLE := s.VarType
|
APPLE := s.VarType
|
||||||
|
@ -67,14 +59,12 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
funcdef := msg.newIterAll(wSort, FRUIT, APPLE, APPLES, LOCK)
|
funcdef := msg.newIterAll(wSort, FRUIT, APPLE, APPLES, LOCK)
|
||||||
log.Printf("JUNK: %-2d %20s %20s %20s %20s %s\n", i, FRUIT, APPLE, "", LOCK, funcdef)
|
log.Printf("%20s %s\n", "", funcdef)
|
||||||
log.Printf("JUNK: %-2d %20s %20s %20s %20s %s\n", i, FRUIT, APPLE, "", LOCK, funcdef)
|
|
||||||
}
|
}
|
||||||
log.Printf("\n")
|
|
||||||
|
|
||||||
log.Printf("START SELECT\n")
|
// log.Printf("START SELECT\n")
|
||||||
// make the sort iterators selectAll()
|
// make the sort iterators selectAll()
|
||||||
for i, s := range pf.ToSort {
|
for _, s := range pf.ToSort {
|
||||||
PARENT := s.MsgName
|
PARENT := s.MsgName
|
||||||
CHILD := s.VarType
|
CHILD := s.VarType
|
||||||
VARNAME := s.VarName
|
VARNAME := s.VarName
|
||||||
|
@ -86,33 +76,22 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
funcdef := msg.addSelectAll(wSort, PARENT, CHILD, VARNAME, LOCK)
|
funcdef := msg.addSelectAll(wSort, PARENT, CHILD, VARNAME, LOCK)
|
||||||
log.Printf("SORT: %-2d %20s %20s %20s %20s %s\n", i, PARENT, CHILD, VARNAME, LOCK, funcdef)
|
log.Printf("%20s %s\n", "", funcdef)
|
||||||
}
|
}
|
||||||
log.Printf("END SELECT\n")
|
// log.Printf("END SELECT\n")
|
||||||
log.Printf("\n")
|
|
||||||
|
|
||||||
log.Printf("START SORT\n")
|
// log.Printf("START SORT\n")
|
||||||
// make the SortBy() functions
|
// make the SortBy() functions
|
||||||
for i, s := range pf.ToSort {
|
for _, s := range pf.ToSort {
|
||||||
// var funcname string
|
// var funcname string
|
||||||
PARENT := s.MsgName
|
PARENT := s.MsgName
|
||||||
CHILD := s.VarType
|
|
||||||
VARNAME := s.VarName
|
VARNAME := s.VarName
|
||||||
|
|
||||||
log.Printf("SORT: %-2d %20s %20s %20s %20s %s\n", i, PARENT, CHILD, VARNAME, "", "")
|
|
||||||
|
|
||||||
msg := pf.findMsg(s.VarType)
|
msg := pf.findMsg(s.VarType)
|
||||||
if msg == nil {
|
if msg == nil {
|
||||||
return fmt.Errorf("failed to find struct %s", s.VarType)
|
return fmt.Errorf("failed to find struct %s", s.VarType)
|
||||||
}
|
}
|
||||||
|
|
||||||
var FUNCTYPE string
|
|
||||||
if PARENT == VARNAME {
|
|
||||||
FUNCTYPE = PARENT
|
|
||||||
} else {
|
|
||||||
FUNCTYPE = VARNAME
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range msg.Vars {
|
for _, v := range msg.Vars {
|
||||||
if v.IsRepeated {
|
if v.IsRepeated {
|
||||||
// can't work against slices
|
// can't work against slices
|
||||||
|
@ -134,16 +113,13 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
sortname := s.VarType + v.VarName
|
sortname := s.VarType + v.VarName
|
||||||
selectName := "selectAll" + VARNAME
|
selectName := "selectAll" + VARNAME
|
||||||
funcdef := newSortBy(wSort, PARENT, s.VarType, sortname, sortby, selectName, v.VarName)
|
funcdef := newSortBy(wSort, PARENT, s.VarType, sortname, sortby, selectName, v.VarName)
|
||||||
log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "", "", funcdef)
|
log.Printf("%20s %s\n", "", funcdef)
|
||||||
} else {
|
} else {
|
||||||
funcname := "func (x *" + FUNCTYPE + ") SortBy" + v.VarName + "(" + v.VarType + ") *[]iter" + s.VarType + " # can not do this yet"
|
// funcdef := "func (x *" + FUNCTYPE + ") SortBy" + v.VarName + "(" + v.VarType + ") *[]iter" + s.VarType + " # can not do this yet"
|
||||||
log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "", "", funcname)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Printf("END SORT\n")
|
|
||||||
log.Printf("\n")
|
|
||||||
|
|
||||||
fmt.Fprintf(wSort, "\n")
|
fmt.Fprintf(wSort, "\n")
|
||||||
fmt.Fprintf(wSort, "// END SORT\n")
|
fmt.Fprintf(wSort, "// END SORT\n")
|
||||||
|
@ -153,9 +129,8 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
PARENT := msg.Name
|
PARENT := msg.Name
|
||||||
LOCK := msg.Lockname
|
LOCK := msg.Lockname
|
||||||
|
|
||||||
for i, v := range msg.Vars {
|
for _, v := range msg.Vars {
|
||||||
if v.IsRepeated {
|
if v.IsRepeated {
|
||||||
CHILD := v.VarType
|
|
||||||
VARNAME := v.VarName
|
VARNAME := v.VarName
|
||||||
// funcdef := "func (x *" + PARENT + ") Len" + VARNAME + "() int " + CHILD + " name:" + VARNAME
|
// funcdef := "func (x *" + PARENT + ") Len" + VARNAME + "() int " + CHILD + " name:" + VARNAME
|
||||||
|
|
||||||
|
@ -163,7 +138,7 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
// special case
|
// special case
|
||||||
funcdef := addLenFunc(wSort, PARENT, VARNAME, LOCK) // + " " + v.VarType + " name:" + v.VarName
|
funcdef := addLenFunc(wSort, PARENT, VARNAME, LOCK) // + " " + v.VarType + " name:" + v.VarName
|
||||||
funcdef += " # is special struct=varname"
|
funcdef += " # is special struct=varname"
|
||||||
log.Printf("LEN: %-2d %20s %20s %20s %20s %s\n", i, PARENT, CHILD, VARNAME, LOCK, funcdef)
|
log.Printf("%20s %s\n", "", funcdef)
|
||||||
}
|
}
|
||||||
if PARENT == VARNAME {
|
if PARENT == VARNAME {
|
||||||
// FUNCNAME := "Append"
|
// FUNCNAME := "Append"
|
||||||
|
@ -184,7 +159,7 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
|
|
||||||
if PARENT == VARNAME {
|
if PARENT == VARNAME {
|
||||||
funcdef := addAllFunc(wSort, PARENT, CHILD, VARNAME)
|
funcdef := addAllFunc(wSort, PARENT, CHILD, VARNAME)
|
||||||
log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef)
|
log.Printf("%20s %s\n", "", funcdef)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -206,15 +181,9 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add Find() Delete() Append() Insert()
|
// add Find() Delete() Append() Insert()
|
||||||
log.Printf(" %-2s %20s %20s %20s %20s\n", "", "PARENT STRUCT", "VAR STRUCT TYPE", "VAR NAME", "LOCK")
|
for _, s := range pf.ToSort {
|
||||||
for i, s := range pf.ToSort {
|
|
||||||
var funcname string
|
|
||||||
PARENT := s.MsgName
|
PARENT := s.MsgName
|
||||||
CHILD := s.VarType
|
|
||||||
VARNAME := s.VarName
|
VARNAME := s.VarName
|
||||||
LOCK := s.Lockname
|
|
||||||
|
|
||||||
log.Printf("SORT: %-2d %20s %20s %20s %20s %s\n", i, PARENT, CHILD, VARNAME, LOCK, "")
|
|
||||||
|
|
||||||
msg := pf.findMsg(s.VarType)
|
msg := pf.findMsg(s.VarType)
|
||||||
if msg == nil {
|
if msg == nil {
|
||||||
|
@ -239,7 +208,7 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
|
|
||||||
funcdef := msg.generateFindBy(wSort, FUNCNAME, PARENT, VARNAME, s.VarType, 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 {
|
// func (msg *MsgName) generateFindBy(w io.Writer, FUNCNAME, STRUCT, VARNAME, VARTYPE, COLOR string) string {
|
||||||
log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef)
|
log.Printf("%20s %s\n", "", funcdef)
|
||||||
} else {
|
} else {
|
||||||
if v.VarType == "string" {
|
if v.VarType == "string" {
|
||||||
// probably dumb. move to a database if you need this
|
// probably dumb. move to a database if you need this
|
||||||
|
@ -276,7 +245,7 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
} else {
|
} else {
|
||||||
funcdef = msg.deleteBy(wSort, FRUIT, APPLES, APPLE, COLOR, FUNCNAME, v.VarName)
|
funcdef = msg.deleteBy(wSort, FRUIT, APPLES, APPLE, COLOR, FUNCNAME, v.VarName)
|
||||||
}
|
}
|
||||||
log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef)
|
log.Printf("%20s %s\n", "", funcdef)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendBy() functions. todo: fix these so Append() is for simple things and Insert() is for unique keys
|
// AppendBy() functions. todo: fix these so Append() is for simple things and Insert() is for unique keys
|
||||||
|
@ -296,7 +265,7 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
} else {
|
} else {
|
||||||
FUNCNAME = "Append" + VARNAME + "By" + v.VarName
|
FUNCNAME = "Append" + VARNAME + "By" + v.VarName
|
||||||
funcdef := msg.addAppendBy(wSort, PARENT, FUNCNAME, VARNAME, v.VarName, s.VarType)
|
funcdef := msg.addAppendBy(wSort, PARENT, FUNCNAME, VARNAME, v.VarName, s.VarType)
|
||||||
log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef)
|
log.Printf("%20s %s\n", "", funcdef)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,13 +275,13 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
if !v.HasUnique {
|
if !v.HasUnique {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
funcname = "func (x *" + PARENT + ") Insert(a *" + v.VarType + ") (*" + CHILD + ", isNew bool) // todo"
|
//funcname = "func (x *" + PARENT + ") Insert(a *" + v.VarType + ") (*" + CHILD + ", isNew bool) // todo"
|
||||||
log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "", "", funcname)
|
//log.Printf("%20s %s\n", "", funcdef)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ucount > 1 {
|
if ucount > 1 {
|
||||||
funcname = "func (x *" + PARENT + ") Insert(a *" + CHILD + ") (*" + CHILD + ", isNew bool) // todo"
|
//funcname = "func (x *" + PARENT + ") Insert(a *" + CHILD + ") (*" + CHILD + ", isNew bool) // todo"
|
||||||
log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "", "", funcname)
|
//log.Printf("%20s %s\n", "", funcdef)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
5
main.go
5
main.go
|
@ -88,11 +88,10 @@ func main() {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// show the protobuf of the protobuf. It's like Inception
|
|
||||||
pf.printMsgTable()
|
|
||||||
|
|
||||||
// if you have gotten here, at least the .proto buf file is OK
|
// if you have gotten here, at least the .proto buf file is OK
|
||||||
if argv.DryRun {
|
if argv.DryRun {
|
||||||
|
// show the protobuf of the protobuf. It's like Inception
|
||||||
|
pf.printMsgTable()
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue