build: unify Label function signatures
The Context.Label method and LABEL global function did not agree. Also breaks the convention I'd like to set that capitalized functions must agree with existing Go assembly syntax. To help avoid a conflict with `avo.Label`, attributes were moved to their own package. Fixes #35
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/mmcloughlin/avo"
|
||||
"github.com/mmcloughlin/avo/attr"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -22,25 +22,25 @@ var (
|
||||
num = flag.Int("num", 32, "number of attributes to generate")
|
||||
)
|
||||
|
||||
func GenerateAttributes(n int) []avo.Attribute {
|
||||
as := make([]avo.Attribute, 0, n)
|
||||
func GenerateAttributes(n int) []attr.Attribute {
|
||||
as := make([]attr.Attribute, 0, n)
|
||||
|
||||
// Include each bitlevel.
|
||||
for i := 0; i < 16 && i < n; i++ {
|
||||
a := avo.Attribute(1 << uint(i))
|
||||
a := attr.Attribute(1 << uint(i))
|
||||
as = append(as, a)
|
||||
}
|
||||
|
||||
// Add randomly generated attributes.
|
||||
for len(as) < n {
|
||||
a := avo.Attribute(rand.Uint32())
|
||||
a := attr.Attribute(rand.Uint32())
|
||||
as = append(as, a)
|
||||
}
|
||||
|
||||
return as
|
||||
}
|
||||
|
||||
func PrintAttributesTest(w io.Writer, as []avo.Attribute) {
|
||||
func PrintAttributesTest(w io.Writer, as []attr.Attribute) {
|
||||
_, self, _, _ := runtime.Caller(0)
|
||||
fmt.Fprintf(w, "// Code generated by %s. DO NOT EDIT.\n\n", filepath.Base(self))
|
||||
fmt.Fprintf(w, "#include \"textflag.h\"\n\n")
|
||||
|
||||
Reference in New Issue
Block a user