mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Remove the cmd/internal/cgen package.
There's no longer separate .c and .h generator executables, so there's no need for an (internal) package for common code.
This commit is contained in:
1 parent
1b4590d878
commit
c195c2362e
5 files changed
+13
-14
No files matched your search
@@ -3,7 +3,7 @@
|
||||
|
||||
//go:generate go run gen.go
|
||||
|
||||
package cgen
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -24,10 +24,10 @@ const (
|
||||
priOnly
|
||||
)
|
||||
|
||||
type Generator struct {
|
||||
type gen struct {
|
||||
}
|
||||
|
||||
func (*Generator) Generate(pkgName string, m *t.IDMap, files []*a.File) ([]byte, error) {
|
||||
func (gen) Generate(pkgName string, m *t.IDMap, files []*a.File) ([]byte, error) {
|
||||
b := &bytes.Buffer{}
|
||||
|
||||
includeGuard := "PUFFS_" + strings.ToUpper(pkgName) + "_H"
|
||||
@@ -362,7 +362,7 @@ func writeField(b *bytes.Buffer, m *t.IDMap, n *a.Field) error {
|
||||
|
||||
func writeVars(b *bytes.Buffer, pkgName string, m *t.IDMap, n *a.Node, depth uint32) error {
|
||||
if depth > a.MaxBodyDepth {
|
||||
return fmt.Errorf("cgen: body recursion depth too large")
|
||||
return fmt.Errorf("body recursion depth too large")
|
||||
}
|
||||
depth++
|
||||
|
||||
@@ -375,7 +375,7 @@ func writeVars(b *bytes.Buffer, pkgName string, m *t.IDMap, n *a.Node, depth uin
|
||||
}
|
||||
}
|
||||
// TODO: fix this.
|
||||
return fmt.Errorf("cgen: cannot convert Puffs type %q to C", x.String(m))
|
||||
return fmt.Errorf("cannot convert Puffs type %q to C", x.String(m))
|
||||
}
|
||||
|
||||
for _, l := range n.Raw().SubLists() {
|
||||
@@ -390,7 +390,7 @@ func writeVars(b *bytes.Buffer, pkgName string, m *t.IDMap, n *a.Node, depth uin
|
||||
|
||||
func writeStatement(b *bytes.Buffer, pkgName string, m *t.IDMap, n *a.Node, depth uint32) error {
|
||||
if depth > a.MaxBodyDepth {
|
||||
return fmt.Errorf("cgen: body recursion depth too large")
|
||||
return fmt.Errorf("body recursion depth too large")
|
||||
}
|
||||
depth++
|
||||
|
||||
@@ -451,12 +451,12 @@ func writeStatement(b *bytes.Buffer, pkgName string, m *t.IDMap, n *a.Node, dept
|
||||
// TODO.
|
||||
|
||||
}
|
||||
return fmt.Errorf("cgen: unrecognized ast.Kind (%s) for writeStatement", n.Kind())
|
||||
return fmt.Errorf("unrecognized ast.Kind (%s) for writeStatement", n.Kind())
|
||||
}
|
||||
|
||||
func writeExpr(b *bytes.Buffer, pkgName string, m *t.IDMap, n *a.Expr, depth uint32) error {
|
||||
if depth > a.MaxExprDepth {
|
||||
return fmt.Errorf("cgen: expression recursion depth too large")
|
||||
return fmt.Errorf("expression recursion depth too large")
|
||||
}
|
||||
depth++
|
||||
|
||||
@@ -484,7 +484,7 @@ func writeExpr(b *bytes.Buffer, pkgName string, m *t.IDMap, n *a.Expr, depth uin
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("cgen: unrecognized token.Key (0x%X) for writeExpr", n.ID0().Key())
|
||||
return fmt.Errorf("unrecognized token.Key (0x%X) for writeExpr", n.ID0().Key())
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -525,7 +525,7 @@ func writeExprOther(b *bytes.Buffer, pkgName string, m *t.IDMap, n *a.Expr, dept
|
||||
b.WriteString(n.ID1().String(m))
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("cgen: unrecognized token.Key (0x%X) for writeExprOther", n.ID0().Key())
|
||||
return fmt.Errorf("unrecognized token.Key (0x%X) for writeExprOther", n.ID0().Key())
|
||||
}
|
||||
|
||||
func writeExprUnaryOp(b *bytes.Buffer, pkgName string, m *t.IDMap, n *a.Expr, depth uint32) error {
|
||||
@@ -3,7 +3,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be found
|
||||
// in the LICENSE file.
|
||||
|
||||
package cgen
|
||||
package main
|
||||
|
||||
const preamble = "" +
|
||||
"// Use of this source code is governed by a BSD-style license that can be found\n// in the LICENSE file.\n\n#include <stdbool.h>\n#include <stdint.h>\n#include <string.h>\n\n// Puffs requires a word size of at least 32 bits because it assumes that\n// converting a u32 to usize will never overflow. For example, the size of a\n// decoded image is often represented, explicitly or implicitly in an image\n// file, as a u32, and it is convenient to compare that to a buffer size.\n#if __WORDSIZE < 32\n#error \"Puffs requires a word size of at least 32 bits\"\n#endif\n\n// PUFFS_VERSION is the major.minor version number as a uint32. The major\n// number is the high 16 bits. The minor number is the low 16 bits.\n//\n// The intention is to bump the version number at least on every API / ABI\n// backwards incompatible change.\n//\n// For now, the API and ABI are simply unstable and can change at any time.\n//\n// TODO: don't hard code this in preamble.h.\n#define PUFFS_VERSION (0x00001)\n" +
|
||||
@@ -47,7 +47,7 @@ func main1() error {
|
||||
out.WriteString("// Use of this source code is governed by a BSD-style license that can be found\n")
|
||||
out.WriteString("// in the LICENSE file.\n")
|
||||
out.WriteString("\n")
|
||||
out.WriteString("package cgen\n")
|
||||
out.WriteString("package main\n")
|
||||
out.WriteString("\n")
|
||||
out.WriteString("const preamble = \"\" +\n")
|
||||
for len(in) > 0 {
|
||||
@@ -10,10 +10,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/google/puffs/cmd/internal/cgen"
|
||||
"github.com/google/puffs/lang/generate"
|
||||
)
|
||||
|
||||
func main() {
|
||||
generate.Main(&cgen.Generator{})
|
||||
generate.Main(gen{})
|
||||
}
|
||||
File renamed without changes.
Reference in new issue
Block a user