mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 00:47:28 +01:00
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:
1 parent
05e2cec03d
commit
1b4590d878
8 files changed
+46
-42
No files matched your search
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user