mirror of
https://github.com/swift-server/RediStack.git
synced 2026-05-03 07:32:28 +00:00
84 lines
2.3 KiB
Bash
Executable File
84 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
##===----------------------------------------------------------------------===##
|
|
##
|
|
## This source file is part of the RediStack open source project
|
|
##
|
|
## Copyright (c) 2023 RediStack project authors
|
|
## Licensed under Apache License v2.0
|
|
##
|
|
## See LICENSE.txt for license information
|
|
## See CONTRIBUTORS.txt for the list of RediStack project authors
|
|
##
|
|
## SPDX-License-Identifier: Apache-2.0
|
|
##
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
set -eu
|
|
|
|
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
function genWithContextParameter() {
|
|
how_many=$1
|
|
|
|
if [[ $how_many -ne 1 ]] ; then
|
|
echo ""
|
|
fi
|
|
|
|
echo " @inlinable"
|
|
echo -n " mutating func encodeRESPArray<T0: RESP3BlobStringEncodable"
|
|
for ((n = 1; n<how_many; n +=1)); do
|
|
echo -n ", T$((n)): RESP3BlobStringEncodable"
|
|
done
|
|
|
|
echo -n ">(_ t0: T0"
|
|
for ((n = 1; n<how_many; n +=1)); do
|
|
echo -n ", _ t$((n)): T$((n))"
|
|
done
|
|
echo ") {"
|
|
|
|
printf " self.buffer.writeBytes(\"*%s\\r\\n\".utf8)\n" "$how_many"
|
|
|
|
for ((n = 0; n<how_many; n +=1)); do
|
|
echo " t$((n)).encodeRedisBlobString(into: &self.buffer)"
|
|
done
|
|
echo " }"
|
|
}
|
|
|
|
grep -q "ByteBuffer" "${BASH_SOURCE[0]}" || {
|
|
echo >&2 "ERROR: ${BASH_SOURCE[0]}: file or directory not found (this should be this script)"
|
|
exit 1
|
|
}
|
|
|
|
{
|
|
cat <<"EOF"
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the RediStack open source project
|
|
//
|
|
// Copyright (c) 2023 Apple Inc. and the RediStack project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of RediStack project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// NOTE: THIS FILE IS AUTO-GENERATED BY scripts/generate_rediscommandencoder_multi_encode.sh
|
|
EOF
|
|
echo
|
|
|
|
echo "#if swift(<5.9)"
|
|
echo "extension RedisCommandEncoder {"
|
|
|
|
# note:
|
|
# - widening the inverval below (eg. going from {1..15} to {1..25}) is Semver minor
|
|
# - narrowing the interval below is SemVer _MAJOR_!
|
|
for n in {1..7}; do
|
|
genWithContextParameter "$n"
|
|
done
|
|
echo "}"
|
|
echo "#endif"
|
|
} > "$here/../Sources/RediStack/RedisCommandEncoder-multi-encode.swift"
|