diff options
| -rw-r--r-- | example/fruit.proto | 1 | ||||
| -rw-r--r-- | file.proto | 1 | ||||
| -rw-r--r-- | generateHeader.go | 3 | ||||
| -rw-r--r-- | protoParse.go | 5 |
4 files changed, 10 insertions, 0 deletions
diff --git a/example/fruit.proto b/example/fruit.proto index f7b8f7d..2f2c908 100644 --- a/example/fruit.proto +++ b/example/fruit.proto @@ -74,4 +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() } @@ -105,6 +105,7 @@ message File { // `autogenpb:var:w io.Wri string goPath = 13; // the version to use in a func NewMsgName() bool doGui = 14; // if a gui.pb.go file should be created bool doHTTP = 15; // http.pb.go + bool doSave = 16; // generate autosave functions (in marshal.go ?) } // I know, I know, the whole point of using protobuf // is so you don't need a uuid or versions because it's diff --git a/generateHeader.go b/generateHeader.go index 4f2b4b6..60d08e7 100644 --- a/generateHeader.go +++ b/generateHeader.go @@ -77,6 +77,9 @@ func (pf *File) addNewFunc(w io.Writer) { 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, " return x") fmt.Fprintln(w, "}") } diff --git a/protoParse.go b/protoParse.go index 33951d2..c8ac75c 100644 --- a/protoParse.go +++ b/protoParse.go @@ -204,6 +204,11 @@ func (pf *File) parseForMessage(line string) *MsgName { msg.DoHTTP = true 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 |
