From e442197b2e87c12813b697e3362c59860216eb12 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 8 Feb 2025 21:33:44 -0600 Subject: [PATCH] Notes removed by 'git notes remove' --- cbaa1c37132e73d4fd112418a7544ae71b46dfe0 | 1241 ---------------------- 1 file changed, 1241 deletions(-) delete mode 100644 cbaa1c37132e73d4fd112418a7544ae71b46dfe0 diff --git a/cbaa1c37132e73d4fd112418a7544ae71b46dfe0 b/cbaa1c37132e73d4fd112418a7544ae71b46dfe0 deleted file mode 100644 index ef72a91..0000000 --- a/cbaa1c37132e73d4fd112418a7544ae71b46dfe0 +++ /dev/null @@ -1,1241 +0,0 @@ -// `autogen:go.mod` - -module go.wit.com/toolkits/tree - -go 1.22 - -toolchain go1.23.4 - -require ( - go.wit.com/log v0.22.11 - go.wit.com/widget v1.1.28 - google.golang.org/protobuf v1.36.5 -) - -// `autogen:go.sum` - -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -go.wit.com/log v0.22.11 h1:BiJe+S81kWrMqW1QyZVu1Es2d//WG9FAcZQEhZkkM4c= -go.wit.com/log v0.22.11/go.mod h1:LsP0nAH4hZEf2qj/F5UmGQT0OEJ3Q5698/P8ZOI2JuE= -go.wit.com/widget v1.1.28 h1:xBrJBJ/5qGXTRE2uyOEcCV+6xAq8+3kBgqsJc1kqkiM= -go.wit.com/widget v1.1.28/go.mod h1:9P1d7NRtyFwEkMS3ccpTEyRqZaFnScbWvE4MB5ooeZI= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= -google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= - -// `autogen:toolkitConfig.marshal.pb.go` - -// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. -// This file was autogenerated with autogenpb v0.0.50 2025-02-07_18:46:58_UTC -// go install go.wit.com/apps/autogenpb@latest -// -// define which structs (messages) you want to use in the .proto file -// Then sort.pb.go and marshal.pb.go files are autogenerated -// -// autogenpb uses it and has an example .proto file with instructions -// - -package tree - -import ( - "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/encoding/prototext" - "google.golang.org/protobuf/proto" -) - -// human readable JSON -func (v *ToolkitConfigs) FormatJSON() string { - return protojson.Format(v) -} - -// marshal json -func (v *ToolkitConfigs) MarshalJSON() ([]byte, error) { - return protojson.Marshal(v) -} - -// unmarshal json -func (v *ToolkitConfigs) UnmarshalJSON(data []byte) error { - return protojson.Unmarshal(data, v) -} - -// apparently this isn't stable, but it's awesomely better -// https://protobuf.dev/reference/go/faq/#unstable-text -// it's brilliant for config files! -func (v *ToolkitConfigs) FormatTEXT() string { - v.fixUuid() - return prototext.Format(v) -} - -// unmarshalTEXT. This reads the .text config file back in after the user edits it -func (v *ToolkitConfigs) UnmarshalTEXT(data []byte) error { - return prototext.Unmarshal(data, v) -} - -// marshal to wire. This is called winning. -func (v *ToolkitConfigs) Marshal() ([]byte, error) { - v.fixUuid() - return proto.Marshal(v) -} - -// unmarshal from wire. You have won. -func (v *ToolkitConfigs) Unmarshal(data []byte) error { - return proto.Unmarshal(data, v) -} - -// `autogen:toolkitConfig.pb.go` - -// Code modified by go.wit.com/apps/autogenpb DO NOT EDIT. -// -// user defined Mutex locks were auto added -// -// autogenpb version & build time: v0.0.50 2025-02-07_18:46:58_UTC -// autogenpb auto generates Sort(), Unique() and Marshal() functions -// go install go.wit.com/apps/autogenpb@latest - -// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.35.2-devel -// protoc v3.21.12 -// source: toolkitConfig.proto - -package tree // autogenpb changed the package name - -import ( - reflect "reflect" - sync "sync" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - _ "google.golang.org/protobuf/types/known/timestamppb" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ToolkitConfig struct { - sync.RWMutex // auto-added by go.wit.com/apps/autogenpb - - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Plugin string `protobuf:"bytes,1,opt,name=plugin,proto3" json:"plugin,omitempty"` // 'gocui', 'andlabs', etc - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // variable name 'fullscreen' - Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` // value "true" -} - -func (x *ToolkitConfig) Reset() { - *x = ToolkitConfig{} - mi := &file_toolkitConfig_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ToolkitConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ToolkitConfig) ProtoMessage() {} - -func (x *ToolkitConfig) ProtoReflect() protoreflect.Message { - mi := &file_toolkitConfig_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ToolkitConfig.ProtoReflect.Descriptor instead. -func (*ToolkitConfig) Descriptor() ([]byte, []int) { - return file_toolkitConfig_proto_rawDescGZIP(), []int{0} -} - -func (x *ToolkitConfig) GetPlugin() string { - if x != nil { - return x.Plugin - } - return "" -} - -func (x *ToolkitConfig) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *ToolkitConfig) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -type ToolkitConfigs struct { - // sync.RWMutex // skipped. protobuf file has `autogenpb:nomutex` - - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // `autogenpb:uuid:d7886d47-a3b9-43b9-b0f6-17074a9844e6` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // `autogenpb:version:v0.0.1` - ToolkitConfigs []*ToolkitConfig `protobuf:"bytes,3,rep,name=ToolkitConfigs,proto3" json:"ToolkitConfigs,omitempty"` -} - -func (x *ToolkitConfigs) Reset() { - *x = ToolkitConfigs{} - mi := &file_toolkitConfig_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ToolkitConfigs) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ToolkitConfigs) ProtoMessage() {} - -func (x *ToolkitConfigs) ProtoReflect() protoreflect.Message { - mi := &file_toolkitConfig_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ToolkitConfigs.ProtoReflect.Descriptor instead. -func (*ToolkitConfigs) Descriptor() ([]byte, []int) { - return file_toolkitConfig_proto_rawDescGZIP(), []int{1} -} - -func (x *ToolkitConfigs) GetUuid() string { - if x != nil { - return x.Uuid - } - return "" -} - -func (x *ToolkitConfigs) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *ToolkitConfigs) GetToolkitConfigs() []*ToolkitConfig { - if x != nil { - return x.ToolkitConfigs - } - return nil -} - -var File_toolkitConfig_proto protoreflect.FileDescriptor - -var file_toolkitConfig_proto_rawDesc = []byte{ - 0x0a, 0x13, 0x74, 0x6f, 0x6f, 0x6c, 0x6b, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x66, 0x6f, 0x72, 0x67, 0x65, 0x70, 0x62, 0x1a, 0x1f, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x51, 0x0a, 0x0d, 0x54, 0x6f, 0x6f, 0x6c, 0x6b, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x22, 0x7e, 0x0a, 0x0e, 0x54, 0x6f, 0x6f, 0x6c, 0x6b, 0x69, 0x74, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x0e, 0x54, 0x6f, 0x6f, 0x6c, 0x6b, 0x69, 0x74, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x66, 0x6f, 0x72, - 0x67, 0x65, 0x70, 0x62, 0x2e, 0x54, 0x6f, 0x6f, 0x6c, 0x6b, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x0e, 0x54, 0x6f, 0x6f, 0x6c, 0x6b, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_toolkitConfig_proto_rawDescOnce sync.Once - file_toolkitConfig_proto_rawDescData = file_toolkitConfig_proto_rawDesc -) - -func file_toolkitConfig_proto_rawDescGZIP() []byte { - file_toolkitConfig_proto_rawDescOnce.Do(func() { - file_toolkitConfig_proto_rawDescData = protoimpl.X.CompressGZIP(file_toolkitConfig_proto_rawDescData) - }) - return file_toolkitConfig_proto_rawDescData -} - -var file_toolkitConfig_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_toolkitConfig_proto_goTypes = []any{ - (*ToolkitConfig)(nil), // 0: forgepb.ToolkitConfig - (*ToolkitConfigs)(nil), // 1: forgepb.ToolkitConfigs -} -var file_toolkitConfig_proto_depIdxs = []int32{ - 0, // 0: forgepb.ToolkitConfigs.ToolkitConfigs:type_name -> forgepb.ToolkitConfig - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_toolkitConfig_proto_init() } -func file_toolkitConfig_proto_init() { - if File_toolkitConfig_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_toolkitConfig_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_toolkitConfig_proto_goTypes, - DependencyIndexes: file_toolkitConfig_proto_depIdxs, - MessageInfos: file_toolkitConfig_proto_msgTypes, - }.Build() - File_toolkitConfig_proto = out.File - file_toolkitConfig_proto_rawDesc = nil - file_toolkitConfig_proto_goTypes = nil - file_toolkitConfig_proto_depIdxs = nil -} - -// `autogen:toolkitConfig.sort.pb.go` - -// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. -// This file was autogenerated with autogenpb v0.0.50 2025-02-07_18:46:58_UTC -// go install go.wit.com/apps/autogenpb@latest -// -// define which structs (messages) you want to use in the .proto file -// Then sort.pb.go and marshal.pb.go files are autogenerated -// -// autogenpb uses it and has an example .proto file with instructions -// - -package tree - -import ( - "fmt" - "sync" -) - -// a simple global lock -var toolkitConfigMu sync.RWMutex - -func (x *ToolkitConfigs) fixUuid() { - if x == nil { - return - } - if x.Uuid == "d7886d47-a3b9-43b9-b0f6-17074a9844e6" { - return - } - x.Uuid = "d7886d47-a3b9-43b9-b0f6-17074a9844e6" - x.Version = "v0.0.1 go.wit.com/toolkits/tree" -} - -func NewToolkitConfigs() *ToolkitConfigs { - x := new(ToolkitConfigs) - x.Uuid = "d7886d47-a3b9-43b9-b0f6-17074a9844e6" - x.Version = "v0.0.1 go.wit.com/toolkits/tree" - return x -} - -// START SORT - -// DEFINE THE ToolkitConfigs ITERATOR. -// itializes a new iterator. -func newToolkitConfigsIterator(things []*ToolkitConfigs) *ToolkitConfigsIterator { - return &ToolkitConfigsIterator{things: things} -} - -type ToolkitConfigsIterator struct { - sync.RWMutex // this isn't getting used properly yet? - - things []*ToolkitConfigs - index int -} - -func (it *ToolkitConfigsIterator) Scan() bool { - if it.index >= len(it.things) { - return false - } - it.index++ - return true -} - -// Next() returns the next thing in the array -func (it *ToolkitConfigsIterator) Next() *ToolkitConfigs { - if it.things[it.index-1] == nil { - fmt.Println("Next() error in ToolkitConfigsIterator", it.index) - } - return it.things[it.index-1] -} - -// END DEFINE THE ITERATOR - -// DEFINE THE ToolkitConfig ITERATOR. -// itializes a new iterator. -func newToolkitConfigIterator(things []*ToolkitConfig) *ToolkitConfigIterator { - return &ToolkitConfigIterator{things: things} -} - -type ToolkitConfigIterator struct { - sync.RWMutex // this isn't getting used properly yet? - - things []*ToolkitConfig - index int -} - -func (it *ToolkitConfigIterator) Scan() bool { - if it.index >= len(it.things) { - return false - } - it.index++ - return true -} - -// Next() returns the next thing in the array -func (it *ToolkitConfigIterator) Next() *ToolkitConfig { - if it.things[it.index-1] == nil { - fmt.Println("Next() error in ToolkitConfigIterator", it.index) - } - return it.things[it.index-1] -} - -// END DEFINE THE ITERATOR - -// safely returns a slice of pointers to the FRUIT protobufs -func (x *ToolkitConfigs) allToolkitConfigs() []*ToolkitConfig { - toolkitConfigMu.RLock() - defer toolkitConfigMu.RUnlock() - - // Create a new slice to hold pointers to each FRUIT - var tmp []*ToolkitConfig - tmp = make([]*ToolkitConfig, len(x.ToolkitConfigs)) - for i, p := range x.ToolkitConfigs { - tmp[i] = p // Copy pointers for safe iteration - } - - return tmp -} - -// safely returns a slice of pointers to the ToolkitConfig protobufs -func (x *ToolkitConfigs) selectAllToolkitConfigs() []*ToolkitConfig { - toolkitConfigMu.RLock() - defer toolkitConfigMu.RUnlock() - - // Create a new slice to hold pointers to each ToolkitConfig - var tmp []*ToolkitConfig - tmp = make([]*ToolkitConfig, len(x.ToolkitConfigs)) - for i, p := range x.ToolkitConfigs { - tmp[i] = p // Copy pointers for safe iteration - } - - return tmp -} - -// END SORT - -func (x *ToolkitConfigs) Len() int { - toolkitConfigMu.RLock() - defer toolkitConfigMu.RUnlock() - - return len(x.ToolkitConfigs) -} - -// just a simple Append() shortcut (but still uses the mutex lock) -func (x *ToolkitConfigs) Append(y *ToolkitConfig) { - toolkitConfigMu.Lock() - defer toolkitConfigMu.Unlock() - - x.ToolkitConfigs = append(x.ToolkitConfigs, y) -} - -func (x *ToolkitConfigs) All() *ToolkitConfigIterator { - ToolkitConfigPointers := x.selectAllToolkitConfigs() - - iterator := newToolkitConfigIterator(ToolkitConfigPointers) - return iterator -} - -func (x *ToolkitConfigs) Delete(y *ToolkitConfig) bool { - toolkitConfigMu.Lock() - defer toolkitConfigMu.Unlock() - - for i, _ := range x.ToolkitConfigs { - if x.ToolkitConfigs[i] == y { - x.ToolkitConfigs[i] = x.ToolkitConfigs[len(x.ToolkitConfigs)-1] - x.ToolkitConfigs = x.ToolkitConfigs[:len(x.ToolkitConfigs)-1] - return true - } - } - return false -} - -// `autogen:widget.marshal.pb.go` - -// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. -// This file was autogenerated with autogenpb v0.0.50 2025-02-07_18:46:58_UTC -// go install go.wit.com/apps/autogenpb@latest -// -// define which structs (messages) you want to use in the .proto file -// Then sort.pb.go and marshal.pb.go files are autogenerated -// -// autogenpb uses it and has an example .proto file with instructions -// - -package tree - -// `autogen:widget.pb.go` - -// Code modified by go.wit.com/apps/autogenpb DO NOT EDIT. -// -// user defined Mutex locks were auto added -// -// autogenpb version & build time: v0.0.50 2025-02-07_10:21:13_UTC -// autogenpb auto generates Sort(), Unique() and Marshal() functions -// go install go.wit.com/apps/autogenpb@latest - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.35.2-devel -// protoc v3.21.12 -// source: widget.proto - -// playing around with ideas here - -package tree // autogenpb changed the package name - -import ( - reflect "reflect" - sync "sync" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - _ "google.golang.org/protobuf/types/known/timestamppb" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Size struct { - sync.RWMutex // auto-added by go.wit.com/apps/autogenpb - - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Width int64 `protobuf:"varint,1,opt,name=width,proto3" json:"width,omitempty"` - Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` -} - -func (x *Size) Reset() { - *x = Size{} - mi := &file_widget_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Size) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Size) ProtoMessage() {} - -func (x *Size) ProtoReflect() protoreflect.Message { - mi := &file_widget_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Size.ProtoReflect.Descriptor instead. -func (*Size) Descriptor() ([]byte, []int) { - return file_widget_proto_rawDescGZIP(), []int{0} -} - -func (x *Size) GetWidth() int64 { - if x != nil { - return x.Width - } - return 0 -} - -func (x *Size) GetHeight() int64 { - if x != nil { - return x.Height - } - return 0 -} - -type Location struct { - sync.RWMutex // auto-added by go.wit.com/apps/autogenpb - - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - X int64 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"` - Y int64 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"` -} - -func (x *Location) Reset() { - *x = Location{} - mi := &file_widget_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Location) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Location) ProtoMessage() {} - -func (x *Location) ProtoReflect() protoreflect.Message { - mi := &file_widget_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Location.ProtoReflect.Descriptor instead. -func (*Location) Descriptor() ([]byte, []int) { - return file_widget_proto_rawDescGZIP(), []int{1} -} - -func (x *Location) GetX() int64 { - if x != nil { - return x.X - } - return 0 -} - -func (x *Location) GetY() int64 { - if x != nil { - return x.Y - } - return 0 -} - -type Tree struct { - sync.RWMutex // auto-added by go.wit.com/apps/autogenpb - - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Parent *Widget `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - Children []*Widget `protobuf:"bytes,2,rep,name=children,proto3" json:"children,omitempty"` -} - -func (x *Tree) Reset() { - *x = Tree{} - mi := &file_widget_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Tree) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Tree) ProtoMessage() {} - -func (x *Tree) ProtoReflect() protoreflect.Message { - mi := &file_widget_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Tree.ProtoReflect.Descriptor instead. -func (*Tree) Descriptor() ([]byte, []int) { - return file_widget_proto_rawDescGZIP(), []int{2} -} - -func (x *Tree) GetParent() *Widget { - if x != nil { - return x.Parent - } - return nil -} - -func (x *Tree) GetChildren() []*Widget { - if x != nil { - return x.Children - } - return nil -} - -type Widget struct { - sync.RWMutex // auto-added by go.wit.com/apps/autogenpb - - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Size *Size `protobuf:"bytes,3,opt,name=size,proto3" json:"size,omitempty"` - Location *Location `protobuf:"bytes,4,opt,name=location,proto3" json:"location,omitempty"` - Color string `protobuf:"bytes,5,opt,name=color,proto3" json:"color,omitempty"` -} - -func (x *Widget) Reset() { - *x = Widget{} - mi := &file_widget_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Widget) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Widget) ProtoMessage() {} - -func (x *Widget) ProtoReflect() protoreflect.Message { - mi := &file_widget_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Widget.ProtoReflect.Descriptor instead. -func (*Widget) Descriptor() ([]byte, []int) { - return file_widget_proto_rawDescGZIP(), []int{3} -} - -func (x *Widget) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Widget) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Widget) GetSize() *Size { - if x != nil { - return x.Size - } - return nil -} - -func (x *Widget) GetLocation() *Location { - if x != nil { - return x.Location - } - return nil -} - -func (x *Widget) GetColor() string { - if x != nil { - return x.Color - } - return "" -} - -type Widgets struct { - sync.RWMutex // auto-added by go.wit.com/apps/autogenpb - - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // `autogenpb:uuid:0331fcd7-3c8c-43e4-be1b-77db6a6bc58c` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // `autogenpb:version:v1` - Widgets []*Widget `protobuf:"bytes,3,rep,name=Widgets,proto3" json:"Widgets,omitempty"` -} - -func (x *Widgets) Reset() { - *x = Widgets{} - mi := &file_widget_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Widgets) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Widgets) ProtoMessage() {} - -func (x *Widgets) ProtoReflect() protoreflect.Message { - mi := &file_widget_proto_msgTypes[4] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Widgets.ProtoReflect.Descriptor instead. -func (*Widgets) Descriptor() ([]byte, []int) { - return file_widget_proto_rawDescGZIP(), []int{4} -} - -func (x *Widgets) GetUuid() string { - if x != nil { - return x.Uuid - } - return "" -} - -func (x *Widgets) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *Widgets) GetWidgets() []*Widget { - if x != nil { - return x.Widgets - } - return nil -} - -var File_widget_proto protoreflect.FileDescriptor - -var file_widget_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, - 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x34, 0x0a, 0x04, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x77, 0x69, - 0x64, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x26, 0x0a, 0x08, 0x4c, - 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x01, 0x79, 0x22, 0x56, 0x0a, 0x04, 0x54, 0x72, 0x65, 0x65, 0x12, 0x24, 0x0a, 0x06, 0x70, - 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d, 0x61, - 0x69, 0x6e, 0x2e, 0x57, 0x69, 0x64, 0x67, 0x65, 0x74, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, - 0x74, 0x12, 0x28, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x57, 0x69, 0x64, 0x67, 0x65, - 0x74, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x22, 0x8e, 0x01, 0x0a, 0x06, - 0x57, 0x69, 0x64, 0x67, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x73, 0x69, - 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, - 0x53, 0x69, 0x7a, 0x65, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x2a, 0x0a, 0x08, 0x6c, 0x6f, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6d, - 0x61, 0x69, 0x6e, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x22, 0x5f, 0x0a, 0x07, - 0x57, 0x69, 0x64, 0x67, 0x65, 0x74, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x07, 0x57, 0x69, 0x64, 0x67, 0x65, 0x74, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x57, 0x69, - 0x64, 0x67, 0x65, 0x74, 0x52, 0x07, 0x57, 0x69, 0x64, 0x67, 0x65, 0x74, 0x73, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_widget_proto_rawDescOnce sync.Once - file_widget_proto_rawDescData = file_widget_proto_rawDesc -) - -func file_widget_proto_rawDescGZIP() []byte { - file_widget_proto_rawDescOnce.Do(func() { - file_widget_proto_rawDescData = protoimpl.X.CompressGZIP(file_widget_proto_rawDescData) - }) - return file_widget_proto_rawDescData -} - -var file_widget_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_widget_proto_goTypes = []any{ - (*Size)(nil), // 0: main.Size - (*Location)(nil), // 1: main.Location - (*Tree)(nil), // 2: main.Tree - (*Widget)(nil), // 3: main.Widget - (*Widgets)(nil), // 4: main.Widgets -} -var file_widget_proto_depIdxs = []int32{ - 3, // 0: main.Tree.parent:type_name -> main.Widget - 3, // 1: main.Tree.children:type_name -> main.Widget - 0, // 2: main.Widget.size:type_name -> main.Size - 1, // 3: main.Widget.location:type_name -> main.Location - 3, // 4: main.Widgets.Widgets:type_name -> main.Widget - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name -} - -func init() { file_widget_proto_init() } -func file_widget_proto_init() { - if File_widget_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_widget_proto_rawDesc, - NumEnums: 0, - NumMessages: 5, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_widget_proto_goTypes, - DependencyIndexes: file_widget_proto_depIdxs, - MessageInfos: file_widget_proto_msgTypes, - }.Build() - File_widget_proto = out.File - file_widget_proto_rawDesc = nil - file_widget_proto_goTypes = nil - file_widget_proto_depIdxs = nil -} - -// `autogen:widget.sort.pb.go` - -// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. -// This file was autogenerated with autogenpb v0.0.50 2025-02-07_18:46:58_UTC -// go install go.wit.com/apps/autogenpb@latest -// -// define which structs (messages) you want to use in the .proto file -// Then sort.pb.go and marshal.pb.go files are autogenerated -// -// autogenpb uses it and has an example .proto file with instructions -// - -package tree - -import ( - "fmt" - "sync" -) - -// a simple global lock -var widgetMu sync.RWMutex - -func (x *Widgets) fixUuid() { - if x == nil { - return - } - if x.Uuid == "0331fcd7-3c8c-43e4-be1b-77db6a6bc58c" { - return - } - x.Uuid = "0331fcd7-3c8c-43e4-be1b-77db6a6bc58c" - x.Version = "v1 " -} - -func NewWidgets() *Widgets { - x := new(Widgets) - x.Uuid = "0331fcd7-3c8c-43e4-be1b-77db6a6bc58c" - x.Version = "v1 " - return x -} - -// START SORT - -// DEFINE THE Widgets ITERATOR. -// itializes a new iterator. -func newWidgetsIterator(things []*Widgets) *WidgetsIterator { - return &WidgetsIterator{things: things} -} - -type WidgetsIterator struct { - sync.RWMutex // this isn't getting used properly yet? - - things []*Widgets - index int -} - -func (it *WidgetsIterator) Scan() bool { - if it.index >= len(it.things) { - return false - } - it.index++ - return true -} - -// Next() returns the next thing in the array -func (it *WidgetsIterator) Next() *Widgets { - if it.things[it.index-1] == nil { - fmt.Println("Next() error in WidgetsIterator", it.index) - } - return it.things[it.index-1] -} - -// END DEFINE THE ITERATOR - -// DEFINE THE Widget ITERATOR. -// itializes a new iterator. -func newWidgetIterator(things []*Widget) *WidgetIterator { - return &WidgetIterator{things: things} -} - -type WidgetIterator struct { - sync.RWMutex // this isn't getting used properly yet? - - things []*Widget - index int -} - -func (it *WidgetIterator) Scan() bool { - if it.index >= len(it.things) { - return false - } - it.index++ - return true -} - -// Next() returns the next thing in the array -func (it *WidgetIterator) Next() *Widget { - if it.things[it.index-1] == nil { - fmt.Println("Next() error in WidgetIterator", it.index) - } - return it.things[it.index-1] -} - -// END DEFINE THE ITERATOR - -// DEFINE THE Size ITERATOR. -// itializes a new iterator. -func newSizeIterator(things []*Size) *SizeIterator { - return &SizeIterator{things: things} -} - -type SizeIterator struct { - sync.RWMutex // this isn't getting used properly yet? - - things []*Size - index int -} - -func (it *SizeIterator) Scan() bool { - if it.index >= len(it.things) { - return false - } - it.index++ - return true -} - -// Next() returns the next thing in the array -func (it *SizeIterator) Next() *Size { - if it.things[it.index-1] == nil { - fmt.Println("Next() error in SizeIterator", it.index) - } - return it.things[it.index-1] -} - -// END DEFINE THE ITERATOR - -// DEFINE THE Location ITERATOR. -// itializes a new iterator. -func newLocationIterator(things []*Location) *LocationIterator { - return &LocationIterator{things: things} -} - -type LocationIterator struct { - sync.RWMutex // this isn't getting used properly yet? - - things []*Location - index int -} - -func (it *LocationIterator) Scan() bool { - if it.index >= len(it.things) { - return false - } - it.index++ - return true -} - -// Next() returns the next thing in the array -func (it *LocationIterator) Next() *Location { - if it.things[it.index-1] == nil { - fmt.Println("Next() error in LocationIterator", it.index) - } - return it.things[it.index-1] -} - -// END DEFINE THE ITERATOR - -// DEFINE THE Tree ITERATOR. -// itializes a new iterator. -func newTreeIterator(things []*Tree) *TreeIterator { - return &TreeIterator{things: things} -} - -type TreeIterator struct { - sync.RWMutex // this isn't getting used properly yet? - - things []*Tree - index int -} - -func (it *TreeIterator) Scan() bool { - if it.index >= len(it.things) { - return false - } - it.index++ - return true -} - -// Next() returns the next thing in the array -func (it *TreeIterator) Next() *Tree { - if it.things[it.index-1] == nil { - fmt.Println("Next() error in TreeIterator", it.index) - } - return it.things[it.index-1] -} - -// END DEFINE THE ITERATOR - -// safely returns a slice of pointers to the FRUIT protobufs -func (x *Widgets) allWidgets() []*Widget { - widgetMu.RLock() - defer widgetMu.RUnlock() - - // Create a new slice to hold pointers to each FRUIT - var tmp []*Widget - tmp = make([]*Widget, len(x.Widgets)) - for i, p := range x.Widgets { - tmp[i] = p // Copy pointers for safe iteration - } - - return tmp -} - -// safely returns a slice of pointers to the FRUIT protobufs -func (x *Tree) allChildren() []*Widget { - widgetMu.RLock() - defer widgetMu.RUnlock() - - // Create a new slice to hold pointers to each FRUIT - var tmp []*Widget - tmp = make([]*Widget, len(x.Children)) - for i, p := range x.Children { - tmp[i] = p // Copy pointers for safe iteration - } - - return tmp -} - -// safely returns a slice of pointers to the Widget protobufs -func (x *Widgets) selectAllWidgets() []*Widget { - widgetMu.RLock() - defer widgetMu.RUnlock() - - // Create a new slice to hold pointers to each Widget - var tmp []*Widget - tmp = make([]*Widget, len(x.Widgets)) - for i, p := range x.Widgets { - tmp[i] = p // Copy pointers for safe iteration - } - - return tmp -} - -// safely returns a slice of pointers to the Widget protobufs -func (x *Tree) selectAllChildren() []*Widget { - widgetMu.RLock() - defer widgetMu.RUnlock() - - // Create a new slice to hold pointers to each Widget - var tmp []*Widget - tmp = make([]*Widget, len(x.Children)) - for i, p := range x.Children { - tmp[i] = p // Copy pointers for safe iteration - } - - return tmp -} - -// END SORT - -func (x *Widgets) Len() int { - widgetMu.RLock() - defer widgetMu.RUnlock() - - return len(x.Widgets) -} - -// just a simple Append() shortcut (but still uses the mutex lock) -func (x *Widgets) Append(y *Widget) { - widgetMu.Lock() - defer widgetMu.Unlock() - - x.Widgets = append(x.Widgets, y) -} - -func (x *Widgets) All() *WidgetIterator { - WidgetPointers := x.selectAllWidgets() - - iterator := newWidgetIterator(WidgetPointers) - return iterator -} - -func (x *Widgets) Delete(y *Widget) bool { - widgetMu.Lock() - defer widgetMu.Unlock() - - for i, _ := range x.Widgets { - if x.Widgets[i] == y { - x.Widgets[i] = x.Widgets[len(x.Widgets)-1] - x.Widgets = x.Widgets[:len(x.Widgets)-1] - return true - } - } - return false -} - -// `autogen:`