summaryrefslogtreecommitdiff
path: root/generateGui.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-15 03:50:46 -0500
committerJeff Carr <[email protected]>2025-09-15 03:50:46 -0500
commit66aacceee5bdc3a5b6e90ff39ce8fcb7dd55e973 (patch)
tree6847ac872df9fd274f64c8f09fb8230cc5f29ff4 /generateGui.go
parent086329f1db3643cfd976c61eadef7b11962f5a61 (diff)
continue work to move to 'any' in GUI PB table
Diffstat (limited to 'generateGui.go')
-rw-r--r--generateGui.go24
1 files changed, 18 insertions, 6 deletions
diff --git a/generateGui.go b/generateGui.go
index 6c8121f..74403ca 100644
--- a/generateGui.go
+++ b/generateGui.go
@@ -141,6 +141,7 @@ func headerGui(w io.Writer, pf *File) {
fmt.Fprintln(w, " \"go.wit.com/gui\"")
fmt.Fprintln(w, " \"go.wit.com/lib/protobuf/guipb\"")
fmt.Fprintln(w, " \"go.wit.com/log\"")
+ fmt.Fprintln(w, " anypb \"google.golang.org/protobuf/types/known/anypb\"")
fmt.Fprintln(w, " timestamppb \"google.golang.org/protobuf/types/known/timestamppb\"")
fmt.Fprintln(w, ")")
fmt.Fprintln(w, "")
@@ -262,15 +263,26 @@ func guiMain(w io.Writer, FRUITS string, FRUIT string) {
fmt.Fprintln(w, " Width int")
fmt.Fprintln(w, "}")
fmt.Fprintln(w, "")
+ fmt.Fprintln(w, "type "+FRUIT+"AnyFunc struct {")
+ fmt.Fprintln(w, " title string")
+ fmt.Fprintln(w, " f func(*"+FRUIT+") any")
+ fmt.Fprintln(w, " Custom func(*"+FRUIT+")")
+ fmt.Fprintln(w, " order int")
+ fmt.Fprintln(w, " Width int")
+ fmt.Fprintln(w, "}")
+ fmt.Fprintln(w, "")
fmt.Fprintln(w, "type "+FRUITS+"Table struct {")
fmt.Fprintln(w, " pb *guipb.Table")
fmt.Fprintln(w, " parent *gui.Node")
fmt.Fprintln(w, " x *"+FRUITS+"")
fmt.Fprintln(w, " hostnames []string")
+ fmt.Fprintln(w, "")
fmt.Fprintln(w, " stringFuncs []*"+FRUIT+"StringFunc")
fmt.Fprintln(w, " intFuncs []*"+FRUIT+"IntFunc")
fmt.Fprintln(w, " timeFuncs []*"+FRUIT+"TimeFunc")
fmt.Fprintln(w, " buttonFuncs []*"+FRUIT+"ButtonFunc")
+ fmt.Fprintln(w, " anyFuncs []*"+FRUIT+"AnyFunc")
+ fmt.Fprintln(w, "")
fmt.Fprintln(w, " CustomFunc func(*"+FRUIT+")")
fmt.Fprintln(w, " order int")
fmt.Fprintln(w, "}")
@@ -352,8 +364,7 @@ func guiStringFuncs(w io.Writer, ZOOPB string, FRUITS string, FRUIT string) {
fmt.Fprintln(w, " if sf.title != name {")
fmt.Fprintln(w, " continue")
fmt.Fprintln(w, " }")
- fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": found timefunc name:\", name)")
- fmt.Fprintln(w, " r := new(guipb.TimeCol)")
+ fmt.Fprintln(w, " r := new(guipb.AnyCol)")
fmt.Fprintln(w, " r.Header = new(guipb.Widget)")
fmt.Fprintln(w, " r.Header.Name = name")
fmt.Fprintln(w, " r.Attr = new(guipb.ColAttr)")
@@ -362,10 +373,12 @@ func guiStringFuncs(w io.Writer, ZOOPB string, FRUITS string, FRUIT string) {
fmt.Fprintln(w, "")
fmt.Fprintln(w, " for m := range mt.x.IterAll() {")
fmt.Fprintln(w, " t := sf.f(m)")
- fmt.Fprintln(w, " r.Vals = append(r.Vals, timestamppb.New(t)) // convert to protobuf time")
- fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": adding\", name, r.Vals)")
+ fmt.Fprintln(w, " tsProto := timestamppb.New(t)")
+ fmt.Fprintln(w, " anyProto, err := anypb.New(tsProto)")
+ fmt.Fprintln(w, " _ = err // do something with err someday (?)")
+ fmt.Fprintln(w, " r.Vals = append(r.Vals, anyProto)")
fmt.Fprintln(w, " }")
- fmt.Fprintln(w, " mt.pb.TimeCols = append(mt.pb.TimeCols, r)")
+ fmt.Fprintln(w, " mt.pb.AnyCols = append(mt.pb.AnyCols, r)")
fmt.Fprintln(w, " return true")
fmt.Fprintln(w, " }")
fmt.Fprintln(w, " return false")
@@ -373,7 +386,6 @@ func guiStringFuncs(w io.Writer, ZOOPB string, FRUITS string, FRUIT string) {
fmt.Fprintln(w, "")
fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) MakeTable() {")
fmt.Fprintln(w, " for _, name := range mt.pb.Order {")
- fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": looking for row name()\", name)")
fmt.Fprintln(w, " if mt.doStringFunc(name) {")
fmt.Fprintln(w, " continue")
fmt.Fprintln(w, " }")