From c372f14e3384a0f2751949270f778f3a6dadbfae Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sat, 24 Sep 2016 23:16:23 -0400 Subject: [PATCH] classes --- ent/class.go | 25 +++++++++++++++++++++++++ ent/env.go | 2 +- ent/type.go | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ent/class.go b/ent/class.go index 27e2d30..41ada50 100644 --- a/ent/class.go +++ b/ent/class.go @@ -1,6 +1,31 @@ package ent +import ( + "fmt" + "github.com/jordanorelli/hyperstone/bit" +) + type class struct { + name string + version int +} + +func (c *class) read(r bit.Reader) (value, error) { + return nil, fmt.Errorf("fart") } type classHistory map[int]*class + +func classType(spec *typeSpec, env *Env) tÿpe { + if spec.serializer != "" { + h := env.classes[spec.serializer] + if h != nil { + class := h[spec.serializerV] + if class != nil { + return class + } + return typeError("class %s exists for spec serializer but can't find version %d", spec.serializer, spec.serializerV) + } + } + return nil +} diff --git a/ent/env.go b/ent/env.go index c8e607f..9fa6e9e 100644 --- a/ent/env.go +++ b/ent/env.go @@ -59,7 +59,7 @@ func (e *Env) stubClasses(flat *dota.CSVCMsg_FlattenedSerializer) { if e.classes[name] == nil { e.classes[name] = make(classHistory, 4) } - e.classes[name][v] = new(class) + e.classes[name][v] = &class{name: name, version: v} } } diff --git a/ent/type.go b/ent/type.go index 898b831..fe91389 100644 --- a/ent/type.go +++ b/ent/type.go @@ -32,7 +32,7 @@ func parseTypeSpec(spec *typeSpec, env *Env) tÿpe { } return nil } - return coalesce(arrayType, atomType, floatType, handleType, qAngleType, hSeqType, genericType) + return coalesce(arrayType, atomType, floatType, handleType, qAngleType, hSeqType, genericType, classType) } // a type error is both an error and a type. It represents a type that we were