|
|
@ -26,32 +26,37 @@ func Hash(base string, name string) SerializedType {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type SerializedType uint64
|
|
|
|
type SerializedType uint64
|
|
|
|
|
|
|
|
|
|
|
|
func (t SerializedType) String() string {
|
|
|
|
func (t SerializedType) String() string {
|
|
|
|
return fmt.Sprintf("0x%x", uint64(t))
|
|
|
|
return fmt.Sprintf("0x%x", uint64(t))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type ExtType SerializedType
|
|
|
|
type ExtType SerializedType
|
|
|
|
|
|
|
|
|
|
|
|
func (t ExtType) String() string {
|
|
|
|
func (t ExtType) String() string {
|
|
|
|
return fmt.Sprintf("0x%x", uint64(t))
|
|
|
|
return fmt.Sprintf("0x%x", uint64(t))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type NodeType SerializedType
|
|
|
|
type NodeType SerializedType
|
|
|
|
|
|
|
|
|
|
|
|
func (t NodeType) String() string {
|
|
|
|
func (t NodeType) String() string {
|
|
|
|
return fmt.Sprintf("0x%x", uint64(t))
|
|
|
|
return fmt.Sprintf("0x%x", uint64(t))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type SignalType SerializedType
|
|
|
|
type SignalType SerializedType
|
|
|
|
|
|
|
|
|
|
|
|
func (t SignalType) String() string {
|
|
|
|
func (t SignalType) String() string {
|
|
|
|
return fmt.Sprintf("0x%x", uint64(t))
|
|
|
|
return fmt.Sprintf("0x%x", uint64(t))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type PolicyType SerializedType
|
|
|
|
type PolicyType SerializedType
|
|
|
|
|
|
|
|
|
|
|
|
func (t PolicyType) String() string {
|
|
|
|
func (t PolicyType) String() string {
|
|
|
|
return fmt.Sprintf("0x%x", uint64(t))
|
|
|
|
return fmt.Sprintf("0x%x", uint64(t))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type TypeSerialize func(*Context,SerializedType,reflect.Type,*reflect.Value) (SerializedValue, error)
|
|
|
|
type TypeSerialize func(*Context, SerializedType, reflect.Type, *reflect.Value) (SerializedValue, error)
|
|
|
|
type TypeDeserialize func(*Context,SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error)
|
|
|
|
type TypeDeserialize func(*Context, SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error)
|
|
|
|
|
|
|
|
|
|
|
|
func NewExtType(name string) ExtType {
|
|
|
|
func NewExtType(name string) ExtType {
|
|
|
|
return ExtType(Hash(ExtTypeBase, name))
|
|
|
|
return ExtType(Hash(ExtTypeBase, name))
|
|
|
@ -84,13 +89,14 @@ var (
|
|
|
|
StopSignalType = NewSignalType("STOP")
|
|
|
|
StopSignalType = NewSignalType("STOP")
|
|
|
|
CreateSignalType = NewSignalType("CREATE")
|
|
|
|
CreateSignalType = NewSignalType("CREATE")
|
|
|
|
StartSignalType = NewSignalType("START")
|
|
|
|
StartSignalType = NewSignalType("START")
|
|
|
|
ErrorSignalType = NewSignalType("ERROR")
|
|
|
|
|
|
|
|
StatusSignalType = NewSignalType("STATUS")
|
|
|
|
StatusSignalType = NewSignalType("STATUS")
|
|
|
|
LinkSignalType = NewSignalType("LINK")
|
|
|
|
LinkSignalType = NewSignalType("LINK")
|
|
|
|
LockSignalType = NewSignalType("LOCK")
|
|
|
|
LockSignalType = NewSignalType("LOCK")
|
|
|
|
ReadSignalType = NewSignalType("READ")
|
|
|
|
ReadSignalType = NewSignalType("READ")
|
|
|
|
ReadResultSignalType = NewSignalType("READ_RESULT")
|
|
|
|
|
|
|
|
ACLTimeoutSignalType = NewSignalType("ACL_TIMEOUT")
|
|
|
|
ACLTimeoutSignalType = NewSignalType("ACL_TIMEOUT")
|
|
|
|
|
|
|
|
ErrorSignalType = NewSignalType("ERROR")
|
|
|
|
|
|
|
|
SuccessSignalType = NewSignalType("SUCCESS")
|
|
|
|
|
|
|
|
ReadResultSignalType = NewSignalType("READ_RESULT")
|
|
|
|
|
|
|
|
|
|
|
|
MemberOfPolicyType = NewPolicyType("USER_OF")
|
|
|
|
MemberOfPolicyType = NewPolicyType("USER_OF")
|
|
|
|
RequirementOfPolicyType = NewPolicyType("REQUIEMENT_OF")
|
|
|
|
RequirementOfPolicyType = NewPolicyType("REQUIEMENT_OF")
|
|
|
@ -134,9 +140,12 @@ var (
|
|
|
|
PendingACLType = NewSerializedType("PENDING_ACL")
|
|
|
|
PendingACLType = NewSerializedType("PENDING_ACL")
|
|
|
|
PendingSignalType = NewSerializedType("PENDING_SIGNAL")
|
|
|
|
PendingSignalType = NewSerializedType("PENDING_SIGNAL")
|
|
|
|
TimeType = NewSerializedType("TIME")
|
|
|
|
TimeType = NewSerializedType("TIME")
|
|
|
|
|
|
|
|
ResultType = NewSerializedType("RESULT")
|
|
|
|
|
|
|
|
TreeType = NewSerializedType("TREE")
|
|
|
|
|
|
|
|
SerializedTypeSerialized = NewSerializedType("SERIALIZED_TYPE")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func SerializeArray(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value)(SerializedValue,error){
|
|
|
|
func SerializeArray(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value) (SerializedValue, error) {
|
|
|
|
type_stack := []SerializedType{ctx_type}
|
|
|
|
type_stack := []SerializedType{ctx_type}
|
|
|
|
if value == nil {
|
|
|
|
if value == nil {
|
|
|
|
return SerializedValue{
|
|
|
|
return SerializedValue{
|
|
|
@ -164,7 +173,7 @@ func SerializeArray(ctx *Context, ctx_type SerializedType, reflect_type reflect.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func DeserializeArray[T any](ctx *Context)(func(ctx *Context, value SerializedValue)(reflect.Type,*reflect.Value,SerializedValue,error)){
|
|
|
|
func DeserializeArray[T any](ctx *Context) func(ctx *Context, value SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
var zero T
|
|
|
|
var zero T
|
|
|
|
array_type := reflect.TypeOf(zero)
|
|
|
|
array_type := reflect.TypeOf(zero)
|
|
|
|
array_size := array_type.Len()
|
|
|
|
array_size := array_type.Len()
|
|
|
@ -173,7 +182,7 @@ func DeserializeArray[T any](ctx *Context)(func(ctx *Context, value SerializedVa
|
|
|
|
panic(err)
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
saved_type_stack := zero_value.TypeStack
|
|
|
|
saved_type_stack := zero_value.TypeStack
|
|
|
|
return func(ctx *Context, value SerializedValue)(reflect.Type,*reflect.Value,SerializedValue,error){
|
|
|
|
return func(ctx *Context, value SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
if value.Data == nil {
|
|
|
|
if value.Data == nil {
|
|
|
|
return array_type, nil, value, nil
|
|
|
|
return array_type, nil, value, nil
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -198,7 +207,7 @@ func DeserializeArray[T any](ctx *Context)(func(ctx *Context, value SerializedVa
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func SerializeUintN(size int)(func(*Context,SerializedType,reflect.Type,*reflect.Value)(SerializedValue,error)){
|
|
|
|
func SerializeUintN(size int) func(*Context, SerializedType, reflect.Type, *reflect.Value) (SerializedValue, error) {
|
|
|
|
var fill_data func([]byte, uint64) = nil
|
|
|
|
var fill_data func([]byte, uint64) = nil
|
|
|
|
switch size {
|
|
|
|
switch size {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
@ -220,7 +229,7 @@ func SerializeUintN(size int)(func(*Context,SerializedType,reflect.Type,*reflect
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("Cannot serialize uint of size %d", size))
|
|
|
|
panic(fmt.Sprintf("Cannot serialize uint of size %d", size))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return func(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value)(SerializedValue,error){
|
|
|
|
return func(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value) (SerializedValue, error) {
|
|
|
|
var data []byte = nil
|
|
|
|
var data []byte = nil
|
|
|
|
if value != nil {
|
|
|
|
if value != nil {
|
|
|
|
data = make([]byte, size)
|
|
|
|
data = make([]byte, size)
|
|
|
@ -233,7 +242,9 @@ func SerializeUintN(size int)(func(*Context,SerializedType,reflect.Type,*reflect
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func DeserializeUintN[T interface{~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64}](size int)(func(ctx *Context, value SerializedValue)(reflect.Type,*reflect.Value,SerializedValue,error)){
|
|
|
|
func DeserializeUintN[T interface {
|
|
|
|
|
|
|
|
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
|
|
|
|
|
|
|
|
}](size int) func(ctx *Context, value SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
var get_uint func([]byte) uint64
|
|
|
|
var get_uint func([]byte) uint64
|
|
|
|
switch size {
|
|
|
|
switch size {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
@ -257,7 +268,7 @@ func DeserializeUintN[T interface{~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var zero T
|
|
|
|
var zero T
|
|
|
|
uint_type := reflect.TypeOf(zero)
|
|
|
|
uint_type := reflect.TypeOf(zero)
|
|
|
|
return func(ctx *Context, value SerializedValue)(reflect.Type,*reflect.Value,SerializedValue,error){
|
|
|
|
return func(ctx *Context, value SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
if value.Data == nil {
|
|
|
|
if value.Data == nil {
|
|
|
|
return uint_type, nil, value, nil
|
|
|
|
return uint_type, nil, value, nil
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -274,7 +285,7 @@ func DeserializeUintN[T interface{~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func SerializeIntN(size int)(func(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value)(SerializedValue,error)){
|
|
|
|
func SerializeIntN(size int) func(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value) (SerializedValue, error) {
|
|
|
|
var fill_data func([]byte, int64) = nil
|
|
|
|
var fill_data func([]byte, int64) = nil
|
|
|
|
switch size {
|
|
|
|
switch size {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
@ -296,7 +307,7 @@ func SerializeIntN(size int)(func(ctx *Context, ctx_type SerializedType, reflect
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("Cannot serialize int of size %d", size))
|
|
|
|
panic(fmt.Sprintf("Cannot serialize int of size %d", size))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return func(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value)(SerializedValue,error){
|
|
|
|
return func(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value) (SerializedValue, error) {
|
|
|
|
var data []byte = nil
|
|
|
|
var data []byte = nil
|
|
|
|
if value != nil {
|
|
|
|
if value != nil {
|
|
|
|
data = make([]byte, size)
|
|
|
|
data = make([]byte, size)
|
|
|
@ -309,7 +320,9 @@ func SerializeIntN(size int)(func(ctx *Context, ctx_type SerializedType, reflect
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func DeserializeIntN[T interface{~int | ~int8 | ~int16 | ~int32 | ~int64}](size int)(func(ctx *Context, value SerializedValue)(reflect.Type,*reflect.Value,SerializedValue,error)){
|
|
|
|
func DeserializeIntN[T interface {
|
|
|
|
|
|
|
|
~int | ~int8 | ~int16 | ~int32 | ~int64
|
|
|
|
|
|
|
|
}](size int) func(ctx *Context, value SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
var get_int func([]byte) int64
|
|
|
|
var get_int func([]byte) int64
|
|
|
|
switch size {
|
|
|
|
switch size {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
@ -333,7 +346,7 @@ func DeserializeIntN[T interface{~int | ~int8 | ~int16 | ~int32 | ~int64}](size
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var zero T
|
|
|
|
var zero T
|
|
|
|
int_type := reflect.TypeOf(zero)
|
|
|
|
int_type := reflect.TypeOf(zero)
|
|
|
|
return func(ctx *Context, value SerializedValue)(reflect.Type,*reflect.Value,SerializedValue,error){
|
|
|
|
return func(ctx *Context, value SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
if value.Data == nil {
|
|
|
|
if value.Data == nil {
|
|
|
|
return int_type, nil, value, nil
|
|
|
|
return int_type, nil, value, nil
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -370,10 +383,10 @@ type Deserializable interface {
|
|
|
|
var deserializable_zero Deserializable = nil
|
|
|
|
var deserializable_zero Deserializable = nil
|
|
|
|
var DeserializableType = reflect.TypeOf(&deserializable_zero).Elem()
|
|
|
|
var DeserializableType = reflect.TypeOf(&deserializable_zero).Elem()
|
|
|
|
|
|
|
|
|
|
|
|
func structInfo(ctx *Context, struct_type reflect.Type)StructInfo{
|
|
|
|
func structInfo(ctx *Context, struct_type reflect.Type) StructInfo {
|
|
|
|
field_order := []SerializedType{}
|
|
|
|
field_order := []SerializedType{}
|
|
|
|
field_map := map[SerializedType]FieldInfo{}
|
|
|
|
field_map := map[SerializedType]FieldInfo{}
|
|
|
|
for _, field := range(reflect.VisibleFields(struct_type)) {
|
|
|
|
for _, field := range reflect.VisibleFields(struct_type) {
|
|
|
|
gv_tag, tagged_gv := field.Tag.Lookup("gv")
|
|
|
|
gv_tag, tagged_gv := field.Tag.Lookup("gv")
|
|
|
|
if tagged_gv == false {
|
|
|
|
if tagged_gv == false {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
@ -396,7 +409,7 @@ func structInfo(ctx *Context, struct_type reflect.Type)StructInfo{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sort.Slice(field_order, func(i, j int)bool {
|
|
|
|
sort.Slice(field_order, func(i, j int) bool {
|
|
|
|
return uint64(field_order[i]) < uint64(field_order[j])
|
|
|
|
return uint64(field_order[i]) < uint64(field_order[j])
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
@ -423,16 +436,16 @@ func structInfo(ctx *Context, struct_type reflect.Type)StructInfo{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func SerializeStruct(ctx *Context, struct_type reflect.Type)(func(*Context,SerializedType,reflect.Type,*reflect.Value)(SerializedValue,error)){
|
|
|
|
func SerializeStruct(ctx *Context, struct_type reflect.Type) func(*Context, SerializedType, reflect.Type, *reflect.Value) (SerializedValue, error) {
|
|
|
|
struct_info := structInfo(ctx, struct_type)
|
|
|
|
struct_info := structInfo(ctx, struct_type)
|
|
|
|
return func(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value)(SerializedValue,error){
|
|
|
|
return func(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value) (SerializedValue, error) {
|
|
|
|
type_stack := []SerializedType{ctx_type}
|
|
|
|
type_stack := []SerializedType{ctx_type}
|
|
|
|
var data []byte
|
|
|
|
var data []byte
|
|
|
|
if value == nil {
|
|
|
|
if value == nil {
|
|
|
|
data = nil
|
|
|
|
data = nil
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
data = make([]byte, 8)
|
|
|
|
data = make([]byte, 8)
|
|
|
|
for _, field_hash := range(struct_info.FieldOrder) {
|
|
|
|
for _, field_hash := range struct_info.FieldOrder {
|
|
|
|
field_hash_bytes := make([]byte, 8)
|
|
|
|
field_hash_bytes := make([]byte, 8)
|
|
|
|
binary.BigEndian.PutUint64(field_hash_bytes, uint64(field_hash))
|
|
|
|
binary.BigEndian.PutUint64(field_hash_bytes, uint64(field_hash))
|
|
|
|
field_info := struct_info.FieldMap[field_hash]
|
|
|
|
field_info := struct_info.FieldMap[field_hash]
|
|
|
@ -453,9 +466,9 @@ func SerializeStruct(ctx *Context, struct_type reflect.Type)(func(*Context,Seria
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func DeserializeStruct(ctx *Context, struct_type reflect.Type)(func(*Context,SerializedValue)(reflect.Type,*reflect.Value,SerializedValue,error)){
|
|
|
|
func DeserializeStruct(ctx *Context, struct_type reflect.Type) func(*Context, SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
struct_info := structInfo(ctx, struct_type)
|
|
|
|
struct_info := structInfo(ctx, struct_type)
|
|
|
|
return func(ctx *Context, value SerializedValue)(reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
return func(ctx *Context, value SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
if value.Data == nil {
|
|
|
|
if value.Data == nil {
|
|
|
|
return struct_info.Type, nil, value, nil
|
|
|
|
return struct_info.Type, nil, value, nil
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -511,7 +524,7 @@ func DeserializeStruct(ctx *Context, struct_type reflect.Type)(func(*Context,Ser
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func SerializeInterface(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value)(SerializedValue,error){
|
|
|
|
func SerializeInterface(ctx *Context, ctx_type SerializedType, reflect_type reflect.Type, value *reflect.Value) (SerializedValue, error) {
|
|
|
|
var data []byte
|
|
|
|
var data []byte
|
|
|
|
type_stack := []SerializedType{ctx_type}
|
|
|
|
type_stack := []SerializedType{ctx_type}
|
|
|
|
if value == nil {
|
|
|
|
if value == nil {
|
|
|
@ -537,8 +550,8 @@ func SerializeInterface(ctx *Context, ctx_type SerializedType, reflect_type refl
|
|
|
|
}, nil
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func DeserializeInterface[T any]()(func(*Context,SerializedValue)(reflect.Type,*reflect.Value,SerializedValue,error)){
|
|
|
|
func DeserializeInterface[T any]() func(*Context, SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
return func(ctx *Context, value SerializedValue)(reflect.Type, *reflect.Value, SerializedValue, error){
|
|
|
|
return func(ctx *Context, value SerializedValue) (reflect.Type, *reflect.Value, SerializedValue, error) {
|
|
|
|
var interface_zero T
|
|
|
|
var interface_zero T
|
|
|
|
var interface_type = reflect.ValueOf(&interface_zero).Type().Elem()
|
|
|
|
var interface_type = reflect.ValueOf(&interface_zero).Type().Elem()
|
|
|
|
if value.Data == nil {
|
|
|
|
if value.Data == nil {
|
|
|
@ -641,7 +654,7 @@ func ExtField(ctx *Context, ext Extension, field_name string) (reflect.Value, er
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ext_value := reflect.ValueOf(ext).Elem()
|
|
|
|
ext_value := reflect.ValueOf(ext).Elem()
|
|
|
|
for _, field := range(reflect.VisibleFields(ext_value.Type())) {
|
|
|
|
for _, field := range reflect.VisibleFields(ext_value.Type()) {
|
|
|
|
gv_tag, tagged := field.Tag.Lookup("gv")
|
|
|
|
gv_tag, tagged := field.Tag.Lookup("gv")
|
|
|
|
if tagged == true && gv_tag == field_name {
|
|
|
|
if tagged == true && gv_tag == field_name {
|
|
|
|
return ext_value.FieldByIndex(field.Index), nil
|
|
|
|
return ext_value.FieldByIndex(field.Index), nil
|
|
|
@ -665,9 +678,9 @@ func (value SerializedValue) MarshalBinary() ([]byte, error) {
|
|
|
|
binary.BigEndian.PutUint64(data[0:8], uint64(len(value.TypeStack)))
|
|
|
|
binary.BigEndian.PutUint64(data[0:8], uint64(len(value.TypeStack)))
|
|
|
|
binary.BigEndian.PutUint64(data[8:16], uint64(len(value.Data)))
|
|
|
|
binary.BigEndian.PutUint64(data[8:16], uint64(len(value.Data)))
|
|
|
|
|
|
|
|
|
|
|
|
for i, t := range(value.TypeStack) {
|
|
|
|
for i, t := range value.TypeStack {
|
|
|
|
type_start := (i+2)*8
|
|
|
|
type_start := (i + 2) * 8
|
|
|
|
type_end := (i+3)*8
|
|
|
|
type_end := (i + 3) * 8
|
|
|
|
binary.BigEndian.PutUint64(data[type_start:type_end], uint64(t))
|
|
|
|
binary.BigEndian.PutUint64(data[type_start:type_end], uint64(t))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -686,12 +699,12 @@ func ParseSerializedValue(data []byte) (SerializedValue, []byte, error) {
|
|
|
|
data_size := int(binary.BigEndian.Uint64(data[8:16]))
|
|
|
|
data_size := int(binary.BigEndian.Uint64(data[8:16]))
|
|
|
|
type_stack := make([]SerializedType, num_types)
|
|
|
|
type_stack := make([]SerializedType, num_types)
|
|
|
|
for i := 0; i < num_types; i += 1 {
|
|
|
|
for i := 0; i < num_types; i += 1 {
|
|
|
|
type_start := (i+2) * 8
|
|
|
|
type_start := (i + 2) * 8
|
|
|
|
type_end := (i+3) * 8
|
|
|
|
type_end := (i + 3) * 8
|
|
|
|
type_stack[i] = SerializedType(binary.BigEndian.Uint64(data[type_start:type_end]))
|
|
|
|
type_stack[i] = SerializedType(binary.BigEndian.Uint64(data[type_start:type_end]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
types_end := 8*(num_types + 2)
|
|
|
|
types_end := 8 * (num_types + 2)
|
|
|
|
data_end := types_end + data_size
|
|
|
|
data_end := types_end + data_size
|
|
|
|
return SerializedValue{
|
|
|
|
return SerializedValue{
|
|
|
|
type_stack,
|
|
|
|
type_stack,
|
|
|
|