more atoms

types
Jordan Orelli 8 years ago
parent 7349613e56
commit 66fe4d7290

@ -5,6 +5,13 @@ import (
) )
var atom_types = map[string]typeFn{ 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) { "uint16": func(r bit.Reader) (value, error) {
// TODO: bounds check here // TODO: bounds check here
return uint16(bit.ReadVarInt(r)), r.Err() return uint16(bit.ReadVarInt(r)), r.Err()

@ -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()
})
}

@ -32,7 +32,7 @@ func parseTypeSpec(spec *typeSpec, env *Env) tÿpe {
} }
return nil 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 // a type error is both an error and a type. It represents a type that we were

Loading…
Cancel
Save