Skip to content

Commit

Permalink
api: add Iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-jukovec committed Apr 20, 2023
1 parent 755f696 commit 9c8e548
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
1 change: 1 addition & 0 deletions generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package iproto
//go:generate stringer -type=Error
//go:generate stringer -type=Feature
//go:generate stringer -type=Flag
//go:generate stringer -type=Iterator
//go:generate stringer -type=Type
//go:generate stringer -type=Key,MetadataKey,BallotKey,RaftKey,SqlInfoKey -output=keys_string.go
//go:generate goimports -w .
21 changes: 21 additions & 0 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ SRC_CONST=${TT_DIR}/src/box/iproto_constants.h
SRC_ERRORS=${TT_DIR}/src/box/errcode.h
SRC_EXECUTE=${TT_DIR}/src/box/execute.h
SRC_FEATURES=${TT_DIR}/src/box/iproto_features.h
SRC_ITERATORS=${TT_DIR}/src/box/iterator_type.h
DST_DOC=doc.go
DST_ERRORS=error.go
DST_ERRORS_TEST=error_test.go
DST_FEATURES=feature.go
DST_FEATURES_TEST=feature_test.go
DST_FLAGS=flag.go
DST_FLAGS_TEST=flag_test.go
DST_ITERATORS=iterator.go
DST_ITERATORS_TEST=iterator_test.go
DST_TYPES=type.go
DST_TYPES_TEST=type_test.go
DST_KEYS=keys.go
Expand Down Expand Up @@ -236,6 +239,24 @@ echo "${FOOTER_TEST}" > ${DST_FLAGS_TEST}
grep -PB 1 "[\t ]*IPROTO_FLAG_[A-Z_]+ =" ${SRC_CONST} | \
generate_test Flag >> ${DST_FLAGS_TEST}

#
# Iterators.
#

echo "${FOOTER}" > ${DST_ITERATORS}
cat << EOF >> ${DST_ITERATORS}
// IPROTO iterators constants, generated from
// ${SRC_ITERATORS}
EOF

read_enum iterator_type ${SRC_ITERATORS} | \
generate_enum Iterator >> ${DST_ITERATORS}

echo "${FOOTER_TEST}" > ${DST_ITERATORS_TEST}

read_enum iterator_type ${SRC_ITERATORS} | \
generate_test Iterator >> ${DST_ITERATORS_TEST}

#
# Types.
#
Expand Down
23 changes: 23 additions & 0 deletions iterator.go

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

34 changes: 34 additions & 0 deletions iterator_string.go

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

42 changes: 42 additions & 0 deletions iterator_test.go

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

0 comments on commit 9c8e548

Please sign in to comment.