Notes added by 'git notes append'

This commit is contained in:
Jeff Carr 2025-02-14 00:46:00 -06:00
parent 8420f413ce
commit 07a1da60f7
1 changed files with 445 additions and 0 deletions

View File

@ -1100,3 +1100,448 @@ func file_file_proto_init() {
}
// `autogen:file.sort.pb.go`
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
// This file was autogenerated with autogenpb v0.0.52 2025-02-12_06:22:03_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 fileMu sync.RWMutex
func (x *Files) fixUuid() {
if x == nil {
return
}
if x.Uuid == "6c9ae4dd-648d-4b51-9738-bd59fb8fafd5" {
return
}
x.Uuid = "6c9ae4dd-648d-4b51-9738-bd59fb8fafd5"
x.Version = "v0.0.38 go.wit.com/apps/autogenpb"
}
func NewFiles() *Files {
x := new(Files)
x.Uuid = "6c9ae4dd-648d-4b51-9738-bd59fb8fafd5"
x.Version = "v0.0.38 go.wit.com/apps/autogenpb"
return x
}
// START SORT
// DEFINE THE Files ITERATOR.
// itializes a new iterator.
func newFilesIterator(things []*Files) *FilesIterator {
return &FilesIterator{things: things}
}
type FilesIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*Files
index int
}
func (it *FilesIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *FilesIterator) Next() *Files {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in FilesIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE File ITERATOR.
// itializes a new iterator.
func newFileIterator(things []*File) *FileIterator {
return &FileIterator{things: things}
}
type FileIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*File
index int
}
func (it *FileIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *FileIterator) Next() *File {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in FileIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE MsgVar ITERATOR.
// itializes a new iterator.
func newMsgVarIterator(things []*MsgVar) *MsgVarIterator {
return &MsgVarIterator{things: things}
}
type MsgVarIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*MsgVar
index int
}
func (it *MsgVarIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *MsgVarIterator) Next() *MsgVar {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in MsgVarIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE MsgName ITERATOR.
// itializes a new iterator.
func newMsgNameIterator(things []*MsgName) *MsgNameIterator {
return &MsgNameIterator{things: things}
}
type MsgNameIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*MsgName
index int
}
func (it *MsgNameIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *MsgNameIterator) Next() *MsgName {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in MsgNameIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE Sort ITERATOR.
// itializes a new iterator.
func newSortIterator(things []*Sort) *SortIterator {
return &SortIterator{things: things}
}
type SortIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*Sort
index int
}
func (it *SortIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *SortIterator) Next() *Sort {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in SortIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE Find ITERATOR.
// itializes a new iterator.
func newFindIterator(things []*Find) *FindIterator {
return &FindIterator{things: things}
}
type FindIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*Find
index int
}
func (it *FindIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *FindIterator) Next() *Find {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in FindIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// DEFINE THE Identify ITERATOR.
// itializes a new iterator.
func newIdentifyIterator(things []*Identify) *IdentifyIterator {
return &IdentifyIterator{things: things}
}
type IdentifyIterator struct {
sync.RWMutex // this isn't getting used properly yet?
things []*Identify
index int
}
func (it *IdentifyIterator) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.index++
return true
}
// Next() returns the next thing in the array
func (it *IdentifyIterator) Next() *Identify {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in IdentifyIterator", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE ITERATOR
// safely returns a slice of pointers to the FRUIT protobufs
func (x *Files) allFiles() []*File {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*File
tmp = make([]*File, len(x.Files))
for i, p := range x.Files {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *File) allMsgNames() []*MsgName {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*MsgName
tmp = make([]*MsgName, len(x.MsgNames))
for i, p := range x.MsgNames {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *File) allSortNames() []*MsgName {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*MsgName
tmp = make([]*MsgName, len(x.SortNames))
for i, p := range x.SortNames {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *File) allToSort() []*Sort {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*Sort
tmp = make([]*Sort, len(x.ToSort))
for i, p := range x.ToSort {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *MsgName) allVars() []*MsgVar {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*MsgVar
tmp = make([]*MsgVar, len(x.Vars))
for i, p := range x.Vars {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the File protobufs
func (x *Files) selectAllFiles() []*File {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each File
var tmp []*File
tmp = make([]*File, len(x.Files))
for i, p := range x.Files {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the MsgName protobufs
func (x *File) selectAllMsgNames() []*MsgName {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each MsgName
var tmp []*MsgName
tmp = make([]*MsgName, len(x.MsgNames))
for i, p := range x.MsgNames {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the MsgName protobufs
func (x *File) selectAllSortNames() []*MsgName {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each MsgName
var tmp []*MsgName
tmp = make([]*MsgName, len(x.SortNames))
for i, p := range x.SortNames {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the Sort protobufs
func (x *File) selectAllToSort() []*Sort {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each Sort
var tmp []*Sort
tmp = make([]*Sort, len(x.ToSort))
for i, p := range x.ToSort {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the MsgVar protobufs
func (x *MsgName) selectAllVars() []*MsgVar {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each MsgVar
var tmp []*MsgVar
tmp = make([]*MsgVar, len(x.Vars))
for i, p := range x.Vars {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// END SORT
func (x *Files) Len() int {
x.RLock()
defer x.RUnlock()
return len(x.Files)
}
// just a simple Append() shortcut (but still uses the mutex lock)
func (x *Files) Append(y *File) {
x.Lock()
defer x.Unlock()
x.Files = append(x.Files, y)
}
func (x *Files) All() *FileIterator {
FilePointers := x.selectAllFiles()
iterator := newFileIterator(FilePointers)
return iterator
}
func (x *Files) Delete(y *File) bool {
x.Lock()
defer x.Unlock()
for i, _ := range x.Files {
if x.Files[i] == y {
x.Files[i] = x.Files[len(x.Files)-1]
x.Files = x.Files[:len(x.Files)-1]
return true
}
}
return false
}