Compare commits

..

2 Commits

Author SHA1 Message Date
Jeff Carr fabf425958 fixes for Width 2025-09-23 09:35:50 -05:00
Jeff Carr 08dc949873 compiles with new forgepb proto files 2025-09-23 07:43:08 -05:00
4 changed files with 13 additions and 86 deletions

View File

@ -179,8 +179,10 @@ func (pb *Files) makeNewSortfile(pf *File) error {
CHILD := s.VarType CHILD := s.VarType
VARNAME := s.VarName VARNAME := s.VarName
pmsg := pf.findMsg(s.MsgName) // log.Printf("TO SORT IterAll() PARENT==VARNAME? PARENT=%s CHILD=%s VARNAME=%s (%v)\n", PARENT, CHILD, VARNAME, pf.ToSort)
pmsg := pf.findMsg(PARENT)
if pmsg == nil { if pmsg == nil {
// log.Printf("FAILED TO ADD SORT pmsg=nil PARENT=%s CHILD=%s VARNAME=%s\n", PARENT, CHILD, VARNAME)
return fmt.Errorf("failed to find struct %s", s.MsgName) return fmt.Errorf("failed to find struct %s", s.MsgName)
} }
@ -192,6 +194,8 @@ func (pb *Files) makeNewSortfile(pf *File) error {
FRUIT := CHILD FRUIT := CHILD
funcdef = pmsg.addIterAll(wSort, FRUITS, FRUIT) funcdef = pmsg.addIterAll(wSort, FRUITS, FRUIT)
log.Printf("Adding %s\n", funcdef) log.Printf("Adding %s\n", funcdef)
} else {
// log.Printf("FAILED TO ADD SORT IterAll() PARENT != VARNAME PARENT=%s CHILD=%s VARNAME=%s\n", PARENT, CHILD, VARNAME)
} }
/* /*

View File

@ -241,6 +241,7 @@ func guiStringFuncs(w io.Writer, ZOOPB string, FRUITS string, FRUIT string) {
fmt.Fprintln(w, " r.Header = new(guipb.Widget)") fmt.Fprintln(w, " r.Header = new(guipb.Widget)")
fmt.Fprintln(w, " r.Header.Name = sf.title") fmt.Fprintln(w, " r.Header.Name = sf.title")
fmt.Fprintln(w, " r.Attr = proto.Clone(sf.attr).(*guipb.ColAttr)") fmt.Fprintln(w, " r.Attr = proto.Clone(sf.attr).(*guipb.ColAttr)")
fmt.Fprintln(w, " r.Attr.Width = int32(sf.Width)")
fmt.Fprintln(w, "") fmt.Fprintln(w, "")
fmt.Fprintln(w, " for m := range mt.x.IterAll() {") fmt.Fprintln(w, " for m := range mt.x.IterAll() {")

View File

@ -125,86 +125,3 @@ func (msg *MsgName) printMsg() {
log.Printf("\t%s %s %s\n", v.VarName, v.VarType, end) log.Printf("\t%s %s %s\n", v.VarName, v.VarType, end)
} }
} }
/*
func checkCmd(cmd string) {
// path, err := exec.LookPath(cmd)
_, err := exec.LookPath(cmd)
if err != nil {
// fmt.Printf("\n%s is not in the PATH\n", cmd)
userInstructions()
log.Sleep(2)
} else {
// fmt.Printf("%s is available at %s\n", cmd, path)
}
}
func (pf *File) noPluralMessage() {
base := cases.Title(language.English, cases.NoLower).String(pf.Filebase)
log.Info("")
log.Info("###########################################################################")
log.Info("Your proto file", pf.Filename, "does not contain the correct 'message' definitions")
log.Info("")
log.Info("For autogenpb to work on your file", pf.Filename, ", you must have both names exactly:")
log.Info("")
log.Printf("message %s {\n", base)
log.Info("}")
log.Printf("message %s {\n", base+"s")
log.Info("}")
log.Info("")
log.Info("###########################################################################")
badExit(fmt.Errorf("proto file error %s", pf.Filename))
}
*/
// message Fruits { // `autogenpb:marshal` `autogenpb:mutex`
// string uuid = 1; // `autogenpb:uuid:be926ad9-f07f-484c-adf2-d96eeabf3079`
// string version = 2; // `autogenpb:version:v0.0.1`
// repeated Fruit Fruits = 3; // THIS MUST BE "Fruit" and then "Fruit" + "s"
// }
/*
func (pf *File) noUuid() {
base := cases.Title(language.English, cases.NoLower).String(pf.Filebase)
id := uuid.New()
log.Info("")
log.Info("###########################################################################")
log.Info("Your proto file", pf.Filename, "is incorrect for 'message' ", base+"s")
log.Info("")
log.Info("For autogenpb to work on your file", pf.Filename, ",", base+"s must be exactly:")
log.Info("")
log.Info("message", base+"s", "{ // `autogenpb:marshal` `autogenpb:mutex`")
log.Info(" string uuid = 1; // `autogenpb:uuid:" + id.String() + "`")
log.Info(" string version = 2; // `autogenpb:version:v0.0.1`")
log.Info(" repeated", base, base+"s", " = 3; // THIS MUST BE ", base, " and then ", base+"s")
log.Info("}")
log.Info("")
log.Info("If you don't have a UUID, you can use the randomly generated one here")
log.Info("")
log.Info("###########################################################################")
badExit(fmt.Errorf("proto file error %s", pf.Filename))
}
func userNotes(result cmd.Status) error {
log.Info("protoc failed", result.Cmd, "with", result.Exit)
for _, line := range result.Stdout {
log.Info("STDOUT:", line)
}
for _, line := range result.Stderr {
log.Info("STDERR:", line)
}
userInstructions()
return fmt.Errorf("protoc failed with %d %v", result.Exit, result.Error)
}
func userInstructions() {
log.Info("This is likely because you don't have protoc and protoc-gen-go installed")
log.Info("")
log.Info("On debian, you can:")
log.Info(" apt install protobuf-compiler # for protoc")
log.Info(" apt install protoc-gen-go # for protoc-gen-go")
log.Info("")
}
*/

View File

@ -91,12 +91,12 @@ func (pf *File) protoParse() error {
} }
pf.makeSortTable() pf.makeSortTable()
// for i, s := range slices.Backward(pf.ToSort) {
return nil return nil
} }
func (pf *File) makeSortTable() { func (pf *File) makeSortTable() {
pf.sortWhat(pf.Bases) pf.sortWhat(pf.Bases)
// log.Info("TO SORT AFTER BASES:", pf.ToSort)
pf.sortWhat(pf.Base) pf.sortWhat(pf.Base)
// everything else // everything else
@ -165,8 +165,13 @@ func (pf *File) parseForMessage(line string) *MsgName {
base := cases.Title(language.English, cases.NoLower).String(pf.Filebase) base := cases.Title(language.English, cases.NoLower).String(pf.Filebase)
prefix := "message " + base + "s {" // only look for this for now prefix := "message " + base + "s {" // only look for this for now
prefixEnglishIsWeird := "message " + base + "es {" // only look for this for now
if strings.HasPrefix(line, prefix) { if strings.HasPrefix(line, prefix) {
pf.Bases = msg pf.Bases = msg
} else if strings.HasPrefix(line, prefixEnglishIsWeird) {
pf.Bases = msg
// panic("got here! :" + prefixEnglishIsWeird)
} else { } else {
prefix := "message " + base + " {" // only look for this for now prefix := "message " + base + " {" // only look for this for now
if strings.HasPrefix(line, prefix) { if strings.HasPrefix(line, prefix) {