...
1 package reflect2
2
3 import (
4 "reflect"
5 "unsafe"
6 )
7
8 type safeType struct {
9 reflect.Type
10 cfg *frozenConfig
11 }
12
13 func (type2 *safeType) New() interface{} {
14 return reflect.New(type2.Type).Interface()
15 }
16
17 func (type2 *safeType) UnsafeNew() unsafe.Pointer {
18 panic("does not support unsafe operation")
19 }
20
21 func (type2 *safeType) Elem() Type {
22 return type2.cfg.Type2(type2.Type.Elem())
23 }
24
25 func (type2 *safeType) Type1() reflect.Type {
26 return type2.Type
27 }
28
29 func (type2 *safeType) PackEFace(ptr unsafe.Pointer) interface{} {
30 panic("does not support unsafe operation")
31 }
32
33 func (type2 *safeType) Implements(thatType Type) bool {
34 return type2.Type.Implements(thatType.Type1())
35 }
36
37 func (type2 *safeType) RType() uintptr {
38 panic("does not support unsafe operation")
39 }
40
41 func (type2 *safeType) Indirect(obj interface{}) interface{} {
42 return reflect.Indirect(reflect.ValueOf(obj)).Interface()
43 }
44
45 func (type2 *safeType) UnsafeIndirect(ptr unsafe.Pointer) interface{} {
46 panic("does not support unsafe operation")
47 }
48
49 func (type2 *safeType) LikePtr() bool {
50 panic("does not support unsafe operation")
51 }
52
53 func (type2 *safeType) IsNullable() bool {
54 return IsNullable(type2.Kind())
55 }
56
57 func (type2 *safeType) IsNil(obj interface{}) bool {
58 if obj == nil {
59 return true
60 }
61 return reflect.ValueOf(obj).Elem().IsNil()
62 }
63
64 func (type2 *safeType) UnsafeIsNil(ptr unsafe.Pointer) bool {
65 panic("does not support unsafe operation")
66 }
67
68 func (type2 *safeType) Set(obj interface{}, val interface{}) {
69 reflect.ValueOf(obj).Elem().Set(reflect.ValueOf(val).Elem())
70 }
71
72 func (type2 *safeType) UnsafeSet(ptr unsafe.Pointer, val unsafe.Pointer) {
73 panic("does not support unsafe operation")
74 }
75
76 func (type2 *safeType) AssignableTo(anotherType Type) bool {
77 return type2.Type1().AssignableTo(anotherType.Type1())
78 }
79
View as plain text