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

.

parent ce695ff1
...@@ -444,7 +444,7 @@ type StoreObject struct { ...@@ -444,7 +444,7 @@ type StoreObject struct {
Serial Tid Serial Tid
Compression bool Compression bool
Checksum Checksum Checksum Checksum
Data []byte // XXX or string ? Data []byte // TODO separately (for writev)
DataSerial Tid DataSerial Tid
Tid Tid Tid Tid
Unlock bool Unlock bool
...@@ -496,7 +496,7 @@ type AnswerGetObject struct { ...@@ -496,7 +496,7 @@ type AnswerGetObject struct {
SerialEnd Tid SerialEnd Tid
Compression bool Compression bool
Checksum Checksum Checksum Checksum
Data []byte // XXX or string ? Data []byte // TODO separately (for writev)
DataSerial Tid DataSerial Tid
} }
......
...@@ -166,7 +166,7 @@ var basicTypes = map[types.BasicKind]basicCodec { ...@@ -166,7 +166,7 @@ var basicTypes = map[types.BasicKind]basicCodec {
types.Float64: {8, "float64_NEOEncode(%v, %v)", "float64_NEODecode(%v)"}, 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) { func typeSizeFixed(typ types.Type) (wireSize int, ok bool) {
switch u := typ.Underlying().(type) { switch u := typ.Underlying().(type) {
case *types.Basic: case *types.Basic:
...@@ -185,6 +185,12 @@ func typeSizeFixed(typ types.Type) (wireSize int, ok bool) { ...@@ -185,6 +185,12 @@ func typeSizeFixed(typ types.Type) (wireSize int, ok bool) {
} }
return wireSize, true return wireSize, true
case *types.Array:
elemSize, ok := typeSizeFixed(u.Elem())
if ok {
return int(u.Len()) * elemSize, ok
}
} }
notfixed: notfixed:
...@@ -498,6 +504,12 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodecCod ...@@ -498,6 +504,12 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodecCod
} }
codegen.genBasic(path, u, typ, obj) 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: case *types.Array:
// TODO optimize for [...]byte // TODO optimize for [...]byte
var i int64 // XXX because `u.Len() int64` var i int64 // XXX because `u.Len() int64`
...@@ -505,12 +517,6 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodecCod ...@@ -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) 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: case *types.Slice:
codegen.genSlice(path, u, obj) 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