/
publishTypeDecl.go
50 lines (44 loc) · 1.38 KB
/
publishTypeDecl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package publishGo
import (
"github.com/bhbosman/CodeGenerators/mitchgenerator/MitchDefinedTypes"
"github.com/bhbosman/CodeGenerators/mitchgenerator/yacc"
"io"
)
type publishTypeDecl struct {
data *yacc.TypeDeclarator
}
func (self *publishTypeDecl) ExportDefinition(writer io.StringWriter) {
//_, _ = writer.WriteString(fmt.Sprintf("type %s struct {\n", self.data.Identifier))
//for _, member := range self.data.Members {
// defaultValue := member.Declarator.DefaultValue()
//
// if defaultValue == nil {
// _, _ = writer.WriteString(fmt.Sprintf(
// "\t%v %v\n",
// member.Declarator.Identifier(),
// member.DefinedType.GetName()))
// } else {
//
// ss := defaultValue.ValueKind().String()
// _, _ = writer.WriteString(fmt.Sprintf(
// "\t%v %v // default value: %v(%v)\n ",
// member.Declarator.Identifier(),
// member.DefinedType.GetName(),
// ss,
// GetExportValue(defaultValue)))
// }
//}
//_, _ = writer.WriteString(fmt.Sprintf("}\n"))
//_, _ = writer.WriteString(fmt.Sprintf("\n"))}
}
func (self *publishTypeDecl) Export(writer io.StringWriter) {
if definition, ok := self.data.DefinedTyped.(*MitchDefinedTypes.MitchBitField); ok {
publish := NewPublishBitField(definition, self.data.Declarator.Identifier())
publish.Export(writer)
}
}
func NewpublishTypeDecl(data *yacc.TypeDeclarator) *publishTypeDecl {
return &publishTypeDecl{
data: data,
}
}