Use data type (un)marshal in generated DCP code.

This commit is contained in:
John Beisley
2013-12-31 16:56:20 +00:00
parent 9db0302a13
commit d2cd2978d9
6 changed files with 5996 additions and 5047 deletions

View File

@ -37,31 +37,6 @@ func (scpd *SCPD) Clean() {
}
}
var dataTypeToGoKindName = map[string]string{
"ui1": "byte",
"ui2": "uint16",
"ui4": "uint32",
"i1": "int8",
"i2": "int16",
"i4": "int32",
"int": "int64",
"float": "float32",
"r4": "float32",
"r8": "float64",
// "fixed.14.4" ~ "float64"
"number": "float64",
"char": "string",
"string": "string",
// "date"
// "dateTime"
// "dateTime.tz"
// "boolean"
// "bin.base64"
// "bin.hex"
// "uri"
// "uuid"
}
func (scpd *SCPD) GetStateVariable(variable string) *StateVariable {
for i := range scpd.StateVariables {
v := &scpd.StateVariables[i]
@ -72,21 +47,6 @@ func (scpd *SCPD) GetStateVariable(variable string) *StateVariable {
return nil
}
// Returns the name of the Go "kind" of type for the named state variable. If
// the state variable is unknown, returns default_.
func (scpd *SCPD) GoKindNameForVariable(variable string, default_ string) string {
v := scpd.GetStateVariable(variable)
if v == nil {
return default_
}
if kindName, ok := dataTypeToGoKindName[v.DataType.Name]; ok {
return kindName
} else {
return default_
}
}
// SpecVersion is part of a SCPD document, describes the version of the
// specification that the data adheres to.
type SpecVersion struct {