summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--sort.go14
-rw-r--r--sortFunc.go75
3 files changed, 5 insertions, 86 deletions
diff --git a/Makefile b/Makefile
index c2830b7..35922e1 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
simple: build
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
@echo everything worked and the example ran
diff --git a/sort.go b/sort.go
index a63b067..90e7f5a 100644
--- a/sort.go
+++ b/sort.go
@@ -19,14 +19,6 @@ func (pb *Files) makeNewSortfile(pf *File) error {
defer wFind.Close()
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.iterNext(wSort)
@@ -45,7 +37,9 @@ func (pb *Files) makeNewSortfile(pf *File) error {
pf.findFunc(wFind)
*/
- pf.specialBases(wSort, wFind)
+ header(wFind, pf)
+ pf.syncLock(wFind)
+ pf.specialBases(wFind)
// attempt to add sort functions for pf.Base
if err := pf.processMessage(pf.Bases, wSort, wFind); err != nil {
@@ -57,7 +51,7 @@ func (pb *Files) makeNewSortfile(pf *File) error {
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 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)
diff --git a/sortFunc.go b/sortFunc.go
index 361462b..b3573a6 100644
--- a/sortFunc.go
+++ b/sortFunc.go
@@ -207,78 +207,3 @@ func (pf *File) replaceFunc(w io.Writer) {
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, "")
- }
-}