@@ -126,7 +126,7 @@ type Type interface {
126
126
// Chan: ChanDir, Elem
127
127
// Func: In, NumIn, Out, NumOut, IsVariadic.
128
128
// Map: Key, Elem
129
- // Ptr : Elem
129
+ // Pointer : Elem
130
130
// Slice: Elem
131
131
// Struct: Field, FieldByIndex, FieldByName, FieldByNameFunc, NumField
132
132
@@ -154,7 +154,7 @@ type Type interface {
154
154
IsVariadic () bool
155
155
156
156
// Elem returns a type's element type.
157
- // It panics if the type's Kind is not Array, Chan, Map, Ptr , or Slice.
157
+ // It panics if the type's Kind is not Array, Chan, Map, Pointer , or Slice.
158
158
Elem () Type
159
159
160
160
// Field returns a struct type's i'th field.
@@ -261,13 +261,18 @@ const (
261
261
Func
262
262
Interface
263
263
Map
264
- Ptr
264
+ Pointer
265
265
Slice
266
266
String
267
267
Struct
268
268
UnsafePointer
269
269
)
270
270
271
+ // Ptr is the old name for the Pointer kind.
272
+ //
273
+ // Deprecated: use the new spelling, Pointer.
274
+ const Ptr = Pointer
275
+
271
276
// tflag is used by an rtype to signal what extra type information is
272
277
// available in the memory directly following the rtype value.
273
278
//
@@ -658,7 +663,7 @@ var kindNames = []string{
658
663
Func : "func" ,
659
664
Interface : "interface" ,
660
665
Map : "map" ,
661
- Ptr : "ptr" ,
666
+ Pointer : "ptr" ,
662
667
Slice : "slice" ,
663
668
String : "string" ,
664
669
Struct : "struct" ,
@@ -741,7 +746,7 @@ func (t *rtype) uncommon() *uncommonType {
741
746
switch t .Kind () {
742
747
case Struct :
743
748
return & (* structTypeUncommon )(unsafe .Pointer (t )).u
744
- case Ptr :
749
+ case Pointer :
745
750
type u struct {
746
751
ptrType
747
752
u uncommonType
@@ -945,7 +950,7 @@ func (t *rtype) Elem() Type {
945
950
case Map :
946
951
tt := (* mapType )(unsafe .Pointer (t ))
947
952
return toType (tt .elem )
948
- case Ptr :
953
+ case Pointer :
949
954
tt := (* ptrType )(unsafe .Pointer (t ))
950
955
return toType (tt .elem )
951
956
case Slice :
@@ -1265,7 +1270,7 @@ func (t *structType) FieldByIndex(index []int) (f StructField) {
1265
1270
for i , x := range index {
1266
1271
if i > 0 {
1267
1272
ft := f .Type
1268
- if ft .Kind () == Ptr && ft .Elem ().Kind () == Struct {
1273
+ if ft .Kind () == Pointer && ft .Elem ().Kind () == Struct {
1269
1274
ft = ft .Elem ()
1270
1275
}
1271
1276
f .Type = ft
@@ -1336,7 +1341,7 @@ func (t *structType) FieldByNameFunc(match func(string) bool) (result StructFiel
1336
1341
if f .embedded () {
1337
1342
// Embedded field of type T or *T.
1338
1343
ntyp = f .typ
1339
- if ntyp .Kind () == Ptr {
1344
+ if ntyp .Kind () == Pointer {
1340
1345
ntyp = ntyp .Elem ().common ()
1341
1346
}
1342
1347
}
@@ -1416,12 +1421,19 @@ func TypeOf(i interface{}) Type {
1416
1421
return toType (eface .typ )
1417
1422
}
1418
1423
1419
- // ptrMap is the cache for PtrTo .
1424
+ // ptrMap is the cache for PointerTo .
1420
1425
var ptrMap sync.Map // map[*rtype]*ptrType
1421
1426
1422
1427
// PtrTo returns the pointer type with element t.
1423
1428
// For example, if t represents type Foo, PtrTo(t) represents *Foo.
1424
- func PtrTo (t Type ) Type {
1429
+ //
1430
+ // Deprecated: use PointerTo. PtrTo is the old spelling.
1431
+ // The two functions behaves identically.
1432
+ func PtrTo (t Type ) Type { return PointerTo (t ) }
1433
+
1434
+ // PointerTo returns the pointer type with element t.
1435
+ // For example, if t represents type Foo, PointerTo(t) represents *Foo.
1436
+ func PointerTo (t Type ) Type {
1425
1437
return t .(* rtype ).ptrTo ()
1426
1438
}
1427
1439
@@ -1695,7 +1707,7 @@ func haveIdenticalUnderlyingType(T, V *rtype, cmpTags bool) bool {
1695
1707
case Map :
1696
1708
return haveIdenticalType (T .Key (), V .Key (), cmpTags ) && haveIdenticalType (T .Elem (), V .Elem (), cmpTags )
1697
1709
1698
- case Ptr , Slice :
1710
+ case Pointer , Slice :
1699
1711
return haveIdenticalType (T .Elem (), V .Elem (), cmpTags )
1700
1712
1701
1713
case Struct :
@@ -2136,7 +2148,7 @@ func funcStr(ft *funcType) string {
2136
2148
// That is, x == x for all values x of type t.
2137
2149
func isReflexive (t * rtype ) bool {
2138
2150
switch t .Kind () {
2139
- case Bool , Int , Int8 , Int16 , Int32 , Int64 , Uint , Uint8 , Uint16 , Uint32 , Uint64 , Uintptr , Chan , Ptr , String , UnsafePointer :
2151
+ case Bool , Int , Int8 , Int16 , Int32 , Int64 , Uint , Uint8 , Uint16 , Uint32 , Uint64 , Uintptr , Chan , Pointer , String , UnsafePointer :
2140
2152
return true
2141
2153
case Float32 , Float64 , Complex64 , Complex128 , Interface :
2142
2154
return false
@@ -2160,7 +2172,7 @@ func isReflexive(t *rtype) bool {
2160
2172
// needKeyUpdate reports whether map overwrites require the key to be copied.
2161
2173
func needKeyUpdate (t * rtype ) bool {
2162
2174
switch t .Kind () {
2163
- case Bool , Int , Int8 , Int16 , Int32 , Int64 , Uint , Uint8 , Uint16 , Uint32 , Uint64 , Uintptr , Chan , Ptr , UnsafePointer :
2175
+ case Bool , Int , Int8 , Int16 , Int32 , Int64 , Uint , Uint8 , Uint16 , Uint32 , Uint64 , Uintptr , Chan , Pointer , UnsafePointer :
2164
2176
return false
2165
2177
case Float32 , Float64 , Complex64 , Complex128 , Interface , String :
2166
2178
// Float keys can be updated from +0 to -0.
@@ -2217,10 +2229,10 @@ const (
2217
2229
2218
2230
func bucketOf (ktyp , etyp * rtype ) * rtype {
2219
2231
if ktyp .size > maxKeySize {
2220
- ktyp = PtrTo (ktyp ).(* rtype )
2232
+ ktyp = PointerTo (ktyp ).(* rtype )
2221
2233
}
2222
2234
if etyp .size > maxValSize {
2223
- etyp = PtrTo (etyp ).(* rtype )
2235
+ etyp = PointerTo (etyp ).(* rtype )
2224
2236
}
2225
2237
2226
2238
// Prepare GC data if any.
@@ -2458,10 +2470,10 @@ func StructOf(fields []StructField) Type {
2458
2470
repr = append (repr , (" " + name )... )
2459
2471
if f .embedded () {
2460
2472
// Embedded field
2461
- if f .typ .Kind () == Ptr {
2473
+ if f .typ .Kind () == Pointer {
2462
2474
// Embedded ** and *interface{} are illegal
2463
2475
elem := ft .Elem ()
2464
- if k := elem .Kind (); k == Ptr || k == Interface {
2476
+ if k := elem .Kind (); k == Pointer || k == Interface {
2465
2477
panic ("reflect.StructOf: illegal embedded field type " + ft .String ())
2466
2478
}
2467
2479
}
@@ -2526,7 +2538,7 @@ func StructOf(fields []StructField) Type {
2526
2538
tfn : resolveReflectText (unsafe .Pointer (& tfn )),
2527
2539
})
2528
2540
}
2529
- case Ptr :
2541
+ case Pointer :
2530
2542
ptr := (* ptrType )(unsafe .Pointer (ft ))
2531
2543
if unt := ptr .uncommon (); unt != nil {
2532
2544
if i > 0 && unt .mcount > 0 {
@@ -3123,7 +3135,7 @@ func addTypeBits(bv *bitVector, offset uintptr, t *rtype) {
3123
3135
}
3124
3136
3125
3137
switch Kind (t .kind & kindMask ) {
3126
- case Chan , Func , Map , Ptr , Slice , String , UnsafePointer :
3138
+ case Chan , Func , Map , Pointer , Slice , String , UnsafePointer :
3127
3139
// 1 pointer at start of representation
3128
3140
for bv .n < uint32 (offset / uintptr (goarch .PtrSize )) {
3129
3141
bv .append (0 )
0 commit comments