-
Notifications
You must be signed in to change notification settings - Fork 24
/
bridge.go
104 lines (90 loc) · 1.86 KB
/
bridge.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package reflect
import (
"reflect"
"unsafe"
)
func toRT(t Type) reflect.Type {
return type_toType(t)
}
func toRTs(t []Type) []reflect.Type {
out := make([]reflect.Type, len(t))
for idx, tt := range t {
out[idx] = toRT(tt)
}
return out
}
func toT(t reflect.Type) Type {
return (Type)(((*Value)(unsafe.Pointer(&t))).ptr)
}
func toRV(v Value) reflect.Value {
return *(*reflect.Value)(unsafe.Pointer(&v))
}
func toRVs(v []Value) []reflect.Value {
out := make([]reflect.Value, len(v))
for idx, vv := range v {
out[idx] = toRV(vv)
}
return out
}
func toV(v reflect.Value) Value {
return *(*Value)(unsafe.Pointer(&v))
}
func toVs(v []reflect.Value) []Value {
out := make([]Value, len(v))
for idx, vv := range v {
out[idx] = toV(vv)
}
return out
}
func toRSFs(v []StructField) []reflect.StructField {
out := make([]reflect.StructField, len(v))
for idx, vv := range v {
out[idx] = toRSF(vv)
}
return out
}
func toRSF(v StructField) reflect.StructField {
return reflect.StructField{
Name: v.Name,
PkgPath: v.PkgPath,
Type: ToReflectType(v.Type),
Tag: v.Tag,
Offset: v.Offset,
Index: v.Index,
Anonymous: v.Anonymous,
}
}
func toSF(v reflect.StructField) StructField {
return StructField{
Name: v.Name,
PkgPath: v.PkgPath,
Type: ToType(v.Type),
Tag: v.Tag,
Offset: v.Offset,
Index: v.Index,
Anonymous: v.Anonymous,
}
}
func toM(v reflect.Method) Method {
return Method{
Name: v.Name,
PkgPath: v.PkgPath,
Type: ToType(v.Type),
Func: toV(v.Func),
Index: v.Index,
}
}
func toRSC(v SelectCase) reflect.SelectCase {
return reflect.SelectCase{
Dir: v.Dir,
Chan: toRV(v.Chan),
Send: toRV(v.Send),
}
}
func toRSCs(v []SelectCase) []reflect.SelectCase {
out := make([]reflect.SelectCase, len(v))
for idx, vv := range v {
out[idx] = toRSC(vv)
}
return out
}