Use data type (un)marshal in generated DCP code.
This commit is contained in:
40
scpd/scpd.go
40
scpd/scpd.go
@ -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 {
|
||||
|
Reference in New Issue
Block a user