aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/modern-go/reflect2/safe_slice.go
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2024-01-02 18:56:31 +0100
committerLibravatar Rutger Broekhoff2024-01-02 18:56:31 +0100
commit8db41da676ac8368ef7c2549d56239a5ff5eedde (patch)
tree09c427fd66de2ec1ebffc8342f5fdbb84b0701b5 /vendor/github.com/modern-go/reflect2/safe_slice.go
parentd4f75fb6db22e57577867445a022227e70958931 (diff)
downloadgitolfs3-8db41da676ac8368ef7c2549d56239a5ff5eedde.tar.gz
gitolfs3-8db41da676ac8368ef7c2549d56239a5ff5eedde.zip
Delete vendor directory
Diffstat (limited to 'vendor/github.com/modern-go/reflect2/safe_slice.go')
-rw-r--r--vendor/github.com/modern-go/reflect2/safe_slice.go92
1 files changed, 0 insertions, 92 deletions
diff --git a/vendor/github.com/modern-go/reflect2/safe_slice.go b/vendor/github.com/modern-go/reflect2/safe_slice.go
deleted file mode 100644
index bcce6fd..0000000
--- a/vendor/github.com/modern-go/reflect2/safe_slice.go
+++ /dev/null
@@ -1,92 +0,0 @@
1package reflect2
2
3import (
4 "reflect"
5 "unsafe"
6)
7
8type safeSliceType struct {
9 safeType
10}
11
12func (type2 *safeSliceType) SetIndex(obj interface{}, index int, value interface{}) {
13 val := reflect.ValueOf(obj).Elem()
14 elem := reflect.ValueOf(value).Elem()
15 val.Index(index).Set(elem)
16}
17
18func (type2 *safeSliceType) UnsafeSetIndex(obj unsafe.Pointer, index int, value unsafe.Pointer) {
19 panic("does not support unsafe operation")
20}
21
22func (type2 *safeSliceType) GetIndex(obj interface{}, index int) interface{} {
23 val := reflect.ValueOf(obj).Elem()
24 elem := val.Index(index)
25 ptr := reflect.New(elem.Type())
26 ptr.Elem().Set(elem)
27 return ptr.Interface()
28}
29
30func (type2 *safeSliceType) UnsafeGetIndex(obj unsafe.Pointer, index int) unsafe.Pointer {
31 panic("does not support unsafe operation")
32}
33
34func (type2 *safeSliceType) MakeSlice(length int, cap int) interface{} {
35 val := reflect.MakeSlice(type2.Type, length, cap)
36 ptr := reflect.New(val.Type())
37 ptr.Elem().Set(val)
38 return ptr.Interface()
39}
40
41func (type2 *safeSliceType) UnsafeMakeSlice(length int, cap int) unsafe.Pointer {
42 panic("does not support unsafe operation")
43}
44
45func (type2 *safeSliceType) Grow(obj interface{}, newLength int) {
46 oldCap := type2.Cap(obj)
47 oldSlice := reflect.ValueOf(obj).Elem()
48 delta := newLength - oldCap
49 deltaVals := make([]reflect.Value, delta)
50 newSlice := reflect.Append(oldSlice, deltaVals...)
51 oldSlice.Set(newSlice)
52}
53
54func (type2 *safeSliceType) UnsafeGrow(ptr unsafe.Pointer, newLength int) {
55 panic("does not support unsafe operation")
56}
57
58func (type2 *safeSliceType) Append(obj interface{}, elem interface{}) {
59 val := reflect.ValueOf(obj).Elem()
60 elemVal := reflect.ValueOf(elem).Elem()
61 newVal := reflect.Append(val, elemVal)
62 val.Set(newVal)
63}
64
65func (type2 *safeSliceType) UnsafeAppend(obj unsafe.Pointer, elem unsafe.Pointer) {
66 panic("does not support unsafe operation")
67}
68
69func (type2 *safeSliceType) SetNil(obj interface{}) {
70 val := reflect.ValueOf(obj).Elem()
71 val.Set(reflect.Zero(val.Type()))
72}
73
74func (type2 *safeSliceType) UnsafeSetNil(ptr unsafe.Pointer) {
75 panic("does not support unsafe operation")
76}
77
78func (type2 *safeSliceType) LengthOf(obj interface{}) int {
79 return reflect.ValueOf(obj).Elem().Len()
80}
81
82func (type2 *safeSliceType) UnsafeLengthOf(ptr unsafe.Pointer) int {
83 panic("does not support unsafe operation")
84}
85
86func (type2 *safeSliceType) Cap(obj interface{}) int {
87 return reflect.ValueOf(obj).Elem().Cap()
88}
89
90func (type2 *safeSliceType) UnsafeCap(ptr unsafe.Pointer) int {
91 panic("does not support unsafe operation")
92}