|
|
|
|
@@ -242,12 +242,22 @@ func decodeAnyOrError(decoder *Decoder, destination reflect.Value, tag Tag) (n i
|
|
|
|
|
}
|
|
|
|
|
lengthCast, err := Uint64ToIntSafe(length)
|
|
|
|
|
if err != nil { return n, err }
|
|
|
|
|
if isTypeAny(destination.Type()) {
|
|
|
|
|
// need a skeleton value if we are assigning to any.
|
|
|
|
|
value := reflect.MakeMapWithSize(reflect.TypeOf(dummyMap), lengthCast)
|
|
|
|
|
destination.Set(value)
|
|
|
|
|
destination = value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// im fucking so done dude. im so fucking done. this was
|
|
|
|
|
// supposed to only run when we need it but i guess it runs all
|
|
|
|
|
// the time, because when we get a map destination (a valid,
|
|
|
|
|
// allocated one) we break apart on SetMapIndex because of a nil
|
|
|
|
|
// map. yeah thats right. a fucking nil map panic. on the map we
|
|
|
|
|
// just allocated. but running this unconditionally (whether or
|
|
|
|
|
// not we receive an empty any value) actually makes it fucking
|
|
|
|
|
// work. go figure().
|
|
|
|
|
//
|
|
|
|
|
// (the map allocation functionality in skeletonPointer has been
|
|
|
|
|
// removed)
|
|
|
|
|
value := reflect.MakeMapWithSize(reflect.TypeOf(dummyMap), lengthCast)
|
|
|
|
|
destination.Set(value)
|
|
|
|
|
destination = value
|
|
|
|
|
|
|
|
|
|
destination.Clear()
|
|
|
|
|
for _ = range lengthCast {
|
|
|
|
|
key, nn, err := decoder.ReadUint16()
|
|
|
|
|
@@ -387,7 +397,11 @@ func canSet(destination reflect.Type, tag Tag) error {
|
|
|
|
|
return errCantAssignf("cannot assign array to %v", destination)
|
|
|
|
|
}
|
|
|
|
|
case KTV:
|
|
|
|
|
if destination != reflect.TypeOf(dummyMap) {
|
|
|
|
|
cantAssign :=
|
|
|
|
|
destination.Kind() != reflect.Map ||
|
|
|
|
|
destination.Key().Kind() != reflect.Uint16 ||
|
|
|
|
|
!isTypeAny(destination.Elem())
|
|
|
|
|
if cantAssign {
|
|
|
|
|
return errCantAssignf("cannot assign table to %v", destination)
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
@@ -497,9 +511,6 @@ func skeletonPointer(decoder *Decoder, tag Tag) (reflect.Value, error) {
|
|
|
|
|
typ, err := typeOf(decoder, tag)
|
|
|
|
|
if err != nil { return reflect.Value { }, err }
|
|
|
|
|
value := reflect.New(typ)
|
|
|
|
|
if tag.Is(KTV) {
|
|
|
|
|
value.Elem().Set(reflect.MakeMap(typ))
|
|
|
|
|
}
|
|
|
|
|
return value, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|