Drop the "__pkg%08X" prefix in gen/wuffs code

This commit is contained in:
Nigel Tao committed 2017-12-28 11:05:46 +11:00
1 parent 7fb19d7669
commit 366a9388b3
1 file changed
+3 -11
+3 -11
View File
@@ -25,7 +25,6 @@ import (
"path/filepath"
"strings"
"github.com/google/wuffs/lang/base38"
"github.com/google/wuffs/lang/generate"
"github.com/google/wuffs/lang/parse"
@@ -242,15 +241,10 @@ func (h *genHelper) genWuffs(dirname string, qualifiedFilenames []string) error
if !ok {
return fmt.Errorf("invalid packageid declaration")
}
pkgIDNum, ok := base38.Encode(pkgIDStr)
if !ok {
return fmt.Errorf("invalid packageid declaration")
}
prefix := fmt.Sprintf("__pkg%08X", pkgIDNum)
out := &bytes.Buffer{}
fmt.Fprintf(out, "// Code generated by running \"wuffs gen\". DO NOT EDIT.\n\n")
fmt.Fprintf(out, "packageid %q // %s\n\n", pkgIDStr, prefix)
fmt.Fprintf(out, "packageid %q\n\n", pkgIDStr)
for _, f := range files {
for _, n := range f.TopLevelDecls() {
@@ -270,8 +264,7 @@ func (h *genHelper) genWuffs(dirname string, qualifiedFilenames []string) error
return fmt.Errorf("TODO: genWuffs for a free-standing function")
}
// TODO: look at n.Asserts().
fmt.Fprintf(out, "pub func %s_%s.%s%s(",
prefix, n.Receiver().Str(&h.tm), n.Name().Str(&h.tm), effect)
fmt.Fprintf(out, "pub func %s.%s%s(", n.Receiver().Str(&h.tm), n.Name().Str(&h.tm), effect)
for i, param := range [2]*a.Struct{n.In(), n.Out()} {
if i > 0 {
fmt.Fprintf(out, ")(")
@@ -293,7 +286,6 @@ func (h *genHelper) genWuffs(dirname string, qualifiedFilenames []string) error
if !n.Public() {
continue
}
// TODO: Qualify status names with the prefix somehow??
fmt.Fprintf(out, "pub %s %s\n", n.Keyword().Str(&h.tm), n.Message().Str(&h.tm))
case a.KStruct:
@@ -305,7 +297,7 @@ func (h *genHelper) genWuffs(dirname string, qualifiedFilenames []string) error
if n.Suspendible() {
effect = "?"
}
fmt.Fprintf(out, "pub struct %s_%s%s()\n", prefix, n.Name().Str(&h.tm), effect)
fmt.Fprintf(out, "pub struct %s%s()\n", n.Name().Str(&h.tm), effect)
}
}
}