github.com/3JoB/go-json@v0.10.4/internal/runtime/rtype.go (about) 1 package runtime 2 3 import ( 4 "unsafe" 5 6 "reflect" 7 ) 8 9 // Type representing reflect.rtype for noescape trick 10 type Type struct{} 11 12 //go:linkname rtype_Align reflect.(*rtype).Align 13 //go:noescape 14 func rtype_Align(*Type) int 15 16 func (t *Type) Align() int { 17 return rtype_Align(t) 18 } 19 20 //go:linkname rtype_FieldAlign reflect.(*rtype).FieldAlign 21 //go:noescape 22 func rtype_FieldAlign(*Type) int 23 24 func (t *Type) FieldAlign() int { 25 return rtype_FieldAlign(t) 26 } 27 28 //go:linkname rtype_Method reflect.(*rtype).Method 29 //go:noescape 30 func rtype_Method(*Type, int) reflect.Method 31 32 func (t *Type) Method(a0 int) reflect.Method { 33 return rtype_Method(t, a0) 34 } 35 36 //go:linkname rtype_MethodByName reflect.(*rtype).MethodByName 37 //go:noescape 38 func rtype_MethodByName(*Type, string) (reflect.Method, bool) 39 40 func (t *Type) MethodByName(a0 string) (reflect.Method, bool) { 41 return rtype_MethodByName(t, a0) 42 } 43 44 //go:linkname rtype_NumMethod reflect.(*rtype).NumMethod 45 //go:noescape 46 func rtype_NumMethod(*Type) int 47 48 func (t *Type) NumMethod() int { 49 return rtype_NumMethod(t) 50 } 51 52 //go:linkname rtype_Name reflect.(*rtype).Name 53 //go:noescape 54 func rtype_Name(*Type) string 55 56 func (t *Type) Name() string { 57 return rtype_Name(t) 58 } 59 60 //go:linkname rtype_PkgPath reflect.(*rtype).PkgPath 61 //go:noescape 62 func rtype_PkgPath(*Type) string 63 64 func (t *Type) PkgPath() string { 65 return rtype_PkgPath(t) 66 } 67 68 //go:linkname rtype_Size reflect.(*rtype).Size 69 //go:noescape 70 func rtype_Size(*Type) uintptr 71 72 func (t *Type) Size() uintptr { 73 return rtype_Size(t) 74 } 75 76 //go:linkname rtype_String reflect.(*rtype).String 77 //go:noescape 78 func rtype_String(*Type) string 79 80 func (t *Type) String() string { 81 return rtype_String(t) 82 } 83 84 //go:linkname rtype_Kind reflect.(*rtype).Kind 85 //go:noescape 86 func rtype_Kind(*Type) reflect.Kind 87 88 func (t *Type) Kind() reflect.Kind { 89 return rtype_Kind(t) 90 } 91 92 //go:linkname rtype_Implements reflect.(*rtype).Implements 93 //go:noescape 94 func rtype_Implements(*Type, reflect.Type) bool 95 96 func (t *Type) Implements(u reflect.Type) bool { 97 return rtype_Implements(t, u) 98 } 99 100 //go:linkname rtype_AssignableTo reflect.(*rtype).AssignableTo 101 //go:noescape 102 func rtype_AssignableTo(*Type, reflect.Type) bool 103 104 func (t *Type) AssignableTo(u reflect.Type) bool { 105 return rtype_AssignableTo(t, u) 106 } 107 108 //go:linkname rtype_ConvertibleTo reflect.(*rtype).ConvertibleTo 109 //go:noescape 110 func rtype_ConvertibleTo(*Type, reflect.Type) bool 111 112 func (t *Type) ConvertibleTo(u reflect.Type) bool { 113 return rtype_ConvertibleTo(t, u) 114 } 115 116 //go:linkname rtype_Comparable reflect.(*rtype).Comparable 117 //go:noescape 118 func rtype_Comparable(*Type) bool 119 120 func (t *Type) Comparable() bool { 121 return rtype_Comparable(t) 122 } 123 124 //go:linkname rtype_Bits reflect.(*rtype).Bits 125 //go:noescape 126 func rtype_Bits(*Type) int 127 128 func (t *Type) Bits() int { 129 return rtype_Bits(t) 130 } 131 132 //go:linkname rtype_ChanDir reflect.(*rtype).ChanDir 133 //go:noescape 134 func rtype_ChanDir(*Type) reflect.ChanDir 135 136 func (t *Type) ChanDir() reflect.ChanDir { 137 return rtype_ChanDir(t) 138 } 139 140 //go:linkname rtype_IsVariadic reflect.(*rtype).IsVariadic 141 //go:noescape 142 func rtype_IsVariadic(*Type) bool 143 144 func (t *Type) IsVariadic() bool { 145 return rtype_IsVariadic(t) 146 } 147 148 //go:linkname rtype_Elem reflect.(*rtype).Elem 149 //go:noescape 150 func rtype_Elem(*Type) reflect.Type 151 152 func (t *Type) Elem() *Type { 153 return Type2RType(rtype_Elem(t)) 154 } 155 156 //go:linkname rtype_Field reflect.(*rtype).Field 157 //go:noescape 158 func rtype_Field(*Type, int) reflect.StructField 159 160 func (t *Type) Field(i int) reflect.StructField { 161 return rtype_Field(t, i) 162 } 163 164 //go:linkname rtype_FieldByIndex reflect.(*rtype).FieldByIndex 165 //go:noescape 166 func rtype_FieldByIndex(*Type, []int) reflect.StructField 167 168 func (t *Type) FieldByIndex(index []int) reflect.StructField { 169 return rtype_FieldByIndex(t, index) 170 } 171 172 //go:linkname rtype_FieldByName reflect.(*rtype).FieldByName 173 //go:noescape 174 func rtype_FieldByName(*Type, string) (reflect.StructField, bool) 175 176 func (t *Type) FieldByName(name string) (reflect.StructField, bool) { 177 return rtype_FieldByName(t, name) 178 } 179 180 //go:linkname rtype_FieldByNameFunc reflect.(*rtype).FieldByNameFunc 181 //go:noescape 182 func rtype_FieldByNameFunc(*Type, func(string) bool) (reflect.StructField, bool) 183 184 func (t *Type) FieldByNameFunc(match func(string) bool) (reflect.StructField, bool) { 185 return rtype_FieldByNameFunc(t, match) 186 } 187 188 //go:linkname rtype_In reflect.(*rtype).In 189 //go:noescape 190 func rtype_In(*Type, int) reflect.Type 191 192 func (t *Type) In(i int) reflect.Type { 193 return rtype_In(t, i) 194 } 195 196 //go:linkname rtype_Key reflect.(*rtype).Key 197 //go:noescape 198 func rtype_Key(*Type) reflect.Type 199 200 func (t *Type) Key() *Type { 201 return Type2RType(rtype_Key(t)) 202 } 203 204 //go:linkname rtype_Len reflect.(*rtype).Len 205 //go:noescape 206 func rtype_Len(*Type) int 207 208 func (t *Type) Len() int { 209 return rtype_Len(t) 210 } 211 212 //go:linkname rtype_NumField reflect.(*rtype).NumField 213 //go:noescape 214 func rtype_NumField(*Type) int 215 216 func (t *Type) NumField() int { 217 return rtype_NumField(t) 218 } 219 220 //go:linkname rtype_NumIn reflect.(*rtype).NumIn 221 //go:noescape 222 func rtype_NumIn(*Type) int 223 224 func (t *Type) NumIn() int { 225 return rtype_NumIn(t) 226 } 227 228 //go:linkname rtype_NumOut reflect.(*rtype).NumOut 229 //go:noescape 230 func rtype_NumOut(*Type) int 231 232 func (t *Type) NumOut() int { 233 return rtype_NumOut(t) 234 } 235 236 //go:linkname rtype_Out reflect.(*rtype).Out 237 //go:noescape 238 func rtype_Out(*Type, int) reflect.Type 239 240 //go:linkname PtrTo reflect.(*rtype).ptrTo 241 //go:noescape 242 func PtrTo(*Type) *Type 243 244 func (t *Type) Out(i int) reflect.Type { 245 return rtype_Out(t, i) 246 } 247 248 //go:linkname IfaceIndir reflect.ifaceIndir 249 //go:noescape 250 func IfaceIndir(*Type) bool 251 252 //go:linkname RType2Type reflect.toType 253 //go:noescape 254 func RType2Type(t *Type) reflect.Type 255 256 //go:nolint structcheck 257 type emptyInterface struct { 258 _ *Type 259 ptr unsafe.Pointer 260 } 261 262 func Type2RType(t reflect.Type) *Type { 263 return (*Type)(((*emptyInterface)(unsafe.Pointer(&t))).ptr) 264 }