LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 * Runtime type representation; master is type.go | 6 * Runtime type representation; master is type.go |
| 7 * |
| 8 * The *Types here correspond 1-1 to type.go's *Type's, but are |
| 9 * prefixed with an extra header of 2 pointers, corresponding to the |
| 10 * interface{} structure, which itself is called type Type again on |
| 11 * the Go side. |
7 */ | 12 */ |
8 | 13 |
9 typedef struct CommonGoType CommonGoType; | 14 typedef struct CommonType CommonType; |
10 typedef struct UncommonGoType UncommonGoType; | 15 typedef struct UncommonType UncommonType; |
11 typedef struct InterfaceGoType InterfaceGoType; | 16 typedef struct InterfaceType InterfaceType; |
12 typedef struct Method Method; | 17 typedef struct Method Method; |
13 typedef struct IMethod IMethod; | 18 typedef struct IMethod IMethod; |
14 typedef struct MapGoType MapGoType; | 19 typedef struct MapType MapType; |
15 typedef struct ChanGoType ChanGoType; | 20 typedef struct ChanType ChanType; |
16 typedef struct SliceGoType SliceGoType; | 21 typedef struct SliceType SliceType; |
17 typedef struct FuncGoType FuncGoType; | 22 typedef struct FuncType FuncType; |
18 | 23 |
19 struct CommonGoType | 24 struct CommonType |
20 { | 25 { |
21 uintptr size; | 26 uintptr size; |
22 uint32 hash; | 27 uint32 hash; |
23 uint8 alg; | 28 uint8 alg; |
24 uint8 align; | 29 uint8 align; |
25 uint8 fieldAlign; | 30 uint8 fieldAlign; |
26 uint8 kind; | 31 uint8 kind; |
27 String *string; | 32 String *string; |
28 » UncommonGoType *x; | 33 » UncommonType *x; |
29 }; | 34 }; |
30 | 35 |
31 enum { | 36 enum { |
32 KindBool = 1, | 37 KindBool = 1, |
33 KindInt, | 38 KindInt, |
34 KindInt8, | 39 KindInt8, |
35 KindInt16, | 40 KindInt16, |
36 KindInt32, | 41 KindInt32, |
37 KindInt64, | 42 KindInt64, |
38 KindUint, | 43 KindUint, |
(...skipping 17 matching lines...) Expand all Loading... |
56 KindStruct, | 61 KindStruct, |
57 KindUnsafePointer, | 62 KindUnsafePointer, |
58 ········ | 63 ········ |
59 KindNoPointers = 1<<7, | 64 KindNoPointers = 1<<7, |
60 }; | 65 }; |
61 | 66 |
62 struct Method | 67 struct Method |
63 { | 68 { |
64 String *name; | 69 String *name; |
65 String *pkgPath; | 70 String *pkgPath; |
66 » GoType» *mtyp; | 71 » Type» *mtyp; |
67 » GoType *typ; | 72 » Type *typ; |
68 void (*ifn)(void); | 73 void (*ifn)(void); |
69 void (*tfn)(void); | 74 void (*tfn)(void); |
70 }; | 75 }; |
71 | 76 |
72 struct UncommonGoType | 77 struct UncommonType |
73 { | 78 { |
74 String *name; | 79 String *name; |
75 String *pkgPath; | 80 String *pkgPath; |
76 Slice mhdr; | 81 Slice mhdr; |
77 Method m[]; | 82 Method m[]; |
78 }; | 83 }; |
79 | 84 |
80 struct GoType | 85 struct Type |
81 { | 86 { |
82 void *type; // interface{} value | 87 void *type; // interface{} value |
83 void *ptr; | 88 void *ptr; |
84 » CommonGoType; | 89 » CommonType; |
85 }; | 90 }; |
86 | 91 |
87 struct IMethod | 92 struct IMethod |
88 { | 93 { |
89 String *name; | 94 String *name; |
90 String *pkgPath; | 95 String *pkgPath; |
91 » GoType *type; | 96 » Type *type; |
92 }; | 97 }; |
93 | 98 |
94 struct InterfaceGoType | 99 struct InterfaceType |
95 { | 100 { |
96 » GoType; | 101 » Type; |
97 Slice mhdr; | 102 Slice mhdr; |
98 IMethod m[]; | 103 IMethod m[]; |
99 }; | 104 }; |
100 | 105 |
101 struct MapGoType | 106 struct MapType |
102 { | 107 { |
103 » GoType; | 108 » Type; |
104 » GoType *key; | 109 » Type *key; |
105 » GoType *elem; | 110 » Type *elem; |
106 }; | 111 }; |
107 | 112 |
108 struct ChanGoType | 113 struct ChanType |
109 { | 114 { |
110 » GoType; | 115 » Type; |
111 » GoType *elem; | 116 » Type *elem; |
112 uintptr dir; | 117 uintptr dir; |
113 }; | 118 }; |
114 | 119 |
115 struct SliceGoType | 120 struct SliceType |
116 { | 121 { |
117 » GoType; | 122 » Type; |
118 » GoType *elem; | 123 » Type *elem; |
119 }; | 124 }; |
120 | 125 |
121 struct FuncGoType | 126 struct FuncType |
122 { | 127 { |
123 » GoType; | 128 » Type; |
124 bool dotdotdot; | 129 bool dotdotdot; |
125 Slice in; | 130 Slice in; |
126 Slice out; | 131 Slice out; |
127 }; | 132 }; |
LEFT | RIGHT |