diff --git a/ent/atoms.go b/ent/atoms.go index 7eda21a..e4c38d6 100644 --- a/ent/atoms.go +++ b/ent/atoms.go @@ -5,6 +5,13 @@ import ( ) var atom_types = map[string]typeFn{ + "bool": func(r bit.Reader) (value, error) { + return bit.ReadBool(r), r.Err() + }, + "uint8": func(r bit.Reader) (value, error) { + // TODO: bounds check here + return uint8(bit.ReadVarInt(r)), r.Err() + }, "uint16": func(r bit.Reader) (value, error) { // TODO: bounds check here return uint16(bit.ReadVarInt(r)), r.Err() diff --git a/ent/string.go b/ent/string.go new file mode 100644 index 0000000..63aca57 --- /dev/null +++ b/ent/string.go @@ -0,0 +1,14 @@ +package ent + +import ( + "github.com/jordanorelli/hyperstone/bit" +) + +func stringType(spec *typeSpec, env *Env) tÿpe { + if spec.typeName != "CUtlStringToken" { + return nil + } + return typeFn(func(r bit.Reader) (value, error) { + return bit.ReadVarInt(r), r.Err() + }) +} diff --git a/ent/type.go b/ent/type.go index 62c6b23..e78a6bc 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(atomType, floatType, handleType, qAngleType, hSeqType, genericType) + return coalesce(atomType, floatType, handleType, qAngleType, hSeqType, genericType, stringType) } // a type error is both an error and a type. It represents a type that we were