diff options
| author | Jeff Carr <[email protected]> | 2025-10-06 23:38:56 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-06 23:38:56 -0500 |
| commit | 6753f190dfdbef8606aea0d1abedf47f089eb49b (patch) | |
| tree | 3102dc6a6dfba980e8df59e2c06d814e9e9426c3 | |
| parent | d8ce54edfbc84d6880f06373b226976a1e702090 (diff) | |
s/save/sort duh
| -rw-r--r-- | example/fruit.proto | 2 | ||||
| -rw-r--r-- | generateHeader.go | 18 | ||||
| -rw-r--r-- | protoParse.go | 8 |
3 files changed, 15 insertions, 13 deletions
diff --git a/example/fruit.proto b/example/fruit.proto index 2f2c908..7cc3f94 100644 --- a/example/fruit.proto +++ b/example/fruit.proto @@ -74,5 +74,5 @@ message Fruits { // `autogenpb:marshal` ` repeated Fruit Fruits = 3; // THIS MUST BE "Fruit" and then "Fruit" + "s" int64 cost = 4; // you can add additional things here but the three lines above must conform to the standard above map<string, string> junk = 5; - string filename = 6; // `autogenpb:sort` -- this enables autogenerated pb.Load() and pb.Save() + string filename = 6; // `autogenpb:save` -- this enables autogenerated pb.Load() and pb.Save() } diff --git a/generateHeader.go b/generateHeader.go index 60d08e7..0a6ae43 100644 --- a/generateHeader.go +++ b/generateHeader.go @@ -50,10 +50,10 @@ func header(w io.Writer, pf *File) { fmt.Fprintln(w, "") } -func (pf *File) addNewFunc(w io.Writer) { - var STRUCT string = pf.Bases.Name - var UUID string = pf.Uuid - var VERSION string = pf.Version +func (pb *File) addNewFunc(w io.Writer) { + var STRUCT string = pb.Bases.Name + var UUID string = pb.Uuid + var VERSION string = pb.Version if UUID == "" { log.Info("error: UUID == ''") os.Exit(-1) @@ -70,15 +70,17 @@ func (pf *File) addNewFunc(w io.Writer) { fmt.Fprintln(w, " return") fmt.Fprintln(w, " }") fmt.Fprintln(w, " x.Uuid = \""+UUID+"\"") - fmt.Fprintln(w, " x.Version = \""+VERSION+" "+pf.GoPath+"\"") + fmt.Fprintln(w, " x.Version = \""+VERSION+" "+pb.GoPath+"\"") fmt.Fprintln(w, "}") fmt.Fprintln(w, "") fmt.Fprintln(w, "func New"+STRUCT+"() *"+STRUCT+"{") fmt.Fprintln(w, " x := new("+STRUCT+")") fmt.Fprintln(w, " x.Uuid = \""+UUID+"\"") - fmt.Fprintln(w, " x.Version = \""+VERSION+" "+pf.GoPath+"\"") - if pf.DoSave { - fmt.Fprintln(w, " // x.Filename = \""+VERSION+" "+pf.GoPath+"\"") + fmt.Fprintln(w, " x.Version = \""+VERSION+" "+pb.GoPath+"\"") + if pb.DoSave { + fmt.Fprintln(w, " // x.Filename = \""+VERSION+" "+pb.GoPath+"\"") + } else { + fmt.Fprintln(w, " // wasn't here x.Filename = \""+VERSION+" "+pb.GoPath+"\"") } fmt.Fprintln(w, " return x") fmt.Fprintln(w, "}") diff --git a/protoParse.go b/protoParse.go index c8ac75c..e09bbc3 100644 --- a/protoParse.go +++ b/protoParse.go @@ -87,6 +87,10 @@ func (pf *File) protoParse() error { curmsg.Unique = append(curmsg.Unique, newU) msgvar.HasUnique = true } + if strings.Contains(line, "`autogenpb:save") { + pf.DoSave = true + } + curmsg.Vars = append(curmsg.Vars, msgvar) } pf.makeSortTable() @@ -205,10 +209,6 @@ func (pf *File) parseForMessage(line string) *MsgName { msg.DoMarshal = true // http requires Marshal } - if strings.Contains(line, "`autogenpb:autosave") { - pf.DoSave = true - } - if strings.Contains(line, "`autogenpb:gui") { log.Info("got autogenpb:gui") pf.DoGui = true |
