reflect: add Type.Bits method, add tags to prohibit conversions

gob: substitute slice for map

R=r
CC=golang-dev
https://golang.org/cl/1699045
This commit is contained in:
Russ Cox 2010-06-21 13:19:29 -07:00
parent 2fc0b4f01b
commit fc090a3a54
9 changed files with 112 additions and 144 deletions

View file

@ -540,7 +540,7 @@ func ignoreSlice(state *decodeState, elemOp decOp) os.Error {
return ignoreArrayHelper(state, elemOp, int(decodeUint(state)))
}
var decOpMap = map[reflect.Kind]decOp{
var decOpMap = []decOp{
reflect.Bool: decBool,
reflect.Int8: decInt8,
reflect.Int16: decInt16,
@ -568,8 +568,12 @@ var decIgnoreOpMap = map[typeId]decOp{
// the indirection count to reach it.
func (dec *Decoder) decOpFor(wireId typeId, rt reflect.Type, name string) (decOp, int, os.Error) {
typ, indir := indirect(rt)
op, ok := decOpMap[typ.Kind()]
if !ok {
var op decOp
k := typ.Kind()
if int(k) < len(decOpMap) {
op = decOpMap[k]
}
if op == nil {
// Special cases
switch t := typ.(type) {
case *reflect.ArrayType: