Commit 30bc8903 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ce695ff1
......@@ -444,7 +444,7 @@ type StoreObject struct {
Serial Tid
Compression bool
Checksum Checksum
Data []byte // XXX or string ?
Data []byte // TODO separately (for writev)
DataSerial Tid
Tid Tid
Unlock bool
......@@ -496,7 +496,7 @@ type AnswerGetObject struct {
SerialEnd Tid
Compression bool
Checksum Checksum
Data []byte // XXX or string ?
Data []byte // TODO separately (for writev)
DataSerial Tid
}
......
......@@ -166,7 +166,7 @@ var basicTypes = map[types.BasicKind]basicCodec {
types.Float64: {8, "float64_NEOEncode(%v, %v)", "float64_NEODecode(%v)"},
}
// does a type have fixed wire size and what it is
// does a type have fixed wire size and, if yes, what it is?
func typeSizeFixed(typ types.Type) (wireSize int, ok bool) {
switch u := typ.Underlying().(type) {
case *types.Basic:
......@@ -185,6 +185,12 @@ func typeSizeFixed(typ types.Type) (wireSize int, ok bool) {
}
return wireSize, true
case *types.Array:
elemSize, ok := typeSizeFixed(u.Elem())
if ok {
return int(u.Len()) * elemSize, ok
}
}
notfixed:
......@@ -498,6 +504,12 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodecCod
}
codegen.genBasic(path, u, typ, obj)
case *types.Struct:
for i := 0; i < u.NumFields(); i++ {
v := u.Field(i)
codegenType(path + "." + v.Name(), v.Type(), v, codegen)
}
case *types.Array:
// TODO optimize for [...]byte
var i int64 // XXX because `u.Len() int64`
......@@ -505,12 +517,6 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodecCod
codegenType(fmt.Sprintf("%v[%v]", path, i), u.Elem(), obj, codegen)
}
case *types.Struct:
for i := 0; i < u.NumFields(); i++ {
v := u.Field(i)
codegenType(path + "." + v.Name(), v.Type(), v, codegen)
}
case *types.Slice:
codegen.genSlice(path, u, obj)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment