start dumping the old code
This commit is contained in:
parent
76968c90e8
commit
74641713f8
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
||||||
|
|
||||||
simple: build
|
simple: build
|
||||||
make -C example clean simpleMutexGlobal goimports vet
|
make -C example clean simpleMutexGlobal goimports vet
|
||||||
# make -C example clean simpleMutexProtoc goimports vet
|
make -C example clean simpleMutexProtoc goimports vet
|
||||||
|
|
||||||
full: install clean auto goimports vet build test install
|
full: install clean auto goimports vet build test install
|
||||||
@echo everything worked and the example ran
|
@echo everything worked and the example ran
|
||||||
|
|
14
sort.go
14
sort.go
|
@ -19,14 +19,6 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
defer wFind.Close()
|
defer wFind.Close()
|
||||||
|
|
||||||
header(wSort, pf)
|
header(wSort, pf)
|
||||||
header(wFind, pf)
|
|
||||||
|
|
||||||
pf.syncLock(wSort)
|
|
||||||
|
|
||||||
// if argv.Mutex {
|
|
||||||
// // use the mutex lock from the modified protoc.pb.go file
|
|
||||||
// pf.Bases.Lockname = "all.Lock"
|
|
||||||
// }
|
|
||||||
|
|
||||||
pf.Base.iterTop(wSort)
|
pf.Base.iterTop(wSort)
|
||||||
pf.Base.iterNext(wSort)
|
pf.Base.iterNext(wSort)
|
||||||
|
@ -45,7 +37,9 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
pf.findFunc(wFind)
|
pf.findFunc(wFind)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pf.specialBases(wSort, wFind)
|
header(wFind, pf)
|
||||||
|
pf.syncLock(wFind)
|
||||||
|
pf.specialBases(wFind)
|
||||||
|
|
||||||
// attempt to add sort functions for pf.Base
|
// attempt to add sort functions for pf.Base
|
||||||
if err := pf.processMessage(pf.Bases, wSort, wFind); err != nil {
|
if err := pf.processMessage(pf.Bases, wSort, wFind); err != nil {
|
||||||
|
@ -57,7 +51,7 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pf *File) specialBases(wSort, wFind io.Writer) {
|
func (pf *File) specialBases(wFind io.Writer) {
|
||||||
var FRUIT string = cases.Title(language.English, cases.NoLower).String(pf.Bases.Name)
|
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 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)
|
var APPLE string = cases.Title(language.English, cases.NoLower).String(pf.Base.Name)
|
||||||
|
|
75
sortFunc.go
75
sortFunc.go
|
@ -207,78 +207,3 @@ func (pf *File) replaceFunc(w io.Writer) {
|
||||||
fmt.Fprintln(w, "")
|
fmt.Fprintln(w, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pf *File) deleteFunc(w io.Writer) {
|
|
||||||
var MSG string = pf.Bases.Name
|
|
||||||
var LOCK string = pf.Bases.Lockname
|
|
||||||
|
|
||||||
for _, KEY := range pf.Base.Unique {
|
|
||||||
fmt.Fprintln(w, "func (all *"+MSG+") DeleteBy"+KEY+"(s string) bool {")
|
|
||||||
fmt.Fprintln(w, " "+LOCK+".RLock()")
|
|
||||||
fmt.Fprintln(w, " defer "+LOCK+".RUnlock()")
|
|
||||||
fmt.Fprintln(w, "")
|
|
||||||
fmt.Fprintln(w, " for i, _ := range all."+MSG+" {")
|
|
||||||
fmt.Fprintln(w, " if all."+MSG+"[i]."+KEY+" == s {")
|
|
||||||
fmt.Fprintln(w, " all."+MSG+"[i] = all."+MSG+"[len(all."+MSG+")-1]")
|
|
||||||
fmt.Fprintln(w, " all."+MSG+" = all."+MSG+"[:len(all."+MSG+")-1]")
|
|
||||||
fmt.Fprintln(w, " return true")
|
|
||||||
fmt.Fprintln(w, " }")
|
|
||||||
fmt.Fprintln(w, " }")
|
|
||||||
fmt.Fprintln(w, " return false")
|
|
||||||
fmt.Fprintln(w, "}")
|
|
||||||
fmt.Fprintln(w, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// this tries to return the deleted one but is wrong/gives warning if mutex lock is in struct
|
|
||||||
func (pf *File) deleteWithCopyFunc(w io.Writer) {
|
|
||||||
var MSG string = pf.Bases.Name
|
|
||||||
var BASE string = pf.Base.Name
|
|
||||||
var LOCK string = pf.Bases.Lockname
|
|
||||||
|
|
||||||
for _, KEY := range pf.Base.Unique {
|
|
||||||
fmt.Fprintln(w, "func (all *"+MSG+") DeleteBy"+KEY+"(s string) *"+BASE+" {")
|
|
||||||
fmt.Fprintln(w, " "+LOCK+".RLock()")
|
|
||||||
fmt.Fprintln(w, " defer "+LOCK+".RUnlock()")
|
|
||||||
fmt.Fprintln(w, "")
|
|
||||||
fmt.Fprintln(w, " var newr "+BASE)
|
|
||||||
fmt.Fprintln(w, "")
|
|
||||||
fmt.Fprintln(w, " for i, _ := range all."+MSG+" {")
|
|
||||||
fmt.Fprintln(w, " if all."+MSG+"[i]."+KEY+" == s {")
|
|
||||||
fmt.Fprintln(w, " newr = *all."+MSG+"[i]")
|
|
||||||
fmt.Fprintln(w, " all."+MSG+"[i] = all."+MSG+"[len(all."+MSG+")-1]")
|
|
||||||
fmt.Fprintln(w, " all."+MSG+" = all."+MSG+"[:len(all."+MSG+")-1]")
|
|
||||||
fmt.Fprintln(w, " return &newr")
|
|
||||||
fmt.Fprintln(w, " }")
|
|
||||||
fmt.Fprintln(w, " }")
|
|
||||||
fmt.Fprintln(w, " return nil")
|
|
||||||
fmt.Fprintln(w, "}")
|
|
||||||
fmt.Fprintln(w, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pf *File) findFunc(w io.Writer) {
|
|
||||||
var MSG string = pf.Bases.Name
|
|
||||||
var BASE string = pf.Base.Name
|
|
||||||
var LOCK string = pf.Bases.Lockname
|
|
||||||
|
|
||||||
for _, KEY := range pf.Base.Unique {
|
|
||||||
fmt.Fprintln(w, "// find a dependancy by the go path")
|
|
||||||
fmt.Fprintln(w, "func (all *"+MSG+") FindBy"+KEY+"(s string) *"+BASE+" {")
|
|
||||||
fmt.Fprintln(w, " if all == nil {")
|
|
||||||
fmt.Fprintln(w, " return nil")
|
|
||||||
fmt.Fprintln(w, " }")
|
|
||||||
fmt.Fprintln(w, "")
|
|
||||||
fmt.Fprintln(w, " "+LOCK+".RLock()")
|
|
||||||
fmt.Fprintln(w, " defer "+LOCK+".RUnlock()")
|
|
||||||
fmt.Fprintln(w, "")
|
|
||||||
fmt.Fprintln(w, " for i, _ := range all."+MSG+" {")
|
|
||||||
fmt.Fprintln(w, " if all."+MSG+"[i]."+KEY+" == s {")
|
|
||||||
fmt.Fprintln(w, " return all."+MSG+"[i]")
|
|
||||||
fmt.Fprintln(w, " }")
|
|
||||||
fmt.Fprintln(w, " }")
|
|
||||||
fmt.Fprintln(w, " return nil")
|
|
||||||
fmt.Fprintln(w, "}")
|
|
||||||
fmt.Fprintln(w, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue