summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go4
-rw-r--r--generateSort.go4
-rw-r--r--protoReformat.go25
3 files changed, 19 insertions, 14 deletions
diff --git a/argv.go b/argv.go
index 76cef67..b85be17 100644
--- a/argv.go
+++ b/argv.go
@@ -26,7 +26,7 @@ type args struct {
}
func (a args) Description() string {
- return "autogenpb " + VERSION + " Built on " + BUILDTIME + `
+ return "go.wit.com/apps/autogenpb " + VERSION + " Built on " + BUILDTIME + `
Auto Generate protocol buffer Sort() and Marshal() functions
@@ -38,5 +38,5 @@ See the git sources for an example .proto file.
}
func (args) Version() string {
- return "autogenpb " + VERSION + " Built on " + BUILDTIME
+ return "go.wit.com/apps/autogenpb " + VERSION + " Built on " + BUILDTIME
}
diff --git a/generateSort.go b/generateSort.go
index a9d5259..4692884 100644
--- a/generateSort.go
+++ b/generateSort.go
@@ -51,7 +51,7 @@ func newIter(w io.Writer, msg *MsgName) string {
fmt.Fprintln(w, "}")
fmt.Fprintln(w, "")
fmt.Fprintln(w, "type "+APPLE+"Iterator struct {")
- fmt.Fprintln(w, " sync.RWMutex // this isn't getting used properly yet?")
+ fmt.Fprintln(w, " sync.Mutex")
fmt.Fprintln(w, "")
fmt.Fprintln(w, " things []*"+APPLE+"")
fmt.Fprintln(w, " index int")
@@ -61,7 +61,9 @@ func newIter(w io.Writer, msg *MsgName) string {
fmt.Fprintln(w, " if it.index >= len(it.things) {")
fmt.Fprintln(w, " return false")
fmt.Fprintln(w, " }")
+ fmt.Fprintln(w, " it.Lock()")
fmt.Fprintln(w, " it.index++")
+ fmt.Fprintln(w, " it.Unlock()")
fmt.Fprintln(w, " return true")
fmt.Fprintln(w, "}")
fmt.Fprintln(w, "")
diff --git a/protoReformat.go b/protoReformat.go
index 44426aa..98f9c86 100644
--- a/protoReformat.go
+++ b/protoReformat.go
@@ -14,8 +14,8 @@ import (
// like 'goimport' but for .proto files
-var maxVarname int
-var maxVartype int
+// var maxVarname int
+// var maxVartype int
var linesIter iter.Seq[string]
func protoReformat(filename string) error {
@@ -46,7 +46,6 @@ func protoReformat(filename string) error {
// find the end of the message
if strings.HasPrefix(line, "}") {
inMessage = false
- // formatMessage(curmsg)
formatMessage2(fmtmsg)
if bigName < fmtmsg.MaxVarname {
bigName = fmtmsg.MaxVarname
@@ -65,12 +64,11 @@ func protoReformat(filename string) error {
fmtmsg.Lines = append(fmtmsg.Lines, line)
}
- maxVarname = int(bigName)
- maxVartype = int(bigType)
-
- var curmsg []string
+ fmtmsg = new(FormatMsg)
+ fmtmsg.MaxVarname = bigName
+ fmtmsg.MaxVartype = bigType
- // gets the max vartype and varname
+ // write out the messages
for line := range linesIter {
if strings.HasPrefix(line, "message ") {
if inMessage {
@@ -95,11 +93,13 @@ func protoReformat(filename string) error {
if strings.HasPrefix(line, "}") {
inMessage = false
// format and write the last message to the file
- for _, newline := range formatMessage(curmsg) {
+ for _, newline := range formatMessage2(fmtmsg) {
newfile += fmt.Sprintln(newline)
}
newfile += fmt.Sprintln(line)
- curmsg = nil
+ fmtmsg = new(FormatMsg)
+ fmtmsg.MaxVarname = bigName
+ fmtmsg.MaxVartype = bigType
continue
}
@@ -108,7 +108,8 @@ func protoReformat(filename string) error {
newfile += fmt.Sprintln(line)
continue
}
- curmsg = append(curmsg, line)
+
+ fmtmsg.Lines = append(fmtmsg.Lines, line)
}
pf, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
@@ -124,6 +125,7 @@ func protoReformat(filename string) error {
return nil
}
+/*
func formatMessage(curmsg []string) []string {
var newmsg []string
@@ -172,6 +174,7 @@ func formatMessage(curmsg []string) []string {
}
return newmsg
}
+*/
// returns vartype, varname, id, end
func tokenMsgVar(line string) (string, string, string, string) {