diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-03 14:29:33 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-12 16:16:53 -0700 |
commit | 11ac4fae146e5f599f34a5fafa27e20fecf713a9 (patch) | |
tree | 79cbc94b5a8a31d297dcf64acca164a6fbc02451 /lib/btrfs/Makefile | |
parent | 677755c799c1b6b942349c7d9de836335c7bbf55 (diff) |
btrfsitem: Clean up items_gen.go
Diffstat (limited to 'lib/btrfs/Makefile')
-rw-r--r-- | lib/btrfs/Makefile | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/btrfs/Makefile b/lib/btrfs/Makefile index 00c22e7..ac39425 100644 --- a/lib/btrfs/Makefile +++ b/lib/btrfs/Makefile @@ -27,16 +27,26 @@ btrfsitem/items_gen.go: btrfsitem/items.txt $(MAKEFILE_LIST) echo '"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsprim"'; \ echo ')'; \ echo 'const ('; \ - sed -E 's,(.*)=(.*) (.*),\1_KEY=btrfsprim.\1_KEY,' $<; \ + sed -E 's/(.*)=(.*) (.*)/\1_KEY=btrfsprim.\1_KEY/' $<; \ echo ')'; \ + echo 'var ('; \ + sed -E 's/(.*)=(.*) (.*)/\3/p' $< | LC_COLLATE=C sort -u | sed 's/.*/\l&Type = reflect.TypeOf(&{})/'; \ + echo ')'; \ + echo '// keytype2gotype is used by UnmarshalItem.'; \ echo 'var keytype2gotype = map[Type]reflect.Type{'; \ - sed -En 's|(.*)=([^:]*) (.*)|\1_KEY: reflect.TypeOf(\3{}),|p' $<; \ + sed -En 's/(.*)=([^:]*) (.*)/\1_KEY: \l\3Type,/p' $<; \ echo '}'; \ + echo '// untypedObjID2gotype is used by UnmarshalItem.'; \ echo 'var untypedObjID2gotype = map[btrfsprim.ObjID]reflect.Type{'; \ - sed -En 's|UNTYPED=0:(.*) (.*)|btrfsprim.\1: reflect.TypeOf(\2{}),|p' $<; \ + sed -En 's/UNTYPED=0:(.*) (.*)/btrfsprim.\1: \l\2Type,/p' $<; \ echo '}'; \ - sed -En 's,(.*)=(.*) (.+),\3,p' $< | LC_COLLATE=C sort -u | sed 's,.*,func (*&) isItem() {},'; \ - } | gofmt >$@ + echo '// isItem implements Item.'; \ + sed -En 's/(.*)=(.*) (.+)/\3/p' $< | LC_COLLATE=C sort -u | sed 's/.*/func (*&) isItem() {}/'; \ + echo '// Type assertions.'; \ + echo 'var ('; \ + sed -En 's/(.*)=(.*) (.+)/\3/p' $< | LC_COLLATE=C sort -u | sed 's/.*/_ Item = (*&)(nil)/'; \ + echo ')'; \ + } | sed 's/uUID/uuid/g' | gofmt >$@ files += btrfsitem/items_gen.go btrfsprim/itemtype.go: btrfsitem/items.txt $(MAKEFILE_LIST) |