uint16 plz6 plz6 plz6 plz6 plz6 plz

types
Jordan Orelli 8 years ago
parent 53793b695c
commit f1c4db00fb

@ -0,0 +1,16 @@
package ent
import (
"github.com/jordanorelli/hyperstone/bit"
)
var atom_types = map[string]tÿpe{
"uint16": {"uint16", func(...interface{}) value { return new(uint16_v) }},
}
type uint16_v uint16
func (u *uint16_v) read(r bit.Reader) error {
*u = uint16_v(bit.ReadVarInt(r))
return r.Err()
}

@ -1,7 +1,6 @@
package ent
import (
"bytes"
"fmt"
"github.com/jordanorelli/hyperstone/dota"
)
@ -15,33 +14,11 @@ func (f *field) fromProto(flat *dota.ProtoFlattenedSerializerFieldT, env *Env) e
var_name := env.symbol(int(flat.GetVarNameSym()))
var_type := env.symbol(int(flat.GetVarTypeSym()))
var pretty bytes.Buffer
fmt.Fprintf(&pretty, "{name: %s type: %s", var_name, var_type)
if flat.BitCount != nil {
fmt.Fprintf(&pretty, " bits: %d", flat.GetBitCount())
if t, ok := atom_types[var_type]; ok {
f.name = var_name
f.tÿpe = t
return nil
}
if flat.LowValue != nil {
fmt.Fprintf(&pretty, " low: %f", flat.GetLowValue())
}
if flat.HighValue != nil {
fmt.Fprintf(&pretty, " high: %f", flat.GetHighValue())
}
if flat.EncodeFlags != nil {
fmt.Fprintf(&pretty, " flags: %d", flat.GetEncodeFlags())
}
if flat.FieldSerializerNameSym != nil {
fmt.Fprintf(&pretty, " serializer: %s", env.symbol(int(flat.GetFieldSerializerNameSym())))
}
if flat.FieldSerializerVersion != nil {
fmt.Fprintf(&pretty, " s_version: %d", flat.GetFieldSerializerVersion())
}
if flat.SendNodeSym != nil {
fmt.Fprintf(&pretty, " send: %s", env.symbol(int(flat.GetSendNodeSym())))
}
if flat.VarEncoderSym != nil {
fmt.Fprintf(&pretty, " var_enc: %s", env.symbol(int(flat.GetVarEncoderSym())))
}
fmt.Fprint(&pretty, "}")
return fmt.Errorf("unable to parse type: %s", pretty.String())
return fmt.Errorf("unable to parse type: %s", prettyFlatField(flat, env))
}

@ -1,6 +1,9 @@
package ent
import (
"bytes"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/jordanorelli/hyperstone/bit"
@ -25,3 +28,37 @@ func getSerializers(m *dota.CDemoSendTables) (*dota.CSVCMsg_FlattenedSerializer,
}
return &flat, nil
}
func prettyFlatField(flat *dota.ProtoFlattenedSerializerFieldT, env *Env) string {
var_name := env.symbol(int(flat.GetVarNameSym()))
var_type := env.symbol(int(flat.GetVarTypeSym()))
var pretty bytes.Buffer
fmt.Fprintf(&pretty, "{name: %s type: %s", var_name, var_type)
if flat.BitCount != nil {
fmt.Fprintf(&pretty, " bits: %d", flat.GetBitCount())
}
if flat.LowValue != nil {
fmt.Fprintf(&pretty, " low: %f", flat.GetLowValue())
}
if flat.HighValue != nil {
fmt.Fprintf(&pretty, " high: %f", flat.GetHighValue())
}
if flat.EncodeFlags != nil {
fmt.Fprintf(&pretty, " flags: %d", flat.GetEncodeFlags())
}
if flat.FieldSerializerNameSym != nil {
fmt.Fprintf(&pretty, " serializer: %s", env.symbol(int(flat.GetFieldSerializerNameSym())))
}
if flat.FieldSerializerVersion != nil {
fmt.Fprintf(&pretty, " s_version: %d", flat.GetFieldSerializerVersion())
}
if flat.SendNodeSym != nil {
fmt.Fprintf(&pretty, " send: %s", env.symbol(int(flat.GetSendNodeSym())))
}
if flat.VarEncoderSym != nil {
fmt.Fprintf(&pretty, " var_enc: %s", env.symbol(int(flat.GetVarEncoderSym())))
}
fmt.Fprint(&pretty, "}")
return pretty.String()
}

@ -1,4 +1,6 @@
package ent
type tÿpe interface {
type tÿpe struct {
name string
alloc func(...interface{}) value
}

Loading…
Cancel
Save