diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..40a0152 --- /dev/null +++ b/go.mod @@ -0,0 +1,24 @@ +module go.wit.com/apps/utils/startxplacement + +go 1.24.1 + +require ( + github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc + go.wit.com/dev/alexflint/arg v1.6.3 + go.wit.com/lib/config v0.0.5 + go.wit.com/lib/gui/prep v0.0.11 + go.wit.com/log v0.25.1 + google.golang.org/protobuf v1.36.9 +) + +require ( + github.com/alexflint/go-scalar v1.2.0 // indirect + github.com/go-cmd/cmd v1.4.3 // indirect + github.com/google/uuid v1.6.0 // indirect + go.wit.com/gui v0.25.3 // indirect + go.wit.com/lib/fhelp v0.0.23 // indirect + go.wit.com/lib/gui/shell v0.22.33 // indirect + go.wit.com/lib/protobuf/guipb v0.0.15 // indirect + go.wit.com/widget v1.1.30 // indirect + golang.org/x/text v0.29.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c75add9 --- /dev/null +++ b/go.sum @@ -0,0 +1,44 @@ +github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc h1:7D+Bh06CRPCJO3gr2F7h1sriovOZ8BMhca2Rg85c2nk= +github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw= +github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-cmd/cmd v1.4.3 h1:6y3G+3UqPerXvPcXvj+5QNPHT02BUw7p6PsqRxLNA7Y= +github.com/go-cmd/cmd v1.4.3/go.mod h1:u3hxg/ry+D5kwh8WvUkHLAMe2zQCaXd00t35WfQaOFk= +github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= +github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +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= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +go.wit.com/dev/alexflint/arg v1.6.3 h1:EduPl3oA/Sk4XcBVM7EYERlHjvbyEDysK5PqI/Wmdtw= +go.wit.com/dev/alexflint/arg v1.6.3/go.mod h1:RKOrAnxFl+856vbfvMEYcdd4qgBq2ZEO8atUcINendY= +go.wit.com/gui v0.25.3 h1:kDUzh/z52ghRlp/urVFCrDEIlkrfsKRmObN3LjbwsBU= +go.wit.com/gui v0.25.3/go.mod h1:H02phAerHwzSZMAb9mhL8rr7/zCbjASU8Cmg97tNvxY= +go.wit.com/lib/config v0.0.5 h1:sHgY4PSpEeiNSJFDQGXOkbgmXrOGU/8+4HjqEiqo43w= +go.wit.com/lib/config v0.0.5/go.mod h1:dZ3Jr3sIjvCWcQX4cZxNFiUcjUAmwT85S8B140DWeS8= +go.wit.com/lib/fhelp v0.0.23 h1:XWQLxxS603xQwJ5IKjCKQ5vNeiivh3jfVrmDdc5piJ8= +go.wit.com/lib/fhelp v0.0.23/go.mod h1:8lRn3kJUuxkhief0JjbxL/ydw06ZJx/HLw7eMx9Xx9Y= +go.wit.com/lib/gui/prep v0.0.11 h1:8lla9pdZ3KkQVgt+F77imtqSMBkXZaFxIwXLcjBgW8E= +go.wit.com/lib/gui/prep v0.0.11/go.mod h1:6lgucjv3/RvzUV2tuo/Loh3WZNlePVRYEsEfiFIy97s= +go.wit.com/lib/gui/shell v0.22.33 h1:3MvWBQU4rOHK4Ac5MkQ62ndW7WhCBpu9F3AVeUF7YgQ= +go.wit.com/lib/gui/shell v0.22.33/go.mod h1:aRDwKXKXkZaO4y/0KPe1lhKQCXpyi8hXgUEOrHhzpAI= +go.wit.com/lib/protobuf/guipb v0.0.15 h1:0MJ9FNFuUuNS8AsK+UcgGGnb3Xlw+ve7AbWLnHyIJ08= +go.wit.com/lib/protobuf/guipb v0.0.15/go.mod h1:9AzFoNKnE0161IOTfdul6SX5+GPAFNW7RPKWohenmcQ= +go.wit.com/log v0.25.1 h1:74WVf9NSN6z5jc2oSbA1ehxdZ7V/NBXTk5t0jIoaTMg= +go.wit.com/log v0.25.1/go.mod h1:XE4lTfAibWgwBJksIk7u3IEJ8xcBvNhnlewYAQGj2Ew= +go.wit.com/widget v1.1.30 h1:O/dIG7QtDrZkR5P6f8JAMyevBiMXSun9vL6F0KFAWV8= +go.wit.com/widget v1.1.30/go.mod h1:wj7TpAr2gk7Poa+v8XQkH1aidnTdgAa/a8GxrMtcztw= +golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= +golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= +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.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw= +google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/placement.marshal.pb.go b/placement.marshal.pb.go new file mode 100644 index 0000000..59bb444 --- /dev/null +++ b/placement.marshal.pb.go @@ -0,0 +1,56 @@ +// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. +// This file was autogenerated with autogenpb v0.5.0 2025-09-11_08:28:21_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 main + +import ( + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" +) + +// human readable JSON +func (v *Placements) FormatJSON() string { + return protojson.Format(v) +} + +// marshal json +func (v *Placements) MarshalJSON() ([]byte, error) { + return protojson.Marshal(v) +} + +// unmarshal json +func (v *Placements) 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 *Placements) FormatTEXT() string { + v.fixUuid() + return prototext.Format(v) +} + +// unmarshalTEXT. This reads the .text config file back in after the user edits it +func (v *Placements) UnmarshalTEXT(data []byte) error { + return prototext.Unmarshal(data, v) +} + +// marshal to wire. This is called winning. +func (v *Placements) Marshal() ([]byte, error) { + v.fixUuid() + return proto.Marshal(v) +} + +// unmarshal from wire. You have won. +func (v *Placements) Unmarshal(data []byte) error { + return proto.Unmarshal(data, v) +} diff --git a/placement.pb.go b/placement.pb.go new file mode 100644 index 0000000..28475e7 --- /dev/null +++ b/placement.pb.go @@ -0,0 +1,514 @@ +// Code modified by go.wit.com/apps/autogenpb DO NOT EDIT. +// +// user defined Mutex locks were auto added +// +// autogenpb version & build time: v0.5.0 2025-09-11_08:28:21_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.33.0 +// protoc v3.21.12 +// source: placement.proto + +package main // autogenpb changed the package name + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +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 Placement struct { + sync.RWMutex // auto-added by go.wit.com/apps/autogenpb + + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // used for grid layouts + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // `autogenpb:sort` `autogenpb:unique` + Geom *Placement_Geom `protobuf:"bytes,2,opt,name=geom,proto3" json:"geom,omitempty"` + Workspace int32 `protobuf:"varint,3,opt,name=workspace,proto3" json:"workspace,omitempty"` // what workspace to show the app on + Wd string `protobuf:"bytes,4,opt,name=wd,proto3" json:"wd,omitempty"` // working dir. Tries to set xterm path at start to this + Argv []string `protobuf:"bytes,5,rep,name=argv,proto3" json:"argv,omitempty"` // argv. argv[0] should be the executable name + Namespace string `protobuf:"bytes,6,opt,name=namespace,proto3" json:"namespace,omitempty"` // namespace of the executable (go.wit.com/apps/forge) +} + +func (x *Placement) Reset() { + *x = Placement{} + if protoimpl.UnsafeEnabled { + mi := &file_placement_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Placement) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Placement) ProtoMessage() {} + +func (x *Placement) ProtoReflect() protoreflect.Message { + mi := &file_placement_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Placement.ProtoReflect.Descriptor instead. +func (*Placement) Descriptor() ([]byte, []int) { + return file_placement_proto_rawDescGZIP(), []int{0} +} + +func (x *Placement) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Placement) GetGeom() *Placement_Geom { + if x != nil { + return x.Geom + } + return nil +} + +func (x *Placement) GetWorkspace() int32 { + if x != nil { + return x.Workspace + } + return 0 +} + +func (x *Placement) GetWd() string { + if x != nil { + return x.Wd + } + return "" +} + +func (x *Placement) GetArgv() []string { + if x != nil { + return x.Argv + } + return nil +} + +func (x *Placement) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +type Placements 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:31769bcb-5865-4926-b7d6-501083312eea` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // `autogenpb:version:v0.0.1` + Placement []*Placement `protobuf:"bytes,3,rep,name=Placement,proto3" json:"Placement,omitempty"` + Filename string `protobuf:"bytes,4,opt,name=filename,proto3" json:"filename,omitempty"` // used by the config save function +} + +func (x *Placements) Reset() { + *x = Placements{} + if protoimpl.UnsafeEnabled { + mi := &file_placement_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Placements) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Placements) ProtoMessage() {} + +func (x *Placements) ProtoReflect() protoreflect.Message { + mi := &file_placement_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Placements.ProtoReflect.Descriptor instead. +func (*Placements) Descriptor() ([]byte, []int) { + return file_placement_proto_rawDescGZIP(), []int{1} +} + +func (x *Placements) GetUuid() string { + if x != nil { + return x.Uuid + } + return "" +} + +func (x *Placements) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *Placements) GetPlacement() []*Placement { + if x != nil { + return x.Placement + } + return nil +} + +func (x *Placements) GetFilename() string { + if x != nil { + return x.Filename + } + return "" +} + +type Placement_Size struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + W int64 `protobuf:"varint,1,opt,name=w,proto3" json:"w,omitempty"` + H int64 `protobuf:"varint,2,opt,name=h,proto3" json:"h,omitempty"` +} + +func (x *Placement_Size) Reset() { + *x = Placement_Size{} + if protoimpl.UnsafeEnabled { + mi := &file_placement_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Placement_Size) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Placement_Size) ProtoMessage() {} + +func (x *Placement_Size) ProtoReflect() protoreflect.Message { + mi := &file_placement_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Placement_Size.ProtoReflect.Descriptor instead. +func (*Placement_Size) Descriptor() ([]byte, []int) { + return file_placement_proto_rawDescGZIP(), []int{0, 0} +} + +func (x *Placement_Size) GetW() int64 { + if x != nil { + return x.W + } + return 0 +} + +func (x *Placement_Size) GetH() int64 { + if x != nil { + return x.H + } + return 0 +} + +type Placement_Offset struct { + 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 *Placement_Offset) Reset() { + *x = Placement_Offset{} + if protoimpl.UnsafeEnabled { + mi := &file_placement_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Placement_Offset) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Placement_Offset) ProtoMessage() {} + +func (x *Placement_Offset) ProtoReflect() protoreflect.Message { + mi := &file_placement_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Placement_Offset.ProtoReflect.Descriptor instead. +func (*Placement_Offset) Descriptor() ([]byte, []int) { + return file_placement_proto_rawDescGZIP(), []int{0, 1} +} + +func (x *Placement_Offset) GetX() int64 { + if x != nil { + return x.X + } + return 0 +} + +func (x *Placement_Offset) GetY() int64 { + if x != nil { + return x.Y + } + return 0 +} + +type Placement_Geom struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Size *Placement_Size `protobuf:"bytes,1,opt,name=size,proto3" json:"size,omitempty"` + Offset *Placement_Offset `protobuf:"bytes,2,opt,name=offset,proto3" json:"offset,omitempty"` +} + +func (x *Placement_Geom) Reset() { + *x = Placement_Geom{} + if protoimpl.UnsafeEnabled { + mi := &file_placement_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Placement_Geom) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Placement_Geom) ProtoMessage() {} + +func (x *Placement_Geom) ProtoReflect() protoreflect.Message { + mi := &file_placement_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Placement_Geom.ProtoReflect.Descriptor instead. +func (*Placement_Geom) Descriptor() ([]byte, []int) { + return file_placement_proto_rawDescGZIP(), []int{0, 2} +} + +func (x *Placement_Geom) GetSize() *Placement_Size { + if x != nil { + return x.Size + } + return nil +} + +func (x *Placement_Geom) GetOffset() *Placement_Offset { + if x != nil { + return x.Offset + } + return nil +} + +var File_placement_proto protoreflect.FileDescriptor + +var file_placement_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0xd5, 0x02, 0x0a, 0x09, 0x50, 0x6c, 0x61, 0x63, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x67, 0x65, 0x6f, + 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x50, + 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x65, 0x6f, 0x6d, 0x52, 0x04, 0x67, + 0x65, 0x6f, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x77, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x77, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x72, 0x67, 0x76, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x04, 0x61, 0x72, 0x67, 0x76, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x1a, 0x22, 0x0a, 0x04, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x77, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x01, 0x77, 0x12, 0x0c, 0x0a, 0x01, 0x68, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x01, 0x68, 0x1a, 0x24, 0x0a, 0x06, 0x4f, 0x66, 0x66, 0x73, 0x65, + 0x74, 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, 0x1a, 0x60, 0x0a, + 0x04, 0x47, 0x65, 0x6f, 0x6d, 0x12, 0x28, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x50, 0x6c, 0x61, 0x63, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x69, 0x7a, 0x65, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, + 0x2e, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x16, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x50, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x2e, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x22, + 0x85, 0x01, 0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 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, 0x2d, 0x0a, 0x09, + 0x50, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x50, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x52, 0x09, 0x50, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, + 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, + 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_placement_proto_rawDescOnce sync.Once + file_placement_proto_rawDescData = file_placement_proto_rawDesc +) + +func file_placement_proto_rawDescGZIP() []byte { + file_placement_proto_rawDescOnce.Do(func() { + file_placement_proto_rawDescData = protoimpl.X.CompressGZIP(file_placement_proto_rawDescData) + }) + return file_placement_proto_rawDescData +} + +var file_placement_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_placement_proto_goTypes = []interface{}{ + (*Placement)(nil), // 0: main.Placement + (*Placements)(nil), // 1: main.Placements + (*Placement_Size)(nil), // 2: main.Placement.Size + (*Placement_Offset)(nil), // 3: main.Placement.Offset + (*Placement_Geom)(nil), // 4: main.Placement.Geom +} +var file_placement_proto_depIdxs = []int32{ + 4, // 0: main.Placement.geom:type_name -> main.Placement.Geom + 0, // 1: main.Placements.Placement:type_name -> main.Placement + 2, // 2: main.Placement.Geom.size:type_name -> main.Placement.Size + 3, // 3: main.Placement.Geom.offset:type_name -> main.Placement.Offset + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_placement_proto_init() } +func file_placement_proto_init() { + if File_placement_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_placement_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Placement); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_placement_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Placements); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_placement_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Placement_Size); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_placement_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Placement_Offset); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_placement_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Placement_Geom); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_placement_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_placement_proto_goTypes, + DependencyIndexes: file_placement_proto_depIdxs, + MessageInfos: file_placement_proto_msgTypes, + }.Build() + File_placement_proto = out.File + file_placement_proto_rawDesc = nil + file_placement_proto_goTypes = nil + file_placement_proto_depIdxs = nil +} diff --git a/placement.sort.pb.go b/placement.sort.pb.go new file mode 100644 index 0000000..93a4dea --- /dev/null +++ b/placement.sort.pb.go @@ -0,0 +1,144 @@ +// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. +// This file was autogenerated with autogenpb v0.5.0 2025-09-11_08:28:21_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 main + +import ( + "fmt" + "sync" +) + +// a simple global lock +var placementMu sync.RWMutex + +func (x *Placements) fixUuid() { + if x == nil { + return + } + if x.Uuid == "31769bcb-5865-4926-b7d6-501083312eea" { + return + } + x.Uuid = "31769bcb-5865-4926-b7d6-501083312eea" + x.Version = "v0.0.1 go.wit.com/apps/utils/startxplacement" +} + +func NewPlacements() *Placements { + x := new(Placements) + x.Uuid = "31769bcb-5865-4926-b7d6-501083312eea" + x.Version = "v0.0.1 go.wit.com/apps/utils/startxplacement" + return x +} + +// START SORT + +// DEFINE THE Placements SCANNER. +// itializes a new scanner. +func newPlacementsScanner(things []*Placements) *PlacementsScanner { + return &PlacementsScanner{things: things} +} + +type PlacementsScanner struct { + sync.Mutex + + things []*Placements + index int +} + +func (it *PlacementsScanner) Scan() bool { + if it.index >= len(it.things) { + return false + } + it.Lock() + it.index++ + it.Unlock() + return true +} + +// Next() returns the next thing in the array +func (it *PlacementsScanner) Next() *Placements { + if it.things[it.index-1] == nil { + fmt.Println("Next() error in PlacementsScanner", it.index) + } + return it.things[it.index-1] +} + +// END DEFINE THE SCANNER + +// DEFINE THE Placement SCANNER. +// itializes a new scanner. +func newPlacementScanner(things []*Placement) *PlacementScanner { + return &PlacementScanner{things: things} +} + +type PlacementScanner struct { + sync.Mutex + + things []*Placement + index int +} + +func (it *PlacementScanner) Scan() bool { + if it.index >= len(it.things) { + return false + } + it.Lock() + it.index++ + it.Unlock() + return true +} + +// Next() returns the next thing in the array +func (it *PlacementScanner) Next() *Placement { + if it.things[it.index-1] == nil { + fmt.Println("Next() error in PlacementScanner", it.index) + } + return it.things[it.index-1] +} + +// END DEFINE THE SCANNER + +// sort struct by Name +type sortPlacementName []*Placement + +func (a sortPlacementName) Len() int { return len(a) } +func (a sortPlacementName) Less(i, j int) bool { return a[i].Name < a[j].Name } +func (a sortPlacementName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } + +// safely returns a slice of pointers to the FRUIT protobufs +func (x *Placements) allPlacement() []*Placement { + x.RLock() + defer x.RUnlock() + + // Create a new slice to hold pointers to each FRUIT + var tmp []*Placement + tmp = make([]*Placement, len(x.Placement)) + for i, p := range x.Placement { + tmp[i] = p // Copy pointers for safe iteration + } + + return tmp +} + +// safely returns a slice of pointers to the Placement protobufs +func (x *Placements) selectAllPlacement() []*Placement { + x.RLock() + defer x.RUnlock() + + // Create a new slice to hold pointers to each Placement + var tmp []*Placement + tmp = make([]*Placement, len(x.Placement)) + for i, p := range x.Placement { + tmp[i] = p // Copy pointers for safe iteration + } + + return tmp +} + +// END SORT