Remove puffs-gen-h as a separate executable.

The .h file is already a prefix of the .c file. We already call
puffs-gen-c and can truncate its output.
This commit is contained in:
Nigel Tao committed 2017-06-01 10:33:42 +10:00
1 parent 05e2cec03d
commit 1b4590d878
8 files changed
+46 -42

No files matched your search

+3 -7
View File
@@ -25,18 +25,16 @@ const (
)
type Generator struct {
// Extension should be either 'c' or 'h'.
Extension byte
}
func (g *Generator) Generate(pkgName string, m *t.IDMap, files []*a.File) ([]byte, error) {
func (*Generator) Generate(pkgName string, m *t.IDMap, files []*a.File) ([]byte, error) {
b := &bytes.Buffer{}
includeGuard := "PUFFS_" + strings.ToUpper(pkgName) + "_H"
fmt.Fprintf(b, "#ifndef %s\n#define %s\n\n", includeGuard, includeGuard)
// Write preamble.
fmt.Fprintf(b, "// Code generated by puffs-gen-%c. DO NOT EDIT.\n\n", g.Extension)
fmt.Fprintf(b, "// Code generated by puffs-gen-c. DO NOT EDIT.\n\n")
b.WriteString(preamble)
b.WriteString("\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n")
@@ -71,9 +69,7 @@ func (g *Generator) Generate(pkgName string, m *t.IDMap, files []*a.File) ([]byt
// Finish up the header, which is also the first part of the .c file.
b.WriteString("\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n")
fmt.Fprintf(b, "#endif // %s\n\n", includeGuard)
if g.Extension == 'h' {
return format(b)
}
b.WriteString("// C HEADER ENDS HERE.\n\n")
b.WriteString("// ---------------- Private Structs\n\n")
if err := forEachStruct(b, pkgName, m, files, priOnly, writeStruct); err != nil {