diff options
| author | 2025-03-09 17:47:56 +0100 | |
|---|---|---|
| committer | 2025-12-01 22:08:04 +0100 | |
| commit | b1af8fd87760b34e3ff2fd3bda38f211815a0473 (patch) | |
| tree | 9317fad1a7ec298d7a8d2678e4e422953bbc6f33 /vendor/codeberg.org/gruf/go-kv/v2/format/pointer.go | |
| parent | [chore] update URLs to forked source (diff) | |
| download | gotosocial-b1af8fd87760b34e3ff2fd3bda38f211815a0473.tar.xz | |
[chore] remove vendor
Diffstat (limited to 'vendor/codeberg.org/gruf/go-kv/v2/format/pointer.go')
| -rw-r--r-- | vendor/codeberg.org/gruf/go-kv/v2/format/pointer.go | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/pointer.go b/vendor/codeberg.org/gruf/go-kv/v2/format/pointer.go deleted file mode 100644 index ec1e2e15d..000000000 --- a/vendor/codeberg.org/gruf/go-kv/v2/format/pointer.go +++ /dev/null @@ -1,130 +0,0 @@ -package format - -import ( - "reflect" - "unsafe" - - "codeberg.org/gruf/go-xunsafe" -) - -// derefPointerType returns a FormatFunc capable of dereferencing -// and formatting the given pointer type currently in TypeIter{}. -// note this will fetch a sub-FormatFunc for resulting value type. -func (fmt *Formatter) derefPointerType(t xunsafe.TypeIter) FormatFunc { - var n int - rtype := t.Type - flags := t.Flag - - // Iteratively dereference pointer types. - for rtype.Kind() == reflect.Pointer { - - // If this actual indirect memory, - // increase dereferences counter. - if flags&xunsafe.Reflect_flagIndir != 0 { - n++ - } - - // Get next elem type. - rtype = rtype.Elem() - - // Get next set of dereferenced element type flags. - flags = xunsafe.ReflectPointerElemFlags(flags, rtype) - } - - // Wrap value as TypeIter. - vt := t.Child(rtype, flags) - - // Get value format func. - fn := fmt.loadOrGet(vt) - if fn == nil { - panic("unreachable") - } - - if !needs_typestr(t) { - if n <= 0 { - // No derefs are needed. - return func(s *State) { - if s.P == nil { - // Final check. - appendNil(s) - return - } - - // Format - // final - // value. - fn(s) - } - } - - return func(s *State) { - // Deref n number times. - for i := n; i > 0; i-- { - - if s.P == nil { - // Nil check. - appendNil(s) - return - } - - // Further deref pointer value. - s.P = *(*unsafe.Pointer)(s.P) - } - - if s.P == nil { - // Final check. - appendNil(s) - return - } - - // Format - // final - // value. - fn(s) - } - } - - // Final type string with ptrs. - typestr := typestr_with_ptrs(t) - - if n <= 0 { - // No derefs are needed. - return func(s *State) { - if s.P == nil { - // Final nil value check. - appendNilType(s, typestr) - return - } - - // Format - // final - // value. - fn(s) - } - } - - return func(s *State) { - // Deref n number times. - for i := n; i > 0; i-- { - if s.P == nil { - // Check for nil value. - appendNilType(s, typestr) - return - } - - // Further deref pointer value. - s.P = *(*unsafe.Pointer)(s.P) - } - - if s.P == nil { - // Final nil value check. - appendNilType(s, typestr) - return - } - - // Format - // final - // value. - fn(s) - } -} |
