Skip to content

Commit

Permalink
Moved bit flags to astikit
Browse files Browse the repository at this point in the history
  • Loading branch information
asticode committed Oct 3, 2023
1 parent 3478442 commit 0c13906
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 90 deletions.
9 changes: 0 additions & 9 deletions flag.go

This file was deleted.

17 changes: 0 additions & 17 deletions flag_test.go

This file was deleted.

116 changes: 60 additions & 56 deletions flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ module github.com/asticode/go-astiav
go 1.17

require (
github.com/asticode/go-astikit v0.28.2
github.com/asticode/go-astikit v0.42.0
github.com/stretchr/testify v1.7.0
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.7.0
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)

//replace github.com/asticode/go-astikit => ../go-astikit
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/asticode/go-astikit v0.28.2 h1:c2shjqarbZwcQGQ7GPfchG2sSOL/7NHGbdgHTx43RH8=
github.com/asticode/go-astikit v0.28.2/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
github.com/asticode/go-astikit v0.42.0 h1:pnir/2KLUSr0527Tv908iAH6EGYYrYta132vvjXsH5w=
github.com/asticode/go-astikit v0.42.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
12 changes: 8 additions & 4 deletions internal/cmd/flags/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ var list = []listItem{

var tmpl = `// Code generated by astiav. DO NOT EDIT.
package astiav
import (
"github.com/asticode/go-astikit"
)
{{ range $val := . }}
type {{ $val.Name }}Flags{{ $val.Suffix }} flags
type {{ $val.Name }}Flags{{ $val.Suffix }} astikit.BitFlags
func New{{ $val.Name }}Flags{{ $val.Suffix }}(fs ...{{ $val.Name }}Flag{{ $val.Suffix }}) {{ $val.Name }}Flags{{ $val.Suffix }} {
o := {{ $val.Name }}Flags{{ $val.Suffix }}(0)
Expand All @@ -44,14 +48,14 @@ func New{{ $val.Name }}Flags{{ $val.Suffix }}(fs ...{{ $val.Name }}Flag{{ $val.S
}
func (fs {{ $val.Name }}Flags{{ $val.Suffix }}) Add(f {{ $val.Name }}Flag{{ $val.Suffix }}) {{ $val.Name }}Flags{{ $val.Suffix }} {
return {{ $val.Name }}Flags{{ $val.Suffix }}(flags(fs).add(int(f)))
return {{ $val.Name }}Flags{{ $val.Suffix }}(astikit.BitFlags(fs).Add(uint64(f)))
}
func (fs {{ $val.Name }}Flags{{ $val.Suffix }}) Del(f {{ $val.Name }}Flag{{ $val.Suffix }}) {{ $val.Name }}Flags{{ $val.Suffix }} {
return {{ $val.Name }}Flags{{ $val.Suffix }}(flags(fs).del(int(f)))
return {{ $val.Name }}Flags{{ $val.Suffix }}(astikit.BitFlags(fs).Del(uint64(f)))
}
func (fs {{ $val.Name }}Flags{{ $val.Suffix }}) Has(f {{ $val.Name }}Flag{{ $val.Suffix }}) bool { return flags(fs).has(int(f)) }
func (fs {{ $val.Name }}Flags{{ $val.Suffix }}) Has(f {{ $val.Name }}Flag{{ $val.Suffix }}) bool { return astikit.BitFlags(fs).Has(uint64(f)) }
{{ end }}`

var tmplTest = `// Code generated by astiav. DO NOT EDIT.
Expand Down

0 comments on commit 0c13906

Please sign in to comment.