From b94eac7ca0875fb2364cd672ae1adc0b70f8f11a Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 2 Feb 2023 09:41:31 -0800 Subject: [PATCH 001/250] Update supported go versions Following our policy regarding supported go releases, change the supported go versions to 1.19.* and 1.20.* with the release of go 1.20. --- .github/workflows/build.yml | 4 ++-- LANGUAGES.md | 2 +- build/docker/ubuntu-bionic/Dockerfile | 4 ++-- build/docker/ubuntu-focal/Dockerfile | 4 ++-- build/docker/ubuntu-jammy/Dockerfile | 4 ++-- go.mod | 2 +- lib/go/test/fuzz/go.mod | 2 +- lib/go/test/go.mod | 2 +- test/go/go.mod | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 252ff2b55cb..f6400158ef4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,8 +57,8 @@ jobs: strategy: matrix: go: - - '1.18' - '1.19' + - '1.20' steps: - uses: actions/checkout@v3 @@ -124,7 +124,7 @@ jobs: run: make -C test/go precross - name: Upload go precross artifacts - if: matrix.go == '1.19' + if: matrix.go == '1.20' uses: actions/upload-artifact@v3 with: name: go-precross diff --git a/LANGUAGES.md b/LANGUAGES.md index 959ca984358..2f1f4f1784f 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -163,7 +163,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr Go 0.7.0 Yes -1.18.71.19.2 +1.19.51.20 YesYesYes YesYesYesYes diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile index e8f8b24bf4b..873dad83657 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/ubuntu-bionic/Dockerfile @@ -144,9 +144,9 @@ RUN apt-get install -y --no-install-recommends \ libglib2.0-dev # golang -ENV GOLANG_VERSION 1.18.7 +ENV GOLANG_VERSION 1.19.5 ENV GOLANG_DOWNLOAD_URL https://go.dev/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 6c967efc22152ce3124fc35cdf50fc686870120c5fd2107234d05d450a6105d8 +ENV GOLANG_DOWNLOAD_SHA256 36519702ae2fd573c9869461990ae550c8c0d955cd28d2827a6b159fda81ff95 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \ tar -C /usr/local -xzf golang.tar.gz && \ diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index 035c9645bfd..0a8c1c763a2 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -145,9 +145,9 @@ RUN apt-get install -y --no-install-recommends \ libglib2.0-dev # golang -ENV GOLANG_VERSION 1.19.2 +ENV GOLANG_VERSION 1.20 ENV GOLANG_DOWNLOAD_URL https://go.dev/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 5e8c5a74fe6470dd7e055a461acda8bb4050ead8c2df70f227e3ff7d8eb7eeb6 +ENV GOLANG_DOWNLOAD_SHA256 5a9ebcc65c1cce56e0d2dc616aff4c4cedcfbda8cc6f0288cc08cda3b18dcbf1 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \ tar -C /usr/local -xzf golang.tar.gz && \ diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index f6b7d041ce3..7d56cc5fe6a 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -145,9 +145,9 @@ RUN apt-get install -y --no-install-recommends \ libglib2.0-dev # golang -ENV GOLANG_VERSION 1.19.2 +ENV GOLANG_VERSION 1.20 ENV GOLANG_DOWNLOAD_URL https://go.dev/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 5e8c5a74fe6470dd7e055a461acda8bb4050ead8c2df70f227e3ff7d8eb7eeb6 +ENV GOLANG_DOWNLOAD_SHA256 5a9ebcc65c1cce56e0d2dc616aff4c4cedcfbda8cc6f0288cc08cda3b18dcbf1 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \ tar -C /usr/local -xzf golang.tar.gz && \ diff --git a/go.mod b/go.mod index 30de9f53da8..5f2a2c829fd 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/apache/thrift -go 1.18 +go 1.19 diff --git a/lib/go/test/fuzz/go.mod b/lib/go/test/fuzz/go.mod index c9ef373fcde..66418812ff5 100644 --- a/lib/go/test/fuzz/go.mod +++ b/lib/go/test/fuzz/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/lib/go/test/fuzz -go 1.18 +go 1.19 replace github.com/apache/thrift => ../../../../ diff --git a/lib/go/test/go.mod b/lib/go/test/go.mod index 37814e060fd..1c6d80ddbc6 100644 --- a/lib/go/test/go.mod +++ b/lib/go/test/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/lib/go/test -go 1.18 +go 1.19 require ( github.com/apache/thrift v0.0.0-00010101000000-000000000000 diff --git a/test/go/go.mod b/test/go/go.mod index 841c3291d3b..0143eba0da2 100644 --- a/test/go/go.mod +++ b/test/go/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/test/go -go 1.18 +go 1.19 require ( github.com/apache/thrift v0.0.0-00010101000000-000000000000 From 41621ee4c23689a2c92610c4aa2e016decdc70ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 17:51:36 +0000 Subject: [PATCH 002/250] Bump qs from 6.5.2 to 6.5.3 Bumps [qs](https://github.com/ljharb/qs) from 6.5.2 to 6.5.3. - [Release notes](https://github.com/ljharb/qs/releases) - [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md) - [Commits](https://github.com/ljharb/qs/compare/v6.5.2...v6.5.3) --- updated-dependencies: - dependency-name: qs dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b0d62039d30..376b972c450 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2491,9 +2491,9 @@ "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" }, "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", "dev": true }, "regexpp": { From d89e37047f8c426bc0228bc726092bf5e2b1b74f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Dec 2022 16:21:42 +0000 Subject: [PATCH 003/250] Bump qs from 6.5.2 to 6.5.3 in /lib/ts Bumps [qs](https://github.com/ljharb/qs) from 6.5.2 to 6.5.3. - [Release notes](https://github.com/ljharb/qs/releases) - [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md) - [Commits](https://github.com/ljharb/qs/compare/v6.5.2...v6.5.3) --- updated-dependencies: - dependency-name: qs dependency-type: indirect ... Signed-off-by: dependabot[bot] --- lib/ts/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ts/package-lock.json b/lib/ts/package-lock.json index 4300828662f..ee2bbe57f10 100644 --- a/lib/ts/package-lock.json +++ b/lib/ts/package-lock.json @@ -3169,9 +3169,9 @@ } }, "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", "dev": true }, "querystring": { From e59defd540671faa0aadc8797b3e9ab57c1c1c36 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 21:00:39 +0000 Subject: [PATCH 004/250] Bump minimatch from 3.0.4 to 3.1.2 Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2) --- updated-dependencies: - dependency-name: minimatch dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 376b972c450..e1051c1b78e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2099,9 +2099,9 @@ "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" From b973d11caad472acbf4c84ac1d490f3c07836d8c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 21:00:40 +0000 Subject: [PATCH 005/250] Bump minimatch from 3.0.4 to 3.0.8 in /lib/js Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.0.8. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.0.8) --- updated-dependencies: - dependency-name: minimatch dependency-type: indirect ... Signed-off-by: dependabot[bot] --- lib/js/package-lock.json | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/js/package-lock.json b/lib/js/package-lock.json index 132c21cccfd..f95e31fe186 100644 --- a/lib/js/package-lock.json +++ b/lib/js/package-lock.json @@ -522,15 +522,6 @@ "once": "^1.3.0", "path-is-absolute": "^1.0.0" } - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } } } }, @@ -1215,6 +1206,15 @@ "path-is-absolute": "^1.0.0" } }, + "minimatch": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, "mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -1886,6 +1886,15 @@ "strip-json-comments": "1.0.x" }, "dependencies": { + "minimatch": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, "strip-json-comments": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", @@ -2208,9 +2217,9 @@ "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" From 27a3311a7dd5b8ea7fcd4e0e40cf5f69a3781ce6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 21:00:44 +0000 Subject: [PATCH 006/250] Bump minimatch from 3.0.4 to 3.0.8 in /lib/ts Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.0.8. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.0.8) --- updated-dependencies: - dependency-name: minimatch dependency-type: indirect ... Signed-off-by: dependabot[bot] --- lib/ts/package-lock.json | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/ts/package-lock.json b/lib/ts/package-lock.json index ee2bbe57f10..16461e6f764 100644 --- a/lib/ts/package-lock.json +++ b/lib/ts/package-lock.json @@ -1459,6 +1459,15 @@ "path-is-absolute": "^1.0.0" } }, + "minimatch": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, "mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -2202,6 +2211,15 @@ "strip-json-comments": "1.0.x" }, "dependencies": { + "minimatch": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, "strip-json-comments": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", @@ -2681,9 +2699,9 @@ "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" From d21188a627bd48c82ea5c3c67ac639e9e256593d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Jan 2023 08:04:55 +0000 Subject: [PATCH 007/250] Bump json5 from 2.1.1 to 2.2.3 Bumps [json5](https://github.com/json5/json5) from 2.1.1 to 2.2.3. - [Release notes](https://github.com/json5/json5/releases) - [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md) - [Commits](https://github.com/json5/json5/compare/v2.1.1...v2.2.3) --- updated-dependencies: - dependency-name: json5 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index e1051c1b78e..8239f386976 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1936,21 +1936,10 @@ "dev": true }, "json5": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.1.tgz", - "integrity": "sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - } - } + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true }, "jsprim": { "version": "1.4.2", From 14489341ce2f2a6a2769069d6091f8f14713fff8 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 2 Feb 2023 10:43:36 -0800 Subject: [PATCH 008/250] go: Use new atomic types introduced in go1.19 Those come with nocopy protection, so they can prevent bugs like people passing the types by value instead of by pointer from the compiler. --- lib/go/thrift/serializer_test.go | 4 ++-- lib/go/thrift/simple_server.go | 10 +++++----- lib/go/thrift/socket_conn.go | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/go/thrift/serializer_test.go b/lib/go/thrift/serializer_test.go index 78b67453bc5..425ce0691bc 100644 --- a/lib/go/thrift/serializer_test.go +++ b/lib/go/thrift/serializer_test.go @@ -243,7 +243,7 @@ func TestSerializer(t *testing.T) { func TestSerializerPoolAsync(t *testing.T) { var wg sync.WaitGroup - var counter int64 + var counter atomic.Int64 s := NewTSerializerPool(NewTSerializer) d := NewTDeserializerPool(NewTDeserializer) f := func(i int64) bool { @@ -251,7 +251,7 @@ func TestSerializerPoolAsync(t *testing.T) { go func() { defer wg.Done() t.Run( - fmt.Sprintf("#%d-%d", atomic.AddInt64(&counter, 1), i), + fmt.Sprintf("#%d-%d", counter.Add(1), i), func(t *testing.T) { m := MyTestStruct{ Int64: i, diff --git a/lib/go/thrift/simple_server.go b/lib/go/thrift/simple_server.go index 31dfa1e6d5d..c5c14feed5f 100644 --- a/lib/go/thrift/simple_server.go +++ b/lib/go/thrift/simple_server.go @@ -54,7 +54,7 @@ var ServerStopTimeout = time.Duration(0) * This will work if golang user implements a conn-pool like thing in client side. */ type TSimpleServer struct { - closed int32 + closed atomic.Int32 wg sync.WaitGroup mu sync.Mutex stopChan chan struct{} @@ -186,7 +186,7 @@ func (p *TSimpleServer) innerAccept() (int32, error) { client, err := p.serverTransport.Accept() p.mu.Lock() defer p.mu.Unlock() - closed := atomic.LoadInt32(&p.closed) + closed := p.closed.Load() if closed != 0 { return closed, nil } @@ -246,10 +246,10 @@ func (p *TSimpleServer) Stop() error { p.mu.Lock() defer p.mu.Unlock() - if atomic.LoadInt32(&p.closed) != 0 { + if !p.closed.CompareAndSwap(0, 1) { + // Already closed return nil } - atomic.StoreInt32(&p.closed, 1) p.serverTransport.Interrupt() ctx, cancel := context.WithCancel(context.Background()) @@ -328,7 +328,7 @@ func (p *TSimpleServer) processRequests(client TTransport) (err error) { defer outputTransport.Close() } for { - if atomic.LoadInt32(&p.closed) != 0 { + if p.closed.Load() != 0 { return nil } diff --git a/lib/go/thrift/socket_conn.go b/lib/go/thrift/socket_conn.go index bbb5b7d15c0..dfd0913abcd 100644 --- a/lib/go/thrift/socket_conn.go +++ b/lib/go/thrift/socket_conn.go @@ -30,7 +30,7 @@ type socketConn struct { net.Conn buffer [1]byte - closed int32 + closed atomic.Int32 } var _ net.Conn = (*socketConn)(nil) @@ -67,7 +67,7 @@ func wrapSocketConn(conn net.Conn) *socketConn { // It's the same as the previous implementation of TSocket.IsOpen and // TSSLSocket.IsOpen before we added connectivity check. func (sc *socketConn) isValid() bool { - return sc != nil && sc.Conn != nil && atomic.LoadInt32(&sc.closed) == 0 + return sc != nil && sc.Conn != nil && sc.closed.Load() == 0 } // IsOpen checks whether the connection is open. @@ -119,6 +119,6 @@ func (sc *socketConn) Close() error { // Already closed return net.ErrClosed } - atomic.StoreInt32(&sc.closed, 1) + sc.closed.Store(1) return sc.Conn.Close() } From 61d3e747adac60f50277c0970d4667a9f655d6ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 21:05:13 +0000 Subject: [PATCH 009/250] Bump http, fixnum, logging, dart_style, build_test, build_web_compilers, mockito and build_runner Bumps [http](https://github.com/dart-lang/http/tree/master/pkgs), [fixnum](https://github.com/dart-lang/fixnum), [logging](https://github.com/dart-lang/logging), [dart_style](https://github.com/dart-lang/dart_style), [build_test](https://github.com/dart-lang/build), [build_web_compilers](https://github.com/dart-lang/build), [mockito](https://github.com/dart-lang/mockito) and [build_runner](https://github.com/dart-lang/build). These dependencies needed to be updated together. Updates `http` from 0.12.2 to 0.13.5 - [Release notes](https://github.com/dart-lang/http/releases) - [Commits](https://github.com/dart-lang/http/commits/HEAD/pkgs) Updates `fixnum` from 0.10.11 to 1.1.0 - [Release notes](https://github.com/dart-lang/fixnum/releases) - [Changelog](https://github.com/dart-lang/fixnum/blob/master/CHANGELOG.md) - [Commits](https://github.com/dart-lang/fixnum/compare/0.10.11...v1.1.0) Updates `logging` from 0.11.4 to 1.1.1 - [Release notes](https://github.com/dart-lang/logging/releases) - [Changelog](https://github.com/dart-lang/logging/blob/master/CHANGELOG.md) - [Commits](https://github.com/dart-lang/logging/compare/0.11.4...v1.1.1) Updates `dart_style` from 1.3.10 to 2.2.4 - [Release notes](https://github.com/dart-lang/dart_style/releases) - [Changelog](https://github.com/dart-lang/dart_style/blob/master/CHANGELOG.md) - [Commits](https://github.com/dart-lang/dart_style/compare/1.3.10...v2.2.4) Updates `build_test` from 0.10.12+1 to 2.1.6 - [Release notes](https://github.com/dart-lang/build/releases) - [Commits](https://github.com/dart-lang/build/compare/build_test-v0.10.12...build_test-v2.1.6) Updates `build_web_compilers` from 2.12.0 to 3.2.7 - [Release notes](https://github.com/dart-lang/build/releases) - [Commits](https://github.com/dart-lang/build/compare/build_web_compilers-v2.12.0...build_web_compilers-v3.2.7) Updates `mockito` from 4.1.4 to 5.3.2 - [Release notes](https://github.com/dart-lang/mockito/releases) - [Changelog](https://github.com/dart-lang/mockito/blob/master/CHANGELOG.md) - [Commits](https://github.com/dart-lang/mockito/compare/4.1.4...5.3.2) Updates `build_runner` from 1.11.1+1 to 2.3.3 - [Release notes](https://github.com/dart-lang/build/releases) - [Commits](https://github.com/dart-lang/build/compare/build_runner-v1.11.1...build_runner-v2.3.3) --- updated-dependencies: - dependency-name: http dependency-type: direct:production - dependency-name: fixnum dependency-type: direct:production - dependency-name: logging dependency-type: direct:production - dependency-name: dart_style dependency-type: direct:production - dependency-name: build_test dependency-type: direct:production - dependency-name: build_web_compilers dependency-type: direct:production - dependency-name: mockito dependency-type: direct:production - dependency-name: build_runner dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- lib/dart/pubspec.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/dart/pubspec.yaml b/lib/dart/pubspec.yaml index 006e2195213..a94dec96905 100644 --- a/lib/dart/pubspec.yaml +++ b/lib/dart/pubspec.yaml @@ -27,17 +27,17 @@ environment: sdk: ">=2.0.0 <3.0.0" dependencies: - fixnum: ^0.10.2 - http: ">=0.11.3 <0.13.0" - logging: ^0.11.0 + fixnum: ">=0.10.2 <2.0.0" + http: ">=0.11.3 <0.14.0" + logging: ">=0.11.0 <2.0.0" dev_dependencies: - build_runner: ^1.7.1 - build_test: ^0.10.9 + build_runner: ">=1.7.1 <3.0.0" + build_test: ">=0.10.9 <3.0.0" build_vm_compilers: ^1.0.3 - build_web_compilers: ^2.7.1 + build_web_compilers: ">=2.7.1 <4.0.0" dart_dev: ^3.0.0 - dart_style: ^1.3.1 - mockito: ^4.1.1 + dart_style: ">=1.3.1 <3.0.0" + mockito: ">=4.1.1 <6.0.0" test: ^1.9.1 workiva_analysis_options: ^1.0.0 \ No newline at end of file From 4eee6815276741a0381063b9e139a4938f808711 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Mon, 6 Feb 2023 23:40:56 +0100 Subject: [PATCH 010/250] fix veralign.sh --- build/veralign.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/veralign.sh b/build/veralign.sh index adac0c59f7c..834bf7e03d3 100755 --- a/build/veralign.sh +++ b/build/veralign.sh @@ -1,4 +1,4 @@ -x#!/usr/bin/env bash +#!/usr/bin/env bash # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file From c6fd86d9f2f15665dd1f3b87e39ed7580d8b25dd Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Mon, 6 Feb 2023 23:42:52 +0100 Subject: [PATCH 011/250] bump version number --- ApacheThrift.nuspec | 8 ++++---- CMakeLists.txt | 2 +- Thrift.podspec | 4 ++-- appveyor.yml | 2 +- bower.json | 2 +- compiler/cpp/src/thrift/version.h | 2 +- configure.ac | 2 +- contrib/Rebus/Properties/AssemblyInfo.cs | 4 ++-- contrib/thrift-maven-plugin/pom.xml | 2 +- contrib/thrift.spec | 2 +- contrib/zeromq/csharp/AssemblyInfo.cs | 2 +- doc/specs/idl.md | 2 +- lib/d/src/thrift/base.d | 2 +- lib/dart/pubspec.yaml | 2 +- lib/delphi/src/Thrift.pas | 2 +- lib/erl/src/thrift.app.src | 2 +- lib/haxe/haxelib.json | 2 +- lib/java/gradle.properties | 2 +- lib/js/package-lock.json | 2 +- lib/js/package.json | 2 +- lib/js/src/thrift.js | 2 +- lib/lua/Thrift.lua | 2 +- .../Thrift.IntegrationTests.csproj | 2 +- .../Thrift.PublicInterfaces.Compile.Tests.csproj | 2 +- lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj | 2 +- lib/netstd/Thrift/Properties/AssemblyInfo.cs | 4 ++-- lib/netstd/Thrift/Thrift.csproj | 6 +++--- lib/ocaml/_oasis | 2 +- lib/perl/lib/Thrift.pm | 2 +- lib/py/setup.py | 2 +- lib/rb/thrift.gemspec | 2 +- lib/rs/Cargo.toml | 2 +- lib/st/package.xml | 2 +- lib/swift/Sources/Thrift.swift | 2 +- lib/swift/Tests/ThriftTests/ThriftTests.swift | 2 +- lib/ts/package-lock.json | 2 +- lib/ts/package.json | 2 +- package-lock.json | 2 +- package.json | 2 +- sonar-project.properties | 6 +++--- test/dart/test_client/pubspec.yaml | 2 +- test/erl/src/thrift_test.app.src | 2 +- test/netstd/Client/Client.csproj | 2 +- test/netstd/Server/Server.csproj | 2 +- tutorial/dart/client/pubspec.yaml | 2 +- tutorial/dart/console_client/pubspec.yaml | 2 +- tutorial/dart/server/pubspec.yaml | 2 +- tutorial/delphi/DelphiClient/DelphiClient.dproj | 4 ++-- tutorial/delphi/DelphiServer/DelphiServer.dproj | 4 ++-- tutorial/netstd/Client/Client.csproj | 2 +- tutorial/netstd/Interfaces/Interfaces.csproj | 2 +- tutorial/netstd/Server/Server.csproj | 2 +- tutorial/ocaml/_oasis | 2 +- 53 files changed, 65 insertions(+), 65 deletions(-) diff --git a/ApacheThrift.nuspec b/ApacheThrift.nuspec index 3404347f21c..0e6f09e9490 100644 --- a/ApacheThrift.nuspec +++ b/ApacheThrift.nuspec @@ -19,14 +19,14 @@ the "Thrift" project. 2. nuget setApiKey 3. nuget pack ApacheThrift.nuspec -Symbols -SymbolPackageFormat snupkg - 4. nuget push ApacheThrift.0.18.0.nupkg -Source https://api.nuget.org/v3/index.json + 4. nuget push ApacheThrift.0.19.0.nupkg -Source https://api.nuget.org/v3/index.json --> ApacheThrift - 0.18.0 - Apache Thrift 0.18.0 + 0.19.0 + Apache Thrift 0.19.0 Apache Thrift Developers Apache Software Foundation Apache-2.0 @@ -36,7 +36,7 @@ Contains runtime libraries from lib/netstd for netstandard2.0 framework development. - + Apache Thrift RPC diff --git a/CMakeLists.txt b/CMakeLists.txt index 859d944326c..f056629478c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ endif() # PACKAGE_VERSION is used by cpack scripts currently # Both thrift_VERSION and PACKAGE_VERSION should be the same for now -set(thrift_VERSION "0.18.0") +set(thrift_VERSION "0.19.0") set(PACKAGE_VERSION ${thrift_VERSION}) project("thrift" VERSION ${PACKAGE_VERSION}) diff --git a/Thrift.podspec b/Thrift.podspec index 7350be47939..fe5bcc3b468 100644 --- a/Thrift.podspec +++ b/Thrift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Thrift' - s.version = '0.18.0' + s.version = '0.19.0' s.summary = "Apache Thrift is a lightweight, language-independent software stack with an associated code generation mechanism for RPC." s.description = <<-DESC The Apache Thrift scalable cross-language software framework for networked services development combines a software stack with a code generation engine to build services that work efficiently and seamlessly between many programming languages. @@ -10,6 +10,6 @@ The Apache Thrift scalable cross-language software framework for networked servi s.author = { 'Apache Thrift Developers' => 'dev@thrift.apache.org' } s.ios.deployment_target = '9.0' s.osx.deployment_target = '10.10' - s.source = { :git => 'https://github.com/apache/thrift.git', :tag => 'v0.18.0' } + s.source = { :git => 'https://github.com/apache/thrift.git', :tag => 'v0.19.0' } s.source_files = 'lib/swift/Sources/*.swift' end diff --git a/appveyor.yml b/appveyor.yml index 1a7f0262941..1f5abeb6497 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,7 +19,7 @@ # build Apache Thrift on AppVeyor - https://ci.appveyor.com -version: '0.18.0.{build}' +version: '0.19.0.{build}' shallow_clone: true diff --git a/bower.json b/bower.json index a6ef878df12..51913dafdf9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.19.0", "homepage": "https://github.com/apache/thrift.git", "authors": [ "Apache Thrift " diff --git a/compiler/cpp/src/thrift/version.h b/compiler/cpp/src/thrift/version.h index 0905b34076b..4f979d9b389 100644 --- a/compiler/cpp/src/thrift/version.h +++ b/compiler/cpp/src/thrift/version.h @@ -24,6 +24,6 @@ #pragma once #endif // _MSC_VER -#define THRIFT_VERSION "0.18.0" +#define THRIFT_VERSION "0.19.0" #endif // _THRIFT_VERSION_H_ diff --git a/configure.ac b/configure.ac index 12c20de0bd5..2cd902d6ca3 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ(2.65) AC_CONFIG_MACRO_DIR([./aclocal]) -AC_INIT([thrift], [0.18.0]) +AC_INIT([thrift], [0.19.0]) AC_CONFIG_AUX_DIR([.]) diff --git a/contrib/Rebus/Properties/AssemblyInfo.cs b/contrib/Rebus/Properties/AssemblyInfo.cs index 605eb5ceff3..ab40a65504a 100644 --- a/contrib/Rebus/Properties/AssemblyInfo.cs +++ b/contrib/Rebus/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ [assembly: Guid("0af10984-40d3-453d-b1e5-421529e8c7e2")] -[assembly: AssemblyVersion("0.18.0.0")] -[assembly: AssemblyFileVersion("0.18.0.0")] +[assembly: AssemblyVersion("0.19.0.0")] +[assembly: AssemblyFileVersion("0.19.0.0")] diff --git a/contrib/thrift-maven-plugin/pom.xml b/contrib/thrift-maven-plugin/pom.xml index 1ea0ddcd836..b7a93c93ac6 100644 --- a/contrib/thrift-maven-plugin/pom.xml +++ b/contrib/thrift-maven-plugin/pom.xml @@ -29,7 +29,7 @@ thrift-maven-plugin maven-plugin thrift-maven-plugin - 0.18.0 + 0.19.0 1.8 diff --git a/contrib/thrift.spec b/contrib/thrift.spec index ecc7fb78ff2..57011167c00 100644 --- a/contrib/thrift.spec +++ b/contrib/thrift.spec @@ -28,7 +28,7 @@ Name: thrift License: Apache License v2.0 Group: Development Summary: RPC and serialization framework -Version: 0.18.0 +Version: 0.19.0 Release: 0 URL: http://thrift.apache.org Packager: Thrift Developers diff --git a/contrib/zeromq/csharp/AssemblyInfo.cs b/contrib/zeromq/csharp/AssemblyInfo.cs index 787b00d6122..e7856206bb1 100644 --- a/contrib/zeromq/csharp/AssemblyInfo.cs +++ b/contrib/zeromq/csharp/AssemblyInfo.cs @@ -36,7 +36,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("0.18.0.0")] +[assembly: AssemblyVersion("0.19.0.0")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. diff --git a/doc/specs/idl.md b/doc/specs/idl.md index 456b777d66e..cf8354f2cfb 100644 --- a/doc/specs/idl.md +++ b/doc/specs/idl.md @@ -1,6 +1,6 @@ ## Thrift interface description language -For Thrift version 0.18.0. +For Thrift version 0.19.0. The Thrift interface definition language (IDL) allows for the definition of [Thrift Types](/docs/types). A Thrift IDL file is processed by the Thrift code generator to produce code for the various target languages to support the defined structs and services in the IDL file. diff --git a/lib/d/src/thrift/base.d b/lib/d/src/thrift/base.d index ce706be1788..dbf14294cd6 100644 --- a/lib/d/src/thrift/base.d +++ b/lib/d/src/thrift/base.d @@ -50,7 +50,7 @@ class TCompoundOperationException : TException { /// The Thrift version string, used for informative purposes. // Note: This is currently hardcoded, but will likely be filled in by the build // system in future versions. -enum VERSION = "0.18.0"; +enum VERSION = "0.19.0"; /** * Functions used for logging inside Thrift. diff --git a/lib/dart/pubspec.yaml b/lib/dart/pubspec.yaml index a94dec96905..f16c3eafc2b 100644 --- a/lib/dart/pubspec.yaml +++ b/lib/dart/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: thrift -version: 0.18.0 +version: 0.19.0 description: > A Dart library for Apache Thrift author: Apache Thrift Developers diff --git a/lib/delphi/src/Thrift.pas b/lib/delphi/src/Thrift.pas index 6fcc65df767..b725ebc10e9 100644 --- a/lib/delphi/src/Thrift.pas +++ b/lib/delphi/src/Thrift.pas @@ -28,7 +28,7 @@ interface Thrift.Protocol; const - Version = '0.18.0'; + Version = '0.19.0'; type TException = Thrift.Exception.TException; // compatibility alias diff --git a/lib/erl/src/thrift.app.src b/lib/erl/src/thrift.app.src index 180f3893e93..c681a2f1036 100644 --- a/lib/erl/src/thrift.app.src +++ b/lib/erl/src/thrift.app.src @@ -22,7 +22,7 @@ {description, "Thrift bindings"}, % The version of the applicaton - {vsn, "0.18.0"}, + {vsn, "0.19.0"}, % All modules used by the application. {modules, [ diff --git a/lib/haxe/haxelib.json b/lib/haxe/haxelib.json index 4775ac42a23..c2dab349b37 100644 --- a/lib/haxe/haxelib.json +++ b/lib/haxe/haxelib.json @@ -10,7 +10,7 @@ "framework" ], "description": "Haxe bindings for the Apache Thrift RPC and serialization framework", - "version": "0.18.0", + "version": "0.19.0", "releasenote": "Licensed under Apache License, Version 2.0. The Apache Thrift compiler needs to be installed separately.", "contributors": ["ApacheThrift"], "dependencies": { diff --git a/lib/java/gradle.properties b/lib/java/gradle.properties index 3ef6a5fbf81..917b24b0161 100644 --- a/lib/java/gradle.properties +++ b/lib/java/gradle.properties @@ -1,7 +1,7 @@ # This file is shared currently between this Gradle build and the # Ant builds for fd303 and JavaScript. Keep the dotted notation for # the properties to minimize the changes in the dependencies. -thrift.version=0.18.0 +thrift.version=0.19.0 thrift.groupid=org.apache.thrift release=false diff --git a/lib/js/package-lock.json b/lib/js/package-lock.json index f95e31fe186..2697f4a578f 100644 --- a/lib/js/package-lock.json +++ b/lib/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.19.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/lib/js/package.json b/lib/js/package.json index ab0cc6b41ea..57b4bb223ed 100644 --- a/lib/js/package.json +++ b/lib/js/package.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.19.0", "description": "Thrift is a software framework for scalable cross-language services development.", "main": "./src/thrift", "author": { diff --git a/lib/js/src/thrift.js b/lib/js/src/thrift.js index 3ea17974f26..78fdfb2bb7a 100644 --- a/lib/js/src/thrift.js +++ b/lib/js/src/thrift.js @@ -46,7 +46,7 @@ var Thrift = { * @const {string} Version * @memberof Thrift */ - Version: '0.18.0', + Version: '0.19.0', /** * Thrift IDL type string to Id mapping. diff --git a/lib/lua/Thrift.lua b/lib/lua/Thrift.lua index 064399c1b18..c249278f9ca 100644 --- a/lib/lua/Thrift.lua +++ b/lib/lua/Thrift.lua @@ -48,7 +48,7 @@ function ttable_size(t) return count end -version = '0.18.0' +version = '0.19.0' TType = { STOP = 0, diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index f21aa8bbf3d..d661f60f1e1 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -22,7 +22,7 @@ net6.0 Thrift.IntegrationTests Thrift.IntegrationTests - 0.18.0.0 + 0.19.0.0 Exe false false diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj index 54970b77d4c..20f74e6461c 100644 --- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj +++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj @@ -19,7 +19,7 @@ --> - 0.18.0 + 0.19.0 Thrift version $(ThriftVersion) net6.0 $(ThriftVersion).0 diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index efd21f89816..8a0e25db486 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -20,7 +20,7 @@ net6.0 - 0.18.0.0 + 0.19.0.0 enable diff --git a/lib/netstd/Thrift/Properties/AssemblyInfo.cs b/lib/netstd/Thrift/Properties/AssemblyInfo.cs index 6978f52196b..3dd0cc6e32e 100644 --- a/lib/netstd/Thrift/Properties/AssemblyInfo.cs +++ b/lib/netstd/Thrift/Properties/AssemblyInfo.cs @@ -52,5 +52,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.18.0.0")] -[assembly: AssemblyFileVersion("0.18.0.0")] +[assembly: AssemblyVersion("0.19.0.0")] +[assembly: AssemblyFileVersion("0.19.0.0")] diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index 902e3db9a80..614a7aa3823 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -40,8 +40,8 @@ true thrift.snk false - Apache Thrift 0.18.0 - 0.18.0.0 + Apache Thrift 0.19.0 + 0.19.0.0 false http://thrift.apache.org/ Apache Thrift Developers @@ -50,7 +50,7 @@ C# .NET Core bindings for the Apache Thrift RPC system Apache Thrift RPC - https://github.com/apache/thrift/blob/0.18.0/CHANGES.md + https://github.com/apache/thrift/blob/0.19.0/CHANGES.md Copyright 2022 The Apache Software Foundation diff --git a/lib/ocaml/_oasis b/lib/ocaml/_oasis index e37dba74236..cd4a0c7c132 100644 --- a/lib/ocaml/_oasis +++ b/lib/ocaml/_oasis @@ -1,5 +1,5 @@ Name: libthrift-ocaml -Version: 0.18.0 +Version: 0.19.0 OASISFormat: 0.3 Synopsis: OCaml bindings for the Apache Thrift RPC system Authors: Apache Thrift Developers diff --git a/lib/perl/lib/Thrift.pm b/lib/perl/lib/Thrift.pm index c10abd832c7..08eb84198d5 100644 --- a/lib/perl/lib/Thrift.pm +++ b/lib/perl/lib/Thrift.pm @@ -31,6 +31,6 @@ use warnings; # package Thrift; -use version 0.77; our $VERSION = version->declare("v0.18.0"); +use version 0.77; our $VERSION = version->declare("v0.19.0"); 1; diff --git a/lib/py/setup.py b/lib/py/setup.py index 7be2b5d66a6..6e365f838aa 100644 --- a/lib/py/setup.py +++ b/lib/py/setup.py @@ -105,7 +105,7 @@ def run_setup(with_binary): twisted_deps = ['twisted'] setup(name='thrift', - version='0.18.0', + version='0.19.0', description='Python bindings for the Apache Thrift RPC system', long_description=read_file("README.md"), long_description_content_type="text/markdown", diff --git a/lib/rb/thrift.gemspec b/lib/rb/thrift.gemspec index e6cc55b9f81..f6ac77cac46 100644 --- a/lib/rb/thrift.gemspec +++ b/lib/rb/thrift.gemspec @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__) Gem::Specification.new do |s| s.name = 'thrift' - s.version = '0.18.0' + s.version = '0.19.0' s.authors = ['Apache Thrift Developers'] s.email = ['dev@thrift.apache.org'] s.homepage = 'http://thrift.apache.org' diff --git a/lib/rs/Cargo.toml b/lib/rs/Cargo.toml index 844355fb6ae..4b3c85702a4 100644 --- a/lib/rs/Cargo.toml +++ b/lib/rs/Cargo.toml @@ -2,7 +2,7 @@ name = "thrift" description = "Rust bindings for the Apache Thrift RPC system" edition = "2021" -version = "0.18.0" +version = "0.19.0" license = "Apache-2.0" authors = ["Apache Thrift Developers "] homepage = "http://thrift.apache.org" diff --git a/lib/st/package.xml b/lib/st/package.xml index 2b2ce8f8c44..63dd3affa03 100644 --- a/lib/st/package.xml +++ b/lib/st/package.xml @@ -17,7 +17,7 @@ specific language governing permissions and limitations under the License. --> - + libthrift-st thrift.st diff --git a/lib/swift/Sources/Thrift.swift b/lib/swift/Sources/Thrift.swift index 73303ae04f9..df1b6588e4e 100644 --- a/lib/swift/Sources/Thrift.swift +++ b/lib/swift/Sources/Thrift.swift @@ -1,3 +1,3 @@ class Thrift { - let version = "0.18.0" + let version = "0.19.0" } diff --git a/lib/swift/Tests/ThriftTests/ThriftTests.swift b/lib/swift/Tests/ThriftTests/ThriftTests.swift index a37c6048b02..aea9bc814b1 100644 --- a/lib/swift/Tests/ThriftTests/ThriftTests.swift +++ b/lib/swift/Tests/ThriftTests/ThriftTests.swift @@ -3,7 +3,7 @@ import XCTest class ThriftTests: XCTestCase { func testVersion() { - XCTAssertEqual(Thrift().version, "0.18.0") + XCTAssertEqual(Thrift().version, "0.19.0") } static var allTests : [(String, (ThriftTests) -> () throws -> Void)] { diff --git a/lib/ts/package-lock.json b/lib/ts/package-lock.json index 16461e6f764..fed7fe462b8 100644 --- a/lib/ts/package-lock.json +++ b/lib/ts/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.19.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/lib/ts/package.json b/lib/ts/package.json index 88fba82edcd..2d93d326b64 100644 --- a/lib/ts/package.json +++ b/lib/ts/package.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.19.0", "description": "Thrift is a software framework for scalable cross-language services development.", "author": { "name": "Apache Thrift Developers", diff --git a/package-lock.json b/package-lock.json index 8239f386976..df629653b1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.19.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2562538deb2..84080a65cb0 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "git", "url": "https://github.com/apache/thrift.git" }, - "version": "0.18.0", + "version": "0.19.0", "author": { "name": "Apache Thrift Developers", "email": "dev@thrift.apache.org", diff --git a/sonar-project.properties b/sonar-project.properties index 0ec39de985f..cac8e8c4e87 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -16,7 +16,7 @@ development, combines a software stack with a code generation engine to build services that work efficiently and seamlessly between all major languages. # Apache Thrift Version -sonar.projectVersion=0.18.0 +sonar.projectVersion=0.19.0 # use this to set another version string # $ sonar-runner -D sonar.projectVersion=`git rev-parse HEAD` # set projectDate in combination with projectVersion for imports of old releases @@ -54,7 +54,7 @@ module1.sonar.projectName=Apache Thrift - Java Library module1.sonar.projectBaseDir=lib/java module1.sonar.sources=src module1.sonar.tests=test -module1.sonar.binaries=build/libs/libthrift-0.18.0.jar +module1.sonar.binaries=build/libs/libthrift-0.19.0.jar module1.sonar.libraries=build/deps/*.jar module1.sonar.language=java @@ -62,7 +62,7 @@ module2.sonar.projectName=Apache Thrift - Java Tutorial module2.sonar.projectBaseDir=. module2.sonar.sources=tutorial/java/src, tutorial/java/gen-java module2.sonar.binaries=tutorial/java/tutorial.jar -module2.sonar.libraries=lib/java/build/deps/*.jar,lib/java/build/libs/libthrift-0.18.0.jar +module2.sonar.libraries=lib/java/build/deps/*.jar,lib/java/build/libs/libthrift-0.19.0.jar module2.sonar.language=java module3.sonar.projectName=Apache Thrift - JavaScript Library diff --git a/test/dart/test_client/pubspec.yaml b/test/dart/test_client/pubspec.yaml index 3ce154480d5..c34d69359c9 100644 --- a/test/dart/test_client/pubspec.yaml +++ b/test/dart/test_client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: thrift_test_client -version: 0.18.0 +version: 0.19.0 description: A client integration test for the Dart Thrift library author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/test/erl/src/thrift_test.app.src b/test/erl/src/thrift_test.app.src index e94e36db595..4a850d04985 100644 --- a/test/erl/src/thrift_test.app.src +++ b/test/erl/src/thrift_test.app.src @@ -22,7 +22,7 @@ {description, "Thrift cross language test"}, % The version of the applicaton - {vsn, "0.18.0"}, + {vsn, "0.19.0"}, % All modules used by the application. {modules, [ diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index 2373e400223..69e130159eb 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -24,7 +24,7 @@ Client Client Exe - 0.18.0.0 + 0.19.0.0 false false false diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index 0a78e88365e..e6b42e247c5 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -24,7 +24,7 @@ Server Server Exe - 0.18.0.0 + 0.19.0.0 false false false diff --git a/tutorial/dart/client/pubspec.yaml b/tutorial/dart/client/pubspec.yaml index dda5ff0eb2b..626c8f963f0 100644 --- a/tutorial/dart/client/pubspec.yaml +++ b/tutorial/dart/client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_client -version: 0.18.0 +version: 0.19.0 description: A Dart client implementation of the Apache Thrift tutorial author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/tutorial/dart/console_client/pubspec.yaml b/tutorial/dart/console_client/pubspec.yaml index 7aeea57e71b..957b96cb551 100644 --- a/tutorial/dart/console_client/pubspec.yaml +++ b/tutorial/dart/console_client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_console_client -version: 0.18.0 +version: 0.19.0 description: > A Dart console client to implementation of the Apache Thrift tutorial author: Apache Thrift Developers diff --git a/tutorial/dart/server/pubspec.yaml b/tutorial/dart/server/pubspec.yaml index 0ac202a2b13..6ad5cdd48d8 100644 --- a/tutorial/dart/server/pubspec.yaml +++ b/tutorial/dart/server/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_server -version: 0.18.0 +version: 0.19.0 description: A Dart server to support the Apache Thrift tutorial author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/tutorial/delphi/DelphiClient/DelphiClient.dproj b/tutorial/delphi/DelphiClient/DelphiClient.dproj index 45daec2d393..e55cc06bade 100644 --- a/tutorial/delphi/DelphiClient/DelphiClient.dproj +++ b/tutorial/delphi/DelphiClient/DelphiClient.dproj @@ -124,13 +124,13 @@ popd]]> Thrift Tutorial - 0.18.0.0 + 0.19.0.0 DelphiClient Copyright © 2012 The Apache Software Foundation DelphiClient.exe Thrift - 0.18.0.0 + 0.19.0.0 diff --git a/tutorial/delphi/DelphiServer/DelphiServer.dproj b/tutorial/delphi/DelphiServer/DelphiServer.dproj index 91cf7bb91d1..4080b92545a 100644 --- a/tutorial/delphi/DelphiServer/DelphiServer.dproj +++ b/tutorial/delphi/DelphiServer/DelphiServer.dproj @@ -121,13 +121,13 @@ popd]]> Thrift Tutorial - 0.18.0.0 + 0.19.0.0 DelphiServer Copyright © 2012 The Apache Software Foundation DelphiServer.exe Thrift - 0.18.0.0 + 0.19.0.0 diff --git a/tutorial/netstd/Client/Client.csproj b/tutorial/netstd/Client/Client.csproj index c07f9cdd62c..0005c369c85 100644 --- a/tutorial/netstd/Client/Client.csproj +++ b/tutorial/netstd/Client/Client.csproj @@ -24,7 +24,7 @@ Client Client Exe - 0.18.0.0 + 0.19.0.0 false false false diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index 544c532f1c5..353811cd29e 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -22,7 +22,7 @@ net6.0 Interfaces Interfaces - 0.18.0.0 + 0.19.0.0 false false false diff --git a/tutorial/netstd/Server/Server.csproj b/tutorial/netstd/Server/Server.csproj index b55b00877d5..b333c5284de 100644 --- a/tutorial/netstd/Server/Server.csproj +++ b/tutorial/netstd/Server/Server.csproj @@ -24,7 +24,7 @@ Server Server Exe - 0.18.0.0 + 0.19.0.0 false false false diff --git a/tutorial/ocaml/_oasis b/tutorial/ocaml/_oasis index 0eaa5687ee5..110174055a6 100644 --- a/tutorial/ocaml/_oasis +++ b/tutorial/ocaml/_oasis @@ -1,5 +1,5 @@ Name: tutorial -Version: 0.18.0 +Version: 0.19.0 OASISFormat: 0.3 Synopsis: OCaml Tutorial example Authors: Apache Thrift Developers From 2f2696bdf6aff18138e401b73436fc20023e88e2 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Mon, 6 Feb 2023 23:55:19 +0100 Subject: [PATCH 012/250] release branch 0.18.0 --- CHANGES.md | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 6 ++++ doap.rdf | 5 +++ 3 files changed, 105 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 232463d1f6f..682f700eda3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,99 @@ # Apache Thrift Changelog +## 0.18.0 + +### Known Open Issues (Blocker or Critical) + +- [THRIFT-3877](https://issues.apache.org/jira/browse/THRIFT-3877) - C++ library don't work with HTTP (csharp server, cpp client; need cross test enhancement) +- [THRIFT-5468](https://issues.apache.org/jira/browse/THRIFT-5468) - Swift service generator doesn't support oneway + +### Compiler (General) + +- [THRIFT-5587](https://issues.apache.org/jira/browse/THRIFT-5587) - Introduce uuid as additional builtin type +- [THRIFT-5591](https://issues.apache.org/jira/browse/THRIFT-5591) - Add uuid type to IDL and implement reference code +- [THRIFT-5626](https://issues.apache.org/jira/browse/THRIFT-5626) - Parser should not confuse data types and field names +- [THRIFT-5627](https://issues.apache.org/jira/browse/THRIFT-5627) - More consistent syntax for cpp_type +- [THRIFT-5652](https://issues.apache.org/jira/browse/THRIFT-5652) - IDL uuid literals can be improved +- [THRIFT-5669](https://issues.apache.org/jira/browse/THRIFT-5669) - "required" keyword is illegal in a "throws" clause + +### C++ + +- [THRIFT-5661](https://issues.apache.org/jira/browse/THRIFT-5661) - TOutput: add zephyr-specific strerror_s implementation +- [THRIFT-5658](https://issues.apache.org/jira/browse/THRIFT-5658) - TProtocol: support zephyr byteorder +- [THRIFT-5659](https://issues.apache.org/jira/browse/THRIFT-5659) - protocol: declare when methods override + +### D language + +- [THRIFT-5647](https://issues.apache.org/jira/browse/THRIFT-5647) - Fix undeclared identifier ECONNRESET on macOS + +### Delphi + +- [THRIFT-5618](https://issues.apache.org/jira/browse/THRIFT-5618) - More consistent naming of container classes +- [THRIFT-5620](https://issues.apache.org/jira/browse/THRIFT-5620) - Option to force usage of COM types to allow for cross-module references +- [THRIFT-5656](https://issues.apache.org/jira/browse/THRIFT-5656) - Escape Delphi keywords with '&' prefix instead of '_' suffix +- [THRIFT-5619](https://issues.apache.org/jira/browse/THRIFT-5619) - make sure CheckReadBytesAvailable() and CountConsumedMessageBytes() handle negative sizes properly +- [THRIFT-5622](https://issues.apache.org/jira/browse/THRIFT-5622) - Garbled test output with multithreaded clients +- [THRIFT-5625](https://issues.apache.org/jira/browse/THRIFT-5625) - SysUtils.TGuidHelper collides with ThriftUtils.TGuidHelper + +### Erlang + +- [THRIFT-5636](https://issues.apache.org/jira/browse/THRIFT-5636) - Broken client in erlang client library + +### Go + +- [THRIFT-5601](https://issues.apache.org/jira/browse/THRIFT-5601) - Typedef after first use causes incorrect go code +- [THRIFT-5650](https://issues.apache.org/jira/browse/THRIFT-5650) - Add UUID support in go + +### Haxe + +- [THRIFT-5593](https://issues.apache.org/jira/browse/THRIFT-5593) - Implement uuid for hx + +### Java +- [THRIFT-3956](https://issues.apache.org/jira/browse/THRIFT-3956) - Java keywords that are legal in IDL can lead to generated code that will not compile +- [THRIFT-4655](https://issues.apache.org/jira/browse/THRIFT-4655) - Parser fails on the word "from" +- [THRIFT-5631](https://issues.apache.org/jira/browse/THRIFT-5631) - Execution failed for task ':generateBeanJava'. +- [THRIFT-5632](https://issues.apache.org/jira/browse/THRIFT-5632) - Fix java lib pmd main offending errors + +### Kotlin + +- [THRIFT-5646](https://issues.apache.org/jira/browse/THRIFT-5646) - Kotlin library should check to see if Gradle is present + +### netstd + +- [THRIFT-5610](https://issues.apache.org/jira/browse/THRIFT-5610) - Inconsistent constructors TSocketTransport +- [THRIFT-5623](https://issues.apache.org/jira/browse/THRIFT-5623) - ref to disposed instance should be set to null +- [THRIFT-5624](https://issues.apache.org/jira/browse/THRIFT-5624) - suboptimal performance of the c# named pipe server transport in multithread servers +- [THRIFT-5628](https://issues.apache.org/jira/browse/THRIFT-5628) - MaxMessageSize is never reset on a read buffer +- [THRIFT-5639](https://issues.apache.org/jira/browse/THRIFT-5639) - ToString() should use InvariantCulture + +### OCaml + +- [THRIFT-5208](https://issues.apache.org/jira/browse/THRIFT-5208) - OCaml codegen exception pattern match syntax error +- [THRIFT-5642](https://issues.apache.org/jira/browse/THRIFT-5642) - OCaml in docker build environment is broken + +### Python + +- [THRIFT-5617](https://issues.apache.org/jira/browse/THRIFT-5617) - T(SSL)Socket TCP keep-alive incorrectly applies SO_KEEPALIVE to IPPROTO_TCP + +### Rust + +- [THRIFT-5124](https://issues.apache.org/jira/browse/THRIFT-5124) - Cannot use reserved language keyword +- [THRIFT-5606](https://issues.apache.org/jira/browse/THRIFT-5606) - Wrong indent for const double +- [THRIFT-5600](https://issues.apache.org/jira/browse/THRIFT-5600) - Upgrade rust toolchain to 1.61 and edition 2021 +- [THRIFT-5643](https://issues.apache.org/jira/browse/THRIFT-5643) - Please publish latest version of the Rust lib to crates.io + +### Swift + +- [THRIFT-5629](https://issues.apache.org/jira/browse/THRIFT-5629) - Add UUID support for Swift +- [THRIFT-4547](https://issues.apache.org/jira/browse/THRIFT-4547) - Finish the conversion to native swift (LANGUAGES.md, cross test) +- [THRIFT-5621](https://issues.apache.org/jira/browse/THRIFT-5621) - Create Swift Tutorial +- [THRIFT-5630](https://issues.apache.org/jira/browse/THRIFT-5630) - Swift TSocketServer not working on Linux + +### Website + +- [THRIFT-5634](https://issues.apache.org/jira/browse/THRIFT-5634) - thrift docs picture was broken + + ## 0.17.0 ### Known Open Issues (Blocker or Critical) diff --git a/debian/changelog b/debian/changelog index dc021678881..1f26d9b17fe 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +thrift (0.18.0) stable; urgency=low + + * update to 0.18.0 + + -- Apache Thrift Developers Mon, 06 Feb 2023 23:30:00 +0100 + thrift (0.17.0) stable; urgency=low * update to 0.17.0 diff --git a/doap.rdf b/doap.rdf index e69bedcf0f4..8a0b0bb3f47 100644 --- a/doap.rdf +++ b/doap.rdf @@ -55,6 +55,11 @@ + + Apache Thrift + 2022-02-06 + 0.18.0 + Apache Thrift 2022-08-30 From c30ee69ef671a9fd4b86f19b38e0b10964c0d4bc Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Tue, 14 Feb 2023 23:33:29 +0100 Subject: [PATCH 013/250] Added reference to existing netstd README.md file to satisfy nuget package upload --- lib/netstd/Thrift/Thrift.csproj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index 902e3db9a80..edc5d8f0a06 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -51,7 +51,8 @@ Apache Thrift RPC https://github.com/apache/thrift/blob/0.18.0/CHANGES.md - Copyright 2022 The Apache Software Foundation + README.md + Copyright 2023 The Apache Software Foundation @@ -72,6 +73,10 @@ + + + + $(IntermediateOutputPath)$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension) From 71df9a35885fda5e7a0b4dc201d2cb27a4ebba0d Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 15 Feb 2023 06:49:58 -0500 Subject: [PATCH 014/250] fix typo as --> and --- doc/specs/thrift-binary-protocol.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/specs/thrift-binary-protocol.md b/doc/specs/thrift-binary-protocol.md index af4bd8196ba..e751a022bf2 100644 --- a/doc/specs/thrift-binary-protocol.md +++ b/doc/specs/thrift-binary-protocol.md @@ -80,7 +80,7 @@ Where: ### Double encoding Values of type `double` are first converted to an int64 according to the IEEE 754 floating-point "double format" bit -layout. Most run-times provide a library to make this conversion. Both the binary protocol as the compact protocol then +layout. Most run-times provide a library to make this conversion. Both the binary protocol and the compact protocol then encode the int64 in 8 bytes in big endian order. ### Boolean encoding From 423ab3997d3c3879d95fcd00e816f226b0f396d4 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Wed, 15 Feb 2023 22:12:19 +0100 Subject: [PATCH 015/250] bump version --- ApacheThrift.nuspec | 8 ++++---- CHANGES.md | 15 +++++++++++++++ CMakeLists.txt | 2 +- Thrift.podspec | 4 ++-- appveyor.yml | 2 +- bower.json | 2 +- compiler/cpp/src/thrift/version.h | 2 +- configure.ac | 2 +- contrib/Rebus/Properties/AssemblyInfo.cs | 4 ++-- contrib/thrift-maven-plugin/pom.xml | 2 +- contrib/thrift.spec | 2 +- contrib/zeromq/csharp/AssemblyInfo.cs | 2 +- debian/changelog | 6 ++++++ doap.rdf | 5 +++++ doc/specs/idl.md | 2 +- lib/d/src/thrift/base.d | 2 +- lib/dart/pubspec.yaml | 2 +- lib/delphi/src/Thrift.pas | 2 +- lib/erl/src/thrift.app.src | 2 +- lib/haxe/haxelib.json | 2 +- lib/java/gradle.properties | 2 +- lib/js/package-lock.json | 2 +- lib/js/package.json | 2 +- lib/js/src/thrift.js | 2 +- lib/lua/Thrift.lua | 2 +- .../Thrift.IntegrationTests.csproj | 2 +- .../Thrift.PublicInterfaces.Compile.Tests.csproj | 2 +- lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj | 2 +- lib/netstd/Thrift/Properties/AssemblyInfo.cs | 4 ++-- lib/netstd/Thrift/Thrift.csproj | 6 +++--- lib/ocaml/_oasis | 2 +- lib/perl/lib/Thrift.pm | 2 +- lib/py/setup.py | 2 +- lib/rb/thrift.gemspec | 2 +- lib/rs/Cargo.toml | 2 +- lib/st/package.xml | 2 +- lib/swift/Sources/Thrift.swift | 2 +- lib/swift/Tests/ThriftTests/ThriftTests.swift | 2 +- lib/ts/package-lock.json | 2 +- lib/ts/package.json | 2 +- package-lock.json | 2 +- package.json | 2 +- sonar-project.properties | 6 +++--- test/dart/test_client/pubspec.yaml | 2 +- test/erl/src/thrift_test.app.src | 2 +- test/netstd/Client/Client.csproj | 2 +- test/netstd/Server/Server.csproj | 2 +- tutorial/dart/client/pubspec.yaml | 2 +- tutorial/dart/console_client/pubspec.yaml | 2 +- tutorial/dart/server/pubspec.yaml | 2 +- tutorial/delphi/DelphiClient/DelphiClient.dproj | 4 ++-- tutorial/delphi/DelphiServer/DelphiServer.dproj | 4 ++-- tutorial/netstd/Client/Client.csproj | 2 +- tutorial/netstd/Interfaces/Interfaces.csproj | 2 +- tutorial/netstd/Server/Server.csproj | 2 +- tutorial/ocaml/_oasis | 2 +- 56 files changed, 91 insertions(+), 65 deletions(-) diff --git a/ApacheThrift.nuspec b/ApacheThrift.nuspec index 3404347f21c..fe066df544e 100644 --- a/ApacheThrift.nuspec +++ b/ApacheThrift.nuspec @@ -19,14 +19,14 @@ the "Thrift" project. 2. nuget setApiKey 3. nuget pack ApacheThrift.nuspec -Symbols -SymbolPackageFormat snupkg - 4. nuget push ApacheThrift.0.18.0.nupkg -Source https://api.nuget.org/v3/index.json + 4. nuget push ApacheThrift.0.18.1.nupkg -Source https://api.nuget.org/v3/index.json --> ApacheThrift - 0.18.0 - Apache Thrift 0.18.0 + 0.18.1 + Apache Thrift 0.18.1 Apache Thrift Developers Apache Software Foundation Apache-2.0 @@ -36,7 +36,7 @@ Contains runtime libraries from lib/netstd for netstandard2.0 framework development. - + Apache Thrift RPC diff --git a/CHANGES.md b/CHANGES.md index 682f700eda3..95faa04037b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,20 @@ # Apache Thrift Changelog +## 0.18.1 + +### Known Open Issues (Blocker or Critical) + +- [THRIFT-3877](https://issues.apache.org/jira/browse/THRIFT-3877) - C++ library don't work with HTTP (csharp server, cpp client; need cross test enhancement) +- [THRIFT-5468](https://issues.apache.org/jira/browse/THRIFT-5468) - Swift service generator doesn't support oneway + +### Reopened issues + +- [THRIFT-5601](https://issues.apache.org/jira/browse/THRIFT-5601) - Typedef after first use causes incorrect go code + +### Go + +- [THRIFT-5685](https://issues.apache.org/jira/browse/THRIFT-5685) - Compiler generates wrong go code for forward defined types in optional fields + ## 0.18.0 ### Known Open Issues (Blocker or Critical) diff --git a/CMakeLists.txt b/CMakeLists.txt index 859d944326c..3dfda417cb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ endif() # PACKAGE_VERSION is used by cpack scripts currently # Both thrift_VERSION and PACKAGE_VERSION should be the same for now -set(thrift_VERSION "0.18.0") +set(thrift_VERSION "0.18.1") set(PACKAGE_VERSION ${thrift_VERSION}) project("thrift" VERSION ${PACKAGE_VERSION}) diff --git a/Thrift.podspec b/Thrift.podspec index 7350be47939..c0ae6c243dc 100644 --- a/Thrift.podspec +++ b/Thrift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Thrift' - s.version = '0.18.0' + s.version = '0.18.1' s.summary = "Apache Thrift is a lightweight, language-independent software stack with an associated code generation mechanism for RPC." s.description = <<-DESC The Apache Thrift scalable cross-language software framework for networked services development combines a software stack with a code generation engine to build services that work efficiently and seamlessly between many programming languages. @@ -10,6 +10,6 @@ The Apache Thrift scalable cross-language software framework for networked servi s.author = { 'Apache Thrift Developers' => 'dev@thrift.apache.org' } s.ios.deployment_target = '9.0' s.osx.deployment_target = '10.10' - s.source = { :git => 'https://github.com/apache/thrift.git', :tag => 'v0.18.0' } + s.source = { :git => 'https://github.com/apache/thrift.git', :tag => 'v0.18.1' } s.source_files = 'lib/swift/Sources/*.swift' end diff --git a/appveyor.yml b/appveyor.yml index 1a7f0262941..97d41cf0465 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,7 +19,7 @@ # build Apache Thrift on AppVeyor - https://ci.appveyor.com -version: '0.18.0.{build}' +version: '0.18.1.{build}' shallow_clone: true diff --git a/bower.json b/bower.json index a6ef878df12..2590c24f912 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.18.1", "homepage": "https://github.com/apache/thrift.git", "authors": [ "Apache Thrift " diff --git a/compiler/cpp/src/thrift/version.h b/compiler/cpp/src/thrift/version.h index 0905b34076b..4aeae050a3e 100644 --- a/compiler/cpp/src/thrift/version.h +++ b/compiler/cpp/src/thrift/version.h @@ -24,6 +24,6 @@ #pragma once #endif // _MSC_VER -#define THRIFT_VERSION "0.18.0" +#define THRIFT_VERSION "0.18.1" #endif // _THRIFT_VERSION_H_ diff --git a/configure.ac b/configure.ac index 12c20de0bd5..87aadc77e0d 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ(2.65) AC_CONFIG_MACRO_DIR([./aclocal]) -AC_INIT([thrift], [0.18.0]) +AC_INIT([thrift], [0.18.1]) AC_CONFIG_AUX_DIR([.]) diff --git a/contrib/Rebus/Properties/AssemblyInfo.cs b/contrib/Rebus/Properties/AssemblyInfo.cs index 605eb5ceff3..5e63934c8b8 100644 --- a/contrib/Rebus/Properties/AssemblyInfo.cs +++ b/contrib/Rebus/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ [assembly: Guid("0af10984-40d3-453d-b1e5-421529e8c7e2")] -[assembly: AssemblyVersion("0.18.0.0")] -[assembly: AssemblyFileVersion("0.18.0.0")] +[assembly: AssemblyVersion("0.18.1.0")] +[assembly: AssemblyFileVersion("0.18.1.0")] diff --git a/contrib/thrift-maven-plugin/pom.xml b/contrib/thrift-maven-plugin/pom.xml index 1ea0ddcd836..19258a8ffbc 100644 --- a/contrib/thrift-maven-plugin/pom.xml +++ b/contrib/thrift-maven-plugin/pom.xml @@ -29,7 +29,7 @@ thrift-maven-plugin maven-plugin thrift-maven-plugin - 0.18.0 + 0.18.1 1.8 diff --git a/contrib/thrift.spec b/contrib/thrift.spec index ecc7fb78ff2..639c51416c4 100644 --- a/contrib/thrift.spec +++ b/contrib/thrift.spec @@ -28,7 +28,7 @@ Name: thrift License: Apache License v2.0 Group: Development Summary: RPC and serialization framework -Version: 0.18.0 +Version: 0.18.1 Release: 0 URL: http://thrift.apache.org Packager: Thrift Developers diff --git a/contrib/zeromq/csharp/AssemblyInfo.cs b/contrib/zeromq/csharp/AssemblyInfo.cs index 787b00d6122..2c0165cdde4 100644 --- a/contrib/zeromq/csharp/AssemblyInfo.cs +++ b/contrib/zeromq/csharp/AssemblyInfo.cs @@ -36,7 +36,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("0.18.0.0")] +[assembly: AssemblyVersion("0.18.1.0")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. diff --git a/debian/changelog b/debian/changelog index 1f26d9b17fe..93dc7aaef8a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +thrift (0.18.1) stable; urgency=low + + * update to 0.18.1 + + -- Apache Thrift Developers Wed, 15 Feb 2023 22:15:00 +0100 + thrift (0.18.0) stable; urgency=low * update to 0.18.0 diff --git a/doap.rdf b/doap.rdf index 8a0b0bb3f47..9c4d63c699b 100644 --- a/doap.rdf +++ b/doap.rdf @@ -55,6 +55,11 @@ + + Apache Thrift + 2022-02-15 + 0.18.1 + Apache Thrift 2022-02-06 diff --git a/doc/specs/idl.md b/doc/specs/idl.md index 456b777d66e..3cf0efd19d2 100644 --- a/doc/specs/idl.md +++ b/doc/specs/idl.md @@ -1,6 +1,6 @@ ## Thrift interface description language -For Thrift version 0.18.0. +For Thrift version 0.18.1. The Thrift interface definition language (IDL) allows for the definition of [Thrift Types](/docs/types). A Thrift IDL file is processed by the Thrift code generator to produce code for the various target languages to support the defined structs and services in the IDL file. diff --git a/lib/d/src/thrift/base.d b/lib/d/src/thrift/base.d index ce706be1788..980db9dd0aa 100644 --- a/lib/d/src/thrift/base.d +++ b/lib/d/src/thrift/base.d @@ -50,7 +50,7 @@ class TCompoundOperationException : TException { /// The Thrift version string, used for informative purposes. // Note: This is currently hardcoded, but will likely be filled in by the build // system in future versions. -enum VERSION = "0.18.0"; +enum VERSION = "0.18.1"; /** * Functions used for logging inside Thrift. diff --git a/lib/dart/pubspec.yaml b/lib/dart/pubspec.yaml index a94dec96905..4716c20d586 100644 --- a/lib/dart/pubspec.yaml +++ b/lib/dart/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: thrift -version: 0.18.0 +version: 0.18.1 description: > A Dart library for Apache Thrift author: Apache Thrift Developers diff --git a/lib/delphi/src/Thrift.pas b/lib/delphi/src/Thrift.pas index 6fcc65df767..b18ffad33c9 100644 --- a/lib/delphi/src/Thrift.pas +++ b/lib/delphi/src/Thrift.pas @@ -28,7 +28,7 @@ interface Thrift.Protocol; const - Version = '0.18.0'; + Version = '0.18.1'; type TException = Thrift.Exception.TException; // compatibility alias diff --git a/lib/erl/src/thrift.app.src b/lib/erl/src/thrift.app.src index 180f3893e93..3d98c0737d6 100644 --- a/lib/erl/src/thrift.app.src +++ b/lib/erl/src/thrift.app.src @@ -22,7 +22,7 @@ {description, "Thrift bindings"}, % The version of the applicaton - {vsn, "0.18.0"}, + {vsn, "0.18.1"}, % All modules used by the application. {modules, [ diff --git a/lib/haxe/haxelib.json b/lib/haxe/haxelib.json index 4775ac42a23..53e128ef815 100644 --- a/lib/haxe/haxelib.json +++ b/lib/haxe/haxelib.json @@ -10,7 +10,7 @@ "framework" ], "description": "Haxe bindings for the Apache Thrift RPC and serialization framework", - "version": "0.18.0", + "version": "0.18.1", "releasenote": "Licensed under Apache License, Version 2.0. The Apache Thrift compiler needs to be installed separately.", "contributors": ["ApacheThrift"], "dependencies": { diff --git a/lib/java/gradle.properties b/lib/java/gradle.properties index 3ef6a5fbf81..07f0b622656 100644 --- a/lib/java/gradle.properties +++ b/lib/java/gradle.properties @@ -1,7 +1,7 @@ # This file is shared currently between this Gradle build and the # Ant builds for fd303 and JavaScript. Keep the dotted notation for # the properties to minimize the changes in the dependencies. -thrift.version=0.18.0 +thrift.version=0.18.1 thrift.groupid=org.apache.thrift release=false diff --git a/lib/js/package-lock.json b/lib/js/package-lock.json index f95e31fe186..3eedc1533eb 100644 --- a/lib/js/package-lock.json +++ b/lib/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.18.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/lib/js/package.json b/lib/js/package.json index ab0cc6b41ea..49f1a7294bc 100644 --- a/lib/js/package.json +++ b/lib/js/package.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.18.1", "description": "Thrift is a software framework for scalable cross-language services development.", "main": "./src/thrift", "author": { diff --git a/lib/js/src/thrift.js b/lib/js/src/thrift.js index 3ea17974f26..e18e251fe55 100644 --- a/lib/js/src/thrift.js +++ b/lib/js/src/thrift.js @@ -46,7 +46,7 @@ var Thrift = { * @const {string} Version * @memberof Thrift */ - Version: '0.18.0', + Version: '0.18.1', /** * Thrift IDL type string to Id mapping. diff --git a/lib/lua/Thrift.lua b/lib/lua/Thrift.lua index 064399c1b18..ed052e1e365 100644 --- a/lib/lua/Thrift.lua +++ b/lib/lua/Thrift.lua @@ -48,7 +48,7 @@ function ttable_size(t) return count end -version = '0.18.0' +version = '0.18.1' TType = { STOP = 0, diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index f21aa8bbf3d..c353da3ab8b 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -22,7 +22,7 @@ net6.0 Thrift.IntegrationTests Thrift.IntegrationTests - 0.18.0.0 + 0.18.1.0 Exe false false diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj index 54970b77d4c..4597d53e716 100644 --- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj +++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj @@ -19,7 +19,7 @@ --> - 0.18.0 + 0.18.1 Thrift version $(ThriftVersion) net6.0 $(ThriftVersion).0 diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index efd21f89816..c412fa0c241 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -20,7 +20,7 @@ net6.0 - 0.18.0.0 + 0.18.1.0 enable diff --git a/lib/netstd/Thrift/Properties/AssemblyInfo.cs b/lib/netstd/Thrift/Properties/AssemblyInfo.cs index 6978f52196b..387033e33d6 100644 --- a/lib/netstd/Thrift/Properties/AssemblyInfo.cs +++ b/lib/netstd/Thrift/Properties/AssemblyInfo.cs @@ -52,5 +52,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.18.0.0")] -[assembly: AssemblyFileVersion("0.18.0.0")] +[assembly: AssemblyVersion("0.18.1.0")] +[assembly: AssemblyFileVersion("0.18.1.0")] diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index edc5d8f0a06..84521d560c2 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -40,8 +40,8 @@ true thrift.snk false - Apache Thrift 0.18.0 - 0.18.0.0 + Apache Thrift 0.18.1 + 0.18.1.0 false http://thrift.apache.org/ Apache Thrift Developers @@ -50,7 +50,7 @@ C# .NET Core bindings for the Apache Thrift RPC system Apache Thrift RPC - https://github.com/apache/thrift/blob/0.18.0/CHANGES.md + https://github.com/apache/thrift/blob/0.18.1/CHANGES.md README.md Copyright 2023 The Apache Software Foundation diff --git a/lib/ocaml/_oasis b/lib/ocaml/_oasis index e37dba74236..4014d810636 100644 --- a/lib/ocaml/_oasis +++ b/lib/ocaml/_oasis @@ -1,5 +1,5 @@ Name: libthrift-ocaml -Version: 0.18.0 +Version: 0.18.1 OASISFormat: 0.3 Synopsis: OCaml bindings for the Apache Thrift RPC system Authors: Apache Thrift Developers diff --git a/lib/perl/lib/Thrift.pm b/lib/perl/lib/Thrift.pm index c10abd832c7..bb41d45f601 100644 --- a/lib/perl/lib/Thrift.pm +++ b/lib/perl/lib/Thrift.pm @@ -31,6 +31,6 @@ use warnings; # package Thrift; -use version 0.77; our $VERSION = version->declare("v0.18.0"); +use version 0.77; our $VERSION = version->declare("v0.18.1"); 1; diff --git a/lib/py/setup.py b/lib/py/setup.py index 7be2b5d66a6..e4d58f93bfe 100644 --- a/lib/py/setup.py +++ b/lib/py/setup.py @@ -105,7 +105,7 @@ def run_setup(with_binary): twisted_deps = ['twisted'] setup(name='thrift', - version='0.18.0', + version='0.18.1', description='Python bindings for the Apache Thrift RPC system', long_description=read_file("README.md"), long_description_content_type="text/markdown", diff --git a/lib/rb/thrift.gemspec b/lib/rb/thrift.gemspec index e6cc55b9f81..17462b03957 100644 --- a/lib/rb/thrift.gemspec +++ b/lib/rb/thrift.gemspec @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__) Gem::Specification.new do |s| s.name = 'thrift' - s.version = '0.18.0' + s.version = '0.18.1' s.authors = ['Apache Thrift Developers'] s.email = ['dev@thrift.apache.org'] s.homepage = 'http://thrift.apache.org' diff --git a/lib/rs/Cargo.toml b/lib/rs/Cargo.toml index 844355fb6ae..dd27060f2df 100644 --- a/lib/rs/Cargo.toml +++ b/lib/rs/Cargo.toml @@ -2,7 +2,7 @@ name = "thrift" description = "Rust bindings for the Apache Thrift RPC system" edition = "2021" -version = "0.18.0" +version = "0.18.1" license = "Apache-2.0" authors = ["Apache Thrift Developers "] homepage = "http://thrift.apache.org" diff --git a/lib/st/package.xml b/lib/st/package.xml index 2b2ce8f8c44..5c9e374d766 100644 --- a/lib/st/package.xml +++ b/lib/st/package.xml @@ -17,7 +17,7 @@ specific language governing permissions and limitations under the License. --> - + libthrift-st thrift.st diff --git a/lib/swift/Sources/Thrift.swift b/lib/swift/Sources/Thrift.swift index 73303ae04f9..603331245b3 100644 --- a/lib/swift/Sources/Thrift.swift +++ b/lib/swift/Sources/Thrift.swift @@ -1,3 +1,3 @@ class Thrift { - let version = "0.18.0" + let version = "0.18.1" } diff --git a/lib/swift/Tests/ThriftTests/ThriftTests.swift b/lib/swift/Tests/ThriftTests/ThriftTests.swift index a37c6048b02..8a3a8a01cee 100644 --- a/lib/swift/Tests/ThriftTests/ThriftTests.swift +++ b/lib/swift/Tests/ThriftTests/ThriftTests.swift @@ -3,7 +3,7 @@ import XCTest class ThriftTests: XCTestCase { func testVersion() { - XCTAssertEqual(Thrift().version, "0.18.0") + XCTAssertEqual(Thrift().version, "0.18.1") } static var allTests : [(String, (ThriftTests) -> () throws -> Void)] { diff --git a/lib/ts/package-lock.json b/lib/ts/package-lock.json index 16461e6f764..7e8382a999e 100644 --- a/lib/ts/package-lock.json +++ b/lib/ts/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.18.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/lib/ts/package.json b/lib/ts/package.json index 88fba82edcd..97da5c47401 100644 --- a/lib/ts/package.json +++ b/lib/ts/package.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.18.1", "description": "Thrift is a software framework for scalable cross-language services development.", "author": { "name": "Apache Thrift Developers", diff --git a/package-lock.json b/package-lock.json index 8239f386976..c2b9b68c3ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.18.0", + "version": "0.18.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2562538deb2..cce14ba970c 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "git", "url": "https://github.com/apache/thrift.git" }, - "version": "0.18.0", + "version": "0.18.1", "author": { "name": "Apache Thrift Developers", "email": "dev@thrift.apache.org", diff --git a/sonar-project.properties b/sonar-project.properties index 0ec39de985f..464f75ec829 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -16,7 +16,7 @@ development, combines a software stack with a code generation engine to build services that work efficiently and seamlessly between all major languages. # Apache Thrift Version -sonar.projectVersion=0.18.0 +sonar.projectVersion=0.18.1 # use this to set another version string # $ sonar-runner -D sonar.projectVersion=`git rev-parse HEAD` # set projectDate in combination with projectVersion for imports of old releases @@ -54,7 +54,7 @@ module1.sonar.projectName=Apache Thrift - Java Library module1.sonar.projectBaseDir=lib/java module1.sonar.sources=src module1.sonar.tests=test -module1.sonar.binaries=build/libs/libthrift-0.18.0.jar +module1.sonar.binaries=build/libs/libthrift-0.18.1.jar module1.sonar.libraries=build/deps/*.jar module1.sonar.language=java @@ -62,7 +62,7 @@ module2.sonar.projectName=Apache Thrift - Java Tutorial module2.sonar.projectBaseDir=. module2.sonar.sources=tutorial/java/src, tutorial/java/gen-java module2.sonar.binaries=tutorial/java/tutorial.jar -module2.sonar.libraries=lib/java/build/deps/*.jar,lib/java/build/libs/libthrift-0.18.0.jar +module2.sonar.libraries=lib/java/build/deps/*.jar,lib/java/build/libs/libthrift-0.18.1.jar module2.sonar.language=java module3.sonar.projectName=Apache Thrift - JavaScript Library diff --git a/test/dart/test_client/pubspec.yaml b/test/dart/test_client/pubspec.yaml index 3ce154480d5..87db0770353 100644 --- a/test/dart/test_client/pubspec.yaml +++ b/test/dart/test_client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: thrift_test_client -version: 0.18.0 +version: 0.18.1 description: A client integration test for the Dart Thrift library author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/test/erl/src/thrift_test.app.src b/test/erl/src/thrift_test.app.src index e94e36db595..dd4e00e482c 100644 --- a/test/erl/src/thrift_test.app.src +++ b/test/erl/src/thrift_test.app.src @@ -22,7 +22,7 @@ {description, "Thrift cross language test"}, % The version of the applicaton - {vsn, "0.18.0"}, + {vsn, "0.18.1"}, % All modules used by the application. {modules, [ diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index 2373e400223..afbdda70350 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -24,7 +24,7 @@ Client Client Exe - 0.18.0.0 + 0.18.1.0 false false false diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index 0a78e88365e..52d2d057aa9 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -24,7 +24,7 @@ Server Server Exe - 0.18.0.0 + 0.18.1.0 false false false diff --git a/tutorial/dart/client/pubspec.yaml b/tutorial/dart/client/pubspec.yaml index dda5ff0eb2b..02106116c16 100644 --- a/tutorial/dart/client/pubspec.yaml +++ b/tutorial/dart/client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_client -version: 0.18.0 +version: 0.18.1 description: A Dart client implementation of the Apache Thrift tutorial author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/tutorial/dart/console_client/pubspec.yaml b/tutorial/dart/console_client/pubspec.yaml index 7aeea57e71b..cb409ddc9f9 100644 --- a/tutorial/dart/console_client/pubspec.yaml +++ b/tutorial/dart/console_client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_console_client -version: 0.18.0 +version: 0.18.1 description: > A Dart console client to implementation of the Apache Thrift tutorial author: Apache Thrift Developers diff --git a/tutorial/dart/server/pubspec.yaml b/tutorial/dart/server/pubspec.yaml index 0ac202a2b13..db08db3a7de 100644 --- a/tutorial/dart/server/pubspec.yaml +++ b/tutorial/dart/server/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_server -version: 0.18.0 +version: 0.18.1 description: A Dart server to support the Apache Thrift tutorial author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/tutorial/delphi/DelphiClient/DelphiClient.dproj b/tutorial/delphi/DelphiClient/DelphiClient.dproj index 45daec2d393..30b44c3ccc2 100644 --- a/tutorial/delphi/DelphiClient/DelphiClient.dproj +++ b/tutorial/delphi/DelphiClient/DelphiClient.dproj @@ -124,13 +124,13 @@ popd]]> Thrift Tutorial - 0.18.0.0 + 0.18.1.0 DelphiClient Copyright © 2012 The Apache Software Foundation DelphiClient.exe Thrift - 0.18.0.0 + 0.18.1.0 diff --git a/tutorial/delphi/DelphiServer/DelphiServer.dproj b/tutorial/delphi/DelphiServer/DelphiServer.dproj index 91cf7bb91d1..3ea81d3eaa8 100644 --- a/tutorial/delphi/DelphiServer/DelphiServer.dproj +++ b/tutorial/delphi/DelphiServer/DelphiServer.dproj @@ -121,13 +121,13 @@ popd]]> Thrift Tutorial - 0.18.0.0 + 0.18.1.0 DelphiServer Copyright © 2012 The Apache Software Foundation DelphiServer.exe Thrift - 0.18.0.0 + 0.18.1.0 diff --git a/tutorial/netstd/Client/Client.csproj b/tutorial/netstd/Client/Client.csproj index c07f9cdd62c..53ea7b46814 100644 --- a/tutorial/netstd/Client/Client.csproj +++ b/tutorial/netstd/Client/Client.csproj @@ -24,7 +24,7 @@ Client Client Exe - 0.18.0.0 + 0.18.1.0 false false false diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index 544c532f1c5..194f859c0ee 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -22,7 +22,7 @@ net6.0 Interfaces Interfaces - 0.18.0.0 + 0.18.1.0 false false false diff --git a/tutorial/netstd/Server/Server.csproj b/tutorial/netstd/Server/Server.csproj index b55b00877d5..c7e80079209 100644 --- a/tutorial/netstd/Server/Server.csproj +++ b/tutorial/netstd/Server/Server.csproj @@ -24,7 +24,7 @@ Server Server Exe - 0.18.0.0 + 0.18.1.0 false false false diff --git a/tutorial/ocaml/_oasis b/tutorial/ocaml/_oasis index 0eaa5687ee5..0231ffab8c1 100644 --- a/tutorial/ocaml/_oasis +++ b/tutorial/ocaml/_oasis @@ -1,5 +1,5 @@ Name: tutorial -Version: 0.18.0 +Version: 0.18.1 OASISFormat: 0.3 Synopsis: OCaml Tutorial example Authors: Apache Thrift Developers From 51fc54f8c161ae94e4d230cddae8d9d2ee279fad Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Tue, 14 Feb 2023 23:51:16 +0100 Subject: [PATCH 016/250] THRIFT-5684 upgrade to net7.0: Client: netstd Patch: Jens Geyer --- build/docker/README.md | 2 +- build/docker/old/debian-stretch/Dockerfile | 8 +++--- build/docker/old/ubuntu-artful/Dockerfile | 8 +++--- build/docker/old/ubuntu-disco/Dockerfile | 8 +++--- build/docker/old/ubuntu-xenial/Dockerfile | 8 +++--- build/docker/ubuntu-bionic/Dockerfile | 8 +++--- build/docker/ubuntu-focal/Dockerfile | 8 +++--- build/docker/ubuntu-jammy/Dockerfile | 8 +++--- .../src/thrift/generate/t_netstd_generator.cc | 26 ++++++++++++------- configure.ac | 2 +- .../Thrift.Benchmarks.csproj | 6 ++--- .../Thrift.IntegrationTests.csproj | 14 +++++----- ...rift.PublicInterfaces.Compile.Tests.csproj | 6 ++--- .../Tests/Thrift.Tests/Thrift.Tests.csproj | 14 +++++----- lib/netstd/Thrift/Thrift.csproj | 14 +++++----- .../Server/TNamedPipeServerTransport.cs | 19 -------------- test/netstd/Client/Client.csproj | 6 ++--- test/netstd/Client/TestClient.cs | 2 +- test/netstd/Server/Server.csproj | 6 ++--- test/netstd/Server/TestServer.cs | 2 +- tutorial/netstd/Client/Client.csproj | 4 +-- tutorial/netstd/Interfaces/Interfaces.csproj | 4 +-- tutorial/netstd/Server/Program.cs | 2 +- tutorial/netstd/Server/Server.csproj | 4 +-- 24 files changed, 88 insertions(+), 101 deletions(-) diff --git a/build/docker/README.md b/build/docker/README.md index a41f031a51e..9635e6f0438 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -183,7 +183,7 @@ Last updated: October 1, 2017 | java | 1.8.0\_191 | 17 | | | js | Node.js 6.17.1, V8 5.1.281.111, npm 3.10.10 | Node.js 10.18.0, V8 6.8.275.32, npm 6.13.4 | | | lua | | 5.2.4 | Lua 5.3: see THRIFT-4386 | -| netstd | 6.0 | 6.0 | | +| netstd | 7.0 | 7.0 | | | nodejs | 6.16.0 | 10.16.0 | | | ocaml | | 4.05.0 | THRIFT-4517: ocaml 4.02.3 on xenial appears broken | | perl | 5.22.1 | 5.26.1 | | diff --git a/build/docker/old/debian-stretch/Dockerfile b/build/docker/old/debian-stretch/Dockerfile index 628b6268e57..25237cabf41 100644 --- a/build/docker/old/debian-stretch/Dockerfile +++ b/build/docker/old/debian-stretch/Dockerfile @@ -102,10 +102,10 @@ ENV PATH /usr/lib/dart/bin:$PATH # project isn't ready for this quite yet: # RUN apt-get install -y --no-install-recommends \ # `# dotnet core dependencies` \ -# dotnet-sdk-6.0 \ -# dotnet-runtime-6.0 \ -# aspnetcore-runtime-6.0 \ -# dotnet-apphost-pack-6.0 +# dotnet-sdk-7.0 \ +# dotnet-runtime-7.0 \ +# aspnetcore-runtime-7.0 \ +# dotnet-apphost-pack-7.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/old/ubuntu-artful/Dockerfile b/build/docker/old/ubuntu-artful/Dockerfile index 80682657b9f..039147033a7 100644 --- a/build/docker/old/ubuntu-artful/Dockerfile +++ b/build/docker/old/ubuntu-artful/Dockerfile @@ -120,10 +120,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/old/ubuntu-disco/Dockerfile b/build/docker/old/ubuntu-disco/Dockerfile index 2e802e5ac2c..37377e34f8d 100644 --- a/build/docker/old/ubuntu-disco/Dockerfile +++ b/build/docker/old/ubuntu-disco/Dockerfile @@ -126,10 +126,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/old/ubuntu-xenial/Dockerfile b/build/docker/old/ubuntu-xenial/Dockerfile index 7cb58e8cece..add524ded84 100644 --- a/build/docker/old/ubuntu-xenial/Dockerfile +++ b/build/docker/old/ubuntu-xenial/Dockerfile @@ -115,10 +115,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=18.3.4.11 diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile index 873dad83657..f0dcb9080aa 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/ubuntu-bionic/Dockerfile @@ -124,10 +124,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=23.3.4.11 diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index 0a8c1c763a2..ad01f7e9f10 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -125,10 +125,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=23.3.4.11 diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index 7d56cc5fe6a..d2a5f64a47f 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -125,10 +125,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-6.0 \ - dotnet-runtime-6.0 \ - aspnetcore-runtime-6.0 \ - dotnet-apphost-pack-6.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=23.3.4.11 diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc index 96bdc3c0695..1c970029998 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc @@ -179,6 +179,12 @@ string t_netstd_generator::normalize_name(string name, bool is_arg_name) return "@" + name; } + // prevent CS8981 "The type name only contains lower-cased ascii characters" + if( name.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == std::string::npos) + { + return "@" + name; + } + // no changes necessary return name; } @@ -356,7 +362,7 @@ void t_netstd_generator::generate_consts(ostream& out, vector consts) for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { generate_netstd_doc(out, *c_iter); - if (print_const_value(out, (*c_iter)->get_name(), (*c_iter)->get_type(), (*c_iter)->get_value(), false)) + if (print_const_value(out, normalize_name((*c_iter)->get_name()), (*c_iter)->get_type(), (*c_iter)->get_value(), false)) { need_static_constructor = true; } @@ -474,7 +480,7 @@ bool t_netstd_generator::print_const_value(ostream& out, string name, t_type* ty if (type->is_base_type()) { string v2 = render_const_value(out, name, type, value); - out << normalize_name(name) << " = " << v2 << ";" << endl; + out << name << " = " << v2 << ";" << endl; need_static_construction = false; } else if (type->is_enum()) @@ -552,7 +558,7 @@ string t_netstd_generator::render_const_value(ostream& out, string name, t_type* } else { - string t = tmp("tmp"); + string t = normalize_name(tmp("tmp")); print_const_value(out, t, type, value, true, true, true); render << t; } @@ -940,7 +946,7 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc { if (field_is_required((*m_iter))) { - print_const_value(out, "this." + prop_name(*m_iter), t, (*m_iter)->get_value(), true, true); + print_const_value(out, "this." + normalize_name(prop_name(*m_iter)), t, (*m_iter)->get_value(), true, true); } else { @@ -1456,14 +1462,14 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct // Let's define the class first start_netstd_namespace(out); - out << indent() << "public abstract partial class " << tunion->get_name() << " : TUnionBase" << endl; + out << indent() << "public abstract partial class " << normalize_name(tunion->get_name()) << " : TUnionBase" << endl; out << indent() << "{" << endl; indent_up(); out << indent() << "public abstract global::System.Threading.Tasks.Task WriteAsync(TProtocol tProtocol, CancellationToken " << CANCELLATION_TOKEN_NAME << ");" << endl << indent() << "public readonly int Isset;" << endl << indent() << "public abstract object" << nullable_suffix() <<" Data { get; }" << endl - << indent() << "protected " << tunion->get_name() << "(int isset)" << endl + << indent() << "protected " << normalize_name(tunion->get_name()) << "(int isset)" << endl << indent() << "{" << endl; indent_up(); out << indent() << "Isset = isset;" << endl; @@ -1669,13 +1675,13 @@ void t_netstd_generator::generate_netstd_union_class(ostream& out, t_struct* tun << endl; - out << indent() << "public class " << tfield->get_name() << " : " << tunion->get_name() << endl; + out << indent() << "public class " << normalize_name(tfield->get_name()) << " : " << normalize_name(tunion->get_name()) << endl; out << indent() << "{" << endl; indent_up(); out << indent() << "private readonly " << type_name(tfield->get_type()) << " _data;" << endl << indent() << "public override object" << nullable_suffix() <<" Data { get { return _data; } }" << endl - << indent() << "public " << tfield->get_name() << "(" << type_name(tfield->get_type()) << " data) : base("<< tfield->get_key() <<")" << endl + << indent() << "public " << normalize_name(tfield->get_name()) << "(" << type_name(tfield->get_type()) << " data) : base("<< tfield->get_key() <<")" << endl << indent() << "{" << endl; indent_up(); out << indent() << "this._data = data;" << endl; @@ -1683,13 +1689,13 @@ void t_netstd_generator::generate_netstd_union_class(ostream& out, t_struct* tun out << indent() << "}" << endl; if( ! suppress_deepcopy) { - out << indent() << "public new " << tfield->get_name() << " " << DEEP_COPY_METHOD_NAME << "()" << endl; + out << indent() << "public new " << normalize_name(tfield->get_name()) << " " << DEEP_COPY_METHOD_NAME << "()" << endl; out << indent() << "{" << endl; indent_up(); bool needs_typecast = false; string suffix(""); string copy_op = get_deep_copy_method_call(tfield->get_type(), true, needs_typecast, suffix); - out << indent() << "return new " << tfield->get_name() << "(_data" << copy_op << ");" << endl; + out << indent() << "return new " << normalize_name(tfield->get_name()) << "(_data" << copy_op << ");" << endl; indent_down(); out << indent() << "}" << endl << endl; } diff --git a/configure.ac b/configure.ac index 2cd902d6ca3..6331acd4aaa 100644 --- a/configure.ac +++ b/configure.ac @@ -469,7 +469,7 @@ AX_THRIFT_LIB(netstd, [.NET Core], yes) if test "$with_netstd" = "yes"; then AC_PATH_PROG([DOTNETCORE], [dotnet]) if [[ -x "$DOTNETCORE" ]] ; then - AX_PROG_DOTNETCORE_VERSION( [3.1.0], have_netstd="yes", have_netstd="no") + AX_PROG_DOTNETCORE_VERSION( [7.0.0], have_netstd="yes", have_netstd="no") fi fi AM_CONDITIONAL(WITH_DOTNET, [test "$have_netstd" = "yes"]) diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj index 0e29b3b784c..aed36cdcb11 100644 --- a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj +++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj @@ -20,14 +20,14 @@ Exe - net6.0 + net7.0 false true enable - + @@ -35,7 +35,7 @@ - + diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index d661f60f1e1..19065c6b6f6 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 Thrift.IntegrationTests Thrift.IntegrationTests 0.19.0.0 @@ -34,11 +34,11 @@ - - - - - + + + + + @@ -47,7 +47,7 @@ - + \ No newline at end of file diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj index 20f74e6461c..990b24051cd 100644 --- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj +++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj @@ -21,7 +21,7 @@ 0.19.0 Thrift version $(ThriftVersion) - net6.0 + net7.0 $(ThriftVersion).0 Thrift.PublicInterfaces.Compile.Tests Thrift.PublicInterfaces.Compile.Tests @@ -37,11 +37,11 @@ - + - + diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index 8a0e25db486..bae55ea5c95 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -19,17 +19,17 @@ --> - net6.0 + net7.0 0.19.0.0 enable - - - - - + + + + + @@ -42,6 +42,6 @@ - + \ No newline at end of file diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index 42f1932041f..760ffe4a0f7 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -19,7 +19,7 @@ --> - netstandard2.1;netstandard2.0;net6.0 + netstandard2.1;netstandard2.0;net6.0;net7.0 Thrift ApacheThrift true @@ -57,12 +57,12 @@ - - - + + + - + @@ -70,11 +70,11 @@ - + - + diff --git a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs index 8ad62aa1498..66018b085cf 100644 --- a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs +++ b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs @@ -32,13 +32,6 @@ namespace Thrift.Transport.Server { - [Obsolete("NamedPipeClientFlags is deprecated, use NamedPipeServerFlags instead.")] - [Flags] - public enum NamedPipeClientFlags { // bad name - None = 0x00, - OnlyLocalClients = 0x01 - }; - [Flags] public enum NamedPipeServerFlags { @@ -84,18 +77,6 @@ public TNamedPipeServerTransport(string pipeAddress, TConfiguration config, Name _numListenPipes = (byte)numListenPipes; } - [Obsolete("NamedPipeClientFlags is deprecated, use NamedPipeServerFlags instead.")] - public TNamedPipeServerTransport(string pipeAddress, TConfiguration config, NamedPipeClientFlags flags, int numListenPipes = 1) - : base(config) - { - if ((numListenPipes < 1) || (numListenPipes > 254)) - throw new ArgumentOutOfRangeException(nameof(numListenPipes), "Value must be in the range of [1..254]"); - - _pipeAddress = pipeAddress; - _onlyLocalClients = flags.HasFlag(NamedPipeClientFlags.OnlyLocalClients); - _numListenPipes = (byte)numListenPipes; - } - public override bool IsOpen() { return true; diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index 69e130159eb..bd7d1ee1810 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 9.0 Client Client @@ -35,9 +35,9 @@ - + - + diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs index 1227a38bbd0..183cfb43063 100644 --- a/test/netstd/Client/TestClient.cs +++ b/test/netstd/Client/TestClient.cs @@ -257,7 +257,7 @@ public TTransport CreateTransport() trans = new TTlsSocketTransport(host, port, Configuration, 0, cert, (sender, certificate, chain, errors) => true, - null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12); + null, SslProtocols.Tls12); break; case TransportChoice.Socket: diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index e6b42e247c5..85c1ad4b0c9 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 9.0 Server Server @@ -37,9 +37,9 @@ - + - + diff --git a/test/netstd/Server/TestServer.cs b/test/netstd/Server/TestServer.cs index 1eb50306ab8..fdbaa9718a4 100644 --- a/test/netstd/Server/TestServer.cs +++ b/test/netstd/Server/TestServer.cs @@ -606,7 +606,7 @@ public static async Task Execute(List args) trans = new TTlsServerSocketTransport(param.port, Configuration, cert, (sender, certificate, chain, errors) => true, - null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12); + null, SslProtocols.Tls12); break; case TransportChoice.Socket: diff --git a/tutorial/netstd/Client/Client.csproj b/tutorial/netstd/Client/Client.csproj index 0005c369c85..c21b58d12ed 100644 --- a/tutorial/netstd/Client/Client.csproj +++ b/tutorial/netstd/Client/Client.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 9.0 Client Client @@ -32,7 +32,7 @@ - + diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index 353811cd29e..1e1193b1dce 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 Interfaces Interfaces 0.19.0.0 @@ -34,7 +34,7 @@ - + diff --git a/tutorial/netstd/Server/Program.cs b/tutorial/netstd/Server/Program.cs index 29b21d07382..01e7336c50f 100644 --- a/tutorial/netstd/Server/Program.cs +++ b/tutorial/netstd/Server/Program.cs @@ -191,7 +191,7 @@ private static async Task RunSelectedConfigurationAsync(Transport transport, Buf TServerTransport serverTransport = transport switch { Transport.Tcp => new TServerSocketTransport(9090, Configuration), - Transport.NamedPipe => new TNamedPipeServerTransport(".test", Configuration, NamedPipeClientFlags.None), + Transport.NamedPipe => new TNamedPipeServerTransport(".test", Configuration, NamedPipeServerFlags.None, 64), Transport.TcpTls => new TTlsServerSocketTransport(9090, Configuration, GetCertificate(), ClientCertValidator, LocalCertificateSelectionCallback), _ => throw new ArgumentException("unsupported value $transport", nameof(transport)), }; diff --git a/tutorial/netstd/Server/Server.csproj b/tutorial/netstd/Server/Server.csproj index b333c5284de..193e3c37ef4 100644 --- a/tutorial/netstd/Server/Server.csproj +++ b/tutorial/netstd/Server/Server.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net7.0 9.0 Server Server @@ -40,6 +40,6 @@ - + From 8fcdf7d5d058a83436abdb30eee28cdc26d51bef Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 15 Feb 2023 12:19:44 -0800 Subject: [PATCH 017/250] THRIFT-5685: Revert "THRIFT-5601: Fix forward typedef in go compiler" This reverts commit b39370ec3bc96d201bbc82fbde136f98ae605ed1, and also adds a test case for THRIFT-5685. --- .../cpp/src/thrift/generate/t_go_generator.cc | 47 ++++++++----------- .../cpp/src/thrift/generate/t_go_generator.h | 3 +- ...rwardTypedef.thrift => ForwardType.thrift} | 9 ++-- lib/go/test/Makefile.am | 7 +-- lib/go/test/tests/forwardtype_test.go | 41 ++++++++++++++++ 5 files changed, 68 insertions(+), 39 deletions(-) rename lib/go/test/{ForwardTypedef.thrift => ForwardType.thrift} (85%) create mode 100644 lib/go/test/tests/forwardtype_test.go diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index 680243d1a54..90353ce9b5c 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -175,7 +175,7 @@ bool t_go_generator::is_pointer_field(t_field* tfield, bool in_container_value) return has_default; } - throw "INVALID TYPE IN is_pointer_field: " + type->get_name(); + throw "INVALID TYPE IN type_to_go_type: " + type->get_name(); } std::string t_go_generator::camelcase(const std::string& value) const { @@ -1088,7 +1088,7 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co t_type* ktype = ((t_map*)type)->get_key_type(); t_type* vtype = ((t_map*)type)->get_val_type(); const map& val = value->get_map(); - out << "map[" << type_to_go_key_type(ktype) << "]" << type_to_go_container_value_type(vtype) << "{" << endl; + out << "map[" << type_to_go_key_type(ktype) << "]" << type_to_go_type(vtype) << "{" << endl; indent_up(); map::const_iterator v_iter; @@ -1102,7 +1102,7 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co } else if (type->is_list()) { t_type* etype = ((t_list*)type)->get_elem_type(); const vector& val = value->get_list(); - out << "[]" << type_to_go_container_value_type(etype) << "{" << endl; + out << "[]" << type_to_go_type(etype) << "{" << endl; indent_up(); vector::const_iterator v_iter; @@ -1115,7 +1115,7 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co } else if (type->is_set()) { t_type* etype = ((t_set*)type)->get_elem_type(); const vector& val = value->get_list(); - out << "[]" << type_to_go_container_value_type(etype) << "{" << endl; + out << "[]" << type_to_go_type(etype) << "{" << endl; indent_up(); vector::const_iterator v_iter; @@ -1258,7 +1258,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, } t_type* fieldType = (*m_iter)->get_type(); - string goType = type_to_go_type_with_opt(fieldType, is_pointer_field(*m_iter), false); + string goType = type_to_go_type_with_opt(fieldType, is_pointer_field(*m_iter)); maptags; tags["db"]=escape_string((*m_iter)->get_name()); @@ -1317,7 +1317,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, t_const_value* def_value; get_publicized_name_and_def_value(*m_iter, &publicized_name, &def_value); t_type* fieldType = (*m_iter)->get_type(); - string goType = type_to_go_type_with_opt(fieldType, false, false); + string goType = type_to_go_type_with_opt(fieldType, false); string def_var_name = tstruct_name + "_" + publicized_name + "_DEFAULT"; if ((*m_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*m_iter)) { out << indent() << "var " << def_var_name << " " << goType; @@ -1335,7 +1335,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, } if (is_pointer_field(*m_iter)) { - string goOptType = type_to_go_type_with_opt(fieldType, true, false); + string goOptType = type_to_go_type_with_opt(fieldType, true); string maybepointer = goOptType != goType ? "*" : ""; out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() " << goType << " {" << endl; @@ -1758,7 +1758,7 @@ void t_go_generator::generate_go_struct_equals(ostream& out, field_name = (*f_iter)->get_name(); t_type* field_type = (*f_iter)->get_type(); publicize_field_name = publicize(field_name); - string goType = type_to_go_type_with_opt(field_type, is_pointer_field(*f_iter), false); + string goType = type_to_go_type_with_opt(field_type, is_pointer_field(*f_iter)); string tgt = "p." + publicize_field_name; string src = "other." + publicize_field_name; @@ -3431,7 +3431,7 @@ void t_go_generator::generate_serialize_container(ostream& out, if (pointer_field) { wrapped_prefix = "(" + prefix + ")"; } - string goType = type_to_go_container_value_type(tset->get_elem_type()); + string goType = type_to_go_type(tset->get_elem_type()); out << indent() << "if func(tgt, src " << goType << ") bool {" << endl; indent_up(); generate_go_equals(out, tset->get_elem_type(), "tgt", "src"); @@ -3892,40 +3892,31 @@ string t_go_generator::type_to_go_key_type(t_type* type) { } if (resolved_type->is_map() || resolved_type->is_list() || resolved_type->is_set()) { - throw "Cannot produce a valid type for a Go map key: " + type_to_go_container_value_type(type) + " - aborting."; + throw "Cannot produce a valid type for a Go map key: " + type_to_go_type(type) + " - aborting."; } if (resolved_type->is_binary()) return "string"; - return type_to_go_container_value_type(type); -} - -/** - * Converts the parse type to a go type to be used in a container value - */ -string t_go_generator::type_to_go_container_value_type(t_type* type) { - return type_to_go_type_with_opt(type, false, true); + return type_to_go_type(type); } /** * Converts the parse type to a go type */ string t_go_generator::type_to_go_type(t_type* type) { - return type_to_go_type_with_opt(type, false, false); + return type_to_go_type_with_opt(type, false); } /** * Converts the parse type to a go type, taking into account whether the field - * associated with the type is T_OPTIONAL and whether it's used in a container - * type. + * associated with the type is T_OPTIONAL. */ string t_go_generator::type_to_go_type_with_opt(t_type* type, - bool optional_field, - bool is_container_value) { + bool optional_field) { string maybe_pointer(optional_field ? "*" : ""); - if (is_container_value && type->is_typedef() && ((t_typedef*)type)->is_forward_typedef()) { + if (type->is_typedef() && ((t_typedef*)type)->is_forward_typedef()) { type = ((t_typedef*)type)->get_true_type(); } @@ -3974,21 +3965,21 @@ string t_go_generator::type_to_go_type_with_opt(t_type* type, } else if (type->is_map()) { t_map* t = (t_map*)type; string keyType = type_to_go_key_type(t->get_key_type()); - string valueType = type_to_go_container_value_type(t->get_val_type()); + string valueType = type_to_go_type(t->get_val_type()); return maybe_pointer + string("map[") + keyType + "]" + valueType; } else if (type->is_set()) { t_set* t = (t_set*)type; - string elemType = type_to_go_container_value_type(t->get_elem_type()); + string elemType = type_to_go_type(t->get_elem_type()); return maybe_pointer + string("[]") + elemType; } else if (type->is_list()) { t_list* t = (t_list*)type; - string elemType = type_to_go_container_value_type(t->get_elem_type()); + string elemType = type_to_go_type(t->get_elem_type()); return maybe_pointer + string("[]") + elemType; } else if (type->is_typedef()) { return maybe_pointer + publicize(type_name(type)); } - throw "INVALID TYPE IN type_to_go_type_with_opt: " + type->get_name(); + throw "INVALID TYPE IN type_to_go_type: " + type->get_name(); } /** See the comment inside generate_go_struct_definition for what this is. */ diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.h b/compiler/cpp/src/thrift/generate/t_go_generator.h index ad6cee636d2..a67485c5506 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.h +++ b/compiler/cpp/src/thrift/generate/t_go_generator.h @@ -264,9 +264,8 @@ class t_go_generator : public t_generator { std::string argument_list(t_struct* tstruct); std::string type_to_enum(t_type* ttype); std::string type_to_go_type(t_type* ttype); - std::string type_to_go_type_with_opt(t_type* ttype, bool optional_field, bool is_container_value); + std::string type_to_go_type_with_opt(t_type* ttype, bool optional_field); std::string type_to_go_key_type(t_type* ttype); - std::string type_to_go_container_value_type(t_type* ttype); std::string type_to_spec_args(t_type* ttype); void indent_up() { t_generator::indent_up(); } diff --git a/lib/go/test/ForwardTypedef.thrift b/lib/go/test/ForwardType.thrift similarity index 85% rename from lib/go/test/ForwardTypedef.thrift rename to lib/go/test/ForwardType.thrift index 4266b7a285b..0433c97cfdc 100644 --- a/lib/go/test/ForwardTypedef.thrift +++ b/lib/go/test/ForwardType.thrift @@ -17,17 +17,14 @@ * under the License. */ -// https://issues.apache.org/jira/browse/THRIFT-5601 +// https://issues.apache.org/jira/browse/THRIFT-5685 -namespace go forwardtypedef +namespace go forwardtypetest struct Struct { - 1: optional Def foo - 2: optional Exc bar + 1: optional Exc foo } -typedef i32 Def - exception Exc { 1: optional i32 code } diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am index c255a8e485b..cb8928bc8c3 100644 --- a/lib/go/test/Makefile.am +++ b/lib/go/test/Makefile.am @@ -62,7 +62,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \ ProcessorMiddlewareTest.thrift \ ClientMiddlewareExceptionTest.thrift \ ValidateTest.thrift \ - ForwardTypedef.thrift + ForwardType.thrift mkdir -p gopath/src grep -v list.*map.*list.*map $(THRIFTTEST) | grep -v 'set' > ThriftTest.thrift $(THRIFT) $(THRIFTARGS) -r IncludesTest.thrift @@ -97,7 +97,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \ $(THRIFT) $(THRIFTARGS_SKIP_REMOTE) ProcessorMiddlewareTest.thrift $(THRIFT) $(THRIFTARGS) ClientMiddlewareExceptionTest.thrift $(THRIFT) $(THRIFTARGS) ValidateTest.thrift - $(THRIFT) $(THRIFTARGS) ForwardTypedef.thrift + $(THRIFT) $(THRIFTARGS) ForwardType.thrift ln -nfs ../../tests gopath/src/tests cp -r ./dontexportrwtest gopath/src touch gopath @@ -124,7 +124,7 @@ check: gopath ./gopath/src/processormiddlewaretest \ ./gopath/src/clientmiddlewareexceptiontest \ ./gopath/src/validatetest \ - ./gopath/src/forwardtypedef + ./gopath/src/forwardtypetest $(GO) test github.com/apache/thrift/lib/go/thrift $(GO) test ./gopath/src/tests ./gopath/src/dontexportrwtest @@ -155,6 +155,7 @@ EXTRA_DIST = \ DuplicateImportsTest.thrift \ ErrorTest.thrift \ EqualsTest.thrift \ + ForwardType.thrift \ GoTagTest.thrift \ IgnoreInitialismsTest.thrift \ IncludesTest.thrift \ diff --git a/lib/go/test/tests/forwardtype_test.go b/lib/go/test/tests/forwardtype_test.go new file mode 100644 index 00000000000..99b7890e60b --- /dev/null +++ b/lib/go/test/tests/forwardtype_test.go @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package tests + +import ( + "testing" + + "github.com/apache/thrift/lib/go/test/gopath/src/forwardtypetest" + "github.com/apache/thrift/lib/go/thrift" +) + +func TestForwardType(t *testing.T) { + // See https://issues.apache.org/jira/browse/THRIFT-5685 + + const code = int32(1) + foo := &forwardtypetest.Struct{ + Foo: &forwardtypetest.Exc{ + Code: thrift.Pointer(code), + }, + } + if got, want := foo.GetFoo().GetCode(), code; got != want { + t.Errorf("code got %v want %v", got, want) + } +} From 05604e261455f1d85a5d04c4364a21d2a7e417b2 Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Sat, 18 Feb 2023 14:50:15 +0100 Subject: [PATCH 018/250] Fix Security Tests for OpenSSLv3 --- lib/cpp/test/SecurityFromBufferTest.cpp | 7 ++++--- lib/cpp/test/SecurityTest.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/cpp/test/SecurityFromBufferTest.cpp b/lib/cpp/test/SecurityFromBufferTest.cpp index d2751919f99..194e67fdd56 100644 --- a/lib/cpp/test/SecurityFromBufferTest.cpp +++ b/lib/cpp/test/SecurityFromBufferTest.cpp @@ -198,15 +198,16 @@ BOOST_AUTO_TEST_CASE(ssl_security_matrix) { try { // matrix of connection success between client and server with different SSLProtocol selections static_assert(apache::thrift::transport::LATEST == 5, "Mismatch in assumed number of ssl protocols"); + bool ossl1 = OPENSSL_VERSION_MAJOR == 1; bool matrix[apache::thrift::transport::LATEST + 1][apache::thrift::transport::LATEST + 1] = { // server = SSLTLS SSLv2 SSLv3 TLSv1_0 TLSv1_1 TLSv1_2 // client - /* SSLTLS */ { true, false, false, true, true, true }, + /* SSLTLS */ { true, false, false, ossl1, ossl1, true }, /* SSLv2 */ { false, false, false, false, false, false }, /* SSLv3 */ { false, false, true, false, false, false }, - /* TLSv1_0 */ { true, false, false, true, false, false }, - /* TLSv1_1 */ { true, false, false, false, true, false }, + /* TLSv1_0 */ { ossl1, false, false, ossl1, false, false }, + /* TLSv1_1 */ { ossl1, false, false, false, ossl1, false }, /* TLSv1_2 */ { true, false, false, false, false, true } }; diff --git a/lib/cpp/test/SecurityTest.cpp b/lib/cpp/test/SecurityTest.cpp index cba876842a3..df0cdaf7686 100644 --- a/lib/cpp/test/SecurityTest.cpp +++ b/lib/cpp/test/SecurityTest.cpp @@ -220,15 +220,16 @@ BOOST_AUTO_TEST_CASE(ssl_security_matrix) { // matrix of connection success between client and server with different SSLProtocol selections static_assert(apache::thrift::transport::LATEST == 5, "Mismatch in assumed number of ssl protocols"); + bool ossl1 = OPENSSL_VERSION_MAJOR == 1; bool matrix[apache::thrift::transport::LATEST + 1][apache::thrift::transport::LATEST + 1] = { // server = SSLTLS SSLv2 SSLv3 TLSv1_0 TLSv1_1 TLSv1_2 // client - /* SSLTLS */ { true, false, false, true, true, true }, + /* SSLTLS */ { true, false, false, ossl1, ossl1, true }, /* SSLv2 */ { false, false, false, false, false, false }, /* SSLv3 */ { false, false, true, false, false, false }, - /* TLSv1_0 */ { true, false, false, true, false, false }, - /* TLSv1_1 */ { true, false, false, false, true, false }, + /* TLSv1_0 */ { ossl1, false, false, ossl1, false, false }, + /* TLSv1_1 */ { ossl1, false, false, false, ossl1, false }, /* TLSv1_2 */ { true, false, false, false, false, true } }; From c922a48502462ddf0194d96c5827b33b5a1b3fe6 Mon Sep 17 00:00:00 2001 From: Zlika Date: Tue, 21 Feb 2023 10:42:06 +0100 Subject: [PATCH 019/250] =?UTF-8?q?THRIFT-5679=20libthrift-0.17.0=20has=20?= =?UTF-8?q?wrong=20version=20numbers=20in=20MANIFEST.MF=20Client:=20Java?= =?UTF-8?q?=20Patch:=20Thomas=20Lorblanch=C3=A8s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This closes #2761 --- lib/java/gradle/sourceConfiguration.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/gradle/sourceConfiguration.gradle b/lib/java/gradle/sourceConfiguration.gradle index 1d4c44cc2bf..f39f5e51d94 100644 --- a/lib/java/gradle/sourceConfiguration.gradle +++ b/lib/java/gradle/sourceConfiguration.gradle @@ -83,7 +83,7 @@ jar { "Bundle-Description": "Apache Thrift library", "Bundle-License": "${project.license}", "Bundle-ActivationPolicy": "lazy", - "Export-Package": "${project.group}.async;uses:=\"${project.group}.protocol,${project.group}.transport,org.slf4j,${project.group}\";version=\"${archiveVersion}\",${project.group}.protocol;uses:=\"${project.group}.transport,${project.group},${project.group}.scheme\";version=\"${archiveVersion}\",${project.group}.server;uses:=\"${project.group}.transport,${project.group}.protocol,${project.group},org.slf4j,javax.servlet,javax.servlet.http\";version=\"${archiveVersion}\",${project.group}.transport;uses:=\"${project.group}.protocol,${project.group},org.apache.http.client,org.apache.http.params,org.apache.http.entity,org.apache.http.client.methods,org.apache.http,org.slf4j,javax.net.ssl,javax.net,javax.security.sasl,javax.security.auth.callback\";version=\"${archiveVersion}\",${project.group};uses:=\"${project.group}.protocol,${project.group}.async,${project.group}.server,${project.group}.transport,org.slf4j,org.apache.log4j,${project.group}.scheme\";version=\"${archiveVersion}\",${project.group}.meta_data;uses:=\"${project.group}\";version=\"${archiveVersion}\",${project.group}.scheme;uses:=\"${project.group}.protocol,${project.group}\";version=\"${archiveVersion}\",${project.group}.annotation;version=\"${archiveVersion}\"", + "Export-Package": "${project.group}.async;uses:=\"${project.group}.protocol,${project.group}.transport,org.slf4j,${project.group}\";version=\"${project.version}\",${project.group}.protocol;uses:=\"${project.group}.transport,${project.group},${project.group}.scheme\";version=\"${project.version}\",${project.group}.server;uses:=\"${project.group}.transport,${project.group}.protocol,${project.group},org.slf4j,javax.servlet,javax.servlet.http\";version=\"${project.version}\",${project.group}.transport;uses:=\"${project.group}.protocol,${project.group},org.apache.http.client,org.apache.http.params,org.apache.http.entity,org.apache.http.client.methods,org.apache.http,org.slf4j,javax.net.ssl,javax.net,javax.security.sasl,javax.security.auth.callback\";version=\"${project.version}\",${project.group};uses:=\"${project.group}.protocol,${project.group}.async,${project.group}.server,${project.group}.transport,org.slf4j,org.apache.log4j,${project.group}.scheme\";version=\"${project.version}\",${project.group}.meta_data;uses:=\"${project.group}\";version=\"${project.version}\",${project.group}.scheme;uses:=\"${project.group}.protocol,${project.group}\";version=\"${project.version}\",${project.group}.annotation;version=\"${project.version}\"", "Import-Package": "javax.net,javax.net.ssl,javax.security.auth.callback,javax.security.sasl,javax.servlet;resolution:=optional,javax.servlet.http;resolution:=optional,org.slf4j;resolution:=optional;version=\"[1.4,2)\",org.apache.http.client;resolution:=optional,org.apache.http.params;resolution:=optional,org.apache.http.entity;resolution:=optional,org.apache.http.client.methods;resolution:=optional,org.apache.http;resolution:=optional" ]) } From d96b17740c52734714afc77a83147d06f3ea70da Mon Sep 17 00:00:00 2001 From: Zlika Date: Tue, 21 Feb 2023 14:44:21 +0100 Subject: [PATCH 020/250] Fix VisualStudio project files and upgrade to VS2015 --- lib/cpp/libthrift.vcxproj | 85 +++++++++++++++-------------- lib/cpp/libthrift.vcxproj.filters | 57 +++++-------------- lib/cpp/libthriftnb.vcxproj | 18 ++++-- lib/cpp/libthriftnb.vcxproj.filters | 8 +-- 4 files changed, 73 insertions(+), 95 deletions(-) mode change 100755 => 100644 lib/cpp/libthriftnb.vcxproj diff --git a/lib/cpp/libthrift.vcxproj b/lib/cpp/libthrift.vcxproj index 2353cd39a51..0b5e16de7c4 100644 --- a/lib/cpp/libthrift.vcxproj +++ b/lib/cpp/libthrift.vcxproj @@ -1,5 +1,5 @@ - - + + Debug-mt @@ -35,41 +35,41 @@ - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - + + - + - - - - - + + + + @@ -99,15 +99,12 @@ - - - @@ -134,45 +131,53 @@ StaticLibrary true MultiByte + v140 StaticLibrary true MultiByte + v140 StaticLibrary true MultiByte + v140 StaticLibrary true MultiByte + v140 StaticLibrary false true MultiByte + v140 StaticLibrary false true MultiByte + v140 StaticLibrary false true MultiByte + v140 StaticLibrary false true MultiByte + v140 @@ -239,7 +244,7 @@ NotUsing Level3 Disabled - HAVE_CONFIG_H=1;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + HAVE_CONFIG_H=1;WIN32;thrift_EXPORTS;_DEBUG;_LIB;%(PreprocessorDefinitions) $(IntDir)libthrift.pdb MultiThreadedDebugDLL @@ -253,7 +258,7 @@ NotUsing Level3 Disabled - HAVE_CONFIG_H=1;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + HAVE_CONFIG_H=1;WIN32;thrift_EXPORTS;_DEBUG;_LIB;%(PreprocessorDefinitions) $(IntDir)libthrift.pdb MultiThreadedDebugDll @@ -295,7 +300,7 @@ MaxSpeed true true - HAVE_CONFIG_H=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + HAVE_CONFIG_H=1;WIN32;thrift_EXPORTS;NDEBUG;_LIB;%(PreprocessorDefinitions) $(IntDir)libthrift.pdb MultiThreadedDll @@ -313,7 +318,7 @@ MaxSpeed true true - HAVE_CONFIG_H=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + HAVE_CONFIG_H=1;WIN32;thrift_EXPORTS;NDEBUG;_LIB;%(PreprocessorDefinitions) $(IntDir)libthrift.pdb MultiThreadedDll @@ -361,4 +366,4 @@ - + \ No newline at end of file diff --git a/lib/cpp/libthrift.vcxproj.filters b/lib/cpp/libthrift.vcxproj.filters index 0e9a9fde1c2..98426fac85b 100644 --- a/lib/cpp/libthrift.vcxproj.filters +++ b/lib/cpp/libthrift.vcxproj.filters @@ -6,9 +6,6 @@ - - windows - transport @@ -21,9 +18,6 @@ concurrency - - concurrency - protocol @@ -48,15 +42,6 @@ transport - - transport - - - transport - - - transport - transport @@ -90,12 +75,6 @@ windows - - concurrency - - - concurrency - windows @@ -105,6 +84,17 @@ transport + + + + + + + + + + + @@ -119,12 +109,6 @@ - - windows - - - windows - concurrency @@ -182,15 +166,6 @@ transport - - transport - - - transport - - - transport - transport @@ -218,9 +193,6 @@ windows - - windows - windows @@ -230,6 +202,8 @@ transport + + @@ -261,8 +235,5 @@ protocol - - windows\tr1 - - + \ No newline at end of file diff --git a/lib/cpp/libthriftnb.vcxproj b/lib/cpp/libthriftnb.vcxproj old mode 100755 new mode 100644 index dc6764e0367..9d80ba7c479 --- a/lib/cpp/libthriftnb.vcxproj +++ b/lib/cpp/libthriftnb.vcxproj @@ -1,5 +1,5 @@  - + Debug-mt @@ -64,45 +64,53 @@ StaticLibrary true MultiByte + v140 StaticLibrary true MultiByte + v140 StaticLibrary true MultiByte + v140 StaticLibrary true MultiByte + v140 StaticLibrary false true MultiByte + v140 StaticLibrary false true MultiByte + v140 StaticLibrary false true MultiByte + v140 StaticLibrary false true MultiByte + v140 @@ -170,7 +178,7 @@ Level3 Disabled - HAVE_CONFIG_H=1;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + HAVE_CONFIG_H=1;WIN32;thrift_EXPORTS;_DEBUG;_LIB;%(PreprocessorDefinitions) $(IntDir)libthriftnb.pdb MultiThreadedDebugDll @@ -185,7 +193,7 @@ Level3 Disabled - HAVE_CONFIG_H=1;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + HAVE_CONFIG_H=1;WIN32;thrift_EXPORTS;_DEBUG;_LIB;%(PreprocessorDefinitions) $(IntDir)libthriftnb.pdb MultiThreadedDebugDll @@ -230,7 +238,7 @@ MaxSpeed true true - HAVE_CONFIG_H=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + HAVE_CONFIG_H=1;WIN32;thrift_EXPORTS;NDEBUG;_LIB;%(PreprocessorDefinitions) $(IntDir)libthriftnb.pdb MultiThreadedDll @@ -249,7 +257,7 @@ MaxSpeed true true - HAVE_CONFIG_H=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + HAVE_CONFIG_H=1;WIN32;thrift_EXPORTS;NDEBUG;_LIB;%(PreprocessorDefinitions) $(IntDir)libthriftnb.pdb MultiThreadedDll diff --git a/lib/cpp/libthriftnb.vcxproj.filters b/lib/cpp/libthriftnb.vcxproj.filters index 85703dd1297..314d454b2fc 100644 --- a/lib/cpp/libthriftnb.vcxproj.filters +++ b/lib/cpp/libthriftnb.vcxproj.filters @@ -27,9 +27,6 @@ async - - windows - transport @@ -53,9 +50,6 @@ windows - - windows - windows @@ -72,4 +66,4 @@ transport - + \ No newline at end of file From 4fcd0725b837dc65842638b9d2f5167bedd15399 Mon Sep 17 00:00:00 2001 From: dejank-isystem <119041215+dejank-isystem@users.noreply.github.com> Date: Tue, 14 Feb 2023 13:34:26 +0100 Subject: [PATCH 021/250] lib/cpp: Fix MSVC warning C4706 (BinaryProtocol) MSVC warning C4706: assignment within conditional expression --- lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc b/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc index 755f24386e3..c448e77c3bb 100644 --- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc +++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc @@ -448,9 +448,9 @@ uint32_t TBinaryProtocolT::readStringBody(StrType& str, } // Try to borrow first - const uint8_t* borrow_buf; uint32_t got = size; - if ((borrow_buf = this->trans_->borrow(nullptr, &got))) { + const uint8_t* borrow_buf = this->trans_->borrow(nullptr, &got); + if (borrow_buf) { str.assign((const char*)borrow_buf, size); this->trans_->consume(size); return size; From 0972190135060341d65cce521b17d5117bdb5b01 Mon Sep 17 00:00:00 2001 From: Zlika Date: Tue, 21 Feb 2023 10:42:06 +0100 Subject: [PATCH 022/250] =?UTF-8?q?THRIFT-5679=20libthrift-0.17.0=20has=20?= =?UTF-8?q?wrong=20version=20numbers=20in=20MANIFEST.MF=20Client:=20Java?= =?UTF-8?q?=20Patch:=20Thomas=20Lorblanch=C3=A8s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This closes #2761 --- lib/java/gradle/sourceConfiguration.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/gradle/sourceConfiguration.gradle b/lib/java/gradle/sourceConfiguration.gradle index 1d4c44cc2bf..f39f5e51d94 100644 --- a/lib/java/gradle/sourceConfiguration.gradle +++ b/lib/java/gradle/sourceConfiguration.gradle @@ -83,7 +83,7 @@ jar { "Bundle-Description": "Apache Thrift library", "Bundle-License": "${project.license}", "Bundle-ActivationPolicy": "lazy", - "Export-Package": "${project.group}.async;uses:=\"${project.group}.protocol,${project.group}.transport,org.slf4j,${project.group}\";version=\"${archiveVersion}\",${project.group}.protocol;uses:=\"${project.group}.transport,${project.group},${project.group}.scheme\";version=\"${archiveVersion}\",${project.group}.server;uses:=\"${project.group}.transport,${project.group}.protocol,${project.group},org.slf4j,javax.servlet,javax.servlet.http\";version=\"${archiveVersion}\",${project.group}.transport;uses:=\"${project.group}.protocol,${project.group},org.apache.http.client,org.apache.http.params,org.apache.http.entity,org.apache.http.client.methods,org.apache.http,org.slf4j,javax.net.ssl,javax.net,javax.security.sasl,javax.security.auth.callback\";version=\"${archiveVersion}\",${project.group};uses:=\"${project.group}.protocol,${project.group}.async,${project.group}.server,${project.group}.transport,org.slf4j,org.apache.log4j,${project.group}.scheme\";version=\"${archiveVersion}\",${project.group}.meta_data;uses:=\"${project.group}\";version=\"${archiveVersion}\",${project.group}.scheme;uses:=\"${project.group}.protocol,${project.group}\";version=\"${archiveVersion}\",${project.group}.annotation;version=\"${archiveVersion}\"", + "Export-Package": "${project.group}.async;uses:=\"${project.group}.protocol,${project.group}.transport,org.slf4j,${project.group}\";version=\"${project.version}\",${project.group}.protocol;uses:=\"${project.group}.transport,${project.group},${project.group}.scheme\";version=\"${project.version}\",${project.group}.server;uses:=\"${project.group}.transport,${project.group}.protocol,${project.group},org.slf4j,javax.servlet,javax.servlet.http\";version=\"${project.version}\",${project.group}.transport;uses:=\"${project.group}.protocol,${project.group},org.apache.http.client,org.apache.http.params,org.apache.http.entity,org.apache.http.client.methods,org.apache.http,org.slf4j,javax.net.ssl,javax.net,javax.security.sasl,javax.security.auth.callback\";version=\"${project.version}\",${project.group};uses:=\"${project.group}.protocol,${project.group}.async,${project.group}.server,${project.group}.transport,org.slf4j,org.apache.log4j,${project.group}.scheme\";version=\"${project.version}\",${project.group}.meta_data;uses:=\"${project.group}\";version=\"${project.version}\",${project.group}.scheme;uses:=\"${project.group}.protocol,${project.group}\";version=\"${project.version}\",${project.group}.annotation;version=\"${project.version}\"", "Import-Package": "javax.net,javax.net.ssl,javax.security.auth.callback,javax.security.sasl,javax.servlet;resolution:=optional,javax.servlet.http;resolution:=optional,org.slf4j;resolution:=optional;version=\"[1.4,2)\",org.apache.http.client;resolution:=optional,org.apache.http.params;resolution:=optional,org.apache.http.entity;resolution:=optional,org.apache.http.client.methods;resolution:=optional,org.apache.http;resolution:=optional" ]) } From 1851da53a31b71e7006a48161c1e3d6d9ee5ded5 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Thu, 23 Feb 2023 21:15:15 +0100 Subject: [PATCH 023/250] Release 0.18.1 --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 95faa04037b..0173f6f074e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ # Apache Thrift Changelog + ## 0.18.1 ### Known Open Issues (Blocker or Critical) @@ -14,6 +15,9 @@ ### Go - [THRIFT-5685](https://issues.apache.org/jira/browse/THRIFT-5685) - Compiler generates wrong go code for forward defined types in optional fields +- [THRIFT-5679](https://issues.apache.org/jira/browse/THRIFT-5679) - libthrift-0.17.0 has wrong version numbers in MANIFEST.MF + + ## 0.18.0 From f5627536bacab4b298aa1b207a98b87357763a88 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 24 Feb 2023 21:25:28 +0100 Subject: [PATCH 024/250] THRIFT-5686 Add comparer and capacity arguments to container classes Client: Delphi Patch: Jens Geyer --- lib/delphi/src/Thrift.Collections.pas | 75 ++++++++++++++++----------- 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/lib/delphi/src/Thrift.Collections.pas b/lib/delphi/src/Thrift.Collections.pas index 36a8d969670..2cb2395adcc 100644 --- a/lib/delphi/src/Thrift.Collections.pas +++ b/lib/delphi/src/Thrift.Collections.pas @@ -66,7 +66,7 @@ interface TThriftDictionaryImpl = class( TInterfacedObject, IThriftDictionary, IThriftContainer, ISupportsToString) strict private - FDictionaly : TDictionary; + FDictionary : TDictionary; strict protected function GetEnumerator: TEnumerator>; @@ -93,7 +93,8 @@ TThriftDictionaryImpl = class( TInterfacedObject, IThriftDictiona property Keys: TDictionary.TKeyCollection read GetKeys; property Values: TDictionary.TValueCollection read GetValues; public - constructor Create(ACapacity: Integer = 0); + constructor Create( const aCapacity: Integer = 0); overload; + constructor Create( const aCapacity: Integer; const aComparer : IEqualityComparer); overload; destructor Destroy; override; function ToString : string; override; end; @@ -185,7 +186,7 @@ TThriftListImpl = class( TInterfacedObject, IThriftList, IThriftContaine property Count: Integer read GetCount write SetCount; property Items[Index: Integer]: T read GetItem write SetItem; default; public - constructor Create; + constructor Create( const aCapacity: Integer = 0); destructor Destroy; override; function ToString : string; override; end; @@ -228,7 +229,8 @@ TThriftHashSetImpl = class( TInterfacedObject, IHashSet, IThri procedure CopyTo(var A: TArray; arrayIndex: Integer); function Remove( const item: TValue ): Boolean; public - constructor Create; + constructor Create( const aCapacity: Integer = 0); overload; + constructor Create( const aCapacity: Integer; const aComparer : IEqualityComparer); overload; function ToString : string; override; end; @@ -271,10 +273,16 @@ procedure TThriftHashSetImpl.CopyTo(var A: TArray; arrayIndex: I end; end; -constructor TThriftHashSetImpl.Create; +constructor TThriftHashSetImpl.Create( const aCapacity: Integer); begin - inherited; - FDictionary := TThriftDictionaryImpl.Create; + inherited Create; + FDictionary := TThriftDictionaryImpl.Create( aCapacity); +end; + +constructor TThriftHashSetImpl.Create( const aCapacity: Integer; const aComparer : IEqualityComparer); +begin + inherited Create; + FDictionary := TThriftDictionaryImpl.Create( aCapacity, aComparer); end; function TThriftHashSetImpl.GetCount: Integer; @@ -329,85 +337,91 @@ function TThriftHashSetImpl.ToString : string; procedure TThriftDictionaryImpl.Add(const Key: TKey; const Value: TValue); begin - FDictionaly.Add( Key, Value); + FDictionary.Add( Key, Value); end; procedure TThriftDictionaryImpl.AddOrSetValue(const Key: TKey; const Value: TValue); begin - FDictionaly.AddOrSetValue( Key, Value); + FDictionary.AddOrSetValue( Key, Value); end; procedure TThriftDictionaryImpl.Clear; begin - FDictionaly.Clear; + FDictionary.Clear; end; function TThriftDictionaryImpl.ContainsKey( const Key: TKey): Boolean; begin - Result := FDictionaly.ContainsKey( Key ); + Result := FDictionary.ContainsKey( Key ); end; function TThriftDictionaryImpl.ContainsValue( const Value: TValue): Boolean; begin - Result := FDictionaly.ContainsValue( Value ); + Result := FDictionary.ContainsValue( Value ); end; -constructor TThriftDictionaryImpl.Create(ACapacity: Integer); +constructor TThriftDictionaryImpl.Create(const aCapacity: Integer); begin inherited Create; - FDictionaly := TDictionary.Create( ACapacity ); + FDictionary := TDictionary.Create( aCapacity); +end; + +constructor TThriftDictionaryImpl.Create(const aCapacity: Integer; const aComparer : IEqualityComparer); +begin + inherited Create; + FDictionary := TDictionary.Create( aCapacity, aComparer); end; destructor TThriftDictionaryImpl.Destroy; begin - FDictionaly.Free; + FDictionary.Free; inherited; end; {$IF CompilerVersion >= 21.0} function TThriftDictionaryImpl.ExtractPair( const Key: TKey): TPair; begin - Result := FDictionaly.ExtractPair( Key); + Result := FDictionary.ExtractPair( Key); end; {$IFEND} function TThriftDictionaryImpl.GetCount: Integer; begin - Result := FDictionaly.Count; + Result := FDictionary.Count; end; function TThriftDictionaryImpl.GetEnumerator: TEnumerator>; begin - Result := FDictionaly.GetEnumerator; + Result := FDictionary.GetEnumerator; end; function TThriftDictionaryImpl.GetItem(const Key: TKey): TValue; begin - Result := FDictionaly.Items[Key]; + Result := FDictionary.Items[Key]; end; function TThriftDictionaryImpl.GetKeys: TDictionary.TKeyCollection; begin - Result := FDictionaly.Keys; + Result := FDictionary.Keys; end; function TThriftDictionaryImpl.GetValues: TDictionary.TValueCollection; begin - Result := FDictionaly.Values; + Result := FDictionary.Values; end; procedure TThriftDictionaryImpl.Remove(const Key: TKey); begin - FDictionaly.Remove( Key ); + FDictionary.Remove( Key ); end; procedure TThriftDictionaryImpl.SetItem(const Key: TKey; const Value: TValue); begin - FDictionaly.AddOrSetValue( Key, Value); + FDictionary.AddOrSetValue( Key, Value); end; function TThriftDictionaryImpl.ToArray: TArray>; @@ -426,7 +440,7 @@ function TThriftDictionaryImpl.ToArray: TArray Inc( i ); end; {$ELSE} - Result := FDictionaly.ToArray; + Result := FDictionary.ToArray; {$IFEND} end; @@ -438,7 +452,7 @@ function TThriftDictionaryImpl.ToString : string; sb := TThriftStringBuilder.Create('{'); try first := TRUE; - for pair in FDictionaly do begin + for pair in FDictionary do begin if first then first := FALSE else sb.Append(', '); @@ -458,13 +472,13 @@ function TThriftDictionaryImpl.ToString : string; procedure TThriftDictionaryImpl.TrimExcess; begin - FDictionaly.TrimExcess; + FDictionary.TrimExcess; end; function TThriftDictionaryImpl.TryGetValue(const Key: TKey; out Value: TValue): Boolean; begin - Result := FDictionaly.TryGetValue( Key, Value); + Result := FDictionary.TryGetValue( Key, Value); end; { TThriftListImpl } @@ -511,10 +525,13 @@ function TThriftListImpl.Contains(const Value: T): Boolean; Result := FList.Contains( Value ); end; -constructor TThriftListImpl.Create; +constructor TThriftListImpl.Create( const aCapacity: Integer); begin - inherited; + inherited Create; FList := TList.Create; + + if aCapacity > 0 + then FList.Capacity := aCapacity; end; procedure TThriftListImpl.Delete(Index: Integer); From bb80ef4e7db152eb744b0bf47cb196059021266f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 25 Feb 2023 08:28:36 +0000 Subject: [PATCH 025/250] Bump golang.org/x/sys in /test/go Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.0.0-20210510120138-977fb7262007 to 0.1.0. - [Release notes](https://github.com/golang/sys/releases) - [Commits](https://github.com/golang/sys/commits/v0.1.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: indirect ... Signed-off-by: dependabot[bot] --- test/go/go.mod | 7 ------- test/go/go.sum | 4 ---- 2 files changed, 11 deletions(-) diff --git a/test/go/go.mod b/test/go/go.mod index 0143eba0da2..245dd2ea1b3 100644 --- a/test/go/go.mod +++ b/test/go/go.mod @@ -7,11 +7,4 @@ require ( github.com/golang/mock v1.6.0 ) -require ( - golang.org/x/mod v0.4.2 // indirect - golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect - golang.org/x/tools v0.1.1 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect -) - replace github.com/apache/thrift => ../../ diff --git a/test/go/go.sum b/test/go/go.sum index 6904b3efe74..d0671277e22 100644 --- a/test/go/go.sum +++ b/test/go/go.sum @@ -3,7 +3,6 @@ github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+Licev github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -14,16 +13,13 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From dca42ab4b521bd4b0ffda67ae47a75b47045af24 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 15 Feb 2023 12:19:44 -0800 Subject: [PATCH 026/250] THRIFT-5685: Revert "THRIFT-5601: Fix forward typedef in go compiler" This reverts commit b39370ec3bc96d201bbc82fbde136f98ae605ed1, and also adds a test case for THRIFT-5685. --- .../cpp/src/thrift/generate/t_go_generator.cc | 47 ++++++++----------- .../cpp/src/thrift/generate/t_go_generator.h | 3 +- ...rwardTypedef.thrift => ForwardType.thrift} | 9 ++-- lib/go/test/Makefile.am | 7 +-- lib/go/test/tests/forwardtype_test.go | 41 ++++++++++++++++ 5 files changed, 68 insertions(+), 39 deletions(-) rename lib/go/test/{ForwardTypedef.thrift => ForwardType.thrift} (85%) create mode 100644 lib/go/test/tests/forwardtype_test.go diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index 680243d1a54..90353ce9b5c 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -175,7 +175,7 @@ bool t_go_generator::is_pointer_field(t_field* tfield, bool in_container_value) return has_default; } - throw "INVALID TYPE IN is_pointer_field: " + type->get_name(); + throw "INVALID TYPE IN type_to_go_type: " + type->get_name(); } std::string t_go_generator::camelcase(const std::string& value) const { @@ -1088,7 +1088,7 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co t_type* ktype = ((t_map*)type)->get_key_type(); t_type* vtype = ((t_map*)type)->get_val_type(); const map& val = value->get_map(); - out << "map[" << type_to_go_key_type(ktype) << "]" << type_to_go_container_value_type(vtype) << "{" << endl; + out << "map[" << type_to_go_key_type(ktype) << "]" << type_to_go_type(vtype) << "{" << endl; indent_up(); map::const_iterator v_iter; @@ -1102,7 +1102,7 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co } else if (type->is_list()) { t_type* etype = ((t_list*)type)->get_elem_type(); const vector& val = value->get_list(); - out << "[]" << type_to_go_container_value_type(etype) << "{" << endl; + out << "[]" << type_to_go_type(etype) << "{" << endl; indent_up(); vector::const_iterator v_iter; @@ -1115,7 +1115,7 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co } else if (type->is_set()) { t_type* etype = ((t_set*)type)->get_elem_type(); const vector& val = value->get_list(); - out << "[]" << type_to_go_container_value_type(etype) << "{" << endl; + out << "[]" << type_to_go_type(etype) << "{" << endl; indent_up(); vector::const_iterator v_iter; @@ -1258,7 +1258,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, } t_type* fieldType = (*m_iter)->get_type(); - string goType = type_to_go_type_with_opt(fieldType, is_pointer_field(*m_iter), false); + string goType = type_to_go_type_with_opt(fieldType, is_pointer_field(*m_iter)); maptags; tags["db"]=escape_string((*m_iter)->get_name()); @@ -1317,7 +1317,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, t_const_value* def_value; get_publicized_name_and_def_value(*m_iter, &publicized_name, &def_value); t_type* fieldType = (*m_iter)->get_type(); - string goType = type_to_go_type_with_opt(fieldType, false, false); + string goType = type_to_go_type_with_opt(fieldType, false); string def_var_name = tstruct_name + "_" + publicized_name + "_DEFAULT"; if ((*m_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*m_iter)) { out << indent() << "var " << def_var_name << " " << goType; @@ -1335,7 +1335,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, } if (is_pointer_field(*m_iter)) { - string goOptType = type_to_go_type_with_opt(fieldType, true, false); + string goOptType = type_to_go_type_with_opt(fieldType, true); string maybepointer = goOptType != goType ? "*" : ""; out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() " << goType << " {" << endl; @@ -1758,7 +1758,7 @@ void t_go_generator::generate_go_struct_equals(ostream& out, field_name = (*f_iter)->get_name(); t_type* field_type = (*f_iter)->get_type(); publicize_field_name = publicize(field_name); - string goType = type_to_go_type_with_opt(field_type, is_pointer_field(*f_iter), false); + string goType = type_to_go_type_with_opt(field_type, is_pointer_field(*f_iter)); string tgt = "p." + publicize_field_name; string src = "other." + publicize_field_name; @@ -3431,7 +3431,7 @@ void t_go_generator::generate_serialize_container(ostream& out, if (pointer_field) { wrapped_prefix = "(" + prefix + ")"; } - string goType = type_to_go_container_value_type(tset->get_elem_type()); + string goType = type_to_go_type(tset->get_elem_type()); out << indent() << "if func(tgt, src " << goType << ") bool {" << endl; indent_up(); generate_go_equals(out, tset->get_elem_type(), "tgt", "src"); @@ -3892,40 +3892,31 @@ string t_go_generator::type_to_go_key_type(t_type* type) { } if (resolved_type->is_map() || resolved_type->is_list() || resolved_type->is_set()) { - throw "Cannot produce a valid type for a Go map key: " + type_to_go_container_value_type(type) + " - aborting."; + throw "Cannot produce a valid type for a Go map key: " + type_to_go_type(type) + " - aborting."; } if (resolved_type->is_binary()) return "string"; - return type_to_go_container_value_type(type); -} - -/** - * Converts the parse type to a go type to be used in a container value - */ -string t_go_generator::type_to_go_container_value_type(t_type* type) { - return type_to_go_type_with_opt(type, false, true); + return type_to_go_type(type); } /** * Converts the parse type to a go type */ string t_go_generator::type_to_go_type(t_type* type) { - return type_to_go_type_with_opt(type, false, false); + return type_to_go_type_with_opt(type, false); } /** * Converts the parse type to a go type, taking into account whether the field - * associated with the type is T_OPTIONAL and whether it's used in a container - * type. + * associated with the type is T_OPTIONAL. */ string t_go_generator::type_to_go_type_with_opt(t_type* type, - bool optional_field, - bool is_container_value) { + bool optional_field) { string maybe_pointer(optional_field ? "*" : ""); - if (is_container_value && type->is_typedef() && ((t_typedef*)type)->is_forward_typedef()) { + if (type->is_typedef() && ((t_typedef*)type)->is_forward_typedef()) { type = ((t_typedef*)type)->get_true_type(); } @@ -3974,21 +3965,21 @@ string t_go_generator::type_to_go_type_with_opt(t_type* type, } else if (type->is_map()) { t_map* t = (t_map*)type; string keyType = type_to_go_key_type(t->get_key_type()); - string valueType = type_to_go_container_value_type(t->get_val_type()); + string valueType = type_to_go_type(t->get_val_type()); return maybe_pointer + string("map[") + keyType + "]" + valueType; } else if (type->is_set()) { t_set* t = (t_set*)type; - string elemType = type_to_go_container_value_type(t->get_elem_type()); + string elemType = type_to_go_type(t->get_elem_type()); return maybe_pointer + string("[]") + elemType; } else if (type->is_list()) { t_list* t = (t_list*)type; - string elemType = type_to_go_container_value_type(t->get_elem_type()); + string elemType = type_to_go_type(t->get_elem_type()); return maybe_pointer + string("[]") + elemType; } else if (type->is_typedef()) { return maybe_pointer + publicize(type_name(type)); } - throw "INVALID TYPE IN type_to_go_type_with_opt: " + type->get_name(); + throw "INVALID TYPE IN type_to_go_type: " + type->get_name(); } /** See the comment inside generate_go_struct_definition for what this is. */ diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.h b/compiler/cpp/src/thrift/generate/t_go_generator.h index ad6cee636d2..a67485c5506 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.h +++ b/compiler/cpp/src/thrift/generate/t_go_generator.h @@ -264,9 +264,8 @@ class t_go_generator : public t_generator { std::string argument_list(t_struct* tstruct); std::string type_to_enum(t_type* ttype); std::string type_to_go_type(t_type* ttype); - std::string type_to_go_type_with_opt(t_type* ttype, bool optional_field, bool is_container_value); + std::string type_to_go_type_with_opt(t_type* ttype, bool optional_field); std::string type_to_go_key_type(t_type* ttype); - std::string type_to_go_container_value_type(t_type* ttype); std::string type_to_spec_args(t_type* ttype); void indent_up() { t_generator::indent_up(); } diff --git a/lib/go/test/ForwardTypedef.thrift b/lib/go/test/ForwardType.thrift similarity index 85% rename from lib/go/test/ForwardTypedef.thrift rename to lib/go/test/ForwardType.thrift index 4266b7a285b..0433c97cfdc 100644 --- a/lib/go/test/ForwardTypedef.thrift +++ b/lib/go/test/ForwardType.thrift @@ -17,17 +17,14 @@ * under the License. */ -// https://issues.apache.org/jira/browse/THRIFT-5601 +// https://issues.apache.org/jira/browse/THRIFT-5685 -namespace go forwardtypedef +namespace go forwardtypetest struct Struct { - 1: optional Def foo - 2: optional Exc bar + 1: optional Exc foo } -typedef i32 Def - exception Exc { 1: optional i32 code } diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am index c255a8e485b..cb8928bc8c3 100644 --- a/lib/go/test/Makefile.am +++ b/lib/go/test/Makefile.am @@ -62,7 +62,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \ ProcessorMiddlewareTest.thrift \ ClientMiddlewareExceptionTest.thrift \ ValidateTest.thrift \ - ForwardTypedef.thrift + ForwardType.thrift mkdir -p gopath/src grep -v list.*map.*list.*map $(THRIFTTEST) | grep -v 'set' > ThriftTest.thrift $(THRIFT) $(THRIFTARGS) -r IncludesTest.thrift @@ -97,7 +97,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \ $(THRIFT) $(THRIFTARGS_SKIP_REMOTE) ProcessorMiddlewareTest.thrift $(THRIFT) $(THRIFTARGS) ClientMiddlewareExceptionTest.thrift $(THRIFT) $(THRIFTARGS) ValidateTest.thrift - $(THRIFT) $(THRIFTARGS) ForwardTypedef.thrift + $(THRIFT) $(THRIFTARGS) ForwardType.thrift ln -nfs ../../tests gopath/src/tests cp -r ./dontexportrwtest gopath/src touch gopath @@ -124,7 +124,7 @@ check: gopath ./gopath/src/processormiddlewaretest \ ./gopath/src/clientmiddlewareexceptiontest \ ./gopath/src/validatetest \ - ./gopath/src/forwardtypedef + ./gopath/src/forwardtypetest $(GO) test github.com/apache/thrift/lib/go/thrift $(GO) test ./gopath/src/tests ./gopath/src/dontexportrwtest @@ -155,6 +155,7 @@ EXTRA_DIST = \ DuplicateImportsTest.thrift \ ErrorTest.thrift \ EqualsTest.thrift \ + ForwardType.thrift \ GoTagTest.thrift \ IgnoreInitialismsTest.thrift \ IncludesTest.thrift \ diff --git a/lib/go/test/tests/forwardtype_test.go b/lib/go/test/tests/forwardtype_test.go new file mode 100644 index 00000000000..99b7890e60b --- /dev/null +++ b/lib/go/test/tests/forwardtype_test.go @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package tests + +import ( + "testing" + + "github.com/apache/thrift/lib/go/test/gopath/src/forwardtypetest" + "github.com/apache/thrift/lib/go/thrift" +) + +func TestForwardType(t *testing.T) { + // See https://issues.apache.org/jira/browse/THRIFT-5685 + + const code = int32(1) + foo := &forwardtypetest.Struct{ + Foo: &forwardtypetest.Exc{ + Code: thrift.Pointer(code), + }, + } + if got, want := foo.GetFoo().GetCode(), code; got != want { + t.Errorf("code got %v want %v", got, want) + } +} From c3d66d2eec27ae8e6e96ad705e706b0920b6bdb5 Mon Sep 17 00:00:00 2001 From: Chandler May Date: Sun, 18 Dec 2022 14:10:53 -0500 Subject: [PATCH 027/250] THRIFT-5674: Catch and handle server implementation exceptions Client: js:es6 --- compiler/cpp/src/thrift/generate/t_js_generator.cc | 4 ++-- tutorial/nodejs/NodeClientPromise.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc b/compiler/cpp/src/thrift/generate/t_js_generator.cc index fbd657efedf..f5937d09359 100644 --- a/compiler/cpp/src/thrift/generate/t_js_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc @@ -1485,7 +1485,7 @@ void t_js_generator::generate_process_function(t_service* tservice, t_function* indent_up(); if (gen_es6_) { - indent(f_service_) << "Promise.resolve(this._handler." << tfunction->get_name() << ".bind(this._handler)(" << endl; + indent(f_service_) << "new Promise((resolve) => resolve(this._handler." << tfunction->get_name() << ".bind(this._handler)(" << endl; } else { string maybeComma = (fields.size() > 0 ? "," : ""); indent(f_service_) << "Q.fcall(this._handler." << tfunction->get_name() << ".bind(this._handler)" @@ -1500,7 +1500,7 @@ void t_js_generator::generate_process_function(t_service* tservice, t_function* indent_down(); if (gen_es6_) { - indent(f_service_) << ")).then(result => {" << endl; + indent(f_service_) << "))).then(result => {" << endl; } else { indent(f_service_) << ").then(function(result) {" << endl; } diff --git a/tutorial/nodejs/NodeClientPromise.js b/tutorial/nodejs/NodeClientPromise.js index 2cdc184f95d..e6ff2d7f42c 100644 --- a/tutorial/nodejs/NodeClientPromise.js +++ b/tutorial/nodejs/NodeClientPromise.js @@ -57,7 +57,7 @@ client.calculate(1, work) .then(function(message) { console.log('Whoa? You know how to divide by zero?'); }) - .fail(function(err) { + .catch(function(err) { console.log("InvalidOperation " + err); }); @@ -74,7 +74,7 @@ client.calculate(1, work) .then(function(message) { console.log('Check log: ' + message.value); }) - .fin(function() { + .finally(function() { //close the connection once we're done connection.end(); }); From 074a9342d85f8df88487699658315c3a8912487e Mon Sep 17 00:00:00 2001 From: Duru Can Celasun Date: Thu, 2 Mar 2023 00:27:49 +0000 Subject: [PATCH 028/250] Add Jira account instructions to the PR template --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 6a18a51847c..079621f65f6 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -3,7 +3,7 @@ -- [ ] Did you create an [Apache Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket? (not required for trivial changes) +- [ ] Did you create an [Apache Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket? ([Request account here](https://selfserve.apache.org/jira-account.html), not required for trivial changes) - [ ] If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"? - [ ] Did you squash your changes to a single commit? (not required, but preferred) - [ ] Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"? From f377dd3445362b5d5f051f549a12424663801894 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 9 Mar 2023 22:51:09 +0800 Subject: [PATCH 029/250] Update Java lib gradle build script docs (#2767) It stated Java 8 but now we are on Java 11 --- lib/java/gradle/sourceConfiguration.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/java/gradle/sourceConfiguration.gradle b/lib/java/gradle/sourceConfiguration.gradle index f39f5e51d94..7eccc73f23e 100644 --- a/lib/java/gradle/sourceConfiguration.gradle +++ b/lib/java/gradle/sourceConfiguration.gradle @@ -27,8 +27,8 @@ // https://docs.gradle.org/current/userguide/toolchains.html // // The '--release' option added below makes sure that even if we are using -// the toolchain version > 8, the final artifact is at version 8. There is -// also a runtime CI that's based on Java 8 to ensure that. +// the toolchain version > 11, the final artifact is at version 11. There is +// also a runtime CI that's based on Java 11 to ensure that. java { toolchain { languageVersion = JavaLanguageVersion.of(17) From ae3e96bd33777e75e92f8947d51240fae5beeaa8 Mon Sep 17 00:00:00 2001 From: Ling Li Date: Thu, 16 Mar 2023 17:34:51 -0700 Subject: [PATCH 030/250] py TSocket: Only disable socket.IPV6_V6ONLY when the family is AF_INET6 --- lib/py/src/transport/TSocket.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/py/src/transport/TSocket.py b/lib/py/src/transport/TSocket.py index a24d8fb71f3..50ee67e7665 100644 --- a/lib/py/src/transport/TSocket.py +++ b/lib/py/src/transport/TSocket.py @@ -228,13 +228,14 @@ def listen(self): if eno == errno.ECONNREFUSED: os.unlink(res[4]) - self.handle = socket.socket(res[0], res[1]) - self.handle.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0) - self.handle.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - if hasattr(self.handle, 'settimeout'): - self.handle.settimeout(None) - self.handle.bind(res[4]) - self.handle.listen(self._backlog) + self.handle = s = socket.socket(res[0], res[1]) + if s.family is socket.AF_INET6: + s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0) + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + if hasattr(s, 'settimeout'): + s.settimeout(None) + s.bind(res[4]) + s.listen(self._backlog) def accept(self): client, addr = self.handle.accept() From 0d95b8c4e1d5be3ae4cc3fe5823cddbb91dbc2ec Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Fri, 10 Mar 2023 09:02:38 +0100 Subject: [PATCH 031/250] Add missing include for the security tests --- lib/cpp/test/SecurityFromBufferTest.cpp | 1 + lib/cpp/test/SecurityTest.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/cpp/test/SecurityFromBufferTest.cpp b/lib/cpp/test/SecurityFromBufferTest.cpp index 194e67fdd56..5fba5ee90d8 100644 --- a/lib/cpp/test/SecurityFromBufferTest.cpp +++ b/lib/cpp/test/SecurityFromBufferTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/lib/cpp/test/SecurityTest.cpp b/lib/cpp/test/SecurityTest.cpp index df0cdaf7686..ab3d99b2b6e 100644 --- a/lib/cpp/test/SecurityTest.cpp +++ b/lib/cpp/test/SecurityTest.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include From 66aac4465926404c2bb0c450e80fac2c2824c04c Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 17 Mar 2023 23:37:43 +0100 Subject: [PATCH 032/250] THRIFT-5692 Support for deprecated methods (via annotation) Client: haxe Patch: Jens Geyer --- .../src/thrift/generate/t_haxe_generator.cc | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc index aa628b7ab8c..9397ff15ff3 100644 --- a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc @@ -209,6 +209,8 @@ class t_haxe_generator : public t_oop_generator { string generate_service_method_onsuccess(t_function* tfunction, bool as_type, bool omit_name); void generate_service_method_signature_combined(t_function* tfunction, bool is_interface); void generate_service_method_signature_normal(t_function* tfunction, bool is_interface); + void generate_deprecation_attribute(ostream& out, t_function* func, bool as_comment); + string make_haxe_string_literal( string const& value); bool type_can_be_null(t_type* ttype) { ttype = get_true_type(ttype); @@ -1664,6 +1666,7 @@ void t_haxe_generator::generate_service_method_signature(t_function* tfunction, void t_haxe_generator::generate_service_method_signature_normal(t_function* tfunction, bool is_interface) { if (is_interface) { + generate_deprecation_attribute(f_service_, tfunction, true); indent(f_service_) << function_signature_normal(tfunction) << ";" << endl << endl; } else { indent(f_service_) << "public " << function_signature_normal(tfunction) << " {" << endl; @@ -1684,12 +1687,60 @@ void t_haxe_generator::generate_service_method_signature_combined(t_function* tf } if (is_interface) { + generate_deprecation_attribute(f_service_, tfunction, false); indent(f_service_) << function_signature_combined(tfunction) << ";" << endl << endl; } else { indent(f_service_) << "public " << function_signature_combined(tfunction) << " {" << endl; } } +string t_haxe_generator::make_haxe_string_literal( string const& value) +{ + if (value.length() == 0) { + return ""; + } + + std::stringstream result; + result << "\""; + for (signed char const c: value) { + if( (c >= 0) && (c < 32)) { // convert ctrl chars, but leave UTF-8 alone + int width = std::min( (int)sizeof(c), 6); + result << "\\u{" << std::hex << std::setw(width) << std::setfill('0') << (int)c << '}'; + } else if ((c == '\\') || (c == '"')) { + result << "\\" << c; + } else { + result << c; // anything else "as is" + } + } + result << "\""; + + return result.str(); +} + +void t_haxe_generator::generate_deprecation_attribute(ostream& out, t_function* func, bool as_comment) +{ + auto iter = func->annotations_.find("deprecated"); + if( func->annotations_.end() != iter) { + if( as_comment) { + out << indent() << "// DEPRECATED"; + } else { + out << indent() << "@:deprecated"; + } + + // empty annotation values end up with "1" somewhere, ignore these as well + if ((iter->second.back().length() > 0) && (iter->second.back() != "1")) { + string text = make_haxe_string_literal(iter->second.back()); + if( as_comment) { + out << ": " << text; + } else { + out << "(" << text << ")"; + } + } + + out << endl; + } +} + /** * Generates a service interface definition. * From 5cdf89019c5598294ea33ff25b540de49b42604c Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 5 Apr 2023 14:51:13 -0700 Subject: [PATCH 033/250] Fix github actions error on go tests --- test/go/go.mod | 7 +++++++ test/go/go.sum | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/test/go/go.mod b/test/go/go.mod index 245dd2ea1b3..0143eba0da2 100644 --- a/test/go/go.mod +++ b/test/go/go.mod @@ -7,4 +7,11 @@ require ( github.com/golang/mock v1.6.0 ) +require ( + golang.org/x/mod v0.4.2 // indirect + golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/tools v0.1.1 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect +) + replace github.com/apache/thrift => ../../ diff --git a/test/go/go.sum b/test/go/go.sum index d0671277e22..6904b3efe74 100644 --- a/test/go/go.sum +++ b/test/go/go.sum @@ -3,6 +3,7 @@ github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+Licev github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -13,13 +14,16 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 12ab079ecfe0c87e984fc7498a43a614d8e8a240 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 5 Apr 2023 16:36:51 -0700 Subject: [PATCH 034/250] Bump test/go dependency This replaces and closes https://github.com/apache/thrift/pull/2774. --- test/go/go.mod | 2 +- test/go/go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/go/go.mod b/test/go/go.mod index 0143eba0da2..ff88c9b3f50 100644 --- a/test/go/go.mod +++ b/test/go/go.mod @@ -9,7 +9,7 @@ require ( require ( golang.org/x/mod v0.4.2 // indirect - golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/sys v0.7.0 // indirect golang.org/x/tools v0.1.1 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/test/go/go.sum b/test/go/go.sum index 6904b3efe74..b6ad5455ed0 100644 --- a/test/go/go.sum +++ b/test/go/go.sum @@ -16,6 +16,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From cb60265ec192a5c152d0ce6d4e4ce65633945073 Mon Sep 17 00:00:00 2001 From: Riza Suminto Date: Wed, 5 Apr 2023 13:31:44 -0700 Subject: [PATCH 035/250] THRIFT-5696: Allow custom TConfiguration for TByteBuffer.java --- .../apache/thrift/transport/TByteBuffer.java | 18 ++++++++++--- .../thrift/transport/TestTByteBuffer.java | 27 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/lib/java/src/main/java/org/apache/thrift/transport/TByteBuffer.java b/lib/java/src/main/java/org/apache/thrift/transport/TByteBuffer.java index fa296e7c429..226f02a0489 100644 --- a/lib/java/src/main/java/org/apache/thrift/transport/TByteBuffer.java +++ b/lib/java/src/main/java/org/apache/thrift/transport/TByteBuffer.java @@ -10,17 +10,29 @@ public final class TByteBuffer extends TEndpointTransport { private final ByteBuffer byteBuffer; /** - * Creates a new TByteBuffer wrapping a given NIO ByteBuffer. + * Creates a new TByteBuffer wrapping a given NIO ByteBuffer and custom TConfiguration. * + * @param configuration the custom TConfiguration. * @param byteBuffer the NIO ByteBuffer to wrap. * @throws TTransportException on error. */ - public TByteBuffer(ByteBuffer byteBuffer) throws TTransportException { - super(new TConfiguration()); + public TByteBuffer(TConfiguration configuration, ByteBuffer byteBuffer) + throws TTransportException { + super(configuration); this.byteBuffer = byteBuffer; updateKnownMessageSize(byteBuffer.capacity()); } + /** + * Creates a new TByteBuffer wrapping a given NIO ByteBuffer. + * + * @param byteBuffer the NIO ByteBuffer to wrap. + * @throws TTransportException on error. + */ + public TByteBuffer(ByteBuffer byteBuffer) throws TTransportException { + this(new TConfiguration(), byteBuffer); + } + @Override public boolean isOpen() { return true; diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTByteBuffer.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTByteBuffer.java index 748de121edf..26ffc5d58f3 100644 --- a/lib/java/src/test/java/org/apache/thrift/transport/TestTByteBuffer.java +++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTByteBuffer.java @@ -1,10 +1,12 @@ package org.apache.thrift.transport; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; +import org.apache.thrift.TConfiguration; import org.junit.jupiter.api.Test; public class TestTByteBuffer { @@ -39,4 +41,29 @@ public void testOverflow() throws Exception { () -> byteBuffer.write("Hello World".getBytes(StandardCharsets.UTF_8))); assertEquals("Not enough room in output buffer", e.getMessage()); } + + @Test + public void testSmallTConfiguration() throws Exception { + // Test that TByteBuffer init fail with small max message size. + final TConfiguration configSmall = + new TConfiguration( + 4, TConfiguration.DEFAULT_MAX_FRAME_SIZE, TConfiguration.DEFAULT_RECURSION_DEPTH); + TTransportException e = + assertThrows( + TTransportException.class, + () -> new TByteBuffer(configSmall, ByteBuffer.allocate(100))); + assertEquals("MaxMessageSize reached", e.getMessage()); + } + + @Test + public void testLargeTConfiguration() throws Exception { + // Test that TByteBuffer init pass with large max message size beyond + // TConfiguration.DEFAULT_MAX_MESSAGE_SIZE. + int maxSize = 101 * 1024 * 1024; + int bufferSize = (100 * 1024 + 512) * 1024; + final TConfiguration configLarge = + new TConfiguration( + maxSize, TConfiguration.DEFAULT_MAX_FRAME_SIZE, TConfiguration.DEFAULT_RECURSION_DEPTH); + assertDoesNotThrow(() -> new TByteBuffer(configLarge, ByteBuffer.allocate(bufferSize))); + } } From c82d0c2101544abcad6895b3c9f962980c15844c Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Sat, 8 Apr 2023 16:42:48 +0700 Subject: [PATCH 036/250] reduce java logging (#2659) --- .../main/java/org/apache/thrift/server/TThreadPoolServer.java | 1 - lib/java/src/test/resources/log4j.properties | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/java/src/main/java/org/apache/thrift/server/TThreadPoolServer.java b/lib/java/src/main/java/org/apache/thrift/server/TThreadPoolServer.java index 82d3a29d49a..06fdeec9ca1 100644 --- a/lib/java/src/main/java/org/apache/thrift/server/TThreadPoolServer.java +++ b/lib/java/src/main/java/org/apache/thrift/server/TThreadPoolServer.java @@ -275,7 +275,6 @@ public void run() { } private void logException(Exception x) { - LOGGER.debug("Error processing request", x); // We'll usually receive RuntimeException types here // Need to unwrap to ascertain real causing exception before we choose to ignore // Ignoring err-logging all transport-level/type exceptions and SocketExceptions diff --git a/lib/java/src/test/resources/log4j.properties b/lib/java/src/test/resources/log4j.properties index ab9bebafe38..733994b2d13 100644 --- a/lib/java/src/test/resources/log4j.properties +++ b/lib/java/src/test/resources/log4j.properties @@ -1,5 +1,5 @@ # log4j configuration used during build and unit tests -log4j.rootLogger=debug,stdout +log4j.rootLogger=warn,stdout log4j.threshold=ALL log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout From 79a4b1e9a36248b8350f637b38ad073f49c5fd8f Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Sun, 9 Apr 2023 14:39:20 +0700 Subject: [PATCH 037/250] update gradle to version 7.6 (#2744) * update gradle to version 7.6 * update hash --- .github/workflows/build.yml | 4 ++-- build/docker/old/ubuntu-disco/Dockerfile | 4 ++-- build/docker/old/ubuntu-xenial/Dockerfile | 4 ++-- build/docker/ubuntu-bionic/Dockerfile | 4 ++-- build/docker/ubuntu-focal/Dockerfile | 4 ++-- build/docker/ubuntu-jammy/Dockerfile | 4 ++-- doc/install/README.md | 2 +- doc/install/debian.md | 2 +- lib/java/README.md | 6 +++--- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6400158ef4..ac5f4192874 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -137,7 +137,7 @@ jobs: needs: compiler runs-on: ubuntu-20.04 env: - GRADLE_VERSION: 7.5.1 + GRADLE_VERSION: "7.6" steps: - uses: actions/checkout@v3 @@ -156,7 +156,7 @@ jobs: - name: Setup gradle run: | wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip - (echo "f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) + (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip sudo mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle sudo ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/old/ubuntu-disco/Dockerfile b/build/docker/old/ubuntu-disco/Dockerfile index 37377e34f8d..78caf5d70bd 100644 --- a/build/docker/old/ubuntu-disco/Dockerfile +++ b/build/docker/old/ubuntu-disco/Dockerfile @@ -160,7 +160,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="7.5.1" +ENV GRADLE_VERSION="7.6" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -169,7 +169,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-11-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/old/ubuntu-xenial/Dockerfile b/build/docker/old/ubuntu-xenial/Dockerfile index add524ded84..63140ac7e97 100644 --- a/build/docker/old/ubuntu-xenial/Dockerfile +++ b/build/docker/old/ubuntu-xenial/Dockerfile @@ -155,7 +155,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib install --always hxcpp 3.4.64 2>&1 > /dev/null # note: hxcpp 3.4.185 (latest) no longer ships static libraries, and caused a build failure -ENV GRADLE_VERSION="7.5.1" +ENV GRADLE_VERSION="7.6" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -165,7 +165,7 @@ RUN apt-get install -y --no-install-recommends \ unzip && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile index f0dcb9080aa..333034474a6 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/ubuntu-bionic/Dockerfile @@ -161,7 +161,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="7.5.1" +ENV GRADLE_VERSION="7.6" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -170,7 +170,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-17-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index ad01f7e9f10..36bd0431d46 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -162,7 +162,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="7.5.1" +ENV GRADLE_VERSION="7.6" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -171,7 +171,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-17-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index d2a5f64a47f..7cbc4a0480d 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -162,7 +162,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="7.5.1" +ENV GRADLE_VERSION="7.6" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -171,7 +171,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-11-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/doc/install/README.md b/doc/install/README.md index e349f0fe077..2a9446bdb34 100644 --- a/doc/install/README.md +++ b/doc/install/README.md @@ -29,7 +29,7 @@ These are only required if you choose to build the libraries for the given langu * Qt (optional) * Java * Java 17 - * Gradle 7.5.1 + * Gradle 7.6 * C#: Mono 1.2.4 (and pkg-config to detect it) or Visual Studio 2005+ * Python 2.6 (including header files for extension modules) * PHP 5.0 (optionally including header files for extension modules) diff --git a/doc/install/debian.md b/doc/install/debian.md index 4d5a4464bf4..281a6a8021b 100644 --- a/doc/install/debian.md +++ b/doc/install/debian.md @@ -18,7 +18,7 @@ Debian 7/Ubuntu 12 users need to manually install a more recent version of autom If you would like to build Apache Thrift libraries for other programming languages you may need to install additional packages. The following languages require the specified additional packages: * Java - * packages: gradle (version 7.5.1) + * packages: gradle (version 7.6) * You will also need Java JDK v1.8 or higher. Type **javac** to see a list of available packages, pick the one you prefer and **apt-get install** it (e.g. default-jdk). * Ruby * ruby-full ruby-dev ruby-rspec rake rubygems bundler diff --git a/lib/java/README.md b/lib/java/README.md index 7005c605f62..956d043dd0b 100644 --- a/lib/java/README.md +++ b/lib/java/README.md @@ -42,7 +42,7 @@ The Thrift Java source is not build using the GNU tools, but rather uses the Gradle build system, which tends to be predominant amongst Java developers. -Currently we use gradle 7.5.1 to build the Thrift Java source. The usual way to setup gradle +Currently we use gradle 7.6 to build the Thrift Java source. The usual way to setup gradle project is to include the gradle-wrapper.jar in the project and then run the gradle wrapper to bootstrap setting up gradle binaries. However to avoid putting binary files into the source tree we have ignored the gradle wrapper files. You are expected to install it manually, as described in @@ -50,13 +50,13 @@ the [gradle documentation](https://docs.gradle.org/current/userguide/installatio following this step (which is also done in the travis CI docker images): ```bash -export GRADLE_VERSION="7.5.1" +export GRADLE_VERSION="7.6" # install dependencies apt-get install -y --no-install-recommends openjdk-17-jdk-headless wget unzip # download gradle distribution wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip # check binary integrity -echo "f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c - +echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c - # unzip and install unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle From be73a570e29dce424c8f20b5a31c21249303c5c3 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Fri, 14 Apr 2023 11:02:43 +0800 Subject: [PATCH 038/250] THRIFT-5699: java lib and build tool chain: gradle 8.0.2 (#2779) --- .github/workflows/build.yml | 6 +++--- build/docker/old/ubuntu-disco/Dockerfile | 4 ++-- build/docker/old/ubuntu-xenial/Dockerfile | 4 ++-- build/docker/ubuntu-bionic/Dockerfile | 4 ++-- build/docker/ubuntu-focal/Dockerfile | 4 ++-- build/docker/ubuntu-jammy/Dockerfile | 4 ++-- doc/install/README.md | 4 ++-- doc/install/debian.md | 2 +- lib/java/README.md | 6 +++--- lib/java/build.gradle | 2 +- lib/java/gradle/sourceConfiguration.gradle | 2 +- lib/java/gradle/unitTests.gradle | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac5f4192874..caeaf16c55c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -137,7 +137,7 @@ jobs: needs: compiler runs-on: ubuntu-20.04 env: - GRADLE_VERSION: "7.6" + GRADLE_VERSION: "8.0.2" steps: - uses: actions/checkout@v3 @@ -156,7 +156,7 @@ jobs: - name: Setup gradle run: | wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip - (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) + (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip sudo mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle sudo ln -s /usr/local/gradle/bin/gradle /usr/local/bin @@ -431,7 +431,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: temurin - # here we intentionally use an older version so that we also verify java 17 compiles to it + # here we intentionally use an older version so that we also verify Java 17 compiles to it java-version: 11 cache: "gradle" diff --git a/build/docker/old/ubuntu-disco/Dockerfile b/build/docker/old/ubuntu-disco/Dockerfile index 78caf5d70bd..55dc853693c 100644 --- a/build/docker/old/ubuntu-disco/Dockerfile +++ b/build/docker/old/ubuntu-disco/Dockerfile @@ -160,7 +160,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="7.6" +ENV GRADLE_VERSION="8.0.2" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -169,7 +169,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-11-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/old/ubuntu-xenial/Dockerfile b/build/docker/old/ubuntu-xenial/Dockerfile index 63140ac7e97..64d4804f776 100644 --- a/build/docker/old/ubuntu-xenial/Dockerfile +++ b/build/docker/old/ubuntu-xenial/Dockerfile @@ -155,7 +155,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib install --always hxcpp 3.4.64 2>&1 > /dev/null # note: hxcpp 3.4.185 (latest) no longer ships static libraries, and caused a build failure -ENV GRADLE_VERSION="7.6" +ENV GRADLE_VERSION="8.0.2" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -165,7 +165,7 @@ RUN apt-get install -y --no-install-recommends \ unzip && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile index 333034474a6..d6d2bda598c 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/ubuntu-bionic/Dockerfile @@ -161,7 +161,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="7.6" +ENV GRADLE_VERSION="8.0.2" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -170,7 +170,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-17-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index 36bd0431d46..1f305734f7a 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -162,7 +162,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="7.6" +ENV GRADLE_VERSION="8.0.2" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -171,7 +171,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-17-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index 7cbc4a0480d..c7724e7942b 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -162,7 +162,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="7.6" +ENV GRADLE_VERSION="8.0.2" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -171,7 +171,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-11-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/doc/install/README.md b/doc/install/README.md index 2a9446bdb34..b90e5c6a3b9 100644 --- a/doc/install/README.md +++ b/doc/install/README.md @@ -28,8 +28,8 @@ These are only required if you choose to build the libraries for the given langu * zlib (optional) * Qt (optional) * Java - * Java 17 - * Gradle 7.6 + * Java 17 (latest LTS) + * Gradle 8.0.2 * C#: Mono 1.2.4 (and pkg-config to detect it) or Visual Studio 2005+ * Python 2.6 (including header files for extension modules) * PHP 5.0 (optionally including header files for extension modules) diff --git a/doc/install/debian.md b/doc/install/debian.md index 281a6a8021b..4718017a763 100644 --- a/doc/install/debian.md +++ b/doc/install/debian.md @@ -18,7 +18,7 @@ Debian 7/Ubuntu 12 users need to manually install a more recent version of autom If you would like to build Apache Thrift libraries for other programming languages you may need to install additional packages. The following languages require the specified additional packages: * Java - * packages: gradle (version 7.6) + * packages: gradle (version 8.0.2) * You will also need Java JDK v1.8 or higher. Type **javac** to see a list of available packages, pick the one you prefer and **apt-get install** it (e.g. default-jdk). * Ruby * ruby-full ruby-dev ruby-rspec rake rubygems bundler diff --git a/lib/java/README.md b/lib/java/README.md index 956d043dd0b..aa07495c86a 100644 --- a/lib/java/README.md +++ b/lib/java/README.md @@ -42,7 +42,7 @@ The Thrift Java source is not build using the GNU tools, but rather uses the Gradle build system, which tends to be predominant amongst Java developers. -Currently we use gradle 7.6 to build the Thrift Java source. The usual way to setup gradle +Currently we use gradle 8.0 to build the Thrift Java source. The usual way to setup gradle project is to include the gradle-wrapper.jar in the project and then run the gradle wrapper to bootstrap setting up gradle binaries. However to avoid putting binary files into the source tree we have ignored the gradle wrapper files. You are expected to install it manually, as described in @@ -50,13 +50,13 @@ the [gradle documentation](https://docs.gradle.org/current/userguide/installatio following this step (which is also done in the travis CI docker images): ```bash -export GRADLE_VERSION="7.6" +export GRADLE_VERSION="8.0.2" # install dependencies apt-get install -y --no-install-recommends openjdk-17-jdk-headless wget unzip # download gradle distribution wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip # check binary integrity -echo "7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c - +echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c - # unzip and install unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle diff --git a/lib/java/build.gradle b/lib/java/build.gradle index c8fc27cfd54..7459e1fcc58 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -40,7 +40,7 @@ plugins { id 'maven-publish' id 'signing' id 'pmd' - id 'com.github.johnrengelman.shadow' version '6.1.0' + id 'com.github.johnrengelman.shadow' version '8.1.1' id "com.github.spotbugs" version "4.7.1" id "com.diffplug.spotless" version "6.5.2" } diff --git a/lib/java/gradle/sourceConfiguration.gradle b/lib/java/gradle/sourceConfiguration.gradle index 7eccc73f23e..e3e143acd99 100644 --- a/lib/java/gradle/sourceConfiguration.gradle +++ b/lib/java/gradle/sourceConfiguration.gradle @@ -21,7 +21,7 @@ // ---------------------------------------------------------------------------- // Compiler configuration details -// We are using Java 17 toolchain to compile. +// We are using Java 17 (latest LTS) toolchain to compile. // This enables decoupling from the Java version that gradle runs, from // the actual JDK version for the project. For more details, see // https://docs.gradle.org/current/userguide/toolchains.html diff --git a/lib/java/gradle/unitTests.gradle b/lib/java/gradle/unitTests.gradle index 293bccaa371..1e7481bda61 100644 --- a/lib/java/gradle/unitTests.gradle +++ b/lib/java/gradle/unitTests.gradle @@ -24,7 +24,7 @@ task testJar(type: Jar, group: 'Build') { description = 'Assembles a jar archive containing the test classes.' project.test.dependsOn it - classifier 'test' + archiveClassifier = 'test' from sourceSets.test.output } From 1e3d90d8fd4160d538b7a4d902169eae5155e08a Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Fri, 14 Apr 2023 23:57:33 +0800 Subject: [PATCH 039/250] update .github workflow to consolidate config (#2786) * update .github workflow to consolidate config * rust => rs --- .github/workflows/build.yml | 128 ++++++++---------------------------- 1 file changed, 29 insertions(+), 99 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index caeaf16c55c..9e164619c12 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,31 @@ on: env: BUILD_DEPS: automake bison flex git libboost-all-dev libevent-dev libssl-dev libtool make pkg-config + CONFIG_ARGS_FOR_LIBS: > + --disable-debug + --disable-tests + --disable-dependency-tracking + --without-cpp + --without-c_glib + --without-java + --without-kotlin + --without-python + --without-py3 + --without-ruby + --without-haxe + --without-netstd + --without-perl + --without-php + --without-php_extension + --without-dart + --without-erlang + --without-go + --without-d + --without-nodejs + --without-nodets + --without-lua + --without-rs + --without-swift permissions: contents: read @@ -76,30 +101,7 @@ jobs: - name: Run configure run: | - ./configure \ - --disable-debug \ - --disable-dependency-tracking \ - --without-cpp \ - --without-c_glib \ - --without-java \ - --without-kotlin \ - --without-python \ - --without-py3 \ - --without-ruby \ - --without-haxe \ - --without-netstd \ - --without-perl \ - --without-php \ - --without-php_extension \ - --without-dart \ - --without-erlang \ - --with-go \ - --without-d \ - --without-nodejs \ - --without-nodets \ - --without-lua \ - --without-rs \ - --without-swift + ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-go/with-go/') - uses: actions/download-artifact@v3 with: @@ -177,31 +179,7 @@ jobs: - name: Run configure run: | - ./configure \ - --disable-debug \ - --disable-tests \ - --disable-dependency-tracking \ - --without-cpp \ - --without-c_glib \ - --with-java \ - --with-kotlin \ - --without-python \ - --without-py3 \ - --without-ruby \ - --without-haxe \ - --without-netstd \ - --without-perl \ - --without-php \ - --without-php_extension \ - --without-dart \ - --without-erlang \ - --without-go \ - --without-d \ - --without-nodejs \ - --without-nodets \ - --without-lua \ - --without-rs \ - --without-swift + ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-java/with-java/' | sed 's/without-kotlin/with-kotlin/') - uses: actions/download-artifact@v3 with: @@ -276,31 +254,7 @@ jobs: - name: Run configure run: | - ./configure \ - --disable-debug \ - --disable-tests \ - --disable-dependency-tracking \ - --without-cpp \ - --without-c_glib \ - --without-java \ - --without-kotlin \ - --without-python \ - --without-py3 \ - --without-ruby \ - --without-haxe \ - --without-netstd \ - --without-perl \ - --without-php \ - --without-php_extension \ - --without-dart \ - --without-erlang \ - --without-go \ - --without-d \ - --without-nodejs \ - --without-nodets \ - --without-lua \ - --without-rs \ - --with-swift + ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-swift/with-swift/') - uses: actions/download-artifact@v3 with: @@ -353,31 +307,7 @@ jobs: - name: Run configure run: | - ./configure \ - --disable-debug \ - --disable-tests \ - --disable-dependency-tracking \ - --without-cpp \ - --without-c_glib \ - --without-java \ - --without-kotlin \ - --without-python \ - --without-py3 \ - --without-ruby \ - --without-haxe \ - --without-netstd \ - --without-perl \ - --without-php \ - --without-php_extension \ - --without-dart \ - --without-erlang \ - --without-go \ - --without-d \ - --without-nodejs \ - --without-nodets \ - --without-lua \ - --with-rs \ - --without-swift + ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-rs/with-rs/') - uses: actions/download-artifact@v3 with: From 6f339004e6c636d9ce7b114d351e9141edff5c17 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 20 Apr 2023 07:39:35 +0800 Subject: [PATCH 040/250] THRIFT-5564: add GitHub action for python 2.x and 3.x (#2787) * update .github workflow to consolidate config * add lib python * Update build.yml update * rust => rs * Update build.yml update * update install openssl remove 3.6 setup daemon try 3.6 fix lib path add backports of py Update build.yml use sudo add install-exec-hook * add ssl test skip --- .github/workflows/build.yml | 68 +++++++++++++++++++++++++ lib/py/src/server/TNonblockingServer.py | 2 +- lib/py/src/server/TServer.py | 4 +- lib/py/test/_import_local_thrift.py | 8 +-- lib/py/test/test_sslsocket.py | 1 + 5 files changed, 77 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9e164619c12..1e93113a6fa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -344,12 +344,79 @@ jobs: - name: Run make test_recursive for rust run: make -C lib/rs/test_recursive check + lib-python: + needs: compiler + runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: ["2.x", "3.x"] + steps: + - uses: actions/checkout@v3 + + - name: Install dependencies + run: | + sudo apt-get update -yq + sudo apt-get install -y --no-install-recommends $BUILD_DEPS + sudo apt-get install -y --no-install-recommends curl openssl ca-certificates + + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + + - name: Python setup + run: | + python -m pip install --upgrade pip setuptools wheel flake8 tornado twisted zope.interface + python --version + pip --version + + - name: Python 2.x backport setup + if: matrix.python-version == '2.x' + run: | + python -m pip install --upgrade ipaddress backports.ssl_match_hostname + + - name: Run bootstrap + run: ./bootstrap.sh + + - name: Run configure 2.x + if: matrix.python-version == '2.x' + run: | + ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-python/with-python/') + + - name: Run configure 3.x + if: matrix.python-version != '2.x' + run: | + ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-py3/with-py3/') + + - uses: actions/download-artifact@v3 + with: + name: thrift-compiler + path: compiler/cpp + + - name: Run thrift-compiler + run: | + chmod a+x compiler/cpp/thrift + compiler/cpp/thrift -version + + - name: Run make for python + run: make -C lib/py + + - name: Run make install for python + run: sudo make -C lib/py install + + # - name: Run make install-exec-hook for python + # run: sudo make -C lib/py install-exec-hook + + - name: Run make check for python + run: make -C lib/py check + cross-test: needs: - lib-java-kotlin - lib-swift - lib-rust - lib-go + - lib-python runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 @@ -428,3 +495,4 @@ jobs: name: cross-test-log path: test/log/ retention-days: 3 + diff --git a/lib/py/src/server/TNonblockingServer.py b/lib/py/src/server/TNonblockingServer.py index cef4079c0d0..76947608f56 100644 --- a/lib/py/src/server/TNonblockingServer.py +++ b/lib/py/src/server/TNonblockingServer.py @@ -268,7 +268,7 @@ def prepare(self): self.socket.listen() for _ in range(self.threads): thread = Worker(self.tasks) - thread.setDaemon(True) + thread.daemon = True thread.start() self.prepared = True diff --git a/lib/py/src/server/TServer.py b/lib/py/src/server/TServer.py index df2a7bb93d3..8b2f938a62a 100644 --- a/lib/py/src/server/TServer.py +++ b/lib/py/src/server/TServer.py @@ -125,7 +125,7 @@ def serve(self): if not client: continue t = threading.Thread(target=self.handle, args=(client,)) - t.setDaemon(self.daemon) + t.daemon = self.daemon t.start() except KeyboardInterrupt: raise @@ -213,7 +213,7 @@ def serve(self): for i in range(self.threads): try: t = threading.Thread(target=self.serveThread) - t.setDaemon(self.daemon) + t.daemon = self.daemon t.start() except Exception as x: logger.exception(x) diff --git a/lib/py/test/_import_local_thrift.py b/lib/py/test/_import_local_thrift.py index d22312298ac..37b75107559 100644 --- a/lib/py/test/_import_local_thrift.py +++ b/lib/py/test/_import_local_thrift.py @@ -25,6 +25,8 @@ ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(SCRIPT_DIR))) for libpath in glob.glob(os.path.join(ROOT_DIR, 'lib', 'py', 'build', 'lib.*')): - if libpath.endswith('-%d.%d' % (sys.version_info[0], sys.version_info[1])): - sys.path.insert(0, libpath) - break + for pattern in ('-%d.%d', '-%d%d'): + postfix = pattern % (sys.version_info[0], sys.version_info[1]) + if libpath.endswith(postfix): + sys.path.insert(0, libpath) + break diff --git a/lib/py/test/test_sslsocket.py b/lib/py/test/test_sslsocket.py index 3b77e391b86..801024a1e6c 100644 --- a/lib/py/test/test_sslsocket.py +++ b/lib/py/test/test_sslsocket.py @@ -118,6 +118,7 @@ def __exit__(self, exc_type, exc_value, traceback): return True +@unittest.skip("failing SSL test to be fixed in subsequent pull request") class TSSLSocketTest(unittest.TestCase): def _server_socket(self, **kwargs): return TSSLServerSocket(port=0, **kwargs) From 6fefbf437c7392aa3a1be4eb1b32fb0e7ecb95db Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 20 Apr 2023 07:41:11 +0800 Subject: [PATCH 041/250] Upgrade java mockito from version 1.x to version 5 (#2781) * use mockito 5 * remove unnecessary flag * fix java annotation test file name --- lib/java/gradle.properties | 2 +- lib/java/gradle/environment.gradle | 2 +- lib/java/gradle/generateTestThrift.gradle | 2 +- lib/java/gradle/unitTests.gradle | 2 -- .../test/java/org/apache/thrift/TestMultiplexedProcessor.java | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/java/gradle.properties b/lib/java/gradle.properties index 917b24b0161..4256dbd47b6 100644 --- a/lib/java/gradle.properties +++ b/lib/java/gradle.properties @@ -31,7 +31,7 @@ slf4j.version=1.7.36 servlet.version=4.0.1 tomcat.embed.version=9.0.43 junit.version=5.8.2 -mockito.version=1.10.19 +mockito.version=5.3.0 javax.annotation.version=1.3.2 commons-lang3.version=3.12.0 diff --git a/lib/java/gradle/environment.gradle b/lib/java/gradle/environment.gradle index f25f3e645aa..cb61c05fc9c 100644 --- a/lib/java/gradle/environment.gradle +++ b/lib/java/gradle/environment.gradle @@ -68,6 +68,6 @@ dependencies { implementation "org.apache.commons:commons-lang3:${commonsLang3Version}" testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}" - testImplementation "org.mockito:mockito-all:${mockitoVersion}" + testImplementation "org.mockito:mockito-core:${mockitoVersion}" testRuntimeOnly "org.slf4j:slf4j-log4j12:${slf4jVersion}" } diff --git a/lib/java/gradle/generateTestThrift.gradle b/lib/java/gradle/generateTestThrift.gradle index 0506aa6cff7..301812fcceb 100644 --- a/lib/java/gradle/generateTestThrift.gradle +++ b/lib/java/gradle/generateTestThrift.gradle @@ -88,7 +88,7 @@ task generateJava(group: 'Build') { thriftCompile(it, 'EnumContainersTest.thrift') thriftCompile(it, 'JavaBinaryDefault.thrift') thriftCompile(it, 'VoidMethExceptionsTest.thrift') - thriftCompile(it, 'AnnotationTest.thrift') + thriftCompile(it, 'JavaAnnotationTest.thrift') thriftCompile(it, 'partial/thrift_test_schema.thrift') } diff --git a/lib/java/gradle/unitTests.gradle b/lib/java/gradle/unitTests.gradle index 1e7481bda61..4f06fcfcdbf 100644 --- a/lib/java/gradle/unitTests.gradle +++ b/lib/java/gradle/unitTests.gradle @@ -65,8 +65,6 @@ test { outputs.upToDateWhen { false } } - // This is required for Mockito to run under Java 17 - jvmArgs '--add-opens=java.base/java.lang=ALL-UNNAMED' include '**/Test*.class' exclude '**/Test*\$*.class' diff --git a/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java b/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java index efd1882bf68..b3c4cb2bc16 100644 --- a/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java +++ b/lib/java/src/test/java/org/apache/thrift/TestMultiplexedProcessor.java @@ -20,7 +20,7 @@ package org.apache.thrift; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; From 2891e4a7dc216a548008f4a8fceb1c6e2fe6f84d Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 14 Apr 2023 00:25:15 +0200 Subject: [PATCH 042/250] THRIFT-5704 Superfluous block scope in generated write() code Client: hx Patch: Jens Geyer --- compiler/cpp/src/thrift/generate/t_haxe_generator.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc index 9397ff15ff3..ee65591b0a3 100644 --- a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc @@ -2521,7 +2521,6 @@ void t_haxe_generator::generate_serialize_struct(ostream& out, t_struct* tstruct * @param prefix String prefix for fields */ void t_haxe_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) { - scope_up(out); if (ttype->is_map()) { string iter = tmp("_key"); @@ -2572,7 +2571,6 @@ void t_haxe_generator::generate_serialize_container(ostream& out, t_type* ttype, indent(out) << "oprot.writeListEnd();" << endl; } - scope_down(out); } /** From 6945c4e1c71c71846430bd6dcfb102bd4123771a Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Thu, 20 Apr 2023 17:29:53 +0200 Subject: [PATCH 043/250] THRIFT-5703 Haxe 4.30 emits "Local variable retval used without being initialized" on generated code Client: hx Patch: Jens Geyer --- .../src/thrift/generate/t_haxe_generator.cc | 73 ++++++++++--------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc index ee65591b0a3..166f78e7c46 100644 --- a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc @@ -201,6 +201,7 @@ class t_haxe_generator : public t_oop_generator { std::string type_name(t_type* ttype, bool in_container = false, bool in_init = false); std::string base_type_name(t_base_type* tbase, bool in_container = false); std::string declare_field(t_field* tfield, bool init = false); + std::string render_default_value_for_type(t_type* type, bool allow_null); std::string function_signature_combined(t_function* tfunction); std::string function_signature_normal(t_function* tfunction); std::string argument_list(t_struct* tstruct); @@ -1878,8 +1879,9 @@ void t_haxe_generator::generate_service_client(t_service* tservice) { string retval = tmp("retval"); if (!((*f_iter)->is_oneway() || (*f_iter)->get_returntype()->is_void())) { - f_service_ << indent() << "var " << retval << " : " << type_name((*f_iter)->get_returntype()) << ";" - << endl; + f_service_ << indent() << "var " << retval << " : " << type_name((*f_iter)->get_returntype()) + << " = " << render_default_value_for_type((*f_iter)->get_returntype(),true) + << ";" << endl; } if ((*f_iter)->is_oneway()) { @@ -2736,50 +2738,51 @@ string t_haxe_generator::base_type_name(t_base_type* type, bool in_container) { * @param ttype The type */ string t_haxe_generator::declare_field(t_field* tfield, bool init) { - // TODO(mcslee): do we ever need to initialize the field? string result = "var " + tfield->get_name() + " : " + type_name(tfield->get_type()); if (init) { t_type* ttype = get_true_type(tfield->get_type()); if (ttype->is_base_type() && tfield->get_value() != nullptr) { result += " = " + render_const_value_str( ttype, tfield->get_value()); - } else if (ttype->is_base_type()) { - t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base(); - switch (tbase) { - case t_base_type::TYPE_VOID: - throw "NO T_VOID CONSTRUCT"; - case t_base_type::TYPE_STRING: - result += " = null"; - break; - case t_base_type::TYPE_UUID: - result += " = uuid.Uuid.NIL"; - break; - case t_base_type::TYPE_BOOL: - result += " = false"; - break; - case t_base_type::TYPE_I8: - case t_base_type::TYPE_I16: - case t_base_type::TYPE_I32: - case t_base_type::TYPE_I64: - result += " = 0"; - break; - case t_base_type::TYPE_DOUBLE: - result += " = (double)0"; - break; - default: - throw "unhandled type"; - } - - } else if (ttype->is_enum()) { - result += " = 0"; - } else if (ttype->is_container()) { - result += " = new " + type_name(ttype, false, true) + "()"; } else { - result += " = new " + type_name(ttype, false, true) + "()"; + result += " = " + render_default_value_for_type( ttype, false); } } return result + ";"; } +string t_haxe_generator::render_default_value_for_type( t_type* type, bool allow_null) { + t_type* ttype = get_true_type(type); + + if (ttype->is_base_type()) { + t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base(); + switch (tbase) { + case t_base_type::TYPE_VOID: + throw "NO T_VOID CONSTRUCT"; + case t_base_type::TYPE_STRING: + return "null"; + case t_base_type::TYPE_UUID: + return "uuid.Uuid.NIL"; + case t_base_type::TYPE_BOOL: + return "false"; + case t_base_type::TYPE_I8: + case t_base_type::TYPE_I16: + case t_base_type::TYPE_I32: + case t_base_type::TYPE_I64: + return "0"; + case t_base_type::TYPE_DOUBLE: + return "0.0"; + default: + throw "unhandled type"; + } + } else if (ttype->is_enum()) { + return "0"; + } else if (ttype->is_container()) { + return allow_null ? "null" : "new " + type_name(ttype, false, true) + "()"; + } else { + return allow_null ? "null" : "new " + type_name(ttype, false, true) + "()"; + } +} + /** * Renders a function signature of the form 'type name(args)' * From 67de2f5542c45abf07519ea600414f86273c51f0 Mon Sep 17 00:00:00 2001 From: Fokko Driesprong Date: Thu, 27 Apr 2023 02:44:33 +0200 Subject: [PATCH 044/250] THRIFT-5701: Add dependabot (#2784) * THRIFT-5701: Add dependabot To keep up to date with the latest dependencies * Update dependabot.yml * Change to monthly * Add `/lib/kotlin` --- .github/dependabot.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..b53f01bf4b7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: monthly + - package-ecosystem: "gradle" + directory: "/lib/java" + schedule: + interval: monthly + - package-ecosystem: "gradle" + directory: "/lib/kotlin" + schedule: + interval: monthly From 172ad9b5b02db726328623e9313c149e9c4fb356 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Wed, 26 Apr 2023 17:45:30 -0700 Subject: [PATCH 045/250] Migration to JakartaEE 8 (#2777) Signed-off-by: Bogdan Drutu Co-authored-by: Jiayu Liu --- lib/java/gradle.properties | 4 ++-- lib/java/gradle/environment.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/java/gradle.properties b/lib/java/gradle.properties index 4256dbd47b6..bfd5c22cbff 100644 --- a/lib/java/gradle.properties +++ b/lib/java/gradle.properties @@ -28,11 +28,11 @@ maven-repository-id=apache.releases.https httpclient.version=4.5.13 httpcore.version=4.4.15 slf4j.version=1.7.36 -servlet.version=4.0.1 +servlet.version=4.0.3 tomcat.embed.version=9.0.43 junit.version=5.8.2 mockito.version=5.3.0 -javax.annotation.version=1.3.2 +javax.annotation.version=1.3.5 commons-lang3.version=3.12.0 org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ diff --git a/lib/java/gradle/environment.gradle b/lib/java/gradle/environment.gradle index cb61c05fc9c..8c14a5209f9 100644 --- a/lib/java/gradle/environment.gradle +++ b/lib/java/gradle/environment.gradle @@ -63,8 +63,8 @@ dependencies { implementation "org.slf4j:slf4j-api:${slf4jVersion}" implementation "org.apache.httpcomponents:httpclient:${httpclientVersion}" implementation "org.apache.httpcomponents:httpcore:${httpcoreVersion}" - implementation "javax.servlet:javax.servlet-api:${servletVersion}" - implementation "javax.annotation:javax.annotation-api:${javaxAnnotationVersion}" + implementation "jakarta.servlet:jakarta.servlet-api:${servletVersion}" + implementation "jakarta.annotation:jakarta.annotation-api:${javaxAnnotationVersion}" implementation "org.apache.commons:commons-lang3:${commonsLang3Version}" testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}" From 9141c0c999e668ef8d066e721f20aebd268306cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Apr 2023 08:45:46 +0800 Subject: [PATCH 046/250] Bump actions/setup-python from 3 to 4 (#2792) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1e93113a6fa..3e50b1b4232 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -360,7 +360,7 @@ jobs: sudo apt-get install -y --no-install-recommends curl openssl ca-certificates - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -421,7 +421,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 with: python-version: "3.x" From ccfb91e2601385d1e0332e8d75a88f8edf9f5b13 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Apr 2023 08:46:40 +0800 Subject: [PATCH 047/250] Bump actions/setup-go from 3 to 4 (#2795) Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3e50b1b4232..911b3b5053a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -87,7 +87,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: ${{ matrix.go }} From fe1f69ab2ec31fb9c9bd17d6fc684b9179c493f6 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Thu, 27 Apr 2023 09:48:04 +0900 Subject: [PATCH 048/250] THRIFT-5668: Install FindLibevent.cmake (#2726) Client: cpp ThriftConfig.cmake uses our FindLibevent.cmake but "make install" doesn't install FindLibevent.cmake. It causes an error with find_package(Thrift) like the following: -- Found thrift: /tmp/xxx/tmp/local -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.13") -- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.0.7") CMake Warning at /usr/share/cmake-3.24/Modules/CMakeFindDependencyMacro.cmake:47 (find_package): By not providing "FindLibevent.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Libevent", but CMake did not find one. Could not find a package configuration file provided by "Libevent" with any of the following names: LibeventConfig.cmake libevent-config.cmake Add the installation prefix of "Libevent" to CMAKE_PREFIX_PATH or set "Libevent_DIR" to a directory containing one of the above files. If "Libevent" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): /tmp/xxx/tmp/local/lib/cmake/thrift/ThriftConfig.cmake:93 (find_dependency) --- build/cmake/GenerateConfigModule.cmake | 1 + build/cmake/ThriftConfig.cmake.in | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/build/cmake/GenerateConfigModule.cmake b/build/cmake/GenerateConfigModule.cmake index 9533c823593..26f018a2123 100644 --- a/build/cmake/GenerateConfigModule.cmake +++ b/build/cmake/GenerateConfigModule.cmake @@ -40,5 +40,6 @@ if (NOT CYGWIN) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ThriftConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/ThriftConfigVersion.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/FindLibevent.cmake" DESTINATION "${CMAKE_INSTALL_DIR}/thrift") endif() diff --git a/build/cmake/ThriftConfig.cmake.in b/build/cmake/ThriftConfig.cmake.in index c0552009499..2f2003bb438 100644 --- a/build/cmake/ThriftConfig.cmake.in +++ b/build/cmake/ThriftConfig.cmake.in @@ -59,7 +59,19 @@ if(@OPENSSL_FOUND@ AND @WITH_OPENSSL@) endif() if(@Libevent_FOUND@ AND @WITH_LIBEVENT@) + if(DEFINED CMAKE_MODULE_PATH) + set(THRIFT_CMAKE_MODULE_PATH_OLD ${CMAKE_MODULE_PATH}) + else() + unset(THRIFT_CMAKE_MODULE_PATH_OLD) + endif() + set(CMAKE_MODULE_PATH "${THRIFT_CMAKE_DIR}") find_dependency(Libevent) + if(DEFINED THRIFT_CMAKE_MODULE_PATH_OLD) + set(CMAKE_MODULE_PATH ${THRIFT_CMAKE_MODULE_PATH_OLD}) + unset(THRIFT_CMAKE_MODULE_PATH_OLD) + else() + unset(CMAKE_MODULE_PATH) + endif() endif() check_required_components(Thrift) From 1287f233171ecf311500e5f3e689f752d669b568 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Apr 2023 09:15:31 +0800 Subject: [PATCH 049/250] Bump com.diffplug.spotless from 6.5.2 to 6.18.0 in /lib/java (#2791) --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index 7459e1fcc58..f04f34dc7b9 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -42,7 +42,7 @@ plugins { id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' id "com.github.spotbugs" version "4.7.1" - id "com.diffplug.spotless" version "6.5.2" + id "com.diffplug.spotless" version "6.18.0" } description = 'Apache Thrift Java Library' From c05549f1964bce0a354cde94c0b2b86ce2953668 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Apr 2023 10:12:34 +0800 Subject: [PATCH 050/250] Bump com.github.spotbugs from 4.7.1 to 5.0.14 in /lib/java (#2797) --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index f04f34dc7b9..68077040001 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -41,7 +41,7 @@ plugins { id 'signing' id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' - id "com.github.spotbugs" version "4.7.1" + id "com.github.spotbugs" version "5.0.14" id "com.diffplug.spotless" version "6.18.0" } From 33662eea9a8334ae7ef2328cb6338d37ef4f5867 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Apr 2023 10:12:48 +0800 Subject: [PATCH 051/250] Bump com.github.spotbugs from 4.7.1 to 5.0.14 in /lib/kotlin (#2796) From 790d4cb86c8c3eb3dd7232028c800771c01c6b06 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 27 Apr 2023 11:35:17 +0800 Subject: [PATCH 052/250] THRIFT-5564: [CI] use GitHub workflow matrix to parallel cross tests (#2801) * use github to parallel cross tests * fix syntax * correct syntax * split more * update fail-fast * fix swift' --- .github/workflows/build.yml | 11 +++-- confdefs.h | 93 +++++++++++++++++++++++++++++++++++++ conftest.err | 7 +++ 3 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 confdefs.h create mode 100644 conftest.err diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 911b3b5053a..c3d98b06d4d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -418,6 +418,12 @@ jobs: - lib-go - lib-python runs-on: ubuntu-20.04 + strategy: + matrix: + server_lang: ['java', 'kotlin', 'go', 'rs', 'swift'] + # we always use comma join as many client langs as possible, to reduce the number of jobs + client_lang: ['java,kotlin', 'go,rs', 'swift'] + fail-fast: false steps: - uses: actions/checkout@v3 @@ -480,13 +486,12 @@ jobs: - name: Run cross test env: THRIFT_CROSSTEST_CONCURRENCY: 4 - PRECROSS_LANGS: java,kotlin,go,rs,swift run: | python test/test.py \ --retry-count 5 \ --skip-known-failures \ - --server $PRECROSS_LANGS \ - --client $PRECROSS_LANGS + --server ${{ matrix.server_lang }} \ + --client ${{ matrix.client_lang }} - name: Upload log files from failed cross test runs uses: actions/upload-artifact@v3 diff --git a/confdefs.h b/confdefs.h new file mode 100644 index 00000000000..9f8d46a2b5a --- /dev/null +++ b/confdefs.h @@ -0,0 +1,93 @@ +/* confdefs.h */ +#define PACKAGE_NAME "thrift" +#define PACKAGE_TARNAME "thrift" +#define PACKAGE_VERSION "0.19.0" +#define PACKAGE_STRING "thrift 0.19.0" +#define PACKAGE_BUGREPORT "" +#define PACKAGE_URL "" +#define PACKAGE "thrift" +#define VERSION "0.19.0" +#define HAVE_STDIO_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_UNISTD_H 1 +#define STDC_HEADERS 1 +#define HAVE_DLFCN_H 1 +#define LT_OBJDIR ".libs/" +#define BISON_VERSION 0.0 +#define BISON_VERSION 3.8.2 +#define AUTOMAKE_VERSION 1.16.5 +#define YYTEXT_POINTER 1 +#define HAVE_CXX11 1 +#define HAVE_ZLIB /**/ +#define HAVE_STDBOOL_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_SELECT_H 1 +#define HAVE_SYS_SOCKET_H 1 +#define TIME_WITH_SYS_TIME 1 +#define HAVE_SYS_WAIT_H 1 +#define RETSIGTYPE void +#define HAVE_ARPA_INET_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_NETDB_H 1 +#define HAVE_NETINET_IN_H 1 +#define HAVE_POLL_H 1 +#define HAVE_PTHREAD_H 1 +#define HAVE_SCHED_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_SYS_IOCTL_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_POLL_H 1 +#define HAVE_SYS_RESOURCE_H 1 +#define HAVE_SYS_SOCKET_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_UN_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_WCHAR_H 1 +#define HAVE_LIBPTHREAD 1 +#define HAVE_PTRDIFF_T 1 +#define HAVE_ALLOCA_H 1 +#define HAVE_ALLOCA 1 +#define HAVE_FORK 1 +#define HAVE_VFORK 1 +#define HAVE_VPRINTF 1 +#define HAVE_WORKING_VFORK 1 +#define HAVE_WORKING_FORK 1 +#define HAVE_MALLOC 1 +#define HAVE_REALLOC 1 +#define SELECT_TYPE_ARG1 int +#define SELECT_TYPE_ARG234 (fd_set *) +#define SELECT_TYPE_ARG5 (struct timeval *) +#define HAVE_DECL_STRERROR_R 1 +#define HAVE_STRERROR_R 1 +#define HAVE_STRFTIME 1 +#define HAVE_STRTOUL 1 +#define HAVE_BZERO 1 +#define HAVE_FTRUNCATE 1 +#define HAVE_GETHOSTBYNAME 1 +#define HAVE_GETTIMEOFDAY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMSET 1 +#define HAVE_MKDIR 1 +#define HAVE_REALPATH 1 +#define HAVE_SELECT 1 +#define HAVE_SETLOCALE 1 +#define HAVE_SOCKET 1 +#define HAVE_STRCHR 1 +#define HAVE_STRDUP 1 +#define HAVE_STRERROR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_SQRT 1 +#define HAVE_ALARM 1 diff --git a/conftest.err b/conftest.err new file mode 100644 index 00000000000..7040a2c2405 --- /dev/null +++ b/conftest.err @@ -0,0 +1,7 @@ +conftest.cpp:23:9: warning: 'BISON_VERSION' macro redefined [-Wmacro-redefined] +#define BISON_VERSION 3.8.2 + ^ +conftest.cpp:22:9: note: previous definition is here +#define BISON_VERSION 0.0 + ^ +1 warning generated. From a4156083c397af7f0539d9bd1327054dc839985b Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 27 Apr 2023 11:39:47 +0800 Subject: [PATCH 053/250] =?UTF-8?q?Revert=20"THRIFT-5564:=20[CI]=20use=20G?= =?UTF-8?q?itHub=20workflow=20matrix=20to=20parallel=20cros=E2=80=A6=20(#2?= =?UTF-8?q?802)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "THRIFT-5564: [CI] use GitHub workflow matrix to parallel cross tests (#2801)" This reverts commit 790d4cb86c8c3eb3dd7232028c800771c01c6b06. * keep action file change --- confdefs.h | 93 ---------------------------------------------------- conftest.err | 7 ---- 2 files changed, 100 deletions(-) delete mode 100644 confdefs.h delete mode 100644 conftest.err diff --git a/confdefs.h b/confdefs.h deleted file mode 100644 index 9f8d46a2b5a..00000000000 --- a/confdefs.h +++ /dev/null @@ -1,93 +0,0 @@ -/* confdefs.h */ -#define PACKAGE_NAME "thrift" -#define PACKAGE_TARNAME "thrift" -#define PACKAGE_VERSION "0.19.0" -#define PACKAGE_STRING "thrift 0.19.0" -#define PACKAGE_BUGREPORT "" -#define PACKAGE_URL "" -#define PACKAGE "thrift" -#define VERSION "0.19.0" -#define HAVE_STDIO_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_UNISTD_H 1 -#define STDC_HEADERS 1 -#define HAVE_DLFCN_H 1 -#define LT_OBJDIR ".libs/" -#define BISON_VERSION 0.0 -#define BISON_VERSION 3.8.2 -#define AUTOMAKE_VERSION 1.16.5 -#define YYTEXT_POINTER 1 -#define HAVE_CXX11 1 -#define HAVE_ZLIB /**/ -#define HAVE_STDBOOL_H 1 -#define HAVE_SYS_TIME_H 1 -#define HAVE_SYS_SELECT_H 1 -#define HAVE_SYS_SOCKET_H 1 -#define TIME_WITH_SYS_TIME 1 -#define HAVE_SYS_WAIT_H 1 -#define RETSIGTYPE void -#define HAVE_ARPA_INET_H 1 -#define HAVE_FCNTL_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_LIMITS_H 1 -#define HAVE_NETDB_H 1 -#define HAVE_NETINET_IN_H 1 -#define HAVE_POLL_H 1 -#define HAVE_PTHREAD_H 1 -#define HAVE_SCHED_H 1 -#define HAVE_SIGNAL_H 1 -#define HAVE_STDDEF_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_SYS_IOCTL_H 1 -#define HAVE_SYS_PARAM_H 1 -#define HAVE_SYS_POLL_H 1 -#define HAVE_SYS_RESOURCE_H 1 -#define HAVE_SYS_SOCKET_H 1 -#define HAVE_SYS_TIME_H 1 -#define HAVE_SYS_UN_H 1 -#define HAVE_UNISTD_H 1 -#define HAVE_WCHAR_H 1 -#define HAVE_LIBPTHREAD 1 -#define HAVE_PTRDIFF_T 1 -#define HAVE_ALLOCA_H 1 -#define HAVE_ALLOCA 1 -#define HAVE_FORK 1 -#define HAVE_VFORK 1 -#define HAVE_VPRINTF 1 -#define HAVE_WORKING_VFORK 1 -#define HAVE_WORKING_FORK 1 -#define HAVE_MALLOC 1 -#define HAVE_REALLOC 1 -#define SELECT_TYPE_ARG1 int -#define SELECT_TYPE_ARG234 (fd_set *) -#define SELECT_TYPE_ARG5 (struct timeval *) -#define HAVE_DECL_STRERROR_R 1 -#define HAVE_STRERROR_R 1 -#define HAVE_STRFTIME 1 -#define HAVE_STRTOUL 1 -#define HAVE_BZERO 1 -#define HAVE_FTRUNCATE 1 -#define HAVE_GETHOSTBYNAME 1 -#define HAVE_GETTIMEOFDAY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMSET 1 -#define HAVE_MKDIR 1 -#define HAVE_REALPATH 1 -#define HAVE_SELECT 1 -#define HAVE_SETLOCALE 1 -#define HAVE_SOCKET 1 -#define HAVE_STRCHR 1 -#define HAVE_STRDUP 1 -#define HAVE_STRERROR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_SQRT 1 -#define HAVE_ALARM 1 diff --git a/conftest.err b/conftest.err deleted file mode 100644 index 7040a2c2405..00000000000 --- a/conftest.err +++ /dev/null @@ -1,7 +0,0 @@ -conftest.cpp:23:9: warning: 'BISON_VERSION' macro redefined [-Wmacro-redefined] -#define BISON_VERSION 3.8.2 - ^ -conftest.cpp:22:9: note: previous definition is here -#define BISON_VERSION 0.0 - ^ -1 warning generated. From 4f63573f5a49fb564e7b65b9573769963511dbea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemen=20Ko=C5=A1ir?= Date: Thu, 27 Apr 2023 15:13:18 +0900 Subject: [PATCH 054/250] THRIFT-4086: Use true type when generating field meta data (#2765) Client: java --- .../src/thrift/generate/t_java_generator.cc | 30 +++++++++---------- .../cpp/src/thrift/generate/t_oop_generator.h | 2 +- lib/java/gradle/generateTestThrift.gradle | 12 ++++---- ...uctOrder.java => TestDefinitionOrder.java} | 16 +++++----- ...erA.thrift => JavaDefinitionOrderA.thrift} | 24 ++++++++++++++- ...erB.thrift => JavaDefinitionOrderB.thrift} | 23 +++++++++++++- 6 files changed, 75 insertions(+), 32 deletions(-) rename lib/java/src/test/java/org/apache/thrift/{TestStructOrder.java => TestDefinitionOrder.java} (78%) rename lib/java/src/test/resources/{JavaStructOrderA.thrift => JavaDefinitionOrderA.thrift} (64%) rename lib/java/src/test/resources/{JavaStructOrderB.thrift => JavaDefinitionOrderB.thrift} (68%) diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc index ee98600f2a1..4259cf8d75b 100644 --- a/compiler/cpp/src/thrift/generate/t_java_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc @@ -3023,46 +3023,46 @@ void t_java_generator::generate_metadata_for_field_annotations(std::ostream& out } void t_java_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) { + t_type* ttype = get_true_type(type); out << endl; indent_up(); indent_up(); - t_type* ttype = get_true_type(type); if (ttype->is_struct() || ttype->is_xception()) { indent(out) << "new " "org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType." "STRUCT, " - << type_name(type) << ".class"; - } else if (type->is_container()) { - if (type->is_list()) { + << type_name(ttype) << ".class"; + } else if (ttype->is_container()) { + if (ttype->is_list()) { indent(out) << "new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, "; - t_type* elem_type = ((t_list*)type)->get_elem_type(); + t_type* elem_type = ((t_list*)ttype)->get_elem_type(); generate_field_value_meta_data(out, elem_type); - } else if (type->is_set()) { + } else if (ttype->is_set()) { indent(out) << "new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET, "; - t_type* elem_type = ((t_set*)type)->get_elem_type(); + t_type* elem_type = ((t_set*)ttype)->get_elem_type(); generate_field_value_meta_data(out, elem_type); } else { // map indent(out) << "new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, "; - t_type* key_type = ((t_map*)type)->get_key_type(); - t_type* val_type = ((t_map*)type)->get_val_type(); + t_type* key_type = ((t_map*)ttype)->get_key_type(); + t_type* val_type = ((t_map*)ttype)->get_val_type(); generate_field_value_meta_data(out, key_type); out << ", "; generate_field_value_meta_data(out, val_type); } - } else if (type->is_enum()) { + } else if (ttype->is_enum()) { indent(out) << "new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, " - << type_name(type) << ".class"; + << type_name(ttype) << ".class"; } else { indent(out) << "new org.apache.thrift.meta_data.FieldValueMetaData(" - << get_java_type_string(type); - if (type->is_typedef()) { - indent(out) << ", \"" << ((t_typedef*)type)->get_symbolic() << "\""; - } else if (type->is_binary()) { + << get_java_type_string(ttype); + if (ttype->is_binary()) { indent(out) << ", true"; + } else if (type->is_typedef()) { + indent(out) << ", \"" << ((t_typedef*)type)->get_symbolic() << "\""; } } out << ")"; diff --git a/compiler/cpp/src/thrift/generate/t_oop_generator.h b/compiler/cpp/src/thrift/generate/t_oop_generator.h index 2df1be41368..88419620333 100644 --- a/compiler/cpp/src/thrift/generate/t_oop_generator.h +++ b/compiler/cpp/src/thrift/generate/t_oop_generator.h @@ -70,7 +70,7 @@ class t_oop_generator : public t_generator { } virtual void generate_java_doc(std::ostream& out, t_field* field) { - if (field->get_type()->is_enum()) { + if (get_true_type(field->get_type())->is_enum()) { std::string combined_message = field->get_doc() + "\n@see " + get_enum_class_name(field->get_type()); generate_java_docstring_comment(out, combined_message); diff --git a/lib/java/gradle/generateTestThrift.gradle b/lib/java/gradle/generateTestThrift.gradle index 301812fcceb..10bb16bbac2 100644 --- a/lib/java/gradle/generateTestThrift.gradle +++ b/lib/java/gradle/generateTestThrift.gradle @@ -26,8 +26,8 @@ ext.genReuseSrc = file("$buildDir/gen-javareuse") ext.genFullCamelSrc = file("$buildDir/gen-fullcamel") ext.genOptionTypeJdk8Src = file("$buildDir/gen-option-type-jdk8") ext.genUnsafeSrc = file("$buildDir/gen-unsafe") -ext.genStructOrderTestASrc = file("$buildDir/resources/test/struct-order-test/a") -ext.genStructOrderTestBSrc = file("$buildDir/resources/test/struct-order-test/b") +ext.genDefinitionOrderTestASrc = file("$buildDir/resources/test/definition-order-test/a") +ext.genDefinitionOrderTestBSrc = file("$buildDir/resources/test/definition-order-test/b") // Add the generated code directories to the test source set sourceSets { @@ -146,12 +146,12 @@ task generateWithAnnotationMetadata(group: 'Build') { thriftCompile(it, 'JavaAnnotationTest.thrift', 'java:annotations_as_metadata', genSrc) } -task generateJavaStructOrderTestJava(group: 'Build') { - description = 'Generate structs defined in different order and add to build dir so we can compare them' +task generateJavaDefinitionOrderTestJava(group: 'Build') { + description = 'Generate fields defined in different order and add to build dir so we can compare them' generate.dependsOn it ext.outputBuffer = new ByteArrayOutputStream() - thriftCompile(it, 'JavaStructOrderA.thrift', 'java', genStructOrderTestASrc) - thriftCompile(it, 'JavaStructOrderB.thrift', 'java', genStructOrderTestBSrc) + thriftCompile(it, 'JavaDefinitionOrderA.thrift', 'java', genDefinitionOrderTestASrc) + thriftCompile(it, 'JavaDefinitionOrderB.thrift', 'java', genDefinitionOrderTestBSrc) } diff --git a/lib/java/src/test/java/org/apache/thrift/TestStructOrder.java b/lib/java/src/test/java/org/apache/thrift/TestDefinitionOrder.java similarity index 78% rename from lib/java/src/test/java/org/apache/thrift/TestStructOrder.java rename to lib/java/src/test/java/org/apache/thrift/TestDefinitionOrder.java index dd67d9b5d4c..51021b79148 100644 --- a/lib/java/src/test/java/org/apache/thrift/TestStructOrder.java +++ b/lib/java/src/test/java/org/apache/thrift/TestDefinitionOrder.java @@ -26,20 +26,20 @@ import java.util.List; import org.junit.jupiter.api.Test; -// Tests that declaring structs in different order (esp. when they reference each other) generates +// Tests that declaring fields in different order (esp. when they reference each other) generates // identical code -public class TestStructOrder { +public class TestDefinitionOrder { @Test - public void testStructOrder() throws Exception { - List filenames = Arrays.asList("Parent.java", "Child.java"); + public void testDefinitionOrder() throws Exception { + List filenames = Arrays.asList("Parent.java", "Child.java", "MyEnum.java"); for (String fn : filenames) { - String fnA = "struct-order-test/a/" + fn; - String fnB = "struct-order-test/b/" + fn; + String fnA = "definition-order-test/a/" + fn; + String fnB = "definition-order-test/b/" + fn; - try (InputStream isA = TestStructOrder.class.getClassLoader().getResourceAsStream(fnA); - InputStream isB = TestStructOrder.class.getClassLoader().getResourceAsStream(fnB)) { + try (InputStream isA = TestDefinitionOrder.class.getClassLoader().getResourceAsStream(fnA); + InputStream isB = TestDefinitionOrder.class.getClassLoader().getResourceAsStream(fnB)) { assertNotNull(isA, "Resource not found: " + fnA); assertNotNull(isB, "Resource not found: " + fnB); diff --git a/lib/java/src/test/resources/JavaStructOrderA.thrift b/lib/java/src/test/resources/JavaDefinitionOrderA.thrift similarity index 64% rename from lib/java/src/test/resources/JavaStructOrderA.thrift rename to lib/java/src/test/resources/JavaDefinitionOrderA.thrift index f00a7106df9..9b429644307 100644 --- a/lib/java/src/test/resources/JavaStructOrderA.thrift +++ b/lib/java/src/test/resources/JavaDefinitionOrderA.thrift @@ -22,7 +22,29 @@ struct Parent { 1: required string Name } +typedef Parent MyParent +typedef list Parents + +enum MyEnum { + FOO = 1 + BAR = 2 +} + +typedef i8 Age +typedef MyEnum MyEnumV2 +typedef set MyEnums +typedef map MyMapping +typedef binary MyBinary + struct Child { 1: required string Name - 2: required Parent Parent + 2: required Age Age + 3: required Parent Parent1 + 4: required MyParent Parent2 + 5: required Parents GrandParents + 6: required MyEnum MyEnum + 7: required MyEnumV2 MyEnumV2 + 8: required MyEnums MyEnums + 9: required MyMapping MyMapping + 10: required MyBinary MyBinary } diff --git a/lib/java/src/test/resources/JavaStructOrderB.thrift b/lib/java/src/test/resources/JavaDefinitionOrderB.thrift similarity index 68% rename from lib/java/src/test/resources/JavaStructOrderB.thrift rename to lib/java/src/test/resources/JavaDefinitionOrderB.thrift index 4682668b32a..0cccd9705a0 100644 --- a/lib/java/src/test/resources/JavaStructOrderB.thrift +++ b/lib/java/src/test/resources/JavaDefinitionOrderB.thrift @@ -21,9 +21,30 @@ // fixing THRIFT-4086: Java compiler generates different meta data depending on order of structures in file struct Child { 1: required string Name - 2: required Parent Parent + 2: required Age Age + 3: required Parent Parent1 + 4: required MyParent Parent2 + 5: required Parents GrandParents + 6: required MyEnum MyEnum + 7: required MyEnumV2 MyEnumV2 + 8: required MyEnums MyEnums + 9: required MyMapping MyMapping + 10: required MyBinary MyBinary } +typedef i8 Age +typedef Parent MyParent +typedef list Parents +typedef MyEnum MyEnumV2 +typedef set MyEnums +typedef map MyMapping +typedef binary MyBinary + struct Parent { 1: required string Name } + +enum MyEnum { + FOO = 1 + BAR = 2 +} From c58acf5d57bbea984935c8f0936eddbfd1d727ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 May 2023 09:35:10 +0800 Subject: [PATCH 055/250] Bump jvm from 1.6.10 to 1.8.21 in /lib/kotlin (#2803) Bumps [jvm](https://github.com/JetBrains/kotlin) from 1.6.10 to 1.8.21. - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.6.10...v1.8.21) --- updated-dependencies: - dependency-name: jvm dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/kotlin/settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/settings.gradle.kts b/lib/kotlin/settings.gradle.kts index c252addacd3..99ceaf00af1 100644 --- a/lib/kotlin/settings.gradle.kts +++ b/lib/kotlin/settings.gradle.kts @@ -18,7 +18,7 @@ */ pluginManagement { plugins { - kotlin("jvm") version "1.6.10" + kotlin("jvm") version "1.8.21" id("com.ncorti.ktfmt.gradle") version "0.8.0" } } From 3880a09565a9a1dad028b3679746eafac268c819 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 May 2023 09:35:26 +0800 Subject: [PATCH 056/250] Bump org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 in /lib/kotlin (#2798) Bumps [org.jetbrains.kotlinx:kotlinx-coroutines-jdk8](https://github.com/Kotlin/kotlinx.coroutines) from 1.6.1 to 1.6.4. - [Release notes](https://github.com/Kotlin/kotlinx.coroutines/releases) - [Changelog](https://github.com/Kotlin/kotlinx.coroutines/blob/master/CHANGES.md) - [Commits](https://github.com/Kotlin/kotlinx.coroutines/compare/1.6.1...1.6.4) --- updated-dependencies: - dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/kotlin/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/build.gradle.kts b/lib/kotlin/build.gradle.kts index 06b73f2390c..3263586b54f 100644 --- a/lib/kotlin/build.gradle.kts +++ b/lib/kotlin/build.gradle.kts @@ -29,7 +29,7 @@ repositories { dependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom")) implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4") implementation("org.apache.thrift:libthrift:INCLUDED") testImplementation(kotlin("test")) } From b5a8a883a1c5227967093c45a6bc8e36932f2711 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Thu, 11 May 2023 23:27:53 +0200 Subject: [PATCH 057/250] THRIFT-5707 deprecation warning fixes for extern and enum Client: hx Patch: Jens Geyer --- .../src/org/apache/thrift/TFieldRequirementType.hx | 11 +++++------ .../src/org/apache/thrift/protocol/TCompactTypes.hx | 3 +-- .../src/org/apache/thrift/protocol/TMessageType.hx | 3 +-- lib/haxe/src/org/apache/thrift/protocol/TType.hx | 3 +-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx b/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx index 039a2cf3ad2..710c0367815 100644 --- a/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx +++ b/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx @@ -19,12 +19,11 @@ package org.apache.thrift; - /** - * Requirement type constants. - * - */ -@:enum -abstract TFieldRequirementType(Int) from Int to Int { +/** +* Requirement type constants. +* +*/ +enum abstract TFieldRequirementType(Int) from Int to Int { public static inline var REQUIRED : Int = 1; public static inline var OPTIONAL : Int = 2; public static inline var DEFAULT : Int = 3; diff --git a/lib/haxe/src/org/apache/thrift/protocol/TCompactTypes.hx b/lib/haxe/src/org/apache/thrift/protocol/TCompactTypes.hx index a3a7aac2778..625b7126446 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TCompactTypes.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TCompactTypes.hx @@ -22,8 +22,7 @@ package org.apache.thrift.protocol; /** * All of the on-wire type codes. */ -@:enum -abstract TCompactTypes(Int) from Int to Int { +enum abstract TCompactTypes(Int) from Int to Int { public static inline var STOP = 0x00; public static inline var BOOLEAN_TRUE = 0x01; public static inline var BOOLEAN_FALSE = 0x02; diff --git a/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx b/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx index 706d3298bdf..a1ff52a49d7 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx @@ -19,8 +19,7 @@ package org.apache.thrift.protocol; -@:enum -abstract TMessageType(Int) from Int to Int { +enum abstract TMessageType(Int) from Int to Int { public static inline var CALL : Int = 1; public static inline var REPLY : Int = 2; public static inline var EXCEPTION : Int = 3; diff --git a/lib/haxe/src/org/apache/thrift/protocol/TType.hx b/lib/haxe/src/org/apache/thrift/protocol/TType.hx index 8e21ed7c06f..731a4ca9cd1 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TType.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TType.hx @@ -19,8 +19,7 @@ package org.apache.thrift.protocol; -@:enum -abstract TType(Int) from Int to Int { +enum abstract TType(Int) from Int to Int { public static inline var STOP : Int = 0; public static inline var VOID_ : Int = 1; // VOID produces collisions with cpp targets in some cases public static inline var BOOL : Int = 2; From 2c927b529761cb7540b226b33ea4ac47b368ce61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Mon, 15 May 2023 14:33:54 +0200 Subject: [PATCH 058/250] Fix NewTZlibTransportFactoryWithFactory comment --- lib/go/thrift/zlib_transport.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/go/thrift/zlib_transport.go b/lib/go/thrift/zlib_transport.go index 259943a627c..cefe1f99448 100644 --- a/lib/go/thrift/zlib_transport.go +++ b/lib/go/thrift/zlib_transport.go @@ -56,7 +56,7 @@ func NewTZlibTransportFactory(level int) *TZlibTransportFactory { return &TZlibTransportFactory{level: level, factory: nil} } -// NewTZlibTransportFactory constructs a new instance of TZlibTransportFactory +// NewTZlibTransportFactoryWithFactory constructs a new instance of TZlibTransportFactory // as a wrapper over existing transport factory func NewTZlibTransportFactoryWithFactory(level int, factory TTransportFactory) *TZlibTransportFactory { return &TZlibTransportFactory{level: level, factory: factory} From 017ba923813688111f4471dcf5621675e8124306 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Wed, 17 May 2023 07:59:56 -0700 Subject: [PATCH 059/250] Remove unnecessary empty spaces form t_java_generator.cc (#2809) Signed-off-by: Bogdan Drutu --- .../src/thrift/generate/t_java_generator.cc | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc index 4259cf8d75b..6a2211f628a 100644 --- a/compiler/cpp/src/thrift/generate/t_java_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc @@ -440,10 +440,10 @@ class t_java_generator : public t_oop_generator { // true, false, and null might seem like keywords, but they are actually literals; // you cannot use them as identifiers in your programs. const std::string JAVA_KEYWORDS[53] = { - "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", - "default", "do", "double", "else", "enum", "extends", "final", "finally", "float", "for", "goto", "if", - "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "package", "private", - "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this", + "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", + "default", "do", "double", "else", "enum", "extends", "final", "finally", "float", "for", "goto", "if", + "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "package", "private", + "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "try", "void", "volatile", "while", "true", "false", "null" }; std::set java_keywords = std::set(JAVA_KEYWORDS, JAVA_KEYWORDS + sizeof(JAVA_KEYWORDS) / sizeof(JAVA_KEYWORDS[0])); @@ -999,7 +999,7 @@ void t_java_generator::generate_union_constructor(ostream& out, t_struct* tstruc indent(out) << " super(setField, value);" << endl; indent(out) << "}" << endl << endl; - indent(out) << "public " << type_name(tstruct) + indent(out) << "public " << type_name(tstruct) << "(" << type_name(tstruct) << " other) {" << endl; indent(out) << " super(other);" << endl; @@ -1549,7 +1549,7 @@ void t_java_generator::generate_java_struct_definition(ostream& out, if (is_exception) { out << "extends org.apache.thrift.TException "; } - out << "implements org.apache.thrift.TBase<" << make_valid_java_identifier(tstruct->get_name()) + out << "implements org.apache.thrift.TBase<" << make_valid_java_identifier(tstruct->get_name()) << ", " << make_valid_java_identifier(tstruct->get_name()) << "._Fields>, java.io.Serializable, Cloneable, Comparable<" << make_valid_java_identifier(tstruct->get_name()) << ">"; @@ -1682,17 +1682,17 @@ void t_java_generator::generate_java_struct_definition(ostream& out, t_type* type = get_true_type((*m_iter)->get_type()); if (type->is_binary()) { if (unsafe_binaries_) { - indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name()) + indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name()) << " = " << make_valid_java_identifier((*m_iter)->get_name()) << ";" << endl; } else { indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name()) - << " = org.apache.thrift.TBaseHelper.copyBinary(" + << " = org.apache.thrift.TBaseHelper.copyBinary(" << make_valid_java_identifier((*m_iter)->get_name()) << ");" << endl; } } else { - indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name()) << " = " + indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name()) << " = " << make_valid_java_identifier((*m_iter)->get_name()) << ";" << endl; } @@ -1708,7 +1708,7 @@ void t_java_generator::generate_java_struct_definition(ostream& out, indent(out) << "/**" << endl; indent(out) << " * Performs a deep copy on other." << endl; indent(out) << " */" << endl; - indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) + indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << "(" << make_valid_java_identifier(tstruct->get_name()) << " other) {" << endl; indent_up(); @@ -2182,7 +2182,7 @@ void t_java_generator::generate_java_struct_compare_to(ostream& out, t_struct* t indent(out) << "if (" << generate_isset_check(field) << ") {" << endl; indent(out) << " lastComparison = org.apache.thrift.TBaseHelper.compareTo(this." - << make_valid_java_identifier(field->get_name()) + << make_valid_java_identifier(field->get_name()) << ", other." << make_valid_java_identifier(field->get_name()) << ");" << endl; indent(out) << " if (lastComparison != 0) {" << endl; indent(out) << " return lastComparison;" << endl; @@ -2731,7 +2731,7 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts out << type_name(tstruct); } out << " set" << cap_name << "(" - << (type_can_be_null(type) ? (java_nullable_annotation() + " ") : "") + << (type_can_be_null(type) ? (java_nullable_annotation() + " ") : "") << type_name(type) << " " << make_valid_java_identifier(field_name) << ") {" << endl; indent_up(); From 5a19e433fbca97b53593f2cf0f4bdc878ea05e0a Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Thu, 18 May 2023 21:13:22 -0700 Subject: [PATCH 060/250] THRIFT-5711: Fix FutureClient implementation when service extends another service (#2810) * Fix FutureClient implementation when service extends another service Signed-off-by: Bogdan Drutu --- compiler/cpp/src/thrift/generate/t_java_generator.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc index 6a2211f628a..2cfce5b9fea 100644 --- a/compiler/cpp/src/thrift/generate/t_java_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc @@ -3366,8 +3366,14 @@ void t_java_generator::generate_service_client(t_service* tservice) { } void t_java_generator::generate_service_future_client(t_service* tservice) { + string extends_client = ""; + if (tservice->get_extends() != nullptr) { + extends_client = "extends " + type_name(tservice->get_extends()) + ".FutureClient "; + } + static string adapter_class = "org.apache.thrift.async.AsyncMethodFutureAdapter"; - indent(f_service_) << "public static class FutureClient implements FutureIface {" << endl; + indent(f_service_) << "public static class FutureClient " << extends_client + << "implements FutureIface {" << endl; indent_up(); indent(f_service_) << "public FutureClient(AsyncIface delegate) {" << endl; indent_up(); From cfede863143810bb8b59e3cb67c532c72bc25bd1 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Mon, 22 May 2023 14:38:41 -0700 Subject: [PATCH 061/250] Cleanup extend client logic for sync and async clients (#2808) Signed-off-by: Bogdan Drutu --- .../cpp/src/thrift/generate/t_java_generator.cc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc index 2cfce5b9fea..7e55bf919d1 100644 --- a/compiler/cpp/src/thrift/generate/t_java_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc @@ -3199,13 +3199,9 @@ void t_java_generator::generate_service_helpers(t_service* tservice) { * @param tservice The service to generate a server for. */ void t_java_generator::generate_service_client(t_service* tservice) { - string extends = ""; - string extends_client = ""; - if (tservice->get_extends() == nullptr) { - extends_client = "org.apache.thrift.TServiceClient"; - } else { - extends = type_name(tservice->get_extends()); - extends_client = extends + ".Client"; + string extends_client = "org.apache.thrift.TServiceClient"; + if (tservice->get_extends() != nullptr) { + extends_client = type_name(tservice->get_extends()) + ".Client"; } indent(f_service_) << "public static class Client extends " << extends_client @@ -3416,13 +3412,12 @@ void t_java_generator::generate_service_future_client(t_service* tservice) { } void t_java_generator::generate_service_async_client(t_service* tservice) { - string extends = "org.apache.thrift.async.TAsyncClient"; - string extends_client = ""; + string extends_client = "org.apache.thrift.async.TAsyncClient"; if (tservice->get_extends() != nullptr) { - extends = type_name(tservice->get_extends()) + ".AsyncClient"; + extends_client = type_name(tservice->get_extends()) + ".AsyncClient"; } - indent(f_service_) << "public static class AsyncClient extends " << extends + indent(f_service_) << "public static class AsyncClient extends " << extends_client << " implements AsyncIface {" << endl; indent_up(); From 285e39c2422935d80442c0952d88315354f2ac64 Mon Sep 17 00:00:00 2001 From: nicolasb29 Date: Thu, 25 May 2023 23:59:11 +0200 Subject: [PATCH 062/250] THRIFT-5700: Migrate to JakartaEE and Apache HttpComponents 5 (#2746) - Migrate to JakartaEE and Apache HttpComponents 5 - Modify C code to choose which namespace choose for "Generated" annotations (jakarta by default) --- .../src/thrift/generate/t_java_generator.cc | 12 +- lib/java/gradle.properties | 12 +- lib/java/gradle/environment.gradle | 4 +- lib/java/gradle/generateTestThrift.gradle | 18 +-- .../org/apache/thrift/test/TestClient.java | 2 +- .../thrift/THttpClientResponseHandler.java | 74 +++++++++++ .../thrift/server/TExtensibleServlet.java | 12 +- .../org/apache/thrift/server/TServlet.java | 8 +- .../apache/thrift/transport/THttpClient.java | 115 ++++++------------ 9 files changed, 147 insertions(+), 110 deletions(-) create mode 100644 lib/java/src/main/java/org/apache/thrift/THttpClientResponseHandler.java diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc index 7e55bf919d1..172d1373bd3 100644 --- a/compiler/cpp/src/thrift/generate/t_java_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc @@ -80,6 +80,7 @@ class t_java_generator : public t_oop_generator { rethrow_unhandled_exceptions_ = false; unsafe_binaries_ = false; annotations_as_metadata_ = false; + jakarta_annotations_ = false; for (iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) { if (iter->first.compare("beans") == 0) { bean_style_ = true; @@ -128,6 +129,8 @@ class t_java_generator : public t_oop_generator { unsafe_binaries_ = true; } else if (iter->first.compare("annotations_as_metadata") == 0) { annotations_as_metadata_ = true; + } else if (iter->first.compare("jakarta_annotations") == 0) { + jakarta_annotations_ = true; } else { throw "unknown option java:" + iter->first; } @@ -465,6 +468,7 @@ class t_java_generator : public t_oop_generator { bool rethrow_unhandled_exceptions_; bool unsafe_binaries_; bool annotations_as_metadata_; + bool jakarta_annotations_; }; /** @@ -5808,7 +5812,12 @@ void t_java_generator::generate_java_scheme_lookup(ostream& out) { void t_java_generator::generate_javax_generated_annotation(ostream& out) { time_t seconds = time(nullptr); struct tm* now = localtime(&seconds); - indent(out) << "@javax.annotation.Generated(value = \"" << autogen_summary() << "\""; + if (jakarta_annotations_) { + indent(out) << "@jakarta.annotation.Generated(value = \"" << autogen_summary() << "\""; + } else { + indent(out) << "@javax.annotation.Generated(value = \"" << autogen_summary() << "\""; + } + if (undated_generated_annotations_) { out << ")" << endl; } else { @@ -5849,5 +5858,6 @@ THRIFT_REGISTER_GENERATOR( " undated: suppress the date at @Generated annotations\n" " suppress: suppress @Generated annotations entirely\n" " unsafe_binaries: Do not copy ByteBuffers in constructors, getters, and setters.\n" + " jakarta_annotations: generate jakarta annotations (javax by default)\n" " annotations_as_metadata:\n" " Include Thrift field annotations as metadata in the generated code.\n") diff --git a/lib/java/gradle.properties b/lib/java/gradle.properties index bfd5c22cbff..2e3d0412464 100644 --- a/lib/java/gradle.properties +++ b/lib/java/gradle.properties @@ -25,14 +25,14 @@ maven-repository-url=https://repository.apache.org/service/local/staging/deploy/ maven-repository-id=apache.releases.https # Dependency versions -httpclient.version=4.5.13 -httpcore.version=4.4.15 +httpclient.version=5.2.1 +httpcore.version=5.2 slf4j.version=1.7.36 -servlet.version=4.0.3 -tomcat.embed.version=9.0.43 -junit.version=5.8.2 +servlet.version=5.0.0 +tomcat.embed.version=10.1.4 +junit.version=5.9.1 mockito.version=5.3.0 -javax.annotation.version=1.3.5 +javax.annotation.version=2.1.1 commons-lang3.version=3.12.0 org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ diff --git a/lib/java/gradle/environment.gradle b/lib/java/gradle/environment.gradle index 8c14a5209f9..977c07ef348 100644 --- a/lib/java/gradle/environment.gradle +++ b/lib/java/gradle/environment.gradle @@ -61,8 +61,8 @@ repositories { dependencies { implementation "org.slf4j:slf4j-api:${slf4jVersion}" - implementation "org.apache.httpcomponents:httpclient:${httpclientVersion}" - implementation "org.apache.httpcomponents:httpcore:${httpcoreVersion}" + implementation "org.apache.httpcomponents.client5:httpclient5:${httpclientVersion}" + implementation "org.apache.httpcomponents.core5:httpcore5:${httpcoreVersion}" implementation "jakarta.servlet:jakarta.servlet-api:${servletVersion}" implementation "jakarta.annotation:jakarta.annotation-api:${javaxAnnotationVersion}" implementation "org.apache.commons:commons-lang3:${commonsLang3Version}" diff --git a/lib/java/gradle/generateTestThrift.gradle b/lib/java/gradle/generateTestThrift.gradle index 10bb16bbac2..7e33b1558bc 100644 --- a/lib/java/gradle/generateTestThrift.gradle +++ b/lib/java/gradle/generateTestThrift.gradle @@ -38,7 +38,7 @@ sourceSets { // Code generation for Unit Testing // A callable closure to make this easier -ext.thriftCompile = { Task task, String thriftFileName, String generator = 'java', File outputDir = genSrc -> +ext.thriftCompile = { Task task, String thriftFileName, String generator = 'java:jakarta_annotations', File outputDir = genSrc -> def thriftFile = file("$thriftRoot/test/$thriftFileName") if (!thriftFile.exists()) { thriftFile = file("$projectDir/src/test/resources/$thriftFileName") @@ -98,7 +98,7 @@ task generateOptionalTypeJava(group: 'Build') { ext.outputBuffer = new ByteArrayOutputStream() - thriftCompile(it, 'JavaOptionTypeJdk8Test.thrift', 'java:option_type=jdk8', genOptionTypeJdk8Src) + thriftCompile(it, 'JavaOptionTypeJdk8Test.thrift', 'java:option_type=jdk8,jakarta_annotations', genOptionTypeJdk8Src) } task generateBeanJava(group: 'Build') { @@ -107,7 +107,7 @@ task generateBeanJava(group: 'Build') { ext.outputBuffer = new ByteArrayOutputStream() - thriftCompile(it, 'JavaBeansTest.thrift', 'java:beans,nocamel,future_iface', genBeanSrc) + thriftCompile(it, 'JavaBeansTest.thrift', 'java:beans,nocamel,future_iface,jakarta_annotations', genBeanSrc) } task generateReuseJava(group: 'Build') { @@ -116,7 +116,7 @@ task generateReuseJava(group: 'Build') { ext.outputBuffer = new ByteArrayOutputStream() - thriftCompile(it, 'FullCamelTest.thrift', 'java:fullcamel,future_iface', genFullCamelSrc) + thriftCompile(it, 'FullCamelTest.thrift', 'java:fullcamel,future_iface,jakarta_annotations', genFullCamelSrc) } task generateFullCamelJava(group: 'Build') { @@ -125,7 +125,7 @@ task generateFullCamelJava(group: 'Build') { ext.outputBuffer = new ByteArrayOutputStream() - thriftCompile(it, 'ReuseObjects.thrift', 'java:reuse_objects', genReuseSrc) + thriftCompile(it, 'ReuseObjects.thrift', 'java:reuse_objects,jakarta_annotations', genReuseSrc) } task generateUnsafeBinariesJava(group: 'Build') { @@ -134,7 +134,7 @@ task generateUnsafeBinariesJava(group: 'Build') { ext.outputBuffer = new ByteArrayOutputStream() - thriftCompile(it, 'UnsafeTypes.thrift', 'java:unsafe_binaries', genUnsafeSrc) + thriftCompile(it, 'UnsafeTypes.thrift', 'java:unsafe_binaries,jakarta_annotations', genUnsafeSrc) } task generateWithAnnotationMetadata(group: 'Build') { @@ -143,7 +143,7 @@ task generateWithAnnotationMetadata(group: 'Build') { ext.outputBuffer = new ByteArrayOutputStream() - thriftCompile(it, 'JavaAnnotationTest.thrift', 'java:annotations_as_metadata', genSrc) + thriftCompile(it, 'JavaAnnotationTest.thrift', 'java:annotations_as_metadata,jakarta_annotations', genSrc) } task generateJavaDefinitionOrderTestJava(group: 'Build') { @@ -152,6 +152,6 @@ task generateJavaDefinitionOrderTestJava(group: 'Build') { ext.outputBuffer = new ByteArrayOutputStream() - thriftCompile(it, 'JavaDefinitionOrderA.thrift', 'java', genDefinitionOrderTestASrc) - thriftCompile(it, 'JavaDefinitionOrderB.thrift', 'java', genDefinitionOrderTestBSrc) + thriftCompile(it, 'JavaDefinitionOrderA.thrift', 'java:jakarta_annotations', genDefinitionOrderTestASrc) + thriftCompile(it, 'JavaDefinitionOrderB.thrift', 'java:jakarta_annotations', genDefinitionOrderTestBSrc) } diff --git a/lib/java/src/crossTest/java/org/apache/thrift/test/TestClient.java b/lib/java/src/crossTest/java/org/apache/thrift/test/TestClient.java index 2807a4316f5..54f34241003 100644 --- a/lib/java/src/crossTest/java/org/apache/thrift/test/TestClient.java +++ b/lib/java/src/crossTest/java/org/apache/thrift/test/TestClient.java @@ -29,7 +29,7 @@ import java.util.Set; import java.util.UUID; import java.util.stream.IntStream; -import org.apache.http.impl.client.HttpClients; +import org.apache.hc.client5.http.impl.classic.HttpClients; import org.apache.thrift.TApplicationException; import org.apache.thrift.TException; import org.apache.thrift.TSerializer; diff --git a/lib/java/src/main/java/org/apache/thrift/THttpClientResponseHandler.java b/lib/java/src/main/java/org/apache/thrift/THttpClientResponseHandler.java new file mode 100644 index 00000000000..1ed1318be20 --- /dev/null +++ b/lib/java/src/main/java/org/apache/thrift/THttpClientResponseHandler.java @@ -0,0 +1,74 @@ +package org.apache.thrift; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import org.apache.hc.core5.http.ClassicHttpResponse; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.HttpException; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.io.HttpClientResponseHandler; + +public class THttpClientResponseHandler implements HttpClientResponseHandler { + @Override + public InputStream handleResponse(ClassicHttpResponse response) + throws HttpException, IOException { + try (InputStream is = response.getEntity().getContent()) { + int responseCode = response.getCode(); + if (responseCode != HttpStatus.SC_OK) { + throw new IOException("HTTP Response code: " + responseCode); + } + byte[] readByteArray = readIntoByteArray(is); + try { + // Indicate we're done with the content. + consume(response.getEntity()); + } catch (IOException ioe) { + // We ignore this exception, it might only mean the server has no + // keep-alive capability. + } + return new ByteArrayInputStream(readByteArray); + } catch (IOException ioe) { + throw ioe; + } + } + + /** + * Read the responses into a byte array so we can release the connection early. This implies that + * the whole content will have to be read in memory, and that momentarily we might use up twice + * the memory (while the thrift struct is being read up the chain). Proceeding differently might + * lead to exhaustion of connections and thus to app failure. + * + * @param is input stream + * @return read bytes + * @throws IOException when exception during read + */ + private static byte[] readIntoByteArray(InputStream is) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buf = new byte[1024]; + int len; + do { + len = is.read(buf); + if (len > 0) { + baos.write(buf, 0, len); + } + } while (-1 != len); + return baos.toByteArray(); + } + + /** + * copy from org.apache.http.util.EntityUtils#consume. Android has it's own httpcore that doesn't + * have a consume. + */ + private static void consume(final HttpEntity entity) throws IOException { + if (entity == null) { + return; + } + if (entity.isStreaming()) { + InputStream instream = entity.getContent(); + if (instream != null) { + instream.close(); + } + } + } +} diff --git a/lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java b/lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java index fa5acac5169..91f05156cd3 100644 --- a/lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java +++ b/lib/java/src/main/java/org/apache/thrift/server/TExtensibleServlet.java @@ -19,18 +19,18 @@ package org.apache.thrift.server; +import jakarta.servlet.ServletConfig; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Map; -import javax.servlet.ServletConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import org.apache.thrift.TException; import org.apache.thrift.TProcessor; import org.apache.thrift.protocol.TProtocol; diff --git a/lib/java/src/main/java/org/apache/thrift/server/TServlet.java b/lib/java/src/main/java/org/apache/thrift/server/TServlet.java index 831842b558c..dbdf6154e64 100644 --- a/lib/java/src/main/java/org/apache/thrift/server/TServlet.java +++ b/lib/java/src/main/java/org/apache/thrift/server/TServlet.java @@ -1,15 +1,15 @@ package org.apache.thrift.server; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Map; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import org.apache.thrift.TException; import org.apache.thrift.TProcessor; import org.apache.thrift.protocol.TProtocol; diff --git a/lib/java/src/main/java/org/apache/thrift/transport/THttpClient.java b/lib/java/src/main/java/org/apache/thrift/transport/THttpClient.java index e514dd54ea6..3a5ec365074 100644 --- a/lib/java/src/main/java/org/apache/thrift/transport/THttpClient.java +++ b/lib/java/src/main/java/org/apache/thrift/transport/THttpClient.java @@ -19,7 +19,6 @@ package org.apache.thrift.transport; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -28,15 +27,15 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.apache.http.HttpEntity; -import org.apache.http.HttpHost; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ByteArrayEntity; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.config.ConnectionConfig; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.http.io.entity.ByteArrayEntity; +import org.apache.hc.core5.util.Timeout; import org.apache.thrift.TConfiguration; +import org.apache.thrift.THttpClientResponseHandler; /** * HTTP implementation of the TTransport interface. Used for working with a Thrift web services @@ -139,9 +138,9 @@ public THttpClient(TConfiguration config, String url, HttpClient client) this.client = client; this.host = new HttpHost( + url_.getProtocol(), url_.getHost(), - -1 == url_.getPort() ? url_.getDefaultPort() : url_.getPort(), - url_.getProtocol()); + -1 == url_.getPort() ? url_.getDefaultPort() : url_.getPort()); } catch (IOException iox) { throw new TTransportException(iox); } @@ -154,9 +153,9 @@ public THttpClient(String url, HttpClient client) throws TTransportException { this.client = client; this.host = new HttpHost( + url_.getProtocol(), url_.getHost(), - -1 == url_.getPort() ? url_.getDefaultPort() : url_.getPort(), - url_.getProtocol()); + -1 == url_.getPort() ? url_.getDefaultPort() : url_.getPort()); } catch (IOException iox) { throw new TTransportException(iox); } @@ -166,6 +165,13 @@ public void setConnectTimeout(int timeout) { connectTimeout_ = timeout; } + /** + * Use instead {@link + * org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager#setConnectionConfig} or + * {@link + * org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager#setDefaultConnectionConfig} + */ + @Deprecated public void setReadTimeout(int timeout) { readTimeout_ = timeout; } @@ -230,12 +236,22 @@ private RequestConfig getRequestConfig() { RequestConfig requestConfig = RequestConfig.DEFAULT; if (connectTimeout_ > 0) { requestConfig = - RequestConfig.copy(requestConfig).setConnectionRequestTimeout(connectTimeout_).build(); + RequestConfig.copy(requestConfig) + .setConnectionRequestTimeout(Timeout.ofMilliseconds(connectTimeout_)) + .build(); } + return requestConfig; + } + + private ConnectionConfig getConnectionConfig() { + ConnectionConfig connectionConfig = ConnectionConfig.DEFAULT; if (readTimeout_ > 0) { - requestConfig = RequestConfig.copy(requestConfig).setSocketTimeout(readTimeout_).build(); + connectionConfig = + ConnectionConfig.copy(connectionConfig) + .setSocketTimeout(Timeout.ofMilliseconds(readTimeout_)) + .build(); } - return requestConfig; + return connectionConfig; } private static Map getDefaultHeaders() { @@ -246,22 +262,6 @@ private static Map getDefaultHeaders() { return headers; } - /** - * copy from org.apache.http.util.EntityUtils#consume. Android has it's own httpcore that doesn't - * have a consume. - */ - private static void consume(final HttpEntity entity) throws IOException { - if (entity == null) { - return; - } - if (entity.isStreaming()) { - InputStream instream = entity.getContent(); - if (instream != null) { - instream.close(); - } - } - } - private void flushUsingHttpClient() throws TTransportException { if (null == this.client) { throw new TTransportException("Null HttpClient, aborting."); @@ -279,64 +279,17 @@ private void flushUsingHttpClient() throws TTransportException { if (null != customHeaders_) { customHeaders_.forEach(post::addHeader); } - post.setEntity(new ByteArrayEntity(data)); - HttpResponse response = this.client.execute(this.host, post); - handleResponse(response); + post.setEntity(new ByteArrayEntity(data, null)); + inputStream_ = client.execute(this.host, post, new THttpClientResponseHandler()); } catch (IOException ioe) { // Abort method so the connection gets released back to the connection manager post.abort(); throw new TTransportException(ioe); } finally { resetConsumedMessageSize(-1); - post.releaseConnection(); } } - private void handleResponse(HttpResponse response) throws TTransportException { - // Retrieve the InputStream BEFORE checking the status code so - // resources get freed in the with clause. - try (InputStream is = response.getEntity().getContent()) { - int responseCode = response.getStatusLine().getStatusCode(); - if (responseCode != HttpStatus.SC_OK) { - throw new TTransportException("HTTP Response code: " + responseCode); - } - byte[] readByteArray = readIntoByteArray(is); - try { - // Indicate we're done with the content. - consume(response.getEntity()); - } catch (IOException ioe) { - // We ignore this exception, it might only mean the server has no - // keep-alive capability. - } - inputStream_ = new ByteArrayInputStream(readByteArray); - } catch (IOException ioe) { - throw new TTransportException(ioe); - } - } - - /** - * Read the responses into a byte array so we can release the connection early. This implies that - * the whole content will have to be read in memory, and that momentarily we might use up twice - * the memory (while the thrift struct is being read up the chain). Proceeding differently might - * lead to exhaustion of connections and thus to app failure. - * - * @param is input stream - * @return read bytes - * @throws IOException when exception during read - */ - private static byte[] readIntoByteArray(InputStream is) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] buf = new byte[1024]; - int len; - do { - len = is.read(buf); - if (len > 0) { - baos.write(buf, 0, len); - } - } while (-1 != len); - return baos.toByteArray(); - } - public void flush() throws TTransportException { if (null != this.client) { From fcf4ba5c8a96463d10d368bbba658ec59b234212 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 19:53:27 -0400 Subject: [PATCH 063/250] Bump org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 in /lib/kotlin (#2813) Bumps [org.jetbrains.kotlinx:kotlinx-coroutines-jdk8](https://github.com/Kotlin/kotlinx.coroutines) from 1.6.4 to 1.7.1. - [Release notes](https://github.com/Kotlin/kotlinx.coroutines/releases) - [Changelog](https://github.com/Kotlin/kotlinx.coroutines/blob/master/CHANGES.md) - [Commits](https://github.com/Kotlin/kotlinx.coroutines/compare/1.6.4...1.7.1) --- updated-dependencies: - dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/kotlin/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/build.gradle.kts b/lib/kotlin/build.gradle.kts index 3263586b54f..0ec88598d9d 100644 --- a/lib/kotlin/build.gradle.kts +++ b/lib/kotlin/build.gradle.kts @@ -29,7 +29,7 @@ repositories { dependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom")) implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.1") implementation("org.apache.thrift:libthrift:INCLUDED") testImplementation(kotlin("test")) } From dd53b94c0bc1a9cfa236ab19dfc4ecd10667c637 Mon Sep 17 00:00:00 2001 From: Nick Gavalas Date: Thu, 11 May 2023 17:13:13 -0500 Subject: [PATCH 064/250] Stop sharing write headers across all instances of transports --- lib/nodejs/lib/thrift/buffered_transport.js | 3 ++- lib/nodejs/lib/thrift/framed_transport.js | 11 ++++---- lib/nodejs/test/header.test.js | 30 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lib/nodejs/lib/thrift/buffered_transport.js b/lib/nodejs/lib/thrift/buffered_transport.js index 113e21616e3..f0d5d4aa1e4 100644 --- a/lib/nodejs/lib/thrift/buffered_transport.js +++ b/lib/nodejs/lib/thrift/buffered_transport.js @@ -24,6 +24,7 @@ var THeaderTransport = require('./header_transport'); module.exports = TBufferedTransport; function TBufferedTransport(buffer, callback) { + THeaderTransport.call(this); this.defaultReadBufferSize = 1024; this.writeBufferSize = 512; // Soft Limit this.inBuf = new Buffer(this.defaultReadBufferSize); @@ -34,7 +35,7 @@ function TBufferedTransport(buffer, callback) { this.onFlush = callback; }; -TBufferedTransport.prototype = new THeaderTransport(); +Object.setPrototypeOf(TBufferedTransport.prototype, THeaderTransport.prototype); TBufferedTransport.prototype.reset = function() { this.inBuf = new Buffer(this.defaultReadBufferSize); diff --git a/lib/nodejs/lib/thrift/framed_transport.js b/lib/nodejs/lib/thrift/framed_transport.js index 0d424d26088..9a50a738dde 100644 --- a/lib/nodejs/lib/thrift/framed_transport.js +++ b/lib/nodejs/lib/thrift/framed_transport.js @@ -24,6 +24,7 @@ var THeaderTransport = require('./header_transport'); module.exports = TFramedTransport; function TFramedTransport(buffer, callback) { + THeaderTransport.call(this); this.inBuf = buffer || new Buffer(0); this.outBuffers = []; this.outCount = 0; @@ -31,20 +32,20 @@ function TFramedTransport(buffer, callback) { this.onFlush = callback; }; -TFramedTransport.prototype = new THeaderTransport(); +Object.setPrototypeOf(TFramedTransport.prototype, THeaderTransport.prototype); TFramedTransport.receiver = function(callback, seqid) { var residual = []; - + return function(data) { // push received data to residual for(var i = 0; i < data.length; ++i) { residual.push(data[i]) } - while (residual.length > 0) { + while (residual.length > 0) { if (residual.length < 4) { - // Not enough bytes to continue, save and resume on next packet + // Not enough bytes to continue, save and resume on next packet return; } // get single package sieze @@ -57,7 +58,7 @@ TFramedTransport.receiver = function(callback, seqid) { // splice first 4 bytes residual.splice(0, 4) // get package data - var frame = Buffer.from(residual.splice(0, frameSize)); + var frame = Buffer.from(residual.splice(0, frameSize)); callback(new TFramedTransport(frame), seqid); } }; diff --git a/lib/nodejs/test/header.test.js b/lib/nodejs/test/header.test.js index efd7f81d5e5..99bb832bc3c 100644 --- a/lib/nodejs/test/header.test.js +++ b/lib/nodejs/test/header.test.js @@ -39,6 +39,19 @@ const cases = { assert.equals(headers.Trace, "abcde"); assert.end(); }, + "Should read different headers from different payload": function(assert) { + const transport = new TFramedTransport(); + const buf = Buffer.from(headerPayload); + buf[24] = 115; // Change Parent to Parens + buf[32] = 122; // Change shoobar to shoobaz + transport.inBuf = buf; + + const headers = transport.readHeaders(); + assert.equals(headers.Parent, undefined); + assert.equals(headers.Parens, "shoobaz"); + assert.equals(headers.Trace, "abcde"); + assert.end(); + }, "Should read headers when reading message begin": function(assert) { const transport = new TFramedTransport(); transport.inBuf = Buffer.from(headerPayload); @@ -70,6 +83,23 @@ const cases = { assert.equals(headers.boobooboo, "fooshoopoo"); assert.equals(headers.a, "z"); assert.end(); + }, + "Separate transports should have separate headers": function(assert) { + const writeTransport = new TFramedTransport(); + writeTransport.setProtocolId(THeaderTransport.SubprotocolId.BINARY); + writeTransport.setWriteHeader("foo", "bar"); + const headers = writeTransport.getWriteHeaders(); + + const otherWriteTransport = new TFramedTransport(); + otherWriteTransport.setProtocolId(THeaderTransport.SubprotocolId.BINARY); + otherWriteTransport.setWriteHeader("otherfoo", "baz"); + const otherHeaders = otherWriteTransport.getWriteHeaders(); + + assert.equals(headers.foo, "bar"); + assert.equals(headers.otherfoo, undefined); + assert.equals(otherHeaders.foo, undefined); + assert.equals(otherHeaders.otherfoo, "baz"); + assert.end(); } }; From dd2e0d4ae21d2123d2136e43ce81f668d89690b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 07:00:01 +0000 Subject: [PATCH 065/250] Bump com.diffplug.spotless from 6.18.0 to 6.19.0 in /lib/java Bumps com.diffplug.spotless from 6.18.0 to 6.19.0. --- updated-dependencies: - dependency-name: com.diffplug.spotless dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index 68077040001..41083d02adf 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -42,7 +42,7 @@ plugins { id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' id "com.github.spotbugs" version "5.0.14" - id "com.diffplug.spotless" version "6.18.0" + id "com.diffplug.spotless" version "6.19.0" } description = 'Apache Thrift Java Library' From 46b1283d18d27bcbcfe4298ed074e81dac081fe2 Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Fri, 12 May 2023 14:53:53 +0200 Subject: [PATCH 066/250] Don't create a new locale on every to_string() call. Creating locales is surprisingly expensive. We have an application where we - especially during tests - write large amounts of Thrift dumps to disk, and is this application we currently spend around 17% of total CPU time in std::locale's constructor. With this change, it's basically down to zero. --- lib/cpp/src/thrift/TToString.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/cpp/src/thrift/TToString.h b/lib/cpp/src/thrift/TToString.h index 79743fdcdf3..474429d963a 100644 --- a/lib/cpp/src/thrift/TToString.h +++ b/lib/cpp/src/thrift/TToString.h @@ -35,7 +35,8 @@ namespace thrift { template std::string to_string(const T& t) { std::ostringstream o; - o.imbue(std::locale("C")); + const static auto locale = std::locale("C"); + o.imbue(locale); o << t; return o.str(); } @@ -44,7 +45,8 @@ std::string to_string(const T& t) { // is enabled. inline std::string to_string(const float& t) { std::ostringstream o; - o.imbue(std::locale("C")); + const static auto locale = std::locale("C"); + o.imbue(locale); o.precision(static_cast(std::ceil(static_cast(std::numeric_limits::digits * std::log10(2.0f) + 1)))); o << t; return o.str(); @@ -52,7 +54,8 @@ inline std::string to_string(const float& t) { inline std::string to_string(const double& t) { std::ostringstream o; - o.imbue(std::locale("C")); + const static auto locale = std::locale("C"); + o.imbue(locale); o.precision(static_cast(std::ceil(static_cast(std::numeric_limits::digits * std::log10(2.0f) + 1)))); o << t; return o.str(); @@ -60,7 +63,8 @@ inline std::string to_string(const double& t) { inline std::string to_string(const long double& t) { std::ostringstream o; - o.imbue(std::locale("C")); + const static auto locale = std::locale("C"); + o.imbue(locale); o.precision(static_cast(std::ceil(static_cast(std::numeric_limits::digits * std::log10(2.0f) + 1)))); o << t; return o.str(); From 1d6a3262cf32d5063cfcb9ee09355aa1315e7f80 Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Wed, 17 May 2023 17:27:52 +0200 Subject: [PATCH 067/250] Use one TU-wide locale instead of three --- lib/cpp/src/thrift/TToString.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/cpp/src/thrift/TToString.h b/lib/cpp/src/thrift/TToString.h index 474429d963a..d91c58c4b2e 100644 --- a/lib/cpp/src/thrift/TToString.h +++ b/lib/cpp/src/thrift/TToString.h @@ -32,11 +32,15 @@ namespace apache { namespace thrift { +// unnamed namespace to enforce internal linkage - could be done with 'inline' when once have C++17 +namespace { +const auto default_locale = std::locale("C"); +} + template std::string to_string(const T& t) { std::ostringstream o; - const static auto locale = std::locale("C"); - o.imbue(locale); + o.imbue(default_locale); o << t; return o.str(); } @@ -45,8 +49,7 @@ std::string to_string(const T& t) { // is enabled. inline std::string to_string(const float& t) { std::ostringstream o; - const static auto locale = std::locale("C"); - o.imbue(locale); + o.imbue(default_locale); o.precision(static_cast(std::ceil(static_cast(std::numeric_limits::digits * std::log10(2.0f) + 1)))); o << t; return o.str(); @@ -54,8 +57,7 @@ inline std::string to_string(const float& t) { inline std::string to_string(const double& t) { std::ostringstream o; - const static auto locale = std::locale("C"); - o.imbue(locale); + o.imbue(default_locale); o.precision(static_cast(std::ceil(static_cast(std::numeric_limits::digits * std::log10(2.0f) + 1)))); o << t; return o.str(); @@ -63,8 +65,7 @@ inline std::string to_string(const double& t) { inline std::string to_string(const long double& t) { std::ostringstream o; - const static auto locale = std::locale("C"); - o.imbue(locale); + o.imbue(default_locale); o.precision(static_cast(std::ceil(static_cast(std::numeric_limits::digits * std::log10(2.0f) + 1)))); o << t; return o.str(); From 9b4e75a342e516a5bd9ca4b348a9b750f3b61130 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:52:46 -0400 Subject: [PATCH 068/250] Bump guava from 30.0-jre to 32.0.0-jre in /contrib/thrift-maven-plugin (#2817) Bumps [guava](https://github.com/google/guava) from 30.0-jre to 32.0.0-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- contrib/thrift-maven-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/thrift-maven-plugin/pom.xml b/contrib/thrift-maven-plugin/pom.xml index b7a93c93ac6..7f255389c14 100644 --- a/contrib/thrift-maven-plugin/pom.xml +++ b/contrib/thrift-maven-plugin/pom.xml @@ -94,7 +94,7 @@ com.google.guava guava - 30.0-jre + 32.0.0-jre org.codehaus.plexus From d67e5c26e4ac78e4c4d78757969b94bfe6238154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?HojjatK=20=F0=9F=92=BE?= Date: Mon, 5 Jun 2023 19:17:26 -0700 Subject: [PATCH 069/250] add TJSONProtocol support The code contains the changes required to support TJSONProtocol in the Thrift-Swift. The codes are ported from C#.NET Thrift official library --- lib/swift/README.md | 2 +- lib/swift/Sources/TBase64Utils.swift | 89 ++ lib/swift/Sources/TJSONProtocol.swift | 1160 +++++++++++++++++ .../ThriftTests/TJSONProtocolTests.swift | 212 +++ 4 files changed, 1462 insertions(+), 1 deletion(-) create mode 100644 lib/swift/Sources/TBase64Utils.swift create mode 100644 lib/swift/Sources/TJSONProtocol.swift create mode 100644 lib/swift/Tests/ThriftTests/TJSONProtocolTests.swift diff --git a/lib/swift/README.md b/lib/swift/README.md index 6f109618424..128482deaa0 100644 --- a/lib/swift/README.md +++ b/lib/swift/README.md @@ -114,7 +114,7 @@ func write(_ val: String) throws ##### Protocols - [x] TBinaryProtocol - [x] TCompactProtocol -- [ ] TJSONProtocol - This will need to be implemented +- [x] TJSONProtocol ##### Generator - [x] Code Complete Generator diff --git a/lib/swift/Sources/TBase64Utils.swift b/lib/swift/Sources/TBase64Utils.swift new file mode 100644 index 00000000000..156018d01a9 --- /dev/null +++ b/lib/swift/Sources/TBase64Utils.swift @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import Foundation + +public class TBase64Utils { + private static let EncodeTable: String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + private static let NA: UInt8 = UInt8(255) + + private static let DecodeTable: [UInt8] = [ + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 62, NA, NA, NA, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, NA, NA, NA, NA, NA, NA, + NA, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, NA, NA, NA, NA, NA, + NA, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + ] + + static func encode(src: [UInt8], srcOff: Int, len: Int, dst: inout [UInt8], dstOff: Int) { + if (src.count == 0) { + return + } + var index: UInt8 = 0 + + index = src[srcOff] >> 2 & 0x3F + dst[dstOff] = EncodeTable[Int(index)].asciiValue! + + if (len == 3) { + index = ((src[srcOff] << 4) & 0x30) | ((src[srcOff + 1] >> 4) & 0x0F) + dst[dstOff + 1] = EncodeTable[Int(index)].asciiValue! + + index = ((src[srcOff + 1] << 2) & 0x3C) | ((src[srcOff + 2] >> 6) & 0x03) + dst[dstOff + 2] = EncodeTable[Int(index)].asciiValue! + + index = (src[srcOff + 2] & 0x3F) + dst[dstOff + 3] = EncodeTable[Int(index)].asciiValue! + } else if (len == 2) { + index = ((src[srcOff] << 4) & 0x30) | ((src[srcOff + 1] >> 4) & 0x0F) + dst[dstOff + 1] = EncodeTable[Int(index)].asciiValue! + + index = ((src[srcOff + 1] << 2) & 0x3C) + dst[dstOff + 2] = EncodeTable[Int(index)].asciiValue! + } else { + // len == 1 + index = ((src[srcOff] << 4) & 0x30) + dst[dstOff + 1] = EncodeTable[Int(index)].asciiValue! + } + } + + static func decode(src: [UInt8], srcOff: Int, len: Int, dst: inout [UInt8], dstOff: Int) { + if (src.count == 0) { + return + } + + dst[dstOff] = (DecodeTable[Int(src[srcOff] & 0x0FF)] << 2) | (DecodeTable[Int(src[srcOff + 1] & 0x0FF)] >> 4) + if (len > 2) { + dst[dstOff + 1] = ((DecodeTable[Int(src[srcOff + 1] & 0x0FF)] << 4) & 0xF0) | (DecodeTable[Int(src[srcOff + 2] & 0x0FF)] >> 2) + if (len > 3) { + dst[dstOff + 2] = ((DecodeTable[Int(src[srcOff + 2] & 0x0FF)] << 6) & 0xC0) | (DecodeTable[Int(src[srcOff + 3] & 0x0FF)]) + } + } + } +} diff --git a/lib/swift/Sources/TJSONProtocol.swift b/lib/swift/Sources/TJSONProtocol.swift new file mode 100644 index 00000000000..b1e41c74559 --- /dev/null +++ b/lib/swift/Sources/TJSONProtocol.swift @@ -0,0 +1,1160 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import Foundation + +/** + JSON protocol implementation for thrift. + This is a full-feature protocol supporting Write and Read. + Please see the C++ class header for a detailed description of the protocol's wire format + Adapted from netstd C# version + */ +public class TJSONProtocol: TProtocol { + static let Version: Int = 1 + + public var transport: TTransport + + // Temporary buffer used by several methods + private var tempBuffer: [UInt8] = [0,0,0,0] + private var contextStack: JSONContextStack = JSONContextStack() + private var currentContext: JSONBaseContext? + private var context: JSONBaseContext { + get throws { + if (currentContext != nil) { + return currentContext! + } + throw TProtocolError(error: .depthLimit, message: "Current context is nil") + } + } + + /** + Reader that manages a 1-byte buffer + */ + private var optionalReader: LookaheadReader? + private var reader: LookaheadReader { + get throws { + if (optionalReader != nil) { + return optionalReader! + } + throw TProtocolError(error: .depthLimit, message: "Lookahead reader is nil") + } + } + + // MARK: TJSONProtocol Constructor + public required init(on transport: TTransport) { + self.transport = transport + currentContext = JSONBaseContext(on: self) + optionalReader = LookaheadReader(on: self) + } + + // MARK: TJSONProtocol helpers + /** + Push a new JSON context onto the context stack + */ + func pushContext(_ context: JSONBaseContext) { + contextStack.push(context) + currentContext = context + } + + /** + Pop current JSON context from the context stack + */ + func popContext() { + _ = contextStack.pop() + currentContext = contextStack.isEmpty() ? JSONBaseContext(on: self) : contextStack.peek() + } + + /** + Reset context stack to pristine state. Allows for reusal of the protocol even in cases where the protocol instance + was in an undefined state due to dangling/stale/obsolete contexts + */ + func resetContext() { + contextStack.clear() + currentContext = JSONBaseContext(on: self) + } + + /** + Read a byte that must match bytes[0]; otherwise an exception is thrown. + - bytes: Input bytes array + */ + func readJsonSyntaxChar(bytes: [UInt8]) throws { + let ch: UInt8 = try reader.read() + if (ch != bytes[0]) { + throw TProtocolError(error: .invalidData, message: "Unexpected character: \(ch.asCharacter())") + } + } + + /** + Write the bytes in array buffer as a JSON characters, escaping as needed + */ + func writeJsonString(bytes: [UInt8]) throws { + try context.writeConditionalDelimiter() + try transport.writeJSONQuote() + + let len: Int = bytes.count + for i in 0..= 0x30) { + if (bytes[i] == TJSONProtocolConstants.Backslash[0]) { + try transport.writeJSONBackslash() + try transport.writeJSONBackslash() + } else { + try transport.write(data: Data(bytes: [bytes[i]], count: 1)) + } + } else { + tempBuffer[0] = TJSONProtocolConstants.JsonCharTable[Int(bytes[i])] + if (tempBuffer[0] == 1) { + try transport.write(data: Data(bytes: [bytes[i]], count: 1)) + } else if (tempBuffer[0] > 1) { + try transport.writeJSONBackslash() + try transport.write(data: Data(bytes: [tempBuffer[0]], count: 1)) + } else { + try transport.writeJSONEscSequences() + tempBuffer[0] = (bytes[i] >> 4).toHexChar() + tempBuffer[1] = (bytes[i]).toHexChar() + try transport.write(data: Data(bytes: [tempBuffer[0], tempBuffer[1]], count:2)) + } + } + } + try transport.writeJSONQuote() + } + + /** + Write out number as a JSON value. If the context dicates so, it will be wrapped in quotes to output as a JSON string. + */ + func writeJsonInteger(num: Int64) throws { + try context.writeConditionalDelimiter() + let str: String = String(num) + + let escapeNum: Bool = try context.escapeNumbers() + if (escapeNum) { + try transport.write(data: Data(bytes: TJSONProtocolConstants.Quote, count: TJSONProtocolConstants.Quote.count)) + } + + let strData: Data = str.data(using: .utf8)! + try transport.write(data: strData) + + if (escapeNum) { + try transport.write(data: Data(bytes: TJSONProtocolConstants.Quote, count: TJSONProtocolConstants.Quote.count)) + } + } + + /** + Write out a double as a JSON value. If it is Nan or Infinity or if the context dictates escaping, write out as JSON string. + */ + func writeJsonDouble(num: Double) throws { + try context.writeConditionalDelimiter() + let str = String(num) + var special = false + + switch(str[0]) { + case "N", "I": + // Nan or Infinity + special = true + case "-": + if (str[1] == "I") { + // -Infinity + special = true + } + default: + special = false + } + + let escapeNum = try context.escapeNumbers() + let escapeNumOrSpecial = special || escapeNum + if (escapeNumOrSpecial) { + try transport.writeJSONQuote() + } + + if let strData = str.data(using: .utf8) { + try transport.write(data: strData) + } else { + throw TProtocolError(error: .invalidData, message: "Cannot convert double number to data bytes") + } + + if (escapeNumOrSpecial) { + try transport.writeJSONQuote() + } + } + + /** + Write out contents of byte array as a JSON string with base-64 encoded data + */ + func writeJsonBase64(bytes: [UInt8]) throws { + try context.writeConditionalDelimiter() + try transport.writeJSONQuote() + + var len = bytes.count + var off = 0 + while (len >= 3) { + // Encode 3 bytes at a time + TBase64Utils.encode(src: bytes, srcOff: off, len: 3, dst: &tempBuffer, dstOff: 0) + try transport.write(data: Data(bytes: tempBuffer, count: 4)) + off += 3 + len -= 3 + } + + if (len > 0) { + // Encode remainder + TBase64Utils.encode(src: bytes, srcOff: off, len: len, dst: &tempBuffer, dstOff: 0) + try transport.write(data: Data(bytes: tempBuffer, count: len + 1)) + } + + try transport.writeJSONQuote() + } + + func writeJsonObjectStart() throws { + try context.writeConditionalDelimiter() + try transport.writeJSONLeftBrace() + pushContext(JSONPairContext(on: self)) + } + + func writeJsonObjectEnd() throws { + popContext() + try transport.writeJSONRightBrace() + } + + func writeJsonArrayStart() throws { + try context.writeConditionalDelimiter() + try transport.writeJSONLeftBracket() + pushContext(JSONListContext(on: self)) + } + + func writeJsonArrayEnd() throws { + popContext() + try transport.writeJSONRightBracket() + } + + /** + Read in a JSON string, unescaping as appropriate. Skip reading from the context if skipContext is true. + */ + func readJsonString(skipContext: Bool) throws -> [UInt8] { + var codeunits: [Character] = [] + + if (!skipContext) { + try context.readConditionalDelimiter() + } + try readJsonSyntaxChar(bytes: TJSONProtocolConstants.Quote) + + var dataBuffer = Data() + while (true) { + var ch: UInt8 = try reader.read() + if (ch == TJSONProtocolConstants.Quote[0]) { + break + } + + // Escaped? + if (ch != TJSONProtocolConstants.EscSequences[0]) { + dataBuffer.append([ch], count: 1) + continue + } + + // distinguish between \uXXXX and \? + ch = try reader.read() + if (ch != TJSONProtocolConstants.EscSequences[1]) { // control chars like \n + guard let off: Int = TJSONProtocolConstants.EscSequences.firstIndex(of: ch) else { + throw TProtocolError(error: .invalidData, message: "Expected control char") + } + ch = TJSONProtocolConstants.EscapeCharValues[off] + dataBuffer.append([ch], count: 1) + continue + } + + // It's \uXXXX + let tempData: Data = try transport.readAll(size: 4) + let wch = Int16( ((tempData[0]).toHexChar() << 12) + + ((tempData[1]).toHexChar() << 8) + + ((tempData[2]).toHexChar() << 4) + + ((tempData[3]).toHexChar()) ) + guard let wchScalar = UnicodeScalar(Int(wch)) else { + throw TProtocolError(error: .invalidData, message: "Expected Unicode character") + } + + if (try wch.magnitude.isHighSurrogate()) { + if (codeunits.count > 0) { + throw TProtocolError(error: .invalidData, message: "Exptected low surrogate char") + } + codeunits.append(Character(wchScalar)) + } else if (try wch.magnitude.isLowSurrogate()) { + if (codeunits.count == 0) { + throw TProtocolError(error: .invalidData, message: "Exptected high surrogate char") + } + codeunits.append(Character(wchScalar)) + guard let codeunitsData = String(codeunits).data(using: .utf8) else { + throw TProtocolError(error: .invalidData, message: "Codeunits cannot be converted to string bytes") + } + dataBuffer.append(codeunitsData) + codeunits.removeAll() + } else { + let bytesArray: [UInt8] = withUnsafeBytes(of: wch.bigEndian, Array.init) + dataBuffer.append(Data(bytes: bytesArray, count: bytesArray.count)) + } + } + + if (codeunits.count > 0) { + throw TProtocolError(error: .invalidData, message: "Expected low surrogate char") + } + + let bytesResult: [UInt8] = dataBuffer.map { $0 } + return bytesResult + } + + /** + Read in a sequence of characters that are all valid in JSON numbers. Does not do a complete regex check + to validate that this is actually a number. + */ + func readJsonNumericChars() throws -> String { + var str = "" + while(true) { + // TODO: Workaround for primitive types with TJSONProtocol: think - how to rewrite into more easy from without exception + do { + let ch: UInt8 = try reader.peek() + if (!ch.isJsonNumeric()) { + break + } + let c = try reader.read() + str.append(c.asCharacter()) + } catch is TTransportError { + break + } + catch let error { + throw error + } + } + return str + } + + /** + Read in a JSON number. If the context dictates, read in enclosing quotes. + */ + func readJsonInteger() throws -> Int64 { + try context.readConditionalDelimiter() + let escapeNum = try context.escapeNumbers() + if (escapeNum) { + try readJsonSyntaxChar(bytes: TJSONProtocolConstants.Quote) + } + + let str: String = try readJsonNumericChars() + if (escapeNum) { + try readJsonSyntaxChar(bytes: TJSONProtocolConstants.Quote) + } + + guard let result = Int64(str) else { throw TProtocolError(error: .invalidData, message: "Cannot convert \(str) to Int64") } + return result + } + + /** + Read in a JSON double value. Throw if the value is not wrapped in quotes when expected or if wrapped in quotes when not expected. + */ + func readJsonDouble() throws -> Double { + try context.readConditionalDelimiter() + + let escapeNum = try context.escapeNumbers() + if (try reader.peek() == TJSONProtocolConstants.Quote[0]) { + let arr: [UInt8] = try readJsonString(skipContext: true) + if let str: String = String(data: Data(arr), encoding: .utf8), + let dub = Double(str) { + if (!escapeNum && !dub.isNaN && !dub.isInfinite) { + throw TProtocolError(error: .invalidData, message: "Numeric data unexpectedly quoted") + } + return dub + } else { + throw TProtocolError(error: .invalidData, message: "Numeric data convertion to double failed") + } + } + + if (escapeNum) { + try readJsonSyntaxChar(bytes: TJSONProtocolConstants.Quote) + } + + let str: String = try readJsonNumericChars() + if let dub = Double(str) { + return dub + } else { + throw TProtocolError(error: .invalidData, message: "Numeric data convertion to double failed") + } + } + + /** + Read in a JSON string containing base-64 encoded data and decode it. + */ + func readJsonBase64() throws -> [UInt8] { + var b = try readJsonString(skipContext: false) + var len = b.count + var off = 0 + var size = 0 + + // Reduce len to ignore fill bytes + while( (len > 0) && (b[len - 1] == "=".asciiBytes()[0]) ) { + len -= 1 + } + + // Read & decode full byte triplets = 4 source bytes + while (len > 4) { + // Decode 4 bytes at a time + TBase64Utils.decode(src: b, srcOff: off, len: 4, dst: &b, dstOff: size) // Nb: decode in place + off += 4 + len -= 4 + size += 3 + } + + // Don't decode if we hit the end or got a single leftover byte + // (invalid base64 but legal for skip of reqular string exType) + if (len > 1) { + // Decode remainder + TBase64Utils.decode(src: b, srcOff: off, len: len, dst: &b, dstOff: size) // NB: decode in place + size += len - 1 + } + + let result: [UInt8] = Array(b[0.. (String, TMessageType, Int32) { + resetContext() + try readJsonArrayStart() + + let version = try readJsonInteger() + if (version != TJSONProtocol.Version) { + throw TProtocolError(error: .badVersion(expected: "\(TJSONProtocol.Version)", got: "\(version)"), message: "Bad version") + } + + let buf = try readJsonString(skipContext: false) + guard let name = String(bytes: buf, encoding: .utf8) else { + throw TProtocolError(error: .invalidData, message: "Invalid message name") + } + guard let type = TMessageType(rawValue: Int32(try readJsonInteger())) else { + throw TProtocolError(error: .invalidData, message: "Invalid message type") + } + let seqID = try readJsonInteger() + + return (name, type, Int32(seqID)) + } + + public func readMessageEnd() throws { + try readJsonArrayEnd() + } + + public func readStructBegin() throws -> String { + try readJsonObjectStart() + return "" + } + + public func readStructEnd() throws { + try readJsonObjectEnd() + } + + public func readFieldBegin() throws -> (String, TType, Int32) { + let ch = try reader.peek() + if (ch == TJSONProtocolConstants.RightBrace[0]) { + return ("", TType.stop, 0) + } + + let fieldID = try readJsonInteger() + try readJsonObjectStart() + let fieldName: [UInt8] = try readJsonString(skipContext: false) + let fieldType: TType = try TType.getTypeIdForTypeName(fieldName) + guard let name = String(bytes: fieldName, encoding: .utf8) else { + throw TProtocolError(error: .invalidData, message: "Invalid field name") + } + return (name, fieldType, Int32(fieldID)) + } + + public func readFieldEnd() throws { + try readJsonObjectEnd() + } + + public func readMapBegin() throws -> (TType, TType, Int32) { + try readJsonArrayStart() + let keyTypeName = try readJsonString(skipContext: false) + let keyType = try TType.getTypeIdForTypeName(keyTypeName) + + let valueTypeName = try readJsonString(skipContext: false) + let valueType = try TType.getTypeIdForTypeName(valueTypeName) + + let count = try readJsonInteger() + + try checkReadBytesAvailable(keyType: keyType, valueType: valueType, count: Int32(count)) + try readJsonObjectStart() + return (keyType, valueType, Int32(count)) + } + + public func readMapEnd() throws { + try readJsonObjectEnd() + try readJsonArrayEnd() + } + + public func readSetBegin() throws -> (TType, Int32) { + try readJsonArrayStart() + + let elementTypeName = try readJsonString(skipContext: false) + let elementType = try TType.getTypeIdForTypeName(elementTypeName) + + let count = try readJsonInteger() + + try checkReadBytesAvailable(elementType, Int32(count)) + + return (elementType, Int32(count)) + } + + public func readSetEnd() throws { + try readJsonArrayEnd() + } + + public func readListBegin() throws -> (TType, Int32) { + try readJsonArrayStart() + + let elementTypeName = try readJsonString(skipContext: false) + let elementType = try TType.getTypeIdForTypeName(elementTypeName) + + let count = try readJsonInteger() + + try checkReadBytesAvailable(elementType, Int32(count)) + return (elementType, Int32(count)) + } + + public func readListEnd() throws { + try readJsonArrayEnd() + } + + public func read() throws -> String { + let buf = try readJsonString(skipContext: false) + guard let str = String(bytes: buf, encoding: .utf8) else { + throw TProtocolError(error: .invalidData, message: "Cannot convert bytes to string") + } + return str + } + + public func read() throws -> Bool { + let intValue = try readJsonInteger() + return intValue == 0 ? false : true + } + + public func read() throws -> UInt8 { + return UInt8(try readJsonInteger()) + } + + public func read() throws -> Int8 { + return Int8(try readJsonInteger()) + } + + public func read() throws -> Int16 { + return Int16(try readJsonInteger()) + } + + public func read() throws -> Int32 { + return Int32(try readJsonInteger()) + } + + public func read() throws -> Int64 { + return try readJsonInteger() + } + + public func read() throws -> Double { + return try readJsonDouble() + } + + public func read() throws -> Data { + let base64Bytes = try readJsonBase64() + return Data(bytes: base64Bytes, count: base64Bytes.count) + } + + public func read() throws -> UUID { + let buf = try readJsonString(skipContext: false) + guard let id = String(bytes: buf, encoding: .utf8) else { + throw TProtocolError(error: .invalidData, message: "Cannot convert bytes to string") + } + guard let uuid = UUID(uuidString: id) else { + throw TProtocolError(error: .invalidData, message: "Cannot convert string to uuid") + } + return uuid + } + + public func writeMessageBegin(name: String, type messageType: TMessageType, sequenceID: Int32) throws { + resetContext() + try writeJsonArrayStart() + try writeJsonInteger(num: Int64(TJSONProtocol.Version)) + + guard let nameData = name.data(using: .utf8) else { + throw TProtocolError(error: .invalidData, message: "Cannot convert message name to bytes data") + } + try writeJsonString(bytes: [UInt8] (nameData)) + + try writeJsonInteger(num: Int64(messageType.rawValue)) + try writeJsonInteger(num: Int64(sequenceID)) + } + + public func writeMessageEnd() throws { + try writeJsonArrayEnd() + } + + public func writeStructBegin(name: String) throws { + try writeJsonObjectStart() + } + + public func writeStructEnd() throws { + try writeJsonObjectEnd() + } + + public func writeFieldBegin(name: String, type fieldType: TType, fieldID: Int32) throws { + try writeJsonInteger(num: Int64(fieldID)) + + try writeJsonObjectStart() + + let fieldTypeName = try fieldType.getTypeNameForTypeId() + try writeJsonString(bytes: fieldTypeName) + } + + public func writeFieldStop() throws { + // Nop + } + + public func writeFieldEnd() throws { + try writeJsonObjectEnd() + } + + public func writeMapBegin(keyType: TType, valueType: TType, size: Int32) throws { + try writeJsonArrayStart() + + let mapKeyTypeName = try keyType.getTypeNameForTypeId() + try writeJsonString(bytes: mapKeyTypeName) + + let mapValueTypeName = try valueType.getTypeNameForTypeId() + try writeJsonString(bytes: mapValueTypeName) + + try writeJsonInteger(num: Int64(size)) + + try writeJsonObjectStart() + } + + public func writeMapEnd() throws { + try writeJsonObjectEnd() + try writeJsonArrayEnd() + } + + public func writeSetBegin(elementType: TType, size: Int32) throws { + try writeJsonArrayStart() + + let elementTypeName = try elementType.getTypeNameForTypeId() + try writeJsonString(bytes: elementTypeName) + + try writeJsonInteger(num: Int64(size)) + } + + public func writeSetEnd() throws { + try writeJsonArrayEnd() + } + + public func writeListBegin(elementType: TType, size: Int32) throws { + try writeJsonArrayStart() + + let elementTypeName = try elementType.getTypeNameForTypeId() + try writeJsonString(bytes: elementTypeName) + + try writeJsonInteger(num: Int64(size)) + } + + public func writeListEnd() throws { + try writeJsonArrayEnd() + } + + public func write(_ value: String) throws { + guard let strData = value.data(using: .utf8) else { + throw TProtocolError(error: .invalidData, message: "Cannot convert string value to bytes data") + } + + try writeJsonString(bytes: [UInt8](strData)) + } + + public func write(_ value: Bool) throws { + try writeJsonInteger(num: value ? 1 : 0) + } + + public func write(_ value: UInt8) throws { + try writeJsonInteger(num: Int64(value)) + } + + public func write(_ value: Int8) throws { + try writeJsonInteger(num: Int64(value)) + } + + public func write(_ value: Int16) throws { + try writeJsonInteger(num: Int64(value)) + } + + public func write(_ value: Int32) throws { + try writeJsonInteger(num: Int64(value)) + } + + public func write(_ value: Int64) throws { + try writeJsonInteger(num: value) + } + + public func write(_ value: Double) throws { + try writeJsonDouble(num: value) + } + + public func write(_ value: Data) throws { + try writeJsonBase64(bytes: [UInt8](value)) + } + + public func write(_ value: UUID) throws { + guard let strData = value.uuidString.data(using: .utf8) else { + throw TProtocolError(error: .invalidData, message: "Cannot convert UUID value to bytes data") + } + + try writeJsonString(bytes: [UInt8](strData)) + } + + // MARK: - Private functions + private func checkReadBytesAvailable(keyType: TType, valueType: TType, count: Int32) throws { + let elmSize = try getMinSerializedSize(keyType) + getMinSerializedSize(valueType) + _ = count * elmSize + // TODO: implement checkReadBytesAvailable in TTransport + // transport.checkReadBytesAvailable(size: count * elmSize) + } + + private func checkReadBytesAvailable(_ elementType: TType, _ count: Int32) throws { + let elmSize = try getMinSerializedSize(elementType) + _ = count * elmSize + // TODO: implement checkReadBytesAvailable in TTransport + // transport.checkReadBytesAvailable(size: count * elmSize) + } + + private func getMinSerializedSize(_ type: TType) throws -> Int32 { + switch(type) { + case .stop, .void: return 0 + case .bool, .i8, .i16, .i32, .i64, .double: return 1 + case .string, .struct, .map, .set, .list: return 2 // empty object + default: + throw TProtocolError(error: .invalidData, message: "Invalid TType") + } + } + + // MARK: - TJSONProtocol inner classes + /* + Base class for tracking JSON contexts that may require + inserting/reading additional JSON syntax characters + This base context does nothing + */ + class JSONBaseContext { + var proto: TJSONProtocol + + init(on proto: TJSONProtocol) { + self.proto = proto + } + + func writeConditionalDelimiter() throws { + } + + func readConditionalDelimiter() throws { + } + + func escapeNumbers() -> Bool { + return false + } + } + + /* + Context for JSON lists. will insert/read commas before each item except for the first one + */ + class JSONListContext: JSONBaseContext { + private var first: Bool = true + + override init(on proto: TJSONProtocol) { + super.init(on: proto) + } + + override func writeConditionalDelimiter() throws { + if (first) { + first = false + } else { + try proto.transport.writeJSONComma() + } + } + + override func readConditionalDelimiter() throws { + if (first) { + first = false + } else { + try proto.readJsonSyntaxChar(bytes: TJSONProtocolConstants.Comma) + } + } + } + + /* + Context for JSON records. Will insert/read colons before the value portion of each record pair, + and commas before each key except the first. In addition, will indicate that numbers in the key position + need to be escaped in quotes (since JSON keys must be strings). + */ + class JSONPairContext : JSONBaseContext { + private var colon: Bool = true + private var first: Bool = true + + override init(on proto: TJSONProtocol) { + super.init(on: proto) + } + + override func writeConditionalDelimiter() throws { + if (first) { + first = false + colon = true + } else { + if (colon) { + try proto.transport.writeJSONColon() + } else { + try proto.transport.writeJSONComma() + } + self.colon = !self.colon + } + } + + override func readConditionalDelimiter() throws { + if (first) { + first = false + colon = true + } else { + try proto.readJsonSyntaxChar(bytes: colon ? TJSONProtocolConstants.Colon : TJSONProtocolConstants.Comma) + self.colon = !self.colon + } + } + + override func escapeNumbers() -> Bool { + return colon + } + } + + class JSONContextStack { + private var items: [JSONBaseContext] = [] + + func peek() -> JSONBaseContext { + guard let topElement = items.first else { fatalError("This stack is empty.") } + return topElement + } + + func pop() -> JSONBaseContext { + return items.removeFirst() + } + + func push(_ element: JSONBaseContext) { + items.insert(element, at: 0) + } + + func clear() { + items.removeAll() + } + + func isEmpty() -> Bool { + return items.count == 0 + } + } + + class LookaheadReader { + private var byteData: UInt8? + private var hasData: Bool = false + var proto: TJSONProtocol + + init(on proto: TJSONProtocol) { + self.proto = proto + } + + func read() throws -> UInt8 { + if (hasData) { + hasData = false + } else { + let data = try proto.transport.readAll(size: 1) + byteData = Array(data)[0] + } + if let byte = byteData { + return byte + } + throw TProtocolError(error: .invalidData, message: "Reader does not have data to read") + } + + func peek() throws -> UInt8 { + if (!hasData) { + let data = try proto.transport.readAll(size: 1) + byteData = Array(data)[0] + hasData = true + } + if let byte = byteData { + return byte + } + throw TProtocolError(error: .invalidData, message: "Reader does not have data to peek") + } + } +} + +// MARK: TJSONProtocolConstants +/** + TJSONProtocol Constants properties/fields + */ +public struct TJSONProtocolConstants { + public static let Comma: [UInt8] = ",".asciiBytes() + public static let Colon: [UInt8] = ":".asciiBytes() + public static let LeftBrace: [UInt8] = "{".asciiBytes() + public static let RightBrace: [UInt8] = "}".asciiBytes() + public static let LeftBracket: [UInt8] = "[".asciiBytes() + public static let RightBracket: [UInt8] = "]".asciiBytes() + public static let Quote: [UInt8] = "\"".asciiBytes() + public static let Backslash: [UInt8] = "\\".asciiBytes() + + public static let JsonCharTable: [UInt8] = [ + 0, 0, 0, 0, 0, 0, 0, 0, b, t, n, 0, f, r, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, qt, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + ] + + // \b -> \u{0008} + // \f -> \u{000C} + public static let EscapeChars: [Character] = ["\"", "\\", "/", "\u{0008}", "\u{000C}", "\n", "\r", "\t" ] + public static let EscapeCharValues: [UInt8] = "\"\\/\u{0008}\u{000C}\n\r\t".asciiBytes() + public static let EscSequences: [UInt8] = "\\u00".asciiBytes() + + public struct TypeNames { + public static let NameBool: [UInt8] = "tf".asciiBytes() + public static let NameByte: [UInt8] = "i8".asciiBytes() + public static let NameI16: [UInt8] = "i16".asciiBytes() + public static let NameI32: [UInt8] = "i32".asciiBytes() + public static let NameI64: [UInt8] = "i64".asciiBytes() + public static let NameDouble: [UInt8] = "dbl".asciiBytes() + public static let NameStruct: [UInt8] = "rec".asciiBytes() + public static let NameString: [UInt8] = "str".asciiBytes() + public static let NameMap: [UInt8] = "map".asciiBytes() + public static let NameList: [UInt8] = "lst".asciiBytes() + public static let NameSet: [UInt8] = "set".asciiBytes() + } + + // MARK: private fields helpers + private static let b: UInt8 = "b".asciiBytes()[0] + private static let t: UInt8 = "t".asciiBytes()[0] + private static let n: UInt8 = "n".asciiBytes()[0] + private static let f: UInt8 = "f".asciiBytes()[0] + private static let r: UInt8 = "r".asciiBytes()[0] + private static let qt: UInt8 = "\"".asciiBytes()[0] +} + +// MARK: Extensions +extension String { + public func asciiBytes() -> [UInt8] { + var result: [UInt8] = [] + for char in self { + result.append(char.asciiValue!) + } + return result + } + + subscript(offset: Int) -> Character { + self[index(startIndex, offsetBy: offset)] + } +} + +extension Character { + public func asciiByte() -> UInt8 { + return self.asciiValue! + } +} + +extension UInt8 { + /** + Convert a byte containing a hex value to its corresponding hex character + */ + public func toHexChar() -> UInt8 { + var value = self & 0x0F + if (value < 10) { + let zeroChar = Character("0").asciiValue! + return value + zeroChar + } + value -= 10 + let aChar = Character("a").asciiValue! + return value + aChar + } + + public func isJsonNumeric() -> Bool { + let numberBytes = "+-.0123456789Ee".asciiBytes() + if (numberBytes.contains(self)) { + return true + } + return false + } + + public func asCharacter() -> Character { + let scalar = UnicodeScalar(self) + return Character(scalar) + } +} + +extension UInt16 { + public func isHighSurrogate() throws -> Bool { + let wch = self + if let d800 = UInt16("D800", radix: 16), + let dbff = UInt16("DBFF", radix: 16) { + return wch >= d800 && wch <= dbff + } else { + throw TProtocolError(error: .invalidData, message: "isHighSurrogate failed") + } + } + + public func isLowSurrogate() throws -> Bool{ + let wch = self + if let dc00 = UInt16("DC00", radix: 16), + let dfff = UInt16("DFFF", radix: 16) { + return wch >= dc00 && wch <= dfff + } else { + throw TProtocolError(error: .invalidData, message: "isLowSurrogate failed") + } + } +} + +extension TType { + public static func getTypeIdForTypeName(_ name: [UInt8]) throws -> TType { + var result = TType.stop + if (name.count > 1) { + switch(name[0]) { + case "t".asciiBytes()[0]: + result = TType.bool + case "i".asciiBytes()[0]: + switch(name[1]) { + case "8".asciiBytes()[0]: + result = TType.i8 + case "1".asciiBytes()[0]: + result = TType.i16 + case "3".asciiBytes()[0]: + result = TType.i32 + case "6".asciiBytes()[0]: + result = TType.i64 + default: + result = TType.stop + } + case "d".asciiBytes()[0]: + result = TType.double + case "l".asciiBytes()[0]: + result = TType.list + case "m".asciiBytes()[0]: + result = TType.map + case "r".asciiBytes()[0]: + result = TType.struct + case "s".asciiBytes()[0]: + if (name[1] == "t".asciiBytes()[0]) { + result = TType.string + } else if (name[1] == "e".asciiBytes()[0]) { + result = TType.set + } + default: + result = TType.stop + } + } + + if (result == TType.stop) { + throw TProtocolError(error: .notImplemented, message: "Unrecognized exType") + } + + return result + } + + public func getTypeNameForTypeId() throws -> [UInt8] { + let typeId = self + switch(typeId) { + case .bool: + return TJSONProtocolConstants.TypeNames.NameBool + case .i8: + return TJSONProtocolConstants.TypeNames.NameByte + case .i16: + return TJSONProtocolConstants.TypeNames.NameI16 + case .i32: + return TJSONProtocolConstants.TypeNames.NameI32 + case .i64: + return TJSONProtocolConstants.TypeNames.NameI64 + case .double: + return TJSONProtocolConstants.TypeNames.NameDouble + case .string: + return TJSONProtocolConstants.TypeNames.NameString + case .struct: + return TJSONProtocolConstants.TypeNames.NameStruct + case .map: + return TJSONProtocolConstants.TypeNames.NameMap + case .set: + return TJSONProtocolConstants.TypeNames.NameSet + case .list: + return TJSONProtocolConstants.TypeNames.NameList + default: + throw TProtocolError(error: .invalidData, message: "TypeId: \(typeId) does not have mapping Name") + } + } +} + +extension TTransport { + func writeJSONColon() throws { + try self.write(data: Data(bytes: TJSONProtocolConstants.Colon, count: TJSONProtocolConstants.Colon.count)) + } + + func writeJSONComma() throws { + try self.write(data: Data(bytes: TJSONProtocolConstants.Comma, count: TJSONProtocolConstants.Comma.count)) + } + + func writeJSONQuote() throws { + try self.write(data: Data(bytes: TJSONProtocolConstants.Quote, count: TJSONProtocolConstants.Quote.count)) + } + + func writeJSONBackslash() throws { + try self.write(data: Data(bytes: TJSONProtocolConstants.Backslash, count: TJSONProtocolConstants.Backslash.count)) + } + + func writeJSONEscSequences() throws { + try self.write(data: Data(bytes: TJSONProtocolConstants.EscSequences, count: TJSONProtocolConstants.EscSequences.count)) + } + + func writeJSONLeftBrace() throws { + try self.write(data: Data(bytes: TJSONProtocolConstants.LeftBrace, count: TJSONProtocolConstants.LeftBrace.count)) + } + + func writeJSONRightBrace() throws { + try self.write(data: Data(bytes: TJSONProtocolConstants.RightBrace, count: TJSONProtocolConstants.RightBrace.count)) + } + + func writeJSONLeftBracket() throws { + try self.write(data: Data(bytes: TJSONProtocolConstants.LeftBracket, count: TJSONProtocolConstants.LeftBracket.count)) + } + + func writeJSONRightBracket() throws { + try self.write(data: Data(bytes: TJSONProtocolConstants.RightBracket, count: TJSONProtocolConstants.RightBracket.count)) + } +} diff --git a/lib/swift/Tests/ThriftTests/TJSONProtocolTests.swift b/lib/swift/Tests/ThriftTests/TJSONProtocolTests.swift new file mode 100644 index 00000000000..1017244f8f0 --- /dev/null +++ b/lib/swift/Tests/ThriftTests/TJSONProtocolTests.swift @@ -0,0 +1,212 @@ +// +// File.swift +// +// Created by Khodabakhsh, Hojjat on 5/18/23. +// + +import XCTest +import Foundation +@testable import Thrift + +class TJSONProtocolTests: XCTestCase { + var transport: TMemoryBufferTransport = TMemoryBufferTransport(flushHandler: { + $0.reset(readBuffer: $1) + }) + + var proto: TJSONProtocol! + + override func setUp() { + super.setUp() + proto = TJSONProtocol(on: transport) + transport.reset() + } + + override func tearDown() { + super.tearDown() + transport.reset() + } + + func testUInt8WriteRead() { + let writeVal: UInt8 = 250 + try? proto.write(writeVal) + try? transport.flush() + + let readVal: UInt8 = (try? proto.read()) ?? 0 + XCTAssertEqual(writeVal, readVal, "Error with UInt8, wrote \(writeVal) but read \(readVal)") + } + + func testInt8WriteRead() { + let writeVal: Int8 = -120 + try? proto.write(writeVal) + try? transport.flush() + + let readVal: Int8 = (try? proto.read()) ?? 0 + XCTAssertEqual(writeVal, readVal, "Error with UInt8, wrote \(writeVal) but read \(readVal)") + } + + func testInt16WriteRead() { + let writeVal: Int16 = 12312 + try? proto.write(writeVal) + try? transport.flush() + let readVal: Int16 = (try? proto.read()) ?? 0 + XCTAssertEqual(writeVal, readVal, "Error with Int16, wrote \(writeVal) but read \(readVal)") + } + + func testInt32WriteRead() { + let writeVal: Int32 = 2029234 + try? proto.write(writeVal) + try? transport.flush() + + let readVal: Int32 = (try? proto.read()) ?? 0 + XCTAssertEqual(writeVal, readVal, "Error with Int32, wrote \(writeVal) but read \(readVal)") + } + + func testInt64WriteRead() { + let writeVal: Int64 = 234234981374134 + try? proto.write(writeVal) + try? transport.flush() + + let readVal: Int64 = (try? proto.read()) ?? 0 + XCTAssertEqual(writeVal, readVal, "Error with Int64, wrote \(writeVal) but read \(readVal)") + } + + func testDoubleWriteRead() { + let writeVal: Double = 3.1415926 + try? proto.write(writeVal) + try? transport.flush() + + let readVal: Double = (try? proto.read()) ?? 0.0 + XCTAssertEqual(writeVal, readVal, "Error with Double, wrote \(writeVal) but read \(readVal)") + } + + func testBoolWriteRead() { + let writeVal: Bool = true + try? proto.write(writeVal) + try? transport.flush() + + let readVal: Bool = (try? proto.read()) ?? false + XCTAssertEqual(writeVal, readVal, "Error with Bool, wrote \(writeVal) but read \(readVal)") + } + + func testStringWriteRead() { + let writeVal: String = "Hello World" + try? proto.write(writeVal) + try? transport.flush() + + let readVal: String + do { + readVal = try proto.read() + } catch let error { + XCTAssertFalse(true, "Error reading \(error)") + return + } + + XCTAssertEqual(writeVal, readVal, "Error with String, wrote \(writeVal) but read \(readVal)") + } + + func testStringWriteRead2() { + let writeVal: String = "你好世界 means hello world!" + try? proto.write(writeVal) + try? transport.flush() + + let readVal: String + do { + print(writeVal) + readVal = try proto.read() + print(readVal) + } catch let error { + XCTAssertFalse(true, "Error reading \(error)") + return + } + + XCTAssertEqual(writeVal, readVal, "Error with String, wrote \(writeVal) but read \(readVal)") + } + + func testDataWriteRead() { + let writeVal: Data = "Data World".data(using: .utf8)! + try? proto.write(writeVal) + try? transport.flush() + + let readVal: Data = (try? proto.read()) ?? "Goodbye World".data(using: .utf8)! + XCTAssertEqual(writeVal, readVal, "Error with Data, wrote \(writeVal) but read \(readVal)") + } + + func testUUIDWriteRead() { + let writeVal: UUID = UUID() + try? proto.write(writeVal) + try? transport.flush() + + let newUuid = UUID() + let readVal: UUID = (try? proto.read()) ?? newUuid + XCTAssertEqual(writeVal, readVal, "Error with Data, wrote \(writeVal) but read \(readVal)") + } + + func testStructWriteRead() { + let msg = "Test Protocol Error" + let writeVal = TApplicationError(error: .protocolError, message: msg) + do { + try writeVal.write(to: proto) + try? transport.flush() + } catch let error { + XCTAssertFalse(true, "Caught Error attempting to write \(error)") + } + + do { + let readVal: TApplicationError = try TApplicationError.read(from: proto) + XCTAssertEqual(readVal.error.thriftErrorCode, writeVal.error.thriftErrorCode, "Error case mismatch, expected \(readVal.error) got \(writeVal.error)") + let readValMessage = readVal.message ?? "", writeValMessage = writeVal.message ?? "" + XCTAssertEqual(readVal.message, writeVal.message, "Error message mismatch, expected \(readValMessage) got \(writeValMessage)") + } catch let error { + XCTAssertFalse(true, "Caught Error attempting to read \(error)") + } + } + + func testBase64WriteRead() { + let writeText = "!testing base64 read and write ..." + let writeData = writeText.data(using: .utf8)! + let writeVal = [UInt8](writeData) + try? proto.writeJsonBase64(bytes: writeVal) + try? transport.flush() + + var data = Data() + if let readVal = try? proto.readJsonBase64() { + data = Data(bytes: readVal, count: readVal.count) + } + let readText = String(decoding: data, as: UTF8.self) + XCTAssertEqual(readText, writeText, "Error message mismatch, expected \(readText) got \(writeText)") + } + + func testBase64WriteRead2() { + let writeText = "你好世界 means hello world!" + let writeData = writeText.data(using: .utf8)! + let writeVal = [UInt8](writeData) + try? proto.writeJsonBase64(bytes: writeVal) + try? transport.flush() + + var data = Data() + if let readVal = try? proto.readJsonBase64() { + data = Data(bytes: readVal, count: readVal.count) + } + let readText = String(decoding: data, as: UTF8.self) + XCTAssertEqual(readText, writeText, "Error message mismatch, expected \(readText) got \(writeText)") + } + + static var allTests : [(String, (TJSONProtocolTests) -> () throws -> Void)] { + return [ + ("testUInt8WriteRead", testUInt8WriteRead), + ("testInt8WriteRead", testInt8WriteRead), + ("testInt16WriteRead", testInt16WriteRead), + ("testInt32WriteRead", testInt32WriteRead), + ("testInt64WriteRead", testInt64WriteRead), + ("testDoubleWriteRead", testDoubleWriteRead), + ("testBoolWriteRead", testBoolWriteRead), + ("testStringWriteRead", testStringWriteRead), + ("testStringWriteRead2", testStringWriteRead2), + ("testDataWriteRead", testDataWriteRead), + ("testUUIDWriteRead", testUUIDWriteRead), + ("testStructWriteRead", testStructWriteRead), + ("testBase64WriteRead", testBase64WriteRead), + ("testBase64WriteRead2", testBase64WriteRead2) + ] + } +} From a2a1f535813511aa274ed328b2318cb2beb7bb08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?HojjatK=20=F0=9F=92=BE?= Date: Tue, 13 Jun 2023 10:32:56 -0700 Subject: [PATCH 070/250] Replace TJSONProtocolTests.swift file header by std ASF license header --- .../ThriftTests/TJSONProtocolTests.swift | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/swift/Tests/ThriftTests/TJSONProtocolTests.swift b/lib/swift/Tests/ThriftTests/TJSONProtocolTests.swift index 1017244f8f0..dc8b132551d 100644 --- a/lib/swift/Tests/ThriftTests/TJSONProtocolTests.swift +++ b/lib/swift/Tests/ThriftTests/TJSONProtocolTests.swift @@ -1,8 +1,21 @@ -// -// File.swift -// -// Created by Khodabakhsh, Hojjat on 5/18/23. -// +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ import XCTest import Foundation From 6e767e6635f459dfee45d45a4051b2919db9027a Mon Sep 17 00:00:00 2001 From: stiga-huang Date: Tue, 22 Nov 2022 11:17:58 +0800 Subject: [PATCH 071/250] THRIFT-5670: Fix wrong usage of GlobalOutput.perror() --- lib/cpp/src/thrift/transport/TSocket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp index d8accadc9d8..6c8a1c843d2 100644 --- a/lib/cpp/src/thrift/transport/TSocket.cpp +++ b/lib/cpp/src/thrift/transport/TSocket.cpp @@ -569,7 +569,7 @@ uint32_t TSocket::read(uint8_t* buf, uint32_t len) { throw TTransportException(TTransportException::INTERRUPTED, "Interrupted"); } } else /* ret == 0 */ { - GlobalOutput.perror("TSocket::read() THRIFT_EAGAIN (timed out) after %f ms", recvTimeout_); + GlobalOutput.printf("TSocket::read() THRIFT_EAGAIN (timed out) after %d ms", recvTimeout_); throw TTransportException(TTransportException::TIMED_OUT, "THRIFT_EAGAIN (timed out)"); } From d1d8ae29e64a2486d49025b631076789f0b9bd86 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 17 Jun 2023 22:03:28 +0200 Subject: [PATCH 072/250] THRIFT-5717 uuid sets and map keys may throw on some Haxe targets Client: hx Patch: Jens Geyer --- compiler/cpp/src/thrift/generate/t_haxe_generator.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc index 166f78e7c46..f51f801a8e1 100644 --- a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc @@ -2637,6 +2637,8 @@ string t_haxe_generator::type_name(t_type* ttype, bool in_container, bool in_ini return "StringMap< " + type_name(tval) + ">"; } break; // default to ObjectMap<> + case t_base_type::TYPE_UUID: + return "StringMap< " + type_name(tval) + ">"; // uuids are stored as strings case t_base_type::TYPE_I8: case t_base_type::TYPE_I16: case t_base_type::TYPE_I32: @@ -2663,6 +2665,8 @@ string t_haxe_generator::type_name(t_type* ttype, bool in_container, bool in_ini return "StringSet"; } break; // default to ObjectSet + case t_base_type::TYPE_UUID: + return "StringSet"; // uuids are stored as strings case t_base_type::TYPE_I8: case t_base_type::TYPE_I16: case t_base_type::TYPE_I32: From 0b14a1bb01fb8e5124ee926b39c28d025deda087 Mon Sep 17 00:00:00 2001 From: Fokko Driesprong Date: Fri, 14 Apr 2023 11:06:15 +0200 Subject: [PATCH 073/250] THRIFT-5702 Support Java 8 Client: Java Patch: Fokko Driesprong This closes #2785 --- .github/workflows/build.yml | 2 +- lib/java/gradle/sourceConfiguration.gradle | 4 ++-- .../org/apache/thrift/transport/TestTSaslTransports.java | 2 +- lib/kotlin/build.gradle.kts | 6 +++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3d98b06d4d..542e768153f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -435,7 +435,7 @@ jobs: with: distribution: temurin # here we intentionally use an older version so that we also verify Java 17 compiles to it - java-version: 11 + java-version: 8 cache: "gradle" - name: Install openssl and certificates (for SSL tests) diff --git a/lib/java/gradle/sourceConfiguration.gradle b/lib/java/gradle/sourceConfiguration.gradle index e3e143acd99..30f72ccbb24 100644 --- a/lib/java/gradle/sourceConfiguration.gradle +++ b/lib/java/gradle/sourceConfiguration.gradle @@ -39,8 +39,8 @@ tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' options.debug = true options.deprecation = true - // the following is to build with Java 11 specifications, even when building with later JDK - options.release = 11 + // the following is to build with Java 8 specifications, even when building with later JDK + options.release = 8 options.compilerArgs += [ '-Werror', '-Xlint:deprecation', diff --git a/lib/java/src/test/java/org/apache/thrift/transport/TestTSaslTransports.java b/lib/java/src/test/java/org/apache/thrift/transport/TestTSaslTransports.java index d4f8fffbba8..224da216daa 100644 --- a/lib/java/src/test/java/org/apache/thrift/transport/TestTSaslTransports.java +++ b/lib/java/src/test/java/org/apache/thrift/transport/TestTSaslTransports.java @@ -492,7 +492,7 @@ public String[] getMechanismNames(Map props) { public static class SaslAnonymousProvider extends java.security.Provider { public SaslAnonymousProvider() { - super("ThriftSaslAnonymous", "1.0", "Thrift Anonymous SASL provider"); + super("ThriftSaslAnonymous", 1.0, "Thrift Anonymous SASL provider"); put("SaslClientFactory.ANONYMOUS", SaslAnonymousFactory.class.getName()); put("SaslServerFactory.ANONYMOUS", SaslAnonymousFactory.class.getName()); } diff --git a/lib/kotlin/build.gradle.kts b/lib/kotlin/build.gradle.kts index 0ec88598d9d..cd52e7fce8b 100644 --- a/lib/kotlin/build.gradle.kts +++ b/lib/kotlin/build.gradle.kts @@ -36,10 +36,14 @@ dependencies { kotlin { jvmToolchain { - (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11)) + (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8)) } } +tasks.withType { + kotlinOptions.jvmTarget = "1.8" +} + tasks { if (JavaVersion.current().isJava11Compatible) { ktfmt { From d665e284df49e2032c151f55646e8ae531e9f3ce Mon Sep 17 00:00:00 2001 From: stiga-huang Date: Fri, 16 Jun 2023 22:53:43 +0800 Subject: [PATCH 074/250] THRIFT-5716: Fix uint32_t overflow in TMemoryBuffer --- lib/cpp/src/thrift/transport/TBufferTransports.cpp | 6 +++--- lib/cpp/test/TMemoryBufferTest.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.cpp b/lib/cpp/src/thrift/transport/TBufferTransports.cpp index efca5bd01b4..f7cf8f03932 100644 --- a/lib/cpp/src/thrift/transport/TBufferTransports.cpp +++ b/lib/cpp/src/thrift/transport/TBufferTransports.cpp @@ -363,9 +363,9 @@ void TMemoryBuffer::ensureCanWrite(uint32_t len) { throw TTransportException("Insufficient space in external MemoryBuffer"); } - // Grow the buffer as necessary. - const uint32_t current_used = bufferSize_ - avail; - const uint32_t required_buffer_size = len + current_used; + // Grow the buffer as necessary. Use uint64_t to avoid overflow. + const uint64_t current_used = bufferSize_ - avail; + const uint64_t required_buffer_size = len + current_used; if (required_buffer_size > maxBufferSize_) { throw TTransportException(TTransportException::BAD_ARGS, "Internal buffer size overflow when requesting a buffer of size " + std::to_string(required_buffer_size)); diff --git a/lib/cpp/test/TMemoryBufferTest.cpp b/lib/cpp/test/TMemoryBufferTest.cpp index 0ae4dc9ad96..2f1aea69411 100644 --- a/lib/cpp/test/TMemoryBufferTest.cpp +++ b/lib/cpp/test/TMemoryBufferTest.cpp @@ -385,6 +385,14 @@ BOOST_AUTO_TEST_CASE(test_maximum_buffer_size) BOOST_CHECK_THROW(buf.write(&small_buff[0], 1), TTransportException); } +BOOST_AUTO_TEST_CASE(test_buffer_overflow) +{ + TMemoryBuffer buf; + std::vector small_buff(1); + buf.write(&small_buff[0], 1); + BOOST_CHECK_THROW(buf.getWritePtr(std::numeric_limits::max()), TTransportException); +} + BOOST_AUTO_TEST_CASE(test_memory_buffer_to_get_sizeof_objects) { // This is a demonstration of how to use TMemoryBuffer to determine From 5582f31f504e2be6dc13a901eb52dc37f35e90e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 May 2023 01:36:02 +0000 Subject: [PATCH 075/250] Bump com.ncorti.ktfmt.gradle from 0.8.0 to 0.12.0 in /lib/kotlin Bumps com.ncorti.ktfmt.gradle from 0.8.0 to 0.12.0. --- updated-dependencies: - dependency-name: com.ncorti.ktfmt.gradle dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- lib/kotlin/settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/settings.gradle.kts b/lib/kotlin/settings.gradle.kts index 99ceaf00af1..342fc3b1d5b 100644 --- a/lib/kotlin/settings.gradle.kts +++ b/lib/kotlin/settings.gradle.kts @@ -19,7 +19,7 @@ pluginManagement { plugins { kotlin("jvm") version "1.8.21" - id("com.ncorti.ktfmt.gradle") version "0.8.0" + id("com.ncorti.ktfmt.gradle") version "0.12.0" } } From 669532189f6a7155f3b7740928788080010effa1 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Wed, 21 Jun 2023 23:01:49 +0200 Subject: [PATCH 076/250] bumping certain JS modules --- package-lock.json | 3277 ++++++++++++++++++++++++++++----------------- package.json | 4 +- 2 files changed, 2018 insertions(+), 1263 deletions(-) diff --git a/package-lock.json b/package-lock.json index df629653b1e..cc367e5447a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,24 +1,58 @@ { "name": "thrift", "version": "0.19.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@babel/code-frame": { + "packages": { + "": { + "name": "thrift", + "version": "0.19.0", + "license": "Apache-2.0", + "dependencies": { + "browser-or-node": "^1.2.1", + "isomorphic-ws": "^4.0.1", + "node-int64": "^0.4.0", + "q": "^1.5.0", + "ws": "^5.2.3" + }, + "devDependencies": { + "@types/node": "^10.12.6", + "@types/node-int64": "^0.4.29", + "@types/q": "^1.5.1", + "buffer-equals": "^1.0.4", + "commander": "^2.14.1", + "connect": "^3.6.6", + "eslint": "^5.7.0", + "eslint-config-prettier": "^3.1.0", + "eslint-plugin-prettier": "^3.0.0", + "html-validator-cli": "^2.0.0", + "jsdoc": "^4.0.2", + "json-int64": "^1.0.2", + "nyc": "^15.0.0", + "prettier": "^1.14.3", + "tape": "^4.9.0", + "typescript": "^3.1.6", + "utf-8-validate": "^5.0.0" + }, + "engines": { + "node": ">= 10.18.0" + } + }, + "node_modules/@babel/code-frame": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", "dev": true, - "requires": { + "dependencies": { "@babel/highlight": "^7.0.0" } }, - "@babel/core": { + "node_modules/@babel/core": { "version": "7.8.4", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.8.4.tgz", "integrity": "sha512-0LiLrB2PwrVI+a2/IEskBopDYSd8BCb3rOvH7D5tzoWd696TBEduBvuLVm4Nx6rltrLZqvI3MCalB2K2aVzQjA==", "dev": true, - "requires": { + "dependencies": { "@babel/code-frame": "^7.8.3", "@babel/generator": "^7.8.4", "@babel/helpers": "^7.8.4", @@ -35,195 +69,198 @@ "semver": "^5.4.1", "source-map": "^0.5.0" }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/@babel/code-frame": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.8.3" + } + }, + "node_modules/@babel/core/node_modules/@babel/highlight": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", + "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", + "dev": true, + "dependencies": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "node_modules/@babel/core/node_modules/debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "deprecated": "Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/@babel/core/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/@babel/core/node_modules/resolve": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", + "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", + "dev": true, "dependencies": { - "@babel/code-frame": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", - "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", - "dev": true, - "requires": { - "@babel/highlight": "^7.8.3" - } - }, - "@babel/highlight": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", - "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", - "dev": true, - "requires": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", - "js-tokens": "^4.0.0" - } - }, - "@babel/parser": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.4.tgz", - "integrity": "sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==", - "dev": true - }, - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "resolve": { - "version": "1.15.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", - "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - }, - "dependencies": { - "path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - } - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } - } - }, - "@babel/generator": { + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/@babel/core/node_modules/resolve/node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/@babel/core/node_modules/source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@babel/generator": { "version": "7.8.4", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.4.tgz", "integrity": "sha512-PwhclGdRpNAf3IxZb0YVuITPZmmrXz9zf6fH8lT4XbrmfQKr6ryBzhv593P5C6poJRciFCL/eHGW2NuGrgEyxA==", "dev": true, - "requires": { + "dependencies": { "@babel/types": "^7.8.3", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" - }, - "dependencies": { - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } } }, - "@babel/helper-function-name": { + "node_modules/@babel/generator/node_modules/source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@babel/helper-function-name": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.8.3.tgz", "integrity": "sha512-BCxgX1BC2hD/oBlIFUgOCQDOPV8nSINxCwM3o93xP4P9Fq6aV5sgv2cOOITDMtCfQ+3PvHp3l689XZvAM9QyOA==", "dev": true, - "requires": { + "dependencies": { "@babel/helper-get-function-arity": "^7.8.3", "@babel/template": "^7.8.3", "@babel/types": "^7.8.3" } }, - "@babel/helper-get-function-arity": { + "node_modules/@babel/helper-get-function-arity": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz", "integrity": "sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA==", "dev": true, - "requires": { + "dependencies": { "@babel/types": "^7.8.3" } }, - "@babel/helper-split-export-declaration": { + "node_modules/@babel/helper-split-export-declaration": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz", "integrity": "sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA==", "dev": true, - "requires": { + "dependencies": { "@babel/types": "^7.8.3" } }, - "@babel/helpers": { + "node_modules/@babel/helpers": { "version": "7.8.4", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.8.4.tgz", "integrity": "sha512-VPbe7wcQ4chu4TDQjimHv/5tj73qz88o12EPkO2ValS2QiQS/1F2SsjyIGNnAD0vF/nZS6Cf9i+vW6HIlnaR8w==", "dev": true, - "requires": { + "dependencies": { "@babel/template": "^7.8.3", "@babel/traverse": "^7.8.4", "@babel/types": "^7.8.3" } }, - "@babel/highlight": { + "node_modules/@babel/highlight": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", "dev": true, - "requires": { + "dependencies": { "chalk": "^2.0.0", "esutils": "^2.0.2", "js-tokens": "^4.0.0" } }, - "@babel/parser": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.19.4.tgz", - "integrity": "sha512-qpVT7gtuOLjWeDTKLkJ6sryqLliBaFpAtGeqw5cs5giLldvh+Ch0plqnUMKoVAUS6ZEueQQiZV+p5pxtPitEsA==", - "dev": true + "node_modules/@babel/parser": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz", + "integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==", + "dev": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } }, - "@babel/template": { + "node_modules/@babel/template": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.3.tgz", "integrity": "sha512-04m87AcQgAFdvuoyiQ2kgELr2tV8B4fP/xJAVUL3Yb3bkNdMedD3d0rlSQr3PegP0cms3eHjl1F7PWlvWbU8FQ==", "dev": true, - "requires": { + "dependencies": { "@babel/code-frame": "^7.8.3", "@babel/parser": "^7.8.3", "@babel/types": "^7.8.3" - }, + } + }, + "node_modules/@babel/template/node_modules/@babel/code-frame": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.8.3" + } + }, + "node_modules/@babel/template/node_modules/@babel/highlight": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", + "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", + "dev": true, "dependencies": { - "@babel/code-frame": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", - "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", - "dev": true, - "requires": { - "@babel/highlight": "^7.8.3" - } - }, - "@babel/highlight": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", - "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", - "dev": true, - "requires": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", - "js-tokens": "^4.0.0" - } - }, - "@babel/parser": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.4.tgz", - "integrity": "sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==", - "dev": true - } - } - }, - "@babel/traverse": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "node_modules/@babel/traverse": { "version": "7.8.4", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.8.4.tgz", "integrity": "sha512-NGLJPZwnVEyBPLI+bl9y9aSnxMhsKz42so7ApAv9D+b4vAFPpY013FTS9LdKxcABoIYFU52HcYga1pPlx454mg==", "dev": true, - "requires": { + "dependencies": { "@babel/code-frame": "^7.8.3", "@babel/generator": "^7.8.4", "@babel/helper-function-name": "^7.8.3", @@ -233,610 +270,722 @@ "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" - }, + } + }, + "node_modules/@babel/traverse/node_modules/@babel/code-frame": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.8.3" + } + }, + "node_modules/@babel/traverse/node_modules/@babel/highlight": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", + "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", + "dev": true, + "dependencies": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "node_modules/@babel/traverse/node_modules/debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "deprecated": "Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)", + "dev": true, "dependencies": { - "@babel/code-frame": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", - "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", - "dev": true, - "requires": { - "@babel/highlight": "^7.8.3" - } - }, - "@babel/highlight": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", - "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", - "dev": true, - "requires": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", - "js-tokens": "^4.0.0" - } - }, - "@babel/parser": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.4.tgz", - "integrity": "sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==", - "dev": true - }, - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - } - } - }, - "@babel/types": { + "ms": "^2.1.1" + } + }, + "node_modules/@babel/traverse/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/@babel/types": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.3.tgz", "integrity": "sha512-jBD+G8+LWpMBBWvVcdr4QysjUE4mU/syrhN17o1u3gx0/WzJB1kwiVZAXRtWbsIPOwW8pF/YJV5+nmetPzepXg==", "dev": true, - "requires": { + "dependencies": { "esutils": "^2.0.2", "lodash": "^4.17.13", "to-fast-properties": "^2.0.0" } }, - "@istanbuljs/load-nyc-config": { + "node_modules/@istanbuljs/load-nyc-config": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.0.0.tgz", "integrity": "sha512-ZR0rq/f/E4f4XcgnDvtMWXCUJpi8eO0rssVhmztsZqLIEFA9UUP9zmpE0VxlM+kv/E1ul2I876Fwil2ayptDVg==", "dev": true, - "requires": { + "dependencies": { "camelcase": "^5.3.1", "find-up": "^4.1.0", "js-yaml": "^3.13.1", "resolve-from": "^5.0.0" }, - "dependencies": { - "resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true - } + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" } }, - "@istanbuljs/schema": { + "node_modules/@istanbuljs/schema": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.2.tgz", "integrity": "sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jsdoc/salty": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.5.tgz", + "integrity": "sha512-TfRP53RqunNe2HBobVBJ0VLhK1HbfvBYeTC1ahnN64PWvyYyGebmMiPkuwvD9fpw2ZbkoPb8Q7mwy0aR8Z9rvw==", + "dev": true, + "dependencies": { + "lodash": "^4.17.21" + }, + "engines": { + "node": ">=v12.0.0" + } }, - "@types/color-name": { + "node_modules/@types/color-name": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, - "@types/linkify-it": { + "node_modules/@types/linkify-it": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==", "dev": true }, - "@types/markdown-it": { + "node_modules/@types/markdown-it": { "version": "12.2.3", "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", "dev": true, - "requires": { + "dependencies": { "@types/linkify-it": "*", "@types/mdurl": "*" } }, - "@types/mdurl": { + "node_modules/@types/mdurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz", "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==", "dev": true }, - "@types/node": { + "node_modules/@types/node": { "version": "10.12.6", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.6.tgz", "integrity": "sha512-+ZWB5Ec1iki99xQFzBlivlKxSZQ+fuUKBott8StBOnLN4dWbRHlgdg1XknpW6g0tweniN5DcOqA64CJyOUPSAw==", "dev": true }, - "@types/node-int64": { + "node_modules/@types/node-int64": { "version": "0.4.29", "resolved": "https://registry.npmjs.org/@types/node-int64/-/node-int64-0.4.29.tgz", "integrity": "sha512-rHXvenLTj/CcsmNAebaBOhxQ2MqEGl3yXZZcZ21XYR+gzGTTcpOy2N4IxpvTCz48loyQNatHvfn6GhIbbZ1R3Q==", "dev": true, - "requires": { + "dependencies": { "@types/node": "*" } }, - "@types/q": { + "node_modules/@types/q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.1.tgz", "integrity": "sha512-eqz8c/0kwNi/OEHQfvIuJVLTst3in0e7uTKeuY+WL/zfKn0xVujOTp42bS/vUUokhK5P2BppLd9JXMOMHcgbjA==", "dev": true }, - "acorn": { + "node_modules/acorn": { "version": "6.4.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz", "integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==", - "dev": true + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } }, - "acorn-jsx": { + "node_modules/acorn-jsx": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.0.tgz", "integrity": "sha512-XkB50fn0MURDyww9+UYL3c1yLbOBz0ZFvrdYlGB8l+Ije1oSC75qAqrzSPjYQbdnQUzhlUGNKuesryAv0gxZOg==", - "dev": true + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0" + } }, - "aggregate-error": { + "node_modules/aggregate-error": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz", "integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==", "dev": true, - "requires": { + "dependencies": { "clean-stack": "^2.0.0", "indent-string": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "ajv": { + "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, - "requires": { + "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" }, - "dependencies": { - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - } + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" } }, - "ansi-escapes": { + "node_modules/ajv/node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/ansi-escapes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "ansi-regex": { + "node_modules/ansi-regex": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "ansi-styles": { + "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, - "requires": { + "dependencies": { "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" } }, - "append-transform": { + "node_modules/append-transform": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", "dev": true, - "requires": { + "dependencies": { "default-require-extensions": "^3.0.0" + }, + "engines": { + "node": ">=8" } }, - "archy": { + "node_modules/archy": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", "dev": true }, - "argparse": { + "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, - "requires": { + "dependencies": { "sprintf-js": "~1.0.2" } }, - "array-union": { + "node_modules/array-union": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true, - "requires": { + "dependencies": { "array-uniq": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "array-uniq": { + "node_modules/array-uniq": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "arrify": { + "node_modules/arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "node_modules/asn1": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", + "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", "dev": true, - "requires": { + "dependencies": { "safer-buffer": "~2.1.0" } }, - "assert-plus": { + "node_modules/assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true + "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==", + "dev": true, + "engines": { + "node": ">=0.8" + } }, - "async-limiter": { + "node_modules/async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" }, - "asynckit": { + "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "dev": true }, - "aws-sign2": { + "node_modules/aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", - "dev": true + "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==", + "dev": true, + "engines": { + "node": "*" + } }, - "aws4": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", - "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "node_modules/aws4": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz", + "integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==", "dev": true }, - "balanced-match": { + "node_modules/balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "bcrypt-pbkdf": { + "node_modules/bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==", "dev": true, - "requires": { + "dependencies": { "tweetnacl": "^0.14.3" } }, - "bluebird": { + "node_modules/bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", "dev": true }, - "brace-expansion": { + "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "requires": { + "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "browser-or-node": { + "node_modules/browser-or-node": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/browser-or-node/-/browser-or-node-1.2.1.tgz", "integrity": "sha512-sVIA0cysIED0nbmNOm7sZzKfgN1rpFmrqvLZaFWspaBAftfQcezlC81G6j6U2RJf4Lh66zFxrCeOsvkUXIcPWg==" }, - "buffer-equals": { + "node_modules/buffer-equals": { "version": "1.0.4", "resolved": "http://registry.npmjs.org/buffer-equals/-/buffer-equals-1.0.4.tgz", "integrity": "sha1-A1O1T9B/2VZBcGca5vZrnPENJ/U=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "caching-transform": { + "node_modules/caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", "dev": true, - "requires": { + "dependencies": { "hasha": "^5.0.0", "make-dir": "^3.0.0", "package-hash": "^4.0.0", "write-file-atomic": "^3.0.0" + }, + "engines": { + "node": ">=8" } }, - "caller-path": { + "node_modules/caller-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", "dev": true, - "requires": { + "dependencies": { "callsites": "^0.2.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "callsites": { + "node_modules/callsites": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "camelcase": { + "node_modules/camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true + "dev": true, + "engines": { + "node": ">=6" + } }, - "caseless": { + "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", "dev": true }, - "catharsis": { + "node_modules/catharsis": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", "integrity": "sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A==", "dev": true, - "requires": { + "dependencies": { "lodash": "^4.17.15" + }, + "engines": { + "node": ">= 10" } }, - "chalk": { + "node_modules/chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "dev": true, - "requires": { + "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" } }, - "chardet": { + "node_modules/chardet": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, - "circular-json": { + "node_modules/circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "deprecated": "CircularJSON is in maintenance only, flatted is its successor.", "dev": true }, - "clean-stack": { + "node_modules/clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", - "dev": true + "dev": true, + "engines": { + "node": ">=6" + } }, - "cli-cursor": { + "node_modules/cli-cursor": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", "dev": true, - "requires": { + "dependencies": { "restore-cursor": "^2.0.0" + }, + "engines": { + "node": ">=4" } }, - "cli-width": { + "node_modules/cli-width": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", "dev": true }, - "cliui": { + "node_modules/cliui": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", "dev": true, - "requires": { + "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", "wrap-ansi": "^6.2.0" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", - "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } - } - }, - "color-convert": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, - "requires": { + "dependencies": { "color-name": "1.1.3" } }, - "color-name": { + "node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, - "combined-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", - "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "dev": true, - "requires": { + "dependencies": { "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" } }, - "commander": { + "node_modules/commander": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", "dev": true }, - "commondir": { + "node_modules/commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", "dev": true }, - "concat-map": { + "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "connect": { + "node_modules/connect": { "version": "3.6.6", "resolved": "https://registry.npmjs.org/connect/-/connect-3.6.6.tgz", "integrity": "sha1-Ce/2xVr3I24TcTWnJXSFi2eG9SQ=", "dev": true, - "requires": { + "dependencies": { "debug": "2.6.9", "finalhandler": "1.1.0", "parseurl": "~1.3.2", "utils-merge": "1.0.1" + }, + "engines": { + "node": ">= 0.10.0" } }, - "convert-source-map": { + "node_modules/convert-source-map": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "~5.1.1" } }, - "core-util-is": { + "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", "dev": true }, - "cross-spawn": { + "node_modules/cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", "dev": true, - "requires": { + "dependencies": { "nice-try": "^1.0.4", "path-key": "^2.0.1", "semver": "^5.5.0", "shebang-command": "^1.2.0", "which": "^1.2.9" + }, + "engines": { + "node": ">=4.8" } }, - "dashdash": { + "node_modules/dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", "dev": true, - "requires": { + "dependencies": { "assert-plus": "^1.0.0" + }, + "engines": { + "node": ">=0.10" } }, - "debug": { + "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, - "requires": { + "dependencies": { "ms": "2.0.0" } }, - "decamelize": { + "node_modules/decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "deep-equal": { + "node_modules/deep-equal": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", "dev": true }, - "deep-is": { + "node_modules/deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, - "default-require-extensions": { + "node_modules/default-require-extensions": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz", "integrity": "sha512-ek6DpXq/SCpvjhpFsLFRVtIxJCRw6fUR42lYMVZuUMK7n8eMz4Uh5clckdBjEpLhn/gEBZo7hDJnJcwdKLKQjg==", "dev": true, - "requires": { + "dependencies": { "strip-bom": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "define-properties": { + "node_modules/define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", "dev": true, - "requires": { + "dependencies": { "object-keys": "^1.0.12" + }, + "engines": { + "node": ">= 0.4" } }, - "defined": { + "node_modules/defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", "dev": true }, - "del": { + "node_modules/del": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", "dev": true, - "requires": { + "dependencies": { "globby": "^5.0.0", "is-path-cwd": "^1.0.0", "is-path-in-cwd": "^1.0.0", @@ -844,105 +993,129 @@ "pify": "^2.0.0", "pinkie-promise": "^2.0.0", "rimraf": "^2.2.8" + }, + "engines": { + "node": ">=0.10.0" } }, - "delayed-stream": { + "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } }, - "doctrine": { + "node_modules/doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, - "requires": { + "dependencies": { "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" } }, - "ecc-jsbn": { + "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", "dev": true, - "requires": { + "dependencies": { "jsbn": "~0.1.0", "safer-buffer": "^2.1.0" } }, - "ee-first": { + "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", "dev": true }, - "emoji-regex": { + "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, - "encodeurl": { + "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "entities": { + "node_modules/entities": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", - "dev": true + "dev": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } }, - "es-abstract": { + "node_modules/es-abstract": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz", "integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==", "dev": true, - "requires": { + "dependencies": { "es-to-primitive": "^1.1.1", "function-bind": "^1.1.1", "has": "^1.0.1", "is-callable": "^1.1.3", "is-regex": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" } }, - "es-to-primitive": { + "node_modules/es-to-primitive": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", "dev": true, - "requires": { + "dependencies": { "is-callable": "^1.1.4", "is-date-object": "^1.0.1", "is-symbol": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" } }, - "es6-error": { + "node_modules/es6-error": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", "dev": true }, - "escape-html": { + "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", "dev": true }, - "escape-string-regexp": { + "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.8.0" + } }, - "eslint": { + "node_modules/eslint": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.7.0.tgz", "integrity": "sha512-zYCeFQahsxffGl87U2aJ7DPyH8CbWgxBC213Y8+TCanhUTf2gEvfq3EKpHmEcozTLyPmGe9LZdMAwC/CpJBM5A==", "dev": true, - "requires": { + "dependencies": { "@babel/code-frame": "^7.0.0", "ajv": "^6.5.3", "chalk": "^2.1.0", @@ -982,188 +1155,250 @@ "table": "^5.0.2", "text-table": "^0.2.0" }, - "dependencies": { - "debug": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz", - "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true - } - } - }, - "eslint-config-prettier": { + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^6.14.0 || ^8.10.0 || >=9.10.0" + } + }, + "node_modules/eslint-config-prettier": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-3.1.0.tgz", "integrity": "sha512-QYGfmzuc4q4J6XIhlp8vRKdI/fI0tQfQPy1dME3UOLprE+v4ssH/3W9LM2Q7h5qBcy5m0ehCrBDU2YF8q6OY8w==", "dev": true, - "requires": { + "dependencies": { "get-stdin": "^6.0.0" + }, + "bin": { + "eslint-config-prettier-check": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=3.14.1" } }, - "eslint-plugin-prettier": { + "node_modules/eslint-plugin-prettier": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.0.tgz", "integrity": "sha512-4g11opzhqq/8+AMmo5Vc2Gn7z9alZ4JqrbZ+D4i8KlSyxeQhZHlmIrY8U9Akf514MoEhogPa87Jgkq87aZ2Ohw==", "dev": true, - "requires": { + "dependencies": { "prettier-linter-helpers": "^1.0.0" + }, + "engines": { + "node": ">=6.0.0" + }, + "peerDependencies": { + "eslint": ">= 5.0.0", + "prettier": ">= 1.13.0" } }, - "eslint-scope": { + "node_modules/eslint-scope": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.0.tgz", "integrity": "sha512-1G6UTDi7Jc1ELFwnR58HV4fK9OQK4S6N985f166xqXxpjU6plxFISJa2Ba9KCQuFa8RCnj/lSFJbHo7UFDBnUA==", "dev": true, - "requires": { + "dependencies": { "esrecurse": "^4.1.0", "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=4.0.0" } }, - "eslint-utils": { + "node_modules/eslint-utils": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", "dev": true, - "requires": { + "dependencies": { "eslint-visitor-keys": "^1.1.0" }, - "dependencies": { - "eslint-visitor-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", - "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", - "dev": true - } + "engines": { + "node": ">=6" } }, - "eslint-visitor-keys": { - "version": "1.0.0", + "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "1.0.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/eslint/node_modules/debug": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz", + "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", + "deprecated": "Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint/node_modules/ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "dev": true }, - "espree": { + "node_modules/espree": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/espree/-/espree-4.1.0.tgz", "integrity": "sha512-I5BycZW6FCVIub93TeVY1s7vjhP9CY6cXCznIRfiig7nRviKZYdRnj/sHEWC6A7WE9RDWOFq9+7OsWSYz8qv2w==", "dev": true, - "requires": { + "dependencies": { "acorn": "^6.0.2", "acorn-jsx": "^5.0.0", "eslint-visitor-keys": "^1.0.0" + }, + "engines": { + "node": ">=6.0.0" } }, - "esprima": { + "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } }, - "esquery": { + "node_modules/esquery": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", "dev": true, - "requires": { + "dependencies": { "estraverse": "^4.0.0" + }, + "engines": { + "node": ">=0.6" } }, - "esrecurse": { + "node_modules/esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, - "requires": { + "dependencies": { "estraverse": "^4.1.0" + }, + "engines": { + "node": ">=4.0" } }, - "estraverse": { + "node_modules/estraverse": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "esutils": { + "node_modules/esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "extend": { + "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, - "external-editor": { + "node_modules/external-editor": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", "integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==", "dev": true, - "requires": { + "dependencies": { "chardet": "^0.7.0", "iconv-lite": "^0.4.24", "tmp": "^0.0.33" + }, + "engines": { + "node": ">=4" } }, - "extsprintf": { + "node_modules/extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true + "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", + "dev": true, + "engines": [ + "node >=0.6.0" + ] }, - "fast-diff": { + "node_modules/fast-diff": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", "dev": true }, - "fast-json-stable-stringify": { + "node_modules/fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", "dev": true }, - "fast-levenshtein": { + "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "figures": { + "node_modules/figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", "dev": true, - "requires": { + "dependencies": { "escape-string-regexp": "^1.0.5" + }, + "engines": { + "node": ">=4" } }, - "file-entry-cache": { + "node_modules/file-entry-cache": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", "dev": true, - "requires": { + "dependencies": { "flat-cache": "^1.2.1", "object-assign": "^4.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "finalhandler": { + "node_modules/finalhandler": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", "dev": true, - "requires": { + "dependencies": { "debug": "2.6.9", "encodeurl": "~1.0.1", "escape-html": "~1.0.3", @@ -1171,352 +1406,453 @@ "parseurl": "~1.3.2", "statuses": "~1.3.1", "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" } }, - "find-cache-dir": { + "node_modules/find-cache-dir": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.2.0.tgz", "integrity": "sha512-1JKclkYYsf1q9WIJKLZa9S9muC+08RIjzAlLrK4QcYLJMS6mk9yombQ9qf+zJ7H9LS800k0s44L4sDq9VYzqyg==", "dev": true, - "requires": { + "dependencies": { "commondir": "^1.0.1", "make-dir": "^3.0.0", "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" } }, - "find-up": { + "node_modules/find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, - "requires": { + "dependencies": { "locate-path": "^5.0.0", "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "flat-cache": { + "node_modules/flat-cache": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", "dev": true, - "requires": { + "dependencies": { "circular-json": "^0.3.1", "del": "^2.0.2", "graceful-fs": "^4.1.2", "write": "^0.2.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "for-each": { + "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", "dev": true, - "requires": { + "dependencies": { "is-callable": "^1.1.3" } }, - "foreground-child": { + "node_modules/foreground-child": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", "dev": true, - "requires": { + "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^3.0.2" }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/foreground-child/node_modules/cross-spawn": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.1.tgz", + "integrity": "sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/foreground-child/node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/foreground-child/node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/foreground-child/node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/foreground-child/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { - "cross-spawn": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.1.tgz", - "integrity": "sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } - } - }, - "forever-agent": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true + "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", + "dev": true, + "engines": { + "node": "*" + } }, - "form-data": { + "node_modules/form-data": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "dev": true, - "requires": { + "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 0.12" } }, - "fromentries": { + "node_modules/fromentries": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.2.0.tgz", "integrity": "sha512-33X7H/wdfO99GdRLLgkjUrD4geAFdq/Uv0kl3HD4da6HDixd2GUg8Mw7dahLCV9r/EARkmtYBB6Tch4EEokFTQ==", "dev": true }, - "fs.realpath": { + "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "function-bind": { + "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "functional-red-black-tree": { + "node_modules/functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, - "gensync": { + "node_modules/gensync": { "version": "1.0.0-beta.1", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz", "integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==", - "dev": true + "dev": true, + "engines": { + "node": ">=6.9.0" + } }, - "get-caller-file": { + "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } }, - "get-stdin": { + "node_modules/get-stdin": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "getpass": { + "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", "dev": true, - "requires": { + "dependencies": { "assert-plus": "^1.0.0" } }, - "glob": { + "node_modules/glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, - "requires": { + "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" } }, - "globals": { + "node_modules/globals": { "version": "11.8.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.8.0.tgz", "integrity": "sha512-io6LkyPVuzCHBSQV9fmOwxZkUk6nIaGmxheLDgmuFv89j0fm2aqDbIXKAGfzCMHqz3HLF2Zf8WSG6VqMh2qFmA==", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "globby": { + "node_modules/globby": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", "dev": true, - "requires": { + "dependencies": { "array-union": "^1.0.1", "arrify": "^1.0.0", "glob": "^7.0.3", "object-assign": "^4.0.1", "pify": "^2.0.0", "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "graceful-fs": { + "node_modules/graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.0" + } }, - "har-schema": { + "node_modules/har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true + "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", + "dev": true, + "engines": { + "node": ">=4" + } }, - "har-validator": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", - "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "node_modules/har-validator": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", + "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", + "deprecated": "this library is no longer supported", "dev": true, - "requires": { - "ajv": "^6.5.5", + "dependencies": { + "ajv": "^6.12.3", "har-schema": "^2.0.0" + }, + "engines": { + "node": ">=6" } }, - "has": { + "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, - "requires": { + "dependencies": { "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" } }, - "has-flag": { + "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "has-symbols": { + "node_modules/has-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + } }, - "hasha": { + "node_modules/hasha": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.0.tgz", "integrity": "sha512-2W+jKdQbAdSIrggA8Q35Br8qKadTrqCTC8+XZvBWepKDK6m9XkX6Iz1a2yh2KP01kzAR/dpuMeUnocoLYDcskw==", "dev": true, - "requires": { + "dependencies": { "is-stream": "^2.0.0", "type-fest": "^0.8.0" + }, + "engines": { + "node": ">=8" } }, - "html-escaper": { + "node_modules/html-escaper": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.0.tgz", "integrity": "sha512-a4u9BeERWGu/S8JiWEAQcdrg9v4QArtP9keViQjGMdff20fBdd8waotXaNmODqBe6uZ3Nafi7K/ho4gCQHV3Ig==", "dev": true }, - "html-validator": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/html-validator/-/html-validator-3.1.3.tgz", - "integrity": "sha512-RhjcQIHS/SfYzQ+/JrFWKU6AVve6AuwftAG/cWX3+bpvBK/tGMqbOleKlsAxLrKD84+GSJ1oJGnkyhdVLBGCqg==", + "node_modules/html-validator": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/html-validator/-/html-validator-0.0.8.tgz", + "integrity": "sha512-7iL7tXUZ73BpRgb9n9dkLCIFbMLUu+liJVOmGwltrMjZf1eVwoIGfpBxnLLCSq9iefAoWb/I1DUiRJWUj9tbUA==", "dev": true, - "requires": { - "request": "2.88.0", - "valid-url": "1.0.9" + "dependencies": { + "minimist": "^1.1.0", + "request": "^2.42.0", + "valid-url": "^1.0.9" + }, + "bin": { + "html-validator": "cli.js" + }, + "engines": { + "node": ">=0.10.0" } }, - "html-validator-cli": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/html-validator-cli/-/html-validator-cli-4.1.4.tgz", - "integrity": "sha512-4vGP107UDhhNHeWA5N8j/nUPlQbtB/W/K2x/P7aElbWMWrOkJA0MRSVFsMFrTPSAAjZWCG9uki2+1cQDzFtVcQ==", + "node_modules/html-validator-cli": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/html-validator-cli/-/html-validator-cli-2.0.0.tgz", + "integrity": "sha512-bfWxpGvVdenUqpJrI4HSCiVP+QPtik86epTTnXGtUU1USAi2sGfJOHTf8cLFqPKsooF+9i0xcH8h7fILnFxEbA==", "dev": true, - "requires": { - "html-validator": "3.1.3", - "minimist": "1.2.0" - }, "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } + "html-validator": "^0.0.8", + "minimist": "^1.2.0" + }, + "bin": { + "html-validator": "index.js" + }, + "engines": { + "node": ">=0.12.0" } }, - "http-signature": { + "node_modules/http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", "dev": true, - "requires": { + "dependencies": { "assert-plus": "^1.0.0", "jsprim": "^1.2.2", "sshpk": "^1.7.0" + }, + "engines": { + "node": ">=0.8", + "npm": ">=1.3.7" } }, - "iconv-lite": { + "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, - "requires": { + "dependencies": { "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" } }, - "ignore": { + "node_modules/ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 4" + } }, - "imurmurhash": { + "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.8.19" + } }, - "indent-string": { + "node_modules/indent-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "inflight": { + "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, - "requires": { + "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, - "inherits": { + "node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "inquirer": { + "node_modules/inquirer": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.0.tgz", "integrity": "sha512-QIEQG4YyQ2UYZGDC4srMZ7BjHOmNk1lR2JQj5UknBapklm6WHA+VVH7N+sUdX3A7NeCfGF8o4X1S3Ao7nAcIeg==", "dev": true, - "requires": { + "dependencies": { "ansi-escapes": "^3.0.0", "chalk": "^2.0.0", "cli-cursor": "^2.1.0", @@ -1530,136 +1866,178 @@ "string-width": "^2.1.0", "strip-ansi": "^4.0.0", "through": "^2.3.6" + }, + "engines": { + "node": ">=6.0.0" } }, - "is-callable": { + "node_modules/is-callable": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + } }, - "is-date-object": { + "node_modules/is-date-object": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + } }, - "is-fullwidth-code-point": { + "node_modules/is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "is-path-cwd": { + "node_modules/is-path-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "is-path-in-cwd": { + "node_modules/is-path-in-cwd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz", "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", "dev": true, - "requires": { + "dependencies": { "is-path-inside": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-path-inside": { + "node_modules/is-path-inside": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, - "requires": { + "dependencies": { "path-is-inside": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-promise": { + "node_modules/is-promise": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, - "is-regex": { + "node_modules/is-regex": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", "dev": true, - "requires": { + "dependencies": { "has": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" } }, - "is-resolvable": { + "node_modules/is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, - "is-stream": { + "node_modules/is-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "is-symbol": { + "node_modules/is-symbol": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", "dev": true, - "requires": { + "dependencies": { "has-symbols": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" } }, - "is-typedarray": { + "node_modules/is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, - "is-windows": { + "node_modules/is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "isexe": { + "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "isomorphic-ws": { + "node_modules/isomorphic-ws": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", - "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==" + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", + "peerDependencies": { + "ws": "*" + } }, - "isstream": { + "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==", "dev": true }, - "istanbul-lib-coverage": { + "node_modules/istanbul-lib-coverage": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", "integrity": "sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "istanbul-lib-hook": { + "node_modules/istanbul-lib-hook": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", "dev": true, - "requires": { + "dependencies": { "append-transform": "^2.0.0" + }, + "engines": { + "node": ">=8" } }, - "istanbul-lib-instrument": { + "node_modules/istanbul-lib-instrument": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.1.tgz", "integrity": "sha512-imIchxnodll7pvQBYOqUu88EufLCU56LMeFPZZM/fJZ1irYcYdqroaV+ACK1Ila8ls09iEYArp+nqyC6lW1Vfg==", "dev": true, - "requires": { + "dependencies": { "@babel/core": "^7.7.5", "@babel/parser": "^7.7.5", "@babel/template": "^7.7.4", @@ -1668,27 +2046,25 @@ "istanbul-lib-coverage": "^3.0.0", "semver": "^6.3.0" }, - "dependencies": { - "@babel/parser": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.4.tgz", - "integrity": "sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==", - "dev": true - }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" } }, - "istanbul-lib-processinfo": { + "node_modules/istanbul-lib-processinfo": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.2.tgz", "integrity": "sha512-kOwpa7z9hme+IBPZMzQ5vdQj8srYgAtaRqeI48NGmAQ+/5yKiHLV0QbYqQpxsdEF0+w14SoB8YbnHKcXE2KnYw==", "dev": true, - "requires": { + "dependencies": { "archy": "^1.0.0", "cross-spawn": "^7.0.0", "istanbul-lib-coverage": "^3.0.0-alpha.1", @@ -1697,175 +2073,213 @@ "rimraf": "^3.0.0", "uuid": "^3.3.3" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-processinfo/node_modules/cross-spawn": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.1.tgz", + "integrity": "sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==", + "dev": true, "dependencies": { - "cross-spawn": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.1.tgz", - "integrity": "sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } - } - }, - "istanbul-lib-report": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/istanbul-lib-processinfo/node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-processinfo/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/istanbul-lib-processinfo/node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-processinfo/node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-processinfo/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/istanbul-lib-report": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", "dev": true, - "requires": { + "dependencies": { "istanbul-lib-coverage": "^3.0.0", "make-dir": "^3.0.0", "supports-color": "^7.1.0" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report/node_modules/supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, "dependencies": { - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "istanbul-lib-source-maps": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-source-maps": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.0.tgz", "integrity": "sha512-c16LpFRkR8vQXyHZ5nLpY35JZtzj1PQY1iZmesUbf1FZHbIupcWfjgOXBY9YHkLEQ6puz1u4Dgj6qmU/DisrZg==", "dev": true, - "requires": { + "dependencies": { "debug": "^4.1.1", "istanbul-lib-coverage": "^3.0.0", "source-map": "^0.6.1" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-source-maps/node_modules/debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "deprecated": "Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)", + "dev": true, "dependencies": { - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "istanbul-reports": { + "ms": "^2.1.1" + } + }, + "node_modules/istanbul-lib-source-maps/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/istanbul-lib-source-maps/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/istanbul-reports": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.0.0.tgz", "integrity": "sha512-2osTcC8zcOSUkImzN2EWQta3Vdi4WjjKw99P2yWx5mLnigAM0Rd5uYFn1cf2i/Ois45GkNjaoTqc5CxgMSX80A==", "dev": true, - "requires": { + "dependencies": { "html-escaper": "^2.0.0", "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" } }, - "js-tokens": { + "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, - "js-yaml": { + "node_modules/js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, - "requires": { + "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" } }, - "js2xmlparser": { + "node_modules/js2xmlparser": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz", "integrity": "sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==", "dev": true, - "requires": { + "dependencies": { "xmlcreate": "^2.0.4" } }, - "jsbn": { + "node_modules/jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==", "dev": true }, - "jsdoc": { - "version": "3.6.11", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.11.tgz", - "integrity": "sha512-8UCU0TYeIYD9KeLzEcAu2q8N/mx9O3phAGl32nmHlE0LpaJL71mMkP4d+QE5zWfNt50qheHtOZ0qoxVrsX5TUg==", + "node_modules/jsdoc": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.2.tgz", + "integrity": "sha512-e8cIg2z62InH7azBBi3EsSEqrKx+nUtAS5bBcYTSpZFA+vhNPyhv8PTFZ0WsjOPDj04/dOLlm08EDcQJDqaGQg==", "dev": true, - "requires": { - "@babel/parser": "^7.9.4", + "dependencies": { + "@babel/parser": "^7.20.15", + "@jsdoc/salty": "^0.2.1", "@types/markdown-it": "^12.2.3", "bluebird": "^3.7.2", "catharsis": "^0.9.0", @@ -1878,291 +2292,370 @@ "mkdirp": "^1.0.4", "requizzle": "^0.2.3", "strip-json-comments": "^3.1.0", - "taffydb": "2.6.2", "underscore": "~1.13.2" }, - "dependencies": { - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true - }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true - }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - } - } - }, - "jsesc": { + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/jsdoc/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/jsdoc/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jsdoc/node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } }, - "json-int64": { + "node_modules/json-int64": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-int64/-/json-int64-1.0.2.tgz", "integrity": "sha512-uGrIXtRehbksM17S2lJRLPljufK52KL2ewbJi0xgcRPONoRLXa4yAUIKAUxF69dbnqIoBu33fB28MAWSxupB8Q==", "dev": true, - "requires": { + "dependencies": { "node-int64": "0.4.0" } }, - "json-schema-traverse": { + "node_modules/json-schema": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", + "dev": true + }, + "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, - "json-stable-stringify-without-jsonify": { + "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, - "json-stringify-safe": { + "node_modules/json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", "dev": true }, - "json5": { + "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true + "dev": true, + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } }, - "jsprim": { + "node_modules/jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", "dev": true, - "requires": { + "dependencies": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", "json-schema": "0.4.0", "verror": "1.10.0" }, - "dependencies": { - "json-schema": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", - "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", - "dev": true - } + "engines": { + "node": ">=0.6.0" } }, - "klaw": { + "node_modules/klaw": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", "dev": true, - "requires": { + "dependencies": { "graceful-fs": "^4.1.9" } }, - "levn": { + "node_modules/levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "dev": true, - "requires": { + "dependencies": { "prelude-ls": "~1.1.2", "type-check": "~0.3.2" + }, + "engines": { + "node": ">= 0.8.0" } }, - "linkify-it": { + "node_modules/linkify-it": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", "dev": true, - "requires": { + "dependencies": { "uc.micro": "^1.0.1" } }, - "locate-path": { + "node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "dev": true, - "requires": { + "dependencies": { "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" } }, - "lodash": { + "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, - "lodash.flattendeep": { + "node_modules/lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", "dev": true }, - "make-dir": { + "node_modules/make-dir": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.2.tgz", "integrity": "sha512-rYKABKutXa6vXTXhoV18cBE7PaewPXHe/Bdq4v+ZLMhxbWApkFFplT0LcbMW+6BbjnQXzZ/sAvSE/JdguApG5w==", "dev": true, - "requires": { + "dependencies": { "semver": "^6.0.0" }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "markdown-it": { + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/markdown-it": { "version": "12.3.2", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", "dev": true, - "requires": { + "dependencies": { "argparse": "^2.0.1", "entities": "~2.1.0", "linkify-it": "^3.0.1", "mdurl": "^1.0.1", "uc.micro": "^1.0.5" }, - "dependencies": { - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - } + "bin": { + "markdown-it": "bin/markdown-it.js" } }, - "markdown-it-anchor": { + "node_modules/markdown-it-anchor": { "version": "8.6.5", "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.5.tgz", "integrity": "sha512-PI1qEHHkTNWT+X6Ip9w+paonfIQ+QZP9sCeMYi47oqhH+EsW8CrJ8J7CzV19QVOj6il8ATGbK2nTECj22ZHGvQ==", + "dev": true, + "peerDependencies": { + "@types/markdown-it": "*", + "markdown-it": "*" + } + }, + "node_modules/markdown-it/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "marked": { + "node_modules/marked": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/marked/-/marked-4.1.1.tgz", "integrity": "sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw==", - "dev": true + "dev": true, + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } }, - "mdurl": { + "node_modules/mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==", "dev": true }, - "mime-db": { - "version": "1.37.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", - "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==", - "dev": true + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "mime-types": { - "version": "2.1.21", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", - "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dev": true, - "requires": { - "mime-db": "~1.37.0" + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" } }, - "mimic-fn": { + "node_modules/mimic-fn": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "minimatch": { + "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, - "requires": { + "dependencies": { "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" } }, - "mkdirp": { + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "dev": true, - "requires": { + "dependencies": { "minimist": "^1.2.5" }, - "dependencies": { - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - } + "bin": { + "mkdirp": "bin/cmd.js" } }, - "ms": { + "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "mute-stream": { + "node_modules/mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", "dev": true }, - "natural-compare": { + "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, - "nice-try": { + "node_modules/nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, - "node-gyp-build": { + "node_modules/node-gyp-build": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-3.7.0.tgz", "integrity": "sha512-L/Eg02Epx6Si2NXmedx+Okg+4UHqmaf3TNcxd50SF9NQGcJaON3AtU++kax69XV7YWz4tUspqZSAsVofhFKG2w==", - "dev": true + "dev": true, + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } }, - "node-int64": { + "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", "integrity": "sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=" }, - "node-preload": { + "node_modules/node-preload": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", "dev": true, - "requires": { + "dependencies": { "process-on-spawn": "^1.0.0" + }, + "engines": { + "node": ">=8" } }, - "nyc": { + "node_modules/nyc": { "version": "15.0.0", "resolved": "https://registry.npmjs.org/nyc/-/nyc-15.0.0.tgz", "integrity": "sha512-qcLBlNCKMDVuKb7d1fpxjPR8sHeMVX0CHarXAVzrVWoFrigCkYR8xcrjfXSPi5HXM7EU78L6ywO7w1c5rZNCNg==", "dev": true, - "requires": { + "dependencies": { "@istanbuljs/load-nyc-config": "^1.0.0", "@istanbuljs/schema": "^0.1.2", "caching-transform": "^4.0.0", @@ -2192,320 +2685,432 @@ "uuid": "^3.3.3", "yargs": "^15.0.2" }, + "bin": { + "nyc": "bin/nyc.js" + }, + "engines": { + "node": ">=8.9" + } + }, + "node_modules/nyc/node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, "dependencies": { - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true - }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true - } - } - }, - "oauth-sign": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/nyc/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "object-assign": { + "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "object-inspect": { + "node_modules/object-inspect": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", "dev": true }, - "object-keys": { + "node_modules/object-keys": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + } }, - "on-finished": { + "node_modules/on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", "dev": true, - "requires": { + "dependencies": { "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" } }, - "once": { + "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "requires": { + "dependencies": { "wrappy": "1" } }, - "onetime": { + "node_modules/onetime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", "dev": true, - "requires": { + "dependencies": { "mimic-fn": "^1.0.0" + }, + "engines": { + "node": ">=4" } }, - "optionator": { + "node_modules/optionator": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", "dev": true, - "requires": { + "dependencies": { "deep-is": "~0.1.3", "fast-levenshtein": "~2.0.4", "levn": "~0.3.0", "prelude-ls": "~1.1.2", "type-check": "~0.3.2", "wordwrap": "~1.0.0" + }, + "engines": { + "node": ">= 0.8.0" } }, - "os-tmpdir": { + "node_modules/os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "p-limit": { + "node_modules/p-limit": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz", "integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==", "dev": true, - "requires": { + "dependencies": { "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "p-locate": { + "node_modules/p-locate": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "dev": true, - "requires": { + "dependencies": { "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" } }, - "p-map": { + "node_modules/p-map": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", "dev": true, - "requires": { + "dependencies": { "aggregate-error": "^3.0.0" + }, + "engines": { + "node": ">=8" } }, - "p-try": { + "node_modules/p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=6" + } }, - "package-hash": { + "node_modules/package-hash": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", "dev": true, - "requires": { + "dependencies": { "graceful-fs": "^4.1.15", "hasha": "^5.0.0", "lodash.flattendeep": "^4.4.0", "release-zalgo": "^1.0.0" }, - "dependencies": { - "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", - "dev": true - } + "engines": { + "node": ">=8" } }, - "parseurl": { + "node_modules/package-hash/node_modules/graceful-fs": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", + "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", + "dev": true + }, + "node_modules/parseurl": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "path-exists": { + "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "path-is-absolute": { + "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "path-is-inside": { + "node_modules/path-is-inside": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", "dev": true }, - "path-key": { + "node_modules/path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "performance-now": { + "node_modules/performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", "dev": true }, - "pify": { + "node_modules/pify": { "version": "2.3.0", "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "pinkie": { + "node_modules/pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "pinkie-promise": { + "node_modules/pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, - "requires": { + "dependencies": { "pinkie": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "pkg-dir": { + "node_modules/pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, - "requires": { + "dependencies": { "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "pluralize": { + "node_modules/pluralize": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "prelude-ls": { + "node_modules/prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8.0" + } }, - "prettier": { + "node_modules/prettier": { "version": "1.14.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.14.3.tgz", "integrity": "sha512-qZDVnCrnpsRJJq5nSsiHCE3BYMED2OtsI+cmzIzF1QIfqm5ALf8tEJcO27zV1gKNKRPdhjO0dNWnrzssDQ1tFg==", - "dev": true + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=4" + } }, - "prettier-linter-helpers": { + "node_modules/prettier-linter-helpers": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", "dev": true, - "requires": { + "dependencies": { "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" } }, - "process-on-spawn": { + "node_modules/process-on-spawn": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", "integrity": "sha512-1WsPDsUSMmZH5LeMLegqkPDrsGgsWwk1Exipy2hvB0o/F0ASzbpIctSCcZIK1ykJvtTJULEH+20WOFjMvGnCTg==", "dev": true, - "requires": { + "dependencies": { "fromentries": "^1.2.0" + }, + "engines": { + "node": ">=8" } }, - "progress": { + "node_modules/progress": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.1.tgz", "integrity": "sha512-OE+a6vzqazc+K6LxJrX5UPyKFvGnL5CYmq2jFGNIBWHpc4QyE49/YOumcrpQFJpfejmvRtbJzgO1zPmMCqlbBg==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.0" + } }, - "psl": { - "version": "1.1.31", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", - "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==", + "node_modules/psl": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", "dev": true }, - "punycode": { + "node_modules/punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true + "dev": true, + "engines": { + "node": ">=6" + } }, - "q": { + "node_modules/q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "engines": { + "node": ">=0.6.0", + "teleport": ">=0.2.0" + } }, - "qs": { + "node_modules/qs": { "version": "6.5.3", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.6" + } }, - "regexpp": { + "node_modules/regexpp": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", - "dev": true + "dev": true, + "engines": { + "node": ">=6.5.0" + } }, - "release-zalgo": { + "node_modules/release-zalgo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", "dev": true, - "requires": { + "dependencies": { "es6-error": "^4.0.1" + }, + "engines": { + "node": ">=4" } }, - "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "node_modules/request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", "dev": true, - "requires": { + "dependencies": { "aws-sign2": "~0.7.0", "aws4": "^1.8.0", "caseless": "~0.12.0", @@ -2513,7 +3118,7 @@ "extend": "~3.0.2", "forever-agent": "~0.6.1", "form-data": "~2.3.2", - "har-validator": "~5.1.0", + "har-validator": "~5.1.3", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", @@ -2523,154 +3128,190 @@ "performance-now": "^2.1.0", "qs": "~6.5.2", "safe-buffer": "^5.1.2", - "tough-cookie": "~2.4.3", + "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" + }, + "engines": { + "node": ">= 6" } }, - "require-directory": { + "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "require-main-filename": { + "node_modules/require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, - "require-uncached": { + "node_modules/require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", "dev": true, - "requires": { + "dependencies": { "caller-path": "^0.1.0", "resolve-from": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "requizzle": { + "node_modules/requizzle": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz", "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==", "dev": true, - "requires": { + "dependencies": { "lodash": "^4.17.14" } }, - "resolve-from": { + "node_modules/resolve-from": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "restore-cursor": { + "node_modules/restore-cursor": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", "dev": true, - "requires": { + "dependencies": { "onetime": "^2.0.0", "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=4" } }, - "resumer": { + "node_modules/resumer": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", "dev": true, - "requires": { + "dependencies": { "through": "~2.3.4" } }, - "rimraf": { + "node_modules/rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, - "requires": { + "dependencies": { "glob": "^7.0.5" + }, + "bin": { + "rimraf": "bin.js" } }, - "run-async": { + "node_modules/run-async": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", "dev": true, - "requires": { + "dependencies": { "is-promise": "^2.1.0" + }, + "engines": { + "node": ">=0.12.0" } }, - "rxjs": { + "node_modules/rxjs": { "version": "6.3.3", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", "dev": true, - "requires": { + "dependencies": { "tslib": "^1.9.0" + }, + "engines": { + "npm": ">=2.0.0" } }, - "safe-buffer": { + "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, - "safer-buffer": { + "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "semver": { + "node_modules/semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "dev": true + "dev": true, + "bin": { + "semver": "bin/semver" + } }, - "set-blocking": { + "node_modules/set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, - "shebang-command": { + "node_modules/shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "dev": true, - "requires": { + "dependencies": { "shebang-regex": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "shebang-regex": { + "node_modules/shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "signal-exit": { + "node_modules/signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, - "slice-ansi": { + "node_modules/slice-ansi": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", "dev": true, - "requires": { + "dependencies": { "is-fullwidth-code-point": "^2.0.0" + }, + "engines": { + "node": ">=4" } }, - "spawn-wrap": { + "node_modules/spawn-wrap": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", "integrity": "sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==", "dev": true, - "requires": { + "dependencies": { "foreground-child": "^2.0.0", "is-windows": "^1.0.2", "make-dir": "^3.0.0", @@ -2678,39 +3319,52 @@ "signal-exit": "^3.0.2", "which": "^2.0.1" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/spawn-wrap/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/spawn-wrap/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } - } - }, - "sprintf-js": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "sshpk": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", - "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "node_modules/sshpk": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz", + "integrity": "sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==", "dev": true, - "requires": { + "dependencies": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", "bcrypt-pbkdf": "^1.0.0", @@ -2720,89 +3374,115 @@ "jsbn": "~0.1.0", "safer-buffer": "^2.0.2", "tweetnacl": "~0.14.0" + }, + "bin": { + "sshpk-conv": "bin/sshpk-conv", + "sshpk-sign": "bin/sshpk-sign", + "sshpk-verify": "bin/sshpk-verify" + }, + "engines": { + "node": ">=0.10.0" } }, - "statuses": { + "node_modules/statuses": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "string-width": { + "node_modules/string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, - "requires": { + "dependencies": { "is-fullwidth-code-point": "^2.0.0", "strip-ansi": "^4.0.0" + }, + "engines": { + "node": ">=4" } }, - "string.prototype.trim": { + "node_modules/string.prototype.trim": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", "dev": true, - "requires": { + "dependencies": { "define-properties": "^1.1.2", "es-abstract": "^1.5.0", "function-bind": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" } }, - "strip-ansi": { + "node_modules/strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, - "requires": { + "dependencies": { "ansi-regex": "^3.0.0" + }, + "engines": { + "node": ">=4" } }, - "strip-bom": { + "node_modules/strip-bom": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "strip-json-comments": { + "node_modules/strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "supports-color": { + "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, - "requires": { + "dependencies": { "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" } }, - "table": { + "node_modules/table": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/table/-/table-5.1.0.tgz", "integrity": "sha512-e542in22ZLhD/fOIuXs/8yDZ9W61ltF8daM88rkRNtgTIct+vI2fTnAyu/Db2TCfEcI8i7mjZz6meLq0nW7TYg==", "dev": true, - "requires": { + "dependencies": { "ajv": "^6.5.3", "lodash": "^4.17.10", "slice-ansi": "1.0.0", "string-width": "^2.1.1" + }, + "engines": { + "node": ">=6.0.0" } }, - "taffydb": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", - "integrity": "sha512-y3JaeRSplks6NYQuCOj3ZFMO3j60rTwbuKCvZxsAraGYH2epusatvZ0baZYA01WsGqJBq/Dl6vOrMUJqyMj8kA==", - "dev": true - }, - "tape": { + "node_modules/tape": { "version": "4.9.1", "resolved": "https://registry.npmjs.org/tape/-/tape-4.9.1.tgz", "integrity": "sha512-6fKIXknLpoe/Jp4rzHKFPpJUHDHDqn8jus99IfPnHIjyz78HYlefTGD3b5EkbQzuLfaEvmfPK3IolLgq2xT3kw==", "dev": true, - "requires": { + "dependencies": { "deep-equal": "~1.0.1", "defined": "~1.0.0", "for-each": "~0.3.3", @@ -2817,364 +3497,423 @@ "string.prototype.trim": "~1.1.2", "through": "~2.3.8" }, + "bin": { + "tape": "bin/tape" + } + }, + "node_modules/tape/node_modules/resolve": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", + "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", + "dev": true, "dependencies": { - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - }, - "resolve": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", - "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", - "dev": true, - "requires": { - "path-parse": "^1.0.5" - }, - "dependencies": { - "path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - } - } - } - } - }, - "test-exclude": { + "path-parse": "^1.0.5" + } + }, + "node_modules/tape/node_modules/resolve/node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", "dev": true, - "requires": { + "dependencies": { "@istanbuljs/schema": "^0.1.2", "glob": "^7.1.4", "minimatch": "^3.0.4" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude/node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, "dependencies": { - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "text-table": { + "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "through": { + "node_modules/through": { "version": "2.3.8", "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, - "tmp": { + "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", "dev": true, - "requires": { + "dependencies": { "os-tmpdir": "~1.0.2" + }, + "engines": { + "node": ">=0.6.0" } }, - "to-fast-properties": { + "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "node_modules/tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", "dev": true, - "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" - }, "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true - } + "psl": "^1.1.28", + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=0.8" } }, - "tslib": { + "node_modules/tslib": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", "dev": true }, - "tunnel-agent": { + "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" } }, - "tweetnacl": { + "node_modules/tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==", "dev": true }, - "type-check": { + "node_modules/type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "dev": true, - "requires": { + "dependencies": { "prelude-ls": "~1.1.2" + }, + "engines": { + "node": ">= 0.8.0" } }, - "type-fest": { + "node_modules/type-fest": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "typedarray-to-buffer": { + "node_modules/typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", "dev": true, - "requires": { + "dependencies": { "is-typedarray": "^1.0.0" } }, - "typescript": { + "node_modules/typescript": { "version": "3.1.6", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.6.tgz", "integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==", - "dev": true + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } }, - "uc.micro": { + "node_modules/uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", "dev": true }, - "underscore": { + "node_modules/underscore": { "version": "1.13.6", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==", "dev": true }, - "unpipe": { + "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "uri-js": { + "node_modules/uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", "dev": true, - "requires": { + "dependencies": { "punycode": "^2.1.0" } }, - "utf-8-validate": { + "node_modules/utf-8-validate": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.2.tgz", "integrity": "sha512-SwV++i2gTD5qh2XqaPzBnNX88N6HdyhQrNNRykvcS0QKvItV9u3vPEJr+X5Hhfb1JC0r0e1alL0iB09rY8+nmw==", "dev": true, - "requires": { + "hasInstallScript": true, + "dependencies": { "node-gyp-build": "~3.7.0" } }, - "utils-merge": { + "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4.0" + } }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", - "dev": true + "node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "dev": true, + "bin": { + "uuid": "bin/uuid" + } }, - "valid-url": { + "node_modules/valid-url": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz", - "integrity": "sha1-HBRHm0DxOXp1eC8RXkCGRHQzogA=", + "integrity": "sha512-QQDsV8OnSf5Uc30CKSwG9lnhMPe6exHtTXLRYX8uMwKENy640pU+2BgBL0LRbDh/eYRahNCS7aewCx0wf3NYVA==", "dev": true }, - "verror": { + "node_modules/verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", "dev": true, - "requires": { + "engines": [ + "node >=0.6.0" + ], + "dependencies": { "assert-plus": "^1.0.0", "core-util-is": "1.0.2", "extsprintf": "^1.2.0" } }, - "which": { + "node_modules/which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, - "requires": { + "dependencies": { "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" } }, - "which-module": { + "node_modules/which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, - "wordwrap": { + "node_modules/wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", "dev": true }, - "wrap-ansi": { + "node_modules/wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", "dev": true, - "requires": { + "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "dependencies": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/wrap-ansi/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/wrap-ansi/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", - "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } - } - }, - "wrappy": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "write": { + "node_modules/write": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", "dev": true, - "requires": { + "dependencies": { "mkdirp": "^0.5.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "write-file-atomic": { + "node_modules/write-file-atomic": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.1.tgz", "integrity": "sha512-JPStrIyyVJ6oCSz/691fAjFtefZ6q+fP6tm+OS4Qw6o+TGQxNp1ziY2PgS+X/m0V8OWhZiO/m4xSj+Pr4RrZvw==", "dev": true, - "requires": { + "dependencies": { "imurmurhash": "^0.1.4", "is-typedarray": "^1.0.0", "signal-exit": "^3.0.2", "typedarray-to-buffer": "^3.1.5" } }, - "ws": { + "node_modules/ws": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.3.tgz", "integrity": "sha512-jZArVERrMsKUatIdnLzqvcfydI85dvd/Fp1u/VOpfdDWQ4c9qWXe+VIeAbQ5FrDwciAkr+lzofXLz3Kuf26AOA==", - "requires": { + "dependencies": { "async-limiter": "~1.0.0" } }, - "xmlcreate": { + "node_modules/xmlcreate": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz", "integrity": "sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg==", "dev": true }, - "y18n": { + "node_modules/y18n": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", "dev": true }, - "yargs": { + "node_modules/yargs": { "version": "15.4.1", "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", "dev": true, - "requires": { + "dependencies": { "cliui": "^6.0.0", "decamelize": "^1.2.0", "find-up": "^4.1.0", @@ -3187,49 +3926,65 @@ "y18n": "^4.0.0", "yargs-parser": "^18.1.2" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } - } + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" } } } diff --git a/package.json b/package.json index 84080a65cb0..28d7a1547f5 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "eslint": "^5.7.0", "eslint-config-prettier": "^3.1.0", "eslint-plugin-prettier": "^3.0.0", - "html-validator-cli": "^4.1.4", - "jsdoc": "^3.6.7", + "html-validator-cli": "^2.0.0", + "jsdoc": "^4.0.2", "json-int64": "^1.0.2", "nyc": "^15.0.0", "prettier": "^1.14.3", From 34d04083a49e76ff4b46af54da54614f741b8729 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Wed, 21 Jun 2023 23:06:56 +0200 Subject: [PATCH 077/250] bumping certain TS modules --- lib/ts/package-lock.json | 3577 ++++++++++++++++++++++++-------------- 1 file changed, 2224 insertions(+), 1353 deletions(-) diff --git a/lib/ts/package-lock.json b/lib/ts/package-lock.json index fed7fe462b8..de1254c6732 100644 --- a/lib/ts/package-lock.json +++ b/lib/ts/package-lock.json @@ -1,391 +1,486 @@ { "name": "thrift", "version": "0.19.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@babel/parser": { + "packages": { + "": { + "name": "thrift", + "version": "0.19.0", + "license": "Apache-2.0", + "dependencies": { + "bufferutil": "^4.0.1", + "jsdoc": "^3.6.7", + "json-int64": "^1.0.0", + "nopt": "^4.0.1" + }, + "devDependencies": { + "@types/node-int64": "^0.4.29", + "@types/phantom": "^3.2.5", + "@types/qunit": "^2.5.4", + "browserify": "^16.2.3", + "bufferutil": "^4.0.1", + "grunt": "^1.4.1", + "grunt-cli": "^1.4.3", + "grunt-contrib-concat": "^1.0.1", + "grunt-contrib-jshint": "^3.2.0", + "grunt-contrib-qunit": "^3.1.0", + "grunt-contrib-uglify": "^1.0.1", + "grunt-jsdoc": "^2.4.1", + "grunt-shell-spawn": "^0.3.12", + "jslint": "^0.12.0", + "node-int64": "^0.4.0", + "phantom": "^6.0.3", + "typescript": "^3.2.4" + } + }, + "node_modules/@babel/parser": { "version": "7.19.3", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.19.3.tgz", - "integrity": "sha512-pJ9xOlNWHiy9+FuFP09DEAFbAn4JskgRsVcc169w2xRBC3FRGuQEwjeIMMND9L2zc0iEhO/tGv4Zq+km+hxNpQ==" + "integrity": "sha512-pJ9xOlNWHiy9+FuFP09DEAFbAn4JskgRsVcc169w2xRBC3FRGuQEwjeIMMND9L2zc0iEhO/tGv4Zq+km+hxNpQ==", + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@colors/colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", + "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "dev": true, + "engines": { + "node": ">=0.1.90" + } + }, + "node_modules/@dabh/diagnostics": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz", + "integrity": "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==", + "dev": true, + "dependencies": { + "colorspace": "1.1.x", + "enabled": "2.0.x", + "kuler": "^2.0.0" + } }, - "@types/linkify-it": { + "node_modules/@types/linkify-it": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==" }, - "@types/markdown-it": { + "node_modules/@types/markdown-it": { "version": "12.2.3", "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", - "requires": { + "dependencies": { "@types/linkify-it": "*", "@types/mdurl": "*" } }, - "@types/mdurl": { + "node_modules/@types/mdurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz", "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==" }, - "@types/node": { + "node_modules/@types/node": { "version": "10.12.18", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==", "dev": true }, - "@types/node-int64": { + "node_modules/@types/node-int64": { "version": "0.4.29", "resolved": "https://registry.npmjs.org/@types/node-int64/-/node-int64-0.4.29.tgz", "integrity": "sha512-rHXvenLTj/CcsmNAebaBOhxQ2MqEGl3yXZZcZ21XYR+gzGTTcpOy2N4IxpvTCz48loyQNatHvfn6GhIbbZ1R3Q==", "dev": true, - "requires": { + "dependencies": { "@types/node": "*" } }, - "@types/phantom": { + "node_modules/@types/phantom": { "version": "3.2.5", "resolved": "https://registry.npmjs.org/@types/phantom/-/phantom-3.2.5.tgz", "integrity": "sha512-7m36DoKSvZgBGWp0xiJ74eHnuotyrpDyQ6m+lers5iMvW4QX+RvBENn7PCjNix7OVqPWlBM+7AqzYVIQ7NrKrA==", "dev": true }, - "@types/qunit": { + "node_modules/@types/qunit": { "version": "2.5.4", "resolved": "https://registry.npmjs.org/@types/qunit/-/qunit-2.5.4.tgz", "integrity": "sha512-VHi2lEd4/zp8OOouf43JXGJJ5ZxHvdLL1dU0Yakp6Iy73SjpuXl7yjwAwmh1qhTv8krDgHteSwaySr++uXX9YQ==", "dev": true }, - "JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dev": true, - "requires": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - } + "node_modules/@types/triple-beam": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.2.tgz", + "integrity": "sha512-txGIh+0eDFzKGC25zORnswy+br1Ha7hj5cMVwKIU7+s0U2AxxJru/jZSMU6OC9MJWP6+pc/hc6ZjyZShpsyY2g==", + "dev": true }, - "abbrev": { + "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, - "acorn": { + "node_modules/acorn": { "version": "6.4.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz", "integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==", - "dev": true + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } }, - "acorn-dynamic-import": { + "node_modules/acorn-dynamic-import": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz", "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==", - "dev": true + "deprecated": "This is probably built in to whatever tool you're using. If you still need it... idk", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0" + } }, - "acorn-node": { + "node_modules/acorn-node": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.6.2.tgz", "integrity": "sha512-rIhNEZuNI8ibQcL7ANm/mGyPukIaZsRNX9psFNQURyJW0nu6k8wjSDld20z6v2mDBWqX13pIEnk9gGZJHIlEXg==", "dev": true, - "requires": { + "dependencies": { "acorn": "^6.0.2", "acorn-dynamic-import": "^4.0.0", "acorn-walk": "^6.1.0", "xtend": "^4.0.1" } }, - "acorn-walk": { + "node_modules/acorn-walk": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.1.tgz", "integrity": "sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.0" + } }, - "ajv": { + "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, - "requires": { + "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" }, - "dependencies": { - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - } + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" } }, - "align-text": { + "node_modules/ajv/node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/align-text": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, - "requires": { + "dependencies": { "kind-of": "^3.0.2", "longest": "^1.0.1", "repeat-string": "^1.5.2" }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/align-text/node_modules/kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } + "is-buffer": "^1.1.5" + }, + "engines": { + "node": ">=0.10.0" } }, - "ansi-regex": { + "node_modules/ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "ansi-styles": { + "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, - "requires": { + "dependencies": { "color-convert": "^2.0.1" }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ansi-styles/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, "dependencies": { - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - } + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" } }, - "argparse": { + "node_modules/ansi-styles/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - }, "dependencies": { - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - } + "sprintf-js": "~1.0.2" } }, - "array-each": { + "node_modules/argparse/node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "node_modules/array-each": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "array-find-index": { + "node_modules/array-find-index": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "array-slice": { + "node_modules/array-slice": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz", "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "asn1": { + "node_modules/asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", "dev": true, - "requires": { + "dependencies": { "safer-buffer": "~2.1.0" } }, - "asn1.js": { + "node_modules/asn1.js": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.0.0", "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, - "assert": { + "node_modules/assert": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", "dev": true, - "requires": { - "util": "0.10.3" - }, "dependencies": { - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true - }, - "util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", - "dev": true, - "requires": { - "inherits": "2.0.1" - } - } + "util": "0.10.3" } }, - "assert-plus": { + "node_modules/assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/assert/node_modules/inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", "dev": true }, - "async": { + "node_modules/assert/node_modules/util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, + "dependencies": { + "inherits": "2.0.1" + } + }, + "node_modules/async": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==", "dev": true }, - "async-limiter": { + "node_modules/async-limiter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", "dev": true }, - "asynckit": { + "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, - "aws-sign2": { + "node_modules/aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "aws4": { + "node_modules/aws4": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", "dev": true }, - "balanced-match": { + "node_modules/balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "base64-js": { + "node_modules/base64-js": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", "dev": true }, - "bcrypt-pbkdf": { + "node_modules/bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", "dev": true, - "requires": { + "dependencies": { "tweetnacl": "^0.14.3" } }, - "bluebird": { + "node_modules/bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, - "bn.js": { + "node_modules/bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", "dev": true }, - "brace-expansion": { + "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "requires": { + "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "braces": { + "node_modules/braces": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "dev": true, - "requires": { + "dependencies": { "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" } }, - "brorand": { + "node_modules/brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", "dev": true }, - "browser-pack": { + "node_modules/browser-pack": { "version": "6.1.0", "resolved": "http://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, - "requires": { - "JSONStream": "^1.0.3", + "dependencies": { "combine-source-map": "~0.8.0", "defined": "^1.0.0", + "JSONStream": "^1.0.3", "safe-buffer": "^5.1.1", "through2": "^2.0.0", "umd": "^3.0.0" + }, + "bin": { + "browser-pack": "bin/cmd.js" } }, - "browser-resolve": { + "node_modules/browser-resolve": { "version": "1.11.3", "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", "dev": true, - "requires": { - "resolve": "1.1.7" - }, "dependencies": { - "resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", - "dev": true - } + "resolve": "1.1.7" } }, - "browserify": { + "node_modules/browser-resolve/node_modules/resolve": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "dev": true + }, + "node_modules/browserify": { "version": "16.2.3", "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.2.3.tgz", "integrity": "sha512-zQt/Gd1+W+IY+h/xX2NYMW4orQWhqSwyV+xsblycTtpOuB27h1fZhhNQuipJ4t79ohw4P4mMem0jp/ZkISQtjQ==", "dev": true, - "requires": { - "JSONStream": "^1.0.3", + "dependencies": { "assert": "^1.4.0", "browser-pack": "^6.0.1", "browser-resolve": "^1.11.0", @@ -407,6 +502,7 @@ "https-browserify": "^1.0.0", "inherits": "~2.0.1", "insert-module-globals": "^7.0.0", + "JSONStream": "^1.0.3", "labeled-stream-splicer": "^2.0.0", "mkdirp": "^0.5.0", "module-deps": "^6.0.0", @@ -433,14 +529,20 @@ "util": "~0.10.1", "vm-browserify": "^1.0.0", "xtend": "^4.0.0" + }, + "bin": { + "browserify": "bin/cmd.js" + }, + "engines": { + "node": ">= 0.8" } }, - "browserify-aes": { + "node_modules/browserify-aes": { "version": "1.2.0", "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, - "requires": { + "dependencies": { "buffer-xor": "^1.0.3", "cipher-base": "^1.0.0", "create-hash": "^1.1.0", @@ -449,45 +551,45 @@ "safe-buffer": "^5.0.1" } }, - "browserify-cipher": { + "node_modules/browserify-cipher": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, - "requires": { + "dependencies": { "browserify-aes": "^1.0.4", "browserify-des": "^1.0.0", "evp_bytestokey": "^1.0.0" } }, - "browserify-des": { + "node_modules/browserify-des": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, - "requires": { + "dependencies": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", "inherits": "^2.0.1", "safe-buffer": "^5.1.2" } }, - "browserify-rsa": { + "node_modules/browserify-rsa": { "version": "4.0.1", "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.1.0", "randombytes": "^2.0.1" } }, - "browserify-sign": { + "node_modules/browserify-sign": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.1.1", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", @@ -497,295 +599,327 @@ "parse-asn1": "^5.0.0" } }, - "browserify-zlib": { + "node_modules/browserify-zlib": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, - "requires": { + "dependencies": { "pako": "~1.0.5" } }, - "buffer": { + "node_modules/buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", "dev": true, - "requires": { + "dependencies": { "base64-js": "^1.0.2", "ieee754": "^1.1.4" } }, - "buffer-crc32": { + "node_modules/buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "buffer-from": { + "node_modules/buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "buffer-shims": { + "node_modules/buffer-shims": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", "dev": true }, - "buffer-xor": { + "node_modules/buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, - "bufferutil": { + "node_modules/bufferutil": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.1.tgz", "integrity": "sha512-xowrxvpxojqkagPcWRQVXZl0YXhRhAtBEIq3VoER1NH5Mw1n1o0ojdspp+GS2J//2gCVyrzQDApQ4unGF+QOoA==", - "requires": { + "dev": true, + "hasInstallScript": true, + "dependencies": { "node-gyp-build": "~3.7.0" } }, - "builtin-modules": { + "node_modules/builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "builtin-status-codes": { + "node_modules/builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, - "cached-path-relative": { + "node_modules/cached-path-relative": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.1.0.tgz", "integrity": "sha512-WF0LihfemtesFcJgO7xfOoOcnWzY/QHR4qeDqV44jPU3HTI54+LnfXK3SA27AVVGCdZFgjjFFaqUA9Jx7dMJZA==", "dev": true }, - "camelcase": { + "node_modules/camelcase": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "camelcase-keys": { + "node_modules/camelcase-keys": { "version": "2.1.0", "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, - "requires": { + "dependencies": { "camelcase": "^2.0.0", "map-obj": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "caseless": { + "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", "dev": true }, - "catharsis": { + "node_modules/catharsis": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", "integrity": "sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A==", - "requires": { + "dependencies": { "lodash": "^4.17.15" + }, + "engines": { + "node": ">= 10" } }, - "center-align": { + "node_modules/center-align": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", "dev": true, - "requires": { + "dependencies": { "align-text": "^0.1.3", "lazy-cache": "^1.0.3" + }, + "engines": { + "node": ">=0.10.0" } }, - "chalk": { + "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, - "requires": { + "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "cipher-base": { + "node_modules/cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" } }, - "cli": { + "node_modules/cli": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", "integrity": "sha512-41U72MB56TfUMGndAKK8vJ78eooOD4Z5NOL4xEfjc0c23s+6EYKXlXsmACBVclLP1yOfWCgEganVzddVrSNoTg==", "dev": true, - "requires": { + "dependencies": { "exit": "0.1.2", "glob": "^7.1.1" + }, + "engines": { + "node": ">=0.2.5" } }, - "cliui": { + "node_modules/cliui": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", "dev": true, - "requires": { + "dependencies": { "center-align": "^0.1.1", "right-align": "^0.1.1", "wordwrap": "0.0.2" } }, - "color": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz", - "integrity": "sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w==", + "node_modules/color": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz", + "integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==", "dev": true, - "requires": { - "color-convert": "^1.9.1", - "color-string": "^1.5.2" + "dependencies": { + "color-convert": "^1.9.3", + "color-string": "^1.6.0" } }, - "color-convert": { + "node_modules/color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, - "requires": { + "dependencies": { "color-name": "1.1.3" } }, - "color-name": { + "node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true }, - "color-string": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.6.0.tgz", - "integrity": "sha512-c/hGS+kRWJutUBEngKKmk4iH3sD59MBkoxVapS/0wgpCz2u7XsNloxknyvBhzwEs1IbV36D9PwqLPJ2DTu3vMA==", + "node_modules/color-string": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", + "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", "dev": true, - "requires": { + "dependencies": { "color-name": "^1.0.0", "simple-swizzle": "^0.2.2" } }, - "colornames": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/colornames/-/colornames-1.1.1.tgz", - "integrity": "sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y=", - "dev": true - }, - "colors": { + "node_modules/colors": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.1.90" + } }, - "colorspace": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.1.tgz", - "integrity": "sha512-pI3btWyiuz7Ken0BWh9Elzsmv2bM9AhA7psXib4anUXy/orfZ/E0MbQwhSOG/9L8hLlalqrU0UhOuqxW1YjmVw==", + "node_modules/colorspace": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.4.tgz", + "integrity": "sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w==", "dev": true, - "requires": { - "color": "3.0.x", + "dependencies": { + "color": "^3.1.3", "text-hex": "1.0.x" } }, - "combine-source-map": { + "node_modules/combine-source-map": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, - "requires": { + "dependencies": { "convert-source-map": "~1.1.0", "inline-source-map": "~0.6.0", "lodash.memoize": "~3.0.3", "source-map": "~0.5.3" } }, - "combined-stream": { + "node_modules/combined-stream": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", "dev": true, - "requires": { + "dependencies": { "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" } }, - "concat-map": { + "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "concat-stream": { + "node_modules/concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, - "requires": { + "engines": [ + "node >= 0.8" + ], + "dependencies": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", "readable-stream": "^2.2.2", "typedarray": "^0.0.6" } }, - "console-browserify": { + "node_modules/console-browserify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", "dev": true, - "requires": { + "dependencies": { "date-now": "^0.1.4" } }, - "constants-browserify": { + "node_modules/constants-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", "dev": true }, - "convert-source-map": { + "node_modules/convert-source-map": { "version": "1.1.3", "resolved": "http://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", "dev": true }, - "core-util-is": { + "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "create-ecdh": { + "node_modules/create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.1.0", "elliptic": "^6.0.0" } }, - "create-hash": { + "node_modules/create-hash": { "version": "1.2.0", "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, - "requires": { + "dependencies": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", "md5.js": "^1.3.4", @@ -793,12 +927,12 @@ "sha.js": "^2.4.0" } }, - "create-hmac": { + "node_modules/create-hmac": { "version": "1.1.7", "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, - "requires": { + "dependencies": { "cipher-base": "^1.0.3", "create-hash": "^1.1.0", "inherits": "^2.0.1", @@ -807,34 +941,41 @@ "sha.js": "^2.4.8" } }, - "cross-spawn": { + "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, - "requires": { + "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/cross-spawn/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } }, - "crypto-browserify": { + "node_modules/crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, - "requires": { + "dependencies": { "browserify-cipher": "^1.0.0", "browserify-sign": "^4.0.0", "create-ecdh": "^4.0.0", @@ -846,206 +987,236 @@ "public-encrypt": "^4.0.0", "randombytes": "^2.0.0", "randomfill": "^1.0.3" + }, + "engines": { + "node": "*" } }, - "currently-unhandled": { + "node_modules/currently-unhandled": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", "dev": true, - "requires": { + "dependencies": { "array-find-index": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "dashdash": { + "node_modules/dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "dev": true, - "requires": { + "dependencies": { "assert-plus": "^1.0.0" + }, + "engines": { + "node": ">=0.10" } }, - "date-now": { + "node_modules/date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", "dev": true }, - "dateformat": { + "node_modules/dateformat": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "debug": { + "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, - "requires": { + "dependencies": { "ms": "2.0.0" } }, - "decamelize": { + "node_modules/decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "defined": { + "node_modules/defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", "dev": true }, - "delayed-stream": { + "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.0" + } }, - "deps-sort": { + "node_modules/deps-sort": { "version": "2.0.0", "resolved": "http://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz", "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", "dev": true, - "requires": { + "dependencies": { "JSONStream": "^1.0.3", "shasum": "^1.0.0", "subarg": "^1.0.0", "through2": "^2.0.0" + }, + "bin": { + "deps-sort": "bin/cmd.js" } }, - "des.js": { + "node_modules/des.js": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, - "detect-file": { + "node_modules/detect-file": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "detective": { + "node_modules/detective": { "version": "5.1.0", "resolved": "http://registry.npmjs.org/detective/-/detective-5.1.0.tgz", "integrity": "sha512-TFHMqfOvxlgrfVzTEkNBSh9SvSNX/HfF4OFI2QFGCyPm02EsyILqnUeb5P6q7JZ3SFNTBL5t2sePRgrN4epUWQ==", "dev": true, - "requires": { + "dependencies": { "acorn-node": "^1.3.0", "defined": "^1.0.0", "minimist": "^1.1.1" + }, + "bin": { + "detective": "bin/detective.js" + }, + "engines": { + "node": ">=0.8.0" } }, - "diagnostics": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.1.tgz", - "integrity": "sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ==", - "dev": true, - "requires": { - "colorspace": "1.1.x", - "enabled": "1.0.x", - "kuler": "1.0.x" - } - }, - "diffie-hellman": { + "node_modules/diffie-hellman": { "version": "5.0.3", "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.1.0", "miller-rabin": "^4.0.0", "randombytes": "^2.0.0" } }, - "dom-serializer": { + "node_modules/dom-serializer": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==", "dev": true, - "requires": { + "dependencies": { "domelementtype": "^2.0.1", "entities": "^2.0.0" - }, - "dependencies": { - "domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "dev": true - }, - "entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", - "dev": true + } + }, + "node_modules/dom-serializer/node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" } + ] + }, + "node_modules/dom-serializer/node_modules/entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" } }, - "domain-browser": { + "node_modules/domain-browser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4", + "npm": ">=1.2" + } }, - "domelementtype": { + "node_modules/domelementtype": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", "dev": true }, - "domhandler": { + "node_modules/domhandler": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", "integrity": "sha512-q9bUwjfp7Eif8jWxxxPSykdRZAb6GkguBGSgvvCrhI9wB71W2K/Kvv4E61CF/mcCfnVJDeDWx/Vb/uAqbDj6UQ==", "dev": true, - "requires": { + "dependencies": { "domelementtype": "1" } }, - "domutils": { + "node_modules/domutils": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", "integrity": "sha512-gSu5Oi/I+3wDENBsOWBiRK1eoGxcywYSqg3rR960/+EfY0CF4EX1VPkgHOZ3WiS/Jg2DtliF6BhWcHlfpYUcGw==", "dev": true, - "requires": { + "dependencies": { "dom-serializer": "0", "domelementtype": "1" } }, - "duplexer2": { + "node_modules/duplexer2": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, - "requires": { + "dependencies": { "readable-stream": "^2.0.2" } }, - "ecc-jsbn": { + "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", "dev": true, - "requires": { + "dependencies": { "jsbn": "~0.1.0", "safer-buffer": "^2.1.0" } }, - "elliptic": { + "node_modules/elliptic": { "version": "6.5.4", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", "hash.js": "^1.0.0", @@ -1053,381 +1224,439 @@ "inherits": "^2.0.4", "minimalistic-assert": "^1.0.1", "minimalistic-crypto-utils": "^1.0.1" - }, - "dependencies": { - "bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - } } }, - "enabled": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", - "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", - "dev": true, - "requires": { - "env-variable": "0.0.x" - } + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/elliptic/node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, - "entities": { + "node_modules/enabled": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz", + "integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==", + "dev": true + }, + "node_modules/entities": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", "integrity": "sha512-LbLqfXgJMmy81t+7c14mnulFHJ170cM6E+0vMXR9k/ZiZwgX8i5pNgjTCX3SO4VeUsFLV+8InixoretwU+MjBQ==", "dev": true }, - "env-variable": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz", - "integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA==", - "dev": true - }, - "error-ex": { + "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", "dev": true, - "requires": { + "dependencies": { "is-arrayish": "^0.2.1" } }, - "es6-promise": { + "node_modules/es6-promise": { "version": "4.2.5", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==", "dev": true }, - "es6-promisify": { + "node_modules/es6-promisify": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", "dev": true, - "requires": { + "dependencies": { "es6-promise": "^4.0.3" } }, - "escape-string-regexp": { + "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.8.0" + } }, - "esprima": { + "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } }, - "eventemitter2": { + "node_modules/eventemitter2": { "version": "0.4.14", "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=", "dev": true }, - "events": { + "node_modules/events": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/events/-/events-2.1.0.tgz", "integrity": "sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.x" + } }, - "evp_bytestokey": { + "node_modules/evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, - "requires": { + "dependencies": { "md5.js": "^1.3.4", "safe-buffer": "^5.1.1" } }, - "exit": { + "node_modules/exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8.0" + } }, - "expand-tilde": { + "node_modules/expand-tilde": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", "dev": true, - "requires": { + "dependencies": { "homedir-polyfill": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "extend": { + "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, - "extract-zip": { + "node_modules/extract-zip": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==", "dev": true, - "requires": { + "dependencies": { "concat-stream": "^1.6.2", "debug": "^2.6.9", "mkdirp": "^0.5.4", "yauzl": "^2.10.0" + }, + "bin": { + "extract-zip": "cli.js" } }, - "extsprintf": { + "node_modules/extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true + "dev": true, + "engines": [ + "node >=0.6.0" + ] }, - "fast-json-stable-stringify": { + "node_modules/fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", "dev": true }, - "fast-safe-stringify": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz", - "integrity": "sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg==", - "dev": true - }, - "fd-slicer": { + "node_modules/fd-slicer": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", "dev": true, - "requires": { + "dependencies": { "pend": "~1.2.0" } }, - "fecha": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", - "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==", + "node_modules/fecha": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz", + "integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==", "dev": true }, - "figures": { + "node_modules/figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, - "requires": { + "dependencies": { "escape-string-regexp": "^1.0.5", "object-assign": "^4.1.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "fill-range": { + "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "dev": true, - "requires": { + "dependencies": { "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" } }, - "find-up": { + "node_modules/find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "dev": true, - "requires": { + "dependencies": { "path-exists": "^2.0.0", "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "findup-sync": { + "node_modules/findup-sync": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz", "integrity": "sha1-N5MKpdgWt3fANEXhlmzGeQpMCxY=", "dev": true, - "requires": { + "dependencies": { "glob": "~5.0.0" }, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/findup-sync/node_modules/glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, "dependencies": { - "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", - "dev": true, - "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" } }, - "fined": { + "node_modules/fined": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", "dev": true, - "requires": { + "dependencies": { "expand-tilde": "^2.0.2", "is-plain-object": "^2.0.3", "object.defaults": "^1.1.0", "object.pick": "^1.2.0", "parse-filepath": "^1.0.1" + }, + "engines": { + "node": ">= 0.10" } }, - "flagged-respawn": { + "node_modules/flagged-respawn": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==", + "dev": true, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/fn.name": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", + "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", "dev": true }, - "for-in": { + "node_modules/for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "for-own": { + "node_modules/for-own": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", "dev": true, - "requires": { + "dependencies": { "for-in": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "forever-agent": { + "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "form-data": { + "node_modules/form-data": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "dev": true, - "requires": { + "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 0.12" } }, - "fs-extra": { + "node_modules/fs-extra": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", "dev": true, - "requires": { + "dependencies": { "graceful-fs": "^4.1.2", "jsonfile": "^2.1.0", "klaw": "^1.0.0" - }, - "dependencies": { - "klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.9" - } - } } }, - "fs.realpath": { + "node_modules/fs-extra/node_modules/klaw": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", + "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", + "dev": true, + "optionalDependencies": { + "graceful-fs": "^4.1.9" + } + }, + "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "function-bind": { + "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "get-assigned-identifiers": { + "node_modules/get-assigned-identifiers": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", "dev": true }, - "get-stdin": { + "node_modules/get-stdin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "getobject": { + "node_modules/getobject": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/getobject/-/getobject-1.0.2.tgz", "integrity": "sha512-2zblDBaFcb3rB4rF77XVnuINOE2h2k/OnqXAiy0IrTxUfV1iFp3la33oAQVY9pCpWU268WFYVt2t71hlMuLsOg==", - "dev": true + "dev": true, + "engines": { + "node": ">=10" + } }, - "getpass": { + "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "dev": true, - "requires": { + "dependencies": { "assert-plus": "^1.0.0" } }, - "glob": { + "node_modules/glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, - "requires": { + "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" } }, - "global-modules": { + "node_modules/global-modules": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", "dev": true, - "requires": { + "dependencies": { "global-prefix": "^1.0.1", "is-windows": "^1.0.1", "resolve-dir": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "global-prefix": { + "node_modules/global-prefix": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", "dev": true, - "requires": { + "dependencies": { "expand-tilde": "^2.0.2", "homedir-polyfill": "^1.0.1", "ini": "^1.3.4", "is-windows": "^1.0.1", "which": "^1.2.14" + }, + "engines": { + "node": ">=0.10.0" } }, - "graceful-fs": { + "node_modules/graceful-fs": { "version": "4.1.15", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" }, - "grunt": { + "node_modules/grunt": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/grunt/-/grunt-1.5.3.tgz", "integrity": "sha512-mKwmo4X2d8/4c/BmcOETHek675uOqw0RuA/zy12jaspWqvTp4+ZeQF1W+OTpcbncnaBsfbQJ6l0l4j+Sn/GmaQ==", "dev": true, - "requires": { + "dependencies": { "dateformat": "~3.0.3", "eventemitter2": "~0.4.13", "exit": "~0.1.2", @@ -1444,220 +1673,225 @@ "nopt": "~3.0.6", "rimraf": "~3.0.2" }, - "dependencies": { - "glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "minimatch": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", - "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true - }, - "nopt": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", - "dev": true, - "requires": { - "abbrev": "1" - } - }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } + "bin": { + "grunt": "bin/grunt" + }, + "engines": { + "node": ">=8" } }, - "grunt-cli": { + "node_modules/grunt-cli": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/grunt-cli/-/grunt-cli-1.4.3.tgz", "integrity": "sha512-9Dtx/AhVeB4LYzsViCjUQkd0Kw0McN2gYpdmGYKtE2a5Yt7v1Q+HYZVWhqXc/kGnxlMtqKDxSwotiGeFmkrCoQ==", "dev": true, - "requires": { + "dependencies": { "grunt-known-options": "~2.0.0", "interpret": "~1.1.0", "liftup": "~3.0.1", "nopt": "~4.0.1", "v8flags": "~3.2.0" + }, + "bin": { + "grunt": "bin/grunt" + }, + "engines": { + "node": ">=10" } }, - "grunt-contrib-concat": { + "node_modules/grunt-contrib-concat": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/grunt-contrib-concat/-/grunt-contrib-concat-1.0.1.tgz", "integrity": "sha1-YVCYYwhOhx1+ht5IwBUlntl3Rb0=", "dev": true, - "requires": { + "dependencies": { "chalk": "^1.0.0", "source-map": "^0.5.3" }, + "engines": { + "node": ">=0.10.0" + }, + "peerDependencies": { + "grunt": ">=0.4.0" + } + }, + "node_modules/grunt-contrib-concat/node_modules/ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/grunt-contrib-concat/node_modules/chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/grunt-contrib-concat/node_modules/supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true, + "engines": { + "node": ">=0.8.0" } }, - "grunt-contrib-jshint": { + "node_modules/grunt-contrib-jshint": { "version": "3.2.0", "resolved": "http://registry.npmjs.org/grunt-contrib-jshint/-/grunt-contrib-jshint-3.2.0.tgz", "integrity": "sha512-pcXWCSZWfoMSvcV4BwH21TUtLtcX0Ms8IGuOPIcLeXK3fud9KclY7iqMKY94jFx8TxZzh028YYtpR+io8DiEaQ==", "dev": true, - "requires": { + "dependencies": { "chalk": "~4.1.2", "hooker": "^0.2.3", "jshint": "~2.13.4" + }, + "engines": { + "node": ">=10" } }, - "grunt-contrib-qunit": { + "node_modules/grunt-contrib-qunit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/grunt-contrib-qunit/-/grunt-contrib-qunit-3.1.0.tgz", "integrity": "sha512-mdk8UltH6mxCD63E0hTXMAts42DOi4z4bBBrY7qnuHiShflMF7IueSMYe0zWaZ2dO8mgujh57Zfny2EbigJhRg==", "dev": true, - "requires": { + "dependencies": { "eventemitter2": "^5.0.1", "p-each-series": "^1.0.0", "puppeteer": "^1.11.0" }, - "dependencies": { - "eventemitter2": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-5.0.1.tgz", - "integrity": "sha1-YZegldX7a1folC9v1+qtY6CclFI=", - "dev": true - } + "engines": { + "node": ">=6" } }, - "grunt-contrib-uglify": { + "node_modules/grunt-contrib-qunit/node_modules/eventemitter2": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-5.0.1.tgz", + "integrity": "sha1-YZegldX7a1folC9v1+qtY6CclFI=", + "dev": true + }, + "node_modules/grunt-contrib-uglify": { "version": "1.0.2", "resolved": "http://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-1.0.2.tgz", "integrity": "sha1-rmekb5FT7dTLEYE6Vetpxw19svs=", "dev": true, - "requires": { + "dependencies": { "chalk": "^1.0.0", "lodash": "^4.0.1", "maxmin": "^1.1.0", "uglify-js": "~2.6.2", "uri-path": "^1.0.0" }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/grunt-contrib-uglify/node_modules/ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/grunt-contrib-uglify/node_modules/chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/grunt-contrib-uglify/node_modules/supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true, + "engines": { + "node": ">=0.8.0" } }, - "grunt-jsdoc": { + "node_modules/grunt-jsdoc": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/grunt-jsdoc/-/grunt-jsdoc-2.4.1.tgz", "integrity": "sha512-S0zxU0wDewRu7z+vijEItOWe/UttxWVmvz0qz2ZVcAYR2GpXjsiski2CAVN0b18t2qeVLdmxZkJaEWCOsKzcAw==", "dev": true, - "requires": { + "dependencies": { "cross-spawn": "^7.0.1", "jsdoc": "^3.6.3" + }, + "bin": { + "grunt-jsdoc": "bin/grunt-jsdoc" + }, + "engines": { + "node": ">= 8.12.0" } }, - "grunt-known-options": { + "node_modules/grunt-known-options": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-2.0.0.tgz", "integrity": "sha512-GD7cTz0I4SAede1/+pAbmJRG44zFLPipVtdL9o3vqx9IEyb7b4/Y3s7r6ofI3CchR5GvYJ+8buCSioDv5dQLiA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "grunt-legacy-log": { + "node_modules/grunt-legacy-log": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-3.0.0.tgz", "integrity": "sha512-GHZQzZmhyq0u3hr7aHW4qUH0xDzwp2YXldLPZTCjlOeGscAOWWPftZG3XioW8MasGp+OBRIu39LFx14SLjXRcA==", "dev": true, - "requires": { + "dependencies": { "colors": "~1.1.2", "grunt-legacy-log-utils": "~2.1.0", "hooker": "~0.2.3", "lodash": "~4.17.19" + }, + "engines": { + "node": ">= 0.10.0" } }, - "grunt-legacy-log-utils": { + "node_modules/grunt-legacy-log-utils": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-2.1.0.tgz", "integrity": "sha512-lwquaPXJtKQk0rUM1IQAop5noEpwFqOXasVoedLeNzaibf/OPWjKYvvdqnEHNmU+0T0CaReAXIbGo747ZD+Aaw==", "dev": true, - "requires": { + "dependencies": { "chalk": "~4.1.0", "lodash": "~4.17.19" + }, + "engines": { + "node": ">=10" } }, - "grunt-legacy-util": { + "node_modules/grunt-legacy-util": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-2.0.1.tgz", "integrity": "sha512-2bQiD4fzXqX8rhNdXkAywCadeqiPiay0oQny77wA2F3WF4grPJXCvAcyoWUJV+po/b15glGkxuSiQCK299UC2w==", "dev": true, - "requires": { + "dependencies": { "async": "~3.2.0", "exit": "~0.1.2", "getobject": "~1.0.0", @@ -1666,507 +1900,683 @@ "underscore.string": "~3.3.5", "which": "~2.0.2" }, + "engines": { + "node": ">=10" + } + }, + "node_modules/grunt-legacy-util/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } }, - "grunt-shell-spawn": { + "node_modules/grunt-shell-spawn": { "version": "0.3.12", "resolved": "https://registry.npmjs.org/grunt-shell-spawn/-/grunt-shell-spawn-0.3.12.tgz", "integrity": "sha512-TprZct92sQ4M2Q92piaeLsCrx4+gq/ageuxjZsRG6cglKt7x7rGA3YHt8D30+G789v+/pw4l0tDjEyrkMXx2tA==", "dev": true, - "requires": { + "dependencies": { "grunt": ">=0.4.x" + }, + "bin": { + "grunt-shell-spawn": "bin/grunt-shell-spawn" + }, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/grunt/node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/grunt/node_modules/minimatch": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/grunt/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/grunt/node_modules/nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" } }, - "gzip-size": { + "node_modules/grunt/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/gzip-size": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-1.0.0.tgz", "integrity": "sha1-Zs+LEBBHInuVus5uodoMF37Vwi8=", "dev": true, - "requires": { + "dependencies": { "browserify-zlib": "^0.1.4", "concat-stream": "^1.4.1" }, + "bin": { + "gzip-size": "cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/gzip-size/node_modules/browserify-zlib": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", + "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", + "dev": true, "dependencies": { - "browserify-zlib": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", - "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", - "dev": true, - "requires": { - "pako": "~0.2.0" - } - }, - "pako": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", - "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", - "dev": true - } + "pako": "~0.2.0" } }, - "har-schema": { + "node_modules/gzip-size/node_modules/pako": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", + "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", + "dev": true + }, + "node_modules/har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "har-validator": { + "node_modules/har-validator": { "version": "5.1.3", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "deprecated": "this library is no longer supported", "dev": true, - "requires": { + "dependencies": { "ajv": "^6.5.5", "har-schema": "^2.0.0" + }, + "engines": { + "node": ">=6" } }, - "has": { + "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, - "requires": { + "dependencies": { "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" } }, - "has-ansi": { + "node_modules/has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, - "requires": { + "dependencies": { "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "has-flag": { + "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "hash-base": { + "node_modules/hash-base": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" + }, + "engines": { + "node": ">=4" } }, - "hash.js": { + "node_modules/hash.js": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" } }, - "hasha": { + "node_modules/hasha": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", "dev": true, - "requires": { + "dependencies": { "is-stream": "^1.0.1", "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "hmac-drbg": { + "node_modules/hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, - "requires": { + "dependencies": { "hash.js": "^1.0.3", "minimalistic-assert": "^1.0.0", "minimalistic-crypto-utils": "^1.0.1" } }, - "homedir-polyfill": { + "node_modules/homedir-polyfill": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", "dev": true, - "requires": { + "dependencies": { "parse-passwd": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "hooker": { + "node_modules/hooker": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "hosted-git-info": { + "node_modules/hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, - "htmlescape": { + "node_modules/htmlescape": { "version": "1.1.1", "resolved": "http://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10" + } }, - "htmlparser2": { + "node_modules/htmlparser2": { "version": "3.8.3", "resolved": "http://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", "integrity": "sha512-hBxEg3CYXe+rPIua8ETe7tmG3XDn9B0edOE/e9wH2nLczxzgdu0m0aNHY+5wFZiviLWLdANPJTssa92dMcXQ5Q==", "dev": true, - "requires": { + "dependencies": { "domelementtype": "1", "domhandler": "2.3", "domutils": "1.5", "entities": "1.0", "readable-stream": "1.1" - }, + } + }, + "node_modules/htmlparser2/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", + "dev": true + }, + "node_modules/htmlparser2/node_modules/readable-stream": { + "version": "1.1.14", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", + "dev": true, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", - "dev": true - } + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" } }, - "http-signature": { + "node_modules/htmlparser2/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", + "dev": true + }, + "node_modules/http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "dev": true, - "requires": { + "dependencies": { "assert-plus": "^1.0.0", "jsprim": "^1.2.2", "sshpk": "^1.7.0" + }, + "engines": { + "node": ">=0.8", + "npm": ">=1.3.7" } }, - "https-browserify": { + "node_modules/https-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", "dev": true }, - "https-proxy-agent": { + "node_modules/https-proxy-agent": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", "dev": true, - "requires": { + "dependencies": { "agent-base": "^4.3.0", "debug": "^3.1.0" }, + "engines": { + "node": ">= 4.5.0" + } + }, + "node_modules/https-proxy-agent/node_modules/agent-base": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", + "dev": true, + "dependencies": { + "es6-promisify": "^5.0.0" + }, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/https-proxy-agent/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, "dependencies": { - "agent-base": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", - "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", - "dev": true, - "requires": { - "es6-promisify": "^5.0.0" - } - }, - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - } + "ms": "^2.1.1" } }, - "iconv-lite": { + "node_modules/https-proxy-agent/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, - "requires": { + "dependencies": { "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" } }, - "ieee754": { + "node_modules/ieee754": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==", "dev": true }, - "indent-string": { + "node_modules/indent-string": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", "dev": true, - "requires": { + "dependencies": { "repeating": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "inflight": { + "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, - "requires": { + "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, - "inherits": { + "node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "ini": { + "node_modules/ini": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "dev": true }, - "inline-source-map": { + "node_modules/inline-source-map": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", "dev": true, - "requires": { + "dependencies": { "source-map": "~0.5.3" } }, - "insert-module-globals": { + "node_modules/insert-module-globals": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", "dev": true, - "requires": { - "JSONStream": "^1.0.3", + "dependencies": { "acorn-node": "^1.5.2", "combine-source-map": "^0.8.0", "concat-stream": "^1.6.1", "is-buffer": "^1.1.0", + "JSONStream": "^1.0.3", "path-is-absolute": "^1.0.1", "process": "~0.11.0", "through2": "^2.0.0", "undeclared-identifiers": "^1.1.2", "xtend": "^4.0.0" + }, + "bin": { + "insert-module-globals": "bin/cmd.js" } }, - "interpret": { + "node_modules/interpret": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", "dev": true }, - "is-absolute": { + "node_modules/is-absolute": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", "dev": true, - "requires": { + "dependencies": { "is-relative": "^1.0.0", "is-windows": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-arrayish": { + "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, - "is-buffer": { + "node_modules/is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, - "is-builtin-module": { + "node_modules/is-builtin-module": { "version": "1.0.0", "resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, - "requires": { + "dependencies": { "builtin-modules": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-core-module": { + "node_modules/is-core-module": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz", "integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==", "dev": true, - "requires": { + "dependencies": { "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "is-extglob": { + "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "is-finite": { + "node_modules/is-finite": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", "dev": true, - "requires": { + "dependencies": { "number-is-nan": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-glob": { + "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, - "requires": { + "dependencies": { "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-number": { + "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.12.0" + } }, - "is-plain-object": { + "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, - "requires": { + "dependencies": { "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-relative": { + "node_modules/is-relative": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", "dev": true, - "requires": { + "dependencies": { "is-unc-path": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-stream": { + "node_modules/is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "is-typedarray": { + "node_modules/is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, - "is-unc-path": { + "node_modules/is-unc-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", "dev": true, - "requires": { + "dependencies": { "unc-path-regex": "^0.1.2" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-utf8": { + "node_modules/is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", "dev": true }, - "is-windows": { + "node_modules/is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "isarray": { + "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "isexe": { + "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "isobject": { + "node_modules/isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "isstream": { + "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, - "js-yaml": { + "node_modules/js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "dev": true, - "requires": { + "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" } }, - "js2xmlparser": { + "node_modules/js2xmlparser": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz", "integrity": "sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==", - "requires": { + "dependencies": { "xmlcreate": "^2.0.4" } }, - "jsbn": { + "node_modules/jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "dev": true }, - "jsdoc": { + "node_modules/jsdoc": { "version": "3.6.11", "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.11.tgz", "integrity": "sha512-8UCU0TYeIYD9KeLzEcAu2q8N/mx9O3phAGl32nmHlE0LpaJL71mMkP4d+QE5zWfNt50qheHtOZ0qoxVrsX5TUg==", - "requires": { + "dependencies": { "@babel/parser": "^7.9.4", "@types/markdown-it": "^12.2.3", "bluebird": "^3.7.2", @@ -2183,25 +2593,38 @@ "taffydb": "2.6.2", "underscore": "~1.13.2" }, - "dependencies": { - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==" - }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" - } + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/jsdoc/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/jsdoc/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" } }, - "jshint": { + "node_modules/jshint": { "version": "2.13.5", "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.13.5.tgz", "integrity": "sha512-dB2n1w3OaQ35PLcBGIWXlszjbPZwsgZoxsg6G8PtNf2cFMC1l0fObkYLUuXqTTdi6tKw4sAjfUseTdmDMHQRcg==", "dev": true, - "requires": { + "dependencies": { "cli": "~1.0.0", "console-browserify": "1.1.x", "exit": "0.1.x", @@ -2210,204 +2633,245 @@ "minimatch": "~3.0.2", "strip-json-comments": "1.0.x" }, + "bin": { + "jshint": "bin/jshint" + } + }, + "node_modules/jshint/node_modules/minimatch": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "dev": true, "dependencies": { - "minimatch": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", - "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "strip-json-comments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "integrity": "sha512-AOPG8EBc5wAikaG1/7uFCNFJwnKOuQwFTpYBdTW6OvWHeZBQBrAA/amefHGrEiOnCPcLFZK6FUPtWVKpQVIRgg==", - "dev": true - } + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/jshint/node_modules/strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha512-AOPG8EBc5wAikaG1/7uFCNFJwnKOuQwFTpYBdTW6OvWHeZBQBrAA/amefHGrEiOnCPcLFZK6FUPtWVKpQVIRgg==", + "dev": true, + "bin": { + "strip-json-comments": "cli.js" + }, + "engines": { + "node": ">=0.8.0" } }, - "jslint": { + "node_modules/jslint": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/jslint/-/jslint-0.12.0.tgz", "integrity": "sha512-RoCsyICcKA+6TFsbys9DpKTfPVaC71Mm5QSjvrWA0lDVN+LIvx6apa42FFisMqmCTvJ8DxkcoQGJ0j7m3kTVow==", "dev": true, - "requires": { + "dependencies": { "exit": "~0.1.2", "glob": "~7.1.2", "nopt": "~3.0.1", "readable-stream": "~2.1.5" }, + "bin": { + "jslint": "bin/jslint.js" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/jslint/node_modules/nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, "dependencies": { - "nopt": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", - "dev": true, - "requires": { - "abbrev": "1" - } - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.1.5", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", - "integrity": "sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA=", - "dev": true, - "requires": { - "buffer-shims": "^1.0.0", - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" } }, - "json-int64": { + "node_modules/jslint/node_modules/process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "node_modules/jslint/node_modules/readable-stream": { + "version": "2.1.5", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "integrity": "sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA=", + "dev": true, + "dependencies": { + "buffer-shims": "^1.0.0", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/jslint/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "node_modules/json-int64": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-int64/-/json-int64-1.0.0.tgz", "integrity": "sha512-yrTg9swToElhEPETLMdZkEzDhbXLs+cxkw/b2rglMPOBlM1DE0utH1EReSMLcnpYJk5iUvD12r0fP2/xHitF5Q==", - "requires": { + "dependencies": { "node-int64": "0.4.0" } }, - "json-schema-traverse": { + "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, - "json-stable-stringify": { + "node_modules/json-stable-stringify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", "dev": true, - "requires": { + "dependencies": { "jsonify": "~0.0.0" } }, - "json-stringify-safe": { + "node_modules/json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, - "jsonfile": { + "node_modules/jsonfile": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "dev": true, - "requires": { + "optionalDependencies": { "graceful-fs": "^4.1.6" } }, - "jsonify": { + "node_modules/jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "jsonparse": { + "node_modules/jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true + "dev": true, + "engines": [ + "node >= 0.2.0" + ] }, - "jsprim": { + "node_modules/JSONStream": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", + "dev": true, + "dependencies": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + }, + "bin": { + "JSONStream": "bin.js" + }, + "engines": { + "node": "*" + } + }, + "node_modules/jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", "dev": true, - "requires": { + "dependencies": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", "json-schema": "0.4.0", "verror": "1.10.0" }, - "dependencies": { - "json-schema": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", - "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", - "dev": true - } + "engines": { + "node": ">=0.6.0" } }, - "kew": { + "node_modules/jsprim/node_modules/json-schema": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", + "dev": true + }, + "node_modules/kew": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", "integrity": "sha1-edk9LTM2PW/dKXCzNdkUGtWR15s=", "dev": true }, - "kind-of": { + "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "klaw": { + "node_modules/klaw": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", - "requires": { + "dependencies": { "graceful-fs": "^4.1.9" } }, - "kuler": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz", - "integrity": "sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ==", - "dev": true, - "requires": { - "colornames": "^1.1.1" - } + "node_modules/kuler": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", + "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==", + "dev": true }, - "labeled-stream-splicer": { + "node_modules/labeled-stream-splicer": { "version": "2.0.1", "resolved": "http://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz", "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "isarray": "^2.0.4", "stream-splicer": "^2.0.0" - }, - "dependencies": { - "isarray": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz", - "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==", - "dev": true - } } }, - "lazy-cache": { + "node_modules/labeled-stream-splicer/node_modules/isarray": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz", + "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==", + "dev": true + }, + "node_modules/lazy-cache": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "liftup": { + "node_modules/liftup": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/liftup/-/liftup-3.0.1.tgz", "integrity": "sha512-yRHaiQDizWSzoXk3APcA71eOI/UuhEkNN9DiW2Tt44mhYzX4joFoCZlxsSOF7RyeLlfqzFLQI1ngFq3ggMPhOw==", "dev": true, - "requires": { + "dependencies": { "extend": "^3.0.2", "findup-sync": "^4.0.0", "fined": "^1.2.0", @@ -2417,222 +2881,264 @@ "rechoir": "^0.7.0", "resolve": "^1.19.0" }, + "engines": { + "node": ">=10" + } + }, + "node_modules/liftup/node_modules/findup-sync": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-4.0.0.tgz", + "integrity": "sha512-6jvvn/12IC4quLBL1KNokxC7wWTvYncaVUYSoxWw7YykPLuRrnv4qdHcSOywOI5RpkOVGeQRtWM8/q+G6W6qfQ==", + "dev": true, "dependencies": { - "findup-sync": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-4.0.0.tgz", - "integrity": "sha512-6jvvn/12IC4quLBL1KNokxC7wWTvYncaVUYSoxWw7YykPLuRrnv4qdHcSOywOI5RpkOVGeQRtWM8/q+G6W6qfQ==", - "dev": true, - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^4.0.0", - "micromatch": "^4.0.2", - "resolve-dir": "^1.0.1" - } - }, - "resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", - "dev": true, - "requires": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" - } - } + "detect-file": "^1.0.0", + "is-glob": "^4.0.0", + "micromatch": "^4.0.2", + "resolve-dir": "^1.0.1" + }, + "engines": { + "node": ">= 8" } }, - "linkify-it": { + "node_modules/liftup/node_modules/resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "dependencies": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/linkify-it": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", - "requires": { + "dependencies": { "uc.micro": "^1.0.1" } }, - "load-json-file": { + "node_modules/load-json-file": { "version": "1.1.0", "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, - "requires": { + "dependencies": { "graceful-fs": "^4.1.2", "parse-json": "^2.2.0", "pify": "^2.0.0", "pinkie-promise": "^2.0.0", "strip-bom": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "lodash": { + "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "lodash.memoize": { + "node_modules/lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", "dev": true }, - "logform": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/logform/-/logform-1.10.0.tgz", - "integrity": "sha512-em5ojIhU18fIMOw/333mD+ZLE2fis0EzXl1ZwHx4iQzmpQi6odNiY/t+ITNr33JZhT9/KEaH+UPIipr6a9EjWg==", + "node_modules/logform": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/logform/-/logform-2.5.1.tgz", + "integrity": "sha512-9FyqAm9o9NKKfiAKfZoYo9bGXXuwMkxQiQttkT4YjjVtQVIQtK6LmVtlxmCaFswo6N4AfEkHqZTV0taDtPotNg==", "dev": true, - "requires": { - "colors": "^1.2.1", - "fast-safe-stringify": "^2.0.4", - "fecha": "^2.3.3", + "dependencies": { + "@colors/colors": "1.5.0", + "@types/triple-beam": "^1.3.2", + "fecha": "^4.2.0", "ms": "^2.1.1", - "triple-beam": "^1.2.0" - }, - "dependencies": { - "colors": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", - "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==", - "dev": true - }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true - } + "safe-stable-stringify": "^2.3.1", + "triple-beam": "^1.3.0" } }, - "longest": { + "node_modules/logform/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "loud-rejection": { + "node_modules/loud-rejection": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", "dev": true, - "requires": { + "dependencies": { "currently-unhandled": "^0.4.1", "signal-exit": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "make-iterator": { + "node_modules/make-iterator": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", "dev": true, - "requires": { + "dependencies": { "kind-of": "^6.0.2" + }, + "engines": { + "node": ">=0.10.0" } }, - "map-cache": { + "node_modules/map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "map-obj": { + "node_modules/map-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "markdown-it": { + "node_modules/markdown-it": { "version": "12.3.2", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", - "requires": { + "dependencies": { "argparse": "^2.0.1", "entities": "~2.1.0", "linkify-it": "^3.0.1", "mdurl": "^1.0.1", "uc.micro": "^1.0.5" }, - "dependencies": { - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "entities": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", - "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==" - } + "bin": { + "markdown-it": "bin/markdown-it.js" } }, - "markdown-it-anchor": { + "node_modules/markdown-it-anchor": { "version": "8.6.5", "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.5.tgz", - "integrity": "sha512-PI1qEHHkTNWT+X6Ip9w+paonfIQ+QZP9sCeMYi47oqhH+EsW8CrJ8J7CzV19QVOj6il8ATGbK2nTECj22ZHGvQ==" + "integrity": "sha512-PI1qEHHkTNWT+X6Ip9w+paonfIQ+QZP9sCeMYi47oqhH+EsW8CrJ8J7CzV19QVOj6il8ATGbK2nTECj22ZHGvQ==", + "peerDependencies": { + "@types/markdown-it": "*", + "markdown-it": "*" + } + }, + "node_modules/markdown-it/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/markdown-it/node_modules/entities": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", + "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } }, - "marked": { + "node_modules/marked": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/marked/-/marked-4.1.1.tgz", - "integrity": "sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw==" + "integrity": "sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw==", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } }, - "maxmin": { + "node_modules/maxmin": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/maxmin/-/maxmin-1.1.0.tgz", "integrity": "sha1-cTZehKmd2Piz99X94vANHn9zvmE=", "dev": true, - "requires": { + "dependencies": { "chalk": "^1.0.0", "figures": "^1.0.1", "gzip-size": "^1.0.0", "pretty-bytes": "^1.0.0" }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/maxmin/node_modules/ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/maxmin/node_modules/chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/maxmin/node_modules/supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true, + "engines": { + "node": ">=0.8.0" } }, - "md5.js": { + "node_modules/md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, - "requires": { + "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1", "safe-buffer": "^5.1.2" } }, - "mdurl": { + "node_modules/mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==" }, - "meow": { + "node_modules/meow": { "version": "3.7.0", "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, - "requires": { + "dependencies": { "camelcase-keys": "^2.0.0", "decamelize": "^1.1.2", "loud-rejection": "^1.0.0", @@ -2643,92 +3149,118 @@ "read-pkg-up": "^1.0.1", "redent": "^1.0.0", "trim-newlines": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "micromatch": { + "node_modules/micromatch": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", "dev": true, - "requires": { + "dependencies": { "braces": "^3.0.1", "picomatch": "^2.2.3" + }, + "engines": { + "node": ">=8.6" } }, - "miller-rabin": { + "node_modules/miller-rabin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.0.0", "brorand": "^1.0.1" + }, + "bin": { + "miller-rabin": "bin/miller-rabin" } }, - "mime": { + "node_modules/mime": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz", "integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==", - "dev": true + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } }, - "mime-db": { + "node_modules/mime-db": { "version": "1.37.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "mime-types": { + "node_modules/mime-types": { "version": "2.1.21", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", "dev": true, - "requires": { + "dependencies": { "mime-db": "~1.37.0" + }, + "engines": { + "node": ">= 0.6" } }, - "minimalistic-assert": { + "node_modules/minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", "dev": true }, - "minimalistic-crypto-utils": { + "node_modules/minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", "dev": true }, - "minimatch": { + "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, - "requires": { + "dependencies": { "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" } }, - "minimist": { + "node_modules/minimist": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, - "mkdirp": { + "node_modules/mkdirp": { "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "dev": true, - "requires": { + "dependencies": { "minimist": "^1.2.5" + }, + "bin": { + "mkdirp": "bin/cmd.js" } }, - "module-deps": { + "node_modules/module-deps": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.0.tgz", "integrity": "sha512-hKPmO06so6bL/ZvqVNVqdTVO8UAYsi3tQWlCa+z9KuWhoN4KDQtb5hcqQQv58qYiDE21wIvnttZEPiDgEbpwbA==", "dev": true, - "requires": { - "JSONStream": "^1.0.3", + "dependencies": { "browser-resolve": "^1.7.0", "cached-path-relative": "^1.0.0", "concat-stream": "~1.6.0", @@ -2736,6 +3268,7 @@ "detective": "^5.0.2", "duplexer2": "^0.1.2", "inherits": "^2.0.1", + "JSONStream": "^1.0.3", "parents": "^1.0.0", "readable-stream": "^2.0.2", "resolve": "^1.4.0", @@ -2743,170 +3276,218 @@ "subarg": "^1.0.0", "through2": "^2.0.0", "xtend": "^4.0.0" + }, + "bin": { + "module-deps": "bin/cmd.js" + }, + "engines": { + "node": ">= 0.8.0" } }, - "ms": { + "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "node-gyp-build": { + "node_modules/node-gyp-build": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-3.7.0.tgz", - "integrity": "sha512-L/Eg02Epx6Si2NXmedx+Okg+4UHqmaf3TNcxd50SF9NQGcJaON3AtU++kax69XV7YWz4tUspqZSAsVofhFKG2w==" + "integrity": "sha512-L/Eg02Epx6Si2NXmedx+Okg+4UHqmaf3TNcxd50SF9NQGcJaON3AtU++kax69XV7YWz4tUspqZSAsVofhFKG2w==", + "dev": true, + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } }, - "node-int64": { + "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", "integrity": "sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=" }, - "nopt": { + "node_modules/nopt": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", - "requires": { + "dependencies": { "abbrev": "1", "osenv": "^0.1.4" + }, + "bin": { + "nopt": "bin/nopt.js" } }, - "normalize-package-data": { + "node_modules/normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, - "requires": { + "dependencies": { "hosted-git-info": "^2.1.4", "is-builtin-module": "^1.0.0", "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } }, - "number-is-nan": { + "node_modules/number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "oauth-sign": { + "node_modules/oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "object-assign": { + "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "object.defaults": { + "node_modules/object.defaults": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", "dev": true, - "requires": { + "dependencies": { "array-each": "^1.0.1", "array-slice": "^1.0.0", "for-own": "^1.0.0", "isobject": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "object.map": { + "node_modules/object.map": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz", "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", "dev": true, - "requires": { + "dependencies": { "for-own": "^1.0.0", "make-iterator": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "object.pick": { + "node_modules/object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, - "requires": { + "dependencies": { "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "once": { + "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "requires": { + "dependencies": { "wrappy": "1" } }, - "one-time": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz", - "integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4=", - "dev": true + "node_modules/one-time": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz", + "integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==", + "dev": true, + "dependencies": { + "fn.name": "1.x.x" + } }, - "os-browserify": { + "node_modules/os-browserify": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", "dev": true }, - "os-homedir": { + "node_modules/os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "engines": { + "node": ">=0.10.0" + } }, - "os-tmpdir": { + "node_modules/os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "engines": { + "node": ">=0.10.0" + } }, - "osenv": { + "node_modules/osenv": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", - "requires": { + "dependencies": { "os-homedir": "^1.0.0", "os-tmpdir": "^1.0.0" } }, - "p-each-series": { + "node_modules/p-each-series": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-each-series/-/p-each-series-1.0.0.tgz", "integrity": "sha1-kw89Et0fUOdDRFeiLNbwSsatf3E=", "dev": true, - "requires": { + "dependencies": { "p-reduce": "^1.0.0" + }, + "engines": { + "node": ">=4" } }, - "p-reduce": { + "node_modules/p-reduce": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-reduce/-/p-reduce-1.0.0.tgz", "integrity": "sha1-GMKw3ZNqRpClKfgjH1ig/bakffo=", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "pako": { + "node_modules/pako": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.7.tgz", "integrity": "sha512-3HNK5tW4x8o5mO8RuHZp3Ydw9icZXx0RANAOMzlMzx7LVXhMJ4mo3MOBpzyd7r/+RUu8BmndP47LXT+vzjtWcQ==", "dev": true }, - "parents": { + "node_modules/parents": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", "dev": true, - "requires": { + "dependencies": { "path-platform": "~0.11.15" } }, - "parse-asn1": { + "node_modules/parse-asn1": { "version": "5.1.1", "resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", "dev": true, - "requires": { + "dependencies": { "asn1.js": "^4.0.0", "browserify-aes": "^1.0.0", "create-hash": "^1.1.0", @@ -2914,139 +3495,181 @@ "pbkdf2": "^3.0.3" } }, - "parse-filepath": { + "node_modules/parse-filepath": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", "dev": true, - "requires": { + "dependencies": { "is-absolute": "^1.0.0", "map-cache": "^0.2.0", "path-root": "^0.1.1" + }, + "engines": { + "node": ">=0.8" } }, - "parse-json": { + "node_modules/parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", "dev": true, - "requires": { + "dependencies": { "error-ex": "^1.2.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "parse-passwd": { + "node_modules/parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "path-browserify": { + "node_modules/path-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", "dev": true }, - "path-exists": { + "node_modules/path-exists": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", "dev": true, - "requires": { + "dependencies": { "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "path-is-absolute": { + "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "path-key": { + "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "path-parse": { + "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, - "path-platform": { + "node_modules/path-platform": { "version": "0.11.15", "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8.0" + } }, - "path-root": { + "node_modules/path-root": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", "dev": true, - "requires": { + "dependencies": { "path-root-regex": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "path-root-regex": { + "node_modules/path-root-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "path-type": { + "node_modules/path-type": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", "dev": true, - "requires": { + "dependencies": { "graceful-fs": "^4.1.2", "pify": "^2.0.0", "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "pbkdf2": { + "node_modules/pbkdf2": { "version": "3.0.17", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "dev": true, - "requires": { + "dependencies": { "create-hash": "^1.1.2", "create-hmac": "^1.1.4", "ripemd160": "^2.0.1", "safe-buffer": "^5.0.1", "sha.js": "^2.4.8" + }, + "engines": { + "node": ">=0.12" } }, - "pend": { + "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", "dev": true }, - "performance-now": { + "node_modules/performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, - "phantom": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/phantom/-/phantom-6.0.3.tgz", - "integrity": "sha512-8bb8urWoUiZ0E+JC4goaYBDPxljTnnxGwogz5cvash2SQovf//QAPoshXQz06kY/tpI+5caBVng0K0oZkVMNIQ==", + "node_modules/phantom": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/phantom/-/phantom-6.3.0.tgz", + "integrity": "sha512-Ptlwjp5eJiBmr3KQzFr9V/ehhcC+PGyJB38q7mnxJiwrssOEtmIWDEzQ7gIsdOXlHoW0n0+KjdAdP9U89Cm9Pw==", + "deprecated": "This package is no longer maintained", "dev": true, - "requires": { + "dependencies": { "phantomjs-prebuilt": "^2.1.16", "split": "^1.0.1", - "winston": "^3.0.0" + "winston": "^3.2.1" + }, + "bin": { + "phantom": "bin/phantom.js" + }, + "engines": { + "node": ">=8" } }, - "phantomjs-prebuilt": { + "node_modules/phantomjs-prebuilt": { "version": "2.1.16", "resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz", - "integrity": "sha1-79ISpKOWbTZHaE6ouniFSb4q7+8=", + "integrity": "sha512-PIiRzBhW85xco2fuj41FmsyuYHKjKuXWmhjy3A/Y+CMpN/63TV+s9uzfVhsUwFe0G77xWtHBG8xmXf5BqEUEuQ==", + "deprecated": "this package is now deprecated", "dev": true, - "requires": { + "hasInstallScript": true, + "dependencies": { "es6-promise": "^4.0.3", "extract-zip": "^1.6.5", "fs-extra": "^1.0.0", @@ -3057,88 +3680,119 @@ "request-progress": "^2.0.1", "which": "^1.2.10" }, - "dependencies": { - "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", - "dev": true - } + "bin": { + "phantomjs": "bin/phantomjs" + } + }, + "node_modules/phantomjs-prebuilt/node_modules/progress": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", + "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "dev": true, + "engines": { + "node": ">=0.4.0" } }, - "picomatch": { + "node_modules/picomatch": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", - "dev": true + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } }, - "pify": { + "node_modules/pify": { "version": "2.3.0", "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "pinkie": { + "node_modules/pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "pinkie-promise": { + "node_modules/pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, - "requires": { + "dependencies": { "pinkie": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "pretty-bytes": { + "node_modules/pretty-bytes": { "version": "1.0.4", "resolved": "http://registry.npmjs.org/pretty-bytes/-/pretty-bytes-1.0.4.tgz", "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", "dev": true, - "requires": { + "dependencies": { "get-stdin": "^4.0.1", "meow": "^3.1.0" + }, + "bin": { + "pretty-bytes": "cli.js" + }, + "engines": { + "node": ">=0.10.0" } }, - "process": { + "node_modules/process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6.0" + } }, - "process-nextick-args": { + "node_modules/process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, - "progress": { + "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.0" + } }, - "proxy-from-env": { + "node_modules/proxy-from-env": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", "dev": true }, - "psl": { - "version": "1.1.31", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", - "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==", + "node_modules/psl": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", "dev": true }, - "public-encrypt": { + "node_modules/public-encrypt": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", @@ -3147,18 +3801,20 @@ "safe-buffer": "^5.1.2" } }, - "punycode": { + "node_modules/punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", "dev": true }, - "puppeteer": { + "node_modules/puppeteer": { "version": "1.20.0", "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.20.0.tgz", "integrity": "sha512-bt48RDBy2eIwZPrkgbcwHtb51mj2nKvHOPMaSH2IsWiv7lOG9k9zhaRzpDZafrk05ajMc3cu+lSQYYOfH2DkVQ==", + "deprecated": "< 19.4.0 is no longer supported", "dev": true, - "requires": { + "hasInstallScript": true, + "dependencies": { "debug": "^4.1.0", "extract-zip": "^1.6.6", "https-proxy-agent": "^2.2.1", @@ -3168,97 +3824,122 @@ "rimraf": "^2.6.1", "ws": "^6.1.0" }, + "engines": { + "node": ">=6.4.0" + } + }, + "node_modules/puppeteer/node_modules/debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, "dependencies": { - "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true } } }, - "qs": { + "node_modules/puppeteer/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/qs": { "version": "6.5.3", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.6" + } }, - "querystring": { + "node_modules/querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "dev": true + "deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.", + "dev": true, + "engines": { + "node": ">=0.4.x" + } }, - "querystring-es3": { + "node_modules/querystring-es3": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.x" + } }, - "randombytes": { + "node_modules/randombytes": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "^5.1.0" } }, - "randomfill": { + "node_modules/randomfill": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, - "requires": { + "dependencies": { "randombytes": "^2.0.5", "safe-buffer": "^5.1.0" } }, - "read-only-stream": { + "node_modules/read-only-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", "dev": true, - "requires": { + "dependencies": { "readable-stream": "^2.0.2" } }, - "read-pkg": { + "node_modules/read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", "dev": true, - "requires": { + "dependencies": { "load-json-file": "^1.0.0", "normalize-package-data": "^2.3.2", "path-type": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "read-pkg-up": { + "node_modules/read-pkg-up": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", "dev": true, - "requires": { + "dependencies": { "find-up": "^1.0.0", "read-pkg": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "readable-stream": { + "node_modules/readable-stream": { "version": "2.3.6", "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, - "requires": { + "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", @@ -3266,59 +3947,70 @@ "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" - }, + } + }, + "node_modules/readable-stream/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, "dependencies": { - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } + "safe-buffer": "~5.1.0" } }, - "rechoir": { + "node_modules/rechoir": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz", "integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==", "dev": true, - "requires": { + "dependencies": { "resolve": "^1.9.0" + }, + "engines": { + "node": ">= 0.10" } }, - "redent": { + "node_modules/redent": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", "dev": true, - "requires": { + "dependencies": { "indent-string": "^2.1.0", "strip-indent": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "repeat-string": { + "node_modules/repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10" + } }, - "repeating": { + "node_modules/repeating": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", "dev": true, - "requires": { + "dependencies": { "is-finite": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "node_modules/request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", "dev": true, - "requires": { + "dependencies": { "aws-sign2": "~0.7.0", "aws4": "^1.8.0", "caseless": "~0.12.0", @@ -3326,7 +4018,7 @@ "extend": "~3.0.2", "forever-agent": "~0.6.1", "form-data": "~2.3.2", - "har-validator": "~5.1.0", + "har-validator": "~5.1.3", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", @@ -3336,222 +4028,259 @@ "performance-now": "^2.1.0", "qs": "~6.5.2", "safe-buffer": "^5.1.2", - "tough-cookie": "~2.4.3", + "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" + }, + "engines": { + "node": ">= 6" } }, - "request-progress": { + "node_modules/request-progress": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", "integrity": "sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg=", "dev": true, - "requires": { + "dependencies": { "throttleit": "^1.0.0" } }, - "requizzle": { + "node_modules/requizzle": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz", "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==", - "requires": { + "dependencies": { "lodash": "^4.17.14" } }, - "resolve": { + "node_modules/resolve": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.9.0.tgz", "integrity": "sha512-TZNye00tI67lwYvzxCxHGjwTNlUV70io54/Ed4j6PscB8xVfuBJpRenI/o6dVk0cY0PYTY27AgCoGGxRnYuItQ==", "dev": true, - "requires": { + "dependencies": { "path-parse": "^1.0.6" } }, - "resolve-dir": { + "node_modules/resolve-dir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", "dev": true, - "requires": { + "dependencies": { "expand-tilde": "^2.0.0", "global-modules": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "right-align": { + "node_modules/right-align": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", "dev": true, - "requires": { + "dependencies": { "align-text": "^0.1.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "rimraf": { + "node_modules/rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, - "requires": { + "dependencies": { "glob": "^7.0.5" + }, + "bin": { + "rimraf": "bin.js" } }, - "ripemd160": { + "node_modules/ripemd160": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, - "requires": { + "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1" } }, - "safe-buffer": { + "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, - "safer-buffer": { + "node_modules/safe-stable-stringify": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.3.tgz", + "integrity": "sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "semver": { + "node_modules/semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "dev": true + "dev": true, + "bin": { + "semver": "bin/semver" + } }, - "sha.js": { + "node_modules/sha.js": { "version": "2.4.11", "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" } }, - "shasum": { + "node_modules/shasum": { "version": "1.0.2", "resolved": "http://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true, - "requires": { + "dependencies": { "json-stable-stringify": "~0.0.0", "sha.js": "~2.4.4" } }, - "shebang-command": { + "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, - "requires": { + "dependencies": { "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" } }, - "shebang-regex": { + "node_modules/shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "shell-quote": { + "node_modules/shell-quote": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", "dev": true }, - "signal-exit": { + "node_modules/signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, - "simple-concat": { + "node_modules/simple-concat": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", "dev": true }, - "simple-swizzle": { + "node_modules/simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", - "integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=", + "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", "dev": true, - "requires": { - "is-arrayish": "^0.3.1" - }, "dependencies": { - "is-arrayish": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", - "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==", - "dev": true - } + "is-arrayish": "^0.3.1" } }, - "source-map": { + "node_modules/simple-swizzle/node_modules/is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==", + "dev": true + }, + "node_modules/source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "spdx-correct": { + "node_modules/spdx-correct": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", "dev": true, - "requires": { + "dependencies": { "spdx-expression-parse": "^3.0.0", "spdx-license-ids": "^3.0.0" } }, - "spdx-exceptions": { + "node_modules/spdx-exceptions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", "dev": true }, - "spdx-expression-parse": { + "node_modules/spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, - "requires": { + "dependencies": { "spdx-exceptions": "^2.1.0", "spdx-license-ids": "^3.0.0" } }, - "spdx-license-ids": { + "node_modules/spdx-license-ids": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.2.tgz", "integrity": "sha512-qky9CVt0lVIECkEsYbNILVnPvycuEBkXoMFLRWsREkomQLevYhtRKC+R91a5TOAQ3bCMjikRwhyaRqj1VYatYg==", "dev": true }, - "split": { + "node_modules/split": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", "dev": true, - "requires": { + "dependencies": { "through": "2" + }, + "engines": { + "node": "*" } }, - "sprintf-js": { + "node_modules/sprintf-js": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", "dev": true }, - "sshpk": { + "node_modules/sshpk": { "version": "1.16.0", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.0.tgz", "integrity": "sha512-Zhev35/y7hRMcID/upReIvRse+I9SVhyVre/KTJSJQWMz3C3+G+HpO7m1wK/yckEtujKZ7dS4hkVxAnmHaIGVQ==", "dev": true, - "requires": { + "dependencies": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", "bcrypt-pbkdf": "^1.0.0", @@ -3561,40 +4290,51 @@ "jsbn": "~0.1.0", "safer-buffer": "^2.0.2", "tweetnacl": "~0.14.0" + }, + "bin": { + "sshpk-conv": "bin/sshpk-conv", + "sshpk-sign": "bin/sshpk-sign", + "sshpk-verify": "bin/sshpk-verify" + }, + "engines": { + "node": ">=0.10.0" } }, - "stack-trace": { + "node_modules/stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", - "dev": true + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", + "dev": true, + "engines": { + "node": "*" + } }, - "stream-browserify": { + "node_modules/stream-browserify": { "version": "2.0.1", "resolved": "http://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", "dev": true, - "requires": { + "dependencies": { "inherits": "~2.0.1", "readable-stream": "^2.0.2" } }, - "stream-combiner2": { + "node_modules/stream-combiner2": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, - "requires": { + "dependencies": { "duplexer2": "~0.1.0", "readable-stream": "^2.0.2" } }, - "stream-http": { + "node_modules/stream-http": { "version": "2.8.3", "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", "dev": true, - "requires": { + "dependencies": { "builtin-status-codes": "^3.0.0", "inherits": "^2.0.1", "readable-stream": "^2.3.6", @@ -3602,475 +4342,606 @@ "xtend": "^4.0.0" } }, - "stream-splicer": { + "node_modules/stream-splicer": { "version": "2.0.0", "resolved": "http://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz", "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "readable-stream": "^2.0.2" } }, - "string_decoder": { + "node_modules/string_decoder": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "~5.1.0" } }, - "strip-ansi": { + "node_modules/strip-ansi": { "version": "3.0.1", "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "requires": { + "dependencies": { "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "strip-bom": { + "node_modules/strip-bom": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, - "requires": { + "dependencies": { "is-utf8": "^0.2.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "strip-indent": { + "node_modules/strip-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", "dev": true, - "requires": { + "dependencies": { "get-stdin": "^4.0.1" + }, + "bin": { + "strip-indent": "cli.js" + }, + "engines": { + "node": ">=0.10.0" } }, - "strip-json-comments": { + "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "subarg": { + "node_modules/subarg": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", "dev": true, - "requires": { + "dependencies": { "minimist": "^1.1.0" } }, - "supports-color": { + "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, - "requires": { + "dependencies": { "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "syntax-error": { + "node_modules/syntax-error": { "version": "1.4.0", "resolved": "http://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, - "requires": { + "dependencies": { "acorn-node": "^1.2.0" } }, - "taffydb": { + "node_modules/taffydb": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", "integrity": "sha512-y3JaeRSplks6NYQuCOj3ZFMO3j60rTwbuKCvZxsAraGYH2epusatvZ0baZYA01WsGqJBq/Dl6vOrMUJqyMj8kA==" }, - "text-hex": { + "node_modules/text-hex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==", "dev": true }, - "throttleit": { + "node_modules/throttleit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", "dev": true }, - "through": { + "node_modules/through": { "version": "2.3.8", "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, - "through2": { + "node_modules/through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "dev": true, - "requires": { + "dependencies": { "readable-stream": "~2.3.6", "xtend": "~4.0.1" } }, - "timers-browserify": { + "node_modules/timers-browserify": { "version": "1.4.2", "resolved": "http://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", "dev": true, - "requires": { + "dependencies": { "process": "~0.11.0" + }, + "engines": { + "node": ">=0.6.0" } }, - "to-arraybuffer": { + "node_modules/to-arraybuffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", "dev": true }, - "to-regex-range": { + "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, - "requires": { + "dependencies": { "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" } }, - "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "node_modules/tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", "dev": true, - "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" + "dependencies": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/tough-cookie/node_modules/punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "dev": true, + "engines": { + "node": ">=6" } }, - "trim-newlines": { + "node_modules/trim-newlines": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true + "integrity": "sha512-Nm4cF79FhSTzrLKGDMi3I4utBtFv8qKy4sq1enftf2gMdpqI8oVQTAfySkTz5r49giVzDj88SVZXP4CeYQwjaw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "triple-beam": { + "node_modules/triple-beam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==", "dev": true }, - "tty-browserify": { + "node_modules/tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", "dev": true }, - "tunnel-agent": { + "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" } }, - "tweetnacl": { + "node_modules/tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "dev": true }, - "typedarray": { + "node_modules/typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, - "typescript": { + "node_modules/typescript": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.4.tgz", "integrity": "sha512-0RNDbSdEokBeEAkgNbxJ+BLwSManFy9TeXz8uW+48j/xhEXv1ePME60olyzw2XzUqUBNAYFeJadIqAgNqIACwg==", - "dev": true + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } }, - "uc.micro": { + "node_modules/uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==" }, - "uglify-js": { + "node_modules/uglify-js": { "version": "2.6.4", "resolved": "http://registry.npmjs.org/uglify-js/-/uglify-js-2.6.4.tgz", "integrity": "sha1-ZeovswWck5RpLxX+2HwrNsFrmt8=", "dev": true, - "requires": { + "dependencies": { "async": "~0.2.6", "source-map": "~0.5.1", "uglify-to-browserify": "~1.0.0", "yargs": "~3.10.0" }, - "dependencies": { - "async": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", - "integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==", - "dev": true - } + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "engines": { + "node": ">=0.8.0" } }, - "uglify-to-browserify": { + "node_modules/uglify-js/node_modules/async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==", + "dev": true + }, + "node_modules/uglify-to-browserify": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", "dev": true }, - "umd": { + "node_modules/umd": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", - "dev": true + "dev": true, + "bin": { + "umd": "bin/cli.js" + } }, - "unc-path-regex": { + "node_modules/unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "undeclared-identifiers": { + "node_modules/undeclared-identifiers": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.2.tgz", "integrity": "sha512-13EaeocO4edF/3JKime9rD7oB6QI8llAGhgn5fKOPyfkJbRb6NFv9pYV6dFEmpa4uRjKeBqLZP8GpuzqHlKDMQ==", "dev": true, - "requires": { + "dependencies": { "acorn-node": "^1.3.0", "get-assigned-identifiers": "^1.2.0", "simple-concat": "^1.0.0", "xtend": "^4.0.1" + }, + "bin": { + "undeclared-identifiers": "bin.js" } }, - "underscore": { + "node_modules/underscore": { "version": "1.13.6", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==" }, - "underscore.string": { + "node_modules/underscore.string": { "version": "3.3.6", "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.6.tgz", "integrity": "sha512-VoC83HWXmCrF6rgkyxS9GHv8W9Q5nhMKho+OadDJGzL2oDYbYEppBaCMH6pFlwLeqj2QS+hhkw2kpXkSdD1JxQ==", "dev": true, - "requires": { + "dependencies": { "sprintf-js": "^1.1.1", "util-deprecate": "^1.0.2" + }, + "engines": { + "node": "*" } }, - "uri-js": { + "node_modules/uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", "dev": true, - "requires": { - "punycode": "^2.1.0" - }, "dependencies": { - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - } + "punycode": "^2.1.0" + } + }, + "node_modules/uri-js/node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true, + "engines": { + "node": ">=6" } }, - "uri-path": { + "node_modules/uri-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/uri-path/-/uri-path-1.0.0.tgz", "integrity": "sha1-l0fwGDWJM8Md4PzP2C0TjmcmLjI=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.10" + } }, - "url": { + "node_modules/url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", "dev": true, - "requires": { + "dependencies": { "punycode": "1.3.2", "querystring": "0.2.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true - } } }, - "util": { + "node_modules/url/node_modules/punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + }, + "node_modules/util": { "version": "0.10.4", "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", "dev": true, - "requires": { + "dependencies": { "inherits": "2.0.3" } }, - "util-deprecate": { + "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, - "uuid": { + "node_modules/uuid": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", - "dev": true + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "dev": true, + "bin": { + "uuid": "bin/uuid" + } }, - "v8flags": { + "node_modules/v8flags": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz", "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", "dev": true, - "requires": { + "dependencies": { "homedir-polyfill": "^1.0.1" + }, + "engines": { + "node": ">= 0.10" } }, - "validate-npm-package-license": { + "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", "dev": true, - "requires": { + "dependencies": { "spdx-correct": "^3.0.0", "spdx-expression-parse": "^3.0.0" } }, - "verror": { + "node_modules/verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "dev": true, - "requires": { + "engines": [ + "node >=0.6.0" + ], + "dependencies": { "assert-plus": "^1.0.0", "core-util-is": "1.0.2", "extsprintf": "^1.2.0" } }, - "vm-browserify": { + "node_modules/vm-browserify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz", "integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==", "dev": true }, - "which": { + "node_modules/which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, - "requires": { + "dependencies": { "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" } }, - "window-size": { + "node_modules/window-size": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8.0" + } }, - "winston": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/winston/-/winston-3.1.0.tgz", - "integrity": "sha512-FsQfEE+8YIEeuZEYhHDk5cILo1HOcWkGwvoidLrDgPog0r4bser1lEIOco2dN9zpDJ1M88hfDgZvxe5z4xNcwg==", - "dev": true, - "requires": { - "async": "^2.6.0", - "diagnostics": "^1.1.1", - "is-stream": "^1.1.0", - "logform": "^1.9.1", - "one-time": "0.0.4", - "readable-stream": "^2.3.6", + "node_modules/winston": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.9.0.tgz", + "integrity": "sha512-jW51iW/X95BCW6MMtZWr2jKQBP4hV5bIDq9QrIjfDk6Q9QuxvTKEAlpUNAzP+HYHFFCeENhph16s0zEunu4uuQ==", + "dev": true, + "dependencies": { + "@colors/colors": "1.5.0", + "@dabh/diagnostics": "^2.0.2", + "async": "^3.2.3", + "is-stream": "^2.0.0", + "logform": "^2.4.0", + "one-time": "^1.0.0", + "readable-stream": "^3.4.0", + "safe-stable-stringify": "^2.3.1", "stack-trace": "0.0.x", "triple-beam": "^1.3.0", - "winston-transport": "^4.2.0" + "winston-transport": "^4.5.0" }, + "engines": { + "node": ">= 12.0.0" + } + }, + "node_modules/winston-transport": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.5.0.tgz", + "integrity": "sha512-YpZzcUzBedhlTAfJg6vJDlyEai/IFMIVcaEZZyl3UXIl4gmqRpU7AE89AHLkbzLUsv0NVmw7ts+iztqKxxPW1Q==", + "dev": true, "dependencies": { - "async": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", - "dev": true, - "requires": { - "lodash": "^4.17.14" - } - } + "logform": "^2.3.2", + "readable-stream": "^3.6.0", + "triple-beam": "^1.3.0" + }, + "engines": { + "node": ">= 6.4.0" } }, - "winston-transport": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.3.0.tgz", - "integrity": "sha512-B2wPuwUi3vhzn/51Uukcao4dIduEiPOcOt9HJ3QeaXgkJ5Z7UwpBzxS4ZGNHtrxrUvTwemsQiSys0ihOf8Mp1A==", + "node_modules/winston-transport/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "dev": true, - "requires": { - "readable-stream": "^2.3.6", - "triple-beam": "^1.2.0" + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/winston/node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/winston/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" } }, - "wordwrap": { + "node_modules/wordwrap": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.0" + } }, - "wrappy": { + "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "ws": { + "node_modules/ws": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", "dev": true, - "requires": { + "dependencies": { "async-limiter": "~1.0.0" } }, - "xmlcreate": { + "node_modules/xmlcreate": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz", "integrity": "sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg==" }, - "xtend": { + "node_modules/xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4" + } }, - "yargs": { + "node_modules/yargs": { "version": "3.10.0", "resolved": "http://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", "dev": true, - "requires": { + "dependencies": { "camelcase": "^1.0.2", "cliui": "^2.1.0", "decamelize": "^1.0.0", "window-size": "0.1.0" - }, - "dependencies": { - "camelcase": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", - "dev": true - } } }, - "yauzl": { + "node_modules/yargs/node_modules/camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", "dev": true, - "requires": { + "dependencies": { "buffer-crc32": "~0.2.3", "fd-slicer": "~1.1.0" } From 4b8bf783ca70b4559aae92babf1606f945265543 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Wed, 21 Jun 2023 23:17:04 +0200 Subject: [PATCH 078/250] bumping certain JS modules --- lib/js/package-lock.json | 3136 +++++++++++++++++++++++--------------- 1 file changed, 1871 insertions(+), 1265 deletions(-) diff --git a/lib/js/package-lock.json b/lib/js/package-lock.json index 2697f4a578f..cbd36f55587 100644 --- a/lib/js/package-lock.json +++ b/lib/js/package-lock.json @@ -1,249 +1,288 @@ { "name": "thrift", "version": "0.19.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@babel/parser": { + "packages": { + "": { + "name": "thrift", + "version": "0.19.0", + "license": "Apache-2.0", + "devDependencies": { + "browserify": "~16.5", + "grunt": "^1.4.1", + "grunt-cli": "^1.4.3", + "grunt-contrib-concat": "~1.0", + "grunt-contrib-jshint": "~3.2", + "grunt-contrib-qunit": "~3.1", + "grunt-contrib-uglify": "~4.0", + "grunt-jsdoc": "~2.4", + "grunt-shell-spawn": "~0.4", + "jsdoc": "^3.6.7", + "jslint": "~0.12.1", + "json-int64": "~1.0.2", + "node-int64": "~0.4.0", + "nopt": "~4.0" + } + }, + "node_modules/@babel/parser": { "version": "7.19.4", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.19.4.tgz", "integrity": "sha512-qpVT7gtuOLjWeDTKLkJ6sryqLliBaFpAtGeqw5cs5giLldvh+Ch0plqnUMKoVAUS6ZEueQQiZV+p5pxtPitEsA==", - "dev": true + "dev": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } }, - "@types/linkify-it": { + "node_modules/@types/linkify-it": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==", "dev": true }, - "@types/markdown-it": { + "node_modules/@types/markdown-it": { "version": "12.2.3", "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", "dev": true, - "requires": { + "dependencies": { "@types/linkify-it": "*", "@types/mdurl": "*" } }, - "@types/mdurl": { + "node_modules/@types/mdurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz", "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==", "dev": true }, - "JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dev": true, - "requires": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - } - }, - "abbrev": { + "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true }, - "acorn": { + "node_modules/acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "dev": true + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } }, - "acorn-node": { + "node_modules/acorn-node": { "version": "1.8.2", "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", "dev": true, - "requires": { + "dependencies": { "acorn": "^7.0.0", "acorn-walk": "^7.0.0", "xtend": "^4.0.2" } }, - "acorn-walk": { + "node_modules/acorn-walk": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.1.1.tgz", "integrity": "sha512-wdlPY2tm/9XBr7QkKlq0WQVgiuGTX6YWPyRyBviSoScBuLfTVQhvwg6wJ369GJ/1nPfTLMfnrFIfjqVg6d+jQQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.0" + } }, - "ansi-regex": { + "node_modules/ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "ansi-styles": { + "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, - "requires": { + "dependencies": { "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" } }, - "argparse": { + "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - }, "dependencies": { - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - } + "sprintf-js": "~1.0.2" } }, - "array-each": { + "node_modules/argparse/node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "node_modules/array-each": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "array-slice": { + "node_modules/array-slice": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz", "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "asn1.js": { + "node_modules/asn1.js": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.0.0", "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, - "assert": { + "node_modules/assert": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", "dev": true, - "requires": { + "dependencies": { "object-assign": "^4.1.1", "util": "0.10.3" - }, + } + }, + "node_modules/assert/node_modules/inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "dev": true + }, + "node_modules/assert/node_modules/util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, "dependencies": { - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true - }, - "util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", - "dev": true, - "requires": { - "inherits": "2.0.1" - } - } + "inherits": "2.0.1" } }, - "async": { + "node_modules/async": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==", "dev": true }, - "async-limiter": { + "node_modules/async-limiter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", "dev": true }, - "balanced-match": { + "node_modules/balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "base64-js": { + "node_modules/base64-js": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", "dev": true }, - "bluebird": { + "node_modules/bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", "dev": true }, - "bn.js": { + "node_modules/bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", "dev": true }, - "brace-expansion": { + "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "requires": { + "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "braces": { + "node_modules/braces": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "dev": true, - "requires": { + "dependencies": { "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" } }, - "brorand": { + "node_modules/brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", "dev": true }, - "browser-pack": { + "node_modules/browser-pack": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, - "requires": { - "JSONStream": "^1.0.3", + "dependencies": { "combine-source-map": "~0.8.0", "defined": "^1.0.0", + "JSONStream": "^1.0.3", "safe-buffer": "^5.1.1", "through2": "^2.0.0", "umd": "^3.0.0" + }, + "bin": { + "browser-pack": "bin/cmd.js" } }, - "browser-resolve": { + "node_modules/browser-resolve": { "version": "1.11.3", "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", "dev": true, - "requires": { + "dependencies": { "resolve": "1.1.7" } }, - "browserify": { + "node_modules/browserify": { "version": "16.5.0", "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.5.0.tgz", "integrity": "sha512-6bfI3cl76YLAnCZ75AGu/XPOsqUhRyc0F/olGIJeCxtfxF2HvPKEcmjU9M8oAPxl4uBY1U7Nry33Q6koV3f2iw==", "dev": true, - "requires": { - "JSONStream": "^1.0.3", + "dependencies": { "assert": "^1.4.0", "browser-pack": "^6.0.1", "browser-resolve": "^1.11.0", @@ -265,6 +304,7 @@ "https-browserify": "^1.0.0", "inherits": "~2.0.1", "insert-module-globals": "^7.0.0", + "JSONStream": "^1.0.3", "labeled-stream-splicer": "^2.0.0", "mkdirp": "^0.5.0", "module-deps": "^6.0.0", @@ -292,72 +332,19 @@ "vm-browserify": "^1.0.0", "xtend": "^4.0.0" }, - "dependencies": { - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - }, - "dependencies": { - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "requires": { - "safe-buffer": "~5.2.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", - "dev": true - } - } - } + "bin": { + "browserify": "bin/cmd.js" + }, + "engines": { + "node": ">= 0.8" } }, - "browserify-aes": { + "node_modules/browserify-aes": { "version": "1.2.0", "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, - "requires": { + "dependencies": { "buffer-xor": "^1.0.3", "cipher-base": "^1.0.0", "create-hash": "^1.1.0", @@ -366,45 +353,45 @@ "safe-buffer": "^5.0.1" } }, - "browserify-cipher": { + "node_modules/browserify-cipher": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, - "requires": { + "dependencies": { "browserify-aes": "^1.0.4", "browserify-des": "^1.0.0", "evp_bytestokey": "^1.0.0" } }, - "browserify-des": { + "node_modules/browserify-des": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, - "requires": { + "dependencies": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", "inherits": "^2.0.1", "safe-buffer": "^5.1.2" } }, - "browserify-rsa": { + "node_modules/browserify-rsa": { "version": "4.0.1", "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.1.0", "randombytes": "^2.0.1" } }, - "browserify-sign": { + "node_modules/browserify-sign": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.1.1", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", @@ -414,243 +401,322 @@ "parse-asn1": "^5.0.0" } }, - "browserify-zlib": { + "node_modules/browserify-zlib": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, - "requires": { + "dependencies": { "pako": "~1.0.5" } }, - "buffer": { + "node_modules/browserify/node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/browserify/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/browserify/node_modules/readable-stream/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/browserify/node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/browserify/node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", + "dev": true + }, + "node_modules/buffer": { "version": "5.4.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.3.tgz", "integrity": "sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==", "dev": true, - "requires": { + "dependencies": { "base64-js": "^1.0.2", "ieee754": "^1.1.4" } }, - "buffer-crc32": { + "node_modules/buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "buffer-from": { + "node_modules/buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "buffer-shims": { + "node_modules/buffer-shims": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", "dev": true }, - "buffer-xor": { + "node_modules/buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, - "builtin-status-codes": { + "node_modules/builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, - "cached-path-relative": { + "node_modules/cached-path-relative": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.1.0.tgz", "integrity": "sha512-WF0LihfemtesFcJgO7xfOoOcnWzY/QHR4qeDqV44jPU3HTI54+LnfXK3SA27AVVGCdZFgjjFFaqUA9Jx7dMJZA==", "dev": true }, - "catharsis": { + "node_modules/catharsis": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", "integrity": "sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A==", "dev": true, - "requires": { + "dependencies": { "lodash": "^4.17.15" + }, + "engines": { + "node": ">= 10" } }, - "chalk": { + "node_modules/chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "dev": true, - "requires": { + "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" } }, - "cipher-base": { + "node_modules/cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" } }, - "cli": { + "node_modules/cli": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", "integrity": "sha512-41U72MB56TfUMGndAKK8vJ78eooOD4Z5NOL4xEfjc0c23s+6EYKXlXsmACBVclLP1yOfWCgEganVzddVrSNoTg==", "dev": true, - "requires": { + "dependencies": { "exit": "0.1.2", "glob": "^7.1.1" }, + "engines": { + "node": ">=0.2.5" + } + }, + "node_modules/cli/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, "dependencies": { - "glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "color-convert": { + "node_modules/color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, - "requires": { + "dependencies": { "color-name": "1.1.3" } }, - "color-name": { + "node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, - "colors": { + "node_modules/colors": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.1.90" + } }, - "combine-source-map": { + "node_modules/combine-source-map": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, - "requires": { + "dependencies": { "convert-source-map": "~1.1.0", "inline-source-map": "~0.6.0", "lodash.memoize": "~3.0.3", "source-map": "~0.5.3" } }, - "commander": { + "node_modules/commander": { "version": "2.20.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", "dev": true }, - "concat-map": { + "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "concat-stream": { + "node_modules/concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, - "requires": { + "engines": [ + "node >= 0.8" + ], + "dependencies": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", "readable-stream": "^2.2.2", "typedarray": "^0.0.6" - }, + } + }, + "node_modules/concat-stream/node_modules/readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, "dependencies": { - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/concat-stream/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" } }, - "console-browserify": { + "node_modules/console-browserify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", "dev": true, - "requires": { + "dependencies": { "date-now": "^0.1.4" } }, - "constants-browserify": { + "node_modules/constants-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", "dev": true }, - "convert-source-map": { + "node_modules/convert-source-map": { "version": "1.1.3", "resolved": "http://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", "dev": true }, - "core-util-is": { + "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "create-ecdh": { + "node_modules/create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.1.0", "elliptic": "^6.0.0" } }, - "create-hash": { + "node_modules/create-hash": { "version": "1.2.0", "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, - "requires": { + "dependencies": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", "md5.js": "^1.3.4", @@ -658,12 +724,12 @@ "sha.js": "^2.4.0" } }, - "create-hmac": { + "node_modules/create-hmac": { "version": "1.1.7", "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, - "requires": { + "dependencies": { "cipher-base": "^1.0.3", "create-hash": "^1.1.0", "inherits": "^2.0.1", @@ -672,34 +738,41 @@ "sha.js": "^2.4.8" } }, - "cross-spawn": { + "node_modules/cross-spawn": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.1.tgz", "integrity": "sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==", "dev": true, - "requires": { + "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/cross-spawn/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } }, - "crypto-browserify": { + "node_modules/crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, - "requires": { + "dependencies": { "browserify-cipher": "^1.0.0", "browserify-sign": "^4.0.0", "create-ecdh": "^4.0.0", @@ -711,193 +784,220 @@ "public-encrypt": "^4.0.0", "randombytes": "^2.0.0", "randomfill": "^1.0.3" + }, + "engines": { + "node": "*" } }, - "dash-ast": { + "node_modules/dash-ast": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz", "integrity": "sha512-Vy4dx7gquTeMcQR/hDkYLGUnwVil6vk4FOOct+djUnHOUWt+zJPJAaRIXaAFkPXtJjvlY7o3rfRu0/3hpnwoUA==", "dev": true }, - "date-now": { + "node_modules/date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", "dev": true }, - "dateformat": { + "node_modules/dateformat": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "debug": { + "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, - "requires": { + "dependencies": { "ms": "2.0.0" } }, - "defined": { + "node_modules/defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", "dev": true }, - "deps-sort": { + "node_modules/deps-sort": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.1.tgz", "integrity": "sha512-1orqXQr5po+3KI6kQb9A4jnXT1PBwggGl2d7Sq2xsnOeI9GPcE/tGcF9UiSZtZBM7MukY4cAh7MemS6tZYipfw==", "dev": true, - "requires": { + "dependencies": { "JSONStream": "^1.0.3", "shasum-object": "^1.0.0", "subarg": "^1.0.0", "through2": "^2.0.0" + }, + "bin": { + "deps-sort": "bin/cmd.js" } }, - "des.js": { + "node_modules/des.js": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, - "detect-file": { + "node_modules/detect-file": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "detective": { + "node_modules/detective": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==", "dev": true, - "requires": { + "dependencies": { "acorn-node": "^1.6.1", "defined": "^1.0.0", "minimist": "^1.1.1" + }, + "bin": { + "detective": "bin/detective.js" + }, + "engines": { + "node": ">=0.8.0" } }, - "diffie-hellman": { + "node_modules/diffie-hellman": { "version": "5.0.3", "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.1.0", "miller-rabin": "^4.0.0", "randombytes": "^2.0.0" } }, - "dom-serializer": { + "node_modules/dom-serializer": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==", "dev": true, - "requires": { + "dependencies": { "domelementtype": "^2.0.1", "entities": "^2.0.0" - }, - "dependencies": { - "domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "dev": true - }, - "entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", - "dev": true + } + }, + "node_modules/dom-serializer/node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" } + ] + }, + "node_modules/dom-serializer/node_modules/entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" } }, - "domain-browser": { + "node_modules/domain-browser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4", + "npm": ">=1.2" + } }, - "domelementtype": { + "node_modules/domelementtype": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", "dev": true }, - "domhandler": { + "node_modules/domhandler": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", "integrity": "sha512-q9bUwjfp7Eif8jWxxxPSykdRZAb6GkguBGSgvvCrhI9wB71W2K/Kvv4E61CF/mcCfnVJDeDWx/Vb/uAqbDj6UQ==", "dev": true, - "requires": { + "dependencies": { "domelementtype": "1" } }, - "domutils": { + "node_modules/domutils": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", "integrity": "sha512-gSu5Oi/I+3wDENBsOWBiRK1eoGxcywYSqg3rR960/+EfY0CF4EX1VPkgHOZ3WiS/Jg2DtliF6BhWcHlfpYUcGw==", "dev": true, - "requires": { + "dependencies": { "dom-serializer": "0", "domelementtype": "1" } }, - "duplexer": { + "node_modules/duplexer": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", "dev": true }, - "duplexer2": { + "node_modules/duplexer2": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, - "requires": { + "dependencies": { "readable-stream": "^2.0.2" - }, + } + }, + "node_modules/duplexer2/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/duplexer2/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" } }, - "elliptic": { + "node_modules/elliptic": { "version": "6.5.4", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", "hash.js": "^1.0.0", @@ -905,276 +1005,330 @@ "inherits": "^2.0.4", "minimalistic-assert": "^1.0.1", "minimalistic-crypto-utils": "^1.0.1" - }, - "dependencies": { - "bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - } } }, - "entities": { + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/elliptic/node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/entities": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", "integrity": "sha512-LbLqfXgJMmy81t+7c14mnulFHJ170cM6E+0vMXR9k/ZiZwgX8i5pNgjTCX3SO4VeUsFLV+8InixoretwU+MjBQ==", "dev": true }, - "es6-promise": { + "node_modules/es6-promise": { "version": "4.2.5", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==", "dev": true }, - "es6-promisify": { + "node_modules/es6-promisify": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", "dev": true, - "requires": { + "dependencies": { "es6-promise": "^4.0.3" } }, - "escape-string-regexp": { + "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.8.0" + } }, - "esprima": { + "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } }, - "eventemitter2": { + "node_modules/eventemitter2": { "version": "0.4.14", "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=", "dev": true }, - "events": { + "node_modules/events": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/events/-/events-2.1.0.tgz", "integrity": "sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.x" + } }, - "evp_bytestokey": { + "node_modules/evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, - "requires": { + "dependencies": { "md5.js": "^1.3.4", "safe-buffer": "^5.1.1" } }, - "exit": { + "node_modules/exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8.0" + } }, - "expand-tilde": { + "node_modules/expand-tilde": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", "dev": true, - "requires": { + "dependencies": { "homedir-polyfill": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "extend": { + "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, - "extract-zip": { + "node_modules/extract-zip": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==", "dev": true, - "requires": { + "dependencies": { "concat-stream": "^1.6.2", "debug": "^2.6.9", "mkdirp": "^0.5.4", "yauzl": "^2.10.0" + }, + "bin": { + "extract-zip": "cli.js" } }, - "fast-safe-stringify": { + "node_modules/fast-safe-stringify": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==", "dev": true }, - "fd-slicer": { + "node_modules/fd-slicer": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", "dev": true, - "requires": { + "dependencies": { "pend": "~1.2.0" } }, - "figures": { + "node_modules/figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, - "requires": { + "dependencies": { "escape-string-regexp": "^1.0.5", "object-assign": "^4.1.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "fill-range": { + "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "dev": true, - "requires": { + "dependencies": { "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" } }, - "findup-sync": { + "node_modules/findup-sync": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz", "integrity": "sha1-N5MKpdgWt3fANEXhlmzGeQpMCxY=", "dev": true, - "requires": { + "dependencies": { "glob": "~5.0.0" }, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/findup-sync/node_modules/glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, "dependencies": { - "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", - "dev": true, - "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" } }, - "fined": { + "node_modules/fined": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", "dev": true, - "requires": { + "dependencies": { "expand-tilde": "^2.0.2", "is-plain-object": "^2.0.3", "object.defaults": "^1.1.0", "object.pick": "^1.2.0", "parse-filepath": "^1.0.1" + }, + "engines": { + "node": ">= 0.10" } }, - "flagged-respawn": { + "node_modules/flagged-respawn": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.10" + } }, - "for-in": { + "node_modules/for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "for-own": { + "node_modules/for-own": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", "dev": true, - "requires": { + "dependencies": { "for-in": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "fs.realpath": { + "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "function-bind": { + "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "get-assigned-identifiers": { + "node_modules/get-assigned-identifiers": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", "dev": true }, - "getobject": { + "node_modules/getobject": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/getobject/-/getobject-1.0.2.tgz", "integrity": "sha512-2zblDBaFcb3rB4rF77XVnuINOE2h2k/OnqXAiy0IrTxUfV1iFp3la33oAQVY9pCpWU268WFYVt2t71hlMuLsOg==", - "dev": true + "dev": true, + "engines": { + "node": ">=10" + } }, - "glob": { + "node_modules/glob": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.6.tgz", "integrity": "sha1-IRuvr0nlJbjNkyYNFKsTYVKz9Xo=", "dev": true, - "requires": { + "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.2", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" } }, - "global-modules": { + "node_modules/global-modules": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", "dev": true, - "requires": { + "dependencies": { "global-prefix": "^1.0.1", "is-windows": "^1.0.1", "resolve-dir": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "global-prefix": { + "node_modules/global-prefix": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", "dev": true, - "requires": { + "dependencies": { "expand-tilde": "^2.0.2", "homedir-polyfill": "^1.0.1", "ini": "^1.3.4", "is-windows": "^1.0.1", "which": "^1.2.14" + }, + "engines": { + "node": ">=0.10.0" } }, - "graceful-fs": { + "node_modules/graceful-fs": { "version": "4.2.10", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, - "grunt": { + "node_modules/grunt": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/grunt/-/grunt-1.5.3.tgz", "integrity": "sha512-mKwmo4X2d8/4c/BmcOETHek675uOqw0RuA/zy12jaspWqvTp4+ZeQF1W+OTpcbncnaBsfbQJ6l0l4j+Sn/GmaQ==", "dev": true, - "requires": { + "dependencies": { "dateformat": "~3.0.3", "eventemitter2": "~0.4.13", "exit": "~0.1.2", @@ -1191,294 +1345,330 @@ "nopt": "~3.0.6", "rimraf": "~3.0.2" }, - "dependencies": { - "glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "minimatch": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", - "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true - }, - "nopt": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", - "dev": true, - "requires": { - "abbrev": "1" - } - }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } + "bin": { + "grunt": "bin/grunt" + }, + "engines": { + "node": ">=8" } }, - "grunt-cli": { + "node_modules/grunt-cli": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/grunt-cli/-/grunt-cli-1.4.3.tgz", "integrity": "sha512-9Dtx/AhVeB4LYzsViCjUQkd0Kw0McN2gYpdmGYKtE2a5Yt7v1Q+HYZVWhqXc/kGnxlMtqKDxSwotiGeFmkrCoQ==", "dev": true, - "requires": { + "dependencies": { "grunt-known-options": "~2.0.0", "interpret": "~1.1.0", "liftup": "~3.0.1", "nopt": "~4.0.1", "v8flags": "~3.2.0" + }, + "bin": { + "grunt": "bin/grunt" + }, + "engines": { + "node": ">=10" } }, - "grunt-contrib-concat": { + "node_modules/grunt-contrib-concat": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/grunt-contrib-concat/-/grunt-contrib-concat-1.0.1.tgz", "integrity": "sha1-YVCYYwhOhx1+ht5IwBUlntl3Rb0=", "dev": true, - "requires": { + "dependencies": { "chalk": "^1.0.0", "source-map": "^0.5.3" }, + "engines": { + "node": ">=0.10.0" + }, + "peerDependencies": { + "grunt": ">=0.4.0" + } + }, + "node_modules/grunt-contrib-concat/node_modules/ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/grunt-contrib-concat/node_modules/chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "grunt-contrib-jshint": { + "node_modules/grunt-contrib-concat/node_modules/supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/grunt-contrib-jshint": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/grunt-contrib-jshint/-/grunt-contrib-jshint-3.2.0.tgz", "integrity": "sha512-pcXWCSZWfoMSvcV4BwH21TUtLtcX0Ms8IGuOPIcLeXK3fud9KclY7iqMKY94jFx8TxZzh028YYtpR+io8DiEaQ==", "dev": true, - "requires": { + "dependencies": { "chalk": "~4.1.2", "hooker": "^0.2.3", "jshint": "~2.13.4" }, + "engines": { + "node": ">=10" + } + }, + "node_modules/grunt-contrib-jshint/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/grunt-contrib-jshint/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "grunt-contrib-qunit": { + "node_modules/grunt-contrib-jshint/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/grunt-contrib-jshint/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/grunt-contrib-jshint/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/grunt-contrib-jshint/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/grunt-contrib-qunit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/grunt-contrib-qunit/-/grunt-contrib-qunit-3.1.0.tgz", "integrity": "sha512-mdk8UltH6mxCD63E0hTXMAts42DOi4z4bBBrY7qnuHiShflMF7IueSMYe0zWaZ2dO8mgujh57Zfny2EbigJhRg==", "dev": true, - "requires": { + "dependencies": { "eventemitter2": "^5.0.1", "p-each-series": "^1.0.0", "puppeteer": "^1.11.0" }, - "dependencies": { - "eventemitter2": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-5.0.1.tgz", - "integrity": "sha1-YZegldX7a1folC9v1+qtY6CclFI=", - "dev": true - } + "engines": { + "node": ">=6" } }, - "grunt-contrib-uglify": { + "node_modules/grunt-contrib-qunit/node_modules/eventemitter2": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-5.0.1.tgz", + "integrity": "sha1-YZegldX7a1folC9v1+qtY6CclFI=", + "dev": true + }, + "node_modules/grunt-contrib-uglify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-4.0.1.tgz", "integrity": "sha512-dwf8/+4uW1+7pH72WButOEnzErPGmtUvc8p08B0eQS/6ON0WdeQu0+WFeafaPTbbY1GqtS25lsHWaDeiTQNWPg==", "dev": true, - "requires": { + "dependencies": { "chalk": "^2.4.1", "maxmin": "^2.1.0", "uglify-js": "^3.5.0", "uri-path": "^1.0.0" + }, + "engines": { + "node": ">=6" } }, - "grunt-jsdoc": { + "node_modules/grunt-jsdoc": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/grunt-jsdoc/-/grunt-jsdoc-2.4.1.tgz", "integrity": "sha512-S0zxU0wDewRu7z+vijEItOWe/UttxWVmvz0qz2ZVcAYR2GpXjsiski2CAVN0b18t2qeVLdmxZkJaEWCOsKzcAw==", "dev": true, - "requires": { + "dependencies": { "cross-spawn": "^7.0.1", "jsdoc": "^3.6.3" + }, + "bin": { + "grunt-jsdoc": "bin/grunt-jsdoc" + }, + "engines": { + "node": ">= 8.12.0" } }, - "grunt-known-options": { + "node_modules/grunt-known-options": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-2.0.0.tgz", "integrity": "sha512-GD7cTz0I4SAede1/+pAbmJRG44zFLPipVtdL9o3vqx9IEyb7b4/Y3s7r6ofI3CchR5GvYJ+8buCSioDv5dQLiA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "grunt-legacy-log": { + "node_modules/grunt-legacy-log": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-3.0.0.tgz", "integrity": "sha512-GHZQzZmhyq0u3hr7aHW4qUH0xDzwp2YXldLPZTCjlOeGscAOWWPftZG3XioW8MasGp+OBRIu39LFx14SLjXRcA==", "dev": true, - "requires": { + "dependencies": { "colors": "~1.1.2", "grunt-legacy-log-utils": "~2.1.0", "hooker": "~0.2.3", "lodash": "~4.17.19" + }, + "engines": { + "node": ">= 0.10.0" } }, - "grunt-legacy-log-utils": { + "node_modules/grunt-legacy-log-utils": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-2.1.0.tgz", "integrity": "sha512-lwquaPXJtKQk0rUM1IQAop5noEpwFqOXasVoedLeNzaibf/OPWjKYvvdqnEHNmU+0T0CaReAXIbGo747ZD+Aaw==", "dev": true, - "requires": { + "dependencies": { "chalk": "~4.1.0", "lodash": "~4.17.19" }, + "engines": { + "node": ">=10" + } + }, + "node_modules/grunt-legacy-log-utils/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "grunt-legacy-util": { + "node_modules/grunt-legacy-log-utils/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/grunt-legacy-log-utils/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/grunt-legacy-log-utils/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/grunt-legacy-log-utils/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/grunt-legacy-log-utils/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/grunt-legacy-util": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-2.0.1.tgz", "integrity": "sha512-2bQiD4fzXqX8rhNdXkAywCadeqiPiay0oQny77wA2F3WF4grPJXCvAcyoWUJV+po/b15glGkxuSiQCK299UC2w==", "dev": true, - "requires": { + "dependencies": { "async": "~3.2.0", "exit": "~0.1.2", "getobject": "~1.0.0", @@ -1487,118 +1677,226 @@ "underscore.string": "~3.3.5", "which": "~2.0.2" }, + "engines": { + "node": ">=10" + } + }, + "node_modules/grunt-legacy-util/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } }, - "grunt-shell-spawn": { + "node_modules/grunt-shell-spawn": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/grunt-shell-spawn/-/grunt-shell-spawn-0.4.0.tgz", "integrity": "sha512-lfYvEQjbO1Wv+1Fk3d3XlcEpuQjyXiErZMkiz/i/tDQeMHHGF1LziqA4ZcietBAo/bM2RHdEEUJfnNWt1VRMwQ==", "dev": true, - "requires": { + "dependencies": { "grunt": ">=0.4.x" + }, + "bin": { + "grunt-shell-spawn": "bin/grunt-shell-spawn" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/grunt/node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/grunt/node_modules/minimatch": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/grunt/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/grunt/node_modules/nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + } + }, + "node_modules/grunt/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "gzip-size": { + "node_modules/gzip-size": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-3.0.0.tgz", "integrity": "sha1-VGGI6b3DN/Zzdy+BZgRks4nc5SA=", "dev": true, - "requires": { + "dependencies": { "duplexer": "^0.1.1" + }, + "engines": { + "node": ">=0.12.0" } }, - "has": { + "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, - "requires": { + "dependencies": { "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" } }, - "has-ansi": { + "node_modules/has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, - "requires": { + "dependencies": { "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "has-flag": { + "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "hash-base": { + "node_modules/hash-base": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" + }, + "engines": { + "node": ">=4" } }, - "hash.js": { + "node_modules/hash.js": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" } }, - "hmac-drbg": { + "node_modules/hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, - "requires": { + "dependencies": { "hash.js": "^1.0.3", "minimalistic-assert": "^1.0.0", "minimalistic-crypto-utils": "^1.0.1" } }, - "homedir-polyfill": { + "node_modules/homedir-polyfill": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", "dev": true, - "requires": { + "dependencies": { "parse-passwd": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "hooker": { + "node_modules/hooker": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "htmlescape": { + "node_modules/htmlescape": { "version": "1.1.1", "resolved": "http://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10" + } }, - "htmlparser2": { + "node_modules/htmlparser2": { "version": "3.8.3", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", "integrity": "sha512-hBxEg3CYXe+rPIua8ETe7tmG3XDn9B0edOE/e9wH2nLczxzgdu0m0aNHY+5wFZiviLWLdANPJTssa92dMcXQ5Q==", "dev": true, - "requires": { + "dependencies": { "domelementtype": "1", "domhandler": "2.3", "domutils": "1.5", @@ -1606,240 +1904,283 @@ "readable-stream": "1.1" } }, - "https-browserify": { + "node_modules/https-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", "dev": true }, - "https-proxy-agent": { + "node_modules/https-proxy-agent": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", "dev": true, - "requires": { + "dependencies": { "agent-base": "^4.3.0", "debug": "^3.1.0" }, + "engines": { + "node": ">= 4.5.0" + } + }, + "node_modules/https-proxy-agent/node_modules/agent-base": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", + "dev": true, "dependencies": { - "agent-base": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", - "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", - "dev": true, - "requires": { - "es6-promisify": "^5.0.0" - } - }, - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - } + "es6-promisify": "^5.0.0" + }, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/https-proxy-agent/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" } }, - "iconv-lite": { + "node_modules/https-proxy-agent/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, - "requires": { + "dependencies": { "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" } }, - "ieee754": { + "node_modules/ieee754": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", "dev": true }, - "inflight": { + "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, - "requires": { + "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, - "inherits": { + "node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "ini": { + "node_modules/ini": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "dev": true }, - "inline-source-map": { + "node_modules/inline-source-map": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", "dev": true, - "requires": { + "dependencies": { "source-map": "~0.5.3" } }, - "insert-module-globals": { + "node_modules/insert-module-globals": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", "dev": true, - "requires": { - "JSONStream": "^1.0.3", + "dependencies": { "acorn-node": "^1.5.2", "combine-source-map": "^0.8.0", "concat-stream": "^1.6.1", "is-buffer": "^1.1.0", + "JSONStream": "^1.0.3", "path-is-absolute": "^1.0.1", "process": "~0.11.0", "through2": "^2.0.0", "undeclared-identifiers": "^1.1.2", "xtend": "^4.0.0" + }, + "bin": { + "insert-module-globals": "bin/cmd.js" } }, - "interpret": { + "node_modules/interpret": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", "dev": true }, - "is-absolute": { + "node_modules/is-absolute": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", "dev": true, - "requires": { + "dependencies": { "is-relative": "^1.0.0", "is-windows": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-buffer": { + "node_modules/is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, - "is-core-module": { + "node_modules/is-core-module": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz", "integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==", "dev": true, - "requires": { + "dependencies": { "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "is-extglob": { + "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "is-glob": { + "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, - "requires": { + "dependencies": { "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-number": { + "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.12.0" + } }, - "is-plain-object": { + "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, - "requires": { + "dependencies": { "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-relative": { + "node_modules/is-relative": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", "dev": true, - "requires": { + "dependencies": { "is-unc-path": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-unc-path": { + "node_modules/is-unc-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", "dev": true, - "requires": { + "dependencies": { "unc-path-regex": "^0.1.2" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-windows": { + "node_modules/is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "isarray": { + "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "isexe": { + "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "isobject": { + "node_modules/isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "js-yaml": { + "node_modules/js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "dev": true, - "requires": { + "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" } }, - "js2xmlparser": { + "node_modules/js2xmlparser": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz", "integrity": "sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==", "dev": true, - "requires": { + "dependencies": { "xmlcreate": "^2.0.4" } }, - "jsdoc": { + "node_modules/jsdoc": { "version": "3.6.11", "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.11.tgz", "integrity": "sha512-8UCU0TYeIYD9KeLzEcAu2q8N/mx9O3phAGl32nmHlE0LpaJL71mMkP4d+QE5zWfNt50qheHtOZ0qoxVrsX5TUg==", "dev": true, - "requires": { + "dependencies": { "@babel/parser": "^7.9.4", "@types/markdown-it": "^12.2.3", "bluebird": "^3.7.2", @@ -1856,27 +2197,40 @@ "taffydb": "2.6.2", "underscore": "~1.13.2" }, - "dependencies": { - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true - }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true - } + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" } }, - "jshint": { + "node_modules/jsdoc/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/jsdoc/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jshint": { "version": "2.13.5", "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.13.5.tgz", "integrity": "sha512-dB2n1w3OaQ35PLcBGIWXlszjbPZwsgZoxsg6G8PtNf2cFMC1l0fObkYLUuXqTTdi6tKw4sAjfUseTdmDMHQRcg==", "dev": true, - "requires": { + "dependencies": { "cli": "~1.0.0", "console-browserify": "1.1.x", "exit": "0.1.x", @@ -1885,134 +2239,179 @@ "minimatch": "~3.0.2", "strip-json-comments": "1.0.x" }, + "bin": { + "jshint": "bin/jshint" + } + }, + "node_modules/jshint/node_modules/minimatch": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "dev": true, "dependencies": { - "minimatch": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", - "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "strip-json-comments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "integrity": "sha512-AOPG8EBc5wAikaG1/7uFCNFJwnKOuQwFTpYBdTW6OvWHeZBQBrAA/amefHGrEiOnCPcLFZK6FUPtWVKpQVIRgg==", - "dev": true - } + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" } }, - "jslint": { + "node_modules/jshint/node_modules/strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha512-AOPG8EBc5wAikaG1/7uFCNFJwnKOuQwFTpYBdTW6OvWHeZBQBrAA/amefHGrEiOnCPcLFZK6FUPtWVKpQVIRgg==", + "dev": true, + "bin": { + "strip-json-comments": "cli.js" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/jslint": { "version": "0.12.1", "resolved": "https://registry.npmjs.org/jslint/-/jslint-0.12.1.tgz", "integrity": "sha512-q5iHswjOmJffbsGVq/1umGh4YBxb5pCArNHCZeHpkuVDDKM6IldqUn4hLehKSwQr7Bn07VXjD34Lx3nw+6j8eA==", "dev": true, - "requires": { + "dependencies": { "exit": "~0.1.2", "glob": "~7.1.3", "nopt": "~4.0.1", "readable-stream": "~2.1.5" }, + "bin": { + "jslint": "bin/jslint.js" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/jslint/node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, "dependencies": { - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", - "integrity": "sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA=", - "dev": true, - "requires": { - "buffer-shims": "^1.0.0", - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" - } - } + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/jslint/node_modules/process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "node_modules/jslint/node_modules/readable-stream": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "integrity": "sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA=", + "dev": true, + "dependencies": { + "buffer-shims": "^1.0.0", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" } }, - "json-int64": { + "node_modules/json-int64": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-int64/-/json-int64-1.0.2.tgz", "integrity": "sha512-uGrIXtRehbksM17S2lJRLPljufK52KL2ewbJi0xgcRPONoRLXa4yAUIKAUxF69dbnqIoBu33fB28MAWSxupB8Q==", "dev": true, - "requires": { + "dependencies": { "node-int64": "0.4.0" } }, - "json-stable-stringify": { + "node_modules/json-stable-stringify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", "dev": true, - "requires": { + "dependencies": { "jsonify": "~0.0.0" } }, - "jsonify": { + "node_modules/jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "jsonparse": { + "node_modules/jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true + "dev": true, + "engines": [ + "node >= 0.2.0" + ] + }, + "node_modules/JSONStream": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", + "dev": true, + "dependencies": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + }, + "bin": { + "JSONStream": "bin.js" + }, + "engines": { + "node": "*" + } }, - "kind-of": { + "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "klaw": { + "node_modules/klaw": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", "dev": true, - "requires": { + "dependencies": { "graceful-fs": "^4.1.9" } }, - "labeled-stream-splicer": { + "node_modules/labeled-stream-splicer": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz", "integrity": "sha512-Ca4LSXFFZUjPScRaqOcFxneA0VpKZr4MMYCljyQr4LIewTLb3Y0IUTIsnBBsVubIeEfxeSZpSjSsRM8APEQaAw==", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "stream-splicer": "^2.0.0" } }, - "liftup": { + "node_modules/liftup": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/liftup/-/liftup-3.0.1.tgz", "integrity": "sha512-yRHaiQDizWSzoXk3APcA71eOI/UuhEkNN9DiW2Tt44mhYzX4joFoCZlxsSOF7RyeLlfqzFLQI1ngFq3ggMPhOw==", "dev": true, - "requires": { + "dependencies": { "extend": "^3.0.2", "findup-sync": "^4.0.0", "fined": "^1.2.0", @@ -2022,231 +2421,285 @@ "rechoir": "^0.7.0", "resolve": "^1.19.0" }, + "engines": { + "node": ">=10" + } + }, + "node_modules/liftup/node_modules/findup-sync": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-4.0.0.tgz", + "integrity": "sha512-6jvvn/12IC4quLBL1KNokxC7wWTvYncaVUYSoxWw7YykPLuRrnv4qdHcSOywOI5RpkOVGeQRtWM8/q+G6W6qfQ==", + "dev": true, "dependencies": { - "findup-sync": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-4.0.0.tgz", - "integrity": "sha512-6jvvn/12IC4quLBL1KNokxC7wWTvYncaVUYSoxWw7YykPLuRrnv4qdHcSOywOI5RpkOVGeQRtWM8/q+G6W6qfQ==", - "dev": true, - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^4.0.0", - "micromatch": "^4.0.2", - "resolve-dir": "^1.0.1" - } - }, - "resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", - "dev": true, - "requires": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" - } - } + "detect-file": "^1.0.0", + "is-glob": "^4.0.0", + "micromatch": "^4.0.2", + "resolve-dir": "^1.0.1" + }, + "engines": { + "node": ">= 8" } }, - "linkify-it": { + "node_modules/liftup/node_modules/resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "dependencies": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/linkify-it": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", "dev": true, - "requires": { + "dependencies": { "uc.micro": "^1.0.1" } }, - "lodash": { + "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, - "lodash.memoize": { + "node_modules/lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", "dev": true }, - "make-iterator": { + "node_modules/make-iterator": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", "dev": true, - "requires": { + "dependencies": { "kind-of": "^6.0.2" + }, + "engines": { + "node": ">=0.10.0" } }, - "map-cache": { + "node_modules/map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "markdown-it": { + "node_modules/markdown-it": { "version": "12.3.2", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", "dev": true, - "requires": { + "dependencies": { "argparse": "^2.0.1", "entities": "~2.1.0", "linkify-it": "^3.0.1", "mdurl": "^1.0.1", "uc.micro": "^1.0.5" }, - "dependencies": { - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "entities": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", - "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", - "dev": true - } + "bin": { + "markdown-it": "bin/markdown-it.js" } }, - "markdown-it-anchor": { + "node_modules/markdown-it-anchor": { "version": "8.6.5", "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.5.tgz", "integrity": "sha512-PI1qEHHkTNWT+X6Ip9w+paonfIQ+QZP9sCeMYi47oqhH+EsW8CrJ8J7CzV19QVOj6il8ATGbK2nTECj22ZHGvQ==", + "dev": true, + "peerDependencies": { + "@types/markdown-it": "*", + "markdown-it": "*" + } + }, + "node_modules/markdown-it/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "marked": { + "node_modules/markdown-it/node_modules/entities": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", + "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", + "dev": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/marked": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/marked/-/marked-4.1.1.tgz", "integrity": "sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw==", - "dev": true + "dev": true, + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } }, - "maxmin": { + "node_modules/maxmin": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/maxmin/-/maxmin-2.1.0.tgz", "integrity": "sha1-TTsiCQPZXu5+t6x/qGTnLcCaMWY=", "dev": true, - "requires": { + "dependencies": { "chalk": "^1.0.0", "figures": "^1.0.1", "gzip-size": "^3.0.0", "pretty-bytes": "^3.0.0" }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/maxmin/node_modules/ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/maxmin/node_modules/chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/maxmin/node_modules/supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true, + "engines": { + "node": ">=0.8.0" } }, - "md5.js": { + "node_modules/md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, - "requires": { + "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1", "safe-buffer": "^5.1.2" } }, - "mdurl": { + "node_modules/mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==", "dev": true }, - "micromatch": { + "node_modules/micromatch": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", "dev": true, - "requires": { + "dependencies": { "braces": "^3.0.1", "picomatch": "^2.2.3" + }, + "engines": { + "node": ">=8.6" } }, - "miller-rabin": { + "node_modules/miller-rabin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.0.0", "brorand": "^1.0.1" + }, + "bin": { + "miller-rabin": "bin/miller-rabin" } }, - "mime": { + "node_modules/mime": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz", "integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==", - "dev": true + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } }, - "minimalistic-assert": { + "node_modules/minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", "dev": true }, - "minimalistic-crypto-utils": { + "node_modules/minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", "dev": true }, - "minimatch": { + "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, - "requires": { + "dependencies": { "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" } }, - "minimist": { + "node_modules/minimist": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, - "mkdirp": { + "node_modules/mkdirp": { "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "dev": true, - "requires": { + "dependencies": { "minimist": "^1.2.5" + }, + "bin": { + "mkdirp": "bin/cmd.js" } }, - "module-deps": { + "node_modules/module-deps": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.2.tgz", "integrity": "sha512-a9y6yDv5u5I4A+IPHTnqFxcaKr4p50/zxTjcQJaX2ws9tN/W6J6YXnEKhqRyPhl494dkcxx951onSKVezmI+3w==", "dev": true, - "requires": { - "JSONStream": "^1.0.3", + "dependencies": { "browser-resolve": "^1.7.0", "cached-path-relative": "^1.0.2", "concat-stream": "~1.6.0", @@ -2254,6 +2707,7 @@ "detective": "^5.2.0", "duplexer2": "^0.1.2", "inherits": "^2.0.1", + "JSONStream": "^1.0.3", "parents": "^1.0.0", "readable-stream": "^2.0.2", "resolve": "^1.4.0", @@ -2262,180 +2716,217 @@ "through2": "^2.0.0", "xtend": "^4.0.0" }, + "bin": { + "module-deps": "bin/cmd.js" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/module-deps/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "resolve": { - "version": "1.15.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", - "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/module-deps/node_modules/resolve": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", + "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", + "dev": true, + "dependencies": { + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/module-deps/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" } }, - "ms": { + "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "node-int64": { + "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", "integrity": "sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=", "dev": true }, - "nopt": { + "node_modules/nopt": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "dev": true, - "requires": { + "dependencies": { "abbrev": "1", "osenv": "^0.1.4" + }, + "bin": { + "nopt": "bin/nopt.js" } }, - "number-is-nan": { + "node_modules/number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "object-assign": { + "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "object.defaults": { + "node_modules/object.defaults": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", "dev": true, - "requires": { + "dependencies": { "array-each": "^1.0.1", "array-slice": "^1.0.0", "for-own": "^1.0.0", "isobject": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "object.map": { + "node_modules/object.map": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz", "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", "dev": true, - "requires": { + "dependencies": { "for-own": "^1.0.0", "make-iterator": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "object.pick": { + "node_modules/object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, - "requires": { + "dependencies": { "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "once": { + "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "requires": { + "dependencies": { "wrappy": "1" } }, - "os-browserify": { + "node_modules/os-browserify": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", "dev": true }, - "os-homedir": { + "node_modules/os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "os-tmpdir": { + "node_modules/os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "osenv": { + "node_modules/osenv": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "dev": true, - "requires": { + "dependencies": { "os-homedir": "^1.0.0", "os-tmpdir": "^1.0.0" } }, - "p-each-series": { + "node_modules/p-each-series": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-each-series/-/p-each-series-1.0.0.tgz", "integrity": "sha1-kw89Et0fUOdDRFeiLNbwSsatf3E=", "dev": true, - "requires": { + "dependencies": { "p-reduce": "^1.0.0" + }, + "engines": { + "node": ">=4" } }, - "p-reduce": { + "node_modules/p-reduce": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-reduce/-/p-reduce-1.0.0.tgz", "integrity": "sha1-GMKw3ZNqRpClKfgjH1ig/bakffo=", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "pako": { + "node_modules/pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", "dev": true }, - "parents": { + "node_modules/parents": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", "dev": true, - "requires": { + "dependencies": { "path-platform": "~0.11.15" } }, - "parse-asn1": { + "node_modules/parse-asn1": { "version": "5.1.5", "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", "dev": true, - "requires": { + "dependencies": { "asn1.js": "^4.0.0", "browserify-aes": "^1.0.0", "create-hash": "^1.1.0", @@ -2444,132 +2935,171 @@ "safe-buffer": "^5.1.1" } }, - "parse-filepath": { + "node_modules/parse-filepath": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", "dev": true, - "requires": { + "dependencies": { "is-absolute": "^1.0.0", "map-cache": "^0.2.0", "path-root": "^0.1.1" + }, + "engines": { + "node": ">=0.8" } }, - "parse-passwd": { + "node_modules/parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "path-browserify": { + "node_modules/path-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", "dev": true }, - "path-is-absolute": { + "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "path-key": { + "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "path-parse": { + "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, - "path-platform": { + "node_modules/path-platform": { "version": "0.11.15", "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8.0" + } }, - "path-root": { + "node_modules/path-root": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", "dev": true, - "requires": { + "dependencies": { "path-root-regex": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "path-root-regex": { + "node_modules/path-root-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "pbkdf2": { + "node_modules/pbkdf2": { "version": "3.0.17", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "dev": true, - "requires": { + "dependencies": { "create-hash": "^1.1.2", "create-hmac": "^1.1.4", "ripemd160": "^2.0.1", "safe-buffer": "^5.0.1", "sha.js": "^2.4.8" + }, + "engines": { + "node": ">=0.12" } }, - "pend": { + "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", "dev": true }, - "picomatch": { + "node_modules/picomatch": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", - "dev": true + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } }, - "pretty-bytes": { + "node_modules/pretty-bytes": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-3.0.1.tgz", "integrity": "sha1-J9AAjXeAY6C0gRuzXHnxvV1fvM8=", "dev": true, - "requires": { + "dependencies": { "number-is-nan": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "process": { + "node_modules/process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6.0" + } }, - "process-nextick-args": { + "node_modules/process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, - "progress": { + "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.0" + } }, - "proxy-from-env": { + "node_modules/proxy-from-env": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", "dev": true }, - "public-encrypt": { + "node_modules/public-encrypt": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, - "requires": { + "dependencies": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", @@ -2578,18 +3108,20 @@ "safe-buffer": "^5.1.2" } }, - "punycode": { + "node_modules/punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", "dev": true }, - "puppeteer": { + "node_modules/puppeteer": { "version": "1.20.0", "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.20.0.tgz", "integrity": "sha512-bt48RDBy2eIwZPrkgbcwHtb51mj2nKvHOPMaSH2IsWiv7lOG9k9zhaRzpDZafrk05ajMc3cu+lSQYYOfH2DkVQ==", + "deprecated": "< 19.4.0 is no longer supported", "dev": true, - "requires": { + "hasInstallScript": true, + "dependencies": { "debug": "^4.1.0", "extract-zip": "^1.6.6", "https-proxy-agent": "^2.2.1", @@ -2599,690 +3131,764 @@ "rimraf": "^2.6.1", "ws": "^6.1.0" }, + "engines": { + "node": ">=6.4.0" + } + }, + "node_modules/puppeteer/node_modules/debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, "dependencies": { - "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true } } }, - "querystring": { + "node_modules/puppeteer/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "dev": true + "deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.", + "dev": true, + "engines": { + "node": ">=0.4.x" + } }, - "querystring-es3": { + "node_modules/querystring-es3": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4.x" + } }, - "randombytes": { + "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "^5.1.0" } }, - "randomfill": { + "node_modules/randomfill": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, - "requires": { + "dependencies": { "randombytes": "^2.0.5", "safe-buffer": "^5.1.0" } }, - "read-only-stream": { + "node_modules/read-only-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", "dev": true, - "requires": { + "dependencies": { "readable-stream": "^2.0.2" - }, + } + }, + "node_modules/read-only-stream/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/read-only-stream/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" } }, - "readable-stream": { + "node_modules/readable-stream": { "version": "1.1.14", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", "dev": true, - "requires": { + "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.1", "isarray": "0.0.1", "string_decoder": "~0.10.x" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", - "dev": true - } } }, - "rechoir": { + "node_modules/readable-stream/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", + "dev": true + }, + "node_modules/rechoir": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz", "integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==", "dev": true, - "requires": { + "dependencies": { "resolve": "^1.9.0" }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/rechoir/node_modules/resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, "dependencies": { - "resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", - "dev": true, - "requires": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" - } - } + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "requizzle": { + "node_modules/requizzle": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz", "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==", "dev": true, - "requires": { + "dependencies": { "lodash": "^4.17.14" } }, - "resolve": { + "node_modules/resolve": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", "dev": true }, - "resolve-dir": { + "node_modules/resolve-dir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", "dev": true, - "requires": { + "dependencies": { "expand-tilde": "^2.0.0", "global-modules": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "rimraf": { + "node_modules/rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, - "requires": { + "dependencies": { "glob": "^7.0.5" + }, + "bin": { + "rimraf": "bin.js" } }, - "ripemd160": { + "node_modules/ripemd160": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, - "requires": { + "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1" } }, - "safe-buffer": { + "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, - "safer-buffer": { + "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "sha.js": { + "node_modules/sha.js": { "version": "2.4.11", "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" } }, - "shasum": { + "node_modules/shasum": { "version": "1.0.2", "resolved": "http://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true, - "requires": { + "dependencies": { "json-stable-stringify": "~0.0.0", "sha.js": "~2.4.4" } }, - "shasum-object": { + "node_modules/shasum-object": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shasum-object/-/shasum-object-1.0.0.tgz", "integrity": "sha512-Iqo5rp/3xVi6M4YheapzZhhGPVs0yZwHj7wvwQ1B9z8H6zk+FEnI7y3Teq7qwnekfEhu8WmG2z0z4iWZaxLWVg==", "dev": true, - "requires": { + "dependencies": { "fast-safe-stringify": "^2.0.7" } }, - "shebang-command": { + "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, - "requires": { + "dependencies": { "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" } }, - "shebang-regex": { + "node_modules/shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "shell-quote": { + "node_modules/shell-quote": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", "dev": true }, - "simple-concat": { + "node_modules/simple-concat": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", "dev": true }, - "source-map": { + "node_modules/source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "sprintf-js": { + "node_modules/sprintf-js": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", "dev": true }, - "stream-browserify": { + "node_modules/stream-browserify": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", "dev": true, - "requires": { + "dependencies": { "inherits": "~2.0.1", "readable-stream": "^2.0.2" - }, + } + }, + "node_modules/stream-browserify/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/stream-browserify/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" } }, - "stream-combiner2": { + "node_modules/stream-combiner2": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, - "requires": { + "dependencies": { "duplexer2": "~0.1.0", "readable-stream": "^2.0.2" - }, + } + }, + "node_modules/stream-combiner2/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/stream-combiner2/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" } }, - "stream-http": { + "node_modules/stream-http": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.1.0.tgz", "integrity": "sha512-cuB6RgO7BqC4FBYzmnvhob5Do3wIdIsXAgGycHJnW+981gHqoYcYz9lqjJrk8WXRddbwPuqPYRl+bag6mYv4lw==", "dev": true, - "requires": { + "dependencies": { "builtin-status-codes": "^3.0.0", "inherits": "^2.0.1", "readable-stream": "^3.0.6", "xtend": "^4.0.0" + } + }, + "node_modules/stream-http/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/stream-http/node_modules/safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", + "dev": true + }, + "node_modules/stream-http/node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, "dependencies": { - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "safe-buffer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", - "dev": true - }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "requires": { - "safe-buffer": "~5.2.0" - } - } + "safe-buffer": "~5.2.0" } }, - "stream-splicer": { + "node_modules/stream-splicer": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.1.tgz", "integrity": "sha512-Xizh4/NPuYSyAXyT7g8IvdJ9HJpxIGL9PjyhtywCZvvP0OPIdqyrr4dMikeuvY8xahpdKEBlBTySe583totajg==", "dev": true, - "requires": { + "dependencies": { "inherits": "^2.0.1", "readable-stream": "^2.0.2" - }, + } + }, + "node_modules/stream-splicer/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/stream-splicer/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" } }, - "string_decoder": { + "node_modules/string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, - "strip-ansi": { + "node_modules/strip-ansi": { "version": "3.0.1", "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "requires": { + "dependencies": { "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" } }, - "strip-json-comments": { + "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "subarg": { + "node_modules/subarg": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", "dev": true, - "requires": { + "dependencies": { "minimist": "^1.1.0" } }, - "supports-color": { + "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, - "requires": { + "dependencies": { "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" } }, - "syntax-error": { + "node_modules/syntax-error": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, - "requires": { + "dependencies": { "acorn-node": "^1.2.0" } }, - "taffydb": { + "node_modules/taffydb": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", "integrity": "sha512-y3JaeRSplks6NYQuCOj3ZFMO3j60rTwbuKCvZxsAraGYH2epusatvZ0baZYA01WsGqJBq/Dl6vOrMUJqyMj8kA==", "dev": true }, - "through": { + "node_modules/through": { "version": "2.3.8", "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, - "through2": { + "node_modules/through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "dev": true, - "requires": { + "dependencies": { "readable-stream": "~2.3.6", "xtend": "~4.0.1" - }, + } + }, + "node_modules/through2/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/through2/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" } }, - "timers-browserify": { + "node_modules/timers-browserify": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", "dev": true, - "requires": { + "dependencies": { "process": "~0.11.0" + }, + "engines": { + "node": ">=0.6.0" } }, - "to-regex-range": { + "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, - "requires": { + "dependencies": { "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" } }, - "tty-browserify": { + "node_modules/tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", "dev": true }, - "typedarray": { + "node_modules/typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, - "uc.micro": { + "node_modules/uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", "dev": true }, - "uglify-js": { + "node_modules/uglify-js": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", "dev": true, - "requires": { + "dependencies": { "commander": "~2.20.0", "source-map": "~0.6.1" }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "engines": { + "node": ">=0.8.0" } }, - "umd": { + "node_modules/uglify-js/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/umd": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", - "dev": true + "dev": true, + "bin": { + "umd": "bin/cli.js" + } }, - "unc-path-regex": { + "node_modules/unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "undeclared-identifiers": { + "node_modules/undeclared-identifiers": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.3.tgz", "integrity": "sha512-pJOW4nxjlmfwKApE4zvxLScM/njmwj/DiUBv7EabwE4O8kRUy+HIwxQtZLBPll/jx1LJyBcqNfB3/cpv9EZwOw==", "dev": true, - "requires": { + "dependencies": { "acorn-node": "^1.3.0", "dash-ast": "^1.0.0", "get-assigned-identifiers": "^1.2.0", "simple-concat": "^1.0.0", "xtend": "^4.0.1" + }, + "bin": { + "undeclared-identifiers": "bin.js" } }, - "underscore": { + "node_modules/underscore": { "version": "1.13.6", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==", "dev": true }, - "underscore.string": { + "node_modules/underscore.string": { "version": "3.3.6", "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.6.tgz", "integrity": "sha512-VoC83HWXmCrF6rgkyxS9GHv8W9Q5nhMKho+OadDJGzL2oDYbYEppBaCMH6pFlwLeqj2QS+hhkw2kpXkSdD1JxQ==", "dev": true, - "requires": { + "dependencies": { "sprintf-js": "^1.1.1", "util-deprecate": "^1.0.2" + }, + "engines": { + "node": "*" } }, - "uri-path": { + "node_modules/uri-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/uri-path/-/uri-path-1.0.0.tgz", "integrity": "sha1-l0fwGDWJM8Md4PzP2C0TjmcmLjI=", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.10" + } }, - "url": { + "node_modules/url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", "dev": true, - "requires": { + "dependencies": { "punycode": "1.3.2", "querystring": "0.2.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true - } } }, - "util": { + "node_modules/url/node_modules/punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + }, + "node_modules/util": { "version": "0.10.4", "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", "dev": true, - "requires": { + "dependencies": { "inherits": "2.0.3" } }, - "util-deprecate": { + "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, - "v8flags": { + "node_modules/v8flags": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz", "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", "dev": true, - "requires": { + "dependencies": { "homedir-polyfill": "^1.0.1" + }, + "engines": { + "node": ">= 0.10" } }, - "vm-browserify": { + "node_modules/vm-browserify": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", "dev": true }, - "which": { + "node_modules/which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, - "requires": { + "dependencies": { "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" } }, - "wrappy": { + "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "ws": { + "node_modules/ws": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", "dev": true, - "requires": { + "dependencies": { "async-limiter": "~1.0.0" } }, - "xmlcreate": { + "node_modules/xmlcreate": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz", "integrity": "sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg==", "dev": true }, - "xtend": { + "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4" + } }, - "yauzl": { + "node_modules/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", "dev": true, - "requires": { + "dependencies": { "buffer-crc32": "~0.2.3", "fd-slicer": "~1.1.0" } From 0335450be47e7998cfc3b8ed3a0ff7fc2c360493 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Wed, 21 Jun 2023 23:01:30 +0200 Subject: [PATCH 079/250] misc dependabot alerts: java, dart, ruby --- contrib/thrift-maven-plugin/pom.xml | 2 +- lib/rb/thrift.gemspec | 2 +- test/dart/test_client/pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/thrift-maven-plugin/pom.xml b/contrib/thrift-maven-plugin/pom.xml index 7f255389c14..863a6a9bb9d 100644 --- a/contrib/thrift-maven-plugin/pom.xml +++ b/contrib/thrift-maven-plugin/pom.xml @@ -94,7 +94,7 @@ com.google.guava guava - 32.0.0-jre + 32.0.1 org.codehaus.plexus diff --git a/lib/rb/thrift.gemspec b/lib/rb/thrift.gemspec index f6ac77cac46..5de4408f552 100644 --- a/lib/rb/thrift.gemspec +++ b/lib/rb/thrift.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry', '~> 0.11.3' s.add_development_dependency 'pry-byebug', '~> 3.6' s.add_development_dependency 'pry-stack_explorer', '~> 0.4.9.2' - s.add_development_dependency 'rack', '= 2.0.8' + s.add_development_dependency 'rack', '= 2.2.6.4' s.add_development_dependency 'rack-test', '~> 0.8.3' s.add_development_dependency 'rake', '~> 12.3' s.add_development_dependency 'rspec', '~> 3.7' diff --git a/test/dart/test_client/pubspec.yaml b/test/dart/test_client/pubspec.yaml index c34d69359c9..45a7a4e38a4 100644 --- a/test/dart/test_client/pubspec.yaml +++ b/test/dart/test_client/pubspec.yaml @@ -26,7 +26,7 @@ environment: dependencies: args: ">=0.13.0 <2.0.0" - http: ^0.11.0 + http: ^0.13.3 thrift: path: ../../../lib/dart thrift_test: From a31208823aedea5740b85575f51d2c97b320330b Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Wed, 21 Jun 2023 23:34:43 +0200 Subject: [PATCH 080/250] Update contrib/thrift-maven-plugin/pom.xml Co-authored-by: Christopher Tubbs --- contrib/thrift-maven-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/thrift-maven-plugin/pom.xml b/contrib/thrift-maven-plugin/pom.xml index 863a6a9bb9d..21bd38167b4 100644 --- a/contrib/thrift-maven-plugin/pom.xml +++ b/contrib/thrift-maven-plugin/pom.xml @@ -94,7 +94,7 @@ com.google.guava guava - 32.0.1 + 32.0.1-jre org.codehaus.plexus From abf3fc31470daf57dc50085f56396abba4b3bc1d Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Tue, 27 Jun 2023 10:04:09 -0700 Subject: [PATCH 081/250] Fix spotlessJavaCheck failures Those are failing CI for a while. --- .../main/java/org/apache/thrift/protocol/TBinaryProtocol.java | 1 + .../java/org/apache/thrift/protocol/TCompactProtocol.java | 1 + .../org/apache/thrift/server/TThreadedSelectorServer.java | 4 ++++ .../java/org/apache/thrift/transport/TIOStreamTransport.java | 1 + 4 files changed, 7 insertions(+) diff --git a/lib/java/src/main/java/org/apache/thrift/protocol/TBinaryProtocol.java b/lib/java/src/main/java/org/apache/thrift/protocol/TBinaryProtocol.java index 263a818e501..99c3e930203 100644 --- a/lib/java/src/main/java/org/apache/thrift/protocol/TBinaryProtocol.java +++ b/lib/java/src/main/java/org/apache/thrift/protocol/TBinaryProtocol.java @@ -553,6 +553,7 @@ public int getMinSerializedSize(byte type) throws TTransportException { throw new TTransportException(TTransportException.UNKNOWN, "unrecognized type code"); } } + // ----------------------------------------------------------------- // Additional methods to improve performance. diff --git a/lib/java/src/main/java/org/apache/thrift/protocol/TCompactProtocol.java b/lib/java/src/main/java/org/apache/thrift/protocol/TCompactProtocol.java index b522956df83..abb5cca31cd 100644 --- a/lib/java/src/main/java/org/apache/thrift/protocol/TCompactProtocol.java +++ b/lib/java/src/main/java/org/apache/thrift/protocol/TCompactProtocol.java @@ -940,6 +940,7 @@ public int getMinSerializedSize(byte type) throws TTransportException { throw new TTransportException(TTransportException.UNKNOWN, "unrecognized type code"); } } + // ----------------------------------------------------------------- // Additional methods to improve performance. diff --git a/lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java b/lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java index ae3d292d4a0..86b8dfd2337 100644 --- a/lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java +++ b/lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java @@ -65,18 +65,22 @@ public static class Args extends AbstractNonblockingServerArgs { /** The number of threads for selecting on already-accepted connections */ public int selectorThreads = 2; + /** * The size of the executor service (if none is specified) that will handle invocations. This * may be set to 0, in which case invocations will be handled directly on the selector threads * (as is in TNonblockingServer) */ private int workerThreads = 5; + /** Time to wait for server to stop gracefully */ private int stopTimeoutVal = 60; private TimeUnit stopTimeoutUnit = TimeUnit.SECONDS; + /** The ExecutorService for handling dispatched requests */ private ExecutorService executorService = null; + /** * The size of the blocking queue per selector thread for passing accepted connections to the * selector thread diff --git a/lib/java/src/main/java/org/apache/thrift/transport/TIOStreamTransport.java b/lib/java/src/main/java/org/apache/thrift/transport/TIOStreamTransport.java index af745b8b56f..44dd2b0ff63 100644 --- a/lib/java/src/main/java/org/apache/thrift/transport/TIOStreamTransport.java +++ b/lib/java/src/main/java/org/apache/thrift/transport/TIOStreamTransport.java @@ -68,6 +68,7 @@ public TIOStreamTransport(TConfiguration config, InputStream is) throws TTranspo super(config); inputStream_ = is; } + /** * Input stream constructor, constructs an input only transport. * From e497030b494b0fbdb662593ac58003a49a26048c Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Tue, 27 Jun 2023 09:47:58 -0700 Subject: [PATCH 082/250] Remove py2 from github actions Although we haven't removed py2 support yet, it's no longer available in github actions so it's been consistently failing in recent github action runs. Also add `fail-fast: false` to all matrices in github actions. --- .github/workflows/build.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 542e768153f..8b660bb6fa8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,6 +43,7 @@ jobs: strategy: matrix: os: [ubuntu-20.04, ubuntu-22.04] + fail-fast: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -84,6 +85,7 @@ jobs: go: - '1.19' - '1.20' + fail-fast: false steps: - uses: actions/checkout@v3 @@ -349,7 +351,9 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: ["2.x", "3.x"] + python-version: + - "3.x" + fail-fast: false steps: - uses: actions/checkout@v3 @@ -370,21 +374,11 @@ jobs: python --version pip --version - - name: Python 2.x backport setup - if: matrix.python-version == '2.x' - run: | - python -m pip install --upgrade ipaddress backports.ssl_match_hostname - - name: Run bootstrap run: ./bootstrap.sh - - name: Run configure 2.x - if: matrix.python-version == '2.x' - run: | - ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-python/with-python/') - - name: Run configure 3.x - if: matrix.python-version != '2.x' + if: matrix.python-version == '3.x' run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-py3/with-py3/') From b2c5805b40645ab9713d895535d37296b91fc1ef Mon Sep 17 00:00:00 2001 From: Roshan Rajan Date: Mon, 26 Jun 2023 18:03:03 -0700 Subject: [PATCH 083/250] Fix typename for value in map for python gen code --- .../cpp/src/thrift/generate/t_py_generator.cc | 2 +- test/py/explicit_module/runtest.sh | 3 ++ test/py/explicit_module/shared_types.thrift | 26 +++++++++++++++ test/py/explicit_module/test4.thrift | 32 +++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 test/py/explicit_module/shared_types.thrift create mode 100644 test/py/explicit_module/test4.thrift diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc index 857cb77fdd6..7063ab21e49 100644 --- a/compiler/cpp/src/thrift/generate/t_py_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc @@ -607,7 +607,7 @@ string t_py_generator::render_const_value(t_type* type, t_const_value* value) { int64_t int_val = value->get_integer(); if (gen_enum_) { t_enum_value* enum_val = ((t_enum*)type)->get_constant_by_value(int_val); - out << type->get_name() << "." << enum_val->get_name(); + out << type_name(type) << "." << enum_val->get_name(); } else { out << int_val; } diff --git a/test/py/explicit_module/runtest.sh b/test/py/explicit_module/runtest.sh index 6d734628311..244505029fb 100755 --- a/test/py/explicit_module/runtest.sh +++ b/test/py/explicit_module/runtest.sh @@ -23,9 +23,12 @@ rm -rf gen-py ../../../compiler/cpp/thrift --gen py test1.thrift || exit 1 ../../../compiler/cpp/thrift --gen py test2.thrift || exit 1 ../../../compiler/cpp/thrift --gen py test3.thrift && exit 1 # Fail since test3.thrift has python keywords +../../../compiler/cpp/thrift --gen py:enum shared_types.thrift || exit 1 +../../../compiler/cpp/thrift --gen py:enum test4.thrift || exit 1 PYTHONPATH=./gen-py python -c 'import foo.bar.baz' || exit 1 PYTHONPATH=./gen-py python -c 'import test2' || exit 1 PYTHONPATH=./gen-py python -c 'import test1' &>/dev/null && exit 1 # Should fail. +PYTHONPATH=./gen-py python -c 'import test4.constants' || exit 1 cp -r gen-py simple ../../../compiler/cpp/thrift -r --gen py test2.thrift || exit 1 PYTHONPATH=./gen-py python -c 'import test2' || exit 1 diff --git a/test/py/explicit_module/shared_types.thrift b/test/py/explicit_module/shared_types.thrift new file mode 100644 index 00000000000..9150f8e02a5 --- /dev/null +++ b/test/py/explicit_module/shared_types.thrift @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +namespace py shared_types + +enum SharedEnum { + SharedEnum0 = 0, + SharedEnum1 = 1 +} + diff --git a/test/py/explicit_module/test4.thrift b/test/py/explicit_module/test4.thrift new file mode 100644 index 00000000000..91e9b36dbd1 --- /dev/null +++ b/test/py/explicit_module/test4.thrift @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +namespace py test4 + +include "shared_types.thrift" + +enum TestEnum { + TestEnum0 = 0, + TestEnum1 = 1, +} + +const map typeConversion = { + TestEnum.TestEnum0: shared_types.SharedEnum0, + TestEnum.TestEnum1: shared_types.SharedEnum1, +} \ No newline at end of file From 774b824ef3b22f3184d76d5f33d45d27c168f6db Mon Sep 17 00:00:00 2001 From: Artemy Date: Wed, 5 Jul 2023 10:43:57 +0300 Subject: [PATCH 084/250] THRIFT-5671: return dependencies to POM (#2782) Client: ["java"] --- lib/java/gradle/publishing.gradle | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/java/gradle/publishing.gradle b/lib/java/gradle/publishing.gradle index 91f456add16..5c26fdced43 100644 --- a/lib/java/gradle/publishing.gradle +++ b/lib/java/gradle/publishing.gradle @@ -43,14 +43,16 @@ java { withSourcesJar() } +// skip shadow jar from publishing. Workaround for https://github.com/johnrengelman/shadow/issues/651 +components.java.withVariantsFromConfiguration(configurations.shadowRuntimeElements) { + skip() +} + publishing { publications { mavenJava(MavenPublication) { artifactId = "libthrift" - // explicitly set 3 jars because calling "from components.java" will include shadow jar which isn't what we want - artifact jar - artifact sourcesJar - artifact javadocJar + from components.java pom { name = 'Apache Thrift' description = 'Thrift is a software framework for scalable cross-language services development.' From 284e6b30b8d6fe4522daf0c6982aa7eac8b8d01e Mon Sep 17 00:00:00 2001 From: Roshan Rajan Date: Mon, 26 Jun 2023 18:03:03 -0700 Subject: [PATCH 085/250] Use Enum not Enum.name in Struct serialization/deserialization --- .../cpp/src/thrift/generate/t_py_generator.cc | 37 ++++++++- .../explicit_module/EnumSerializationTest.py | 80 +++++++++++++++++++ test/py/explicit_module/runtest.sh | 5 ++ test/py/explicit_module/test5.thrift | 42 ++++++++++ 4 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 test/py/explicit_module/EnumSerializationTest.py create mode 100644 test/py/explicit_module/test5.thrift diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc index 7063ab21e49..8dd915e1919 100644 --- a/compiler/cpp/src/thrift/generate/t_py_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc @@ -871,7 +871,12 @@ void t_py_generator::generate_py_struct_definition(ostream& out, } if (is_immutable(tstruct)) { - if (gen_newstyle_ || gen_dynamic_) { + if (gen_enum_ && type->is_enum()) { + indent(out) << "super(" << tstruct->get_name() << ", self).__setattr__('" + << (*m_iter)->get_name() << "', " << (*m_iter)->get_name() + << " if hasattr(" << (*m_iter)->get_name() << ", 'value') else " + << type_name(type) << ".__members__.get(" << (*m_iter)->get_name() << "))" << endl; + } else if (gen_newstyle_ || gen_dynamic_) { indent(out) << "super(" << tstruct->get_name() << ", self).__setattr__('" << (*m_iter)->get_name() << "', " << (*m_iter)->get_name() << ")" << endl; } else { @@ -905,6 +910,32 @@ void t_py_generator::generate_py_struct_definition(ostream& out, } out << "))" << endl; + } else if (gen_enum_) { + bool has_enum = false; + for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + t_type* type = (*m_iter)->get_type(); + if (type->is_enum()) { + has_enum = true; + break; + } + } + + if (has_enum) { + out << endl; + indent(out) << "def __setattr__(self, name, value):" << endl; + indent_up(); + for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + t_type* type = (*m_iter)->get_type(); + if (type->is_enum()) { + out << indent() << "if name == \"" << (*m_iter)->get_name() << "\":" << endl + << indent() << indent_str() << "super().__setattr__(name, value if hasattr(value, 'value') else " + << type_name(type) << ".__members__.get(value))" << endl + << indent() << indent_str() << "return" << endl; + } + } + indent(out) << "super().__setattr__(name, value)" << endl << endl; + indent_down(); + } } if (!gen_dynamic_) { @@ -2287,7 +2318,7 @@ void t_py_generator::generate_deserialize_field(ostream& out, out << endl; } else if (type->is_enum()) { if (gen_enum_) { - indent(out) << name << " = " << type_name(type) << "(iprot.readI32()).name"; + indent(out) << name << " = " << type_name(type) << "(iprot.readI32())"; } else { indent(out) << name << " = iprot.readI32()"; } @@ -2477,7 +2508,7 @@ void t_py_generator::generate_serialize_field(ostream& out, t_field* tfield, str } } else if (type->is_enum()) { if (gen_enum_){ - out << "writeI32(" << type_name(type) << "[" << name << "].value)"; + out << "writeI32(" << name << ".value)"; } else { out << "writeI32(" << name << ")"; } diff --git a/test/py/explicit_module/EnumSerializationTest.py b/test/py/explicit_module/EnumSerializationTest.py new file mode 100644 index 00000000000..8d82708ae07 --- /dev/null +++ b/test/py/explicit_module/EnumSerializationTest.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from __future__ import annotations + +import sys +from shared_types.ttypes import SharedEnum +from thrift.TSerialization import serialize, deserialize +from thrift.protocol import TBinaryProtocol +from thrift.transport import TTransport + +def deserialize_immutable(base, + buf, + protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()): + transport = TTransport.TMemoryBuffer(buf) + protocol = protocol_factory.getProtocol(transport) + return base.read(protocol) + +def serialization_deserialization_struct_enum_test(): + test_obj = TestStruct(param1="test_string", param2=TestEnum.TestEnum1, param3=SharedEnum.SharedEnum1) + test_obj_serialized = serialize(test_obj) + test_obj2 = deserialize(TestStruct(), test_obj_serialized) + assert test_obj.param1 == test_obj2.param1 + assert test_obj.param2 == test_obj2.param2 + assert test_obj.param3 == test_obj2.param3 + +def serialization_deserialization_struct_enum_as_string_test(): + test_obj = TestStruct(param1="test_string", param2=TestEnum.TestEnum1.name, param3=SharedEnum.SharedEnum1.name) + test_obj_serialized = serialize(test_obj) + test_obj2 = deserialize(TestStruct(), test_obj_serialized) + assert test_obj.param1 == test_obj2.param1 + assert test_obj.param2 == test_obj2.param2 + assert test_obj.param3 == test_obj2.param3 + +def serialization_deserialization_exception_enum_as_string_test(): + test_obj = TestException(whatOp=0, why=SharedEnum.SharedEnum0.name, who=TestEnum.TestEnum0.name) + test_obj_serialized = serialize(test_obj) + test_obj2 = deserialize_immutable(TestException, test_obj_serialized) + assert test_obj.whatOp == test_obj2.whatOp + assert test_obj.why == test_obj2.why + assert test_obj.who == test_obj2.who + +def serialization_deserialization_exception_enum_test(): + test_obj = TestException(whatOp=0, why=SharedEnum.SharedEnum0, who=TestEnum.TestEnum0) + test_obj_serialized = serialize(test_obj) + test_obj2 = deserialize_immutable(TestException, test_obj_serialized) + assert test_obj.whatOp == test_obj2.whatOp + assert test_obj.why == test_obj2.why + assert test_obj.who == test_obj2.who + + + +if __name__ == "__main__": + args = sys.argv[1:] + if args: + from test5_slots.test5.ttypes import TestEnum, TestStruct, TestException + else: + from test5.ttypes import TestEnum, TestStruct, TestException + serialization_deserialization_struct_enum_test() + serialization_deserialization_struct_enum_as_string_test() + serialization_deserialization_exception_enum_as_string_test() + serialization_deserialization_exception_enum_test() \ No newline at end of file diff --git a/test/py/explicit_module/runtest.sh b/test/py/explicit_module/runtest.sh index 244505029fb..e4618b299f7 100755 --- a/test/py/explicit_module/runtest.sh +++ b/test/py/explicit_module/runtest.sh @@ -25,10 +25,15 @@ rm -rf gen-py ../../../compiler/cpp/thrift --gen py test3.thrift && exit 1 # Fail since test3.thrift has python keywords ../../../compiler/cpp/thrift --gen py:enum shared_types.thrift || exit 1 ../../../compiler/cpp/thrift --gen py:enum test4.thrift || exit 1 +../../../compiler/cpp/thrift --gen py:enum test5.thrift || exit 1 +mkdir -p ./gen-py/test5_slots +../../../compiler/cpp/thrift --gen py:enum,slots -out ./gen-py/test5_slots test5.thrift || exit 1 PYTHONPATH=./gen-py python -c 'import foo.bar.baz' || exit 1 PYTHONPATH=./gen-py python -c 'import test2' || exit 1 PYTHONPATH=./gen-py python -c 'import test1' &>/dev/null && exit 1 # Should fail. PYTHONPATH=./gen-py python -c 'import test4.constants' || exit 1 +PYTHONPATH=./gen-py python EnumSerializationTest.py || exit 1 +PYTHONPATH=./gen-py python EnumSerializationTest.py slot|| exit 1 cp -r gen-py simple ../../../compiler/cpp/thrift -r --gen py test2.thrift || exit 1 PYTHONPATH=./gen-py python -c 'import test2' || exit 1 diff --git a/test/py/explicit_module/test5.thrift b/test/py/explicit_module/test5.thrift new file mode 100644 index 00000000000..f2814240b12 --- /dev/null +++ b/test/py/explicit_module/test5.thrift @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +namespace py test5 + +include "shared_types.thrift" + +enum TestEnum { + TestEnum0 = 0, + TestEnum1 = 1, +} + +struct TestStruct { + 1: optional string param1 + 2: optional TestEnum param2 + 3: optional shared_types.SharedEnum param3 +} + +/** + * Structs can also be exceptions, if they are nasty. + */ +exception TestException { + 1: i32 whatOp, + 2: shared_types.SharedEnum why + 3: TestEnum who +} \ No newline at end of file From 3abf7ecbda08629673828895a99cfa07920a0a5b Mon Sep 17 00:00:00 2001 From: "vladimir.panivko" Date: Thu, 6 Jul 2023 08:55:46 +0200 Subject: [PATCH 086/250] THRIFT-5723 Php8.1 fix warnings --- lib/php/lib/Exception/TException.php | 2 +- lib/php/src/Thrift.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/php/lib/Exception/TException.php b/lib/php/lib/Exception/TException.php index 7dbf8329338..228d761e960 100644 --- a/lib/php/lib/Exception/TException.php +++ b/lib/php/lib/Exception/TException.php @@ -52,7 +52,7 @@ public function __construct($p1 = null, $p2 = 0) } } } else { - parent::__construct($p1, $p2); + parent::__construct((string)$p1, $p2); } } diff --git a/lib/php/src/Thrift.php b/lib/php/src/Thrift.php index 4fe439271e0..0364c90812f 100644 --- a/lib/php/src/Thrift.php +++ b/lib/php/src/Thrift.php @@ -82,7 +82,7 @@ public function __construct($p1=null, $p2=0) } } } else { - parent::__construct($p1, $p2); + parent::__construct((string)$p1, $p2); } } From ff9850eda6b9e00cffe4e07bc7f56c50851cd06e Mon Sep 17 00:00:00 2001 From: Katie Atkinson Date: Mon, 12 Jun 2023 12:23:56 -0700 Subject: [PATCH 087/250] THRIFT-5715 Python Exceptions mutable with slots In Python 3.11 exceptions generated by the compiler can't be used with a context manager because they are immutable. As of Python 3.11 `contextlib.contextmanager` sets `exc.__traceback__` in the event that the code in the context manager errors. As of Thrift v0.18.1 exceptions are generated as immutable by default. See [PR#1835](https://github.com/apache/thrift/pull/1835) for more information about why exceptions were made immutable by default. This change makes all non-Thrift fields mutable when slots is used without dynamic. This will allow exceptions to be re-raised properly by the contextmanager in Python 3.11. --- .../cpp/src/thrift/generate/t_py_generator.cc | 42 ++++++++++++++++--- test/py/TestClient.py | 29 +++++++++++++ 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc index 8dd915e1919..ffabd56521f 100644 --- a/compiler/cpp/src/thrift/generate/t_py_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc @@ -893,12 +893,42 @@ void t_py_generator::generate_py_struct_definition(ostream& out, if (is_immutable(tstruct)) { out << endl; - out << indent() << "def __setattr__(self, *args):" << endl - << indent() << indent_str() << "raise TypeError(\"can't modify immutable instance\")" << endl - << endl; - out << indent() << "def __delattr__(self, *args):" << endl - << indent() << indent_str() << "raise TypeError(\"can't modify immutable instance\")" << endl - << endl; + out << indent() << "def __setattr__(self, *args):" << endl; + indent_up(); + + // Not user-provided fields should be editable so that the Python Standard Library can edit + // internal fields of std library base classes. For example, in Python 3.11 ContextManager + // edits the `__traceback__` field on Exceptions. Allowing this to work with `__slots__` is + // trivial because we know which fields are user-provided, without slots we need to build a + // way to know which fields are user-provided. + if (gen_slots_ && !gen_dynamic_) { + out << indent() << "if args[0] not in self.__slots__:" << endl; + indent_up(); + out << indent() << "super().__setattr__(*args)" << endl + << indent() << "return" << endl; + indent_down(); + } + out << indent() << "raise TypeError(\"can't modify immutable instance\")" << endl; + indent_down(); + out << endl; + out << indent() << "def __delattr__(self, *args):" << endl; + indent_up(); + + // Not user-provided fields should be editable so that the Python Standard Library can edit + // internal fields of std library base classes. For example, in Python 3.11 ContextManager + // edits the `__traceback__` field on Exceptions. Allowing this to work with `__slots__` is + // trivial because we know which fields are user-provided, without slots we need to build a + // way to know which fields are user-provided. + if (gen_slots_ && !gen_dynamic_) { + out << indent() << "if args[0] not in self.__slots__:" << endl; + indent_up(); + out << indent() << "super().__delattr__(*args)" << endl + << indent() << "return" << endl; + indent_down(); + } + out << indent() << "raise TypeError(\"can't modify immutable instance\")" << endl; + indent_down(); + out << endl; // Hash all of the members in order, and also hash in the class // to avoid collisions for stuff like single-field structures. diff --git a/test/py/TestClient.py b/test/py/TestClient.py index 8a30c3a57cd..61a9c60404f 100755 --- a/test/py/TestClient.py +++ b/test/py/TestClient.py @@ -256,6 +256,35 @@ def testMultiException(self): y = self.client.testMultiException('success', 'foobar') self.assertEqual(y.string_thing, 'foobar') + def testException__traceback__(self): + print('testException__traceback__') + self.client.testException('Safe') + expect_slots = uses_slots = False + expect_dynamic = uses_dynamic = False + try: + self.client.testException('Xception') + self.fail("should have gotten exception") + except Xception as x: + uses_slots = hasattr(x, '__slots__') + uses_dynamic = (not isinstance(x, TException)) + # We set expected values here so that we get clean tracebackes when + # the assertions fail. + try: + x.__traceback__ = x.__traceback__ + # If `__traceback__` was set without errors than we expect that + # the slots option was used and that dynamic classes were not. + expect_slots = True + expect_dynamic = False + except Exception as e: + self.assertTrue(isinstance(e, TypeError)) + # There are no other meaningful tests we can preform because we + # are unable to determine the desired state of either `__slots__` + # or `dynamic`. + return + + self.assertEqual(expect_slots, uses_slots) + self.assertEqual(expect_dynamic, uses_dynamic) + def testOneway(self): print('testOneway') start = time.time() From bccca9301dedd6403062ef6be4c56533f889e5b5 Mon Sep 17 00:00:00 2001 From: Prasenjit Sarkar Date: Thu, 6 Jul 2023 21:26:32 -0700 Subject: [PATCH 088/250] THRIFT-5725: Fix the comparison check for bio_get_fd Client: cpp Patch: Prasenjit Sarkar This closes #2831 --- lib/cpp/src/thrift/transport/TSSLSocket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.cpp b/lib/cpp/src/thrift/transport/TSSLSocket.cpp index eb96a73a631..26ae2beda44 100644 --- a/lib/cpp/src/thrift/transport/TSSLSocket.cpp +++ b/lib/cpp/src/thrift/transport/TSSLSocket.cpp @@ -825,7 +825,7 @@ unsigned int TSSLSocket::waitForEvent(bool wantRead) { throw TSSLException("SSL_get_?bio returned nullptr"); } - if (BIO_get_fd(bio, &fdSocket) <= 0) { + if (BIO_get_fd(bio, &fdSocket) < 0) { throw TSSLException("BIO_get_fd failed"); } From 0d5b4f9fa1e9b69c1f8da9a68f2a7eb2c734662b Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 8 Jul 2023 12:49:11 +0200 Subject: [PATCH 089/250] =?UTF-8?q?created=20re=C3=B6ease=20branch=200.19.?= =?UTF-8?q?0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ApacheThrift.nuspec | 8 ++++---- CMakeLists.txt | 2 +- Thrift.podspec | 4 ++-- appveyor.yml | 2 +- bower.json | 2 +- compiler/cpp/src/thrift/version.h | 2 +- configure.ac | 2 +- contrib/Rebus/Properties/AssemblyInfo.cs | 4 ++-- contrib/thrift-maven-plugin/pom.xml | 2 +- contrib/thrift.spec | 2 +- contrib/zeromq/csharp/AssemblyInfo.cs | 2 +- doc/specs/idl.md | 2 +- lib/d/src/thrift/base.d | 2 +- lib/dart/pubspec.yaml | 2 +- lib/delphi/src/Thrift.pas | 2 +- lib/erl/src/thrift.app.src | 2 +- lib/haxe/haxelib.json | 2 +- lib/java/gradle.properties | 2 +- lib/js/package-lock.json | 2 +- lib/js/package.json | 2 +- lib/js/src/thrift.js | 2 +- lib/lua/Thrift.lua | 2 +- .../Thrift.IntegrationTests.csproj | 2 +- .../Thrift.PublicInterfaces.Compile.Tests.csproj | 2 +- lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj | 2 +- lib/netstd/Thrift/Properties/AssemblyInfo.cs | 4 ++-- lib/netstd/Thrift/Thrift.csproj | 6 +++--- lib/ocaml/_oasis | 2 +- lib/perl/lib/Thrift.pm | 2 +- lib/py/setup.py | 2 +- lib/rb/thrift.gemspec | 2 +- lib/rs/Cargo.toml | 2 +- lib/st/package.xml | 2 +- lib/swift/Sources/Thrift.swift | 2 +- lib/swift/Tests/ThriftTests/ThriftTests.swift | 2 +- lib/ts/package-lock.json | 2 +- lib/ts/package.json | 2 +- package-lock.json | 2 +- package.json | 2 +- sonar-project.properties | 6 +++--- test/dart/test_client/pubspec.yaml | 2 +- test/erl/src/thrift_test.app.src | 2 +- test/netstd/Client/Client.csproj | 2 +- test/netstd/Server/Server.csproj | 2 +- tutorial/dart/client/pubspec.yaml | 2 +- tutorial/dart/console_client/pubspec.yaml | 2 +- tutorial/dart/server/pubspec.yaml | 2 +- tutorial/delphi/DelphiClient/DelphiClient.dproj | 4 ++-- tutorial/delphi/DelphiServer/DelphiServer.dproj | 4 ++-- tutorial/netstd/Client/Client.csproj | 2 +- tutorial/netstd/Interfaces/Interfaces.csproj | 2 +- tutorial/netstd/Server/Server.csproj | 2 +- tutorial/ocaml/_oasis | 2 +- 53 files changed, 65 insertions(+), 65 deletions(-) diff --git a/ApacheThrift.nuspec b/ApacheThrift.nuspec index 0e6f09e9490..cd9a29c6c90 100644 --- a/ApacheThrift.nuspec +++ b/ApacheThrift.nuspec @@ -19,14 +19,14 @@ the "Thrift" project. 2. nuget setApiKey 3. nuget pack ApacheThrift.nuspec -Symbols -SymbolPackageFormat snupkg - 4. nuget push ApacheThrift.0.19.0.nupkg -Source https://api.nuget.org/v3/index.json + 4. nuget push ApacheThrift.0.20.0.nupkg -Source https://api.nuget.org/v3/index.json --> ApacheThrift - 0.19.0 - Apache Thrift 0.19.0 + 0.20.0 + Apache Thrift 0.20.0 Apache Thrift Developers Apache Software Foundation Apache-2.0 @@ -36,7 +36,7 @@ Contains runtime libraries from lib/netstd for netstandard2.0 framework development. - + Apache Thrift RPC diff --git a/CMakeLists.txt b/CMakeLists.txt index f056629478c..a685e4f3705 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ endif() # PACKAGE_VERSION is used by cpack scripts currently # Both thrift_VERSION and PACKAGE_VERSION should be the same for now -set(thrift_VERSION "0.19.0") +set(thrift_VERSION "0.20.0") set(PACKAGE_VERSION ${thrift_VERSION}) project("thrift" VERSION ${PACKAGE_VERSION}) diff --git a/Thrift.podspec b/Thrift.podspec index fe5bcc3b468..8bf70f64f18 100644 --- a/Thrift.podspec +++ b/Thrift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Thrift' - s.version = '0.19.0' + s.version = '0.20.0' s.summary = "Apache Thrift is a lightweight, language-independent software stack with an associated code generation mechanism for RPC." s.description = <<-DESC The Apache Thrift scalable cross-language software framework for networked services development combines a software stack with a code generation engine to build services that work efficiently and seamlessly between many programming languages. @@ -10,6 +10,6 @@ The Apache Thrift scalable cross-language software framework for networked servi s.author = { 'Apache Thrift Developers' => 'dev@thrift.apache.org' } s.ios.deployment_target = '9.0' s.osx.deployment_target = '10.10' - s.source = { :git => 'https://github.com/apache/thrift.git', :tag => 'v0.19.0' } + s.source = { :git => 'https://github.com/apache/thrift.git', :tag => 'v0.20.0' } s.source_files = 'lib/swift/Sources/*.swift' end diff --git a/appveyor.yml b/appveyor.yml index 1f5abeb6497..5847ea926ba 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,7 +19,7 @@ # build Apache Thrift on AppVeyor - https://ci.appveyor.com -version: '0.19.0.{build}' +version: '0.20.0.{build}' shallow_clone: true diff --git a/bower.json b/bower.json index 51913dafdf9..84f3a989012 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.19.0", + "version": "0.20.0", "homepage": "https://github.com/apache/thrift.git", "authors": [ "Apache Thrift " diff --git a/compiler/cpp/src/thrift/version.h b/compiler/cpp/src/thrift/version.h index 4f979d9b389..65e0f43684b 100644 --- a/compiler/cpp/src/thrift/version.h +++ b/compiler/cpp/src/thrift/version.h @@ -24,6 +24,6 @@ #pragma once #endif // _MSC_VER -#define THRIFT_VERSION "0.19.0" +#define THRIFT_VERSION "0.20.0" #endif // _THRIFT_VERSION_H_ diff --git a/configure.ac b/configure.ac index 6331acd4aaa..ace48fc3ec4 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ(2.65) AC_CONFIG_MACRO_DIR([./aclocal]) -AC_INIT([thrift], [0.19.0]) +AC_INIT([thrift], [0.20.0]) AC_CONFIG_AUX_DIR([.]) diff --git a/contrib/Rebus/Properties/AssemblyInfo.cs b/contrib/Rebus/Properties/AssemblyInfo.cs index ab40a65504a..33b0aa872c6 100644 --- a/contrib/Rebus/Properties/AssemblyInfo.cs +++ b/contrib/Rebus/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ [assembly: Guid("0af10984-40d3-453d-b1e5-421529e8c7e2")] -[assembly: AssemblyVersion("0.19.0.0")] -[assembly: AssemblyFileVersion("0.19.0.0")] +[assembly: AssemblyVersion("0.20.0.0")] +[assembly: AssemblyFileVersion("0.20.0.0")] diff --git a/contrib/thrift-maven-plugin/pom.xml b/contrib/thrift-maven-plugin/pom.xml index 21bd38167b4..e6e43246381 100644 --- a/contrib/thrift-maven-plugin/pom.xml +++ b/contrib/thrift-maven-plugin/pom.xml @@ -29,7 +29,7 @@ thrift-maven-plugin maven-plugin thrift-maven-plugin - 0.19.0 + 0.20.0 1.8 diff --git a/contrib/thrift.spec b/contrib/thrift.spec index 57011167c00..90bf4aae567 100644 --- a/contrib/thrift.spec +++ b/contrib/thrift.spec @@ -28,7 +28,7 @@ Name: thrift License: Apache License v2.0 Group: Development Summary: RPC and serialization framework -Version: 0.19.0 +Version: 0.20.0 Release: 0 URL: http://thrift.apache.org Packager: Thrift Developers diff --git a/contrib/zeromq/csharp/AssemblyInfo.cs b/contrib/zeromq/csharp/AssemblyInfo.cs index e7856206bb1..8d7ed390b49 100644 --- a/contrib/zeromq/csharp/AssemblyInfo.cs +++ b/contrib/zeromq/csharp/AssemblyInfo.cs @@ -36,7 +36,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("0.19.0.0")] +[assembly: AssemblyVersion("0.20.0.0")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. diff --git a/doc/specs/idl.md b/doc/specs/idl.md index cf8354f2cfb..0980f5bbc6d 100644 --- a/doc/specs/idl.md +++ b/doc/specs/idl.md @@ -1,6 +1,6 @@ ## Thrift interface description language -For Thrift version 0.19.0. +For Thrift version 0.20.0. The Thrift interface definition language (IDL) allows for the definition of [Thrift Types](/docs/types). A Thrift IDL file is processed by the Thrift code generator to produce code for the various target languages to support the defined structs and services in the IDL file. diff --git a/lib/d/src/thrift/base.d b/lib/d/src/thrift/base.d index dbf14294cd6..e843a5c8549 100644 --- a/lib/d/src/thrift/base.d +++ b/lib/d/src/thrift/base.d @@ -50,7 +50,7 @@ class TCompoundOperationException : TException { /// The Thrift version string, used for informative purposes. // Note: This is currently hardcoded, but will likely be filled in by the build // system in future versions. -enum VERSION = "0.19.0"; +enum VERSION = "0.20.0"; /** * Functions used for logging inside Thrift. diff --git a/lib/dart/pubspec.yaml b/lib/dart/pubspec.yaml index f16c3eafc2b..7e205483adc 100644 --- a/lib/dart/pubspec.yaml +++ b/lib/dart/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: thrift -version: 0.19.0 +version: 0.20.0 description: > A Dart library for Apache Thrift author: Apache Thrift Developers diff --git a/lib/delphi/src/Thrift.pas b/lib/delphi/src/Thrift.pas index b725ebc10e9..6696a195a57 100644 --- a/lib/delphi/src/Thrift.pas +++ b/lib/delphi/src/Thrift.pas @@ -28,7 +28,7 @@ interface Thrift.Protocol; const - Version = '0.19.0'; + Version = '0.20.0'; type TException = Thrift.Exception.TException; // compatibility alias diff --git a/lib/erl/src/thrift.app.src b/lib/erl/src/thrift.app.src index c681a2f1036..32e172159e2 100644 --- a/lib/erl/src/thrift.app.src +++ b/lib/erl/src/thrift.app.src @@ -22,7 +22,7 @@ {description, "Thrift bindings"}, % The version of the applicaton - {vsn, "0.19.0"}, + {vsn, "0.20.0"}, % All modules used by the application. {modules, [ diff --git a/lib/haxe/haxelib.json b/lib/haxe/haxelib.json index c2dab349b37..78779da4534 100644 --- a/lib/haxe/haxelib.json +++ b/lib/haxe/haxelib.json @@ -10,7 +10,7 @@ "framework" ], "description": "Haxe bindings for the Apache Thrift RPC and serialization framework", - "version": "0.19.0", + "version": "0.20.0", "releasenote": "Licensed under Apache License, Version 2.0. The Apache Thrift compiler needs to be installed separately.", "contributors": ["ApacheThrift"], "dependencies": { diff --git a/lib/java/gradle.properties b/lib/java/gradle.properties index 2e3d0412464..404318bed34 100644 --- a/lib/java/gradle.properties +++ b/lib/java/gradle.properties @@ -1,7 +1,7 @@ # This file is shared currently between this Gradle build and the # Ant builds for fd303 and JavaScript. Keep the dotted notation for # the properties to minimize the changes in the dependencies. -thrift.version=0.19.0 +thrift.version=0.20.0 thrift.groupid=org.apache.thrift release=false diff --git a/lib/js/package-lock.json b/lib/js/package-lock.json index cbd36f55587..555979080b3 100644 --- a/lib/js/package-lock.json +++ b/lib/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.19.0", + "version": "0.20.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/lib/js/package.json b/lib/js/package.json index 57b4bb223ed..8543b2500c4 100644 --- a/lib/js/package.json +++ b/lib/js/package.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.19.0", + "version": "0.20.0", "description": "Thrift is a software framework for scalable cross-language services development.", "main": "./src/thrift", "author": { diff --git a/lib/js/src/thrift.js b/lib/js/src/thrift.js index 78fdfb2bb7a..7dbb560c740 100644 --- a/lib/js/src/thrift.js +++ b/lib/js/src/thrift.js @@ -46,7 +46,7 @@ var Thrift = { * @const {string} Version * @memberof Thrift */ - Version: '0.19.0', + Version: '0.20.0', /** * Thrift IDL type string to Id mapping. diff --git a/lib/lua/Thrift.lua b/lib/lua/Thrift.lua index c249278f9ca..1f9a562fac0 100644 --- a/lib/lua/Thrift.lua +++ b/lib/lua/Thrift.lua @@ -48,7 +48,7 @@ function ttable_size(t) return count end -version = '0.19.0' +version = '0.20.0' TType = { STOP = 0, diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index 19065c6b6f6..8a0167a2815 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -22,7 +22,7 @@ net7.0 Thrift.IntegrationTests Thrift.IntegrationTests - 0.19.0.0 + 0.20.0.0 Exe false false diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj index 990b24051cd..457cdef3a57 100644 --- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj +++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj @@ -19,7 +19,7 @@ --> - 0.19.0 + 0.20.0 Thrift version $(ThriftVersion) net7.0 $(ThriftVersion).0 diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index bae55ea5c95..6b20f5c9a0c 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -20,7 +20,7 @@ net7.0 - 0.19.0.0 + 0.20.0.0 enable diff --git a/lib/netstd/Thrift/Properties/AssemblyInfo.cs b/lib/netstd/Thrift/Properties/AssemblyInfo.cs index 3dd0cc6e32e..bd84c4ea37a 100644 --- a/lib/netstd/Thrift/Properties/AssemblyInfo.cs +++ b/lib/netstd/Thrift/Properties/AssemblyInfo.cs @@ -52,5 +52,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.19.0.0")] -[assembly: AssemblyFileVersion("0.19.0.0")] +[assembly: AssemblyVersion("0.20.0.0")] +[assembly: AssemblyFileVersion("0.20.0.0")] diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index 760ffe4a0f7..d2f9c17fccb 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -40,8 +40,8 @@ true thrift.snk false - Apache Thrift 0.19.0 - 0.19.0.0 + Apache Thrift 0.20.0 + 0.20.0.0 false http://thrift.apache.org/ Apache Thrift Developers @@ -50,7 +50,7 @@ C# .NET Core bindings for the Apache Thrift RPC system Apache Thrift RPC - https://github.com/apache/thrift/blob/0.19.0/CHANGES.md + https://github.com/apache/thrift/blob/0.20.0/CHANGES.md README.md Copyright 2023 The Apache Software Foundation diff --git a/lib/ocaml/_oasis b/lib/ocaml/_oasis index cd4a0c7c132..be1ce1265b9 100644 --- a/lib/ocaml/_oasis +++ b/lib/ocaml/_oasis @@ -1,5 +1,5 @@ Name: libthrift-ocaml -Version: 0.19.0 +Version: 0.20.0 OASISFormat: 0.3 Synopsis: OCaml bindings for the Apache Thrift RPC system Authors: Apache Thrift Developers diff --git a/lib/perl/lib/Thrift.pm b/lib/perl/lib/Thrift.pm index 08eb84198d5..4b5f781e09f 100644 --- a/lib/perl/lib/Thrift.pm +++ b/lib/perl/lib/Thrift.pm @@ -31,6 +31,6 @@ use warnings; # package Thrift; -use version 0.77; our $VERSION = version->declare("v0.19.0"); +use version 0.77; our $VERSION = version->declare("v0.20.0"); 1; diff --git a/lib/py/setup.py b/lib/py/setup.py index 6e365f838aa..f5371af753c 100644 --- a/lib/py/setup.py +++ b/lib/py/setup.py @@ -105,7 +105,7 @@ def run_setup(with_binary): twisted_deps = ['twisted'] setup(name='thrift', - version='0.19.0', + version='0.20.0', description='Python bindings for the Apache Thrift RPC system', long_description=read_file("README.md"), long_description_content_type="text/markdown", diff --git a/lib/rb/thrift.gemspec b/lib/rb/thrift.gemspec index 5de4408f552..6b510c78be9 100644 --- a/lib/rb/thrift.gemspec +++ b/lib/rb/thrift.gemspec @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__) Gem::Specification.new do |s| s.name = 'thrift' - s.version = '0.19.0' + s.version = '0.20.0' s.authors = ['Apache Thrift Developers'] s.email = ['dev@thrift.apache.org'] s.homepage = 'http://thrift.apache.org' diff --git a/lib/rs/Cargo.toml b/lib/rs/Cargo.toml index 4b3c85702a4..38c277df5e9 100644 --- a/lib/rs/Cargo.toml +++ b/lib/rs/Cargo.toml @@ -2,7 +2,7 @@ name = "thrift" description = "Rust bindings for the Apache Thrift RPC system" edition = "2021" -version = "0.19.0" +version = "0.20.0" license = "Apache-2.0" authors = ["Apache Thrift Developers "] homepage = "http://thrift.apache.org" diff --git a/lib/st/package.xml b/lib/st/package.xml index 63dd3affa03..7af883ee624 100644 --- a/lib/st/package.xml +++ b/lib/st/package.xml @@ -17,7 +17,7 @@ specific language governing permissions and limitations under the License. --> - + libthrift-st thrift.st diff --git a/lib/swift/Sources/Thrift.swift b/lib/swift/Sources/Thrift.swift index df1b6588e4e..22981a0fcf4 100644 --- a/lib/swift/Sources/Thrift.swift +++ b/lib/swift/Sources/Thrift.swift @@ -1,3 +1,3 @@ class Thrift { - let version = "0.19.0" + let version = "0.20.0" } diff --git a/lib/swift/Tests/ThriftTests/ThriftTests.swift b/lib/swift/Tests/ThriftTests/ThriftTests.swift index aea9bc814b1..3c6854c6587 100644 --- a/lib/swift/Tests/ThriftTests/ThriftTests.swift +++ b/lib/swift/Tests/ThriftTests/ThriftTests.swift @@ -3,7 +3,7 @@ import XCTest class ThriftTests: XCTestCase { func testVersion() { - XCTAssertEqual(Thrift().version, "0.19.0") + XCTAssertEqual(Thrift().version, "0.20.0") } static var allTests : [(String, (ThriftTests) -> () throws -> Void)] { diff --git a/lib/ts/package-lock.json b/lib/ts/package-lock.json index de1254c6732..b7a591b1f36 100644 --- a/lib/ts/package-lock.json +++ b/lib/ts/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.19.0", + "version": "0.20.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/lib/ts/package.json b/lib/ts/package.json index 2d93d326b64..054807f91c9 100644 --- a/lib/ts/package.json +++ b/lib/ts/package.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.19.0", + "version": "0.20.0", "description": "Thrift is a software framework for scalable cross-language services development.", "author": { "name": "Apache Thrift Developers", diff --git a/package-lock.json b/package-lock.json index cc367e5447a..e1440f0f473 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.19.0", + "version": "0.20.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 28d7a1547f5..47f9e874884 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "git", "url": "https://github.com/apache/thrift.git" }, - "version": "0.19.0", + "version": "0.20.0", "author": { "name": "Apache Thrift Developers", "email": "dev@thrift.apache.org", diff --git a/sonar-project.properties b/sonar-project.properties index cac8e8c4e87..258dfe913af 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -16,7 +16,7 @@ development, combines a software stack with a code generation engine to build services that work efficiently and seamlessly between all major languages. # Apache Thrift Version -sonar.projectVersion=0.19.0 +sonar.projectVersion=0.20.0 # use this to set another version string # $ sonar-runner -D sonar.projectVersion=`git rev-parse HEAD` # set projectDate in combination with projectVersion for imports of old releases @@ -54,7 +54,7 @@ module1.sonar.projectName=Apache Thrift - Java Library module1.sonar.projectBaseDir=lib/java module1.sonar.sources=src module1.sonar.tests=test -module1.sonar.binaries=build/libs/libthrift-0.19.0.jar +module1.sonar.binaries=build/libs/libthrift-0.20.0.jar module1.sonar.libraries=build/deps/*.jar module1.sonar.language=java @@ -62,7 +62,7 @@ module2.sonar.projectName=Apache Thrift - Java Tutorial module2.sonar.projectBaseDir=. module2.sonar.sources=tutorial/java/src, tutorial/java/gen-java module2.sonar.binaries=tutorial/java/tutorial.jar -module2.sonar.libraries=lib/java/build/deps/*.jar,lib/java/build/libs/libthrift-0.19.0.jar +module2.sonar.libraries=lib/java/build/deps/*.jar,lib/java/build/libs/libthrift-0.20.0.jar module2.sonar.language=java module3.sonar.projectName=Apache Thrift - JavaScript Library diff --git a/test/dart/test_client/pubspec.yaml b/test/dart/test_client/pubspec.yaml index 45a7a4e38a4..177e2cdf141 100644 --- a/test/dart/test_client/pubspec.yaml +++ b/test/dart/test_client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: thrift_test_client -version: 0.19.0 +version: 0.20.0 description: A client integration test for the Dart Thrift library author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/test/erl/src/thrift_test.app.src b/test/erl/src/thrift_test.app.src index 4a850d04985..9d68a564533 100644 --- a/test/erl/src/thrift_test.app.src +++ b/test/erl/src/thrift_test.app.src @@ -22,7 +22,7 @@ {description, "Thrift cross language test"}, % The version of the applicaton - {vsn, "0.19.0"}, + {vsn, "0.20.0"}, % All modules used by the application. {modules, [ diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index bd7d1ee1810..4482f35a031 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -24,7 +24,7 @@ Client Client Exe - 0.19.0.0 + 0.20.0.0 false false false diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index 85c1ad4b0c9..905edc2cec9 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -24,7 +24,7 @@ Server Server Exe - 0.19.0.0 + 0.20.0.0 false false false diff --git a/tutorial/dart/client/pubspec.yaml b/tutorial/dart/client/pubspec.yaml index 626c8f963f0..e8c6db8ab90 100644 --- a/tutorial/dart/client/pubspec.yaml +++ b/tutorial/dart/client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_client -version: 0.19.0 +version: 0.20.0 description: A Dart client implementation of the Apache Thrift tutorial author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/tutorial/dart/console_client/pubspec.yaml b/tutorial/dart/console_client/pubspec.yaml index 957b96cb551..e5c0938b973 100644 --- a/tutorial/dart/console_client/pubspec.yaml +++ b/tutorial/dart/console_client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_console_client -version: 0.19.0 +version: 0.20.0 description: > A Dart console client to implementation of the Apache Thrift tutorial author: Apache Thrift Developers diff --git a/tutorial/dart/server/pubspec.yaml b/tutorial/dart/server/pubspec.yaml index 6ad5cdd48d8..5f7edb9bc25 100644 --- a/tutorial/dart/server/pubspec.yaml +++ b/tutorial/dart/server/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_server -version: 0.19.0 +version: 0.20.0 description: A Dart server to support the Apache Thrift tutorial author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/tutorial/delphi/DelphiClient/DelphiClient.dproj b/tutorial/delphi/DelphiClient/DelphiClient.dproj index e55cc06bade..34d9f03dc22 100644 --- a/tutorial/delphi/DelphiClient/DelphiClient.dproj +++ b/tutorial/delphi/DelphiClient/DelphiClient.dproj @@ -124,13 +124,13 @@ popd]]> Thrift Tutorial - 0.19.0.0 + 0.20.0.0 DelphiClient Copyright © 2012 The Apache Software Foundation DelphiClient.exe Thrift - 0.19.0.0 + 0.20.0.0 diff --git a/tutorial/delphi/DelphiServer/DelphiServer.dproj b/tutorial/delphi/DelphiServer/DelphiServer.dproj index 4080b92545a..fa8cb92d84a 100644 --- a/tutorial/delphi/DelphiServer/DelphiServer.dproj +++ b/tutorial/delphi/DelphiServer/DelphiServer.dproj @@ -121,13 +121,13 @@ popd]]> Thrift Tutorial - 0.19.0.0 + 0.20.0.0 DelphiServer Copyright © 2012 The Apache Software Foundation DelphiServer.exe Thrift - 0.19.0.0 + 0.20.0.0 diff --git a/tutorial/netstd/Client/Client.csproj b/tutorial/netstd/Client/Client.csproj index c21b58d12ed..ee0bc8284d1 100644 --- a/tutorial/netstd/Client/Client.csproj +++ b/tutorial/netstd/Client/Client.csproj @@ -24,7 +24,7 @@ Client Client Exe - 0.19.0.0 + 0.20.0.0 false false false diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index 1e1193b1dce..de5f113e7af 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -22,7 +22,7 @@ net7.0 Interfaces Interfaces - 0.19.0.0 + 0.20.0.0 false false false diff --git a/tutorial/netstd/Server/Server.csproj b/tutorial/netstd/Server/Server.csproj index 193e3c37ef4..478fa8c4eff 100644 --- a/tutorial/netstd/Server/Server.csproj +++ b/tutorial/netstd/Server/Server.csproj @@ -24,7 +24,7 @@ Server Server Exe - 0.19.0.0 + 0.20.0.0 false false false diff --git a/tutorial/ocaml/_oasis b/tutorial/ocaml/_oasis index 110174055a6..6072e4b969f 100644 --- a/tutorial/ocaml/_oasis +++ b/tutorial/ocaml/_oasis @@ -1,5 +1,5 @@ Name: tutorial -Version: 0.19.0 +Version: 0.20.0 OASISFormat: 0.3 Synopsis: OCaml Tutorial example Authors: Apache Thrift Developers From f5a67528d820d9bf1ba194d9403519f032a31b0a Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 15 Jul 2023 11:18:25 +0200 Subject: [PATCH 090/250] Release 0.19.0 --- CHANGES.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 6 +++++ doap.rdf | 5 ++++ 3 files changed, 71 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 0173f6f074e..1fcbbe631d9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,65 @@ # Apache Thrift Changelog +## 0.19.0 + +### Known Open Issues (Blocker or Critical) + +- [THRIFT-3877](https://issues.apache.org/jira/browse/THRIFT-3877) - C++ library don't work with HTTP (csharp server, cpp client; need cross test enhancement) +- [THRIFT-5468](https://issues.apache.org/jira/browse/THRIFT-5468) - Swift service generator doesn't support oneway + + +## Build Process + +- [THRIFT-5701](https://issues.apache.org/jira/browse/THRIFT-5701) - Add dependabot + +## C++ + +- [THRIFT-5725](https://issues.apache.org/jira/browse/THRIFT-5725) - Thrift SSL server stops working if the file descriptor returned is zero +- [THRIFT-5716](https://issues.apache.org/jira/browse/THRIFT-5716) - TMemoryBuffer resizing might shrink the buffer size due to uint32_t overflow + +## Compiler (General) + +- [THRIFT-5690](https://issues.apache.org/jira/browse/THRIFT-5690) - Constant expects type to be defined before + +## Delphi + +- [THRIFT-5686](https://issues.apache.org/jira/browse/THRIFT-5686) - Add comparer and capacity arguments to container classes + +## Haxe + +- [THRIFT-5717](https://issues.apache.org/jira/browse/THRIFT-5717) - uuid sets and map keys may throw on some Haxe targets +- [THRIFT-5704](https://issues.apache.org/jira/browse/THRIFT-5704) - Superfluous block scope in generated write() code +- [THRIFT-5703](https://issues.apache.org/jira/browse/THRIFT-5703) - Haxe 4.30 emits "Local variable retval used without being initialized" on generated code +- [THRIFT-5692](https://issues.apache.org/jira/browse/THRIFT-5692) - Support for deprecated methods (via annotation) +- [THRIFT-5707](https://issues.apache.org/jira/browse/THRIFT-5707) - deprecation warning fixes for @:extern and @:enum + +## Java + +- [THRIFT-5700](https://issues.apache.org/jira/browse/THRIFT-5700) - Migration to JakartaEE and Apache HttpComponents 5 +- [THRIFT-5711](https://issues.apache.org/jira/browse/THRIFT-5711) - FutureClient does not extend when service extends from another service +- [THRIFT-5702](https://issues.apache.org/jira/browse/THRIFT-5702) - Support Java 8 +- [THRIFT-5696](https://issues.apache.org/jira/browse/THRIFT-5696) - TByteBuffer.java does not allow non-default TConfiguration + +## JavaScript + +- [THRIFT-5674](https://issues.apache.org/jira/browse/THRIFT-5674) - Server implementation exceptions are not sent to client in ES6 promise-style invocation + +## netstd + +- [THRIFT-5684](https://issues.apache.org/jira/browse/THRIFT-5684) - Upgrade to net7.0 + +## Node.js + +- [THRIFT-5710](https://issues.apache.org/jira/browse/THRIFT-5710) - NodeJS header transport leaks headers between all instances + +## PHP + +- [THRIFT-5723](https://issues.apache.org/jira/browse/THRIFT-5723) - Php8.1 fix warnings + +## Swift + +- [THRIFT-5714](https://issues.apache.org/jira/browse/THRIFT-5714) - add TJSONProtocol support in thrift-swift + ## 0.18.1 diff --git a/debian/changelog b/debian/changelog index 93dc7aaef8a..40898292a06 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +thrift (0.19.0) stable; urgency=low + + * update to 0.19.0 + + -- Apache Thrift Developers Sat, 15 Jul 2023 11:00:00 +0100 + thrift (0.18.1) stable; urgency=low * update to 0.18.1 diff --git a/doap.rdf b/doap.rdf index 9c4d63c699b..6ad3026d7fe 100644 --- a/doap.rdf +++ b/doap.rdf @@ -55,6 +55,11 @@ + + Apache Thrift + 2022-07-15 + 0.19.0 + Apache Thrift 2022-02-15 From 30b31aaecbfc440e2cdb9cd6a0cdf2d856581519 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 15 Jul 2023 11:48:39 +0200 Subject: [PATCH 091/250] Release 0.19.0 --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 1fcbbe631d9..7b220e0374c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,7 +6,7 @@ - [THRIFT-3877](https://issues.apache.org/jira/browse/THRIFT-3877) - C++ library don't work with HTTP (csharp server, cpp client; need cross test enhancement) - [THRIFT-5468](https://issues.apache.org/jira/browse/THRIFT-5468) - Swift service generator doesn't support oneway - +- [THRIFT-5654](https://issues.apache.org/jira/browse/THRIFT-5654) - LNK4042 and LNK2019 in go_validator_generator.cc ## Build Process From 8a5a440b71d78de2d22c3d47f25c75fe4928f1ca Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Wed, 5 Jul 2023 08:18:26 +0000 Subject: [PATCH 092/250] reformat kotlin files --- .../org/apache/thrift/test/TestClient.kt | 18 ++++++++++++------ .../org/apache/thrift/test/TestServer.kt | 17 ++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt b/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt index 39500dfbb07..c238d0b426e 100644 --- a/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt +++ b/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt @@ -101,9 +101,12 @@ class TestClient : CliktCommand() { private fun createProtocol(transport: TTransport): TProtocol = when (protocolType) { - ProtocolType.Binary, ProtocolType.Multi -> TBinaryProtocol(transport) - ProtocolType.Compact, ProtocolType.MultiCompact -> TCompactProtocol(transport) - ProtocolType.Json, ProtocolType.MultiJson -> TJSONProtocol(transport) + ProtocolType.Binary, + ProtocolType.Multi -> TBinaryProtocol(transport) + ProtocolType.Compact, + ProtocolType.MultiCompact -> TCompactProtocol(transport) + ProtocolType.Json, + ProtocolType.MultiJson -> TJSONProtocol(transport) } private fun createTransport(): TNonblockingTransport = @@ -283,7 +286,8 @@ class TestClient : CliktCommand() { if (whoa.size == 2 && whoa.containsKey(1L) && whoa.containsKey(2L)) { val firstMap = whoa[1L]!! val secondMap = whoa[2L]!! - if (firstMap.size == 2 && + if ( + firstMap.size == 2 && firstMap.containsKey(Numberz.TWO) && firstMap.containsKey(Numberz.THREE) && secondMap.size == 1 && @@ -361,7 +365,8 @@ class TestClient : CliktCommand() { private suspend fun multiplexTest(returnCode: Int): Int { var code = returnCode - if (protocolType == ProtocolType.Multi || + if ( + protocolType == ProtocolType.Multi || protocolType == ProtocolType.MultiJson || protocolType == ProtocolType.MultiCompact ) { @@ -574,7 +579,8 @@ private suspend fun ThriftTestClient.nestedMapTest(returnCode: Int): Int { } else { val m1 = mm[4]!! val m2 = mm[-4]!! - if (m1[1] != 1 || + if ( + m1[1] != 1 || m1[2] != 2 || m1[3] != 3 || m1[4] != 4 || diff --git a/lib/kotlin/cross-test-server/src/main/kotlin/org/apache/thrift/test/TestServer.kt b/lib/kotlin/cross-test-server/src/main/kotlin/org/apache/thrift/test/TestServer.kt index 566e53dac19..315d12e722d 100644 --- a/lib/kotlin/cross-test-server/src/main/kotlin/org/apache/thrift/test/TestServer.kt +++ b/lib/kotlin/cross-test-server/src/main/kotlin/org/apache/thrift/test/TestServer.kt @@ -226,11 +226,12 @@ class TestServerCommand : CliktCommand() { private fun getProtocolFactory(): TProtocolFactory = when (protocolType) { - ProtocolType.Json, ProtocolType.MultiJson -> TJSONProtocol.Factory() - ProtocolType.Compact, ProtocolType.MultiCompact -> - TCompactProtocol.Factory(stringLimit, containerLimit) - ProtocolType.Binary, ProtocolType.Multi -> - TBinaryProtocol.Factory(stringLimit, containerLimit) + ProtocolType.Json, + ProtocolType.MultiJson -> TJSONProtocol.Factory() + ProtocolType.Compact, + ProtocolType.MultiCompact -> TCompactProtocol.Factory(stringLimit, containerLimit) + ProtocolType.Binary, + ProtocolType.Multi -> TBinaryProtocol.Factory(stringLimit, containerLimit) } } @@ -258,7 +259,8 @@ private fun getServerEngine( multiplexedProcessor.registerProcessor("ThriftTest", testProcessor) multiplexedProcessor.registerProcessor("SecondService", secondProcessor) when (serverType) { - ServerType.NonBlocking, ServerType.ThreadedSelector -> { + ServerType.NonBlocking, + ServerType.ThreadedSelector -> { val tNonblockingServerSocket = TNonblockingServerSocket(NonblockingAbstractServerSocketArgs().port(port)) when (serverType) { @@ -283,7 +285,8 @@ private fun getServerEngine( } } } - ServerType.Simple, ServerType.ThreadPool -> { + ServerType.Simple, + ServerType.ThreadPool -> { // SSL socket val tServerSocket: TServerSocket = if (ssl) { From a4e1136541fe4c092f5f88ad43b335827897f371 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Wed, 5 Jul 2023 08:32:55 +0000 Subject: [PATCH 093/250] fix gradle format --- lib/kotlin/build.gradle.kts | 4 ++-- lib/kotlin/cross-test-client/build.gradle.kts | 2 +- lib/kotlin/settings.gradle.kts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/kotlin/build.gradle.kts b/lib/kotlin/build.gradle.kts index cd52e7fce8b..754df89fc6f 100644 --- a/lib/kotlin/build.gradle.kts +++ b/lib/kotlin/build.gradle.kts @@ -40,7 +40,7 @@ kotlin { } } -tasks.withType { +tasks.withType { kotlinOptions.jvmTarget = "1.8" } @@ -57,7 +57,7 @@ tasks { task("compileThrift") { val thriftBin = if (hasProperty("thrift.compiler")) { - file(property("thrift.compiler")) + file(property("thrift.compiler")!!) } else { project.rootDir.resolve("../../compiler/cpp/thrift") } diff --git a/lib/kotlin/cross-test-client/build.gradle.kts b/lib/kotlin/cross-test-client/build.gradle.kts index 579d01e4c87..b370a403c71 100644 --- a/lib/kotlin/cross-test-client/build.gradle.kts +++ b/lib/kotlin/cross-test-client/build.gradle.kts @@ -70,7 +70,7 @@ tasks { task("compileThrift") { val thriftBin = if (hasProperty("thrift.compiler")) { - file(property("thrift.compiler")) + file(property("thrift.compiler")!!) } else { project.rootDir.resolve("../../compiler/cpp/thrift") } diff --git a/lib/kotlin/settings.gradle.kts b/lib/kotlin/settings.gradle.kts index 342fc3b1d5b..86fa02adac1 100644 --- a/lib/kotlin/settings.gradle.kts +++ b/lib/kotlin/settings.gradle.kts @@ -18,7 +18,7 @@ */ pluginManagement { plugins { - kotlin("jvm") version "1.8.21" + kotlin("jvm") version "1.8.22" id("com.ncorti.ktfmt.gradle") version "0.12.0" } } From 2cfde6b440c23bca01e5a10df74cfac48b09a86d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jul 2023 06:30:05 +0000 Subject: [PATCH 094/250] Bump org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 in /lib/kotlin Bumps [org.jetbrains.kotlinx:kotlinx-coroutines-jdk8](https://github.com/Kotlin/kotlinx.coroutines) from 1.7.1 to 1.7.2. - [Release notes](https://github.com/Kotlin/kotlinx.coroutines/releases) - [Changelog](https://github.com/Kotlin/kotlinx.coroutines/blob/master/CHANGES.md) - [Commits](https://github.com/Kotlin/kotlinx.coroutines/compare/1.7.1...1.7.2) --- updated-dependencies: - dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- lib/kotlin/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/build.gradle.kts b/lib/kotlin/build.gradle.kts index 754df89fc6f..fde32de625d 100644 --- a/lib/kotlin/build.gradle.kts +++ b/lib/kotlin/build.gradle.kts @@ -29,7 +29,7 @@ repositories { dependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom")) implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.2") implementation("org.apache.thrift:libthrift:INCLUDED") testImplementation(kotlin("test")) } From cfb4a80cfcaf5e2bc39a4ad05c796f63e484c2bb Mon Sep 17 00:00:00 2001 From: tsxiaofang <33743720+tsxiaofang@users.noreply.github.com> Date: Mon, 17 Jul 2023 18:16:32 +0800 Subject: [PATCH 095/250] Setting TCP_ NODELAY option for rust server (#2832) Resolve TFramedWriteTransport write message size 4 bytes causing approximately 40 milliseconds delay --- lib/rs/src/server/threaded.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rs/src/server/threaded.rs b/lib/rs/src/server/threaded.rs index ad55b4459f2..ee863952b71 100644 --- a/lib/rs/src/server/threaded.rs +++ b/lib/rs/src/server/threaded.rs @@ -183,6 +183,7 @@ where for stream in listener.incoming() { match stream { Ok(s) => { + s.set_nodelay(true).ok(); let channel = TTcpChannel::with_stream(s); self.handle_stream(channel)?; } From 8e89abee1744cb91708640a9bfd1bef7b672ed2a Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Thu, 20 Jul 2023 21:43:23 +0200 Subject: [PATCH 096/250] THRIFT-5726 package upgrades and consolidation/improvement of build targets checks Client: netstd Patch: Jens Geyer --- .../Thrift.Benchmarks.csproj | 2 +- .../Thrift.IntegrationTests.csproj | 8 +++---- ...rift.PublicInterfaces.Compile.Tests.csproj | 2 +- .../Tests/Thrift.Tests/Thrift.Tests.csproj | 6 ++--- lib/netstd/Thrift/Protocol/TJSONProtocol.cs | 24 +++++++++---------- lib/netstd/Thrift/Thrift.csproj | 14 +++++++++-- .../Thrift/Transport/Client/THttpTransport.cs | 18 +++++++------- .../Transport/Client/TNamedPipeTransport.cs | 12 +++++----- .../Transport/Client/TStreamTransport.cs | 12 +++++----- .../Server/TNamedPipeServerTransport.cs | 6 ++--- test/netstd/Client/Client.csproj | 2 +- test/netstd/Server/Server.csproj | 3 +-- tutorial/netstd/Interfaces/Interfaces.csproj | 2 +- tutorial/netstd/Server/Server.csproj | 9 ++++--- 14 files changed, 64 insertions(+), 56 deletions(-) diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj index aed36cdcb11..b5afef58213 100644 --- a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj +++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj @@ -27,7 +27,7 @@ - + diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index 8a0167a2815..98e80077530 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -35,10 +35,10 @@ - - - - + + + + diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj index 457cdef3a57..6f3abb15587 100644 --- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj +++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj @@ -37,7 +37,7 @@ - + diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index 6b20f5c9a0c..94b7b09c1bc 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -26,9 +26,9 @@ - - - + + + diff --git a/lib/netstd/Thrift/Protocol/TJSONProtocol.cs b/lib/netstd/Thrift/Protocol/TJSONProtocol.cs index 82e758b1ee9..9f761aeaee5 100644 --- a/lib/netstd/Thrift/Protocol/TJSONProtocol.cs +++ b/lib/netstd/Thrift/Protocol/TJSONProtocol.cs @@ -435,11 +435,11 @@ private async ValueTask ReadJsonStringAsync(bool skipContext, Cancellati // escaped? if (ch != TJSONProtocolConstants.EscSequences[0]) { -#if NETSTANDARD2_0 - await buffer.WriteAsync(new[] {ch}, 0, 1, cancellationToken); -#else +#if NET5_0_OR_GREATER var wbuf = new[] { ch }; await buffer.WriteAsync(wbuf.AsMemory(0, 1), cancellationToken); +#else + await buffer.WriteAsync(new[] { ch }, 0, 1, cancellationToken); #endif continue; } @@ -454,11 +454,11 @@ private async ValueTask ReadJsonStringAsync(bool skipContext, Cancellati throw new TProtocolException(TProtocolException.INVALID_DATA, "Expected control char"); } ch = TJSONProtocolConstants.EscapeCharValues[off]; -#if NETSTANDARD2_0 - await buffer.WriteAsync(new[] {ch}, 0, 1, cancellationToken); -#else +#if NET5_0_OR_GREATER var wbuf = new[] { ch }; await buffer.WriteAsync( wbuf.AsMemory(0, 1), cancellationToken); +#else + await buffer.WriteAsync(new[] { ch }, 0, 1, cancellationToken); #endif continue; } @@ -488,20 +488,20 @@ private async ValueTask ReadJsonStringAsync(bool skipContext, Cancellati codeunits.Add((char) wch); var tmp = Utf8Encoding.GetBytes(codeunits.ToArray()); -#if NETSTANDARD2_0 - await buffer.WriteAsync(tmp, 0, tmp.Length, cancellationToken); -#else +#if NET5_0_OR_GREATER await buffer.WriteAsync(tmp.AsMemory(0, tmp.Length), cancellationToken); +#else + await buffer.WriteAsync(tmp, 0, tmp.Length, cancellationToken); #endif codeunits.Clear(); } else { var tmp = Utf8Encoding.GetBytes(new[] { (char)wch }); -#if NETSTANDARD2_0 - await buffer.WriteAsync(tmp, 0, tmp.Length, cancellationToken); -#else +#if NET5_0_OR_GREATER await buffer.WriteAsync(tmp.AsMemory( 0, tmp.Length), cancellationToken); +#else + await buffer.WriteAsync(tmp, 0, tmp.Length, cancellationToken); #endif } } diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index d2f9c17fccb..2ebfb06df38 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -56,12 +56,12 @@ - + - + @@ -69,6 +69,10 @@ + + + + @@ -76,6 +80,12 @@ + + + + 7.0.9 + + diff --git a/lib/netstd/Thrift/Transport/Client/THttpTransport.cs b/lib/netstd/Thrift/Transport/Client/THttpTransport.cs index 60ed59c6753..1ab1caf729c 100644 --- a/lib/netstd/Thrift/Transport/Client/THttpTransport.cs +++ b/lib/netstd/Thrift/Transport/Client/THttpTransport.cs @@ -150,10 +150,10 @@ public override async ValueTask ReadAsync(byte[] buffer, int offset, int le try { -#if NETSTANDARD2_0 - var ret = await _inputStream.ReadAsync(buffer, offset, length, cancellationToken); -#else +#if NET5_0_OR_GREATER var ret = await _inputStream.ReadAsync(new Memory(buffer, offset, length), cancellationToken); +#else + var ret = await _inputStream.ReadAsync(buffer, offset, length, cancellationToken); #endif if (ret == -1) { @@ -173,10 +173,10 @@ public override async Task WriteAsync(byte[] buffer, int offset, int length, Can { cancellationToken.ThrowIfCancellationRequested(); -#if NETSTANDARD2_0 - await _outputStream.WriteAsync(buffer, offset, length, cancellationToken); -#else +#if NET5_0_OR_GREATER await _outputStream.WriteAsync(buffer.AsMemory(offset, length), cancellationToken); +#else + await _outputStream.WriteAsync(buffer, offset, length, cancellationToken); #endif } @@ -245,10 +245,10 @@ public override async Task FlushAsync(CancellationToken cancellationToken) var response = (await _httpClient.PostAsync(_uri, contentStream, cancellationToken)).EnsureSuccessStatusCode(); _inputStream?.Dispose(); -#if NETSTANDARD2_0 || NETSTANDARD2_1 - _inputStream = await response.Content.ReadAsStreamAsync(); -#else +#if NET5_0_OR_GREATER _inputStream = await response.Content.ReadAsStreamAsync(cancellationToken); +#else + _inputStream = await response.Content.ReadAsStreamAsync(); #endif if (_inputStream.CanSeek) { diff --git a/lib/netstd/Thrift/Transport/Client/TNamedPipeTransport.cs b/lib/netstd/Thrift/Transport/Client/TNamedPipeTransport.cs index 071c6601791..8e60f9f5e60 100644 --- a/lib/netstd/Thrift/Transport/Client/TNamedPipeTransport.cs +++ b/lib/netstd/Thrift/Transport/Client/TNamedPipeTransport.cs @@ -76,10 +76,10 @@ public override async ValueTask ReadAsync(byte[] buffer, int offset, int le } CheckReadBytesAvailable(length); -#if NETSTANDARD2_0 - var numRead = await PipeStream.ReadAsync(buffer, offset, length, cancellationToken); -#else +#if NET5_0_OR_GREATER var numRead = await PipeStream.ReadAsync(new Memory(buffer, offset, length), cancellationToken); +#else + var numRead = await PipeStream.ReadAsync(buffer, offset, length, cancellationToken); #endif CountConsumedMessageBytes(numRead); return numRead; @@ -98,10 +98,10 @@ public override async Task WriteAsync(byte[] buffer, int offset, int length, Can var nBytes = Math.Min(15 * 4096, length); // 16 would exceed the limit while (nBytes > 0) { -#if NETSTANDARD2_0 - await PipeStream.WriteAsync(buffer, offset, nBytes, cancellationToken); -#else +#if NET5_0_OR_GREATER await PipeStream.WriteAsync(buffer.AsMemory(offset, nBytes), cancellationToken); +#else + await PipeStream.WriteAsync(buffer, offset, nBytes, cancellationToken); #endif offset += nBytes; length -= nBytes; diff --git a/lib/netstd/Thrift/Transport/Client/TStreamTransport.cs b/lib/netstd/Thrift/Transport/Client/TStreamTransport.cs index 55b636df2a4..7237b8dd27d 100644 --- a/lib/netstd/Thrift/Transport/Client/TStreamTransport.cs +++ b/lib/netstd/Thrift/Transport/Client/TStreamTransport.cs @@ -81,10 +81,10 @@ public override async ValueTask ReadAsync(byte[] buffer, int offset, int le "Cannot read from null inputstream"); } -#if NETSTANDARD2_0 - return await InputStream.ReadAsync(buffer, offset, length, cancellationToken); -#else +#if NET5_0_OR_GREATER return await InputStream.ReadAsync(new Memory(buffer, offset, length), cancellationToken); +#else + return await InputStream.ReadAsync(buffer, offset, length, cancellationToken); #endif } @@ -96,10 +96,10 @@ public override async Task WriteAsync(byte[] buffer, int offset, int length, Can "Cannot write to null outputstream"); } -#if NETSTANDARD2_0 - await OutputStream.WriteAsync(buffer, offset, length, cancellationToken); -#else +#if NET5_0_OR_GREATER await OutputStream.WriteAsync(buffer.AsMemory(offset, length), cancellationToken); +#else + await OutputStream.WriteAsync(buffer, offset, length, cancellationToken); #endif } diff --git a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs index 66018b085cf..b1ed91ef16d 100644 --- a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs +++ b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs @@ -382,10 +382,10 @@ public override async ValueTask ReadAsync(byte[] buffer, int offset, int le } CheckReadBytesAvailable(length); -#if NETSTANDARD2_0 - var numBytes = await PipeStream.ReadAsync(buffer, offset, length, cancellationToken); -#else +#if NET5_0_OR_GREATER var numBytes = await PipeStream.ReadAsync(buffer.AsMemory(offset, length), cancellationToken); +#else + var numBytes = await PipeStream.ReadAsync(buffer, offset, length, cancellationToken); #endif CountConsumedMessageBytes(numBytes); return numBytes; diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index 4482f35a031..1ae67fa4053 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -37,7 +37,7 @@ - + diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index 905edc2cec9..020b8d54542 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -36,10 +36,9 @@ - - + diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index de5f113e7af..ff7891e5b3b 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -34,7 +34,7 @@ - + diff --git a/tutorial/netstd/Server/Server.csproj b/tutorial/netstd/Server/Server.csproj index 478fa8c4eff..9aa3bc6b7c7 100644 --- a/tutorial/netstd/Server/Server.csproj +++ b/tutorial/netstd/Server/Server.csproj @@ -36,10 +36,9 @@ - - - - - + + + 7.0.9 + From 45764096573890ef4c84bebf7499d51891746034 Mon Sep 17 00:00:00 2001 From: Sergei Elin Date: Fri, 23 Sep 2022 23:21:31 +0300 Subject: [PATCH 097/250] THRIFT-5635 Update erlang client for Erlang 23-25 Client: erl Patch: Sergey Yelin This closes #2677 Summary of changes: - Add useful compiler options - Format sources using erlfmt - Switch to modern callbacks in thrift_* modules - Add static analysis (dialyzer), disabled by default - Add/fix types for API calls NOTE: Enabling static analysis requires additional tweaks in multiplexer module. --- .gitignore | 1 - build/docker/README.md | 2 +- build/docker/old/ubuntu-xenial/Dockerfile | 2 +- lib/erl/include/thrift_constants.hrl | 16 +- lib/erl/include/thrift_protocol.hrl | 75 +- lib/erl/include/thrift_protocol_behaviour.hrl | 37 - .../include/thrift_transport_behaviour.hrl | 31 - lib/erl/rebar.config | 51 +- lib/erl/src/thrift.app.src | 67 +- lib/erl/src/thrift_base64_transport.erl | 17 +- lib/erl/src/thrift_binary_protocol.erl | 253 ++- lib/erl/src/thrift_buffered_transport.erl | 82 +- lib/erl/src/thrift_client.erl | 178 ++- lib/erl/src/thrift_client_util.erl | 126 +- lib/erl/src/thrift_compact_protocol.erl | 509 +++--- lib/erl/src/thrift_disk_log_transport.erl | 49 +- lib/erl/src/thrift_file_transport.erl | 114 +- lib/erl/src/thrift_framed_transport.erl | 161 +- lib/erl/src/thrift_http_transport.erl | 75 +- lib/erl/src/thrift_json_parser.erl | 133 +- lib/erl/src/thrift_json_protocol.erl | 501 +++--- lib/erl/src/thrift_membuffer_transport.erl | 85 +- lib/erl/src/thrift_memory_buffer.erl | 2 - .../src/thrift_multiplexed_map_wrapper.erl | 30 +- lib/erl/src/thrift_multiplexed_protocol.erl | 109 +- lib/erl/src/thrift_processor.erl | 188 ++- lib/erl/src/thrift_protocol.erl | 442 +++--- lib/erl/src/thrift_reconnecting_client.erl | 362 +++-- lib/erl/src/thrift_server.erl | 98 +- lib/erl/src/thrift_service.erl | 8 +- lib/erl/src/thrift_socket_server.erl | 452 +++--- lib/erl/src/thrift_socket_transport.erl | 246 ++- lib/erl/src/thrift_sslsocket_transport.erl | 149 +- lib/erl/src/thrift_transport.erl | 137 +- lib/erl/src/thrift_transport_state_test.erl | 36 +- lib/erl/test/legacy_names_test.erl | 84 +- lib/erl/test/multiplexing_test.erl | 64 +- lib/erl/test/name_conflict_test.erl | 589 +++---- lib/erl/test/stress_server.erl | 31 +- lib/erl/test/test_const.erl | 37 +- lib/erl/test/test_disklog.erl | 146 +- lib/erl/test/test_omit.erl | 136 +- .../test/test_rendered_double_constants.erl | 126 +- lib/erl/test/test_thrift_1151.erl | 63 +- lib/erl/test/test_thrift_3214.erl | 58 +- .../test/test_thrift_buffered_transport.erl | 583 ++++--- lib/erl/test/test_thrift_compact_protocol.erl | 331 ++-- lib/erl/test/test_thrift_file_transport.erl | 345 +++-- lib/erl/test/test_thrift_framed_transport.erl | 635 ++++---- .../test/test_thrift_membuffer_transport.erl | 262 ++-- lib/erl/test/test_thrift_socket_transport.erl | 328 ++-- lib/erl/test/thrift_socket_server_test.erl | 150 +- lib/erl/test/thrift_test_test.erl | 1363 +++++++++-------- 53 files changed, 5399 insertions(+), 4756 deletions(-) delete mode 100644 lib/erl/include/thrift_protocol_behaviour.hrl delete mode 100644 lib/erl/include/thrift_transport_behaviour.hrl diff --git a/.gitignore b/.gitignore index 232ed2c654a..cb8029c9888 100644 --- a/.gitignore +++ b/.gitignore @@ -210,7 +210,6 @@ project.lock.json /lib/delphi/**/*.dcu /lib/delphi/**/*.2007 /lib/delphi/**/codegen/*.bat -/lib/erl/_build/ /lib/erl/.eunit /lib/erl/.generated /lib/erl/.rebar/ diff --git a/build/docker/README.md b/build/docker/README.md index 9635e6f0438..abf082307b2 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -177,7 +177,7 @@ Last updated: October 1, 2017 | d | 2.087.0 | 2.087.0 | | | dart | 2.0.0 | 2.4.0 | | | delphi | | | Not in CI | -| erlang | OTP-18 | OTP-23 | | +| erlang | OTP-20 | OTP-25 | | | go | 1.15.10 | 1.16.2 | | | haxe | 3.2.1 | 3.4.4 | THRIFT-4352: avoid 3.4.2 | | java | 1.8.0\_191 | 17 | | diff --git a/build/docker/old/ubuntu-xenial/Dockerfile b/build/docker/old/ubuntu-xenial/Dockerfile index 64d4804f776..d954e7fd961 100644 --- a/build/docker/old/ubuntu-xenial/Dockerfile +++ b/build/docker/old/ubuntu-xenial/Dockerfile @@ -121,7 +121,7 @@ RUN apt-get install -y --no-install-recommends \ dotnet-apphost-pack-7.0 # Erlang dependencies -ARG ERLANG_OTP_VERSION=18.3.4.11 +ARG ERLANG_OTP_VERSION=20.3.8.9 ARG ERLANG_REBAR_VERSION=3.13.2 RUN apt-get update && apt-get install -y --no-install-recommends automake libncurses5-dev && \ curl https://raw.githubusercontent.com/kerl/kerl/master/kerl -o /usr/local/bin/kerl && chmod +x /usr/local/bin/kerl && \ diff --git a/lib/erl/include/thrift_constants.hrl b/lib/erl/include/thrift_constants.hrl index 7cb29ebdb6e..4096854846c 100644 --- a/lib/erl/include/thrift_constants.hrl +++ b/lib/erl/include/thrift_constants.hrl @@ -41,10 +41,16 @@ % TApplicationException -define(TApplicationException_Structure, - {struct, [{1, string}, - {2, i32}]}). + {struct, [ + {1, string}, + {2, i32} + ]} +). --record('TApplicationException', {message, type}). +-record('TApplicationException', { + message :: string(), + type :: integer() +}). -define(TApplicationException_UNKNOWN, 0). -define(TApplicationException_UNKNOWN_METHOD, 1). @@ -58,5 +64,5 @@ -define(TApplicationException_INVALID_PROTOCOL, 9). -define(TApplicationException_UNSUPPORTED_CLIENT_TYPE, 10). --define (MULTIPLEXED_SERVICE_SEPARATOR, ":"). --define (MULTIPLEXED_ERROR_HANDLER_KEY, "error_handler"). +-define(MULTIPLEXED_SERVICE_SEPARATOR, ":"). +-define(MULTIPLEXED_ERROR_HANDLER_KEY, "error_handler"). diff --git a/lib/erl/include/thrift_protocol.hrl b/lib/erl/include/thrift_protocol.hrl index bc0acc88356..f4774237489 100644 --- a/lib/erl/include/thrift_protocol.hrl +++ b/lib/erl/include/thrift_protocol.hrl @@ -21,46 +21,47 @@ -define(THRIFT_PROTOCOL_INCLUDED, true). -record(protocol_message_begin, {name :: string(), type :: integer(), seqid :: integer()}). --record(protocol_struct_begin, {name :: string()}). --record(protocol_field_begin, {name :: string(), type :: integer(), id :: integer()}). +-record(protocol_struct_begin, {name :: undefined | string()}). +-record(protocol_field_begin, { + name :: undefined | string(), type :: integer(), id :: undefined | integer() +}). -record(protocol_map_begin, {ktype :: integer(), vtype :: integer(), size :: integer()}). -record(protocol_list_begin, {etype :: integer(), size :: integer()}). -record(protocol_set_begin, {etype :: integer(), size :: integer()}). --type tprot_header_val() :: #protocol_message_begin{} - | #protocol_struct_begin{} - | #protocol_field_begin{} - | #protocol_map_begin{} - | #protocol_list_begin{} - | #protocol_set_begin{} - . --type tprot_empty_tag() :: message_end - | struct_begin - | struct_end - | field_end - | map_end - | list_end - | set_end - . --type tprot_header_tag() :: message_begin - | field_begin - | map_begin - | list_begin - | set_begin - . --type tprot_data_tag() :: ui32 - | bool - | byte - | i16 - | i32 - | i64 - | double - | string - . --type tprot_cont_tag() :: {list, _Type} - | {map, _KType, _VType} - | {set, _Type} - . - +-type tprot_header_val() :: + #protocol_message_begin{} + | #protocol_struct_begin{} + | #protocol_field_begin{} + | #protocol_map_begin{} + | #protocol_list_begin{} + | #protocol_set_begin{}. +-type tprot_empty_tag() :: + message_end + | struct_begin + | struct_end + | field_end + | map_end + | list_end + | set_end. +-type tprot_header_tag() :: + message_begin + | field_begin + | map_begin + | list_begin + | set_begin. +-type tprot_data_tag() :: + ui32 + | bool + | byte + | i16 + | i32 + | i64 + | double + | string. +-type tprot_cont_tag() :: + {list, _Type} + | {map, _KType, _VType} + | {set, _Type}. -endif. diff --git a/lib/erl/include/thrift_protocol_behaviour.hrl b/lib/erl/include/thrift_protocol_behaviour.hrl deleted file mode 100644 index abe300b1bbc..00000000000 --- a/lib/erl/include/thrift_protocol_behaviour.hrl +++ /dev/null @@ -1,37 +0,0 @@ -%% -%% Licensed to the Apache Software Foundation (ASF) under one -%% or more contributor license agreements. See the NOTICE file -%% distributed with this work for additional information -%% regarding copyright ownership. The ASF licenses this file -%% to you under the Apache License, Version 2.0 (the -%% "License"); you may not use this file except in compliance -%% with the License. You may obtain a copy of the License at -%% -%% http://www.apache.org/licenses/LICENSE-2.0 -%% -%% Unless required by applicable law or agreed to in writing, -%% software distributed under the License is distributed on an -%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -%% KIND, either express or implied. See the License for the -%% specific language governing permissions and limitations -%% under the License. -%% - -%% Signature specifications for protocol implementations. - --ifndef(THRIFT_PROTOCOL_BEHAVIOUR_INCLUDED). --define(THRIFT_PROTOCOL_BEHAVIOUR_INCLUDED, true). - --spec flush_transport(state()) -> {state(), ok | {error, _Reason}}. --spec close_transport(state()) -> {state(), ok | {error, _Reason}}. - --spec write(state(), any()) -> {state(), ok | {error, _Reason}}. - -%% NOTE: Keep this in sync with thrift_protocol:read and read_specific. --spec read - (state(), tprot_empty_tag()) -> {state(), ok | {error, _Reason}}; - (state(), tprot_header_tag()) -> {state(), tprot_header_val() | {error, _Reason}}; - (state(), tprot_data_tag()) -> {state(), {ok, any()} | {error, _Reason}}. - - --endif. diff --git a/lib/erl/include/thrift_transport_behaviour.hrl b/lib/erl/include/thrift_transport_behaviour.hrl deleted file mode 100644 index dbc05aacfac..00000000000 --- a/lib/erl/include/thrift_transport_behaviour.hrl +++ /dev/null @@ -1,31 +0,0 @@ -%% -%% Licensed to the Apache Software Foundation (ASF) under one -%% or more contributor license agreements. See the NOTICE file -%% distributed with this work for additional information -%% regarding copyright ownership. The ASF licenses this file -%% to you under the Apache License, Version 2.0 (the -%% "License"); you may not use this file except in compliance -%% with the License. You may obtain a copy of the License at -%% -%% http://www.apache.org/licenses/LICENSE-2.0 -%% -%% Unless required by applicable law or agreed to in writing, -%% software distributed under the License is distributed on an -%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -%% KIND, either express or implied. See the License for the -%% specific language governing permissions and limitations -%% under the License. -%% - -%% Signature specifications for transport implementations. - --ifndef(THRIFT_TRANSPORT_BEHAVIOUR_INCLUDED). --define(THRIFT_TRANSPORT_BEHAVIOUR_INCLUDED, true). - --spec write(state(), iolist() | binary()) -> {state(), ok | {error, _Reason}}. --spec read(state(), non_neg_integer()) -> {state(), {ok, binary()} | {error, _Reason}}. --spec flush(state()) -> {state(), ok | {error, _Reason}}. --spec close(state()) -> {state(), ok | {error, _Reason}}. - - --endif. diff --git a/lib/erl/rebar.config b/lib/erl/rebar.config index b5258a2c1c4..c3149b4c088 100644 --- a/lib/erl/rebar.config +++ b/lib/erl/rebar.config @@ -1,8 +1,55 @@ -{erl_opts, [debug_info]}. +%% Common project erlang options. +{erl_opts, [ + + % mandatory + debug_info, + warn_export_all, + warn_untyped_record, + warn_export_vars, + + % by default + warn_unused_record, + warn_bif_clash, + warn_obsolete_guard, + warn_unused_vars, + warn_shadow_vars, + warn_unused_import, + warn_unused_function, + warn_deprecated_function +]}. + +%% XRef checks +{xref_checks, [ + deprecated_functions_calls, + deprecated_functions +]}. + +%% Dialyzer static analyzing +{dialyzer, [ + {warnings, [ + % mandatory + unmatched_returns, + error_handling, + unknown + % hardcore mode + % overspecs, + % underspecs + ]}, + {plt_extra_apps, [ssl, inets, public_key]} +]}. + +{plugins, [ + {erlfmt, "1.1.0"} +]}. + +{erlfmt, [ + {print_width, 100}, + {files, "{src,include,test}/*.{hrl,erl,app.src}"} +]}. {profiles, [ {test, [ - {deps, [meck]}, + {deps, [{meck, "0.9.2"}]}, {eunit_tests, [ {dir, "test"}, {dir, "test/gen-erl"} diff --git a/lib/erl/src/thrift.app.src b/lib/erl/src/thrift.app.src index 32e172159e2..0e25b675592 100644 --- a/lib/erl/src/thrift.app.src +++ b/lib/erl/src/thrift.app.src @@ -18,57 +18,34 @@ %% %%% -*- mode:erlang -*- {application, thrift, [ - % A quick description of the application. - {description, "Thrift bindings"}, + % A quick description of the application. + {description, "Thrift bindings"}, % The version of the applicaton {vsn, "0.20.0"}, - % All modules used by the application. - {modules, [ - thrift_base64_transport, - thrift_binary_protocol, - thrift_buffered_transport, - thrift_client_util, - thrift_client, - thrift_disk_log_transport, - thrift_file_transport, - thrift_framed_transport, - thrift_http_transport, - thrift_json_parser, - thrift_json_protocol, - thrift_membuffer_transport, - thrift_memory_buffer, - thrift_processor, - thrift_protocol, - thrift_reconnecting_client, - thrift_server, - thrift_service, - thrift_socket_server, - thrift_socket_transport, - thrift_transport_state_test, - thrift_transport - ]}, + % All modules used by the application. + {modules, []}, - % All of the registered names the application uses. This can be ignored. - {registered, []}, + % All of the registered names the application uses. This can be ignored. + {registered, []}, - % Applications that are to be started prior to this one. This can be ignored - % leave it alone unless you understand it well and let the .rel files in - % your release handle this. - {applications, [kernel, stdlib]}, + % Applications that are to be started prior to this one. This can be ignored + % leave it alone unless you understand it well and let the .rel files in + % your release handle this. + {applications, [kernel, stdlib]}, - % OTP application loader will load, but not start, included apps. Again - % this can be ignored as well. To load but not start an application it - % is easier to include it in the .rel file followed by the atom 'none' - {included_applications, []}, + % OTP application loader will load, but not start, included apps. Again + % this can be ignored as well. To load but not start an application it + % is easier to include it in the .rel file followed by the atom 'none' + {included_applications, []}, - % configuration parameters similar to those in the config file specified - % on the command line. can be fetched with gas:get_env - {env, [ - % If an error/crash occurs during processing of a function, - % should the TApplicationException serialized back to the client - % include the erlang backtrace? - {exceptions_include_traces, true} - ]} + % configuration parameters similar to those in the config file specified + % on the command line. can be fetched with gas:get_env + {env, [ + % If an error/crash occurs during processing of a function, + % should the TApplicationException serialized back to the client + % include the erlang backtrace? + {exceptions_include_traces, true} + ]} ]}. diff --git a/lib/erl/src/thrift_base64_transport.erl b/lib/erl/src/thrift_base64_transport.erl index d31f2bacf71..9aa629f50a5 100644 --- a/lib/erl/src/thrift_base64_transport.erl +++ b/lib/erl/src/thrift_base64_transport.erl @@ -28,42 +28,37 @@ -export([write/2, read/2, flush/1, close/1]). %% State --record(b64_transport, {wrapped}). --type state() :: #b64_transport{}. --include("thrift_transport_behaviour.hrl"). +-record(b64_transport, { + wrapped :: thrift_transport:t_transport() +}). new(Wrapped) -> State = #b64_transport{wrapped = Wrapped}, thrift_transport:new(?MODULE, State). - write(This = #b64_transport{wrapped = Wrapped}, Data) -> {NewWrapped, Result} = thrift_transport:write(Wrapped, base64:encode(iolist_to_binary(Data))), {This#b64_transport{wrapped = NewWrapped}, Result}. - %% base64 doesn't support reading quite yet since it would involve %% nasty buffering and such read(This = #b64_transport{}, _Data) -> {This, {error, no_reads_allowed}}. - flush(This = #b64_transport{wrapped = Wrapped0}) -> {Wrapped1, ok} = thrift_transport:write(Wrapped0, <<"\n">>), {Wrapped2, ok} = thrift_transport:flush(Wrapped1), {This#b64_transport{wrapped = Wrapped2}, ok}. - close(This0) -> {This1 = #b64_transport{wrapped = Wrapped}, ok} = flush(This0), {NewWrapped, ok} = thrift_transport:close(Wrapped), {This1#b64_transport{wrapped = NewWrapped}, ok}. - %%%% FACTORY GENERATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% new_transport_factory(WrapFactory) -> F = fun() -> - {ok, Wrapped} = WrapFactory(), - new(Wrapped) - end, + {ok, Wrapped} = WrapFactory(), + new(Wrapped) + end, {ok, F}. diff --git a/lib/erl/src/thrift_binary_protocol.erl b/lib/erl/src/thrift_binary_protocol.erl index 85abb62d235..d2c89d34076 100644 --- a/lib/erl/src/thrift_binary_protocol.erl +++ b/lib/erl/src/thrift_binary_protocol.erl @@ -24,21 +24,21 @@ -include("thrift_constants.hrl"). -include("thrift_protocol.hrl"). --export([new/1, new/2, - read/2, - write/2, - flush_transport/1, - close_transport/1, - - new_protocol_factory/2 - ]). - --record(binary_protocol, {transport, - strict_read=true, - strict_write=true - }). --type state() :: #binary_protocol{}. --include("thrift_protocol_behaviour.hrl"). +-export([ + new/1, new/2, + read/2, + write/2, + flush_transport/1, + close_transport/1, + + new_protocol_factory/2 +]). + +-record(binary_protocol, { + transport :: term(), + strict_read = true :: boolean(), + strict_write = true :: boolean() +}). -define(VERSION_MASK, 16#FFFF0000). -define(VERSION_1, 16#80010000). @@ -48,17 +48,16 @@ new(Transport) -> new(Transport, _Options = []). new(Transport, Options) -> - State = #binary_protocol{transport = Transport}, + State = #binary_protocol{transport = Transport}, State1 = parse_options(Options, State), thrift_protocol:new(?MODULE, State1). parse_options([], State) -> State; parse_options([{strict_read, Bool} | Rest], State) when is_boolean(Bool) -> - parse_options(Rest, State#binary_protocol{strict_read=Bool}); + parse_options(Rest, State#binary_protocol{strict_read = Bool}); parse_options([{strict_write, Bool} | Rest], State) when is_boolean(Bool) -> - parse_options(Rest, State#binary_protocol{strict_write=Bool}). - + parse_options(Rest, State#binary_protocol{strict_write = Bool}). flush_transport(This = #binary_protocol{transport = Transport}) -> {NewTransport, Result} = thrift_transport:flush(Transport), @@ -73,9 +72,10 @@ close_transport(This = #binary_protocol{transport = Transport}) -> %%% write(This0, #protocol_message_begin{ - name = Name, - type = Type, - seqid = Seqid}) -> + name = Name, + type = Type, + seqid = Seqid +}) -> case This0#binary_protocol.strict_write of true -> {This1, ok} = write(This0, {i32, ?VERSION_1 bor Type}), @@ -88,82 +88,75 @@ write(This0, #protocol_message_begin{ {This3, ok} = write(This2, {i32, Seqid}), {This3, ok} end; - -write(This, message_end) -> {This, ok}; - +write(This, message_end) -> + {This, ok}; write(This0, #protocol_field_begin{ - name = _Name, - type = Type, - id = Id}) -> + name = _Name, + type = Type, + id = Id +}) -> {This1, ok} = write(This0, {byte, Type}), {This2, ok} = write(This1, {i16, Id}), {This2, ok}; - write(This, field_stop) -> write(This, {byte, ?tType_STOP}); - -write(This, field_end) -> {This, ok}; - +write(This, field_end) -> + {This, ok}; write(This0, #protocol_map_begin{ - ktype = Ktype, - vtype = Vtype, - size = Size}) -> + ktype = Ktype, + vtype = Vtype, + size = Size +}) -> {This1, ok} = write(This0, {byte, Ktype}), {This2, ok} = write(This1, {byte, Vtype}), {This3, ok} = write(This2, {i32, Size}), {This3, ok}; - -write(This, map_end) -> {This, ok}; - +write(This, map_end) -> + {This, ok}; write(This0, #protocol_list_begin{ - etype = Etype, - size = Size}) -> + etype = Etype, + size = Size +}) -> {This1, ok} = write(This0, {byte, Etype}), {This2, ok} = write(This1, {i32, Size}), {This2, ok}; - -write(This, list_end) -> {This, ok}; - +write(This, list_end) -> + {This, ok}; write(This0, #protocol_set_begin{ - etype = Etype, - size = Size}) -> + etype = Etype, + size = Size +}) -> {This1, ok} = write(This0, {byte, Etype}), {This2, ok} = write(This1, {i32, Size}), {This2, ok}; - -write(This, set_end) -> {This, ok}; - -write(This, #protocol_struct_begin{}) -> {This, ok}; -write(This, struct_end) -> {This, ok}; - -write(This, {bool, true}) -> write(This, {byte, 1}); -write(This, {bool, false}) -> write(This, {byte, 0}); - +write(This, set_end) -> + {This, ok}; +write(This, #protocol_struct_begin{}) -> + {This, ok}; +write(This, struct_end) -> + {This, ok}; +write(This, {bool, true}) -> + write(This, {byte, 1}); +write(This, {bool, false}) -> + write(This, {byte, 0}); write(This, {byte, Byte}) -> write(This, <>); - write(This, {i16, I16}) -> write(This, <>); - write(This, {i32, I32}) -> write(This, <>); - write(This, {i64, I64}) -> write(This, <>); - write(This, {double, Double}) -> write(This, <>); - write(This0, {string, Str}) when is_list(Str) -> {This1, ok} = write(This0, {i32, length(Str)}), {This2, ok} = write(This1, list_to_binary(Str)), {This2, ok}; - write(This0, {string, Bin}) when is_binary(Bin) -> {This1, ok} = write(This0, {i32, size(Bin)}), {This2, ok} = write(This1, Bin), {This2, ok}; - %% Data :: iolist() write(This = #binary_protocol{transport = Trans}, Data) -> {NewTransport, Result} = thrift_transport:write(Trans, Data), @@ -176,39 +169,39 @@ read(This0, message_begin) -> case Initial of {ok, Sz} when Sz band ?VERSION_MASK =:= ?VERSION_1 -> %% we're at version 1 - {This2, {ok, Name}} = read(This1, string), + {This2, {ok, Name}} = read(This1, string), {This3, {ok, SeqId}} = read(This2, i32), - Type = Sz band ?TYPE_MASK, - {This3, #protocol_message_begin{name = binary_to_list(Name), - type = Type, - seqid = SeqId}}; - + Type = Sz band ?TYPE_MASK, + {This3, #protocol_message_begin{ + name = binary_to_list(Name), + type = Type, + seqid = SeqId + }}; {ok, Sz} when Sz < 0 -> %% there's a version number but it's unexpected {This1, {error, {bad_binary_protocol_version, Sz}}}; - {ok, _Sz} when This1#binary_protocol.strict_read =:= true -> %% strict_read is true and there's no version header; that's an error {This1, {error, no_binary_protocol_version}}; - {ok, Sz} when This1#binary_protocol.strict_read =:= false -> %% strict_read is false, so just read the old way - {This2, {ok, Name}} = read_data(This1, Sz), - {This3, {ok, Type}} = read(This2, byte), + {This2, {ok, Name}} = read_data(This1, Sz), + {This3, {ok, Type}} = read(This2, byte), {This4, {ok, SeqId}} = read(This3, i32), - {This4, #protocol_message_begin{name = binary_to_list(Name), - type = Type, - seqid = SeqId}}; - + {This4, #protocol_message_begin{ + name = binary_to_list(Name), + type = Type, + seqid = SeqId + }}; Else -> {This1, Else} end; - -read(This, message_end) -> {This, ok}; - -read(This, struct_begin) -> {This, ok}; -read(This, struct_end) -> {This, ok}; - +read(This, message_end) -> + {This, ok}; +read(This, struct_begin) -> + {This, ok}; +read(This, struct_end) -> + {This, ok}; read(This0, field_begin) -> {This1, Result} = read(This0, byte), case Result of @@ -216,39 +209,45 @@ read(This0, field_begin) -> {This1, #protocol_field_begin{type = Type}}; {ok, Type} -> {This2, {ok, Id}} = read(This1, i16), - {This2, #protocol_field_begin{type = Type, - id = Id}} + {This2, #protocol_field_begin{ + type = Type, + id = Id + }} end; - -read(This, field_end) -> {This, ok}; - +read(This, field_end) -> + {This, ok}; read(This0, map_begin) -> {This1, {ok, Ktype}} = read(This0, byte), {This2, {ok, Vtype}} = read(This1, byte), - {This3, {ok, Size}} = read(This2, i32), - {This3, #protocol_map_begin{ktype = Ktype, - vtype = Vtype, - size = Size}}; -read(This, map_end) -> {This, ok}; - + {This3, {ok, Size}} = read(This2, i32), + {This3, #protocol_map_begin{ + ktype = Ktype, + vtype = Vtype, + size = Size + }}; +read(This, map_end) -> + {This, ok}; read(This0, list_begin) -> {This1, {ok, Etype}} = read(This0, byte), - {This2, {ok, Size}} = read(This1, i32), - {This2, #protocol_list_begin{etype = Etype, - size = Size}}; -read(This, list_end) -> {This, ok}; - + {This2, {ok, Size}} = read(This1, i32), + {This2, #protocol_list_begin{ + etype = Etype, + size = Size + }}; +read(This, list_end) -> + {This, ok}; read(This0, set_begin) -> {This1, {ok, Etype}} = read(This0, byte), - {This2, {ok, Size}} = read(This1, i32), - {This2, #protocol_set_begin{etype = Etype, - size = Size}}; -read(This, set_end) -> {This, ok}; - + {This2, {ok, Size}} = read(This1, i32), + {This2, #protocol_set_begin{ + etype = Etype, + size = Size + }}; +read(This, set_end) -> + {This, ok}; read(This0, field_stop) -> {This1, {ok, ?tType_STOP}} = read(This0, byte), {This1, ok}; - %% read(This0, bool) -> @@ -257,28 +256,24 @@ read(This0, bool) -> {ok, Byte} -> {This1, {ok, Byte /= 0}}; Else -> {This1, Else} end; - read(This0, byte) -> {This1, Bytes} = read_data(This0, 1), case Bytes of {ok, <>} -> {This1, {ok, Val}}; Else -> {This1, Else} end; - read(This0, i16) -> {This1, Bytes} = read_data(This0, 2), case Bytes of {ok, <>} -> {This1, {ok, Val}}; Else -> {This1, Else} end; - read(This0, i32) -> {This1, Bytes} = read_data(This0, 4), case Bytes of {ok, <>} -> {This1, {ok, Val}}; Else -> {This1, Else} end; - %% unsigned ints aren't used by thrift itself, but it's used for the parsing %% of the packet version header. Without this special function BEAM works fine %% but hipe thinks it received a bad version header. @@ -288,60 +283,60 @@ read(This0, ui32) -> {ok, <>} -> {This1, {ok, Val}}; Else -> {This1, Else} end; - read(This0, i64) -> {This1, Bytes} = read_data(This0, 8), case Bytes of {ok, <>} -> {This1, {ok, Val}}; Else -> {This1, Else} end; - read(This0, double) -> {This1, Bytes} = read_data(This0, 8), case Bytes of {ok, <>} -> {This1, {ok, Val}}; Else -> {This1, Else} end; - % returns a binary directly, call binary_to_list if necessary read(This0, string) -> - {This1, {ok, Sz}} = read(This0, i32), + {This1, {ok, Sz}} = read(This0, i32), read_data(This1, Sz). -spec read_data(#binary_protocol{}, non_neg_integer()) -> {#binary_protocol{}, {ok, binary()} | {error, _Reason}}. -read_data(This, 0) -> {This, {ok, <<>>}}; +read_data(This, 0) -> + {This, {ok, <<>>}}; read_data(This = #binary_protocol{transport = Trans}, Len) when is_integer(Len) andalso Len > 0 -> {NewTransport, Result} = thrift_transport:read(Trans, Len), {This#binary_protocol{transport = NewTransport}, Result}. - %%%% FACTORY GENERATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record(tbp_opts, {strict_read = true, - strict_write = true}). +-record(tbp_opts, { + strict_read = true :: boolean(), + strict_write = true :: boolean() +}). parse_factory_options([], Opts) -> Opts; parse_factory_options([{strict_read, Bool} | Rest], Opts) when is_boolean(Bool) -> - parse_factory_options(Rest, Opts#tbp_opts{strict_read=Bool}); + parse_factory_options(Rest, Opts#tbp_opts{strict_read = Bool}); parse_factory_options([{strict_write, Bool} | Rest], Opts) when is_boolean(Bool) -> - parse_factory_options(Rest, Opts#tbp_opts{strict_write=Bool}). - + parse_factory_options(Rest, Opts#tbp_opts{strict_write = Bool}). %% returns a (fun() -> thrift_protocol()) new_protocol_factory(TransportFactory, Options) -> ParsedOpts = parse_factory_options(Options, #tbp_opts{}), F = fun() -> - case TransportFactory() of - {ok, Transport} -> - thrift_binary_protocol:new( - Transport, - [{strict_read, ParsedOpts#tbp_opts.strict_read}, - {strict_write, ParsedOpts#tbp_opts.strict_write}]); - {error, Error} -> - {error, Error} - end - end, + case TransportFactory() of + {ok, Transport} -> + thrift_binary_protocol:new( + Transport, + [ + {strict_read, ParsedOpts#tbp_opts.strict_read}, + {strict_write, ParsedOpts#tbp_opts.strict_write} + ] + ); + {error, Error} -> + {error, Error} + end + end, {ok, F}. - diff --git a/lib/erl/src/thrift_buffered_transport.erl b/lib/erl/src/thrift_buffered_transport.erl index e9d3fffa7c5..423e89ac7cb 100644 --- a/lib/erl/src/thrift_buffered_transport.erl +++ b/lib/erl/src/thrift_buffered_transport.erl @@ -28,71 +28,59 @@ %% legacy api -export([new_transport_factory/1]). - -record(t_buffered, { - wrapped, - write_buffer + wrapped :: thrift_transport:t_transport(), + write_buffer :: iodata() }). --type state() :: #t_buffered{}. - - --spec new(Transport::thrift_transport:t_transport()) -> - thrift_transport:t_transport(). +-spec new(Transport :: thrift_transport:t_transport()) -> {ok, thrift_transport:t_transport()}. new(Wrapped) -> - State = #t_buffered{ - wrapped = Wrapped, - write_buffer = [] - }, - thrift_transport:new(?MODULE, State). - - --include("thrift_transport_behaviour.hrl"). - + State = #t_buffered{ + wrapped = Wrapped, + write_buffer = [] + }, + thrift_transport:new(?MODULE, State). %% reads data through from the wrapped transport -read(State = #t_buffered{wrapped = Wrapped}, Len) -when is_integer(Len), Len >= 0 -> - {NewState, Response} = thrift_transport:read(Wrapped, Len), - {State#t_buffered{wrapped = NewState}, Response}. - +read(State = #t_buffered{wrapped = Wrapped}, Len) when + is_integer(Len), Len >= 0 +-> + {NewState, Response} = thrift_transport:read(Wrapped, Len), + {State#t_buffered{wrapped = NewState}, Response}. %% reads data through from the wrapped transport -read_exact(State = #t_buffered{wrapped = Wrapped}, Len) -when is_integer(Len), Len >= 0 -> - {NewState, Response} = thrift_transport:read_exact(Wrapped, Len), - {State#t_buffered{wrapped = NewState}, Response}. - +read_exact(State = #t_buffered{wrapped = Wrapped}, Len) when + is_integer(Len), Len >= 0 +-> + {NewState, Response} = thrift_transport:read_exact(Wrapped, Len), + {State#t_buffered{wrapped = NewState}, Response}. write(State = #t_buffered{write_buffer = Buffer}, Data) -> - {State#t_buffered{write_buffer = [Buffer, Data]}, ok}. - + {State#t_buffered{write_buffer = [Buffer, Data]}, ok}. flush(State = #t_buffered{wrapped = Wrapped, write_buffer = Buffer}) -> - case iolist_size(Buffer) of - %% if write buffer is empty, do nothing - 0 -> {State, ok}; - _ -> - {Written, Response} = thrift_transport:write(Wrapped, Buffer), - {Flushed, ok} = thrift_transport:flush(Written), - {State#t_buffered{wrapped = Flushed, write_buffer = []}, Response} - end. - + case iolist_size(Buffer) of + %% if write buffer is empty, do nothing + 0 -> + {State, ok}; + _ -> + {Written, Response} = thrift_transport:write(Wrapped, Buffer), + {Flushed, ok} = thrift_transport:flush(Written), + {State#t_buffered{wrapped = Flushed, write_buffer = []}, Response} + end. close(State = #t_buffered{wrapped = Wrapped}) -> - {Closed, Result} = thrift_transport:close(Wrapped), - {State#t_buffered{wrapped = Closed}, Result}. - + {Closed, Result} = thrift_transport:close(Wrapped), + {State#t_buffered{wrapped = Closed}, Result}. %%-------------------------------------------------------------------- %%% Internal functions %%-------------------------------------------------------------------- %%%% FACTORY GENERATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% new_transport_factory(WrapFactory) -> - F = fun() -> - {ok, Wrapped} = WrapFactory(), - new(Wrapped) - end, - {ok, F}. - + F = fun() -> + {ok, Wrapped} = WrapFactory(), + new(Wrapped) + end, + {ok, F}. diff --git a/lib/erl/src/thrift_client.erl b/lib/erl/src/thrift_client.erl index 1a9cb50a493..1c274052e25 100644 --- a/lib/erl/src/thrift_client.erl +++ b/lib/erl/src/thrift_client.erl @@ -25,78 +25,91 @@ -include("thrift_constants.hrl"). -include("thrift_protocol.hrl"). --record(tclient, {service, protocol, seqid}). - - -new(Protocol, Service) - when is_atom(Service) -> - {ok, #tclient{protocol = Protocol, - service = Service, - seqid = 0}}. +-record(tclient, { + service :: module(), + protocol :: thrift_protocol:state(), + seqid :: non_neg_integer() +}). +-type tclient() :: #tclient{}. + +new(Protocol, Service) when + is_atom(Service) +-> + {ok, #tclient{ + protocol = Protocol, + service = Service, + seqid = 0 + }}. -spec call(#tclient{}, atom(), list()) -> {#tclient{}, {ok, any()} | {error, any()}}. -call(Client = #tclient{}, Function, Args) -when is_atom(Function), is_list(Args) -> - case send_function_call(Client, Function, Args) of - {ok, Client1} -> receive_function_result(Client1, Function); - {{error, X}, Client1} -> {Client1, {error, X}}; - Else -> Else - end. - +call(Client = #tclient{}, Function, Args) when + is_atom(Function), is_list(Args) +-> + case send_function_call(Client, Function, Args) of + {ok, Client1} -> receive_function_result(Client1, Function); + {{error, X}, Client1} -> {Client1, {error, X}} + end. %% Sends a function call but does not read the result. This is useful %% if you're trying to log non-oneway function calls to write-only %% transports like thrift_disk_log_transport. -spec send_call(#tclient{}, atom(), list()) -> {#tclient{}, ok}. -send_call(Client = #tclient{}, Function, Args) - when is_atom(Function), is_list(Args) -> +send_call(Client = #tclient{}, Function, Args) when + is_atom(Function), is_list(Args) +-> case send_function_call(Client, Function, Args) of - {ok, Client1} -> {Client1, ok}; - Else -> Else + {ok, Client1} -> {Client1, ok}; + Else -> Else end. -spec close(#tclient{}) -> ok. -close(#tclient{protocol=Protocol}) -> +close(#tclient{protocol = Protocol}) -> thrift_protocol:close_transport(Protocol). - %%-------------------------------------------------------------------- %%% Internal functions %%-------------------------------------------------------------------- -spec send_function_call(#tclient{}, atom(), list()) -> {ok | {error, any()}, #tclient{}}. send_function_call(Client = #tclient{service = Service}, Function, Args) -> - {Params, Reply} = try - {Service:function_info(Function, params_type), Service:function_info(Function, reply_type)} - catch error:function_clause -> {no_function, 0} - end, - MsgType = case Reply of - oneway_void -> ?tMessageType_ONEWAY; - _ -> ?tMessageType_CALL - end, - case Params of - no_function -> - {{error, {no_function, Function}}, Client}; - {struct, PList} when length(PList) =/= length(Args) -> - {{error, {bad_args, Function, Args}}, Client}; - {struct, _PList} -> write_message(Client, Function, Args, Params, MsgType) - end. + {Params, Reply} = + try + { + Service:function_info(Function, params_type), + Service:function_info(Function, reply_type) + } + catch + error:function_clause -> {no_function, 0} + end, + MsgType = + case Reply of + oneway_void -> ?tMessageType_ONEWAY; + _ -> ?tMessageType_CALL + end, + case Params of + no_function -> + {{error, {no_function, Function}}, Client}; + {struct, PList} when length(PList) =/= length(Args) -> + {{error, {bad_args, Function, Args}}, Client}; + {struct, _PList} -> + write_message(Client, Function, Args, Params, MsgType) + end. -spec write_message(#tclient{}, atom(), list(), {struct, list()}, integer()) -> - {ok | {error, any()}, #tclient{}}. + {ok | {error, any()}, #tclient{}}. write_message(Client = #tclient{protocol = P0, seqid = Seq}, Function, Args, Params, MsgType) -> - try - {P1, ok} = thrift_protocol:write(P0, #protocol_message_begin{ - name = atom_to_list(Function), - type = MsgType, - seqid = Seq - }), - {P2, ok} = thrift_protocol:write(P1, {Params, list_to_tuple([Function|Args])}), - {P3, ok} = thrift_protocol:write(P2, message_end), - {P4, ok} = thrift_protocol:flush_transport(P3), - {ok, Client#tclient{protocol = P4}} - catch - error:{badmatch, {_, {error, _} = Error}} -> {Error, Client} - end. + try + {P1, ok} = thrift_protocol:write(P0, #protocol_message_begin{ + name = atom_to_list(Function), + type = MsgType, + seqid = Seq + }), + {P2, ok} = thrift_protocol:write(P1, {Params, list_to_tuple([Function | Args])}), + {P3, ok} = thrift_protocol:write(P2, message_end), + {P4, ok} = thrift_protocol:flush_transport(P3), + {ok, Client#tclient{protocol = P4}} + catch + error:{badmatch, {_, {error, _} = Error}} -> {Error, Client} + end. -spec receive_function_result(#tclient{}, atom()) -> {#tclient{}, {ok, any()} | {error, any()}}. receive_function_result(Client = #tclient{service = Service}, Function) -> @@ -105,32 +118,38 @@ receive_function_result(Client = #tclient{service = Service}, Function) -> read_result(Client, _Function, oneway_void) -> {Client, {ok, ok}}; - -read_result(Client = #tclient{protocol = Proto0, - seqid = SeqId}, - Function, - ReplyType) -> +read_result( + Client = #tclient{ + protocol = Proto0, + seqid = SeqId + }, + Function, + ReplyType +) -> case thrift_protocol:read(Proto0, message_begin) of - {Proto1, {error, Reason}} -> - NewClient = Client#tclient{protocol = Proto1}, - {NewClient, {error, Reason}}; - {Proto1, MessageBegin} -> - NewClient = Client#tclient{protocol = Proto1}, - case MessageBegin of - #protocol_message_begin{seqid = RetSeqId} when RetSeqId =/= SeqId -> - {NewClient, {error, {bad_seq_id, SeqId}}}; - #protocol_message_begin{type = ?tMessageType_EXCEPTION} -> - handle_application_exception(NewClient); - #protocol_message_begin{type = ?tMessageType_REPLY} -> - handle_reply(NewClient, Function, ReplyType) - end + {Proto1, {error, Reason}} -> + NewClient = Client#tclient{protocol = Proto1}, + {NewClient, {error, Reason}}; + {Proto1, MessageBegin} -> + NewClient = Client#tclient{protocol = Proto1}, + case MessageBegin of + #protocol_message_begin{seqid = RetSeqId} when RetSeqId =/= SeqId -> + {NewClient, {error, {bad_seq_id, SeqId}}}; + #protocol_message_begin{type = ?tMessageType_EXCEPTION} -> + handle_application_exception(NewClient); + #protocol_message_begin{type = ?tMessageType_REPLY} -> + handle_reply(NewClient, Function, ReplyType) + end end. - -handle_reply(Client = #tclient{protocol = Proto0, - service = Service}, - Function, - ReplyType) -> +handle_reply( + Client = #tclient{ + protocol = Proto0, + service = Service + }, + Function, + ReplyType +) -> {struct, ExceptionFields} = Service:function_info(Function, exceptions), ReplyStructDef = {struct, [{0, ReplyType}] ++ ExceptionFields}, {Proto1, {ok, Reply}} = thrift_protocol:read(Proto0, ReplyStructDef), @@ -139,8 +158,11 @@ handle_reply(Client = #tclient{protocol = Proto0, ReplyList = tuple_to_list(Reply), true = length(ReplyList) == length(ExceptionFields) + 1, ExceptionVals = tl(ReplyList), - Thrown = [X || X <- ExceptionVals, - X =/= undefined], + Thrown = [ + X + || X <- ExceptionVals, + X =/= undefined + ], case Thrown of [] when ReplyType == {struct, []} -> {NewClient, {ok, ok}}; @@ -150,12 +172,14 @@ handle_reply(Client = #tclient{protocol = Proto0, throw({NewClient, {exception, Exception}}) end. +-spec handle_application_exception(tclient()) -> no_return(). handle_application_exception(Client = #tclient{protocol = Proto0}) -> {Proto1, {ok, Exception}} = thrift_protocol:read(Proto0, ?TApplicationException_Structure), {Proto2, ok} = thrift_protocol:read(Proto1, message_end), XRecord = list_to_tuple( - ['TApplicationException' | tuple_to_list(Exception)]), + ['TApplicationException' | tuple_to_list(Exception)] + ), error_logger:error_msg("X: ~p~n", [XRecord]), true = is_record(XRecord, 'TApplicationException'), NewClient = Client#tclient{protocol = Proto2}, diff --git a/lib/erl/src/thrift_client_util.erl b/lib/erl/src/thrift_client_util.erl index 1dbe51e9d4f..7c5f094beae 100644 --- a/lib/erl/src/thrift_client_util.erl +++ b/lib/erl/src/thrift_client_util.erl @@ -22,9 +22,11 @@ -export([new/4]). -export([new_multiplexed/3, new_multiplexed/4]). --type service_name() :: nonempty_string(). --type service_module() :: atom(). --type multiplexed_service_map() :: [{ServiceName::service_name(), ServiceModule::service_module()}]. +-type service_name() :: nonempty_string(). +-type service_module() :: atom(). +-type multiplexed_service_map() :: [ + {ServiceName :: service_name(), ServiceModule :: service_module()} +]. %% %% Splits client options into client, protocol, and transport options @@ -36,44 +38,47 @@ split_options(Options) -> split_options([], ProtoIn, TransIn) -> {ProtoIn, TransIn}; - -split_options([Opt = {OptKey, _} | Rest], ProtoIn, TransIn) - when OptKey =:= strict_read; - OptKey =:= strict_write; - OptKey =:= protocol -> +split_options([Opt = {OptKey, _} | Rest], ProtoIn, TransIn) when + OptKey =:= strict_read; + OptKey =:= strict_write; + OptKey =:= protocol +-> split_options(Rest, [Opt | ProtoIn], TransIn); - -split_options([Opt = {OptKey, _} | Rest], ProtoIn, TransIn) - when OptKey =:= framed; - OptKey =:= connect_timeout; - OptKey =:= recv_timeout; - OptKey =:= sockopts; - OptKey =:= ssltransport; - OptKey =:= ssloptions-> +split_options([Opt = {OptKey, _} | Rest], ProtoIn, TransIn) when + OptKey =:= framed; + OptKey =:= connect_timeout; + OptKey =:= recv_timeout; + OptKey =:= sockopts; + OptKey =:= ssltransport; + OptKey =:= ssloptions +-> split_options(Rest, ProtoIn, [Opt | TransIn]). - %% Client constructor for the common-case of socket transports -new(Host, Port, Service, Options) - when is_integer(Port), is_atom(Service), is_list(Options) -> +new(Host, Port, Service, Options) when + is_integer(Port), is_atom(Service), is_list(Options) +-> {ProtoOpts, TransOpts0} = split_options(Options), - {TransportModule, TransOpts2} = case lists:keytake(ssltransport, 1, TransOpts0) of - {value, {_, true}, TransOpts1} -> {thrift_sslsocket_transport, TransOpts1}; - false -> {thrift_socket_transport, TransOpts0} - end, - - {ProtocolModule, ProtoOpts1} = case lists:keytake(protocol, 1, ProtoOpts) of - {value, {_, compact}, Opts} -> {thrift_compact_protocol, Opts}; - {value, {_, json}, Opts} -> {thrift_json_protocol, Opts}; - {value, {_, binary}, Opts} -> {thrift_binary_protocol, Opts}; - false -> {thrift_binary_protocol, ProtoOpts} - end, + {TransportModule, TransOpts2} = + case lists:keytake(ssltransport, 1, TransOpts0) of + {value, {_, true}, TransOpts1} -> {thrift_sslsocket_transport, TransOpts1}; + false -> {thrift_socket_transport, TransOpts0} + end, + + {ProtocolModule, ProtoOpts1} = + case lists:keytake(protocol, 1, ProtoOpts) of + {value, {_, compact}, Opts} -> {thrift_compact_protocol, Opts}; + {value, {_, json}, Opts} -> {thrift_json_protocol, Opts}; + {value, {_, binary}, Opts} -> {thrift_binary_protocol, Opts}; + false -> {thrift_binary_protocol, ProtoOpts} + end, {ok, TransportFactory} = TransportModule:new_transport_factory(Host, Port, TransOpts2), {ok, ProtocolFactory} = ProtocolModule:new_protocol_factory( - TransportFactory, ProtoOpts1), + TransportFactory, ProtoOpts1 + ), case ProtocolFactory() of {ok, Protocol} -> @@ -83,30 +88,49 @@ new(Host, Port, Service, Options) end. -spec new_multiplexed(Host, Port, Services, Options) -> {ok, ServiceThriftClientList} when - Host :: nonempty_string(), - Port :: non_neg_integer(), - Services :: multiplexed_service_map(), - Options :: list(), - ServiceThriftClientList :: [{ServiceName::list(), ThriftClient::term()}]. -new_multiplexed(Host, Port, Services, Options) when is_integer(Port), - is_list(Services), - is_list(Options) -> - new_multiplexed(thrift_socket_transport:new_transport_factory(Host, Port, Options), Services, Options). - --spec new_multiplexed(TransportFactoryTuple, Services, Options) -> {ok, ServiceThriftClientList} when - TransportFactoryTuple :: {ok, TransportFactory::term()}, - Services :: multiplexed_service_map(), - Options :: list(), - ServiceThriftClientList :: [{ServiceName::service_name(), ThriftClient::term()}]. -new_multiplexed(TransportFactoryTuple, Services, Options) when is_list(Services), - is_list(Options), - is_tuple(TransportFactoryTuple) -> + Host :: nonempty_string(), + Port :: non_neg_integer(), + Services :: multiplexed_service_map(), + Options :: list(), + ServiceThriftClientList :: [{ServiceName :: list(), ThriftClient :: term()}]. +new_multiplexed(Host, Port, Services, Options) when + is_integer(Port), + is_list(Services), + is_list(Options) +-> + new_multiplexed( + thrift_socket_transport:new_transport_factory(Host, Port, Options), Services, Options + ). + +-spec new_multiplexed(TransportFactoryTuple, Services, Options) -> + {ok, ServiceThriftClientList} +when + TransportFactoryTuple :: {ok, TransportFactory :: term()}, + Services :: multiplexed_service_map(), + Options :: list(), + ServiceThriftClientList :: [{ServiceName :: service_name(), ThriftClient :: term()}]. +new_multiplexed(TransportFactoryTuple, Services, Options) when + is_list(Services), + is_list(Options), + is_tuple(TransportFactoryTuple) +-> {ProtoOpts, _} = split_options(Options), {ok, TransportFactory} = TransportFactoryTuple, - {ok, ProtocolFactory} = thrift_binary_protocol:new_protocol_factory(TransportFactory, ProtoOpts), + {ok, ProtocolFactory} = thrift_binary_protocol:new_protocol_factory( + TransportFactory, ProtoOpts + ), {ok, Protocol} = ProtocolFactory(), - {ok, [{ServiceName, element(2, thrift_client:new(element(2, thrift_multiplexed_protocol:new(Protocol, ServiceName)), Service))} || {ServiceName, Service} <- Services]}. + {ok, [ + {ServiceName, + element( + 2, + thrift_client:new( + element(2, thrift_multiplexed_protocol:new(Protocol, ServiceName)), Service + ) + )} + || {ServiceName, Service} <- Services + ]}. diff --git a/lib/erl/src/thrift_compact_protocol.erl b/lib/erl/src/thrift_compact_protocol.erl index 0f14221914e..f852fcb49ad 100644 --- a/lib/erl/src/thrift_compact_protocol.erl +++ b/lib/erl/src/thrift_compact_protocol.erl @@ -24,28 +24,32 @@ -include("thrift_constants.hrl"). -include("thrift_protocol.hrl"). --export([new/1, new/2, - read/2, - write/2, - flush_transport/1, - close_transport/1, - new_protocol_factory/2 - ]). +-export([ + new/1, new/2, + read/2, + write/2, + flush_transport/1, + close_transport/1, + new_protocol_factory/2 +]). -define(ID_NONE, 16#10000). -define(CBOOL_NONE, 0). -define(CBOOL_TRUE, 1). -define(CBOOL_FALSE, 2). --record(t_compact, {transport, - % state for pending boolean fields - read_stack=[], - read_value=?CBOOL_NONE, - write_stack=[], - write_id=?ID_NONE - }). --type state() :: #t_compact{}. --include("thrift_protocol_behaviour.hrl"). +-type cbool() :: ?CBOOL_NONE | ?CBOOL_TRUE | ?CBOOL_FALSE. + +-record(t_compact, { + transport :: term(), + % state for pending boolean fields + read_stack = [] :: iodata(), + read_value = ?CBOOL_NONE :: cbool(), + write_stack = [] :: iodata(), + write_id = ?ID_NONE :: non_neg_integer() +}). + +-type t_compact() :: #t_compact{}. -define(PROTOCOL_ID, 16#82). -define(VERSION_MASK, 16#1f). @@ -67,19 +71,19 @@ typeid_to_compact(?tType_MAP) -> 16#B; typeid_to_compact(?tType_SET) -> 16#A; typeid_to_compact(?tType_LIST) -> 16#9. -compact_to_typeid(16#0) -> ?tType_STOP; -compact_to_typeid(?CBOOL_FALSE) -> ?tType_BOOL; -compact_to_typeid(?CBOOL_TRUE) -> ?tType_BOOL; -compact_to_typeid(16#7) -> ?tType_DOUBLE; -compact_to_typeid(16#3) -> ?tType_I8; -compact_to_typeid(16#4) -> ?tType_I16; -compact_to_typeid(16#5) -> ?tType_I32; -compact_to_typeid(16#6) -> ?tType_I64; -compact_to_typeid(16#8) -> ?tType_STRING; -compact_to_typeid(16#C) -> ?tType_STRUCT; -compact_to_typeid(16#B) -> ?tType_MAP; -compact_to_typeid(16#A) -> ?tType_SET; -compact_to_typeid(16#9) -> ?tType_LIST. +compact_to_typeid(16#0) -> ?tType_STOP; +compact_to_typeid(?CBOOL_FALSE) -> ?tType_BOOL; +compact_to_typeid(?CBOOL_TRUE) -> ?tType_BOOL; +compact_to_typeid(16#7) -> ?tType_DOUBLE; +compact_to_typeid(16#3) -> ?tType_I8; +compact_to_typeid(16#4) -> ?tType_I16; +compact_to_typeid(16#5) -> ?tType_I32; +compact_to_typeid(16#6) -> ?tType_I64; +compact_to_typeid(16#8) -> ?tType_STRING; +compact_to_typeid(16#C) -> ?tType_STRUCT; +compact_to_typeid(16#B) -> ?tType_MAP; +compact_to_typeid(16#A) -> ?tType_SET; +compact_to_typeid(16#9) -> ?tType_LIST. bool_to_cbool(Value) when Value -> ?CBOOL_TRUE; bool_to_cbool(_) -> ?CBOOL_FALSE. @@ -88,30 +92,31 @@ cbool_to_bool(Value) -> Value =:= ?CBOOL_TRUE. new(Transport) -> new(Transport, _Options = []). new(Transport, _Options) -> - State = #t_compact{transport = Transport}, - thrift_protocol:new(?MODULE, State). + State = #t_compact{transport = Transport}, + thrift_protocol:new(?MODULE, State). flush_transport(This = #t_compact{transport = Transport}) -> - {NewTransport, Result} = thrift_transport:flush(Transport), - {This#t_compact{transport = NewTransport}, Result}. + {NewTransport, Result} = thrift_transport:flush(Transport), + {This#t_compact{transport = NewTransport}, Result}. close_transport(This = #t_compact{transport = Transport}) -> - {NewTransport, Result} = thrift_transport:close(Transport), - {This#t_compact{transport = NewTransport}, Result}. + {NewTransport, Result} = thrift_transport:close(Transport), + {This#t_compact{transport = NewTransport}, Result}. %%% %%% instance methods %%% -write_field_begin(This0 = #t_compact{write_stack=[LastId|T]}, CompactType, Id) -> - IdDiff = Id - LastId, - This1 = This0#t_compact{write_stack=[Id|T]}, - case (IdDiff > 0) and (IdDiff < 16) of - true -> write(This1, {byte, (IdDiff bsl 4) bor CompactType}); - false -> - {This2, ok} = write(This1, {byte, CompactType}), - write(This2, {i16, Id}) - end. +write_field_begin(This0 = #t_compact{write_stack = [LastId | T]}, CompactType, Id) -> + IdDiff = Id - LastId, + This1 = This0#t_compact{write_stack = [Id | T]}, + case (IdDiff > 0) and (IdDiff < 16) of + true -> + write(This1, {byte, (IdDiff bsl 4) bor CompactType}); + false -> + {This2, ok} = write(This1, {byte, CompactType}), + write(This2, {i16, Id}) + end. -spec to_zigzag(integer()) -> non_neg_integer(). to_zigzag(Value) -> 16#FFFFFFFFFFFFFFFF band ((Value bsl 1) bxor (Value bsr 63)). @@ -121,270 +126,270 @@ from_zigzag(Value) -> (Value bsr 1) bxor -(Value band 1). -spec to_varint(non_neg_integer(), iolist()) -> iolist(). to_varint(Value, Acc) when (Value < 16#80) -> [Acc, Value]; -to_varint(Value, Acc) -> - to_varint(Value bsr 7, [Acc, ((Value band 16#7F) bor 16#80)]). +to_varint(Value, Acc) -> to_varint(Value bsr 7, [Acc, ((Value band 16#7F) bor 16#80)]). --spec read_varint(#t_compact{}, non_neg_integer(), non_neg_integer()) -> non_neg_integer(). +-spec read_varint(t_compact(), non_neg_integer(), non_neg_integer()) -> + {t_compact(), {'ok', integer()}}. read_varint(This0, Acc, Count) -> - {This1, {ok, Byte}} = read(This0, byte), - case (Byte band 16#80) of - 0 -> {This1, {ok, (Byte bsl (7 * Count)) + Acc}}; - _ -> read_varint(This1, ((Byte band 16#7f) bsl (7 * Count)) + Acc, Count + 1) - end. + {This1, {ok, Byte}} = read(This0, byte), + case (Byte band 16#80) of + 0 -> {This1, {ok, (Byte bsl (7 * Count)) + Acc}}; + _ -> read_varint(This1, ((Byte band 16#7f) bsl (7 * Count)) + Acc, Count + 1) + end. write(This0, #protocol_message_begin{ - name = Name, - type = Type, - seqid = Seqid}) -> - {This1, ok} = write(This0, {byte, ?PROTOCOL_ID}), - {This2, ok} = write(This1, {byte, (?VERSION_1 band ?VERSION_MASK) bor (Type bsl ?TYPE_SHIFT_AMOUNT)}), - {This3, ok} = write(This2, {ui32, Seqid}), - {This4, ok} = write(This3, {string, Name}), - {This4, ok}; - -write(This, message_end) -> {This, ok}; - + name = Name, + type = Type, + seqid = Seqid +}) -> + {This1, ok} = write(This0, {byte, ?PROTOCOL_ID}), + {This2, ok} = write( + This1, {byte, (?VERSION_1 band ?VERSION_MASK) bor (Type bsl ?TYPE_SHIFT_AMOUNT)} + ), + {This3, ok} = write(This2, {ui32, Seqid}), + {This4, ok} = write(This3, {string, Name}), + {This4, ok}; +write(This, message_end) -> + {This, ok}; write(This0, #protocol_field_begin{ - name = _Name, - type = Type, - id = Id}) -when (Type =:= ?tType_BOOL) -> {This0#t_compact{write_id = Id}, ok}; - + name = _Name, + type = Type, + id = Id +}) when + (Type =:= ?tType_BOOL) +-> + {This0#t_compact{write_id = Id}, ok}; write(This0, #protocol_field_begin{ - name = _Name, - type = Type, - id = Id}) -> - write_field_begin(This0, typeid_to_compact(Type), Id); - -write(This, field_stop) -> write(This, {byte, ?tType_STOP}); - -write(This, field_end) -> {This, ok}; - + name = _Name, + type = Type, + id = Id +}) -> + write_field_begin(This0, typeid_to_compact(Type), Id); +write(This, field_stop) -> + write(This, {byte, ?tType_STOP}); +write(This, field_end) -> + {This, ok}; write(This0, #protocol_map_begin{ - ktype = _Ktype, - vtype = _Vtype, - size = Size}) -when Size =:= 0 -> - write(This0, {byte, 0}); - + ktype = _Ktype, + vtype = _Vtype, + size = Size +}) when + Size =:= 0 +-> + write(This0, {byte, 0}); write(This0, #protocol_map_begin{ - ktype = Ktype, - vtype = Vtype, - size = Size}) -> - {This1, ok} = write(This0, {ui32, Size}), - write(This1, {byte, (typeid_to_compact(Ktype) bsl 4) bor typeid_to_compact(Vtype)}); - -write(This, map_end) -> {This, ok}; - + ktype = Ktype, + vtype = Vtype, + size = Size +}) -> + {This1, ok} = write(This0, {ui32, Size}), + write(This1, {byte, (typeid_to_compact(Ktype) bsl 4) bor typeid_to_compact(Vtype)}); +write(This, map_end) -> + {This, ok}; write(This0, #protocol_list_begin{ - etype = Etype, - size = Size}) -when Size < 16#f -> - write(This0, {byte, (Size bsl 4) bor typeid_to_compact(Etype)}); - + etype = Etype, + size = Size +}) when + Size < 16#f +-> + write(This0, {byte, (Size bsl 4) bor typeid_to_compact(Etype)}); write(This0, #protocol_list_begin{ - etype = Etype, - size = Size}) -> - {This1, ok} = write(This0, {byte, 16#f0 bor typeid_to_compact(Etype)}), - write(This1, {ui32, Size}); - -write(This, list_end) -> {This, ok}; - + etype = Etype, + size = Size +}) -> + {This1, ok} = write(This0, {byte, 16#f0 bor typeid_to_compact(Etype)}), + write(This1, {ui32, Size}); +write(This, list_end) -> + {This, ok}; write(This0, #protocol_set_begin{ - etype = Etype, - size = Size}) -> - write(This0, #protocol_list_begin{etype = Etype, size = Size}); - -write(This, set_end) -> {This, ok}; - + etype = Etype, + size = Size +}) -> + write(This0, #protocol_list_begin{etype = Etype, size = Size}); +write(This, set_end) -> + {This, ok}; write(This = #t_compact{write_stack = Stack}, #protocol_struct_begin{}) -> - {This#t_compact{write_stack = [0|Stack]}, ok}; -write(This = #t_compact{write_stack = [_|T]}, struct_end) -> - {This#t_compact{write_stack = T}, ok}; - + {This#t_compact{write_stack = [0 | Stack]}, ok}; +write(This = #t_compact{write_stack = [_ | T]}, struct_end) -> + {This#t_compact{write_stack = T}, ok}; write(This = #t_compact{write_id = ?ID_NONE}, {bool, Value}) -> - write(This, {byte, bool_to_cbool(Value)}); - + write(This, {byte, bool_to_cbool(Value)}); write(This0 = #t_compact{write_id = Id}, {bool, Value}) -> - {This1, ok} = write_field_begin(This0, bool_to_cbool(Value), Id), - {This1#t_compact{write_id = ?ID_NONE}, ok}; - + {This1, ok} = write_field_begin(This0, bool_to_cbool(Value), Id), + {This1#t_compact{write_id = ?ID_NONE}, ok}; write(This, {byte, Value}) when is_integer(Value) -> - write(This, <>); - + write(This, <>); write(This, {i16, Value}) when is_integer(Value) -> write(This, to_varint(to_zigzag(Value), [])); write(This, {ui32, Value}) when is_integer(Value) -> write(This, to_varint(Value, [])); write(This, {i32, Value}) when is_integer(Value) -> - write(This, to_varint(to_zigzag(Value), [])); + write(This, to_varint(to_zigzag(Value), [])); write(This, {i64, Value}) when is_integer(Value) -> write(This, to_varint(to_zigzag(Value), [])); - write(This, {double, Double}) -> - write(This, <>); - + write(This, <>); write(This0, {string, Str}) when is_list(Str) -> - % TODO: limit length - {This1, ok} = write(This0, {ui32, length(Str)}), - {This2, ok} = write(This1, list_to_binary(Str)), - {This2, ok}; - + % TODO: limit length + {This1, ok} = write(This0, {ui32, length(Str)}), + {This2, ok} = write(This1, list_to_binary(Str)), + {This2, ok}; write(This0, {string, Bin}) when is_binary(Bin) -> - % TODO: limit length - {This1, ok} = write(This0, {ui32, size(Bin)}), - {This2, ok} = write(This1, Bin), - {This2, ok}; - + % TODO: limit length + {This1, ok} = write(This0, {ui32, size(Bin)}), + {This2, ok} = write(This1, Bin), + {This2, ok}; %% Data :: iolist() write(This = #t_compact{transport = Trans}, Data) -> - {NewTransport, Result} = thrift_transport:write(Trans, Data), - {This#t_compact{transport = NewTransport}, Result}. + {NewTransport, Result} = thrift_transport:write(Trans, Data), + {This#t_compact{transport = NewTransport}, Result}. %% %% read(This0, message_begin) -> - {This1, {ok, ?PROTOCOL_ID}} = read(This0, ubyte), - {This2, {ok, VerAndType}} = read(This1, ubyte), - ?VERSION_1 = VerAndType band ?VERSION_MASK, - {This3, {ok, SeqId}} = read(This2, ui32), - {This4, {ok, Name}} = read(This3, string), - {This4, #protocol_message_begin{ - name = binary_to_list(Name), - type = (VerAndType bsr ?TYPE_SHIFT_AMOUNT) band ?TYPE_BITS, - seqid = SeqId}}; - -read(This, message_end) -> {This, ok}; - + {This1, {ok, ?PROTOCOL_ID}} = read(This0, ubyte), + {This2, {ok, VerAndType}} = read(This1, ubyte), + ?VERSION_1 = VerAndType band ?VERSION_MASK, + {This3, {ok, SeqId}} = read(This2, ui32), + {This4, {ok, Name}} = read(This3, string), + {This4, #protocol_message_begin{ + name = binary_to_list(Name), + type = (VerAndType bsr ?TYPE_SHIFT_AMOUNT) band ?TYPE_BITS, + seqid = SeqId + }}; +read(This, message_end) -> + {This, ok}; read(This = #t_compact{read_stack = Stack}, struct_begin) -> - {This#t_compact{read_stack = [0|Stack]}, ok}; -read(This = #t_compact{read_stack = [_H|T]}, struct_end) -> - {This#t_compact{read_stack = T}, ok}; - -read(This0 = #t_compact{read_stack = [LastId|T]}, field_begin) -> - {This1, {ok, Byte}} = read(This0, ubyte), - case Byte band 16#f of - CompactType = ?tType_STOP -> - {This1, #protocol_field_begin{type = CompactType}}; - CompactType -> - {This2, {ok, Id}} = case Byte bsr 4 of - 0 -> read(This1, i16); - IdDiff -> - {This1, {ok, LastId + IdDiff}} - end, - case compact_to_typeid(CompactType) of - ?tType_BOOL -> - {This2#t_compact{read_stack = [Id|T], read_value = cbool_to_bool(CompactType)}, - #protocol_field_begin{type = ?tType_BOOL, id = Id}}; - Type -> - {This2#t_compact{read_stack = [Id|T]}, - #protocol_field_begin{type = Type, id = Id}} - end - end; - -read(This, field_end) -> {This, ok}; - + {This#t_compact{read_stack = [0 | Stack]}, ok}; +read(This = #t_compact{read_stack = [_H | T]}, struct_end) -> + {This#t_compact{read_stack = T}, ok}; +read(This0 = #t_compact{read_stack = [LastId | T]}, field_begin) -> + {This1, {ok, Byte}} = read(This0, ubyte), + case Byte band 16#f of + CompactType = ?tType_STOP -> + {This1, #protocol_field_begin{type = CompactType}}; + CompactType -> + {This2, {ok, Id}} = + case Byte bsr 4 of + 0 -> read(This1, i16); + IdDiff -> {This1, {ok, LastId + IdDiff}} + end, + case compact_to_typeid(CompactType) of + ?tType_BOOL -> + { + This2#t_compact{ + read_stack = [Id | T], read_value = CompactType + }, + #protocol_field_begin{type = ?tType_BOOL, id = Id} + }; + Type -> + {This2#t_compact{read_stack = [Id | T]}, #protocol_field_begin{ + type = Type, id = Id + }} + end + end; +read(This, field_end) -> + {This, ok}; read(This0, map_begin) -> - {This1, {ok, Size}} = read(This0, ui32), - {This2, {ok, KV}} = case Size of - 0 -> {This1, {ok, 0}}; - _ -> read(This1, ubyte) - end, - {This2, #protocol_map_begin{ktype = compact_to_typeid(KV bsr 4), - vtype = compact_to_typeid(KV band 16#f), - size = Size}}; -read(This, map_end) -> {This, ok}; - + {This1, {ok, Size}} = read(This0, ui32), + {This2, {ok, KV}} = + case Size of + 0 -> {This1, {ok, 0}}; + _ -> read(This1, ubyte) + end, + {This2, #protocol_map_begin{ + ktype = compact_to_typeid(KV bsr 4), + vtype = compact_to_typeid(KV band 16#f), + size = Size + }}; +read(This, map_end) -> + {This, ok}; read(This0, list_begin) -> - {This1, {ok, SizeAndType}} = read(This0, ubyte), - {This2, {ok, Size}} = case (SizeAndType bsr 4) band 16#f of - 16#f -> read(This1, ui32); - Else -> {This1, {ok, Else}} - end, - {This2, #protocol_list_begin{etype = compact_to_typeid(SizeAndType band 16#f), - size = Size}}; - -read(This, list_end) -> {This, ok}; - + {This1, {ok, SizeAndType}} = read(This0, ubyte), + {This2, {ok, Size}} = + case (SizeAndType bsr 4) band 16#f of + 16#f -> read(This1, ui32); + Else -> {This1, {ok, Else}} + end, + {This2, #protocol_list_begin{ + etype = compact_to_typeid(SizeAndType band 16#f), + size = Size + }}; +read(This, list_end) -> + {This, ok}; read(This0, set_begin) -> - {This1, {ok, SizeAndType}} = read(This0, ubyte), - {This2, {ok, Size}} = case (SizeAndType bsr 4) band 16#f of - 16#f -> read(This1, ui32); - Else -> {This1, {ok, Else}} - end, - {This2, #protocol_set_begin{etype = compact_to_typeid(SizeAndType band 16#f), - size = Size}}; - -read(This, set_end) -> {This, ok}; - + {This1, {ok, SizeAndType}} = read(This0, ubyte), + {This2, {ok, Size}} = + case (SizeAndType bsr 4) band 16#f of + 16#f -> read(This1, ui32); + Else -> {This1, {ok, Else}} + end, + {This2, #protocol_set_begin{ + etype = compact_to_typeid(SizeAndType band 16#f), + size = Size + }}; +read(This, set_end) -> + {This, ok}; read(This0, field_stop) -> - {This1, {ok, ?tType_STOP}} = read(This0, ubyte), - {This1, ok}; - + {This1, {ok, ?tType_STOP}} = read(This0, ubyte), + {This1, ok}; %% read(This0 = #t_compact{read_value = ?CBOOL_NONE}, bool) -> - {This1, {ok, Byte}} = read(This0, ubyte), - {This1, {ok, cbool_to_bool(Byte)}}; - + {This1, {ok, Byte}} = read(This0, ubyte), + {This1, {ok, cbool_to_bool(Byte)}}; read(This0 = #t_compact{read_value = Bool}, bool) -> - {This0#t_compact{read_value = ?CBOOL_NONE}, {ok, Bool}}; - + {This0#t_compact{read_value = ?CBOOL_NONE}, {ok, cbool_to_bool(Bool)}}; read(This0, ubyte) -> - {This1, {ok, <>}} = read_data(This0, 1), - {This1, {ok, Val}}; - + {This1, {ok, <>}} = read_data(This0, 1), + {This1, {ok, Val}}; read(This0, byte) -> - {This1, Bytes} = read_data(This0, 1), - case Bytes of - {ok, <>} -> {This1, {ok, Val}}; - Else -> {This1, Else} - end; - + {This1, Bytes} = read_data(This0, 1), + case Bytes of + {ok, <>} -> {This1, {ok, Val}}; + Else -> {This1, Else} + end; read(This0, i16) -> - {This1, {ok, Zigzag}} = read_varint(This0, 0, 0), - {This1, {ok, from_zigzag(Zigzag)}}; - -read(This0, ui32) -> read_varint(This0, 0, 0); - + {This1, {ok, Zigzag}} = read_varint(This0, 0, 0), + {This1, {ok, from_zigzag(Zigzag)}}; +read(This0, ui32) -> + read_varint(This0, 0, 0); read(This0, i32) -> - {This1, {ok, Zigzag}} = read_varint(This0, 0, 0), - {This1, {ok, from_zigzag(Zigzag)}}; - + {This1, {ok, Zigzag}} = read_varint(This0, 0, 0), + {This1, {ok, from_zigzag(Zigzag)}}; read(This0, i64) -> - {This1, {ok, Zigzag}} = read_varint(This0, 0, 0), - {This1, {ok, from_zigzag(Zigzag)}}; - + {This1, {ok, Zigzag}} = read_varint(This0, 0, 0), + {This1, {ok, from_zigzag(Zigzag)}}; read(This0, double) -> - {This1, Bytes} = read_data(This0, 8), - case Bytes of - {ok, <>} -> {This1, {ok, Val}}; - Else -> {This1, Else} - end; - + {This1, Bytes} = read_data(This0, 8), + case Bytes of + {ok, <>} -> {This1, {ok, Val}}; + Else -> {This1, Else} + end; % returns a binary directly, call binary_to_list if necessary read(This0, string) -> - {This1, {ok, Sz}} = read(This0, ui32), - read_data(This1, Sz). + {This1, {ok, Sz}} = read(This0, ui32), + read_data(This1, Sz). -spec read_data(#t_compact{}, non_neg_integer()) -> {#t_compact{}, {ok, binary()} | {error, _Reason}}. -read_data(This, 0) -> {This, {ok, <<>>}}; +read_data(This, 0) -> + {This, {ok, <<>>}}; read_data(This = #t_compact{transport = Trans}, Len) when is_integer(Len) andalso Len > 0 -> {NewTransport, Result} = thrift_transport:read(Trans, Len), {This#t_compact{transport = NewTransport}, Result}. - %%%% FACTORY GENERATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% returns a (fun() -> thrift_protocol()) new_protocol_factory(TransportFactory, _Options) -> - F = fun() -> - case TransportFactory() of + F = fun() -> + case TransportFactory() of {ok, Transport} -> - thrift_compact_protocol:new( - Transport, - []); + thrift_compact_protocol:new( + Transport, + [] + ); {error, Error} -> - {error, Error} - end - end, - {ok, F}. + {error, Error} + end + end, + {ok, F}. diff --git a/lib/erl/src/thrift_disk_log_transport.erl b/lib/erl/src/thrift_disk_log_transport.erl index de8ee417b8b..733d88f189e 100644 --- a/lib/erl/src/thrift_disk_log_transport.erl +++ b/lib/erl/src/thrift_disk_log_transport.erl @@ -31,13 +31,13 @@ -export([read/2, write/2, force_flush/1, flush/1, close/1]). %% state --record(dl_transport, {log, - close_on_close = false, - sync_every = infinity, - sync_tref}). --type state() :: #dl_transport{}. --include("thrift_transport_behaviour.hrl"). - +-record(dl_transport, { + %% Keep in sync with disk_log:log/0 type + log :: term(), + close_on_close = false :: boolean(), + sync_every = infinity :: undefined | timeout(), + sync_tref :: undefined | timer:tref() +}). %% Create a transport attached to an already open log. %% If you'd like this transport to close the disk_log using disk_log:lclose() @@ -51,12 +51,12 @@ new(LogName, Opts) when is_atom(LogName), is_list(Opts) -> N when is_integer(N), N > 0 -> {ok, TRef} = timer:apply_interval(N, ?MODULE, force_flush, [State]), State#dl_transport{sync_tref = TRef}; - _ -> State + _ -> + State end, thrift_transport:new(?MODULE, State2). - parse_opts([], State) -> State; parse_opts([{close_on_close, Bool} | Rest], State) when is_boolean(Bool) -> @@ -64,7 +64,6 @@ parse_opts([{close_on_close, Bool} | Rest], State) when is_boolean(Bool) -> parse_opts([{sync_every, Int} | Rest], State) when is_integer(Int), Int > 0 -> parse_opts(Rest, State#dl_transport{sync_every = Int}). - %%%% TRANSPORT IMPLENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% disk_log_transport is write-only @@ -80,38 +79,40 @@ force_flush(#dl_transport{log = Log}) -> flush(This = #dl_transport{log = Log, sync_every = SE}) -> case SE of - undefined -> % no time-based sync - disk_log:sync(Log); - _Else -> % sync will happen automagically + % no time-based sync + undefined -> + ok = disk_log:sync(Log); + % sync will happen automagically + _Else -> ok end, {This, ok}. - - - %% On close, close the underlying log if we're configured to do so. close(This = #dl_transport{close_on_close = false}) -> {This, ok}; close(This = #dl_transport{log = Log}) -> - {This, disk_log:lclose(Log)}. - + {This, disk_log:close(Log)}. %%%% FACTORY GENERATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% new_transport_factory(Name, ExtraLogOpts) -> - new_transport_factory(Name, ExtraLogOpts, [{close_on_close, true}, - {sync_every, 500}]). + new_transport_factory(Name, ExtraLogOpts, [ + {close_on_close, true}, + {sync_every, 500} + ]). new_transport_factory(Name, ExtraLogOpts, TransportOpts) -> F = fun() -> factory_impl(Name, ExtraLogOpts, TransportOpts) end, {ok, F}. factory_impl(Name, ExtraLogOpts, TransportOpts) -> - LogOpts = [{name, Name}, - {format, external}, - {type, wrap} | - ExtraLogOpts], + LogOpts = [ + {name, Name}, + {format, external}, + {type, wrap} + | ExtraLogOpts + ], Log = case disk_log:open(LogOpts) of {ok, LogS} -> diff --git a/lib/erl/src/thrift_file_transport.erl b/lib/erl/src/thrift_file_transport.erl index 071152b63d9..b0bf3839857 100644 --- a/lib/erl/src/thrift_file_transport.erl +++ b/lib/erl/src/thrift_file_transport.erl @@ -28,88 +28,76 @@ %% legacy api -export([new_reader/1]). - -record(t_file, { - device, - should_close = true, - mode = write + device :: file:io_device(), + should_close = true :: boolean(), + mode = write :: file:mode() }). --type state() :: #t_file{}. - - --spec new(Device::file:io_device()) -> - thrift_transport:t_transport(). +-spec new(Device :: file:io_device()) -> {ok, thrift_transport:t_transport()}. new(Device) -> new(Device, []). --spec new(Device::file:io_device(), Opts::list()) -> - thrift_transport:t_transport(). +-spec new(Device :: file:io_device(), Opts :: list()) -> {ok, thrift_transport:t_transport()}. %% Device should be opened in raw and binary mode. new(Device, Opts) when is_list(Opts) -> - State = parse_opts(Opts, #t_file{device = Device}), - thrift_transport:new(?MODULE, State). - - -parse_opts([{should_close, Bool}|Rest], State) -when is_boolean(Bool) -> - parse_opts(Rest, State#t_file{should_close = Bool}); -parse_opts([{mode, Mode}|Rest], State) -when Mode =:= write; Mode =:= read -> - parse_opts(Rest, State#t_file{mode = Mode}); + State = parse_opts(Opts, #t_file{device = Device}), + thrift_transport:new(?MODULE, State). + +parse_opts([{should_close, Bool} | Rest], State) when + is_boolean(Bool) +-> + parse_opts(Rest, State#t_file{should_close = Bool}); +parse_opts([{mode, Mode} | Rest], State) when + Mode =:= write; Mode =:= read +-> + parse_opts(Rest, State#t_file{mode = Mode}); parse_opts([], State) -> - State. - - --include("thrift_transport_behaviour.hrl"). - - -read(State = #t_file{device = Device, mode = read}, Len) -when is_integer(Len), Len >= 0 -> - case file:read(Device, Len) of - eof -> {State, {error, eof}}; - {ok, Result} -> {State, {ok, iolist_to_binary(Result)}} - end; + State. + +read(State = #t_file{device = Device, mode = read}, Len) when + is_integer(Len), Len >= 0 +-> + case file:read(Device, Len) of + eof -> {State, {error, eof}}; + {ok, Result} -> {State, {ok, iolist_to_binary(Result)}} + end; read(State, _) -> - {State, {error, write_mode}}. - - -read_exact(State = #t_file{device = Device, mode = read}, Len) -when is_integer(Len), Len >= 0 -> - case file:read(Device, Len) of - eof -> {State, {error, eof}}; - {ok, Result} -> - case iolist_size(Result) of - X when X < Len -> {State, {error, eof}}; - _ -> {State, {ok, iolist_to_binary(Result)}} - end - end; + {State, {error, write_mode}}. + +read_exact(State = #t_file{device = Device, mode = read}, Len) when + is_integer(Len), Len >= 0 +-> + case file:read(Device, Len) of + eof -> + {State, {error, eof}}; + {ok, Result} -> + case iolist_size(Result) of + X when X < Len -> {State, {error, eof}}; + _ -> {State, {ok, iolist_to_binary(Result)}} + end + end; read_exact(State, _) -> - {State, {error, write_mode}}. - + {State, {error, write_mode}}. write(State = #t_file{device = Device, mode = write}, Data) -> - {State, file:write(Device, Data)}; + {State, file:write(Device, Data)}; write(State, _) -> - {State, {error, read_mode}}. - + {State, {error, read_mode}}. flush(State = #t_file{device = Device, mode = write}) -> - {State, file:sync(Device)}. - + {State, file:sync(Device)}. close(State = #t_file{device = Device, should_close = SC}) -> - case SC of - true -> {State, file:close(Device)}; - false -> {State, ok} - end. - + case SC of + true -> {State, file:close(Device)}; + false -> {State, ok} + end. %% legacy api. left for compatibility new_reader(Filename) -> - case file:open(Filename, [read, binary, {read_ahead, 1024*1024}]) of - {ok, IODevice} -> new(IODevice, [{should_close, true}, {mode, read}]); - Error -> Error - end. - + case file:open(Filename, [read, binary, {read_ahead, 1024 * 1024}]) of + {ok, IODevice} -> new(IODevice, [{should_close, true}, {mode, read}]); + Error -> Error + end. diff --git a/lib/erl/src/thrift_framed_transport.erl b/lib/erl/src/thrift_framed_transport.erl index 9a5d6af552b..0d93baa949f 100644 --- a/lib/erl/src/thrift_framed_transport.erl +++ b/lib/erl/src/thrift_framed_transport.erl @@ -26,101 +26,92 @@ %% protocol callbacks -export([read/2, read_exact/2, write/2, flush/1, close/1]). - -record(t_framed, { - wrapped, - read_buffer, - write_buffer + wrapped :: thrift_transport:t_transport(), + read_buffer :: iodata(), + write_buffer :: iodata() }). --type state() :: #t_framed{}. - - --spec new(Transport::thrift_transport:t_transport()) -> - thrift_transport:t_transport(). +-spec new(Transport :: thrift_transport:t_transport()) -> {ok, thrift_transport:t_transport()}. new(Wrapped) -> - State = #t_framed{ - wrapped = Wrapped, - read_buffer = [], - write_buffer = [] - }, - thrift_transport:new(?MODULE, State). - - --include("thrift_transport_behaviour.hrl"). - - -read(State = #t_framed{wrapped = Wrapped, read_buffer = Buffer}, Len) -when is_integer(Len), Len >= 0 -> - Binary = iolist_to_binary(Buffer), - case Binary of - <<>> when Len > 0 -> - case next_frame(Wrapped) of - {NewState, {ok, Frame}} -> - NewBinary = iolist_to_binary([Binary, Frame]), - Give = min(iolist_size(NewBinary), Len), - {Result, Remaining} = split_binary(NewBinary, Give), - {State#t_framed{wrapped = NewState, read_buffer = Remaining}, {ok, Result}}; - {NewState, Error} -> - {State#t_framed{wrapped = NewState}, Error} - end; - %% read of zero bytes - <<>> -> {State, {ok, <<>>}}; - %% read buffer is nonempty - _ -> - Give = min(iolist_size(Binary), Len), - {Result, Remaining} = split_binary(Binary, Give), - {State#t_framed{read_buffer = Remaining}, {ok, Result}} - end. - - -read_exact(State = #t_framed{wrapped = Wrapped, read_buffer = Buffer}, Len) -when is_integer(Len), Len >= 0 -> - Binary = iolist_to_binary(Buffer), - case iolist_size(Binary) of - %% read buffer is larger than requested read size - X when X >= Len -> - {Result, Remaining} = split_binary(Binary, Len), - {State#t_framed{read_buffer = Remaining}, {ok, Result}}; - %% read buffer is insufficient for requested read size - _ -> - case next_frame(Wrapped) of - {NewState, {ok, Frame}} -> - read_exact( - State#t_framed{wrapped = NewState, read_buffer = [Buffer, Frame]}, - Len - ); - {NewState, Error} -> - {State#t_framed{wrapped = NewState}, Error} - end - end. + State = #t_framed{ + wrapped = Wrapped, + read_buffer = [], + write_buffer = [] + }, + thrift_transport:new(?MODULE, State). + +read(State = #t_framed{wrapped = Wrapped, read_buffer = Buffer}, Len) when + is_integer(Len), Len >= 0 +-> + Binary = iolist_to_binary(Buffer), + case Binary of + <<>> when Len > 0 -> + case next_frame(Wrapped) of + {NewState, {ok, Frame}} -> + NewBinary = iolist_to_binary([Binary, Frame]), + Give = min(iolist_size(NewBinary), Len), + {Result, Remaining} = split_binary(NewBinary, Give), + {State#t_framed{wrapped = NewState, read_buffer = Remaining}, {ok, Result}}; + {NewState, Error} -> + {State#t_framed{wrapped = NewState}, Error} + end; + %% read of zero bytes + <<>> -> + {State, {ok, <<>>}}; + %% read buffer is nonempty + _ -> + Give = min(iolist_size(Binary), Len), + {Result, Remaining} = split_binary(Binary, Give), + {State#t_framed{read_buffer = Remaining}, {ok, Result}} + end. + +read_exact(State = #t_framed{wrapped = Wrapped, read_buffer = Buffer}, Len) when + is_integer(Len), Len >= 0 +-> + Binary = iolist_to_binary(Buffer), + case iolist_size(Binary) of + %% read buffer is larger than requested read size + X when X >= Len -> + {Result, Remaining} = split_binary(Binary, Len), + {State#t_framed{read_buffer = Remaining}, {ok, Result}}; + %% read buffer is insufficient for requested read size + _ -> + case next_frame(Wrapped) of + {NewState, {ok, Frame}} -> + read_exact( + State#t_framed{wrapped = NewState, read_buffer = [Buffer, Frame]}, + Len + ); + {NewState, Error} -> + {State#t_framed{wrapped = NewState}, Error} + end + end. next_frame(Transport) -> - case thrift_transport:read_exact(Transport, 4) of - {NewState, {ok, <>}} -> - thrift_transport:read_exact(NewState, FrameLength); - Error -> Error - end. - + case thrift_transport:read_exact(Transport, 4) of + {NewState, {ok, <>}} -> + thrift_transport:read_exact(NewState, FrameLength); + Error -> + Error + end. write(State = #t_framed{write_buffer = Buffer}, Data) -> - {State#t_framed{write_buffer = [Buffer, Data]}, ok}. - + {State#t_framed{write_buffer = [Buffer, Data]}, ok}. flush(State = #t_framed{write_buffer = Buffer, wrapped = Wrapped}) -> - case iolist_size(Buffer) of - %% if write buffer is empty, do nothing - 0 -> {State, ok}; - FrameLen -> - Data = [<>, Buffer], - {Written, Response} = thrift_transport:write(Wrapped, Data), - {Flushed, ok} = thrift_transport:flush(Written), - {State#t_framed{wrapped = Flushed, write_buffer = []}, Response} - end. - + case iolist_size(Buffer) of + %% if write buffer is empty, do nothing + 0 -> + {State, ok}; + FrameLen -> + Data = [<>, Buffer], + {Written, Response} = thrift_transport:write(Wrapped, Data), + {Flushed, ok} = thrift_transport:flush(Written), + {State#t_framed{wrapped = Flushed, write_buffer = []}, Response} + end. close(State = #t_framed{wrapped = Wrapped}) -> - {Closed, Result} = thrift_transport:close(Wrapped), - {State#t_framed{wrapped = Closed}, Result}. - + {Closed, Result} = thrift_transport:close(Wrapped), + {State#t_framed{wrapped = Closed}, Result}. diff --git a/lib/erl/src/thrift_http_transport.erl b/lib/erl/src/thrift_http_transport.erl index 46bcede53ce..b422b3f0344 100644 --- a/lib/erl/src/thrift_http_transport.erl +++ b/lib/erl/src/thrift_http_transport.erl @@ -27,15 +27,16 @@ %% thrift_transport callbacks -export([write/2, read/2, flush/1, close/1]). --record(http_transport, {host, % string() - path, % string() - read_buffer, % iolist() - write_buffer, % iolist() - http_options, % see http(3) - extra_headers % [{str(), str()}, ...] - }). --type state() :: #http_transport{}. --include("thrift_transport_behaviour.hrl"). +% string() +-record(http_transport, { + host :: string(), + path :: string(), + read_buffer :: iodata(), + write_buffer :: iodata(), + % see httpc(3) + http_options :: [{atom(), term()}], + extra_headers :: [{string(), string()}] +}). new(Host, Path) -> new(Host, Path, _Options = []). @@ -46,12 +47,14 @@ new(Host, Path) -> %% {extra_headers, ExtraHeaders} = List of extra HTTP headers %%-------------------------------------------------------------------- new(Host, Path, Options) -> - State1 = #http_transport{host = Host, - path = Path, - read_buffer = [], - write_buffer = [], - http_options = [], - extra_headers = []}, + State1 = #http_transport{ + host = Host, + path = Path, + read_buffer = [], + write_buffer = [], + http_options = [], + extra_headers = [] + }, ApplyOption = fun ({http_options, HttpOpts}, State = #http_transport{}) -> @@ -75,28 +78,38 @@ write(State = #http_transport{write_buffer = WBuf}, Data) -> {State#http_transport{write_buffer = [WBuf, Data]}, ok}. %% Flushes the buffer, making a request -flush(State = #http_transport{host = Host, - path = Path, - read_buffer = Rbuf, - write_buffer = Wbuf, - http_options = HttpOptions, - extra_headers = ExtraHeaders}) -> +flush( + State = #http_transport{ + host = Host, + path = Path, + read_buffer = Rbuf, + write_buffer = Wbuf, + http_options = HttpOptions, + extra_headers = ExtraHeaders + } +) -> case iolist_to_binary(Wbuf) of <<>> -> %% Don't bother flushing empty buffers. {State, ok}; WBinary -> {ok, {{_Version, 200, _ReasonPhrase}, _Headers, Body}} = - httpc:request(post, - {"http://" ++ Host ++ Path, - [{"User-Agent", "Erlang/thrift_http_transport"} | ExtraHeaders], - "application/x-thrift", - WBinary}, - HttpOptions, - [{body_format, binary}]), + httpc:request( + post, + { + "http://" ++ Host ++ Path, + [{"User-Agent", "Erlang/thrift_http_transport"} | ExtraHeaders], + "application/x-thrift", + WBinary + }, + HttpOptions, + [{body_format, binary}] + ), - State1 = State#http_transport{read_buffer = [Rbuf, Body], - write_buffer = []}, + State1 = State#http_transport{ + read_buffer = [Rbuf, Body], + write_buffer = [] + }, {State1, ok} end. @@ -109,7 +122,7 @@ read(State = #http_transport{read_buffer = RBuf}, Len) when is_integer(Len) -> case iolist_to_binary(RBuf) of <> -> Response = {ok, Data}, - State1 = State#http_transport{read_buffer=RBuf1}, + State1 = State#http_transport{read_buffer = RBuf1}, {State1, Response}; _ -> {State, {error, 'EOF'}} diff --git a/lib/erl/src/thrift_json_parser.erl b/lib/erl/src/thrift_json_parser.erl index 4e47f10ec9a..18e0c0377dd 100644 --- a/lib/erl/src/thrift_json_parser.erl +++ b/lib/erl/src/thrift_json_parser.erl @@ -22,19 +22,15 @@ -module(thrift_json_parser). -export([parser/0, handle_event/2]). - -record(config, {strict_utf8 = false :: boolean()}). - parser() -> fun(JSON) -> start(JSON, {?MODULE, []}, [], #config{}) end. - handle_event(Event, {Handler, State}, _Config) -> {Handler, Handler:handle_event(Event, State)}. handle_event(end_json, State) -> lists:reverse([end_json] ++ State); handle_event(Event, State) -> [Event] ++ State. - %% whitespace -define(space, 16#20). -define(tab, 16#09). @@ -68,12 +64,11 @@ handle_event(Event, State) -> [Event] ++ State. %% comments -define(star, 16#2A). - %% some useful guards -define(is_hex(Symbol), (Symbol >= $a andalso Symbol =< $f) orelse - (Symbol >= $A andalso Symbol =< $F) orelse - (Symbol >= $0 andalso Symbol =< $9) + (Symbol >= $A andalso Symbol =< $F) orelse + (Symbol >= $0 andalso Symbol =< $9) ). -define(is_nonzero(Symbol), @@ -84,7 +79,6 @@ handle_event(Event, State) -> [Event] ++ State. Symbol =:= ?space; Symbol =:= ?tab; Symbol =:= ?cr; Symbol =:= ?newline ). - %% lists are benchmarked to be faster (tho higher in memory usage) than binaries new_seq() -> []. new_seq(C) -> [C]. @@ -96,13 +90,11 @@ end_seq(Seq) -> unicode:characters_to_binary(lists:reverse(Seq)). end_seq(Seq, _) -> end_seq(Seq). - start(<<16#ef, 16#bb, 16#bf, Rest/binary>>, Handler, Stack, Config) -> value(Rest, Handler, Stack, Config); start(Bin, Handler, Stack, Config) -> value(Bin, Handler, Stack, Config). - value(<>, Handler, Stack, Config) -> string(Rest, Handler, new_seq(), Stack, Config); value(<<$t, Rest/binary>>, Handler, Stack, Config) -> @@ -118,41 +110,37 @@ value(<>, Handler, Stack, Config) -> value(<>, Handler, Stack, Config) when ?is_nonzero(S) -> integer(Rest, Handler, new_seq(S), Stack, Config); value(<>, Handler, Stack, Config) -> - object(Rest, handle_event(start_object, Handler, Config), [key|Stack], Config); + object(Rest, handle_event(start_object, Handler, Config), [key | Stack], Config); value(<>, Handler, Stack, Config) -> - array(Rest, handle_event(start_array, Handler, Config), [array|Stack], Config); + array(Rest, handle_event(start_array, Handler, Config), [array | Stack], Config); value(<>, Handler, Stack, Config) when ?is_whitespace(S) -> value(Rest, Handler, Stack, Config); value(_Bin, _Handler, _Stack, _Config) -> erlang:error(badarg). - object(<>, Handler, Stack, Config) -> string(Rest, Handler, new_seq(), Stack, Config); -object(<>, Handler, [key|Stack], Config) -> +object(<>, Handler, [key | Stack], Config) -> maybe_done(Rest, handle_event(end_object, Handler, Config), Stack, Config); object(<>, Handler, Stack, Config) when ?is_whitespace(S) -> object(Rest, Handler, Stack, Config); object(_Bin, _Handler, _Stack, _Config) -> erlang:error(badarg). - -array(<>, Handler, [array|Stack], Config) -> +array(<>, Handler, [array | Stack], Config) -> maybe_done(Rest, handle_event(end_array, Handler, Config), Stack, Config); array(<>, Handler, Stack, Config) when ?is_whitespace(S) -> array(Rest, Handler, Stack, Config); array(Bin, Handler, Stack, Config) -> value(Bin, Handler, Stack, Config). - -colon(<>, Handler, [key|Stack], Config) -> - value(Rest, Handler, [object|Stack], Config); +colon(<>, Handler, [key | Stack], Config) -> + value(Rest, Handler, [object | Stack], Config); colon(<>, Handler, Stack, Config) when ?is_whitespace(S) -> colon(Rest, Handler, Stack, Config); colon(_Bin, _Handler, _Stack, _Config) -> erlang:error(badarg). - key(<>, Handler, Stack, Config) -> string(Rest, Handler, new_seq(), Stack, Config); key(<>, Handler, Stack, Config) when ?is_whitespace(S) -> @@ -160,7 +148,6 @@ key(<>, Handler, Stack, Config) when ?is_whitespace(S) -> key(_Bin, _Handler, _Stack, _Config) -> erlang:error(badarg). - %% note that if you encounter an error from string and you can't find the clause that %% caused it here, it might be in unescape below string(<>, Handler, Acc, Stack, Config) -> @@ -212,42 +199,47 @@ string(<>, Handler, Acc, Stack, Config) when X >= 16#f0000, string(<>, Handler, Acc, Stack, Config) when X >= 16#100000, X < 16#10fffe -> string(Rest, Handler, acc_seq(Acc, X), Stack, Config); %% surrogates -string(<<237, X, _, Rest/binary>>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) - when X >= 160 -> +string(<<237, X, _, Rest/binary>>, Handler, Acc, Stack, Config = #config{strict_utf8 = false}) when + X >= 160 +-> string(Rest, Handler, acc_seq(Acc, 16#fffd), Stack, Config); %% u+xfffe, u+xffff, control codes and other noncharacters -string(<<_/utf8, Rest/binary>>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) -> +string(<<_/utf8, Rest/binary>>, Handler, Acc, Stack, Config = #config{strict_utf8 = false}) -> string(Rest, Handler, acc_seq(Acc, 16#fffd), Stack, Config); %% u+fffe and u+ffff for R14BXX (subsequent runtimes will happily match the %% preceding clause -string(<<239, 191, X, Rest/binary>>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) - when X == 190; X == 191 -> +string( + <<239, 191, X, Rest/binary>>, Handler, Acc, Stack, Config = #config{strict_utf8 = false} +) when + X == 190; X == 191 +-> string(Rest, Handler, acc_seq(Acc, 16#fffd), Stack, Config); %% overlong encodings and missing continuations of a 2 byte sequence -string(<>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) - when X >= 192, X =< 223 -> +string(<>, Handler, Acc, Stack, Config = #config{strict_utf8 = false}) when + X >= 192, X =< 223 +-> strip_continuations(Rest, Handler, Acc, Stack, Config, 1); %% overlong encodings and missing continuations of a 3 byte sequence -string(<>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) - when X >= 224, X =< 239 -> +string(<>, Handler, Acc, Stack, Config = #config{strict_utf8 = false}) when + X >= 224, X =< 239 +-> strip_continuations(Rest, Handler, Acc, Stack, Config, 2); %% overlong encodings and missing continuations of a 4 byte sequence -string(<>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) - when X >= 240, X =< 247 -> +string(<>, Handler, Acc, Stack, Config = #config{strict_utf8 = false}) when + X >= 240, X =< 247 +-> strip_continuations(Rest, Handler, Acc, Stack, Config, 3); %% incompletes and unexpected bytes, including orphan continuations -string(<<_, Rest/binary>>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) -> +string(<<_, Rest/binary>>, Handler, Acc, Stack, Config = #config{strict_utf8 = false}) -> string(Rest, Handler, acc_seq(Acc, 16#fffd), Stack, Config); string(_Bin, _Handler, _Acc, _Stack, _Config) -> - erlang:error(badarg). - + erlang:error(badarg). -doublequote(Rest, Handler, Acc, [key|_] = Stack, Config) -> +doublequote(Rest, Handler, Acc, [key | _] = Stack, Config) -> colon(Rest, handle_event({key, end_seq(Acc, Config)}, Handler, Config), Stack, Config); doublequote(Rest, Handler, Acc, Stack, Config) -> maybe_done(Rest, handle_event({string, end_seq(Acc, Config)}, Handler, Config), Stack, Config). - %% strips continuation bytes after bad utf bytes, guards against both too short %% and overlong sequences. N is the maximum number of bytes to strip strip_continuations(<>, Handler, Acc, Stack, Config, 0) -> @@ -259,7 +251,6 @@ strip_continuations(<>, Handler, Acc, Stack, Config, N) when X > strip_continuations(<>, Handler, Acc, Stack, Config, _) -> string(Rest, Handler, acc_seq(Acc, 16#fffd), Stack, Config). - %% this all gets really gross and should probably eventually be folded into %% but for now it fakes being part of string on incompletes and errors unescape(<<$b, Rest/binary>>, Handler, Acc, Stack, Config) -> @@ -278,22 +269,35 @@ unescape(<>, Handler, Acc, Stack, Config) -> string(Rest, Handler, acc_seq(Acc, $\\), Stack, Config); unescape(<>, Handler, Acc, Stack, Config) -> string(Rest, Handler, acc_seq(Acc, $/), Stack, Config); -unescape(<<$u, $d, A, B, C, ?rsolidus, $u, $d, X, Y, Z, Rest/binary>>, Handler, Acc, Stack, Config) - when (A == $8 orelse A == $9 orelse A == $a orelse A == $b), - (X == $c orelse X == $d orelse X == $e orelse X == $f), - ?is_hex(B), ?is_hex(C), ?is_hex(Y), ?is_hex(Z) - -> +unescape( + <<$u, $d, A, B, C, ?rsolidus, $u, $d, X, Y, Z, Rest/binary>>, Handler, Acc, Stack, Config +) when + (A == $8 orelse A == $9 orelse A == $a orelse A == $b), + (X == $c orelse X == $d orelse X == $e orelse X == $f), + ?is_hex(B), + ?is_hex(C), + ?is_hex(Y), + ?is_hex(Z) +-> High = erlang:list_to_integer([$d, A, B, C], 16), Low = erlang:list_to_integer([$d, X, Y, Z], 16), Codepoint = (High - 16#d800) * 16#400 + (Low - 16#dc00) + 16#10000, string(Rest, Handler, acc_seq(Acc, Codepoint), Stack, Config); -unescape(<<$u, $d, A, B, C, ?rsolidus, $u, W, X, Y, Z, Rest/binary>>, Handler, Acc, Stack, Config) - when (A == $8 orelse A == $9 orelse A == $a orelse A == $b), - ?is_hex(B), ?is_hex(C), ?is_hex(W), ?is_hex(X), ?is_hex(Y), ?is_hex(Z) - -> +unescape( + <<$u, $d, A, B, C, ?rsolidus, $u, W, X, Y, Z, Rest/binary>>, Handler, Acc, Stack, Config +) when + (A == $8 orelse A == $9 orelse A == $a orelse A == $b), + ?is_hex(B), + ?is_hex(C), + ?is_hex(W), + ?is_hex(X), + ?is_hex(Y), + ?is_hex(Z) +-> string(Rest, Handler, acc_seq(Acc, [16#fffd, 16#fffd]), Stack, Config); -unescape(<<$u, A, B, C, D, Rest/binary>>, Handler, Acc, Stack, Config) - when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D) -> +unescape(<<$u, A, B, C, D, Rest/binary>>, Handler, Acc, Stack, Config) when + ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D) +-> case erlang:list_to_integer([A, B, C, D], 16) of Codepoint when Codepoint < 16#d800; Codepoint > 16#dfff -> string(Rest, Handler, acc_seq(Acc, Codepoint), Stack, Config); @@ -303,7 +307,6 @@ unescape(<<$u, A, B, C, D, Rest/binary>>, Handler, Acc, Stack, Config) unescape(_Bin, _Handler, _Acc, _Stack, _Config) -> erlang:error(badarg). - %% like in strings, there's some pseudo states in here that will never %% show up in errors or incompletes. some show up in value, some show %% up in integer, decimal or exp @@ -314,7 +317,6 @@ negative(<>, Handler, Acc, Stack, Config) when ?is_nonzero(S) -> negative(_Bin, _Handler, _Acc, _Stack, _Config) -> erlang:error(badarg). - zero(<>, Handler, Acc, Stack, Config) -> decimal(Rest, Handler, acc_seq(Acc, ?decimalpoint), Stack, Config); zero(<>, Handler, Acc, Stack, Config) when S =:= $e; S =:= $E -> @@ -322,7 +324,6 @@ zero(<>, Handler, Acc, Stack, Config) when S =:= $e; S =:= $E -> zero(Bin, Handler, Acc, Stack, Config) -> finish_number(Bin, Handler, {zero, Acc}, Stack, Config). - integer(<>, Handler, Acc, Stack, Config) when S =:= ?zero; ?is_nonzero(S) -> integer(Rest, Handler, acc_seq(Acc, S), Stack, Config); integer(<>, Handler, Acc, Stack, Config) -> @@ -332,13 +333,11 @@ integer(<>, Handler, Acc, Stack, Config) when S =:= $e; S =:= $E integer(Bin, Handler, Acc, Stack, Config) -> finish_number(Bin, Handler, {integer, Acc}, Stack, Config). - initialdecimal(<>, Handler, Acc, Stack, Config) when S =:= ?zero; ?is_nonzero(S) -> decimal(Rest, Handler, acc_seq(Acc, S), Stack, Config); initialdecimal(_Bin, _Handler, _Acc, _Stack, _Config) -> erlang:error(badarg). - decimal(<>, Handler, Acc, Stack, Config) when S =:= ?zero; ?is_nonzero(S) -> decimal(Rest, Handler, acc_seq(Acc, S), Stack, Config); decimal(<>, Handler, Acc, Stack, Config) when S =:= $e; S =:= $E -> @@ -346,7 +345,6 @@ decimal(<>, Handler, Acc, Stack, Config) when S =:= $e; S =:= $E decimal(Bin, Handler, Acc, Stack, Config) -> finish_number(Bin, Handler, {decimal, Acc}, Stack, Config). - e(<>, Handler, Acc, Stack, Config) when S =:= ?zero; ?is_nonzero(S) -> exp(Rest, Handler, acc_seq(Acc, S), Stack, Config); e(<>, Handler, Acc, Stack, Config) when Sign =:= ?positive; Sign =:= ?negative -> @@ -354,66 +352,59 @@ e(<>, Handler, Acc, Stack, Config) when Sign =:= ?positive; S e(_Bin, _Handler, _Acc, _Stack, _Config) -> erlang:error(badarg). - ex(<>, Handler, Acc, Stack, Config) when S =:= ?zero; ?is_nonzero(S) -> exp(Rest, Handler, acc_seq(Acc, S), Stack, Config); ex(_Bin, _Handler, _Acc, _Stack, _Config) -> erlang:error(badarg). - exp(<>, Handler, Acc, Stack, Config) when S =:= ?zero; ?is_nonzero(S) -> exp(Rest, Handler, acc_seq(Acc, S), Stack, Config); exp(Bin, Handler, Acc, Stack, Config) -> finish_number(Bin, Handler, {exp, Acc}, Stack, Config). - finish_number(Rest, Handler, Acc, [], Config) -> maybe_done(Rest, handle_event(format_number(Acc), Handler, Config), [], Config); finish_number(Rest, Handler, Acc, Stack, Config) -> maybe_done(Rest, handle_event(format_number(Acc), Handler, Config), Stack, Config). - format_number({zero, Acc}) -> {integer, list_to_integer(lists:reverse(Acc))}; format_number({integer, Acc}) -> {integer, list_to_integer(lists:reverse(Acc))}; format_number({decimal, Acc}) -> {float, list_to_float(lists:reverse(Acc))}; format_number({exp, Acc}) -> {float, list_to_float(lists:reverse(Acc))}. - true(<<$r, $u, $e, Rest/binary>>, Handler, Stack, Config) -> maybe_done(Rest, handle_event({literal, true}, Handler, Config), Stack, Config); true(_Bin, _Handler, _Stack, _Config) -> erlang:error(badarg). - false(<<$a, $l, $s, $e, Rest/binary>>, Handler, Stack, Config) -> maybe_done(Rest, handle_event({literal, false}, Handler, Config), Stack, Config); false(_Bin, _Handler, _Stack, _Config) -> erlang:error(badarg). - null(<<$u, $l, $l, Rest/binary>>, Handler, Stack, Config) -> maybe_done(Rest, handle_event({literal, null}, Handler, Config), Stack, Config); null(_Bin, _Handler, _Stack, _Config) -> erlang:error(badarg). - maybe_done(<>, Handler, [], Config) -> done(Rest, handle_event(end_json, Handler, Config), [], Config); -maybe_done(<>, Handler, [object|Stack], Config) -> +maybe_done(<>, Handler, [object | Stack], Config) -> maybe_done(Rest, handle_event(end_object, Handler, Config), Stack, Config); -maybe_done(<>, Handler, [array|Stack], Config) -> +maybe_done(<>, Handler, [array | Stack], Config) -> maybe_done(Rest, handle_event(end_array, Handler, Config), Stack, Config); -maybe_done(<>, Handler, [object|Stack], Config) -> - key(Rest, Handler, [key|Stack], Config); -maybe_done(<>, Handler, [array|_] = Stack, Config) -> +maybe_done(<>, Handler, [object | Stack], Config) -> + key(Rest, Handler, [key | Stack], Config); +maybe_done(<>, Handler, [array | _] = Stack, Config) -> value(Rest, Handler, Stack, Config); maybe_done(<>, Handler, Stack, Config) when ?is_whitespace(S) -> maybe_done(Rest, Handler, Stack, Config); maybe_done(_Bin, _Handler, _Stack, _Config) -> erlang:error(badarg). - done(<>, Handler, [], Config) when ?is_whitespace(S) -> done(Rest, Handler, [], Config); -done(<<>>, {_Handler, State}, [], _Config) -> State; -done(_Bin, _Handler, _Stack, _Config) -> erlang:error(badarg). +done(<<>>, {_Handler, State}, [], _Config) -> + State; +done(_Bin, _Handler, _Stack, _Config) -> + erlang:error(badarg). diff --git a/lib/erl/src/thrift_json_protocol.erl b/lib/erl/src/thrift_json_protocol.erl index c5f3da83839..b0a3918271c 100644 --- a/lib/erl/src/thrift_json_protocol.erl +++ b/lib/erl/src/thrift_json_protocol.erl @@ -27,35 +27,38 @@ -include("thrift_constants.hrl"). -include("thrift_protocol.hrl"). --export([new/1, new/2, - read/2, - write/2, - flush_transport/1, - close_transport/1, - new_protocol_factory/2 - ]). +-export([ + new/1, new/2, + read/2, + write/2, + flush_transport/1, + close_transport/1, + new_protocol_factory/2 +]). -record(json_context, { % the type of json_context: array or object - type, + type :: undefined | array | object, % fields read or written - fields_processed = 0 + fields_processed = 0 :: non_neg_integer() }). +-type json_context() :: #json_context{}. +-type jsx_type() :: atom() | {atom(), atom() | string()}. +-type jsx() :: {event, jsx_type(), [jsx_type()]}. + -record(json_protocol, { - transport, - context_stack = [], - jsx + transport :: term(), + context_stack = [] :: [json_context()], + jsx :: undefined | jsx() }). --type state() :: #json_protocol{}. --include("thrift_protocol_behaviour.hrl"). -define(VERSION_1, 1). -define(JSON_DOUBLE_PRECISION, 16). typeid_to_json(?tType_BOOL) -> "tf"; -typeid_to_json(?tType_BYTE) -> "i8"; typeid_to_json(?tType_DOUBLE) -> "dbl"; +% NOTE: ?tType_BYTE also match here typeid_to_json(?tType_I8) -> "i8"; typeid_to_json(?tType_I16) -> "i16"; typeid_to_json(?tType_I32) -> "i32"; @@ -84,28 +87,33 @@ start_context(array) -> "[". end_context(object) -> "}"; end_context(array) -> "]". - new(Transport) -> new(Transport, _Options = []). new(Transport, _Options) -> - State = #json_protocol{transport = Transport}, + State = #json_protocol{transport = Transport}, thrift_protocol:new(?MODULE, State). flush_transport(This = #json_protocol{transport = Transport}) -> {NewTransport, Result} = thrift_transport:flush(Transport), - {This#json_protocol{ + { + This#json_protocol{ transport = NewTransport, context_stack = [] - }, Result}. + }, + Result + }. close_transport(This = #json_protocol{transport = Transport}) -> {NewTransport, Result} = thrift_transport:close(Transport), - {This#json_protocol{ + { + This#json_protocol{ transport = NewTransport, context_stack = [], jsx = undefined - }, Result}. + }, + Result + }. %%% %%% instance methods @@ -113,63 +121,82 @@ close_transport(This = #json_protocol{transport = Transport}) -> % places a new context on the stack: write(#json_protocol{context_stack = Stack} = State0, {enter_context, Type}) -> {State1, ok} = write_values(State0, [{context_pre_item, false}]), - State2 = State1#json_protocol{context_stack = [ - #json_context{type=Type}|Stack]}, - write_values(State2, [list_to_binary(start_context(Type))]); - -% removes the topmost context from stack -write(#json_protocol{context_stack = [CurrCtxt|Stack]} = State0, {exit_context}) -> + State2 = State1#json_protocol{ + context_stack = [ + #json_context{type = Type} | Stack + ] + }, + write_values(State2, [list_to_binary(start_context(Type))]); +% removes the topmost context from stack +write(#json_protocol{context_stack = [CurrCtxt | Stack]} = State0, {exit_context}) -> Type = CurrCtxt#json_context.type, State1 = State0#json_protocol{context_stack = Stack}, write_values(State1, [ - list_to_binary(end_context(Type)), - {context_post_item, false} - ]); - -% writes necessary prelude to field or container depending on current context -write(#json_protocol{context_stack = []} = This0, - {context_pre_item, _}) -> {This0, ok}; -write(#json_protocol{context_stack = [Context|_CtxtTail]} = This0, - {context_pre_item, MayNeedQuotes}) -> + list_to_binary(end_context(Type)), + {context_post_item, false} + ]); +% writes necessary prelude to field or container depending on current context +write( + #json_protocol{context_stack = []} = This0, + {context_pre_item, _} +) -> + {This0, ok}; +write( + #json_protocol{context_stack = [Context | _CtxtTail]} = This0, + {context_pre_item, MayNeedQuotes} +) -> FieldNo = Context#json_context.fields_processed, CtxtType = Context#json_context.type, Rem = FieldNo rem 2, case {CtxtType, FieldNo, Rem, MayNeedQuotes} of - {array, N, _, _} when N > 0 -> % array element (not first) + % array element (not first) + {array, N, _, _} when N > 0 -> write(This0, <<",">>); - {object, 0, _, true} -> % non-string object key (first) + % non-string object key (first) + {object, 0, _, true} -> write(This0, <<"\"">>); - {object, N, 0, true} when N > 0 -> % non-string object key (not first) + % non-string object key (not first) + {object, N, 0, true} when N > 0 -> write(This0, <<",\"">>); - {object, N, 0, false} when N > 0-> % string object key (not first) + % string object key (not first) + {object, N, 0, false} when N > 0 -> write(This0, <<",">>); - _ -> % no pre-field necessary + % no pre-field necessary + _ -> {This0, ok} end; - -% writes necessary postlude to field or container depending on current context -write(#json_protocol{context_stack = []} = This0, - {context_post_item, _}) -> {This0, ok}; -write(#json_protocol{context_stack = [Context|CtxtTail]} = This0, - {context_post_item, MayNeedQuotes}) -> +% writes necessary postlude to field or container depending on current context +write( + #json_protocol{context_stack = []} = This0, + {context_post_item, _} +) -> + {This0, ok}; +write( + #json_protocol{context_stack = [Context | CtxtTail]} = This0, + {context_post_item, MayNeedQuotes} +) -> FieldNo = Context#json_context.fields_processed, CtxtType = Context#json_context.type, Rem = FieldNo rem 2, - {This1, ok} = case {CtxtType, Rem, MayNeedQuotes} of - {object, 0, true} -> % non-string object key - write(This0, <<"\":">>); - {object, 0, false} -> % string object key - write(This0, <<":">>); - _ -> % no pre-field necessary - {This0, ok} - end, + {This1, ok} = + case {CtxtType, Rem, MayNeedQuotes} of + % non-string object key + {object, 0, true} -> + write(This0, <<"\":">>); + % string object key + {object, 0, false} -> + write(This0, <<":">>); + % no pre-field necessary + _ -> + {This0, ok} + end, NewContext = Context#json_context{fields_processed = FieldNo + 1}, - {This1#json_protocol{context_stack=[NewContext|CtxtTail]}, ok}; - + {This1#json_protocol{context_stack = [NewContext | CtxtTail]}, ok}; write(This0, #protocol_message_begin{ name = Name, type = Type, - seqid = Seqid}) -> + seqid = Seqid +}) -> write_values(This0, [ {enter_context, array}, {i32, ?VERSION_1}, @@ -177,15 +204,14 @@ write(This0, #protocol_message_begin{ {i32, Type}, {i32, Seqid} ]); - -write(This, message_end) -> +write(This, message_end) -> write_values(This, [{exit_context}]); - % Example field expression: "1":{"dbl":3.14} write(This0, #protocol_field_begin{ - name = _Name, - type = Type, - id = Id}) -> + name = _Name, + type = Type, + id = Id +}) -> write_values(This0, [ % entering 'outer' object {i16, Id}, @@ -193,18 +219,16 @@ write(This0, #protocol_field_begin{ {enter_context, object}, {string, typeid_to_json(Type)} ]); - -write(This, field_stop) -> +write(This, field_stop) -> {This, ok}; - -write(This, field_end) -> - write_values(This,[{exit_context}]); - +write(This, field_end) -> + write_values(This, [{exit_context}]); % Example message with map: [1,"testMap",1,0,{"1":{"map":["i32","i32",3,{"7":77,"8":88,"9":99}]}}] write(This0, #protocol_map_begin{ - ktype = Ktype, - vtype = Vtype, - size = Size}) -> + ktype = Ktype, + vtype = Vtype, + size = Size +}) -> write_values(This0, [ {enter_context, array}, {string, typeid_to_json(Ktype)}, @@ -212,86 +236,79 @@ write(This0, #protocol_map_begin{ {i32, Size}, {enter_context, object} ]); - -write(This, map_end) -> - write_values(This,[ +write(This, map_end) -> + write_values(This, [ {exit_context}, {exit_context} ]); - write(This0, #protocol_list_begin{ - etype = Etype, - size = Size}) -> + etype = Etype, + size = Size +}) -> write_values(This0, [ {enter_context, array}, {string, typeid_to_json(Etype)}, {i32, Size} ]); - -write(This, list_end) -> - write_values(This,[ +write(This, list_end) -> + write_values(This, [ {exit_context} ]); - % example message with set: [1,"testSet",1,0,{"1":{"set":["i32",3,1,2,3]}}] write(This0, #protocol_set_begin{ - etype = Etype, - size = Size}) -> + etype = Etype, + size = Size +}) -> write_values(This0, [ {enter_context, array}, {string, typeid_to_json(Etype)}, {i32, Size} ]); - -write(This, set_end) -> - write_values(This,[ +write(This, set_end) -> + write_values(This, [ {exit_context} ]); % example message with struct: [1,"testStruct",1,0,{"1":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":1152921504606847000}}}}] -write(This, #protocol_struct_begin{}) -> +write(This, #protocol_struct_begin{}) -> write_values(This, [ {enter_context, object} ]); - -write(This, struct_end) -> - write_values(This,[ +write(This, struct_end) -> + write_values(This, [ {exit_context} ]); - -write(This, {bool, true}) -> write_values(This, [ +write(This, {bool, true}) -> + write_values(This, [ {context_pre_item, true}, <<"true">>, {context_post_item, true} ]); - -write(This, {bool, false}) -> write_values(This, [ +write(This, {bool, false}) -> + write_values(This, [ {context_pre_item, true}, <<"false">>, {context_post_item, true} ]); - -write(This, {byte, Byte}) -> write_values(This, [ +write(This, {byte, Byte}) -> + write_values(This, [ {context_pre_item, true}, list_to_binary(integer_to_list(Byte)), {context_post_item, true} ]); - write(This, {i16, I16}) -> write(This, {byte, I16}); - write(This, {i32, I32}) -> write(This, {byte, I32}); - write(This, {i64, I64}) -> write(This, {byte, I64}); - -write(This, {double, Double}) -> write_values(This, [ +write(This, {double, Double}) -> + write_values(This, [ {context_pre_item, true}, - list_to_binary(io_lib:format("~.*f", [?JSON_DOUBLE_PRECISION,Double])), + list_to_binary(io_lib:format("~.*f", [?JSON_DOUBLE_PRECISION, Double])), {context_post_item, true} ]); - -write(This0, {string, Str}) -> write_values(This0, [ +write(This0, {string, Str}) -> + write_values(This0, [ {context_pre_item, false}, case is_binary(Str) of true -> Str; @@ -299,7 +316,6 @@ write(This0, {string, Str}) -> write_values(This0, [ end, {context_post_item, false} ]); - %% TODO: binary fields should be base64 encoded? %% Data :: iolist() @@ -315,10 +331,11 @@ write_values(This0, ValueList) -> ThisOut end, This0, - ValueList), + ValueList + ), {FinalState, ok}. -%% I wish the erlang version of the transport interface included a +%% I wish the erlang version of the transport interface included a %% read_all function (like eg. the java implementation). Since it doesn't, %% here's my version (even though it probably shouldn't be in this file). %% @@ -327,7 +344,7 @@ write_values(This0, ValueList) -> read_all(#json_protocol{transport = Transport0} = State) -> {Transport1, Bin} = read_all_1(Transport0, []), P = thrift_json_parser:parser(), - [First|Rest] = P(Bin), + [First | Rest] = P(Bin), State#json_protocol{ transport = Transport1, jsx = {event, First, Rest} @@ -336,11 +353,14 @@ read_all(#json_protocol{transport = Transport0} = State) -> read_all_1(Transport0, IoList) -> {Transport1, Result} = thrift_transport:read(Transport0, 1), case Result of - {ok, <<>>} -> % nothing read: assume we're done + % nothing read: assume we're done + {ok, <<>>} -> {Transport1, iolist_to_binary(lists:reverse(IoList))}; - {ok, Data} -> % character successfully read; read more - read_all_1(Transport1, [Data|IoList]); - {error, 'EOF'} -> % we're done + % character successfully read; read more + {ok, Data} -> + read_all_1(Transport1, [Data | IoList]); + % we're done + {error, 'EOF'} -> {Transport1, iolist_to_binary(lists:reverse(IoList))} end. @@ -348,17 +368,16 @@ read_all_1(Transport0, IoList) -> % type as input. Comparing the read event from the one is was passed, it % returns an error if something other than the expected value is encountered. % Expect also maintains the context stack in #json_protocol. -expect(#json_protocol{jsx={event, {Type, Data}=Ev, [Next|Rest]}}=State, ExpectedType) -> - NextState = State#json_protocol{jsx={event, Next, Rest}}, +expect(#json_protocol{jsx = {event, {Type, Data} = Ev, [Next | Rest]}} = State, ExpectedType) -> + NextState = State#json_protocol{jsx = {event, Next, Rest}}, case Type == ExpectedType of - true -> + true -> {NextState, {ok, convert_data(Type, Data)}}; false -> {NextState, {error, {unexpected_json_event, Ev}}} end; - -expect(#json_protocol{jsx={event, Event, Next}}=State, ExpectedEvent) -> - expect(State#json_protocol{jsx={event, {Event, none}, Next}}, ExpectedEvent). +expect(#json_protocol{jsx = {event, Event, Next}} = State, ExpectedEvent) -> + expect(State#json_protocol{jsx = {event, {Event, none}, Next}}, ExpectedEvent). convert_data(integer, I) -> list_to_integer(I); convert_data(float, F) -> list_to_float(F); @@ -369,9 +388,9 @@ expect_many(State, ExpectedList) -> expect_many_1(State, [], ResultList, Status) -> {State, {Status, lists:reverse(ResultList)}}; -expect_many_1(State, [Expected|ExpTail], ResultList, _PrevStatus) -> +expect_many_1(State, [Expected | ExpTail], ResultList, _PrevStatus) -> {State1, {Status, Data}} = expect(State, Expected), - NewResultList = [Data|ResultList], + NewResultList = [Data | ResultList], case Status of % in case of error, end prematurely error -> expect_many_1(State1, [], NewResultList, Status); @@ -381,178 +400,202 @@ expect_many_1(State, [Expected|ExpTail], ResultList, _PrevStatus) -> % wrapper around expect to make life easier for container opening/closing functions expect_nodata(This, ExpectedList) -> case expect_many(This, ExpectedList) of - {State, {ok, _}} -> + {State, {ok, _}} -> {State, ok}; - Error -> + Error -> Error end. -read_field(#json_protocol{jsx={event, Field, [Next|Rest]}} = State) -> - NewState = State#json_protocol{jsx={event, Next, Rest}}, +read_field(#json_protocol{jsx = {event, Field, [Next | Rest]}} = State) -> + NewState = State#json_protocol{jsx = {event, Next, Rest}}, {NewState, Field}. read(This0, message_begin) -> % call read_all to get the contents of the transport buffer into JSX. This1 = read_all(This0), - case expect_many(This1, - [start_array, integer, string, integer, integer]) of + case + expect_many( + This1, + [start_array, integer, string, integer, integer] + ) + of {This2, {ok, [_, Version, Name, Type, SeqId]}} -> case Version =:= ?VERSION_1 of true -> - {This2, #protocol_message_begin{name = Name, - type = Type, - seqid = SeqId}}; + {This2, #protocol_message_begin{ + name = Name, + type = Type, + seqid = SeqId + }}; false -> {This2, {error, no_json_protocol_version}} end; - Other -> Other + Other -> + Other end; - -read(This, message_end) -> +read(This, message_end) -> expect_nodata(This, [end_array]); - -read(This, struct_begin) -> +read(This, struct_begin) -> expect_nodata(This, [start_object]); - -read(This, struct_end) -> +read(This, struct_end) -> expect_nodata(This, [end_object]); - read(This0, field_begin) -> - {This1, Read} = expect_many(This0, - [%field id - key, - % {} surrounding field - start_object, - % type of field - key]), + {This1, Read} = expect_many( + This0, + %field id + [ + key, + % {} surrounding field + start_object, + % type of field + key + ] + ), case Read of {ok, [FieldIdStr, _, FieldType]} -> {This1, #protocol_field_begin{ - type = json_to_typeid(FieldType), - id = list_to_integer(FieldIdStr)}}; % TODO: do we need to wrap this in a try/catch? - {error,[{unexpected_json_event, {end_object,none}}]} -> + type = json_to_typeid(FieldType), + % TODO: do we need to wrap this in a try/catch? + id = list_to_integer(FieldIdStr) + }}; + {error, [{unexpected_json_event, {end_object, none}}]} -> {This1, #protocol_field_begin{type = ?tType_STOP}}; - Other -> + Other -> io:format("**** OTHER branch selected ****"), {This1, Other} end; - -read(This, field_end) -> +read(This, field_end) -> expect_nodata(This, [end_object]); - % Example message with map: [1,"testMap",1,0,{"1":{"map":["i32","i32",3,{"7":77,"8":88,"9":99}]}}] read(This0, map_begin) -> - case expect_many(This0, - [start_array, - % key type - string, - % value type - string, - % size - integer, - % the following object contains the map - start_object]) of + case + expect_many( + This0, + [ + start_array, + % key type + string, + % value type + string, + % size + integer, + % the following object contains the map + start_object + ] + ) + of {This1, {ok, [_, Ktype, Vtype, Size, _]}} -> - {This1, #protocol_map_begin{ktype = Ktype, - vtype = Vtype, - size = Size}}; - Other -> Other + {This1, #protocol_map_begin{ + ktype = Ktype, + vtype = Vtype, + size = Size + }}; + Other -> + Other end; - -read(This, map_end) -> +read(This, map_end) -> expect_nodata(This, [end_object, end_array]); - read(This0, list_begin) -> - case expect_many(This0, - [start_array, - % element type - string, - % size - integer]) of + case + expect_many( + This0, + [ + start_array, + % element type + string, + % size + integer + ] + ) + of {This1, {ok, [_, Etype, Size]}} -> {This1, #protocol_list_begin{ etype = Etype, - size = Size}}; - Other -> Other + size = Size + }}; + Other -> + Other end; - -read(This, list_end) -> +read(This, list_end) -> expect_nodata(This, [end_array]); - % example message with set: [1,"testSet",1,0,{"1":{"set":["i32",3,1,2,3]}}] read(This0, set_begin) -> - case expect_many(This0, - [start_array, - % element type - string, - % size - integer]) of + case + expect_many( + This0, + [ + start_array, + % element type + string, + % size + integer + ] + ) + of {This1, {ok, [_, Etype, Size]}} -> {This1, #protocol_set_begin{ etype = Etype, - size = Size}}; - Other -> Other + size = Size + }}; + Other -> + Other end; - -read(This, set_end) -> +read(This, set_end) -> expect_nodata(This, [end_array]); - read(This0, field_stop) -> {This0, ok}; %% read(This0, bool) -> {This1, Field} = read_field(This0), - Value = case Field of - {literal, I} -> - {ok, I}; - _Other -> - {error, unexpected_event_for_boolean} - end, + Value = + case Field of + {literal, I} -> + {ok, I}; + _Other -> + {error, unexpected_event_for_boolean} + end, {This1, Value}; - read(This0, byte) -> {This1, Field} = read_field(This0), - Value = case Field of - {key, K} -> - {ok, list_to_integer(K)}; - {integer, I} -> - {ok, list_to_integer(I)}; - _Other -> - {error, unexpected_event_for_integer} - end, + Value = + case Field of + {key, K} -> + {ok, list_to_integer(K)}; + {integer, I} -> + {ok, list_to_integer(I)}; + _Other -> + {error, unexpected_event_for_integer} + end, {This1, Value}; - read(This0, i16) -> read(This0, byte); - read(This0, i32) -> read(This0, byte); - read(This0, i64) -> read(This0, byte); - read(This0, double) -> {This1, Field} = read_field(This0), - Value = case Field of - {float, I} -> - {ok, list_to_float(I)}; - _Other -> - {error, unexpected_event_for_double} - end, + Value = + case Field of + {float, I} -> + {ok, list_to_float(I)}; + _Other -> + {error, unexpected_event_for_double} + end, {This1, Value}; - % returns a binary directly, call binary_to_list if necessary read(This0, string) -> {This1, Field} = read_field(This0), - Value = case Field of - {string, I} -> - {ok, I}; - {key, J} -> - {ok, J}; - _Other -> - {error, unexpected_event_for_string} - end, + Value = + case Field of + {string, I} -> + {ok, I}; + {key, J} -> + {ok, J}; + _Other -> + {error, unexpected_event_for_string} + end, {This1, Value}. %%%% FACTORY GENERATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -561,7 +604,7 @@ read(This0, string) -> new_protocol_factory(TransportFactory, _Options) -> % Only strice read/write are implemented F = fun() -> - {ok, Transport} = TransportFactory(), - thrift_json_protocol:new(Transport, []) - end, + {ok, Transport} = TransportFactory(), + thrift_json_protocol:new(Transport, []) + end, {ok, F}. diff --git a/lib/erl/src/thrift_membuffer_transport.erl b/lib/erl/src/thrift_membuffer_transport.erl index be9acb23add..df23b0315b5 100644 --- a/lib/erl/src/thrift_membuffer_transport.erl +++ b/lib/erl/src/thrift_membuffer_transport.erl @@ -22,62 +22,55 @@ -behaviour(thrift_transport). %% constructors --export([new/0, new/1]). +-export([new/0, new/1, new/2]). %% protocol callbacks -export([read/2, read_exact/2, write/2, flush/1, close/1]). - -record(t_membuffer, { - buffer = [] + buffer = [] :: iodata() }). --type state() :: #t_membuffer{}. - - --spec new() -> thrift_transport:t_transport(). +-spec new() -> {ok, thrift_transport:t_transport()}. new() -> new([]). --spec new(Buf::iodata()) -> thrift_transport:t_transport(). - -new(Buf) when is_list(Buf) -> - State = #t_membuffer{buffer = Buf}, - thrift_transport:new(?MODULE, State); -new(Buf) when is_binary(Buf) -> - State = #t_membuffer{buffer = [Buf]}, - thrift_transport:new(?MODULE, State). - - --include("thrift_transport_behaviour.hrl"). - - -read(State = #t_membuffer{buffer = Buf}, Len) -when is_integer(Len), Len >= 0 -> - Binary = iolist_to_binary(Buf), - Give = min(iolist_size(Binary), Len), - {Result, Remaining} = split_binary(Binary, Give), - {State#t_membuffer{buffer = Remaining}, {ok, Result}}. - - -read_exact(State = #t_membuffer{buffer = Buf}, Len) -when is_integer(Len), Len >= 0 -> - Binary = iolist_to_binary(Buf), - case iolist_size(Binary) of - X when X >= Len -> - {Result, Remaining} = split_binary(Binary, Len), - {State#t_membuffer{buffer = Remaining}, {ok, Result}}; - _ -> - {State, {error, eof}} - end. - - -write(State = #t_membuffer{buffer = Buf}, Data) -when is_list(Data); is_binary(Data) -> - {State#t_membuffer{buffer = [Buf, Data]}, ok}. - +-spec new(Buf :: iodata()) -> {ok, thrift_transport:t_transport()}. + +new(Buf) -> + new(Buf, []). + +new(Buf, _Opts) when is_list(Buf) -> + State = #t_membuffer{buffer = Buf}, + thrift_transport:new(?MODULE, State); +new(Buf, _Opts) when is_binary(Buf) -> + State = #t_membuffer{buffer = [Buf]}, + thrift_transport:new(?MODULE, State). + +read(State = #t_membuffer{buffer = Buf}, Len) when + is_integer(Len), Len >= 0 +-> + Binary = iolist_to_binary(Buf), + Give = min(iolist_size(Binary), Len), + {Result, Remaining} = split_binary(Binary, Give), + {State#t_membuffer{buffer = Remaining}, {ok, Result}}. + +read_exact(State = #t_membuffer{buffer = Buf}, Len) when + is_integer(Len), Len >= 0 +-> + Binary = iolist_to_binary(Buf), + case iolist_size(Binary) of + X when X >= Len -> + {Result, Remaining} = split_binary(Binary, Len), + {State#t_membuffer{buffer = Remaining}, {ok, Result}}; + _ -> + {State, {error, eof}} + end. + +write(State = #t_membuffer{buffer = Buf}, Data) when + is_list(Data); is_binary(Data) +-> + {State#t_membuffer{buffer = [Buf, Data]}, ok}. flush(State) -> {State, ok}. - close(State) -> {State, ok}. - diff --git a/lib/erl/src/thrift_memory_buffer.erl b/lib/erl/src/thrift_memory_buffer.erl index 6a59ea56d8f..3007f73c7e5 100644 --- a/lib/erl/src/thrift_memory_buffer.erl +++ b/lib/erl/src/thrift_memory_buffer.erl @@ -28,7 +28,6 @@ %% legacy api -export([new_transport_factory/0]). - %% wrapper around thrift_membuffer_transport for legacy reasons new() -> thrift_membuffer_transport:new(). @@ -44,4 +43,3 @@ read(State, Data) -> thrift_membuffer_transport:read(State, Data). flush(State) -> thrift_membuffer_transport:flush(State). close(State) -> thrift_membuffer_transport:close(State). - diff --git a/lib/erl/src/thrift_multiplexed_map_wrapper.erl b/lib/erl/src/thrift_multiplexed_map_wrapper.erl index 34c5e95f536..706aaf723e1 100644 --- a/lib/erl/src/thrift_multiplexed_map_wrapper.erl +++ b/lib/erl/src/thrift_multiplexed_map_wrapper.erl @@ -20,15 +20,15 @@ -module(thrift_multiplexed_map_wrapper). -export([ - new/0 - ,store/3 - ,find/2 - ,fetch/2 - ]). + new/0, + store/3, + find/2, + fetch/2 +]). --type service_handler() :: nonempty_string(). --type module_() :: atom(). --type service_handler_map() :: [{ServiceHandler::service_handler(), Module::module_()}]. +-type service_handler() :: nonempty_string(). +-type service_handler_map() :: orddict:orddict(service_handler(), [module()]). +-export_type([service_handler_map/0]). -spec new() -> service_handler_map(). new() -> @@ -36,22 +36,22 @@ new() -> -spec store(ServiceHandler, Module, Map) -> NewMap when ServiceHandler :: service_handler(), - Module :: module_(), - Map :: service_handler_map(), - NewMap :: service_handler_map(). + Module :: module(), + Map :: service_handler_map(), + NewMap :: service_handler_map(). store(ServiceHandler, Module, Map) -> orddict:store(ServiceHandler, Module, Map). -spec find(ServiceHandler, Map) -> {ok, Module} | error when ServiceHandler :: service_handler(), - Module :: module_(), - Map :: service_handler_map(). + Module :: module(), + Map :: service_handler_map(). find(ServiceHandler, Map) -> orddict:find(ServiceHandler, Map). -spec fetch(ServiceHandler, Map) -> Module when ServiceHandler :: service_handler(), - Module :: module_(), - Map :: service_handler_map(). + Module :: module(), + Map :: service_handler_map(). fetch(ServiceHandler, Map) -> orddict:fetch(ServiceHandler, Map). diff --git a/lib/erl/src/thrift_multiplexed_protocol.erl b/lib/erl/src/thrift_multiplexed_protocol.erl index 5f7b70c80d0..ddc9475576b 100644 --- a/lib/erl/src/thrift_multiplexed_protocol.erl +++ b/lib/erl/src/thrift_multiplexed_protocol.erl @@ -24,60 +24,91 @@ -include("thrift_constants.hrl"). -include("thrift_protocol.hrl"). --include("thrift_protocol_behaviour.hrl"). +-export([ + new/2, + read/2, + write/2, + flush_transport/1, + close_transport/1 +]). --export([new/2, - read/2, - write/2, - flush_transport/1, - close_transport/1 - ]). - --record(protocol, {module, data}). +-record(protocol, { + module :: module(), + data :: term() +}). -type protocol() :: #protocol{}. --record (multiplexed_protocol, {protocol_module_to_decorate::atom(), - protocol_data_to_decorate::term(), - service_name::nonempty_string()}). - --type state() :: #multiplexed_protocol{}. +-record(multiplexed_protocol, { + protocol_module_to_decorate :: atom(), + protocol_data_to_decorate :: term(), + service_name :: nonempty_string() +}). --spec new(ProtocolToDecorate::protocol(), ServiceName::nonempty_string()) -> {ok, Protocol::protocol()}. -new(ProtocolToDecorate, ServiceName) when is_record(ProtocolToDecorate, protocol), - is_list(ServiceName) -> - State = #multiplexed_protocol{protocol_module_to_decorate = ProtocolToDecorate#protocol.module, - protocol_data_to_decorate = ProtocolToDecorate#protocol.data, - service_name = ServiceName}, +-spec new(ProtocolToDecorate :: protocol(), ServiceName :: nonempty_string()) -> + {ok, Protocol :: protocol()}. +new(ProtocolToDecorate, ServiceName) when + is_record(ProtocolToDecorate, protocol), + is_list(ServiceName) +-> + State = #multiplexed_protocol{ + protocol_module_to_decorate = ProtocolToDecorate#protocol.module, + protocol_data_to_decorate = ProtocolToDecorate#protocol.data, + service_name = ServiceName + }, thrift_protocol:new(?MODULE, State). -flush_transport(State = #multiplexed_protocol{protocol_module_to_decorate = ProtocolModuleToDecorate, - protocol_data_to_decorate = State0}) -> +flush_transport( + State = #multiplexed_protocol{ + protocol_module_to_decorate = ProtocolModuleToDecorate, + protocol_data_to_decorate = State0 + } +) -> {State1, ok} = ProtocolModuleToDecorate:flush_transport(State0), {State#multiplexed_protocol{protocol_data_to_decorate = State1}, ok}. -close_transport(State = #multiplexed_protocol{protocol_module_to_decorate = ProtocolModuleToDecorate, - protocol_data_to_decorate = State0}) -> +close_transport( + State = #multiplexed_protocol{ + protocol_module_to_decorate = ProtocolModuleToDecorate, + protocol_data_to_decorate = State0 + } +) -> {State1, ok} = ProtocolModuleToDecorate:close_transport(State0), {State#multiplexed_protocol{protocol_data_to_decorate = State1}, ok}. -write(State = #multiplexed_protocol{protocol_module_to_decorate = ProtocolModuleToDecorate, - protocol_data_to_decorate = State0, - service_name = ServiceName}, - Message = #protocol_message_begin{name = Name}) -> - {State1, ok} = ProtocolModuleToDecorate:write(State0, - Message#protocol_message_begin{name=ServiceName ++ - ?MULTIPLEXED_SERVICE_SEPARATOR ++ - Name}), +write( + State = #multiplexed_protocol{ + protocol_module_to_decorate = ProtocolModuleToDecorate, + protocol_data_to_decorate = State0, + service_name = ServiceName + }, + Message = #protocol_message_begin{name = Name} +) -> + {State1, ok} = ProtocolModuleToDecorate:write( + State0, + Message#protocol_message_begin{ + name = + ServiceName ++ + ?MULTIPLEXED_SERVICE_SEPARATOR ++ + Name + } + ), {State#multiplexed_protocol{protocol_data_to_decorate = State1}, ok}; - -write(State = #multiplexed_protocol{protocol_module_to_decorate = ProtocolModuleToDecorate, - protocol_data_to_decorate = State0}, - Message) -> +write( + State = #multiplexed_protocol{ + protocol_module_to_decorate = ProtocolModuleToDecorate, + protocol_data_to_decorate = State0 + }, + Message +) -> {State1, ok} = ProtocolModuleToDecorate:write(State0, Message), {State#multiplexed_protocol{protocol_data_to_decorate = State1}, ok}. -read(State = #multiplexed_protocol{protocol_module_to_decorate = ProtocolModuleToDecorate, - protocol_data_to_decorate = State0}, - Message) -> +read( + State = #multiplexed_protocol{ + protocol_module_to_decorate = ProtocolModuleToDecorate, + protocol_data_to_decorate = State0 + }, + Message +) -> {State1, Result} = ProtocolModuleToDecorate:read(State0, Message), {State#multiplexed_protocol{protocol_data_to_decorate = State1}, Result}. diff --git a/lib/erl/src/thrift_processor.erl b/lib/erl/src/thrift_processor.erl index 5c9f26f52a0..e17eadba2fb 100644 --- a/lib/erl/src/thrift_processor.erl +++ b/lib/erl/src/thrift_processor.erl @@ -24,71 +24,101 @@ -include("thrift_constants.hrl"). -include("thrift_protocol.hrl"). --record(thrift_processor, {handler, protocol, service}). +-record(thrift_processor, { + handler :: module(), + protocol :: term(), + service :: atom() +}). init({_Server, ProtoGen, Service, Handler}) when is_function(ProtoGen, 0) -> {ok, Proto} = ProtoGen(), - loop(#thrift_processor{protocol = Proto, - service = Service, - handler = Handler}). - -loop(State0 = #thrift_processor{protocol = Proto0, - handler = Handler, - service = Service}) -> + loop(#thrift_processor{ + protocol = Proto, + service = Service, + handler = Handler + }). +loop( + State0 = #thrift_processor{ + protocol = Proto0, + handler = Handler, + service = Service + } +) -> {Proto1, MessageBegin} = thrift_protocol:read(Proto0, message_begin), State1 = State0#thrift_processor{protocol = Proto1}, ErrorHandler = fun - (HandlerModules) when is_list(HandlerModules) -> thrift_multiplexed_map_wrapper:fetch(?MULTIPLEXED_ERROR_HANDLER_KEY, HandlerModules); - (HandlerModule) -> HandlerModule + (HandlerModules) when is_list(HandlerModules) -> + thrift_multiplexed_map_wrapper:fetch(?MULTIPLEXED_ERROR_HANDLER_KEY, HandlerModules); + (HandlerModule) -> + HandlerModule end, case MessageBegin of - - #protocol_message_begin{name = Function, - type = Type, - seqid = Seqid} when Type =:= ?tMessageType_CALL; Type =:= ?tMessageType_ONEWAY -> + #protocol_message_begin{ + name = Function, + type = Type, + seqid = Seqid + } when Type =:= ?tMessageType_CALL; Type =:= ?tMessageType_ONEWAY -> case string:tokens(Function, ?MULTIPLEXED_SERVICE_SEPARATOR) of [ServiceName, FunctionName] -> - ServiceModule = thrift_multiplexed_map_wrapper:fetch(ServiceName, Service), + ServiceModule = thrift_multiplexed_map_wrapper:fetch(ServiceName, Service), ServiceHandler = thrift_multiplexed_map_wrapper:fetch(ServiceName, Handler), - case handle_function(State1#thrift_processor{service=ServiceModule, handler=ServiceHandler}, list_to_atom(FunctionName), Seqid) of - {State2, ok} -> loop(State2#thrift_processor{service=Service, handler=Handler}); + case + handle_function( + State1#thrift_processor{ + service = ServiceModule, handler = ServiceHandler + }, + list_to_existing_atom(FunctionName), + Seqid + ) + of + {State2, ok} -> + loop(State2#thrift_processor{service = Service, handler = Handler}); {_State2, {error, Reason}} -> - apply(ErrorHandler(Handler), handle_error, [list_to_atom(Function), Reason]), + apply(ErrorHandler(Handler), handle_error, [ + list_to_existing_atom(Function), Reason + ]), thrift_protocol:close_transport(Proto1), ok end; _ -> - case handle_function(State1, list_to_atom(Function), Seqid) of - {State2, ok} -> loop(State2); + case handle_function(State1, list_to_existing_atom(Function), Seqid) of + {State2, ok} -> + loop(State2); {_State2, {error, Reason}} -> - apply(ErrorHandler(Handler), handle_error, [list_to_atom(Function), Reason]), + apply(ErrorHandler(Handler), handle_error, [ + list_to_existing_atom(Function), Reason + ]), thrift_protocol:close_transport(Proto1), ok end end; {error, timeout = Reason} -> - apply(ErrorHandler(Handler), handle_error, [undefined, Reason]), + apply(ErrorHandler(Handler), handle_error, [undefined, Reason]), thrift_protocol:close_transport(Proto1), ok; {error, closed = Reason} -> %% error_logger:info_msg("Client disconnected~n"), - apply(ErrorHandler(Handler), handle_error, [undefined, Reason]), + apply(ErrorHandler(Handler), handle_error, [undefined, Reason]), thrift_protocol:close_transport(Proto1), exit(shutdown); {error, Reason} -> - apply(ErrorHandler(Handler), handle_error, [undefined, Reason]), + apply(ErrorHandler(Handler), handle_error, [undefined, Reason]), thrift_protocol:close_transport(Proto1), exit(shutdown) end. -handle_function(State0=#thrift_processor{protocol = Proto0, - handler = Handler, - service = Service}, - Function, - Seqid) -> +handle_function( + State0 = #thrift_processor{ + protocol = Proto0, + handler = Handler, + service = Service + }, + Function, + Seqid +) -> InParams = Service:function_info(Function, params_type), {Proto1, {ok, Params}} = thrift_protocol:read(Proto0, InParams), @@ -101,55 +131,63 @@ handle_function(State0=#thrift_processor{protocol = Proto0, %% [Function, Params, Micro/1000.0]), handle_success(State1, Function, Result, Seqid) catch - Type:Data when Type =:= throw orelse Type =:= error -> - handle_function_catch(State1, Function, Type, Data, Seqid) + Type:Data:Stack when Type =:= throw orelse Type =:= error -> + handle_function_catch(State1, Function, Type, Data, Seqid, Stack) end. -handle_function_catch(State = #thrift_processor{service = Service}, - Function, ErrType, ErrData, Seqid) -> +handle_function_catch( + State = #thrift_processor{service = Service}, + Function, + ErrType, + ErrData, + Seqid, + Stack +) -> IsOneway = Service:function_info(Function, reply_type) =:= oneway_void, case {ErrType, ErrData} of _ when IsOneway -> - Stack = erlang:get_stacktrace(), error_logger:warning_msg( - "oneway void ~p threw error which must be ignored: ~p", - [Function, {ErrType, ErrData, Stack}]), + "oneway void ~p threw error which must be ignored: ~p", + [Function, {ErrType, ErrData, Stack}] + ), {State, ok}; - {throw, Exception} when is_tuple(Exception), size(Exception) > 0 -> %error_logger:warning_msg("~p threw exception: ~p~n", [Function, Exception]), - handle_exception(State, Function, Exception, Seqid); - % we still want to accept more requests from this client + handle_exception(State, Function, Exception, Seqid, Stack); + % we still want to accept more requests from this client {error, Error} -> - handle_error(State, Function, Error, Seqid) + handle_error(State, Function, Error, Seqid, Stack) end. -handle_success(State = #thrift_processor{service = Service}, - Function, - Result, - Seqid) -> - ReplyType = Service:function_info(Function, reply_type), +handle_success( + State = #thrift_processor{service = Service}, + Function, + Result, + Seqid +) -> + ReplyType = Service:function_info(Function, reply_type), StructName = atom_to_list(Function) ++ "_result", case Result of {reply, ReplyData} -> Reply = {{struct, [{0, ReplyType}]}, {StructName, ReplyData}}, send_reply(State, Function, ?tMessageType_REPLY, Reply, Seqid); - ok when ReplyType == {struct, []} -> send_reply(State, Function, ?tMessageType_REPLY, {ReplyType, {StructName}}, Seqid); - ok when ReplyType == oneway_void -> %% no reply for oneway void {State, ok} end. -handle_exception(State = #thrift_processor{service = Service}, - Function, - Exception, - Seqid) -> +handle_exception( + State = #thrift_processor{service = Service}, + Function, + Exception, + Seqid, + Stack +) -> ExceptionType = element(1, Exception), %% Fetch a structure like {struct, [{-2, {struct, {Module, Type}}}, %% {-3, {struct, {Module, Type}}}]} @@ -161,18 +199,20 @@ handle_exception(State = #thrift_processor{service = Service}, %% Assuming we had a type1 exception, we'd get: [undefined, Exception, undefined] %% e.g.: [{-1, type0}, {-2, type1}, {-3, type2}] - ExceptionList = [case Type of - ExceptionType -> Exception; - _ -> undefined - end - || {_Fid, {struct, {_Module, Type}}} <- XInfo], + ExceptionList = [ + case Type of + ExceptionType -> Exception; + _ -> undefined + end + || {_Fid, {struct, {_Module, Type}}} <- XInfo + ], ExceptionTuple = list_to_tuple([Function | ExceptionList]), - % Make sure we got at least one defined + % Make sure we got at least one defined case lists:all(fun(X) -> X =:= undefined end, ExceptionList) of true -> - handle_unknown_exception(State, Function, Exception, Seqid); + handle_unknown_exception(State, Function, Exception, Seqid, Stack); false -> send_reply(State, Function, ?tMessageType_REPLY, {ReplySpec, ExceptionTuple}, Seqid) end. @@ -181,34 +221,38 @@ handle_exception(State = #thrift_processor{service = Service}, %% Called when an exception has been explicitly thrown by the service, but it was %% not one of the exceptions that was defined for the function. %% -handle_unknown_exception(State, Function, Exception, Seqid) -> - handle_error(State, Function, {exception_not_declared_as_thrown, - Exception}, Seqid). +handle_unknown_exception(State, Function, Exception, Seqid, Stack) -> + handle_error(State, Function, {exception_not_declared_as_thrown, Exception}, Seqid, Stack). -handle_error(State, Function, Error, Seqid) -> - Stack = erlang:get_stacktrace(), +handle_error(State, Function, Error, Seqid, Stack) -> error_logger:error_msg("~p had an error: ~p~n", [Function, {Error, Stack}]), Message = case application:get_env(thrift, exceptions_include_traces) of {ok, true} -> - lists:flatten(io_lib:format("An error occurred: ~p~n", - [{Error, Stack}])); + lists:flatten( + io_lib:format( + "An error occurred: ~p~n", + [{Error, Stack}] + ) + ); _ -> "An unknown handler error occurred." end, - Reply = {?TApplicationException_Structure, - #'TApplicationException'{ - message = Message, - type = ?TApplicationException_UNKNOWN}}, + Reply = + {?TApplicationException_Structure, #'TApplicationException'{ + message = Message, + type = ?TApplicationException_UNKNOWN + }}, send_reply(State, Function, ?tMessageType_EXCEPTION, Reply, Seqid). send_reply(State = #thrift_processor{protocol = Proto0}, Function, ReplyMessageType, Reply, Seqid) -> try {Proto1, ok} = thrift_protocol:write(Proto0, #protocol_message_begin{ - name = atom_to_list(Function), - type = ReplyMessageType, - seqid = Seqid}), + name = atom_to_list(Function), + type = ReplyMessageType, + seqid = Seqid + }), {Proto2, ok} = thrift_protocol:write(Proto1, Reply), {Proto3, ok} = thrift_protocol:write(Proto2, message_end), {Proto4, ok} = thrift_protocol:flush_transport(Proto3), diff --git a/lib/erl/src/thrift_protocol.erl b/lib/erl/src/thrift_protocol.erl index 2fe10d6a25d..c75712ad7d8 100644 --- a/lib/erl/src/thrift_protocol.erl +++ b/lib/erl/src/thrift_protocol.erl @@ -19,45 +19,67 @@ -module(thrift_protocol). --export([new/2, - write/2, - read/2, - read/3, - skip/2, - flush_transport/1, - close_transport/1, - typeid_to_atom/1 - ]). - --export([behaviour_info/1]). +-export([ + new/2, + write/2, + read/2, + read/3, + skip/2, + flush_transport/1, + close_transport/1, + typeid_to_atom/1 +]). -include("thrift_constants.hrl"). -include("thrift_protocol.hrl"). --record(protocol, {module, data}). +-record(protocol, { + module :: module(), + data :: term() +}). + +%%%========================================================================= +%%% API +%%%========================================================================= +-type state() :: term(). +-export_type([state/0]). +-type reason() :: term(). +-export_type([reason/0]). + +%% NOTE: keep this in sync with read/2 spec +-callback read + (state(), {struct, _Info}) -> {state(), {ok, tuple()} | {error, reason()}}; + (state(), tprot_cont_tag()) -> {state(), {ok, any()} | {error, reason()}}; + (state(), tprot_empty_tag()) -> {state(), ok | {error, reason()}}; + (state(), tprot_header_tag()) -> {state(), tprot_header_val() | {error, reason()}}; + (state(), tprot_data_tag()) -> {state(), {ok, any()} | {error, reason()}}. + +-callback write(state(), any()) -> {state(), ok | {error, reason()}}. -behaviour_info(callbacks) -> - [ - {read, 2}, - {write, 2}, - {flush_transport, 1}, - {close_transport, 1} - ]; -behaviour_info(_Else) -> undefined. +-callback flush_transport(state()) -> {state(), ok | {error, reason()}}. +-callback close_transport(state()) -> {state(), ok | {error, reason()}}. new(Module, Data) when is_atom(Module) -> - {ok, #protocol{module = Module, - data = Data}}. + {ok, #protocol{ + module = Module, + data = Data + }}. -spec flush_transport(#protocol{}) -> {#protocol{}, ok}. -flush_transport(Proto = #protocol{module = Module, - data = Data}) -> +flush_transport( + Proto = #protocol{ + module = Module, + data = Data + } +) -> {NewData, Result} = Module:flush_transport(Data), {Proto#protocol{data = NewData}, Result}. -spec close_transport(#protocol{}) -> ok. -close_transport(#protocol{module = Module, - data = Data}) -> +close_transport(#protocol{ + module = Module, + data = Data +}) -> Module:close_transport(Data). typeid_to_atom(?tType_STOP) -> field_stop; @@ -91,103 +113,123 @@ term_to_typeid({list, _}) -> ?tType_LIST. %% Structure is like: %% [{Fid, Type}, ...] -spec read(#protocol{}, {struct, _StructDef}, atom()) -> {#protocol{}, {ok, tuple()}}. -read(IProto0, {struct, Structure}, Tag) - when is_list(Structure), is_atom(Tag) -> - +read(IProto0, {struct, Structure}, Tag) when + is_list(Structure), is_atom(Tag) +-> % If we want a tagged tuple, we need to offset all the tuple indices % by 1 to avoid overwriting the tag. - Offset = if Tag =/= undefined -> 1; true -> 0 end, - IndexList = case length(Structure) of - N when N > 0 -> lists:seq(1 + Offset, N + Offset); - _ -> [] - end, - - SWithIndices = [{Fid, {Type, Index}} || - {{Fid, Type}, Index} <- - lists:zip(Structure, IndexList)], + Offset = + if + Tag =/= undefined -> 1; + true -> 0 + end, + IndexList = + case length(Structure) of + N when N > 0 -> lists:seq(1 + Offset, N + Offset); + _ -> [] + end, + + SWithIndices = [ + {Fid, {Type, Index}} + || {{Fid, Type}, Index} <- + lists:zip(Structure, IndexList) + ], % Fid -> {Type, Index} SDict = dict:from_list(SWithIndices), {IProto1, ok} = read(IProto0, struct_begin), RTuple0 = erlang:make_tuple(length(Structure) + Offset, undefined), - RTuple1 = if Tag =/= undefined -> setelement(1, RTuple0, Tag); - true -> RTuple0 - end, + RTuple1 = + if + Tag =/= undefined -> setelement(1, RTuple0, Tag); + true -> RTuple0 + end, {IProto2, RTuple2} = read_struct_loop(IProto1, SDict, RTuple1), {IProto2, {ok, RTuple2}}. - -%% NOTE: Keep this in sync with thrift_protocol_behaviour:read +%% NOTE: Keep this in sync with read callback -spec read - (#protocol{}, {struct, _Info}) -> {#protocol{}, {ok, tuple()} | {error, _Reason}}; - (#protocol{}, tprot_cont_tag()) -> {#protocol{}, {ok, any()} | {error, _Reason}}; - (#protocol{}, tprot_empty_tag()) -> {#protocol{}, ok | {error, _Reason}}; - (#protocol{}, tprot_header_tag()) -> {#protocol{}, tprot_header_val() | {error, _Reason}}; - (#protocol{}, tprot_data_tag()) -> {#protocol{}, {ok, any()} | {error, _Reason}}. - -read(IProto, {struct, {Module, StructureName}}) when is_atom(Module), - is_atom(StructureName) -> + (#protocol{}, {struct, _Info}) -> {#protocol{}, {ok, tuple()} | {error, _Reason}}; + (#protocol{}, tprot_cont_tag()) -> {#protocol{}, {ok, any()} | {error, _Reason}}; + (#protocol{}, tprot_empty_tag()) -> {#protocol{}, ok | {error, _Reason}}; + (#protocol{}, tprot_header_tag()) -> {#protocol{}, tprot_header_val() | {error, _Reason}}; + (#protocol{}, tprot_data_tag()) -> {#protocol{}, {ok, any()} | {error, _Reason}}. + +read(IProto, {struct, {Module, StructureName}}) when + is_atom(Module), + is_atom(StructureName) +-> read(IProto, Module:struct_info(StructureName), StructureName); - -read(IProto, S={struct, Structure}) when is_list(Structure) -> +read(IProto, S = {struct, Structure}) when is_list(Structure) -> read(IProto, S, undefined); - read(IProto0, {list, Type}) -> {IProto1, #protocol_list_begin{etype = EType, size = Size}} = read(IProto0, list_begin), {EType, EType} = {term_to_typeid(Type), EType}, - {List, IProto2} = lists:mapfoldl(fun(_, ProtoS0) -> - {ProtoS1, {ok, Item}} = read(ProtoS0, Type), - {Item, ProtoS1} - end, - IProto1, - lists:duplicate(Size, 0)), + {List, IProto2} = lists:mapfoldl( + fun(_, ProtoS0) -> + {ProtoS1, {ok, Item}} = read(ProtoS0, Type), + {Item, ProtoS1} + end, + IProto1, + lists:duplicate(Size, 0) + ), {IProto3, ok} = read(IProto2, list_end), {IProto3, {ok, List}}; - read(IProto0, {map, KeyType, ValType}) -> {IProto1, #protocol_map_begin{size = Size, ktype = KType, vtype = VType}} = read(IProto0, map_begin), - _ = case Size of - 0 -> 0; - _ -> - {KType, KType} = {term_to_typeid(KeyType), KType}, - {VType, VType} = {term_to_typeid(ValType), VType} - end, - {List, IProto2} = lists:mapfoldl(fun(_, ProtoS0) -> - {ProtoS1, {ok, Key}} = read(ProtoS0, KeyType), - {ProtoS2, {ok, Val}} = read(ProtoS1, ValType), - {{Key, Val}, ProtoS2} - end, - IProto1, - lists:duplicate(Size, 0)), + _ = + case Size of + 0 -> + 0; + _ -> + {KType, KType} = {term_to_typeid(KeyType), KType}, + {VType, VType} = {term_to_typeid(ValType), VType} + end, + {List, IProto2} = lists:mapfoldl( + fun(_, ProtoS0) -> + {ProtoS1, {ok, Key}} = read(ProtoS0, KeyType), + {ProtoS2, {ok, Val}} = read(ProtoS1, ValType), + {{Key, Val}, ProtoS2} + end, + IProto1, + lists:duplicate(Size, 0) + ), {IProto3, ok} = read(IProto2, map_end), {IProto3, {ok, dict:from_list(List)}}; - read(IProto0, {set, Type}) -> {IProto1, #protocol_set_begin{etype = EType, size = Size}} = read(IProto0, set_begin), {EType, EType} = {term_to_typeid(Type), EType}, - {List, IProto2} = lists:mapfoldl(fun(_, ProtoS0) -> - {ProtoS1, {ok, Item}} = read(ProtoS0, Type), - {Item, ProtoS1} - end, - IProto1, - lists:duplicate(Size, 0)), + {List, IProto2} = lists:mapfoldl( + fun(_, ProtoS0) -> + {ProtoS1, {ok, Item}} = read(ProtoS0, Type), + {Item, ProtoS1} + end, + IProto1, + lists:duplicate(Size, 0) + ), {IProto3, ok} = read(IProto2, set_end), {IProto3, {ok, sets:from_list(List)}}; - read(Protocol, ProtocolType) -> read_specific(Protocol, ProtocolType). -%% NOTE: Keep this in sync with thrift_protocol_behaviour:read +%% NOTE: Keep this in sync with read/2 spec -spec read_specific - (#protocol{}, tprot_empty_tag()) -> {#protocol{}, ok | {error, _Reason}}; - (#protocol{}, tprot_header_tag()) -> {#protocol{}, tprot_header_val() | {error, _Reason}}; - (#protocol{}, tprot_data_tag()) -> {#protocol{}, {ok, any()} | {error, _Reason}}. -read_specific(Proto = #protocol{module = Module, - data = ModuleData}, ProtocolType) -> + (#protocol{}, {struct, _Info}) -> {#protocol{}, {ok, tuple()} | {error, _Reason}}; + (#protocol{}, tprot_cont_tag()) -> {#protocol{}, {ok, any()} | {error, _Reason}}; + (#protocol{}, tprot_empty_tag()) -> {#protocol{}, ok | {error, _Reason}}; + (#protocol{}, tprot_header_tag()) -> {#protocol{}, tprot_header_val() | {error, _Reason}}; + (#protocol{}, tprot_data_tag()) -> {#protocol{}, {ok, any()} | {error, _Reason}}. +read_specific( + Proto = #protocol{ + module = Module, + data = ModuleData + }, + ProtocolType +) -> {NewData, Result} = Module:read(ModuleData, ProtocolType), {Proto#protocol{data = NewData}, Result}. @@ -209,8 +251,9 @@ read_struct_loop(IProto0, SDict, RTuple) -> read_struct_loop(IProto3, SDict, NewRTuple); Expected -> error_logger:info_msg( - "Skipping field ~p with wrong type (~p != ~p)~n", - [Fid, FType, Expected]), + "Skipping field ~p with wrong type (~p != ~p)~n", + [Fid, FType, Expected] + ), skip_field(FType, IProto1, SDict, RTuple) end; _Else2 -> @@ -230,30 +273,25 @@ skip(Proto0, struct) -> {Proto2, ok} = skip_struct_loop(Proto1), {Proto3, ok} = read(Proto2, struct_end), {Proto3, ok}; - skip(Proto0, map) -> {Proto1, Map} = read(Proto0, map_begin), {Proto2, ok} = skip_map_loop(Proto1, Map), {Proto3, ok} = read(Proto2, map_end), {Proto3, ok}; - skip(Proto0, set) -> {Proto1, Set} = read(Proto0, set_begin), {Proto2, ok} = skip_set_loop(Proto1, Set), {Proto3, ok} = read(Proto2, set_end), {Proto3, ok}; - skip(Proto0, list) -> {Proto1, List} = read(Proto0, list_begin), {Proto2, ok} = skip_list_loop(Proto1, List), {Proto3, ok} = read(Proto2, list_end), {Proto3, ok}; - skip(Proto0, Type) when is_atom(Type) -> {Proto1, _Ignore} = read(Proto0, Type), {Proto1, ok}. - skip_struct_loop(Proto0) -> {Proto1, #protocol_field_begin{type = Type}} = read(Proto0, field_begin), case Type of @@ -265,39 +303,62 @@ skip_struct_loop(Proto0) -> skip_struct_loop(Proto3) end. -skip_map_loop(Proto0, Map = #protocol_map_begin{ktype = Ktype, - vtype = Vtype, - size = Size}) -> +skip_map_loop( + Proto0, + Map = #protocol_map_begin{ + ktype = Ktype, + vtype = Vtype, + size = Size + } +) -> case Size of N when N > 0 -> {Proto1, ok} = skip(Proto0, typeid_to_atom(Ktype)), {Proto2, ok} = skip(Proto1, typeid_to_atom(Vtype)), - skip_map_loop(Proto2, - Map#protocol_map_begin{size = Size - 1}); - 0 -> {Proto0, ok} + skip_map_loop( + Proto2, + Map#protocol_map_begin{size = Size - 1} + ); + 0 -> + {Proto0, ok} end. -skip_set_loop(Proto0, Map = #protocol_set_begin{etype = Etype, - size = Size}) -> +skip_set_loop( + Proto0, + Map = #protocol_set_begin{ + etype = Etype, + size = Size + } +) -> case Size of N when N > 0 -> {Proto1, ok} = skip(Proto0, typeid_to_atom(Etype)), - skip_set_loop(Proto1, - Map#protocol_set_begin{size = Size - 1}); - 0 -> {Proto0, ok} + skip_set_loop( + Proto1, + Map#protocol_set_begin{size = Size - 1} + ); + 0 -> + {Proto0, ok} end. -skip_list_loop(Proto0, Map = #protocol_list_begin{etype = Etype, - size = Size}) -> +skip_list_loop( + Proto0, + Map = #protocol_list_begin{ + etype = Etype, + size = Size + } +) -> case Size of N when N > 0 -> {Proto1, ok} = skip(Proto0, typeid_to_atom(Etype)), - skip_list_loop(Proto1, - Map#protocol_list_begin{size = Size - 1}); - 0 -> {Proto0, ok} + skip_list_loop( + Proto1, + Map#protocol_list_begin{size = Size - 1} + ); + 0 -> + {Proto0, ok} end. - %%-------------------------------------------------------------------- %% Function: write(OProto, {Type, Data}) -> ok %% @@ -318,95 +379,112 @@ skip_list_loop(Proto0, Map = #protocol_list_begin{etype = Etype, %%-------------------------------------------------------------------- -spec write(#protocol{}, any()) -> {#protocol{}, ok | {error, _Reason}}. -write(Proto0, {{struct, StructDef}, Data}) - when is_list(StructDef), is_tuple(Data), length(StructDef) == size(Data) - 1 -> - +write(Proto0, {{struct, StructDef}, Data}) when + is_list(StructDef), is_tuple(Data), length(StructDef) == size(Data) - 1 +-> [StructName | Elems] = tuple_to_list(Data), {Proto1, ok} = write(Proto0, #protocol_struct_begin{name = StructName}), {Proto2, ok} = struct_write_loop(Proto1, StructDef, Elems), {Proto3, ok} = write(Proto2, struct_end), {Proto3, ok}; - -write(Proto, {{struct, {Module, StructureName}}, Data}) - when is_atom(Module), - is_atom(StructureName), - element(1, Data) =:= StructureName -> +write(Proto, {{struct, {Module, StructureName}}, Data}) when + is_atom(Module), + is_atom(StructureName), + element(1, Data) =:= StructureName +-> write(Proto, {Module:struct_info(StructureName), Data}); - -write(_, {{struct, {Module, StructureName}}, Data}) - when is_atom(Module), - is_atom(StructureName) -> - erlang:error(struct_unmatched, {{provided, element(1, Data)}, - {expected, StructureName}}); - -write(Proto0, {{list, Type}, Data}) - when is_list(Data) -> - {Proto1, ok} = write(Proto0, - #protocol_list_begin{ - etype = term_to_typeid(Type), - size = length(Data) - }), - Proto2 = lists:foldl(fun(Elem, ProtoIn) -> - {ProtoOut, ok} = write(ProtoIn, {Type, Elem}), - ProtoOut - end, - Proto1, - Data), +write(_, {{struct, {Module, StructureName}}, Data}) when + is_atom(Module), + is_atom(StructureName) +-> + erlang:error(struct_unmatched, {{provided, element(1, Data)}, {expected, StructureName}}); +write(Proto0, {{list, Type}, Data}) when + is_list(Data) +-> + {Proto1, ok} = write( + Proto0, + #protocol_list_begin{ + etype = term_to_typeid(Type), + size = length(Data) + } + ), + Proto2 = lists:foldl( + fun(Elem, ProtoIn) -> + {ProtoOut, ok} = write(ProtoIn, {Type, Elem}), + ProtoOut + end, + Proto1, + Data + ), {Proto3, ok} = write(Proto2, list_end), {Proto3, ok}; - write(Proto0, {{map, KeyType, ValType}, Data}) -> - {Proto1, ok} = write(Proto0, - #protocol_map_begin{ - ktype = term_to_typeid(KeyType), - vtype = term_to_typeid(ValType), - size = dict:size(Data) - }), - Proto2 = dict:fold(fun(KeyData, ValData, ProtoS0) -> - {ProtoS1, ok} = write(ProtoS0, {KeyType, KeyData}), - {ProtoS2, ok} = write(ProtoS1, {ValType, ValData}), - ProtoS2 - end, - Proto1, - Data), + {Proto1, ok} = write( + Proto0, + #protocol_map_begin{ + ktype = term_to_typeid(KeyType), + vtype = term_to_typeid(ValType), + size = dict:size(Data) + } + ), + Proto2 = dict:fold( + fun(KeyData, ValData, ProtoS0) -> + {ProtoS1, ok} = write(ProtoS0, {KeyType, KeyData}), + {ProtoS2, ok} = write(ProtoS1, {ValType, ValData}), + ProtoS2 + end, + Proto1, + Data + ), {Proto3, ok} = write(Proto2, map_end), {Proto3, ok}; - write(Proto0, {{set, Type}, Data}) -> true = sets:is_set(Data), - {Proto1, ok} = write(Proto0, - #protocol_set_begin{ - etype = term_to_typeid(Type), - size = sets:size(Data) - }), - Proto2 = sets:fold(fun(Elem, ProtoIn) -> - {ProtoOut, ok} = write(ProtoIn, {Type, Elem}), - ProtoOut - end, - Proto1, - Data), + {Proto1, ok} = write( + Proto0, + #protocol_set_begin{ + etype = term_to_typeid(Type), + size = sets:size(Data) + } + ), + Proto2 = sets:fold( + fun(Elem, ProtoIn) -> + {ProtoOut, ok} = write(ProtoIn, {Type, Elem}), + ProtoOut + end, + Proto1, + Data + ), {Proto3, ok} = write(Proto2, set_end), {Proto3, ok}; - -write(Proto = #protocol{module = Module, - data = ModuleData}, Data) -> +write( + Proto = #protocol{ + module = Module, + data = ModuleData + }, + Data +) -> {NewData, Result} = Module:write(ModuleData, Data), {Proto#protocol{data = NewData}, Result}. struct_write_loop(Proto0, [{Fid, Type} | RestStructDef], [Data | RestData]) -> - NewProto = case Data of - undefined -> - Proto0; % null fields are skipped in response - _ -> - {Proto1, ok} = write(Proto0, - #protocol_field_begin{ - type = term_to_typeid(Type), - id = Fid - }), - {Proto2, ok} = write(Proto1, {Type, Data}), - {Proto3, ok} = write(Proto2, field_end), - Proto3 - end, + NewProto = + case Data of + undefined -> + % null fields are skipped in response + Proto0; + _ -> + {Proto1, ok} = write( + Proto0, + #protocol_field_begin{ + type = term_to_typeid(Type), + id = Fid + } + ), + {Proto2, ok} = write(Proto1, {Type, Data}), + {Proto3, ok} = write(Proto2, field_end), + Proto3 + end, struct_write_loop(NewProto, RestStructDef, RestData); struct_write_loop(Proto, [], []) -> write(Proto, field_stop). diff --git a/lib/erl/src/thrift_reconnecting_client.erl b/lib/erl/src/thrift_reconnecting_client.erl index 538fd3ad13a..c9fe2aa036a 100644 --- a/lib/erl/src/thrift_reconnecting_client.erl +++ b/lib/erl/src/thrift_reconnecting_client.erl @@ -22,30 +22,36 @@ -behaviour(gen_server). %% API --export([ call/3, - get_stats/1, - get_and_reset_stats/1 ]). +-export([ + call/3, + get_stats/1, + get_and_reset_stats/1 +]). --export([ start_link/6 ]). +-export([start_link/6]). %% gen_server callbacks --export([ init/1, - handle_call/3, - handle_cast/2, - handle_info/2, - terminate/2, - code_change/3 ]). - --record( state, { client = nil, - host, - port, - thrift_svc, - thrift_opts, - reconn_min, - reconn_max, - reconn_time = 0, - op_cnt_dict, - op_time_dict } ). +-export([ + init/1, + handle_call/3, + handle_cast/2, + handle_info/2, + terminate/2, + code_change/3 +]). + +-record(state, { + client = nil, + host, + port, + thrift_svc, + thrift_opts, + reconn_min, + reconn_max, + reconn_time = 0, + op_cnt_dict, + op_time_dict +}). %%==================================================================== %% API @@ -54,23 +60,35 @@ %% Function: start_link() -> {ok,Pid} | ignore | {error,Error} %% Description: Starts the server %%-------------------------------------------------------------------- -start_link( Host, Port, - ThriftSvc, ThriftOpts, - ReconnMin, ReconnMax ) -> - gen_server:start_link( ?MODULE, - [ Host, Port, - ThriftSvc, ThriftOpts, - ReconnMin, ReconnMax ], - [] ). - -call( Pid, Op, Args ) -> - gen_server:call( Pid, { call, Op, Args } ). - -get_stats( Pid ) -> - gen_server:call( Pid, get_stats ). - -get_and_reset_stats( Pid ) -> - gen_server:call( Pid, get_and_reset_stats ). +start_link( + Host, + Port, + ThriftSvc, + ThriftOpts, + ReconnMin, + ReconnMax +) -> + gen_server:start_link( + ?MODULE, + [ + Host, + Port, + ThriftSvc, + ThriftOpts, + ReconnMin, + ReconnMax + ], + [] + ). + +call(Pid, Op, Args) -> + gen_server:call(Pid, {call, Op, Args}). + +get_stats(Pid) -> + gen_server:call(Pid, get_stats). + +get_and_reset_stats(Pid) -> + gen_server:call(Pid, get_and_reset_stats). %%==================================================================== %% gen_server callbacks @@ -83,19 +101,21 @@ get_and_reset_stats( Pid ) -> %% {stop, Reason} %% Description: Start the server. %%-------------------------------------------------------------------- -init( [ Host, Port, TSvc, TOpts, ReconnMin, ReconnMax ] ) -> - process_flag( trap_exit, true ), - - State = #state{ host = Host, - port = Port, - thrift_svc = TSvc, - thrift_opts = TOpts, - reconn_min = ReconnMin, - reconn_max = ReconnMax, - op_cnt_dict = dict:new(), - op_time_dict = dict:new() }, - - { ok, try_connect( State ) }. +init([Host, Port, TSvc, TOpts, ReconnMin, ReconnMax]) -> + process_flag(trap_exit, true), + + State = #state{ + host = Host, + port = Port, + thrift_svc = TSvc, + thrift_opts = TOpts, + reconn_min = ReconnMin, + reconn_max = ReconnMax, + op_cnt_dict = dict:new(), + op_time_dict = dict:new() + }, + + {ok, try_connect(State)}. %%-------------------------------------------------------------------- %% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} | @@ -106,40 +126,44 @@ init( [ Host, Port, TSvc, TOpts, ReconnMin, ReconnMax ] ) -> %% {stop, Reason, State} %% Description: Handling call messages %%-------------------------------------------------------------------- -handle_call( { call, Op, _ }, - _From, - State = #state{ client = nil } ) -> - { reply, { error, noconn }, incr_stats( Op, "failfast", 1, State ) }; - -handle_call( { call, Op, Args }, - _From, - State=#state{ client = Client } ) -> - - Timer = timer_fun(), - Result = ( catch thrift_client:call( Client, Op, Args) ), - Time = Timer(), - - case Result of - { C, { ok, Reply } } -> - S = incr_stats( Op, "success", Time, State#state{ client = C } ), - { reply, {ok, Reply }, S }; - { _, { E, Msg } } when E == error; E == exception -> - S = incr_stats( Op, "error", Time, try_connect( State ) ), - { reply, { E, Msg }, S }; - Other -> - S = incr_stats( Op, "error", Time, try_connect( State ) ), - { reply, Other, S } - end; - -handle_call( get_stats, - _From, - State = #state{} ) -> - { reply, stats( State ), State }; - -handle_call( get_and_reset_stats, - _From, - State = #state{} ) -> - { reply, stats( State ), reset_stats( State ) }. +handle_call( + {call, Op, _}, + _From, + State = #state{client = nil} +) -> + {reply, {error, noconn}, incr_stats(Op, "failfast", 1, State)}; +handle_call( + {call, Op, Args}, + _From, + State = #state{client = Client} +) -> + Timer = timer_fun(), + Result = (catch thrift_client:call(Client, Op, Args)), + Time = Timer(), + + case Result of + {C, {ok, Reply}} -> + S = incr_stats(Op, "success", Time, State#state{client = C}), + {reply, {ok, Reply}, S}; + {_, {E, Msg}} when E == error; E == exception -> + S = incr_stats(Op, "error", Time, try_connect(State)), + {reply, {E, Msg}, S}; + Other -> + S = incr_stats(Op, "error", Time, try_connect(State)), + {reply, Other, S} + end; +handle_call( + get_stats, + _From, + State = #state{} +) -> + {reply, stats(State), State}; +handle_call( + get_and_reset_stats, + _From, + State = #state{} +) -> + {reply, stats(State), reset_stats(State)}. %%-------------------------------------------------------------------- %% Function: handle_cast(Msg, State) -> {noreply, State} | @@ -147,8 +171,8 @@ handle_call( get_and_reset_stats, %% {stop, Reason, State} %% Description: Handling cast messages %%-------------------------------------------------------------------- -handle_cast( _Msg, State ) -> - { noreply, State }. +handle_cast(_Msg, State) -> + {noreply, State}. %%-------------------------------------------------------------------- %% Function: handle_info(Info, State) -> {noreply, State} | @@ -156,11 +180,10 @@ handle_cast( _Msg, State ) -> %% {stop, Reason, State} %% Description: Handling all non call/cast messages %%-------------------------------------------------------------------- -handle_info( try_connect, State ) -> - { noreply, try_connect( State ) }; - -handle_info( _Info, State ) -> - { noreply, State }. +handle_info(try_connect, State) -> + {noreply, try_connect(State)}; +handle_info(_Info, State) -> + {noreply, State}. %%-------------------------------------------------------------------- %% Function: terminate(Reason, State) -> void() @@ -169,90 +192,103 @@ handle_info( _Info, State ) -> %% cleaning up. When it returns, the gen_server terminates with Reason. %% The return value is ignored. %%-------------------------------------------------------------------- -terminate( _Reason, #state{ client = Client } ) -> - thrift_client:close( Client ), - ok. +terminate(_Reason, #state{client = Client}) -> + thrift_client:close(Client), + ok. %%-------------------------------------------------------------------- %% Func: code_change(OldVsn, State, Extra) -> {ok, NewState} %% Description: Convert process state when code is changed %%-------------------------------------------------------------------- -code_change( _OldVsn, State, _Extra ) -> - { ok, State }. +code_change(_OldVsn, State, _Extra) -> + {ok, State}. %%-------------------------------------------------------------------- %%% Internal functions %%-------------------------------------------------------------------- -try_connect( State = #state{ client = OldClient, - host = Host, - port = Port, - thrift_svc = TSvc, - thrift_opts = TOpts } ) -> - - case OldClient of - nil -> ok; - _ -> ( catch thrift_client:close( OldClient ) ) - end, - - case catch thrift_client_util:new( Host, Port, TSvc, TOpts ) of - { ok, Client } -> - State#state{ client = Client, reconn_time = 0 }; - { E, Msg } when E == error; E == exception -> - ReconnTime = reconn_time( State ), - error_logger:error_msg( "[~w] ~w connect failed (~w), trying again in ~w ms~n", - [ self(), TSvc, Msg, ReconnTime ] ), - erlang:send_after( ReconnTime, self(), try_connect ), - State#state{ client = nil, reconn_time = ReconnTime } - end. - - -reconn_time( #state{ reconn_min = ReconnMin, reconn_time = 0 } ) -> - ReconnMin; -reconn_time( #state{ reconn_max = ReconnMax, reconn_time = ReconnMax } ) -> - ReconnMax; -reconn_time( #state{ reconn_max = ReconnMax, reconn_time = R } ) -> - Backoff = 2 * R, - case Backoff > ReconnMax of - true -> ReconnMax; - false -> Backoff - end. +try_connect( + State = #state{ + client = OldClient, + host = Host, + port = Port, + thrift_svc = TSvc, + thrift_opts = TOpts + } +) -> + case OldClient of + nil -> ok; + _ -> (catch thrift_client:close(OldClient)) + end, + + case catch thrift_client_util:new(Host, Port, TSvc, TOpts) of + {ok, Client} -> + State#state{client = Client, reconn_time = 0}; + {E, Msg} when E == error; E == exception -> + ReconnTime = reconn_time(State), + error_logger:error_msg( + "[~w] ~w connect failed (~w), trying again in ~w ms~n", + [self(), TSvc, Msg, ReconnTime] + ), + erlang:send_after(ReconnTime, self(), try_connect), + State#state{client = nil, reconn_time = ReconnTime} + end. + +reconn_time(#state{reconn_min = ReconnMin, reconn_time = 0}) -> + ReconnMin; +reconn_time(#state{reconn_max = ReconnMax, reconn_time = ReconnMax}) -> + ReconnMax; +reconn_time(#state{reconn_max = ReconnMax, reconn_time = R}) -> + Backoff = 2 * R, + case Backoff > ReconnMax of + true -> ReconnMax; + false -> Backoff + end. -ifdef(time_correction). timer_fun() -> - T1 = erlang:monotonic_time(), - fun() -> - T2 = erlang:monotonic_time(), - erlang:convert_time_unit(T2 - T1, native, micro_seconds) - end. + T1 = erlang:monotonic_time(), + fun() -> + T2 = erlang:monotonic_time(), + erlang:convert_time_unit(T2 - T1, native, micro_seconds) + end. -else. timer_fun() -> - T1 = erlang:timestamp(), - fun() -> - T2 = erlang:timestamp(), - timer:now_diff(T2, T1) - end. + T1 = erlang:timestamp(), + fun() -> + T2 = erlang:timestamp(), + timer:now_diff(T2, T1) + end. -endif. -incr_stats( Op, Result, Time, - State = #state{ op_cnt_dict = OpCntDict, - op_time_dict = OpTimeDict } ) -> - Key = lists:flatten( [ atom_to_list( Op ), [ "_" | Result ] ] ), - State#state{ op_cnt_dict = dict:update_counter( Key, 1, OpCntDict ), - op_time_dict = dict:update_counter( Key, Time, OpTimeDict ) }. - - -stats( #state{ thrift_svc = TSvc, - op_cnt_dict = OpCntDict, - op_time_dict = OpTimeDict } ) -> - Svc = atom_to_list(TSvc), - - F = fun( Key, Count, Stats ) -> - Name = lists:flatten( [ Svc, [ "_" | Key ] ] ), - Micros = dict:fetch( Key, OpTimeDict ), - [ { Name, Count, Micros } | Stats ] - end, - - dict:fold( F, [], OpCntDict ). - -reset_stats( State = #state{} ) -> - State#state{ op_cnt_dict = dict:new(), op_time_dict = dict:new() }. +incr_stats( + Op, + Result, + Time, + State = #state{ + op_cnt_dict = OpCntDict, + op_time_dict = OpTimeDict + } +) -> + Key = lists:flatten([atom_to_list(Op), ["_" | Result]]), + State#state{ + op_cnt_dict = dict:update_counter(Key, 1, OpCntDict), + op_time_dict = dict:update_counter(Key, Time, OpTimeDict) + }. + +stats(#state{ + thrift_svc = TSvc, + op_cnt_dict = OpCntDict, + op_time_dict = OpTimeDict +}) -> + Svc = atom_to_list(TSvc), + + F = fun(Key, Count, Stats) -> + Name = lists:flatten([Svc, ["_" | Key]]), + Micros = dict:fetch(Key, OpTimeDict), + [{Name, Count, Micros} | Stats] + end, + + dict:fold(F, [], OpCntDict). + +reset_stats(State = #state{}) -> + State#state{op_cnt_dict = dict:new(), op_time_dict = dict:new()}. diff --git a/lib/erl/src/thrift_server.erl b/lib/erl/src/thrift_server.erl index 5012e168f6a..e97acff93eb 100644 --- a/lib/erl/src/thrift_server.erl +++ b/lib/erl/src/thrift_server.erl @@ -25,12 +25,23 @@ -export([start_link/3, stop/1, take_socket/2]). %% gen_server callbacks --export([init/1, handle_call/3, handle_cast/2, handle_info/2, - terminate/2, code_change/3]). +-export([ + init/1, + handle_call/3, + handle_cast/2, + handle_info/2, + terminate/2, + code_change/3 +]). -define(SERVER, ?MODULE). --record(state, {listen_socket, acceptor_ref, service, handler}). +-record(state, { + listen_socket :: gen_tcp:socket(), + acceptor_ref :: term(), + service :: module(), + handler :: module() +}). %%==================================================================== %% API @@ -49,11 +60,9 @@ start_link(Port, Service, HandlerModule) when is_integer(Port), is_atom(HandlerM stop(Pid) when is_pid(Pid) -> gen_server:call(Pid, stop). - take_socket(Server, Socket) -> gen_server:call(Server, {take_socket, Socket}). - %%==================================================================== %% gen_server callbacks %%==================================================================== @@ -66,17 +75,23 @@ take_socket(Server, Socket) -> %% Description: Initiates the server %%-------------------------------------------------------------------- init({Port, Service, Handler}) -> - {ok, Socket} = gen_tcp:listen(Port, - [binary, - {packet, 0}, - {active, false}, - {nodelay, true}, - {reuseaddr, true}]), + {ok, Socket} = gen_tcp:listen( + Port, + [ + binary, + {packet, 0}, + {active, false}, + {nodelay, true}, + {reuseaddr, true} + ] + ), {ok, Ref} = prim_inet:async_accept(Socket, -1), - {ok, #state{listen_socket = Socket, - acceptor_ref = Ref, - service = Service, - handler = Handler}}. + {ok, #state{ + listen_socket = Socket, + acceptor_ref = Ref, + service = Service, + handler = Handler + }}. %%-------------------------------------------------------------------- %% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} | @@ -89,7 +104,6 @@ init({Port, Service, Handler}) -> %%-------------------------------------------------------------------- handle_call(stop, _From, State) -> {stop, stopped, ok, State}; - handle_call({take_socket, Socket}, {FromPid, _Tag}, State) -> Result = gen_tcp:controlling_process(Socket, FromPid), {reply, Result, State}. @@ -109,11 +123,15 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% Description: Handling all non call/cast messages %%-------------------------------------------------------------------- -handle_info({inet_async, ListenSocket, Ref, {ok, ClientSocket}}, - State = #state{listen_socket = ListenSocket, - acceptor_ref = Ref, - service = Service, - handler = Handler}) -> +handle_info( + {inet_async, ListenSocket, Ref, {ok, ClientSocket}}, + State = #state{ + listen_socket = ListenSocket, + acceptor_ref = Ref, + service = Service, + handler = Handler + } +) -> case set_sockopt(ListenSocket, ClientSocket) of ok -> %% New client connected - start processor @@ -121,15 +139,15 @@ handle_info({inet_async, ListenSocket, Ref, {ok, ClientSocket}}, {ok, NewRef} = prim_inet:async_accept(ListenSocket, -1), {noreply, State#state{acceptor_ref = NewRef}}; {error, Reason} -> - error_logger:error_msg("Couldn't set socket opts: ~p~n", - [Reason]), + error_logger:error_msg( + "Couldn't set socket opts: ~p~n", + [Reason] + ), {stop, Reason, State} end; - handle_info({inet_async, _ListenSocket, _Ref, Error}, State) -> error_logger:error_msg("Error in acceptor: ~p~n", [Error]), {stop, Error, State}; - handle_info(_Info, State) -> {noreply, State}. @@ -155,13 +173,19 @@ code_change(_OldVsn, State, _Extra) -> %%-------------------------------------------------------------------- set_sockopt(ListenSocket, ClientSocket) -> true = inet_db:register_socket(ClientSocket, inet_tcp), - case prim_inet:getopts(ListenSocket, - [active, nodelay, keepalive, delay_send, priority, tos]) of + case + prim_inet:getopts( + ListenSocket, + [active, nodelay, keepalive, delay_send, priority, tos] + ) + of {ok, Opts} -> case prim_inet:setopts(ClientSocket, Opts) of - ok -> ok; - Error -> gen_tcp:close(ClientSocket), - Error + ok -> + ok; + Error -> + gen_tcp:close(ClientSocket), + Error end; Error -> gen_tcp:close(ClientSocket), @@ -172,12 +196,12 @@ start_processor(Socket, Service, Handler) -> Server = self(), ProtoGen = fun() -> - % Become the controlling process - ok = take_socket(Server, Socket), - {ok, SocketTransport} = thrift_socket_transport:new(Socket), - {ok, BufferedTransport} = thrift_buffered_transport:new(SocketTransport), - {ok, Protocol} = thrift_binary_protocol:new(BufferedTransport), - {ok, Protocol} - end, + % Become the controlling process + ok = take_socket(Server, Socket), + {ok, SocketTransport} = thrift_socket_transport:new(Socket), + {ok, BufferedTransport} = thrift_buffered_transport:new(SocketTransport), + {ok, Protocol} = thrift_binary_protocol:new(BufferedTransport), + {ok, Protocol} + end, spawn(thrift_processor, init, [{Server, ProtoGen, Service, Handler}]). diff --git a/lib/erl/src/thrift_service.erl b/lib/erl/src/thrift_service.erl index 2ed7b57b0e5..50241029782 100644 --- a/lib/erl/src/thrift_service.erl +++ b/lib/erl/src/thrift_service.erl @@ -19,7 +19,9 @@ -module(thrift_service). --export([behaviour_info/1]). +%%%========================================================================= +%%% API +%%%========================================================================= -behaviour_info(callbacks) -> - [{function_info, 2}]. +%% TODO Replace response with type +-callback function_info(atom(), atom()) -> {struct, term()}. diff --git a/lib/erl/src/thrift_socket_server.erl b/lib/erl/src/thrift_socket_server.erl index 432e65b563e..abeee8198a9 100644 --- a/lib/erl/src/thrift_socket_server.erl +++ b/lib/erl/src/thrift_socket_server.erl @@ -21,40 +21,51 @@ -behaviour(gen_server). --include ("thrift_constants.hrl"). +-include("thrift_constants.hrl"). + +-export([start/1, stop/1]). +-export([ + init/1, + handle_call/3, + handle_cast/2, + terminate/2, + code_change/3, + handle_info/2 +]). +-export([acceptor_loop/1]). -ifdef(TEST). - -compile(export_all). - -export_records([thrift_socket_server]). --else. - -export([start/1, stop/1]). +-export([parse_options/1]). +-endif. - -export([init/1, handle_call/3, handle_cast/2, terminate/2, code_change/3, - handle_info/2]). +-type protocol() :: + compact + | {compact, term()} + | json + | {json, term()} + | binary + | {binary | term()} + | {custom, module(), term()}. - -export([acceptor_loop/1]). --endif. +-type socket_opts() :: [inet:inet_backend() | gen_tcp:listen_option()]. +-type ssl_opts() :: [ssl:tls_server_option()]. --record(thrift_socket_server, - {port, - service, - handler, - name, - max=2048, - ip=any, - listen=null, - acceptor=null, - socket_opts=[{recv_timeout, 500}], - protocol=binary, - framed=false, - ssltransport=false, - ssloptions=[] - }). +-record(thrift_socket_server, { + port :: inet:port_number(), + service :: thrift_multiplexed_map_wrapper:service_handler_map(), + handler :: thrift_multiplexed_map_wrapper:service_handler_map(), + acceptors_left :: non_neg_integer(), + listen :: gen_tcp:socket(), + acceptor :: undefined | pid(), + socket_opts :: socket_opts(), + protocol :: protocol(), + framed :: boolean(), + ssltransport :: boolean(), + ssloptions :: ssl_opts() +}). -start(State=#thrift_socket_server{}) -> - start_server(State); start(Options) -> - start(parse_options(Options)). + start_server(parse_options(Options)). stop(Name) when is_atom(Name) -> gen_server:cast(Name, stop); @@ -65,259 +76,300 @@ stop({local, Name}) -> stop({global, Name}) -> stop(Name); stop(Options) -> - State = parse_options(Options), - stop(State#thrift_socket_server.name). + #{name := Name} = parse_options(Options), + stop(Name). %% Internal API parse_options(Options) -> - parse_options(Options, #thrift_socket_server{}). + parse_options(Options, #{}). parse_options([], State) -> State; parse_options([{name, L} | Rest], State) when is_list(L) -> Name = {local, list_to_atom(L)}, - parse_options(Rest, State#thrift_socket_server{name=Name}); + parse_options(Rest, State#{name => Name}); parse_options([{name, A} | Rest], State) when is_atom(A) -> Name = {local, A}, - parse_options(Rest, State#thrift_socket_server{name=Name}); + parse_options(Rest, State#{name => Name}); parse_options([{name, Name} | Rest], State) -> - parse_options(Rest, State#thrift_socket_server{name=Name}); + parse_options(Rest, State#{name => Name}); parse_options([{port, L} | Rest], State) when is_list(L) -> Port = list_to_integer(L), - parse_options(Rest, State#thrift_socket_server{port=Port}); -parse_options([{port, Port} | Rest], State) -> - parse_options(Rest, State#thrift_socket_server{port=Port}); + parse_options(Rest, State#{port => Port}); +parse_options([{port, Port} | Rest], State) when is_integer(Port), Port >= 0, Port =< 65535 -> + parse_options(Rest, State#{port => Port}); parse_options([{ip, Ip} | Rest], State) -> - ParsedIp = case Ip of - any -> - any; - Ip when is_tuple(Ip) -> - Ip; - Ip when is_list(Ip) -> - {ok, IpTuple} = inet_parse:address(Ip), - IpTuple - end, - parse_options(Rest, State#thrift_socket_server{ip=ParsedIp}); + case Ip of + any -> + parse_options(Rest, State); + Ip when is_tuple(Ip) -> + parse_options(Rest, State#{ip => Ip}); + Ip when is_list(Ip) -> + {ok, IpTuple} = inet_parse:address(Ip), + parse_options(Rest, State#{ip => IpTuple}) + end; parse_options([{socket_opts, L} | Rest], State) when is_list(L), length(L) > 0 -> - parse_options(Rest, State#thrift_socket_server{socket_opts=L}); - + parse_options(Rest, State#{socket_opts => L}); parse_options([{handler, []} | _Rest], _State) -> throw("At least an error handler must be defined."); -parse_options([{handler, ServiceHandlerPropertyList} | Rest], State) when is_list(ServiceHandlerPropertyList) -> +parse_options([{handler, ServiceHandlerPropertyList} | Rest], State) when + is_list(ServiceHandlerPropertyList) +-> ServiceHandlerMap = - case State#thrift_socket_server.handler of - undefined -> - lists:foldl( - fun ({ServiceName, ServiceHandler}, Acc) when is_list(ServiceName), is_atom(ServiceHandler) -> - thrift_multiplexed_map_wrapper:store(ServiceName, ServiceHandler, Acc); - (_, _Acc) -> - throw("The handler option is not properly configured for multiplexed services. It should be a kind of [{\"error_handler\", Module::atom()}, {SericeName::list(), Module::atom()}, ...]") - end, thrift_multiplexed_map_wrapper:new(), ServiceHandlerPropertyList); - _ -> throw("Error while parsing the handler option.") - end, + case maps:get(handler, State, undefined) of + undefined -> + lists:foldl( + fun + ({ServiceName, ServiceHandler}, Acc) when + is_list(ServiceName), is_atom(ServiceHandler) + -> + thrift_multiplexed_map_wrapper:store(ServiceName, ServiceHandler, Acc); + (_, _Acc) -> + throw( + "The handler option is not properly configured for multiplexed services. It should be a kind of [{\"error_handler\", Module::atom()}, {SericeName::list(), Module::atom()}, ...]" + ) + end, + thrift_multiplexed_map_wrapper:new(), + ServiceHandlerPropertyList + ); + _ -> + throw("Error while parsing the handler option.") + end, case thrift_multiplexed_map_wrapper:find(?MULTIPLEXED_ERROR_HANDLER_KEY, ServiceHandlerMap) of - {ok, _ErrorHandler} -> parse_options(Rest, State#thrift_socket_server{handler=ServiceHandlerMap}); - error -> throw("The handler option is not properly configured for multiplexed services. It should be a kind of [{\"error_handler\", Module::atom()}, {SericeName::list(), Module::atom()}, ...]") + {ok, _ErrorHandler} -> + parse_options(Rest, State#{handler => ServiceHandlerMap}); + error -> + throw( + "The handler option is not properly configured for multiplexed services. It should be a kind of [{\"error_handler\", Module::atom()}, {SericeName::list(), Module::atom()}, ...]" + ) end; -parse_options([{handler, Handler} | Rest], State) when State#thrift_socket_server.handler == undefined, is_atom(Handler) -> - parse_options(Rest, State#thrift_socket_server{handler=Handler}); - +parse_options([{handler, Handler} | Rest], State) when + not is_map_key(handler, State), is_atom(Handler) +-> + parse_options(Rest, State#{handler => Handler}); parse_options([{service, []} | _Rest], _State) -> throw("At least one service module must be defined."); -parse_options([{service, ServiceModulePropertyList} | Rest], State) when is_list(ServiceModulePropertyList) -> +parse_options([{service, ServiceModulePropertyList} | Rest], State) when + is_list(ServiceModulePropertyList) +-> ServiceModuleMap = - case State#thrift_socket_server.service of - undefined -> - lists:foldl( - fun ({ServiceName, ServiceModule}, Acc) when is_list(ServiceName), is_atom(ServiceModule) -> - thrift_multiplexed_map_wrapper:store(ServiceName, ServiceModule, Acc); - (_, _Acc) -> - throw("The service option is not properly configured for multiplexed services. It should be a kind of [{SericeName::list(), ServiceModule::atom()}, ...]") - end, thrift_multiplexed_map_wrapper:new(), ServiceModulePropertyList); - _ -> throw("Error while parsing the service option.") - end, - parse_options(Rest, State#thrift_socket_server{service=ServiceModuleMap}); -parse_options([{service, Service} | Rest], State) when State#thrift_socket_server.service == undefined, is_atom(Service) -> - parse_options(Rest, State#thrift_socket_server{service=Service}); - -parse_options([{max, Max} | Rest], State) -> - MaxInt = case Max of - Max when is_list(Max) -> - list_to_integer(Max); - Max when is_integer(Max) -> - Max - end, - parse_options(Rest, State#thrift_socket_server{max=MaxInt}); - + case maps:get(service, State, undefined) of + undefined -> + lists:foldl( + fun + ({ServiceName, ServiceModule}, Acc) when + is_list(ServiceName), is_atom(ServiceModule) + -> + thrift_multiplexed_map_wrapper:store(ServiceName, ServiceModule, Acc); + (_, _Acc) -> + throw( + "The service option is not properly configured for multiplexed services. It should be a kind of [{SericeName::list(), ServiceModule::atom()}, ...]" + ) + end, + thrift_multiplexed_map_wrapper:new(), + ServiceModulePropertyList + ); + _ -> + throw("Error while parsing the service option.") + end, + parse_options(Rest, State#{service => ServiceModuleMap}); +parse_options([{service, Service} | Rest], State) when + not is_map_key(service, State), is_atom(Service) +-> + parse_options(Rest, State#{service => Service}); +parse_options([{max, Max} | Rest], State) when is_integer(Max), Max > 0 -> + parse_options(Rest, State#{max => Max}); parse_options([{protocol, Proto} | Rest], State) when is_atom(Proto) -> - parse_options(Rest, State#thrift_socket_server{protocol=Proto}); - + parse_options(Rest, State#{protocol => Proto}); parse_options([{framed, Framed} | Rest], State) when is_boolean(Framed) -> - parse_options(Rest, State#thrift_socket_server{framed=Framed}); - + parse_options(Rest, State#{framed => Framed}); parse_options([{ssltransport, SSLTransport} | Rest], State) when is_boolean(SSLTransport) -> - parse_options(Rest, State#thrift_socket_server{ssltransport=SSLTransport}); + parse_options(Rest, State#{ssltransport => SSLTransport}); parse_options([{ssloptions, SSLOptions} | Rest], State) when is_list(SSLOptions) -> - parse_options(Rest, State#thrift_socket_server{ssloptions=SSLOptions}). + parse_options(Rest, State#{ssloptions => SSLOptions}). -start_server(State=#thrift_socket_server{name=Name}) -> +start_server(Options = #{name := Name}) -> case Name of undefined -> - gen_server:start_link(?MODULE, State, []); + gen_server:start_link(?MODULE, Options, []); _ -> - gen_server:start_link(Name, ?MODULE, State, []) + gen_server:start_link(Name, ?MODULE, Options, []) end. -init(State=#thrift_socket_server{ip=Ip, port=Port}) -> +init(State = #{port := Port}) -> process_flag(trap_exit, true), - BaseOpts = [binary, - {reuseaddr, true}, - {packet, 0}, - {backlog, 4096}, - {recbuf, 8192}, - {active, false}], - Opts = case Ip of - any -> - BaseOpts; - Ip -> - [{ip, Ip} | BaseOpts] - end, - case gen_tcp_listen(Port, Opts, State) of - {stop, eacces} -> - %% fdsrv module allows another shot to bind - %% ports which require root access - case Port < 1024 of - true -> - case fdsrv:start() of - {ok, _} -> - case fdsrv:bind_socket(tcp, Port) of - {ok, Fd} -> - gen_tcp_listen(Port, [{fd, Fd} | Opts], State); - _ -> - {stop, fdsrv_bind_failed} - end; - _ -> - {stop, fdsrv_start_failed} - end; - false -> - {stop, eacces} - end; - Other -> - error_logger:info_msg("thrift service listening on port ~p", [Port]), - Other - end. - -gen_tcp_listen(Port, Opts, State) -> + BaseOpts = [ + binary, + {reuseaddr, true}, + {packet, 0}, + {backlog, 4096}, + {recbuf, 8192}, + {active, false} + ], + Opts = + case maps:get(ip, State, undefined) of + undefined -> + BaseOpts; + Ip -> + [{ip, Ip} | BaseOpts] + end, case gen_tcp:listen(Port, Opts) of {ok, Listen} -> {ok, ListenPort} = inet:port(Listen), - {ok, new_acceptor(State#thrift_socket_server{listen=Listen, - port=ListenPort})}; + {ok, + new_acceptor(#thrift_socket_server{ + acceptors_left = maps:get(max, State, 2048), + listen = Listen, + port = ListenPort, + service = maps:get(service, State), + handler = maps:get(handler, State), + socket_opts = maps:get(socket_opts, State, [{recv_timeout, 500}]), + framed = maps:get(framed, State, false), + protocol = maps:get(protocol, State, binary), + ssltransport = maps:get(ssltransport, State, false), + ssloptions = maps:get(ssloptions, State, []) + })}; {error, Reason} -> {stop, Reason} end. -new_acceptor(State=#thrift_socket_server{max=0}) -> +new_acceptor(State = #thrift_socket_server{acceptors_left = 0}) -> error_logger:error_msg("Not accepting new connections"), - State#thrift_socket_server{acceptor=null}; -new_acceptor(State=#thrift_socket_server{listen=Listen, - service=Service, handler=Handler, - socket_opts=Opts, framed=Framed, protocol=Proto, - ssltransport=SslTransport, ssloptions=SslOptions - }) -> - Pid = proc_lib:spawn_link(?MODULE, acceptor_loop, - [{self(), Listen, Service, Handler, Opts, Framed, SslTransport, SslOptions, Proto}]), - State#thrift_socket_server{acceptor=Pid}. + State#thrift_socket_server{acceptor = undefined}; +new_acceptor( + State = #thrift_socket_server{ + listen = Listen, + service = Service, + handler = Handler, + socket_opts = Opts, + framed = Framed, + protocol = Proto, + ssltransport = SslTransport, + ssloptions = SslOptions + } +) -> + Pid = proc_lib:spawn_link( + ?MODULE, + acceptor_loop, + [{self(), Listen, Service, Handler, Opts, Framed, SslTransport, SslOptions, Proto}] + ), + State#thrift_socket_server{acceptor = Pid}. -acceptor_loop({Server, Listen, Service, Handler, SocketOpts, Framed, SslTransport, SslOptions, Proto}) - when is_pid(Server), is_list(SocketOpts) -> - case catch gen_tcp:accept(Listen) of % infinite timeout +acceptor_loop( + {Server, Listen, Service, Handler, SocketOpts, Framed, SslTransport, SslOptions, Proto} +) when + is_pid(Server), is_list(SocketOpts) +-> + % infinite timeout + case catch gen_tcp:accept(Listen) of {ok, Socket} -> gen_server:cast(Server, {accepted, self()}), ProtoGen = fun() -> - {ok, SocketTransport} = case SslTransport of - true -> thrift_sslsocket_transport:new(Socket, SocketOpts, SslOptions); - false -> thrift_socket_transport:new(Socket, SocketOpts) - end, - {ok, Transport} = case Framed of - true -> thrift_framed_transport:new(SocketTransport); - false -> thrift_buffered_transport:new(SocketTransport) - end, - {ok, Protocol} = case Proto of - compact -> thrift_compact_protocol:new(Transport); - json -> thrift_json_protocol:new(Transport); - _ -> thrift_binary_protocol:new(Transport) - end, - {ok, Protocol} - end, + {ok, SocketTransport} = + case SslTransport of + true -> thrift_sslsocket_transport:new(Socket, SocketOpts, SslOptions); + false -> thrift_socket_transport:new(Socket, SocketOpts) + end, + {ok, Transport} = + case Framed of + true -> thrift_framed_transport:new(SocketTransport); + false -> thrift_buffered_transport:new(SocketTransport) + end, + {ok, Protocol} = + case Proto of + compact -> + thrift_compact_protocol:new(Transport); + {compact, Options} -> + thrift_compact_protocol:new(Transport, Options); + json -> + thrift_json_protocol:new(Transport); + {json, Options} -> + thrift_json_protocol:new(Transport, Options); + binary -> + thrift_binary_protocol:new(Transport); + {binary, Options} -> + thrift_binary_protocol:new(Transport, Options); + {custom, Module, Options} -> + case erlang:function_exported(Module, new, 2) of + true -> Module:new(Transport, Options); + false -> throw("Could not instantiate custom protocol") + end + end, + {ok, Protocol} + end, thrift_processor:init({Server, ProtoGen, Service, Handler}); {error, closed} -> exit({error, closed}); Other -> error_logger:error_report( - [{application, thrift}, - "Accept failed error", - lists:flatten(io_lib:format("~p", [Other]))]), + [ + {application, thrift}, + "Accept failed error", + lists:flatten(io_lib:format("~p", [Other])) + ] + ), exit({error, accept_failed}) end. -handle_call({get, port}, _From, State=#thrift_socket_server{port=Port}) -> +handle_call({get, port}, _From, State = #thrift_socket_server{port = Port}) -> {reply, Port, State}; handle_call(_Message, _From, State) -> Res = error, {reply, Res, State}. -handle_cast({accepted, Pid}, - State=#thrift_socket_server{acceptor=Pid, max=Max}) -> +handle_cast( + {accepted, Pid}, + State = #thrift_socket_server{acceptor = Pid, acceptors_left = Max} +) -> % io:format("accepted ~p~n", [Pid]), - State1 = State#thrift_socket_server{max=Max - 1}, + State1 = State#thrift_socket_server{acceptors_left = Max - 1}, {noreply, new_acceptor(State1)}; handle_cast(stop, State) -> {stop, normal, State}. -terminate(Reason, #thrift_socket_server{listen=Listen, port=Port}) -> +terminate(Reason, #thrift_socket_server{listen = Listen}) -> gen_tcp:close(Listen), case Reason of - normal -> ok; - shutdown -> ok; - _ -> {backtrace, Bt} = erlang:process_info(self(), backtrace), - error_logger:error_report({?MODULE, ?LINE, - {child_error, Reason, Bt}}) - end, - case Port < 1024 of - true -> - catch fdsrv:stop(), + normal -> ok; - false -> - ok + shutdown -> + ok; + _ -> + {backtrace, Bt} = erlang:process_info(self(), backtrace), + error_logger:error_report({?MODULE, ?LINE, {child_error, Reason, Bt}}) end. code_change(_OldVsn, State, _Extra) -> State. -handle_info({'EXIT', Pid, normal}, - State=#thrift_socket_server{acceptor=Pid}) -> +handle_info( + {'EXIT', Pid, normal}, + State = #thrift_socket_server{acceptor = Pid} +) -> {noreply, new_acceptor(State)}; -handle_info({'EXIT', Pid, Reason}, - State=#thrift_socket_server{acceptor=Pid}) -> - error_logger:error_report({?MODULE, ?LINE, - {acceptor_error, Reason}}), +handle_info( + {'EXIT', Pid, Reason}, + State = #thrift_socket_server{acceptor = Pid} +) -> + error_logger:error_report({?MODULE, ?LINE, {acceptor_error, Reason}}), timer:sleep(100), {noreply, new_acceptor(State)}; -handle_info({'EXIT', _LoopPid, Reason}, - State=#thrift_socket_server{acceptor=Pid, max=Max}) -> +handle_info( + {'EXIT', _LoopPid, Reason}, + State = #thrift_socket_server{acceptor = Pid, acceptors_left = AcceptorsLeft} +) -> case Reason of normal -> ok; shutdown -> ok; - _ -> error_logger:error_report({?MODULE, ?LINE, - {child_error, Reason, erlang:get_stacktrace()}}) + _ -> error_logger:error_report({?MODULE, ?LINE, {child_error, Reason}}) end, - State1 = State#thrift_socket_server{max=Max + 1}, - State2 = case Pid of - null -> new_acceptor(State1); - _ -> State1 - end, + State1 = State#thrift_socket_server{acceptors_left = AcceptorsLeft + 1}, + State2 = + case Pid of + undefined -> new_acceptor(State1); + _ -> State1 + end, {noreply, State2}; handle_info(Info, State) -> error_logger:info_report([{'INFO', Info}, {'State', State}]), diff --git a/lib/erl/src/thrift_socket_transport.erl b/lib/erl/src/thrift_socket_transport.erl index fe210da977d..a5b68e1b4f0 100644 --- a/lib/erl/src/thrift_socket_transport.erl +++ b/lib/erl/src/thrift_socket_transport.erl @@ -28,113 +28,89 @@ %% legacy api -export([new_transport_factory/3]). - -record(t_socket, { - socket, - recv_timeout=60000, - buffer = [] + socket :: gen_tcp:socket(), + recv_timeout = 60000 :: timeout(), + buffer = [] :: iodata() }). --type state() :: #t_socket{}. - - --spec new(Socket::any()) -> - thrift_transport:t_transport(). +-spec new(Socket :: any()) -> {ok, thrift_transport:t_transport()}. new(Socket) -> new(Socket, []). --spec new(Socket::any(), Opts::list()) -> - thrift_transport:t_transport(). +-spec new(Socket :: any(), Opts :: list()) -> {ok, thrift_transport:t_transport()}. new(Socket, Opts) when is_list(Opts) -> - State = parse_opts(Opts, #t_socket{socket = Socket}), - thrift_transport:new(?MODULE, State). - - -parse_opts([{recv_timeout, Timeout}|Rest], State) -when is_integer(Timeout), Timeout > 0 -> - parse_opts(Rest, State#t_socket{recv_timeout = Timeout}); -parse_opts([{recv_timeout, infinity}|Rest], State) -> - parse_opts(Rest, State#t_socket{recv_timeout = infinity}); + State = parse_opts(Opts, #t_socket{socket = Socket}), + thrift_transport:new(?MODULE, State). + +parse_opts([{recv_timeout, Timeout} | Rest], State) when + is_integer(Timeout), Timeout > 0 +-> + parse_opts(Rest, State#t_socket{recv_timeout = Timeout}); +parse_opts([{recv_timeout, infinity} | Rest], State) -> + parse_opts(Rest, State#t_socket{recv_timeout = infinity}); parse_opts([], State) -> - State. - - --include("thrift_transport_behaviour.hrl"). - - -read(State = #t_socket{buffer = Buf}, Len) -when is_integer(Len), Len >= 0 -> - Binary = iolist_to_binary(Buf), - case iolist_size(Binary) of - X when X >= Len -> - {Result, Remaining} = split_binary(Binary, Len), - {State#t_socket{buffer = Remaining}, {ok, Result}}; - _ -> - %%recv(State, Len) - loop_recv(State,Len,Len) - end. - -loop_recv(State=#t_socket{buffer = Buf},ReadLen,NextReadLen) when NextReadLen =< 0-> - {Result,Remaining}=split_binary(Buf,ReadLen), - {State#t_socket{buffer = Remaining},{ok,Result}}; - -loop_recv(State=#t_socket{socket = Socket,buffer = Buf},ReadLen,NextReadLen) when NextReadLen >0 -> - case gen_tcp:recv(Socket,0,State#t_socket.recv_timeout) of - {error,Error}-> - gen_tcp:close(Socket), - {State,{error,Error}}; - {ok,Data}-> - Binary=iolist_to_binary([Buf,Data]), - Give=min(iolist_size(Binary),ReadLen), - loop_recv(State#t_socket{buffer = Binary},ReadLen,ReadLen-Give) - end. - -recv(State = #t_socket{socket = Socket, buffer = Buf}, Len) -> - case gen_tcp:recv(Socket, 0, State#t_socket.recv_timeout) of - {error, Error} -> - gen_tcp:close(Socket), - {State, {error, Error}}; - {ok, Data} -> - Binary = iolist_to_binary([Buf, Data]), - Give = min(iolist_size(Binary), Len), - {Result, Remaining} = split_binary(Binary, Give), - {State#t_socket{buffer = Remaining}, {ok, Result}} - end. - - -read_exact(State = #t_socket{buffer = Buf}, Len) -when is_integer(Len), Len >= 0 -> - Binary = iolist_to_binary(Buf), - case iolist_size(Binary) of - X when X >= Len -> read(State, Len); - X -> - case gen_tcp:recv(State#t_socket.socket, Len - X, State#t_socket.recv_timeout) of + State. + +read(State = #t_socket{buffer = Buf}, Len) when + is_integer(Len), Len >= 0 +-> + Binary = iolist_to_binary(Buf), + case iolist_size(Binary) of + X when X >= Len -> + {Result, Remaining} = split_binary(Binary, Len), + {State#t_socket{buffer = Remaining}, {ok, Result}}; + _ -> + loop_recv(State, Len, Len) + end. + +loop_recv(State = #t_socket{buffer = Buf}, ReadLen, NextReadLen) when NextReadLen =< 0 -> + {Result, Remaining} = split_binary(Buf, ReadLen), + {State#t_socket{buffer = Remaining}, {ok, Result}}; +loop_recv(State = #t_socket{socket = Socket, buffer = Buf}, ReadLen, NextReadLen) when + NextReadLen > 0 +-> + case gen_tcp:recv(Socket, 0, State#t_socket.recv_timeout) of {error, Error} -> - gen_tcp:close(State#t_socket.socket), - {State, {error, Error}}; + gen_tcp:close(Socket), + {State, {error, Error}}; {ok, Data} -> - {State#t_socket{buffer = []}, {ok, <>}} - end - end. - + Binary = iolist_to_binary([Buf, Data]), + Give = min(iolist_size(Binary), ReadLen), + loop_recv(State#t_socket{buffer = Binary}, ReadLen, ReadLen - Give) + end. + +read_exact(State = #t_socket{buffer = Buf}, Len) when + is_integer(Len), Len >= 0 +-> + Binary = iolist_to_binary(Buf), + case iolist_size(Binary) of + X when X >= Len -> read(State, Len); + X -> + case gen_tcp:recv(State#t_socket.socket, Len - X, State#t_socket.recv_timeout) of + {error, Error} -> + gen_tcp:close(State#t_socket.socket), + {State, {error, Error}}; + {ok, Data} -> + {State#t_socket{buffer = []}, {ok, <>}} + end + end. write(State = #t_socket{socket = Socket}, Data) -> - case gen_tcp:send(Socket, Data) of - {error, Error} -> - gen_tcp:close(Socket), - {State, {error, Error}}; - ok -> {State, ok} - end. - + case gen_tcp:send(Socket, Data) of + {error, Error} -> + gen_tcp:close(Socket), + {State, {error, Error}}; + ok -> + {State, ok} + end. flush(State) -> - {State#t_socket{buffer = []}, ok}. - + {State#t_socket{buffer = []}, ok}. close(State = #t_socket{socket = Socket}) -> - {State, gen_tcp:close(Socket)}. - + {State, gen_tcp:close(Socket)}. %% legacy api. left for compatibility @@ -143,51 +119,61 @@ close(State = #t_socket{socket = Socket}) -> %% proplists-style option list. They're parsed like this so it is an O(n) %% operation instead of O(n^2) -record(factory_opts, { - connect_timeout = infinity, - sockopts = [], - framed = false + connect_timeout = infinity :: timeout(), + sockopts = [] :: [inet:inet_backend() | gen_tcp:connect_option()], + framed = false :: boolean() }). -parse_factory_options([], FactoryOpts, TransOpts) -> {FactoryOpts, TransOpts}; -parse_factory_options([{framed, Bool}|Rest], FactoryOpts, TransOpts) -when is_boolean(Bool) -> - parse_factory_options(Rest, FactoryOpts#factory_opts{framed = Bool}, TransOpts); -parse_factory_options([{sockopts, OptList}|Rest], FactoryOpts, TransOpts) -when is_list(OptList) -> - parse_factory_options(Rest, FactoryOpts#factory_opts{sockopts = OptList}, TransOpts); -parse_factory_options([{connect_timeout, TO}|Rest], FactoryOpts, TransOpts) -when TO =:= infinity; is_integer(TO) -> - parse_factory_options(Rest, FactoryOpts#factory_opts{connect_timeout = TO}, TransOpts); -parse_factory_options([{recv_timeout, TO}|Rest], FactoryOpts, TransOpts) -when TO =:= infinity; is_integer(TO) -> - parse_factory_options(Rest, FactoryOpts, [{recv_timeout, TO}] ++ TransOpts). - +parse_factory_options([], FactoryOpts, TransOpts) -> + {FactoryOpts, TransOpts}; +parse_factory_options([{framed, Bool} | Rest], FactoryOpts, TransOpts) when + is_boolean(Bool) +-> + parse_factory_options(Rest, FactoryOpts#factory_opts{framed = Bool}, TransOpts); +parse_factory_options([{sockopts, OptList} | Rest], FactoryOpts, TransOpts) when + is_list(OptList) +-> + parse_factory_options(Rest, FactoryOpts#factory_opts{sockopts = OptList}, TransOpts); +parse_factory_options([{connect_timeout, TO} | Rest], FactoryOpts, TransOpts) when + TO =:= infinity; is_integer(TO) +-> + parse_factory_options(Rest, FactoryOpts#factory_opts{connect_timeout = TO}, TransOpts); +parse_factory_options([{recv_timeout, TO} | Rest], FactoryOpts, TransOpts) when + TO =:= infinity; is_integer(TO) +-> + parse_factory_options(Rest, FactoryOpts, [{recv_timeout, TO}] ++ TransOpts). %% Generates a "transport factory" function - a fun which returns a thrift_transport() %% instance. %% State can be passed into a protocol factory to generate a connection to a %% thrift server over a socket. new_transport_factory(Host, Port, Options) -> - {FactoryOpts, TransOpts} = parse_factory_options(Options, #factory_opts{}, []), - {ok, fun() -> SockOpts = [binary, - {packet, 0}, - {active, false}, - {nodelay, true}|FactoryOpts#factory_opts.sockopts - ], - case catch gen_tcp:connect( - Host, - Port, - SockOpts, - FactoryOpts#factory_opts.connect_timeout - ) of - {ok, Sock} -> - {ok, Transport} = thrift_socket_transport:new(Sock, TransOpts), - {ok, BufTransport} = case FactoryOpts#factory_opts.framed of - true -> thrift_framed_transport:new(Transport); - false -> thrift_buffered_transport:new(Transport) - end, - {ok, BufTransport}; - Error -> Error - end - end}. - + {FactoryOpts, TransOpts} = parse_factory_options(Options, #factory_opts{}, []), + {ok, fun() -> + SockOpts = [ + binary, + {packet, 0}, + {active, false}, + {nodelay, true} + | FactoryOpts#factory_opts.sockopts + ], + case + catch gen_tcp:connect( + Host, + Port, + SockOpts, + FactoryOpts#factory_opts.connect_timeout + ) + of + {ok, Sock} -> + {ok, Transport} = thrift_socket_transport:new(Sock, TransOpts), + {ok, BufTransport} = + case FactoryOpts#factory_opts.framed of + true -> thrift_framed_transport:new(Transport); + false -> thrift_buffered_transport:new(Transport) + end, + {ok, BufTransport}; + Error -> + Error + end + end}. diff --git a/lib/erl/src/thrift_sslsocket_transport.erl b/lib/erl/src/thrift_sslsocket_transport.erl index 211153f7b75..43e64b183e1 100644 --- a/lib/erl/src/thrift_sslsocket_transport.erl +++ b/lib/erl/src/thrift_sslsocket_transport.erl @@ -18,80 +18,97 @@ %% -module(thrift_sslsocket_transport). --include("thrift_transport_behaviour.hrl"). - -behaviour(thrift_transport). --export([new/3, - write/2, read/2, flush/1, close/1, +-export([ + new/3, + write/2, + read/2, + flush/1, + close/1, - new_transport_factory/3]). + new_transport_factory/3 +]). %% Export only for the transport factory -export([new/2]). --record(data, {socket, - recv_timeout=infinity}). --type state() :: #data{}. +-record(data, { + socket :: ssl:sslsocket(), + recv_timeout = infinity :: infinity | timeout() +}). + +-type data() :: #data{}. +-type reason() :: thrift_transport:reason(). %% The following "local" record is filled in by parse_factory_options/2 %% below. These options can be passed to new_protocol_factory/3 in a %% proplists-style option list. They're parsed like this so it is an O(n) %% operation instead of O(n^2) --record(factory_opts, {connect_timeout = infinity, - sockopts = [], - framed = false, - ssloptions = []}). +-record(factory_opts, { + connect_timeout = infinity :: infinity | timeout(), + sockopts = [] :: [inet:inet_backend() | gen_tcp:connect_option()], + framed = false :: boolean(), + ssloptions = [] :: [ssl:tls_client_option()] +}). parse_factory_options([], Opts) -> Opts; parse_factory_options([{framed, Bool} | Rest], Opts) when is_boolean(Bool) -> - parse_factory_options(Rest, Opts#factory_opts{framed=Bool}); + parse_factory_options(Rest, Opts#factory_opts{framed = Bool}); parse_factory_options([{sockopts, OptList} | Rest], Opts) when is_list(OptList) -> - parse_factory_options(Rest, Opts#factory_opts{sockopts=OptList}); + parse_factory_options(Rest, Opts#factory_opts{sockopts = OptList}); parse_factory_options([{connect_timeout, TO} | Rest], Opts) when TO =:= infinity; is_integer(TO) -> - parse_factory_options(Rest, Opts#factory_opts{connect_timeout=TO}); + parse_factory_options(Rest, Opts#factory_opts{connect_timeout = TO}); parse_factory_options([{ssloptions, SslOptions} | Rest], Opts) when is_list(SslOptions) -> - parse_factory_options(Rest, Opts#factory_opts{ssloptions=SslOptions}). + parse_factory_options(Rest, Opts#factory_opts{ssloptions = SslOptions}). new(Socket, SockOpts, SslOptions) when is_list(SockOpts), is_list(SslOptions) -> - inet:setopts(Socket, [{active, false}]), %% => prevent the ssl handshake messages get lost + %% => prevent the ssl handshake messages get lost + ok = inet:setopts(Socket, [{active, false}]), %% upgrade to an ssl socket - case catch ssl:ssl_accept(Socket, SslOptions) of % infinite timeout + + % infinite timeout + case catch ssl:handshake(Socket, SslOptions) of {ok, SslSocket} -> new(SslSocket, SockOpts); {error, Reason} -> exit({error, Reason}); Other -> error_logger:error_report( - [{application, thrift}, - "SSL accept failed error", - lists:flatten(io_lib:format("~p", [Other]))]), + [ + {application, thrift}, + "SSL accept failed error", + lists:flatten(io_lib:format("~p", [Other])) + ] + ), exit({error, ssl_accept_failed}) end. new(SslSocket, SockOpts) -> State = case lists:keysearch(recv_timeout, 1, SockOpts) of - {value, {recv_timeout, Timeout}} - when is_integer(Timeout), Timeout > 0 -> - #data{socket=SslSocket, recv_timeout=Timeout}; + {value, {recv_timeout, Timeout}} when + is_integer(Timeout), Timeout > 0 + -> + #data{socket = SslSocket, recv_timeout = Timeout}; _ -> - #data{socket=SslSocket} + #data{socket = SslSocket} end, thrift_transport:new(?MODULE, State). %% Data :: iolist() +-spec write(data(), iolist()) -> {data(), ok | {error, reason()}}. write(This = #data{socket = Socket}, Data) -> {This, ssl:send(Socket, Data)}. -read(This = #data{socket=Socket, recv_timeout=Timeout}, Len) - when is_integer(Len), Len >= 0 -> +read(This = #data{socket = Socket, recv_timeout = Timeout}, Len) when + is_integer(Len), Len >= 0 +-> case ssl:recv(Socket, Len, Timeout) of Err = {error, timeout} -> - error_logger:info_msg("read timeout: peer conn ~p", [inet:peername(Socket)]), - ssl:close(Socket), + ok = ssl:close(Socket), {This, Err}; Data -> {This, Data} @@ -116,32 +133,48 @@ new_transport_factory(Host, Port, Options) -> ParsedOpts = parse_factory_options(Options, #factory_opts{}), F = fun() -> - SockOpts = [binary, - {packet, 0}, - {active, false}, - {nodelay, true} | - ParsedOpts#factory_opts.sockopts], - case catch gen_tcp:connect(Host, Port, SockOpts, - ParsedOpts#factory_opts.connect_timeout) of - {ok, Sock} -> - SslSock = case catch ssl:connect(Sock, ParsedOpts#factory_opts.ssloptions, - ParsedOpts#factory_opts.connect_timeout) of - {ok, SslSocket} -> - SslSocket; - Other -> - error_logger:info_msg("error while connecting over ssl - reason: ~p~n", [Other]), - catch gen_tcp:close(Sock), - exit(error) - end, - {ok, Transport} = thrift_sslsocket_transport:new(SslSock, SockOpts), - {ok, BufTransport} = - case ParsedOpts#factory_opts.framed of - true -> thrift_framed_transport:new(Transport); - false -> thrift_buffered_transport:new(Transport) - end, - {ok, BufTransport}; - Error -> - Error - end - end, - {ok, F}. \ No newline at end of file + SockOpts = [ + binary, + {packet, 0}, + {active, false}, + {nodelay, true} + | ParsedOpts#factory_opts.sockopts + ], + case + catch gen_tcp:connect( + Host, + Port, + SockOpts, + ParsedOpts#factory_opts.connect_timeout + ) + of + {ok, Sock} -> + SslSock = + case + catch ssl:connect( + Sock, + ParsedOpts#factory_opts.ssloptions, + ParsedOpts#factory_opts.connect_timeout + ) + of + {ok, SslSocket} -> + SslSocket; + Other -> + error_logger:info_msg( + "error while connecting over ssl - reason: ~p~n", [Other] + ), + catch gen_tcp:close(Sock), + exit(error) + end, + {ok, Transport} = thrift_sslsocket_transport:new(SslSock, SockOpts), + {ok, BufTransport} = + case ParsedOpts#factory_opts.framed of + true -> thrift_framed_transport:new(Transport); + false -> thrift_buffered_transport:new(Transport) + end, + {ok, BufTransport}; + Error -> + Error + end + end, + {ok, F}. diff --git a/lib/erl/src/thrift_transport.erl b/lib/erl/src/thrift_transport.erl index 2414bde3636..cc9ca1b7db8 100644 --- a/lib/erl/src/thrift_transport.erl +++ b/lib/erl/src/thrift_transport.erl @@ -19,108 +19,105 @@ -module(thrift_transport). --export([behaviour_info/1]). %% constructors -export([new/1, new/2]). %% transport callbacks -export([read/2, read_exact/2, write/2, flush/1, close/1]). --export_type([t_transport/0]). - - -behaviour_info(callbacks) -> - [{read, 2}, {write, 2}, {flush, 1}, {close, 1}]. - - -record(t_transport, { - module, - state + module :: module(), + state :: term() }). - --type state() :: #t_transport{}. -type t_transport() :: #t_transport{}. +-export_type([t_transport/0]). + +%%%========================================================================= +%%% API +%%%========================================================================= +-type state() :: term(). +-export_type([state/0]). +-type reason() :: term(). +-export_type([reason/0]). +-callback write(state(), iolist() | binary()) -> {state(), ok | {error, reason()}}. +-callback read(state(), non_neg_integer()) -> {state(), {ok, binary()} | {error, reason()}}. +-callback flush(state()) -> {state(), ok | {error, reason()}}. +-callback close(state()) -> {state(), ok | {error, reason()}}. -ifdef(transport_wrapper_module). -define(debug_wrap(Transport), - case Transport#t_transport.module of - ?transport_wrapper_module -> Transport; - _Else -> - {ok, Result} = ?transport_wrapper_module:new(Transport), - Result - end + case Transport#t_transport.module of + ?transport_wrapper_module -> + Transport; + _Else -> + {ok, Result} = ?transport_wrapper_module:new(Transport), + Result + end ). -else. -define(debug_wrap(Transport), Transport). -endif. - -type wrappable() :: - binary() | - list() | - {membuffer, binary() | list()} | - {tcp, port()} | - {tcp, port(), list()} | - {file, file:io_device()} | - {file, file:io_device(), list()} | - {file, file:filename()} | - {file, file:filename(), list()}. + binary() + | list() + | {membuffer, binary() | list()} + | {membuffer, binary() | list(), list()} + | {tcp, port()} + | {tcp, port(), list()} + | {file, file:io_device()} + | {file, file:io_device(), list()} + | {file, file:filename()} + | {file, file:filename(), list()}. -spec new(wrappable()) -> {ok, #t_transport{}}. -new({membuffer, Membuffer}) when is_binary(Membuffer); is_list(Membuffer) -> - thrift_membuffer_transport:new(Membuffer); -new({membuffer, Membuffer, []}) when is_binary(Membuffer); is_list(Membuffer) -> - thrift_membuffer_transport:new(Membuffer); +new({membuffer, Membuffer}) -> + new({membuffer, Membuffer, []}); +new({membuffer, Membuffer, Opts}) when is_binary(Membuffer); is_list(Membuffer) -> + thrift_membuffer_transport:new(Membuffer, Opts); new({tcp, Socket}) when is_port(Socket) -> - new({tcp, Socket, []}); + new({tcp, Socket, []}); new({tcp, Socket, Opts}) when is_port(Socket) -> - thrift_socket_transport:new(Socket, Opts); + thrift_socket_transport:new(Socket, Opts); new({file, Filename}) when is_list(Filename); is_binary(Filename) -> - new({file, Filename, []}); + new({file, Filename, []}); new({file, Filename, Opts}) when is_list(Filename); is_binary(Filename) -> - {ok, File} = file:open(Filename, [raw, binary]), - new({file, File, Opts}); + {ok, File} = file:open(Filename, [raw, binary]), + new({file, File, Opts}); new({file, File, Opts}) -> - thrift_file_transport:new(File, Opts). + thrift_file_transport:new(File, Opts). --spec new(Module::module(), State::any()) -> {ok, #t_transport{}}. +-spec new(Module :: module(), State :: any()) -> {ok, t_transport()}. new(Module, State) when is_atom(Module) -> - {ok, ?debug_wrap(#t_transport{module = Module, state = State})}. - - --include("thrift_transport_behaviour.hrl"). - - -read(Transport = #t_transport{module = Module}, Len) -when is_integer(Len), Len >= 0 -> - {NewState, Result} = Module:read(Transport#t_transport.state, Len), - {Transport#t_transport{state = NewState}, Result}. - - -read_exact(Transport = #t_transport{module = Module}, Len) -when is_integer(Len), Len >= 0 -> - case lists:keyfind(read_exact, 1, Module:module_info(exports)) of - {read_exact, 2} -> - {NewState, Result} = Module:read_exact(Transport#t_transport.state, Len), - {Transport#t_transport{state = NewState}, Result}; - _ -> - read(Transport, Len) - end. - + {ok, ?debug_wrap(#t_transport{module = Module, state = State})}. + +read(Transport = #t_transport{module = Module}, Len) when + is_integer(Len), Len >= 0 +-> + {NewState, Result} = Module:read(Transport#t_transport.state, Len), + {Transport#t_transport{state = NewState}, Result}. + +read_exact(Transport = #t_transport{module = Module}, Len) when + is_integer(Len), Len >= 0 +-> + case lists:keyfind(read_exact, 1, Module:module_info(exports)) of + {read_exact, 2} -> + {NewState, Result} = Module:read_exact(Transport#t_transport.state, Len), + {Transport#t_transport{state = NewState}, Result}; + _ -> + read(Transport, Len) + end. write(Transport = #t_transport{module = Module}, Data) -> - {NewState, Result} = Module:write(Transport#t_transport.state, Data), - {Transport#t_transport{state = NewState}, Result}. - + {NewState, Result} = Module:write(Transport#t_transport.state, Data), + {Transport#t_transport{state = NewState}, Result}. flush(Transport = #t_transport{module = Module}) -> - {NewState, Result} = Module:flush(Transport#t_transport.state), - {Transport#t_transport{state = NewState}, Result}. - + {NewState, Result} = Module:flush(Transport#t_transport.state), + {Transport#t_transport{state = NewState}, Result}. close(Transport = #t_transport{module = Module}) -> - {NewState, Result} = Module:close(Transport#t_transport.state), - {Transport#t_transport{state = NewState}, Result}. - + {NewState, Result} = Module:close(Transport#t_transport.state), + {Transport#t_transport{state = NewState}, Result}. diff --git a/lib/erl/src/thrift_transport_state_test.erl b/lib/erl/src/thrift_transport_state_test.erl index e83a44d26b0..99b5649fdac 100644 --- a/lib/erl/src/thrift_transport_state_test.erl +++ b/lib/erl/src/thrift_transport_state_test.erl @@ -26,28 +26,35 @@ -export([new/1]). %% gen_server callbacks --export([init/1, handle_call/3, handle_cast/2, handle_info/2, - terminate/2, code_change/3]). +-export([ + init/1, + handle_call/3, + handle_cast/2, + handle_info/2, + terminate/2, + code_change/3 +]). %% thrift_transport callbacks -export([write/2, read/2, flush/1, close/1]). --record(trans, {wrapped, % #thrift_transport{} - version :: integer(), - counter :: pid() - }). --type state() :: #trans{}. --include("thrift_transport_behaviour.hrl"). +% #thrift_transport{} +-record(trans, { + wrapped :: thrift_transport:t_transport(), + version :: integer(), + counter :: pid() +}). -record(state, {cversion :: integer()}). - new(WrappedTransport) -> case gen_server:start_link(?MODULE, [], []) of {ok, Pid} -> - Trans = #trans{wrapped = WrappedTransport, - version = 0, - counter = Pid}, + Trans = #trans{ + wrapped = WrappedTransport, + version = 0, + counter = Pid + }, thrift_transport:new(?MODULE, Trans); Else -> Else @@ -82,7 +89,6 @@ read(Transport0 = #trans{wrapped = Wrapped0}, Len) -> Transport2 = Transport1#trans{wrapped = Wrapped1}, {Transport2, Result}. - %%==================================================================== %% gen_server callbacks %%==================================================================== @@ -91,7 +97,7 @@ init([]) -> {ok, #state{cversion = 0}}. handle_call(check_version, _From, State = #state{cversion = Version}) -> - {reply, Version, State#state{cversion = Version+1}}. + {reply, Version, State#state{cversion = Version + 1}}. handle_cast(shutdown, State) -> {stop, normal, State}. @@ -107,7 +113,7 @@ terminate(_Reason, _State) -> ok. check_version(Transport = #trans{version = Version, counter = Counter}) -> case gen_server:call(Counter, check_version) of Version -> - Transport#trans{version = Version+1}; + Transport#trans{version = Version + 1}; _Else -> % State wasn't propagated properly. Die. erlang:error(state_not_propagated) diff --git a/lib/erl/test/legacy_names_test.erl b/lib/erl/test/legacy_names_test.erl index c16aa3ee255..9076ffb6137 100644 --- a/lib/erl/test/legacy_names_test.erl +++ b/lib/erl/test/legacy_names_test.erl @@ -18,52 +18,58 @@ %% -module(legacy_names_test). --compile(export_all). -include_lib("eunit/include/eunit.hrl"). -include("gen-erl/legacyNames_constants.hrl"). record_generation_test_() -> - [ - {"capitalizedStruct record", ?_assertMatch( - {capitalizedStruct, _, _}, - #capitalizedStruct{id=null,message=null} - )} - ]. + [ + {"capitalizedStruct record", + ?_assertMatch( + {capitalizedStruct, _, _}, + #capitalizedStruct{id = null, message = null} + )} + ]. struct_info_test_() -> - [ - {"capitalizedStruct extended definition", ?_assertEqual( - {struct, [ - {1, undefined, i32, 'id', undefined}, - {2, undefined, string, 'message', undefined} - ]}, - legacyNames_types:struct_info_ext(capitalizedStruct) - )}, - {"listCapitalizedStructs extended definition", ?_assertEqual( - {struct, [ - {1, undefined, {list, {struct, {'legacyNames_types', 'capitalizedStruct'}}}, 'structs', []} - ]}, - legacyNames_types:struct_info_ext(listCapitalizedStructs) - )} - ]. + [ + {"capitalizedStruct extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, i32, 'id', undefined}, + {2, undefined, string, 'message', undefined} + ]}, + legacyNames_types:struct_info_ext(capitalizedStruct) + )}, + {"listCapitalizedStructs extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, {list, {struct, {'legacyNames_types', 'capitalizedStruct'}}}, + 'structs', []} + ]}, + legacyNames_types:struct_info_ext(listCapitalizedStructs) + )} + ]. service_info_test_() -> - [ - {"names params", ?_assertEqual( - {struct, [ - {1, {struct, {'legacyNames_types', 'capitalizedStruct'}}}, - {2, {struct, {'legacyNames_types', 'capitalizedStruct'}}} - ]}, - legacyNames_thrift:function_info(names, params_type) - )}, - {"names reply", ?_assertEqual( - {struct, {'legacyNames_types', 'listCapitalizedStructs'}}, - legacyNames_thrift:function_info(names, reply_type) - )}, - {"names exceptions", ?_assertEqual( - {struct, [{1, {struct, {'legacyNames_types', 'xception'}}}]}, - legacyNames_thrift:function_info(names, exceptions) - )} - ]. + [ + {"names params", + ?_assertEqual( + {struct, [ + {1, {struct, {'legacyNames_types', 'capitalizedStruct'}}}, + {2, {struct, {'legacyNames_types', 'capitalizedStruct'}}} + ]}, + legacyNames_thrift:function_info(names, params_type) + )}, + {"names reply", + ?_assertEqual( + {struct, {'legacyNames_types', 'listCapitalizedStructs'}}, + legacyNames_thrift:function_info(names, reply_type) + )}, + {"names exceptions", + ?_assertEqual( + {struct, [{1, {struct, {'legacyNames_types', 'xception'}}}]}, + legacyNames_thrift:function_info(names, exceptions) + )} + ]. diff --git a/lib/erl/test/multiplexing_test.erl b/lib/erl/test/multiplexing_test.erl index 0f2d616b84a..5752e53a4d4 100644 --- a/lib/erl/test/multiplexing_test.erl +++ b/lib/erl/test/multiplexing_test.erl @@ -1,19 +1,37 @@ +%% +%% Licensed to the Apache Software Foundation (ASF) under one +%% or more contributor license agreements. See the NOTICE file +%% distributed with this work for additional information +%% regarding copyright ownership. The ASF licenses this file +%% to you under the Apache License, Version 2.0 (the +%% "License"); you may not use this file except in compliance +%% with the License. You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, +%% software distributed under the License is distributed on an +%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +%% KIND, either express or implied. See the License for the +%% specific language governing permissions and limitations +%% under the License. +%% + -module(multiplexing_test). -include_lib("eunit/include/eunit.hrl"). -export([ - handle_function/2 - ,handle_error/2 + handle_function/2, + handle_error/2 ]). start_multiplexed_server_test() -> - Port = 9090, Services = [ - {"Multiplexing_Calculator", multiplexing__calculator_thrift}, - {"Multiplexing_WeatherReport", multiplexing__weather_report_thrift} - ], + {"Multiplexing_Calculator", multiplexing__calculator_thrift}, + {"Multiplexing_WeatherReport", multiplexing__weather_report_thrift} + ], {ok, Pid} = thrift_socket_server:start([ {ip, "127.0.0.1"}, @@ -21,21 +39,32 @@ start_multiplexed_server_test() -> {name, ?MODULE}, {service, Services}, {handler, [ - {"error_handler", ?MODULE}, - {"Multiplexing_Calculator", ?MODULE}, + {"error_handler", ?MODULE}, + {"Multiplexing_Calculator", ?MODULE}, {"Multiplexing_WeatherReport", ?MODULE} ]} - ]), + ]), - {ok, [{"Multiplexing_Calculator", CalculatorClient0}, - {"Multiplexing_WeatherReport", WeatherReportClient0}]} = thrift_client_util:new_multiplexed("127.0.0.1", Port, Services, []), + {ok, [ + {"Multiplexing_Calculator", CalculatorClient0}, + {"Multiplexing_WeatherReport", WeatherReportClient0} + ]} = thrift_client_util:new_multiplexed("127.0.0.1", Port, Services, []), - ?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(WeatherReportClient0, getTemperature, [1])), + ?assertMatch( + {_, {error, {bad_args, _, _}}}, + thrift_client:call(WeatherReportClient0, getTemperature, [1]) + ), ?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(CalculatorClient0, add, [1])), - ?assertMatch({_, {error, {bad_args, _, _}}}, thrift_client:call(CalculatorClient0, add, [1,1,1])), + ?assertMatch( + {_, {error, {bad_args, _, _}}}, thrift_client:call(CalculatorClient0, add, [1, 1, 1]) + ), - ?assertMatch({_, {error, {no_function, _}}}, thrift_client:call(CalculatorClient0, getTemperature, [])), - ?assertMatch({_, {error, {no_function, _}}}, thrift_client:call(WeatherReportClient0, add, [41, 1])), + ?assertMatch( + {_, {error, {no_function, _}}}, thrift_client:call(CalculatorClient0, getTemperature, []) + ), + ?assertMatch( + {_, {error, {no_function, _}}}, thrift_client:call(WeatherReportClient0, add, [41, 1]) + ), ?assertMatch({_, {ok, 42}}, thrift_client:call(CalculatorClient0, add, [41, 1])), ?assertMatch({_, {ok, 42.0}}, thrift_client:call(WeatherReportClient0, getTemperature, [])), @@ -47,11 +76,10 @@ start_multiplexed_server_test() -> %% Calculator handles handle_function(add, {X, Y}) -> {reply, X + Y}; - %% WeatherReport handles handle_function(getTemperature, {}) -> {reply, 42.0}. handle_error(_F, _Reason) -> -%% ?debugHere, ?debugVal({_F, _Reason}), - ok. \ No newline at end of file + %% ?debugHere, ?debugVal({_F, _Reason}), + ok. diff --git a/lib/erl/test/name_conflict_test.erl b/lib/erl/test/name_conflict_test.erl index b01df573212..30c1a8ec7d0 100644 --- a/lib/erl/test/name_conflict_test.erl +++ b/lib/erl/test/name_conflict_test.erl @@ -18,282 +18,333 @@ %% -module(name_conflict_test). --compile(export_all). -include_lib("eunit/include/eunit.hrl"). -include("gen-erl/name_conflict_test_constants.hrl"). record_generation_test_() -> - [ - {"using record", ?_assertMatch( - {using, _, _}, - #using{single=null,integer=null} - )}, - {"delegate record", ?_assertMatch( - {delegate, _, _}, - #delegate{partial=null,delegate=null} - )}, - {"get record", ?_assertMatch( - {get, _}, - #get{sbyte=null} - )}, - {"partial record", ?_assertMatch( - {partial, _, _, _}, - #partial{using=null} - )}, - {"ClassAndProp record", ?_assertMatch( - {'ClassAndProp', _, _, _, _}, - #'ClassAndProp'{ - 'ClassAndProp'=null, - 'ClassAndProp_'=null, - 'ClassAndProp__'=null, - 'ClassAndProper'=null - } - )}, - {"second_chance record", ?_assertMatch( - {second_chance, _, _, _, _}, - #second_chance{ - 'SECOND_CHANCE'=null, - 'SECOND_CHANCE_'=null, - 'SECOND_CHANCE__'=null, - 'SECOND_CHANCES'=null - } - )}, - {"NOW_EAT_THIS record", ?_assertMatch( - {'NOW_EAT_THIS', _, _, _, _}, - #'NOW_EAT_THIS'{ - now_eat_this=null, - now_eat_this_=null, - now_eat_this__=null, - now_eat_this_and_this=null - } - )}, - {"TheEdgeCase record", ?_assertMatch( - {'TheEdgeCase', _, _, _, _, _, _}, - #'TheEdgeCase'{ - theEdgeCase=null, - theEdgeCase_=null, - theEdgeCase__=null, - 'TheEdgeCase'=null, - 'TheEdgeCase_'=null, - 'TheEdgeCase__'=null - } - )}, - {"Tricky_ record", ?_assertMatch( - {'Tricky_', _, _}, - #'Tricky_'{tricky=null,'Tricky'=null} - )}, - {"Nested record", ?_assertMatch( - {'Nested', _, _, _, _, _, _}, - #'Nested'{ - 'ClassAndProp'=null, - second_chance=null, - 'NOW_EAT_THIS'=null, - 'TheEdgeCase'=null, - 'Tricky_'=null, - 'Nested'=null - } - )}, - {"Problem_ record", ?_assertMatch( - {'Problem_', _, _}, - #'Problem_'{problem=null,'Problem'=null} - )} - ]. + [ + {"using record", + ?_assertMatch( + {using, _, _}, + #using{single = null, integer = null} + )}, + {"delegate record", + ?_assertMatch( + {delegate, _, _}, + #delegate{partial = null, delegate = null} + )}, + {"get record", + ?_assertMatch( + {get, _}, + #get{sbyte = null} + )}, + {"partial record", + ?_assertMatch( + {partial, _, _, _}, + #partial{using = null} + )}, + {"ClassAndProp record", + ?_assertMatch( + {'ClassAndProp', _, _, _, _}, + #'ClassAndProp'{ + 'ClassAndProp' = null, + 'ClassAndProp_' = null, + 'ClassAndProp__' = null, + 'ClassAndProper' = null + } + )}, + {"second_chance record", + ?_assertMatch( + {second_chance, _, _, _, _}, + #second_chance{ + 'SECOND_CHANCE' = null, + 'SECOND_CHANCE_' = null, + 'SECOND_CHANCE__' = null, + 'SECOND_CHANCES' = null + } + )}, + {"NOW_EAT_THIS record", + ?_assertMatch( + {'NOW_EAT_THIS', _, _, _, _}, + #'NOW_EAT_THIS'{ + now_eat_this = null, + now_eat_this_ = null, + now_eat_this__ = null, + now_eat_this_and_this = null + } + )}, + {"TheEdgeCase record", + ?_assertMatch( + {'TheEdgeCase', _, _, _, _, _, _}, + #'TheEdgeCase'{ + theEdgeCase = null, + theEdgeCase_ = null, + theEdgeCase__ = null, + 'TheEdgeCase' = null, + 'TheEdgeCase_' = null, + 'TheEdgeCase__' = null + } + )}, + {"Tricky_ record", + ?_assertMatch( + {'Tricky_', _, _}, + #'Tricky_'{tricky = null, 'Tricky' = null} + )}, + {"Nested record", + ?_assertMatch( + {'Nested', _, _, _, _, _, _}, + #'Nested'{ + 'ClassAndProp' = null, + second_chance = null, + 'NOW_EAT_THIS' = null, + 'TheEdgeCase' = null, + 'Tricky_' = null, + 'Nested' = null + } + )}, + {"Problem_ record", + ?_assertMatch( + {'Problem_', _, _}, + #'Problem_'{problem = null, 'Problem' = null} + )} + ]. struct_info_test_() -> - [ - {"using definition", ?_assertEqual( - {struct, [{1, double},{2, double}]}, - name_conflict_test_types:struct_info(using) - )}, - {"delegate definition", ?_assertEqual( - {struct, [ - {1, string}, - {2, {struct, {name_conflict_test_types, delegate}}} - ]}, - name_conflict_test_types:struct_info(delegate) - )}, - {"get definition", ?_assertEqual( - {struct, [{1, bool}]}, - name_conflict_test_types:struct_info(get) - )}, - {"partial definition", ?_assertEqual( - {struct, [ - {1, {struct, {name_conflict_test_types, using}}}, - {2, bool}, - {3, bool} - ]}, - name_conflict_test_types:struct_info(partial) - )}, - {"ClassAndProp definition", ?_assertEqual( - {struct, [{1, bool},{2, bool},{3, bool},{4, bool}]}, - name_conflict_test_types:struct_info('ClassAndProp') - )}, - {"second_chance definition", ?_assertEqual( - {struct, [{1, bool},{2, bool},{3, bool},{4, bool}]}, - name_conflict_test_types:struct_info(second_chance) - )}, - {"NOW_EAT_THIS definition", ?_assertEqual( - {struct, [{1, bool},{2, bool},{3, bool},{4, bool}]}, - name_conflict_test_types:struct_info('NOW_EAT_THIS') - )}, - {"TheEdgeCase definition", ?_assertEqual( - {struct, [{1, bool},{2, bool},{3, bool},{4, bool},{5, bool},{6, bool}]}, - name_conflict_test_types:struct_info('TheEdgeCase') - )}, - {"Tricky_ definition", ?_assertEqual( - {struct, [{1, bool},{2, bool}]}, - name_conflict_test_types:struct_info('Tricky_') - )}, - {"Nested definition", ?_assertEqual( - {struct, [ - {1, {struct, {name_conflict_test_types, 'ClassAndProp'}}}, - {2, {struct, {name_conflict_test_types, second_chance}}}, - {3, {struct, {name_conflict_test_types, 'NOW_EAT_THIS'}}}, - {4, {struct, {name_conflict_test_types, 'TheEdgeCase'}}}, - {5, {struct, {name_conflict_test_types, 'Tricky_'}}}, - {6, {struct, {name_conflict_test_types, 'Nested'}}} - ]}, - name_conflict_test_types:struct_info('Nested') - )}, - {"Problem_ definition", ?_assertEqual( - {struct, [{1, bool},{2, bool}]}, - name_conflict_test_types:struct_info('Problem_') - )}, - {"using extended definition", ?_assertEqual( - {struct, [ - {1, undefined, double, single, undefined}, - {2, undefined, double, integer, undefined} - ]}, - name_conflict_test_types:struct_info_ext(using) - )}, - {"delegate extended definition", ?_assertEqual( - {struct, [ - {1, undefined, string, partial, undefined}, - {2, undefined, {struct, {name_conflict_test_types, delegate}}, delegate, undefined} - ]}, - name_conflict_test_types:struct_info_ext(delegate) - )}, - {"get extended definition", ?_assertEqual( - {struct, [{1, undefined, bool, sbyte, undefined}]}, - name_conflict_test_types:struct_info_ext(get) - )}, - {"partial extended definition", ?_assertEqual( - {struct, [ - {1, undefined, {struct, {name_conflict_test_types, using}}, using, #using{}}, - {2, undefined, bool, read, undefined}, - {3, undefined, bool, write, undefined} - ]}, - name_conflict_test_types:struct_info_ext(partial) - )}, - {"ClassAndProp extended definition", ?_assertEqual( - {struct, [ - {1, undefined, bool, 'ClassAndProp', undefined}, - {2, undefined, bool, 'ClassAndProp_', undefined}, - {3, undefined, bool, 'ClassAndProp__', undefined}, - {4, undefined, bool, 'ClassAndProper', undefined} - ]}, - name_conflict_test_types:struct_info_ext('ClassAndProp') - )}, - {"second_chance extended definition", ?_assertEqual( - {struct, [ - {1, undefined, bool, 'SECOND_CHANCE', undefined}, - {2, undefined, bool, 'SECOND_CHANCE_', undefined}, - {3, undefined, bool, 'SECOND_CHANCE__', undefined}, - {4, undefined, bool, 'SECOND_CHANCES', undefined} - ]}, - name_conflict_test_types:struct_info_ext(second_chance) - )}, - {"NOW_EAT_THIS extended definition", ?_assertEqual( - {struct, [ - {1, undefined, bool, now_eat_this, undefined}, - {2, undefined, bool, now_eat_this_, undefined}, - {3, undefined, bool, now_eat_this__, undefined}, - {4, undefined, bool, now_eat_this_and_this, undefined} - ]}, - name_conflict_test_types:struct_info_ext('NOW_EAT_THIS') - )}, - {"TheEdgeCase extended definition", ?_assertEqual( - {struct, [ - {1, undefined, bool, theEdgeCase, undefined}, - {2, undefined, bool, theEdgeCase_, undefined}, - {3, undefined, bool, theEdgeCase__, undefined}, - {4, undefined, bool, 'TheEdgeCase', undefined}, - {5, undefined, bool, 'TheEdgeCase_', undefined}, - {6, undefined, bool, 'TheEdgeCase__', undefined} - ]}, - name_conflict_test_types:struct_info_ext('TheEdgeCase') - )}, - {"Tricky_ extended definition", ?_assertEqual( - {struct, [ - {1, undefined, bool, tricky, undefined}, - {2, undefined, bool, 'Tricky', undefined} - ]}, - name_conflict_test_types:struct_info_ext('Tricky_') - )}, - {"Nested extended definition", ?_assertEqual( - {struct, [ - {1, undefined, {struct, { - name_conflict_test_types, - 'ClassAndProp' - }}, 'ClassAndProp', #'ClassAndProp'{}}, - {2, undefined, {struct, { - name_conflict_test_types, - second_chance - }}, second_chance, #second_chance{}}, - {3, undefined, {struct, { - name_conflict_test_types, - 'NOW_EAT_THIS' - }}, 'NOW_EAT_THIS', #'NOW_EAT_THIS'{}}, - {4, undefined, {struct, { - name_conflict_test_types, - 'TheEdgeCase' - }}, 'TheEdgeCase', #'TheEdgeCase'{}}, - {5, undefined, {struct, { - name_conflict_test_types, - 'Tricky_' - }}, 'Tricky_', #'Tricky_'{}}, - {6, undefined, {struct, { - name_conflict_test_types, - 'Nested' - }}, 'Nested', undefined} - ]}, - name_conflict_test_types:struct_info_ext('Nested') - )}, - {"Problem_ extended definition", ?_assertEqual( - {struct, [ - {1, undefined, bool, problem, undefined}, - {2, undefined, bool, 'Problem', undefined} - ]}, - name_conflict_test_types:struct_info_ext('Problem_') - )} - ]. + [ + {"using definition", + ?_assertEqual( + {struct, [{1, double}, {2, double}]}, + name_conflict_test_types:struct_info(using) + )}, + {"delegate definition", + ?_assertEqual( + {struct, [ + {1, string}, + {2, {struct, {name_conflict_test_types, delegate}}} + ]}, + name_conflict_test_types:struct_info(delegate) + )}, + {"get definition", + ?_assertEqual( + {struct, [{1, bool}]}, + name_conflict_test_types:struct_info(get) + )}, + {"partial definition", + ?_assertEqual( + {struct, [ + {1, {struct, {name_conflict_test_types, using}}}, + {2, bool}, + {3, bool} + ]}, + name_conflict_test_types:struct_info(partial) + )}, + {"ClassAndProp definition", + ?_assertEqual( + {struct, [{1, bool}, {2, bool}, {3, bool}, {4, bool}]}, + name_conflict_test_types:struct_info('ClassAndProp') + )}, + {"second_chance definition", + ?_assertEqual( + {struct, [{1, bool}, {2, bool}, {3, bool}, {4, bool}]}, + name_conflict_test_types:struct_info(second_chance) + )}, + {"NOW_EAT_THIS definition", + ?_assertEqual( + {struct, [{1, bool}, {2, bool}, {3, bool}, {4, bool}]}, + name_conflict_test_types:struct_info('NOW_EAT_THIS') + )}, + {"TheEdgeCase definition", + ?_assertEqual( + {struct, [{1, bool}, {2, bool}, {3, bool}, {4, bool}, {5, bool}, {6, bool}]}, + name_conflict_test_types:struct_info('TheEdgeCase') + )}, + {"Tricky_ definition", + ?_assertEqual( + {struct, [{1, bool}, {2, bool}]}, + name_conflict_test_types:struct_info('Tricky_') + )}, + {"Nested definition", + ?_assertEqual( + {struct, [ + {1, {struct, {name_conflict_test_types, 'ClassAndProp'}}}, + {2, {struct, {name_conflict_test_types, second_chance}}}, + {3, {struct, {name_conflict_test_types, 'NOW_EAT_THIS'}}}, + {4, {struct, {name_conflict_test_types, 'TheEdgeCase'}}}, + {5, {struct, {name_conflict_test_types, 'Tricky_'}}}, + {6, {struct, {name_conflict_test_types, 'Nested'}}} + ]}, + name_conflict_test_types:struct_info('Nested') + )}, + {"Problem_ definition", + ?_assertEqual( + {struct, [{1, bool}, {2, bool}]}, + name_conflict_test_types:struct_info('Problem_') + )}, + {"using extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, double, single, undefined}, + {2, undefined, double, integer, undefined} + ]}, + name_conflict_test_types:struct_info_ext(using) + )}, + {"delegate extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, string, partial, undefined}, + {2, undefined, {struct, {name_conflict_test_types, delegate}}, delegate, + undefined} + ]}, + name_conflict_test_types:struct_info_ext(delegate) + )}, + {"get extended definition", + ?_assertEqual( + {struct, [{1, undefined, bool, sbyte, undefined}]}, + name_conflict_test_types:struct_info_ext(get) + )}, + {"partial extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, {struct, {name_conflict_test_types, using}}, using, #using{}}, + {2, undefined, bool, read, undefined}, + {3, undefined, bool, write, undefined} + ]}, + name_conflict_test_types:struct_info_ext(partial) + )}, + {"ClassAndProp extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, bool, 'ClassAndProp', undefined}, + {2, undefined, bool, 'ClassAndProp_', undefined}, + {3, undefined, bool, 'ClassAndProp__', undefined}, + {4, undefined, bool, 'ClassAndProper', undefined} + ]}, + name_conflict_test_types:struct_info_ext('ClassAndProp') + )}, + {"second_chance extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, bool, 'SECOND_CHANCE', undefined}, + {2, undefined, bool, 'SECOND_CHANCE_', undefined}, + {3, undefined, bool, 'SECOND_CHANCE__', undefined}, + {4, undefined, bool, 'SECOND_CHANCES', undefined} + ]}, + name_conflict_test_types:struct_info_ext(second_chance) + )}, + {"NOW_EAT_THIS extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, bool, now_eat_this, undefined}, + {2, undefined, bool, now_eat_this_, undefined}, + {3, undefined, bool, now_eat_this__, undefined}, + {4, undefined, bool, now_eat_this_and_this, undefined} + ]}, + name_conflict_test_types:struct_info_ext('NOW_EAT_THIS') + )}, + {"TheEdgeCase extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, bool, theEdgeCase, undefined}, + {2, undefined, bool, theEdgeCase_, undefined}, + {3, undefined, bool, theEdgeCase__, undefined}, + {4, undefined, bool, 'TheEdgeCase', undefined}, + {5, undefined, bool, 'TheEdgeCase_', undefined}, + {6, undefined, bool, 'TheEdgeCase__', undefined} + ]}, + name_conflict_test_types:struct_info_ext('TheEdgeCase') + )}, + {"Tricky_ extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, bool, tricky, undefined}, + {2, undefined, bool, 'Tricky', undefined} + ]}, + name_conflict_test_types:struct_info_ext('Tricky_') + )}, + {"Nested extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, + {struct, { + name_conflict_test_types, + 'ClassAndProp' + }}, + 'ClassAndProp', #'ClassAndProp'{}}, + {2, undefined, + {struct, { + name_conflict_test_types, + second_chance + }}, + second_chance, #second_chance{}}, + {3, undefined, + {struct, { + name_conflict_test_types, + 'NOW_EAT_THIS' + }}, + 'NOW_EAT_THIS', #'NOW_EAT_THIS'{}}, + {4, undefined, + {struct, { + name_conflict_test_types, + 'TheEdgeCase' + }}, + 'TheEdgeCase', #'TheEdgeCase'{}}, + {5, undefined, + {struct, { + name_conflict_test_types, + 'Tricky_' + }}, + 'Tricky_', #'Tricky_'{}}, + {6, undefined, + {struct, { + name_conflict_test_types, + 'Nested' + }}, + 'Nested', undefined} + ]}, + name_conflict_test_types:struct_info_ext('Nested') + )}, + {"Problem_ extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, bool, problem, undefined}, + {2, undefined, bool, 'Problem', undefined} + ]}, + name_conflict_test_types:struct_info_ext('Problem_') + )} + ]. service_info_test_() -> - [ - {"event params", ?_assertEqual( - {struct, [{1, {struct, {name_conflict_test_types, partial}}}]}, - extern_thrift:function_info(event, params_type) - )}, - {"event reply", ?_assertEqual( - {struct, {name_conflict_test_types, delegate}}, - extern_thrift:function_info(event, reply_type) - )}, - {"event exceptions", ?_assertEqual( - {struct, []}, - extern_thrift:function_info(event, exceptions) - )}, - {"Foo params", ?_assertEqual( - {struct, [{1, {struct, {name_conflict_test_types, 'Nested'}}}]}, - extern_thrift:function_info('Foo', params_type) - )}, - {"Foo reply", ?_assertEqual( - {struct, []}, - extern_thrift:function_info('Foo', reply_type) - )}, - {"Foo exceptions", ?_assertEqual( - {struct, [{1, {struct, {name_conflict_test_types, 'Problem_'}}}]}, - extern_thrift:function_info('Foo', exceptions) - )} - ]. + [ + {"event params", + ?_assertEqual( + {struct, [{1, {struct, {name_conflict_test_types, partial}}}]}, + extern_thrift:function_info(event, params_type) + )}, + {"event reply", + ?_assertEqual( + {struct, {name_conflict_test_types, delegate}}, + extern_thrift:function_info(event, reply_type) + )}, + {"event exceptions", + ?_assertEqual( + {struct, []}, + extern_thrift:function_info(event, exceptions) + )}, + {"Foo params", + ?_assertEqual( + {struct, [{1, {struct, {name_conflict_test_types, 'Nested'}}}]}, + extern_thrift:function_info('Foo', params_type) + )}, + {"Foo reply", + ?_assertEqual( + {struct, []}, + extern_thrift:function_info('Foo', reply_type) + )}, + {"Foo exceptions", + ?_assertEqual( + {struct, [{1, {struct, {name_conflict_test_types, 'Problem_'}}}]}, + extern_thrift:function_info('Foo', exceptions) + )} + ]. diff --git a/lib/erl/test/stress_server.erl b/lib/erl/test/stress_server.erl index 35fff069370..78ddefe6e71 100644 --- a/lib/erl/test/stress_server.erl +++ b/lib/erl/test/stress_server.erl @@ -19,33 +19,32 @@ -module(stress_server). +-export([ + start_link/1, --export([start_link/1, + handle_function/2, - handle_function/2, - - echoVoid/0, - echoByte/1, - echoI32/1, - echoI64/1, - echoString/1, - echoList/1, - echoSet/1, - echoMap/1 - ]). + echoVoid/0, + echoByte/1, + echoI32/1, + echoI64/1, + echoString/1, + echoList/1, + echoSet/1, + echoMap/1 +]). start_link(Port) -> thrift_server:start_link(Port, service_thrift, ?MODULE). - handle_function(Function, Args) -> case apply(?MODULE, Function, tuple_to_list(Args)) of ok -> - ok; - Else -> {reply, Else} + ok; + Else -> + {reply, Else} end. - echoVoid() -> ok. echoByte(X) -> diff --git a/lib/erl/test/test_const.erl b/lib/erl/test/test_const.erl index 627777baa7d..74830e9736f 100644 --- a/lib/erl/test/test_const.erl +++ b/lib/erl/test/test_const.erl @@ -25,30 +25,31 @@ -include("gen-erl/constants_demo_types.hrl"). namespace_test() -> - %% Verify that records produced by ConstantsDemo.thrift have the right namespace. - io:format(user, "in namespace_test()\n", []), - {struct, _} = constants_demo_types:struct_info('consts_thing'), - {struct, _} = constants_demo_types:struct_info('consts_Blah'), - ok. + %% Verify that records produced by ConstantsDemo.thrift have the right namespace. + io:format(user, "in namespace_test()\n", []), + {struct, _} = constants_demo_types:struct_info('consts_thing'), + {struct, _} = constants_demo_types:struct_info('consts_Blah'), + ok. const_map_test() -> - ?assertEqual(233, constants_demo_constants:gen_map(35532)), - ?assertError(function_clause, constants_demo_constants:gen_map(0)), + ?assertEqual(233, constants_demo_constants:gen_map(35532)), + ?assertError(function_clause, constants_demo_constants:gen_map(0)), - ?assertEqual(853, constants_demo_constants:gen_map(43523, default)), - ?assertEqual(default, constants_demo_constants:gen_map(10110, default)), + ?assertEqual(853, constants_demo_constants:gen_map(43523, default)), + ?assertEqual(default, constants_demo_constants:gen_map(10110, default)), - ?assertEqual(98325, constants_demo_constants:gen_map2("lkjsdf")), - ?assertError(function_clause, constants_demo_constants:gen_map2("nonexist")), + ?assertEqual(98325, constants_demo_constants:gen_map2("lkjsdf")), + ?assertError(function_clause, constants_demo_constants:gen_map2("nonexist")), - ?assertEqual(233, constants_demo_constants:gen_map2("hello", 321)), - ?assertEqual(321, constants_demo_constants:gen_map2("goodbye", 321)). + ?assertEqual(233, constants_demo_constants:gen_map2("hello", 321)), + ?assertEqual(321, constants_demo_constants:gen_map2("goodbye", 321)). const_list_test() -> - ?assertEqual(23598352, constants_demo_constants:gen_list(2)), - ?assertError(function_clause, constants_demo_constants:gen_list(0)), + ?assertEqual(23598352, constants_demo_constants:gen_list(2)), + ?assertError(function_clause, constants_demo_constants:gen_list(0)), - ?assertEqual(3253523, constants_demo_constants:gen_list(3, default)), - ?assertEqual(default, constants_demo_constants:gen_list(10, default)). + ?assertEqual(3253523, constants_demo_constants:gen_list(3, default)), + ?assertEqual(default, constants_demo_constants:gen_list(10, default)). --endif. %% TEST +%% TEST +-endif. diff --git a/lib/erl/test/test_disklog.erl b/lib/erl/test/test_disklog.erl index dcb6fc1b925..742e895fd0f 100644 --- a/lib/erl/test/test_disklog.erl +++ b/lib/erl/test/test_disklog.erl @@ -23,77 +23,83 @@ -include_lib("eunit/include/eunit.hrl"). disklog_test() -> - {ok, TransportFactory} = - thrift_disk_log_transport:new_transport_factory( - test_disklog, - [{file, "./test_log"}, - {size, {1024*1024, 10}}]), - {ok, ProtocolFactory} = - thrift_binary_protocol:new_protocol_factory( TransportFactory, []), - {ok, Proto} = ProtocolFactory(), - {ok, Client0} = thrift_client:new(Proto, thrift_test_thrift), - - io:format("Client started~n"), - - % We have to make oneway calls into this client only since otherwise it - % will try to read from the disklog and go boom. - {Client1, {ok, ok}} = thrift_client:call(Client0, testOneway, [16#deadbeef]), - io:format("Call written~n"), - - % Use the send_call method to write a non-oneway call into the log - {Client2, ok} = - thrift_client:send_call(Client1, testString, [<<"hello world">>]), - io:format("Non-oneway call sent~n"), - - {_Client3, ok} = thrift_client:close(Client2), - io:format("Client closed~n"), - - lists:foreach(fun(File) -> file:delete(File) end, [ - "./test_log.1", - "./test_log.idx", - "./test_log.siz" - ]), - io:format("Cleaning up test files~n"), - - ok. + {ok, TransportFactory} = + thrift_disk_log_transport:new_transport_factory( + test_disklog, + [ + {file, "./test_log"}, + {size, {1024 * 1024, 10}} + ] + ), + {ok, ProtocolFactory} = + thrift_binary_protocol:new_protocol_factory(TransportFactory, []), + {ok, Proto} = ProtocolFactory(), + {ok, Client0} = thrift_client:new(Proto, thrift_test_thrift), + + io:format("Client started~n"), + + % We have to make oneway calls into this client only since otherwise it + % will try to read from the disklog and go boom. + {Client1, {ok, ok}} = thrift_client:call(Client0, testOneway, [16#deadbeef]), + io:format("Call written~n"), + + % Use the send_call method to write a non-oneway call into the log + {Client2, ok} = + thrift_client:send_call(Client1, testString, [<<"hello world">>]), + io:format("Non-oneway call sent~n"), + + {_Client3, ok} = thrift_client:close(Client2), + io:format("Client closed~n"), + + lists:foreach(fun(File) -> file:delete(File) end, [ + "./test_log.1", + "./test_log.idx", + "./test_log.siz" + ]), + io:format("Cleaning up test files~n"), + + ok. disklog_base64_test() -> - {ok, TransportFactory} = - thrift_disk_log_transport:new_transport_factory( - test_disklog, - [{file, "./test_b64_log"}, - {size, {1024*1024, 10}}]), - {ok, B64Factory} = - thrift_base64_transport:new_transport_factory(TransportFactory), - {ok, BufFactory} = - thrift_buffered_transport:new_transport_factory(B64Factory), - {ok, ProtocolFactory} = - thrift_binary_protocol:new_protocol_factory(BufFactory, []), - {ok, Proto} = ProtocolFactory(), - {ok, Client0} = thrift_client:new(Proto, thrift_test_thrift), - - io:format("Client started~n"), - - % We have to make oneway calls into this client only since otherwise - % it will try to read from the disklog and go boom. - {Client1, {ok, ok}} = thrift_client:call(Client0, testOneway, [16#deadbeef]), - io:format("Call written~n"), - - % Use the send_call method to write a non-oneway call into the log - {Client2, ok} = - thrift_client:send_call(Client1, testString, [<<"hello world">>]), - io:format("Non-oneway call sent~n"), - - {_Client3, ok} = thrift_client:close(Client2), - io:format("Client closed~n"), - - lists:foreach(fun(File) -> file:delete(File) end, [ - "./test_b64_log.1", - "./test_b64_log.idx", - "./test_b64_log.siz" - ]), - io:format("Cleaning up test files~n"), - - ok. + {ok, TransportFactory} = + thrift_disk_log_transport:new_transport_factory( + test_disklog, + [ + {file, "./test_b64_log"}, + {size, {1024 * 1024, 10}} + ] + ), + {ok, B64Factory} = + thrift_base64_transport:new_transport_factory(TransportFactory), + {ok, BufFactory} = + thrift_buffered_transport:new_transport_factory(B64Factory), + {ok, ProtocolFactory} = + thrift_binary_protocol:new_protocol_factory(BufFactory, []), + {ok, Proto} = ProtocolFactory(), + {ok, Client0} = thrift_client:new(Proto, thrift_test_thrift), + + io:format("Client started~n"), + + % We have to make oneway calls into this client only since otherwise + % it will try to read from the disklog and go boom. + {Client1, {ok, ok}} = thrift_client:call(Client0, testOneway, [16#deadbeef]), + io:format("Call written~n"), + + % Use the send_call method to write a non-oneway call into the log + {Client2, ok} = + thrift_client:send_call(Client1, testString, [<<"hello world">>]), + io:format("Non-oneway call sent~n"), + + {_Client3, ok} = thrift_client:close(Client2), + io:format("Client closed~n"), + + lists:foreach(fun(File) -> file:delete(File) end, [ + "./test_b64_log.1", + "./test_b64_log.idx", + "./test_b64_log.siz" + ]), + io:format("Cleaning up test files~n"), + + ok. -endif. diff --git a/lib/erl/test/test_omit.erl b/lib/erl/test/test_omit.erl index 80841e2910d..a51f1ed5a47 100644 --- a/lib/erl/test/test_omit.erl +++ b/lib/erl/test/test_omit.erl @@ -1,3 +1,22 @@ +%% +%% Licensed to the Apache Software Foundation (ASF) under one +%% or more contributor license agreements. See the NOTICE file +%% distributed with this work for additional information +%% regarding copyright ownership. The ASF licenses this file +%% to you under the Apache License, Version 2.0 (the +%% "License"); you may not use this file except in compliance +%% with the License. You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, +%% software distributed under the License is distributed on an +%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +%% KIND, either express or implied. See the License for the +%% specific language governing permissions and limitations +%% under the License. +%% + -module(test_omit). -include("gen-erl/thrift_omit_with_types.hrl"). @@ -6,74 +25,83 @@ -include_lib("eunit/include/eunit.hrl"). omit_struct1_test() -> - %% In this test, the field that is deleted is a basic type (an i32). - A = #test1{one = 1, three = 3}, - B = #test1{one = 1, two = 2, three = 3}, - {ok, Transport} = thrift_membuffer_transport:new(), - {ok, P0} = thrift_binary_protocol:new(Transport), - - {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, A)}}, A}), - {P2, {ok, O0}} = thrift_protocol:read(P1, {struct, {thrift_omit_without_types, element(1, A)}}), - ?assertEqual(element(1, A), element(1, O0)), - ?assertEqual(element(2, A), element(2, O0)), - ?assertEqual(element(4, A), element(3, O0)), - - {P3, ok} = thrift_protocol:write(P2, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), - {_P4, {ok, O1}} = thrift_protocol:read(P3, {struct, {thrift_omit_without_types, element(1, A)}}), - ?assertEqual(element(1, A), element(1, O1)), - ?assertEqual(element(2, A), element(2, O1)), - ?assertEqual(element(4, A), element(3, O1)), - - ok. + %% In this test, the field that is deleted is a basic type (an i32). + A = #test1{one = 1, three = 3}, + B = #test1{one = 1, two = 2, three = 3}, + {ok, Transport} = thrift_membuffer_transport:new(), + {ok, P0} = thrift_binary_protocol:new(Transport), + + {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, A)}}, A}), + {P2, {ok, O0}} = thrift_protocol:read(P1, {struct, {thrift_omit_without_types, element(1, A)}}), + ?assertEqual(element(1, A), element(1, O0)), + ?assertEqual(element(2, A), element(2, O0)), + ?assertEqual(element(4, A), element(3, O0)), + + {P3, ok} = thrift_protocol:write(P2, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), + {_P4, {ok, O1}} = thrift_protocol:read( + P3, {struct, {thrift_omit_without_types, element(1, A)}} + ), + ?assertEqual(element(1, A), element(1, O1)), + ?assertEqual(element(2, A), element(2, O1)), + ?assertEqual(element(4, A), element(3, O1)), + + ok. omit_struct2_test() -> - %% In this test, the field that is deleted is a struct. - A = #test2{one = 1, two = #test2{one = 10, three = 30}, three = 3}, - B = #test2{one = 1, two = #test2{one = 10, two = #test2{one = 100}, three = 30}, three = 3}, + %% In this test, the field that is deleted is a struct. + A = #test2{one = 1, two = #test2{one = 10, three = 30}, three = 3}, + B = #test2{one = 1, two = #test2{one = 10, two = #test2{one = 100}, three = 30}, three = 3}, - {ok, Transport} = thrift_membuffer_transport:new(), - {ok, P0} = thrift_binary_protocol:new(Transport), + {ok, Transport} = thrift_membuffer_transport:new(), + {ok, P0} = thrift_binary_protocol:new(Transport), - {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, A)}}, A}), - {P2, {ok, O0}} = thrift_protocol:read(P1, {struct, {thrift_omit_without_types, element(1, A)}}), - ?assertEqual(element(1, A), element(1, O0)), - ?assertEqual(element(2, A), element(2, O0)), - ?assertEqual(element(4, A), element(3, O0)), + {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, A)}}, A}), + {P2, {ok, O0}} = thrift_protocol:read(P1, {struct, {thrift_omit_without_types, element(1, A)}}), + ?assertEqual(element(1, A), element(1, O0)), + ?assertEqual(element(2, A), element(2, O0)), + ?assertEqual(element(4, A), element(3, O0)), - {P3, ok} = thrift_protocol:write(P2, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), - {_P4, {ok, O1}} = thrift_protocol:read(P3, {struct, {thrift_omit_without_types, element(1, A)}}), - ?assertEqual(element(1, A), element(1, O1)), - ?assertEqual(element(2, A), element(2, O1)), - ?assertEqual(element(4, A), element(3, O1)), + {P3, ok} = thrift_protocol:write(P2, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), + {_P4, {ok, O1}} = thrift_protocol:read( + P3, {struct, {thrift_omit_without_types, element(1, A)}} + ), + ?assertEqual(element(1, A), element(1, O1)), + ?assertEqual(element(2, A), element(2, O1)), + ?assertEqual(element(4, A), element(3, O1)), - ok. + ok. omit_list_test() -> - %% In this test, the field that is deleted is a list. - A = #test1{one = 1, two = 2, three = 3}, - B = #test3{one = 1, two = [ A ]}, + %% In this test, the field that is deleted is a list. + A = #test1{one = 1, two = 2, three = 3}, + B = #test3{one = 1, two = [A]}, - {ok, Transport} = thrift_membuffer_transport:new(), - {ok, P0} = thrift_binary_protocol:new(Transport), + {ok, Transport} = thrift_membuffer_transport:new(), + {ok, P0} = thrift_binary_protocol:new(Transport), - {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), - {_P2, {ok, O0}} = thrift_protocol:read(P1, {struct, {thrift_omit_without_types, element(1, B)}}), - ?assertEqual(element(2, B), element(2, O0)), + {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), + {_P2, {ok, O0}} = thrift_protocol:read( + P1, {struct, {thrift_omit_without_types, element(1, B)}} + ), + ?assertEqual(element(2, B), element(2, O0)), - ok. + ok. omit_map_test() -> - %% In this test, the field that is deleted is a map. - A = #test1{one = 1, two = 2, three = 3}, - B = #test4{one = 1, two = dict:from_list([ {2, A} ])}, + %% In this test, the field that is deleted is a map. + A = #test1{one = 1, two = 2, three = 3}, + B = #test4{one = 1, two = dict:from_list([{2, A}])}, - {ok, Transport} = thrift_membuffer_transport:new(), - {ok, P0} = thrift_binary_protocol:new(Transport), + {ok, Transport} = thrift_membuffer_transport:new(), + {ok, P0} = thrift_binary_protocol:new(Transport), - {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), - {_P2, {ok, O0}} = thrift_protocol:read(P1, {struct, {thrift_omit_without_types, element(1, B)}}), - ?assertEqual(element(2, B), element(2, O0)), + {P1, ok} = thrift_protocol:write(P0, {{struct, {thrift_omit_with_types, element(1, B)}}, B}), + {_P2, {ok, O0}} = thrift_protocol:read( + P1, {struct, {thrift_omit_without_types, element(1, B)}} + ), + ?assertEqual(element(2, B), element(2, O0)), - ok. + ok. --endif. %% TEST +%% TEST +-endif. diff --git a/lib/erl/test/test_rendered_double_constants.erl b/lib/erl/test/test_rendered_double_constants.erl index 87fce8130d9..02950f26aee 100644 --- a/lib/erl/test/test_rendered_double_constants.erl +++ b/lib/erl/test/test_rendered_double_constants.erl @@ -27,42 +27,96 @@ -define(EPSILON, 0.0000001). rendered_double_constants_test() -> - ?assert(abs(1.0 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST) =< ?EPSILON), - ?assert(abs(-100.0 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST) =< ?EPSILON), - ?assert(abs(9223372036854775807.0 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST) =< ?EPSILON), - ?assert(abs(-9223372036854775807.0 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST) =< ?EPSILON), - ?assert(abs(3.14159265359 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST) =< ?EPSILON), - ?assert(abs(1000000.1 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST) =< ?EPSILON), - ?assert(abs(-1000000.1 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST) =< ?EPSILON), - ?assert(abs(1.7e+308 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST) =< ?EPSILON), - ?assert(abs(9223372036854775816.43 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST) =< ?EPSILON), - ?assert(abs(-1.7e+308 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST) =< ?EPSILON), - ?assert(abs(-9223372036854775816.43 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST) =< ?EPSILON), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST)), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST)), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST)), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST)), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST)), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST)), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST)), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST)), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST)), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST)), - ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST)). + ?assert(abs(1.0 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST) =< ?EPSILON), + ?assert( + abs(-100.0 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST) =< + ?EPSILON + ), + ?assert( + abs( + 9223372036854775807.0 - + ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST + ) =< ?EPSILON + ), + ?assert( + abs( + -9223372036854775807.0 - + ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST + ) =< ?EPSILON + ), + ?assert( + abs( + 3.14159265359 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST + ) =< ?EPSILON + ), + ?assert( + abs(1000000.1 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST) =< + ?EPSILON + ), + ?assert( + abs(-1000000.1 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST) =< + ?EPSILON + ), + ?assert( + abs(1.7e+308 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST) =< ?EPSILON + ), + ?assert( + abs( + 9223372036854775816.43 - + ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST + ) =< ?EPSILON + ), + ?assert( + abs(-1.7e+308 - ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST) =< ?EPSILON + ), + ?assert( + abs( + -9223372036854775816.43 - + ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST + ) =< ?EPSILON + ), + ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST)), + ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST)), + ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST)), + ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST)), + ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST)), + ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST)), + ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST)), + ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST)), + ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST)), + ?assert(is_float(?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST)), + ?assert( + is_float( + ?DOUBLE_CONSTANTS_TEST_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST + ) + ). rendered_double_list_test() -> - ?assertEqual(12, length(?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)), - ?assert(abs(1.0 - lists:nth(1, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(-100.0 - lists:nth(2, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(100.0 - lists:nth(3, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(9223372036854775807.0 - lists:nth(4, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(-9223372036854775807.0 - lists:nth(5, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(3.14159265359 - lists:nth(6, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(1000000.1 - lists:nth(7, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(-1000000.1 - lists:nth(8, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(1.7e+308 - lists:nth(9, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(-1.7e+308 - lists:nth(10, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(9223372036854775816.43 - lists:nth(11, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), - ?assert(abs(-9223372036854775816.43 - lists:nth(12, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON). + ?assertEqual(12, length(?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)), + ?assert(abs(1.0 - lists:nth(1, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), + ?assert(abs(-100.0 - lists:nth(2, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), + ?assert(abs(100.0 - lists:nth(3, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), + ?assert( + abs(9223372036854775807.0 - lists:nth(4, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< + ?EPSILON + ), + ?assert( + abs(-9223372036854775807.0 - lists:nth(5, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< + ?EPSILON + ), + ?assert(abs(3.14159265359 - lists:nth(6, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), + ?assert(abs(1000000.1 - lists:nth(7, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), + ?assert(abs(-1000000.1 - lists:nth(8, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), + ?assert(abs(1.7e+308 - lists:nth(9, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), + ?assert(abs(-1.7e+308 - lists:nth(10, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< ?EPSILON), + ?assert( + abs(9223372036854775816.43 - lists:nth(11, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< + ?EPSILON + ), + ?assert( + abs(-9223372036854775816.43 - lists:nth(12, ?DOUBLE_CONSTANTS_TEST_DOUBLE_LIST_TEST)) =< + ?EPSILON + ). --endif. %% TEST \ No newline at end of file +%% TEST +-endif. diff --git a/lib/erl/test/test_thrift_1151.erl b/lib/erl/test/test_thrift_1151.erl index f4a910e7dbb..141787e57c6 100644 --- a/lib/erl/test/test_thrift_1151.erl +++ b/lib/erl/test/test_thrift_1151.erl @@ -1,3 +1,22 @@ +%% +%% Licensed to the Apache Software Foundation (ASF) under one +%% or more contributor license agreements. See the NOTICE file +%% distributed with this work for additional information +%% regarding copyright ownership. The ASF licenses this file +%% to you under the Apache License, Version 2.0 (the +%% "License"); you may not use this file except in compliance +%% with the License. You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, +%% software distributed under the License is distributed on an +%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +%% KIND, either express or implied. See the License for the +%% specific language governing permissions and limitations +%% under the License. +%% + -module(test_thrift_1151). -include("gen-erl/thrift1151_types.hrl"). @@ -6,29 +25,29 @@ -include_lib("eunit/include/eunit.hrl"). unmatched_struct_test() -> - S1 = #'StructC'{x=#'StructB'{x=1}}, - {ok, Transport} = thrift_memory_buffer:new(), - {ok, Protocol} = thrift_binary_protocol:new(Transport), - ?assertException( - error, - struct_unmatched, - thrift_protocol:write( - Protocol, - {{struct, element(2, thrift1151_types:struct_info('StructC'))}, S1} - ) - ). + S1 = #'StructC'{x = #'StructB'{x = 1}}, + {ok, Transport} = thrift_memory_buffer:new(), + {ok, Protocol} = thrift_binary_protocol:new(Transport), + ?assertException( + error, + struct_unmatched, + thrift_protocol:write( + Protocol, + {{struct, element(2, thrift1151_types:struct_info('StructC'))}, S1} + ) + ). badarg_test() -> - S2 = #'StructC'{x=#'StructA'{x="1"}}, - {ok, Transport} = thrift_memory_buffer:new(), - {ok, Protocol} = thrift_binary_protocol:new(Transport), - ?assertException( - error, - badarg, - thrift_protocol:write( - Protocol, - {{struct, element(2, thrift1151_types:struct_info('StructC'))}, S2} - ) - ). + S2 = #'StructC'{x = #'StructA'{x = "1"}}, + {ok, Transport} = thrift_memory_buffer:new(), + {ok, Protocol} = thrift_binary_protocol:new(Transport), + ?assertException( + error, + badarg, + thrift_protocol:write( + Protocol, + {{struct, element(2, thrift1151_types:struct_info('StructC'))}, S2} + ) + ). -endif. diff --git a/lib/erl/test/test_thrift_3214.erl b/lib/erl/test/test_thrift_3214.erl index 118e77944d9..4d7dd3e4082 100644 --- a/lib/erl/test/test_thrift_3214.erl +++ b/lib/erl/test/test_thrift_3214.erl @@ -18,7 +18,6 @@ %% -module(test_thrift_3214). --compile(export_all). -include("gen-erl/thrift3214_types.hrl"). @@ -26,33 +25,38 @@ -include_lib("eunit/include/eunit.hrl"). record_generation_test_() -> - [ - {"StringMap record", ?_assertMatch( - {'StringMap', _}, - #'StringMap'{data=#{50 => "foo"}} - )}, - {"StringMap record defaults", ?_assertEqual( - {'StringMap', #{1 => "a", 2 => "b"}}, - #'StringMap'{} - )}, - {"StringMap record dict from list", ?_assertNotEqual( - {'StringMap', dict:from_list([{1, "a"}, {2, "b"}])}, - #'StringMap'{} - )}, - {"StringMap record map from list", ?_assertEqual( - {'StringMap', maps:from_list([{1, "a"}, {2, "b"}])}, - #'StringMap'{} - )} - ]. + [ + {"StringMap record", + ?_assertMatch( + {'StringMap', _}, + #'StringMap'{data = #{50 => "foo"}} + )}, + {"StringMap record defaults", + ?_assertEqual( + {'StringMap', #{1 => "a", 2 => "b"}}, + #'StringMap'{} + )}, + {"StringMap record dict from list", + ?_assertNotEqual( + {'StringMap', dict:from_list([{1, "a"}, {2, "b"}])}, + #'StringMap'{} + )}, + {"StringMap record map from list", + ?_assertEqual( + {'StringMap', maps:from_list([{1, "a"}, {2, "b"}])}, + #'StringMap'{} + )} + ]. struct_info_test_() -> - [ - {"StringMap extended definition", ?_assertEqual( - {struct, [ - {1, undefined, {map, i32, string}, 'data', #{1 => "a", 2 => "b"}} - ]}, - thrift3214_types:struct_info_ext('StringMap') - )} - ]. + [ + {"StringMap extended definition", + ?_assertEqual( + {struct, [ + {1, undefined, {map, i32, string}, 'data', #{1 => "a", 2 => "b"}} + ]}, + thrift3214_types:struct_info_ext('StringMap') + )} + ]. -endif. diff --git a/lib/erl/test/test_thrift_buffered_transport.erl b/lib/erl/test/test_thrift_buffered_transport.erl index 8519e82a1f8..e7b23ab925e 100644 --- a/lib/erl/test/test_thrift_buffered_transport.erl +++ b/lib/erl/test/test_thrift_buffered_transport.erl @@ -20,340 +20,295 @@ -module(test_thrift_buffered_transport). -include_lib("eunit/include/eunit.hrl"). - new(Transport) -> thrift_buffered_transport:new(Transport). new_test_() -> - [ - {"new buffered membuffer", ?_assertMatch( - {ok, {t_transport, thrift_buffered_transport, {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, []}}, - [] - }}}, - new({t_transport, thrift_membuffer_transport, {t_membuffer, []}}) - )} - ]. - + [ + {"new buffered membuffer", + ?_assertMatch( + {ok, + {t_transport, thrift_buffered_transport, + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, []}}, + []}}}, + new({t_transport, thrift_membuffer_transport, {t_membuffer, []}}) + )} + ]. read(Frame, Bytes) -> thrift_buffered_transport:read(Frame, Bytes). read_test_() -> - [ - {"read zero bytes from an empty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - {ok, <<>>} - }, - read( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - 0 - ) - )}, - {"read 1 byte from an empty buffered membuffer", ?_assertMatch( - {_, {ok, <<>>}}, - read( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - 1 - ) - )}, - {"read zero bytes from nonempty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<"hallo world">> - }}, - [] - }, - {ok, <<>>} - }, - read( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<"hallo world">> - }}, - [] - }, - 0 - ) - )}, - {"read 1 byte from nonempty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}}, - [] - }, - {ok, <<"h">>} - }, - read( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, - [] - }, - 1 - ) - )}, - {"read 1 byte from nonempty buffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}}, - [] - }, - {ok, <<"h">>} - }, - read( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, - [] - }, - 1 - ) - )}, - {"read a zillion bytes from nonempty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - {ok, <<"hallo world">>} - }, - read( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, - [] - }, - 65536 - ) - )} - ]. - + [ + {"read zero bytes from an empty buffered membuffer", + ?_assertMatch( + { + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + []}, + {ok, <<>>} + }, + read( + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + []}, + 0 + ) + )}, + {"read 1 byte from an empty buffered membuffer", + ?_assertMatch( + {_, {ok, <<>>}}, + read( + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + []}, + 1 + ) + )}, + {"read zero bytes from nonempty buffered membuffer", + ?_assertMatch( + { + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + {ok, <<>>} + }, + read( + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + 0 + ) + )}, + {"read 1 byte from nonempty buffered membuffer", + ?_assertMatch( + { + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}}, + []}, + {ok, <<"h">>} + }, + read( + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + 1 + ) + )}, + {"read 1 byte from nonempty buffer", + ?_assertMatch( + { + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}}, + []}, + {ok, <<"h">>} + }, + read( + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + 1 + ) + )}, + {"read a zillion bytes from nonempty buffered membuffer", + ?_assertMatch( + { + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + []}, + {ok, <<"hallo world">>} + }, + read( + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + 65536 + ) + )} + ]. read_exact(Frame, Bytes) -> thrift_buffered_transport:read_exact(Frame, Bytes). read_exact_test_() -> - [ - {"read exactly zero bytes from an empty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - {ok, <<>>} - }, - read_exact( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - 0 - ) - )}, - {"read exactly 1 byte from an empty buffered membuffer", ?_assertMatch( - {_, {error, eof}}, - read_exact( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - 1 - ) - )}, - {"read exactly zero bytes from nonempty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, - [] - }, - {ok, <<>>} - }, - read_exact( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, - [] - }, - 0 - ) - )}, - {"read exactly 1 byte from nonempty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}}, - [] - }, - {ok, <<"h">>} - }, - read_exact( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<"hallo world">> - }}, - [] - }, - 1 - ) - )}, - {"read exactly 1 byte from nonempty buffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}}, - [] - }, - {ok, <<"h">>} - }, - read_exact( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, - [] - }, - 1 - ) - )}, - {"read exactly a zillion bytes from nonempty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, - [] - }, - {error, eof} - }, - read_exact( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<"hallo world">> - }}, - [] - }, - 65536 - ) - )} - ]. - + [ + {"read exactly zero bytes from an empty buffered membuffer", + ?_assertMatch( + { + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + []}, + {ok, <<>>} + }, + read_exact( + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + []}, + 0 + ) + )}, + {"read exactly 1 byte from an empty buffered membuffer", + ?_assertMatch( + {_, {error, eof}}, + read_exact( + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + []}, + 1 + ) + )}, + {"read exactly zero bytes from nonempty buffered membuffer", + ?_assertMatch( + { + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + {ok, <<>>} + }, + read_exact( + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + 0 + ) + )}, + {"read exactly 1 byte from nonempty buffered membuffer", + ?_assertMatch( + { + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}}, + []}, + {ok, <<"h">>} + }, + read_exact( + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + 1 + ) + )}, + {"read exactly 1 byte from nonempty buffer", + ?_assertMatch( + { + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"allo world">>}}, + []}, + {ok, <<"h">>} + }, + read_exact( + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + 1 + ) + )}, + {"read exactly a zillion bytes from nonempty buffered membuffer", + ?_assertMatch( + { + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + {error, eof} + }, + read_exact( + {t_buffered, + {t_transport, thrift_membuffer_transport, {t_membuffer, <<"hallo world">>}}, + []}, + 65536 + ) + )} + ]. write(Framed, Data) -> thrift_buffered_transport:write(Framed, Data). write_test_() -> - [ - {"write empty list to empty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [[], []] - }, - ok - }, - write( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - [] - ) - )}, - {"write empty list to nonempty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [["hallo world"], []] - }, - ok - }, - write( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - ["hallo world"] - }, - [] - ) - )}, - {"write empty binary to empty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [[], <<>>] - }, - ok - }, - write( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - <<>> - ) - )}, - {"write empty binary to nonempty buffered membuffer", ?_assertMatch( - { - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [["hallo world"], <<>>] - }, - ok - }, - write( - {t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - ["hallo world"] - }, - <<>> - ) - )} - ]. - + [ + {"write empty list to empty buffered membuffer", + ?_assertMatch( + { + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [ + [], [] + ]}, + ok + }, + write( + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + []}, + [] + ) + )}, + {"write empty list to nonempty buffered membuffer", + ?_assertMatch( + { + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [ + ["hallo world"], [] + ]}, + ok + }, + write( + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [ + "hallo world" + ]}, + [] + ) + )}, + {"write empty binary to empty buffered membuffer", + ?_assertMatch( + { + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [ + [], <<>> + ]}, + ok + }, + write( + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + []}, + <<>> + ) + )}, + {"write empty binary to nonempty buffered membuffer", + ?_assertMatch( + { + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [ + ["hallo world"], <<>> + ]}, + ok + }, + write( + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [ + "hallo world" + ]}, + <<>> + ) + )} + ]. flush(Transport) -> thrift_buffered_transport:flush(Transport). flush_test_() -> - [ - {"flush empty buffered membuffer", ?_assertMatch( - {{t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - ok - }, - flush({t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }) - )}, - {"flush nonempty buffered membuffer", ?_assertMatch( - {{t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, - [<<>>, <<"hallo world">>] - }}, - [] - }, - ok - }, - flush({t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - <<"hallo world">> - }) - )} - ]. - + [ + {"flush empty buffered membuffer", + ?_assertMatch( + { + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + []}, + ok + }, + flush( + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, []} + ) + )}, + {"flush nonempty buffered membuffer", + ?_assertMatch( + { + {t_buffered, + {t_transport, thrift_membuffer_transport, + {t_membuffer, [<<>>, <<"hallo world">>]}}, + []}, + ok + }, + flush( + {t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + <<"hallo world">>} + ) + )} + ]. close(Transport) -> thrift_buffered_transport:close(Transport). close_test_() -> - {"close buffered membuffer", ?_assertMatch( - {{t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }, - ok - }, - close({t_buffered, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [] - }) - )}. - + {"close buffered membuffer", + ?_assertMatch( + {{t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, []}, ok}, + close({t_buffered, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, []}) + )}. diff --git a/lib/erl/test/test_thrift_compact_protocol.erl b/lib/erl/test/test_thrift_compact_protocol.erl index 5da78c61243..b9efae71c08 100644 --- a/lib/erl/test/test_thrift_compact_protocol.erl +++ b/lib/erl/test/test_thrift_compact_protocol.erl @@ -22,198 +22,203 @@ -include("thrift_constants.hrl"). -include("thrift_protocol.hrl"). - new(Transport) -> thrift_compact_protocol:new(Transport). new() -> - {ok, Transport} = thrift_membuffer_transport:new(), - thrift_compact_protocol:new(Transport). + {ok, Transport} = thrift_membuffer_transport:new(), + thrift_compact_protocol:new(Transport). new_test() -> - new(thrift_membuffer_transport:new()). + new(thrift_membuffer_transport:new()). write(This, Value) -> thrift_protocol:write(This, Value). read(This, Type) -> thrift_protocol:read(This, Type). str(This0, Value0) -> - {This1, ok} = write(This0, {string, Value0}), - {This2, {ok, Value1}} = read(This1, string), - ?assertEqual(Value0, binary_to_list(Value1)), - {This2, ok}. + {This1, ok} = write(This0, {string, Value0}), + {This2, {ok, Value1}} = read(This1, string), + ?assertEqual(Value0, binary_to_list(Value1)), + {This2, ok}. string_test() -> - {ok, This0} = new(), - {This1, ok} = str(This0, "aaa"), - {This2, ok} = str(This1, ""), - {This2, ok}. + {ok, This0} = new(), + {This1, ok} = str(This0, "aaa"), + {This2, ok} = str(This1, ""), + {This2, ok}. round_trip(This0, Type, Value0) -> - {This1, ok} = write(This0, {Type, Value0}), - {This2, {ok, Value1}} = read(This1, Type), - ?assertEqual(Value0, Value1), - {This2, ok}. + {This1, ok} = write(This0, {Type, Value0}), + {This2, {ok, Value1}} = read(This1, Type), + ?assertEqual(Value0, Value1), + {This2, ok}. bool_test() -> - {ok, This0} = new(), - {This1, ok} = round_trip(This0, bool, true), - {This2, ok} = round_trip(This1, bool, false), - {This2, ok}. + {ok, This0} = new(), + {This1, ok} = round_trip(This0, bool, true), + {This2, ok} = round_trip(This1, bool, false), + {This2, ok}. byte(This0, Value0) -> round_trip(This0, byte, Value0). byte_test() -> - {ok, This0} = new(), - {This1, ok} = byte(This0, 0), - {This2, ok} = byte(This1, 42), - {This3, ok} = byte(This2, -1), - {This4, ok} = byte(This3, -128), - {This4, ok}. + {ok, This0} = new(), + {This1, ok} = byte(This0, 0), + {This2, ok} = byte(This1, 42), + {This3, ok} = byte(This2, -1), + {This4, ok} = byte(This3, -128), + {This4, ok}. i16(This0, Value0) -> round_trip(This0, i16, Value0). i16_test() -> - {ok, This0} = new(), - {This1, ok} = i16(This0, 0), - {This2, ok} = i16(This1, 42), - {This3, ok} = i16(This2, 30000), - {This4, ok} = i16(This3, -1), - {This5, ok} = i16(This4, -128), - {This6, ok} = i16(This5, -30000), - {This6, ok}. + {ok, This0} = new(), + {This1, ok} = i16(This0, 0), + {This2, ok} = i16(This1, 42), + {This3, ok} = i16(This2, 30000), + {This4, ok} = i16(This3, -1), + {This5, ok} = i16(This4, -128), + {This6, ok} = i16(This5, -30000), + {This6, ok}. i32(This0, Value0) -> round_trip(This0, i32, Value0). i32_test() -> - {ok, This0} = new(), - {This1, ok} = i32(This0, 0), - {This2, ok} = i32(This1, 42), - {This3, ok} = i32(This2, 30000), - {This4, ok} = i32(This3, 2000000002), - {This5, ok} = i32(This4, -1), - {This6, ok} = i32(This5, -128), - {This7, ok} = i32(This6, -30000), - {This8, ok} = i32(This7, -2000000002), - {This8, ok}. + {ok, This0} = new(), + {This1, ok} = i32(This0, 0), + {This2, ok} = i32(This1, 42), + {This3, ok} = i32(This2, 30000), + {This4, ok} = i32(This3, 2000000002), + {This5, ok} = i32(This4, -1), + {This6, ok} = i32(This5, -128), + {This7, ok} = i32(This6, -30000), + {This8, ok} = i32(This7, -2000000002), + {This8, ok}. i64(This0, Value0) -> round_trip(This0, i64, Value0). i64_test() -> - {ok, This0} = new(), - {This1, ok} = i64(This0, 0), - {This2, ok} = i64(This1, 42), - {This3, ok} = i64(This2, 30000), - {This4, ok} = i64(This3, 2000000002), - {This5, ok} = i64(This4, 100000000000000064), - {This6, ok} = i64(This5, -1), - {This7, ok} = i64(This6, -128), - {This8, ok} = i64(This7, -30000), - {This9, ok} = i64(This8, -2000000002), - {This10, ok} = i64(This9, -100000000000000064), - {This10, ok}. + {ok, This0} = new(), + {This1, ok} = i64(This0, 0), + {This2, ok} = i64(This1, 42), + {This3, ok} = i64(This2, 30000), + {This4, ok} = i64(This3, 2000000002), + {This5, ok} = i64(This4, 100000000000000064), + {This6, ok} = i64(This5, -1), + {This7, ok} = i64(This6, -128), + {This8, ok} = i64(This7, -30000), + {This9, ok} = i64(This8, -2000000002), + {This10, ok} = i64(This9, -100000000000000064), + {This10, ok}. struct_test() -> - {ok, P0} = new(), - {P1, ok} = write(P0, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}), - {P2, ok} = write(P1, #protocol_struct_begin{}), - {P3, ok} = write(P2, #protocol_field_begin{ name = "field1", type = ?tType_I8, id = 1}), - {P4, ok} = write(P3, {byte, 42}), - {P5, ok} = write(P4, field_end), - {P6, ok} = write(P5, #protocol_field_begin{ name = "field2", type = ?tType_I8, id = 14}), - {P7, ok} = write(P6, {byte, 3}), - {P8, ok} = write(P7, field_end), - {P9, ok} = write(P8, #protocol_field_begin{ name = "field3", type = ?tType_I8, id = 42}), - {P10, ok} = write(P9, {byte, 8}), - {P11, ok} = write(P10, field_end), - {P12, ok} = write(P11, field_stop), - {P13, ok} = write(P12, struct_end), - {P14, ok} = write(P13, message_end), - - {P15, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}} = read(P14, message_begin), - {P16, ok} = read(P15, struct_begin), - {P17, #protocol_field_begin{ type = ?tType_I8, id = 1 }} = read(P16, field_begin), - {P18, {ok, 42}} = read(P17, byte), - {P19, ok} = read(P18, field_end), - {P20, #protocol_field_begin{ type = ?tType_I8, id = 14 }} = read(P19, field_begin), - {P21, {ok, 3}} = read(P20, byte), - {P22, ok} = read(P21, field_end), - {P23, #protocol_field_begin{ type = ?tType_I8, id = 42 }} = read(P22, field_begin), - {P24, {ok, 8}} = read(P23, byte), - {P25, ok} = read(P24, field_end), - {P26, #protocol_field_begin{ type = ?tType_STOP}} = read(P25, field_begin), - {P27, ok} = read(P26, struct_end), - {P28, ok} = read(P27, message_end), - {P28, ok}. + {ok, P0} = new(), + {P1, ok} = write(P0, #protocol_message_begin{name = "Message1", type = ?tType_I8, seqid = 3}), + {P2, ok} = write(P1, #protocol_struct_begin{}), + {P3, ok} = write(P2, #protocol_field_begin{name = "field1", type = ?tType_I8, id = 1}), + {P4, ok} = write(P3, {byte, 42}), + {P5, ok} = write(P4, field_end), + {P6, ok} = write(P5, #protocol_field_begin{name = "field2", type = ?tType_I8, id = 14}), + {P7, ok} = write(P6, {byte, 3}), + {P8, ok} = write(P7, field_end), + {P9, ok} = write(P8, #protocol_field_begin{name = "field3", type = ?tType_I8, id = 42}), + {P10, ok} = write(P9, {byte, 8}), + {P11, ok} = write(P10, field_end), + {P12, ok} = write(P11, field_stop), + {P13, ok} = write(P12, struct_end), + {P14, ok} = write(P13, message_end), + + {P15, #protocol_message_begin{name = "Message1", type = ?tType_I8, seqid = 3}} = read( + P14, message_begin + ), + {P16, ok} = read(P15, struct_begin), + {P17, #protocol_field_begin{type = ?tType_I8, id = 1}} = read(P16, field_begin), + {P18, {ok, 42}} = read(P17, byte), + {P19, ok} = read(P18, field_end), + {P20, #protocol_field_begin{type = ?tType_I8, id = 14}} = read(P19, field_begin), + {P21, {ok, 3}} = read(P20, byte), + {P22, ok} = read(P21, field_end), + {P23, #protocol_field_begin{type = ?tType_I8, id = 42}} = read(P22, field_begin), + {P24, {ok, 8}} = read(P23, byte), + {P25, ok} = read(P24, field_end), + {P26, #protocol_field_begin{type = ?tType_STOP}} = read(P25, field_begin), + {P27, ok} = read(P26, struct_end), + {P28, ok} = read(P27, message_end), + {P28, ok}. bool_field_test() -> - {ok, P0} = new(), - {P1, ok} = write(P0, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}), - {P2, ok} = write(P1, #protocol_struct_begin{}), - {P3, ok} = write(P2, #protocol_field_begin{ name = "field1", type = ?tType_BOOL, id = 1}), - {P4, ok} = write(P3, {bool, true}), - {P5, ok} = write(P4, field_end), - {P6, ok} = write(P5, #protocol_field_begin{ name = "field2", type = ?tType_BOOL, id = 14}), - {P7, ok} = write(P6, {bool, false}), - {P8, ok} = write(P7, field_end), - {P9, ok} = write(P8, #protocol_field_begin{ name = "field3", type = ?tType_BOOL, id = 42}), - {P10, ok} = write(P9, {bool, true}), - {P11, ok} = write(P10, field_end), - {P12, ok} = write(P11, field_stop), - {P13, ok} = write(P12, struct_end), - {P14, ok} = write(P13, message_end), - - {P15, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}} = read(P14, message_begin), - {P16, ok} = read(P15, struct_begin), - {P17, #protocol_field_begin{ type = ?tType_BOOL, id = 1 }} = read(P16, field_begin), - {P18, {ok, true}} = read(P17, bool), - {P19, ok} = read(P18, field_end), - {P20, #protocol_field_begin{ type = ?tType_BOOL, id = 14 }} = read(P19, field_begin), - {P21, {ok, false}} = read(P20, bool), - {P22, ok} = read(P21, field_end), - {P23, #protocol_field_begin{ type = ?tType_BOOL, id = 42 }} = read(P22, field_begin), - {P24, {ok, true}} = read(P23, bool), - {P25, ok} = read(P24, field_end), - {P26, #protocol_field_begin{ type = ?tType_STOP}} = read(P25, field_begin), - {P27, ok} = read(P26, struct_end), - {P28, ok} = read(P27, message_end), - {P28, ok}. + {ok, P0} = new(), + {P1, ok} = write(P0, #protocol_message_begin{name = "Message1", type = ?tType_I8, seqid = 3}), + {P2, ok} = write(P1, #protocol_struct_begin{}), + {P3, ok} = write(P2, #protocol_field_begin{name = "field1", type = ?tType_BOOL, id = 1}), + {P4, ok} = write(P3, {bool, true}), + {P5, ok} = write(P4, field_end), + {P6, ok} = write(P5, #protocol_field_begin{name = "field2", type = ?tType_BOOL, id = 14}), + {P7, ok} = write(P6, {bool, false}), + {P8, ok} = write(P7, field_end), + {P9, ok} = write(P8, #protocol_field_begin{name = "field3", type = ?tType_BOOL, id = 42}), + {P10, ok} = write(P9, {bool, true}), + {P11, ok} = write(P10, field_end), + {P12, ok} = write(P11, field_stop), + {P13, ok} = write(P12, struct_end), + {P14, ok} = write(P13, message_end), + + {P15, #protocol_message_begin{name = "Message1", type = ?tType_I8, seqid = 3}} = read( + P14, message_begin + ), + {P16, ok} = read(P15, struct_begin), + {P17, #protocol_field_begin{type = ?tType_BOOL, id = 1}} = read(P16, field_begin), + {P18, {ok, true}} = read(P17, bool), + {P19, ok} = read(P18, field_end), + {P20, #protocol_field_begin{type = ?tType_BOOL, id = 14}} = read(P19, field_begin), + {P21, {ok, false}} = read(P20, bool), + {P22, ok} = read(P21, field_end), + {P23, #protocol_field_begin{type = ?tType_BOOL, id = 42}} = read(P22, field_begin), + {P24, {ok, true}} = read(P23, bool), + {P25, ok} = read(P24, field_end), + {P26, #protocol_field_begin{type = ?tType_STOP}} = read(P25, field_begin), + {P27, ok} = read(P26, struct_end), + {P28, ok} = read(P27, message_end), + {P28, ok}. nesting_test() -> - {ok, P0} = new(), - {P1, ok} = write(P0, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}), - {P2, ok} = write(P1, #protocol_struct_begin{}), - {P3, ok} = write(P2, #protocol_field_begin{ name = "field1", type = ?tType_BOOL, id = 14}), - {P4, ok} = write(P3, {bool, true}), - {P5, ok} = write(P4, field_end), - - {P6, ok} = write(P5, #protocol_field_begin{ name = "field2", type = ?tType_STRUCT, id = 28}), - {P7, ok} = write(P6, #protocol_struct_begin{}), - {P8, ok} = write(P7, #protocol_field_begin{ name = "field2_1", type = ?tType_BOOL, id = 30000}), - {P9, ok} = write(P8, {bool, false}), - {P10, ok} = write(P9, field_end), - {P11, ok} = write(P10, field_stop), - {P12, ok} = write(P11, struct_end), - {P13, ok} = write(P12, field_end), - - {P14, ok} = write(P13, #protocol_field_begin{ name = "field3", type = ?tType_BOOL, id = 42}), - {P15, ok} = write(P14, {bool, true}), - {P16, ok} = write(P15, field_end), - {P17, ok} = write(P16, field_stop), - {P18, ok} = write(P17, struct_end), - {P19, ok} = write(P18, message_end), - - {P20, #protocol_message_begin{ name = "Message1", type = ?tType_I8, seqid = 3}} = read(P19, message_begin), - {P21, ok} = read(P20, struct_begin), - {P22, #protocol_field_begin{ type = ?tType_BOOL, id = 14 }} = read(P21, field_begin), - {P23, {ok, true}} = read(P22, bool), - {P24, ok} = read(P23, field_end), - - {P25, #protocol_field_begin{ type = ?tType_STRUCT, id = 28 }} = read(P24, field_begin), - {P26, ok} = read(P25, struct_begin), - {P27, #protocol_field_begin{ type = ?tType_BOOL, id = 30000 }} = read(P26, field_begin), - {P28, {ok, false}} = read(P27, bool), - {P29, ok} = read(P28, field_end), - {P30, #protocol_field_begin{ type = ?tType_STOP }} = read(P29, field_begin), - {P31, ok} = read(P30, struct_end), - {P32, ok} = read(P31, field_end), - - {P33, #protocol_field_begin{ type = ?tType_BOOL, id = 42 }} = read(P32, field_begin), - {P34, {ok, true}} = read(P33, bool), - {P35, ok} = read(P34, field_end), - {P36, #protocol_field_begin{ type = ?tType_STOP }} = read(P35, field_begin), - {P37, ok} = read(P36, struct_end), - {P38, ok} = read(P37, message_end), - {P38, ok}. + {ok, P0} = new(), + {P1, ok} = write(P0, #protocol_message_begin{name = "Message1", type = ?tType_I8, seqid = 3}), + {P2, ok} = write(P1, #protocol_struct_begin{}), + {P3, ok} = write(P2, #protocol_field_begin{name = "field1", type = ?tType_BOOL, id = 14}), + {P4, ok} = write(P3, {bool, true}), + {P5, ok} = write(P4, field_end), + + {P6, ok} = write(P5, #protocol_field_begin{name = "field2", type = ?tType_STRUCT, id = 28}), + {P7, ok} = write(P6, #protocol_struct_begin{}), + {P8, ok} = write(P7, #protocol_field_begin{name = "field2_1", type = ?tType_BOOL, id = 30000}), + {P9, ok} = write(P8, {bool, false}), + {P10, ok} = write(P9, field_end), + {P11, ok} = write(P10, field_stop), + {P12, ok} = write(P11, struct_end), + {P13, ok} = write(P12, field_end), + + {P14, ok} = write(P13, #protocol_field_begin{name = "field3", type = ?tType_BOOL, id = 42}), + {P15, ok} = write(P14, {bool, true}), + {P16, ok} = write(P15, field_end), + {P17, ok} = write(P16, field_stop), + {P18, ok} = write(P17, struct_end), + {P19, ok} = write(P18, message_end), + + {P20, #protocol_message_begin{name = "Message1", type = ?tType_I8, seqid = 3}} = read( + P19, message_begin + ), + {P21, ok} = read(P20, struct_begin), + {P22, #protocol_field_begin{type = ?tType_BOOL, id = 14}} = read(P21, field_begin), + {P23, {ok, true}} = read(P22, bool), + {P24, ok} = read(P23, field_end), + + {P25, #protocol_field_begin{type = ?tType_STRUCT, id = 28}} = read(P24, field_begin), + {P26, ok} = read(P25, struct_begin), + {P27, #protocol_field_begin{type = ?tType_BOOL, id = 30000}} = read(P26, field_begin), + {P28, {ok, false}} = read(P27, bool), + {P29, ok} = read(P28, field_end), + {P30, #protocol_field_begin{type = ?tType_STOP}} = read(P29, field_begin), + {P31, ok} = read(P30, struct_end), + {P32, ok} = read(P31, field_end), + + {P33, #protocol_field_begin{type = ?tType_BOOL, id = 42}} = read(P32, field_begin), + {P34, {ok, true}} = read(P33, bool), + {P35, ok} = read(P34, field_end), + {P36, #protocol_field_begin{type = ?tType_STOP}} = read(P35, field_begin), + {P37, ok} = read(P36, struct_end), + {P38, ok} = read(P37, message_end), + {P38, ok}. diff --git a/lib/erl/test/test_thrift_file_transport.erl b/lib/erl/test/test_thrift_file_transport.erl index 3e5c1d1e46c..85b6c46feb1 100644 --- a/lib/erl/test/test_thrift_file_transport.erl +++ b/lib/erl/test/test_thrift_file_transport.erl @@ -20,194 +20,205 @@ -module(test_thrift_file_transport). -include_lib("eunit/include/eunit.hrl"). - new(File) -> thrift_file_transport:new(File). new(File, Opts) -> thrift_file_transport:new(File, Opts). new_test_() -> - [ - {"new file", ?_assertMatch( - {ok, {_, thrift_file_transport, {t_file, a_fake_file, true, write}}}, - new(a_fake_file) - )}, - {"new file in read mode", ?_assertMatch( - {ok, {_, thrift_file_transport, {t_file, a_fake_file, true, read}}}, - new(a_fake_file, [{mode, read}]) - )}, - {"new file in write mode", ?_assertMatch( - {ok, {_, thrift_file_transport, {t_file, a_fake_file, true, write}}}, - new(a_fake_file, [{mode, write}]) - )}, - {"new file in should_close true mode", ?_assertMatch( - {ok, {_, thrift_file_transport, {t_file, a_fake_file, true, write}}}, - new(a_fake_file, [{should_close, true}]) - )}, - {"new file in should_close false mode", ?_assertMatch( - {ok, {_, thrift_file_transport, {t_file, a_fake_file, false, write}}}, - new(a_fake_file, [{should_close, false}]) - )} - ]. - + [ + {"new file", + ?_assertMatch( + {ok, {_, thrift_file_transport, {t_file, a_fake_file, true, write}}}, + new(a_fake_file) + )}, + {"new file in read mode", + ?_assertMatch( + {ok, {_, thrift_file_transport, {t_file, a_fake_file, true, read}}}, + new(a_fake_file, [{mode, read}]) + )}, + {"new file in write mode", + ?_assertMatch( + {ok, {_, thrift_file_transport, {t_file, a_fake_file, true, write}}}, + new(a_fake_file, [{mode, write}]) + )}, + {"new file in should_close true mode", + ?_assertMatch( + {ok, {_, thrift_file_transport, {t_file, a_fake_file, true, write}}}, + new(a_fake_file, [{should_close, true}]) + )}, + {"new file in should_close false mode", + ?_assertMatch( + {ok, {_, thrift_file_transport, {t_file, a_fake_file, false, write}}}, + new(a_fake_file, [{should_close, false}]) + )} + ]. read(File, Bytes) -> thrift_file_transport:read(File, Bytes). read_test_() -> - {setup, - fun() -> - meck:new(file, [unstick, passthrough]), - meck:expect(file, read, fun(Bin, N) -> - {Result, _} = split_binary(Bin, min(iolist_size(Bin), N)), - {ok, Result} - end) - end, - fun(_) -> meck:unload(file) end, - [ - {"read zero bytes from empty file", ?_assertMatch( - {_, {ok, <<>>}}, - read({t_file, <<>>, true, read}, 0) - )}, - {"read 1 byte from empty file", ?_assertMatch( - {_, {ok, <<>>}}, - read({t_file, <<>>, true, read}, 1) - )}, - {"read zero bytes from nonempty file", ?_assertMatch( - {_, {ok, <<>>}}, - read({t_file, <<"hallo world">>, true, read}, 0) - )}, - {"read 1 byte from nonempty file", ?_assertMatch( - {_, {ok, <<"h">>}}, - read({t_file, <<"hallo world">>, true, read}, 1) - )}, - {"read a zillion bytes from nonempty file", ?_assertMatch( - {_, {ok, <<"hallo world">>}}, - read({t_file, <<"hallo world">>, true, read}, 65536) - )}, - {"read 0 byte from file in write mode", ?_assertMatch( - {_, {error, write_mode}}, - read({t_file, <<>>, true, write}, 0) - )}, - {"read 1 byte from file in write mode", ?_assertMatch( - {_, {error, write_mode}}, - read({t_file, <<>>, true, write}, 1) - )} - ] - }. - + {setup, + fun() -> + meck:new(file, [unstick, passthrough]), + meck:expect(file, read, fun(Bin, N) -> + {Result, _} = split_binary(Bin, min(iolist_size(Bin), N)), + {ok, Result} + end) + end, + fun(_) -> meck:unload(file) end, [ + {"read zero bytes from empty file", + ?_assertMatch( + {_, {ok, <<>>}}, + read({t_file, <<>>, true, read}, 0) + )}, + {"read 1 byte from empty file", + ?_assertMatch( + {_, {ok, <<>>}}, + read({t_file, <<>>, true, read}, 1) + )}, + {"read zero bytes from nonempty file", + ?_assertMatch( + {_, {ok, <<>>}}, + read({t_file, <<"hallo world">>, true, read}, 0) + )}, + {"read 1 byte from nonempty file", + ?_assertMatch( + {_, {ok, <<"h">>}}, + read({t_file, <<"hallo world">>, true, read}, 1) + )}, + {"read a zillion bytes from nonempty file", + ?_assertMatch( + {_, {ok, <<"hallo world">>}}, + read({t_file, <<"hallo world">>, true, read}, 65536) + )}, + {"read 0 byte from file in write mode", + ?_assertMatch( + {_, {error, write_mode}}, + read({t_file, <<>>, true, write}, 0) + )}, + {"read 1 byte from file in write mode", + ?_assertMatch( + {_, {error, write_mode}}, + read({t_file, <<>>, true, write}, 1) + )} + ]}. read_exact(File, Bytes) -> thrift_file_transport:read_exact(File, Bytes). read_exact_test_() -> - {setup, - fun() -> - meck:new(file, [unstick, passthrough]), - meck:expect(file, read, fun(Bin, N) -> - {Result, _} = split_binary(Bin, min(iolist_size(Bin), N)), - {ok, Result} - end) - end, - fun(_) -> meck:unload(file) end, - [ - {"read exactly zero bytes from empty file", ?_assertMatch( - {_, {ok, <<>>}}, - read_exact({t_file, <<>>, true, read}, 0) - )}, - {"read exactly 1 byte from empty file", ?_assertMatch( - {_, {error, eof}}, - read_exact({t_file, <<>>, true, read}, 1) - )}, - {"read exactly zero bytes from nonempty file", ?_assertMatch( - {_, {ok, <<>>}}, - read_exact({t_file, <<"hallo world">>, true, read}, 0) - )}, - {"read exactly 1 byte from nonempty file", ?_assertMatch( - {_, {ok, <<"h">>}}, - read_exact({t_file, <<"hallo world">>, true, read}, 1) - )}, - {"read exactly a zillion bytes from nonempty file", ?_assertMatch( - {_, {error, eof}}, - read_exact({t_file, <<"hallo world">>, true, read}, 65536) - )}, - {"read exactly 0 byte from file in write mode", ?_assertMatch( - {_, {error, write_mode}}, - read_exact({t_file, <<>>, true, write}, 0) - )}, - {"read exactly 1 byte from file in write mode", ?_assertMatch( - {_, {error, write_mode}}, - read_exact({t_file, <<>>, true, write}, 1) - )} - ] - }. - + {setup, + fun() -> + meck:new(file, [unstick, passthrough]), + meck:expect(file, read, fun(Bin, N) -> + {Result, _} = split_binary(Bin, min(iolist_size(Bin), N)), + {ok, Result} + end) + end, + fun(_) -> meck:unload(file) end, [ + {"read exactly zero bytes from empty file", + ?_assertMatch( + {_, {ok, <<>>}}, + read_exact({t_file, <<>>, true, read}, 0) + )}, + {"read exactly 1 byte from empty file", + ?_assertMatch( + {_, {error, eof}}, + read_exact({t_file, <<>>, true, read}, 1) + )}, + {"read exactly zero bytes from nonempty file", + ?_assertMatch( + {_, {ok, <<>>}}, + read_exact({t_file, <<"hallo world">>, true, read}, 0) + )}, + {"read exactly 1 byte from nonempty file", + ?_assertMatch( + {_, {ok, <<"h">>}}, + read_exact({t_file, <<"hallo world">>, true, read}, 1) + )}, + {"read exactly a zillion bytes from nonempty file", + ?_assertMatch( + {_, {error, eof}}, + read_exact({t_file, <<"hallo world">>, true, read}, 65536) + )}, + {"read exactly 0 byte from file in write mode", + ?_assertMatch( + {_, {error, write_mode}}, + read_exact({t_file, <<>>, true, write}, 0) + )}, + {"read exactly 1 byte from file in write mode", + ?_assertMatch( + {_, {error, write_mode}}, + read_exact({t_file, <<>>, true, write}, 1) + )} + ]}. write(File, Data) -> thrift_file_transport:write(File, Data). write_test_() -> - {setup, - fun() -> - meck:new(file, [unstick, passthrough]), - meck:expect(file, write, fun(_, _) -> ok end) - end, - fun(_) -> meck:unload(file) end, - [ - {"write empty list to file", ?_assertMatch( - {{t_file, a_fake_file, true, write}, ok}, - write({t_file, a_fake_file, true, write}, []) - )}, - {"write empty binary to file", ?_assertMatch( - {{t_file, a_fake_file, true, write}, ok}, - write({t_file, a_fake_file, true, write}, <<>>) - )}, - {"write a list to file", ?_assertMatch( - {{t_file, a_fake_file, true, write}, ok}, - write({t_file, a_fake_file, true, write}, "hallo world") - )}, - {"write a binary to file", ?_assertMatch( - {{t_file, a_fake_file, true, write}, ok}, - write({t_file, a_fake_file, true, write}, <<"hallo world">>) - )}, - {"write a binary to file in read mode", ?_assertMatch( - {_, {error, read_mode}}, - write({t_file, a_fake_file, true, read}, <<"hallo world">>) - )}, - {"write a list to file in read mode", ?_assertMatch( - {_, {error, read_mode}}, - write({t_file, a_fake_file, true, read}, "hallo world") - )} - ] - }. - + {setup, + fun() -> + meck:new(file, [unstick, passthrough]), + meck:expect(file, write, fun(_, _) -> ok end) + end, + fun(_) -> meck:unload(file) end, [ + {"write empty list to file", + ?_assertMatch( + {{t_file, a_fake_file, true, write}, ok}, + write({t_file, a_fake_file, true, write}, []) + )}, + {"write empty binary to file", + ?_assertMatch( + {{t_file, a_fake_file, true, write}, ok}, + write({t_file, a_fake_file, true, write}, <<>>) + )}, + {"write a list to file", + ?_assertMatch( + {{t_file, a_fake_file, true, write}, ok}, + write({t_file, a_fake_file, true, write}, "hallo world") + )}, + {"write a binary to file", + ?_assertMatch( + {{t_file, a_fake_file, true, write}, ok}, + write({t_file, a_fake_file, true, write}, <<"hallo world">>) + )}, + {"write a binary to file in read mode", + ?_assertMatch( + {_, {error, read_mode}}, + write({t_file, a_fake_file, true, read}, <<"hallo world">>) + )}, + {"write a list to file in read mode", + ?_assertMatch( + {_, {error, read_mode}}, + write({t_file, a_fake_file, true, read}, "hallo world") + )} + ]}. flush(Transport) -> thrift_file_transport:flush(Transport). flush_test_() -> - {setup, - fun() -> - meck:new(file, [unstick, passthrough]), - meck:expect(file, sync, fun(_File) -> ok end) - end, - fun(_) -> meck:unload(file) end, - [ - {"flush file", ?_assertMatch( - {{t_file, a_fake_file, true, write}, ok}, - flush({t_file, a_fake_file, true, write}) - )} - ] - }. - + {setup, + fun() -> + meck:new(file, [unstick, passthrough]), + meck:expect(file, sync, fun(_File) -> ok end) + end, + fun(_) -> meck:unload(file) end, [ + {"flush file", + ?_assertMatch( + {{t_file, a_fake_file, true, write}, ok}, + flush({t_file, a_fake_file, true, write}) + )} + ]}. close(Transport) -> thrift_file_transport:close(Transport). close_test_() -> - {setup, - fun() -> - meck:new(file, [unstick, passthrough]), - meck:expect(file, close, fun(_) -> ok end) - end, - fun(_) -> meck:unload(file) end, - [ - {"close file", ?_assertMatch( - {{t_file, a_fake_file, true, write}, ok}, - close({t_file, a_fake_file, true, write}) - )} - ] - }. \ No newline at end of file + {setup, + fun() -> + meck:new(file, [unstick, passthrough]), + meck:expect(file, close, fun(_) -> ok end) + end, + fun(_) -> meck:unload(file) end, [ + {"close file", + ?_assertMatch( + {{t_file, a_fake_file, true, write}, ok}, + close({t_file, a_fake_file, true, write}) + )} + ]}. diff --git a/lib/erl/test/test_thrift_framed_transport.erl b/lib/erl/test/test_thrift_framed_transport.erl index 8a538a53ad8..b96092093d2 100644 --- a/lib/erl/test/test_thrift_framed_transport.erl +++ b/lib/erl/test/test_thrift_framed_transport.erl @@ -20,385 +20,302 @@ -module(test_thrift_framed_transport). -include_lib("eunit/include/eunit.hrl"). - new(Transport) -> thrift_framed_transport:new(Transport). new_test_() -> - [ - {"new framed membuffer", ?_assertMatch( - {ok, {t_transport, thrift_framed_transport, {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, []}}, - [], - [] - }}}, - new({t_transport, thrift_membuffer_transport, {t_membuffer, []}}) - )} - ]. - + [ + {"new framed membuffer", + ?_assertMatch( + {ok, + {t_transport, thrift_framed_transport, + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, []}}, [], + []}}}, + new({t_transport, thrift_membuffer_transport, {t_membuffer, []}}) + )} + ]. read(Frame, Bytes) -> thrift_framed_transport:read(Frame, Bytes). read_test_() -> - [ - {"read zero bytes from an empty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }, - {ok, <<>>} - }, - read( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }, - 0 - ) - )}, - {"read 1 byte from an empty framed membuffer", ?_assertMatch( - {_, {error, eof}}, - read( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }, - 1 - ) - )}, - {"read zero bytes from nonempty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<0, 0, 0, 11, "hallo world">> - }}, - [], - [] - }, - {ok, <<>>} - }, - read( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<0, 0, 0, 11, "hallo world">> - }}, - [], - [] - }, - 0 - ) - )}, - {"read 1 byte from nonempty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - <<"allo world">>, - [] - }, - {ok, <<"h">>} - }, - read( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<0, 0, 0, 11, "hallo world">> - }}, - [], - [] - }, - 1 - ) - )}, - {"read 1 byte from nonempty buffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - <<"allo world">>, - [] - }, - {ok, <<"h">>} - }, - read( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - <<"hallo world">>, - [] - }, - 1 - ) - )}, - {"read a zillion bytes from nonempty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - <<>>, - [] - }, - {ok, <<"hallo world">>} - }, - read( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<0, 0, 0, 11, "hallo world">> - }}, - [], - [] - }, - 65536 - ) - )} - ]. - + [ + {"read zero bytes from an empty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], + []}, + {ok, <<>>} + }, + read( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], + []}, + 0 + ) + )}, + {"read 1 byte from an empty framed membuffer", + ?_assertMatch( + {_, {error, eof}}, + read( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], + []}, + 1 + ) + )}, + {"read zero bytes from nonempty framed membuffer", + ?_assertMatch( + { + {t_framed, + {t_transport, thrift_membuffer_transport, + {t_membuffer, <<0, 0, 0, 11, "hallo world">>}}, + [], []}, + {ok, <<>>} + }, + read( + {t_framed, + {t_transport, thrift_membuffer_transport, + {t_membuffer, <<0, 0, 0, 11, "hallo world">>}}, + [], []}, + 0 + ) + )}, + {"read 1 byte from nonempty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + <<"allo world">>, []}, + {ok, <<"h">>} + }, + read( + {t_framed, + {t_transport, thrift_membuffer_transport, + {t_membuffer, <<0, 0, 0, 11, "hallo world">>}}, + [], []}, + 1 + ) + )}, + {"read 1 byte from nonempty buffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + <<"allo world">>, []}, + {ok, <<"h">>} + }, + read( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + <<"hallo world">>, []}, + 1 + ) + )}, + {"read a zillion bytes from nonempty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, <<>>, + []}, + {ok, <<"hallo world">>} + }, + read( + {t_framed, + {t_transport, thrift_membuffer_transport, + {t_membuffer, <<0, 0, 0, 11, "hallo world">>}}, + [], []}, + 65536 + ) + )} + ]. read_exact(Frame, Bytes) -> thrift_framed_transport:read_exact(Frame, Bytes). read_exact_test_() -> - [ - {"read exactly zero bytes from an empty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - <<>>, - [] - }, - {ok, <<>>} - }, - read_exact( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }, - 0 - ) - )}, - {"read exactly 1 byte from an empty framed membuffer", ?_assertMatch( - {_, {error, eof}}, - read_exact( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }, - 1 - ) - )}, - {"read exactly zero bytes from nonempty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<0, 0, 0, 11, "hallo world">> - }}, - <<>>, - [] - }, - {ok, <<>>} - }, - read_exact( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<0, 0, 0, 11, "hallo world">> - }}, - [], - [] - }, - 0 - ) - )}, - {"read exactly 1 byte from nonempty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - <<"allo world">>, - [] - }, - {ok, <<"h">>} - }, - read_exact( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<0, 0, 0, 11, "hallo world">> - }}, - [], - [] - }, - 1 - ) - )}, - {"read exactly 1 byte from nonempty buffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - <<"allo world">>, - [] - }, - {ok, <<"h">>} - }, - read_exact( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - <<"hallo world">>, - [] - }, - 1 - ) - )}, - {"read exactly a zillion bytes from nonempty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [[],<<"hallo world">>], - [] - }, - {error, eof} - }, - read_exact( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, - <<0, 0, 0, 11, "hallo world">> - }}, - [], - [] - }, - 65536 - ) - )} - ]. - + [ + {"read exactly zero bytes from an empty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, <<>>, + []}, + {ok, <<>>} + }, + read_exact( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], + []}, + 0 + ) + )}, + {"read exactly 1 byte from an empty framed membuffer", + ?_assertMatch( + {_, {error, eof}}, + read_exact( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], + []}, + 1 + ) + )}, + {"read exactly zero bytes from nonempty framed membuffer", + ?_assertMatch( + { + {t_framed, + {t_transport, thrift_membuffer_transport, + {t_membuffer, <<0, 0, 0, 11, "hallo world">>}}, + <<>>, []}, + {ok, <<>>} + }, + read_exact( + {t_framed, + {t_transport, thrift_membuffer_transport, + {t_membuffer, <<0, 0, 0, 11, "hallo world">>}}, + [], []}, + 0 + ) + )}, + {"read exactly 1 byte from nonempty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + <<"allo world">>, []}, + {ok, <<"h">>} + }, + read_exact( + {t_framed, + {t_transport, thrift_membuffer_transport, + {t_membuffer, <<0, 0, 0, 11, "hallo world">>}}, + [], []}, + 1 + ) + )}, + {"read exactly 1 byte from nonempty buffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + <<"allo world">>, []}, + {ok, <<"h">>} + }, + read_exact( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + <<"hallo world">>, []}, + 1 + ) + )}, + {"read exactly a zillion bytes from nonempty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, + [[], <<"hallo world">>], []}, + {error, eof} + }, + read_exact( + {t_framed, + {t_transport, thrift_membuffer_transport, + {t_membuffer, <<0, 0, 0, 11, "hallo world">>}}, + [], []}, + 65536 + ) + )} + ]. write(Framed, Data) -> thrift_framed_transport:write(Framed, Data). write_test_() -> - [ - {"write empty list to empty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [[], []] - }, - ok - }, - write( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }, - [] - ) - )}, - {"write empty list to nonempty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [["hallo world"], []] - }, - ok - }, - write( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - ["hallo world"] - }, - [] - ) - )}, - {"write empty binary to empty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [[], <<>>] - }, - ok - }, - write( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }, - <<>> - ) - )}, - {"write empty binary to nonempty framed membuffer", ?_assertMatch( - { - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [["hallo world"], <<>>] - }, - ok - }, - write( - {t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - ["hallo world"] - }, - <<>> - ) - )} - ]. - + [ + {"write empty list to empty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], [ + [], [] + ]}, + ok + }, + write( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], + []}, + [] + ) + )}, + {"write empty list to nonempty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], [ + ["hallo world"], [] + ]}, + ok + }, + write( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], [ + "hallo world" + ]}, + [] + ) + )}, + {"write empty binary to empty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], [ + [], <<>> + ]}, + ok + }, + write( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], + []}, + <<>> + ) + )}, + {"write empty binary to nonempty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], [ + ["hallo world"], <<>> + ]}, + ok + }, + write( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], [ + "hallo world" + ]}, + <<>> + ) + )} + ]. flush(Transport) -> thrift_framed_transport:flush(Transport). flush_test_() -> - [ - {"flush empty framed membuffer", ?_assertMatch( - {{t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }, - ok - }, - flush({t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }) - )}, - {"flush nonempty framed membuffer", ?_assertMatch( - {{t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, - [<<>>, [<<0, 0, 0, 11>>, <<"hallo world">>]] - }}, - [], - [] - }, - ok - }, - flush({t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - <<"hallo world">> - }) - )} - ]. - + [ + {"flush empty framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], + []}, + ok + }, + flush( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], + []} + ) + )}, + {"flush nonempty framed membuffer", + ?_assertMatch( + { + {t_framed, + {t_transport, thrift_membuffer_transport, + {t_membuffer, [<<>>, [<<0, 0, 0, 11>>, <<"hallo world">>]]}}, + [], []}, + ok + }, + flush( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], + <<"hallo world">>} + ) + )} + ]. close(Transport) -> thrift_framed_transport:close(Transport). close_test_() -> - {"close framed membuffer", ?_assertMatch( - {{t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }, - ok - }, - close({t_framed, - {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, - [], - [] - }) - )}. - + {"close framed membuffer", + ?_assertMatch( + { + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], []}, + ok + }, + close( + {t_framed, {t_transport, thrift_membuffer_transport, {t_membuffer, <<>>}}, [], []} + ) + )}. diff --git a/lib/erl/test/test_thrift_membuffer_transport.erl b/lib/erl/test/test_thrift_membuffer_transport.erl index 9689c7987a5..e388311f145 100644 --- a/lib/erl/test/test_thrift_membuffer_transport.erl +++ b/lib/erl/test/test_thrift_membuffer_transport.erl @@ -20,148 +20,168 @@ -module(test_thrift_membuffer_transport). -include_lib("eunit/include/eunit.hrl"). - new() -> thrift_membuffer_transport:new(). new(Data) -> thrift_membuffer_transport:new(Data). new_test_() -> - [ - {"new empty membuffer", ?_assertMatch( - {ok, {_, _, {t_membuffer, []}}}, - new() - )}, - {"new membuffer with <<>>", ?_assertMatch( - {ok, {_, _, {t_membuffer, [<<>>]}}}, - new(<<>>) - )}, - {"new membuffer with []", ?_assertMatch( - {ok, {_, _, {t_membuffer, []}}}, - new([]) - )}, - {"new membuffer with <<\"hallo world\">>", ?_assertMatch( - {ok, {_, _, {t_membuffer, [<<"hallo world">>]}}}, - new(<<"hallo world">>) - )}, - {"new membuffer with \"hallo world\"", ?_assertMatch( - {ok, {_, _, {t_membuffer, "hallo world"}}}, - new("hallo world") - )} - ]. - + [ + {"new empty membuffer", + ?_assertMatch( + {ok, {_, _, {t_membuffer, []}}}, + new() + )}, + {"new membuffer with <<>>", + ?_assertMatch( + {ok, {_, _, {t_membuffer, [<<>>]}}}, + new(<<>>) + )}, + {"new membuffer with []", + ?_assertMatch( + {ok, {_, _, {t_membuffer, []}}}, + new([]) + )}, + {"new membuffer with <<\"hallo world\">>", + ?_assertMatch( + {ok, {_, _, {t_membuffer, [<<"hallo world">>]}}}, + new(<<"hallo world">>) + )}, + {"new membuffer with \"hallo world\"", + ?_assertMatch( + {ok, {_, _, {t_membuffer, "hallo world"}}}, + new("hallo world") + )} + ]. read(Membuffer, Bytes) -> thrift_membuffer_transport:read(Membuffer, Bytes). read_test_() -> - [ - {"read zero bytes from an empty membuffer", ?_assertMatch( - {_, {ok, <<>>}}, - read({t_membuffer, []}, 0) - )}, - {"read 1 byte from an empty membuffer", ?_assertMatch( - {_, {ok, <<>>}}, - read({t_membuffer, []}, 1) - )}, - {"read zero bytes from nonempty membuffer", ?_assertMatch( - {{t_membuffer, <<"hallo world">>}, {ok, <<>>}}, - read({t_membuffer, [["hallo", " "], "world"]}, 0) - )}, - {"read 1 byte from nonempty membuffer", ?_assertMatch( - {{t_membuffer, <<"allo world">>}, {ok, <<"h">>}}, - read({t_membuffer, [["hallo", " "], "world"]}, 1) - )}, - {"read a zillion bytes from nonempty buffer", ?_assertMatch( - {{t_membuffer, <<>>}, {ok, <<"hallo world">>}}, - read({t_membuffer, [["hallo", " "], "world"]}, 65536) - )} - ]. - + [ + {"read zero bytes from an empty membuffer", + ?_assertMatch( + {_, {ok, <<>>}}, + read({t_membuffer, []}, 0) + )}, + {"read 1 byte from an empty membuffer", + ?_assertMatch( + {_, {ok, <<>>}}, + read({t_membuffer, []}, 1) + )}, + {"read zero bytes from nonempty membuffer", + ?_assertMatch( + {{t_membuffer, <<"hallo world">>}, {ok, <<>>}}, + read({t_membuffer, [["hallo", " "], "world"]}, 0) + )}, + {"read 1 byte from nonempty membuffer", + ?_assertMatch( + {{t_membuffer, <<"allo world">>}, {ok, <<"h">>}}, + read({t_membuffer, [["hallo", " "], "world"]}, 1) + )}, + {"read a zillion bytes from nonempty buffer", + ?_assertMatch( + {{t_membuffer, <<>>}, {ok, <<"hallo world">>}}, + read({t_membuffer, [["hallo", " "], "world"]}, 65536) + )} + ]. read_exact(Membuffer, Bytes) -> - thrift_membuffer_transport:read_exact(Membuffer, Bytes). + thrift_membuffer_transport:read_exact(Membuffer, Bytes). read_exact_test_() -> - [ - {"read exactly zero bytes from an empty membuffer", ?_assertMatch( - {_, {ok, <<>>}}, - read_exact({t_membuffer, []}, 0) - )}, - {"read exactly 1 byte from an empty membuffer", ?_assertMatch( - {_, {error, eof}}, - read_exact({t_membuffer, []}, 1) - )}, - {"read exactly zero bytes from nonempty membuffer", ?_assertMatch( - {{t_membuffer, <<"hallo world">>}, {ok, <<>>}}, - read_exact({t_membuffer, [["hallo", " "], "world"]}, 0) - )}, - {"read exactly 1 byte from nonempty membuffer", ?_assertMatch( - {{t_membuffer, <<"allo world">>}, {ok, <<"h">>}}, - read_exact({t_membuffer, [["hallo", " "], "world"]}, 1) - )}, - {"read exactly a zillion bytes from nonempty buffer", ?_assertMatch( - {{t_membuffer, [["hallo", " "], "world"]}, {error, eof}}, - read_exact({t_membuffer, [["hallo", " "], "world"]}, 65536) - )} - ]. - + [ + {"read exactly zero bytes from an empty membuffer", + ?_assertMatch( + {_, {ok, <<>>}}, + read_exact({t_membuffer, []}, 0) + )}, + {"read exactly 1 byte from an empty membuffer", + ?_assertMatch( + {_, {error, eof}}, + read_exact({t_membuffer, []}, 1) + )}, + {"read exactly zero bytes from nonempty membuffer", + ?_assertMatch( + {{t_membuffer, <<"hallo world">>}, {ok, <<>>}}, + read_exact({t_membuffer, [["hallo", " "], "world"]}, 0) + )}, + {"read exactly 1 byte from nonempty membuffer", + ?_assertMatch( + {{t_membuffer, <<"allo world">>}, {ok, <<"h">>}}, + read_exact({t_membuffer, [["hallo", " "], "world"]}, 1) + )}, + {"read exactly a zillion bytes from nonempty buffer", + ?_assertMatch( + {{t_membuffer, [["hallo", " "], "world"]}, {error, eof}}, + read_exact({t_membuffer, [["hallo", " "], "world"]}, 65536) + )} + ]. write(Membuffer, Data) -> thrift_membuffer_transport:write(Membuffer, Data). write_test_() -> - [ - {"write empty list to empty membuffer", ?_assertMatch( - {{t_membuffer, [[], []]}, ok}, - write({t_membuffer, []}, []) - )}, - {"write empty list to nonempty membuffer", ?_assertMatch( - {{t_membuffer, ["hallo world", []]}, ok}, - write({t_membuffer, "hallo world"}, []) - )}, - {"write empty binary to empty membuffer", ?_assertMatch( - {{t_membuffer, [[], <<>>]}, ok}, - write({t_membuffer, []}, <<>>) - )}, - {"write empty binary to nonempty membuffer", ?_assertMatch( - {{t_membuffer, ["hallo world", <<>>]}, ok}, - write({t_membuffer, "hallo world"}, <<>>) - )}, - {"write a list to empty membuffer", ?_assertMatch( - {{t_membuffer, [[], "hallo world"]}, ok}, - write({t_membuffer, []}, "hallo world") - )}, - {"write a list to nonempty membuffer", ?_assertMatch( - {{t_membuffer, [["hallo", " "], "world"]}, ok}, - write({t_membuffer, ["hallo", " "]}, "world") - )}, - {"write a binary to empty membuffer", ?_assertMatch( - {{t_membuffer, [[], <<"hallo world">>]}, ok}, - write({t_membuffer, []}, <<"hallo world">>) - )}, - {"write a binary to nonempty membuffer", ?_assertMatch( - {{t_membuffer, [["hallo", " "], <<"world">>]}, ok}, - write({t_membuffer, ["hallo", " "]}, <<"world">>) - )} - ]. - + [ + {"write empty list to empty membuffer", + ?_assertMatch( + {{t_membuffer, [[], []]}, ok}, + write({t_membuffer, []}, []) + )}, + {"write empty list to nonempty membuffer", + ?_assertMatch( + {{t_membuffer, ["hallo world", []]}, ok}, + write({t_membuffer, "hallo world"}, []) + )}, + {"write empty binary to empty membuffer", + ?_assertMatch( + {{t_membuffer, [[], <<>>]}, ok}, + write({t_membuffer, []}, <<>>) + )}, + {"write empty binary to nonempty membuffer", + ?_assertMatch( + {{t_membuffer, ["hallo world", <<>>]}, ok}, + write({t_membuffer, "hallo world"}, <<>>) + )}, + {"write a list to empty membuffer", + ?_assertMatch( + {{t_membuffer, [[], "hallo world"]}, ok}, + write({t_membuffer, []}, "hallo world") + )}, + {"write a list to nonempty membuffer", + ?_assertMatch( + {{t_membuffer, [["hallo", " "], "world"]}, ok}, + write({t_membuffer, ["hallo", " "]}, "world") + )}, + {"write a binary to empty membuffer", + ?_assertMatch( + {{t_membuffer, [[], <<"hallo world">>]}, ok}, + write({t_membuffer, []}, <<"hallo world">>) + )}, + {"write a binary to nonempty membuffer", + ?_assertMatch( + {{t_membuffer, [["hallo", " "], <<"world">>]}, ok}, + write({t_membuffer, ["hallo", " "]}, <<"world">>) + )} + ]. flush(Transport) -> thrift_membuffer_transport:flush(Transport). flush_test_() -> - [ - {"flush empty membuffer", ?_assertMatch( - {{t_membuffer, []}, ok}, - flush({t_membuffer, []}) - )}, - {"flush nonempty membuffer", ?_assertMatch( - {{t_membuffer, [<<"hallo world">>]}, ok}, - flush({t_membuffer, [<<"hallo world">>]}) - )} - ]. - + [ + {"flush empty membuffer", + ?_assertMatch( + {{t_membuffer, []}, ok}, + flush({t_membuffer, []}) + )}, + {"flush nonempty membuffer", + ?_assertMatch( + {{t_membuffer, [<<"hallo world">>]}, ok}, + flush({t_membuffer, [<<"hallo world">>]}) + )} + ]. close(Transport) -> thrift_membuffer_transport:close(Transport). close_test_() -> - {"close membuffer", ?_assertMatch( - {{t_membuffer, _}, ok}, - close({t_membuffer, []}) - )}. \ No newline at end of file + {"close membuffer", + ?_assertMatch( + {{t_membuffer, _}, ok}, + close({t_membuffer, []}) + )}. diff --git a/lib/erl/test/test_thrift_socket_transport.erl b/lib/erl/test/test_thrift_socket_transport.erl index 757c6d993ba..7e4731471b8 100644 --- a/lib/erl/test/test_thrift_socket_transport.erl +++ b/lib/erl/test/test_thrift_socket_transport.erl @@ -20,185 +20,197 @@ -module(test_thrift_socket_transport). -include_lib("eunit/include/eunit.hrl"). - new(Socket) -> thrift_socket_transport:new(Socket). new(Socket, Opts) -> thrift_socket_transport:new(Socket, Opts). new_test_() -> - [ - {"new socket", ?_assertMatch( - {ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, 60000, []}}}, - new(a_fake_socket) - )}, - {"new socket with no options", ?_assertMatch( - {ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, 60000, []}}}, - new(a_fake_socket, []) - )}, - {"new socket with integer timeout", ?_assertMatch( - {ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, 5000, []}}}, - new(a_fake_socket, [{recv_timeout, 5000}]) - )}, - {"new socket with infinity timeout", ?_assertMatch( - {ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, infinity, []}}}, - new(a_fake_socket, [{recv_timeout, infinity}]) - )} - ]. - + [ + {"new socket", + ?_assertMatch( + {ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, 60000, []}}}, + new(a_fake_socket) + )}, + {"new socket with no options", + ?_assertMatch( + {ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, 60000, []}}}, + new(a_fake_socket, []) + )}, + {"new socket with integer timeout", + ?_assertMatch( + {ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, 5000, []}}}, + new(a_fake_socket, [{recv_timeout, 5000}]) + )}, + {"new socket with infinity timeout", + ?_assertMatch( + {ok, {_, thrift_socket_transport, {t_socket, a_fake_socket, infinity, []}}}, + new(a_fake_socket, [{recv_timeout, infinity}]) + )} + ]. read(Socket, Bytes) -> thrift_socket_transport:read(Socket, Bytes). read_test_() -> - {setup, - fun() -> - meck:new(gen_tcp, [unstick, passthrough]), - meck:expect(gen_tcp, recv, fun(Bin, 0, _) -> - case Bin of - <<"empty">> -> {error, timeout}; - _ -> {ok, Bin} - end end), - meck:expect(gen_tcp, close, fun(_) -> ok end) - end, - fun(_) -> meck:unload(gen_tcp) end, - [ - {"read zero bytes from empty socket", ?_assertMatch( - {_, {ok, <<>>}}, - read({t_socket, <<>>, 60000, []}, 0) - )}, - {"read 1 byte from empty socket", ?_assertMatch( - {_, {error, timeout}}, - read({t_socket, <<"empty">>, 60000, []}, 1) - )}, - {"read zero bytes from nonempty socket", ?_assertMatch( - {{t_socket, _, _, _}, {ok, <<>>}}, - read({t_socket, <<"hallo world">>, 60000, []}, 0) - )}, - {"read 1 byte from nonempty socket", ?_assertMatch( - {{t_socket, _, _, <<"allo world">>}, {ok, <<"h">>}}, - read({t_socket, <<"hallo world">>, 60000, []}, 1) - )}, - {"read a zillion bytes from nonempty socket", ?_assertMatch( - {{t_socket, _, _, <<"ld">>}, {ok, <<"hallo world world world world wor">>}}, - read({t_socket, <<"hallo world world world world world">>, 60000, []}, 33) - )}, - {"read 1 byte from previously buffered socket", ?_assertMatch( - {{t_socket, _, _, <<"allo">>}, {ok, <<"h">>}}, - read({t_socket, <<" world">>, 60000, <<"hallo">>}, 1) - )}, - {"read 6 byte from previously buffered socket", ?_assertMatch( - {{t_socket, _, _, <<"world">>}, {ok, <<"hallo ">>}}, - read({t_socket, <<" world">>, 60000, <<"hallo">>}, 6) - )}, - {"read a zillion bytes from previously buffered socket", ?_assertMatch( - {{t_socket, _, _, <<"ld">>}, {ok, <<"hallo world world world world wor">>}}, - read({t_socket, <<" world">>, 60000, <<"hallo">>}, 33) - )} - ] - }. - + {setup, + fun() -> + meck:new(gen_tcp, [unstick, passthrough]), + meck:expect(gen_tcp, recv, fun(Bin, 0, _) -> + case Bin of + <<"empty">> -> {error, timeout}; + _ -> {ok, Bin} + end + end), + meck:expect(gen_tcp, close, fun(_) -> ok end) + end, + fun(_) -> meck:unload(gen_tcp) end, [ + {"read zero bytes from empty socket", + ?_assertMatch( + {_, {ok, <<>>}}, + read({t_socket, <<>>, 60000, []}, 0) + )}, + {"read 1 byte from empty socket", + ?_assertMatch( + {_, {error, timeout}}, + read({t_socket, <<"empty">>, 60000, []}, 1) + )}, + {"read zero bytes from nonempty socket", + ?_assertMatch( + {{t_socket, _, _, _}, {ok, <<>>}}, + read({t_socket, <<"hallo world">>, 60000, []}, 0) + )}, + {"read 1 byte from nonempty socket", + ?_assertMatch( + {{t_socket, _, _, <<"allo world">>}, {ok, <<"h">>}}, + read({t_socket, <<"hallo world">>, 60000, []}, 1) + )}, + {"read a zillion bytes from nonempty socket", + ?_assertMatch( + {{t_socket, _, _, <<"ld">>}, {ok, <<"hallo world world world world wor">>}}, + read({t_socket, <<"hallo world world world world world">>, 60000, []}, 33) + )}, + {"read 1 byte from previously buffered socket", + ?_assertMatch( + {{t_socket, _, _, <<"allo">>}, {ok, <<"h">>}}, + read({t_socket, <<" world">>, 60000, <<"hallo">>}, 1) + )}, + {"read 6 byte from previously buffered socket", + ?_assertMatch( + {{t_socket, _, _, <<"world">>}, {ok, <<"hallo ">>}}, + read({t_socket, <<" world">>, 60000, <<"hallo">>}, 6) + )}, + {"read a zillion bytes from previously buffered socket", + ?_assertMatch( + {{t_socket, _, _, <<"ld">>}, {ok, <<"hallo world world world world wor">>}}, + read({t_socket, <<" world">>, 60000, <<"hallo">>}, 33) + )} + ]}. read_exact(Socket, Bytes) -> thrift_socket_transport:read_exact(Socket, Bytes). read_exact_test_() -> - {setup, - fun() -> - meck:new(gen_tcp, [unstick, passthrough]), - meck:expect(gen_tcp, recv, fun(Bin, N, _) -> - case N of - 0 -> {ok, Bin}; - 1 -> {ok, <<"h">>}; - N when N > 2 -> {error, timeout} - end - end), - meck:expect(gen_tcp, close, fun(_) -> ok end) - end, - fun(_) -> meck:unload(gen_tcp) end, - [ - {"read_exact zero bytes from empty socket", ?_assertMatch( - {_, {ok, <<>>}}, - read_exact({t_socket, <<>>, 60000, []}, 0) - )}, - {"read_exact zero bytes from nonempty socket", ?_assertMatch( - {{t_socket, _, _, _}, {ok, <<>>}}, - read_exact({t_socket, <<"hallo world">>, 60000, []}, 0) - )}, - {"read_exact 1 byte from nonempty socket", ?_assertMatch( - {{t_socket, _, _, []}, {ok, <<"h">>}}, - read_exact({t_socket, <<"hallo world">>, 60000, []}, 1) - )}, - {"read_exact a zillion bytes from nonempty socket", ?_assertMatch( - {{t_socket, _, _, []}, {error, timeout}}, - read_exact({t_socket, <<"hallo world">>, 60000, []}, 65536) - )}, - {"read_exact 1 byte from previously buffered socket", ?_assertMatch( - {{t_socket, _, _, <<"allo">>}, {ok, <<"h">>}}, - read_exact({t_socket, <<" world">>, 60000, <<"hallo">>}, 1) - )}, - {"read_exact 6 byte from previously buffered socket", ?_assertMatch( - {{t_socket, _, _, []}, {ok, <<"more h">>}}, - read_exact({t_socket, <<"hallo">>, 60000, <<"more ">>}, 6) - )}, - {"read_exact a zillion bytes from previously buffered socket", ?_assertMatch( - {{t_socket, _, _, <<"hallo">>}, {error, timeout}}, - read_exact({t_socket, <<" world">>, 60000, <<"hallo">>}, 65536) - )} - ] - }. - + {setup, + fun() -> + meck:new(gen_tcp, [unstick, passthrough]), + meck:expect(gen_tcp, recv, fun(Bin, N, _) -> + case N of + 0 -> {ok, Bin}; + 1 -> {ok, <<"h">>}; + N when N > 2 -> {error, timeout} + end + end), + meck:expect(gen_tcp, close, fun(_) -> ok end) + end, + fun(_) -> meck:unload(gen_tcp) end, [ + {"read_exact zero bytes from empty socket", + ?_assertMatch( + {_, {ok, <<>>}}, + read_exact({t_socket, <<>>, 60000, []}, 0) + )}, + {"read_exact zero bytes from nonempty socket", + ?_assertMatch( + {{t_socket, _, _, _}, {ok, <<>>}}, + read_exact({t_socket, <<"hallo world">>, 60000, []}, 0) + )}, + {"read_exact 1 byte from nonempty socket", + ?_assertMatch( + {{t_socket, _, _, []}, {ok, <<"h">>}}, + read_exact({t_socket, <<"hallo world">>, 60000, []}, 1) + )}, + {"read_exact a zillion bytes from nonempty socket", + ?_assertMatch( + {{t_socket, _, _, []}, {error, timeout}}, + read_exact({t_socket, <<"hallo world">>, 60000, []}, 65536) + )}, + {"read_exact 1 byte from previously buffered socket", + ?_assertMatch( + {{t_socket, _, _, <<"allo">>}, {ok, <<"h">>}}, + read_exact({t_socket, <<" world">>, 60000, <<"hallo">>}, 1) + )}, + {"read_exact 6 byte from previously buffered socket", + ?_assertMatch( + {{t_socket, _, _, []}, {ok, <<"more h">>}}, + read_exact({t_socket, <<"hallo">>, 60000, <<"more ">>}, 6) + )}, + {"read_exact a zillion bytes from previously buffered socket", + ?_assertMatch( + {{t_socket, _, _, <<"hallo">>}, {error, timeout}}, + read_exact({t_socket, <<" world">>, 60000, <<"hallo">>}, 65536) + )} + ]}. write(Socket, Data) -> thrift_socket_transport:write(Socket, Data). write_test_() -> - {setup, - fun() -> - meck:new(gen_tcp, [unstick, passthrough]), - meck:expect(gen_tcp, send, fun(_, _) -> ok end) - end, - fun(_) -> meck:unload(gen_tcp) end, - [ - {"write empty list to socket", ?_assertMatch( - {{t_socket, a_fake_socket, 60000, []}, ok}, - write({t_socket, a_fake_socket, 60000, []}, []) - )}, - {"write empty binary to socket", ?_assertMatch( - {{t_socket, a_fake_socket, 60000, []}, ok}, - write({t_socket, a_fake_socket, 60000, []}, <<>>) - )}, - {"write a list to socket", ?_assertMatch( - {{t_socket, a_fake_socket, 60000, []}, ok}, - write({t_socket, a_fake_socket, 60000, []}, "hallo world") - )}, - {"write a binary to socket", ?_assertMatch( - {{t_socket, a_fake_socket, 60000, []}, ok}, - write({t_socket, a_fake_socket, 60000, []}, <<"hallo world">>) - )} - ] - }. - + {setup, + fun() -> + meck:new(gen_tcp, [unstick, passthrough]), + meck:expect(gen_tcp, send, fun(_, _) -> ok end) + end, + fun(_) -> meck:unload(gen_tcp) end, [ + {"write empty list to socket", + ?_assertMatch( + {{t_socket, a_fake_socket, 60000, []}, ok}, + write({t_socket, a_fake_socket, 60000, []}, []) + )}, + {"write empty binary to socket", + ?_assertMatch( + {{t_socket, a_fake_socket, 60000, []}, ok}, + write({t_socket, a_fake_socket, 60000, []}, <<>>) + )}, + {"write a list to socket", + ?_assertMatch( + {{t_socket, a_fake_socket, 60000, []}, ok}, + write({t_socket, a_fake_socket, 60000, []}, "hallo world") + )}, + {"write a binary to socket", + ?_assertMatch( + {{t_socket, a_fake_socket, 60000, []}, ok}, + write({t_socket, a_fake_socket, 60000, []}, <<"hallo world">>) + )} + ]}. flush(Transport) -> thrift_socket_transport:flush(Transport). flush_test_() -> - [ - {"flush socket", ?_assertMatch( - {{t_socket, a_fake_socket, 60000, []}, ok}, - flush({t_socket, a_fake_socket, 60000, []}) - )} - ]. - + [ + {"flush socket", + ?_assertMatch( + {{t_socket, a_fake_socket, 60000, []}, ok}, + flush({t_socket, a_fake_socket, 60000, []}) + )} + ]. close(Transport) -> thrift_socket_transport:close(Transport). close_test_() -> - {setup, - fun() -> - meck:new(gen_tcp, [unstick, passthrough]), - meck:expect(gen_tcp, close, fun(_) -> ok end) - end, - fun(_) -> meck:unload(gen_tcp) end, - [ - {"close membuffer", ?_assertMatch( - {{t_socket, a_fake_socket, 60000, []}, ok}, - close({t_socket, a_fake_socket, 60000, []}) - )} - ] - }. + {setup, + fun() -> + meck:new(gen_tcp, [unstick, passthrough]), + meck:expect(gen_tcp, close, fun(_) -> ok end) + end, + fun(_) -> meck:unload(gen_tcp) end, [ + {"close membuffer", + ?_assertMatch( + {{t_socket, a_fake_socket, 60000, []}, ok}, + close({t_socket, a_fake_socket, 60000, []}) + )} + ]}. diff --git a/lib/erl/test/thrift_socket_server_test.erl b/lib/erl/test/thrift_socket_server_test.erl index 0818b844ea0..0330198e4c3 100644 --- a/lib/erl/test/thrift_socket_server_test.erl +++ b/lib/erl/test/thrift_socket_server_test.erl @@ -1,49 +1,133 @@ --module (thrift_socket_server_test). +%% +%% Licensed to the Apache Software Foundation (ASF) under one +%% or more contributor license agreements. See the NOTICE file +%% distributed with this work for additional information +%% regarding copyright ownership. The ASF licenses this file +%% to you under the Apache License, Version 2.0 (the +%% "License"); you may not use this file except in compliance +%% with the License. You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, +%% software distributed under the License is distributed on an +%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +%% KIND, either express or implied. See the License for the +%% specific language governing permissions and limitations +%% under the License. +%% + +-module(thrift_socket_server_test). -include_lib("eunit/include/eunit.hrl"). --include ("thrift_constants.hrl"). +-include("thrift_constants.hrl"). parse_handler_options_test_() -> - CorrectServiceHandlerOptionList = [{?MULTIPLEXED_ERROR_HANDLER_KEY, ?MODULE}, {"Service1", ?MODULE}, {"Service2", ?MODULE}], - MissingErrorHandlerOptionList = [{"Service1", ?MODULE}, {"Service2", ?MODULE}], - WrongService2HandlerOptionList = [{?MULTIPLEXED_ERROR_HANDLER_KEY, ?MODULE}, {"Service1", ?MODULE}, {"Service2", "Module"}], - WrongServiceKeyOptionList = [{?MULTIPLEXED_ERROR_HANDLER_KEY, ?MODULE}, {'service1', ?MODULE}, {"Service2", ?MODULE}], + CorrectServiceHandlerOptionList = [ + {?MULTIPLEXED_ERROR_HANDLER_KEY, ?MODULE}, {"Service1", ?MODULE}, {"Service2", ?MODULE} + ], + MissingErrorHandlerOptionList = [{"Service1", ?MODULE}, {"Service2", ?MODULE}], + WrongService2HandlerOptionList = [ + {?MULTIPLEXED_ERROR_HANDLER_KEY, ?MODULE}, {"Service1", ?MODULE}, {"Service2", "Module"} + ], + WrongServiceKeyOptionList = [ + {?MULTIPLEXED_ERROR_HANDLER_KEY, ?MODULE}, {'service1', ?MODULE}, {"Service2", ?MODULE} + ], CorrectHandlerTestFunction = fun() -> - ?assertMatch({thrift_socket_server,_,_,_,_,_,_,_,_,_,_,_,_,_}, thrift_socket_server:parse_options([{handler, CorrectServiceHandlerOptionList}])), - {thrift_socket_server,_,_, HandlerList,_,_,_,_,_,_,_,_,_,_} = thrift_socket_server:parse_options([{handler, CorrectServiceHandlerOptionList}]), - lists:foreach(fun - ({ServiceName, HandlerModule}) -> - ?assertMatch({ok, HandlerModule} when is_atom(HandlerModule), thrift_multiplexed_map_wrapper:find(ServiceName, HandlerList)) - end, CorrectServiceHandlerOptionList) + ?assertMatch( + #{}, + thrift_socket_server:parse_options([{handler, CorrectServiceHandlerOptionList}]) + ), + #{handler := HandlerList} = thrift_socket_server:parse_options( + [ + {handler, CorrectServiceHandlerOptionList} + ] + ), + lists:foreach( + fun({ServiceName, HandlerModule}) -> + ?assertMatch( + {ok, HandlerModule} when is_atom(HandlerModule), + thrift_multiplexed_map_wrapper:find(ServiceName, HandlerList) + ) + end, + CorrectServiceHandlerOptionList + ) end, [ - {"Bad argument for the handler option", ?_assertThrow(_, thrift_socket_server:parse_options([{handler, []}]))}, - {"Try to parse the handler option twice", ?_assertThrow(_, thrift_socket_server:parse_options([{handler, ?MODULE}, {handler, CorrectServiceHandlerOptionList}]))}, - {"Parse the handler option as a non multiplexed service handler", ?_assertMatch({thrift_socket_server,_,_,?MODULE,_,_,_,_,_,_,_,_,_,_}, thrift_socket_server:parse_options([{handler, ?MODULE}]))}, - {"No error handler was defined", ?_assertThrow(_, thrift_socket_server:parse_options([{handler, MissingErrorHandlerOptionList}]))}, - {"Bad handler module for Service2", ?_assertThrow(_, thrift_socket_server:parse_options([{handler, WrongService2HandlerOptionList}]))}, - {"Bad service key for Service1", ?_assertThrow(_, thrift_socket_server:parse_options([{handler, WrongServiceKeyOptionList}]))}, - {"Try to parse a correct handler option list", CorrectHandlerTestFunction} + {"Bad argument for the handler option", + ?_assertThrow(_, thrift_socket_server:parse_options([{handler, []}]))}, + {"Try to parse the handler option twice", + ?_assertThrow( + _, + thrift_socket_server:parse_options([ + {handler, ?MODULE}, {handler, CorrectServiceHandlerOptionList} + ]) + )}, + {"Parse the handler option as a non multiplexed service handler", + ?_assertMatch( + #{handler := ?MODULE}, + thrift_socket_server:parse_options([{handler, ?MODULE}]) + )}, + {"No error handler was defined", + ?_assertThrow( + _, thrift_socket_server:parse_options([{handler, MissingErrorHandlerOptionList}]) + )}, + {"Bad handler module for Service2", + ?_assertThrow( + _, thrift_socket_server:parse_options([{handler, WrongService2HandlerOptionList}]) + )}, + {"Bad service key for Service1", + ?_assertThrow( + _, thrift_socket_server:parse_options([{handler, WrongServiceKeyOptionList}]) + )}, + {"Try to parse a correct handler option list", CorrectHandlerTestFunction} ]. parse_service_options_test_() -> CorrectServiceModuleOptionList = [{"Service1", ?MODULE}, {"Service2", ?MODULE}], - WrongService2ModuleOptionList = [{"Service1", ?MODULE}, {"Service2", "thrift_service_module"}], - WrongServiceKeyOptionList = [{'service1', ?MODULE}, {"Service2", ?MODULE}], + WrongService2ModuleOptionList = [{"Service1", ?MODULE}, {"Service2", "thrift_service_module"}], + WrongServiceKeyOptionList = [{'service1', ?MODULE}, {"Service2", ?MODULE}], CorrectServiceModuleTestFunction = fun() -> - ?assertMatch({thrift_socket_server,_,_,_,_,_,_,_,_,_,_,_,_,_}, thrift_socket_server:parse_options([{service, CorrectServiceModuleOptionList}])), - {thrift_socket_server,_, ServiceModuleList,_,_,_,_,_,_,_,_,_,_,_} = thrift_socket_server:parse_options([{service, CorrectServiceModuleOptionList}]), - lists:foreach(fun - ({ServiceName, ServiceModule}) -> - ?assertMatch({ok, ServiceModule} when is_atom(ServiceModule), thrift_multiplexed_map_wrapper:find(ServiceName, ServiceModuleList)) - end, CorrectServiceModuleOptionList) + ?assertMatch( + #{}, + thrift_socket_server:parse_options([{service, CorrectServiceModuleOptionList}]) + ), + #{service := ServiceModuleList} = thrift_socket_server:parse_options( + [{service, CorrectServiceModuleOptionList}] + ), + lists:foreach( + fun({ServiceName, ServiceModule}) -> + ?assertMatch( + {ok, ServiceModule} when is_atom(ServiceModule), + thrift_multiplexed_map_wrapper:find(ServiceName, ServiceModuleList) + ) + end, + CorrectServiceModuleOptionList + ) end, [ - {"Bad argument for the service option", ?_assertThrow(_, thrift_socket_server:parse_options([{service, []}]))}, - {"Try to parse the service option twice", ?_assertThrow(_, thrift_socket_server:parse_options([{service, ?MODULE}, {service, CorrectServiceModuleOptionList}]))}, - {"Parse a service module for a non multiplexed service", ?_assertMatch({thrift_socket_server,_,?MODULE,_,_,_,_,_,_,_,_,_,_,_}, thrift_socket_server:parse_options([{service, ?MODULE}]))}, - {"Bad service module for Service2", ?_assertThrow(_, thrift_socket_server:parse_options([{service, WrongService2ModuleOptionList}]))}, - {"Bad service key for Service1", ?_assertThrow(_, thrift_socket_server:parse_options([{service, WrongServiceKeyOptionList}]))}, - {"Try to parse a correct service option list", CorrectServiceModuleTestFunction} + {"Bad argument for the service option", + ?_assertThrow(_, thrift_socket_server:parse_options([{service, []}]))}, + {"Try to parse the service option twice", + ?_assertThrow( + _, + thrift_socket_server:parse_options([ + {service, ?MODULE}, {service, CorrectServiceModuleOptionList} + ]) + )}, + {"Parse a service module for a non multiplexed service", + ?_assertMatch( + #{service := ?MODULE}, + thrift_socket_server:parse_options([{service, ?MODULE}]) + )}, + {"Bad service module for Service2", + ?_assertThrow( + _, thrift_socket_server:parse_options([{service, WrongService2ModuleOptionList}]) + )}, + {"Bad service key for Service1", + ?_assertThrow( + _, thrift_socket_server:parse_options([{service, WrongServiceKeyOptionList}]) + )}, + {"Try to parse a correct service option list", CorrectServiceModuleTestFunction} ]. diff --git a/lib/erl/test/thrift_test_test.erl b/lib/erl/test/thrift_test_test.erl index 77df61d9a1f..f86627b7300 100644 --- a/lib/erl/test/thrift_test_test.erl +++ b/lib/erl/test/thrift_test_test.erl @@ -19,625 +19,768 @@ % don't rename this thrift_test, it clobbers generated files -module(thrift_test_test). --compile(export_all). -include_lib("eunit/include/eunit.hrl"). -include("gen-erl/thrift_test_constants.hrl"). constant_test_() -> - [ - {"myNumberz equals 1", ?_assertEqual(1, ?THRIFT_TEST_MYNUMBERZ)} - ]. + [ + {"myNumberz equals 1", ?_assertEqual(1, ?THRIFT_TEST_MYNUMBERZ)} + ]. record_generation_test_() -> - [ - {"Bonk record", ?_assertMatch( - {'thrift.test.Bonk', _, _}, - #'thrift.test.Bonk'{message=null,type=null} - )}, - {"Bools record", ?_assertMatch( - {'thrift.test.Bools', _, _}, - #'thrift.test.Bools'{im_true=null,im_false=null} - )}, - {"Xtruct record", ?_assertMatch( - {'thrift.test.Xtruct', _, _, _, _}, - #'thrift.test.Xtruct'{string_thing=null,byte_thing=null,i32_thing=null,i64_thing=null} - )}, - {"Xtruct2 record", ?_assertMatch( - {'thrift.test.Xtruct2', _, _, _}, - #'thrift.test.Xtruct2'{byte_thing=null,struct_thing=null,i32_thing=null} - )}, - {"Xtruct3 record", ?_assertMatch( - {'thrift.test.Xtruct3', _, _, _, _}, - #'thrift.test.Xtruct3'{string_thing=null,changed=null,i32_thing=null,i64_thing=null} - )}, - {"Insanity record", ?_assertMatch( - {'thrift.test.Insanity', _, _}, - #'thrift.test.Insanity'{userMap=null,xtructs=null} - )}, - {"CrazyNesting record", ?_assertMatch( - {'thrift.test.CrazyNesting', _, _, _, _}, - #'thrift.test.CrazyNesting'{ - string_field=null, - set_field=null, - list_field=null, - binary_field=null - } - )}, - {"Xception record", ?_assertMatch( - {'thrift.test.Xception', _, _}, - #'thrift.test.Xception'{errorCode=null,message=null} - )}, - {"Xception2 record", ?_assertMatch( - {'thrift.test.Xception2', _, _}, - #'thrift.test.Xception2'{errorCode=null,struct_thing=null} - )}, - {"EmptyStruct record", ?_assertMatch({'thrift.test.EmptyStruct'}, #'thrift.test.EmptyStruct'{})}, - {"OneField record", ?_assertMatch({'thrift.test.OneField', _}, #'thrift.test.OneField'{field=null})}, - {"VersioningTestV1 record", ?_assertMatch( - {'thrift.test.VersioningTestV1', _, _, _}, - #'thrift.test.VersioningTestV1'{begin_in_both=null,old_string=null,end_in_both=null} - )}, - {"VersioningTestV2 record", ?_assertMatch( - {'thrift.test.VersioningTestV2', _, _, _, _, _, _, _, _, _, _, _, _}, - #'thrift.test.VersioningTestV2'{ - begin_in_both=null, - newint=null, - newbyte=null, - newshort=null, - newlong=null, - newdouble=null, - newstruct=null, - newlist=null, - newset=null, - newmap=null, - newstring=null, - end_in_both=null - } - )}, - {"ListTypeVersioningV1 record", ?_assertMatch( - {'thrift.test.ListTypeVersioningV1', _, _}, - #'thrift.test.ListTypeVersioningV1'{myints=null,hello=null} - )}, - {"ListTypeVersioningV2 record", ?_assertMatch( - {'thrift.test.ListTypeVersioningV2', _, _}, - #'thrift.test.ListTypeVersioningV2'{strings=null,hello=null} - )}, - {"GuessProtocolStruct record", ?_assertMatch( - {'thrift.test.GuessProtocolStruct', _}, - #'thrift.test.GuessProtocolStruct'{map_field=null} - )}, - {"LargeDeltas record", ?_assertMatch( - {'thrift.test.LargeDeltas', _, _, _, _, _, _, _, _, _, _}, - #'thrift.test.LargeDeltas'{ - b1=null, - b10=null, - b100=null, - check_true=null, - b1000=null, - check_false=null, - vertwo2000=null, - a_set2500=null, - vertwo3000=null, - big_numbers=null - } - )}, - {"NestedListsI32x2 record", ?_assertMatch( - {'thrift.test.NestedListsI32x2', _}, - #'thrift.test.NestedListsI32x2'{integerlist=null} - )}, - {"NestedListsI32x3 record", ?_assertMatch( - {'thrift.test.NestedListsI32x3', _}, - #'thrift.test.NestedListsI32x3'{integerlist=null} - )}, - {"NestedMixedx2 record", ?_assertMatch( - {'thrift.test.NestedMixedx2', _, _, _}, - #'thrift.test.NestedMixedx2'{ - int_set_list=null, - map_int_strset=null, - map_int_strset_list=null - } - )}, - {"ListBonks record", ?_assertMatch({'thrift.test.ListBonks', _}, #'thrift.test.ListBonks'{bonk=null})}, - {"NestedListsBonk record", ?_assertMatch( - {'thrift.test.NestedListsBonk', _}, - #'thrift.test.NestedListsBonk'{bonk=null} - )}, - {"BoolTest record", ?_assertMatch( - {'thrift.test.BoolTest', _, _}, - #'thrift.test.BoolTest'{b=null,s=null} - )}, - {"StructA record", ?_assertMatch({'thrift.test.StructA', _}, #'thrift.test.StructA'{s=null})}, - {"StructB record", ?_assertMatch( - {'thrift.test.StructB', _, _}, - #'thrift.test.StructB'{aa=null,ab=null} - )} - ]. + [ + {"Bonk record", + ?_assertMatch( + {'thrift.test.Bonk', _, _}, + #'thrift.test.Bonk'{message = null, type = null} + )}, + {"Bools record", + ?_assertMatch( + {'thrift.test.Bools', _, _}, + #'thrift.test.Bools'{im_true = null, im_false = null} + )}, + {"Xtruct record", + ?_assertMatch( + {'thrift.test.Xtruct', _, _, _, _}, + #'thrift.test.Xtruct'{ + string_thing = null, byte_thing = null, i32_thing = null, i64_thing = null + } + )}, + {"Xtruct2 record", + ?_assertMatch( + {'thrift.test.Xtruct2', _, _, _}, + #'thrift.test.Xtruct2'{byte_thing = null, struct_thing = null, i32_thing = null} + )}, + {"Xtruct3 record", + ?_assertMatch( + {'thrift.test.Xtruct3', _, _, _, _}, + #'thrift.test.Xtruct3'{ + string_thing = null, changed = null, i32_thing = null, i64_thing = null + } + )}, + {"Insanity record", + ?_assertMatch( + {'thrift.test.Insanity', _, _}, + #'thrift.test.Insanity'{userMap = null, xtructs = null} + )}, + {"CrazyNesting record", + ?_assertMatch( + {'thrift.test.CrazyNesting', _, _, _, _}, + #'thrift.test.CrazyNesting'{ + string_field = null, + set_field = null, + list_field = null, + binary_field = null + } + )}, + {"Xception record", + ?_assertMatch( + {'thrift.test.Xception', _, _}, + #'thrift.test.Xception'{errorCode = null, message = null} + )}, + {"Xception2 record", + ?_assertMatch( + {'thrift.test.Xception2', _, _}, + #'thrift.test.Xception2'{errorCode = null, struct_thing = null} + )}, + {"EmptyStruct record", + ?_assertMatch({'thrift.test.EmptyStruct'}, #'thrift.test.EmptyStruct'{})}, + {"OneField record", + ?_assertMatch({'thrift.test.OneField', _}, #'thrift.test.OneField'{field = null})}, + {"VersioningTestV1 record", + ?_assertMatch( + {'thrift.test.VersioningTestV1', _, _, _}, + #'thrift.test.VersioningTestV1'{ + begin_in_both = null, old_string = null, end_in_both = null + } + )}, + {"VersioningTestV2 record", + ?_assertMatch( + {'thrift.test.VersioningTestV2', _, _, _, _, _, _, _, _, _, _, _, _}, + #'thrift.test.VersioningTestV2'{ + begin_in_both = null, + newint = null, + newbyte = null, + newshort = null, + newlong = null, + newdouble = null, + newstruct = null, + newlist = null, + newset = null, + newmap = null, + newstring = null, + end_in_both = null + } + )}, + {"ListTypeVersioningV1 record", + ?_assertMatch( + {'thrift.test.ListTypeVersioningV1', _, _}, + #'thrift.test.ListTypeVersioningV1'{myints = null, hello = null} + )}, + {"ListTypeVersioningV2 record", + ?_assertMatch( + {'thrift.test.ListTypeVersioningV2', _, _}, + #'thrift.test.ListTypeVersioningV2'{strings = null, hello = null} + )}, + {"GuessProtocolStruct record", + ?_assertMatch( + {'thrift.test.GuessProtocolStruct', _}, + #'thrift.test.GuessProtocolStruct'{map_field = null} + )}, + {"LargeDeltas record", + ?_assertMatch( + {'thrift.test.LargeDeltas', _, _, _, _, _, _, _, _, _, _}, + #'thrift.test.LargeDeltas'{ + b1 = null, + b10 = null, + b100 = null, + check_true = null, + b1000 = null, + check_false = null, + vertwo2000 = null, + a_set2500 = null, + vertwo3000 = null, + big_numbers = null + } + )}, + {"NestedListsI32x2 record", + ?_assertMatch( + {'thrift.test.NestedListsI32x2', _}, + #'thrift.test.NestedListsI32x2'{integerlist = null} + )}, + {"NestedListsI32x3 record", + ?_assertMatch( + {'thrift.test.NestedListsI32x3', _}, + #'thrift.test.NestedListsI32x3'{integerlist = null} + )}, + {"NestedMixedx2 record", + ?_assertMatch( + {'thrift.test.NestedMixedx2', _, _, _}, + #'thrift.test.NestedMixedx2'{ + int_set_list = null, + map_int_strset = null, + map_int_strset_list = null + } + )}, + {"ListBonks record", + ?_assertMatch({'thrift.test.ListBonks', _}, #'thrift.test.ListBonks'{bonk = null})}, + {"NestedListsBonk record", + ?_assertMatch( + {'thrift.test.NestedListsBonk', _}, + #'thrift.test.NestedListsBonk'{bonk = null} + )}, + {"BoolTest record", + ?_assertMatch( + {'thrift.test.BoolTest', _, _}, + #'thrift.test.BoolTest'{b = null, s = null} + )}, + {"StructA record", + ?_assertMatch({'thrift.test.StructA', _}, #'thrift.test.StructA'{s = null})}, + {"StructB record", + ?_assertMatch( + {'thrift.test.StructB', _, _}, + #'thrift.test.StructB'{aa = null, ab = null} + )} + ]. struct_info_test_() -> - [ - {"Bonk definition (short version)", ?_assertEqual( - {struct, [{1, string}, {2, i32}]}, - thrift_test_types:struct_info('thrift.test.Bonk') - )}, - {"Bonk definition", ?_assertEqual( - {struct, [ - {1, undefined, string, message, undefined}, - {2, undefined, i32, type, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.Bonk') - )}, - {"Bools definition", ?_assertEqual( - {struct, [ - {1, undefined, bool, im_true, undefined}, - {2, undefined, bool, im_false, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.Bools') - )}, - {"Xtruct definition", ?_assertEqual( - {struct, [ - {1, undefined, string, string_thing, undefined}, - {4, undefined, byte, byte_thing, undefined}, - {9, undefined, i32, i32_thing, undefined}, - {11, undefined, i64, i64_thing, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.Xtruct') - )}, - {"Xtruct2 definition", ?_assertEqual( - {struct, [ - {1, undefined, byte, byte_thing, undefined}, - {2, undefined, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}, struct_thing, #'thrift.test.Xtruct'{}}, - {3, undefined, i32, i32_thing, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.Xtruct2') - )}, - {"Xtruct3 definition", ?_assertEqual( - {struct, [ - {1, undefined, string, string_thing, undefined}, - {4, undefined, i32, changed, undefined}, - {9, undefined, i32, i32_thing, undefined}, - {11, undefined, i64, i64_thing, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.Xtruct3') - )}, - {"Insanity definition", ?_assertEqual( - {struct, [ - {1, undefined, {map, i32, i64}, userMap, dict:new()}, - {2, undefined, {list, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}}, xtructs, []} - ]}, - thrift_test_types:struct_info_ext('thrift.test.Insanity') - )}, - {"CrazyNesting definition", ?_assertEqual( - {struct, [ - {1, undefined, string, string_field, undefined}, - {2, optional, {set, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}}, set_field, sets:new()}, - {3, required, {list, {map, - {set, i32}, - {map, i32, {set, {list, {map, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}, string}}}} - }}, list_field, []}, - {4, undefined, string, binary_field, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.CrazyNesting') - )}, - {"Xception definition", ?_assertEqual( - {struct, [ - {1, undefined, i32, errorCode, undefined}, - {2, undefined, string, message, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.Xception') - )}, - {"Xception2 definition", ?_assertEqual( - {struct, [ - {1, undefined, i32, errorCode, undefined}, - {2, undefined, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}, struct_thing, #'thrift.test.Xtruct'{}} - ]}, - thrift_test_types:struct_info_ext('thrift.test.Xception2') - )}, - {"EmptyStruct definition", ?_assertEqual( - {struct, []}, - thrift_test_types:struct_info_ext('thrift.test.EmptyStruct') - )}, - {"OneField definition", ?_assertEqual( - {struct, [ - {1, undefined, {struct, {'thrift_test_types', 'thrift.test.EmptyStruct'}}, field, #'thrift.test.EmptyStruct'{}} - ]}, - thrift_test_types:struct_info_ext('thrift.test.OneField') - )}, - {"VersioningTestV1 definition", ?_assertEqual( - {struct, [ - {1, undefined, i32, begin_in_both, undefined}, - {3, undefined, string, old_string, undefined}, - {12, undefined, i32, end_in_both, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.VersioningTestV1') - )}, - {"VersioningTestV2 definition", ?_assertEqual( - {struct, [ - {1, undefined, i32, begin_in_both, undefined}, - {2, undefined, i32, newint, undefined}, - {3, undefined, byte, newbyte, undefined}, - {4, undefined, i16, newshort, undefined}, - {5, undefined, i64, newlong, undefined}, - {6, undefined, double, newdouble, undefined}, - {7, undefined, {struct, {thrift_test_types, 'thrift.test.Bonk'}}, newstruct, #'thrift.test.Bonk'{}}, - {8, undefined, {list, i32}, newlist, []}, - {9, undefined, {set, i32}, newset, sets:new()}, - {10, undefined, {map, i32, i32}, newmap, dict:new()}, - {11, undefined, string, newstring, undefined}, - {12, undefined, i32, end_in_both, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.VersioningTestV2') - )}, - {"ListTypeVersioningV1 definition", ?_assertEqual( - {struct, [ - {1, undefined, {list, i32}, myints, []}, - {2, undefined, string, hello, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.ListTypeVersioningV1') - )}, - {"ListTypeVersioningV2 definition", ?_assertEqual( - {struct, [ - {1, undefined, {list, string}, strings, []}, - {2, undefined, string, hello, undefined} - ]}, - thrift_test_types:struct_info_ext('thrift.test.ListTypeVersioningV2') - )}, - {"GuessProtocolStruct definition", ?_assertEqual( - {struct, [ - {7, undefined, {map, string, string}, map_field, dict:new()} - ]}, - thrift_test_types:struct_info_ext('thrift.test.GuessProtocolStruct') - )}, - {"LargeDeltas definition", ?_assertEqual( - {struct, [ - {1, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b1, #'thrift.test.Bools'{}}, - {10, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b10, #'thrift.test.Bools'{}}, - {100, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b100, #'thrift.test.Bools'{}}, - {500, undefined, bool, check_true, undefined}, - {1000, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b1000, #'thrift.test.Bools'{}}, - {1500, undefined, bool, check_false, undefined}, - {2000, undefined, {struct, {thrift_test_types, 'thrift.test.VersioningTestV2'}}, vertwo2000, #'thrift.test.VersioningTestV2'{}}, - {2500, undefined, {set, string}, a_set2500, sets:new()}, - {3000, undefined, {struct, {thrift_test_types, 'thrift.test.VersioningTestV2'}}, vertwo3000, #'thrift.test.VersioningTestV2'{}}, - {4000, undefined, {list, i32}, big_numbers, []} - ]}, - thrift_test_types:struct_info_ext('thrift.test.LargeDeltas') - )}, - {"NestedListsI32x2 definition", ?_assertEqual( - {struct, [ - {1, undefined, {list, {list, i32}}, integerlist, []} - ]}, - thrift_test_types:struct_info_ext('thrift.test.NestedListsI32x2') - )}, - {"NestedListsI32x3 definition", ?_assertEqual( - {struct, [ - {1, undefined, {list, {list, {list, i32}}}, integerlist, []} - ]}, - thrift_test_types:struct_info_ext('thrift.test.NestedListsI32x3') - )}, - {"NestedMixedx2 definition", ?_assertEqual( - {struct, [ - {1, undefined, {list, {set, i32}}, int_set_list, []}, - {2, undefined, {map, i32, {set, string}}, map_int_strset, dict:new()}, - {3, undefined, {list, {map, i32, {set, string}}}, map_int_strset_list, []} - ]}, - thrift_test_types:struct_info_ext('thrift.test.NestedMixedx2') - )}, - {"ListBonks definition", ?_assertEqual( - {struct, [ - {1, undefined, {list, {struct, {thrift_test_types, 'thrift.test.Bonk'}}}, bonk, []} - ]}, - thrift_test_types:struct_info_ext('thrift.test.ListBonks') - )}, - {"NestedListsBonk definition", ?_assertEqual( - {struct, [ - {1, undefined, {list, {list, {list, {struct, {thrift_test_types, 'thrift.test.Bonk'}}}}}, bonk, []} - ]}, - thrift_test_types:struct_info_ext('thrift.test.NestedListsBonk') - )}, - {"BoolTest definition", ?_assertEqual( - {struct, [ - {1, optional, bool, b, true}, - {2, optional, string, s, "true"} - ]}, - thrift_test_types:struct_info_ext('thrift.test.BoolTest') - )}, - {"StructA definition", ?_assertEqual( - {struct, [{1, required, string, s, undefined}]}, - thrift_test_types:struct_info_ext('thrift.test.StructA') - )}, - {"StructB definition", ?_assertEqual( - {struct, [ - {1, optional, {struct, {thrift_test_types, 'thrift.test.StructA'}}, aa, #'thrift.test.StructA'{}}, - {2, required, {struct, {thrift_test_types, 'thrift.test.StructA'}}, ab, #'thrift.test.StructA'{}} - ]}, - thrift_test_types:struct_info_ext('thrift.test.StructB') - )} - ]. + [ + {"Bonk definition (short version)", + ?_assertEqual( + {struct, [{1, string}, {2, i32}]}, + thrift_test_types:struct_info('thrift.test.Bonk') + )}, + {"Bonk definition", + ?_assertEqual( + {struct, [ + {1, undefined, string, message, undefined}, + {2, undefined, i32, type, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.Bonk') + )}, + {"Bools definition", + ?_assertEqual( + {struct, [ + {1, undefined, bool, im_true, undefined}, + {2, undefined, bool, im_false, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.Bools') + )}, + {"Xtruct definition", + ?_assertEqual( + {struct, [ + {1, undefined, string, string_thing, undefined}, + {4, undefined, byte, byte_thing, undefined}, + {9, undefined, i32, i32_thing, undefined}, + {11, undefined, i64, i64_thing, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.Xtruct') + )}, + {"Xtruct2 definition", + ?_assertEqual( + {struct, [ + {1, undefined, byte, byte_thing, undefined}, + {2, undefined, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}, + struct_thing, #'thrift.test.Xtruct'{}}, + {3, undefined, i32, i32_thing, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.Xtruct2') + )}, + {"Xtruct3 definition", + ?_assertEqual( + {struct, [ + {1, undefined, string, string_thing, undefined}, + {4, undefined, i32, changed, undefined}, + {9, undefined, i32, i32_thing, undefined}, + {11, undefined, i64, i64_thing, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.Xtruct3') + )}, + {"Insanity definition", + ?_assertEqual( + {struct, [ + {1, undefined, {map, i32, i64}, userMap, dict:new()}, + {2, undefined, {list, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}}, + xtructs, []} + ]}, + thrift_test_types:struct_info_ext('thrift.test.Insanity') + )}, + {"CrazyNesting definition", + ?_assertEqual( + {struct, [ + {1, undefined, string, string_field, undefined}, + {2, optional, {set, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}}, + set_field, sets:new()}, + {3, required, + {list, + {map, {set, i32}, + {map, i32, + {set, + {list, + {map, + {struct, + {'thrift_test_types', 'thrift.test.Insanity'}}, + string}}}}}}, + list_field, []}, + {4, undefined, string, binary_field, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.CrazyNesting') + )}, + {"Xception definition", + ?_assertEqual( + {struct, [ + {1, undefined, i32, errorCode, undefined}, + {2, undefined, string, message, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.Xception') + )}, + {"Xception2 definition", + ?_assertEqual( + {struct, [ + {1, undefined, i32, errorCode, undefined}, + {2, undefined, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}, + struct_thing, #'thrift.test.Xtruct'{}} + ]}, + thrift_test_types:struct_info_ext('thrift.test.Xception2') + )}, + {"EmptyStruct definition", + ?_assertEqual( + {struct, []}, + thrift_test_types:struct_info_ext('thrift.test.EmptyStruct') + )}, + {"OneField definition", + ?_assertEqual( + {struct, [ + {1, undefined, {struct, {'thrift_test_types', 'thrift.test.EmptyStruct'}}, + field, #'thrift.test.EmptyStruct'{}} + ]}, + thrift_test_types:struct_info_ext('thrift.test.OneField') + )}, + {"VersioningTestV1 definition", + ?_assertEqual( + {struct, [ + {1, undefined, i32, begin_in_both, undefined}, + {3, undefined, string, old_string, undefined}, + {12, undefined, i32, end_in_both, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.VersioningTestV1') + )}, + {"VersioningTestV2 definition", + ?_assertEqual( + {struct, [ + {1, undefined, i32, begin_in_both, undefined}, + {2, undefined, i32, newint, undefined}, + {3, undefined, byte, newbyte, undefined}, + {4, undefined, i16, newshort, undefined}, + {5, undefined, i64, newlong, undefined}, + {6, undefined, double, newdouble, undefined}, + {7, undefined, {struct, {thrift_test_types, 'thrift.test.Bonk'}}, newstruct, + #'thrift.test.Bonk'{}}, + {8, undefined, {list, i32}, newlist, []}, + {9, undefined, {set, i32}, newset, sets:new()}, + {10, undefined, {map, i32, i32}, newmap, dict:new()}, + {11, undefined, string, newstring, undefined}, + {12, undefined, i32, end_in_both, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.VersioningTestV2') + )}, + {"ListTypeVersioningV1 definition", + ?_assertEqual( + {struct, [ + {1, undefined, {list, i32}, myints, []}, + {2, undefined, string, hello, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.ListTypeVersioningV1') + )}, + {"ListTypeVersioningV2 definition", + ?_assertEqual( + {struct, [ + {1, undefined, {list, string}, strings, []}, + {2, undefined, string, hello, undefined} + ]}, + thrift_test_types:struct_info_ext('thrift.test.ListTypeVersioningV2') + )}, + {"GuessProtocolStruct definition", + ?_assertEqual( + {struct, [ + {7, undefined, {map, string, string}, map_field, dict:new()} + ]}, + thrift_test_types:struct_info_ext('thrift.test.GuessProtocolStruct') + )}, + {"LargeDeltas definition", + ?_assertEqual( + {struct, [ + {1, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b1, + #'thrift.test.Bools'{}}, + {10, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b10, + #'thrift.test.Bools'{}}, + {100, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b100, + #'thrift.test.Bools'{}}, + {500, undefined, bool, check_true, undefined}, + {1000, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b1000, + #'thrift.test.Bools'{}}, + {1500, undefined, bool, check_false, undefined}, + {2000, undefined, {struct, {thrift_test_types, 'thrift.test.VersioningTestV2'}}, + vertwo2000, #'thrift.test.VersioningTestV2'{}}, + {2500, undefined, {set, string}, a_set2500, sets:new()}, + {3000, undefined, {struct, {thrift_test_types, 'thrift.test.VersioningTestV2'}}, + vertwo3000, #'thrift.test.VersioningTestV2'{}}, + {4000, undefined, {list, i32}, big_numbers, []} + ]}, + thrift_test_types:struct_info_ext('thrift.test.LargeDeltas') + )}, + {"NestedListsI32x2 definition", + ?_assertEqual( + {struct, [ + {1, undefined, {list, {list, i32}}, integerlist, []} + ]}, + thrift_test_types:struct_info_ext('thrift.test.NestedListsI32x2') + )}, + {"NestedListsI32x3 definition", + ?_assertEqual( + {struct, [ + {1, undefined, {list, {list, {list, i32}}}, integerlist, []} + ]}, + thrift_test_types:struct_info_ext('thrift.test.NestedListsI32x3') + )}, + {"NestedMixedx2 definition", + ?_assertEqual( + {struct, [ + {1, undefined, {list, {set, i32}}, int_set_list, []}, + {2, undefined, {map, i32, {set, string}}, map_int_strset, dict:new()}, + {3, undefined, {list, {map, i32, {set, string}}}, map_int_strset_list, []} + ]}, + thrift_test_types:struct_info_ext('thrift.test.NestedMixedx2') + )}, + {"ListBonks definition", + ?_assertEqual( + {struct, [ + {1, undefined, {list, {struct, {thrift_test_types, 'thrift.test.Bonk'}}}, bonk, + []} + ]}, + thrift_test_types:struct_info_ext('thrift.test.ListBonks') + )}, + {"NestedListsBonk definition", + ?_assertEqual( + {struct, [ + {1, undefined, + {list, {list, {list, {struct, {thrift_test_types, 'thrift.test.Bonk'}}}}}, + bonk, []} + ]}, + thrift_test_types:struct_info_ext('thrift.test.NestedListsBonk') + )}, + {"BoolTest definition", + ?_assertEqual( + {struct, [ + {1, optional, bool, b, true}, + {2, optional, string, s, "true"} + ]}, + thrift_test_types:struct_info_ext('thrift.test.BoolTest') + )}, + {"StructA definition", + ?_assertEqual( + {struct, [{1, required, string, s, undefined}]}, + thrift_test_types:struct_info_ext('thrift.test.StructA') + )}, + {"StructB definition", + ?_assertEqual( + {struct, [ + {1, optional, {struct, {thrift_test_types, 'thrift.test.StructA'}}, aa, + #'thrift.test.StructA'{}}, + {2, required, {struct, {thrift_test_types, 'thrift.test.StructA'}}, ab, + #'thrift.test.StructA'{}} + ]}, + thrift_test_types:struct_info_ext('thrift.test.StructB') + )} + ]. service_info_test_() -> - [ - {"testVoid params", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testVoid, params_type) - )}, - {"testVoid reply", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testVoid, reply_type) - )}, - {"testVoid exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testVoid, exceptions) - )}, - {"testString params", ?_assertEqual( - {struct, [{1, string}]}, - thrift_test_thrift:function_info(testString, params_type) - )}, - {"testString reply", ?_assertEqual( - string, - thrift_test_thrift:function_info(testString, reply_type) - )}, - {"testString exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testString, exceptions) - )}, - {"testByte params", ?_assertEqual( - {struct, [{1, byte}]}, - thrift_test_thrift:function_info(testByte, params_type) - )}, - {"testByte reply", ?_assertEqual( - byte, - thrift_test_thrift:function_info(testByte, reply_type) - )}, - {"testByte exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testByte, exceptions) - )}, - {"testI32 params", ?_assertEqual( - {struct, [{1, i32}]}, - thrift_test_thrift:function_info(testI32, params_type) - )}, - {"testI32 reply", ?_assertEqual( - i32, - thrift_test_thrift:function_info(testI32, reply_type) - )}, - {"testI32 exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testI32, exceptions) - )}, - {"testI64 params", ?_assertEqual( - {struct, [{1, i64}]}, - thrift_test_thrift:function_info(testI64, params_type) - )}, - {"testI64 reply", ?_assertEqual( - i64, - thrift_test_thrift:function_info(testI64, reply_type) - )}, - {"testI64 exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testI64, exceptions) - )}, - {"testDouble params", ?_assertEqual( - {struct, [{1, double}]}, - thrift_test_thrift:function_info(testDouble, params_type) - )}, - {"testDouble reply", ?_assertEqual( - double, - thrift_test_thrift:function_info(testDouble, reply_type) - )}, - {"testDouble exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testDouble, exceptions) - )}, - {"testStruct params", ?_assertEqual( - {struct, [ - {1, {struct, {thrift_test_types, 'thrift.test.Xtruct'}}} - ]}, - thrift_test_thrift:function_info(testStruct, params_type) - )}, - {"testStruct reply", ?_assertEqual( - {struct, {thrift_test_types, 'thrift.test.Xtruct'}}, - thrift_test_thrift:function_info(testStruct, reply_type) - )}, - {"testStruct exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testStruct, exceptions) - )}, - {"testNest params", ?_assertEqual( - {struct, [ - {1, {struct, {thrift_test_types, 'thrift.test.Xtruct2'}}} - ]}, - thrift_test_thrift:function_info(testNest, params_type) - )}, - {"testNest reply", ?_assertEqual( - {struct, {thrift_test_types, 'thrift.test.Xtruct2'}}, - thrift_test_thrift:function_info(testNest, reply_type) - )}, - {"testNest exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testNest, exceptions) - )}, - {"testMap params", ?_assertEqual( - {struct, [ - {1, {map, i32, i32}} - ]}, - thrift_test_thrift:function_info(testMap, params_type) - )}, - {"testMap reply", ?_assertEqual( - {map, i32, i32}, - thrift_test_thrift:function_info(testMap, reply_type) - )}, - {"testMap exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testMap, exceptions) - )}, - {"testStringMap params", ?_assertEqual( - {struct, [ - {1, {map, string, string}} - ]}, - thrift_test_thrift:function_info(testStringMap, params_type) - )}, - {"testStringMap reply", ?_assertEqual( - {map, string, string}, - thrift_test_thrift:function_info(testStringMap, reply_type) - )}, - {"testStringMap exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testStringMap, exceptions) - )}, - {"testSet params", ?_assertEqual( - {struct, [ - {1, {set, i32}} - ]}, - thrift_test_thrift:function_info(testSet, params_type) - )}, - {"testSet reply", ?_assertEqual( - {set, i32}, - thrift_test_thrift:function_info(testSet, reply_type) - )}, - {"testSet exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testSet, exceptions) - )}, - {"testList params", ?_assertEqual( - {struct, [ - {1, {list, i32}} - ]}, - thrift_test_thrift:function_info(testList, params_type) - )}, - {"testList reply", ?_assertEqual( - {list, i32}, - thrift_test_thrift:function_info(testList, reply_type) - )}, - {"testList exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testList, exceptions) - )}, - {"testEnum params", ?_assertEqual( - {struct, [ - {1, i32} - ]}, - thrift_test_thrift:function_info(testEnum, params_type) - )}, - {"testEnum reply", ?_assertEqual( - i32, - thrift_test_thrift:function_info(testEnum, reply_type) - )}, - {"testEnum exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testEnum, exceptions) - )}, - {"testTypedef params", ?_assertEqual( - {struct, [{1, i64}]}, - thrift_test_thrift:function_info(testTypedef, params_type) - )}, - {"testTypedef reply", ?_assertEqual( - i64, - thrift_test_thrift:function_info(testTypedef, reply_type) - )}, - {"testTypedef exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testTypedef, exceptions) - )}, - {"testMapMap params", ?_assertEqual( - {struct, [ - {1, i32} - ]}, - thrift_test_thrift:function_info(testMapMap, params_type) - )}, - {"testMapMap reply", ?_assertEqual( - {map, i32, {map, i32,i32}}, - thrift_test_thrift:function_info(testMapMap, reply_type) - )}, - {"testMapMap exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testMapMap, exceptions) - )}, - {"testInsanity params", ?_assertEqual( - {struct, [ - {1, {struct, {thrift_test_types, 'thrift.test.Insanity'}}} - ]}, - thrift_test_thrift:function_info(testInsanity, params_type) - )}, - {"testInsanity reply", ?_assertEqual( - {map, i64, {map, i32, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}}}, - thrift_test_thrift:function_info(testInsanity, reply_type) - )}, - {"testInsanity exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testInsanity, exceptions) - )}, - {"testMulti params", ?_assertEqual( - {struct, [ - {1, byte}, - {2, i32}, - {3, i64}, - {4, {map, i16, string}}, - {5, i32}, - {6, i64} - ]}, - thrift_test_thrift:function_info(testMulti, params_type) - )}, - {"testMulti reply", ?_assertEqual( - {struct, {thrift_test_types, 'thrift.test.Xtruct'}}, - thrift_test_thrift:function_info(testMulti, reply_type) - )}, - {"testMulti exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testMulti, exceptions) - )}, - {"testException params", ?_assertEqual( - {struct, [{1, string}]}, - thrift_test_thrift:function_info(testException, params_type) - )}, - {"testException reply", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testException, reply_type) - )}, - {"testException exceptions", ?_assertEqual( - {struct, [ - {1, {struct, {thrift_test_types, 'thrift.test.Xception'}}} - ]}, - thrift_test_thrift:function_info(testException, exceptions) - )}, - {"testMultiException params", ?_assertEqual( - {struct, [{1, string}, {2, string}]}, - thrift_test_thrift:function_info(testMultiException, params_type) - )}, - {"testMultiException reply", ?_assertEqual( - {struct, {thrift_test_types, 'thrift.test.Xtruct'}}, - thrift_test_thrift:function_info(testMultiException, reply_type) - )}, - {"testMultiException exceptions", ?_assertEqual( - {struct, [ - {1, {struct, {thrift_test_types, 'thrift.test.Xception'}}}, - {2, {struct, {thrift_test_types, 'thrift.test.Xception2'}}} - ]}, - thrift_test_thrift:function_info(testMultiException, exceptions) - )}, - {"testOneway params", ?_assertEqual( - {struct, [{1, i32}]}, - thrift_test_thrift:function_info(testOneway, params_type) - )}, - {"testOneway reply", ?_assertEqual( - oneway_void, - thrift_test_thrift:function_info(testOneway, reply_type) - )}, - {"testOneway exceptions", ?_assertEqual( - {struct, []}, - thrift_test_thrift:function_info(testOneway, exceptions) - )}, - {"secondtestString params", ?_assertEqual( - {struct, [{1, string}]}, - second_service_thrift:function_info(secondtestString, params_type) - )}, - {"secondtestString reply", ?_assertEqual( - string, - second_service_thrift:function_info(secondtestString, reply_type) - )}, - {"secondtestString exceptions", ?_assertEqual( - {struct, []}, - second_service_thrift:function_info(secondtestString, exceptions) - )} - ]. + [ + {"testVoid params", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testVoid, params_type) + )}, + {"testVoid reply", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testVoid, reply_type) + )}, + {"testVoid exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testVoid, exceptions) + )}, + {"testString params", + ?_assertEqual( + {struct, [{1, string}]}, + thrift_test_thrift:function_info(testString, params_type) + )}, + {"testString reply", + ?_assertEqual( + string, + thrift_test_thrift:function_info(testString, reply_type) + )}, + {"testString exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testString, exceptions) + )}, + {"testByte params", + ?_assertEqual( + {struct, [{1, byte}]}, + thrift_test_thrift:function_info(testByte, params_type) + )}, + {"testByte reply", + ?_assertEqual( + byte, + thrift_test_thrift:function_info(testByte, reply_type) + )}, + {"testByte exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testByte, exceptions) + )}, + {"testI32 params", + ?_assertEqual( + {struct, [{1, i32}]}, + thrift_test_thrift:function_info(testI32, params_type) + )}, + {"testI32 reply", + ?_assertEqual( + i32, + thrift_test_thrift:function_info(testI32, reply_type) + )}, + {"testI32 exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testI32, exceptions) + )}, + {"testI64 params", + ?_assertEqual( + {struct, [{1, i64}]}, + thrift_test_thrift:function_info(testI64, params_type) + )}, + {"testI64 reply", + ?_assertEqual( + i64, + thrift_test_thrift:function_info(testI64, reply_type) + )}, + {"testI64 exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testI64, exceptions) + )}, + {"testDouble params", + ?_assertEqual( + {struct, [{1, double}]}, + thrift_test_thrift:function_info(testDouble, params_type) + )}, + {"testDouble reply", + ?_assertEqual( + double, + thrift_test_thrift:function_info(testDouble, reply_type) + )}, + {"testDouble exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testDouble, exceptions) + )}, + {"testStruct params", + ?_assertEqual( + {struct, [ + {1, {struct, {thrift_test_types, 'thrift.test.Xtruct'}}} + ]}, + thrift_test_thrift:function_info(testStruct, params_type) + )}, + {"testStruct reply", + ?_assertEqual( + {struct, {thrift_test_types, 'thrift.test.Xtruct'}}, + thrift_test_thrift:function_info(testStruct, reply_type) + )}, + {"testStruct exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testStruct, exceptions) + )}, + {"testNest params", + ?_assertEqual( + {struct, [ + {1, {struct, {thrift_test_types, 'thrift.test.Xtruct2'}}} + ]}, + thrift_test_thrift:function_info(testNest, params_type) + )}, + {"testNest reply", + ?_assertEqual( + {struct, {thrift_test_types, 'thrift.test.Xtruct2'}}, + thrift_test_thrift:function_info(testNest, reply_type) + )}, + {"testNest exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testNest, exceptions) + )}, + {"testMap params", + ?_assertEqual( + {struct, [ + {1, {map, i32, i32}} + ]}, + thrift_test_thrift:function_info(testMap, params_type) + )}, + {"testMap reply", + ?_assertEqual( + {map, i32, i32}, + thrift_test_thrift:function_info(testMap, reply_type) + )}, + {"testMap exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testMap, exceptions) + )}, + {"testStringMap params", + ?_assertEqual( + {struct, [ + {1, {map, string, string}} + ]}, + thrift_test_thrift:function_info(testStringMap, params_type) + )}, + {"testStringMap reply", + ?_assertEqual( + {map, string, string}, + thrift_test_thrift:function_info(testStringMap, reply_type) + )}, + {"testStringMap exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testStringMap, exceptions) + )}, + {"testSet params", + ?_assertEqual( + {struct, [ + {1, {set, i32}} + ]}, + thrift_test_thrift:function_info(testSet, params_type) + )}, + {"testSet reply", + ?_assertEqual( + {set, i32}, + thrift_test_thrift:function_info(testSet, reply_type) + )}, + {"testSet exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testSet, exceptions) + )}, + {"testList params", + ?_assertEqual( + {struct, [ + {1, {list, i32}} + ]}, + thrift_test_thrift:function_info(testList, params_type) + )}, + {"testList reply", + ?_assertEqual( + {list, i32}, + thrift_test_thrift:function_info(testList, reply_type) + )}, + {"testList exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testList, exceptions) + )}, + {"testEnum params", + ?_assertEqual( + {struct, [ + {1, i32} + ]}, + thrift_test_thrift:function_info(testEnum, params_type) + )}, + {"testEnum reply", + ?_assertEqual( + i32, + thrift_test_thrift:function_info(testEnum, reply_type) + )}, + {"testEnum exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testEnum, exceptions) + )}, + {"testTypedef params", + ?_assertEqual( + {struct, [{1, i64}]}, + thrift_test_thrift:function_info(testTypedef, params_type) + )}, + {"testTypedef reply", + ?_assertEqual( + i64, + thrift_test_thrift:function_info(testTypedef, reply_type) + )}, + {"testTypedef exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testTypedef, exceptions) + )}, + {"testMapMap params", + ?_assertEqual( + {struct, [ + {1, i32} + ]}, + thrift_test_thrift:function_info(testMapMap, params_type) + )}, + {"testMapMap reply", + ?_assertEqual( + {map, i32, {map, i32, i32}}, + thrift_test_thrift:function_info(testMapMap, reply_type) + )}, + {"testMapMap exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testMapMap, exceptions) + )}, + {"testInsanity params", + ?_assertEqual( + {struct, [ + {1, {struct, {thrift_test_types, 'thrift.test.Insanity'}}} + ]}, + thrift_test_thrift:function_info(testInsanity, params_type) + )}, + {"testInsanity reply", + ?_assertEqual( + {map, i64, {map, i32, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}}}, + thrift_test_thrift:function_info(testInsanity, reply_type) + )}, + {"testInsanity exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testInsanity, exceptions) + )}, + {"testMulti params", + ?_assertEqual( + {struct, [ + {1, byte}, + {2, i32}, + {3, i64}, + {4, {map, i16, string}}, + {5, i32}, + {6, i64} + ]}, + thrift_test_thrift:function_info(testMulti, params_type) + )}, + {"testMulti reply", + ?_assertEqual( + {struct, {thrift_test_types, 'thrift.test.Xtruct'}}, + thrift_test_thrift:function_info(testMulti, reply_type) + )}, + {"testMulti exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testMulti, exceptions) + )}, + {"testException params", + ?_assertEqual( + {struct, [{1, string}]}, + thrift_test_thrift:function_info(testException, params_type) + )}, + {"testException reply", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testException, reply_type) + )}, + {"testException exceptions", + ?_assertEqual( + {struct, [ + {1, {struct, {thrift_test_types, 'thrift.test.Xception'}}} + ]}, + thrift_test_thrift:function_info(testException, exceptions) + )}, + {"testMultiException params", + ?_assertEqual( + {struct, [{1, string}, {2, string}]}, + thrift_test_thrift:function_info(testMultiException, params_type) + )}, + {"testMultiException reply", + ?_assertEqual( + {struct, {thrift_test_types, 'thrift.test.Xtruct'}}, + thrift_test_thrift:function_info(testMultiException, reply_type) + )}, + {"testMultiException exceptions", + ?_assertEqual( + {struct, [ + {1, {struct, {thrift_test_types, 'thrift.test.Xception'}}}, + {2, {struct, {thrift_test_types, 'thrift.test.Xception2'}}} + ]}, + thrift_test_thrift:function_info(testMultiException, exceptions) + )}, + {"testOneway params", + ?_assertEqual( + {struct, [{1, i32}]}, + thrift_test_thrift:function_info(testOneway, params_type) + )}, + {"testOneway reply", + ?_assertEqual( + oneway_void, + thrift_test_thrift:function_info(testOneway, reply_type) + )}, + {"testOneway exceptions", + ?_assertEqual( + {struct, []}, + thrift_test_thrift:function_info(testOneway, exceptions) + )}, + {"secondtestString params", + ?_assertEqual( + {struct, [{1, string}]}, + second_service_thrift:function_info(secondtestString, params_type) + )}, + {"secondtestString reply", + ?_assertEqual( + string, + second_service_thrift:function_info(secondtestString, reply_type) + )}, + {"secondtestString exceptions", + ?_assertEqual( + {struct, []}, + second_service_thrift:function_info(secondtestString, exceptions) + )} + ]. From c500eabf4b4d872c9fc43a5bff78b30000ae9719 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 22:30:59 -0400 Subject: [PATCH 098/250] Bump com.github.spotbugs from 5.0.14 to 5.1.0 in /lib/java (#2838) Bumps com.github.spotbugs from 5.0.14 to 5.1.0. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index 41083d02adf..49eae9a7bdb 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -41,7 +41,7 @@ plugins { id 'signing' id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' - id "com.github.spotbugs" version "5.0.14" + id "com.github.spotbugs" version "5.1.0" id "com.diffplug.spotless" version "6.19.0" } From cc4d99d93da50475c21096ade8646d9fd02388c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 22:32:38 -0400 Subject: [PATCH 099/250] Bump com.diffplug.spotless from 6.19.0 to 6.20.0 in /lib/java (#2839) Bumps com.diffplug.spotless from 6.19.0 to 6.20.0. --- updated-dependencies: - dependency-name: com.diffplug.spotless dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index 49eae9a7bdb..81ffbd93079 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -42,7 +42,7 @@ plugins { id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' id "com.github.spotbugs" version "5.1.0" - id "com.diffplug.spotless" version "6.19.0" + id "com.diffplug.spotless" version "6.20.0" } description = 'Apache Thrift Java Library' From 055ceecebf23d910f69e9555a46a8a8c457d1b12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 22:39:55 -0400 Subject: [PATCH 100/250] Bump org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 in /lib/kotlin (#2834) Bumps [org.jetbrains.kotlinx:kotlinx-coroutines-jdk8](https://github.com/Kotlin/kotlinx.coroutines) from 1.7.2 to 1.7.3. - [Release notes](https://github.com/Kotlin/kotlinx.coroutines/releases) - [Changelog](https://github.com/Kotlin/kotlinx.coroutines/blob/master/CHANGES.md) - [Commits](https://github.com/Kotlin/kotlinx.coroutines/compare/1.7.2...1.7.3) --- updated-dependencies: - dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/kotlin/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/build.gradle.kts b/lib/kotlin/build.gradle.kts index fde32de625d..5c9929bd987 100644 --- a/lib/kotlin/build.gradle.kts +++ b/lib/kotlin/build.gradle.kts @@ -29,7 +29,7 @@ repositories { dependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom")) implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.3") implementation("org.apache.thrift:libthrift:INCLUDED") testImplementation(kotlin("test")) } From dc733faff4c1b1783042afdb782e974f17d01253 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Fri, 23 Jun 2023 09:29:25 -0700 Subject: [PATCH 101/250] Update supported go versions to 1.20 and 1.21 --- .github/workflows/build.yml | 4 ++-- LANGUAGES.md | 2 +- go.mod | 2 +- lib/go/test/fuzz/go.mod | 2 +- lib/go/test/go.mod | 2 +- test/go/go.mod | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b660bb6fa8..d9696adef6c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,8 +83,8 @@ jobs: strategy: matrix: go: - - '1.19' - '1.20' + - '1.21' fail-fast: false steps: - uses: actions/checkout@v3 @@ -128,7 +128,7 @@ jobs: run: make -C test/go precross - name: Upload go precross artifacts - if: matrix.go == '1.20' + if: matrix.go == '1.21' uses: actions/upload-artifact@v3 with: name: go-precross diff --git a/LANGUAGES.md b/LANGUAGES.md index 2f1f4f1784f..6cb6018807a 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -163,7 +163,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr Go 0.7.0 Yes -1.19.51.20 +1.201.21 YesYesYes YesYesYesYes diff --git a/go.mod b/go.mod index 5f2a2c829fd..7be425635ec 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/apache/thrift -go 1.19 +go 1.20 diff --git a/lib/go/test/fuzz/go.mod b/lib/go/test/fuzz/go.mod index 66418812ff5..41cccc3e2fe 100644 --- a/lib/go/test/fuzz/go.mod +++ b/lib/go/test/fuzz/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/lib/go/test/fuzz -go 1.19 +go 1.20 replace github.com/apache/thrift => ../../../../ diff --git a/lib/go/test/go.mod b/lib/go/test/go.mod index 1c6d80ddbc6..59535e6446d 100644 --- a/lib/go/test/go.mod +++ b/lib/go/test/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/lib/go/test -go 1.19 +go 1.20 require ( github.com/apache/thrift v0.0.0-00010101000000-000000000000 diff --git a/test/go/go.mod b/test/go/go.mod index ff88c9b3f50..723069b7875 100644 --- a/test/go/go.mod +++ b/test/go/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/test/go -go 1.19 +go 1.20 require ( github.com/apache/thrift v0.0.0-00010101000000-000000000000 From 166a2136ca62b21b813f55c84fc7f0afc32dad9c Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 10 Aug 2023 06:33:43 +0800 Subject: [PATCH 102/250] fix kotlin cross test by downgrading to java 8 (#2840) --- lib/kotlin/cross-test-client/build.gradle.kts | 2 +- lib/kotlin/cross-test-server/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kotlin/cross-test-client/build.gradle.kts b/lib/kotlin/cross-test-client/build.gradle.kts index b370a403c71..8a2c234b823 100644 --- a/lib/kotlin/cross-test-client/build.gradle.kts +++ b/lib/kotlin/cross-test-client/build.gradle.kts @@ -52,7 +52,7 @@ dependencies { kotlin { jvmToolchain { - (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11)) + (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8)) } } diff --git a/lib/kotlin/cross-test-server/build.gradle.kts b/lib/kotlin/cross-test-server/build.gradle.kts index 4f6e12de966..eda1ebd0c39 100644 --- a/lib/kotlin/cross-test-server/build.gradle.kts +++ b/lib/kotlin/cross-test-server/build.gradle.kts @@ -50,7 +50,7 @@ dependencies { kotlin { jvmToolchain { - (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11)) + (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8)) } } From 0e872c84aaa49fe9ce72123827f666c0064f0c97 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 9 Aug 2023 15:06:37 -0700 Subject: [PATCH 103/250] THRIFT-5731: Handle ErrAbandonRequest automatically Also add a test to verify the behavior. The test helped me to found a bug in TSimpleServer that didn't handle the ErrAbandonRequest case correctly, so fix the bug as well. client: go --- .../cpp/src/thrift/generate/t_go_generator.cc | 19 ++-- lib/go/README.md | 12 ++- .../tests/server_connectivity_check_test.go | 88 +++++++++++++++++++ lib/go/thrift/simple_server.go | 9 +- 4 files changed, 119 insertions(+), 9 deletions(-) create mode 100644 lib/go/test/tests/server_connectivity_check_test.go diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index 90353ce9b5c..54422c82670 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -2797,13 +2797,13 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* f_types_ << indent() << "if thrift.ServerConnectivityCheckInterval > 0 {" << endl; indent_up(); - f_types_ << indent() << "var cancel context.CancelFunc" << endl; - f_types_ << indent() << "ctx, cancel = context.WithCancel(ctx)" << endl; - f_types_ << indent() << "defer cancel()" << endl; + f_types_ << indent() << "var cancel context.CancelCauseFunc" << endl; + f_types_ << indent() << "ctx, cancel = context.WithCancelCause(ctx)" << endl; + f_types_ << indent() << "defer cancel(nil)" << endl; f_types_ << indent() << "var tickerCtx context.Context" << endl; f_types_ << indent() << "tickerCtx, tickerCancel = context.WithCancel(context.Background())" << endl; f_types_ << indent() << "defer tickerCancel()" << endl; - f_types_ << indent() << "go func(ctx context.Context, cancel context.CancelFunc) {" << endl; + f_types_ << indent() << "go func(ctx context.Context, cancel context.CancelCauseFunc) {" << endl; indent_up(); f_types_ << indent() << "ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval)" << endl; @@ -2821,7 +2821,7 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* indent_up(); f_types_ << indent() << "if !iprot.Transport().IsOpen() {" << endl; indent_up(); - f_types_ << indent() << "cancel()" << endl; + f_types_ << indent() << "cancel(thrift.ErrAbandonRequest)" << endl; f_types_ << indent() << "return" << endl; indent_down(); f_types_ << indent() << "}" << endl; @@ -2901,6 +2901,15 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* f_types_ << indent() << "return false, thrift.WrapTException(err2)" << endl; indent_down(); f_types_ << indent() << "}" << endl; + f_types_ << indent() << "if errors.Is(err2, context.Canceled) {" << endl; + indent_up(); + f_types_ << indent() << "if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) {" << endl; + indent_up(); + f_types_ << indent() << "return false, thrift.WrapTException(err)" << endl; + indent_down(); + f_types_ << indent() << "}" << endl; + indent_down(); + f_types_ << indent() << "}" << endl; string exc(tmp("_exc")); f_types_ << indent() << exc << " := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, " diff --git a/lib/go/README.md b/lib/go/README.md index b2cf1df12c2..0aa4f1bc6f2 100644 --- a/lib/go/README.md +++ b/lib/go/README.md @@ -108,13 +108,19 @@ The context object passed into the server handler function will be canceled when the client closes the connection (this is a best effort check, not a guarantee -- there's no guarantee that the context object is always canceled when client closes the connection, but when it's canceled you can always assume the client -closed the connection). When implementing Go Thrift server, you can take -advantage of that to abandon requests that's no longer needed: +closed the connection). The cause of the cancellation (via `context.Cause(ctx)`) +would also be set to `thrift.ErrAbandonRequest`. + +When implementing Go Thrift server, you can take advantage of that to abandon +requests that's no longer needed by returning `thrift.ErrAbandonRequest`: func MyEndpoint(ctx context.Context, req *thriftRequestType) (*thriftResponseType, error) { ... if ctx.Err() == context.Canceled { return nil, thrift.ErrAbandonRequest + // Or just return ctx.Err(), compiler generated processor code will + // handle it for you automatically: + // return nil, ctx.Err() } ... } @@ -155,4 +161,4 @@ will wait for all the client connections to be closed gracefully with zero err time. Otherwise, the stop will wait for all the client connections to be closed gracefully util thrift.ServerStopTimeout is reached, and client connections that are not closed after thrift.ServerStopTimeout -will be closed abruptly which may cause some client errors. \ No newline at end of file +will be closed abruptly which may cause some client errors. diff --git a/lib/go/test/tests/server_connectivity_check_test.go b/lib/go/test/tests/server_connectivity_check_test.go new file mode 100644 index 00000000000..51710eda291 --- /dev/null +++ b/lib/go/test/tests/server_connectivity_check_test.go @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package tests + +import ( + "context" + "runtime/debug" + "testing" + "time" + + "github.com/apache/thrift/lib/go/test/gopath/src/clientmiddlewareexceptiontest" + "github.com/apache/thrift/lib/go/thrift" +) + +func TestServerConnectivityCheck(t *testing.T) { + const ( + // Server will sleep for longer than client is willing to wait + // so client will close the connection. + serverSleep = 50 * time.Millisecond + clientSocketTimeout = time.Millisecond + ) + serverSocket, err := thrift.NewTServerSocket(":0") + if err != nil { + t.Fatalf("failed to create server socket: %v", err) + } + processor := clientmiddlewareexceptiontest.NewClientMiddlewareExceptionTestProcessor(fakeClientMiddlewareExceptionTestHandler( + func(ctx context.Context) (*clientmiddlewareexceptiontest.FooResponse, error) { + time.Sleep(serverSleep) + err := ctx.Err() + if err == nil { + t.Error("Expected server ctx to be cancelled, did not happen") + return new(clientmiddlewareexceptiontest.FooResponse), nil + } + return nil, err + }, + )) + server := thrift.NewTSimpleServer2(processor, serverSocket) + if err := server.Listen(); err != nil { + t.Fatalf("failed to listen server: %v", err) + } + server.SetLogger(func(msg string) { + t.Errorf("Server logger called with %q", msg) + t.Errorf("Server logger callstack:\n%s", debug.Stack()) + }) + addr := serverSocket.Addr().String() + go server.Serve() + t.Cleanup(func() { + server.Stop() + }) + + cfg := &thrift.TConfiguration{ + SocketTimeout: clientSocketTimeout, + } + socket := thrift.NewTSocketConf(addr, cfg) + if err := socket.Open(); err != nil { + t.Fatalf("failed to create client connection: %v", err) + } + t.Cleanup(func() { + socket.Close() + }) + inProtocol := thrift.NewTBinaryProtocolConf(socket, cfg) + outProtocol := thrift.NewTBinaryProtocolConf(socket, cfg) + client := thrift.NewTStandardClient(inProtocol, outProtocol) + ctx, cancel := context.WithTimeout(context.Background(), clientSocketTimeout) + defer cancel() + _, err = clientmiddlewareexceptiontest.NewClientMiddlewareExceptionTestClient(client).Foo(ctx) + socket.Close() + if err == nil { + t.Error("Expected client to time out, did not happen") + } +} diff --git a/lib/go/thrift/simple_server.go b/lib/go/thrift/simple_server.go index c5c14feed5f..d4f555ccd51 100644 --- a/lib/go/thrift/simple_server.go +++ b/lib/go/thrift/simple_server.go @@ -24,6 +24,7 @@ import ( "errors" "fmt" "io" + "net" "sync" "sync/atomic" "time" @@ -354,7 +355,13 @@ func (p *TSimpleServer) processRequests(client TTransport) (err error) { ok, err := processor.Process(ctx, inputProtocol, outputProtocol) if errors.Is(err, ErrAbandonRequest) { - return client.Close() + err := client.Close() + if errors.Is(err, net.ErrClosed) { + // In this case, it's kinda expected to get + // net.ErrClosed, treat that as no-error + return nil + } + return err } if errors.As(err, new(TTransportException)) && err != nil { return err From 4e4461a946df3a426e54023cc238417f2b14a070 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 10 Aug 2023 08:54:54 -0700 Subject: [PATCH 104/250] THRIFT-5653: Fix Java UUID typeid It should be 16 not 17 according to the spec. Currently ENUM holds 16, it's not in TBinaryProtocol spec and seems to be a Java implementation detail somehow got mixed inside TType, move that to -1 for now. Someone more familiar with Java can probably remove it from TType completely in the future. client: java --- .../src/main/java/org/apache/thrift/protocol/TType.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/java/src/main/java/org/apache/thrift/protocol/TType.java b/lib/java/src/main/java/org/apache/thrift/protocol/TType.java index 5a64e4278f3..fbcdac33e29 100644 --- a/lib/java/src/main/java/org/apache/thrift/protocol/TType.java +++ b/lib/java/src/main/java/org/apache/thrift/protocol/TType.java @@ -34,6 +34,8 @@ public final class TType { public static final byte MAP = 13; public static final byte SET = 14; public static final byte LIST = 15; - public static final byte ENUM = 16; - public static final byte UUID = 17; + public static final byte UUID = 16; + + /** This is not part of the TBinaryProtocol spec but Java specific implementation detail */ + public static final byte ENUM = -1; } From fd60a9a3a167154fdb1b9f10685197a6f469a52f Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Wed, 5 Jul 2023 08:18:26 +0000 Subject: [PATCH 105/250] reformat kotlin files --- .../org/apache/thrift/test/TestClient.kt | 18 ++++++++++++------ .../org/apache/thrift/test/TestServer.kt | 17 ++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt b/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt index 39500dfbb07..c238d0b426e 100644 --- a/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt +++ b/lib/kotlin/cross-test-client/src/main/kotlin/org/apache/thrift/test/TestClient.kt @@ -101,9 +101,12 @@ class TestClient : CliktCommand() { private fun createProtocol(transport: TTransport): TProtocol = when (protocolType) { - ProtocolType.Binary, ProtocolType.Multi -> TBinaryProtocol(transport) - ProtocolType.Compact, ProtocolType.MultiCompact -> TCompactProtocol(transport) - ProtocolType.Json, ProtocolType.MultiJson -> TJSONProtocol(transport) + ProtocolType.Binary, + ProtocolType.Multi -> TBinaryProtocol(transport) + ProtocolType.Compact, + ProtocolType.MultiCompact -> TCompactProtocol(transport) + ProtocolType.Json, + ProtocolType.MultiJson -> TJSONProtocol(transport) } private fun createTransport(): TNonblockingTransport = @@ -283,7 +286,8 @@ class TestClient : CliktCommand() { if (whoa.size == 2 && whoa.containsKey(1L) && whoa.containsKey(2L)) { val firstMap = whoa[1L]!! val secondMap = whoa[2L]!! - if (firstMap.size == 2 && + if ( + firstMap.size == 2 && firstMap.containsKey(Numberz.TWO) && firstMap.containsKey(Numberz.THREE) && secondMap.size == 1 && @@ -361,7 +365,8 @@ class TestClient : CliktCommand() { private suspend fun multiplexTest(returnCode: Int): Int { var code = returnCode - if (protocolType == ProtocolType.Multi || + if ( + protocolType == ProtocolType.Multi || protocolType == ProtocolType.MultiJson || protocolType == ProtocolType.MultiCompact ) { @@ -574,7 +579,8 @@ private suspend fun ThriftTestClient.nestedMapTest(returnCode: Int): Int { } else { val m1 = mm[4]!! val m2 = mm[-4]!! - if (m1[1] != 1 || + if ( + m1[1] != 1 || m1[2] != 2 || m1[3] != 3 || m1[4] != 4 || diff --git a/lib/kotlin/cross-test-server/src/main/kotlin/org/apache/thrift/test/TestServer.kt b/lib/kotlin/cross-test-server/src/main/kotlin/org/apache/thrift/test/TestServer.kt index 566e53dac19..315d12e722d 100644 --- a/lib/kotlin/cross-test-server/src/main/kotlin/org/apache/thrift/test/TestServer.kt +++ b/lib/kotlin/cross-test-server/src/main/kotlin/org/apache/thrift/test/TestServer.kt @@ -226,11 +226,12 @@ class TestServerCommand : CliktCommand() { private fun getProtocolFactory(): TProtocolFactory = when (protocolType) { - ProtocolType.Json, ProtocolType.MultiJson -> TJSONProtocol.Factory() - ProtocolType.Compact, ProtocolType.MultiCompact -> - TCompactProtocol.Factory(stringLimit, containerLimit) - ProtocolType.Binary, ProtocolType.Multi -> - TBinaryProtocol.Factory(stringLimit, containerLimit) + ProtocolType.Json, + ProtocolType.MultiJson -> TJSONProtocol.Factory() + ProtocolType.Compact, + ProtocolType.MultiCompact -> TCompactProtocol.Factory(stringLimit, containerLimit) + ProtocolType.Binary, + ProtocolType.Multi -> TBinaryProtocol.Factory(stringLimit, containerLimit) } } @@ -258,7 +259,8 @@ private fun getServerEngine( multiplexedProcessor.registerProcessor("ThriftTest", testProcessor) multiplexedProcessor.registerProcessor("SecondService", secondProcessor) when (serverType) { - ServerType.NonBlocking, ServerType.ThreadedSelector -> { + ServerType.NonBlocking, + ServerType.ThreadedSelector -> { val tNonblockingServerSocket = TNonblockingServerSocket(NonblockingAbstractServerSocketArgs().port(port)) when (serverType) { @@ -283,7 +285,8 @@ private fun getServerEngine( } } } - ServerType.Simple, ServerType.ThreadPool -> { + ServerType.Simple, + ServerType.ThreadPool -> { // SSL socket val tServerSocket: TServerSocket = if (ssl) { From 628023c273d203fc5a38c47f4eaeeb3c9295ef70 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Wed, 5 Jul 2023 08:32:55 +0000 Subject: [PATCH 106/250] fix gradle format --- lib/kotlin/build.gradle.kts | 4 ++-- lib/kotlin/cross-test-client/build.gradle.kts | 2 +- lib/kotlin/settings.gradle.kts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/kotlin/build.gradle.kts b/lib/kotlin/build.gradle.kts index cd52e7fce8b..754df89fc6f 100644 --- a/lib/kotlin/build.gradle.kts +++ b/lib/kotlin/build.gradle.kts @@ -40,7 +40,7 @@ kotlin { } } -tasks.withType { +tasks.withType { kotlinOptions.jvmTarget = "1.8" } @@ -57,7 +57,7 @@ tasks { task("compileThrift") { val thriftBin = if (hasProperty("thrift.compiler")) { - file(property("thrift.compiler")) + file(property("thrift.compiler")!!) } else { project.rootDir.resolve("../../compiler/cpp/thrift") } diff --git a/lib/kotlin/cross-test-client/build.gradle.kts b/lib/kotlin/cross-test-client/build.gradle.kts index 579d01e4c87..b370a403c71 100644 --- a/lib/kotlin/cross-test-client/build.gradle.kts +++ b/lib/kotlin/cross-test-client/build.gradle.kts @@ -70,7 +70,7 @@ tasks { task("compileThrift") { val thriftBin = if (hasProperty("thrift.compiler")) { - file(property("thrift.compiler")) + file(property("thrift.compiler")!!) } else { project.rootDir.resolve("../../compiler/cpp/thrift") } diff --git a/lib/kotlin/settings.gradle.kts b/lib/kotlin/settings.gradle.kts index 342fc3b1d5b..86fa02adac1 100644 --- a/lib/kotlin/settings.gradle.kts +++ b/lib/kotlin/settings.gradle.kts @@ -18,7 +18,7 @@ */ pluginManagement { plugins { - kotlin("jvm") version "1.8.21" + kotlin("jvm") version "1.8.22" id("com.ncorti.ktfmt.gradle") version "0.12.0" } } From 79c56026fc012ba7e3ecb3eefb120dd19047bd5b Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Fri, 23 Jun 2023 09:29:25 -0700 Subject: [PATCH 107/250] Update supported go versions to 1.20 and 1.21 --- .github/workflows/build.yml | 4 ++-- LANGUAGES.md | 2 +- go.mod | 2 +- lib/go/test/fuzz/go.mod | 2 +- lib/go/test/go.mod | 2 +- test/go/go.mod | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b660bb6fa8..d9696adef6c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,8 +83,8 @@ jobs: strategy: matrix: go: - - '1.19' - '1.20' + - '1.21' fail-fast: false steps: - uses: actions/checkout@v3 @@ -128,7 +128,7 @@ jobs: run: make -C test/go precross - name: Upload go precross artifacts - if: matrix.go == '1.20' + if: matrix.go == '1.21' uses: actions/upload-artifact@v3 with: name: go-precross diff --git a/LANGUAGES.md b/LANGUAGES.md index 2f1f4f1784f..6cb6018807a 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -163,7 +163,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr Go 0.7.0 Yes -1.19.51.20 +1.201.21 YesYesYes YesYesYesYes diff --git a/go.mod b/go.mod index 5f2a2c829fd..7be425635ec 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/apache/thrift -go 1.19 +go 1.20 diff --git a/lib/go/test/fuzz/go.mod b/lib/go/test/fuzz/go.mod index 66418812ff5..41cccc3e2fe 100644 --- a/lib/go/test/fuzz/go.mod +++ b/lib/go/test/fuzz/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/lib/go/test/fuzz -go 1.19 +go 1.20 replace github.com/apache/thrift => ../../../../ diff --git a/lib/go/test/go.mod b/lib/go/test/go.mod index 1c6d80ddbc6..59535e6446d 100644 --- a/lib/go/test/go.mod +++ b/lib/go/test/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/lib/go/test -go 1.19 +go 1.20 require ( github.com/apache/thrift v0.0.0-00010101000000-000000000000 diff --git a/test/go/go.mod b/test/go/go.mod index ff88c9b3f50..723069b7875 100644 --- a/test/go/go.mod +++ b/test/go/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/test/go -go 1.19 +go 1.20 require ( github.com/apache/thrift v0.0.0-00010101000000-000000000000 From 4ca47e0362c943e5fd389c61c793986ac99d4e05 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 10 Aug 2023 06:33:43 +0800 Subject: [PATCH 108/250] fix kotlin cross test by downgrading to java 8 (#2840) --- lib/kotlin/cross-test-client/build.gradle.kts | 2 +- lib/kotlin/cross-test-server/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kotlin/cross-test-client/build.gradle.kts b/lib/kotlin/cross-test-client/build.gradle.kts index b370a403c71..8a2c234b823 100644 --- a/lib/kotlin/cross-test-client/build.gradle.kts +++ b/lib/kotlin/cross-test-client/build.gradle.kts @@ -52,7 +52,7 @@ dependencies { kotlin { jvmToolchain { - (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11)) + (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8)) } } diff --git a/lib/kotlin/cross-test-server/build.gradle.kts b/lib/kotlin/cross-test-server/build.gradle.kts index 4f6e12de966..eda1ebd0c39 100644 --- a/lib/kotlin/cross-test-server/build.gradle.kts +++ b/lib/kotlin/cross-test-server/build.gradle.kts @@ -50,7 +50,7 @@ dependencies { kotlin { jvmToolchain { - (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11)) + (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8)) } } From ee1a7ea35b72ab95445106410343088cf66ac173 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 9 Aug 2023 15:06:37 -0700 Subject: [PATCH 109/250] THRIFT-5731: Handle ErrAbandonRequest automatically Also add a test to verify the behavior. The test helped me to found a bug in TSimpleServer that didn't handle the ErrAbandonRequest case correctly, so fix the bug as well. client: go --- .../cpp/src/thrift/generate/t_go_generator.cc | 19 ++-- lib/go/README.md | 12 ++- .../tests/server_connectivity_check_test.go | 88 +++++++++++++++++++ lib/go/thrift/simple_server.go | 9 +- 4 files changed, 119 insertions(+), 9 deletions(-) create mode 100644 lib/go/test/tests/server_connectivity_check_test.go diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index 90353ce9b5c..54422c82670 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -2797,13 +2797,13 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* f_types_ << indent() << "if thrift.ServerConnectivityCheckInterval > 0 {" << endl; indent_up(); - f_types_ << indent() << "var cancel context.CancelFunc" << endl; - f_types_ << indent() << "ctx, cancel = context.WithCancel(ctx)" << endl; - f_types_ << indent() << "defer cancel()" << endl; + f_types_ << indent() << "var cancel context.CancelCauseFunc" << endl; + f_types_ << indent() << "ctx, cancel = context.WithCancelCause(ctx)" << endl; + f_types_ << indent() << "defer cancel(nil)" << endl; f_types_ << indent() << "var tickerCtx context.Context" << endl; f_types_ << indent() << "tickerCtx, tickerCancel = context.WithCancel(context.Background())" << endl; f_types_ << indent() << "defer tickerCancel()" << endl; - f_types_ << indent() << "go func(ctx context.Context, cancel context.CancelFunc) {" << endl; + f_types_ << indent() << "go func(ctx context.Context, cancel context.CancelCauseFunc) {" << endl; indent_up(); f_types_ << indent() << "ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval)" << endl; @@ -2821,7 +2821,7 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* indent_up(); f_types_ << indent() << "if !iprot.Transport().IsOpen() {" << endl; indent_up(); - f_types_ << indent() << "cancel()" << endl; + f_types_ << indent() << "cancel(thrift.ErrAbandonRequest)" << endl; f_types_ << indent() << "return" << endl; indent_down(); f_types_ << indent() << "}" << endl; @@ -2901,6 +2901,15 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* f_types_ << indent() << "return false, thrift.WrapTException(err2)" << endl; indent_down(); f_types_ << indent() << "}" << endl; + f_types_ << indent() << "if errors.Is(err2, context.Canceled) {" << endl; + indent_up(); + f_types_ << indent() << "if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) {" << endl; + indent_up(); + f_types_ << indent() << "return false, thrift.WrapTException(err)" << endl; + indent_down(); + f_types_ << indent() << "}" << endl; + indent_down(); + f_types_ << indent() << "}" << endl; string exc(tmp("_exc")); f_types_ << indent() << exc << " := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, " diff --git a/lib/go/README.md b/lib/go/README.md index b2cf1df12c2..0aa4f1bc6f2 100644 --- a/lib/go/README.md +++ b/lib/go/README.md @@ -108,13 +108,19 @@ The context object passed into the server handler function will be canceled when the client closes the connection (this is a best effort check, not a guarantee -- there's no guarantee that the context object is always canceled when client closes the connection, but when it's canceled you can always assume the client -closed the connection). When implementing Go Thrift server, you can take -advantage of that to abandon requests that's no longer needed: +closed the connection). The cause of the cancellation (via `context.Cause(ctx)`) +would also be set to `thrift.ErrAbandonRequest`. + +When implementing Go Thrift server, you can take advantage of that to abandon +requests that's no longer needed by returning `thrift.ErrAbandonRequest`: func MyEndpoint(ctx context.Context, req *thriftRequestType) (*thriftResponseType, error) { ... if ctx.Err() == context.Canceled { return nil, thrift.ErrAbandonRequest + // Or just return ctx.Err(), compiler generated processor code will + // handle it for you automatically: + // return nil, ctx.Err() } ... } @@ -155,4 +161,4 @@ will wait for all the client connections to be closed gracefully with zero err time. Otherwise, the stop will wait for all the client connections to be closed gracefully util thrift.ServerStopTimeout is reached, and client connections that are not closed after thrift.ServerStopTimeout -will be closed abruptly which may cause some client errors. \ No newline at end of file +will be closed abruptly which may cause some client errors. diff --git a/lib/go/test/tests/server_connectivity_check_test.go b/lib/go/test/tests/server_connectivity_check_test.go new file mode 100644 index 00000000000..51710eda291 --- /dev/null +++ b/lib/go/test/tests/server_connectivity_check_test.go @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package tests + +import ( + "context" + "runtime/debug" + "testing" + "time" + + "github.com/apache/thrift/lib/go/test/gopath/src/clientmiddlewareexceptiontest" + "github.com/apache/thrift/lib/go/thrift" +) + +func TestServerConnectivityCheck(t *testing.T) { + const ( + // Server will sleep for longer than client is willing to wait + // so client will close the connection. + serverSleep = 50 * time.Millisecond + clientSocketTimeout = time.Millisecond + ) + serverSocket, err := thrift.NewTServerSocket(":0") + if err != nil { + t.Fatalf("failed to create server socket: %v", err) + } + processor := clientmiddlewareexceptiontest.NewClientMiddlewareExceptionTestProcessor(fakeClientMiddlewareExceptionTestHandler( + func(ctx context.Context) (*clientmiddlewareexceptiontest.FooResponse, error) { + time.Sleep(serverSleep) + err := ctx.Err() + if err == nil { + t.Error("Expected server ctx to be cancelled, did not happen") + return new(clientmiddlewareexceptiontest.FooResponse), nil + } + return nil, err + }, + )) + server := thrift.NewTSimpleServer2(processor, serverSocket) + if err := server.Listen(); err != nil { + t.Fatalf("failed to listen server: %v", err) + } + server.SetLogger(func(msg string) { + t.Errorf("Server logger called with %q", msg) + t.Errorf("Server logger callstack:\n%s", debug.Stack()) + }) + addr := serverSocket.Addr().String() + go server.Serve() + t.Cleanup(func() { + server.Stop() + }) + + cfg := &thrift.TConfiguration{ + SocketTimeout: clientSocketTimeout, + } + socket := thrift.NewTSocketConf(addr, cfg) + if err := socket.Open(); err != nil { + t.Fatalf("failed to create client connection: %v", err) + } + t.Cleanup(func() { + socket.Close() + }) + inProtocol := thrift.NewTBinaryProtocolConf(socket, cfg) + outProtocol := thrift.NewTBinaryProtocolConf(socket, cfg) + client := thrift.NewTStandardClient(inProtocol, outProtocol) + ctx, cancel := context.WithTimeout(context.Background(), clientSocketTimeout) + defer cancel() + _, err = clientmiddlewareexceptiontest.NewClientMiddlewareExceptionTestClient(client).Foo(ctx) + socket.Close() + if err == nil { + t.Error("Expected client to time out, did not happen") + } +} diff --git a/lib/go/thrift/simple_server.go b/lib/go/thrift/simple_server.go index c5c14feed5f..d4f555ccd51 100644 --- a/lib/go/thrift/simple_server.go +++ b/lib/go/thrift/simple_server.go @@ -24,6 +24,7 @@ import ( "errors" "fmt" "io" + "net" "sync" "sync/atomic" "time" @@ -354,7 +355,13 @@ func (p *TSimpleServer) processRequests(client TTransport) (err error) { ok, err := processor.Process(ctx, inputProtocol, outputProtocol) if errors.Is(err, ErrAbandonRequest) { - return client.Close() + err := client.Close() + if errors.Is(err, net.ErrClosed) { + // In this case, it's kinda expected to get + // net.ErrClosed, treat that as no-error + return nil + } + return err } if errors.As(err, new(TTransportException)) && err != nil { return err From 291b560c36f7f1a15ab87b19ceef23b0d92e11c6 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 10 Aug 2023 08:54:54 -0700 Subject: [PATCH 110/250] THRIFT-5653: Fix Java UUID typeid It should be 16 not 17 according to the spec. Currently ENUM holds 16, it's not in TBinaryProtocol spec and seems to be a Java implementation detail somehow got mixed inside TType, move that to -1 for now. Someone more familiar with Java can probably remove it from TType completely in the future. client: java --- .../src/main/java/org/apache/thrift/protocol/TType.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/java/src/main/java/org/apache/thrift/protocol/TType.java b/lib/java/src/main/java/org/apache/thrift/protocol/TType.java index 5a64e4278f3..fbcdac33e29 100644 --- a/lib/java/src/main/java/org/apache/thrift/protocol/TType.java +++ b/lib/java/src/main/java/org/apache/thrift/protocol/TType.java @@ -34,6 +34,8 @@ public final class TType { public static final byte MAP = 13; public static final byte SET = 14; public static final byte LIST = 15; - public static final byte ENUM = 16; - public static final byte UUID = 17; + public static final byte UUID = 16; + + /** This is not part of the TBinaryProtocol spec but Java specific implementation detail */ + public static final byte ENUM = -1; } From 5656208a202ca0be4d4dc44125b5ca0485f91bf0 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sun, 27 Aug 2023 15:45:30 +0200 Subject: [PATCH 111/250] release 0.19.0 --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 7b220e0374c..a8de33648ed 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -25,6 +25,10 @@ - [THRIFT-5686](https://issues.apache.org/jira/browse/THRIFT-5686) - Add comparer and capacity arguments to container classes +## Go +- [THRIFT-5731](https://issues.apache.org/jira/browse/THRIFT-5731) - Handle ErrAbandonRequest automatically + + ## Haxe - [THRIFT-5717](https://issues.apache.org/jira/browse/THRIFT-5717) - uuid sets and map keys may throw on some Haxe targets @@ -39,6 +43,8 @@ - [THRIFT-5711](https://issues.apache.org/jira/browse/THRIFT-5711) - FutureClient does not extend when service extends from another service - [THRIFT-5702](https://issues.apache.org/jira/browse/THRIFT-5702) - Support Java 8 - [THRIFT-5696](https://issues.apache.org/jira/browse/THRIFT-5696) - TByteBuffer.java does not allow non-default TConfiguration +- [THRIFT-5653](https://issues.apache.org/jira/browse/THRIFT-5653) - Fix Java UUID typeid + ## JavaScript From c340e0bad1ea5e20fe96b3d0825e5b8855ea3f30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 02:41:47 -0400 Subject: [PATCH 112/250] Bump com.github.spotbugs from 5.1.0 to 5.1.3 in /lib/java (#2848) Bumps com.github.spotbugs from 5.1.0 to 5.1.3. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index 81ffbd93079..09465d99c45 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -41,7 +41,7 @@ plugins { id 'signing' id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' - id "com.github.spotbugs" version "5.1.0" + id "com.github.spotbugs" version "5.1.3" id "com.diffplug.spotless" version "6.20.0" } From 09820df910fbec6b8d6a668ac9a92736f6be2d05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 03:13:27 -0400 Subject: [PATCH 113/250] Bump com.diffplug.spotless from 6.20.0 to 6.21.0 in /lib/java (#2847) Bumps com.diffplug.spotless from 6.20.0 to 6.21.0. --- updated-dependencies: - dependency-name: com.diffplug.spotless dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index 09465d99c45..f5c3d6691b3 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -42,7 +42,7 @@ plugins { id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' id "com.github.spotbugs" version "5.1.3" - id "com.diffplug.spotless" version "6.20.0" + id "com.diffplug.spotless" version "6.21.0" } description = 'Apache Thrift Java Library' From 346aa81899dec2c2a63a7b7ace97341a5ef783dc Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 2 Sep 2023 22:24:07 +0200 Subject: [PATCH 114/250] THRIFT-5733 Building code with circular includes crashes Thrift compiler Patch: Jens Geyer This closes #2851 --- compiler/cpp/src/thrift/main.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/compiler/cpp/src/thrift/main.cc b/compiler/cpp/src/thrift/main.cc index 485ec0022cb..5177076adf7 100644 --- a/compiler/cpp/src/thrift/main.cc +++ b/compiler/cpp/src/thrift/main.cc @@ -911,9 +911,12 @@ bool skip_utf8_bom(FILE* f) { /** * Parses a program */ -void parse(t_program* program, t_program* parent_program) { +void parse(t_program* program, t_program* parent_program, std::set& known_includes) { // Get scope file path string path = program->get_path(); + if( ! known_includes.insert(path).second) { + failure("Recursion detected, file: \"%s\"", path.c_str()); + } // Set current dir global, which is used in the include_file function g_curdir = directory_name(path); @@ -947,7 +950,7 @@ void parse(t_program* program, t_program* parent_program) { vector& includes = program->get_includes(); vector::iterator iter; for (iter = includes.begin(); iter != includes.end(); ++iter) { - parse(*iter, program); + parse(*iter, program, known_includes); } // reset program doctext status before parsing a new file @@ -980,6 +983,8 @@ void parse(t_program* program, t_program* parent_program) { failure(x.c_str()); } fclose(yyin); + + known_includes.erase(path); } /** @@ -1041,14 +1046,16 @@ void audit(t_program* new_program, g_incl_searchpath.push_back(old_thrift_include_path); } - parse(old_program, nullptr); + std::set old_includes; + parse(old_program, nullptr, old_includes); g_incl_searchpath = temp_incl_searchpath; if (!new_thrift_include_path.empty()) { g_incl_searchpath.push_back(new_thrift_include_path); } - parse(new_program, nullptr); + std::set new_includes; + parse(new_program, nullptr, new_includes); compare_namespace(new_program, old_program); compare_services(new_program->get_services(), old_program->get_services()); @@ -1268,7 +1275,8 @@ int main(int argc, char** argv) { program->set_include_prefix(include_prefix); // Parse it! - parse(program, nullptr); + std::set known_includes; + parse(program, nullptr, known_includes); // The current path is not really relevant when we are doing generation. // Reset the variable to make warning messages clearer. From 50787cc0b090f3efc6a3a503dbdbe21ad9254a40 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 2 Sep 2023 23:56:46 +0200 Subject: [PATCH 115/250] THRIFT-5734 generated code may lack required capitalization at class names CLient: haxe Patch: Jens Geyer --- .../cpp/src/thrift/generate/t_haxe_generator.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc index f51f801a8e1..b236e0bc619 100644 --- a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc @@ -358,7 +358,7 @@ string t_haxe_generator::haxe_thrift_gen_imports(t_struct* tstruct, string& impo string package = make_package_name( program->get_namespace("haxe")); if (!package.empty()) { if (imports.find(package + "." + (*m_iter)->get_type()->get_name()) == string::npos) { - imports.append("import " + package + "." + (*m_iter)->get_type()->get_name() + ";\n"); + imports.append("import " + package + "." + get_cap_name((*m_iter)->get_type()->get_name()) + ";\n"); } } } @@ -383,7 +383,7 @@ string t_haxe_generator::haxe_thrift_gen_imports(t_service* tservice) { string package = make_package_name( program->get_namespace("haxe")); if (!package.empty()) { if (imports.find(package + "." + (*f_iter)->get_returntype()->get_name()) == string::npos) { - imports.append("import " + package + "." + (*f_iter)->get_returntype()->get_name()+ ";\n"); + imports.append("import " + package + "." + get_cap_name((*f_iter)->get_returntype()->get_name())+ ";\n"); } } } @@ -1536,7 +1536,7 @@ void t_haxe_generator::generate_service(t_service* tservice) { t_type* parent = tservice->get_extends(); string parent_namespace = make_package_name( parent->get_program()->get_namespace("haxe")); if (!parent_namespace.empty() && parent_namespace != package_name_) { - f_service_ << "import " << type_name(parent) << "_service;" << endl; + f_service_ << "import " << get_cap_name(type_name(parent)) << "_service;" << endl; } } @@ -1558,7 +1558,7 @@ void t_haxe_generator::generate_service(t_service* tservice) { t_type* parent = tservice->get_extends(); string parent_namespace = make_package_name( parent->get_program()->get_namespace("haxe")); if (!parent_namespace.empty() && parent_namespace != package_name_) { - f_service_ << "import " << type_name(parent) << ";" << endl; + f_service_ << "import " << get_cap_name(type_name(parent)) << ";" << endl; } } @@ -1578,7 +1578,7 @@ void t_haxe_generator::generate_service(t_service* tservice) { t_type* parent = tservice->get_extends(); string parent_namespace = make_package_name( parent->get_program()->get_namespace("haxe")); if (!parent_namespace.empty() && parent_namespace != package_name_) { - f_service_ << "import " << type_name(parent) << "Impl;" << endl; + f_service_ << "import " << get_cap_name(type_name(parent)) << "Impl;" << endl; } } @@ -1752,7 +1752,7 @@ void t_haxe_generator::generate_service_interface(t_service* tservice, bool comb string extends_iface = ""; if (tservice->get_extends() != nullptr) { - extends_iface = " extends " + tservice->get_extends()->get_name() + cbk_postfix; + extends_iface = " extends " + get_cap_name(type_name(tservice->get_extends())) + cbk_postfix; } vector functions = tservice->get_functions(); @@ -1797,7 +1797,7 @@ void t_haxe_generator::generate_service_client(t_service* tservice) { string extends = ""; string extends_client = ""; if (tservice->get_extends() != nullptr) { - extends = get_cap_name(tservice->get_extends()->get_name()); + extends = get_cap_name(type_name(tservice->get_extends())); extends_client = " extends " + extends + "Impl"; } From 0ca6e888fc4acfd4f30c56e1e006ce61b8314efa Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Tue, 12 Sep 2023 15:23:49 +0200 Subject: [PATCH 116/250] Release Management: added the missing EXTRA_DIST validation step --- doc/ReleaseManagement.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/ReleaseManagement.md b/doc/ReleaseManagement.md index e659ad47074..e06c9b4468e 100644 --- a/doc/ReleaseManagement.md +++ b/doc/ReleaseManagement.md @@ -159,6 +159,13 @@ All Apache Thrift releases go through a 72-hour final release candidate voting p The result will be a file named `thrift-1.0.0.tar.gz`. Check the size and make sure it is roughly 4MB. It could get larger over time, but it shouldn't jump by orders of magnitude. Once satisfied you can exit the docker container with `exit`. + 1. Validate the contents of the tarball + + Unpack the tarball in some empty folder and do a fresh git clone of the branch into another. + Now compare both folders and check for any files missing. These need to be added to the appropriate `EXTRA_DIST` + makefile section(s). If necessary, commit the changes and repeat generating the source tarball until no more + differences can be found. + 1. Generate signatures and checksums for the tarball: ```bash From 407630f28089be2580809332e9f15078fce4be7e Mon Sep 17 00:00:00 2001 From: bwangelme Date: Mon, 4 Sep 2023 19:32:36 +0800 Subject: [PATCH 117/250] fix: fix NewTSocketConf comment error Client: ["go"] [skip ci] --- lib/go/thrift/socket.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/go/thrift/socket.go b/lib/go/thrift/socket.go index cba7c0f77a3..2185fb18ca0 100644 --- a/lib/go/thrift/socket.go +++ b/lib/go/thrift/socket.go @@ -55,7 +55,7 @@ func NewTSocket(hostPort string) (*TSocket, error) { // // Example: // -// trans, err := thrift.NewTSocketConf("localhost:9090", &TConfiguration{ +// trans := thrift.NewTSocketConf("localhost:9090", &TConfiguration{ // ConnectTimeout: time.Second, // Use 0 for no timeout // SocketTimeout: time.Second, // Use 0 for no timeout // }) From bc9c04d8049d7d5f5cf4e63a25226c1fb8c930bf Mon Sep 17 00:00:00 2001 From: Jeff Alder <49817386+jeffalder@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:57:20 -0700 Subject: [PATCH 118/250] THRIFT-5738: Remove unused variable --- compiler/cpp/src/thrift/generate/t_java_generator.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc index 172d1373bd3..d7e0b65939c 100644 --- a/compiler/cpp/src/thrift/generate/t_java_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc @@ -5756,7 +5756,6 @@ void t_java_generator::generate_java_struct_tuple_writer(ostream& out, t_struct* } indent(out) << "oprot.writeBitSet(optionals, " << optional_count << ");" << endl; - int j = 0; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_OPTIONAL || (*f_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT) { @@ -5765,7 +5764,6 @@ void t_java_generator::generate_java_struct_tuple_writer(ostream& out, t_struct* generate_serialize_field(out, (*f_iter), "struct.", "", false); indent_down(); indent(out) << "}" << endl; - j++; } } } From 94abea1b2e212936d27207c85bbac73187aff729 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:32:45 -0400 Subject: [PATCH 119/250] Bump com.diffplug.spotless from 6.21.0 to 6.22.0 in /lib/kotlin (#2859) Bumps com.diffplug.spotless from 6.21.0 to 6.22.0. --- updated-dependencies: - dependency-name: com.diffplug.spotless dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index f5c3d6691b3..f0252ce033a 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -42,7 +42,7 @@ plugins { id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' id "com.github.spotbugs" version "5.1.3" - id "com.diffplug.spotless" version "6.21.0" + id "com.diffplug.spotless" version "6.22.0" } description = 'Apache Thrift Java Library' From a14231c6980e4e5fafc4acb61f0cabd7f385e354 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:33:29 -0400 Subject: [PATCH 120/250] Bump actions/checkout from 3 to 4 (#2858) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 14 +++++++------- .github/workflows/cmake.yml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d9696adef6c..958a308dab1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,7 @@ jobs: fail-fast: false runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | @@ -87,7 +87,7 @@ jobs: - '1.21' fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: @@ -143,7 +143,7 @@ jobs: env: GRADLE_VERSION: "8.0.2" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-java@v3 with: @@ -249,7 +249,7 @@ jobs: needs: compiler runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run bootstrap run: ./bootstrap.sh @@ -287,7 +287,7 @@ jobs: env: TOOLCHAIN_VERSION: 1.61.0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | @@ -355,7 +355,7 @@ jobs: - "3.x" fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | @@ -419,7 +419,7 @@ jobs: client_lang: ['java,kotlin', 'go,rs', 'swift'] fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 69b8cbe8d04..71748e8fc4d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -16,7 +16,7 @@ jobs: compiler: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | From 7b8c04273f12e2464903556f322cdb407ba45981 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Thu, 5 Oct 2023 20:05:13 +0000 Subject: [PATCH 121/250] Fix building with gcc 13 This fixes the following compiler error. t_js_generator.cc:48:14: error: 'int64_t' does not name a type 48 | static const int64_t max_safe_integer = 0x1fffffffffffff; | ^~~~~~~ t_js_generator.cc:50:14: error: 'int64_t' does not name a type 50 | static const int64_t min_safe_integer = -max_safe_integer; | ^~~~~~~ --- compiler/cpp/src/thrift/generate/t_js_generator.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc b/compiler/cpp/src/thrift/generate/t_js_generator.cc index f5937d09359..96250c9bac7 100644 --- a/compiler/cpp/src/thrift/generate/t_js_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc @@ -28,6 +28,7 @@ #include #include +#include #include #include #include From 5f87b836a58040459d06288cfe425e6fa96fddd0 Mon Sep 17 00:00:00 2001 From: Mario Emmenlauer Date: Mon, 9 Oct 2023 14:42:27 +0200 Subject: [PATCH 122/250] lib/cpp/test/Security*Test.cpp: Fix the check for OpenSSL version --- lib/cpp/test/SecurityFromBufferTest.cpp | 2 +- lib/cpp/test/SecurityTest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cpp/test/SecurityFromBufferTest.cpp b/lib/cpp/test/SecurityFromBufferTest.cpp index 5fba5ee90d8..65ec8b6a26a 100644 --- a/lib/cpp/test/SecurityFromBufferTest.cpp +++ b/lib/cpp/test/SecurityFromBufferTest.cpp @@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE(ssl_security_matrix) { try { // matrix of connection success between client and server with different SSLProtocol selections static_assert(apache::thrift::transport::LATEST == 5, "Mismatch in assumed number of ssl protocols"); - bool ossl1 = OPENSSL_VERSION_MAJOR == 1; + bool ossl1 = (OPENSSL_VERSION_NUMBER < 0x30000000L); bool matrix[apache::thrift::transport::LATEST + 1][apache::thrift::transport::LATEST + 1] = { // server = SSLTLS SSLv2 SSLv3 TLSv1_0 TLSv1_1 TLSv1_2 diff --git a/lib/cpp/test/SecurityTest.cpp b/lib/cpp/test/SecurityTest.cpp index ab3d99b2b6e..06ee8fe57aa 100644 --- a/lib/cpp/test/SecurityTest.cpp +++ b/lib/cpp/test/SecurityTest.cpp @@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(ssl_security_matrix) { // matrix of connection success between client and server with different SSLProtocol selections static_assert(apache::thrift::transport::LATEST == 5, "Mismatch in assumed number of ssl protocols"); - bool ossl1 = OPENSSL_VERSION_MAJOR == 1; + bool ossl1 = (OPENSSL_VERSION_NUMBER < 0x30000000L); bool matrix[apache::thrift::transport::LATEST + 1][apache::thrift::transport::LATEST + 1] = { // server = SSLTLS SSLv2 SSLv3 TLSv1_0 TLSv1_1 TLSv1_2 From c5a5f79d7a8dbe0be6b800413b01736a440310ec Mon Sep 17 00:00:00 2001 From: Mario Emmenlauer Date: Tue, 10 Oct 2023 12:01:13 +0200 Subject: [PATCH 123/250] build/cmake/DefinePlatformSpecifc.cmake: Separated MSVC and Clang-Cl settings for Windows --- build/cmake/DefinePlatformSpecifc.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/cmake/DefinePlatformSpecifc.cmake b/build/cmake/DefinePlatformSpecifc.cmake index 84409e6ff51..a78d80cac46 100644 --- a/build/cmake/DefinePlatformSpecifc.cmake +++ b/build/cmake/DefinePlatformSpecifc.cmake @@ -25,8 +25,12 @@ set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix") # basic options foreach(lang IN ITEMS C CXX) - if("CMAKE_${lang}_COMPILER_ID" STREQUAL "MSVC" OR "${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "MSVC") + if("CMAKE_${lang}_COMPILER_ID" STREQUAL "MSVC") + # These flags are not supported (or needed) with Clang-Cl on Windows: set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} /MP") # parallel build + endif() + + if("CMAKE_${lang}_COMPILER_ID" STREQUAL "MSVC" OR "${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "MSVC") set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} /W3") # warning level 3 include(CheckCXXCompilerFlag) set(CMAKE_REQUIRED_QUIET ON) From 8aa22a42fac6957df705059ec88ef9b858d9bcc0 Mon Sep 17 00:00:00 2001 From: Ilya Urvachev Date: Wed, 11 Oct 2023 14:30:51 +0300 Subject: [PATCH 124/250] fix(php): exclude most part of the repo for php package --- composer.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/composer.json b/composer.json index d1ada505cd3..454beeaa9fa 100644 --- a/composer.json +++ b/composer.json @@ -35,5 +35,19 @@ "branch-alias": { "dev-master": "1.0.x-dev" } + }, + "archive": { + "exclude": [ + "*", + ".*", + "!/CHANGES.md", + "!/LICENSE", + "!/NOTICE", + "!/README.md", + "!/composer.json", + "!/lib/php/README.apache.md", + "!/lib/php/README.md", + "!/lib/php/lib" + ] } } From 49c6ec702d963c05fa83470e71a486780ef825bc Mon Sep 17 00:00:00 2001 From: Mario Emmenlauer Date: Tue, 10 Oct 2023 10:46:09 +0200 Subject: [PATCH 125/250] TProtocol.h: Be extra careful when including MSVC Windows-related headers to not pollute the c++ namespace --- lib/cpp/src/thrift/protocol/TProtocol.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h index c6ff3604915..237c1e56883 100644 --- a/lib/cpp/src/thrift/protocol/TProtocol.h +++ b/lib/cpp/src/thrift/protocol/TProtocol.h @@ -21,8 +21,26 @@ #define _THRIFT_PROTOCOL_TPROTOCOL_H_ 1 #ifdef _WIN32 +// Including Winsock2.h adds problematic macros like min() and max(). +// Try to work around: +#ifndef NOMINMAX +#define NOMINMAX +#define _THRIFT_UNDEF_NOMINMAX +#endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#define _THRIFT_UNDEF_WIN32_LEAN_AND_MEAN +#endif // Need to come before any Windows.h includes #include +#ifdef _THRIFT_UNDEF_NOMINMAX +#undef NOMINMAX +#undef _THRIFT_UNDEF_NOMINMAX +#endif +#ifdef _THRIFT_UNDEF_WIN32_LEAN_AND_MEAN +#undef WIN32_LEAN_AND_MEAN +#undef _THRIFT_UNDEF_WIN32_LEAN_AND_MEAN +#endif #endif #include @@ -558,14 +576,14 @@ class TProtocol { void setRecurisionLimit(uint32_t depth) {recursion_limit_ = depth;} // Returns the minimum amount of bytes needed to store the smallest possible instance of TType. - virtual int getMinSerializedSize(TType type) { + virtual int getMinSerializedSize(TType type) { THRIFT_UNUSED_VARIABLE(type); return 0; } protected: TProtocol(std::shared_ptr ptrans) - : ptrans_(ptrans), input_recursion_depth_(0), output_recursion_depth_(0), + : ptrans_(ptrans), input_recursion_depth_(0), output_recursion_depth_(0), recursion_limit_(ptrans->getConfiguration()->getRecursionLimit()) {} From d327636dad1933a2a1211b7a91a48a51ee2aa3be Mon Sep 17 00:00:00 2001 From: Mario Emmenlauer Date: Sun, 25 Sep 2022 18:58:55 +0200 Subject: [PATCH 126/250] lib/cpp/test/concurrency/Tests.cpp: Very minor code cleanup (whitespace changes only) --- lib/cpp/test/concurrency/Tests.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/cpp/test/concurrency/Tests.cpp b/lib/cpp/test/concurrency/Tests.cpp index 8c734c2d5af..45054a92ad6 100644 --- a/lib/cpp/test/concurrency/Tests.cpp +++ b/lib/cpp/test/concurrency/Tests.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "ThreadFactoryTests.h" #include "TimerManagerTests.h" @@ -31,7 +32,7 @@ static int WEIGHT = 10; int main(int argc, char** argv) { - std::vector args(argc - 1 > 1 ? argc - 1 : 1); + std::vector args((argc - 1) > 1 ? (argc - 1) : 1); args[0] = "all"; @@ -44,7 +45,7 @@ int main(int argc, char** argv) { WEIGHT = 1; } - bool runAll = args[0].compare("all") == 0; + const bool runAll = args[0].compare("all") == 0; if (runAll || args[0].compare("thread-factory") == 0) { @@ -52,10 +53,10 @@ int main(int argc, char** argv) { std::cout << "ThreadFactory tests..." << std::endl; - int reapLoops = 2 * WEIGHT; - int reapCount = 100 * WEIGHT; - size_t floodLoops = 3; - size_t floodCount = 500 * WEIGHT; + const int reapLoops = 2 * WEIGHT; + const int reapCount = 100 * WEIGHT; + const size_t floodLoops = 3; + const size_t floodCount = 500 * WEIGHT; std::cout << "\t\tThreadFactory reap N threads test: N = " << reapLoops << "x" << reapCount << std::endl; From a4e7b9a4a0aeece800a6f861348f2a35be443596 Mon Sep 17 00:00:00 2001 From: Mario Emmenlauer Date: Mon, 9 Oct 2023 14:53:10 +0200 Subject: [PATCH 127/250] build/cmake/GenerateConfigModule.cmake: Do not install 'FindLibevent.cmake' if libevent is disabled --- build/cmake/GenerateConfigModule.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/cmake/GenerateConfigModule.cmake b/build/cmake/GenerateConfigModule.cmake index 26f018a2123..597ffd8f72c 100644 --- a/build/cmake/GenerateConfigModule.cmake +++ b/build/cmake/GenerateConfigModule.cmake @@ -40,6 +40,9 @@ if (NOT CYGWIN) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ThriftConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/ThriftConfigVersion.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/FindLibevent.cmake" DESTINATION "${CMAKE_INSTALL_DIR}/thrift") + if(WITH_LIBEVENT) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/FindLibevent.cmake" + DESTINATION "${CMAKE_INSTALL_DIR}/thrift") + endif() endif() From 653d184a840dee4221d8fbf88b91ec6318cd2684 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 06:50:21 +0000 Subject: [PATCH 128/250] Bump jvm from 1.8.22 to 1.9.10 in /lib/kotlin Bumps [jvm](https://github.com/JetBrains/kotlin) from 1.8.22 to 1.9.10. - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.9.10/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.22...v1.9.10) --- updated-dependencies: - dependency-name: jvm dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- lib/kotlin/settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/settings.gradle.kts b/lib/kotlin/settings.gradle.kts index 86fa02adac1..9eea8d19522 100644 --- a/lib/kotlin/settings.gradle.kts +++ b/lib/kotlin/settings.gradle.kts @@ -18,7 +18,7 @@ */ pluginManagement { plugins { - kotlin("jvm") version "1.8.22" + kotlin("jvm") version "1.9.10" id("com.ncorti.ktfmt.gradle") version "0.12.0" } } From b6b6dc715c0073af76de8244191b18c43ed4d24d Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Sat, 8 Oct 2022 14:28:44 +0800 Subject: [PATCH 129/250] rust to add uuid support --- .../cpp/src/thrift/generate/t_rs_generator.cc | 1334 ++++++++--------- lib/rs/Cargo.toml | 4 + lib/rs/src/errors.rs | 9 + lib/rs/src/protocol/binary.rs | 39 +- lib/rs/src/protocol/compact.rs | 10 + lib/rs/src/protocol/mod.rs | 18 +- lib/rs/src/protocol/multiplexed.rs | 4 + lib/rs/src/protocol/stored.rs | 4 + lib/rs/test/Cargo.toml | 1 + lib/rs/test/thrifts/Base_One.thrift | 1 + test/rs/Cargo.toml | 2 +- test/rs/Makefile.am | 4 +- test/rs/src/bin/test_client.rs | 6 + test/rs/src/bin/test_server.rs | 5 + 14 files changed, 697 insertions(+), 744 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_rs_generator.cc b/compiler/cpp/src/thrift/generate/t_rs_generator.cc index f454d9b9291..2742724a605 100644 --- a/compiler/cpp/src/thrift/generate/t_rs_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_rs_generator.cc @@ -17,11 +17,11 @@ * under the License. */ -#include #include +#include -#include "thrift/platform.h" #include "thrift/generate/t_generator.h" +#include "thrift/platform.h" using std::map; using std::ofstream; @@ -34,25 +34,17 @@ using std::vector; static const string endl("\n"); // avoid ostream << std::endl flushes static const string SERVICE_RESULT_VARIABLE("result_value"); static const string RESULT_STRUCT_SUFFIX("Result"); -static const string RUST_RESERVED_WORDS[] = { - "abstract", "alignof", "as", "become", - "box", "break", "const", "continue", - "crate", "do", "else", "enum", - "extern", "false", "final", "fn", - "for", "if", "impl", "in", - "let", "loop", "macro", "match", - "mod", "move", "mut", "offsetof", - "override", "priv", "proc", "pub", - "pure", "ref", "return", "Self", - "self", "sizeof", "static", "struct", - "super", "trait", "true", "type", - "typeof", "unsafe", "unsized", "use", - "virtual", "where", "while", "yield" -}; -const set RUST_RESERVED_WORDS_SET( - RUST_RESERVED_WORDS, - RUST_RESERVED_WORDS + sizeof(RUST_RESERVED_WORDS)/sizeof(RUST_RESERVED_WORDS[0]) -); +static const string RUST_RESERVED_WORDS[] + = {"abstract", "alignof", "as", "become", "box", "break", "const", "continue", "crate", + "do", "else", "enum", "extern", "false", "final", "fn", "for", "if", + "impl", "in", "let", "loop", "macro", "match", "mod", "move", "mut", + "offsetof", "override", "priv", "proc", "pub", "pure", "ref", "return", "Self", + "self", "sizeof", "static", "struct", "super", "trait", "true", "type", "typeof", + "unsafe", "unsized", "use", "virtual", "where", "while", "yield"}; +const set RUST_RESERVED_WORDS_SET(RUST_RESERVED_WORDS, + RUST_RESERVED_WORDS + + sizeof(RUST_RESERVED_WORDS) + / sizeof(RUST_RESERVED_WORDS[0])); static const string SYNC_CLIENT_GENERIC_BOUND_VARS(""); static const string SYNC_CLIENT_GENERIC_BOUNDS("where IP: TInputProtocol, OP: TOutputProtocol"); @@ -62,11 +54,8 @@ static const string SYNC_CLIENT_GENERIC_BOUNDS("where IP: TInputProtocol, OP: TO class t_rs_generator : public t_generator { public: - t_rs_generator( - t_program* program, - const std::map&, - const std::string& - ) : t_generator(program) { + t_rs_generator(t_program* program, const std::map&, const std::string&) + : t_generator(program) { gen_dir_ = get_out_dir(); } @@ -107,7 +96,8 @@ class t_rs_generator : public t_generator { void render_attributes_and_includes(); // Create the closure of Rust modules referenced by this service. - void compute_service_referenced_modules(t_service *tservice, set> &referenced_modules); + void compute_service_referenced_modules(t_service* tservice, + set>& referenced_modules); // Write the rust representation of an enum. void render_enum_definition(t_enum* tenum, const string& enum_name); @@ -122,13 +112,16 @@ class t_rs_generator : public t_generator { // Write a simple rust const value (ie. `pub const FOO: foo...`). void render_const_value(const string& name, t_type* ttype, t_const_value* tvalue); - // Write a constant list, set, map or struct. These constants require allocation and cannot be defined - // using a 'pub const'. As a result, I create a holder struct with a single `const_value` method that - // returns the initialized instance. + // Write a constant list, set, map or struct. These constants require allocation and cannot be + // defined using a 'pub const'. As a result, I create a holder struct with a single `const_value` + // method that returns the initialized instance. void render_const_value_holder(const string& name, t_type* ttype, t_const_value* tvalue); // Write the actual const value - the right side of a const definition. - void render_const_value(t_type* ttype, t_const_value* tvalue, bool is_owned = true, bool is_inline = true); + void render_const_value(t_type* ttype, + t_const_value* tvalue, + bool is_owned = true, + bool is_inline = true); // Write a const struct (returned from `const_value` method). void render_const_struct(t_type* ttype, t_const_value* tvalue); @@ -142,12 +135,14 @@ class t_rs_generator : public t_generator { // Write a const map (returned from `const_value` method). void render_const_map(t_type* ttype, t_const_value* tvalue); - // Write the rust representation of a thrift struct to the generated file. Set `struct_type` to `T_ARGS` - // if rendering the struct used to pack arguments for a service call. When `struct_type` is `T_ARGS` the - // struct and its members have module visibility, and all fields are required. When `struct_type` is - // anything else the struct and its members have public visibility and fields have the visibility set - // in their definition. - void render_struct(const string& struct_name, t_struct* tstruct, t_rs_generator::e_struct_type struct_type); + // Write the rust representation of a thrift struct to the generated file. Set `struct_type` to + // `T_ARGS` if rendering the struct used to pack arguments for a service call. When `struct_type` + // is `T_ARGS` the struct and its members have module visibility, and all fields are required. + // When `struct_type` is anything else the struct and its members have public visibility and + // fields have the visibility set in their definition. + void render_struct(const string& struct_name, + t_struct* tstruct, + t_rs_generator::e_struct_type struct_type); // Write the comment block preceding a type definition (and implementation). void render_type_comment(const string& struct_name); @@ -156,79 +151,77 @@ class t_rs_generator : public t_generator { // user-defined structs and exception structs. The exact struct type to be generated is controlled // by the `struct_type` parameter, which (among other things) modifies the visibility of the // written struct and members, controls which trait implementations are generated. - void render_struct_definition( - const string& struct_name, - t_struct* tstruct, - t_rs_generator::e_struct_type struct_type - ); + void render_struct_definition(const string& struct_name, + t_struct* tstruct, + t_rs_generator::e_struct_type struct_type); // Writes the impl block associated with the rust representation of a struct. At minimum this // contains the methods to read from a protocol and write to a protocol. Additional methods may // be generated depending on `struct_type`. - void render_struct_impl( - const string& struct_name, - t_struct* tstruct, - t_rs_generator::e_struct_type struct_type - ); - - // Generate a `fn new(...)` for a struct with name `struct_name` and type `t_struct`. The auto-generated - // code may include generic type parameters to make the constructor more ergonomic. `struct_type` controls - // the visibility of the generated constructor. - void render_struct_constructor( - const string& struct_name, - t_struct* tstruct, - t_rs_generator::e_struct_type struct_type - ); - - // Write the `ok_or` method added to all Thrift service call result structs. You can use this method - // to convert a struct into a `Result` and use it in a `try!` or combinator chain. + void render_struct_impl(const string& struct_name, + t_struct* tstruct, + t_rs_generator::e_struct_type struct_type); + + // Generate a `fn new(...)` for a struct with name `struct_name` and type `t_struct`. The + // auto-generated code may include generic type parameters to make the constructor more ergonomic. + // `struct_type` controls the visibility of the generated constructor. + void render_struct_constructor(const string& struct_name, + t_struct* tstruct, + t_rs_generator::e_struct_type struct_type); + + // Write the `ok_or` method added to all Thrift service call result structs. You can use this + // method to convert a struct into a `Result` and use it in a `try!` or combinator chain. void render_result_struct_to_result_method(t_struct* tstruct); // Write the implementations for the `Error` and `Debug` traits. These traits are necessary for a // user-defined exception to be properly handled as Rust errors. void render_exception_struct_error_trait_impls(const string& struct_name, t_struct* tstruct); - // Write the function that serializes a struct to its wire representation. If `struct_type` is `T_ARGS` - // then all fields are considered "required", if not, the default optionality is used. - void render_struct_sync_write(t_struct *tstruct, t_rs_generator::e_struct_type struct_type); + // Write the function that serializes a struct to its wire representation. If `struct_type` is + // `T_ARGS` then all fields are considered "required", if not, the default optionality is used. + void render_struct_sync_write(t_struct* tstruct, t_rs_generator::e_struct_type struct_type); // Helper function that serializes a single struct field to its wire representation. Unpacks the - // variable (since it may be optional) and serializes according to the optionality rules required by `req`. - // Variables in auto-generated code are passed by reference. Since this function may be called in - // contexts where the variable is *already* a reference you can set `field_var_is_ref` to `true` to avoid - // generating an extra, unnecessary `&` that the compiler will have to automatically dereference. - void render_struct_field_sync_write( - const string &field_var, - bool field_var_is_ref, - t_field *tfield, - t_field::e_req req); - - // Write the rust function that serializes a single type (i.e. a i32 etc.) to its wire representation. - // Variables in auto-generated code are passed by reference. Since this function may be called in - // contexts where the variable is *already* a reference you can set `type_var_is_ref` to `true` to avoid - // generating an extra, unnecessary `&` that the compiler will have to automatically dereference. - void render_type_sync_write(const string &type_var, bool type_var_is_ref, t_type *ttype); + // variable (since it may be optional) and serializes according to the optionality rules required + // by `req`. Variables in auto-generated code are passed by reference. Since this function may be + // called in contexts where the variable is *already* a reference you can set `field_var_is_ref` + // to `true` to avoid generating an extra, unnecessary `&` that the compiler will have to + // automatically dereference. + void render_struct_field_sync_write(const string& field_var, + bool field_var_is_ref, + t_field* tfield, + t_field::e_req req); + + // Write the rust function that serializes a single type (i.e. a i32 etc.) to its wire + // representation. Variables in auto-generated code are passed by reference. Since this function + // may be called in contexts where the variable is *already* a reference you can set + // `type_var_is_ref` to `true` to avoid generating an extra, unnecessary `&` that the compiler + // will have to automatically dereference. + void render_type_sync_write(const string& type_var, bool type_var_is_ref, t_type* ttype); // Write a list to the output protocol. `list_variable` is the variable containing the list // that will be written to the output protocol. // Variables in auto-generated code are passed by reference. Since this function may be called in - // contexts where the variable is *already* a reference you can set `list_var_is_ref` to `true` to avoid - // generating an extra, unnecessary `&` that the compiler will have to automatically dereference. - void render_list_sync_write(const string &list_var, bool list_var_is_ref, t_list *tlist); + // contexts where the variable is *already* a reference you can set `list_var_is_ref` to `true` to + // avoid generating an extra, unnecessary `&` that the compiler will have to automatically + // dereference. + void render_list_sync_write(const string& list_var, bool list_var_is_ref, t_list* tlist); // Write a set to the output protocol. `set_variable` is the variable containing the set that will // be written to the output protocol. // Variables in auto-generated code are passed by reference. Since this function may be called in - // contexts where the variable is *already* a reference you can set `set_var_is_ref` to `true` to avoid - // generating an extra, unnecessary `&` that the compiler will have to automatically dereference. - void render_set_sync_write(const string &set_var, bool set_var_is_ref, t_set *tset); + // contexts where the variable is *already* a reference you can set `set_var_is_ref` to `true` to + // avoid generating an extra, unnecessary `&` that the compiler will have to automatically + // dereference. + void render_set_sync_write(const string& set_var, bool set_var_is_ref, t_set* tset); // Write a map to the output protocol. `map_variable` is the variable containing the map that will // be written to the output protocol. // Variables in auto-generated code are passed by reference. Since this function may be called in - // contexts where the variable is *already* a reference you can set `map_var_is_ref` to `true` to avoid - // generating an extra, unnecessary `&` that the compiler will have to automatically dereference. - void render_map_sync_write(const string &map_var, bool map_var_is_ref, t_map *tset); + // contexts where the variable is *already* a reference you can set `map_var_is_ref` to `true` to + // avoid generating an extra, unnecessary `&` that the compiler will have to automatically + // dereference. + void render_map_sync_write(const string& map_var, bool map_var_is_ref, t_map* tset); // Return `true` if we need to dereference ths type when writing an element from a container. // Iterations on rust containers are performed as follows: `for v in &values { ... }` @@ -237,38 +230,41 @@ class t_rs_generator : public t_generator { bool needs_deref_on_container_write(t_type* ttype); // Return the variable (including all dereferences) required to write values from a rust container - // to the output protocol. For example, if you were iterating through a container and using the temp - // variable `v` to represent each element, then `ttype` is the type stored in the container and - // `base_var` is "v". The return value is the actual string you will have to use to properly reference - // the temp variable for writing to the output protocol. + // to the output protocol. For example, if you were iterating through a container and using the + // temp variable `v` to represent each element, then `ttype` is the type stored in the container + // and `base_var` is "v". The return value is the actual string you will have to use to properly + // reference the temp variable for writing to the output protocol. string string_container_write_variable(t_type* ttype, const string& base_var); // Write the code to read bytes from the wire into the given `t_struct`. `struct_name` is the // actual Rust name of the `t_struct`. If `struct_type` is `T_ARGS` then all struct fields are // necessary. Otherwise, the field's default optionality is used. - void render_struct_sync_read(const string &struct_name, t_struct *tstruct, t_rs_generator::e_struct_type struct_type); + void render_struct_sync_read(const string& struct_name, + t_struct* tstruct, + t_rs_generator::e_struct_type struct_type); - // Write the rust function that deserializes a single type (i.e. i32 etc.) from its wire representation. - // Set `is_boxed` to `true` if the resulting value should be wrapped in a `Box::new(...)`. - void render_type_sync_read(const string &type_var, t_type *ttype, bool is_boxed = false); + // Write the rust function that deserializes a single type (i.e. i32 etc.) from its wire + // representation. Set `is_boxed` to `true` if the resulting value should be wrapped in a + // `Box::new(...)`. + void render_type_sync_read(const string& type_var, t_type* ttype, bool is_boxed = false); // Read the wire representation of a list and convert it to its corresponding rust implementation. // The deserialized list is stored in `list_variable`. - void render_list_sync_read(t_list *tlist, const string &list_variable); + void render_list_sync_read(t_list* tlist, const string& list_variable); // Read the wire representation of a set and convert it to its corresponding rust implementation. // The deserialized set is stored in `set_variable`. - void render_set_sync_read(t_set *tset, const string &set_variable); + void render_set_sync_read(t_set* tset, const string& set_variable); // Read the wire representation of a map and convert it to its corresponding rust implementation. // The deserialized map is stored in `map_variable`. - void render_map_sync_read(t_map *tmap, const string &map_variable); + void render_map_sync_read(t_map* tmap, const string& map_variable); // Return a temporary variable used to store values when deserializing nested containers. string struct_field_read_temp_variable(t_field* tfield); - // Top-level function that calls the various render functions necessary to write the rust representation - // of a thrift union (i.e. an enum). + // Top-level function that calls the various render functions necessary to write the rust + // representation of a thrift union (i.e. an enum). void render_union(t_struct* tstruct); // Write the enum corresponding to the Thrift union. @@ -278,20 +274,21 @@ class t_rs_generator : public t_generator { void render_union_impl(const string& union_name, t_struct* tstruct); // Write the `ENUM::write_to_out_protocol` function. - void render_union_sync_write(const string &union_name, t_struct *tstruct); + void render_union_sync_write(const string& union_name, t_struct* tstruct); // Write the `ENUM::read_from_in_protocol` function. - void render_union_sync_read(const string &union_name, t_struct *tstruct); + void render_union_sync_read(const string& union_name, t_struct* tstruct); - // Top-level function that calls the various render functions necessary to write the rust representation - // of a Thrift client. + // Top-level function that calls the various render functions necessary to write the rust + // representation of a Thrift client. void render_sync_client(t_service* tservice); // Write the trait with the service-call methods for `tservice`. - void render_sync_client_trait(t_service *tservice); + void render_sync_client_trait(t_service* tservice); - // Write the trait to be implemented by the client impl if end users can use it to make service calls. - void render_sync_client_marker_trait(t_service *tservice); + // Write the trait to be implemented by the client impl if end users can use it to make service + // calls. + void render_sync_client_marker_trait(t_service* tservice); // Write the code to create the Thrift service sync client struct and its matching 'impl' block. void render_sync_client_definition_and_impl(const string& client_impl_name); @@ -303,14 +300,14 @@ class t_rs_generator : public t_generator { // Write the code to create the impl block for the `TThriftClient` trait. Since generated // Rust Thrift clients perform all their operations using methods defined in this trait, we // have to implement it for the client structs. - void render_sync_client_tthriftclient_impl(const string &client_impl_name); + void render_sync_client_tthriftclient_impl(const string& client_impl_name); // Write the marker traits for any service(s) being extended, including the one for the current // service itself (i.e. `tservice`) - void render_sync_client_marker_trait_impls(t_service *tservice, const string &impl_struct_name); + void render_sync_client_marker_trait_impls(t_service* tservice, const string& impl_struct_name); // Generate a list of all the traits this Thrift client struct extends. - string sync_client_marker_traits_for_extension(t_service *tservice); + string sync_client_marker_traits_for_extension(t_service* tservice); // Top-level function that writes the code to make the Thrift service calls. void render_sync_client_process_impl(t_service* tservice); @@ -318,26 +315,28 @@ class t_rs_generator : public t_generator { // Write the actual function that calls out to the remote service and processes its response. void render_sync_send_recv_wrapper(t_function* tfunc); - // Write the `send` functionality for a Thrift service call represented by a `t_service->t_function`. + // Write the `send` functionality for a Thrift service call represented by a + // `t_service->t_function`. void render_sync_send(t_function* tfunc); - // Write the `recv` functionality for a Thrift service call represented by a `t_service->t_function`. - // This method is only rendered if the function is *not* oneway. + // Write the `recv` functionality for a Thrift service call represented by a + // `t_service->t_function`. This method is only rendered if the function is *not* oneway. void render_sync_recv(t_function* tfunc); - void render_sync_processor(t_service *tservice); + void render_sync_processor(t_service* tservice); - void render_sync_handler_trait(t_service *tservice); - void render_sync_processor_definition_and_impl(t_service *tservice); - void render_sync_process_delegation_functions(t_service *tservice); - void render_sync_process_function(t_function *tfunc, const string &handler_type); + void render_sync_handler_trait(t_service* tservice); + void render_sync_processor_definition_and_impl(t_service* tservice); + void render_sync_process_delegation_functions(t_service* tservice); + void render_sync_process_function(t_function* tfunc, const string& handler_type); void render_process_match_statements(t_service* tservice); - void render_sync_handler_succeeded(t_function *tfunc); - void render_sync_handler_failed(t_function *tfunc); - void render_sync_handler_failed_user_exception_branch(t_function *tfunc); - void render_sync_handler_failed_application_exception_branch(t_function *tfunc, const string &app_err_var); - void render_sync_handler_failed_default_exception_branch(t_function *tfunc); - void render_sync_handler_send_exception_response(t_function *tfunc, const string &err_var); + void render_sync_handler_succeeded(t_function* tfunc); + void render_sync_handler_failed(t_function* tfunc); + void render_sync_handler_failed_user_exception_branch(t_function* tfunc); + void render_sync_handler_failed_application_exception_branch(t_function* tfunc, + const string& app_err_var); + void render_sync_handler_failed_default_exception_branch(t_function* tfunc); + void render_sync_handler_send_exception_response(t_function* tfunc, const string& err_var); void render_service_call_structs(t_service* tservice); void render_service_call_args_struct(t_function* tfunc); void render_service_call_result_value_struct(t_function* tfunc); @@ -345,12 +344,10 @@ class t_rs_generator : public t_generator { string handler_successful_return_struct(t_function* tfunc); // Writes the result of `render_thrift_error_struct` wrapped in an `Err(thrift::Error(...))`. - void render_thrift_error( - const string& error_kind, - const string& error_struct, - const string& sub_error_kind, - const string& error_message - ); + void render_thrift_error(const string& error_kind, + const string& error_struct, + const string& sub_error_kind, + const string& error_message); // Write a thrift::Error variant struct. Error structs take the form: // ``` @@ -366,11 +363,9 @@ class t_rs_generator : public t_generator { // message: "This is some error message", // } // ``` - void render_thrift_error_struct( - const string& error_struct, - const string& sub_error_kind, - const string& error_message - ); + void render_thrift_error_struct(const string& error_struct, + const string& sub_error_kind, + const string& error_message); // Return a string containing all the unpacked service call args given a service call function // `t_function`. Prepends the args with either `&mut self` or `&self` and includes the arg types @@ -383,8 +378,8 @@ class t_rs_generator : public t_generator { // `field_prefix`, for example: `self.field_0`. string rust_sync_service_call_invocation(t_function* tfunc, const string& field_prefix = ""); - // Return a string containing all fields in the struct `tstruct` for use in a function declaration. - // Each field is followed by its type, for example: `field_0: String`. + // Return a string containing all fields in the struct `tstruct` for use in a function + // declaration. Each field is followed by its type, for example: `field_0: String`. string struct_to_declaration(t_struct* tstruct, t_rs_generator::e_struct_type struct_type); // Return a string containing all fields in the struct `tstruct` for use in a function call, @@ -413,7 +408,8 @@ class t_rs_generator : public t_generator { // Return `true` if we can write a const of the form `pub const FOO: ...`. bool can_generate_simple_const(t_type* ttype); - // Return `true` if we cannot write a standard Rust constant (because the type needs some allocation). + // Return `true` if we cannot write a standard Rust constant (because the type needs some + // allocation). bool can_generate_const_holder(t_type* ttype); // Return `true` if this type is a void, and should be represented by the rust `()` type. @@ -421,8 +417,9 @@ class t_rs_generator : public t_generator { t_field::e_req actual_field_req(t_field* tfield, t_rs_generator::e_struct_type struct_type); - // Return `true` if this `t_field::e_req` is either `t_field::T_OPTIONAL` or `t_field::T_OPT_IN_REQ_OUT` - // and needs to be wrapped by an `Option`, `false` otherwise. + // Return `true` if this `t_field::e_req` is either `t_field::T_OPTIONAL` or + // `t_field::T_OPT_IN_REQ_OUT` and needs to be wrapped by an `Option`, `false` + // otherwise. bool is_optional(t_field::e_req req); // Return `true` if the service call has arguments, `false` otherwise. @@ -431,30 +428,32 @@ class t_rs_generator : public t_generator { // Return `true` if a service call has non-`()` arguments, `false` otherwise. bool has_non_void_args(t_function* tfunc); - // Return `pub ` (notice trailing whitespace!) if the struct should be public, `` (empty string) otherwise. + // Return `pub ` (notice trailing whitespace!) if the struct should be public, `` (empty string) + // otherwise. string visibility_qualifier(t_rs_generator::e_struct_type struct_type); - // Returns the namespace prefix for a given Thrift service. If the type is defined in the presently-computed - // Thrift program, then an empty string is returned. + // Returns the namespace prefix for a given Thrift service. If the type is defined in the + // presently-computed Thrift program, then an empty string is returned. string rust_namespace(t_service* tservice); - // Returns the namespace prefix for a given Thrift type. If the type is defined in the presently-computed - // Thrift program, then an empty string is returned. + // Returns the namespace prefix for a given Thrift type. If the type is defined in the + // presently-computed Thrift program, then an empty string is returned. string rust_namespace(t_type* ttype); - // Returns the camel-cased name for a Rust struct type. Handles the case where `tstruct->get_name()` is - // a reserved word. + // Returns the camel-cased name for a Rust struct type. Handles the case where + // `tstruct->get_name()` is a reserved word. string rust_struct_name(t_struct* tstruct); // Returns the snake-cased name for a Rust field or local variable. Handles the case where // `tfield->get_name()` is a reserved word. string rust_field_name(t_field* tstruct); - // Returns the camel-cased name for a Rust union type. Handles the case where `tstruct->get_name()` is - // a reserved word. + // Returns the camel-cased name for a Rust union type. Handles the case where + // `tstruct->get_name()` is a reserved word. string rust_union_field_name(t_field* tstruct); - // Converts any variable name into a 'safe' variant that does not clash with any Rust reserved keywords. + // Converts any variable name into a 'safe' variant that does not clash with any Rust reserved + // keywords. string rust_safe_name(const string& name); // Return `true` if the name is a reserved Rust keyword, `false` otherwise. @@ -463,7 +462,8 @@ class t_rs_generator : public t_generator { // Return the name of the function that users will invoke to make outgoing service calls. string service_call_client_function_name(t_function* tfunc); - // Return the name of the function that users will have to implement to handle incoming service calls. + // Return the name of the function that users will have to implement to handle incoming service + // calls. string service_call_handler_function_name(t_function* tfunc); // Return the name of the struct used to pack the arguments for the thrift service call. @@ -481,7 +481,8 @@ class t_rs_generator : public t_generator { // Return the name for the sync service client struct given a `t_service`. string rust_sync_client_impl_name(t_service* tservice); - // Return the trait name that users will have to implement for the server half of a Thrift service. + // Return the trait name that users will have to implement for the server half of a Thrift + // service. string rust_sync_handler_trait_name(t_service* tservice); // Return the struct name for the server half of a Thrift service. @@ -489,7 +490,7 @@ class t_rs_generator : public t_generator { // Return the struct name for the struct that contains all the service-call implementations for // the server half of a Thrift service. - string rust_sync_processor_impl_name(t_service *tservice); + string rust_sync_processor_impl_name(t_service* tservice); // Return the variant name for an enum variant string rust_enum_variant_name(const string& name); @@ -537,14 +538,17 @@ void t_rs_generator::render_attributes_and_includes() { // code might not include imports from crates f_gen_ << "#![allow(unused_extern_crates)]" << endl; // constructors take *all* struct parameters, which can trigger the "too many arguments" warning - // some auto-gen'd types can be deeply nested. clippy recommends factoring them out which is hard to autogen - // some methods may start with "is_" - // FIXME: re-enable the 'vec_box' lint see: [THRIFT-5364](https://issues.apache.org/jira/browse/THRIFT-5364) - // This can happen because we automatically generate a Vec> when the type is a typedef - // and it's a forward typedef. This (typedef + forward typedef) can happen in two situations: + // some auto-gen'd types can be deeply nested. clippy recommends factoring them out which is hard + // to autogen some methods may start with "is_" + // FIXME: re-enable the 'vec_box' lint see: + // [THRIFT-5364](https://issues.apache.org/jira/browse/THRIFT-5364) This can happen because we + // automatically generate a Vec> when the type is a typedef and it's a forward typedef. + // This (typedef + forward typedef) can happen in two situations: // 1. When the type is recursive // 2. When you define types out of order - f_gen_ << "#![allow(clippy::too_many_arguments, clippy::type_complexity, clippy::vec_box, clippy::wrong_self_convention)]" << endl; + f_gen_ << "#![allow(clippy::too_many_arguments, clippy::type_complexity, clippy::vec_box, " + "clippy::wrong_self_convention)]" + << endl; // prevent rustfmt from running against this file // lines are too long, code is (thankfully!) not visual-indented, etc. // can't use #[rustfmt::skip] see: https://github.com/rust-lang/rust/issues/54726 @@ -562,8 +566,13 @@ void t_rs_generator::render_attributes_and_includes() { f_gen_ << "use std::rc::Rc;" << endl; f_gen_ << endl; f_gen_ << "use thrift::OrderedFloat;" << endl; - f_gen_ << "use thrift::{ApplicationError, ApplicationErrorKind, ProtocolError, ProtocolErrorKind, TThriftClient};" << endl; - f_gen_ << "use thrift::protocol::{TFieldIdentifier, TListIdentifier, TMapIdentifier, TMessageIdentifier, TMessageType, TInputProtocol, TOutputProtocol, TSerializable, TSetIdentifier, TStructIdentifier, TType};" << endl; + f_gen_ << "use thrift::{ApplicationError, ApplicationErrorKind, ProtocolError, " + "ProtocolErrorKind, TThriftClient};" + << endl; + f_gen_ << "use thrift::protocol::{TFieldIdentifier, TListIdentifier, TMapIdentifier, " + "TMessageIdentifier, TMessageType, TInputProtocol, TOutputProtocol, TSerializable, " + "TSetIdentifier, TStructIdentifier, TType};" + << endl; f_gen_ << "use thrift::protocol::field_id;" << endl; f_gen_ << "use thrift::protocol::verify_expected_message_type;" << endl; f_gen_ << "use thrift::protocol::verify_expected_sequence_number;" << endl; @@ -574,18 +583,21 @@ void t_rs_generator::render_attributes_and_includes() { // add all the program includes // NOTE: this is more involved than you would expect because of service extension - // Basically, I have to find the closure of all the services and include their modules at the top-level + // Basically, I have to find the closure of all the services and include their modules at the + // top-level set> referenced_modules; // set // first, start by adding explicit thrift includes const vector includes = get_program()->get_includes(); vector::const_iterator includes_iter; - for(includes_iter = includes.begin(); includes_iter != includes.end(); ++includes_iter) { - referenced_modules.insert(std::make_pair((*includes_iter)->get_name(), (*includes_iter)->get_namespace("rs"))); + for (includes_iter = includes.begin(); includes_iter != includes.end(); ++includes_iter) { + referenced_modules.insert( + std::make_pair((*includes_iter)->get_name(), (*includes_iter)->get_namespace("rs"))); } - // next, recursively iterate through all the services and add the names of any programs they reference + // next, recursively iterate through all the services and add the names of any programs they + // reference const vector services = get_program()->get_services(); vector::const_iterator service_iter; for (service_iter = services.begin(); service_iter != services.end(); ++service_iter) { @@ -595,7 +607,8 @@ void t_rs_generator::render_attributes_and_includes() { // finally, write all the "pub use..." declarations if (!referenced_modules.empty()) { set>::iterator module_iter; - for (module_iter = referenced_modules.begin(); module_iter != referenced_modules.end(); ++module_iter) { + for (module_iter = referenced_modules.begin(); module_iter != referenced_modules.end(); + ++module_iter) { string module_name((*module_iter).first); string module_namespace((*module_iter).second); @@ -604,7 +617,8 @@ void t_rs_generator::render_attributes_and_includes() { if (module_namespace.empty()) { f_gen_ << "use crate::" << rust_snake_case(module_name) << ";" << endl; } else { - f_gen_ << "use crate::" << module_namespace << "::" << rust_snake_case(module_name) << ";" << endl; + f_gen_ << "use crate::" << module_namespace << "::" << rust_snake_case(module_name) << ";" + << endl; } } f_gen_ << endl; @@ -612,13 +626,13 @@ void t_rs_generator::render_attributes_and_includes() { } void t_rs_generator::compute_service_referenced_modules( - t_service *tservice, - set> &referenced_modules -) { + t_service* tservice, + set>& referenced_modules) { t_service* extends = tservice->get_extends(); if (extends) { if (extends->get_program() != get_program()) { - referenced_modules.insert(std::make_pair(extends->get_program()->get_name(), extends->get_program()->get_namespace("rs"))); + referenced_modules.insert(std::make_pair(extends->get_program()->get_name(), + extends->get_program()->get_namespace("rs"))); } compute_service_referenced_modules(extends, referenced_modules); } @@ -663,7 +677,9 @@ void t_rs_generator::render_const_value(const string& name, t_type* ttype, t_con f_gen_ << endl; } -void t_rs_generator::render_const_value_holder(const string& name, t_type* ttype, t_const_value* tvalue) { +void t_rs_generator::render_const_value_holder(const string& name, + t_type* ttype, + t_const_value* tvalue) { if (!can_generate_const_holder(ttype)) { throw "cannot generate constant holder for " + ttype->get_name(); } @@ -685,7 +701,10 @@ void t_rs_generator::render_const_value_holder(const string& name, t_type* ttype f_gen_ << endl; } -void t_rs_generator::render_const_value(t_type* ttype, t_const_value* tvalue, bool is_owned, bool is_inline) { +void t_rs_generator::render_const_value(t_type* ttype, + t_const_value* tvalue, + bool is_owned, + bool is_inline) { if (!is_inline) { f_gen_ << indent(); } @@ -696,7 +715,8 @@ void t_rs_generator::render_const_value(t_type* ttype, t_const_value* tvalue, bo case t_base_type::TYPE_STRING: if (tbase_type->is_binary()) { if (is_owned) { - f_gen_ << "\"" << tvalue->get_string() << "\""<< ".to_owned().into_bytes()"; + f_gen_ << "\"" << tvalue->get_string() << "\"" + << ".to_owned().into_bytes()"; } else { f_gen_ << "b\"" << tvalue->get_string() << "\""; } @@ -707,6 +727,9 @@ void t_rs_generator::render_const_value(t_type* ttype, t_const_value* tvalue, bo } } break; + case t_base_type::TYPE_UUID: + f_gen_ << "Uuid::parse_str(\"" << tvalue->get_string() << "\").unwrap()"; + break; case t_base_type::TYPE_BOOL: f_gen_ << (tvalue->get_integer() ? "true" : "false"); break; @@ -727,13 +750,8 @@ void t_rs_generator::render_const_value(t_type* ttype, t_const_value* tvalue, bo } else if (ttype->is_enum()) { f_gen_ << "{" << endl; indent_up(); - f_gen_ - << indent() - << to_rust_type(ttype) - << "::try_from(" - << tvalue->get_integer() - << ").expect(\"expecting valid const value\")" - << endl; + f_gen_ << indent() << to_rust_type(ttype) << "::try_from(" << tvalue->get_integer() + << ").expect(\"expecting valid const value\")" << endl; indent_down(); f_gen_ << indent() << "}"; } else if (ttype->is_struct() || ttype->is_xception()) { @@ -780,7 +798,7 @@ void t_rs_generator::render_const_list(t_type* ttype, t_const_value* tvalue) { indent_up(); const vector& elems = tvalue->get_list(); vector::const_iterator elem_iter; - for(elem_iter = elems.begin(); elem_iter != elems.end(); ++elem_iter) { + for (elem_iter = elems.begin(); elem_iter != elems.end(); ++elem_iter) { f_gen_ << indent(); t_const_value* elem_value = (*elem_iter); render_const_value(elem_type, elem_value); @@ -796,7 +814,7 @@ void t_rs_generator::render_const_set(t_type* ttype, t_const_value* tvalue) { indent_up(); const vector& elems = tvalue->get_list(); vector::const_iterator elem_iter; - for(elem_iter = elems.begin(); elem_iter != elems.end(); ++elem_iter) { + for (elem_iter = elems.begin(); elem_iter != elems.end(); ++elem_iter) { f_gen_ << indent(); t_const_value* elem_value = (*elem_iter); render_const_value(elem_type, elem_value); @@ -811,7 +829,8 @@ void t_rs_generator::render_const_map(t_type* ttype, t_const_value* tvalue) { t_type* val_type = ((t_map*)ttype)->get_val_type(); f_gen_ << "BTreeMap::from([" << endl; indent_up(); - const map& elems = tvalue->get_map(); + const map& elems + = tvalue->get_map(); map::const_iterator elem_iter; for (elem_iter = elems.begin(); elem_iter != elems.end(); ++elem_iter) { t_const_value* key_value = elem_iter->first; @@ -840,7 +859,8 @@ void t_rs_generator::render_const_map(t_type* ttype, t_const_value* tvalue) { void t_rs_generator::generate_typedef(t_typedef* ttypedef) { std::string actual_type = to_rust_type(ttypedef->get_type()); - f_gen_ << "pub type " << rust_safe_name(ttypedef->get_symbolic()) << " = " << actual_type << ";" << endl; + f_gen_ << "pub type " << rust_safe_name(ttypedef->get_symbolic()) << " = " << actual_type << ";" + << endl; f_gen_ << endl; } @@ -858,7 +878,7 @@ void t_rs_generator::generate_enum(t_enum* tenum) { } void t_rs_generator::render_enum_definition(t_enum* tenum, const string& enum_name) { - render_rustdoc((t_doc*) tenum); + render_rustdoc((t_doc*)tenum); f_gen_ << "#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]" << endl; f_gen_ << "pub struct " << enum_name << "(pub i32);" << endl; f_gen_ << endl; @@ -872,18 +892,14 @@ void t_rs_generator::render_enum_impl(t_enum* tenum, const string& enum_name) { // associated constants for each IDL-defined enum variant { - vector::iterator constants_iter; - for (constants_iter = constants.begin(); constants_iter != constants.end(); ++constants_iter) { - t_enum_value* val = (*constants_iter); - render_rustdoc((t_doc*) val); - f_gen_ - << indent() - << "pub const " << rust_enum_variant_name(val->get_name()) << ": " << enum_name - << " = " - << enum_name << "(" << val->get_value() << ")" - << ";" - << endl; - } + vector::iterator constants_iter; + for (constants_iter = constants.begin(); constants_iter != constants.end(); ++constants_iter) { + t_enum_value* val = (*constants_iter); + render_rustdoc((t_doc*)val); + f_gen_ << indent() << "pub const " << rust_enum_variant_name(val->get_name()) << ": " + << enum_name << " = " << enum_name << "(" << val->get_value() << ")" + << ";" << endl; + } } // array containing all IDL-defined enum variants @@ -893,11 +909,7 @@ void t_rs_generator::render_enum_impl(t_enum* tenum, const string& enum_name) { vector::iterator constants_iter; for (constants_iter = constants.begin(); constants_iter != constants.end(); ++constants_iter) { t_enum_value* val = (*constants_iter); - f_gen_ - << indent() - << "Self::" << rust_enum_variant_name(val->get_name()) - << "," - << endl; + f_gen_ << indent() << "Self::" << rust_enum_variant_name(val->get_name()) << "," << endl; } indent_down(); f_gen_ << indent() << "];" << endl; @@ -912,21 +924,21 @@ void t_rs_generator::render_enum_impl(t_enum* tenum, const string& enum_name) { f_gen_ << indent() << "#[allow(clippy::trivially_copy_pass_by_ref)]" << endl; f_gen_ - << indent() - << "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {" - << endl; + << indent() + << "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {" + << endl; indent_up(); f_gen_ << indent() << "o_prot.write_i32(self.0)" << endl; indent_down(); f_gen_ << indent() << "}" << endl; - f_gen_ - << indent() - << "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<" << enum_name << "> {" - << endl; + f_gen_ << indent() + << "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<" + << enum_name << "> {" << endl; indent_up(); f_gen_ << indent() << "let enum_value = i_prot.read_i32()?;" << endl; - f_gen_ << indent() << "Ok(" << enum_name << "::from(enum_value)" << ")" << endl; + f_gen_ << indent() << "Ok(" << enum_name << "::from(enum_value)" + << ")" << endl; indent_down(); f_gen_ << indent() << "}" << endl; @@ -947,11 +959,8 @@ void t_rs_generator::render_enum_conversion(t_enum* tenum, const string& enum_na vector::iterator constants_iter; for (constants_iter = constants.begin(); constants_iter != constants.end(); ++constants_iter) { t_enum_value* val = (*constants_iter); - f_gen_ - << indent() - << val->get_value() - << " => " << enum_name << "::" << rust_enum_variant_name(val->get_name()) << "," - << endl; + f_gen_ << indent() << val->get_value() << " => " << enum_name + << "::" << rust_enum_variant_name(val->get_name()) << "," << endl; } f_gen_ << indent() << "_ => " << enum_name << "(i)" << endl; indent_down(); @@ -1019,11 +1028,9 @@ void t_rs_generator::generate_struct(t_struct* tstruct) { } } -void t_rs_generator::render_struct( - const string& struct_name, - t_struct* tstruct, - t_rs_generator::e_struct_type struct_type -) { +void t_rs_generator::render_struct(const string& struct_name, + t_struct* tstruct, + t_rs_generator::e_struct_type struct_type) { render_type_comment(struct_name); render_struct_definition(struct_name, tstruct, struct_type); render_struct_impl(struct_name, tstruct, struct_type); @@ -1032,46 +1039,40 @@ void t_rs_generator::render_struct( } } -void t_rs_generator::render_struct_definition( - const string& struct_name, - t_struct* tstruct, - t_rs_generator::e_struct_type struct_type -) { - render_rustdoc((t_doc*) tstruct); +void t_rs_generator::render_struct_definition(const string& struct_name, + t_struct* tstruct, + t_rs_generator::e_struct_type struct_type) { + render_rustdoc((t_doc*)tstruct); const vector members = tstruct->get_sorted_members(); vector::const_iterator members_iter; - bool need_default = struct_type == t_rs_generator::T_REGULAR || struct_type == t_rs_generator::T_EXCEPTION; - for (members_iter = members.begin(); need_default && members_iter != members.end(); ++members_iter) { + bool need_default + = struct_type == t_rs_generator::T_REGULAR || struct_type == t_rs_generator::T_EXCEPTION; + for (members_iter = members.begin(); need_default && members_iter != members.end(); + ++members_iter) { t_field* member = *members_iter; if (!is_optional(member->get_req())) { need_default = false; } } - f_gen_ - << "#[derive(Clone, Debug" - << (need_default ? ", Default" : "") - << ", Eq, Hash, Ord, PartialEq, PartialOrd)]" - << endl; + f_gen_ << "#[derive(Clone, Debug" << (need_default ? ", Default" : "") + << ", Eq, Hash, Ord, PartialEq, PartialOrd)]" << endl; f_gen_ << visibility_qualifier(struct_type) << "struct " << struct_name << " {" << endl; // render the members if (!members.empty()) { indent_up(); - for(members_iter = members.begin(); members_iter != members.end(); ++members_iter) { + for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* member = (*members_iter); t_field::e_req member_req = actual_field_req(member, struct_type); string rust_type = to_rust_type(member->get_type()); rust_type = is_optional(member_req) ? "Option<" + rust_type + ">" : rust_type; - render_rustdoc((t_doc*) member); - f_gen_ - << indent() - << visibility_qualifier(struct_type) - << rust_field_name(member) << ": " << rust_type << "," - << endl; + render_rustdoc((t_doc*)member); + f_gen_ << indent() << visibility_qualifier(struct_type) << rust_field_name(member) << ": " + << rust_type << "," << endl; } indent_down(); @@ -1081,7 +1082,8 @@ void t_rs_generator::render_struct_definition( f_gen_ << endl; } -void t_rs_generator::render_exception_struct_error_trait_impls(const string& struct_name, t_struct* tstruct) { +void t_rs_generator::render_exception_struct_error_trait_impls(const string& struct_name, + t_struct* tstruct) { // error::Error trait f_gen_ << "impl Error for " << struct_name << " {}" << endl; f_gen_ << endl; @@ -1103,12 +1105,9 @@ void t_rs_generator::render_exception_struct_error_trait_impls(const string& str indent_up(); f_gen_ << indent() << "fn fmt(&self, f: &mut Formatter) -> fmt::Result {" << endl; indent_up(); - f_gen_ - << indent() - << "write!(f, " - << "\"remote service threw " << tstruct->get_name() << "\"" // use *original* name - << ")" - << endl; + f_gen_ << indent() << "write!(f, " + << "\"remote service threw " << tstruct->get_name() << "\"" // use *original* name + << ")" << endl; indent_down(); f_gen_ << indent() << "}" << endl; indent_down(); @@ -1116,11 +1115,9 @@ void t_rs_generator::render_exception_struct_error_trait_impls(const string& str f_gen_ << endl; } -void t_rs_generator::render_struct_impl( - const string& struct_name, - t_struct* tstruct, - t_rs_generator::e_struct_type struct_type -) { +void t_rs_generator::render_struct_impl(const string& struct_name, + t_struct* tstruct, + t_rs_generator::e_struct_type struct_type) { f_gen_ << "impl " << struct_name << " {" << endl; indent_up(); @@ -1149,21 +1146,19 @@ void t_rs_generator::render_struct_impl( f_gen_ << endl; } -void t_rs_generator::render_struct_constructor( - const string& struct_name, - t_struct* tstruct, - t_rs_generator::e_struct_type struct_type -) { +void t_rs_generator::render_struct_constructor(const string& struct_name, + t_struct* tstruct, + t_rs_generator::e_struct_type struct_type) { const vector& members = tstruct->get_sorted_members(); vector::const_iterator members_iter; - // build the convenience type parameters that allows us to pass unwrapped values to a constructor and - // have them automatically converted into Option + // build the convenience type parameters that allows us to pass unwrapped values to a constructor + // and have them automatically converted into Option bool first_arg = true; ostringstream generic_type_parameters; ostringstream generic_type_qualifiers; - for(members_iter = members.begin(); members_iter != members.end(); ++members_iter) { + for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* member = (*members_iter); t_field::e_req member_req = actual_field_req(member, struct_type); @@ -1175,7 +1170,8 @@ void t_rs_generator::render_struct_constructor( generic_type_qualifiers << ", "; } generic_type_parameters << "F" << rust_safe_field_id(member->get_key()); - generic_type_qualifiers << "F" << rust_safe_field_id(member->get_key()) << ": Intoget_type()) << ">>"; + generic_type_qualifiers << "F" << rust_safe_field_id(member->get_key()) << ": Intoget_type()) << ">>"; } } @@ -1190,11 +1186,11 @@ void t_rs_generator::render_struct_constructor( } // now build the actual constructor arg list - // when we're building this list we have to use the type parameters in place of the actual type names - // if necessary + // when we're building this list we have to use the type parameters in place of the actual type + // names if necessary ostringstream args; first_arg = true; - for(members_iter = members.begin(); members_iter != members.end(); ++members_iter) { + for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* member = (*members_iter); t_field::e_req member_req = actual_field_req(member, struct_type); string member_name(rust_field_name(member)); @@ -1206,7 +1202,8 @@ void t_rs_generator::render_struct_constructor( } if (is_optional(member_req)) { - args << member_name << ": " << "F" << rust_safe_field_id(member->get_key()); + args << member_name << ": " + << "F" << rust_safe_field_id(member->get_key()); } else { args << member_name << ": " << to_rust_type(member->get_type()); } @@ -1215,19 +1212,8 @@ void t_rs_generator::render_struct_constructor( string arg_string = args.str(); string visibility(visibility_qualifier(struct_type)); - f_gen_ - << indent() - << visibility - << "fn new" - << type_parameter_string - << "(" - << arg_string - << ") -> " - << struct_name - << " " - << type_qualifier_string - << "{" - << endl; + f_gen_ << indent() << visibility << "fn new" << type_parameter_string << "(" << arg_string + << ") -> " << struct_name << " " << type_qualifier_string << "{" << endl; indent_up(); if (members.empty()) { @@ -1236,7 +1222,7 @@ void t_rs_generator::render_struct_constructor( f_gen_ << indent() << struct_name << " {" << endl; indent_up(); - for(members_iter = members.begin(); members_iter != members.end(); ++members_iter) { + for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* member = (*members_iter); t_field::e_req member_req = actual_field_req(member, struct_type); string member_name(rust_field_name(member)); @@ -1265,7 +1251,7 @@ void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) { if (index == std::string::npos) { throw "result struct " + service_call_name + " missing result suffix"; } else { - service_call_name.replace(index, 6, ""); + service_call_name.replace(index, 6, ""); } const vector& members = tstruct->get_sorted_members(); @@ -1273,7 +1259,7 @@ void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) { // find out what the call's expected return type was string rust_return_type = "()"; - for(members_iter = members.begin(); members_iter != members.end(); ++members_iter) { + for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* member = (*members_iter); if (member->get_name() == SERVICE_RESULT_VARIABLE) { // don't have to check safe name here rust_return_type = to_rust_type(member->get_type()); @@ -1292,7 +1278,7 @@ void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) { int rendered_branch_count = 0; // render the exception branches - for(members_iter = members.begin(); members_iter != members.end(); ++members_iter) { + for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* tfield = (*members_iter); if (tfield->get_name() != SERVICE_RESULT_VARIABLE) { // don't have to check safe name here string field_name("self." + rust_field_name(tfield)); @@ -1300,7 +1286,8 @@ void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) { f_gen_ << indent() << branch_statement << " " << field_name << ".is_some() {" << endl; indent_up(); - f_gen_ << indent() << "Err(thrift::Error::User(Box::new(" << field_name << ".unwrap())))" << endl; + f_gen_ << indent() << "Err(thrift::Error::User(Box::new(" << field_name << ".unwrap())))" + << endl; indent_down(); rendered_branch_count++; @@ -1324,7 +1311,8 @@ void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) { } } else { string branch_statement = rendered_branch_count == 0 ? "if" : "} else if"; - f_gen_ << indent() << branch_statement << " self." << SERVICE_RESULT_VARIABLE << ".is_some() {" << endl; + f_gen_ << indent() << branch_statement << " self." << SERVICE_RESULT_VARIABLE << ".is_some() {" + << endl; indent_up(); f_gen_ << indent() << "Ok(self." << SERVICE_RESULT_VARIABLE << ".unwrap())" << endl; indent_down(); @@ -1332,12 +1320,8 @@ void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) { indent_up(); // if we haven't found a valid return value *or* a user exception // then we're in trouble; return a default error - render_thrift_error( - "Application", - "ApplicationError", - "ApplicationErrorKind::MissingResult", - "\"no result received for " + service_call_name + "\"" - ); + render_thrift_error("Application", "ApplicationError", "ApplicationErrorKind::MissingResult", + "\"no result received for " + service_call_name + "\""); indent_down(); f_gen_ << indent() << "}" << endl; } @@ -1364,13 +1348,10 @@ void t_rs_generator::render_union_definition(const string& union_name, t_struct* indent_up(); vector::const_iterator member_iter; - for(member_iter = members.begin(); member_iter != members.end(); ++member_iter) { + for (member_iter = members.begin(); member_iter != members.end(); ++member_iter) { t_field* tfield = (*member_iter); - f_gen_ - << indent() - << rust_union_field_name(tfield) - << "(" << to_rust_type(tfield->get_type()) << ")," - << endl; + f_gen_ << indent() << rust_union_field_name(tfield) << "(" << to_rust_type(tfield->get_type()) + << ")," << endl; } indent_down(); @@ -1396,26 +1377,25 @@ void t_rs_generator::render_union_impl(const string& union_name, t_struct* tstru // //----------------------------------------------------------------------------- -void t_rs_generator::render_struct_sync_write( - t_struct *tstruct, - t_rs_generator::e_struct_type struct_type -) { +void t_rs_generator::render_struct_sync_write(t_struct* tstruct, + t_rs_generator::e_struct_type struct_type) { f_gen_ - << indent() - << "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {" - << endl; + << indent() + << "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {" + << endl; indent_up(); // write struct header to output protocol // note: use the *original* struct name here - f_gen_ << indent() << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << endl; + f_gen_ << indent() + << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << endl; f_gen_ << indent() << "o_prot.write_struct_begin(&struct_ident)?;" << endl; // write struct members to output protocol vector members = tstruct->get_sorted_members(); if (!members.empty()) { vector::iterator members_iter; - for(members_iter = members.begin(); members_iter != members.end(); ++members_iter) { + for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* member = (*members_iter); t_field::e_req member_req = actual_field_req(member, struct_type); string member_var("self." + rust_field_name(member)); @@ -1431,16 +1411,17 @@ void t_rs_generator::render_struct_sync_write( f_gen_ << indent() << "}" << endl; } -void t_rs_generator::render_union_sync_write(const string &union_name, t_struct *tstruct) { +void t_rs_generator::render_union_sync_write(const string& union_name, t_struct* tstruct) { f_gen_ - << indent() - << "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {" - << endl; + << indent() + << "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {" + << endl; indent_up(); // write struct header to output protocol // note: use the *original* struct name here - f_gen_ << indent() << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << endl; + f_gen_ << indent() + << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << endl; f_gen_ << indent() << "o_prot.write_struct_begin(&struct_ident)?;" << endl; // write the enum field to the output protocol @@ -1449,7 +1430,7 @@ void t_rs_generator::render_union_sync_write(const string &union_name, t_struct f_gen_ << indent() << "match *self {" << endl; indent_up(); vector::iterator members_iter; - for(members_iter = members.begin(); members_iter != members.end(); ++members_iter) { + for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* member = (*members_iter); t_field::e_req member_req = t_field::T_REQUIRED; t_type* ttype = member->get_type(); @@ -1458,11 +1439,8 @@ void t_rs_generator::render_union_sync_write(const string &union_name, t_struct ttype = ((t_typedef*)ttype)->get_type(); } string match_var((ttype->is_base_type() && !ttype->is_string()) ? "f" : "ref f"); - f_gen_ - << indent() - << union_name << "::" << rust_union_field_name(member) - << "(" << match_var << ") => {" - << endl; + f_gen_ << indent() << union_name << "::" << rust_union_field_name(member) << "(" << match_var + << ") => {" << endl; indent_up(); render_struct_field_sync_write("f", true, member, member_req); indent_down(); @@ -1480,25 +1458,23 @@ void t_rs_generator::render_union_sync_write(const string &union_name, t_struct f_gen_ << indent() << "}" << endl; } -void t_rs_generator::render_struct_field_sync_write( - const string &field_var, - bool field_var_is_ref, - t_field *tfield, - t_field::e_req req -) { +void t_rs_generator::render_struct_field_sync_write(const string& field_var, + bool field_var_is_ref, + t_field* tfield, + t_field::e_req req) { t_type* field_type = tfield->get_type(); t_type* actual_type = get_true_type(field_type); ostringstream field_stream; - field_stream - << "TFieldIdentifier::new(" - << "\"" << tfield->get_name() << "\"" << ", " // note: use *original* name - << to_rust_field_type_enum(field_type) << ", " - << tfield->get_key() << ")"; + field_stream << "TFieldIdentifier::new(" + << "\"" << tfield->get_name() << "\"" + << ", " // note: use *original* name + << to_rust_field_type_enum(field_type) << ", " << tfield->get_key() << ")"; string field_ident_string = field_stream.str(); if (is_optional(req)) { - string let_var((actual_type->is_base_type() && !actual_type->is_string()) ? "fld_var" : "ref fld_var"); + string let_var((actual_type->is_base_type() && !actual_type->is_string()) ? "fld_var" + : "ref fld_var"); f_gen_ << indent() << "if let Some(" << let_var << ") = " << field_var << " {" << endl; indent_up(); f_gen_ << indent() << "o_prot.write_field_begin(&" << field_ident_string << ")?;" << endl; @@ -1519,7 +1495,9 @@ void t_rs_generator::render_struct_field_sync_write( } } -void t_rs_generator::render_type_sync_write(const string &type_var, bool type_var_is_ref, t_type *ttype) { +void t_rs_generator::render_type_sync_write(const string& type_var, + bool type_var_is_ref, + t_type* ttype) { if (ttype->is_base_type()) { t_base_type* tbase_type = (t_base_type*)ttype; switch (tbase_type->get_base()) { @@ -1534,6 +1512,9 @@ void t_rs_generator::render_type_sync_write(const string &type_var, bool type_va } return; } + case t_base_type::TYPE_UUID: + f_gen_ << indent() << "o_prot.write_uuid(&" + type_var + ")?;" << endl; + return; case t_base_type::TYPE_BOOL: f_gen_ << indent() << "o_prot.write_bool(" + type_var + ")?;" << endl; return; @@ -1556,37 +1537,36 @@ void t_rs_generator::render_type_sync_write(const string &type_var, bool type_va throw "compiler error: unhandled type"; } } else if (ttype->is_typedef()) { - t_typedef* ttypedef = (t_typedef*) ttype; + t_typedef* ttypedef = (t_typedef*)ttype; render_type_sync_write(type_var, type_var_is_ref, ttypedef->get_type()); return; } else if (ttype->is_enum() || ttype->is_struct() || ttype->is_xception()) { f_gen_ << indent() << type_var + ".write_to_out_protocol(o_prot)?;" << endl; return; } else if (ttype->is_map()) { - render_map_sync_write(type_var, type_var_is_ref, (t_map *) ttype); + render_map_sync_write(type_var, type_var_is_ref, (t_map*)ttype); return; } else if (ttype->is_set()) { - render_set_sync_write(type_var, type_var_is_ref, (t_set *) ttype); + render_set_sync_write(type_var, type_var_is_ref, (t_set*)ttype); return; } else if (ttype->is_list()) { - render_list_sync_write(type_var, type_var_is_ref, (t_list *) ttype); + render_list_sync_write(type_var, type_var_is_ref, (t_list*)ttype); return; } throw "cannot write unsupported type " + ttype->get_name(); } -void t_rs_generator::render_list_sync_write(const string &list_var, bool list_var_is_ref, t_list *tlist) { +void t_rs_generator::render_list_sync_write(const string& list_var, + bool list_var_is_ref, + t_list* tlist) { t_type* elem_type = tlist->get_elem_type(); - f_gen_ - << indent() - << "o_prot.write_list_begin(" - << "&TListIdentifier::new(" - << to_rust_field_type_enum(elem_type) << ", " - << list_var << ".len() as i32" << ")" - << ")?;" - << endl; + f_gen_ << indent() << "o_prot.write_list_begin(" + << "&TListIdentifier::new(" << to_rust_field_type_enum(elem_type) << ", " << list_var + << ".len() as i32" + << ")" + << ")?;" << endl; string ref(list_var_is_ref ? "" : "&"); f_gen_ << indent() << "for e in " << ref << list_var << " {" << endl; @@ -1597,17 +1577,16 @@ void t_rs_generator::render_list_sync_write(const string &list_var, bool list_va f_gen_ << indent() << "o_prot.write_list_end()?;" << endl; } -void t_rs_generator::render_set_sync_write(const string &set_var, bool set_var_is_ref, t_set *tset) { +void t_rs_generator::render_set_sync_write(const string& set_var, + bool set_var_is_ref, + t_set* tset) { t_type* elem_type = tset->get_elem_type(); - f_gen_ - << indent() - << "o_prot.write_set_begin(" - << "&TSetIdentifier::new(" - << to_rust_field_type_enum(elem_type) << ", " - << set_var << ".len() as i32" << ")" - << ")?;" - << endl; + f_gen_ << indent() << "o_prot.write_set_begin(" + << "&TSetIdentifier::new(" << to_rust_field_type_enum(elem_type) << ", " << set_var + << ".len() as i32" + << ")" + << ")?;" << endl; string ref(set_var_is_ref ? "" : "&"); f_gen_ << indent() << "for e in " << ref << set_var << " {" << endl; @@ -1618,19 +1597,16 @@ void t_rs_generator::render_set_sync_write(const string &set_var, bool set_var_i f_gen_ << indent() << "o_prot.write_set_end()?;" << endl; } -void t_rs_generator::render_map_sync_write(const string &map_var, bool map_var_is_ref, t_map *tmap) { +void t_rs_generator::render_map_sync_write(const string& map_var, + bool map_var_is_ref, + t_map* tmap) { t_type* key_type = tmap->get_key_type(); t_type* val_type = tmap->get_val_type(); - f_gen_ - << indent() - << "o_prot.write_map_begin(" - << "&TMapIdentifier::new(" - << to_rust_field_type_enum(key_type) << ", " - << to_rust_field_type_enum(val_type) << ", " - << map_var << ".len() as i32)" - << ")?;" - << endl; + f_gen_ << indent() << "o_prot.write_map_begin(" + << "&TMapIdentifier::new(" << to_rust_field_type_enum(key_type) << ", " + << to_rust_field_type_enum(val_type) << ", " << map_var << ".len() as i32)" + << ")?;" << endl; string ref(map_var_is_ref ? "" : "&"); f_gen_ << indent() << "for (k, v) in " << ref << map_var << " {" << endl; @@ -1670,14 +1646,12 @@ bool t_rs_generator::needs_deref_on_container_write(t_type* ttype) { // //----------------------------------------------------------------------------- -void t_rs_generator::render_struct_sync_read( - const string &struct_name, - t_struct *tstruct, t_rs_generator::e_struct_type struct_type -) { - f_gen_ - << indent() - << "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<" << struct_name << "> {" - << endl; +void t_rs_generator::render_struct_sync_read(const string& struct_name, + t_struct* tstruct, + t_rs_generator::e_struct_type struct_type) { + f_gen_ << indent() + << "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<" + << struct_name << "> {" << endl; indent_up(); @@ -1690,16 +1664,14 @@ void t_rs_generator::render_struct_sync_read( t_field* member = (*members_iter); t_field::e_req member_req = actual_field_req(member, struct_type); - f_gen_ - << indent() - << "let mut " << struct_field_read_temp_variable(member) - << ": Option<" << to_rust_type(member->get_type()) << "> = "; - if (member_req == t_field::T_OPT_IN_REQ_OUT) { - f_gen_ << opt_in_req_out_value(member->get_type()) << ";"; - } else { - f_gen_ << "None;"; - } - f_gen_ << endl; + f_gen_ << indent() << "let mut " << struct_field_read_temp_variable(member) << ": Option<" + << to_rust_type(member->get_type()) << "> = "; + if (member_req == t_field::T_OPT_IN_REQ_OUT) { + f_gen_ << opt_in_req_out_value(member->get_type()) << ";"; + } else { + f_gen_ << "None;"; + } + f_gen_ << endl; } // now loop through the fields we've received @@ -1746,7 +1718,7 @@ void t_rs_generator::render_struct_sync_read( f_gen_ << indent() << "i_prot.read_field_end()?;" << endl; indent_down(); - f_gen_ << indent() << "}" << endl; // finish loop + f_gen_ << indent() << "}" << endl; // finish loop f_gen_ << indent() << "i_prot.read_struct_end()?;" << endl; // read message footer from the wire // verify that all required fields exist @@ -1754,13 +1726,10 @@ void t_rs_generator::render_struct_sync_read( t_field* tfield = (*members_iter); t_field::e_req req = actual_field_req(tfield, struct_type); if (!is_optional(req)) { - f_gen_ - << indent() - << "verify_required_field_exists(" - << "\"" << struct_name << "." << rust_field_name(tfield) << "\"" - << ", " - << "&" << struct_field_read_temp_variable(tfield) - << ")?;" << endl; + f_gen_ << indent() << "verify_required_field_exists(" + << "\"" << struct_name << "." << rust_field_name(tfield) << "\"" + << ", " + << "&" << struct_field_read_temp_variable(tfield) << ")?;" << endl; } } @@ -1779,14 +1748,10 @@ void t_rs_generator::render_struct_sync_read( if (is_optional(req)) { f_gen_ << indent() << field_name << ": " << field_key << "," << endl; } else { - f_gen_ - << indent() - << field_name - << ": " - << field_key - << ".expect(\"auto-generated code should have checked for presence of required fields\")" - << "," - << endl; + f_gen_ << indent() << field_name << ": " << field_key + << ".expect(\"auto-generated code should have checked for presence of required " + "fields\")" + << "," << endl; } } @@ -1801,11 +1766,10 @@ void t_rs_generator::render_struct_sync_read( f_gen_ << indent() << "}" << endl; } -void t_rs_generator::render_union_sync_read(const string &union_name, t_struct *tstruct) { - f_gen_ - << indent() - << "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<" << union_name << "> {" - << endl; +void t_rs_generator::render_union_sync_read(const string& union_name, t_struct* tstruct) { + f_gen_ << indent() + << "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<" + << union_name << "> {" << endl; indent_up(); // create temporary variables to hold the @@ -1842,10 +1806,8 @@ void t_rs_generator::render_union_sync_read(const string &union_name, t_struct * render_type_sync_read("val", member->get_type()); f_gen_ << indent() << "if ret.is_none() {" << endl; indent_up(); - f_gen_ - << indent() - << "ret = Some(" << union_name << "::" << rust_union_field_name(member) << "(val));" - << endl; + f_gen_ << indent() << "ret = Some(" << union_name << "::" << rust_union_field_name(member) + << "(val));" << endl; indent_down(); f_gen_ << indent() << "}" << endl; f_gen_ << indent() << "received_field_count += 1;" << endl; @@ -1865,27 +1827,19 @@ void t_rs_generator::render_union_sync_read(const string &union_name, t_struct * f_gen_ << indent() << "};" << endl; // finish match f_gen_ << indent() << "i_prot.read_field_end()?;" << endl; indent_down(); - f_gen_ << indent() << "}" << endl; // finish loop + f_gen_ << indent() << "}" << endl; // finish loop f_gen_ << indent() << "i_prot.read_struct_end()?;" << endl; // finish reading message from wire // return the value or an error f_gen_ << indent() << "if received_field_count == 0 {" << endl; indent_up(); - render_thrift_error( - "Protocol", - "ProtocolError", - "ProtocolErrorKind::InvalidData", - "\"received empty union from remote " + union_name + "\"" - ); + render_thrift_error("Protocol", "ProtocolError", "ProtocolErrorKind::InvalidData", + "\"received empty union from remote " + union_name + "\""); indent_down(); f_gen_ << indent() << "} else if received_field_count > 1 {" << endl; indent_up(); - render_thrift_error( - "Protocol", - "ProtocolError", - "ProtocolErrorKind::InvalidData", - "\"received multiple fields for union from remote " + union_name + "\"" - ); + render_thrift_error("Protocol", "ProtocolError", "ProtocolErrorKind::InvalidData", + "\"received multiple fields for union from remote " + union_name + "\""); indent_down(); f_gen_ << indent() << "} else {" << endl; indent_up(); @@ -1898,7 +1852,7 @@ void t_rs_generator::render_union_sync_read(const string &union_name, t_struct * } // Construct the rust representation of all supported types from the wire. -void t_rs_generator::render_type_sync_read(const string &type_var, t_type *ttype, bool is_boxed) { +void t_rs_generator::render_type_sync_read(const string& type_var, t_type* ttype, bool is_boxed) { if (ttype->is_base_type()) { t_base_type* tbase_type = (t_base_type*)ttype; switch (tbase_type->get_base()) { @@ -1911,6 +1865,9 @@ void t_rs_generator::render_type_sync_read(const string &type_var, t_type *ttype f_gen_ << indent() << "let " << type_var << " = i_prot.read_string()?;" << endl; } return; + case t_base_type::TYPE_UUID: + f_gen_ << indent() << "let " << type_var << " = i_prot.read_uuid()?;" << endl; + return; case t_base_type::TYPE_BOOL: f_gen_ << indent() << "let " << type_var << " = i_prot.read_bool()?;" << endl; return; @@ -1927,7 +1884,8 @@ void t_rs_generator::render_type_sync_read(const string &type_var, t_type *ttype f_gen_ << indent() << "let " << type_var << " = i_prot.read_i64()?;" << endl; return; case t_base_type::TYPE_DOUBLE: - f_gen_ << indent() << "let " << type_var << " = OrderedFloat::from(i_prot.read_double()?);" << endl; + f_gen_ << indent() << "let " << type_var << " = OrderedFloat::from(i_prot.read_double()?);" + << endl; return; default: throw "compiler error: unhandled type"; @@ -1947,19 +1905,16 @@ void t_rs_generator::render_type_sync_read(const string &type_var, t_type *ttype } else if (ttype->is_enum() || ttype->is_struct() || ttype->is_xception()) { string read_call(to_rust_type(ttype) + "::read_from_in_protocol(i_prot)?"); read_call = is_boxed ? "Box::new(" + read_call + ")" : read_call; - f_gen_ - << indent() - << "let " << type_var << " = " << read_call << ";" - << endl; + f_gen_ << indent() << "let " << type_var << " = " << read_call << ";" << endl; return; } else if (ttype->is_map()) { - render_map_sync_read((t_map *) ttype, type_var); + render_map_sync_read((t_map*)ttype, type_var); return; } else if (ttype->is_set()) { - render_set_sync_read((t_set *) ttype, type_var); + render_set_sync_read((t_set*)ttype, type_var); return; } else if (ttype->is_list()) { - render_list_sync_read((t_list *) ttype, type_var); + render_list_sync_read((t_list*)ttype, type_var); return; } @@ -1967,15 +1922,12 @@ void t_rs_generator::render_type_sync_read(const string &type_var, t_type *ttype } // Construct the rust representation of a list from the wire. -void t_rs_generator::render_list_sync_read(t_list *tlist, const string &list_var) { +void t_rs_generator::render_list_sync_read(t_list* tlist, const string& list_var) { t_type* elem_type = tlist->get_elem_type(); f_gen_ << indent() << "let list_ident = i_prot.read_list_begin()?;" << endl; - f_gen_ - << indent() - << "let mut " << list_var << ": " << to_rust_type((t_type*) tlist) - << " = Vec::with_capacity(list_ident.size as usize);" - << endl; + f_gen_ << indent() << "let mut " << list_var << ": " << to_rust_type((t_type*)tlist) + << " = Vec::with_capacity(list_ident.size as usize);" << endl; f_gen_ << indent() << "for _ in 0..list_ident.size {" << endl; indent_up(); @@ -1991,15 +1943,12 @@ void t_rs_generator::render_list_sync_read(t_list *tlist, const string &list_var } // Construct the rust representation of a set from the wire. -void t_rs_generator::render_set_sync_read(t_set *tset, const string &set_var) { +void t_rs_generator::render_set_sync_read(t_set* tset, const string& set_var) { t_type* elem_type = tset->get_elem_type(); f_gen_ << indent() << "let set_ident = i_prot.read_set_begin()?;" << endl; - f_gen_ - << indent() - << "let mut " << set_var << ": " << to_rust_type((t_type*) tset) - << " = BTreeSet::new();" - << endl; + f_gen_ << indent() << "let mut " << set_var << ": " << to_rust_type((t_type*)tset) + << " = BTreeSet::new();" << endl; f_gen_ << indent() << "for _ in 0..set_ident.size {" << endl; indent_up(); @@ -2015,16 +1964,13 @@ void t_rs_generator::render_set_sync_read(t_set *tset, const string &set_var) { } // Construct the rust representation of a map from the wire. -void t_rs_generator::render_map_sync_read(t_map *tmap, const string &map_var) { +void t_rs_generator::render_map_sync_read(t_map* tmap, const string& map_var) { t_type* key_type = tmap->get_key_type(); t_type* val_type = tmap->get_val_type(); f_gen_ << indent() << "let map_ident = i_prot.read_map_begin()?;" << endl; - f_gen_ - << indent() - << "let mut " << map_var << ": " << to_rust_type((t_type*) tmap) - << " = BTreeMap::new();" - << endl; + f_gen_ << indent() << "let mut " << map_var << ": " << to_rust_type((t_type*)tmap) + << " = BTreeMap::new();" << endl; f_gen_ << indent() << "for _ in 0..map_ident.size {" << endl; indent_up(); @@ -2033,7 +1979,8 @@ void t_rs_generator::render_map_sync_read(t_map *tmap, const string &map_var) { render_type_sync_read(key_elem_var, key_type); string val_elem_var = tmp("map_val_"); render_type_sync_read(val_elem_var, val_type); - f_gen_ << indent() << map_var << ".insert(" << key_elem_var << ", " << val_elem_var << ");" << endl; + f_gen_ << indent() << map_var << ".insert(" << key_elem_var << ", " << val_elem_var << ");" + << endl; indent_down(); @@ -2071,7 +2018,7 @@ void t_rs_generator::render_service_call_structs(t_service* tservice) { // that's passed over the wire, so, generate the struct // for that too. Note that this result struct *also* // contains the exceptions as well - for(func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { + for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { t_function* tfunc = (*func_iter); render_service_call_args_struct(tfunc); if (!tfunc->is_oneway()) { @@ -2088,30 +2035,32 @@ void t_rs_generator::render_sync_client(t_service* tservice) { render_sync_client_marker_trait(tservice); render_sync_client_definition_and_impl(client_impl_name); render_sync_client_tthriftclient_impl(client_impl_name); - render_sync_client_marker_trait_impls(tservice, client_impl_name); f_gen_ << endl; + render_sync_client_marker_trait_impls(tservice, client_impl_name); + f_gen_ << endl; render_sync_client_process_impl(tservice); } -void t_rs_generator::render_sync_client_trait(t_service *tservice) { +void t_rs_generator::render_sync_client_trait(t_service* tservice) { string extension = ""; if (tservice->get_extends()) { t_service* extends = tservice->get_extends(); extension = " : " + rust_namespace(extends) + rust_sync_client_trait_name(extends); } - render_rustdoc((t_doc*) tservice); + render_rustdoc((t_doc*)tservice); f_gen_ << "pub trait " << rust_sync_client_trait_name(tservice) << extension << " {" << endl; indent_up(); const std::vector functions = tservice->get_functions(); std::vector::const_iterator func_iter; - for(func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { + for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { t_function* tfunc = (*func_iter); string func_name = service_call_client_function_name(tfunc); string func_args = rust_sync_service_call_declaration(tfunc, true); string func_return = to_rust_type(tfunc->get_returntype()); - render_rustdoc((t_doc*) tfunc); - f_gen_ << indent() << "fn " << func_name << func_args << " -> thrift::Result<" << func_return << ">;" << endl; + render_rustdoc((t_doc*)tfunc); + f_gen_ << indent() << "fn " << func_name << func_args << " -> thrift::Result<" << func_return + << ">;" << endl; } indent_down(); @@ -2119,24 +2068,17 @@ void t_rs_generator::render_sync_client_trait(t_service *tservice) { f_gen_ << endl; } -void t_rs_generator::render_sync_client_marker_trait(t_service *tservice) { - f_gen_ << indent() << "pub trait " << rust_sync_client_marker_trait_name(tservice) << " {}" << endl; +void t_rs_generator::render_sync_client_marker_trait(t_service* tservice) { + f_gen_ << indent() << "pub trait " << rust_sync_client_marker_trait_name(tservice) << " {}" + << endl; f_gen_ << endl; } -void t_rs_generator::render_sync_client_marker_trait_impls(t_service *tservice, const string &impl_struct_name) { - f_gen_ - << indent() - << "impl " - << SYNC_CLIENT_GENERIC_BOUND_VARS - << " " - << rust_namespace(tservice) << rust_sync_client_marker_trait_name(tservice) - << " for " - << impl_struct_name << SYNC_CLIENT_GENERIC_BOUND_VARS - << " " - << SYNC_CLIENT_GENERIC_BOUNDS - << " {}" - << endl; +void t_rs_generator::render_sync_client_marker_trait_impls(t_service* tservice, + const string& impl_struct_name) { + f_gen_ << indent() << "impl " << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << rust_namespace(tservice) + << rust_sync_client_marker_trait_name(tservice) << " for " << impl_struct_name + << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS << " {}" << endl; t_service* extends = tservice->get_extends(); if (extends) { @@ -2147,14 +2089,8 @@ void t_rs_generator::render_sync_client_marker_trait_impls(t_service *tservice, void t_rs_generator::render_sync_client_definition_and_impl(const string& client_impl_name) { // render the definition for the client struct - f_gen_ - << "pub struct " - << client_impl_name - << SYNC_CLIENT_GENERIC_BOUND_VARS - << " " - << SYNC_CLIENT_GENERIC_BOUNDS - << " {" - << endl; + f_gen_ << "pub struct " << client_impl_name << SYNC_CLIENT_GENERIC_BOUND_VARS << " " + << SYNC_CLIENT_GENERIC_BOUNDS << " {" << endl; indent_up(); f_gen_ << indent() << "_i_prot: IP," << endl; f_gen_ << indent() << "_o_prot: OP," << endl; @@ -2165,16 +2101,8 @@ void t_rs_generator::render_sync_client_definition_and_impl(const string& client // render the struct implementation // this includes the new() function as well as the helper send/recv methods for each service call - f_gen_ - << "impl " - << SYNC_CLIENT_GENERIC_BOUND_VARS - << " " - << client_impl_name - << SYNC_CLIENT_GENERIC_BOUND_VARS - << " " - << SYNC_CLIENT_GENERIC_BOUNDS - << " {" - << endl; + f_gen_ << "impl " << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << client_impl_name + << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS << " {" << endl; indent_up(); render_sync_client_lifecycle_functions(client_impl_name); indent_down(); @@ -2183,45 +2111,32 @@ void t_rs_generator::render_sync_client_definition_and_impl(const string& client } void t_rs_generator::render_sync_client_lifecycle_functions(const string& client_struct) { - f_gen_ - << indent() - << "pub fn new(input_protocol: IP, output_protocol: OP) -> " - << client_struct - << SYNC_CLIENT_GENERIC_BOUND_VARS - << " {" - << endl; + f_gen_ << indent() << "pub fn new(input_protocol: IP, output_protocol: OP) -> " << client_struct + << SYNC_CLIENT_GENERIC_BOUND_VARS << " {" << endl; indent_up(); - f_gen_ - << indent() - << client_struct - << " { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }" - << endl; + f_gen_ << indent() << client_struct + << " { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }" << endl; indent_down(); f_gen_ << indent() << "}" << endl; } -void t_rs_generator::render_sync_client_tthriftclient_impl(const string &client_impl_name) { - f_gen_ - << indent() - << "impl " - << SYNC_CLIENT_GENERIC_BOUND_VARS - << " TThriftClient for " - << client_impl_name - << SYNC_CLIENT_GENERIC_BOUND_VARS - << " " - << SYNC_CLIENT_GENERIC_BOUNDS - << " {" << endl; - indent_up(); - - f_gen_ << indent() << "fn i_prot_mut(&mut self) -> &mut dyn TInputProtocol { &mut self._i_prot }" << endl; - f_gen_ << indent() << "fn o_prot_mut(&mut self) -> &mut dyn TOutputProtocol { &mut self._o_prot }" << endl; +void t_rs_generator::render_sync_client_tthriftclient_impl(const string& client_impl_name) { + f_gen_ << indent() << "impl " << SYNC_CLIENT_GENERIC_BOUND_VARS << " TThriftClient for " + << client_impl_name << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS + << " {" << endl; + indent_up(); + + f_gen_ << indent() << "fn i_prot_mut(&mut self) -> &mut dyn TInputProtocol { &mut self._i_prot }" + << endl; + f_gen_ << indent() << "fn o_prot_mut(&mut self) -> &mut dyn TOutputProtocol { &mut self._o_prot }" + << endl; f_gen_ << indent() << "fn sequence_number(&self) -> i32 { self._sequence_number }" << endl; - f_gen_ - << indent() - << "fn increment_sequence_number(&mut self) -> i32 { self._sequence_number += 1; self._sequence_number }" - << endl; + f_gen_ << indent() + << "fn increment_sequence_number(&mut self) -> i32 { self._sequence_number += 1; " + "self._sequence_number }" + << endl; indent_down(); f_gen_ << indent() << "}" << endl; @@ -2231,15 +2146,13 @@ void t_rs_generator::render_sync_client_tthriftclient_impl(const string &client_ void t_rs_generator::render_sync_client_process_impl(t_service* tservice) { string marker_extension = "" + sync_client_marker_traits_for_extension(tservice); - f_gen_ - << "impl " - << rust_sync_client_trait_name(tservice) - << " for C {" << endl; + f_gen_ << "impl " << rust_sync_client_trait_name(tservice) << " for C {" << endl; indent_up(); const std::vector functions = tservice->get_functions(); std::vector::const_iterator func_iter; - for(func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { + for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { t_function* func = (*func_iter); render_sync_send_recv_wrapper(func); } @@ -2249,12 +2162,13 @@ void t_rs_generator::render_sync_client_process_impl(t_service* tservice) { f_gen_ << endl; } -string t_rs_generator::sync_client_marker_traits_for_extension(t_service *tservice) { +string t_rs_generator::sync_client_marker_traits_for_extension(t_service* tservice) { string marker_extension; t_service* extends = tservice->get_extends(); if (extends) { - marker_extension = " + " + rust_namespace(extends) + rust_sync_client_marker_trait_name(extends); + marker_extension + = " + " + rust_namespace(extends) + rust_sync_client_marker_trait_name(extends); marker_extension = marker_extension + sync_client_marker_traits_for_extension(extends); } @@ -2267,11 +2181,8 @@ void t_rs_generator::render_sync_send_recv_wrapper(t_function* tfunc) { string func_call_args = rust_sync_service_call_invocation(tfunc); string func_return = to_rust_type(tfunc->get_returntype()); - f_gen_ - << indent() - << "fn " << func_name << func_decl_args << " -> thrift::Result<" << func_return - << "> {" - << endl; + f_gen_ << indent() << "fn " << func_name << func_decl_args << " -> thrift::Result<" << func_return + << "> {" << endl; indent_up(); f_gen_ << indent() << "(" << endl; @@ -2296,13 +2207,10 @@ void t_rs_generator::render_sync_send(t_function* tfunc) { // increment the sequence number and generate the call header string message_type = tfunc->is_oneway() ? "TMessageType::OneWay" : "TMessageType::Call"; f_gen_ << indent() << "self.increment_sequence_number();" << endl; - f_gen_ - << indent() - << "let message_ident = " - << "TMessageIdentifier::new(\"" << tfunc->get_name() << "\", " // note: use *original* name - << message_type << ", " - << "self.sequence_number());" - << endl; + f_gen_ << indent() << "let message_ident = " + << "TMessageIdentifier::new(\"" << tfunc->get_name() << "\", " // note: use *original* name + << message_type << ", " + << "self.sequence_number());" << endl; // pack the arguments into the containing struct that we'll write out over the wire // note that this struct is generated even if we have 0 args ostringstream struct_definition; @@ -2317,17 +2225,12 @@ void t_rs_generator::render_sync_send(t_function* tfunc) { if (struct_fields.size() > 0) { struct_fields = struct_fields.substr(0, struct_fields.size() - 2); // strip trailing comma } - f_gen_ - << indent() - << "let call_args = " - << service_call_args_struct_name(tfunc) - << " { " - << struct_fields - << " };" - << endl; + f_gen_ << indent() << "let call_args = " << service_call_args_struct_name(tfunc) << " { " + << struct_fields << " };" << endl; // write everything over the wire f_gen_ << indent() << "self.o_prot_mut().write_message_begin(&message_ident)?;" << endl; - f_gen_ << indent() << "call_args.write_to_out_protocol(self.o_prot_mut())?;" << endl; // written even if we have 0 args + f_gen_ << indent() << "call_args.write_to_out_protocol(self.o_prot_mut())?;" + << endl; // written even if we have 0 args f_gen_ << indent() << "self.o_prot_mut().write_message_end()?;" << endl; f_gen_ << indent() << "self.o_prot_mut().flush()" << endl; @@ -2340,18 +2243,28 @@ void t_rs_generator::render_sync_recv(t_function* tfunc) { indent_up(); f_gen_ << indent() << "let message_ident = self.i_prot_mut().read_message_begin()?;" << endl; - f_gen_ << indent() << "verify_expected_sequence_number(self.sequence_number(), message_ident.sequence_number)?;" << endl; - f_gen_ << indent() << "verify_expected_service_call(\"" << tfunc->get_name() <<"\", &message_ident.name)?;" << endl; // note: use *original* name + f_gen_ + << indent() + << "verify_expected_sequence_number(self.sequence_number(), message_ident.sequence_number)?;" + << endl; + f_gen_ << indent() << "verify_expected_service_call(\"" << tfunc->get_name() + << "\", &message_ident.name)?;" << endl; // note: use *original* name // FIXME: replace with a "try" block f_gen_ << indent() << "if message_ident.message_type == TMessageType::Exception {" << endl; indent_up(); - f_gen_ << indent() << "let remote_error = thrift::Error::read_application_error_from_in_protocol(self.i_prot_mut())?;" << endl; + f_gen_ << indent() + << "let remote_error = " + "thrift::Error::read_application_error_from_in_protocol(self.i_prot_mut())?;" + << endl; f_gen_ << indent() << "self.i_prot_mut().read_message_end()?;" << endl; f_gen_ << indent() << "return Err(thrift::Error::Application(remote_error))" << endl; indent_down(); f_gen_ << indent() << "}" << endl; - f_gen_ << indent() << "verify_expected_message_type(TMessageType::Reply, message_ident.message_type)?;" << endl; - f_gen_ << indent() << "let result = " << service_call_result_struct_name(tfunc) << "::read_from_in_protocol(self.i_prot_mut())?;" << endl; + f_gen_ << indent() + << "verify_expected_message_type(TMessageType::Reply, message_ident.message_type)?;" + << endl; + f_gen_ << indent() << "let result = " << service_call_result_struct_name(tfunc) + << "::read_from_in_protocol(self.i_prot_mut())?;" << endl; f_gen_ << indent() << "self.i_prot_mut().read_message_end()?;" << endl; f_gen_ << indent() << "result.ok_or()" << endl; @@ -2377,7 +2290,8 @@ string t_rs_generator::rust_sync_service_call_declaration(t_function* tfunc, boo return func_args.str(); } -string t_rs_generator::rust_sync_service_call_invocation(t_function* tfunc, const string& field_prefix) { +string t_rs_generator::rust_sync_service_call_invocation(t_function* tfunc, + const string& field_prefix) { ostringstream func_args; func_args << "("; @@ -2389,7 +2303,8 @@ string t_rs_generator::rust_sync_service_call_invocation(t_function* tfunc, cons return func_args.str(); } -string t_rs_generator::struct_to_declaration(t_struct* tstruct, t_rs_generator::e_struct_type struct_type) { +string t_rs_generator::struct_to_declaration(t_struct* tstruct, + t_rs_generator::e_struct_type struct_type) { ostringstream args; bool first_arg = true; @@ -2435,8 +2350,8 @@ string t_rs_generator::struct_to_invocation(t_struct* tstruct, const string& fie } void t_rs_generator::render_service_call_args_struct(t_function* tfunc) { - string args_struct_name(service_call_args_struct_name(tfunc)); - render_struct(args_struct_name, tfunc->get_arglist(), t_rs_generator::T_ARGS); + string args_struct_name(service_call_args_struct_name(tfunc)); + render_struct(args_struct_name, tfunc->get_arglist(), t_rs_generator::T_ARGS); } void t_rs_generator::render_service_call_result_value_struct(t_function* tfunc) { @@ -2452,7 +2367,8 @@ void t_rs_generator::render_service_call_result_value_struct(t_function* tfunc) t_struct* exceptions = tfunc->get_xceptions(); const vector& exception_types = exceptions->get_members(); vector::const_iterator exception_iter; - for(exception_iter = exception_types.begin(); exception_iter != exception_types.end(); ++exception_iter) { + for (exception_iter = exception_types.begin(); exception_iter != exception_types.end(); + ++exception_iter) { t_field* exception_type = *exception_iter; exception_type->set_req(t_field::T_OPTIONAL); result.append(exception_type); @@ -2467,13 +2383,13 @@ void t_rs_generator::render_service_call_result_value_struct(t_function* tfunc) // //----------------------------------------------------------------------------- -void t_rs_generator::render_sync_processor(t_service *tservice) { +void t_rs_generator::render_sync_processor(t_service* tservice) { render_type_comment(tservice->get_name() + " service processor"); // note: use *original* name render_sync_handler_trait(tservice); render_sync_processor_definition_and_impl(tservice); } -void t_rs_generator::render_sync_handler_trait(t_service *tservice) { +void t_rs_generator::render_sync_handler_trait(t_service* tservice) { string extension = ""; if (tservice->get_extends() != nullptr) { t_service* extends = tservice->get_extends(); @@ -2483,38 +2399,30 @@ void t_rs_generator::render_sync_handler_trait(t_service *tservice) { const std::vector functions = tservice->get_functions(); std::vector::const_iterator func_iter; - render_rustdoc((t_doc*) tservice); + render_rustdoc((t_doc*)tservice); f_gen_ << "pub trait " << rust_sync_handler_trait_name(tservice) << extension << " {" << endl; indent_up(); - for(func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { + for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { t_function* tfunc = (*func_iter); string func_name = service_call_handler_function_name(tfunc); string func_args = rust_sync_service_call_declaration(tfunc, false); string func_return = to_rust_type(tfunc->get_returntype()); - render_rustdoc((t_doc*) tfunc); - f_gen_ - << indent() - << "fn " - << func_name << func_args - << " -> thrift::Result<" << func_return << ">;" - << endl; + render_rustdoc((t_doc*)tfunc); + f_gen_ << indent() << "fn " << func_name << func_args << " -> thrift::Result<" << func_return + << ">;" << endl; } indent_down(); f_gen_ << indent() << "}" << endl; f_gen_ << endl; } -void t_rs_generator::render_sync_processor_definition_and_impl(t_service *tservice) { +void t_rs_generator::render_sync_processor_definition_and_impl(t_service* tservice) { string service_processor_name = rust_sync_processor_name(tservice); string handler_trait_name = rust_sync_handler_trait_name(tservice); // struct - f_gen_ - << indent() - << "pub struct " << service_processor_name - << " {" - << endl; + f_gen_ << indent() << "pub struct " << service_processor_name << " {" << endl; indent_up(); f_gen_ << indent() << "handler: H," << endl; indent_down(); @@ -2522,12 +2430,8 @@ void t_rs_generator::render_sync_processor_definition_and_impl(t_service *tservi f_gen_ << endl; // delegating impl - f_gen_ - << indent() - << "impl " - << service_processor_name - << " {" - << endl; + f_gen_ << indent() << "impl " << service_processor_name + << " {" << endl; indent_up(); f_gen_ << indent() << "pub fn new(handler: H) -> " << service_processor_name << " {" << endl; indent_up(); @@ -2552,7 +2456,7 @@ void t_rs_generator::render_sync_processor_definition_and_impl(t_service *tservi vector functions = tservice->get_functions(); vector::iterator func_iter; - for(func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { + for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { t_function* tfunc = (*func_iter); render_sync_process_function(tfunc, handler_trait_name); } @@ -2562,40 +2466,33 @@ void t_rs_generator::render_sync_processor_definition_and_impl(t_service *tservi f_gen_ << endl; // processor impl - f_gen_ - << indent() - << "impl TProcessor for " - << service_processor_name - << " {" - << endl; + f_gen_ << indent() << "impl TProcessor for " + << service_processor_name << " {" << endl; indent_up(); - f_gen_ - << indent() - << "fn process(&self, i_prot: &mut dyn TInputProtocol, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {" - << endl; + f_gen_ << indent() + << "fn process(&self, i_prot: &mut dyn TInputProtocol, o_prot: &mut dyn TOutputProtocol) " + "-> thrift::Result<()> {" + << endl; indent_up(); f_gen_ << indent() << "let message_ident = i_prot.read_message_begin()?;" << endl; - f_gen_ << indent() << "let res = match &*message_ident.name {" << endl; // [sigh] explicit deref coercion + f_gen_ << indent() << "let res = match &*message_ident.name {" + << endl; // [sigh] explicit deref coercion indent_up(); render_process_match_statements(tservice); f_gen_ << indent() << "method => {" << endl; indent_up(); - render_thrift_error( - "Application", - "ApplicationError", - "ApplicationErrorKind::UnknownMethod", - "format!(\"unknown method {}\", method)" - ); + render_thrift_error("Application", "ApplicationError", "ApplicationErrorKind::UnknownMethod", + "format!(\"unknown method {}\", method)"); indent_down(); f_gen_ << indent() << "}," << endl; indent_down(); f_gen_ << indent() << "};" << endl; - f_gen_ << indent() << "thrift::server::handle_process_result(&message_ident, res, o_prot)" << endl; + f_gen_ << indent() << "thrift::server::handle_process_result(&message_ident, res, o_prot)" + << endl; indent_down(); f_gen_ << indent() << "}" << endl; @@ -2605,36 +2502,27 @@ void t_rs_generator::render_sync_processor_definition_and_impl(t_service *tservi f_gen_ << endl; } -void t_rs_generator::render_sync_process_delegation_functions(t_service *tservice) { +void t_rs_generator::render_sync_process_delegation_functions(t_service* tservice) { string actual_processor(rust_namespace(tservice) + rust_sync_processor_impl_name(tservice)); vector functions = tservice->get_functions(); vector::iterator func_iter; - for(func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { + for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { t_function* tfunc = (*func_iter); string function_name("process_" + rust_snake_case(tfunc->get_name())); - f_gen_ - << indent() - << "fn " << function_name - << "(&self, " - << "incoming_sequence_number: i32, " - << "i_prot: &mut dyn TInputProtocol, " - << "o_prot: &mut dyn TOutputProtocol) " - << "-> thrift::Result<()> {" - << endl; + f_gen_ << indent() << "fn " << function_name << "(&self, " + << "incoming_sequence_number: i32, " + << "i_prot: &mut dyn TInputProtocol, " + << "o_prot: &mut dyn TOutputProtocol) " + << "-> thrift::Result<()> {" << endl; indent_up(); - f_gen_ - << indent() - << actual_processor - << "::" << function_name - << "(" - << "&self.handler, " - << "incoming_sequence_number, " - << "i_prot, " - << "o_prot" - << ")" - << endl; + f_gen_ << indent() << actual_processor << "::" << function_name << "(" + << "&self.handler, " + << "incoming_sequence_number, " + << "i_prot, " + << "o_prot" + << ")" << endl; indent_down(); f_gen_ << indent() << "}" << endl; @@ -2649,15 +2537,13 @@ void t_rs_generator::render_sync_process_delegation_functions(t_service *tservic void t_rs_generator::render_process_match_statements(t_service* tservice) { vector functions = tservice->get_functions(); vector::iterator func_iter; - for(func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { + for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { t_function* tfunc = (*func_iter); - f_gen_ << indent() << "\"" << tfunc->get_name() << "\"" << " => {" << endl; // note: use *original* name + f_gen_ << indent() << "\"" << tfunc->get_name() << "\"" + << " => {" << endl; // note: use *original* name indent_up(); - f_gen_ - << indent() - << "self.process_" << rust_snake_case(tfunc->get_name()) - << "(message_ident.sequence_number, i_prot, o_prot)" - << endl; + f_gen_ << indent() << "self.process_" << rust_snake_case(tfunc->get_name()) + << "(message_ident.sequence_number, i_prot, o_prot)" << endl; indent_down(); f_gen_ << indent() << "}," << endl; } @@ -2668,7 +2554,7 @@ void t_rs_generator::render_process_match_statements(t_service* tservice) { } } -void t_rs_generator::render_sync_process_function(t_function *tfunc, const string &handler_type) { +void t_rs_generator::render_sync_process_function(t_function* tfunc, const string& handler_type) { string sequence_number_param("incoming_sequence_number"); string output_protocol_param("o_prot"); @@ -2677,40 +2563,26 @@ void t_rs_generator::render_sync_process_function(t_function *tfunc, const strin output_protocol_param = "_"; } - f_gen_ - << indent() - << "pub fn process_" << rust_snake_case(tfunc->get_name()) - << "" - << "(handler: &H, " - << sequence_number_param << ": i32, " - << "i_prot: &mut dyn TInputProtocol, " - << output_protocol_param << ": &mut dyn TOutputProtocol) " - << "-> thrift::Result<()> {" - << endl; + f_gen_ << indent() << "pub fn process_" << rust_snake_case(tfunc->get_name()) + << "" + << "(handler: &H, " << sequence_number_param << ": i32, " + << "i_prot: &mut dyn TInputProtocol, " << output_protocol_param + << ": &mut dyn TOutputProtocol) " + << "-> thrift::Result<()> {" << endl; indent_up(); // *always* read arguments from the input protocol - f_gen_ - << indent() - << "let " - << (has_non_void_args(tfunc) ? "args" : "_") - << " = " - << service_call_args_struct_name(tfunc) - << "::read_from_in_protocol(i_prot)?;" - << endl; + f_gen_ << indent() << "let " << (has_non_void_args(tfunc) ? "args" : "_") << " = " + << service_call_args_struct_name(tfunc) << "::read_from_in_protocol(i_prot)?;" << endl; - f_gen_ - << indent() - << "match handler." - << service_call_handler_function_name(tfunc) - << rust_sync_service_call_invocation(tfunc, "args.") - << " {" - << endl; // start match + f_gen_ << indent() << "match handler." << service_call_handler_function_name(tfunc) + << rust_sync_service_call_invocation(tfunc, "args.") << " {" << endl; // start match indent_up(); // handler succeeded - string handler_return_variable = tfunc->is_oneway() || tfunc->get_returntype()->is_void() ? "_" : "handler_return"; + string handler_return_variable + = tfunc->is_oneway() || tfunc->get_returntype()->is_void() ? "_" : "handler_return"; f_gen_ << indent() << "Ok(" << handler_return_variable << ") => {" << endl; indent_up(); render_sync_handler_succeeded(tfunc); @@ -2730,33 +2602,31 @@ void t_rs_generator::render_sync_process_function(t_function *tfunc, const strin f_gen_ << indent() << "}" << endl; // end function } -void t_rs_generator::render_sync_handler_succeeded(t_function *tfunc) { +void t_rs_generator::render_sync_handler_succeeded(t_function* tfunc) { if (tfunc->is_oneway()) { f_gen_ << indent() << "Ok(())" << endl; } else { - f_gen_ - << indent() - << "let message_ident = TMessageIdentifier::new(" - << "\"" << tfunc->get_name() << "\", " // note: use *original* name - << "TMessageType::Reply, " - << "incoming_sequence_number);" - << endl; + f_gen_ << indent() << "let message_ident = TMessageIdentifier::new(" + << "\"" << tfunc->get_name() << "\", " // note: use *original* name + << "TMessageType::Reply, " + << "incoming_sequence_number);" << endl; f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << endl; - f_gen_ << indent() << "let ret = " << handler_successful_return_struct(tfunc) <<";" << endl; + f_gen_ << indent() << "let ret = " << handler_successful_return_struct(tfunc) << ";" << endl; f_gen_ << indent() << "ret.write_to_out_protocol(o_prot)?;" << endl; f_gen_ << indent() << "o_prot.write_message_end()?;" << endl; f_gen_ << indent() << "o_prot.flush()" << endl; } } -void t_rs_generator::render_sync_handler_failed(t_function *tfunc) { +void t_rs_generator::render_sync_handler_failed(t_function* tfunc) { string err_var("e"); f_gen_ << indent() << "match " << err_var << " {" << endl; indent_up(); // if there are any user-defined exceptions for this service call handle them first - if (tfunc->get_xceptions() != nullptr && tfunc->get_xceptions()->get_sorted_members().size() > 0) { + if (tfunc->get_xceptions() != nullptr + && tfunc->get_xceptions()->get_sorted_members().size() > 0) { string user_err_var("usr_err"); f_gen_ << indent() << "thrift::Error::User(" << user_err_var << ") => {" << endl; indent_up(); @@ -2784,7 +2654,7 @@ void t_rs_generator::render_sync_handler_failed(t_function *tfunc) { f_gen_ << indent() << "}" << endl; } -void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function *tfunc) { +void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function* tfunc) { if (tfunc->get_xceptions() == nullptr || tfunc->get_xceptions()->get_sorted_members().empty()) { throw "cannot render user exception branches if no user exceptions defined"; } @@ -2799,13 +2669,12 @@ void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function string if_statement(branches_rendered == 0 ? "if usr_err" : "} else if usr_err"); string exception_type(to_rust_type(xception_field->get_type())); - f_gen_ << indent() << if_statement << ".downcast_ref::<" << exception_type << ">().is_some() {" << endl; + f_gen_ << indent() << if_statement << ".downcast_ref::<" << exception_type << ">().is_some() {" + << endl; indent_up(); - f_gen_ - << indent() - << "let err = usr_err.downcast::<" << exception_type << ">().expect(\"downcast already checked\");" - << endl; + f_gen_ << indent() << "let err = usr_err.downcast::<" << exception_type + << ">().expect(\"downcast already checked\");" << endl; // render the members of the return struct ostringstream members; @@ -2816,7 +2685,8 @@ void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function } vector::const_iterator xception_members_iter; - for(xception_members_iter = txceptions.begin(); xception_members_iter != txceptions.end(); ++xception_members_iter) { + for (xception_members_iter = txceptions.begin(); xception_members_iter != txceptions.end(); + ++xception_members_iter) { t_field* member = (*xception_members_iter); string member_name(rust_field_name(member)); if (member == xception_field) { @@ -2830,21 +2700,14 @@ void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function member_string.replace(member_string.size() - 2, 2, " "); // trim trailing comma // now write out the return struct - f_gen_ - << indent() - << "let ret_err = " - << service_call_result_struct_name(tfunc) - << "{ " << member_string << "};" - << endl; - - f_gen_ - << indent() - << "let message_ident = " - << "TMessageIdentifier::new(" - << "\"" << tfunc->get_name() << "\", " // note: use *original* name - << "TMessageType::Reply, " - << "incoming_sequence_number);" - << endl; + f_gen_ << indent() << "let ret_err = " << service_call_result_struct_name(tfunc) << "{ " + << member_string << "};" << endl; + + f_gen_ << indent() << "let message_ident = " + << "TMessageIdentifier::new(" + << "\"" << tfunc->get_name() << "\", " // note: use *original* name + << "TMessageType::Reply, " + << "incoming_sequence_number);" << endl; f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << endl; f_gen_ << indent() << "ret_err.write_to_out_protocol(o_prot)?;" << endl; f_gen_ << indent() << "o_prot.write_message_end()?;" << endl; @@ -2863,7 +2726,8 @@ void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function f_gen_ << indent() << "let ret_err = {" << endl; indent_up(); - render_thrift_error_struct("ApplicationError", "ApplicationErrorKind::Unknown", "usr_err.to_string()"); + render_thrift_error_struct("ApplicationError", "ApplicationErrorKind::Unknown", + "usr_err.to_string()"); indent_down(); f_gen_ << indent() << "};" << endl; render_sync_handler_send_exception_response(tfunc, "ret_err"); @@ -2873,9 +2737,8 @@ void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function } void t_rs_generator::render_sync_handler_failed_application_exception_branch( - t_function *tfunc, - const string &app_err_var -) { + t_function* tfunc, + const string& app_err_var) { if (tfunc->is_oneway()) { f_gen_ << indent() << "Err(thrift::Error::Application(" << app_err_var << "))" << endl; } else { @@ -2883,7 +2746,7 @@ void t_rs_generator::render_sync_handler_failed_application_exception_branch( } } -void t_rs_generator::render_sync_handler_failed_default_exception_branch(t_function *tfunc) { +void t_rs_generator::render_sync_handler_failed_default_exception_branch(t_function* tfunc) { f_gen_ << indent() << "let ret_err = {" << endl; indent_up(); render_thrift_error_struct("ApplicationError", "ApplicationErrorKind::Unknown", "e.to_string()"); @@ -2896,16 +2759,15 @@ void t_rs_generator::render_sync_handler_failed_default_exception_branch(t_funct } } -void t_rs_generator::render_sync_handler_send_exception_response(t_function *tfunc, const string &err_var) { - f_gen_ - << indent() - << "let message_ident = TMessageIdentifier::new(" - << "\"" << tfunc->get_name() << "\", " // note: use *original* name - << "TMessageType::Exception, " - << "incoming_sequence_number);" - << endl; +void t_rs_generator::render_sync_handler_send_exception_response(t_function* tfunc, + const string& err_var) { + f_gen_ << indent() << "let message_ident = TMessageIdentifier::new(" + << "\"" << tfunc->get_name() << "\", " // note: use *original* name + << "TMessageType::Exception, " + << "incoming_sequence_number);" << endl; f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << endl; - f_gen_ << indent() << "thrift::Error::write_application_error_to_out_protocol(&" << err_var << ", o_prot)?;" << endl; + f_gen_ << indent() << "thrift::Error::write_application_error_to_out_protocol(&" << err_var + << ", o_prot)?;" << endl; f_gen_ << indent() << "o_prot.write_message_end()?;" << endl; f_gen_ << indent() << "o_prot.flush()" << endl; } @@ -2929,7 +2791,9 @@ string t_rs_generator::handler_successful_return_struct(t_function* tfunc) { vector::const_iterator members_iter; for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* xception_field = (*members_iter); - if (member_count > 0) { return_struct << ", "; } + if (member_count > 0) { + return_struct << ", "; + } return_struct << rust_field_name(xception_field) << ": None"; member_count++; } @@ -2937,7 +2801,7 @@ string t_rs_generator::handler_successful_return_struct(t_function* tfunc) { return_struct << " }"; - return return_struct.str(); + return return_struct.str(); } //----------------------------------------------------------------------------- @@ -2963,12 +2827,10 @@ void t_rs_generator::render_rustdoc(t_doc* tdoc) { generate_docstring_comment(f_gen_, "", "/// ", tdoc->get_doc(), ""); } -void t_rs_generator::render_thrift_error( - const string& error_kind, - const string& error_struct, - const string& sub_error_kind, - const string& error_message -) { +void t_rs_generator::render_thrift_error(const string& error_kind, + const string& error_struct, + const string& sub_error_kind, + const string& error_message) { f_gen_ << indent() << "Err(" << endl; indent_up(); f_gen_ << indent() << "thrift::Error::" << error_kind << "(" << endl; @@ -2980,11 +2842,9 @@ void t_rs_generator::render_thrift_error( f_gen_ << indent() << ")" << endl; } -void t_rs_generator::render_thrift_error_struct( - const string& error_struct, - const string& sub_error_kind, - const string& error_message -) { +void t_rs_generator::render_thrift_error_struct(const string& error_struct, + const string& sub_error_kind, + const string& error_message) { f_gen_ << indent() << error_struct << "::new(" << endl; indent_up(); f_gen_ << indent() << sub_error_kind << "," << endl; @@ -3018,6 +2878,8 @@ string t_rs_generator::to_rust_type(t_type* ttype) { } else { return "String"; } + case t_base_type::TYPE_UUID: + return "uuid::Uuid"; case t_base_type::TYPE_BOOL: return "bool"; case t_base_type::TYPE_I8: @@ -3036,7 +2898,7 @@ string t_rs_generator::to_rust_type(t_type* ttype) { } else if (ttype->is_typedef()) { t_typedef* ttypedef = (t_typedef*)ttype; string rust_type = rust_namespace(ttype) + ttypedef->get_symbolic(); - rust_type = ttypedef->is_forward_typedef() ? "Box<" + rust_type + ">" : rust_type; + rust_type = ttypedef->is_forward_typedef() ? "Box<" + rust_type + ">" : rust_type; return rust_type; } else if (ttype->is_enum()) { return rust_namespace(ttype) + rust_camel_case(ttype->get_name()); @@ -3044,7 +2906,8 @@ string t_rs_generator::to_rust_type(t_type* ttype) { return rust_namespace(ttype) + rust_camel_case(ttype->get_name()); } else if (ttype->is_map()) { t_map* tmap = (t_map*)ttype; - return "BTreeMap<" + to_rust_type(tmap->get_key_type()) + ", " + to_rust_type(tmap->get_val_type()) + ">"; + return "BTreeMap<" + to_rust_type(tmap->get_key_type()) + ", " + + to_rust_type(tmap->get_val_type()) + ">"; } else if (ttype->is_set()) { t_set* tset = (t_set*)ttype; return "BTreeSet<" + to_rust_type(tset->get_elem_type()) + ">"; @@ -3080,6 +2943,8 @@ string t_rs_generator::to_rust_field_type_enum(t_type* ttype) { throw "will not generate protocol::TType for TYPE_VOID"; case t_base_type::TYPE_STRING: // both strings and binary are actually encoded as TType::String return "TType::String"; + case t_base_type::TYPE_UUID: + return "TType::Uuid"; case t_base_type::TYPE_BOOL: return "TType::Bool"; case t_base_type::TYPE_I8: @@ -3123,6 +2988,8 @@ string t_rs_generator::opt_in_req_out_value(t_type* ttype) { } else { return "Some(\"\".to_owned())"; } + case t_base_type::TYPE_UUID: + return "Some(uuid::Uuid::nil())"; case t_base_type::TYPE_BOOL: return "Some(false)"; case t_base_type::TYPE_I8: @@ -3172,7 +3039,8 @@ bool t_rs_generator::is_optional(t_field::e_req req) { return req == t_field::T_OPTIONAL || req == t_field::T_OPT_IN_REQ_OUT; } -t_field::e_req t_rs_generator::actual_field_req(t_field* tfield, t_rs_generator::e_struct_type struct_type) { +t_field::e_req t_rs_generator::actual_field_req(t_field* tfield, + t_rs_generator::e_struct_type struct_type) { return struct_type == t_rs_generator::T_ARGS ? t_field::T_REQUIRED : tfield->get_req(); } @@ -3197,7 +3065,7 @@ bool t_rs_generator::has_non_void_args(t_function* tfunc) { } string t_rs_generator::visibility_qualifier(t_rs_generator::e_struct_type struct_type) { - switch(struct_type) { + switch (struct_type) { case t_rs_generator::T_ARGS: case t_rs_generator::T_RESULT: return ""; @@ -3286,11 +3154,11 @@ string t_rs_generator::rust_sync_processor_name(t_service* tservice) { return rust_camel_case(tservice->get_name()) + "SyncProcessor"; } -string t_rs_generator::rust_sync_processor_impl_name(t_service *tservice) { +string t_rs_generator::rust_sync_processor_impl_name(t_service* tservice) { return "T" + rust_camel_case(tservice->get_name()) + "ProcessFunctions"; } -string t_rs_generator::rust_enum_variant_name(const string &name) { +string t_rs_generator::rust_enum_variant_name(const string& name) { bool all_uppercase = true; for (char i : name) { @@ -3341,17 +3209,19 @@ string t_rs_generator::rust_camel_case(const string& name) { } string t_rs_generator::rust_safe_field_id(int32_t id) { - string id_str = std::to_string(abs(id)); - if (id >= 0) { - return id_str; - } else { - string str("neg"); - str += id_str; - return str; - } + string id_str = std::to_string(abs(id)); + if (id >= 0) { + return id_str; + } else { + string str("neg"); + str += id_str; + return str; + } } -void t_rs_generator::string_replace(string& target, const string& search_string, const string& replace_string) { +void t_rs_generator::string_replace(string& target, + const string& search_string, + const string& replace_string) { if (target.empty()) { return; } @@ -3371,8 +3241,4 @@ std::string t_rs_generator::display_name() const { return "Rust"; } - -THRIFT_REGISTER_GENERATOR( - rs, - "Rust", - "\n") // no Rust-generator-specific options +THRIFT_REGISTER_GENERATOR(rs, "Rust", "\n") // no Rust-generator-specific options diff --git a/lib/rs/Cargo.toml b/lib/rs/Cargo.toml index 38c277df5e9..a6e8533aa57 100644 --- a/lib/rs/Cargo.toml +++ b/lib/rs/Cargo.toml @@ -15,6 +15,7 @@ keywords = ["thrift"] [dependencies] byteorder = "1.3" integer-encoding = "3.0.3" +uuid = "1" log = {version = "0.4", optional = true} ordered-float = "3.0" threadpool = {version = "1.7", optional = true} @@ -22,3 +23,6 @@ threadpool = {version = "1.7", optional = true} [features] default = ["server"] server = ["threadpool", "log"] + +[dev-dependencies] +uuid = { version = "*", features = ["v4"] } diff --git a/lib/rs/src/errors.rs b/lib/rs/src/errors.rs index fc263309d41..3cd77e573d2 100644 --- a/lib/rs/src/errors.rs +++ b/lib/rs/src/errors.rs @@ -441,6 +441,15 @@ impl From for Error { } } +impl From for Error { + fn from(err: uuid::Error) -> Self { + Error::Protocol(ProtocolError { + kind: ProtocolErrorKind::InvalidData, + message: err.to_string(), // FIXME: use fmt::Error's debug string + }) + } +} + impl From for Error { fn from(err: string::FromUtf8Error) -> Self { Error::Protocol(ProtocolError { diff --git a/lib/rs/src/protocol/binary.rs b/lib/rs/src/protocol/binary.rs index 9f8af430ba1..5da801807ed 100644 --- a/lib/rs/src/protocol/binary.rs +++ b/lib/rs/src/protocol/binary.rs @@ -190,6 +190,14 @@ where self.transport.read_f64::().map_err(From::from) } + fn read_uuid(&mut self) -> crate::Result { + let mut buf = [0u8; 16]; + self.transport + .read_exact(&mut buf) + .map(|_| uuid::Uuid::from_bytes(buf)) + .map_err(From::from) + } + fn read_string(&mut self) -> crate::Result { let bytes = self.read_bytes()?; String::from_utf8(bytes).map_err(From::from) @@ -389,6 +397,12 @@ where self.write_bytes(s.as_bytes()) } + fn write_uuid(&mut self, uuid: &uuid::Uuid) -> crate::Result<()> { + self.transport + .write_all(uuid.as_bytes()) + .map_err(From::from) + } + fn write_list_begin(&mut self, identifier: &TListIdentifier) -> crate::Result<()> { self.write_byte(field_type_to_u8(identifier.element_type))?; self.write_i32(identifier.size) @@ -470,8 +484,7 @@ fn field_type_to_u8(field_type: TType) -> u8 { TType::Map => 0x0D, TType::Set => 0x0E, TType::List => 0x0F, - TType::Utf8 => 0x10, - TType::Utf16 => 0x11, + TType::Uuid => 0x10, } } @@ -490,8 +503,7 @@ fn field_type_from_u8(b: u8) -> crate::Result { 0x0D => Ok(TType::Map), 0x0E => Ok(TType::Set), 0x0F => Ok(TType::List), - 0x10 => Ok(TType::Utf8), - 0x11 => Ok(TType::Utf16), + 0x10 => Ok(TType::Uuid), unkn => Err(crate::Error::Protocol(ProtocolError { kind: ProtocolErrorKind::InvalidData, message: format!("cannot convert {} to TType", unkn), @@ -885,6 +897,25 @@ mod tests { assert_eq!(&buf[4..], bytes); // actual bytes } + #[test] + fn must_write_uuid() { + let (_, mut o_prot) = test_objects(true); + let uuid = uuid::Uuid::new_v4(); + assert!(o_prot.write_uuid(&uuid).is_ok()); + let buf = o_prot.transport.write_bytes(); + assert_eq!(&buf, uuid.as_bytes()); + } + + #[test] + fn must_round_trip_uuid() { + let (mut i_prot, mut o_prot) = test_objects(true); + let uuid = uuid::uuid!("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4"); + assert!(o_prot.write_uuid(&uuid).is_ok()); + copy_write_buffer_to_read_buffer!(o_prot); + let received_uuid = assert_success!(i_prot.read_uuid()); + assert_eq!(&received_uuid, &uuid); + } + #[test] fn must_round_trip_bytes() { let (mut i_prot, mut o_prot) = test_objects(true); diff --git a/lib/rs/src/protocol/compact.rs b/lib/rs/src/protocol/compact.rs index 87cfbfc46ed..a1aa2532932 100644 --- a/lib/rs/src/protocol/compact.rs +++ b/lib/rs/src/protocol/compact.rs @@ -252,6 +252,10 @@ where .map_err(From::from) } + fn read_uuid(&mut self) -> crate::Result { + uuid::Uuid::from_slice(&self.read_bytes()?).map_err(From::from) + } + fn read_string(&mut self) -> crate::Result { let bytes = self.read_bytes()?; String::from_utf8(bytes).map_err(From::from) @@ -538,6 +542,10 @@ where .map_err(From::from) } + fn write_uuid(&mut self, uuid: &uuid::Uuid) -> crate::Result<()> { + self.write_bytes(uuid.as_bytes()) + } + fn write_string(&mut self, s: &str) -> crate::Result<()> { self.write_bytes(s.as_bytes()) } @@ -637,6 +645,7 @@ fn type_to_u8(field_type: TType) -> u8 { TType::Set => 0x0A, TType::Map => 0x0B, TType::Struct => 0x0C, + TType::Uuid => 0x0D, _ => panic!("should not have attempted to convert {} to u8", field_type), } } @@ -661,6 +670,7 @@ fn u8_to_type(b: u8) -> crate::Result { 0x0A => Ok(TType::Set), 0x0B => Ok(TType::Map), 0x0C => Ok(TType::Struct), + 0x0D => Ok(TType::Uuid), unkn => Err(crate::Error::Protocol(crate::ProtocolError { kind: crate::ProtocolErrorKind::InvalidData, message: format!("cannot convert {} into TType", unkn), diff --git a/lib/rs/src/protocol/mod.rs b/lib/rs/src/protocol/mod.rs index 019f7172128..0e47795d0b0 100644 --- a/lib/rs/src/protocol/mod.rs +++ b/lib/rs/src/protocol/mod.rs @@ -171,6 +171,8 @@ pub trait TInputProtocol { fn read_i64(&mut self) -> crate::Result; /// Read a 64-bit float. fn read_double(&mut self) -> crate::Result; + /// Read a UUID. + fn read_uuid(&mut self) -> crate::Result; /// Read a fixed-length string (not null terminated). fn read_string(&mut self) -> crate::Result; /// Read the beginning of a list. @@ -323,6 +325,8 @@ pub trait TOutputProtocol { fn write_i64(&mut self, i: i64) -> crate::Result<()>; /// Write a 64-bit float. fn write_double(&mut self, d: f64) -> crate::Result<()>; + /// Write a UUID + fn write_uuid(&mut self, uuid: &uuid::Uuid) -> crate::Result<()>; /// Write a fixed-length string. fn write_string(&mut self, s: &str) -> crate::Result<()>; /// Write the beginning of a list. @@ -405,6 +409,10 @@ where (**self).read_double() } + fn read_uuid(&mut self) -> crate::Result { + (**self).read_uuid() + } + fn read_string(&mut self) -> crate::Result { (**self).read_string() } @@ -498,6 +506,10 @@ where (**self).write_double(d) } + fn write_uuid(&mut self, uuid: &uuid::Uuid) -> crate::Result<()> { + (**self).write_uuid(uuid) + } + fn write_string(&mut self, s: &str) -> crate::Result<()> { (**self).write_string(s) } @@ -823,8 +835,8 @@ pub enum TType { List, /// UTF-8 string. Utf8, - /// UTF-16 string. *Unsupported*. - Utf16, + /// Uuid. + Uuid, } impl Display for TType { @@ -845,7 +857,7 @@ impl Display for TType { TType::Set => write!(f, "set"), TType::List => write!(f, "list"), TType::Utf8 => write!(f, "UTF8"), - TType::Utf16 => write!(f, "UTF16"), + TType::Uuid => write!(f, "UUID"), } } } diff --git a/lib/rs/src/protocol/multiplexed.rs b/lib/rs/src/protocol/multiplexed.rs index 697b7e6bced..48d49891fd0 100644 --- a/lib/rs/src/protocol/multiplexed.rs +++ b/lib/rs/src/protocol/multiplexed.rs @@ -152,6 +152,10 @@ where self.inner.write_string(s) } + fn write_uuid(&mut self, uuid: &uuid::Uuid) -> crate::Result<()> { + self.inner.write_uuid(uuid) + } + fn write_list_begin(&mut self, identifier: &TListIdentifier) -> crate::Result<()> { self.inner.write_list_begin(identifier) } diff --git a/lib/rs/src/protocol/stored.rs b/lib/rs/src/protocol/stored.rs index 179ae07b00d..f4bdfb19780 100644 --- a/lib/rs/src/protocol/stored.rs +++ b/lib/rs/src/protocol/stored.rs @@ -158,6 +158,10 @@ impl<'a> TInputProtocol for TStoredInputProtocol<'a> { self.inner.read_double() } + fn read_uuid(&mut self) -> crate::Result { + self.inner.read_uuid() + } + fn read_string(&mut self) -> crate::Result { self.inner.read_string() } diff --git a/lib/rs/test/Cargo.toml b/lib/rs/test/Cargo.toml index a1c6836da15..4c64f38f2e6 100644 --- a/lib/rs/test/Cargo.toml +++ b/lib/rs/test/Cargo.toml @@ -10,6 +10,7 @@ publish = false clap = "~2.33" bitflags = "=1.2" log = "0.4" +uuid = "1" [dependencies.thrift] path = "../" diff --git a/lib/rs/test/thrifts/Base_One.thrift b/lib/rs/test/thrifts/Base_One.thrift index c5fa6c20df9..f1214c909ce 100644 --- a/lib/rs/test/thrifts/Base_One.thrift +++ b/lib/rs/test/thrifts/Base_One.thrift @@ -74,6 +74,7 @@ struct Recipe { 1: string recipeName 2: string cuisine 3: i8 page + 4: uuid recipeId } union CookingTools { diff --git a/test/rs/Cargo.toml b/test/rs/Cargo.toml index b039fff4c91..da53b967a0b 100644 --- a/test/rs/Cargo.toml +++ b/test/rs/Cargo.toml @@ -11,7 +11,7 @@ clap = "~2.33" bitflags = "=1.2" env_logger = "0.8" log = "0.4" +uuid = "1" [dependencies.thrift] path = "../../lib/rs" - diff --git a/test/rs/Makefile.am b/test/rs/Makefile.am index 103f80c9ad8..78db5ee0c5c 100644 --- a/test/rs/Makefile.am +++ b/test/rs/Makefile.am @@ -17,8 +17,8 @@ # under the License. # -stubs: ../v0.16/ThriftTest.thrift - $(THRIFT) -I ./thrifts -out src --gen rs ../v0.16/ThriftTest.thrift +stubs: ../ThriftTest.thrift + $(THRIFT) -I ./thrifts -out src --gen rs ../ThriftTest.thrift precross: stubs $(CARGO) build diff --git a/test/rs/src/bin/test_client.rs b/test/rs/src/bin/test_client.rs index a44bac3c9cf..fd3a18550b9 100644 --- a/test/rs/src/bin/test_client.rs +++ b/test/rs/src/bin/test_client.rs @@ -231,6 +231,12 @@ fn make_thrift_calls( "thing".to_owned(), )?; + info!("testUuid"); + verify_expected_result( + thrift_test_client.test_uuid(uuid::uuid!("00010203-0405-0607-0809-0a0b0c0d0e0f")), + uuid::uuid!("00010203-0405-0607-0809-0a0b0c0d0e0f"), + )?; + info!("testBool"); verify_expected_result(thrift_test_client.test_bool(true), true)?; diff --git a/test/rs/src/bin/test_server.rs b/test/rs/src/bin/test_server.rs index 92a4bcc45bc..3e622d5503a 100644 --- a/test/rs/src/bin/test_server.rs +++ b/test/rs/src/bin/test_server.rs @@ -174,6 +174,11 @@ impl ThriftTestSyncHandler for ThriftTestSyncHandlerImpl { Ok(thing) } + fn handle_test_uuid(&self, thing: uuid::Uuid) -> thrift::Result { + info!("testUUID({})", &thing); + Ok(thing) + } + fn handle_test_bool(&self, thing: bool) -> thrift::Result { info!("testBool({})", thing); Ok(thing) From ca7664462733ffe2a3e4f50b03231c382b209095 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Tue, 22 Nov 2022 01:04:17 +0000 Subject: [PATCH 130/250] remove utf8 --- lib/rs/src/protocol/mod.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/rs/src/protocol/mod.rs b/lib/rs/src/protocol/mod.rs index 0e47795d0b0..8bbbb3c7cf0 100644 --- a/lib/rs/src/protocol/mod.rs +++ b/lib/rs/src/protocol/mod.rs @@ -833,8 +833,6 @@ pub enum TType { Set, /// List. List, - /// UTF-8 string. - Utf8, /// Uuid. Uuid, } @@ -856,7 +854,6 @@ impl Display for TType { TType::Map => write!(f, "map"), TType::Set => write!(f, "set"), TType::List => write!(f, "list"), - TType::Utf8 => write!(f, "UTF8"), TType::Uuid => write!(f, "UUID"), } } From df0c674f4e50efe8d343ba1ca942c942a6bfb96f Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 27 Apr 2023 14:53:12 +0800 Subject: [PATCH 131/250] fix domain socket --- test/crossrunner/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/crossrunner/util.py b/test/crossrunner/util.py index 8511f583226..c214df85a52 100644 --- a/test/crossrunner/util.py +++ b/test/crossrunner/util.py @@ -21,7 +21,7 @@ def domain_socket_path(port): - return '/tmp/v0.16/ThriftTest.thrift.%d' % port + return '/tmp/ThriftTest.thrift.%d' % port def merge_dict(base, update): From 49e4cea002fed0133b4cd3baf88c73787b1f1907 Mon Sep 17 00:00:00 2001 From: Mario Emmenlauer Date: Sat, 14 Oct 2023 15:03:12 +0200 Subject: [PATCH 132/250] THRIFT-5660: Revert "lib: cpp: TTransportException: create thrift::numeric_cast" This reverts commit 6e9cbbd059b00741c886b252cc63d325e4d86e22. See https://issues.apache.org/jira/browse/THRIFT-5660 for a discussion. --- lib/cpp/src/thrift/numeric_cast.h | 70 ------------------- .../thrift/transport/TTransportException.h | 5 +- 2 files changed, 2 insertions(+), 73 deletions(-) delete mode 100644 lib/cpp/src/thrift/numeric_cast.h diff --git a/lib/cpp/src/thrift/numeric_cast.h b/lib/cpp/src/thrift/numeric_cast.h deleted file mode 100644 index d7063dbc690..00000000000 --- a/lib/cpp/src/thrift/numeric_cast.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef THRIFT_NUMERIC_CAST_H -#define THRIFT_NUMERIC_CAST_H - -#include -#include - -#if defined(_MSC_VER) -// avoid compiler warnings and errors in MSVC if max is defined as a macro -#undef max -#endif - -namespace apache { -namespace thrift { - -/** - * @brief Perform a safe numeric cast - * - * Previously this was provided by `boost::numeric_cast`. This - * implementation reduces the dependency on `boost`. - * - * @tparam Dst The destination type - * @tparam Src The source type - * @param value The value to be converted - * @return Dst The converted value - * - * @see SA49658182 - */ -template -inline Dst numeric_cast(Src value) { - typedef std::numeric_limits DstLim; - typedef std::numeric_limits SrcLim; - - const bool positive_overflow_possible = DstLim::max() < SrcLim::max(); - const bool negative_overflow_possible = DstLim::lowest() > SrcLim::lowest(); - - if (positive_overflow_possible && value > DstLim::max()) { - throw std::bad_cast(); - } - - if (negative_overflow_possible && (value < DstLim::lowest())) { - throw std::bad_cast(); - } - - // limits have been checked, therefore safe to cast - return static_cast(value); -} - -} // namespace thrift -} // namespace apache - -#endif diff --git a/lib/cpp/src/thrift/transport/TTransportException.h b/lib/cpp/src/thrift/transport/TTransportException.h index 3ce55cb765b..dd5f361f151 100644 --- a/lib/cpp/src/thrift/transport/TTransportException.h +++ b/lib/cpp/src/thrift/transport/TTransportException.h @@ -20,9 +20,8 @@ #ifndef _THRIFT_TRANSPORT_TTRANSPORTEXCEPTION_H_ #define _THRIFT_TRANSPORT_TTRANSPORTEXCEPTION_H_ 1 +#include #include - -#include #include namespace apache { @@ -93,7 +92,7 @@ class TTransportException : public apache::thrift::TException { */ template To safe_numeric_cast(From i) { try { - return apache::thrift::numeric_cast(i); + return boost::numeric_cast(i); } catch (const std::bad_cast& bc) { throw TTransportException(TTransportException::CORRUPTED_DATA, From 597907a2e47a4cb9bd0e061f8a95f88806284bb6 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Mon, 16 Oct 2023 03:01:43 +0200 Subject: [PATCH 133/250] THRIFT-4606 LGPL license file still present (follow-up to THRIFT-3209) --- doc/licenses/lgpl-2.1.txt | 504 -------------------------------------- 1 file changed, 504 deletions(-) delete mode 100644 doc/licenses/lgpl-2.1.txt diff --git a/doc/licenses/lgpl-2.1.txt b/doc/licenses/lgpl-2.1.txt deleted file mode 100644 index 5ab7695ab8c..00000000000 --- a/doc/licenses/lgpl-2.1.txt +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - From d40dd7203e0a92b357255fc071354ba13c6ccaa4 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Thu, 19 Oct 2023 08:37:49 +0800 Subject: [PATCH 134/250] use gradle 8.4 (#2869) --- .github/workflows/build.yml | 4 ++-- build/docker/old/ubuntu-disco/Dockerfile | 4 ++-- build/docker/old/ubuntu-xenial/Dockerfile | 4 ++-- build/docker/ubuntu-bionic/Dockerfile | 4 ++-- build/docker/ubuntu-focal/Dockerfile | 4 ++-- build/docker/ubuntu-jammy/Dockerfile | 4 ++-- doc/install/README.md | 2 +- doc/install/debian.md | 2 +- lib/java/README.md | 4 ++-- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 958a308dab1..c5d66f6ed1f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -141,7 +141,7 @@ jobs: needs: compiler runs-on: ubuntu-20.04 env: - GRADLE_VERSION: "8.0.2" + GRADLE_VERSION: "8.4" steps: - uses: actions/checkout@v4 @@ -160,7 +160,7 @@ jobs: - name: Setup gradle run: | wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip - (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) + (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip sudo mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle sudo ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/old/ubuntu-disco/Dockerfile b/build/docker/old/ubuntu-disco/Dockerfile index 55dc853693c..43f4a00956e 100644 --- a/build/docker/old/ubuntu-disco/Dockerfile +++ b/build/docker/old/ubuntu-disco/Dockerfile @@ -160,7 +160,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="8.0.2" +ENV GRADLE_VERSION="8.4" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -169,7 +169,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-11-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/old/ubuntu-xenial/Dockerfile b/build/docker/old/ubuntu-xenial/Dockerfile index d954e7fd961..735108552eb 100644 --- a/build/docker/old/ubuntu-xenial/Dockerfile +++ b/build/docker/old/ubuntu-xenial/Dockerfile @@ -155,7 +155,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib install --always hxcpp 3.4.64 2>&1 > /dev/null # note: hxcpp 3.4.185 (latest) no longer ships static libraries, and caused a build failure -ENV GRADLE_VERSION="8.0.2" +ENV GRADLE_VERSION="8.4" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -165,7 +165,7 @@ RUN apt-get install -y --no-install-recommends \ unzip && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile index d6d2bda598c..57a8aee25fc 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/ubuntu-bionic/Dockerfile @@ -161,7 +161,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="8.0.2" +ENV GRADLE_VERSION="8.4" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -170,7 +170,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-17-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index 1f305734f7a..a6121faddf4 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -162,7 +162,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="8.0.2" +ENV GRADLE_VERSION="8.4" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -171,7 +171,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-17-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index c7724e7942b..bbb46d79adc 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -162,7 +162,7 @@ RUN apt-get install -y --no-install-recommends \ haxelib setup --always /usr/share/haxe/lib && \ haxelib install --always hxcpp 2>&1 > /dev/null -ENV GRADLE_VERSION="8.0.2" +ENV GRADLE_VERSION="8.4" RUN apt-get install -y --no-install-recommends \ `# Java dependencies` \ ant \ @@ -171,7 +171,7 @@ RUN apt-get install -y --no-install-recommends \ openjdk-11-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ + (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ ln -s /usr/local/gradle/bin/gradle /usr/local/bin diff --git a/doc/install/README.md b/doc/install/README.md index b90e5c6a3b9..d073e918dcf 100644 --- a/doc/install/README.md +++ b/doc/install/README.md @@ -29,7 +29,7 @@ These are only required if you choose to build the libraries for the given langu * Qt (optional) * Java * Java 17 (latest LTS) - * Gradle 8.0.2 + * Gradle 8.4 * C#: Mono 1.2.4 (and pkg-config to detect it) or Visual Studio 2005+ * Python 2.6 (including header files for extension modules) * PHP 5.0 (optionally including header files for extension modules) diff --git a/doc/install/debian.md b/doc/install/debian.md index 4718017a763..3d80531c85e 100644 --- a/doc/install/debian.md +++ b/doc/install/debian.md @@ -18,7 +18,7 @@ Debian 7/Ubuntu 12 users need to manually install a more recent version of autom If you would like to build Apache Thrift libraries for other programming languages you may need to install additional packages. The following languages require the specified additional packages: * Java - * packages: gradle (version 8.0.2) + * packages: gradle (version 8.4) * You will also need Java JDK v1.8 or higher. Type **javac** to see a list of available packages, pick the one you prefer and **apt-get install** it (e.g. default-jdk). * Ruby * ruby-full ruby-dev ruby-rspec rake rubygems bundler diff --git a/lib/java/README.md b/lib/java/README.md index aa07495c86a..c65f97ca4f9 100644 --- a/lib/java/README.md +++ b/lib/java/README.md @@ -50,13 +50,13 @@ the [gradle documentation](https://docs.gradle.org/current/userguide/installatio following this step (which is also done in the travis CI docker images): ```bash -export GRADLE_VERSION="8.0.2" +export GRADLE_VERSION="8.4" # install dependencies apt-get install -y --no-install-recommends openjdk-17-jdk-headless wget unzip # download gradle distribution wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip # check binary integrity -echo "ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c - +echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c - # unzip and install unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle From 44a7233cf9a2c2b4624e9a16e1011f997210d418 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 00:38:24 +0000 Subject: [PATCH 135/250] Bump @babel/traverse from 7.8.4 to 7.23.2 Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.8.4 to 7.23.2. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) --- updated-dependencies: - dependency-name: "@babel/traverse" dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 288 ++++++++++++++++++++++++++-------------------- 1 file changed, 161 insertions(+), 127 deletions(-) diff --git a/package-lock.json b/package-lock.json index e1440f0f473..3f8780a5ab5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "thrift", - "version": "0.19.0", + "version": "0.20.0", "license": "Apache-2.0", "dependencies": { "browser-or-node": "^1.2.1", @@ -39,12 +39,16 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", - "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", + "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", "dev": true, "dependencies": { - "@babel/highlight": "^7.0.0" + "@babel/highlight": "^7.22.13", + "chalk": "^2.4.2" + }, + "engines": { + "node": ">=6.9.0" } }, "node_modules/@babel/core": { @@ -77,26 +81,6 @@ "url": "https://opencollective.com/babel" } }, - "node_modules/@babel/core/node_modules/@babel/code-frame": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", - "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", - "dev": true, - "dependencies": { - "@babel/highlight": "^7.8.3" - } - }, - "node_modules/@babel/core/node_modules/@babel/highlight": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", - "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", - "dev": true, - "dependencies": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", - "js-tokens": "^4.0.0" - } - }, "node_modules/@babel/core/node_modules/debug": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", @@ -141,53 +125,82 @@ } }, "node_modules/@babel/generator": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.4.tgz", - "integrity": "sha512-PwhclGdRpNAf3IxZb0YVuITPZmmrXz9zf6fH8lT4XbrmfQKr6ryBzhv593P5C6poJRciFCL/eHGW2NuGrgEyxA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, "dependencies": { - "@babel/types": "^7.8.3", - "jsesc": "^2.5.1", - "lodash": "^4.17.13", - "source-map": "^0.5.0" + "@babel/types": "^7.23.0", + "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", + "jsesc": "^2.5.1" + }, + "engines": { + "node": ">=6.9.0" } }, - "node_modules/@babel/generator/node_modules/source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "node_modules/@babel/helper-environment-visitor": { + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.8.3.tgz", - "integrity": "sha512-BCxgX1BC2hD/oBlIFUgOCQDOPV8nSINxCwM3o93xP4P9Fq6aV5sgv2cOOITDMtCfQ+3PvHp3l689XZvAM9QyOA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "dependencies": { - "@babel/helper-get-function-arity": "^7.8.3", - "@babel/template": "^7.8.3", - "@babel/types": "^7.8.3" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" + }, + "engines": { + "node": ">=6.9.0" } }, - "node_modules/@babel/helper-get-function-arity": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz", - "integrity": "sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA==", + "node_modules/@babel/helper-hoist-variables": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, "dependencies": { - "@babel/types": "^7.8.3" + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz", - "integrity": "sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "dependencies": { - "@babel/types": "^7.8.3" + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "dev": true, + "engines": { + "node": ">=6.9.0" } }, "node_modules/@babel/helpers": { @@ -202,20 +215,23 @@ } }, "node_modules/@babel/highlight": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", - "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", + "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", "dev": true, "dependencies": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz", - "integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -225,71 +241,38 @@ } }, "node_modules/@babel/template": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.3.tgz", - "integrity": "sha512-04m87AcQgAFdvuoyiQ2kgELr2tV8B4fP/xJAVUL3Yb3bkNdMedD3d0rlSQr3PegP0cms3eHjl1F7PWlvWbU8FQ==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.8.3", - "@babel/parser": "^7.8.3", - "@babel/types": "^7.8.3" - } - }, - "node_modules/@babel/template/node_modules/@babel/code-frame": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", - "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", - "dev": true, - "dependencies": { - "@babel/highlight": "^7.8.3" - } - }, - "node_modules/@babel/template/node_modules/@babel/highlight": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", - "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", - "dev": true, - "dependencies": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", - "js-tokens": "^4.0.0" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" + }, + "engines": { + "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.8.4.tgz", - "integrity": "sha512-NGLJPZwnVEyBPLI+bl9y9aSnxMhsKz42so7ApAv9D+b4vAFPpY013FTS9LdKxcABoIYFU52HcYga1pPlx454mg==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.8.3", - "@babel/generator": "^7.8.4", - "@babel/helper-function-name": "^7.8.3", - "@babel/helper-split-export-declaration": "^7.8.3", - "@babel/parser": "^7.8.4", - "@babel/types": "^7.8.3", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", - "globals": "^11.1.0", - "lodash": "^4.17.13" - } - }, - "node_modules/@babel/traverse/node_modules/@babel/code-frame": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", - "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", - "dev": true, - "dependencies": { - "@babel/highlight": "^7.8.3" - } - }, - "node_modules/@babel/traverse/node_modules/@babel/highlight": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", - "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", - "dev": true, - "dependencies": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", - "js-tokens": "^4.0.0" + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" } }, "node_modules/@babel/traverse/node_modules/debug": { @@ -309,14 +292,17 @@ "dev": true }, "node_modules/@babel/types": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.3.tgz", - "integrity": "sha512-jBD+G8+LWpMBBWvVcdr4QysjUE4mU/syrhN17o1u3gx0/WzJB1kwiVZAXRtWbsIPOwW8pF/YJV5+nmetPzepXg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, "dependencies": { - "esutils": "^2.0.2", - "lodash": "^4.17.13", + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" } }, "node_modules/@istanbuljs/load-nyc-config": { @@ -352,6 +338,54 @@ "node": ">=8" } }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/@jsdoc/salty": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.5.tgz", @@ -709,9 +743,9 @@ } }, "node_modules/chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, "dependencies": { "ansi-styles": "^3.2.1", From dd1c1115b2275c6a7c1cfe7461a427849313c999 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 23:52:31 +0000 Subject: [PATCH 136/250] Bump browserify-sign from 4.0.4 to 4.2.2 in /lib/js Bumps [browserify-sign](https://github.com/crypto-browserify/browserify-sign) from 4.0.4 to 4.2.2. - [Changelog](https://github.com/browserify/browserify-sign/blob/main/CHANGELOG.md) - [Commits](https://github.com/crypto-browserify/browserify-sign/compare/v4.0.4...v4.2.2) --- updated-dependencies: - dependency-name: browserify-sign dependency-type: indirect ... Signed-off-by: dependabot[bot] --- lib/js/package-lock.json | 114 ++++++++++++++++++++++++++++++--------- 1 file changed, 90 insertions(+), 24 deletions(-) diff --git a/lib/js/package-lock.json b/lib/js/package-lock.json index 555979080b3..0d9de1242b8 100644 --- a/lib/js/package-lock.json +++ b/lib/js/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "thrift", - "version": "0.19.0", + "version": "0.20.0", "license": "Apache-2.0", "devDependencies": { "browserify": "~16.5", @@ -152,14 +152,15 @@ } }, "node_modules/asn1.js": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", + "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", "dev": true, "dependencies": { "bn.js": "^4.0.0", "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.0", + "safer-buffer": "^2.1.0" } }, "node_modules/assert": { @@ -377,28 +378,94 @@ } }, "node_modules/browserify-rsa": { - "version": "4.0.1", - "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", - "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "version": "4.1.0", + "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", + "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", "dev": true, "dependencies": { - "bn.js": "^4.1.0", + "bn.js": "^5.0.0", "randombytes": "^2.0.1" } }, + "node_modules/browserify-rsa/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", + "dev": true + }, "node_modules/browserify-sign": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", - "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.2.tgz", + "integrity": "sha512-1rudGyeYY42Dk6texmv7c4VcQ0EsvVbLwZkA+AQB7SxvXxmcD93jcHie8bzecJ+ChDlmAm2Qyu0+Ccg5uhZXCg==", "dev": true, "dependencies": { - "bn.js": "^4.1.1", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.2", - "elliptic": "^6.0.0", - "inherits": "^2.0.1", - "parse-asn1": "^5.0.0" + "bn.js": "^5.2.1", + "browserify-rsa": "^4.1.0", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.5.4", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.6", + "readable-stream": "^3.6.2", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 4" + } + }, + "node_modules/browserify-sign/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", + "dev": true + }, + "node_modules/browserify-sign/node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/browserify-sign/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/browserify-sign/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/browserify-sign/node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" } }, "node_modules/browserify-zlib": { @@ -2922,14 +2989,13 @@ } }, "node_modules/parse-asn1": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", - "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", + "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", "dev": true, "dependencies": { - "asn1.js": "^4.0.0", + "asn1.js": "^5.2.0", "browserify-aes": "^1.0.0", - "create-hash": "^1.1.0", "evp_bytestokey": "^1.0.0", "pbkdf2": "^3.0.3", "safe-buffer": "^5.1.1" From fb9ffd2ad4fac24fa487efa9c620d015d748df30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Oct 2023 09:55:54 +0000 Subject: [PATCH 137/250] Bump browserify-sign from 4.0.4 to 4.2.2 in /lib/ts Bumps [browserify-sign](https://github.com/crypto-browserify/browserify-sign) from 4.0.4 to 4.2.2. - [Changelog](https://github.com/browserify/browserify-sign/blob/main/CHANGELOG.md) - [Commits](https://github.com/crypto-browserify/browserify-sign/compare/v4.0.4...v4.2.2) --- updated-dependencies: - dependency-name: browserify-sign dependency-type: indirect ... Signed-off-by: dependabot[bot] --- lib/ts/package-lock.json | 114 +++++++++++++++++++++++++++++---------- 1 file changed, 86 insertions(+), 28 deletions(-) diff --git a/lib/ts/package-lock.json b/lib/ts/package-lock.json index b7a591b1f36..f99d8a34713 100644 --- a/lib/ts/package-lock.json +++ b/lib/ts/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "thrift", - "version": "0.19.0", + "version": "0.20.0", "license": "Apache-2.0", "dependencies": { "bufferutil": "^4.0.1", @@ -307,14 +307,15 @@ } }, "node_modules/asn1.js": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", + "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", "dev": true, "dependencies": { "bn.js": "^4.0.0", "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.0", + "safer-buffer": "^2.1.0" } }, "node_modules/assert": { @@ -575,30 +576,87 @@ } }, "node_modules/browserify-rsa": { - "version": "4.0.1", - "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", - "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "version": "4.1.0", + "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", + "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", "dev": true, "dependencies": { - "bn.js": "^4.1.0", + "bn.js": "^5.0.0", "randombytes": "^2.0.1" } }, + "node_modules/browserify-rsa/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", + "dev": true + }, "node_modules/browserify-sign": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", - "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.2.tgz", + "integrity": "sha512-1rudGyeYY42Dk6texmv7c4VcQ0EsvVbLwZkA+AQB7SxvXxmcD93jcHie8bzecJ+ChDlmAm2Qyu0+Ccg5uhZXCg==", "dev": true, "dependencies": { - "bn.js": "^4.1.1", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.2", - "elliptic": "^6.0.0", - "inherits": "^2.0.1", - "parse-asn1": "^5.0.0" + "bn.js": "^5.2.1", + "browserify-rsa": "^4.1.0", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.5.4", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.6", + "readable-stream": "^3.6.2", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 4" + } + }, + "node_modules/browserify-sign/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", + "dev": true + }, + "node_modules/browserify-sign/node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/browserify-sign/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" } }, + "node_modules/browserify-sign/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/browserify-zlib": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", @@ -2196,7 +2254,7 @@ }, "node_modules/htmlparser2/node_modules/readable-stream": { "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", "dev": true, "dependencies": { @@ -2699,7 +2757,7 @@ }, "node_modules/jslint/node_modules/readable-stream": { "version": "2.1.5", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", "integrity": "sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA=", "dev": true, "dependencies": { @@ -3483,16 +3541,16 @@ } }, "node_modules/parse-asn1": { - "version": "5.1.1", - "resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", - "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", + "version": "5.1.6", + "resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", + "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", "dev": true, "dependencies": { - "asn1.js": "^4.0.0", + "asn1.js": "^5.2.0", "browserify-aes": "^1.0.0", - "create-hash": "^1.1.0", "evp_bytestokey": "^1.0.0", - "pbkdf2": "^3.0.3" + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" } }, "node_modules/parse-filepath": { @@ -3936,7 +3994,7 @@ }, "node_modules/readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "dependencies": { From ce7ae32e807d60cf43fa5fd5700e753cccd27565 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 06:32:15 +0000 Subject: [PATCH 138/250] Bump com.github.spotbugs from 5.1.3 to 5.2.1 in /lib/kotlin Bumps com.github.spotbugs from 5.1.3 to 5.2.1. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index f0252ce033a..e5694ac03a6 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -41,7 +41,7 @@ plugins { id 'signing' id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' - id "com.github.spotbugs" version "5.1.3" + id "com.github.spotbugs" version "5.2.1" id "com.diffplug.spotless" version "6.22.0" } From 2b00c0ae996abada050cffad902ec488652e150c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 06:32:12 +0000 Subject: [PATCH 139/250] Bump jvm from 1.9.10 to 1.9.20 in /lib/kotlin Bumps [jvm](https://github.com/JetBrains/kotlin) from 1.9.10 to 1.9.20. - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) --- updated-dependencies: - dependency-name: jvm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- lib/kotlin/settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/settings.gradle.kts b/lib/kotlin/settings.gradle.kts index 9eea8d19522..4090e863f80 100644 --- a/lib/kotlin/settings.gradle.kts +++ b/lib/kotlin/settings.gradle.kts @@ -18,7 +18,7 @@ */ pluginManagement { plugins { - kotlin("jvm") version "1.9.10" + kotlin("jvm") version "1.9.20" id("com.ncorti.ktfmt.gradle") version "0.12.0" } } From 0eab6e0ae55fcba624a9278415ed8807e5a591c9 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 3 Nov 2023 11:17:01 +0100 Subject: [PATCH 140/250] THRIFT-5740 inherited interfaces should be explicitly listed in Delphi class decl Client: Delphi Patch: Jens Geyer --- lib/delphi/test/TestServer.pas | 2 +- tutorial/delphi/DelphiServer/DelphiServer.dpr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/delphi/test/TestServer.pas b/lib/delphi/test/TestServer.pas index 3ae82a1fccd..1e3a3938d5d 100644 --- a/lib/delphi/test/TestServer.pas +++ b/lib/delphi/test/TestServer.pas @@ -55,7 +55,7 @@ TTestServer = class procedure TestStop; end; - TTestHandlerImpl = class( TInterfacedObject, ITestHandler ) + TTestHandlerImpl = class( TInterfacedObject, ITestHandler, TThriftTest.Iface) strict private FServer : IServer; strict protected diff --git a/tutorial/delphi/DelphiServer/DelphiServer.dpr b/tutorial/delphi/DelphiServer/DelphiServer.dpr index 5f2dc454d10..6b8e115e92b 100644 --- a/tutorial/delphi/DelphiServer/DelphiServer.dpr +++ b/tutorial/delphi/DelphiServer/DelphiServer.dpr @@ -41,7 +41,7 @@ uses type - TCalculatorHandler = class( TInterfacedObject, TCalculator.Iface) + TCalculatorHandler = class( TInterfacedObject, TSharedService.Iface, TCalculator.Iface) protected FLog : TDictionary< Integer, ISharedStruct>; From fbfa52cd045818b44a0f53ef8559db9d1dc198d8 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Tue, 7 Nov 2023 13:47:24 +0800 Subject: [PATCH 141/250] THRIFT-5741: use rust 1.65 (#2870) * use rust 1.65 * fix clippy * fix alert * fix protocol * fix one more dereference * fix more lint * fix over-fix * fix match &*server_type { --- .github/workflows/build.yml | 2 +- LANGUAGES.md | 2 +- build/docker/README.md | 2 +- build/docker/old/ubuntu-disco/Dockerfile | 2 +- build/docker/old/ubuntu-xenial/Dockerfile | 2 +- build/docker/ubuntu-bionic/Dockerfile | 2 +- build/docker/ubuntu-focal/Dockerfile | 2 +- build/docker/ubuntu-jammy/Dockerfile | 2 +- lib/rs/README.md | 2 +- lib/rs/src/protocol/binary.rs | 8 ++++---- lib/rs/src/protocol/compact.rs | 16 ++++++++-------- lib/rs/src/server/multiplexed.rs | 12 ++++++------ lib/rs/test/src/bin/kitchen_sink_server.rs | 4 ++-- rust-toolchain | 2 +- test/rs/src/bin/test_server.rs | 6 +++--- 15 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c5d66f6ed1f..7dfc14feb3b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -285,7 +285,7 @@ jobs: needs: compiler runs-on: ubuntu-20.04 env: - TOOLCHAIN_VERSION: 1.61.0 + TOOLCHAIN_VERSION: 1.65.0 steps: - uses: actions/checkout@v4 diff --git a/LANGUAGES.md b/LANGUAGES.md index 6cb6018807a..236007f9af8 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -319,7 +319,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr Rust 0.11.0 Yes -1.61.01.xx.x +1.65.01.xx.x YesYes Yes diff --git a/build/docker/README.md b/build/docker/README.md index abf082307b2..9c9175ff824 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -191,6 +191,6 @@ Last updated: October 1, 2017 | python | 2.7.12 | 2.7.15 | | | python3 | 3.5.2 | 3.6.8 | | | ruby | 2.3.1p112 | 2.5.1p57 | | -| rust | 1.61.0 | 1.61.0 | | +| rust | 1.65.0 | 1.65.0 | | | smalltalk | | | Not in CI | | swift | | 5.1.4 | | diff --git a/build/docker/old/ubuntu-disco/Dockerfile b/build/docker/old/ubuntu-disco/Dockerfile index 43f4a00956e..d2f397a60ef 100644 --- a/build/docker/old/ubuntu-disco/Dockerfile +++ b/build/docker/old/ubuntu-disco/Dockerfile @@ -254,7 +254,7 @@ RUN apt-get install -y --no-install-recommends \ ruby-bundler # Rust dependencies -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.61.0 -y +RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y ENV PATH /root/.cargo/bin:$PATH # Swift on Linux for cross tests diff --git a/build/docker/old/ubuntu-xenial/Dockerfile b/build/docker/old/ubuntu-xenial/Dockerfile index 735108552eb..37df80f8c5f 100644 --- a/build/docker/old/ubuntu-xenial/Dockerfile +++ b/build/docker/old/ubuntu-xenial/Dockerfile @@ -249,7 +249,7 @@ RUN apt-get install -y --no-install-recommends \ ruby-bundler # Rust dependencies -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.61.0 -y +RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y # Locale(s) for cpp unit tests RUN apt-get install -y --no-install-recommends \ diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile index 57a8aee25fc..00c7de359a4 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/ubuntu-bionic/Dockerfile @@ -254,7 +254,7 @@ RUN apt-get install -y --no-install-recommends \ ruby-bundler # Rust dependencies -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.61.0 -y +RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y ENV PATH /root/.cargo/bin:$PATH # Swift on Linux for cross tests diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index a6121faddf4..1039e459da0 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -241,7 +241,7 @@ RUN apt-get install -y --no-install-recommends \ ruby-bundler # Rust dependencies -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.61.0 -y +RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y ENV PATH /root/.cargo/bin:$PATH # Swift on Linux for cross tests diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index bbb46d79adc..d45070f45d5 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -241,7 +241,7 @@ RUN apt-get install -y --no-install-recommends \ ruby-bundler # Rust dependencies -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.61.0 -y +RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y ENV PATH /root/.cargo/bin:$PATH # Swift on Linux for cross tests diff --git a/lib/rs/README.md b/lib/rs/README.md index 010bb17a3ec..51aa63e620f 100644 --- a/lib/rs/README.md +++ b/lib/rs/README.md @@ -177,7 +177,7 @@ Breaking changes are minimized. When they are made they will be outlined below w ##### Thrift 0.14.0 -* **[THRIFT-5158]** - Rust library and generator now support Rust 2021 only. Required rust 1.61.0 or higher +* **[THRIFT-5158]** - Rust library and generator now support Rust 2021 only. Required rust 1.65.0 or higher The Rust `thrift` library was updated to Rust 2021 via `cargo fix --edition`. All test code in the repo was updated as well. The code generator was also updated diff --git a/lib/rs/src/protocol/binary.rs b/lib/rs/src/protocol/binary.rs index 5da801807ed..b4b51f682e0 100644 --- a/lib/rs/src/protocol/binary.rs +++ b/lib/rs/src/protocol/binary.rs @@ -59,7 +59,7 @@ where pub transport: T, // FIXME: shouldn't be public } -impl<'a, T> TBinaryInputProtocol +impl TBinaryInputProtocol where T: TReadTransport, { @@ -861,7 +861,7 @@ mod tests { set_readable_bytes!(i_prot, &[0x01]); let read_bool = assert_success!(i_prot.read_bool()); - assert_eq!(read_bool, true); + assert!(read_bool); } #[test] @@ -871,7 +871,7 @@ mod tests { set_readable_bytes!(i_prot, &[0x00]); let read_bool = assert_success!(i_prot.read_bool()); - assert_eq!(read_bool, false); + assert!(!read_bool); } #[test] @@ -881,7 +881,7 @@ mod tests { set_readable_bytes!(i_prot, &[0xAC]); let read_bool = assert_success!(i_prot.read_bool()); - assert_eq!(read_bool, true); + assert!(read_bool); } #[test] diff --git a/lib/rs/src/protocol/compact.rs b/lib/rs/src/protocol/compact.rs index a1aa2532932..c0c43722ed8 100644 --- a/lib/rs/src/protocol/compact.rs +++ b/lib/rs/src/protocol/compact.rs @@ -2461,7 +2461,7 @@ mod tests { } ); let read_value_1 = assert_success!(i_prot.read_bool()); - assert_eq!(read_value_1, true); + assert!(read_value_1); assert_success!(i_prot.read_field_end()); let read_ident_2 = assert_success!(i_prot.read_field_begin()); @@ -2473,7 +2473,7 @@ mod tests { } ); let read_value_2 = assert_success!(i_prot.read_bool()); - assert_eq!(read_value_2, false); + assert!(!read_value_2); assert_success!(i_prot.read_field_end()); let read_ident_3 = assert_success!(i_prot.read_field_begin()); @@ -2485,7 +2485,7 @@ mod tests { } ); let read_value_3 = assert_success!(i_prot.read_bool()); - assert_eq!(read_value_3, true); + assert!(read_value_3); assert_success!(i_prot.read_field_end()); let read_ident_4 = assert_success!(i_prot.read_field_begin()); @@ -2497,7 +2497,7 @@ mod tests { } ); let read_value_4 = assert_success!(i_prot.read_bool()); - assert_eq!(read_value_4, false); + assert!(!read_value_4); assert_success!(i_prot.read_field_end()); let read_ident_5 = assert_success!(i_prot.read_field_begin()); @@ -2774,16 +2774,16 @@ mod tests { assert_eq!(&rcvd_ident, &map_ident); // key 1 let b = assert_success!(i_prot.read_bool()); - assert_eq!(b, true); + assert!(b); // val 1 let b = assert_success!(i_prot.read_bool()); - assert_eq!(b, false); + assert!(!b); // key 2 let b = assert_success!(i_prot.read_bool()); - assert_eq!(b, false); + assert!(!b); // val 2 let b = assert_success!(i_prot.read_bool()); - assert_eq!(b, true); + assert!(b); // map end assert_success!(i_prot.read_map_end()); } diff --git a/lib/rs/src/server/multiplexed.rs b/lib/rs/src/server/multiplexed.rs index f6811a42d76..85126b7e23c 100644 --- a/lib/rs/src/server/multiplexed.rs +++ b/lib/rs/src/server/multiplexed.rs @@ -197,7 +197,7 @@ mod tests { #[test] fn should_split_name_into_proper_separator_and_service_call() { let ident_name = "foo:bar_call"; - let (serv, call) = split_ident_name(&ident_name); + let (serv, call) = split_ident_name(ident_name); assert_eq!(serv, Some("foo")); assert_eq!(call, "bar_call"); } @@ -205,7 +205,7 @@ mod tests { #[test] fn should_return_full_ident_if_no_separator_exists() { let ident_name = "bar_call"; - let (serv, call) = split_ident_name(&ident_name); + let (serv, call) = split_ident_name(ident_name); assert_eq!(serv, None); assert_eq!(call, "bar_call"); } @@ -311,8 +311,8 @@ mod tests { p.process(&mut i, &mut o).unwrap(); // service 1 should have been invoked, not service 2 - assert_eq!(atm_1.load(Ordering::Relaxed), true); - assert_eq!(atm_2.load(Ordering::Relaxed), false); + assert!(atm_1.load(Ordering::Relaxed)); + assert!(!atm_2.load(Ordering::Relaxed)); } #[test] @@ -344,8 +344,8 @@ mod tests { p.process(&mut i, &mut o).unwrap(); // service 2 should have been invoked, not service 1 - assert_eq!(atm_1.load(Ordering::Relaxed), false); - assert_eq!(atm_2.load(Ordering::Relaxed), true); + assert!(!atm_1.load(Ordering::Relaxed)); + assert!(atm_2.load(Ordering::Relaxed)); } fn build_objects() -> ( diff --git a/lib/rs/test/src/bin/kitchen_sink_server.rs b/lib/rs/test/src/bin/kitchen_sink_server.rs index 1abd07c66f8..6595d6397d7 100644 --- a/lib/rs/test/src/bin/kitchen_sink_server.rs +++ b/lib/rs/test/src/bin/kitchen_sink_server.rs @@ -93,7 +93,7 @@ fn run() -> thrift::Result<()> { let (i_protocol_factory, o_protocol_factory): ( Box, Box, - ) = match &*protocol { + ) = match protocol { "binary" => ( Box::new(TBinaryInputProtocolFactory::new()), Box::new(TBinaryOutputProtocolFactory::new()), @@ -117,7 +117,7 @@ fn run() -> thrift::Result<()> { // different processor) this isn't possible. // // Since what I'm doing is uncommon I'm just going to duplicate the code - match &*service { + match service { "part" => run_meal_server( socket, r_transport_factory, diff --git a/rust-toolchain b/rust-toolchain index 91951fd8ad7..902c74186fb 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.61.0 +1.65.0 diff --git a/test/rs/src/bin/test_server.rs b/test/rs/src/bin/test_server.rs index 3e622d5503a..aa8191cf959 100644 --- a/test/rs/src/bin/test_server.rs +++ b/test/rs/src/bin/test_server.rs @@ -81,7 +81,7 @@ fn run() -> thrift::Result<()> { let (i_transport_factory, o_transport_factory): ( Box, Box, - ) = match &*transport { + ) = match transport { "buffered" => ( Box::new(TBufferedReadTransportFactory::new()), Box::new(TBufferedWriteTransportFactory::new()), @@ -98,7 +98,7 @@ fn run() -> thrift::Result<()> { let (i_protocol_factory, o_protocol_factory): ( Box, Box, - ) = match &*protocol { + ) = match protocol { "binary" | "multi" | "multi:binary" => ( Box::new(TBinaryInputProtocolFactory::new()), Box::new(TBinaryOutputProtocolFactory::new()), @@ -114,7 +114,7 @@ fn run() -> thrift::Result<()> { let test_processor = ThriftTestSyncProcessor::new(ThriftTestSyncHandlerImpl {}); - match &*server_type { + match server_type { "simple" | "thread-pool" => { if protocol == "multi" || protocol == "multic" { let second_service_processor = From fa123f950d7c2a983b242026b3d52a29a2576e91 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 10 Nov 2023 01:50:24 +0100 Subject: [PATCH 142/250] THRIFT-5742 Add addRange() function to Set helper classes to support adding data from arbitrary enumerable source containers Client: hx Patch: Jens Geyer --- lib/haxe/src/org/apache/thrift/helper/IntSet.hx | 12 +++++++++--- lib/haxe/src/org/apache/thrift/helper/ObjectSet.hx | 12 +++++++++--- lib/haxe/src/org/apache/thrift/helper/StringSet.hx | 12 +++++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/lib/haxe/src/org/apache/thrift/helper/IntSet.hx b/lib/haxe/src/org/apache/thrift/helper/IntSet.hx index 91e5d8e975e..676463be1a6 100644 --- a/lib/haxe/src/org/apache/thrift/helper/IntSet.hx +++ b/lib/haxe/src/org/apache/thrift/helper/IntSet.hx @@ -30,9 +30,7 @@ class IntSet { public function new( values : Array = null) { if ( values != null) { - for ( value in values) { - add(value); - } + addRange(values.iterator()); } } @@ -57,6 +55,14 @@ class IntSet { return true; } + public function addRange( values : Iterator) { + if ( values != null) { + for ( value in values) { + add(value); + } + } + } + public function clear() : Void { while( _size > 0) { remove( _elements.keys().next()); diff --git a/lib/haxe/src/org/apache/thrift/helper/ObjectSet.hx b/lib/haxe/src/org/apache/thrift/helper/ObjectSet.hx index 60e88e49bb8..5a3831c8314 100644 --- a/lib/haxe/src/org/apache/thrift/helper/ObjectSet.hx +++ b/lib/haxe/src/org/apache/thrift/helper/ObjectSet.hx @@ -30,9 +30,7 @@ class ObjectSet { public function new( values : Array = null) { if ( values != null) { - for ( value in values) { - add(value); - } + addRange(values.iterator()); } } @@ -57,6 +55,14 @@ class ObjectSet { return true; } + public function addRange( values : Iterator) { + if ( values != null) { + for ( value in values) { + add(value); + } + } + } + public function clear() : Void { while( _size > 0) { remove( _elements.keys().next()); diff --git a/lib/haxe/src/org/apache/thrift/helper/StringSet.hx b/lib/haxe/src/org/apache/thrift/helper/StringSet.hx index b47f8683782..2c255e6a003 100644 --- a/lib/haxe/src/org/apache/thrift/helper/StringSet.hx +++ b/lib/haxe/src/org/apache/thrift/helper/StringSet.hx @@ -30,9 +30,7 @@ class StringSet { public function new( values : Array = null) { if ( values != null) { - for ( value in values) { - add(value); - } + addRange(values.iterator()); } } @@ -57,6 +55,14 @@ class StringSet { return true; } + public function addRange( values : Iterator) { + if ( values != null) { + for ( value in values) { + add(value); + } + } + } + public function clear() : Void { while( _size > 0) { remove( _elements.keys().next()); From a06eedcbfc80c11b751d7cad20e3d9940b2bff67 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Thu, 16 Nov 2023 23:23:04 +0100 Subject: [PATCH 143/250] THRIFT-5743 add TLS1.3 to default protocols where available Client: netstd Patch: Jens Geyer --- .../Transport/Client/TTlsSocketTransport.cs | 23 ++++++++++++++----- .../Server/TTlsServerSocketTransport.cs | 4 ++-- test/netstd/Client/TestClient.cs | 2 +- test/netstd/Server/TestServer.cs | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs b/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs index e3da6f4c264..bda12900798 100644 --- a/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs +++ b/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs @@ -16,6 +16,7 @@ // under the License. using System; +using System.Diagnostics; using System.Net; using System.Net.Security; using System.Net.Sockets; @@ -43,11 +44,19 @@ public class TTlsSocketTransport : TStreamTransport private SslStream _secureStream; private int _timeout; + #if NET7_0_OR_GREATER + public const SslProtocols DefaultSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13; + #else + public const SslProtocols DefaultSslProtocols = SslProtocols.Tls12; + #endif + + + public TTlsSocketTransport(TcpClient client, TConfiguration config, X509Certificate2 certificate, bool isServer = false, RemoteCertificateValidationCallback certValidator = null, LocalCertificateSelectionCallback localCertificateSelectionCallback = null, - SslProtocols sslProtocols = SslProtocols.Tls12) + SslProtocols sslProtocols = DefaultSslProtocols) : base(config) { _client = client; @@ -74,7 +83,7 @@ public TTlsSocketTransport(IPAddress host, int port, TConfiguration config, string certificatePath, RemoteCertificateValidationCallback certValidator = null, LocalCertificateSelectionCallback localCertificateSelectionCallback = null, - SslProtocols sslProtocols = SslProtocols.Tls12) + SslProtocols sslProtocols = DefaultSslProtocols) : this(host, port, config, 0, new X509Certificate2(certificatePath), certValidator, @@ -87,7 +96,7 @@ public TTlsSocketTransport(IPAddress host, int port, TConfiguration config, X509Certificate2 certificate = null, RemoteCertificateValidationCallback certValidator = null, LocalCertificateSelectionCallback localCertificateSelectionCallback = null, - SslProtocols sslProtocols = SslProtocols.Tls12) + SslProtocols sslProtocols = DefaultSslProtocols) : this(host, port, config, 0, certificate, certValidator, @@ -100,7 +109,7 @@ public TTlsSocketTransport(IPAddress host, int port, TConfiguration config, int X509Certificate2 certificate, RemoteCertificateValidationCallback certValidator = null, LocalCertificateSelectionCallback localCertificateSelectionCallback = null, - SslProtocols sslProtocols = SslProtocols.Tls12) + SslProtocols sslProtocols = DefaultSslProtocols) : base(config) { _host = host; @@ -118,7 +127,7 @@ public TTlsSocketTransport(string host, int port, TConfiguration config, int tim X509Certificate2 certificate, RemoteCertificateValidationCallback certValidator = null, LocalCertificateSelectionCallback localCertificateSelectionCallback = null, - SslProtocols sslProtocols = SslProtocols.Tls12) + SslProtocols sslProtocols = DefaultSslProtocols) : base(config) { try @@ -237,7 +246,7 @@ public async Task SetupTlsAsync() { // Client authentication var certs = _certificate != null - ? new X509CertificateCollection {_certificate} + ? new X509CertificateCollection { _certificate } : new X509CertificateCollection(); var targetHost = _targetHost ?? _host.ToString(); @@ -269,5 +278,7 @@ public override void Close() _secureStream = null; } } + + } } diff --git a/lib/netstd/Thrift/Transport/Server/TTlsServerSocketTransport.cs b/lib/netstd/Thrift/Transport/Server/TTlsServerSocketTransport.cs index 2b7f80cd167..0f72438e802 100644 --- a/lib/netstd/Thrift/Transport/Server/TTlsServerSocketTransport.cs +++ b/lib/netstd/Thrift/Transport/Server/TTlsServerSocketTransport.cs @@ -43,7 +43,7 @@ public TTlsServerSocketTransport( X509Certificate2 certificate, RemoteCertificateValidationCallback clientCertValidator = null, LocalCertificateSelectionCallback localCertificateSelectionCallback = null, - SslProtocols sslProtocols = SslProtocols.Tls12) + SslProtocols sslProtocols = TTlsSocketTransport.DefaultSslProtocols) : base(config) { if (!certificate.HasPrivateKey) @@ -65,7 +65,7 @@ public TTlsServerSocketTransport( X509Certificate2 certificate, RemoteCertificateValidationCallback clientCertValidator = null, LocalCertificateSelectionCallback localCertificateSelectionCallback = null, - SslProtocols sslProtocols = SslProtocols.Tls12) + SslProtocols sslProtocols = TTlsSocketTransport.DefaultSslProtocols) : this(null, config, certificate, clientCertValidator, localCertificateSelectionCallback, sslProtocols) { try diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs index 183cfb43063..3bf2daaae48 100644 --- a/test/netstd/Client/TestClient.cs +++ b/test/netstd/Client/TestClient.cs @@ -257,7 +257,7 @@ public TTransport CreateTransport() trans = new TTlsSocketTransport(host, port, Configuration, 0, cert, (sender, certificate, chain, errors) => true, - null, SslProtocols.Tls12); + null); break; case TransportChoice.Socket: diff --git a/test/netstd/Server/TestServer.cs b/test/netstd/Server/TestServer.cs index fdbaa9718a4..a540d1919bf 100644 --- a/test/netstd/Server/TestServer.cs +++ b/test/netstd/Server/TestServer.cs @@ -606,7 +606,7 @@ public static async Task Execute(List args) trans = new TTlsServerSocketTransport(param.port, Configuration, cert, (sender, certificate, chain, errors) => true, - null, SslProtocols.Tls12); + null); break; case TransportChoice.Socket: From 4115e952b5bed2887113af053b63acd3a03c6e19 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Tue, 21 Nov 2023 23:00:01 +0100 Subject: [PATCH 144/250] THRIFT-5746 Upgrade to net8 Client: netstd Patch: Jens Geyer --- build/docker/old/debian-stretch/Dockerfile | 8 +- build/docker/old/ubuntu-artful/Dockerfile | 8 +- build/docker/old/ubuntu-disco/Dockerfile | 8 +- build/docker/old/ubuntu-xenial/Dockerfile | 8 +- build/docker/ubuntu-bionic/Dockerfile | 8 +- build/docker/ubuntu-focal/Dockerfile | 8 +- build/docker/ubuntu-jammy/Dockerfile | 8 +- .../src/thrift/generate/t_netstd_generator.cc | 225 ++++++++++++------ .../src/thrift/generate/t_netstd_generator.h | 6 +- .../Thrift.Benchmarks.csproj | 3 +- .../Thrift.IntegrationTests.csproj | 3 +- ...rift.PublicInterfaces.Compile.Tests.csproj | 19 +- .../Collections/TCollectionsTests.cs | 40 ++-- .../Tests/Thrift.Tests/DataModel/DeepCopy.cs | 79 +++--- .../Thrift.Tests/DataModel/NullValuesSet.cs | 1 + .../Protocols/TJsonProtocolHelperTests.cs | 54 ++--- .../Protocols/TJsonProtocolTests.cs | 6 +- .../Tests/Thrift.Tests/Thrift.Tests.csproj | 3 +- lib/netstd/Thrift/.editorconfig | 5 + .../Thrift/Processor/TMultiplexedProcessor.cs | 8 +- .../Processor/TSingletonProcessorFactory.cs | 7 +- lib/netstd/Thrift/Protocol/Entities/TField.cs | 5 +- lib/netstd/Thrift/Protocol/Entities/TList.cs | 5 +- lib/netstd/Thrift/Protocol/Entities/TMap.cs | 5 +- .../Thrift/Protocol/Entities/TMessage.cs | 5 +- lib/netstd/Thrift/Protocol/Entities/TSet.cs | 5 +- .../Thrift/Protocol/Entities/TStruct.cs | 3 + lib/netstd/Thrift/Protocol/TBinaryProtocol.cs | 17 +- .../Thrift/Protocol/TCompactProtocol.cs | 2 + lib/netstd/Thrift/Protocol/TJSONProtocol.cs | 2 + .../Thrift/Protocol/TMultiplexedProtocol.cs | 3 + lib/netstd/Thrift/Protocol/ToString.cs | 20 +- .../Thrift/Protocol/Utilities/TBase64Utils.cs | 8 +- .../Protocol/Utilities/TGuidExtensions.cs | 4 +- .../Utilities/TJsonProtocolConstants.cs | 3 + lib/netstd/Thrift/Server/TServer.cs | 3 +- .../Thrift/Server/TSimpleAsyncServer.cs | 2 + lib/netstd/Thrift/Thrift.csproj | 2 +- .../Transport/Client/TTlsSocketTransport.cs | 3 + .../Transport/Layered/TFramedTransport.cs | 4 + .../Transport/Layered/TLayeredTransport.cs | 7 +- .../Server/TNamedPipeServerTransport.cs | 10 +- .../Server/TServerSocketTransport.cs | 3 + .../Transport/Server/TServerTransport.cs | 13 +- lib/netstd/Thrift/Transport/TTransport.cs | 6 +- test/netstd/Client/Client.csproj | 10 +- .../Client/Performance/PerformanceTests.cs | 6 +- test/netstd/Client/TestClient.cs | 24 +- test/netstd/Server/Server.csproj | 10 +- test/netstd/Server/TestServer.cs | 25 +- tutorial/netstd/Client/Client.csproj | 4 +- tutorial/netstd/Interfaces/Interfaces.csproj | 2 +- tutorial/netstd/Server/Server.csproj | 4 +- 53 files changed, 426 insertions(+), 314 deletions(-) diff --git a/build/docker/old/debian-stretch/Dockerfile b/build/docker/old/debian-stretch/Dockerfile index 25237cabf41..f584bba9a96 100644 --- a/build/docker/old/debian-stretch/Dockerfile +++ b/build/docker/old/debian-stretch/Dockerfile @@ -102,10 +102,10 @@ ENV PATH /usr/lib/dart/bin:$PATH # project isn't ready for this quite yet: # RUN apt-get install -y --no-install-recommends \ # `# dotnet core dependencies` \ -# dotnet-sdk-7.0 \ -# dotnet-runtime-7.0 \ -# aspnetcore-runtime-7.0 \ -# dotnet-apphost-pack-7.0 +# dotnet-sdk-8.0 \ +# dotnet-runtime-8.0 \ +# aspnetcore-runtime-8.0 \ +# dotnet-apphost-pack-8.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/old/ubuntu-artful/Dockerfile b/build/docker/old/ubuntu-artful/Dockerfile index 039147033a7..f94b70086b5 100644 --- a/build/docker/old/ubuntu-artful/Dockerfile +++ b/build/docker/old/ubuntu-artful/Dockerfile @@ -120,10 +120,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-7.0 \ - dotnet-runtime-7.0 \ - aspnetcore-runtime-7.0 \ - dotnet-apphost-pack-7.0 + dotnet-sdk-8.0 \ + dotnet-runtime-8.0 \ + aspnetcore-runtime-8.0 \ + dotnet-apphost-pack-8.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/old/ubuntu-disco/Dockerfile b/build/docker/old/ubuntu-disco/Dockerfile index d2f397a60ef..39642cf2b00 100644 --- a/build/docker/old/ubuntu-disco/Dockerfile +++ b/build/docker/old/ubuntu-disco/Dockerfile @@ -126,10 +126,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-7.0 \ - dotnet-runtime-7.0 \ - aspnetcore-runtime-7.0 \ - dotnet-apphost-pack-7.0 + dotnet-sdk-8.0 \ + dotnet-runtime-8.0 \ + aspnetcore-runtime-8.0 \ + dotnet-apphost-pack-8.0 RUN apt-get install -y --no-install-recommends \ `# Erlang dependencies` \ diff --git a/build/docker/old/ubuntu-xenial/Dockerfile b/build/docker/old/ubuntu-xenial/Dockerfile index 37df80f8c5f..d9d87ccaea3 100644 --- a/build/docker/old/ubuntu-xenial/Dockerfile +++ b/build/docker/old/ubuntu-xenial/Dockerfile @@ -115,10 +115,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-7.0 \ - dotnet-runtime-7.0 \ - aspnetcore-runtime-7.0 \ - dotnet-apphost-pack-7.0 + dotnet-sdk-8.0 \ + dotnet-runtime-8.0 \ + aspnetcore-runtime-8.0 \ + dotnet-apphost-pack-8.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=20.3.8.9 diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile index 00c7de359a4..350921ae50a 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/ubuntu-bionic/Dockerfile @@ -124,10 +124,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-7.0 \ - dotnet-runtime-7.0 \ - aspnetcore-runtime-7.0 \ - dotnet-apphost-pack-7.0 + dotnet-sdk-8.0 \ + dotnet-runtime-8.0 \ + aspnetcore-runtime-8.0 \ + dotnet-apphost-pack-8.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=23.3.4.11 diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index 1039e459da0..416e806469c 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -125,10 +125,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-7.0 \ - dotnet-runtime-7.0 \ - aspnetcore-runtime-7.0 \ - dotnet-apphost-pack-7.0 + dotnet-sdk-8.0 \ + dotnet-runtime-8.0 \ + aspnetcore-runtime-8.0 \ + dotnet-apphost-pack-8.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=23.3.4.11 diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index d45070f45d5..a10fea6500a 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -125,10 +125,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-7.0 \ - dotnet-runtime-7.0 \ - aspnetcore-runtime-7.0 \ - dotnet-apphost-pack-7.0 + dotnet-sdk-8.0 \ + dotnet-runtime-8.0 \ + aspnetcore-runtime-8.0 \ + dotnet-apphost-pack-8.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=23.3.4.11 diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc index 1c970029998..1a27c0c3b2f 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc @@ -51,7 +51,7 @@ t_netstd_generator::t_netstd_generator(t_program* program, const mapfirst.compare("net6") == 0) { - use_net6_features = true; + target_net_version = 6; + } + else if (iter->first.compare("net8") == 0) { + target_net_version = 8; } else if (iter->first.compare("async_postfix") == 0) { add_async_postfix = true; @@ -153,13 +156,13 @@ void t_netstd_generator::init_generator() } pverbose(".NET Standard options:\n"); - pverbose("- union ........... %s\n", (is_union_enabled() ? "ON" : "off")); - pverbose("- serialize ....... %s\n", (is_serialize_enabled() ? "ON" : "off")); - pverbose("- wcf ............. %s\n", (is_wcf_enabled() ? "ON" : "off")); - pverbose("- pascal .......... %s\n", (use_pascal_case_properties ? "ON" : "off")); - pverbose("- net6 ............ %s\n", (use_net6_features ? "ON" : "off")); - pverbose("- no_deepcopy ..... %s\n", (suppress_deepcopy ? "ON" : "off")); - pverbose("- async_postfix ... %s\n", (add_async_postfix ? "ON" : "off")); + pverbose("- union ................ %s\n", (is_union_enabled() ? "ON" : "off")); + pverbose("- serialize ............ %s\n", (is_serialize_enabled() ? "ON" : "off")); + pverbose("- wcf .................. %s\n", (is_wcf_enabled() ? "ON" : "off")); + pverbose("- pascal ............... %s\n", (use_pascal_case_properties ? "ON" : "off")); + pverbose("- target NET version ... %d\n", target_net_version); + pverbose("- no_deepcopy .......... %s\n", (suppress_deepcopy ? "ON" : "off")); + pverbose("- async_postfix ........ %s\n", (add_async_postfix ? "ON" : "off")); } string t_netstd_generator::normalize_name(string name, bool is_arg_name) @@ -180,7 +183,7 @@ string t_netstd_generator::normalize_name(string name, bool is_arg_name) } // prevent CS8981 "The type name only contains lower-cased ascii characters" - if( name.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == std::string::npos) + if( name.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == std::string::npos) { return "@" + name; } @@ -199,19 +202,24 @@ void t_netstd_generator::reset_indent() { void t_netstd_generator::pragmas_and_directives(ostream& out) { - if( use_net6_features) { + if( target_net_version >= 6) { + out << "// Thrift code generated for net" << target_net_version << endl; out << "#nullable enable // requires C# 8.0" << endl; } // this one must be first out << "#pragma warning disable IDE0079 // remove unnecessary pragmas" << endl; - out << "#pragma warning disable IDE0017 // object init can be simplified" << endl - << "#pragma warning disable IDE0028 // collection init can be simplified" << endl - << "#pragma warning disable IDE1006 // parts of the code use IDL spelling" << endl - << "#pragma warning disable CA1822 // empty " << DEEP_COPY_METHOD_NAME << "() methods still non-static" << endl; + if( target_net_version >= 8) { + out << "#pragma warning disable IDE0290 // use primary CTOR" << endl; + } else { + out << "#pragma warning disable IDE0017 // object init can be simplified" << endl; + out << "#pragma warning disable IDE0028 // collection init can be simplified" << endl; + } + out << "#pragma warning disable IDE1006 // parts of the code use IDL spelling" << endl; + out << "#pragma warning disable CA1822 // empty " << DEEP_COPY_METHOD_NAME << "() methods still non-static" << endl; - if( ! use_net6_features) { + if( target_net_version < 6) { out << "#pragma warning disable IDE0083 // pattern matching \"that is not SomeType\" requires net5.0 but we still support earlier versions" << endl; } out << endl; @@ -474,7 +482,13 @@ bool t_netstd_generator::print_const_value(ostream& out, string name, t_type* ty if (!defval || needtype) { - out << (in_static ? "" : type->is_base_type() ? "public const " : "public static ") << type_name(type) << " "; + if(in_static) { + out << type_name(type) << " "; + } else if(type->is_base_type()) { + out << "public const " << type_name(type) << " "; + } else { + out << "public static " << (target_net_version >= 6 ? "readonly " : "") << type_name(type) << " "; + } } if (type->is_base_type()) @@ -490,15 +504,21 @@ bool t_netstd_generator::print_const_value(ostream& out, string name, t_type* ty } else if (type->is_struct() || type->is_xception()) { - out << name << " = new " << type_name(type) << "();" << endl; - } - else if (type->is_map()) - { - out << name << " = new " << type_name(type) << "();" << endl; + if(target_net_version >= 6) { + out << name << " = new();" << endl; + } else { + out << name << " = new " << type_name(type) << "();" << endl; + } } - else if (type->is_list() || type->is_set()) + else if (type->is_map() || type->is_list() || type->is_set()) { - out << name << " = new " << type_name(type) << "();" << endl; + if(target_net_version >= 8) { + out << name << " = [];" << endl; + } else if(target_net_version >= 6) { + out << name << " = new();" << endl; + } else { + out << name << " = new " << type_name(type) << "();" << endl; + } } if (defval && !type->is_base_type() && !type->is_enum()) @@ -667,7 +687,7 @@ void t_netstd_generator::generate_extensions(ostream& out, map { out << indent() << "public static bool Equals(this " << iter->first << " instance, object that)" << endl; scope_up(out); - if( use_net6_features) { + if( target_net_version >= 6) { out << indent() << "if (that is not " << iter->first << " other) return false;" << endl; } else { out << indent() << "if (!(that is " << iter->first << " other)) return false;" << endl; @@ -705,7 +725,7 @@ void t_netstd_generator::generate_extensions(ostream& out, map out << indent() << "foreach (var pair in source)" << endl; indent_up(); - if( use_net6_features) { + if( target_net_version >= 6) { out << indent() << tmp_instance << ".Add(pair.Key" << copy_key; out << ", pair.Value" << copy_val; } else { @@ -743,7 +763,7 @@ void t_netstd_generator::generate_extensions(ostream& out, map out << indent() << "foreach (var elem in source)" << endl; indent_up(); - if( use_net6_features) { + if( target_net_version >= 6) { out << indent() << tmp_instance << ".Add(elem" << copy_elm; } else { out << indent() << tmp_instance << ".Add("; @@ -1077,7 +1097,14 @@ void t_netstd_generator::generate_netstd_deepcopy_method(ostream& out, t_struct* // return directly if there are only required fields string tmp_instance = tmp("tmp"); - out << indent() << "var " << tmp_instance << " = new " << sharp_struct_name << "();" << endl; + out << indent() << "var " << tmp_instance << " = new " << sharp_struct_name << "()"; + bool inline_assignment = (target_net_version >= 6); + if(inline_assignment) { + out << endl << indent() << "{" << endl; + indent_up(); + } else { + out << endl; + } for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { bool needs_typecast = false; @@ -1086,21 +1113,46 @@ void t_netstd_generator::generate_netstd_deepcopy_method(ostream& out, t_struct* string copy_op = get_deep_copy_method_call(ttype, true, needs_typecast, suffix); bool is_required = field_is_required(*m_iter); + bool null_allowed = type_can_be_null((*m_iter)->get_type()); + + if(inline_assignment) { + if( null_allowed || (!is_required)) { // = has isset + indent_down(); + out << indent() << "};" << endl; + inline_assignment = false; + } + } + generate_null_check_begin( out, *m_iter); - out << indent() << tmp_instance << "." << prop_name(*m_iter) << " = "; + out << indent(); + if(!inline_assignment) { + out << tmp_instance << "."; + } + out << prop_name(*m_iter) << " = "; if( needs_typecast) { out << "(" << type_name(ttype) << ")"; } - out << "this." << prop_name(*m_iter) << copy_op << ";" << endl; + out << "this." << prop_name(*m_iter) << copy_op; + out << (inline_assignment ? "," : ";") << endl; generate_null_check_end( out, *m_iter); if( !is_required) { - out << indent() << tmp_instance << ".__isset." << get_isset_name(normalize_name((*m_iter)->get_name())) - << " = this.__isset." << get_isset_name(normalize_name((*m_iter)->get_name())) << ";" << endl; + out << indent(); + if(!inline_assignment) { + out << tmp_instance << "."; + } + out << "__isset." << get_isset_name(normalize_name((*m_iter)->get_name())); + out << " = this.__isset." << get_isset_name(normalize_name((*m_iter)->get_name())); + out << (inline_assignment ? "," : ";") << endl; } } + if(inline_assignment) { + indent_down(); + out << indent() << "};" << endl; + } + out << indent() << "return " << tmp_instance << ";" << endl; indent_down(); @@ -1271,6 +1323,9 @@ void t_netstd_generator::generate_netstd_struct_writer(ostream& out, t_struct* t if (fields.size() > 0) { tmpvar = tmp("tmp"); + if(target_net_version >= 8) { + out << indent() << "#pragma warning disable IDE0017 // simplified init" << endl; + } out << indent() << "var " << tmpvar << " = new TField();" << endl; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { @@ -1285,6 +1340,9 @@ void t_netstd_generator::generate_netstd_struct_writer(ostream& out, t_struct* t out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; generate_null_check_end(out, *f_iter); } + if(target_net_version >= 8) { + out << indent() << "#pragma warning restore IDE0017 // simplified init" << endl; + } } out << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl @@ -1323,6 +1381,9 @@ void t_netstd_generator::generate_netstd_struct_result_writer(ostream& out, t_st if (fields.size() > 0) { tmpvar = tmp("tmp"); + if(target_net_version >= 8) { + out << indent() << "#pragma warning disable IDE0017 // simplified init" << endl; + } out << indent() << "var " << tmpvar << " = new TField();" << endl; bool first = true; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) @@ -1367,6 +1428,9 @@ void t_netstd_generator::generate_netstd_struct_result_writer(ostream& out, t_st indent_down(); out << indent() << "}" << endl; } + if(target_net_version >= 8) { + out << indent() << "#pragma warning restore IDE0017 // simplified init" << endl; + } } out << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl @@ -1481,7 +1545,7 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << endl; scope_up(out); - if( use_net6_features) { + if( target_net_version >= 6) { out << indent() << "if (that is not " << tunion->get_name() << " other) return false;" << endl; } else { out << indent() << "if (!(that is " << tunion->get_name() << " other)) return false;" << endl; @@ -1490,7 +1554,7 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct out << endl; out << indent() << "if(this.Isset != other.Isset) return false;" << endl; out << endl; - if(use_net6_features) { + if(target_net_version >= 6) { out << indent() << "return Isset switch" << endl; scope_up(out); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) @@ -1528,13 +1592,13 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct out << indent() << "public override int GetHashCode()" << endl; out << indent() << "{" << endl; indent_up(); - if(use_net6_features) { + if(target_net_version >= 6) { out << indent() << "return Isset switch" << endl; out << indent() << "{" << endl; indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - string null_coalesce(is_nullable_type((*f_iter)->get_type()) ? "?" : ""); + string null_coalesce(is_nullable_type((*f_iter)->get_type()) ? "?" : ""); out << indent() << (*f_iter)->get_key() << " => As_" << (*f_iter)->get_name() << null_coalesce << ".GetHashCode()"; if( null_coalesce.size() > 0) { out << " ?? 0"; @@ -1550,7 +1614,7 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - string null_coalesce(is_nullable_type((*f_iter)->get_type()) ? "?" : ""); + string null_coalesce(is_nullable_type((*f_iter)->get_type()) ? "?" : ""); out << indent() << "case " << (*f_iter)->get_key() << ":" << endl; indent_up(); out << indent() << "return As_" << (*f_iter)->get_name() << null_coalesce << ".GetHashCode()"; @@ -1574,7 +1638,7 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct out << indent() << "public " << tunion->get_name() << " " << DEEP_COPY_METHOD_NAME << "()" << endl; out << indent() << "{" << endl; indent_up(); - if(use_net6_features) { + if(target_net_version >= 6) { out << indent() << "return Isset switch" << endl; out << indent() << "{" << endl; indent_up(); @@ -1666,7 +1730,7 @@ void t_netstd_generator::generate_netstd_union_class(ostream& out, t_struct* tun out << indent() << "return (" << tfield->get_key() << " == Isset) && (Data != null)" << " ? (" << type_name(tfield->get_type()) << nullable_field_suffix(tfield) << ")Data" << " : default" - << (use_net6_features ? "" : ("(" + type_name(tfield->get_type()) + ")")) + << (target_net_version >= 6 ? "" : ("(" + type_name(tfield->get_type()) + ")")) << ";" << endl; indent_down(); out << indent() << "}" << endl; @@ -1703,7 +1767,7 @@ void t_netstd_generator::generate_netstd_union_class(ostream& out, t_struct* tun out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << endl; out << indent() << "{" << endl; indent_up(); - if(use_net6_features) { + if(target_net_version >= 6) { out << indent() << "if (that is not " << tunion->get_name() << " other) return false;" << endl; } else { out << indent() << "if (!(that is " << tunion->get_name() << " other)) return false;" << endl; @@ -1732,11 +1796,15 @@ void t_netstd_generator::generate_netstd_union_class(ostream& out, t_struct* tun out << indent() << "var struc = new TStruct(\"" << tunion->get_name() << "\");" << endl << indent() << "await oprot.WriteStructBeginAsync(struc, " << CANCELLATION_TOKEN_NAME << ");" << endl; - out << indent() << "var field = new TField();" << endl - << indent() << "field.Name = \"" << tfield->get_name() << "\";" << endl - << indent() << "field.Type = " << type_to_enum(tfield->get_type()) << ";" << endl - << indent() << "field.ID = " << tfield->get_key() << ";" << endl - << indent() << "await oprot.WriteFieldBeginAsync(field, " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "var field = new TField()" << endl; + out << indent() << "{" << endl; + indent_up(); + out << indent() << "Name = \"" << tfield->get_name() << "\"," << endl + << indent() << "Type = " << type_to_enum(tfield->get_type()) << "," << endl + << indent() << "ID = " << tfield->get_key() << endl; + indent_down(); + out << indent() << "};" << endl; + out << indent() << "await oprot.WriteFieldBeginAsync(field, " << CANCELLATION_TOKEN_NAME << ");" << endl; generate_serialize_field(out, tfield, "_data", true, false); @@ -1762,7 +1830,7 @@ void t_netstd_generator::generate_netstd_struct_equals(ostream& out, t_struct* t out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << endl << indent() << "{" << endl; indent_up(); - if(use_net6_features) { + if(target_net_version >= 6) { out << indent() << "if (that is not " << type_name(tstruct,false) << " other) return false;" << endl; } else { out << indent() << "if (!(that is " << type_name(tstruct,false) << " other)) return false;" << endl; @@ -2203,9 +2271,14 @@ void t_netstd_generator::generate_service_server(ostream& out, t_service* tservi if (extends.empty()) { - out << indent() << "protected Dictionary processMap_ = new" - << (use_net6_features ? "" : " Dictionary") // Simplify new expression (IDE0090) - << "();" << endl; + out << indent() << "protected Dictionary processMap_ = "; + if(target_net_version >= 8) { + out << "[];" << endl; + } else if(target_net_version >= 6) { + out << "new();" << endl; + } else { + out << "new Dictionary();" << endl; + } } out << endl; @@ -2960,7 +3033,7 @@ void t_netstd_generator::generate_netstd_property(ostream& out, t_field* tfield, if (is_required) { out << " { get; set; }"; - if( use_net6_features && (!force_member_nullable(tfield))) { + if( (target_net_version >= 6) && (!force_member_nullable(tfield))) { out << initialize_field(tfield) << ";"; } out << endl; @@ -3258,7 +3331,7 @@ bool t_netstd_generator::is_nullable_type(t_type* ttype) { string t_netstd_generator::nullable_suffix() { - if(use_net6_features) { + if(target_net_version >= 6) { return "?"; } else { return ""; @@ -3272,10 +3345,10 @@ string t_netstd_generator::nullable_field_suffix(t_field* tfield) { else return nullable_field_suffix(tfield->get_type()); } - + string t_netstd_generator::nullable_field_suffix(t_type* ttype) { - if( ! use_net6_features) { + if( target_net_version < 6) { return ""; } @@ -3300,7 +3373,7 @@ string t_netstd_generator::nullable_field_suffix(t_type* ttype) { } string t_netstd_generator::nullable_value_access(t_type* ttype) { - if( ! use_net6_features) + if( target_net_version < 6) return ""; ttype = resolve_typedef(ttype); @@ -3326,9 +3399,9 @@ string t_netstd_generator::nullable_value_access(t_type* ttype) { } bool t_netstd_generator::force_member_nullable(t_field* tfield) { - // IMPORTANT: + // IMPORTANT: // If tfield is a struct that contains a required field of the same type (directly or indirectly), - // auto-initializing such a member field would immediately produce an OOM, or at least unexpectedly + // auto-initializing such a member field would immediately produce an OOM, or at least unexpectedly // allocate potentially large amounts of memory -> ALWAYS leave containers and struct members nullable t_type* ttype = resolve_typedef(tfield->get_type()); return ttype->is_struct() || ttype->is_container(); @@ -3427,12 +3500,15 @@ string t_netstd_generator::get_deep_copy_method_call(t_type* ttype, bool is_not_ case t_base_type::TYPE_STRING: if (ttype->is_binary()) { suffix = nullable_suffix(); - if( use_net6_features) { + if( target_net_version >= 8) { + null_check = is_not_null ? "!" : " ?? []"; + } + else if( target_net_version >= 6) { null_check = is_not_null ? "!" : " ?? Array.Empty()"; } return ".ToArray()" + null_check; } else { - if( use_net6_features) { + if( target_net_version >= 6) { null_check = is_not_null ? "!" : " ?? string.Empty"; } return null_check; // simple assignment will do, strings are immutable in C# @@ -3448,23 +3524,25 @@ string t_netstd_generator::get_deep_copy_method_call(t_type* ttype, bool is_not_ } else if (is_union_enabled() && ttype->is_struct() && static_cast(ttype)->is_union()) { - needs_typecast = (! ttype->is_container()); + needs_typecast = (! ttype->is_container()); suffix = nullable_suffix(); - if( use_net6_features) { + if( target_net_version >= 6) { null_check = is_not_null ? "!" : " ?? new "+ttype->get_name() +".___undefined()"; - } + } return "." + DEEP_COPY_METHOD_NAME + "()" + null_check; } else { - needs_typecast = (! ttype->is_container()); + needs_typecast = (! ttype->is_container()); suffix = nullable_suffix(); - if( use_net6_features) { + if( (target_net_version >= 8) && ttype->is_container()) { + null_check = is_not_null ? "!" : " ?? []"; + } else if( target_net_version >= 6) { null_check = is_not_null ? "!" : " ?? new()"; - } + } return "." + DEEP_COPY_METHOD_NAME + "()" + null_check; } - + throw "UNEXPECTED TYPE IN get_deep_copy_method_call: " + ttype->get_name(); } @@ -3486,8 +3564,8 @@ string t_netstd_generator::declare_field(t_field* tfield, bool init, bool allow_ string t_netstd_generator::initialize_field(t_field* tfield) { t_type* ttype = tfield->get_type(); - ttype = resolve_typedef(ttype); - + ttype = resolve_typedef(ttype); + if (ttype->is_base_type() && field_has_default(tfield)) { std::ofstream dummy; @@ -3505,9 +3583,9 @@ string t_netstd_generator::initialize_field(t_field* tfield) case t_base_type::TYPE_VOID: throw "NO T_VOID CONSTRUCT"; case t_base_type::TYPE_STRING: - if(use_net6_features && field_is_required(tfield)) { + if((target_net_version >= 6) && field_is_required(tfield)) { if (ttype->is_binary()) { - return " = Array.Empty()"; + return target_net_version >= 8 ? "= []" : " = Array.Empty()"; } else { return " = string.Empty"; } @@ -3538,7 +3616,7 @@ string t_netstd_generator::initialize_field(t_field* tfield) } else if (ttype->is_container()) { - if(use_net6_features) { + if(target_net_version >= 6) { return " = new()"; } else { return " = new " + type_name(ttype) + "()"; @@ -3546,8 +3624,8 @@ string t_netstd_generator::initialize_field(t_field* tfield) } else if (ttype->is_struct()) { - t_struct* tstruct = static_cast(ttype); - if(use_net6_features) { + t_struct* tstruct = static_cast(ttype); + if(target_net_version >= 6) { if(tstruct->is_union()) { return " = new " + type_name(ttype) + ".___undefined()"; } else { @@ -3557,7 +3635,7 @@ string t_netstd_generator::initialize_field(t_field* tfield) return " = new " + type_name(ttype) + "()"; } } - + throw "UNEXPECTED TYPE IN initialize_field: " + ttype->get_name(); } @@ -3777,6 +3855,7 @@ THRIFT_REGISTER_GENERATOR( " union: Use new union typing, which includes a static read function for union types.\n" " pascal: Generate Pascal Case property names according to Microsoft naming convention.\n" " net6: Enable features that require net6 and C# 8 or higher.\n" + " net8: Enable features that require net8 and C# 12 or higher.\n" " no_deepcopy: Suppress generation of " + DEEP_COPY_METHOD_NAME + "() method.\n" " async_postfix: Append \"Async\" to all service methods (maintains compatibility with existing code).\n" ) diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.h b/compiler/cpp/src/thrift/generate/t_netstd_generator.h index f16f7d3ad7f..ff3cfb1264c 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.h +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.h @@ -154,12 +154,12 @@ class t_netstd_generator : public t_oop_generator protected: std::string autogen_comment() override { string comment = "/**\n"; - if( ! use_net6_features) { + if( target_net_version < 6) { comment += " * \n"; } comment += " * " + autogen_summary() + "\n"; comment += " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n"; - if( ! use_net6_features) { + if( target_net_version < 6) { comment += " * \n"; } comment += " */\n"; @@ -177,7 +177,7 @@ class t_netstd_generator : public t_oop_generator bool wcf_; bool use_pascal_case_properties; bool suppress_deepcopy; - bool use_net6_features; + int target_net_version; // 0 = any, 6 = net6, 8 = net8 bool add_async_postfix; const std::string CSHARP_KEYWORDS[101] = { diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj index b5afef58213..cc2360de7bf 100644 --- a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj +++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj @@ -20,7 +20,8 @@ Exe - net7.0 + net8.0 + latestMajor false true enable diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index 98e80077530..3f52a5fe0f6 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -19,7 +19,8 @@ --> - net7.0 + net8.0 + latestMajor Thrift.IntegrationTests Thrift.IntegrationTests 0.20.0.0 diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj index 6f3abb15587..ecde3668946 100644 --- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj +++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj @@ -21,7 +21,8 @@ 0.20.0 Thrift version $(ThriftVersion) - net7.0 + net8.0 + latestMajor $(ThriftVersion).0 Thrift.PublicInterfaces.Compile.Tests Thrift.PublicInterfaces.Compile.Tests @@ -68,14 +69,14 @@ - - - - - - - - + + + + + + + + diff --git a/lib/netstd/Tests/Thrift.Tests/Collections/TCollectionsTests.cs b/lib/netstd/Tests/Thrift.Tests/Collections/TCollectionsTests.cs index 49108d187f2..c6cd22d4f47 100644 --- a/lib/netstd/Tests/Thrift.Tests/Collections/TCollectionsTests.cs +++ b/lib/netstd/Tests/Thrift.Tests/Collections/TCollectionsTests.cs @@ -56,8 +56,8 @@ public void TCollection_List_Equals_Primitive_Different_Test() [TestMethod] public void TCollection_List_Equals_Objects_Test() { - var collection1 = new List { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } }; - var collection2 = new List { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } }; + var collection1 = new List { new() { X = 1 }, new() { X = 2 } }; + var collection2 = new List { new() { X = 1 }, new() { X = 2 } }; Assert.IsTrue(TCollections.Equals(collection1, collection2)); Assert.IsTrue(collection1.SequenceEqual(collection2)); } @@ -65,8 +65,8 @@ public void TCollection_List_Equals_Objects_Test() [TestMethod] public void TCollection_List_List_Equals_Objects_Test() { - var collection1 = new List> { new List { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } } }; - var collection2 = new List> { new List { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } } }; + var collection1 = new List> { new() { new() { X = 1 }, new() { X = 2 } } }; + var collection2 = new List> { new() { new() { X = 1 }, new() { X = 2 } } }; Assert.IsTrue(TCollections.Equals(collection1, collection2)); Assert.IsFalse(collection1.SequenceEqual(collection2)); // SequenceEqual() calls Equals() of the inner list instead of SequenceEqual() } @@ -74,7 +74,7 @@ public void TCollection_List_List_Equals_Objects_Test() [TestMethod] public void TCollection_List_Equals_OneAndTheSameObject_Test() { - var collection1 = new List { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } }; + var collection1 = new List { new() { X = 1 }, new() { X = 2 } }; var collection2 = collection1; Assert.IsTrue(TCollections.Equals(collection1, collection2)); Assert.IsTrue(collection1.SequenceEqual(collection2)); @@ -105,8 +105,8 @@ public void TCollection_Set_Equals_Primitive_Different_Test() [TestMethod] public void TCollection_Set_Equals_Objects_Test() { - var collection1 = new HashSet { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } }; - var collection2 = new HashSet { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } }; + var collection1 = new HashSet { new() { X = 1 }, new() { X = 2 } }; + var collection2 = new HashSet { new() { X = 1 }, new() { X = 2 } }; Assert.IsTrue(TCollections.Equals(collection1, collection2)); Assert.IsTrue(collection1.SequenceEqual(collection2)); } @@ -114,8 +114,8 @@ public void TCollection_Set_Equals_Objects_Test() [TestMethod] public void TCollection_Set_Set_Equals_Objects_Test() { - var collection1 = new HashSet> { new HashSet { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } } }; - var collection2 = new HashSet> { new HashSet { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } } }; + var collection1 = new HashSet> { new() { new() { X = 1 }, new() { X = 2 } } }; + var collection2 = new HashSet> { new() { new() { X = 1 }, new() { X = 2 } } }; Assert.IsTrue(TCollections.Equals(collection1, collection2)); Assert.IsFalse(collection1.SequenceEqual(collection2)); // SequenceEqual() calls Equals() of the inner list instead of SequenceEqual() } @@ -123,7 +123,7 @@ public void TCollection_Set_Set_Equals_Objects_Test() [TestMethod] public void TCollection_Set_Equals_OneAndTheSameObject_Test() { - var collection1 = new HashSet { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } }; + var collection1 = new HashSet { new() { X = 1 }, new() { X = 2 } }; var collection2 = collection1; // references to one and the same collection Assert.IsTrue(TCollections.Equals(collection1, collection2)); Assert.IsTrue(collection1.SequenceEqual(collection2)); @@ -160,13 +160,13 @@ public void TCollection_Map_Equals_Objects_Test() { var collection1 = new Dictionary { - [1] = new ExampleClass { X = 1 }, - [-1] = new ExampleClass { X = 2 } + [1] = new() { X = 1 }, + [-1] = new() { X = 2 } }; var collection2 = new Dictionary { - [1] = new ExampleClass { X = 1 }, - [-1] = new ExampleClass { X = 2 } + [1] = new() { X = 1 }, + [-1] = new() { X = 2 } }; Assert.IsTrue(TCollections.Equals(collection1, collection2)); @@ -180,16 +180,16 @@ public void TCollection_Map_Map_Equals_Objects_Test() { [0] = new Dictionary { - [1] = new ExampleClass { X = 1 }, - [-1] = new ExampleClass { X = 2 } + [1] = new() { X = 1 }, + [-1] = new() { X = 2 } } }; var collection2 = new Dictionary> { [0] = new Dictionary { - [1] = new ExampleClass { X = 1 }, - [-1] = new ExampleClass { X = 2 } + [1] = new() { X = 1 }, + [-1] = new() { X = 2 } } }; @@ -202,8 +202,8 @@ public void TCollection_Map_Equals_OneAndTheSameObject_Test() { var collection1 = new Dictionary { - [1] = new ExampleClass { X = 1 }, - [-1] = new ExampleClass { X = 2 } + [1] = new() { X = 1 }, + [-1] = new() { X = 2 } }; var collection2 = collection1; Assert.IsTrue(TCollections.Equals(collection1, collection2)); diff --git a/lib/netstd/Tests/Thrift.Tests/DataModel/DeepCopy.cs b/lib/netstd/Tests/Thrift.Tests/DataModel/DeepCopy.cs index 11b5af4eebb..7a43ca86728 100644 --- a/lib/netstd/Tests/Thrift.Tests/DataModel/DeepCopy.cs +++ b/lib/netstd/Tests/Thrift.Tests/DataModel/DeepCopy.cs @@ -59,7 +59,7 @@ public void Test_Complex_DeepCopy() return instance; } - private jack? MakeNestedUnion(int nesting) + private jack.nested_struct? MakeNestedUnion(int nesting) { if (++nesting > 1) return null; @@ -148,14 +148,14 @@ private RaceDetails InitializeInstance(RaceDetails instance, int nesting = 0) if (nesting < 2) { - instance.Far_list = new List() { Distance.foo, Distance.bar, Distance.baz }; - instance.Far_set = new HashSet() { Distance.foo, Distance.bar, Distance.baz }; - instance.Far_map = new Dictionary() { [Distance.foo] = Distance.foo, [Distance.bar] = Distance.bar, [Distance.baz] = Distance.baz }; + instance.Far_list = [Distance.foo, Distance.bar, Distance.baz]; + instance.Far_set = [Distance.foo, Distance.bar, Distance.baz]; + instance.Far_map = new() { [Distance.foo] = Distance.foo, [Distance.bar] = Distance.bar, [Distance.baz] = Distance.baz }; - instance.Far_set_list = new HashSet>() { new List() { Distance.foo } }; - instance.Far_list_map_set = new List>>() { new Dictionary>() { [1] = new HashSet() { Distance.baz } } }; + instance.Far_set_list = [[Distance.foo]]; + instance.Far_list_map_set = [new Dictionary>() { [1] = [Distance.baz] }]; - instance.Far_map_dist_to_rds = new Dictionary>() { [Distance.bar] = new List() }; + instance.Far_map_dist_to_rds = new() { [Distance.bar] = [] }; var details = MakeNestedRaceDetails(nesting); if (details != null) instance.Far_map_dist_to_rds[Distance.bar].Add(details); @@ -265,8 +265,7 @@ private void ModifyInstance(RaceDetails instance, int level) if (++level > 4) return value; - if (value == null) - value = MakeNestedUnion(0); + value ??= MakeNestedUnion(0); Debug.Assert(value?.As_nested_struct != null); ModifyInstance(value.As_nested_struct, level); return value; @@ -277,23 +276,21 @@ private void ModifyInstance(RaceDetails instance, int level) if (++level > 4) return value; - if (value == null) - value = new RaceDetails(); + value ??= new RaceDetails(); ModifyInstance(value,level); return value; } private Dictionary> ModifyValue(Dictionary>? value, int level) { - if (value == null) - value = new Dictionary>(); + value ??= []; if (++level > 4) return value; var details = new RaceDetails(); InitializeInstance(details); - value[Distance.foo] = new List() { details }; + value[Distance.foo] = [details]; if (value.TryGetValue(Distance.bar, out var list) && (list.Count > 0)) { @@ -309,17 +306,16 @@ private Dictionary> ModifyValue(Dictionary>> ModifyValue(List>>? value) { - if (value == null) - value = new List>>(); + value ??= []; if (value.Count == 0) - value.Add(new Dictionary>()); + value.Add([]); //else //value.Add(null); --Thrift does not allow null values in containers sbyte key = (sbyte)(value[0].Count + 10); if (value[0].Count == 0) - value[0].Add(key, new HashSet()); + value[0].Add(key, []); //else //value[0].Add(key, null); --Thrift does not allow null values in containers @@ -331,9 +327,7 @@ private static List>> ModifyValue(List>> ModifyValue(List> ModifyValue(HashSet>? value) { - if (value == null) - value = new HashSet>(); + value ??= []; if (value.Count == 0) - value.Add(new List()); + value.Add([]); //else //value.Add(null); -- Thrift does not allow null values in containers foreach (var entry in value) - if( entry != null) - entry.Add(Distance.baz); + entry?.Add(Distance.baz); return value; } private static Dictionary ModifyValue(Dictionary? value) { - if (value == null) - value = new Dictionary(); + value ??= []; value[Distance.foo] = value.ContainsKey(Distance.foo) ? ++value[Distance.foo] : Distance.foo; value[Distance.bar] = value.ContainsKey(Distance.bar) ? ++value[Distance.bar] : Distance.bar; value[Distance.baz] = value.ContainsKey(Distance.baz) ? ++value[Distance.baz] : Distance.baz; @@ -372,22 +363,15 @@ private static Dictionary ModifyValue(Dictionary ModifyValue(HashSet? value) { - if (value == null) - value = new HashSet(); + value ??= []; - if (value.Contains(Distance.foo)) - value.Remove(Distance.foo); - else + if (!value.Remove(Distance.foo)) value.Add(Distance.foo); - if (value.Contains(Distance.bar)) - value.Remove(Distance.bar); - else + if (!value.Remove(Distance.bar)) value.Add(Distance.bar); - if (value.Contains(Distance.baz)) - value.Remove(Distance.baz); - else + if (!value.Remove(Distance.baz)) value.Add(Distance.baz); return value; @@ -395,8 +379,7 @@ private static HashSet ModifyValue(HashSet? value) private static List ModifyValue(List? value) { - if (value == null) - value = new List(); + value ??= []; value.Add(Distance.foo); value.Add(Distance.bar); value.Add(Distance.baz); @@ -410,36 +393,32 @@ private static bool ModifyValue(bool value) private static Dictionary ModifyValue(Dictionary? value) { - if (value == null) - value = new Dictionary(); + value ??= []; value.Add((sbyte)(value.Count + 10), (short)value.Count); return value; } private static HashSet ModifyValue(HashSet? value) { - if (value == null) - value = new HashSet(); + value ??= []; value.Add(value.Count+100); return value; } private static List ModifyValue(List? value) { - if (value == null) - value = new List(); + value ??= []; value.Add(value.Count); return value; } private static byte[] ModifyValue(byte[]? value) { - if (value == null) - value = new byte[1] { 0 }; + value ??= [0]; if (value.Length > 0) value[0] = (value[0] < 0xFF) ? ++value[0] : (byte)0; else - value = new byte[1] { 0 }; + value = [0]; return value; } diff --git a/lib/netstd/Tests/Thrift.Tests/DataModel/NullValuesSet.cs b/lib/netstd/Tests/Thrift.Tests/DataModel/NullValuesSet.cs index 80eacc25896..09f725140a8 100644 --- a/lib/netstd/Tests/Thrift.Tests/DataModel/NullValuesSet.cs +++ b/lib/netstd/Tests/Thrift.Tests/DataModel/NullValuesSet.cs @@ -25,6 +25,7 @@ using OptReqDefTest; using Thrift.Collections; +#pragma warning disable IDE0079 // net20 - unneeded suppression #pragma warning disable IDE0017 // init can be simplified - we don't want that here namespace Thrift.Tests.DataModel diff --git a/lib/netstd/Tests/Thrift.Tests/Protocols/TJsonProtocolHelperTests.cs b/lib/netstd/Tests/Thrift.Tests/Protocols/TJsonProtocolHelperTests.cs index 6d391516e44..03e3efa701e 100644 --- a/lib/netstd/Tests/Thrift.Tests/Protocols/TJsonProtocolHelperTests.cs +++ b/lib/netstd/Tests/Thrift.Tests/Protocols/TJsonProtocolHelperTests.cs @@ -1,4 +1,4 @@ -// Licensed to the Apache Software Foundation(ASF) under one +// Licensed to the Apache Software Foundation(ASF) under one // or more contributor license agreements.See the NOTICE file // distributed with this work for additional information // regarding copyright ownership.The ASF licenses this file @@ -34,17 +34,17 @@ public void GetTypeNameForTypeId_Test() // input/output var sets = new List> { - new Tuple(TType.Bool, TJSONProtocolConstants.TypeNames.NameBool), - new Tuple(TType.Byte, TJSONProtocolConstants.TypeNames.NameByte), - new Tuple(TType.I16, TJSONProtocolConstants.TypeNames.NameI16), - new Tuple(TType.I32, TJSONProtocolConstants.TypeNames.NameI32), - new Tuple(TType.I64, TJSONProtocolConstants.TypeNames.NameI64), - new Tuple(TType.Double, TJSONProtocolConstants.TypeNames.NameDouble), - new Tuple(TType.String, TJSONProtocolConstants.TypeNames.NameString), - new Tuple(TType.Struct, TJSONProtocolConstants.TypeNames.NameStruct), - new Tuple(TType.Map, TJSONProtocolConstants.TypeNames.NameMap), - new Tuple(TType.Set, TJSONProtocolConstants.TypeNames.NameSet), - new Tuple(TType.List, TJSONProtocolConstants.TypeNames.NameList), + new(TType.Bool, TJSONProtocolConstants.TypeNames.NameBool), + new(TType.Byte, TJSONProtocolConstants.TypeNames.NameByte), + new(TType.I16, TJSONProtocolConstants.TypeNames.NameI16), + new(TType.I32, TJSONProtocolConstants.TypeNames.NameI32), + new(TType.I64, TJSONProtocolConstants.TypeNames.NameI64), + new(TType.Double, TJSONProtocolConstants.TypeNames.NameDouble), + new(TType.String, TJSONProtocolConstants.TypeNames.NameString), + new(TType.Struct, TJSONProtocolConstants.TypeNames.NameStruct), + new(TType.Map, TJSONProtocolConstants.TypeNames.NameMap), + new(TType.Set, TJSONProtocolConstants.TypeNames.NameSet), + new(TType.List, TJSONProtocolConstants.TypeNames.NameList), }; foreach (var t in sets) @@ -73,17 +73,17 @@ public void GetTypeIdForTypeName_Test() // input/output var sets = new List> { - new Tuple(TType.Bool, TJSONProtocolConstants.TypeNames.NameBool), - new Tuple(TType.Byte, TJSONProtocolConstants.TypeNames.NameByte), - new Tuple(TType.I16, TJSONProtocolConstants.TypeNames.NameI16), - new Tuple(TType.I32, TJSONProtocolConstants.TypeNames.NameI32), - new Tuple(TType.I64, TJSONProtocolConstants.TypeNames.NameI64), - new Tuple(TType.Double, TJSONProtocolConstants.TypeNames.NameDouble), - new Tuple(TType.String, TJSONProtocolConstants.TypeNames.NameString), - new Tuple(TType.Struct, TJSONProtocolConstants.TypeNames.NameStruct), - new Tuple(TType.Map, TJSONProtocolConstants.TypeNames.NameMap), - new Tuple(TType.Set, TJSONProtocolConstants.TypeNames.NameSet), - new Tuple(TType.List, TJSONProtocolConstants.TypeNames.NameList), + new(TType.Bool, TJSONProtocolConstants.TypeNames.NameBool), + new(TType.Byte, TJSONProtocolConstants.TypeNames.NameByte), + new(TType.I16, TJSONProtocolConstants.TypeNames.NameI16), + new(TType.I32, TJSONProtocolConstants.TypeNames.NameI32), + new(TType.I64, TJSONProtocolConstants.TypeNames.NameI64), + new(TType.Double, TJSONProtocolConstants.TypeNames.NameDouble), + new(TType.String, TJSONProtocolConstants.TypeNames.NameString), + new(TType.Struct, TJSONProtocolConstants.TypeNames.NameStruct), + new(TType.Map, TJSONProtocolConstants.TypeNames.NameMap), + new(TType.Set, TJSONProtocolConstants.TypeNames.NameSet), + new(TType.List, TJSONProtocolConstants.TypeNames.NameList), }; foreach (var t in sets) @@ -96,21 +96,21 @@ public void GetTypeIdForTypeName_Test() [ExpectedException(typeof(TProtocolException))] public void GetTypeIdForTypeName_TStopTypeName_Test() { - TJSONProtocolHelper.GetTypeIdForTypeName(new []{(byte)TType.Stop, (byte)TType.Stop}); + TJSONProtocolHelper.GetTypeIdForTypeName([(byte)TType.Stop, (byte)TType.Stop]); } [TestMethod] [ExpectedException(typeof(TProtocolException))] public void GetTypeIdForTypeName_NonExistingTypeName_Test() { - TJSONProtocolHelper.GetTypeIdForTypeName(new byte[]{100}); + TJSONProtocolHelper.GetTypeIdForTypeName([100]); } [TestMethod] [ExpectedException(typeof(TProtocolException))] public void GetTypeIdForTypeName_EmptyName_Test() { - TJSONProtocolHelper.GetTypeIdForTypeName(new byte[] {}); + TJSONProtocolHelper.GetTypeIdForTypeName([]); } [TestMethod] @@ -169,4 +169,4 @@ public void ToHexChar_Test() } } } -} \ No newline at end of file +} diff --git a/lib/netstd/Tests/Thrift.Tests/Protocols/TJsonProtocolTests.cs b/lib/netstd/Tests/Thrift.Tests/Protocols/TJsonProtocolTests.cs index 4054a29f255..4f14ba792dc 100644 --- a/lib/netstd/Tests/Thrift.Tests/Protocols/TJsonProtocolTests.cs +++ b/lib/netstd/Tests/Thrift.Tests/Protocols/TJsonProtocolTests.cs @@ -51,12 +51,8 @@ public void TJSONProtocol_Can_Create_Instance_Test() Assert.IsTrue(result.WrappedReader.GetType().Name.Equals("LookaheadReader", StringComparison.OrdinalIgnoreCase)); } - private class TJSONProtocolWrapper : TJsonProtocol + private class TJSONProtocolWrapper(TTransport trans) : TJsonProtocol(trans) { - public TJSONProtocolWrapper(TTransport trans) : base(trans) - { - } - public object WrappedContext => Context; public object WrappedReader => Reader; public int WrappedRecursionDepth => RecursionDepth; diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index 94b7b09c1bc..54ce1e89c4b 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -19,7 +19,8 @@ --> - net7.0 + net8.0 + latestMajor 0.20.0.0 enable diff --git a/lib/netstd/Thrift/.editorconfig b/lib/netstd/Thrift/.editorconfig index 54b698cf480..82ff4a36058 100644 --- a/lib/netstd/Thrift/.editorconfig +++ b/lib/netstd/Thrift/.editorconfig @@ -2,3 +2,8 @@ # CS1591: missing XML comment for public element dotnet_diagnostic.CS1591.severity = silent + +# silence certain yet unfixed false positives for net8 +dotnet_diagnostic.IDE0290.severity = silent +dotnet_diagnostic.CA1510.severity = silent +dotnet_diagnostic.CA1513.severity = silent diff --git a/lib/netstd/Thrift/Processor/TMultiplexedProcessor.cs b/lib/netstd/Thrift/Processor/TMultiplexedProcessor.cs index 9759058b310..5fc1fda4e0f 100644 --- a/lib/netstd/Thrift/Processor/TMultiplexedProcessor.cs +++ b/lib/netstd/Thrift/Processor/TMultiplexedProcessor.cs @@ -23,6 +23,11 @@ using Thrift.Protocol; using Thrift.Protocol.Entities; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0028 // net8 - simplified collection init +#pragma warning disable IDE0300 // net8 - simplified collection init +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Processor { // ReSharper disable once InconsistentNaming @@ -30,8 +35,7 @@ public class TMultiplexedProcessor : ITAsyncProcessor { //TODO: Localization - private readonly Dictionary _serviceProcessorMap = - new Dictionary(); + private readonly Dictionary _serviceProcessorMap = new Dictionary(); public async Task ProcessAsync(TProtocol iprot, TProtocol oprot) { diff --git a/lib/netstd/Thrift/Processor/TSingletonProcessorFactory.cs b/lib/netstd/Thrift/Processor/TSingletonProcessorFactory.cs index 97ecff65c45..568a50c516e 100644 --- a/lib/netstd/Thrift/Processor/TSingletonProcessorFactory.cs +++ b/lib/netstd/Thrift/Processor/TSingletonProcessorFactory.cs @@ -1,4 +1,4 @@ -// Licensed to the Apache Software Foundation(ASF) under one +// Licensed to the Apache Software Foundation(ASF) under one // or more contributor license agreements.See the NOTICE file // distributed with this work for additional information // regarding copyright ownership.The ASF licenses this file @@ -18,6 +18,9 @@ using Thrift.Server; using Thrift.Transport; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Processor { // ReSharper disable once InconsistentNaming @@ -35,4 +38,4 @@ public ITAsyncProcessor GetAsyncProcessor(TTransport trans, TServer baseServer = return _asyncProcessor; } } -} \ No newline at end of file +} diff --git a/lib/netstd/Thrift/Protocol/Entities/TField.cs b/lib/netstd/Thrift/Protocol/Entities/TField.cs index 4e29bb5d4e4..92fd41a8ba6 100644 --- a/lib/netstd/Thrift/Protocol/Entities/TField.cs +++ b/lib/netstd/Thrift/Protocol/Entities/TField.cs @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Protocol.Entities { // ReSharper disable once InconsistentNaming @@ -34,4 +37,4 @@ public TField(string name, TType type, short id) // ReSharper disable once InconsistentNaming - do not rename - it used for generation public short ID { get; set; } } -} \ No newline at end of file +} diff --git a/lib/netstd/Thrift/Protocol/Entities/TList.cs b/lib/netstd/Thrift/Protocol/Entities/TList.cs index f5992256444..7e5c5457beb 100644 --- a/lib/netstd/Thrift/Protocol/Entities/TList.cs +++ b/lib/netstd/Thrift/Protocol/Entities/TList.cs @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Protocol.Entities { // ReSharper disable once InconsistentNaming @@ -30,4 +33,4 @@ public TList(TType elementType, int count) public int Count { get; set; } } -} \ No newline at end of file +} diff --git a/lib/netstd/Thrift/Protocol/Entities/TMap.cs b/lib/netstd/Thrift/Protocol/Entities/TMap.cs index 1efebe7a199..fba57809721 100644 --- a/lib/netstd/Thrift/Protocol/Entities/TMap.cs +++ b/lib/netstd/Thrift/Protocol/Entities/TMap.cs @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Protocol.Entities { // ReSharper disable once InconsistentNaming @@ -33,4 +36,4 @@ public TMap(TType keyType, TType valueType, int count) public int Count { get; set; } } -} \ No newline at end of file +} diff --git a/lib/netstd/Thrift/Protocol/Entities/TMessage.cs b/lib/netstd/Thrift/Protocol/Entities/TMessage.cs index 08d741d65ec..2e586ea68bc 100644 --- a/lib/netstd/Thrift/Protocol/Entities/TMessage.cs +++ b/lib/netstd/Thrift/Protocol/Entities/TMessage.cs @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Protocol.Entities { // ReSharper disable once InconsistentNaming @@ -34,4 +37,4 @@ public TMessage(string name, TMessageType type, int seqid) // ReSharper disable once InconsistentNaming - do not rename - it used for generation public int SeqID { get; set; } } -} \ No newline at end of file +} diff --git a/lib/netstd/Thrift/Protocol/Entities/TSet.cs b/lib/netstd/Thrift/Protocol/Entities/TSet.cs index 692d5642c4e..d29cc0db784 100644 --- a/lib/netstd/Thrift/Protocol/Entities/TSet.cs +++ b/lib/netstd/Thrift/Protocol/Entities/TSet.cs @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Protocol.Entities { // ReSharper disable once InconsistentNaming @@ -35,4 +38,4 @@ public TSet(TList list) public int Count { get; set; } } -} \ No newline at end of file +} diff --git a/lib/netstd/Thrift/Protocol/Entities/TStruct.cs b/lib/netstd/Thrift/Protocol/Entities/TStruct.cs index d87608799c1..b2fd00060d2 100644 --- a/lib/netstd/Thrift/Protocol/Entities/TStruct.cs +++ b/lib/netstd/Thrift/Protocol/Entities/TStruct.cs @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Protocol.Entities { // ReSharper disable once InconsistentNaming diff --git a/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs b/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs index 7feb698b458..6389184a41c 100644 --- a/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs +++ b/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs @@ -24,6 +24,8 @@ using Thrift.Protocol.Utilities; using Thrift.Transport; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR namespace Thrift.Protocol { @@ -33,8 +35,8 @@ public class TBinaryProtocol : TProtocol protected const uint VersionMask = 0xffff0000; protected const uint Version1 = 0x80010000; - protected bool StrictRead; - protected bool StrictWrite; + protected readonly bool StrictRead; + protected readonly bool StrictWrite; // minimize memory allocations by means of an preallocated bytes buffer // The value of 128 is arbitrarily chosen, the required minimum size must be sizeof(long) @@ -470,15 +472,10 @@ public override int GetMinSerializedSize(TType type) public class Factory : TProtocolFactory { - protected bool StrictRead; - protected bool StrictWrite; + protected readonly bool StrictRead; + protected readonly bool StrictWrite; - public Factory() - : this(false, true) - { - } - - public Factory(bool strictRead, bool strictWrite) + public Factory(bool strictRead = false, bool strictWrite = true) { StrictRead = strictRead; StrictWrite = strictWrite; diff --git a/lib/netstd/Thrift/Protocol/TCompactProtocol.cs b/lib/netstd/Thrift/Protocol/TCompactProtocol.cs index dd38f48705a..8e5d00d14f6 100644 --- a/lib/netstd/Thrift/Protocol/TCompactProtocol.cs +++ b/lib/netstd/Thrift/Protocol/TCompactProtocol.cs @@ -27,6 +27,8 @@ using Thrift.Protocol.Utilities; using Thrift.Transport; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0301 // net8 - simplified collection init namespace Thrift.Protocol { diff --git a/lib/netstd/Thrift/Protocol/TJSONProtocol.cs b/lib/netstd/Thrift/Protocol/TJSONProtocol.cs index 9f761aeaee5..64308d60be6 100644 --- a/lib/netstd/Thrift/Protocol/TJSONProtocol.cs +++ b/lib/netstd/Thrift/Protocol/TJSONProtocol.cs @@ -27,6 +27,8 @@ using Thrift.Protocol.Utilities; using Thrift.Transport; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR namespace Thrift.Protocol { diff --git a/lib/netstd/Thrift/Protocol/TMultiplexedProtocol.cs b/lib/netstd/Thrift/Protocol/TMultiplexedProtocol.cs index fbc8c05ccd7..510dc28af16 100644 --- a/lib/netstd/Thrift/Protocol/TMultiplexedProtocol.cs +++ b/lib/netstd/Thrift/Protocol/TMultiplexedProtocol.cs @@ -19,6 +19,9 @@ using System.Threading.Tasks; using Thrift.Protocol.Entities; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Protocol { /** diff --git a/lib/netstd/Thrift/Protocol/ToString.cs b/lib/netstd/Thrift/Protocol/ToString.cs index ae69d1cb950..9a94c081324 100644 --- a/lib/netstd/Thrift/Protocol/ToString.cs +++ b/lib/netstd/Thrift/Protocol/ToString.cs @@ -34,16 +34,16 @@ public static void ToString(this object self, StringBuilder sb, bool first = tru sb.Append(", "); bool first_child = true; - if (self is string) // string is IEnumerable + if (self is string str) // string is IEnumerable { sb.Append('"'); - sb.Append(self); + sb.Append(str); sb.Append('"'); } - else if (self is IDictionary) + else if (self is IDictionary dict) { sb.Append("{ "); - foreach (DictionaryEntry pair in (self as IDictionary)) + foreach (DictionaryEntry pair in dict) { if (first_child) first_child = false; @@ -58,23 +58,23 @@ public static void ToString(this object self, StringBuilder sb, bool first = tru } sb.Append('}'); } - else if (self is IEnumerable) + else if (self is IEnumerable enumerable) { sb.Append("{ "); - foreach (var elm in (self as IEnumerable)) + foreach (var elm in enumerable) { elm.ToString(sb, first_child); first_child = false; } sb.Append('}'); } - else if (self is TBase) + else if (self is TBase tbase) { - sb.Append((self as TBase).ToString()); + sb.Append(tbase.ToString()); } - else if (self is double) + else if (self is double dbVal) { - sb.Append(((double)self).ToString(CultureInfo.InvariantCulture)); + sb.Append(dbVal.ToString(CultureInfo.InvariantCulture)); } else { diff --git a/lib/netstd/Thrift/Protocol/Utilities/TBase64Utils.cs b/lib/netstd/Thrift/Protocol/Utilities/TBase64Utils.cs index 90b8f8867b1..15ef04faff5 100644 --- a/lib/netstd/Thrift/Protocol/Utilities/TBase64Utils.cs +++ b/lib/netstd/Thrift/Protocol/Utilities/TBase64Utils.cs @@ -17,6 +17,12 @@ using System; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0300 // net8 - simplified collection init +#pragma warning disable IDE0028 // net8 - simplified collection init +#pragma warning disable CA1510 // net8 - use ThrowIfNull +#pragma warning disable CA1513 // net8 - use ThrowIfNull + namespace Thrift.Protocol.Utilities { // ReSharper disable once InconsistentNaming @@ -98,4 +104,4 @@ internal static void Decode(byte[] src, int srcOff, int len, byte[] dst, int dst } } } -} \ No newline at end of file +} diff --git a/lib/netstd/Thrift/Protocol/Utilities/TGuidExtensions.cs b/lib/netstd/Thrift/Protocol/Utilities/TGuidExtensions.cs index 190ddbbc5f3..ecc026369c0 100644 --- a/lib/netstd/Thrift/Protocol/Utilities/TGuidExtensions.cs +++ b/lib/netstd/Thrift/Protocol/Utilities/TGuidExtensions.cs @@ -42,9 +42,7 @@ public static Guid SwapByteOrder(this Guid self) private static void SwapBytes(ref byte one, ref byte two) { - var tmp = one; - one = two; - two = tmp; + (two, one) = (one, two); } #region SelfTest diff --git a/lib/netstd/Thrift/Protocol/Utilities/TJsonProtocolConstants.cs b/lib/netstd/Thrift/Protocol/Utilities/TJsonProtocolConstants.cs index f8c261aa8f0..6e248db8d77 100644 --- a/lib/netstd/Thrift/Protocol/Utilities/TJsonProtocolConstants.cs +++ b/lib/netstd/Thrift/Protocol/Utilities/TJsonProtocolConstants.cs @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0300 // net8 - simplified collection init + namespace Thrift.Protocol.Utilities { // ReSharper disable once InconsistentNaming diff --git a/lib/netstd/Thrift/Server/TServer.cs b/lib/netstd/Thrift/Server/TServer.cs index 3d4f3fc2077..5f5bc498c9d 100644 --- a/lib/netstd/Thrift/Server/TServer.cs +++ b/lib/netstd/Thrift/Server/TServer.cs @@ -65,8 +65,7 @@ public ITServerEventHandler GetEventHandler() // Log delegation? deprecated, use ILogger protected void LogError( string msg) { - if (Logger != null) - Logger.LogError("{Msg}",msg); // NOTE: Log message template, not string interpolation! + Logger?.LogError("{Msg}",msg); // NOTE: Log message template, not string interpolation! } public abstract void Stop(); diff --git a/lib/netstd/Thrift/Server/TSimpleAsyncServer.cs b/lib/netstd/Thrift/Server/TSimpleAsyncServer.cs index f1f6277d5af..ffa3b883581 100644 --- a/lib/netstd/Thrift/Server/TSimpleAsyncServer.cs +++ b/lib/netstd/Thrift/Server/TSimpleAsyncServer.cs @@ -23,6 +23,8 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR namespace Thrift.Server { diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index 2ebfb06df38..c7b2a828ecc 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -19,7 +19,7 @@ --> - netstandard2.1;netstandard2.0;net6.0;net7.0 + netstandard2.1;netstandard2.0;net6.0;net7.0;net8.0 Thrift ApacheThrift true diff --git a/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs b/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs index bda12900798..0a51c9a2378 100644 --- a/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs +++ b/lib/netstd/Thrift/Transport/Client/TTlsSocketTransport.cs @@ -25,6 +25,9 @@ using System.Threading; using System.Threading.Tasks; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0028 // net8 - simplified collection init + namespace Thrift.Transport.Client { //TODO: check for correct work diff --git a/lib/netstd/Thrift/Transport/Layered/TFramedTransport.cs b/lib/netstd/Thrift/Transport/Layered/TFramedTransport.cs index 694ea0f4066..5e67f10cda6 100644 --- a/lib/netstd/Thrift/Transport/Layered/TFramedTransport.cs +++ b/lib/netstd/Thrift/Transport/Layered/TFramedTransport.cs @@ -21,6 +21,10 @@ using System.Threading; using System.Threading.Tasks; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable CA1510 // net8 - use ThrowIfNull +#pragma warning disable CA1513 // net8 - use ThrowIfNull + namespace Thrift.Transport { // ReSharper disable once InconsistentNaming diff --git a/lib/netstd/Thrift/Transport/Layered/TLayeredTransport.cs b/lib/netstd/Thrift/Transport/Layered/TLayeredTransport.cs index 98fbd227d5a..3d855a4f5f0 100644 --- a/lib/netstd/Thrift/Transport/Layered/TLayeredTransport.cs +++ b/lib/netstd/Thrift/Transport/Layered/TLayeredTransport.cs @@ -1,4 +1,4 @@ -// Licensed to the Apache Software Foundation(ASF) under one +// Licensed to the Apache Software Foundation(ASF) under one // or more contributor license agreements.See the NOTICE file // distributed with this work for additional information // regarding copyright ownership.The ASF licenses this file @@ -16,8 +16,9 @@ // under the License. using System; -using System.Collections.Generic; -using System.Text; + +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR namespace Thrift.Transport { diff --git a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs index b1ed91ef16d..138c7fd9b14 100644 --- a/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs +++ b/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs @@ -28,6 +28,11 @@ using System.IO; using System.Diagnostics; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0028 // net8 - simplified collection init +#pragma warning disable IDE0300 // net8 - simplified collection init +#pragma warning disable IDE0290 // net8 - primary CTOR +#pragma warning disable SYSLIB1054 // net8 - use LibraryImport attribute #pragma warning disable CS1998 // async no await namespace Thrift.Transport.Server @@ -46,7 +51,7 @@ public class TNamedPipeServerTransport : TServerTransport // to manage incoming connections, we set up a task for each stream to listen on private struct TaskStreamPair { - public NamedPipeServerStream Stream; + public readonly NamedPipeServerStream Stream; public Task Task; public TaskStreamPair(NamedPipeServerStream stream, Task task) @@ -321,8 +326,9 @@ protected override async ValueTask AcceptImplementationAsync(Cancell // there must be an exact mapping between task index and stream index Debug.Assert(_streams.Count == tasks.Count); + #pragma warning disable IDE0305 // see https://github.com/dotnet/roslyn/issues/70656 - yet unsolved var index = Task.WaitAny(tasks.ToArray(), cancellationToken); - + #pragma warning restore IDE0305 var trans = new ServerTransport(_streams[index].Stream, Configuration); _streams.RemoveAt(index); // pass stream ownership to ServerTransport diff --git a/lib/netstd/Thrift/Transport/Server/TServerSocketTransport.cs b/lib/netstd/Thrift/Transport/Server/TServerSocketTransport.cs index 31ecef3aa6f..43663c3a78e 100644 --- a/lib/netstd/Thrift/Transport/Server/TServerSocketTransport.cs +++ b/lib/netstd/Thrift/Transport/Server/TServerSocketTransport.cs @@ -22,6 +22,9 @@ using System.Threading.Tasks; using Thrift.Transport.Client; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Transport.Server { diff --git a/lib/netstd/Thrift/Transport/Server/TServerTransport.cs b/lib/netstd/Thrift/Transport/Server/TServerTransport.cs index 5366114b0dd..70857c5887a 100644 --- a/lib/netstd/Thrift/Transport/Server/TServerTransport.cs +++ b/lib/netstd/Thrift/Transport/Server/TServerTransport.cs @@ -18,6 +18,9 @@ using System.Threading; using System.Threading.Tasks; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable IDE0290 // net8 - primary CTOR + namespace Thrift.Transport { // ReSharper disable once InconsistentNaming @@ -40,14 +43,8 @@ public TServerTransport(TConfiguration config) public async ValueTask AcceptAsync(CancellationToken cancellationToken = default) { - var transport = await AcceptImplementationAsync(cancellationToken); - - if (transport == null) - { - throw new TTransportException($"{nameof(AcceptImplementationAsync)} should not return null"); - } - - return transport; + return await AcceptImplementationAsync(cancellationToken) + ?? throw new TTransportException($"{nameof(AcceptImplementationAsync)} should not return null"); } } } diff --git a/lib/netstd/Thrift/Transport/TTransport.cs b/lib/netstd/Thrift/Transport/TTransport.cs index 2f87ca0bee5..44202249243 100644 --- a/lib/netstd/Thrift/Transport/TTransport.cs +++ b/lib/netstd/Thrift/Transport/TTransport.cs @@ -1,4 +1,4 @@ -// Licensed to the Apache Software Foundation(ASF) under one +// Licensed to the Apache Software Foundation(ASF) under one // or more contributor license agreements.See the NOTICE file // distributed with this work for additional information // regarding copyright ownership.The ASF licenses this file @@ -21,6 +21,10 @@ using System.Threading; using System.Threading.Tasks; +#pragma warning disable IDE0079 // net20 - unneeded suppression +#pragma warning disable CA1510 // net8 - use ThrowIfNull +#pragma warning disable CA1513 // net8 - use ThrowIfNull + namespace Thrift.Transport { //TODO: think about client info diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index 1ae67fa4053..0e1eaa3af8f 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -19,8 +19,8 @@ --> - net7.0 - 9.0 + net8.0 + latestMajor Client Client Exe @@ -49,8 +49,8 @@ - - - + + + diff --git a/test/netstd/Client/Performance/PerformanceTests.cs b/test/netstd/Client/Performance/PerformanceTests.cs index 6ac3aed861a..5262379a622 100644 --- a/test/netstd/Client/Performance/PerformanceTests.cs +++ b/test/netstd/Client/Performance/PerformanceTests.cs @@ -28,8 +28,6 @@ using System.Diagnostics; using Thrift.Transport; -#pragma warning disable CS1998 // no await in async method - namespace Client.Tests { public class PerformanceTests @@ -44,7 +42,7 @@ public class PerformanceTests internal static async Task Execute() { var instance = new PerformanceTests(); - instance.ProtocolPeformanceTestAsync().Wait(); + await instance.ProtocolPeformanceTestAsync(); // debug only if (Debugger.IsAttached) @@ -101,7 +99,7 @@ private async Task GenericProtocolFactory(bool forWrite) ; if (!Transport.IsOpen) - Transport.OpenAsync().Wait(); + await Transport.OpenAsync(); if (Activator.CreateInstance(typeof(T), Transport) is T instance) return instance; diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs index 3bf2daaae48..74867122951 100644 --- a/test/netstd/Client/TestClient.cs +++ b/test/netstd/Client/TestClient.cs @@ -17,7 +17,6 @@ #pragma warning disable IDE0066 // switch expression #pragma warning disable IDE0057 // substring -#pragma warning disable CS1998 // no await in async method using System; using System.Collections.Generic; @@ -93,19 +92,19 @@ internal void Parse(List args) } else if (args[i].StartsWith("--pipe=")) { - pipe = args[i].Substring(args[i].IndexOf("=") + 1); + pipe = args[i].Substring(args[i].IndexOf('=') + 1); transport = TransportChoice.NamedPipe; } else if (args[i].StartsWith("--host=")) { // check there for ipaddress - host = args[i].Substring(args[i].IndexOf("=") + 1); + host = args[i].Substring(args[i].IndexOf('=') + 1); if (transport != TransportChoice.TlsSocket) transport = TransportChoice.Socket; } else if (args[i].StartsWith("--port=")) { - port = int.Parse(args[i].Substring(args[i].IndexOf("=") + 1)); + port = int.Parse(args[i].Substring(args[i].IndexOf('=') + 1)); if (transport != TransportChoice.TlsSocket) transport = TransportChoice.Socket; } @@ -393,7 +392,7 @@ internal static void PrintOptionsHelp() Console.WriteLine(); } - public static async Task Execute(List args) + public static Task Execute(List args) { try { @@ -408,7 +407,7 @@ public static async Task Execute(List args) Console.WriteLine("*** FAILED ***"); Console.WriteLine("Error while parsing arguments"); Console.WriteLine("{0} {1}\nStack:\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace); - return ErrorUnknown; + return Task.FromResult(ErrorUnknown); } //issue tests on separate threads simultaneously @@ -432,14 +431,14 @@ public static async Task Execute(List args) Task.WaitAll(tasks); Console.WriteLine("Total time: " + (DateTime.Now - start)); Console.WriteLine(); - return retcode; + return Task.FromResult(retcode); } catch (Exception outerEx) { Console.WriteLine("*** FAILED ***"); Console.WriteLine("Unexpected error"); Console.WriteLine(outerEx.Message + "\n" + outerEx.StackTrace); - return ErrorUnknown; + return Task.FromResult(ErrorUnknown); } } @@ -646,8 +645,8 @@ public static async Task ExecuteClientTest(ThriftTest.Client client) var two = new CrazyNesting(); one.String_field = "crazy"; two.String_field = "crazy"; - one.Binary_field = new byte[] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF }; - two.Binary_field = new byte[10] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF }; + one.Binary_field = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF]; + two.Binary_field = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF]; if (typeof(CrazyNesting).GetMethod("Equals")?.DeclaringType == typeof(CrazyNesting)) { if (!one.Equals(two)) @@ -820,10 +819,7 @@ public static async Task ExecuteClientTest(ThriftTest.Client client) I32_thing = 8, I64_thing = 8 }; - insane.Xtructs = new List - { - truck - }; + insane.Xtructs = [ truck ]; Console.Write("testInsanity()"); var whoa = await client.testInsanity(insane, MakeTimeoutToken()); Console.Write(" = {"); diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index 020b8d54542..38a942a063a 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -19,8 +19,8 @@ --> - net7.0 - 9.0 + net8.0 + latestMajor Server Server Exe @@ -50,8 +50,8 @@ - - - + + + diff --git a/test/netstd/Server/TestServer.cs b/test/netstd/Server/TestServer.cs index a540d1919bf..2dea4182477 100644 --- a/test/netstd/Server/TestServer.cs +++ b/test/netstd/Server/TestServer.cs @@ -20,6 +20,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection.Metadata.Ecma335; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using System.Text; @@ -36,7 +37,6 @@ #pragma warning disable IDE0063 // using can be simplified, we don't #pragma warning disable IDE0057 // substr can be simplified, we don't -#pragma warning disable CS1998 // await missing namespace ThriftTest { @@ -83,12 +83,12 @@ internal void Parse(List args) { if (args[i].StartsWith("--pipe=")) { - pipe = args[i].Substring(args[i].IndexOf("=") + 1); + pipe = args[i].Substring(args[i].IndexOf('=') + 1); transport = TransportChoice.NamedPipe; } else if (args[i].StartsWith("--port=")) { - port = int.Parse(args[i].Substring(args[i].IndexOf("=") + 1)); + port = int.Parse(args[i].Substring(args[i].IndexOf('=') + 1)); if(transport != TransportChoice.TlsSocket) transport = TransportChoice.Socket; } @@ -163,9 +163,8 @@ internal static void PrintOptionsHelp() public class TestServer { - #pragma warning disable CA2211 - public static int _clientID = -1; // use with Interlocked only! - #pragma warning restore CA2211 + private static int _clientID = -1; // use with Interlocked only! + public static int ClientID => Interlocked.Add(ref _clientID, 0); private static readonly TConfiguration Configuration = new(); @@ -181,10 +180,10 @@ public Task PreServeAsync(CancellationToken cancellationToken) return Task.CompletedTask; } - public async Task CreateContextAsync(TProtocol input, TProtocol output, CancellationToken cancellationToken) + public Task CreateContextAsync(TProtocol input, TProtocol output, CancellationToken cancellationToken) { callCount++; - return null; + return Task.FromResult(null); } public Task DeleteContextAsync(object serverContext, TProtocol input, TProtocol output, CancellationToken cancellationToken) @@ -268,7 +267,7 @@ public Task testDouble(double thing, CancellationToken cancellationToken public Task testBinary(byte[]? thing, CancellationToken cancellationToken) { logger.Invoke("testBinary({0} bytes)", thing?.Length ?? 0); - return Task.FromResult(thing ?? Array.Empty()); + return Task.FromResult(thing ?? []); } public Task testUuid(Guid thing, CancellationToken cancellationToken) @@ -318,7 +317,7 @@ public Task> testMap(Dictionary? thing, Cancellat } sb.Append("}})"); logger.Invoke(sb.ToString()); - return Task.FromResult(thing ?? new Dictionary()); // null returns are not allowed in Thrift + return Task.FromResult(thing ?? []); // null returns are not allowed in Thrift } public Task> testStringMap(Dictionary? thing, CancellationToken cancellationToken) @@ -343,7 +342,7 @@ public Task> testStringMap(Dictionary } sb.Append("}})"); logger.Invoke(sb.ToString()); - return Task.FromResult(thing ?? new Dictionary()); // null returns are not allowed in Thrift + return Task.FromResult(thing ?? []); // null returns are not allowed in Thrift } public Task> testSet(HashSet? thing, CancellationToken cancellationToken) @@ -368,7 +367,7 @@ public Task> testSet(HashSet? thing, CancellationToken cancell } sb.Append("}})"); logger.Invoke(sb.ToString()); - return Task.FromResult(thing ?? new HashSet()); // null returns are not allowed in Thrift + return Task.FromResult(thing ?? []); // null returns are not allowed in Thrift } public Task> testList(List? thing, CancellationToken cancellationToken) @@ -393,7 +392,7 @@ public Task> testList(List? thing, CancellationToken cancellation } sb.Append("}})"); logger.Invoke(sb.ToString()); - return Task.FromResult(thing ?? new List()); // null returns are not allowed in Thrift + return Task.FromResult(thing ?? []); // null returns are not allowed in Thrift } public Task testEnum(Numberz thing, CancellationToken cancellationToken) diff --git a/tutorial/netstd/Client/Client.csproj b/tutorial/netstd/Client/Client.csproj index ee0bc8284d1..994d6be7be6 100644 --- a/tutorial/netstd/Client/Client.csproj +++ b/tutorial/netstd/Client/Client.csproj @@ -19,8 +19,8 @@ --> - net7.0 - 9.0 + net8.0 + latestMajor Client Client Exe diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index ff7891e5b3b..5ff8d9fb94e 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -19,7 +19,7 @@ --> - net7.0 + net6.0 Interfaces Interfaces 0.20.0.0 diff --git a/tutorial/netstd/Server/Server.csproj b/tutorial/netstd/Server/Server.csproj index 9aa3bc6b7c7..c72ec88ce34 100644 --- a/tutorial/netstd/Server/Server.csproj +++ b/tutorial/netstd/Server/Server.csproj @@ -19,8 +19,8 @@ --> - net7.0 - 9.0 + net8.0 + latestMajor Server Server Exe From ac2deed0fcf1d94e65bfa806866e2eaaa3aa0482 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 25 Nov 2023 09:55:58 +0100 Subject: [PATCH 145/250] THRIFT-5746 Upgrade to net8 Client: netstd Patch: Jens Geyer This updates certain packages that became available now for 8.0.0 --- .../Thrift.Benchmarks/Thrift.Benchmarks.csproj | 2 +- .../Thrift.IntegrationTests.csproj | 6 +++--- .../Thrift.PublicInterfaces.Compile.Tests.csproj | 2 +- lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj | 6 +++--- lib/netstd/Thrift/Thrift.csproj | 14 ++++++++++---- test/netstd/Client/Client.csproj | 4 ++-- test/netstd/Server/Server.csproj | 4 ++-- tutorial/netstd/Interfaces/Interfaces.csproj | 2 +- 8 files changed, 23 insertions(+), 17 deletions(-) diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj index cc2360de7bf..a8543a3bf37 100644 --- a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj +++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj @@ -28,7 +28,7 @@ - + diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index 3f52a5fe0f6..3f8345926ae 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -35,11 +35,11 @@ - - + + - + diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj index ecde3668946..7c5775026b8 100644 --- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj +++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj @@ -38,7 +38,7 @@ - + diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index 54ce1e89c4b..a37be1b1046 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -26,11 +26,11 @@ - - + + - + diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index c7b2a828ecc..d255f37c4eb 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -57,12 +57,12 @@ - - - + + + - + @@ -87,6 +87,12 @@ + + + 8.0.0 + + + $(IntermediateOutputPath)$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension) diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index 0e1eaa3af8f..aa90e2c5ec7 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -35,9 +35,9 @@ - + - + diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index 38a942a063a..63ce613bbda 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -36,9 +36,9 @@ - + - + diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index 5ff8d9fb94e..c3524575adc 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -34,7 +34,7 @@ - + From 8a6bcc76f30b72d87563722040d2018da3e5d7f4 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Wed, 22 Nov 2023 22:13:43 +0100 Subject: [PATCH 146/250] THRIFT-5747 warning: The macro `AC_HELP_STRING' is obsolete. Patch: Jens Geyer --- aclocal/ax_thrift_internal.m4 | 2 +- configure.ac | 7 ++++--- contrib/fb303/aclocal/ax_thrift_internal.m4 | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/aclocal/ax_thrift_internal.m4 b/aclocal/ax_thrift_internal.m4 index 8c0e3cbc1ae..097bcf5a6b2 100644 --- a/aclocal/ax_thrift_internal.m4 +++ b/aclocal/ax_thrift_internal.m4 @@ -18,7 +18,7 @@ dnl notice and this notice are preserved. AC_DEFUN([AX_THRIFT_LIB], [ AC_ARG_WITH($1, - AC_HELP_STRING([--with-$1], [build the $2 library @<:@default=$3@:>@]), + AS_HELP_STRING([--with-$1], [build the $2 library @<:@default=$3@:>@]), [with_$1="$withval"], [with_$1=$3] ) diff --git a/configure.ac b/configure.ac index ace48fc3ec4..eed4a84d775 100644 --- a/configure.ac +++ b/configure.ac @@ -311,9 +311,9 @@ AX_THRIFT_LIB(perl, [Perl], yes) if test "$with_perl" = "yes"; then AC_PATH_PROG([PERL], [perl]) if test -n "$PERL" ; then - AC_PROG_PERL_MODULES([Bit::Vector], success="yes", success="no") + AX_PROG_PERL_MODULES([Bit::Vector],[success="yes"],[success="no"]) have_perl_bit_vector="$success" - AC_PROG_PERL_MODULES([Class::Accessor], success="yes", success="no") + AX_PROG_PERL_MODULES([Class::Accessor],[success="yes"],[success="no"]) have_perl_class_accessor="$success" fi if test -n "$PERL" -a "$have_perl_bit_vector" = "yes" ; then @@ -589,13 +589,14 @@ case "${host_os}" in AM_CONDITIONAL(MINGW, true) ;; *) - AC_ISC_POSIX + AC_SEARCH_LIBS([strerror],[cposix]) ;; esac AC_C_CONST AC_C_INLINE AC_C_VOLATILE +AC_C_RESTRICT AC_HEADER_STDBOOL AC_HEADER_STDC diff --git a/contrib/fb303/aclocal/ax_thrift_internal.m4 b/contrib/fb303/aclocal/ax_thrift_internal.m4 index 8c0e3cbc1ae..097bcf5a6b2 100644 --- a/contrib/fb303/aclocal/ax_thrift_internal.m4 +++ b/contrib/fb303/aclocal/ax_thrift_internal.m4 @@ -18,7 +18,7 @@ dnl notice and this notice are preserved. AC_DEFUN([AX_THRIFT_LIB], [ AC_ARG_WITH($1, - AC_HELP_STRING([--with-$1], [build the $2 library @<:@default=$3@:>@]), + AS_HELP_STRING([--with-$1], [build the $2 library @<:@default=$3@:>@]), [with_$1="$withval"], [with_$1=$3] ) From 87e7be7541dae33a6138b0d005853802d417f6f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 06:53:10 +0000 Subject: [PATCH 147/250] Bump com.diffplug.spotless from 6.22.0 to 6.23.2 in /lib/kotlin Bumps com.diffplug.spotless from 6.22.0 to 6.23.2. --- updated-dependencies: - dependency-name: com.diffplug.spotless dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index e5694ac03a6..b2454cf75da 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -42,7 +42,7 @@ plugins { id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' id "com.github.spotbugs" version "5.2.1" - id "com.diffplug.spotless" version "6.22.0" + id "com.diffplug.spotless" version "6.23.2" } description = 'Apache Thrift Java Library' From a58e915338264256776c8563e66da0cc68597eb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 06:53:07 +0000 Subject: [PATCH 148/250] Bump jvm from 1.9.20 to 1.9.21 in /lib/kotlin Bumps [jvm](https://github.com/JetBrains/kotlin) from 1.9.20 to 1.9.21. - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.20...v1.9.21) --- updated-dependencies: - dependency-name: jvm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- lib/kotlin/settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/settings.gradle.kts b/lib/kotlin/settings.gradle.kts index 4090e863f80..638fd968152 100644 --- a/lib/kotlin/settings.gradle.kts +++ b/lib/kotlin/settings.gradle.kts @@ -18,7 +18,7 @@ */ pluginManagement { plugins { - kotlin("jvm") version "1.9.20" + kotlin("jvm") version "1.9.21" id("com.ncorti.ktfmt.gradle") version "0.12.0" } } From f4b6d9600802112c0c57ed979fb3f49239fbe4ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 06:30:44 +0000 Subject: [PATCH 149/250] Bump actions/setup-java from 3 to 4 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3 to 4. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7dfc14feb3b..8862b79a052 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,7 +145,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: 17 @@ -425,7 +425,7 @@ jobs: with: python-version: "3.x" - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: temurin # here we intentionally use an older version so that we also verify Java 17 compiles to it From 697c08badc95d1b29a39080df5e04efcb3e2b8ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 3 Dec 2023 21:00:42 +0000 Subject: [PATCH 150/250] Bump com.github.spotbugs from 5.2.1 to 6.0.1 in /lib/kotlin Bumps com.github.spotbugs from 5.2.1 to 6.0.1. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index b2454cf75da..43db204ff9b 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -41,7 +41,7 @@ plugins { id 'signing' id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' - id "com.github.spotbugs" version "5.2.1" + id "com.github.spotbugs" version "6.0.1" id "com.diffplug.spotless" version "6.23.2" } From 022d0278ebdbc049f77fbda6b97a3d835fdd3ad3 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 22 Nov 2023 09:09:57 -0800 Subject: [PATCH 151/250] Github Actions: Remove --disable-tests With --disable-tests, for example for Go the `make check` under `lib/go` would only run unit tests under `lib/go/thrift` but not the unit tests under `lib/go/test`. Also some changes in lib/go/test/fuzz/Makefile.am so it works in both go 1.20 and 1.21 (The current state breaks in 1.21 but because of `--disable-tests` we never noticed that). --- .github/workflows/build.yml | 1 - lib/go/test/fuzz/Makefile.am | 9 +++------ lib/go/test/fuzz/fuzz.go | 6 +++--- lib/go/test/fuzz/go.mod | 12 ++---------- lib/go/test/fuzz/go.sum | 13 ------------- 5 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 lib/go/test/fuzz/go.sum diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8862b79a052..d963b0a9ea8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,6 @@ env: BUILD_DEPS: automake bison flex git libboost-all-dev libevent-dev libssl-dev libtool make pkg-config CONFIG_ARGS_FOR_LIBS: > --disable-debug - --disable-tests --disable-dependency-tracking --without-cpp --without-c_glib diff --git a/lib/go/test/fuzz/Makefile.am b/lib/go/test/fuzz/Makefile.am index 56f138a7e2f..9677f4f0016 100644 --- a/lib/go/test/fuzz/Makefile.am +++ b/lib/go/test/fuzz/Makefile.am @@ -18,19 +18,16 @@ # gopathfuzz: $(THRIFT) fuzz.go - $(THRIFT) -r --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift$(COMPILER_EXTRAFLAG) ../../../../tutorial/tutorial.thrift - cd gen-go/shared && go mod init shared - cd gen-go/tutorial && go mod init tutorial + $(THRIFT) -r --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/lib/go/test/fuzz/gen-go/$(COMPILER_EXTRAFLAG) ../../../../tutorial/tutorial.thrift touch gopathfuzz check: gopathfuzz go test -tags gofuzz clean-local: - $(RM) -r gopathfuzz gen-go + $(RM) -rf gopathfuzz gen-go EXTRA_DIST = \ fuzz.go \ fuzz_test.go \ - go.mod \ - go.sum + go.mod diff --git a/lib/go/test/fuzz/fuzz.go b/lib/go/test/fuzz/fuzz.go index cd99d58de58..06983799823 100644 --- a/lib/go/test/fuzz/fuzz.go +++ b/lib/go/test/fuzz/fuzz.go @@ -1,3 +1,4 @@ +//go:build gofuzz // +build gofuzz /* @@ -26,9 +27,8 @@ import ( "fmt" "strconv" - "shared" - "tutorial" - + "github.com/apache/thrift/lib/go/test/fuzz/gen-go/shared" + "github.com/apache/thrift/lib/go/test/fuzz/gen-go/tutorial" "github.com/apache/thrift/lib/go/thrift" ) diff --git a/lib/go/test/fuzz/go.mod b/lib/go/test/fuzz/go.mod index 41cccc3e2fe..4ff6c5d934e 100644 --- a/lib/go/test/fuzz/go.mod +++ b/lib/go/test/fuzz/go.mod @@ -2,14 +2,6 @@ module github.com/apache/thrift/lib/go/test/fuzz go 1.20 -replace github.com/apache/thrift => ../../../../ - -replace shared => ./gen-go/shared +require github.com/apache/thrift v0.0.0-00010101000000-000000000000 -replace tutorial => ./gen-go/tutorial - -require ( - github.com/apache/thrift v0.0.0-00010101000000-000000000000 - shared v0.0.0-00010101000000-000000000000 - tutorial v0.0.0-00010101000000-000000000000 -) +replace github.com/apache/thrift => ../../../../ diff --git a/lib/go/test/fuzz/go.sum b/lib/go/test/fuzz/go.sum deleted file mode 100644 index 64682154d5b..00000000000 --- a/lib/go/test/fuzz/go.sum +++ /dev/null @@ -1,13 +0,0 @@ -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 9a9e60ed26d6e11e1e7711000c0e8150e2de41de Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 7 Dec 2023 09:03:04 -0800 Subject: [PATCH 152/250] Downgrade spotbugs to 5.2.5 6.x has breaking changes need extra care to upgrade. --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index 43db204ff9b..4c842ff35a4 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -41,7 +41,7 @@ plugins { id 'signing' id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' - id "com.github.spotbugs" version "6.0.1" + id "com.github.spotbugs" version "5.2.5" id "com.diffplug.spotless" version "6.23.2" } From 20e3124caefaee9922a6598b7c983ae7d49862a8 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 7 Dec 2023 08:37:51 -0800 Subject: [PATCH 153/250] Revert "lib: cpp: automake: ship thrift/numeric_cast.h" This reverts commit 779deabf0e1fdefe4f6340546181ac9d81fcf670. --- lib/cpp/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am index 7512ec53cfd..c015b0db60f 100644 --- a/lib/cpp/Makefile.am +++ b/lib/cpp/Makefile.am @@ -133,7 +133,6 @@ libthriftqt5_la_LDFLAGS = -release $(VERSION) $(BOOST_LDFLAGS) $(QT5_LIBS) include_thriftdir = $(includedir)/thrift include_thrift_HEADERS = \ $(top_builddir)/config.h \ - src/thrift/numeric_cast.h \ src/thrift/thrift-config.h \ src/thrift/thrift_export.h \ src/thrift/TDispatchProcessor.h \ From 93222f62dc1d38b27c7b9200f32b6ae9b5f5c1aa Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 15 Dec 2023 16:03:48 +0100 Subject: [PATCH 154/250] THRIFT-5749 Option to enable RTTI info Client: Delphi Patch: Jens Geyer --- .../src/thrift/generate/t_delphi_generator.cc | 26 ++++++++++++++++--- lib/delphi/src/Thrift.Protocol.pas | 5 ++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc index 4264d856818..fbf6709d452 100644 --- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc @@ -76,6 +76,7 @@ class t_delphi_generator : public t_oop_generator { xmldoc_ = false; async_ = false; com_types_ = false; + rtti_ = false; for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) { if( iter->first.compare("ansistr_binary") == 0) { ansistr_binary_ = true; @@ -93,6 +94,8 @@ class t_delphi_generator : public t_oop_generator { async_ = true; } else if( iter->first.compare("com_types") == 0) { com_types_ = true; + } else if( iter->first.compare("rtti") == 0) { + rtti_ = true; } else { throw "unknown option delphi:" + iter->first; } @@ -472,6 +475,7 @@ class t_delphi_generator : public t_oop_generator { bool xmldoc_; bool async_; bool com_types_; + bool rtti_; void indent_up_impl() { ++indent_impl_; }; void indent_down_impl() { --indent_impl_; }; std::string indent_impl() { @@ -720,10 +724,14 @@ void t_delphi_generator::close_generator() { f_all << autogen_comment() << endl; generate_delphi_doc(f_all, program_); f_all << "unit " << unitname << ";" << endl << endl; - f_all << "{$WARN SYMBOL_DEPRECATED OFF}" << endl << endl; + f_all << "{$WARN SYMBOL_DEPRECATED OFF}" << endl; if(com_types_) { - f_all << "{$MINENUMSIZE 4}" << endl << endl; + f_all << "{$MINENUMSIZE 4}" << endl; } + if(rtti_) { + f_all << "{$IFOPT M+} {$DEFINE TYPEINFO_WAS_ON} {$ELSE} {$UNDEF TYPEINFO_WAS_ON} {$ENDIF}" << endl; + } + f_all << endl; f_all << "interface" << endl << endl; f_all << "uses" << endl; @@ -759,6 +767,7 @@ void t_delphi_generator::close_generator() { indent(f_all) << "c" << tmp_unit << "_Option_Async = " << (async_ ? "True" : "False") << ";" << endl; indent(f_all) << "c" << tmp_unit << "_Option_COM_types = " << (com_types_ ? "True" : "False") << ";" << endl; indent(f_all) << "c" << tmp_unit << "_Option_Old_Names = " << (old_names_ ? "True" : "False") << ";" << endl; + indent(f_all) << "c" << tmp_unit << "_Option_RTTI = " << (rtti_ ? "True" : "False") << ";" << endl; indent_down(); f_all << endl; @@ -1661,6 +1670,10 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, if ((!is_exception) || is_x_factory) { generate_delphi_doc(out, tstruct); + if(rtti_) { + indent(out) << "{$TYPEINFO ON}" << endl; + indent(out) << "{$RTTI INHERIT}" << endl; + } indent(out) << struct_intf_name << " = interface(IBase)" << endl; indent_up(); @@ -1705,7 +1718,11 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, } indent_down(); - indent(out) << "end;" << endl << endl; + indent(out) << "end;" << endl; + if(rtti_) { + indent(out) << "{$IFNDEF TYPEINFO_WAS_ON} {$TYPEINFO OFF} {$ENDIF}" << endl; + } + indent(out) << endl; } generate_delphi_doc(out, tstruct); @@ -4058,4 +4075,5 @@ THRIFT_REGISTER_GENERATOR( " xmldoc: Enable XMLDoc comments for Help Insight etc.\n" " async: Generate IAsync interface to use Parallel Programming Library (XE7+ only).\n" " com_types: Use COM-compatible data types (e.g. WideString).\n" - " old_names: Compatibility: generate \"reserved\" identifiers with '_' postfix instead of '&' prefix.\n") + " old_names: Compatibility: generate \"reserved\" identifiers with '_' postfix instead of '&' prefix.\n" + " rtti: Activate {$TYPEINFO} and {$RTTI} at the generated API interfaces.\n") diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas index c6b1a00a563..0134ddffcc5 100644 --- a/lib/delphi/src/Thrift.Protocol.pas +++ b/lib/delphi/src/Thrift.Protocol.pas @@ -18,6 +18,7 @@ *) {$SCOPEDENUMS ON} +{$IFOPT M+} {$DEFINE TYPEINFO_WAS_ON} {$ELSE} {$UNDEF TYPEINFO_WAS_ON} {$ENDIF} unit Thrift.Protocol; @@ -335,11 +336,15 @@ TProtocolImpl = class abstract( TInterfacedObject, IProtocol) constructor Create( const aTransport : ITransport); virtual; end; + {$TYPEINFO ON} + {$RTTI EXPLICIT METHODS([vcPublic, vcPublished]) PROPERTIES([vcPublic, vcPublished])} IBase = interface( ISupportsToString) ['{AFF6CECA-5200-4540-950E-9B89E0C1C00C}'] procedure Read( const prot: IProtocol); procedure Write( const prot: IProtocol); end; + {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} + {$IFNDEF TYPEINFO_WAS_ON} {$TYPEINFO OFF} {$ENDIF} IThriftBytes = interface( ISupportsToString) From f1584f5f61abe5197aace042e4e3da5f322250c4 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 16 Dec 2023 15:30:50 +0100 Subject: [PATCH 155/250] FIX: Unused import Map Client: hx Patch: Jens Geyer --- lib/haxe/src/org/apache/thrift/helper/IntSet.hx | 3 --- lib/haxe/src/org/apache/thrift/helper/StringSet.hx | 3 --- 2 files changed, 6 deletions(-) diff --git a/lib/haxe/src/org/apache/thrift/helper/IntSet.hx b/lib/haxe/src/org/apache/thrift/helper/IntSet.hx index 676463be1a6..c2b68ba54d4 100644 --- a/lib/haxe/src/org/apache/thrift/helper/IntSet.hx +++ b/lib/haxe/src/org/apache/thrift/helper/IntSet.hx @@ -19,9 +19,6 @@ package org.apache.thrift.helper; -import Map; - - class IntSet { private var _elements = new haxe.ds.IntMap(); diff --git a/lib/haxe/src/org/apache/thrift/helper/StringSet.hx b/lib/haxe/src/org/apache/thrift/helper/StringSet.hx index 2c255e6a003..803ae5bcc3b 100644 --- a/lib/haxe/src/org/apache/thrift/helper/StringSet.hx +++ b/lib/haxe/src/org/apache/thrift/helper/StringSet.hx @@ -19,9 +19,6 @@ package org.apache.thrift.helper; -import Map; - - class StringSet { private var _elements = new haxe.ds.StringMap(); From 5cf71b2beec3c67a4c8452ddabbbc6ae43fff16f Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Mon, 18 Dec 2023 11:44:55 +0100 Subject: [PATCH 156/250] THRIFT-5749 Option to enable RTTI info (2nd attempt) Client: Delphi Patch: Jens Geyer --- .../src/thrift/generate/t_delphi_generator.cc | 18 ++++---- lib/delphi/src/Thrift.Protocol.pas | 42 ++++++++++++++++++- .../test/serializer/TestSerializer.dproj | 2 +- lib/delphi/test/server.dproj | 2 +- lib/delphi/test/skip/skiptest_version2.dproj | 2 +- 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc index fbf6709d452..8bf9a3febd5 100644 --- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc @@ -1672,9 +1672,11 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, generate_delphi_doc(out, tstruct); if(rtti_) { indent(out) << "{$TYPEINFO ON}" << endl; - indent(out) << "{$RTTI INHERIT}" << endl; + indent(out) << "{$RTTI EXPLICIT METHODS([vcPublic, vcPublished]) PROPERTIES([vcPublic, vcPublished])}" << endl; + indent(out) << struct_intf_name << " = interface(IBaseWithTypeInfo)" << endl; + } else { + indent(out) << struct_intf_name << " = interface(IBase)" << endl; } - indent(out) << struct_intf_name << " = interface(IBase)" << endl; indent_up(); generate_guid(out); @@ -3177,13 +3179,15 @@ string t_delphi_generator::base_type_name(t_base_type* tbase) { return ""; case t_base_type::TYPE_STRING: if (tbase->is_binary()) { - if (ansistr_binary_) { + if (ansistr_binary_) return "System.AnsiString"; - } else { - return com_types_ ? "IThriftBytes" : "SysUtils.TBytes"; - } + if( com_types_) + return "IThriftBytes"; + if( rtti_) + return "Thrift.Protocol.TThriftBytes"; // has TypeInfo + return "SysUtils.TBytes"; } else { - return com_types_ ? "System.WideString" : "System.string"; + return com_types_ ? "System.WideString" : "System.UnicodeString"; } case t_base_type::TYPE_UUID: return "System.TGuid"; diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas index 0134ddffcc5..f5cb454d4c1 100644 --- a/lib/delphi/src/Thrift.Protocol.pas +++ b/lib/delphi/src/Thrift.Protocol.pas @@ -197,6 +197,17 @@ TProtocolRecursionTrackerImpl = class abstract( TInterfacedObject, IProtocolRe IThriftBytes = interface; // forward + {$TYPEINFO ON} + TThriftBytes = packed record // can't use SysUtils.TBytes because it has no typinfo -> E2134 + data : System.TArray; + + class operator Implicit(aRec : SysUtils.TBytes) : TThriftBytes; + class operator Implicit(aRec : TThriftBytes) : SysUtils.TBytes; + function Length : Integer; + end; + {$IFNDEF TYPEINFO_WAS_ON} {$TYPEINFO OFF} {$ENDIF} + + IProtocol = interface ['{6067A28E-15BF-4C9D-9A6F-D991BB3DCB85}'] function GetTransport: ITransport; @@ -336,13 +347,18 @@ TProtocolImpl = class abstract( TInterfacedObject, IProtocol) constructor Create( const aTransport : ITransport); virtual; end; - {$TYPEINFO ON} + {.$TYPEINFO ON} // big NO -> may cause E2134 due to Delphis stupidity on enums vs TypeInfo {$RTTI EXPLICIT METHODS([vcPublic, vcPublished]) PROPERTIES([vcPublic, vcPublished])} IBase = interface( ISupportsToString) ['{AFF6CECA-5200-4540-950E-9B89E0C1C00C}'] procedure Read( const prot: IProtocol); procedure Write( const prot: IProtocol); end; + + {$TYPEINFO ON} + {$RTTI EXPLICIT METHODS([vcPublic, vcPublished]) PROPERTIES([vcPublic, vcPublished])} + IBaseWithTypeInfo = interface( IBase) end; + {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} {$IFNDEF TYPEINFO_WAS_ON} {$TYPEINFO OFF} {$ENDIF} @@ -578,6 +594,30 @@ function ConvertDoubleToInt64( const d: Double): Int64; inline; end; +//--- TThriftBytes ---------------------------------------------------------------------- + + +class operator TThriftBytes.Implicit(aRec : SysUtils.TBytes) : TThriftBytes; +begin + ASSERT( @result.data = @result); // must be first field + ASSERT( SizeOf(aRec) = SizeOf(result)); // must be the only field + result := TThriftBytes(aRec); +end; + + +class operator TThriftBytes.Implicit(aRec : TThriftBytes) : SysUtils.TBytes; +begin + ASSERT( @aRec.data = @aRec); // must be first field + ASSERT( SizeOf(aRec) = SizeOf(result)); // must be the only field + result := SysUtils.TBytes(aRec.data); +end; + + +function TThriftBytes.Length : Integer; +begin + result := System.Length(data); +end; + { TProtocolRecursionTrackerImpl } diff --git a/lib/delphi/test/serializer/TestSerializer.dproj b/lib/delphi/test/serializer/TestSerializer.dproj index 1d98d3a6866..383e04a9547 100644 --- a/lib/delphi/test/serializer/TestSerializer.dproj +++ b/lib/delphi/test/serializer/TestSerializer.dproj @@ -101,7 +101,7 @@ - diff --git a/lib/delphi/test/server.dproj b/lib/delphi/test/server.dproj index 151f7ee7229..8e9b99dd72d 100644 --- a/lib/delphi/test/server.dproj +++ b/lib/delphi/test/server.dproj @@ -123,7 +123,7 @@ - --protocol=compact + --protocol=compact diff --git a/lib/delphi/test/skip/skiptest_version2.dproj b/lib/delphi/test/skip/skiptest_version2.dproj index 3192d288902..14936371a4c 100644 --- a/lib/delphi/test/skip/skiptest_version2.dproj +++ b/lib/delphi/test/skip/skiptest_version2.dproj @@ -97,7 +97,7 @@ - + Delphi.Personality.12 From be1c8fd836132fe9d7d6058db05fd9aacd3b3002 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Tue, 2 Jan 2024 09:04:19 -0800 Subject: [PATCH 157/250] Fix github actions for python3 tests Add a dummy test in test_sslsocket.py to workaround an issue in Python 3.12. --- lib/py/test/test_sslsocket.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/py/test/test_sslsocket.py b/lib/py/test/test_sslsocket.py index 801024a1e6c..a5ea06ae9e4 100644 --- a/lib/py/test/test_sslsocket.py +++ b/lib/py/test/test_sslsocket.py @@ -348,6 +348,13 @@ def test_ssl_context(self): self._assert_connection_success(server, ssl_context=client_context) +# Add a dummy test because starting from python 3.12, if all tests in a test +# file are skipped that's considered an error. +class DummyTest(unittest.TestCase): + def test_dummy(self): + self.assertEqual(0, 0) + + if __name__ == '__main__': logging.basicConfig(level=logging.WARN) from thrift.transport.TSSLSocket import TSSLSocket, TSSLServerSocket, _match_has_ipaddress From 1ebfcf8e0b8eb0c0e4137b7bc1a45e3f887e273e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 16:59:31 +0000 Subject: [PATCH 158/250] Bump actions/setup-go from 4 to 5 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4 to 5. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d963b0a9ea8..3ef763ff9e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,7 +88,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} From 781c590457dd6d2c09c94273efca7a7a131a0941 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 16:59:42 +0000 Subject: [PATCH 159/250] Bump com.diffplug.spotless from 6.23.2 to 6.23.3 in /lib/java Bumps com.diffplug.spotless from 6.23.2 to 6.23.3. --- updated-dependencies: - dependency-name: com.diffplug.spotless dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index 4c842ff35a4..e7c7ee91f1e 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -42,7 +42,7 @@ plugins { id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' id "com.github.spotbugs" version "5.2.5" - id "com.diffplug.spotless" version "6.23.2" + id "com.diffplug.spotless" version "6.23.3" } description = 'Apache Thrift Java Library' From 30c2845fdc4eeb07335f809cdca1091fe52180c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 16:59:14 +0000 Subject: [PATCH 160/250] Bump actions/setup-python from 4 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ef763ff9e2..c0b5a976753 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -363,7 +363,7 @@ jobs: sudo apt-get install -y --no-install-recommends curl openssl ca-certificates - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -420,7 +420,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.x" From 8004c375dfa9cff943e9e393078d8cdc854ed7d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 16:59:56 +0000 Subject: [PATCH 161/250] Bump jvm from 1.9.21 to 1.9.22 in /lib/kotlin Bumps [jvm](https://github.com/JetBrains/kotlin) from 1.9.21 to 1.9.22. - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.21...v1.9.22) --- updated-dependencies: - dependency-name: jvm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- lib/kotlin/settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/settings.gradle.kts b/lib/kotlin/settings.gradle.kts index 638fd968152..294cd83c1d6 100644 --- a/lib/kotlin/settings.gradle.kts +++ b/lib/kotlin/settings.gradle.kts @@ -18,7 +18,7 @@ */ pluginManagement { plugins { - kotlin("jvm") version "1.9.21" + kotlin("jvm") version "1.9.22" id("com.ncorti.ktfmt.gradle") version "0.12.0" } } From 85400668007ea1938c250e01a7c4763ecfef3c71 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 3 Jan 2024 09:18:23 -0800 Subject: [PATCH 162/250] Bump upload/download-artifacts from v3 to v4 This is the combination of https://github.com/apache/thrift/pull/2910 & https://github.com/apache/thrift/pull/2912. It looks like these 2 changes need to be done together, doing them individually will break CI. --- .github/workflows/build.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0b5a976753..af6e279d296 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,7 +70,7 @@ jobs: # only upload while building ubuntu-20.04 - name: Archive built thrift compiler if: matrix.os == 'ubuntu-20.04' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: thrift-compiler path: compiler/cpp/thrift @@ -104,7 +104,7 @@ jobs: run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-go/with-go/') - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: thrift-compiler path: compiler/cpp @@ -128,7 +128,7 @@ jobs: - name: Upload go precross artifacts if: matrix.go == '1.21' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: go-precross if-no-files-found: error @@ -182,7 +182,7 @@ jobs: run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-java/with-java/' | sed 's/without-kotlin/with-kotlin/') - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: thrift-compiler path: compiler/cpp @@ -200,7 +200,7 @@ jobs: run: make -C lib/java install - name: Upload java libthrift artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: libthrift if-no-files-found: error @@ -213,7 +213,7 @@ jobs: run: make -C lib/java precross - name: Upload java precross artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: java-precross if-no-files-found: error @@ -235,7 +235,7 @@ jobs: run: make -C lib/kotlin precross - name: Upload kotlin precross artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: kotlin-precross if-no-files-found: error @@ -257,7 +257,7 @@ jobs: run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-swift/with-swift/') - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: thrift-compiler path: compiler/cpp @@ -271,7 +271,7 @@ jobs: run: make -C test/swift precross - name: Upload swift precross artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: swift-precross if-no-files-found: error @@ -310,7 +310,7 @@ jobs: run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-rs/with-rs/') - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: thrift-compiler path: compiler/cpp @@ -333,7 +333,7 @@ jobs: run: make -C test/rs precross - name: Upload rust precross artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: rs-precross if-no-files-found: error @@ -381,7 +381,7 @@ jobs: run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-py3/with-py3/') - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: thrift-compiler path: compiler/cpp @@ -437,31 +437,31 @@ jobs: sudo apt-get install -y --no-install-recommends openssl ca-certificates - name: Download java precross artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: java-precross path: lib/java/build - name: Download kotlin precross artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: kotlin-precross path: lib/kotlin - name: Download swift precross artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: swift-precross path: test/swift/CrossTests/.build/x86_64-unknown-linux-gnu/debug - name: Download rust precross artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: rs-precross path: test/rs/bin - name: Download go precross artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: go-precross path: test/go/bin @@ -487,7 +487,7 @@ jobs: --client ${{ matrix.client_lang }} - name: Upload log files from failed cross test runs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: cross-test-log From 8ea1a483f54aeb1fd0b2834c318f4dbc5c47f278 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 17:21:14 +0000 Subject: [PATCH 163/250] Bump org.codehaus.plexus:plexus-utils in /contrib/thrift-maven-plugin Bumps [org.codehaus.plexus:plexus-utils](https://github.com/codehaus-plexus/plexus-utils) from 3.0.16 to 3.0.24. - [Release notes](https://github.com/codehaus-plexus/plexus-utils/releases) - [Commits](https://github.com/codehaus-plexus/plexus-utils/compare/plexus-utils-3.0.16...plexus-utils-3.0.24) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-utils dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- contrib/thrift-maven-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/thrift-maven-plugin/pom.xml b/contrib/thrift-maven-plugin/pom.xml index e6e43246381..46f3cb18327 100644 --- a/contrib/thrift-maven-plugin/pom.xml +++ b/contrib/thrift-maven-plugin/pom.xml @@ -99,7 +99,7 @@ org.codehaus.plexus plexus-utils - 3.0.16 + 3.0.24 org.mockito From c2738d058eb16b1ef5b8ae0b6367bdd3f59dde10 Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Sat, 6 Jan 2024 14:12:04 +0100 Subject: [PATCH 164/250] [THRIFT-5752] Add TTransportFactoryInterface --- lib/php/Makefile.am | 2 ++ lib/php/lib/Factory/TFramedTransportFactory.php | 14 ++++++++++++++ lib/php/lib/Factory/TTransportFactory.php | 2 +- .../lib/Factory/TTransportFactoryInterface.php | 15 +++++++++++++++ lib/php/lib/Server/TServer.php | 14 +++++++------- 5 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 lib/php/lib/Factory/TFramedTransportFactory.php create mode 100644 lib/php/lib/Factory/TTransportFactoryInterface.php diff --git a/lib/php/Makefile.am b/lib/php/Makefile.am index 4ec6be35b50..91944c48164 100644 --- a/lib/php/Makefile.am +++ b/lib/php/Makefile.am @@ -64,7 +64,9 @@ phpfactory_DATA = \ lib/Factory/TJSONProtocolFactory.php \ lib/Factory/TProtocolFactory.php \ lib/Factory/TStringFuncFactory.php \ + lib/Factory/TTransportFactoryInterface.php lib/Factory/TTransportFactory.php + lib/Factory/TFramedTransportFactory.php phpprotocoldir = $(phpdir)/Protocol phpprotocol_DATA = \ diff --git a/lib/php/lib/Factory/TFramedTransportFactory.php b/lib/php/lib/Factory/TFramedTransportFactory.php new file mode 100644 index 00000000000..485fca505fb --- /dev/null +++ b/lib/php/lib/Factory/TFramedTransportFactory.php @@ -0,0 +1,14 @@ + Date: Mon, 8 Jan 2024 14:11:25 -0800 Subject: [PATCH 165/250] Revert "Bump upload/download-artifacts from v3 to v4" This reverts commit 85400668007ea1938c250e01a7c4763ecfef3c71. https://github.com/actions/upload-artifact/issues/478 will impact us. --- .github/workflows/build.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af6e279d296..c0b5a976753 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,7 +70,7 @@ jobs: # only upload while building ubuntu-20.04 - name: Archive built thrift compiler if: matrix.os == 'ubuntu-20.04' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: thrift-compiler path: compiler/cpp/thrift @@ -104,7 +104,7 @@ jobs: run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-go/with-go/') - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v3 with: name: thrift-compiler path: compiler/cpp @@ -128,7 +128,7 @@ jobs: - name: Upload go precross artifacts if: matrix.go == '1.21' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: go-precross if-no-files-found: error @@ -182,7 +182,7 @@ jobs: run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-java/with-java/' | sed 's/without-kotlin/with-kotlin/') - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v3 with: name: thrift-compiler path: compiler/cpp @@ -200,7 +200,7 @@ jobs: run: make -C lib/java install - name: Upload java libthrift artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: libthrift if-no-files-found: error @@ -213,7 +213,7 @@ jobs: run: make -C lib/java precross - name: Upload java precross artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: java-precross if-no-files-found: error @@ -235,7 +235,7 @@ jobs: run: make -C lib/kotlin precross - name: Upload kotlin precross artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: kotlin-precross if-no-files-found: error @@ -257,7 +257,7 @@ jobs: run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-swift/with-swift/') - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v3 with: name: thrift-compiler path: compiler/cpp @@ -271,7 +271,7 @@ jobs: run: make -C test/swift precross - name: Upload swift precross artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: swift-precross if-no-files-found: error @@ -310,7 +310,7 @@ jobs: run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-rs/with-rs/') - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v3 with: name: thrift-compiler path: compiler/cpp @@ -333,7 +333,7 @@ jobs: run: make -C test/rs precross - name: Upload rust precross artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: rs-precross if-no-files-found: error @@ -381,7 +381,7 @@ jobs: run: | ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-py3/with-py3/') - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v3 with: name: thrift-compiler path: compiler/cpp @@ -437,31 +437,31 @@ jobs: sudo apt-get install -y --no-install-recommends openssl ca-certificates - name: Download java precross artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: name: java-precross path: lib/java/build - name: Download kotlin precross artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: name: kotlin-precross path: lib/kotlin - name: Download swift precross artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: name: swift-precross path: test/swift/CrossTests/.build/x86_64-unknown-linux-gnu/debug - name: Download rust precross artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: name: rs-precross path: test/rs/bin - name: Download go precross artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: name: go-precross path: test/go/bin @@ -487,7 +487,7 @@ jobs: --client ${{ matrix.client_lang }} - name: Upload log files from failed cross test runs - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 if: failure() with: name: cross-test-log From 8238364c6b25b8d3769660c87b44afb12ee251a5 Mon Sep 17 00:00:00 2001 From: Pavel Kvach Date: Sun, 14 Jan 2024 15:53:17 +0200 Subject: [PATCH 166/250] THRIFT-5754: Fix PHP 8.1 deprecates passing null to non-nullable internal function parameters --- lib/php/lib/Protocol/TJSONProtocol.php | 2 +- lib/php/lib/StringFunc/Core.php | 6 +++--- lib/php/lib/StringFunc/Mbstring.php | 4 ++-- lib/php/lib/TMultiplexedProcessor.php | 2 +- lib/php/src/TStringUtils.php | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/php/lib/Protocol/TJSONProtocol.php b/lib/php/lib/Protocol/TJSONProtocol.php index 9144884219e..e1412cc3acb 100644 --- a/lib/php/lib/Protocol/TJSONProtocol.php +++ b/lib/php/lib/Protocol/TJSONProtocol.php @@ -108,7 +108,7 @@ private function getTypeIDForTypeName($name) { $result = TType::STOP; - if (strlen($name) > 1) { + if (strlen((string) $name) > 1) { switch (substr($name, 0, 1)) { case 'd': $result = TType::DOUBLE; diff --git a/lib/php/lib/StringFunc/Core.php b/lib/php/lib/StringFunc/Core.php index 39a75b3a23a..376e437ff7f 100644 --- a/lib/php/lib/StringFunc/Core.php +++ b/lib/php/lib/StringFunc/Core.php @@ -27,14 +27,14 @@ public function substr($str, $start, $length = null) { // specifying a null $length would return an empty string if ($length === null) { - return substr($str, $start); + return substr((string) $str, $start); } - return substr($str, $start, $length); + return substr((string) $str, $start, $length); } public function strlen($str) { - return strlen($str); + return strlen((string) $str); } } diff --git a/lib/php/lib/StringFunc/Mbstring.php b/lib/php/lib/StringFunc/Mbstring.php index 968ff18f195..ac48309da4c 100644 --- a/lib/php/lib/StringFunc/Mbstring.php +++ b/lib/php/lib/StringFunc/Mbstring.php @@ -36,11 +36,11 @@ public function substr($str, $start, $length = null) $length = $this->strlen($str) - $start; } - return mb_substr($str, $start, $length, '8bit'); + return mb_substr((string) $str, $start, $length, '8bit'); } public function strlen($str) { - return mb_strlen($str, '8bit'); + return mb_strlen((string) $str, '8bit'); } } diff --git a/lib/php/lib/TMultiplexedProcessor.php b/lib/php/lib/TMultiplexedProcessor.php index a64a9687c3c..d276caebb90 100644 --- a/lib/php/lib/TMultiplexedProcessor.php +++ b/lib/php/lib/TMultiplexedProcessor.php @@ -97,7 +97,7 @@ public function process(TProtocol $input, TProtocol $output) } // Extract the service name and the new Message name. - if (strpos($fname, TMultiplexedProtocol::SEPARATOR) === false) { + if (strpos((string) $fname, TMultiplexedProtocol::SEPARATOR) === false) { throw new TException("Service name not found in message name: {$fname}. Did you " . "forget to use a TMultiplexProtocol in your client?"); } diff --git a/lib/php/src/TStringUtils.php b/lib/php/src/TStringUtils.php index 894baf8d4ba..544211baab2 100644 --- a/lib/php/src/TStringUtils.php +++ b/lib/php/src/TStringUtils.php @@ -12,15 +12,15 @@ public function substr($str, $start, $length = null) { // specifying a null $length would return an empty string if ($length === null) { - return substr($str, $start); + return substr((string) $str, $start); } - return substr($str, $start, $length); + return substr((string) $str, $start, $length); } public function strlen($str) { - return strlen($str); + return strlen((string) $str); } } @@ -39,12 +39,12 @@ public function substr($str, $start, $length = null) $length = $this->strlen($str) - $start; } - return mb_substr($str, $start, $length, '8bit'); + return mb_substr((string) $str, $start, $length, '8bit'); } public function strlen($str) { - return mb_strlen($str, '8bit'); + return mb_strlen((string) $str, '8bit'); } } From 7507fa01c22a81858b8df96ee4377251f794e2db Mon Sep 17 00:00:00 2001 From: Pavel Kvach Date: Thu, 11 Jan 2024 10:01:01 +0200 Subject: [PATCH 167/250] THRIFT-5753 PHP 8.1 deprecated warning about return type in jsonSerialize functions --- compiler/cpp/src/thrift/generate/t_php_generator.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/cpp/src/thrift/generate/t_php_generator.cc b/compiler/cpp/src/thrift/generate/t_php_generator.cc index 5e02b9b69d3..83738586821 100644 --- a/compiler/cpp/src/thrift/generate/t_php_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_php_generator.cc @@ -1285,6 +1285,7 @@ void t_php_generator::generate_php_struct_required_validator(ostream& out, void t_php_generator::generate_php_struct_json_serialize(ostream& out, t_struct* tstruct, bool is_result) { + indent(out) << "#[\\ReturnTypeWillChange]" << endl; indent(out) << "public function jsonSerialize() {" << endl; indent_up(); From 7d4c7fa69b8a8fcb6d013141edeaae85182a28d7 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sun, 21 Jan 2024 15:43:11 +0100 Subject: [PATCH 168/250] THRIFT-5750 deprecate "ansistr_binary_" option Client: delphi Patch: Jens Geyer --- compiler/cpp/src/thrift/generate/t_delphi_generator.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc index 8bf9a3febd5..c91ff332eab 100644 --- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc @@ -80,6 +80,7 @@ class t_delphi_generator : public t_oop_generator { for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) { if( iter->first.compare("ansistr_binary") == 0) { ansistr_binary_ = true; + pwarning(0, "The 'ansistr_binary' option is deprecated."); } else if( iter->first.compare("register_types") == 0) { register_types_ = true; } else if( iter->first.compare("old_names") == 0) { From 9d96f200adca6a273590db40c0c68b7f743fd8bb Mon Sep 17 00:00:00 2001 From: adrianhelvikspond Date: Mon, 22 Jan 2024 10:23:25 +0100 Subject: [PATCH 169/250] Fix ambigous typescript definitions --- compiler/cpp/src/thrift/generate/t_js_generator.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc b/compiler/cpp/src/thrift/generate/t_js_generator.cc index 96250c9bac7..0e8da5963ee 100644 --- a/compiler/cpp/src/thrift/generate/t_js_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc @@ -2851,12 +2851,12 @@ std::string t_js_generator::ts_function_signature(t_function* tfunction, bool in } } if (exception_types == "") { - str += "callback?: (error: void, response: " + ts_get_type(tfunction->get_returntype()) + ")=>void): "; + str += "callback: (error: void, response: " + ts_get_type(tfunction->get_returntype()) + ")=>void): "; } else { - str += "callback?: (error: " + exception_types + ", response: " + ts_get_type(tfunction->get_returntype()) + ")=>void): "; + str += "callback: (error: " + exception_types + ", response: " + ts_get_type(tfunction->get_returntype()) + ")=>void): "; } } else { - str += "callback?: (data: " + ts_get_type(tfunction->get_returntype()) + ")=>void): "; + str += "callback: (data: " + ts_get_type(tfunction->get_returntype()) + ")=>void): "; } if (gen_jquery_) { From 0c637d7aa553a52b11bf92855448a20914d59817 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 06:57:36 +0000 Subject: [PATCH 170/250] Bump com.diffplug.spotless from 6.23.3 to 6.25.0 in /lib/java Bumps com.diffplug.spotless from 6.23.3 to 6.25.0. --- updated-dependencies: - dependency-name: com.diffplug.spotless dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- lib/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/build.gradle b/lib/java/build.gradle index e7c7ee91f1e..67c4af5cb39 100644 --- a/lib/java/build.gradle +++ b/lib/java/build.gradle @@ -42,7 +42,7 @@ plugins { id 'pmd' id 'com.github.johnrengelman.shadow' version '8.1.1' id "com.github.spotbugs" version "5.2.5" - id "com.diffplug.spotless" version "6.23.3" + id "com.diffplug.spotless" version "6.25.0" } description = 'Apache Thrift Java Library' From 318731b119a491d3a405b235afc4c0606cd3db2a Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sun, 4 Feb 2024 14:56:03 +0100 Subject: [PATCH 171/250] Updated manual version info and CHANGES --- CHANGES.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 6 ++++++ doap.rdf | 11 +++++++--- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a8de33648ed..d903760a653 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,60 @@ # Apache Thrift Changelog +## 0.20.0 + +### Known Open Issues (Blocker or Critical) + +- [THRIFT-3877](https://issues.apache.org/jira/browse/THRIFT-3877) - C++ library don't work with HTTP (csharp server, cpp client; need cross test enhancement) +- [THRIFT-5468](https://issues.apache.org/jira/browse/THRIFT-5468) - Swift service generator doesn't support oneway +- [THRIFT-5654](https://issues.apache.org/jira/browse/THRIFT-5654) - LNK4042 and LNK2019 in go_validator_generator.cc + +### Build Process + +- [THRIFT-5747]https://issues.apache.org/jira/browse/THRIFT-5747 - warning: The macro `AC_HELP_STRING' is obsolete. You should run autoupdate. and some more warnings + +### C++ + +- [THRIFT-5670]https://issues.apache.org/jira/browse/THRIFT-5670 - recvTimeout is not printed correctly for THRIFT_EAGAIN + +### Compiler (General) + +- [THRIFT-5733]https://issues.apache.org/jira/browse/THRIFT-5733 - Building code with circular `include`s can result in tons of memory usage and eventual segfault + +### Delphi + +- [THRIFT-5749]https://issues.apache.org/jira/browse/THRIFT-5749 - Option to enable RTTI info +- [THRIFT-5740]https://issues.apache.org/jira/browse/THRIFT-5740 - inherited interfaces should be explicitly listed in Delphi class decl + +### Documentation + +- [THRIFT-4606]https://issues.apache.org/jira/browse/THRIFT-4606 - LGPL license file still present + +### Erlang + +- [THRIFT-5635]https://issues.apache.org/jira/browse/THRIFT-5635 - Replace some removed functions with new counterparts + +### Haxe + +- [THRIFT-5734]https://issues.apache.org/jira/browse/THRIFT-5734 - generated code may lack required capitalization at class names +- [THRIFT-5742]https://issues.apache.org/jira/browse/THRIFT-5742 - Add addRange() function to Set helpers to support adding data from arbitrary enumerable containers + +### Java + +- [THRIFT-5738]https://issues.apache.org/jira/browse/THRIFT-5738 - Compiler build fails on Mac + +### netstd + +- [THRIFT-5746]https://issues.apache.org/jira/browse/THRIFT-5746 - Upgrade to net8 +- [THRIFT-5743]https://issues.apache.org/jira/browse/THRIFT-5743 - add TLS1.3 to default protocols where available +- [THRIFT-5726]https://issues.apache.org/jira/browse/THRIFT-5726 - package upgrades and consolidation/improvement of build targets checks + +### PHP + +- [THRIFT-5752]https://issues.apache.org/jira/browse/THRIFT-5752 - Add TTransportFactoryInterface +- [THRIFT-5754]https://issues.apache.org/jira/browse/THRIFT-5754 - Fix PHP 8.1 deprecates passing null to non-nullable internal function parameters +- [THRIFT-5753]https://issues.apache.org/jira/browse/THRIFT-5753 - PHP 8.1 deprecated warning about return type in jsonSerialize functions + + ## 0.19.0 ### Known Open Issues (Blocker or Critical) diff --git a/debian/changelog b/debian/changelog index 40898292a06..147c4b4bf65 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +thrift (0.20.0) stable; urgency=low + + * update to 0.20.0 + + -- Apache Thrift Developers Sat, 04 Feb 2024 14:55:00 +0100 + thrift (0.19.0) stable; urgency=low * update to 0.19.0 diff --git a/doap.rdf b/doap.rdf index 6ad3026d7fe..703082acb81 100644 --- a/doap.rdf +++ b/doap.rdf @@ -57,17 +57,22 @@ Apache Thrift - 2022-07-15 + 2024-02-04 + 0.20.0 + + + Apache Thrift + 2023-07-15 0.19.0 Apache Thrift - 2022-02-15 + 2023-02-15 0.18.1 Apache Thrift - 2022-02-06 + 2023-02-06 0.18.0 From ab6f3ef1f439e0706ed39c7e741cda80ff355f9a Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Fri, 17 Nov 2023 12:36:31 -0800 Subject: [PATCH 172/250] THRIFT-5744: Switch to slog for go library Client: go --- .github/workflows/build.yml | 4 +- LANGUAGES.md | 2 +- go.mod | 2 +- lib/go/test/fuzz/go.mod | 2 +- lib/go/test/go.mod | 2 +- lib/go/thrift/debug_protocol.go | 329 +++++++++++++++++++++++++++----- lib/go/thrift/logger.go | 12 ++ lib/go/thrift/simple_server.go | 23 ++- test/go/go.mod | 4 +- test/go/go.sum | 2 - 10 files changed, 315 insertions(+), 67 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0b5a976753..aeb1614134a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,8 +82,8 @@ jobs: strategy: matrix: go: - - '1.20' - '1.21' + - '1.22' fail-fast: false steps: - uses: actions/checkout@v4 @@ -127,7 +127,7 @@ jobs: run: make -C test/go precross - name: Upload go precross artifacts - if: matrix.go == '1.21' + if: matrix.go == '1.22' uses: actions/upload-artifact@v3 with: name: go-precross diff --git a/LANGUAGES.md b/LANGUAGES.md index 236007f9af8..4952ade158b 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -163,7 +163,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr Go 0.7.0 Yes -1.201.21 +1.211.22 YesYesYes YesYesYesYes diff --git a/go.mod b/go.mod index 7be425635ec..b435d78a368 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/apache/thrift -go 1.20 +go 1.21 diff --git a/lib/go/test/fuzz/go.mod b/lib/go/test/fuzz/go.mod index 4ff6c5d934e..b7ddd5fcc60 100644 --- a/lib/go/test/fuzz/go.mod +++ b/lib/go/test/fuzz/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/lib/go/test/fuzz -go 1.20 +go 1.21 require github.com/apache/thrift v0.0.0-00010101000000-000000000000 diff --git a/lib/go/test/go.mod b/lib/go/test/go.mod index 59535e6446d..0c032b70fe0 100644 --- a/lib/go/test/go.mod +++ b/lib/go/test/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/lib/go/test -go 1.20 +go 1.21 require ( github.com/apache/thrift v0.0.0-00010101000000-000000000000 diff --git a/lib/go/thrift/debug_protocol.go b/lib/go/thrift/debug_protocol.go index 83ccad94bff..d730411b4b6 100644 --- a/lib/go/thrift/debug_protocol.go +++ b/lib/go/thrift/debug_protocol.go @@ -21,7 +21,7 @@ package thrift import ( "context" - "fmt" + "log/slog" ) type TDebugProtocol struct { @@ -34,7 +34,11 @@ type TDebugProtocol struct { // If Logger is nil, StdLogger using stdlib log package with os.Stderr // will be used. If disable logging is desired, set Logger to NopLogger // explicitly instead of leaving it as nil/unset. - Logger Logger + // + // Deprecated: TDebugProtocol always use slog at debug level now. + // This field will be removed in a future version. + Logger Logger + LogPrefix string // Optional. An TProtocol to duplicate everything read/written from Delegate. @@ -86,13 +90,16 @@ func (t *TDebugProtocolFactory) GetProtocol(trans TTransport) TProtocol { } } -func (tdp *TDebugProtocol) logf(format string, v ...interface{}) { - fallbackLogger(tdp.Logger)(fmt.Sprintf(format, v...)) -} - func (tdp *TDebugProtocol) WriteMessageBegin(ctx context.Context, name string, typeId TMessageType, seqid int32) error { err := tdp.Delegate.WriteMessageBegin(ctx, name, typeId, seqid) - tdp.logf("%sWriteMessageBegin(name=%#v, typeId=%#v, seqid=%#v) => %#v", tdp.LogPrefix, name, typeId, seqid, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteMessageBegin", + "name", name, + "typeId", typeId, + "seqid", seqid, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteMessageBegin(ctx, name, typeId, seqid) } @@ -100,7 +107,11 @@ func (tdp *TDebugProtocol) WriteMessageBegin(ctx context.Context, name string, t } func (tdp *TDebugProtocol) WriteMessageEnd(ctx context.Context) error { err := tdp.Delegate.WriteMessageEnd(ctx) - tdp.logf("%sWriteMessageEnd() => %#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteMessageEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteMessageEnd(ctx) } @@ -108,7 +119,12 @@ func (tdp *TDebugProtocol) WriteMessageEnd(ctx context.Context) error { } func (tdp *TDebugProtocol) WriteStructBegin(ctx context.Context, name string) error { err := tdp.Delegate.WriteStructBegin(ctx, name) - tdp.logf("%sWriteStructBegin(name=%#v) => %#v", tdp.LogPrefix, name, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteStructBegin", + "name", name, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteStructBegin(ctx, name) } @@ -116,7 +132,11 @@ func (tdp *TDebugProtocol) WriteStructBegin(ctx context.Context, name string) er } func (tdp *TDebugProtocol) WriteStructEnd(ctx context.Context) error { err := tdp.Delegate.WriteStructEnd(ctx) - tdp.logf("%sWriteStructEnd() => %#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteStructEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteStructEnd(ctx) } @@ -124,7 +144,14 @@ func (tdp *TDebugProtocol) WriteStructEnd(ctx context.Context) error { } func (tdp *TDebugProtocol) WriteFieldBegin(ctx context.Context, name string, typeId TType, id int16) error { err := tdp.Delegate.WriteFieldBegin(ctx, name, typeId, id) - tdp.logf("%sWriteFieldBegin(name=%#v, typeId=%#v, id%#v) => %#v", tdp.LogPrefix, name, typeId, id, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteFieldBegin", + "name", name, + "typeId", typeId, + "id", id, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteFieldBegin(ctx, name, typeId, id) } @@ -132,7 +159,11 @@ func (tdp *TDebugProtocol) WriteFieldBegin(ctx context.Context, name string, typ } func (tdp *TDebugProtocol) WriteFieldEnd(ctx context.Context) error { err := tdp.Delegate.WriteFieldEnd(ctx) - tdp.logf("%sWriteFieldEnd() => %#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteFieldEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteFieldEnd(ctx) } @@ -140,7 +171,11 @@ func (tdp *TDebugProtocol) WriteFieldEnd(ctx context.Context) error { } func (tdp *TDebugProtocol) WriteFieldStop(ctx context.Context) error { err := tdp.Delegate.WriteFieldStop(ctx) - tdp.logf("%sWriteFieldStop() => %#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteFieldStop", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteFieldStop(ctx) } @@ -148,7 +183,14 @@ func (tdp *TDebugProtocol) WriteFieldStop(ctx context.Context) error { } func (tdp *TDebugProtocol) WriteMapBegin(ctx context.Context, keyType TType, valueType TType, size int) error { err := tdp.Delegate.WriteMapBegin(ctx, keyType, valueType, size) - tdp.logf("%sWriteMapBegin(keyType=%#v, valueType=%#v, size=%#v) => %#v", tdp.LogPrefix, keyType, valueType, size, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteMapBegin", + "keyType", keyType, + "valueType", valueType, + "size", size, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteMapBegin(ctx, keyType, valueType, size) } @@ -156,7 +198,11 @@ func (tdp *TDebugProtocol) WriteMapBegin(ctx context.Context, keyType TType, val } func (tdp *TDebugProtocol) WriteMapEnd(ctx context.Context) error { err := tdp.Delegate.WriteMapEnd(ctx) - tdp.logf("%sWriteMapEnd() => %#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteMapEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteMapEnd(ctx) } @@ -164,7 +210,13 @@ func (tdp *TDebugProtocol) WriteMapEnd(ctx context.Context) error { } func (tdp *TDebugProtocol) WriteListBegin(ctx context.Context, elemType TType, size int) error { err := tdp.Delegate.WriteListBegin(ctx, elemType, size) - tdp.logf("%sWriteListBegin(elemType=%#v, size=%#v) => %#v", tdp.LogPrefix, elemType, size, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteListBegin", + "elemType", elemType, + "size", size, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteListBegin(ctx, elemType, size) } @@ -172,7 +224,11 @@ func (tdp *TDebugProtocol) WriteListBegin(ctx context.Context, elemType TType, s } func (tdp *TDebugProtocol) WriteListEnd(ctx context.Context) error { err := tdp.Delegate.WriteListEnd(ctx) - tdp.logf("%sWriteListEnd() => %#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteListEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteListEnd(ctx) } @@ -180,7 +236,13 @@ func (tdp *TDebugProtocol) WriteListEnd(ctx context.Context) error { } func (tdp *TDebugProtocol) WriteSetBegin(ctx context.Context, elemType TType, size int) error { err := tdp.Delegate.WriteSetBegin(ctx, elemType, size) - tdp.logf("%sWriteSetBegin(elemType=%#v, size=%#v) => %#v", tdp.LogPrefix, elemType, size, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteSetBegin", + "elemType", elemType, + "size", size, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteSetBegin(ctx, elemType, size) } @@ -188,7 +250,11 @@ func (tdp *TDebugProtocol) WriteSetBegin(ctx context.Context, elemType TType, si } func (tdp *TDebugProtocol) WriteSetEnd(ctx context.Context) error { err := tdp.Delegate.WriteSetEnd(ctx) - tdp.logf("%sWriteSetEnd() => %#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteSetEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteSetEnd(ctx) } @@ -196,7 +262,12 @@ func (tdp *TDebugProtocol) WriteSetEnd(ctx context.Context) error { } func (tdp *TDebugProtocol) WriteBool(ctx context.Context, value bool) error { err := tdp.Delegate.WriteBool(ctx, value) - tdp.logf("%sWriteBool(value=%#v) => %#v", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteBool", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteBool(ctx, value) } @@ -204,7 +275,12 @@ func (tdp *TDebugProtocol) WriteBool(ctx context.Context, value bool) error { } func (tdp *TDebugProtocol) WriteByte(ctx context.Context, value int8) error { err := tdp.Delegate.WriteByte(ctx, value) - tdp.logf("%sWriteByte(value=%#v) => %#v", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteByte", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteByte(ctx, value) } @@ -212,7 +288,12 @@ func (tdp *TDebugProtocol) WriteByte(ctx context.Context, value int8) error { } func (tdp *TDebugProtocol) WriteI16(ctx context.Context, value int16) error { err := tdp.Delegate.WriteI16(ctx, value) - tdp.logf("%sWriteI16(value=%#v) => %#v", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteI16", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteI16(ctx, value) } @@ -220,7 +301,12 @@ func (tdp *TDebugProtocol) WriteI16(ctx context.Context, value int16) error { } func (tdp *TDebugProtocol) WriteI32(ctx context.Context, value int32) error { err := tdp.Delegate.WriteI32(ctx, value) - tdp.logf("%sWriteI32(value=%#v) => %#v", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteI32", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteI32(ctx, value) } @@ -228,7 +314,12 @@ func (tdp *TDebugProtocol) WriteI32(ctx context.Context, value int32) error { } func (tdp *TDebugProtocol) WriteI64(ctx context.Context, value int64) error { err := tdp.Delegate.WriteI64(ctx, value) - tdp.logf("%sWriteI64(value=%#v) => %#v", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteI64", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteI64(ctx, value) } @@ -236,7 +327,12 @@ func (tdp *TDebugProtocol) WriteI64(ctx context.Context, value int64) error { } func (tdp *TDebugProtocol) WriteDouble(ctx context.Context, value float64) error { err := tdp.Delegate.WriteDouble(ctx, value) - tdp.logf("%sWriteDouble(value=%#v) => %#v", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteDouble", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteDouble(ctx, value) } @@ -244,7 +340,12 @@ func (tdp *TDebugProtocol) WriteDouble(ctx context.Context, value float64) error } func (tdp *TDebugProtocol) WriteString(ctx context.Context, value string) error { err := tdp.Delegate.WriteString(ctx, value) - tdp.logf("%sWriteString(value=%#v) => %#v", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteString", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteString(ctx, value) } @@ -252,7 +353,12 @@ func (tdp *TDebugProtocol) WriteString(ctx context.Context, value string) error } func (tdp *TDebugProtocol) WriteBinary(ctx context.Context, value []byte) error { err := tdp.Delegate.WriteBinary(ctx, value) - tdp.logf("%sWriteBinary(value=%#v) => %#v", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteBinary", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteBinary(ctx, value) } @@ -260,7 +366,12 @@ func (tdp *TDebugProtocol) WriteBinary(ctx context.Context, value []byte) error } func (tdp *TDebugProtocol) WriteUUID(ctx context.Context, value Tuuid) error { err := tdp.Delegate.WriteUUID(ctx, value) - tdp.logf("%sWriteUUID(value=%#v) => %#v", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"WriteUUID", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteUUID(ctx, value) } @@ -269,7 +380,14 @@ func (tdp *TDebugProtocol) WriteUUID(ctx context.Context, value Tuuid) error { func (tdp *TDebugProtocol) ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqid int32, err error) { name, typeId, seqid, err = tdp.Delegate.ReadMessageBegin(ctx) - tdp.logf("%sReadMessageBegin() (name=%#v, typeId=%#v, seqid=%#v, err=%#v)", tdp.LogPrefix, name, typeId, seqid, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadMessageBegin", + "name", name, + "typeId", typeId, + "seqid", seqid, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteMessageBegin(ctx, name, typeId, seqid) } @@ -277,7 +395,11 @@ func (tdp *TDebugProtocol) ReadMessageBegin(ctx context.Context) (name string, t } func (tdp *TDebugProtocol) ReadMessageEnd(ctx context.Context) (err error) { err = tdp.Delegate.ReadMessageEnd(ctx) - tdp.logf("%sReadMessageEnd() err=%#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadMessageEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteMessageEnd(ctx) } @@ -285,7 +407,12 @@ func (tdp *TDebugProtocol) ReadMessageEnd(ctx context.Context) (err error) { } func (tdp *TDebugProtocol) ReadStructBegin(ctx context.Context) (name string, err error) { name, err = tdp.Delegate.ReadStructBegin(ctx) - tdp.logf("%sReadStructBegin() (name%#v, err=%#v)", tdp.LogPrefix, name, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadStructBegin", + "name", name, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteStructBegin(ctx, name) } @@ -293,7 +420,11 @@ func (tdp *TDebugProtocol) ReadStructBegin(ctx context.Context) (name string, er } func (tdp *TDebugProtocol) ReadStructEnd(ctx context.Context) (err error) { err = tdp.Delegate.ReadStructEnd(ctx) - tdp.logf("%sReadStructEnd() err=%#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadStructEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteStructEnd(ctx) } @@ -301,7 +432,14 @@ func (tdp *TDebugProtocol) ReadStructEnd(ctx context.Context) (err error) { } func (tdp *TDebugProtocol) ReadFieldBegin(ctx context.Context) (name string, typeId TType, id int16, err error) { name, typeId, id, err = tdp.Delegate.ReadFieldBegin(ctx) - tdp.logf("%sReadFieldBegin() (name=%#v, typeId=%#v, id=%#v, err=%#v)", tdp.LogPrefix, name, typeId, id, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadFieldBegin", + "name", name, + "typeId", typeId, + "id", id, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteFieldBegin(ctx, name, typeId, id) } @@ -309,7 +447,11 @@ func (tdp *TDebugProtocol) ReadFieldBegin(ctx context.Context) (name string, typ } func (tdp *TDebugProtocol) ReadFieldEnd(ctx context.Context) (err error) { err = tdp.Delegate.ReadFieldEnd(ctx) - tdp.logf("%sReadFieldEnd() err=%#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadFieldEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteFieldEnd(ctx) } @@ -317,7 +459,14 @@ func (tdp *TDebugProtocol) ReadFieldEnd(ctx context.Context) (err error) { } func (tdp *TDebugProtocol) ReadMapBegin(ctx context.Context) (keyType TType, valueType TType, size int, err error) { keyType, valueType, size, err = tdp.Delegate.ReadMapBegin(ctx) - tdp.logf("%sReadMapBegin() (keyType=%#v, valueType=%#v, size=%#v, err=%#v)", tdp.LogPrefix, keyType, valueType, size, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadMapBegin", + "keyType", keyType, + "valueType", valueType, + "size", size, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteMapBegin(ctx, keyType, valueType, size) } @@ -325,7 +474,11 @@ func (tdp *TDebugProtocol) ReadMapBegin(ctx context.Context) (keyType TType, val } func (tdp *TDebugProtocol) ReadMapEnd(ctx context.Context) (err error) { err = tdp.Delegate.ReadMapEnd(ctx) - tdp.logf("%sReadMapEnd() err=%#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadMapEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteMapEnd(ctx) } @@ -333,7 +486,13 @@ func (tdp *TDebugProtocol) ReadMapEnd(ctx context.Context) (err error) { } func (tdp *TDebugProtocol) ReadListBegin(ctx context.Context) (elemType TType, size int, err error) { elemType, size, err = tdp.Delegate.ReadListBegin(ctx) - tdp.logf("%sReadListBegin() (elemType=%#v, size=%#v, err=%#v)", tdp.LogPrefix, elemType, size, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadListBegin", + "elemType", elemType, + "size", size, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteListBegin(ctx, elemType, size) } @@ -341,7 +500,11 @@ func (tdp *TDebugProtocol) ReadListBegin(ctx context.Context) (elemType TType, s } func (tdp *TDebugProtocol) ReadListEnd(ctx context.Context) (err error) { err = tdp.Delegate.ReadListEnd(ctx) - tdp.logf("%sReadListEnd() err=%#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadListEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteListEnd(ctx) } @@ -349,7 +512,13 @@ func (tdp *TDebugProtocol) ReadListEnd(ctx context.Context) (err error) { } func (tdp *TDebugProtocol) ReadSetBegin(ctx context.Context) (elemType TType, size int, err error) { elemType, size, err = tdp.Delegate.ReadSetBegin(ctx) - tdp.logf("%sReadSetBegin() (elemType=%#v, size=%#v, err=%#v)", tdp.LogPrefix, elemType, size, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadSetBegin", + "elemType", elemType, + "size", size, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteSetBegin(ctx, elemType, size) } @@ -357,7 +526,11 @@ func (tdp *TDebugProtocol) ReadSetBegin(ctx context.Context) (elemType TType, si } func (tdp *TDebugProtocol) ReadSetEnd(ctx context.Context) (err error) { err = tdp.Delegate.ReadSetEnd(ctx) - tdp.logf("%sReadSetEnd() err=%#v", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadSetEnd", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteSetEnd(ctx) } @@ -365,7 +538,12 @@ func (tdp *TDebugProtocol) ReadSetEnd(ctx context.Context) (err error) { } func (tdp *TDebugProtocol) ReadBool(ctx context.Context) (value bool, err error) { value, err = tdp.Delegate.ReadBool(ctx) - tdp.logf("%sReadBool() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadBool", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteBool(ctx, value) } @@ -373,7 +551,12 @@ func (tdp *TDebugProtocol) ReadBool(ctx context.Context) (value bool, err error) } func (tdp *TDebugProtocol) ReadByte(ctx context.Context) (value int8, err error) { value, err = tdp.Delegate.ReadByte(ctx) - tdp.logf("%sReadByte() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadByte", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteByte(ctx, value) } @@ -381,7 +564,12 @@ func (tdp *TDebugProtocol) ReadByte(ctx context.Context) (value int8, err error) } func (tdp *TDebugProtocol) ReadI16(ctx context.Context) (value int16, err error) { value, err = tdp.Delegate.ReadI16(ctx) - tdp.logf("%sReadI16() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadI16", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteI16(ctx, value) } @@ -389,7 +577,12 @@ func (tdp *TDebugProtocol) ReadI16(ctx context.Context) (value int16, err error) } func (tdp *TDebugProtocol) ReadI32(ctx context.Context) (value int32, err error) { value, err = tdp.Delegate.ReadI32(ctx) - tdp.logf("%sReadI32() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadI32", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteI32(ctx, value) } @@ -397,7 +590,12 @@ func (tdp *TDebugProtocol) ReadI32(ctx context.Context) (value int32, err error) } func (tdp *TDebugProtocol) ReadI64(ctx context.Context) (value int64, err error) { value, err = tdp.Delegate.ReadI64(ctx) - tdp.logf("%sReadI64() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadI64", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteI64(ctx, value) } @@ -405,7 +603,12 @@ func (tdp *TDebugProtocol) ReadI64(ctx context.Context) (value int64, err error) } func (tdp *TDebugProtocol) ReadDouble(ctx context.Context) (value float64, err error) { value, err = tdp.Delegate.ReadDouble(ctx) - tdp.logf("%sReadDouble() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadDouble", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteDouble(ctx, value) } @@ -413,7 +616,12 @@ func (tdp *TDebugProtocol) ReadDouble(ctx context.Context) (value float64, err e } func (tdp *TDebugProtocol) ReadString(ctx context.Context) (value string, err error) { value, err = tdp.Delegate.ReadString(ctx) - tdp.logf("%sReadString() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadString", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteString(ctx, value) } @@ -421,7 +629,12 @@ func (tdp *TDebugProtocol) ReadString(ctx context.Context) (value string, err er } func (tdp *TDebugProtocol) ReadBinary(ctx context.Context) (value []byte, err error) { value, err = tdp.Delegate.ReadBinary(ctx) - tdp.logf("%sReadBinary() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadBinary", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteBinary(ctx, value) } @@ -429,7 +642,12 @@ func (tdp *TDebugProtocol) ReadBinary(ctx context.Context) (value []byte, err er } func (tdp *TDebugProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error) { value, err = tdp.Delegate.ReadUUID(ctx) - tdp.logf("%sReadUUID() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"ReadUUID", + "value", value, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.WriteUUID(ctx, value) } @@ -437,7 +655,12 @@ func (tdp *TDebugProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error } func (tdp *TDebugProtocol) Skip(ctx context.Context, fieldType TType) (err error) { err = tdp.Delegate.Skip(ctx, fieldType) - tdp.logf("%sSkip(fieldType=%#v) (err=%#v)", tdp.LogPrefix, fieldType, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"Skip", + "fieldType", fieldType, + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.Skip(ctx, fieldType) } @@ -445,7 +668,11 @@ func (tdp *TDebugProtocol) Skip(ctx context.Context, fieldType TType) (err error } func (tdp *TDebugProtocol) Flush(ctx context.Context) (err error) { err = tdp.Delegate.Flush(ctx) - tdp.logf("%sFlush() (err=%#v)", tdp.LogPrefix, err) + slog.DebugContext( + ctx, + tdp.LogPrefix+"Flush", + "err", err, + ) if tdp.DuplicateTo != nil { tdp.DuplicateTo.Flush(ctx) } diff --git a/lib/go/thrift/logger.go b/lib/go/thrift/logger.go index c42aac998b7..4a0affe6229 100644 --- a/lib/go/thrift/logger.go +++ b/lib/go/thrift/logger.go @@ -35,14 +35,23 @@ import ( // // See https://issues.apache.org/jira/browse/THRIFT-4985 for the design // discussion behind it. +// +// Deprecated: This is no longer used by any thrift go library code, +// will be removed in the future version. type Logger func(msg string) // NopLogger is a Logger implementation that does nothing. +// +// Deprecated: This is no longer used by any thrift go library code, +// will be removed in the future version. func NopLogger(msg string) {} // StdLogger wraps stdlib log package into a Logger. // // If logger passed in is nil, it will fallback to use stderr and default flags. +// +// Deprecated: This is no longer used by any thrift go library code, +// will be removed in the future version. func StdLogger(logger *log.Logger) Logger { if logger == nil { logger = log.New(os.Stderr, "", log.LstdFlags) @@ -55,6 +64,9 @@ func StdLogger(logger *log.Logger) Logger { // TestLogger is a Logger implementation can be used in test codes. // // It fails the test when being called. +// +// Deprecated: This is no longer used by any thrift go library code, +// will be removed in the future version. func TestLogger(tb testing.TB) Logger { return func(msg string) { tb.Errorf("logger called with msg: %q", msg) diff --git a/lib/go/thrift/simple_server.go b/lib/go/thrift/simple_server.go index d4f555ccd51..a8634fc5f0e 100644 --- a/lib/go/thrift/simple_server.go +++ b/lib/go/thrift/simple_server.go @@ -22,8 +22,8 @@ package thrift import ( "context" "errors" - "fmt" "io" + "log/slog" "net" "sync" "sync/atomic" @@ -70,7 +70,7 @@ type TSimpleServer struct { // Headers to auto forward in THeaderProtocol forwardHeaders []string - logger Logger + logContext atomic.Pointer[context.Context] } func NewTSimpleServer2(processor TProcessor, serverTransport TServerTransport) *TSimpleServer { @@ -179,8 +179,18 @@ func (p *TSimpleServer) SetForwardHeaders(headers []string) { // // If no logger was set before Serve is called, a default logger using standard // log library will be used. -func (p *TSimpleServer) SetLogger(logger Logger) { - p.logger = logger +// +// Deprecated: The logging inside TSimpleServer is now done via slog on error +// level, this does nothing now. It will be removed in a future version. +func (p *TSimpleServer) SetLogger(_ Logger) {} + +// SetLogContext sets the context to be used when logging errors inside +// TSimpleServer. +// +// If this is not called before calling Serve, context.Background() will be +// used. +func (p *TSimpleServer) SetLogContext(ctx context.Context) { + p.logContext.Store(&ctx) } func (p *TSimpleServer) innerAccept() (int32, error) { @@ -202,7 +212,8 @@ func (p *TSimpleServer) innerAccept() (int32, error) { defer p.wg.Done() defer cancel() if err := p.processRequests(client); err != nil { - p.logger(fmt.Sprintf("error processing request: %v", err)) + ctx := p.logContext.Load() + slog.ErrorContext(*ctx, "error processing request", "err", err) } }() @@ -233,7 +244,7 @@ func (p *TSimpleServer) AcceptLoop() error { } func (p *TSimpleServer) Serve() error { - p.logger = fallbackLogger(p.logger) + p.logContext.CompareAndSwap(nil, Pointer(context.Background())) err := p.Listen() if err != nil { diff --git a/test/go/go.mod b/test/go/go.mod index 723069b7875..f69cdb4438e 100644 --- a/test/go/go.mod +++ b/test/go/go.mod @@ -1,6 +1,6 @@ module github.com/apache/thrift/test/go -go 1.20 +go 1.21 require ( github.com/apache/thrift v0.0.0-00010101000000-000000000000 @@ -9,7 +9,7 @@ require ( require ( golang.org/x/mod v0.4.2 // indirect - golang.org/x/sys v0.7.0 // indirect + golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect golang.org/x/tools v0.1.1 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/test/go/go.sum b/test/go/go.sum index b6ad5455ed0..6904b3efe74 100644 --- a/test/go/go.sum +++ b/test/go/go.sum @@ -16,8 +16,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From dd1217fc9a201e1db86f2c2669c6f5a93d7fcf89 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Tue, 21 Nov 2023 16:42:00 -0800 Subject: [PATCH 173/250] THRIFT-5745: Implement slog.LogValuer on go TStructs Client: go Implement slog.LogValuer for all TStruct and TException generated by the compiler for go code. Also add SlogTStructWrapper in the library so we don't have to repeat it in the compiler generated go code. --- .../cpp/src/thrift/generate/t_go_generator.cc | 64 +++++++-- .../test/tests/slog_tstruct_wrapper_test.go | 132 ++++++++++++++++++ lib/go/thrift/slog.go | 55 ++++++++ lib/go/thrift/slog_test.go | 37 +++++ 4 files changed, 275 insertions(+), 13 deletions(-) create mode 100644 lib/go/test/tests/slog_tstruct_wrapper_test.go create mode 100644 lib/go/thrift/slog.go create mode 100644 lib/go/thrift/slog_test.go diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index 54422c82670..db30c8bae8c 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -706,6 +706,7 @@ string t_go_generator::go_imports_begin(bool consts) { } system_packages.push_back("errors"); system_packages.push_back("fmt"); + system_packages.push_back("log/slog"); system_packages.push_back("time"); // For the thrift import, always do rename import to make sure it's called thrift. system_packages.push_back("thrift \"" + gen_thrift_import_ + "\""); @@ -726,12 +727,13 @@ string t_go_generator::go_imports_end() { string import_end = string( ")\n\n" "// (needed to ensure safety because of naive import list construction.)\n" - "var _ = thrift.ZERO\n" - "var _ = fmt.Printf\n" - "var _ = errors.New\n" + "var _ = bytes.Equal\n" "var _ = context.Background\n" + "var _ = errors.New\n" + "var _ = fmt.Printf\n" + "var _ = slog.Log\n" "var _ = time.Now\n" - "var _ = bytes.Equal\n" + "var _ = thrift.ZERO\n" "// (needed by validator.)\n" "var _ = strings.Contains\n" "var _ = regexp.MatchString\n\n"); @@ -1308,8 +1310,10 @@ void t_go_generator::generate_go_struct_definition(ostream& out, indent_down(); out << indent() << "}" << endl << endl; out << indent() << "func New" << tstruct_name << "() *" << tstruct_name << " {" << endl; - out << indent() << " return &"; + indent_up(); + out << indent() << "return &"; generate_go_struct_initializer(out, tstruct, is_result || is_args); + indent_down(); out << indent() << "}" << endl << endl; // Default values for optional fields for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -1339,16 +1343,22 @@ void t_go_generator::generate_go_struct_definition(ostream& out, string maybepointer = goOptType != goType ? "*" : ""; out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() " << goType << " {" << endl; - out << indent() << " if !p.IsSet" << publicized_name << "() {" << endl; - out << indent() << " return " << def_var_name << endl; - out << indent() << " }" << endl; + indent_up(); + out << indent() << "if !p.IsSet" << publicized_name << "() {" << endl; + indent_up(); + out << indent() << "return " << def_var_name << endl; + indent_down(); + out << indent() << "}" << endl; out << indent() << "return " << maybepointer << "p." << publicized_name << endl; + indent_down(); out << indent() << "}" << endl; } else { out << endl; out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() " << goType << " {" << endl; - out << indent() << " return p." << publicized_name << endl; + indent_up(); + out << indent() << "return p." << publicized_name << endl; + indent_down(); out << indent() << "}" << endl; } } @@ -1365,11 +1375,15 @@ void t_go_generator::generate_go_struct_definition(ostream& out, } out << indent() << "func (p *" << tstruct_name << ") String() string {" << endl; - out << indent() << " if p == nil {" << endl; - out << indent() << " return \"\"" << endl; - out << indent() << " }" << endl; - out << indent() << " return fmt.Sprintf(\"" << escape_string(tstruct_name) << "(%+v)\", *p)" + indent_up(); + out << indent() << "if p == nil {" << endl; + indent_up(); + out << indent() << "return \"\"" << endl; + indent_down(); + out << indent() << "}" << endl; + out << indent() << "return fmt.Sprintf(\"" << escape_string(tstruct_name) << "(%+v)\", *p)" << endl; + indent_down(); out << indent() << "}" << endl << endl; if (is_exception) { @@ -1388,6 +1402,30 @@ void t_go_generator::generate_go_struct_definition(ostream& out, out << indent() << "var _ thrift.TException = (*" << tstruct_name << ")(nil)" << endl << endl; } + + if (!read_write_private_) { + // Generate the implementation of slog.LogValuer, + // see: https://issues.apache.org/jira/browse/THRIFT-5745 + out << indent() << "func (p *" << tstruct_name << ") LogValue() slog.Value {" << endl; + indent_up(); + out << indent() << "if p == nil {" << endl; + indent_up(); + out << indent() << "return slog.AnyValue(nil)" << endl; + indent_down(); + out << indent() << "}" << endl; + out << indent() << "v := thrift.SlogTStructWrapper{" << endl; + indent_up(); + out << indent() << "Type: \"*" << package_name_ << "." << tstruct_name << "\"," << endl; + out << indent() << "Value: p," << endl; + indent_down(); + out << indent() << "}" << endl; + out << indent() << "return slog.AnyValue(v)" << endl; + indent_down(); + out << indent() << "}" << endl << endl; + + out << indent() << "var _ slog.LogValuer = (*" << tstruct_name << ")(nil)" + << endl << endl; + } } /** diff --git a/lib/go/test/tests/slog_tstruct_wrapper_test.go b/lib/go/test/tests/slog_tstruct_wrapper_test.go new file mode 100644 index 00000000000..854c562092b --- /dev/null +++ b/lib/go/test/tests/slog_tstruct_wrapper_test.go @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package tests + +import ( + "log/slog" + "strings" + "testing" + + "github.com/apache/thrift/lib/go/test/gopath/src/forwardtypetest" + "github.com/apache/thrift/lib/go/thrift" +) + +func dropTime(groups []string, a slog.Attr) slog.Attr { + if len(groups) == 0 && a.Key == slog.TimeKey { + return slog.Attr{} + } + return a +} + +func TestSlogTStructWrapperJSON(t *testing.T) { + for _, c := range []struct { + label string + value thrift.TStruct + want string + }{ + { + label: "struct", + value: &forwardtypetest.Struct{ + Foo: &forwardtypetest.Exc{ + Code: thrift.Int32Ptr(10), + }, + }, + want: `{"level":"INFO","msg":"bar","struct":{"type":"*forwardtypetest.Struct","value":{"foo":{"code":10}}}}`, + }, + { + label: "exception", + value: &forwardtypetest.Exc{ + Code: thrift.Int32Ptr(10), + }, + want: `{"level":"INFO","msg":"bar","struct":{"type":"*forwardtypetest.Exc","value":{"code":10}}}`, + }, + { + label: "nil-struct", + value: (*forwardtypetest.Struct)(nil), + want: `{"level":"INFO","msg":"bar","struct":null}`, + }, + { + label: "nil-exception", + value: (*forwardtypetest.Exc)(nil), + want: `{"level":"INFO","msg":"bar","struct":null}`, + }, + } { + t.Run(c.label, func(t *testing.T) { + var sb strings.Builder + logger := slog.New(slog.NewJSONHandler(&sb, &slog.HandlerOptions{ + AddSource: false, + ReplaceAttr: dropTime, + })) + + logger.Info("bar", "struct", c.value) + if got := strings.TrimSuffix(sb.String(), "\n"); got != c.want { + t.Errorf("got %q want %q", got, c.want) + } + }) + } +} + +func TestSlogTStructWrapperText(t *testing.T) { + for _, c := range []struct { + label string + value thrift.TStruct + want string + }{ + { + label: "struct", + value: &forwardtypetest.Struct{ + Foo: &forwardtypetest.Exc{ + Code: thrift.Int32Ptr(10), + }, + }, + want: `level=INFO msg=bar struct="*forwardtypetest.Struct{\"foo\":{\"code\":10}}"`, + }, + { + label: "exception", + value: &forwardtypetest.Exc{ + Code: thrift.Int32Ptr(10), + }, + want: `level=INFO msg=bar struct="*forwardtypetest.Exc{\"code\":10}"`, + }, + { + label: "nil-struct", + value: (*forwardtypetest.Struct)(nil), + want: `level=INFO msg=bar struct=`, + }, + { + label: "nil-exception", + value: (*forwardtypetest.Exc)(nil), + want: `level=INFO msg=bar struct=`, + }, + } { + t.Run(c.label, func(t *testing.T) { + var sb strings.Builder + logger := slog.New(slog.NewTextHandler(&sb, &slog.HandlerOptions{ + AddSource: false, + ReplaceAttr: dropTime, + })) + + logger.Info("bar", "struct", c.value) + if got := strings.TrimSuffix(sb.String(), "\n"); got != c.want { + t.Errorf("got %q want %q", got, c.want) + } + }) + } +} diff --git a/lib/go/thrift/slog.go b/lib/go/thrift/slog.go new file mode 100644 index 00000000000..22545d843d8 --- /dev/null +++ b/lib/go/thrift/slog.go @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "encoding/json" + "fmt" + "strings" +) + +// SlogTStructWrapper is a wrapper used by the compiler to wrap TStruct and +// TException to be better logged by slog. +type SlogTStructWrapper struct { + Type string `json:"type"` + Value TStruct `json:"value"` +} + +var ( + _ fmt.Stringer = SlogTStructWrapper{} + _ json.Marshaler = SlogTStructWrapper{} +) + +func (w SlogTStructWrapper) MarshalJSON() ([]byte, error) { + // Use an alias to avoid infinite recursion + type alias SlogTStructWrapper + return json.Marshal(alias(w)) +} + +func (w SlogTStructWrapper) String() string { + var sb strings.Builder + sb.WriteString(w.Type) + if err := json.NewEncoder(&sb).Encode(w.Value); err != nil { + // Should not happen, but just in case + return fmt.Sprintf("%s: %v", w.Type, w.Value) + } + // json encoder will write an additional \n at the end, get rid of it + return strings.TrimSuffix(sb.String(), "\n") +} diff --git a/lib/go/thrift/slog_test.go b/lib/go/thrift/slog_test.go new file mode 100644 index 00000000000..f4155d4e002 --- /dev/null +++ b/lib/go/thrift/slog_test.go @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "encoding/json" + "strings" + "testing" +) + +func TestSlogTStructWrapperJSON(t *testing.T) { + // This test just ensures that we don't have infinite recursion when + // json encoding it. More comprehensive tests are under lib/go/test. + v := SlogTStructWrapper{Type: "foo"} + var sb strings.Builder + if err := json.NewEncoder(&sb).Encode(v); err != nil { + t.Fatal(err) + } + t.Log(strings.TrimSuffix(sb.String(), "\n")) +} From 9a253e7002343ac942864ac3821744871feff092 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 7 Feb 2024 17:42:39 -0800 Subject: [PATCH 174/250] THRIFT-5688: Add PyPI publishing github actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is tested with https://github.com/apache/thrift/pull/2927, which published to https://test.pypi.org/project/thrift-test/. I tested locally with: (venv) fishy@penguin:~/work/test$ pip install -i https://test.pypi.org/simple/ thrift-test Looking in indexes: https://test.pypi.org/simple/ Collecting thrift-test Downloading https://test-files.pythonhosted.org/packages/e6/02/5885ea1406f560d0a23351f68acc2892d7f6495b16bfc2eeee8de4649777/thrift-test-0.21.0.tar.gz (62 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.3/62.3 kB 1.4 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Collecting six>=1.7.2 (from thrift-test) Downloading https://test-files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz (29 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: thrift-test, six Building wheel for thrift-test (setup.py) ... done Created wheel for thrift-test: filename=thrift_test-0.21.0-cp311-cp311-linux_x86_64.whl size=416914 sha256=3a972bc562be7ed19cb37399e444ed0d373cde5319023974080b625e550901d4 Stored in directory: /home/fishy/.cache/pip/wheels/45/20/1f/d3e1b869ac068d63ca2b2c13a2f4e33a80b360fae7091c8a9b Building wheel for six (setup.py) ... done Created wheel for six: filename=six-1.10.0-py2.py3-none-any.whl size=9942 sha256=74014380446ccf331366316cec0b1aaf40e0162e70307622b493e38e8451115f Stored in directory: /home/fishy/.cache/pip/wheels/e4/18/d0/e02474c90dcf14c511c0f52145d7e72e41ff3fb80b330ba58e Successfully built thrift-test six Installing collected packages: six, thrift-test Successfully installed six-1.10.0 thrift-test-0.21.0 (venv) fishy@penguin:~/work/test$ python3 Python 3.11.7 (main, Dec 8 2023, 14:22:46) [GCC 13.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from thrift.transport import TSocket >>> transport = TSocket.TSocket('localhost', 9090) >>> transport >>> transport.open() Could not connect to any of [('::1', 9090, 0, 0), ('127.0.0.1', 9090)] Traceback (most recent call last): File "", line 1, in File "/home/fishy/work/test/venv/lib/python3.11/site-packages/thrift/transport/TSocket.py", line 149, in open raise TTransportException(type=TTransportException.NOT_OPEN, message=msg) thrift.transport.TTransport.TTransportException: Could not connect to any of [('::1', 9090, 0, 0), ('127.0.0.1', 9090)] >>> from thrift.protocol import fastbinary >>> fastbinary >>> fastbinary.decode_compact >>> If we want to merge this version, I'll enable pending publishing with `pypi.yml` from this repo on pypi [1]. [1]: https://pypi.org/manage/account/publishing/ --- .github/workflows/pypi.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 00000000000..ad089f0e6dc --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,32 @@ +name: "PyPI publishing" + +on: + release: + types: [published] + +jobs: + pypi-publish: + name: Publish release to PyPI + runs-on: ubuntu-latest + # Specifying a GitHub environment is optional, but strongly encouraged + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.8" + + - name: Build + run: | + cd lib/py + python setup.py sdist + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: lib/py/dist/ From 417eafd480324a596e080be6801da60575350496 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Mon, 19 Feb 2024 14:24:51 -0800 Subject: [PATCH 175/250] Add license header to pypi workflow file --- .github/workflows/pypi.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index ad089f0e6dc..4fc292dc79c 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -1,3 +1,22 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + name: "PyPI publishing" on: From 0d0ac75347267f7c12fc9b5b349bf9ef7f632347 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Tue, 12 Mar 2024 21:49:28 +0100 Subject: [PATCH 176/250] Preparing 0.20.0 --- CHANGES.md | 10 ++++++++++ Makefile.am | 6 ++++++ lib/go/test/Makefile.am | 2 ++ test/Makefile.am | 2 ++ test/go/Makefile.am | 2 ++ tutorial/swift/Makefile.am | 10 ++++++++++ 6 files changed, 32 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index d903760a653..bc2fed4750e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,4 @@ + # Apache Thrift Changelog ## 0.20.0 @@ -33,6 +34,12 @@ - [THRIFT-5635]https://issues.apache.org/jira/browse/THRIFT-5635 - Replace some removed functions with new counterparts +### Go + +- [THRIFT-5744]https://issues.apache.org/jira/browse/THRIFT-5744 - Switch to slog for go library +- [THRIFT-5745]https://issues.apache.org/jira/browse/THRIFT-5745 - Implement slog.LogValuer on go TStructs + + ### Haxe - [THRIFT-5734]https://issues.apache.org/jira/browse/THRIFT-5734 - generated code may lack required capitalization at class names @@ -54,6 +61,9 @@ - [THRIFT-5754]https://issues.apache.org/jira/browse/THRIFT-5754 - Fix PHP 8.1 deprecates passing null to non-nullable internal function parameters - [THRIFT-5753]https://issues.apache.org/jira/browse/THRIFT-5753 - PHP 8.1 deprecated warning about return type in jsonSerialize functions +### Python + +- [THRIFT-5688]https://issues.apache.org/jira/browse/THRIFT-5688 - Add PyPI publishing github actions ## 0.19.0 diff --git a/Makefile.am b/Makefile.am index b2e5b18cd5a..5b9e9709f2f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -141,6 +141,12 @@ EXTRA_DIST = \ .flake8 \ .gitattributes \ .gitignore \ + .github/dependabot.yml \ + .github/pull_request_template.md \ + .github/stale.yml \ + .github/workflows/build.yml \ + .github/workflows/cmake.yml \ + .github/workflows/pypi.yml \ .travis.yml \ ApacheThrift.nuspec \ appveyor.yml \ diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am index cb8928bc8c3..22fad9e42d9 100644 --- a/lib/go/test/Makefile.am +++ b/lib/go/test/Makefile.am @@ -138,6 +138,8 @@ EXTRA_DIST = \ dontexportrwtest \ tests \ common \ + go.mod \ + go.sum \ BinaryKeyTest.thrift \ ClientMiddlewareExceptionTest.thrift \ ConflictArgNamesTest.thrift \ diff --git a/test/Makefile.am b/test/Makefile.am index d5f14340287..d3d0075266a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -144,6 +144,7 @@ EXTRA_DIST = \ AnnotationTest.thrift \ BrokenConstants.thrift \ ConstantsDemo.thrift \ + v0.16/ConstantsDemo.thrift \ DebugProtoTest.thrift \ v0.16/DebugProtoTest.thrift \ DenseLinkingTest.thrift \ @@ -159,6 +160,7 @@ EXTRA_DIST = \ ManyOptionals.thrift \ ManyTypedefs.thrift \ NameConflictTest.thrift \ + v0.16/NameConflictTest.thrift \ OptionalRequiredTest.thrift \ Recursive.thrift \ ReuseObjects.thrift \ diff --git a/test/go/Makefile.am b/test/go/Makefile.am index ff7ce683e6b..92ddc93c955 100644 --- a/test/go/Makefile.am +++ b/test/go/Makefile.am @@ -63,4 +63,6 @@ genmock: gopath EXTRA_DIST = \ src/bin \ src/common \ + go.mod \ + go.sum \ genmock.sh diff --git a/tutorial/swift/Makefile.am b/tutorial/swift/Makefile.am index f48456054f4..e8b8b2284cb 100644 --- a/tutorial/swift/Makefile.am +++ b/tutorial/swift/Makefile.am @@ -31,3 +31,13 @@ tutorialserver: gen_swift tutorialclient: gen_swift swift run TutorialClient + +EXTRA_DIST = \ + Package.swift \ + swift-dep \ + Sources/TutorialClient/main.swift \ + Sources/TutorialRunner/main.swift \ + Sources/TutorialServer/main.swift \ + Sources/TutorialServer/CalculatorService.swift \ + README.md + From 62c52516d429dc0f9be36643d76a752c72fc4695 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sun, 4 Feb 2024 14:50:37 +0100 Subject: [PATCH 177/250] bump version number --- ApacheThrift.nuspec | 8 ++++---- CMakeLists.txt | 2 +- Thrift.podspec | 4 ++-- appveyor.yml | 2 +- bower.json | 2 +- compiler/cpp/src/thrift/version.h | 2 +- configure.ac | 2 +- contrib/Rebus/Properties/AssemblyInfo.cs | 4 ++-- contrib/thrift-maven-plugin/pom.xml | 2 +- contrib/thrift.spec | 2 +- contrib/zeromq/csharp/AssemblyInfo.cs | 2 +- doc/specs/idl.md | 2 +- lib/d/src/thrift/base.d | 2 +- lib/dart/pubspec.yaml | 2 +- lib/delphi/src/Thrift.pas | 2 +- lib/erl/src/thrift.app.src | 2 +- lib/haxe/haxelib.json | 2 +- lib/java/gradle.properties | 2 +- lib/js/package-lock.json | 2 +- lib/js/package.json | 2 +- lib/js/src/thrift.js | 2 +- lib/lua/Thrift.lua | 2 +- .../Thrift.IntegrationTests.csproj | 2 +- .../Thrift.PublicInterfaces.Compile.Tests.csproj | 2 +- lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj | 2 +- lib/netstd/Thrift/Properties/AssemblyInfo.cs | 4 ++-- lib/netstd/Thrift/Thrift.csproj | 6 +++--- lib/ocaml/_oasis | 2 +- lib/perl/lib/Thrift.pm | 2 +- lib/py/setup.py | 2 +- lib/rb/thrift.gemspec | 2 +- lib/rs/Cargo.toml | 2 +- lib/st/package.xml | 2 +- lib/swift/Sources/Thrift.swift | 2 +- lib/swift/Tests/ThriftTests/ThriftTests.swift | 2 +- lib/ts/package-lock.json | 2 +- lib/ts/package.json | 2 +- package-lock.json | 2 +- package.json | 2 +- sonar-project.properties | 6 +++--- test/dart/test_client/pubspec.yaml | 2 +- test/erl/src/thrift_test.app.src | 2 +- test/netstd/Client/Client.csproj | 2 +- test/netstd/Server/Server.csproj | 2 +- tutorial/dart/client/pubspec.yaml | 2 +- tutorial/dart/console_client/pubspec.yaml | 2 +- tutorial/dart/server/pubspec.yaml | 2 +- tutorial/delphi/DelphiClient/DelphiClient.dproj | 4 ++-- tutorial/delphi/DelphiServer/DelphiServer.dproj | 4 ++-- tutorial/netstd/Client/Client.csproj | 2 +- tutorial/netstd/Interfaces/Interfaces.csproj | 2 +- tutorial/netstd/Server/Server.csproj | 2 +- tutorial/ocaml/_oasis | 2 +- 53 files changed, 65 insertions(+), 65 deletions(-) diff --git a/ApacheThrift.nuspec b/ApacheThrift.nuspec index cd9a29c6c90..a4ca51e4256 100644 --- a/ApacheThrift.nuspec +++ b/ApacheThrift.nuspec @@ -19,14 +19,14 @@ the "Thrift" project. 2. nuget setApiKey 3. nuget pack ApacheThrift.nuspec -Symbols -SymbolPackageFormat snupkg - 4. nuget push ApacheThrift.0.20.0.nupkg -Source https://api.nuget.org/v3/index.json + 4. nuget push ApacheThrift.0.21.0.nupkg -Source https://api.nuget.org/v3/index.json --> ApacheThrift - 0.20.0 - Apache Thrift 0.20.0 + 0.21.0 + Apache Thrift 0.21.0 Apache Thrift Developers Apache Software Foundation Apache-2.0 @@ -36,7 +36,7 @@ Contains runtime libraries from lib/netstd for netstandard2.0 framework development. - + Apache Thrift RPC diff --git a/CMakeLists.txt b/CMakeLists.txt index a685e4f3705..78969f275e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ endif() # PACKAGE_VERSION is used by cpack scripts currently # Both thrift_VERSION and PACKAGE_VERSION should be the same for now -set(thrift_VERSION "0.20.0") +set(thrift_VERSION "0.21.0") set(PACKAGE_VERSION ${thrift_VERSION}) project("thrift" VERSION ${PACKAGE_VERSION}) diff --git a/Thrift.podspec b/Thrift.podspec index 8bf70f64f18..4fde1e5988f 100644 --- a/Thrift.podspec +++ b/Thrift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Thrift' - s.version = '0.20.0' + s.version = '0.21.0' s.summary = "Apache Thrift is a lightweight, language-independent software stack with an associated code generation mechanism for RPC." s.description = <<-DESC The Apache Thrift scalable cross-language software framework for networked services development combines a software stack with a code generation engine to build services that work efficiently and seamlessly between many programming languages. @@ -10,6 +10,6 @@ The Apache Thrift scalable cross-language software framework for networked servi s.author = { 'Apache Thrift Developers' => 'dev@thrift.apache.org' } s.ios.deployment_target = '9.0' s.osx.deployment_target = '10.10' - s.source = { :git => 'https://github.com/apache/thrift.git', :tag => 'v0.20.0' } + s.source = { :git => 'https://github.com/apache/thrift.git', :tag => 'v0.21.0' } s.source_files = 'lib/swift/Sources/*.swift' end diff --git a/appveyor.yml b/appveyor.yml index 5847ea926ba..0e81ba44757 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,7 +19,7 @@ # build Apache Thrift on AppVeyor - https://ci.appveyor.com -version: '0.20.0.{build}' +version: '0.21.0.{build}' shallow_clone: true diff --git a/bower.json b/bower.json index 84f3a989012..f80fe97bb02 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.20.0", + "version": "0.21.0", "homepage": "https://github.com/apache/thrift.git", "authors": [ "Apache Thrift " diff --git a/compiler/cpp/src/thrift/version.h b/compiler/cpp/src/thrift/version.h index 65e0f43684b..9692231e549 100644 --- a/compiler/cpp/src/thrift/version.h +++ b/compiler/cpp/src/thrift/version.h @@ -24,6 +24,6 @@ #pragma once #endif // _MSC_VER -#define THRIFT_VERSION "0.20.0" +#define THRIFT_VERSION "0.21.0" #endif // _THRIFT_VERSION_H_ diff --git a/configure.ac b/configure.ac index eed4a84d775..12a1168a8af 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ(2.65) AC_CONFIG_MACRO_DIR([./aclocal]) -AC_INIT([thrift], [0.20.0]) +AC_INIT([thrift], [0.21.0]) AC_CONFIG_AUX_DIR([.]) diff --git a/contrib/Rebus/Properties/AssemblyInfo.cs b/contrib/Rebus/Properties/AssemblyInfo.cs index 33b0aa872c6..f1dc685c2f7 100644 --- a/contrib/Rebus/Properties/AssemblyInfo.cs +++ b/contrib/Rebus/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ [assembly: Guid("0af10984-40d3-453d-b1e5-421529e8c7e2")] -[assembly: AssemblyVersion("0.20.0.0")] -[assembly: AssemblyFileVersion("0.20.0.0")] +[assembly: AssemblyVersion("0.21.0.0")] +[assembly: AssemblyFileVersion("0.21.0.0")] diff --git a/contrib/thrift-maven-plugin/pom.xml b/contrib/thrift-maven-plugin/pom.xml index 46f3cb18327..54ff1e02d6d 100644 --- a/contrib/thrift-maven-plugin/pom.xml +++ b/contrib/thrift-maven-plugin/pom.xml @@ -29,7 +29,7 @@ thrift-maven-plugin maven-plugin thrift-maven-plugin - 0.20.0 + 0.21.0 1.8 diff --git a/contrib/thrift.spec b/contrib/thrift.spec index 90bf4aae567..20dcc574060 100644 --- a/contrib/thrift.spec +++ b/contrib/thrift.spec @@ -28,7 +28,7 @@ Name: thrift License: Apache License v2.0 Group: Development Summary: RPC and serialization framework -Version: 0.20.0 +Version: 0.21.0 Release: 0 URL: http://thrift.apache.org Packager: Thrift Developers diff --git a/contrib/zeromq/csharp/AssemblyInfo.cs b/contrib/zeromq/csharp/AssemblyInfo.cs index 8d7ed390b49..7f91c339042 100644 --- a/contrib/zeromq/csharp/AssemblyInfo.cs +++ b/contrib/zeromq/csharp/AssemblyInfo.cs @@ -36,7 +36,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("0.20.0.0")] +[assembly: AssemblyVersion("0.21.0.0")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. diff --git a/doc/specs/idl.md b/doc/specs/idl.md index 0980f5bbc6d..f5803b54a50 100644 --- a/doc/specs/idl.md +++ b/doc/specs/idl.md @@ -1,6 +1,6 @@ ## Thrift interface description language -For Thrift version 0.20.0. +For Thrift version 0.21.0. The Thrift interface definition language (IDL) allows for the definition of [Thrift Types](/docs/types). A Thrift IDL file is processed by the Thrift code generator to produce code for the various target languages to support the defined structs and services in the IDL file. diff --git a/lib/d/src/thrift/base.d b/lib/d/src/thrift/base.d index e843a5c8549..ddc0dd498bf 100644 --- a/lib/d/src/thrift/base.d +++ b/lib/d/src/thrift/base.d @@ -50,7 +50,7 @@ class TCompoundOperationException : TException { /// The Thrift version string, used for informative purposes. // Note: This is currently hardcoded, but will likely be filled in by the build // system in future versions. -enum VERSION = "0.20.0"; +enum VERSION = "0.21.0"; /** * Functions used for logging inside Thrift. diff --git a/lib/dart/pubspec.yaml b/lib/dart/pubspec.yaml index 7e205483adc..069818f0864 100644 --- a/lib/dart/pubspec.yaml +++ b/lib/dart/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: thrift -version: 0.20.0 +version: 0.21.0 description: > A Dart library for Apache Thrift author: Apache Thrift Developers diff --git a/lib/delphi/src/Thrift.pas b/lib/delphi/src/Thrift.pas index 6696a195a57..9e1b0bbf59b 100644 --- a/lib/delphi/src/Thrift.pas +++ b/lib/delphi/src/Thrift.pas @@ -28,7 +28,7 @@ interface Thrift.Protocol; const - Version = '0.20.0'; + Version = '0.21.0'; type TException = Thrift.Exception.TException; // compatibility alias diff --git a/lib/erl/src/thrift.app.src b/lib/erl/src/thrift.app.src index 0e25b675592..8431213272a 100644 --- a/lib/erl/src/thrift.app.src +++ b/lib/erl/src/thrift.app.src @@ -22,7 +22,7 @@ {description, "Thrift bindings"}, % The version of the applicaton - {vsn, "0.20.0"}, + {vsn, "0.21.0"}, % All modules used by the application. {modules, []}, diff --git a/lib/haxe/haxelib.json b/lib/haxe/haxelib.json index 78779da4534..6f5de0b11b7 100644 --- a/lib/haxe/haxelib.json +++ b/lib/haxe/haxelib.json @@ -10,7 +10,7 @@ "framework" ], "description": "Haxe bindings for the Apache Thrift RPC and serialization framework", - "version": "0.20.0", + "version": "0.21.0", "releasenote": "Licensed under Apache License, Version 2.0. The Apache Thrift compiler needs to be installed separately.", "contributors": ["ApacheThrift"], "dependencies": { diff --git a/lib/java/gradle.properties b/lib/java/gradle.properties index 404318bed34..a3912e3cbe3 100644 --- a/lib/java/gradle.properties +++ b/lib/java/gradle.properties @@ -1,7 +1,7 @@ # This file is shared currently between this Gradle build and the # Ant builds for fd303 and JavaScript. Keep the dotted notation for # the properties to minimize the changes in the dependencies. -thrift.version=0.20.0 +thrift.version=0.21.0 thrift.groupid=org.apache.thrift release=false diff --git a/lib/js/package-lock.json b/lib/js/package-lock.json index 0d9de1242b8..88026612efb 100644 --- a/lib/js/package-lock.json +++ b/lib/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.20.0", + "version": "0.21.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/lib/js/package.json b/lib/js/package.json index 8543b2500c4..d9ab5a63bae 100644 --- a/lib/js/package.json +++ b/lib/js/package.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.20.0", + "version": "0.21.0", "description": "Thrift is a software framework for scalable cross-language services development.", "main": "./src/thrift", "author": { diff --git a/lib/js/src/thrift.js b/lib/js/src/thrift.js index 7dbb560c740..de5ca198aaf 100644 --- a/lib/js/src/thrift.js +++ b/lib/js/src/thrift.js @@ -46,7 +46,7 @@ var Thrift = { * @const {string} Version * @memberof Thrift */ - Version: '0.20.0', + Version: '0.21.0', /** * Thrift IDL type string to Id mapping. diff --git a/lib/lua/Thrift.lua b/lib/lua/Thrift.lua index 1f9a562fac0..212359bc19e 100644 --- a/lib/lua/Thrift.lua +++ b/lib/lua/Thrift.lua @@ -48,7 +48,7 @@ function ttable_size(t) return count end -version = '0.20.0' +version = '0.21.0' TType = { STOP = 0, diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index 3f8345926ae..5602f91292b 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -23,7 +23,7 @@ latestMajor Thrift.IntegrationTests Thrift.IntegrationTests - 0.20.0.0 + 0.21.0.0 Exe false false diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj index 7c5775026b8..5745bd9dae9 100644 --- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj +++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj @@ -19,7 +19,7 @@ --> - 0.20.0 + 0.21.0 Thrift version $(ThriftVersion) net8.0 latestMajor diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index a37be1b1046..7f9dcb7cbb5 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -21,7 +21,7 @@ net8.0 latestMajor - 0.20.0.0 + 0.21.0.0 enable diff --git a/lib/netstd/Thrift/Properties/AssemblyInfo.cs b/lib/netstd/Thrift/Properties/AssemblyInfo.cs index bd84c4ea37a..383b256c4c1 100644 --- a/lib/netstd/Thrift/Properties/AssemblyInfo.cs +++ b/lib/netstd/Thrift/Properties/AssemblyInfo.cs @@ -52,5 +52,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.20.0.0")] -[assembly: AssemblyFileVersion("0.20.0.0")] +[assembly: AssemblyVersion("0.21.0.0")] +[assembly: AssemblyFileVersion("0.21.0.0")] diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index d255f37c4eb..3aa16d25ea1 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -40,8 +40,8 @@ true thrift.snk false - Apache Thrift 0.20.0 - 0.20.0.0 + Apache Thrift 0.21.0 + 0.21.0.0 false http://thrift.apache.org/ Apache Thrift Developers @@ -50,7 +50,7 @@ C# .NET Core bindings for the Apache Thrift RPC system Apache Thrift RPC - https://github.com/apache/thrift/blob/0.20.0/CHANGES.md + https://github.com/apache/thrift/blob/0.21.0/CHANGES.md README.md Copyright 2023 The Apache Software Foundation diff --git a/lib/ocaml/_oasis b/lib/ocaml/_oasis index be1ce1265b9..adf619804bc 100644 --- a/lib/ocaml/_oasis +++ b/lib/ocaml/_oasis @@ -1,5 +1,5 @@ Name: libthrift-ocaml -Version: 0.20.0 +Version: 0.21.0 OASISFormat: 0.3 Synopsis: OCaml bindings for the Apache Thrift RPC system Authors: Apache Thrift Developers diff --git a/lib/perl/lib/Thrift.pm b/lib/perl/lib/Thrift.pm index 4b5f781e09f..45bf33bb792 100644 --- a/lib/perl/lib/Thrift.pm +++ b/lib/perl/lib/Thrift.pm @@ -31,6 +31,6 @@ use warnings; # package Thrift; -use version 0.77; our $VERSION = version->declare("v0.20.0"); +use version 0.77; our $VERSION = version->declare("v0.21.0"); 1; diff --git a/lib/py/setup.py b/lib/py/setup.py index f5371af753c..31e2bae326e 100644 --- a/lib/py/setup.py +++ b/lib/py/setup.py @@ -105,7 +105,7 @@ def run_setup(with_binary): twisted_deps = ['twisted'] setup(name='thrift', - version='0.20.0', + version='0.21.0', description='Python bindings for the Apache Thrift RPC system', long_description=read_file("README.md"), long_description_content_type="text/markdown", diff --git a/lib/rb/thrift.gemspec b/lib/rb/thrift.gemspec index 6b510c78be9..86d21897bc2 100644 --- a/lib/rb/thrift.gemspec +++ b/lib/rb/thrift.gemspec @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__) Gem::Specification.new do |s| s.name = 'thrift' - s.version = '0.20.0' + s.version = '0.21.0' s.authors = ['Apache Thrift Developers'] s.email = ['dev@thrift.apache.org'] s.homepage = 'http://thrift.apache.org' diff --git a/lib/rs/Cargo.toml b/lib/rs/Cargo.toml index a6e8533aa57..dd4a1b641cc 100644 --- a/lib/rs/Cargo.toml +++ b/lib/rs/Cargo.toml @@ -2,7 +2,7 @@ name = "thrift" description = "Rust bindings for the Apache Thrift RPC system" edition = "2021" -version = "0.20.0" +version = "0.21.0" license = "Apache-2.0" authors = ["Apache Thrift Developers "] homepage = "http://thrift.apache.org" diff --git a/lib/st/package.xml b/lib/st/package.xml index 7af883ee624..d606aadb748 100644 --- a/lib/st/package.xml +++ b/lib/st/package.xml @@ -17,7 +17,7 @@ specific language governing permissions and limitations under the License. --> - + libthrift-st thrift.st diff --git a/lib/swift/Sources/Thrift.swift b/lib/swift/Sources/Thrift.swift index 22981a0fcf4..d78cff6c01f 100644 --- a/lib/swift/Sources/Thrift.swift +++ b/lib/swift/Sources/Thrift.swift @@ -1,3 +1,3 @@ class Thrift { - let version = "0.20.0" + let version = "0.21.0" } diff --git a/lib/swift/Tests/ThriftTests/ThriftTests.swift b/lib/swift/Tests/ThriftTests/ThriftTests.swift index 3c6854c6587..10121e744fe 100644 --- a/lib/swift/Tests/ThriftTests/ThriftTests.swift +++ b/lib/swift/Tests/ThriftTests/ThriftTests.swift @@ -3,7 +3,7 @@ import XCTest class ThriftTests: XCTestCase { func testVersion() { - XCTAssertEqual(Thrift().version, "0.20.0") + XCTAssertEqual(Thrift().version, "0.21.0") } static var allTests : [(String, (ThriftTests) -> () throws -> Void)] { diff --git a/lib/ts/package-lock.json b/lib/ts/package-lock.json index f99d8a34713..31e0c52d69f 100644 --- a/lib/ts/package-lock.json +++ b/lib/ts/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.20.0", + "version": "0.21.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/lib/ts/package.json b/lib/ts/package.json index 054807f91c9..f2960657bf6 100644 --- a/lib/ts/package.json +++ b/lib/ts/package.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.20.0", + "version": "0.21.0", "description": "Thrift is a software framework for scalable cross-language services development.", "author": { "name": "Apache Thrift Developers", diff --git a/package-lock.json b/package-lock.json index 3f8780a5ab5..5c3b06dd2f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "thrift", - "version": "0.20.0", + "version": "0.21.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 47f9e874884..2925cc8f2ae 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "git", "url": "https://github.com/apache/thrift.git" }, - "version": "0.20.0", + "version": "0.21.0", "author": { "name": "Apache Thrift Developers", "email": "dev@thrift.apache.org", diff --git a/sonar-project.properties b/sonar-project.properties index 258dfe913af..02b1195c229 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -16,7 +16,7 @@ development, combines a software stack with a code generation engine to build services that work efficiently and seamlessly between all major languages. # Apache Thrift Version -sonar.projectVersion=0.20.0 +sonar.projectVersion=0.21.0 # use this to set another version string # $ sonar-runner -D sonar.projectVersion=`git rev-parse HEAD` # set projectDate in combination with projectVersion for imports of old releases @@ -54,7 +54,7 @@ module1.sonar.projectName=Apache Thrift - Java Library module1.sonar.projectBaseDir=lib/java module1.sonar.sources=src module1.sonar.tests=test -module1.sonar.binaries=build/libs/libthrift-0.20.0.jar +module1.sonar.binaries=build/libs/libthrift-0.21.0.jar module1.sonar.libraries=build/deps/*.jar module1.sonar.language=java @@ -62,7 +62,7 @@ module2.sonar.projectName=Apache Thrift - Java Tutorial module2.sonar.projectBaseDir=. module2.sonar.sources=tutorial/java/src, tutorial/java/gen-java module2.sonar.binaries=tutorial/java/tutorial.jar -module2.sonar.libraries=lib/java/build/deps/*.jar,lib/java/build/libs/libthrift-0.20.0.jar +module2.sonar.libraries=lib/java/build/deps/*.jar,lib/java/build/libs/libthrift-0.21.0.jar module2.sonar.language=java module3.sonar.projectName=Apache Thrift - JavaScript Library diff --git a/test/dart/test_client/pubspec.yaml b/test/dart/test_client/pubspec.yaml index 177e2cdf141..f4d01358a9c 100644 --- a/test/dart/test_client/pubspec.yaml +++ b/test/dart/test_client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: thrift_test_client -version: 0.20.0 +version: 0.21.0 description: A client integration test for the Dart Thrift library author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/test/erl/src/thrift_test.app.src b/test/erl/src/thrift_test.app.src index 9d68a564533..b78fc296c75 100644 --- a/test/erl/src/thrift_test.app.src +++ b/test/erl/src/thrift_test.app.src @@ -22,7 +22,7 @@ {description, "Thrift cross language test"}, % The version of the applicaton - {vsn, "0.20.0"}, + {vsn, "0.21.0"}, % All modules used by the application. {modules, [ diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index aa90e2c5ec7..977303bbc58 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -24,7 +24,7 @@ Client Client Exe - 0.20.0.0 + 0.21.0.0 false false false diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index 63ce613bbda..359578a4e29 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -24,7 +24,7 @@ Server Server Exe - 0.20.0.0 + 0.21.0.0 false false false diff --git a/tutorial/dart/client/pubspec.yaml b/tutorial/dart/client/pubspec.yaml index e8c6db8ab90..b486ec80b28 100644 --- a/tutorial/dart/client/pubspec.yaml +++ b/tutorial/dart/client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_client -version: 0.20.0 +version: 0.21.0 description: A Dart client implementation of the Apache Thrift tutorial author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/tutorial/dart/console_client/pubspec.yaml b/tutorial/dart/console_client/pubspec.yaml index e5c0938b973..bf61ded77ad 100644 --- a/tutorial/dart/console_client/pubspec.yaml +++ b/tutorial/dart/console_client/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_console_client -version: 0.20.0 +version: 0.21.0 description: > A Dart console client to implementation of the Apache Thrift tutorial author: Apache Thrift Developers diff --git a/tutorial/dart/server/pubspec.yaml b/tutorial/dart/server/pubspec.yaml index 5f7edb9bc25..29811eb21be 100644 --- a/tutorial/dart/server/pubspec.yaml +++ b/tutorial/dart/server/pubspec.yaml @@ -16,7 +16,7 @@ # under the License. name: tutorial_server -version: 0.20.0 +version: 0.21.0 description: A Dart server to support the Apache Thrift tutorial author: Apache Thrift Developers homepage: http://thrift.apache.org diff --git a/tutorial/delphi/DelphiClient/DelphiClient.dproj b/tutorial/delphi/DelphiClient/DelphiClient.dproj index 34d9f03dc22..fbb63f7f616 100644 --- a/tutorial/delphi/DelphiClient/DelphiClient.dproj +++ b/tutorial/delphi/DelphiClient/DelphiClient.dproj @@ -124,13 +124,13 @@ popd]]> Thrift Tutorial - 0.20.0.0 + 0.21.0.0 DelphiClient Copyright © 2012 The Apache Software Foundation DelphiClient.exe Thrift - 0.20.0.0 + 0.21.0.0 diff --git a/tutorial/delphi/DelphiServer/DelphiServer.dproj b/tutorial/delphi/DelphiServer/DelphiServer.dproj index fa8cb92d84a..376d90ae1b1 100644 --- a/tutorial/delphi/DelphiServer/DelphiServer.dproj +++ b/tutorial/delphi/DelphiServer/DelphiServer.dproj @@ -121,13 +121,13 @@ popd]]> Thrift Tutorial - 0.20.0.0 + 0.21.0.0 DelphiServer Copyright © 2012 The Apache Software Foundation DelphiServer.exe Thrift - 0.20.0.0 + 0.21.0.0 diff --git a/tutorial/netstd/Client/Client.csproj b/tutorial/netstd/Client/Client.csproj index 994d6be7be6..399b0e0d096 100644 --- a/tutorial/netstd/Client/Client.csproj +++ b/tutorial/netstd/Client/Client.csproj @@ -24,7 +24,7 @@ Client Client Exe - 0.20.0.0 + 0.21.0.0 false false false diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index c3524575adc..576722ba591 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -22,7 +22,7 @@ net6.0 Interfaces Interfaces - 0.20.0.0 + 0.21.0.0 false false false diff --git a/tutorial/netstd/Server/Server.csproj b/tutorial/netstd/Server/Server.csproj index c72ec88ce34..38131a6d32d 100644 --- a/tutorial/netstd/Server/Server.csproj +++ b/tutorial/netstd/Server/Server.csproj @@ -24,7 +24,7 @@ Server Server Exe - 0.20.0.0 + 0.21.0.0 false false false diff --git a/tutorial/ocaml/_oasis b/tutorial/ocaml/_oasis index 6072e4b969f..180f86560e8 100644 --- a/tutorial/ocaml/_oasis +++ b/tutorial/ocaml/_oasis @@ -1,5 +1,5 @@ Name: tutorial -Version: 0.20.0 +Version: 0.21.0 OASISFormat: 0.3 Synopsis: OCaml Tutorial example Authors: Apache Thrift Developers From 5ad083aee672702b863d850eadf257e3d8cd9c82 Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Mon, 19 Feb 2024 11:34:48 +0100 Subject: [PATCH 178/250] THRIFT-5756 Run php tests in github actions --- .github/workflows/build.yml | 56 +++++++++++++++++++ .gitignore | 5 +- build/docker/ubuntu-bionic/Dockerfile | 5 ++ composer.json | 6 +- lib/php/README.apache.md | 3 +- lib/php/phpunit.xml | 24 ++++++++ lib/php/test/{ => Fixtures}/Fixtures.php | 2 +- .../TJSONProtocolFixtures.php | 2 +- .../TSimpleJSONProtocolFixtures.php | 2 +- lib/php/test/Makefile.am | 37 +++++------- .../ThriftTest.thrift} | 2 +- .../{Validator => Unit}/BaseValidatorTest.php | 16 +++++- .../BinarySerializerTest.php | 23 +++----- .../JsonSerializeTest.php | 21 ++++--- .../{Protocol => Unit}/TJSONProtocolTest.php | 30 +++++----- .../TSimpleJSONProtocolTest.php | 27 ++++----- .../{Validator => Unit}/ValidatorTest.php | 22 ++++---- .../{Validator => Unit}/ValidatorTestOop.php | 22 ++++---- 18 files changed, 188 insertions(+), 117 deletions(-) create mode 100644 lib/php/phpunit.xml rename lib/php/test/{ => Fixtures}/Fixtures.php (99%) rename lib/php/test/{Protocol => Fixtures}/TJSONProtocolFixtures.php (99%) rename lib/php/test/{Protocol => Fixtures}/TSimpleJSONProtocolFixtures.php (99%) rename lib/php/test/{TestValidators.thrift => Resources/ThriftTest.thrift} (95%) rename lib/php/test/{Validator => Unit}/BaseValidatorTest.php (90%) rename lib/php/test/{Protocol => Unit}/BinarySerializerTest.php (72%) rename lib/php/test/{JsonSerialize => Unit}/JsonSerializeTest.php (87%) rename lib/php/test/{Protocol => Unit}/TJSONProtocolTest.php (95%) rename lib/php/test/{Protocol => Unit}/TSimpleJSONProtocolTest.php (92%) rename lib/php/test/{Validator => Unit}/ValidatorTest.php (57%) rename lib/php/test/{Validator => Unit}/ValidatorTestOop.php (57%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aeb1614134a..aca1a37f12f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,6 +76,62 @@ jobs: path: compiler/cpp/thrift retention-days: 3 + lib-php: + needs: compiler + runs-on: ubuntu-20.04 + strategy: + matrix: + php-version: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3] + fail-fast: false + steps: + - uses: actions/checkout@v4 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, intl, xml + + - name: Install Dependencies + run: composer install + + - name: Backward compatibility for unit test in php greater then 7.1 + if: matrix.php-version > 7.0 + run: | + sed -i 's/setUp()/setUp():void/' lib/php/test/Unit/*Test.php + sed -i 's/setUpBeforeClass()/setUpBeforeClass():void/' lib/php/test/Unit/*Test.php + + - name: Run bootstrap + run: ./bootstrap.sh + + - name: Run configure + run: | + ./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-php/with-php/' | sed 's/without-php_extension/with-php_extension/' ) + + - uses: actions/download-artifact@v3 + with: + name: thrift-compiler + path: compiler/cpp + + - name: Run thrift-compiler + run: | + chmod a+x compiler/cpp/thrift + compiler/cpp/thrift -version + + - name: Build Thrift Classes + run: | + mkdir -p ./lib/php/test/Resources/packages/php + mkdir -p ./lib/php/test/Resources/packages/phpv + mkdir -p ./lib/php/test/Resources/packages/phpvo + mkdir -p ./lib/php/test/Resources/packages/phpjs + compiler/cpp/thrift --gen php -r --out ./lib/php/test/Resources/packages/php lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:validate -r --out ./lib/php/test/Resources/packages/phpv lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:validate,oop -r --out ./lib/php/test/Resources/packages/phpvo lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:json -r --out ./lib/php/test/Resources/packages/phpjs lib/php/test/Resources/ThriftTest.thrift + + - name: Run Tests + run: vendor/bin/phpunit -c lib/php/phpunit.xml + lib-go: needs: compiler runs-on: ubuntu-20.04 diff --git a/.gitignore b/.gitignore index cb8029c9888..0ed47297d13 100644 --- a/.gitignore +++ b/.gitignore @@ -279,9 +279,8 @@ project.lock.json /lib/php/src/ext/thrift_protocol/run-tests.php /lib/php/src/ext/thrift_protocol/thrift_protocol.la /lib/php/src/ext/thrift_protocol/tmp-php.ini -/lib/php/src/packages/ -/lib/php/test/TEST-*.xml -/lib/php/test/packages/ +/lib/php/tests/Resources/packages/ +/lib/php/test/test-log-junit.xml /lib/py/dist/ /lib/erl/logs/ /lib/go/pkg diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile index 350921ae50a..5ece6e10d1c 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/ubuntu-bionic/Dockerfile @@ -216,9 +216,14 @@ RUN apt-get install -y --no-install-recommends \ php-dev \ php-json \ php-pear \ + php-mbstring \ + php-xml \ re2c \ composer +RUN pecl install xdebug-3.1.1 && \ + echo "zend_extension=xdebug.so" > /etc/php/7.2/cli/conf.d/20-xdebug.ini + RUN apt-get install -y --no-install-recommends \ `# Python dependencies` \ python-all \ diff --git a/composer.json b/composer.json index 454beeaa9fa..d882a97f724 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,10 @@ "php": "^5.5 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "~4.8.36", - "squizlabs/php_codesniffer": "3.*" + "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.5 || ^9.3", + "squizlabs/php_codesniffer": "3.*", + "ext-json": "*", + "ext-xml": "*" }, "autoload": { "psr-4": {"Thrift\\": "lib/php/lib/"} diff --git a/lib/php/README.apache.md b/lib/php/README.apache.md index 5e925897596..2fae257afb5 100644 --- a/lib/php/README.apache.md +++ b/lib/php/README.apache.md @@ -29,7 +29,7 @@ you must use a THttpClient transport. Sample Code =========== - +```php open(); $processor->process($protocol, $protocol); $transport->close(); +``` diff --git a/lib/php/phpunit.xml b/lib/php/phpunit.xml new file mode 100644 index 00000000000..a5d287f282d --- /dev/null +++ b/lib/php/phpunit.xml @@ -0,0 +1,24 @@ + + + + + ./src + ./lib + + + + + ./test/Unit + + + diff --git a/lib/php/test/Fixtures.php b/lib/php/test/Fixtures/Fixtures.php similarity index 99% rename from lib/php/test/Fixtures.php rename to lib/php/test/Fixtures/Fixtures.php index fd57d831c5e..eb348fc7101 100644 --- a/lib/php/test/Fixtures.php +++ b/lib/php/test/Fixtures/Fixtures.php @@ -21,7 +21,7 @@ * @package thrift.test */ -namespace Test\Thrift; +namespace Test\Thrift\Fixtures; use ThriftTest\Xtruct; use ThriftTest\Xtruct2; diff --git a/lib/php/test/Protocol/TJSONProtocolFixtures.php b/lib/php/test/Fixtures/TJSONProtocolFixtures.php similarity index 99% rename from lib/php/test/Protocol/TJSONProtocolFixtures.php rename to lib/php/test/Fixtures/TJSONProtocolFixtures.php index dd9039fcac0..81ada779638 100644 --- a/lib/php/test/Protocol/TJSONProtocolFixtures.php +++ b/lib/php/test/Fixtures/TJSONProtocolFixtures.php @@ -21,7 +21,7 @@ * @package thrift.test */ -namespace Test\Thrift\Protocol; +namespace Test\Thrift\Fixtures; class TJSONProtocolFixtures { diff --git a/lib/php/test/Protocol/TSimpleJSONProtocolFixtures.php b/lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php similarity index 99% rename from lib/php/test/Protocol/TSimpleJSONProtocolFixtures.php rename to lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php index 547fd86623d..448eb61261b 100644 --- a/lib/php/test/Protocol/TSimpleJSONProtocolFixtures.php +++ b/lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php @@ -21,7 +21,7 @@ * @package thrift.test */ -namespace test\Thrift\Protocol; +namespace Test\Thrift\Fixtures; class TSimpleJSONProtocolFixtures { diff --git a/lib/php/test/Makefile.am b/lib/php/test/Makefile.am index 30765c34460..c2de405277a 100644 --- a/lib/php/test/Makefile.am +++ b/lib/php/test/Makefile.am @@ -19,37 +19,26 @@ PHPUNIT=php $(top_srcdir)/vendor/bin/phpunit -stubs: ../../../test/v0.16/ThriftTest.thrift TestValidators.thrift - mkdir -p ./packages/php - $(THRIFT) --gen php -r --out ./packages/php ../../../test/v0.16/ThriftTest.thrift - mkdir -p ./packages/phpv - mkdir -p ./packages/phpvo - mkdir -p ./packages/phpjs - $(THRIFT) --gen php:validate -r --out ./packages/phpv TestValidators.thrift - $(THRIFT) --gen php:validate,oop -r --out ./packages/phpvo TestValidators.thrift - $(THRIFT) --gen php:json -r --out ./packages/phpjs TestValidators.thrift +stubs: Resources/ThriftTest.thrift + mkdir -p ./Resources/packages/php + mkdir -p ./Resources/packages/phpv + mkdir -p ./Resources/packages/phpvo + mkdir -p ./Resources/packages/phpjs + $(THRIFT) --gen php -r --out ./Resources/packages/php Resources/ThriftTest.thrift + $(THRIFT) --gen php:validate -r --out ./Resources/packages/phpv Resources/ThriftTest.thrift + $(THRIFT) --gen php:validate,oop -r --out ./Resources/packages/phpvo Resources/ThriftTest.thrift + $(THRIFT) --gen php:json -r --out ./Resources/packages/phpjs Resources/ThriftTest.thrift deps: $(top_srcdir)/composer.json composer install --working-dir=$(top_srcdir) all-local: deps -check-json-serializer: deps stubs - $(PHPUNIT) --log-junit=TEST-log-json-serializer.xml JsonSerialize/ - -check-validator: deps stubs - $(PHPUNIT) --log-junit=TEST-log-validator.xml Validator/ - -check-protocol: deps stubs - $(PHPUNIT) --log-junit=TEST-log-protocol.xml Protocol/ - -check: deps stubs \ - check-protocol \ - check-validator \ - check-json-serializer +check: deps stubs + $(PHPUNIT) --log-junit=test-log-junit.xml -c phpunit.xml / distclean-local: clean-local: - $(RM) -r ./packages - $(RM) TEST-*.xml + $(RM) -r ./Resources/packages + $(RM) test-log-junit.xml diff --git a/lib/php/test/TestValidators.thrift b/lib/php/test/Resources/ThriftTest.thrift similarity index 95% rename from lib/php/test/TestValidators.thrift rename to lib/php/test/Resources/ThriftTest.thrift index a9804704ccc..07ca6e49203 100644 --- a/lib/php/test/TestValidators.thrift +++ b/lib/php/test/Resources/ThriftTest.thrift @@ -19,7 +19,7 @@ namespace php TestValidators -include "../../../test/v0.16/ThriftTest.thrift" +include "../../../../test/v0.16/ThriftTest.thrift" union UnionOfStrings { 1: string aa; diff --git a/lib/php/test/Validator/BaseValidatorTest.php b/lib/php/test/Unit/BaseValidatorTest.php similarity index 90% rename from lib/php/test/Validator/BaseValidatorTest.php rename to lib/php/test/Unit/BaseValidatorTest.php index 60290830e06..4404e72ce98 100644 --- a/lib/php/test/Validator/BaseValidatorTest.php +++ b/lib/php/test/Unit/BaseValidatorTest.php @@ -1,4 +1,5 @@ read($protocol); + $this->assertTrue(true); } public function testWriteEmpty() @@ -73,6 +75,8 @@ public function testWriteEmpty() $bonk->write($protocol); $this->fail('Bonk was able to write an empty object'); } catch (TProtocolException $e) { + $this->expectExceptionMessage('Required field Bonk.message is unset!'); + throw $e; } } @@ -87,6 +91,8 @@ public function testWriteWithMissingRequired() $structa->write($protocol); $this->fail('StructA was able to write an empty object'); } catch (TProtocolException $e) { + $this->expectExceptionMessage('Required field StructA.s is unset!'); + throw $e; } } @@ -114,6 +120,8 @@ protected static function assertHasReadValidator($class) { if (!static::hasReadValidator($class)) { static::fail($class . ' class should have a read validator'); + } else { + static::assertTrue(true); } } @@ -121,6 +129,8 @@ protected static function assertNoReadValidator($class) { if (static::hasReadValidator($class)) { static::fail($class . ' class should not have a write validator'); + } else { + static::assertTrue(true); } } @@ -128,6 +138,8 @@ protected static function assertHasWriteValidator($class) { if (!static::hasWriteValidator($class)) { static::fail($class . ' class should have a write validator'); + } else { + static::assertTrue(true); } } @@ -135,6 +147,8 @@ protected static function assertNoWriteValidator($class) { if (static::hasWriteValidator($class)) { static::fail($class . ' class should not have a write validator'); + } else { + static::assertTrue(true); } } diff --git a/lib/php/test/Protocol/BinarySerializerTest.php b/lib/php/test/Unit/BinarySerializerTest.php similarity index 72% rename from lib/php/test/Protocol/BinarySerializerTest.php rename to lib/php/test/Unit/BinarySerializerTest.php index 71b0bb5066a..b97da74ddcb 100644 --- a/lib/php/test/Protocol/BinarySerializerTest.php +++ b/lib/php/test/Unit/BinarySerializerTest.php @@ -17,33 +17,26 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.test */ -namespace Test\Thrift\Protocol; +namespace Test\Thrift\Unit; use PHPUnit\Framework\TestCase; +use Thrift\ClassLoader\ThriftClassLoader; use Thrift\Serializer\TBinarySerializer; -require __DIR__ . '/../../../../vendor/autoload.php'; - /*** - * This test suite depends on running the compiler against the - * standard ThriftTest.thrift file: - * - * lib/php/test$ ../../../compiler/cpp/thrift --gen php -r \ - * --out ./packages ../../../test/ThriftTest.thrift - * - * @runTestsInSeparateProcesses + * This test suite depends on running the compiler against the ./Resources/ThriftTest.thrift file: + * lib/php/test$ ../../../compiler/cpp/thrift --gen php -r --out ./Resources/packages/php ./Resources/ThriftTest.thrift */ class BinarySerializerTest extends TestCase { public function setUp() { - /** @var \Composer\Autoload\ClassLoader $loader */ - $loader = require __DIR__ . '/../../../../vendor/autoload.php'; - $loader->addPsr4('', __DIR__ . '/../packages/php'); + $loader = new ThriftClassLoader(); + $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/php'); + $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/php'); + $loader->register(); } /** diff --git a/lib/php/test/JsonSerialize/JsonSerializeTest.php b/lib/php/test/Unit/JsonSerializeTest.php similarity index 87% rename from lib/php/test/JsonSerialize/JsonSerializeTest.php rename to lib/php/test/Unit/JsonSerializeTest.php index c6686525fac..9fdc3f3cf48 100644 --- a/lib/php/test/JsonSerialize/JsonSerializeTest.php +++ b/lib/php/test/Unit/JsonSerializeTest.php @@ -1,4 +1,5 @@ markTestSkipped('Requires PHP 5.4 or newer!'); - } - /** @var \Composer\Autoload\ClassLoader $loader */ - $loader = require __DIR__ . '/../../../../vendor/autoload.php'; - $loader->addPsr4('', __DIR__ . '/../packages/phpjs'); + $loader = new ThriftClassLoader(); + $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/phpjs'); + $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/phpjs'); + $loader->register(); } public function testEmptyStruct() diff --git a/lib/php/test/Protocol/TJSONProtocolTest.php b/lib/php/test/Unit/TJSONProtocolTest.php similarity index 95% rename from lib/php/test/Protocol/TJSONProtocolTest.php rename to lib/php/test/Unit/TJSONProtocolTest.php index bf0ecce4293..178d63bb172 100644 --- a/lib/php/test/Protocol/TJSONProtocolTest.php +++ b/lib/php/test/Unit/TJSONProtocolTest.php @@ -17,27 +17,20 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.test */ -namespace Test\Thrift\Protocol; +namespace Test\Thrift\Unit; use PHPUnit\Framework\TestCase; -use Test\Thrift\Fixtures; +use Test\Thrift\Fixtures\Fixtures; +use Test\Thrift\Fixtures\TJSONProtocolFixtures; +use Thrift\ClassLoader\ThriftClassLoader; use Thrift\Protocol\TJSONProtocol; use Thrift\Transport\TMemoryBuffer; -require __DIR__ . '/../../../../vendor/autoload.php'; - /*** - * This test suite depends on running the compiler against the - * standard ThriftTest.thrift file: - * - * lib/php/test$ ../../../compiler/cpp/thrift --gen php -r \ - * --out ./packages ../../../test/ThriftTest.thrift - * - * @runTestsInSeparateProcesses + * This test suite depends on running the compiler against the ./Resources/ThriftTest.thrift file: + * lib/php/test$ ../../../compiler/cpp/thrift --gen php -r --out ./Resources/packages/php ./Resources/ThriftTest.thrift */ class TJSONProtocolTest extends TestCase { @@ -46,9 +39,10 @@ class TJSONProtocolTest extends TestCase public static function setUpBeforeClass() { - /** @var \Composer\Autoload\ClassLoader $loader */ - $loader = require __DIR__ . '/../../../../vendor/autoload.php'; - $loader->addPsr4('', __DIR__ . '/../packages/php'); + $loader = new ThriftClassLoader(); + $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/php'); + $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/php'); + $loader->register(); Fixtures::populateTestArgs(); TJSONProtocolFixtures::populateTestArgsJSON(); @@ -265,7 +259,9 @@ public function testVoidRead() TJSONProtocolFixtures::$testArgsJSON['testVoid'] ); $args = new \ThriftTest\ThriftTest_testVoid_args(); - $args->read($this->protocol); + $result = $args->read($this->protocol); + + $this->assertEquals(0, $result); } public function testString1Read() diff --git a/lib/php/test/Protocol/TSimpleJSONProtocolTest.php b/lib/php/test/Unit/TSimpleJSONProtocolTest.php similarity index 92% rename from lib/php/test/Protocol/TSimpleJSONProtocolTest.php rename to lib/php/test/Unit/TSimpleJSONProtocolTest.php index e4a13736ed7..3189d9931e4 100644 --- a/lib/php/test/Protocol/TSimpleJSONProtocolTest.php +++ b/lib/php/test/Unit/TSimpleJSONProtocolTest.php @@ -17,27 +17,20 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.test */ -namespace Test\Thrift\Protocol; +namespace Test\Thrift\Unit; use PHPUnit\Framework\TestCase; -use Test\Thrift\Fixtures; +use Test\Thrift\Fixtures\Fixtures; +use Test\Thrift\Fixtures\TSimpleJSONProtocolFixtures; +use Thrift\ClassLoader\ThriftClassLoader; use Thrift\Protocol\TSimpleJSONProtocol; use Thrift\Transport\TMemoryBuffer; -require __DIR__ . '/../../../../vendor/autoload.php'; - /*** - * This test suite depends on running the compiler against the - * standard ThriftTest.thrift file: - * - * lib/php/test$ ../../../compiler/cpp/thrift --gen php -r \ - * --out ./packages ../../../test/ThriftTest.thrift - * - * @runTestsInSeparateProcesses + * This test suite depends on running the compiler against the ./Resources/ThriftTest.thrift file: + * lib/php/test$ ../../../compiler/cpp/thrift --gen php -r --out ./Resources/packages/php ./Resources/ThriftTest.thrift */ class TSimpleJSONProtocolTest extends TestCase { @@ -46,10 +39,10 @@ class TSimpleJSONProtocolTest extends TestCase public static function setUpBeforeClass() { - - /** @var \Composer\Autoload\ClassLoader $loader */ - $loader = require __DIR__ . '/../../../../vendor/autoload.php'; - $loader->addPsr4('', __DIR__ . '/../packages/php'); + $loader = new ThriftClassLoader(); + $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/php'); + $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/php'); + $loader->register(); Fixtures::populateTestArgs(); TSimpleJSONProtocolFixtures::populateTestArgsSimpleJSON(); diff --git a/lib/php/test/Validator/ValidatorTest.php b/lib/php/test/Unit/ValidatorTest.php similarity index 57% rename from lib/php/test/Validator/ValidatorTest.php rename to lib/php/test/Unit/ValidatorTest.php index fa6c7a9f7e0..06f6e5502f9 100644 --- a/lib/php/test/Validator/ValidatorTest.php +++ b/lib/php/test/Unit/ValidatorTest.php @@ -1,4 +1,5 @@ addPsr4('', __DIR__ . '/../packages/phpv'); + $loader = new ThriftClassLoader(); + $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/phpv'); + $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/phpv'); + $loader->registerNamespace('TestValidators', __DIR__ . '/../Resources/packages/phpv'); + $loader->registerDefinition('TestValidators', __DIR__ . '/../Resources/packages/phpv'); + $loader->register(); } } diff --git a/lib/php/test/Validator/ValidatorTestOop.php b/lib/php/test/Unit/ValidatorTestOop.php similarity index 57% rename from lib/php/test/Validator/ValidatorTestOop.php rename to lib/php/test/Unit/ValidatorTestOop.php index 93bca4d0cbc..79da11e0390 100644 --- a/lib/php/test/Validator/ValidatorTestOop.php +++ b/lib/php/test/Unit/ValidatorTestOop.php @@ -1,4 +1,5 @@ addPsr4('', __DIR__ . '/../packages/phpvo'); + $loader = new ThriftClassLoader(); + $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/phpvo'); + $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/phpvo'); + $loader->registerNamespace('TestValidators', __DIR__ . '/../Resources/packages/phpvo'); + $loader->registerDefinition('TestValidators', __DIR__ . '/../Resources/packages/phpvo'); + $loader->register(); } } From c123c58c1015222ceaeeadf05ae02d9a93d5e321 Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Wed, 21 Feb 2024 09:07:46 +0100 Subject: [PATCH 179/250] add ASF Header --- lib/php/phpunit.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/php/phpunit.xml b/lib/php/phpunit.xml index a5d287f282d..53b3f351a9f 100644 --- a/lib/php/phpunit.xml +++ b/lib/php/phpunit.xml @@ -1,4 +1,22 @@ + Date: Sat, 24 Feb 2024 17:12:10 +0100 Subject: [PATCH 180/250] [THRIFT-5760] Update minimal version of php --- .github/workflows/build.yml | 8 +------- composer.json | 4 ++-- doc/install/README.md | 2 +- lib/php/README.md | 2 +- lib/php/test/Unit/BinarySerializerTest.php | 2 +- lib/php/test/Unit/JsonSerializeTest.php | 2 +- lib/php/test/Unit/TJSONProtocolTest.php | 4 ++-- lib/php/test/Unit/TSimpleJSONProtocolTest.php | 4 ++-- lib/php/test/Unit/ValidatorTest.php | 2 +- lib/php/test/Unit/ValidatorTestOop.php | 2 +- 10 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aca1a37f12f..4ed83389ae2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -81,7 +81,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - php-version: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3] + php-version: [7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3] fail-fast: false steps: - uses: actions/checkout@v4 @@ -95,12 +95,6 @@ jobs: - name: Install Dependencies run: composer install - - name: Backward compatibility for unit test in php greater then 7.1 - if: matrix.php-version > 7.0 - run: | - sed -i 's/setUp()/setUp():void/' lib/php/test/Unit/*Test.php - sed -i 's/setUpBeforeClass()/setUpBeforeClass():void/' lib/php/test/Unit/*Test.php - - name: Run bootstrap run: ./bootstrap.sh diff --git a/composer.json b/composer.json index d882a97f724..77248a9329e 100644 --- a/composer.json +++ b/composer.json @@ -18,10 +18,10 @@ "issues": "https://issues.apache.org/jira/browse/THRIFT" }, "require": { - "php": "^5.5 || ^7.0 || ^8.0" + "php": "^7.1 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.5 || ^9.3", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", "squizlabs/php_codesniffer": "3.*", "ext-json": "*", "ext-xml": "*" diff --git a/doc/install/README.md b/doc/install/README.md index d073e918dcf..0ebe77c7110 100644 --- a/doc/install/README.md +++ b/doc/install/README.md @@ -32,7 +32,7 @@ These are only required if you choose to build the libraries for the given langu * Gradle 8.4 * C#: Mono 1.2.4 (and pkg-config to detect it) or Visual Studio 2005+ * Python 2.6 (including header files for extension modules) -* PHP 5.0 (optionally including header files for extension modules) +* PHP 7.1 (optionally including header files for extension modules) * Ruby 1.8 * bundler gem * Erlang R12 (R11 works but not recommended) diff --git a/lib/php/README.md b/lib/php/README.md index e7144fe444e..4bbc9675559 100644 --- a/lib/php/README.md +++ b/lib/php/README.md @@ -21,7 +21,7 @@ under the License. # Using Thrift with PHP -Thrift requires PHP 5. Thrift makes as few assumptions about your PHP +Thrift requires PHP 7.1 Thrift makes as few assumptions about your PHP environment as possible while trying to make some more advanced PHP features (i.e. APCu cacheing using asbolute path URLs) as simple as possible. diff --git a/lib/php/test/Unit/BinarySerializerTest.php b/lib/php/test/Unit/BinarySerializerTest.php index b97da74ddcb..744ca7ad130 100644 --- a/lib/php/test/Unit/BinarySerializerTest.php +++ b/lib/php/test/Unit/BinarySerializerTest.php @@ -31,7 +31,7 @@ */ class BinarySerializerTest extends TestCase { - public function setUp() + public function setUp(): void { $loader = new ThriftClassLoader(); $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/php'); diff --git a/lib/php/test/Unit/JsonSerializeTest.php b/lib/php/test/Unit/JsonSerializeTest.php index 9fdc3f3cf48..66e4d5e376f 100644 --- a/lib/php/test/Unit/JsonSerializeTest.php +++ b/lib/php/test/Unit/JsonSerializeTest.php @@ -31,7 +31,7 @@ */ class JsonSerializeTest extends TestCase { - protected function setUp() + protected function setUp(): void { $loader = new ThriftClassLoader(); $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/phpjs'); diff --git a/lib/php/test/Unit/TJSONProtocolTest.php b/lib/php/test/Unit/TJSONProtocolTest.php index 178d63bb172..9837803708b 100644 --- a/lib/php/test/Unit/TJSONProtocolTest.php +++ b/lib/php/test/Unit/TJSONProtocolTest.php @@ -37,7 +37,7 @@ class TJSONProtocolTest extends TestCase private $transport; private $protocol; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { $loader = new ThriftClassLoader(); $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/php'); @@ -48,7 +48,7 @@ public static function setUpBeforeClass() TJSONProtocolFixtures::populateTestArgsJSON(); } - public function setUp() + public function setUp(): void { $this->transport = new TMemoryBuffer(); $this->protocol = new TJSONProtocol($this->transport); diff --git a/lib/php/test/Unit/TSimpleJSONProtocolTest.php b/lib/php/test/Unit/TSimpleJSONProtocolTest.php index 3189d9931e4..8e6a6d91743 100644 --- a/lib/php/test/Unit/TSimpleJSONProtocolTest.php +++ b/lib/php/test/Unit/TSimpleJSONProtocolTest.php @@ -37,7 +37,7 @@ class TSimpleJSONProtocolTest extends TestCase private $transport; private $protocol; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { $loader = new ThriftClassLoader(); $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/php'); @@ -48,7 +48,7 @@ public static function setUpBeforeClass() TSimpleJSONProtocolFixtures::populateTestArgsSimpleJSON(); } - public function setUp() + public function setUp(): void { $this->transport = new TMemoryBuffer(); $this->protocol = new TSimpleJSONProtocol($this->transport); diff --git a/lib/php/test/Unit/ValidatorTest.php b/lib/php/test/Unit/ValidatorTest.php index 06f6e5502f9..b125424c15e 100644 --- a/lib/php/test/Unit/ValidatorTest.php +++ b/lib/php/test/Unit/ValidatorTest.php @@ -29,7 +29,7 @@ */ class ValidatorTest extends BaseValidatorTest { - public function setUp() + public function setUp(): void { $loader = new ThriftClassLoader(); $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/phpv'); diff --git a/lib/php/test/Unit/ValidatorTestOop.php b/lib/php/test/Unit/ValidatorTestOop.php index 79da11e0390..95581825e0c 100644 --- a/lib/php/test/Unit/ValidatorTestOop.php +++ b/lib/php/test/Unit/ValidatorTestOop.php @@ -29,7 +29,7 @@ */ class ValidatorTestOop extends BaseValidatorTest { - public function setUp() + public function setUp(): void { $loader = new ThriftClassLoader(); $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/phpvo'); From 25350857ba4ac8bc57464579efcf603752203ff0 Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Thu, 22 Feb 2024 22:09:00 +0100 Subject: [PATCH 181/250] [THRIFT-5758] PHP 8.2 Deprecate dynamic properties --- .github/workflows/build.yml | 1 + lib/php/lib/Base/TBase.php | 1 + lib/php/lib/Exception/TException.php | 1 + lib/php/src/Thrift.php | 2 + .../Unit/Lib/Exception/TExceptionTest.php | 60 +++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 lib/php/test/Unit/Lib/Exception/TExceptionTest.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ed83389ae2..b9afd502da1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -91,6 +91,7 @@ jobs: with: php-version: ${{ matrix.php-version }} extensions: mbstring, intl, xml + ini-values: "error_reporting=E_ALL" - name: Install Dependencies run: composer install diff --git a/lib/php/lib/Base/TBase.php b/lib/php/lib/Base/TBase.php index c61b631af60..d946665ecdc 100644 --- a/lib/php/lib/Base/TBase.php +++ b/lib/php/lib/Base/TBase.php @@ -31,6 +31,7 @@ * of PHP. Note that code is intentionally duplicated in here to avoid making * function calls for every field or member of a container.. */ +#[\AllowDynamicProperties] abstract class TBase { public static $tmethod = array( diff --git a/lib/php/lib/Exception/TException.php b/lib/php/lib/Exception/TException.php index 228d761e960..168688c665c 100644 --- a/lib/php/lib/Exception/TException.php +++ b/lib/php/lib/Exception/TException.php @@ -38,6 +38,7 @@ * @param mixed $p1 Message (string) or type-spec (array) * @param mixed $p2 Code (integer) or values (array) */ +#[\AllowDynamicProperties] class TException extends \Exception { public function __construct($p1 = null, $p2 = 0) diff --git a/lib/php/src/Thrift.php b/lib/php/src/Thrift.php index 0364c90812f..1dbf64b0049 100644 --- a/lib/php/src/Thrift.php +++ b/lib/php/src/Thrift.php @@ -68,6 +68,7 @@ class TMessageType * @param mixed $p1 Message (string) or type-spec (array) * @param mixed $p2 Code (integer) or values (array) */ +#[\AllowDynamicProperties] class TException extends Exception { public function __construct($p1=null, $p2=0) @@ -419,6 +420,7 @@ protected function _write($class, $spec, $output) * of PHP. Note that code is intentionally duplicated in here to avoid making * function calls for every field or member of a container.. */ +#[\AllowDynamicProperties] abstract class TBase { static $tmethod = array(TType::BOOL => 'Bool', diff --git a/lib/php/test/Unit/Lib/Exception/TExceptionTest.php b/lib/php/test/Unit/Lib/Exception/TExceptionTest.php new file mode 100644 index 00000000000..add8803b0ea --- /dev/null +++ b/lib/php/test/Unit/Lib/Exception/TExceptionTest.php @@ -0,0 +1,60 @@ +assertInstanceOf(TException::class, $exception); + $this->assertSame($message, $exception->getMessage()); + $this->assertSame($code, $exception->getCode()); + } + + public function testExceptionWithSpecAndVals() + { + $spec = [ + ['var' => 'string'], + ['var' => 'int'], + ['var' => 'bool'], + ]; + + $vals = [ + 'string' => 'Test value', + 'int' => 123456, + 'bool' => true, + ]; + $exception = new TException($spec, $vals); + + $this->assertEquals('Test value', $exception->string); + $this->assertEquals(123456, $exception->int); + $this->assertEquals(true, $exception->bool); + } +} From 72a668381357e54edfc8e3b47d7163bebd997985 Mon Sep 17 00:00:00 2001 From: bwangelme Date: Mon, 6 Nov 2023 12:21:38 +0800 Subject: [PATCH 182/250] Fix: fix readMessageBegin name type error Client: ["python"] --- lib/py/src/protocol/TBinaryProtocol.py | 3 ++- lib/py/test/thrift_TBinaryProtocol.py | 28 +++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/py/src/protocol/TBinaryProtocol.py b/lib/py/src/protocol/TBinaryProtocol.py index 6b2facc4f72..e59e0dcbdb6 100644 --- a/lib/py/src/protocol/TBinaryProtocol.py +++ b/lib/py/src/protocol/TBinaryProtocol.py @@ -18,6 +18,7 @@ # from .TProtocol import TType, TProtocolBase, TProtocolException, TProtocolFactory +from ..compat import binary_to_str from struct import pack, unpack @@ -145,7 +146,7 @@ def readMessageBegin(self): if self.strictRead: raise TProtocolException(type=TProtocolException.BAD_VERSION, message='No protocol version header') - name = self.trans.readAll(sz) + name = binary_to_str(self.trans.readAll(sz)) type = self.readByte() seqid = self.readI32() return (name, type, seqid) diff --git a/lib/py/test/thrift_TBinaryProtocol.py b/lib/py/test/thrift_TBinaryProtocol.py index f7d05ff975d..b257626b1f8 100644 --- a/lib/py/test/thrift_TBinaryProtocol.py +++ b/lib/py/test/thrift_TBinaryProtocol.py @@ -152,15 +152,19 @@ def testField(type, data): protocol.readStructEnd() -def testMessage(data): +def testMessage(data, strict=True): message = {} message['name'] = data[0] message['type'] = data[1] message['seqid'] = data[2] + strictRead, strictWrite = True, True + if not strict: + strictRead, strictWrite = False, False + buf = TTransport.TMemoryBuffer() transport = TTransport.TBufferedTransportFactory().getTransport(buf) - protocol = TBinaryProtocol(transport) + protocol = TBinaryProtocol(transport, strictRead=strictRead, strictWrite=strictWrite) protocol.writeMessageBegin(message['name'], message['type'], message['seqid']) protocol.writeMessageEnd() @@ -169,7 +173,7 @@ def testMessage(data): buf = TTransport.TMemoryBuffer(data_r) transport = TTransport.TBufferedTransportFactory().getTransport(buf) - protocol = TBinaryProtocol(transport) + protocol = TBinaryProtocol(transport, strictRead=strictRead, strictWrite=strictWrite) result = protocol.readMessageBegin() protocol.readMessageEnd() return result @@ -259,6 +263,24 @@ def test_TBinaryProtocol_write_read(self): print("Assertion fail") raise e + def test_TBinaryProtocol_no_strict_write_read(self): + TMessageType = {"T_CALL": 1, "T_REPLY": 2, "T_EXCEPTION": 3, "T_ONEWAY": 4} + test_data = [("short message name", TMessageType['T_CALL'], 0), + ("1", TMessageType['T_REPLY'], 12345), + ("loooooooooooooooooooooooooooooooooong", TMessageType['T_EXCEPTION'], 1 << 16), + ("one way push", TMessageType['T_ONEWAY'], 12), + ("Janky", TMessageType['T_CALL'], 0)] + + try: + for dt in test_data: + result = testMessage(dt, strict=False) + self.assertEqual(result[0], dt[0]) + self.assertEqual(result[1], dt[1]) + self.assertEqual(result[2], dt[2]) + except Exception as e: + print("Assertion fail") + raise e + if __name__ == '__main__': unittest.main() From 7a5b4e20728b8bef34df72fe290f5b98ee43e332 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 25 Feb 2024 23:37:35 +0900 Subject: [PATCH 183/250] THRIFT-5761 Lib/json tests fail Fix the test to expect `typeId` and `class` inside the `type` object instead of on the root level. This is the way the compiler generates is. Old output: ```json "constants": [ { "name": "myNumberz", "typeId": "enum", "type": { "typeId": "enum", "class": "Numberz" }, "value": 1 } ], ``` New output: ``` "constants": [ { "name": "myNumberz", "typeId": "enum", "class": "Numberz", "value": 1 } ], ``` --- lib/json/schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/json/schema.json b/lib/json/schema.json index f7b10dff437..e2b997745c9 100644 --- a/lib/json/schema.json +++ b/lib/json/schema.json @@ -64,7 +64,7 @@ "required": [ "typeId", "keyTypeId", "valueTypeId" ] }, "struct-type": { - "title": "Struct, union and exception schema", + "title": "Struct, union, enum and exception schema", "type": "object", "properties": { "typeId": { @@ -145,9 +145,9 @@ "type": "object", "allOf": [ { "$ref": "#/definitions/name-and-doc" }, - { "$ref": "#/definitions/type-desc" }, { "properties": { + "type": { "$ref": "#/definitions/type-desc" }, "value": { "oneOf": [ { "type": "string" }, From 09892f7edf47fdb76c089d8b36ae4be94f298003 Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Thu, 22 Feb 2024 18:17:40 +0100 Subject: [PATCH 184/250] [THRIFT-5757] Unit tests for php lib --- .github/workflows/build.yml | 10 +- lib/php/lib/ClassLoader/ThriftClassLoader.php | 14 +- .../lib/Factory/TBinaryProtocolFactory.php | 16 ++ .../lib/Factory/TCompactProtocolFactory.php | 10 +- lib/php/lib/Factory/TJSONProtocolFactory.php | 10 +- lib/php/lib/Factory/TProtocolFactory.php | 4 +- lib/php/lib/Factory/TStringFuncFactory.php | 1 + lib/php/lib/StringFunc/Core.php | 11 + lib/php/lib/StringFunc/Mbstring.php | 11 + lib/php/lib/StringFunc/TStringFunc.php | 12 + lib/php/test/Makefile.am | 10 +- .../Lib/ClassLoader/Fixtures/A/TestClass.php | 35 +++ .../Lib/ClassLoader/Fixtures/B/TestClass.php | 35 +++ .../Lib/ClassLoader/Fixtures/C/TestClass.php | 35 +++ .../Lib/ClassLoader/Fixtures/D/TestClass.php | 35 +++ .../Lib/ClassLoader/Fixtures/E/TestClass.php | 35 +++ .../Lib/ClassLoader/ThriftClassLoaderTest.php | 223 ++++++++++++++++++ .../Factory/TBinaryProtocolFactoryTest.php | 81 +++++++ .../Factory/TCompactProtocolFactoryTest.php | 50 ++++ .../Factory/TFramedTransportFactoryTest.php | 56 +++++ .../Lib/Factory/TJSONProtocolFactoryTest.php | 50 ++++ .../Lib/Factory/TStringFuncFactoryTest.php | 74 ++++++ .../Lib/Factory/TTransportFactoryTest.php | 43 ++++ lib/php/test/Unit/Lib/StringFunc/CoreTest.php | 215 +++++++++++++++++ .../test/Unit/Lib/StringFunc/MbStringTest.php | 215 +++++++++++++++++ 25 files changed, 1269 insertions(+), 22 deletions(-) create mode 100644 lib/php/test/Unit/Lib/ClassLoader/Fixtures/A/TestClass.php create mode 100644 lib/php/test/Unit/Lib/ClassLoader/Fixtures/B/TestClass.php create mode 100644 lib/php/test/Unit/Lib/ClassLoader/Fixtures/C/TestClass.php create mode 100644 lib/php/test/Unit/Lib/ClassLoader/Fixtures/D/TestClass.php create mode 100644 lib/php/test/Unit/Lib/ClassLoader/Fixtures/E/TestClass.php create mode 100644 lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php create mode 100644 lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php create mode 100644 lib/php/test/Unit/Lib/Factory/TCompactProtocolFactoryTest.php create mode 100644 lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php create mode 100644 lib/php/test/Unit/Lib/Factory/TJSONProtocolFactoryTest.php create mode 100644 lib/php/test/Unit/Lib/Factory/TStringFuncFactoryTest.php create mode 100644 lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php create mode 100644 lib/php/test/Unit/Lib/StringFunc/CoreTest.php create mode 100644 lib/php/test/Unit/Lib/StringFunc/MbStringTest.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9afd502da1..f003db241c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,10 +119,12 @@ jobs: mkdir -p ./lib/php/test/Resources/packages/phpv mkdir -p ./lib/php/test/Resources/packages/phpvo mkdir -p ./lib/php/test/Resources/packages/phpjs - compiler/cpp/thrift --gen php -r --out ./lib/php/test/Resources/packages/php lib/php/test/Resources/ThriftTest.thrift - compiler/cpp/thrift --gen php:validate -r --out ./lib/php/test/Resources/packages/phpv lib/php/test/Resources/ThriftTest.thrift - compiler/cpp/thrift --gen php:validate,oop -r --out ./lib/php/test/Resources/packages/phpvo lib/php/test/Resources/ThriftTest.thrift - compiler/cpp/thrift --gen php:json -r --out ./lib/php/test/Resources/packages/phpjs lib/php/test/Resources/ThriftTest.thrift + mkdir -p ./lib/php/test/Resources/packages/phpcm + compiler/cpp/thrift --gen php -r --out ./lib/php/test/Resources/packages/php lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:validate -r --out ./lib/php/test/Resources/packages/phpv lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:validate,oop -r --out ./lib/php/test/Resources/packages/phpvo lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:json -r --out ./lib/php/test/Resources/packages/phpjs lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:classmap,server,rest -r --out ./lib/php/test/Resources/packages/phpcm lib/php/test/Resources/ThriftTest.thrift - name: Run Tests run: vendor/bin/phpunit -c lib/php/phpunit.xml diff --git a/lib/php/lib/ClassLoader/ThriftClassLoader.php b/lib/php/lib/ClassLoader/ThriftClassLoader.php index e4b4a17c0c4..c1da4cb732b 100644 --- a/lib/php/lib/ClassLoader/ThriftClassLoader.php +++ b/lib/php/lib/ClassLoader/ThriftClassLoader.php @@ -1,4 +1,5 @@ apcu && ($file = $this->findFileInApcu($class))) or - ($file = $this->findFile($class)) + if ( + (true === $this->apcu && ($file = $this->findFileInApcu($class))) + || ($file = $this->findFile($class)) ) { require_once $file; } @@ -166,6 +168,7 @@ public function findFile($class) // Ignore wrong call if (count($m) <= 1) { + #HOW TO TEST THIS? HOW TEST CASE SHOULD LOOK LIKE? return; } @@ -183,8 +186,9 @@ public function findFile($class) * Available in service: Interface, Client, Processor, Rest * And every service methods (_.+) */ - if (0 === preg_match('#(.+)(if|client|processor|rest)$#i', $class, $n) and - 0 === preg_match('#(.+)_[a-z0-9]+_(args|result)$#i', $class, $n) + if ( + 0 === preg_match('#(.+)(if|client|processor|rest)$#i', $class, $n) + && 0 === preg_match('#(.+)_[a-z0-9]+_(args|result)$#i', $class, $n) ) { $className = 'Types'; } else { diff --git a/lib/php/lib/Factory/TBinaryProtocolFactory.php b/lib/php/lib/Factory/TBinaryProtocolFactory.php index 2519183df22..fc02d7169aa 100644 --- a/lib/php/lib/Factory/TBinaryProtocolFactory.php +++ b/lib/php/lib/Factory/TBinaryProtocolFactory.php @@ -1,4 +1,5 @@ strictRead_ = $strictRead; $this->strictWrite_ = $strictWrite; } + /** + * @param TTransport $trans + * @return TBinaryProtocol + */ public function getProtocol($trans) { return new TBinaryProtocol($trans, $this->strictRead_, $this->strictWrite_); diff --git a/lib/php/lib/Factory/TCompactProtocolFactory.php b/lib/php/lib/Factory/TCompactProtocolFactory.php index 11fb8ff3369..9171f7b6f02 100644 --- a/lib/php/lib/Factory/TCompactProtocolFactory.php +++ b/lib/php/lib/Factory/TCompactProtocolFactory.php @@ -1,4 +1,5 @@ $paths) { + $loader->registerNamespace($namespace, $paths); + } + $loader->register(); + $loader->loadClass($class); + if ($isClassExist) { + $this->assertTrue(class_exists($class, false), "->loadClass() loads '$class'"); + } else { + $this->assertFalse(class_exists($class, false), "->loadClass() loads '$class'"); + } + } + + public function registerNamespaceDataProvider() + { + yield 'default' => [ + 'namespaces' => [ + 'A' => __DIR__ . '/Fixtures', + ], + 'class' => 'A\TestClass', + ]; + yield 'missedClass' => [ + 'namespaces' => [ + 'A' => __DIR__ . '/Fixtures', + ], + 'class' => 'A\MissedClass', + 'isClassExist' => false, + ]; + yield 'pathAsArray' => [ + 'namespaces' => [ + 'B' => [__DIR__ . '/Fixtures'], + ], + 'class' => 'B\TestClass', + ]; + yield 'loadClassWithSlash' => [ + 'namespaces' => [ + 'C' => __DIR__ . '/Fixtures', + ], + 'class' => '\C\TestClass', + ]; + yield 'severalNamespaces' => [ + 'namespaces' => [ + 'D' => __DIR__ . '/Fixtures', + 'E' => __DIR__ . '/Fixtures', + ], + 'class' => '\E\TestClass', + ]; + yield 'useApcu' => [ + 'namespaces' => [ + 'D' => __DIR__ . '/Fixtures', + 'E' => __DIR__ . '/Fixtures', + ], + 'class' => '\E\TestClass', + 'isClassExist' => true, + 'useApcu' => true, + 'apcuPrefix' => self::APCU_PREFIX, + ]; + } + + /** + * @dataProvider registerDefinitionDataProvider + */ + public function testRegisterDefinition( + $definitions, + $class, + $checkInterfaceExist = false, + $useApcu = false, + $apcuPrefix = null + ) { + $loader = new ThriftClassLoader($useApcu, $apcuPrefix); + foreach ($definitions as $namespace => $paths) { + $loader->registerDefinition($namespace, $paths); + } + $loader->register(); + + $loader->loadClass($class); + if ($checkInterfaceExist) { + $this->assertTrue(interface_exists($class, false), "->loadClass() loads '$class'"); + } else { + $this->assertTrue(class_exists($class, false), "->loadClass() loads '$class'"); + } + } + + public function registerDefinitionDataProvider() + { + yield 'loadType' => [ + 'definitions' => [ + 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => 'ThriftTest\Xtruct', + ]; + yield 'loadInterface' => [ + 'definitions' => [ + 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\ThriftTest\ThriftTestIf', + 'checkInterfaceExist' => true, + ]; + yield 'loadClient' => [ + 'definitions' => [ + 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\ThriftTest\ThriftTestClient', + ]; + yield 'loadProcessor' => [ + 'definitions' => [ + 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\ThriftTest\ThriftTestProcessor', + ]; + yield 'loadRest' => [ + 'definitions' => [ + 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\ThriftTest\ThriftTestRest', + ]; + yield 'load_args' => [ + 'definitions' => [ + 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\ThriftTest\ThriftTest_testVoid_args', + ]; + yield 'load_result' => [ + 'definitions' => [ + 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\ThriftTest\ThriftTest_testVoid_result', + ]; + yield 'pathAsArray' => [ + 'definitions' => [ + 'ThriftTest' => [__DIR__ . '/../../../Resources/packages/phpcm'], + ], + 'class' => 'ThriftTest\Xtruct', + ]; + yield 'severalDefinitions' => [ + 'definitions' => [ + 'ThriftTest' => [__DIR__ . '/../../../Resources/packages/phpcm'], + 'TestValidators' => [__DIR__ . '/../../../Resources/packages/phpcm'], + ], + 'class' => '\TestValidators\TestServiceClient', + ]; + yield 'useApcu' => [ + 'definitions' => [ + 'ThriftTest' => [__DIR__ . '/../../../Resources/packages/phpcm'], + 'TestValidators' => [__DIR__ . '/../../../Resources/packages/phpcm'], + ], + 'class' => '\TestValidators\TestServiceClient', + 'checkInterfaceExist' => false, + 'useApcu' => true, + 'apcuPrefix' => self::APCU_PREFIX, + ]; + } +} + +namespace Thrift\ClassLoader; + +use Test\Thrift\Unit\Lib\ClassLoader\ThriftClassLoaderTest; + +if (!function_exists('apcu_fetch')) { + { + function apcu_fetch($key, &$success = null) + { + if (strpos($key, ThriftClassLoaderTest::APCU_PREFIX) === false) { + throw new \Exception('apcu_fetch error, invalid key'); + } + + return false; + } + + function apcu_store($key, $var, $ttl = 0) + { + if (strpos($key, ThriftClassLoaderTest::APCU_PREFIX) === false) { + throw new \Exception('apcu_store error, invalid key'); + } + + return false; + } + }; +} diff --git a/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php new file mode 100644 index 00000000000..5f7c2a25287 --- /dev/null +++ b/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php @@ -0,0 +1,81 @@ +createMock(TTransport::class); + $factory = new TBinaryProtocolFactory($strictRead, $strictWrite); + $protocol = $factory->getProtocol($transport); + + $this->assertInstanceOf(TBinaryProtocol::class, $protocol); + + $ref = new \ReflectionClass($protocol); + $refStrictRead = $ref->getProperty('strictRead_'); + $refStrictRead->setAccessible(true); + $refStrictWrite = $ref->getProperty('strictWrite_'); + $refStrictWrite->setAccessible(true); + $refTrans = $ref->getProperty('trans_'); + $refTrans->setAccessible(true); + + $this->assertEquals($strictRead, $refStrictRead->getValue($protocol)); + $this->assertEquals($strictWrite, $refStrictWrite->getValue($protocol)); + $this->assertSame($transport, $refTrans->getValue($protocol)); + } + + public function getProtocolDataProvider() + { + yield 'allTrue' => [ + 'strictRead' => true, + 'strictWrite' => true, + ]; + yield 'allFalse' => [ + 'strictRead' => false, + 'strictWrite' => false, + ]; + yield 'strictReadTrue' => [ + 'strictRead' => true, + 'strictWrite' => false, + ]; + yield 'strictWriteTrue' => [ + 'strictRead' => false, + 'strictWrite' => true, + ]; + } +} diff --git a/lib/php/test/Unit/Lib/Factory/TCompactProtocolFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TCompactProtocolFactoryTest.php new file mode 100644 index 00000000000..f81e789b4c5 --- /dev/null +++ b/lib/php/test/Unit/Lib/Factory/TCompactProtocolFactoryTest.php @@ -0,0 +1,50 @@ +createMock(TTransport::class); + $factory = new TCompactProtocolFactory(); + $protocol = $factory->getProtocol($transport); + + $this->assertInstanceOf(TCompactProtocol::class, $protocol); + + $ref = new \ReflectionClass($protocol); + $refTrans = $ref->getProperty('trans_'); + $refTrans->setAccessible(true); + + $this->assertSame($transport, $refTrans->getValue($protocol)); + } +} diff --git a/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php new file mode 100644 index 00000000000..2cb32d8d3b9 --- /dev/null +++ b/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php @@ -0,0 +1,56 @@ +createMock(TTransport::class); + $factory = new TFramedTransportFactory(); + $framedTransport = $factory::getTransport($transport); + + $this->assertInstanceOf(TFramedTransport::class, $framedTransport); + + $ref = new \ReflectionClass($framedTransport); + $refRead = $ref->getProperty('read_'); + $refRead->setAccessible(true); + $refWrite = $ref->getProperty('write_'); + $refWrite->setAccessible(true); + $refTrans = $ref->getProperty('transport_'); + $refTrans->setAccessible(true); + + $this->assertTrue($refRead->getValue($framedTransport)); + $this->assertTrue($refWrite->getValue($framedTransport)); + $this->assertSame($transport, $refTrans->getValue($framedTransport)); + } +} diff --git a/lib/php/test/Unit/Lib/Factory/TJSONProtocolFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TJSONProtocolFactoryTest.php new file mode 100644 index 00000000000..0685af79707 --- /dev/null +++ b/lib/php/test/Unit/Lib/Factory/TJSONProtocolFactoryTest.php @@ -0,0 +1,50 @@ +createMock(TTransport::class); + $factory = new TJSONProtocolFactory(); + $protocol = $factory->getProtocol($transport); + + $this->assertInstanceOf(TJSONProtocol::class, $protocol); + + $ref = new \ReflectionClass($protocol); + $refTrans = $ref->getProperty('trans_'); + $refTrans->setAccessible(true); + + $this->assertSame($transport, $refTrans->getValue($protocol)); + } +} diff --git a/lib/php/test/Unit/Lib/Factory/TStringFuncFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TStringFuncFactoryTest.php new file mode 100644 index 00000000000..eb4df44d045 --- /dev/null +++ b/lib/php/test/Unit/Lib/Factory/TStringFuncFactoryTest.php @@ -0,0 +1,74 @@ +assertInstanceOf(TStringFunc::class, $stringFunc); + $this->assertInstanceOf(Mbstring::class, $stringFunc); + + /** + * it is a hack to nullable the instance of TStringFuncFactory, and get a new instance based on the new ini_get value + */ + $ref = new \ReflectionClass($factory); + $refInstance = $ref->getProperty('_instance'); + $refInstance->setAccessible(true); + $refInstance->setValue($factory, null); + + $stringFunc = $factory::create(); + $this->assertInstanceOf(TStringFunc::class, $stringFunc); + $this->assertInstanceOf(Core::class, $stringFunc); + } +} + + +namespace Thrift\Factory; + +function ini_get($key) +{ + static $count = 0; + if ($key === 'mbstring.func_overload') { + if ($count === 0) { + $count++; + return 2; + } else { + return 0; + } + } else { + return \ini_get($key); + } +} diff --git a/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php new file mode 100644 index 00000000000..da91b64b355 --- /dev/null +++ b/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php @@ -0,0 +1,43 @@ +createMock(TTransport::class); + $factory = new TTransportFactory(); + $result = $factory::getTransport($transport); + + $this->assertSame($transport, $result); + } +} diff --git a/lib/php/test/Unit/Lib/StringFunc/CoreTest.php b/lib/php/test/Unit/Lib/StringFunc/CoreTest.php new file mode 100644 index 00000000000..73ebbfde306 --- /dev/null +++ b/lib/php/test/Unit/Lib/StringFunc/CoreTest.php @@ -0,0 +1,215 @@ +assertEquals($expected, $core->substr($str, $start, $length)); + } + + /** + * @dataProvider strlenDataProvider + */ + public function testStrlen( + $expectedLength, + $str + ) { + $core = new Core(); + $this->assertEquals($expectedLength, $core->strlen($str)); + } + + public function substrDataProvider() + { + yield 'Afrikaans' => [ + 'expected' => 'Afrikaans', + 'str' => 'Afrikaans', + ]; + yield 'Alemannisch' => [ + 'expected' => 'Alemannisch', + 'str' => 'Alemannisch', + ]; + yield 'Aragonés' => [ + 'expected' => 'Aragonés', + 'str' => 'Aragonés', + ]; + yield 'العربية' => [ + 'expected' => 'العربية', + 'str' => 'العربية', + ]; + yield 'مصرى' => [ + 'expected' => 'مصرى', + 'str' => 'مصرى', + ]; + yield 'മലയാളം' => [ + 'expected' => 'മലയാളം', + 'str' => 'മലയാളം', + ]; + yield 'Slovenščina' => [ + 'expected' => 'Slovenščina', + 'str' => 'Slovenščina', + ]; + yield 'Українська' => [ + 'expected' => 'Українська', + 'str' => 'Українська', + ]; + yield 'اردو' => [ + 'expected' => 'اردو', + 'str' => 'اردو', + ]; + yield '中文' => [ + 'expected' => '中文', + 'str' => '中文', + ]; + yield '粵語' => [ + 'expected' => '粵語', + 'str' => '粵語', + ]; + yield 'Afrikaans_SUB' => [ + 'expected' => 'rikaan', + 'str' => 'Afrikaans', + 'start' => 2, + 'length' => 6, + ]; + yield 'Alemannisch_SUB' => [ + 'expected' => 'emanni', + 'str' => 'Alemannisch', + 'start' => 2, + 'length' => 6, + ]; + yield 'Aragonés_SUB' => [ + 'expected' => 'agoné', + 'str' => 'Aragonés', + 'start' => 2, + 'length' => 6, + ]; + yield 'العربية_SUB' => [ + 'expected' => 'لعر', + 'str' => 'العربية', + 'start' => 2, + 'length' => 6, + ]; + yield 'مصرى_SUB' => [ + 'expected' => 'صرى', + 'str' => 'مصرى', + 'start' => 2, + 'length' => 6, + ]; + yield 'മലയാളം_SUB' => [ + 'expected' => 'ലയ', + 'str' => 'മലയാളം', + 'start' => 3, + 'length' => 6, + ]; + yield 'Slovenščina_SUB' => [ + 'expected' => 'ovenš', + 'str' => 'Slovenščina', + 'start' => 2, + 'length' => 6, + ]; + yield 'Українська_SUB' => [ + 'expected' => 'кра', + 'str' => 'Українська', + 'start' => 2, + 'length' => 6, + ]; + yield 'اردو_SUB' => [ + 'expected' => 'ردو', + 'str' => 'اردو', + 'start' => 2, + 'length' => 6, + ]; + yield '中文_SUB' => [ + 'expected' => '文', + 'str' => '中文', + 'start' => 3, + 'length' => 3, + ]; + yield '粵語_SUB' => [ + 'expected' => '語', + 'str' => '粵語', + 'start' => 3, + 'length' => 3, + ]; + } + + public function strlenDataProvider() + { + yield 'Afrikaans' => [ + 'expectedLength' => 9, + 'str' => 'Afrikaans', + ]; + yield 'Alemannisch' => [ + 'expectedLength' => 11, + 'str' => 'Alemannisch', + ]; + yield 'Aragonés' => [ + 'expectedLength' => 9, + 'str' => 'Aragonés', + ]; + yield 'العربية' => [ + 'expectedLength' => 14, + 'str' => 'العربية', + ]; + yield 'مصرى' => [ + 'expectedLength' => 8, + 'str' => 'مصرى', + ]; + yield 'മലയാളം' => [ + 'expectedLength' => 18, + 'str' => 'മലയാളം', + ]; + yield 'Slovenščina' => [ + 'expectedLength' => 13, + 'str' => 'Slovenščina', + ]; + yield 'Українська' => [ + 'expectedLength' => 20, + 'str' => 'Українська', + ]; + yield 'اردو' => [ + 'expectedLength' => 8, + 'str' => 'اردو', + ]; + yield '中文' => [ + 'expectedLength' => 6, + 'str' => '中文', + ]; + yield '粵語' => [ + 'expectedLength' => 6, + 'str' => '粵語', + ]; + } +} diff --git a/lib/php/test/Unit/Lib/StringFunc/MbStringTest.php b/lib/php/test/Unit/Lib/StringFunc/MbStringTest.php new file mode 100644 index 00000000000..5827f919eac --- /dev/null +++ b/lib/php/test/Unit/Lib/StringFunc/MbStringTest.php @@ -0,0 +1,215 @@ +assertEquals($expected, $core->substr($str, $start, $length)); + } + + /** + * @dataProvider strlenDataProvider + */ + public function testStrlen( + $expectedLength, + $str + ) { + $core = new Mbstring(); + $this->assertEquals($expectedLength, $core->strlen($str)); + } + + public function substrDataProvider() + { + yield 'Afrikaans' => [ + 'expected' => 'Afrikaans', + 'str' => 'Afrikaans', + ]; + yield 'Alemannisch' => [ + 'expected' => 'Alemannisch', + 'str' => 'Alemannisch', + ]; + yield 'Aragonés' => [ + 'expected' => 'Aragonés', + 'str' => 'Aragonés', + ]; + yield 'العربية' => [ + 'expected' => 'العربية', + 'str' => 'العربية', + ]; + yield 'مصرى' => [ + 'expected' => 'مصرى', + 'str' => 'مصرى', + ]; + yield 'മലയാളം' => [ + 'expected' => 'മലയാളം', + 'str' => 'മലയാളം', + ]; + yield 'Slovenščina' => [ + 'expected' => 'Slovenščina', + 'str' => 'Slovenščina', + ]; + yield 'Українська' => [ + 'expected' => 'Українська', + 'str' => 'Українська', + ]; + yield 'اردو' => [ + 'expected' => 'اردو', + 'str' => 'اردو', + ]; + yield '中文' => [ + 'expected' => '中文', + 'str' => '中文', + ]; + yield '粵語' => [ + 'expected' => '粵語', + 'str' => '粵語', + ]; + yield 'Afrikaans_SUB' => [ + 'expected' => 'rikaan', + 'str' => 'Afrikaans', + 'start' => 2, + 'length' => 6, + ]; + yield 'Alemannisch_SUB' => [ + 'expected' => 'emanni', + 'str' => 'Alemannisch', + 'start' => 2, + 'length' => 6, + ]; + yield 'Aragonés_SUB' => [ + 'expected' => 'agoné', + 'str' => 'Aragonés', + 'start' => 2, + 'length' => 6, + ]; + yield 'العربية_SUB' => [ + 'expected' => 'لعر', + 'str' => 'العربية', + 'start' => 2, + 'length' => 6, + ]; + yield 'مصرى_SUB' => [ + 'expected' => 'صرى', + 'str' => 'مصرى', + 'start' => 2, + 'length' => 6, + ]; + yield 'മലയാളം_SUB' => [ + 'expected' => 'ലയ', + 'str' => 'മലയാളം', + 'start' => 3, + 'length' => 6, + ]; + yield 'Slovenščina_SUB' => [ + 'expected' => 'ovenš', + 'str' => 'Slovenščina', + 'start' => 2, + 'length' => 6, + ]; + yield 'Українська_SUB' => [ + 'expected' => 'кра', + 'str' => 'Українська', + 'start' => 2, + 'length' => 6, + ]; + yield 'اردو_SUB' => [ + 'expected' => 'ردو', + 'str' => 'اردو', + 'start' => 2, + 'length' => 6, + ]; + yield '中文_SUB' => [ + 'expected' => '文', + 'str' => '中文', + 'start' => 3, + 'length' => 3, + ]; + yield '粵語_SUB' => [ + 'expected' => '語', + 'str' => '粵語', + 'start' => 3, + 'length' => 3, + ]; + } + + public function strlenDataProvider() + { + yield 'Afrikaans' => [ + 'expectedLength' => 9, + 'str' => 'Afrikaans', + ]; + yield 'Alemannisch' => [ + 'expectedLength' => 11, + 'str' => 'Alemannisch', + ]; + yield 'Aragonés' => [ + 'expectedLength' => 9, + 'str' => 'Aragonés', + ]; + yield 'العربية' => [ + 'expectedLength' => 14, + 'str' => 'العربية', + ]; + yield 'مصرى' => [ + 'expectedLength' => 8, + 'str' => 'مصرى', + ]; + yield 'മലയാളം' => [ + 'expectedLength' => 18, + 'str' => 'മലയാളം', + ]; + yield 'Slovenščina' => [ + 'expectedLength' => 13, + 'str' => 'Slovenščina', + ]; + yield 'Українська' => [ + 'expectedLength' => 20, + 'str' => 'Українська', + ]; + yield 'اردو' => [ + 'expectedLength' => 8, + 'str' => 'اردو', + ]; + yield '中文' => [ + 'expectedLength' => 6, + 'str' => '中文', + ]; + yield '粵語' => [ + 'expectedLength' => 6, + 'str' => '粵語', + ]; + } +} From 5283155e7787522b7a65f441eba90394a73c0a0b Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Fri, 23 Feb 2024 20:04:20 +0100 Subject: [PATCH 185/250] Update lib/php/test/Unit/Lib/StringFunc/MbStringTest.php Co-authored-by: Pavel Kvach --- lib/php/test/Unit/Lib/StringFunc/MbStringTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/php/test/Unit/Lib/StringFunc/MbStringTest.php b/lib/php/test/Unit/Lib/StringFunc/MbStringTest.php index 5827f919eac..5670219955e 100644 --- a/lib/php/test/Unit/Lib/StringFunc/MbStringTest.php +++ b/lib/php/test/Unit/Lib/StringFunc/MbStringTest.php @@ -20,7 +20,7 @@ * */ -namespace Unit\Lib\StringFunc; +namespace Test\Thrift\Unit\Lib\StringFunc; use PHPUnit\Framework\TestCase; use Thrift\StringFunc\Mbstring; From d25b785a13332ed7880a97efdfe10f63c0193839 Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Fri, 23 Feb 2024 20:04:29 +0100 Subject: [PATCH 186/250] Update lib/php/test/Unit/Lib/StringFunc/CoreTest.php Co-authored-by: Pavel Kvach --- lib/php/test/Unit/Lib/StringFunc/CoreTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/php/test/Unit/Lib/StringFunc/CoreTest.php b/lib/php/test/Unit/Lib/StringFunc/CoreTest.php index 73ebbfde306..b2eaac23d29 100644 --- a/lib/php/test/Unit/Lib/StringFunc/CoreTest.php +++ b/lib/php/test/Unit/Lib/StringFunc/CoreTest.php @@ -20,7 +20,7 @@ * */ -namespace Unit\Lib\StringFunc; +namespace Test\Thrift\Unit\Lib\StringFunc; use PHPUnit\Framework\TestCase; use Thrift\StringFunc\Core; From 1f0100c2b49b8fccb465f69e4d75d29d07fdc718 Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Fri, 23 Feb 2024 22:51:59 +0100 Subject: [PATCH 187/250] Update lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php Co-authored-by: Pavel Kvach --- lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php b/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php index 2fa05c2cbd0..1180211243c 100644 --- a/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php +++ b/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php @@ -219,5 +219,5 @@ function apcu_store($key, $var, $ttl = 0) return false; } - }; + } } From caa3662728b5650acfb56b5eb89351cdd347c495 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 25 Feb 2024 18:05:38 +0900 Subject: [PATCH 188/250] THRIFT-5762 Expose service result objects in Java Some libraries want to bypass the TServer class and handle the full service startup manually. For example when building a service that hosts multiple thrift services where the IFace type is unknown when handling a request. For example when you host multiple services on top of netty and through an HTTP path you want to route to the correct thrift service. In this situation you treat can treat an IFace as an Object and use the `getProcessMapView()` method to parse a byte array into a thrift message and pass let the `AsyncProcessFunction` handle the invocation. To return a correct thrift response it's necessary to write the `{service_name}_result` that contains the response args. While it is possible to get an incoming args object from the (Async)ProcessFunction its unfortunately not possible to get a result object without using reflection. This PR extends the (Async)ProcessFunction by adding a `getEmptyResultInstance` method that returns a new generic `A` (answer) that matches the `{service_name}_result` object. This allows thrift users to write the following processing code: ```java void handleRequest( TProtocol in, TProtocol out, TBaseAsyncProcessor processor, I asyncIface ) throws TException { final Map, TBase, TBase>> processMap = (Map) processor.getProcessMapView(); final var msg = in.readMessageBegin(); final var fn = processMap.get(msg.name); final var args = fn.getEmptyArgsInstance(); args.read(in); in.readMessageEnd(); if (fn.isOneway()) { return; } fn.start(asyncIface, args, new AsyncMethodCallback<>() { @Override public void onComplete(TBase o) { try { out.writeMessageBegin(new TMessage(fn.getMethodName(), TMessageType.REPLY, msg.getSeqid())); final var response_result = fn.getEmptyResultInstance(); final var success_field = response_result.fieldForId(SUCCESS_ID); ((TBase) response_result).setFieldValue(success_field, o); response_result.write(out); out.writeMessageEnd(); out.getTransport().flush(); } catch (TException e) { throw new RuntimeException(e); } } @Override public void onError(Exception e) { try { out.writeMessageBegin(new TMessage(fn.getMethodName(), TMessageType.EXCEPTION, msg.getSeqid())); ((TApplicationException) e).write(out); out.writeMessageEnd(); out.getTransport().flush(); } catch (TException ex) { throw new RuntimeException(ex); } } }); } ``` The above example code doesn't need any reference to the original types and can dynamically create the correct objects to return a correct response. --- .../src/thrift/generate/t_java_generator.cc | 51 +++++-- .../apache/thrift/AsyncProcessFunction.java | 6 +- .../org/apache/thrift/ProcessFunction.java | 141 +++++++++--------- .../apache/thrift/TBaseAsyncProcessor.java | 6 +- .../org/apache/thrift/TBaseProcessor.java | 6 +- .../thrift/server/TSaslNonblockingServer.java | 2 +- 6 files changed, 120 insertions(+), 92 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc index d7e0b65939c..1985a3d8494 100644 --- a/compiler/cpp/src/thrift/generate/t_java_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc @@ -3635,22 +3635,23 @@ void t_java_generator::generate_service_server(t_service* tservice) { indent(f_service_) << "public Processor(I iface) {" << endl; indent(f_service_) << " super(iface, getProcessMap(new java.util.HashMap>()));" + "org.apache.thrift.TBase, ? extends org.apache.thrift.TBase>>()));" << endl; indent(f_service_) << "}" << endl << endl; indent(f_service_) << "protected Processor(I iface, java.util.Map> " - "processMap) {" + "org.apache.thrift.ProcessFunction> processMap) {" << endl; indent(f_service_) << " super(iface, getProcessMap(processMap));" << endl; indent(f_service_) << "}" << endl << endl; - indent(f_service_) << "private static java.util.Map> " + indent(f_service_) << "private static java.util.Map> " "getProcessMap(java.util.Map> processMap) {" + " org.apache.thrift.TBase, ? extends org.apache.thrift.TBase>> processMap) {" << endl; indent_up(); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -3702,13 +3703,13 @@ void t_java_generator::generate_service_async_server(t_service* tservice) { indent(f_service_) << "public AsyncProcessor(I iface) {" << endl; indent(f_service_) << " super(iface, getProcessMap(new java.util.HashMap>()));" + "org.apache.thrift.TBase, ?, ? extends org.apache.thrift.TBase>>()));" << endl; indent(f_service_) << "}" << endl << endl; indent(f_service_) << "protected AsyncProcessor(I iface, java.util.Map> processMap) {" + "org.apache.thrift.TBase, ?, ? extends org.apache.thrift.TBase>> processMap) {" << endl; indent(f_service_) << " super(iface, getProcessMap(processMap));" << endl; indent(f_service_) << "}" << endl << endl; @@ -3716,9 +3717,9 @@ void t_java_generator::generate_service_async_server(t_service* tservice) { indent(f_service_) << "private static java.util.Map> getProcessMap(java.util.Map> getProcessMap(java.util.Map> processMap) {" + "org.apache.thrift.TBase, ?, ? extends org.apache.thrift.TBase>> processMap) {" << endl; indent_up(); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -3783,13 +3784,23 @@ void t_java_generator::generate_process_async_function(t_service* tservice, t_fu // Open class indent(f_service_) << "public static class " << make_valid_java_identifier(tfunction->get_name()) << " extends org.apache.thrift.AsyncProcessFunction {" << endl; + << argsname << ", " << resulttype << ", " << resultname << "> {" << endl; indent_up(); indent(f_service_) << "public " << make_valid_java_identifier(tfunction->get_name()) << "() {" << endl; indent(f_service_) << " super(\"" << tfunction->get_name() << "\");" << endl; indent(f_service_) << "}" << endl << endl; + indent(f_service_) << java_override_annotation() << endl; + indent(f_service_) << "public " << resultname << " getEmptyResultInstance() {" << endl; + if (tfunction->is_oneway()) { + indent(f_service_) << " return null;" << endl; + } + else { + indent(f_service_) << " return new " << resultname << "();" << endl; + } + indent(f_service_) << "}" << endl << endl; + indent(f_service_) << java_override_annotation() << endl; indent(f_service_) << "public " << argsname << " getEmptyArgsInstance() {" << endl; indent(f_service_) << " return new " << argsname << "();" << endl; @@ -3931,7 +3942,7 @@ void t_java_generator::generate_process_async_function(t_service* tservice, t_fu indent(f_service_) << "}" << endl << endl; indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "protected boolean isOneway() {" << endl; + indent(f_service_) << "public boolean isOneway() {" << endl; indent(f_service_) << " return " << ((tfunction->is_oneway()) ? "true" : "false") << ";" << endl; indent(f_service_) << "}" << endl << endl; @@ -3989,7 +4000,7 @@ void t_java_generator::generate_process_function(t_service* tservice, t_function // Open class indent(f_service_) << "public static class " << make_valid_java_identifier(tfunction->get_name()) << " extends org.apache.thrift.ProcessFunction {" << endl; + << argsname << ", " << resultname << "> {" << endl; indent_up(); indent(f_service_) << "public " << make_valid_java_identifier(tfunction->get_name()) << "() {" << endl; @@ -4002,7 +4013,7 @@ void t_java_generator::generate_process_function(t_service* tservice, t_function indent(f_service_) << "}" << endl << endl; indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "protected boolean isOneway() {" << endl; + indent(f_service_) << "public boolean isOneway() {" << endl; indent(f_service_) << " return " << ((tfunction->is_oneway()) ? "true" : "false") << ";" << endl; indent(f_service_) << "}" << endl << endl; @@ -4012,12 +4023,22 @@ void t_java_generator::generate_process_function(t_service* tservice, t_function << endl; indent(f_service_) << "}" << endl << endl; + indent(f_service_) << java_override_annotation() << endl; + indent(f_service_) << "public " << resultname << " getEmptyResultInstance() {" << endl; + if (tfunction->is_oneway()) { + indent(f_service_) << " return null;" << endl; + } + else { + indent(f_service_) << " return new " << resultname << "();" << endl; + } + indent(f_service_) << "}" << endl << endl; + indent(f_service_) << java_override_annotation() << endl; indent(f_service_) << "public " << resultname << " getResult(I iface, " << argsname << " args) throws org.apache.thrift.TException {" << endl; indent_up(); if (!tfunction->is_oneway()) { - indent(f_service_) << resultname << " result = new " << resultname << "();" << endl; + indent(f_service_) << resultname << " result = getEmptyResultInstance();" << endl; } t_struct* xs = tfunction->get_xceptions(); diff --git a/lib/java/src/main/java/org/apache/thrift/AsyncProcessFunction.java b/lib/java/src/main/java/org/apache/thrift/AsyncProcessFunction.java index c7c4be3036d..4e65ae66e17 100644 --- a/lib/java/src/main/java/org/apache/thrift/AsyncProcessFunction.java +++ b/lib/java/src/main/java/org/apache/thrift/AsyncProcessFunction.java @@ -23,20 +23,22 @@ import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.server.AbstractNonblockingServer; -public abstract class AsyncProcessFunction { +public abstract class AsyncProcessFunction { final String methodName; public AsyncProcessFunction(String methodName) { this.methodName = methodName; } - protected abstract boolean isOneway(); + public abstract boolean isOneway(); public abstract void start(I iface, T args, AsyncMethodCallback resultHandler) throws TException; public abstract T getEmptyArgsInstance(); + public abstract A getEmptyResultInstance(); + public abstract AsyncMethodCallback getResultHandler( final AbstractNonblockingServer.AsyncFrameBuffer fb, int seqid); diff --git a/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java b/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java index 7399342a217..8552863aaef 100644 --- a/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java +++ b/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java @@ -8,86 +8,91 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class ProcessFunction { - private final String methodName; +public abstract class ProcessFunction { + private final String methodName; - private static final Logger LOGGER = LoggerFactory.getLogger(ProcessFunction.class.getName()); + private static final Logger LOGGER = LoggerFactory.getLogger(ProcessFunction.class.getName()); - public ProcessFunction(String methodName) { - this.methodName = methodName; - } - - public final void process(int seqid, TProtocol iprot, TProtocol oprot, I iface) - throws TException { - T args = getEmptyArgsInstance(); - try { - args.read(iprot); - } catch (TProtocolException e) { - iprot.readMessageEnd(); - TApplicationException x = - new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage()); - oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid)); - x.write(oprot); - oprot.writeMessageEnd(); - oprot.getTransport().flush(); - return; + public ProcessFunction(String methodName) { + this.methodName = methodName; } - iprot.readMessageEnd(); - TSerializable result = null; - byte msgType = TMessageType.REPLY; - try { - result = getResult(iface, args); - } catch (TTransportException ex) { - LOGGER.error("Transport error while processing " + getMethodName(), ex); - throw ex; - } catch (TApplicationException ex) { - LOGGER.error("Internal application error processing " + getMethodName(), ex); - result = ex; - msgType = TMessageType.EXCEPTION; - } catch (Exception ex) { - LOGGER.error("Internal error processing " + getMethodName(), ex); - if (rethrowUnhandledExceptions()) throw new RuntimeException(ex.getMessage(), ex); - if (!isOneway()) { - result = - new TApplicationException( - TApplicationException.INTERNAL_ERROR, - "Internal error processing " + getMethodName()); - msgType = TMessageType.EXCEPTION; - } + public final void process(int seqid, TProtocol iprot, TProtocol oprot, I iface) + throws TException { + T args = getEmptyArgsInstance(); + try { + args.read(iprot); + } catch (TProtocolException e) { + iprot.readMessageEnd(); + TApplicationException x = + new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage()); + oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid)); + x.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); + return; + } + iprot.readMessageEnd(); + TSerializable result = null; + byte msgType = TMessageType.REPLY; + + try { + result = getResult(iface, args); + } catch (TTransportException ex) { + LOGGER.error("Transport error while processing " + getMethodName(), ex); + throw ex; + } catch (TApplicationException ex) { + LOGGER.error("Internal application error processing " + getMethodName(), ex); + result = ex; + msgType = TMessageType.EXCEPTION; + } catch (Exception ex) { + LOGGER.error("Internal error processing " + getMethodName(), ex); + if (rethrowUnhandledExceptions()) throw new RuntimeException(ex.getMessage(), ex); + if (!isOneway()) { + result = + new TApplicationException( + TApplicationException.INTERNAL_ERROR, + "Internal error processing " + getMethodName()); + msgType = TMessageType.EXCEPTION; + } + } + + if (!isOneway()) { + oprot.writeMessageBegin(new TMessage(getMethodName(), msgType, seqid)); + result.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); + } } - if (!isOneway()) { - oprot.writeMessageBegin(new TMessage(getMethodName(), msgType, seqid)); - result.write(oprot); - oprot.writeMessageEnd(); - oprot.getTransport().flush(); + private void handleException(int seqid, TProtocol oprot) throws TException { + if (!isOneway()) { + TApplicationException x = + new TApplicationException( + TApplicationException.INTERNAL_ERROR, "Internal error processing " + getMethodName()); + oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid)); + x.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); + } } - } - private void handleException(int seqid, TProtocol oprot) throws TException { - if (!isOneway()) { - TApplicationException x = - new TApplicationException( - TApplicationException.INTERNAL_ERROR, "Internal error processing " + getMethodName()); - oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid)); - x.write(oprot); - oprot.writeMessageEnd(); - oprot.getTransport().flush(); + protected boolean rethrowUnhandledExceptions() { + return false; } - } - protected boolean rethrowUnhandledExceptions() { - return false; - } + public abstract boolean isOneway(); - protected abstract boolean isOneway(); + public abstract TBase getResult(I iface, T args) throws TException; - public abstract TBase getResult(I iface, T args) throws TException; + public abstract T getEmptyArgsInstance(); - public abstract T getEmptyArgsInstance(); + /** + * Returns null when this is a oneWay function. + */ + public abstract A getEmptyResultInstance(); - public String getMethodName() { - return methodName; - } + public String getMethodName() { + return methodName; + } } diff --git a/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java b/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java index 266f0c0ceec..0a583c05a6a 100644 --- a/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java +++ b/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java @@ -30,15 +30,15 @@ public class TBaseAsyncProcessor implements TAsyncProcessor, TProcessor { protected final Logger LOGGER = LoggerFactory.getLogger(getClass().getName()); final I iface; - final Map> processMap; + final Map> processMap; public TBaseAsyncProcessor( - I iface, Map> processMap) { + I iface, Map> processMap) { this.iface = iface; this.processMap = processMap; } - public Map> getProcessMapView() { + public Map> getProcessMapView() { return Collections.unmodifiableMap(processMap); } diff --git a/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java b/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java index 05cd7b8ccda..ff1ccfcc9c0 100644 --- a/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java +++ b/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java @@ -10,15 +10,15 @@ public abstract class TBaseProcessor implements TProcessor { private final I iface; - private final Map> processMap; + private final Map> processMap; protected TBaseProcessor( - I iface, Map> processFunctionMap) { + I iface, Map> processFunctionMap) { this.iface = iface; this.processMap = processFunctionMap; } - public Map> getProcessMapView() { + public Map> getProcessMapView() { return Collections.unmodifiableMap(processMap); } diff --git a/lib/java/src/main/java/org/apache/thrift/server/TSaslNonblockingServer.java b/lib/java/src/main/java/org/apache/thrift/server/TSaslNonblockingServer.java index 6f22d8bb454..8c899d56cdb 100644 --- a/lib/java/src/main/java/org/apache/thrift/server/TSaslNonblockingServer.java +++ b/lib/java/src/main/java/org/apache/thrift/server/TSaslNonblockingServer.java @@ -255,7 +255,7 @@ private void handleIO() { } else if (selected.isWritable()) { saslHandler.handleWrite(); } else { - LOGGER.error("Invalid intrest op " + selected.interestOps()); + LOGGER.error("Invalid interest op " + selected.interestOps()); closeChannel(selected); continue; } From f44dc2cda97f65d40b3c2651074a181eff1f948a Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Thu, 7 Mar 2024 23:01:20 +0100 Subject: [PATCH 189/250] THRIFT-5764 Extra CTOR for TThriftBytesImpl Client: Delphi Patch: Jens Geyer --- lib/delphi/src/Thrift.Protocol.pas | 9 +++++++++ .../test/serializer/TestSerializer.Tests.pas | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas index f5cb454d4c1..4c02d3ff317 100644 --- a/lib/delphi/src/Thrift.Protocol.pas +++ b/lib/delphi/src/Thrift.Protocol.pas @@ -28,6 +28,7 @@ interface Classes, SysUtils, Contnrs, + Math, Thrift.Exception, Thrift.Stream, Thrift.Utils, @@ -388,6 +389,7 @@ TThriftBytesImpl = class( TInterfacedObject, IThriftBytes, ISupportsToString) constructor Create; overload; constructor Create( const bytes : TBytes); overload; constructor Create( var bytes : TBytes; const aTakeOwnership : Boolean = FALSE); overload; + constructor Create( const pData : Pointer; const nCount : Integer); overload; function ToString : string; override; end; @@ -802,6 +804,13 @@ constructor TThriftBytesImpl.Create( var bytes : TBytes; const aTakeOwnership : end; +constructor TThriftBytesImpl.Create( const pData : Pointer; const nCount : Integer); +begin + SetLength(FData, Max(nCount,0)); + if Length(FData) > 0 then Move( pData^, FData[0], Length(FData)); +end; + + function TThriftBytesImpl.ToString : string; var sb : TThriftStringBuilder; begin diff --git a/lib/delphi/test/serializer/TestSerializer.Tests.pas b/lib/delphi/test/serializer/TestSerializer.Tests.pas index 6ed1a48a2c5..91ced8a1707 100644 --- a/lib/delphi/test/serializer/TestSerializer.Tests.pas +++ b/lib/delphi/test/serializer/TestSerializer.Tests.pas @@ -81,6 +81,7 @@ TTestSerializer = class //extends TestCase { procedure Test_Serializer_Deserializer; procedure Test_COM_Types; + procedure Test_ThriftBytesCTORs; procedure Test_OneOfEach( const method : TMethod; const factory : TFactoryPair; const stream : TFileStream); procedure Test_CompactStruct( const method : TMethod; const factory : TFactoryPair; const stream : TFileStream); @@ -325,11 +326,28 @@ procedure TTestSerializer.Test_COM_Types; end; +procedure TTestSerializer.Test_ThriftBytesCTORs; +var one, two : IThriftBytes; + bytes : TBytes; + sAscii : AnsiString; +begin + sAscii := 'ABC/xzy'; + bytes := TEncoding.ASCII.GetBytes(sAscii); + + one := TThriftBytesImpl.Create( PAnsiChar(sAscii), Length(sAscii)); + two := TThriftBytesImpl.Create( bytes, TRUE); + + ASSERT( one.Count = two.Count); + ASSERT( CompareMem( one.QueryRawDataPtr, two.QueryRawDataPtr, one.Count)); +end; + + procedure TTestSerializer.RunTests; begin try Test_Serializer_Deserializer; Test_COM_Types; + Test_ThriftBytesCTORs; except on e:Exception do begin Writeln( e.ClassName+': '+ e.Message); From 81f610134f3a4348968763278c8b0295515b2285 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 8 Mar 2024 00:33:22 +0100 Subject: [PATCH 190/250] THRIFT-5765 Extra override for WriteBinary() to avoid unnecessary memory allocations when using COM types Client: Delphi Patch: JensG --- lib/delphi/src/Thrift.Protocol.Compact.pas | 9 +++++++++ lib/delphi/src/Thrift.Protocol.pas | 18 ++++++++++++++++++ .../test/serializer/TestSerializer.Tests.pas | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/delphi/src/Thrift.Protocol.Compact.pas b/lib/delphi/src/Thrift.Protocol.Compact.pas index 80f1ce58abd..a8ad53a4192 100644 --- a/lib/delphi/src/Thrift.Protocol.Compact.pas +++ b/lib/delphi/src/Thrift.Protocol.Compact.pas @@ -176,6 +176,7 @@ TFactory = class( TInterfacedObject, IProtocolFactory) procedure WriteI64( const i64: Int64); override; procedure WriteDouble( const dub: Double); override; procedure WriteBinary( const b: TBytes); overload; override; + procedure WriteBinary( const bytes : IThriftBytes); overload; override; procedure WriteUuid( const uuid: TGuid); override; private // unit visible stuff @@ -542,6 +543,14 @@ procedure TCompactProtocolImpl.WriteBinary( const b: TBytes); Transport.Write( b); end; + +procedure TCompactProtocolImpl.WriteBinary( const bytes : IThriftBytes); +begin + WriteVarint32( Cardinal(bytes.Count)); + Transport.Write( bytes.QueryRawDataPtr, 0, bytes.Count); +end; + + procedure TCompactProtocolImpl.WriteUuid( const uuid: TGuid); var network : TGuid; // in network order (Big Endian) begin diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas index 4c02d3ff317..fd92da9b73b 100644 --- a/lib/delphi/src/Thrift.Protocol.pas +++ b/lib/delphi/src/Thrift.Protocol.pas @@ -443,6 +443,7 @@ TFactory = class( TInterfacedObject, IProtocolFactory) procedure WriteI64( const i64: Int64); override; procedure WriteDouble( const d: Double); override; procedure WriteBinary( const b: TBytes); override; + procedure WriteBinary( const bytes : IThriftBytes); overload; override; procedure WriteUuid( const uuid: TGuid); override; function ReadMessageBegin: TThriftMessage; override; @@ -509,6 +510,7 @@ TProtocolDecorator = class( TProtocolImpl) procedure WriteString( const s: string ); override; procedure WriteAnsiString( const s: AnsiString); override; procedure WriteBinary( const b: TBytes); override; + procedure WriteBinary( const bytes : IThriftBytes); overload; override; procedure WriteUuid( const uuid: TGuid); override; function ReadMessageBegin: TThriftMessage; override; @@ -749,6 +751,8 @@ procedure TProtocolImpl.CheckReadBytesAvailable( const value : TThriftMap); procedure TProtocolImpl.WriteBinary( const bytes : IThriftBytes); +// This implementation works, but is rather inefficient due to the extra memory allocation +// Consider overwriting this for your transport implementation var tmp : TBytes; begin SetLength( tmp, bytes.Count); @@ -1114,6 +1118,14 @@ procedure TBinaryProtocolImpl.WriteBinary( const b: TBytes); if iLen > 0 then FTrans.Write(b, 0, iLen); end; +procedure TBinaryProtocolImpl.WriteBinary( const bytes : IThriftBytes); +var iLen : Integer; +begin + iLen := bytes.Count; + WriteI32( iLen); + if iLen > 0 then FTrans.Write( bytes.QueryRawDataPtr, 0, iLen); +end; + procedure TBinaryProtocolImpl.WriteUuid( const uuid: TGuid); var network : TGuid; // in network order (Big Endian) begin @@ -1518,6 +1530,12 @@ procedure TProtocolDecorator.WriteBinary( const b: TBytes); end; +procedure TProtocolDecorator.WriteBinary( const bytes : IThriftBytes); +begin + FWrappedProtocol.WriteBinary( bytes); +end; + + procedure TProtocolDecorator.WriteUuid( const uuid: TGuid); begin FWrappedProtocol.WriteUuid( uuid); diff --git a/lib/delphi/test/serializer/TestSerializer.Tests.pas b/lib/delphi/test/serializer/TestSerializer.Tests.pas index 91ced8a1707..e6a309e6861 100644 --- a/lib/delphi/test/serializer/TestSerializer.Tests.pas +++ b/lib/delphi/test/serializer/TestSerializer.Tests.pas @@ -332,7 +332,7 @@ procedure TTestSerializer.Test_ThriftBytesCTORs; sAscii : AnsiString; begin sAscii := 'ABC/xzy'; - bytes := TEncoding.ASCII.GetBytes(sAscii); + bytes := TEncoding.ASCII.GetBytes(string(sAscii)); one := TThriftBytesImpl.Create( PAnsiChar(sAscii), Length(sAscii)); two := TThriftBytesImpl.Create( bytes, TRUE); From e58c2b082821b9e5e7242c48f762f9ba765fa61a Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Wed, 8 Feb 2023 09:33:03 +0100 Subject: [PATCH 191/250] Move default constructor and operator== implementation to CPP file Both the default constructor and operator== implementations reference certain member functions of the class' members. As an example, the default constructor references (i.e., "uses") the default constructors of its members. If a class contains a std::vector, and Foo has only been *forward*- declared (which happens often in Thrift-generated code), this creates undefined behavior: The std::vector specification states that as long as Foo is an incomplete type, it is fine to reference std::vector, but not any members (such as its default constructor). Thus, we must defer our default constructor's implementation (which references the default constructor of std::vector) to a point where Foo is a complete type. That is the case in the .cpp file. The same holds for operator==. --- .../src/thrift/generate/t_cpp_generator.cc | 187 +++++++++++------- 1 file changed, 121 insertions(+), 66 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index 9724fae80a6..fecfa4bb564 100644 --- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc @@ -146,11 +146,13 @@ class t_cpp_generator : public t_oop_generator { bool is_user_struct = false); void generate_copy_constructor(std::ostream& out, t_struct* tstruct, bool is_exception); void generate_move_constructor(std::ostream& out, t_struct* tstruct, bool is_exception); + void generate_default_constructor(std::ostream& out, t_struct* tstruct, bool is_exception); void generate_constructor_helper(std::ostream& out, t_struct* tstruct, bool is_excpetion, bool is_move); void generate_assignment_operator(std::ostream& out, t_struct* tstruct); + void generate_equality_operator(std::ostream& out, t_struct* tstruct); void generate_move_assignment_operator(std::ostream& out, t_struct* tstruct); void generate_assignment_helper(std::ostream& out, t_struct* tstruct, bool is_move); void generate_struct_reader(std::ostream& out, t_struct* tstruct, bool pointers = false); @@ -914,6 +916,10 @@ void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception) generate_struct_reader(out, tstruct); generate_struct_writer(out, tstruct); generate_struct_swap(f_types_impl_, tstruct); + if (!gen_no_default_operators_) { + generate_equality_operator(f_types_impl_, tstruct); + } + generate_default_constructor(f_types_impl_, tstruct, is_exception); generate_copy_constructor(f_types_impl_, tstruct, is_exception); if (gen_moveable_) { generate_move_constructor(f_types_impl_, tstruct, is_exception); @@ -934,6 +940,117 @@ void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception) has_members_ = true; } +void t_cpp_generator::generate_equality_operator(std::ostream& out, t_struct* tstruct) { + // Get members + vector::const_iterator m_iter; + const vector& members = tstruct->get_members(); + + out << indent() << "bool " << tstruct->get_name() + << "::operator==(const " << tstruct->get_name() << " & " + << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << endl; + scope_up(out); + for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + // Most existing Thrift code does not use isset or optional/required, + // so we treat "default" fields as required. + if ((*m_iter)->get_req() != t_field::T_OPTIONAL) { + out << indent() << "if (!(" << (*m_iter)->get_name() << " == rhs." + << (*m_iter)->get_name() << "))" << endl << indent() << " return false;" << endl; + } else { + out << indent() << "if (__isset." << (*m_iter)->get_name() << " != rhs.__isset." + << (*m_iter)->get_name() << ")" << endl << indent() << " return false;" << endl + << indent() << "else if (__isset." << (*m_iter)->get_name() << " && !(" + << (*m_iter)->get_name() << " == rhs." << (*m_iter)->get_name() << "))" << endl + << indent() << " return false;" << endl; + } + } + indent(out) << "return true;" << endl; + scope_down(out); + out << "\n"; +} + +void t_cpp_generator::generate_default_constructor(ostream& out, + t_struct* tstruct, + bool is_exception) { + // Get members + vector::const_iterator m_iter; + const vector& members = tstruct->get_members(); + + // TODO(barth) this is duplicated from generate_struct_declaration + bool has_default_value = false; + for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + t_type* t = get_true_type((*m_iter)->get_type()); + if (is_reference(*m_iter) || t->is_string()) { + t_const_value* cv = (*m_iter)->get_value(); + if (cv != nullptr) { + has_default_value = true; + break; + } + } + } + + std::string clsname_ctor = tstruct->get_name() + "::" + tstruct->get_name() + "()"; + indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept"); + + if (has_default_value || is_exception) { + // We need an initializer block + + bool init_ctor = false; + std::string args_indent(" "); + + // Default-initialize TException, if it is our base type + if (is_exception) + { + out << "\n"; + indent(out) << " : "; + out << "TException()"; + init_ctor = true; + } + + // Default-initialize all members that should be initialized in + // the initializer block + for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + t_type* t = get_true_type((*m_iter)->get_type()); + if (t->is_base_type() || t->is_enum() || is_reference(*m_iter)) { + string dval; + t_const_value* cv = (*m_iter)->get_value(); + if (cv != nullptr) { + dval += render_const_value(out, (*m_iter)->get_name(), t, cv); + } else if (t->is_enum()) { + dval += "static_cast<" + type_name(t) + ">(0)"; + } else { + dval += (t->is_string() || is_reference(*m_iter)) ? "" : "0"; + } + if (!init_ctor) { + out << "\n"; + indent(out) << " : "; + init_ctor = true; + } else { + out << ",\n"; + indent(out) << args_indent; + } + + out << (*m_iter)->get_name() << "(" << dval << ")"; + } + } + out << " {" << endl; + indent_up(); + // TODO(dreiss): When everything else in Thrift is perfect, + // do more of these in the initializer list. + for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + t_type* t = get_true_type((*m_iter)->get_type()); + if (!t->is_base_type() && !t->is_enum() && !is_reference(*m_iter)) { + t_const_value* cv = (*m_iter)->get_value(); + if (cv != nullptr) { + print_const_value(out, (*m_iter)->get_name(), t, cv); + } + } + } + scope_down(out); + } else { + out << " {}\n"; + } +} + void t_cpp_generator::generate_copy_constructor(ostream& out, t_struct* tstruct, bool is_exception) { @@ -1168,52 +1285,7 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, // Default constructor std::string clsname_ctor = tstruct->get_name() + "()"; - indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept"); - - bool init_ctor = false; - std::string args_indent( - indent().size() + clsname_ctor.size() + (has_default_value ? 3 : -1), ' '); - - for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - t_type* t = get_true_type((*m_iter)->get_type()); - if (t->is_base_type() || t->is_enum() || is_reference(*m_iter)) { - string dval; - t_const_value* cv = (*m_iter)->get_value(); - if (cv != nullptr) { - dval += render_const_value(out, (*m_iter)->get_name(), t, cv); - } else if (t->is_enum()) { - dval += "static_cast<" + type_name(t) + ">(0)"; - } else { - dval += (t->is_string() || is_reference(*m_iter)) ? "" : "0"; - } - if (!init_ctor) { - init_ctor = true; - if(has_default_value) { - out << " : "; - } else { - out << '\n' << args_indent << ": "; - args_indent.append(" "); - } - } else { - out << ",\n" << args_indent; - } - out << (*m_iter)->get_name() << "(" << dval << ")"; - } - } - out << " {" << endl; - indent_up(); - // TODO(dreiss): When everything else in Thrift is perfect, - // do more of these in the initializer list. - for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - t_type* t = get_true_type((*m_iter)->get_type()); - if (!t->is_base_type() && !t->is_enum() && !is_reference(*m_iter)) { - t_const_value* cv = (*m_iter)->get_value(); - if (cv != nullptr) { - print_const_value(out, (*m_iter)->get_name(), t, cv); - } - } - } - scope_down(out); + indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept") << ";" << endl; } if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) { @@ -1254,27 +1326,10 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, if (!pointers) { // Should we generate default operators? if (!gen_no_default_operators_) { - // Generate an equality testing operator. Make it inline since the compiler - // will do a better job than we would when deciding whether to inline it. + // Generate an equality testing operator. out << indent() << "bool operator == (const " << tstruct->get_name() << " & " - << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << endl; - scope_up(out); - for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - // Most existing Thrift code does not use isset or optional/required, - // so we treat "default" fields as required. - if ((*m_iter)->get_req() != t_field::T_OPTIONAL) { - out << indent() << "if (!(" << (*m_iter)->get_name() << " == rhs." - << (*m_iter)->get_name() << "))" << endl << indent() << " return false;" << endl; - } else { - out << indent() << "if (__isset." << (*m_iter)->get_name() << " != rhs.__isset." - << (*m_iter)->get_name() << ")" << endl << indent() << " return false;" << endl - << indent() << "else if (__isset." << (*m_iter)->get_name() << " && !(" - << (*m_iter)->get_name() << " == rhs." << (*m_iter)->get_name() << "))" << endl - << indent() << " return false;" << endl; - } - } - indent(out) << "return true;" << endl; - scope_down(out); + << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const;" << endl; + out << indent() << "bool operator != (const " << tstruct->get_name() << " &rhs) const {" << endl << indent() << " return !(*this == rhs);" << endl << indent() << "}" << endl << endl; From 9ff073fab10c72d4824a7e668426a3abdfad420f Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Wed, 8 Feb 2023 10:11:48 +0100 Subject: [PATCH 192/250] Factor out duplicated code into helper function --- .../src/thrift/generate/t_cpp_generator.cc | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index fecfa4bb564..a77982f6192 100644 --- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc @@ -302,6 +302,12 @@ class t_cpp_generator : public t_oop_generator { */ bool is_struct_storage_not_throwing(t_struct* tstruct) const; + /** + * Helper function to determine whether any of the members of our struct + * has a default value. + */ + bool has_field_with_default_value(t_struct* tstruct); + private: /** * Returns the include prefix to use for a file generated by program, or the @@ -968,26 +974,33 @@ void t_cpp_generator::generate_equality_operator(std::ostream& out, t_struct* ts out << "\n"; } -void t_cpp_generator::generate_default_constructor(ostream& out, - t_struct* tstruct, - bool is_exception) { - // Get members +bool t_cpp_generator::has_field_with_default_value(t_struct* tstruct) +{ vector::const_iterator m_iter; const vector& members = tstruct->get_members(); - // TODO(barth) this is duplicated from generate_struct_declaration - bool has_default_value = false; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* t = get_true_type((*m_iter)->get_type()); if (is_reference(*m_iter) || t->is_string()) { t_const_value* cv = (*m_iter)->get_value(); if (cv != nullptr) { - has_default_value = true; - break; + return true; } } } + return false; +} + +void t_cpp_generator::generate_default_constructor(ostream& out, + t_struct* tstruct, + bool is_exception) { + // Get members + vector::const_iterator m_iter; + const vector& members = tstruct->get_members(); + + bool has_default_value = has_field_with_default_value(tstruct); + std::string clsname_ctor = tstruct->get_name() + "::" + tstruct->get_name() + "()"; indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept"); @@ -1271,18 +1284,8 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, << endl; } - bool has_default_value = false; - for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - t_type* t = get_true_type((*m_iter)->get_type()); - if (is_reference(*m_iter) || t->is_string()) { - t_const_value* cv = (*m_iter)->get_value(); - if (cv != nullptr) { - has_default_value = true; - break; - } - } - } - + bool has_default_value = has_field_with_default_value(tstruct); + // Default constructor std::string clsname_ctor = tstruct->get_name() + "()"; indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept") << ";" << endl; From 3aeef82b1d9351687a45030e24bede8d82e1f22f Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Fri, 24 Feb 2023 13:46:58 +0100 Subject: [PATCH 193/250] Move generate_default_constructor call into generate_struct_definition This makes sure that helper structs like _args and _result also have their default constructors defined. --- .../src/thrift/generate/t_cpp_generator.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index a77982f6192..ccb79bc4868 100644 --- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc @@ -143,7 +143,8 @@ class t_cpp_generator : public t_oop_generator { std::ostream& force_cpp_out, t_struct* tstruct, bool setters = true, - bool is_user_struct = false); + bool is_user_struct = false, + bool pointers = false); void generate_copy_constructor(std::ostream& out, t_struct* tstruct, bool is_exception); void generate_move_constructor(std::ostream& out, t_struct* tstruct, bool is_exception); void generate_default_constructor(std::ostream& out, t_struct* tstruct, bool is_exception); @@ -916,7 +917,7 @@ void t_cpp_generator::generate_forward_declaration(t_struct* tstruct) { */ void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception) { generate_struct_declaration(f_types_, tstruct, is_exception, false, true, true, true, true); - generate_struct_definition(f_types_impl_, f_types_impl_, tstruct, true, true); + generate_struct_definition(f_types_impl_, f_types_impl_, tstruct, true, true, false); std::ostream& out = (gen_templates_ ? f_types_tcc_ : f_types_impl_); generate_struct_reader(out, tstruct); @@ -925,7 +926,6 @@ void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception) if (!gen_no_default_operators_) { generate_equality_operator(f_types_impl_, tstruct); } - generate_default_constructor(f_types_impl_, tstruct, is_exception); generate_copy_constructor(f_types_impl_, tstruct, is_exception); if (gen_moveable_) { generate_move_constructor(f_types_impl_, tstruct, is_exception); @@ -1408,7 +1408,8 @@ void t_cpp_generator::generate_struct_definition(ostream& out, ostream& force_cpp_out, t_struct* tstruct, bool setters, - bool is_user_struct) { + bool is_user_struct, + bool pointers) { // Get members vector::const_iterator m_iter; const vector& members = tstruct->get_members(); @@ -1423,6 +1424,11 @@ void t_cpp_generator::generate_struct_definition(ostream& out, force_cpp_out << indent() << "}" << endl << endl; } + if (!pointers) + { + generate_default_constructor(out, tstruct, false); + } + // Create a setter function for each field if (setters) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -2058,9 +2064,10 @@ void t_cpp_generator::generate_service_helpers(t_service* tservice) { generate_struct_definition(out, f_service_, ts, false); generate_struct_reader(out, ts); generate_struct_writer(out, ts); + ts->set_name(tservice->get_name() + "_" + (*f_iter)->get_name() + "_pargs"); generate_struct_declaration(f_header_, ts, false, true, false, true); - generate_struct_definition(out, f_service_, ts, false); + generate_struct_definition(out, f_service_, ts, false, false, true); generate_struct_writer(out, ts, true); ts->set_name(name_orig); @@ -3508,7 +3515,7 @@ void t_cpp_generator::generate_function_helpers(t_service* tservice, t_function* result.set_name(tservice->get_name() + "_" + tfunction->get_name() + "_presult"); generate_struct_declaration(f_header_, &result, false, true, true, gen_cob_style_); - generate_struct_definition(out, f_service_, &result, false); + generate_struct_definition(out, f_service_, &result, false, false, true); generate_struct_reader(out, &result, true); if (gen_cob_style_) { generate_struct_writer(out, &result, true); From 5c92ad95e7837773114daa2deab2a092526b7c2a Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Mon, 6 Mar 2023 11:37:09 +0100 Subject: [PATCH 194/250] Always generate an initializer list --- .../src/thrift/generate/t_cpp_generator.cc | 106 +++++++++--------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index ccb79bc4868..2a65bfb9679 100644 --- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc @@ -1004,64 +1004,70 @@ void t_cpp_generator::generate_default_constructor(ostream& out, std::string clsname_ctor = tstruct->get_name() + "::" + tstruct->get_name() + "()"; indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept"); - if (has_default_value || is_exception) { - // We need an initializer block - - bool init_ctor = false; - std::string args_indent(" "); - - // Default-initialize TException, if it is our base type - if (is_exception) - { - out << "\n"; - indent(out) << " : "; - out << "TException()"; - init_ctor = true; - } + // + // Start generating initializer list + // - // Default-initialize all members that should be initialized in - // the initializer block - for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - t_type* t = get_true_type((*m_iter)->get_type()); - if (t->is_base_type() || t->is_enum() || is_reference(*m_iter)) { - string dval; - t_const_value* cv = (*m_iter)->get_value(); - if (cv != nullptr) { - dval += render_const_value(out, (*m_iter)->get_name(), t, cv); - } else if (t->is_enum()) { - dval += "static_cast<" + type_name(t) + ">(0)"; - } else { - dval += (t->is_string() || is_reference(*m_iter)) ? "" : "0"; - } - if (!init_ctor) { - out << "\n"; - indent(out) << " : "; - init_ctor = true; + bool init_ctor = false; + std::string args_indent(" "); + + // Default-initialize TException, if it is our base type + if (is_exception) + { + out << "\n"; + indent(out) << " : "; + out << "TException()"; + init_ctor = true; + } + + // Default-initialize all members that should be initialized in + // the initializer block + for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + t_type* t = get_true_type((*m_iter)->get_type()); + if (t->is_base_type() || t->is_enum() || is_reference(*m_iter)) { + string dval; + t_const_value* cv = (*m_iter)->get_value(); + if (cv != nullptr) { + dval += render_const_value(out, (*m_iter)->get_name(), t, cv); + } else if (t->is_enum()) { + dval += "static_cast<" + type_name(t) + ">(0)"; + } else { + dval += (t->is_string() || is_reference(*m_iter)) ? "" : "0"; + } + if (!init_ctor) { + init_ctor = true; + if(has_default_value) { + out << " : "; } else { - out << ",\n"; - indent(out) << args_indent; + out << '\n' << args_indent << ": "; + args_indent.append(" "); } - - out << (*m_iter)->get_name() << "(" << dval << ")"; + } else { + out << ",\n" << args_indent; } + + out << (*m_iter)->get_name() << "(" << dval << ")"; } - out << " {" << endl; - indent_up(); - // TODO(dreiss): When everything else in Thrift is perfect, - // do more of these in the initializer list. - for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - t_type* t = get_true_type((*m_iter)->get_type()); - if (!t->is_base_type() && !t->is_enum() && !is_reference(*m_iter)) { - t_const_value* cv = (*m_iter)->get_value(); - if (cv != nullptr) { - print_const_value(out, (*m_iter)->get_name(), t, cv); - } + } + + // + // Start generating body + // + + out << " {" << endl; + indent_up(); + // TODO(dreiss): When everything else in Thrift is perfect, + // do more of these in the initializer list. + for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + t_type* t = get_true_type((*m_iter)->get_type()); + if (!t->is_base_type() && !t->is_enum() && !is_reference(*m_iter)) { + t_const_value* cv = (*m_iter)->get_value(); + if (cv != nullptr) { + print_const_value(out, (*m_iter)->get_name(), t, cv); } } - scope_down(out); - } else { - out << " {}\n"; } + scope_down(out); } void t_cpp_generator::generate_copy_constructor(ostream& out, From 5bd001c07f0b6fa054cd29acdef11740d865033b Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Tue, 4 Apr 2023 16:25:06 +0200 Subject: [PATCH 195/250] Fix ODR violations in cases where templates are involved --- compiler/cpp/src/thrift/generate/t_cpp_generator.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index 2a65bfb9679..a085ada0e7b 100644 --- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc @@ -1432,7 +1432,10 @@ void t_cpp_generator::generate_struct_definition(ostream& out, if (!pointers) { - generate_default_constructor(out, tstruct, false); + // 'force_cpp_out' always goes into the .cpp file, and never into a .tcc + // file in case templates are involved. Since the constructor is not templated, + // putting it into the (later included) .tcc file would cause ODR violations. + generate_default_constructor(force_cpp_out, tstruct, false); } // Create a setter function for each field From 65742296b232ca6f3007a97a21e61bd1c2ee6dfe Mon Sep 17 00:00:00 2001 From: Tobias Weihs Date: Fri, 9 Sep 2022 11:21:45 +0200 Subject: [PATCH 196/250] expose qt5 targets if available --- build/cmake/ThriftConfig.cmake.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/cmake/ThriftConfig.cmake.in b/build/cmake/ThriftConfig.cmake.in index 2f2003bb438..f132fe11f54 100644 --- a/build/cmake/ThriftConfig.cmake.in +++ b/build/cmake/ThriftConfig.cmake.in @@ -40,6 +40,13 @@ if(@ZLIB_FOUND@ AND @WITH_ZLIB@) set(THRIFT_LIBRARIES thriftz::thriftz) endif() +if(@Qt5_FOUND@ AND @WITH_QT5@) + if (NOT TARGET thriftqt5::thriftqt5) + include("${THRIFT_CMAKE_DIR}/thriftqt5Targets.cmake") + endif() + set(THRIFT_LIBRARIES thriftqt5::thriftqt5) +endif() + if ("${THRIFT_LIBRARIES}" STREQUAL "") message(FATAL_ERROR "thrift libraries were not found") endif() From 91d69e41332d1e254c8bb6c77405e1f8e08cd49a Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Sat, 2 Mar 2024 21:41:01 +0100 Subject: [PATCH 197/250] [THRIFT-5757] Unit tests for php lib --- .github/workflows/build.yml | 2 +- composer.json | 4 +- lib/php/lib/Transport/TBufferedTransport.php | 1 + lib/php/lib/Transport/TCurlClient.php | 11 +- lib/php/lib/Transport/THttpClient.php | 14 +- lib/php/lib/Transport/TMemoryBuffer.php | 5 +- lib/php/lib/Transport/TPhpStream.php | 5 +- lib/php/lib/Transport/TSSLSocket.php | 9 +- lib/php/lib/Transport/TSocket.php | 6 +- lib/php/lib/Transport/TSocketPool.php | 61 +- lib/php/phpunit.xml | 9 +- lib/php/test/Fixtures/Fixtures.php | 2 - .../test/Fixtures/TJSONProtocolFixtures.php | 2 - .../Fixtures/TSimpleJSONProtocolFixtures.php | 2 - .../Lib/ClassLoader/Fixtures/A/TestClass.php | 5 - .../Lib/ClassLoader/Fixtures/B/TestClass.php | 5 - .../Lib/ClassLoader/Fixtures/C/TestClass.php | 5 - .../Lib/ClassLoader/Fixtures/D/TestClass.php | 5 - .../Lib/ClassLoader/Fixtures/E/TestClass.php | 5 - .../Lib/ClassLoader/ThriftClassLoaderTest.php | 53 +- .../Factory/TBinaryProtocolFactoryTest.php | 2 - .../Factory/TCompactProtocolFactoryTest.php | 2 - .../Factory/TFramedTransportFactoryTest.php | 2 - .../Lib/Factory/TJSONProtocolFactoryTest.php | 2 - .../Lib/Factory/TStringFuncFactoryTest.php | 50 +- .../Lib/Factory/TTransportFactoryTest.php | 2 - .../Lib/Transport/TBufferedTransportTest.php | 286 ++++++++ .../Unit/Lib/Transport/TCurlClientTest.php | 423 +++++++++++ .../Lib/Transport/TFramedTransportTest.php | 240 +++++++ .../Unit/Lib/Transport/THttpClientTest.php | 332 +++++++++ .../Unit/Lib/Transport/TMemoryBufferTest.php | 143 ++++ .../Unit/Lib/Transport/TNullTransportTest.php | 62 ++ .../Unit/Lib/Transport/TPhpStreamTest.php | 296 ++++++++ .../Unit/Lib/Transport/TSSLSocketTest.php | 247 +++++++ .../Unit/Lib/Transport/TSocketPoolTest.php | 541 ++++++++++++++ .../test/Unit/Lib/Transport/TSocketTest.php | 669 ++++++++++++++++++ 36 files changed, 3366 insertions(+), 144 deletions(-) create mode 100644 lib/php/test/Unit/Lib/Transport/TBufferedTransportTest.php create mode 100644 lib/php/test/Unit/Lib/Transport/TCurlClientTest.php create mode 100644 lib/php/test/Unit/Lib/Transport/TFramedTransportTest.php create mode 100644 lib/php/test/Unit/Lib/Transport/THttpClientTest.php create mode 100644 lib/php/test/Unit/Lib/Transport/TMemoryBufferTest.php create mode 100644 lib/php/test/Unit/Lib/Transport/TNullTransportTest.php create mode 100644 lib/php/test/Unit/Lib/Transport/TPhpStreamTest.php create mode 100644 lib/php/test/Unit/Lib/Transport/TSSLSocketTest.php create mode 100644 lib/php/test/Unit/Lib/Transport/TSocketPoolTest.php create mode 100644 lib/php/test/Unit/Lib/Transport/TSocketTest.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f003db241c7..0b29ddb906e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -90,7 +90,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - extensions: mbstring, intl, xml + extensions: mbstring, intl, xml, curl ini-values: "error_reporting=E_ALL" - name: Install Dependencies diff --git a/composer.json b/composer.json index 77248a9329e..900fb2854e7 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,10 @@ "require-dev": { "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", "squizlabs/php_codesniffer": "3.*", + "php-mock/php-mock-phpunit": "^2.10", "ext-json": "*", - "ext-xml": "*" + "ext-xml": "*", + "ext-curl": "*" }, "autoload": { "psr-4": {"Thrift\\": "lib/php/lib/"} diff --git a/lib/php/lib/Transport/TBufferedTransport.php b/lib/php/lib/Transport/TBufferedTransport.php index 253c5acfb47..e3a40a435cf 100644 --- a/lib/php/lib/Transport/TBufferedTransport.php +++ b/lib/php/lib/Transport/TBufferedTransport.php @@ -1,4 +1,5 @@ scheme_ . "://" . $host . $this->uri_; $headers = array(); - $defaultHeaders = array('Accept' => 'application/x-thrift', + $defaultHeaders = array( + 'Accept' => 'application/x-thrift', 'Content-Type' => 'application/x-thrift', - 'Content-Length' => TStringFuncFactory::create()->strlen($this->request_)); + 'Content-Length' => TStringFuncFactory::create()->strlen($this->request_) + ); foreach (array_merge($defaultHeaders, $this->headers_) as $key => $value) { $headers[] = "$key: $value"; } @@ -292,10 +294,11 @@ public static function closeCurlHandle() { try { if (self::$curlHandle) { - curl_close(self::$curlHandle); + curl_close(self::$curlHandle); #This function has no effect. Prior to PHP 8.0.0, this function was used to close the resource. self::$curlHandle = null; } } catch (\Exception $x) { + #it's not possible to throw an exception by calling a function that has no effect error_log('There was an error closing the curl handle: ' . $x->getMessage()); } } diff --git a/lib/php/lib/Transport/THttpClient.php b/lib/php/lib/Transport/THttpClient.php index 4d6be32fed2..0f767f44330 100644 --- a/lib/php/lib/Transport/THttpClient.php +++ b/lib/php/lib/Transport/THttpClient.php @@ -1,4 +1,5 @@ host_ . ($this->port_ != 80 ? ':' . $this->port_ : ''); $headers = array(); - $defaultHeaders = array('Host' => $host, + $defaultHeaders = array( + 'Host' => $host, 'Accept' => 'application/x-thrift', 'User-Agent' => 'PHP/THttpClient', 'Content-Type' => 'application/x-thrift', - 'Content-Length' => TStringFuncFactory::create()->strlen($this->buf_)); + 'Content-Length' => TStringFuncFactory::create()->strlen($this->buf_) + ); + foreach (array_merge($defaultHeaders, $this->headers_) as $key => $value) { $headers[] = "$key: $value"; } @@ -225,10 +229,12 @@ public function flush() $baseHttpOptions = isset($options["http"]) ? $options["http"] : array(); - $httpOptions = $baseHttpOptions + array('method' => 'POST', + $httpOptions = $baseHttpOptions + array( + 'method' => 'POST', 'header' => implode("\r\n", $headers), 'max_redirects' => 1, - 'content' => $this->buf_); + 'content' => $this->buf_ + ); if ($this->timeout_ > 0) { $httpOptions['timeout'] = $this->timeout_; } diff --git a/lib/php/lib/Transport/TMemoryBuffer.php b/lib/php/lib/Transport/TMemoryBuffer.php index fee03a2a4b4..e5da9dab2c9 100644 --- a/lib/php/lib/Transport/TMemoryBuffer.php +++ b/lib/php/lib/Transport/TMemoryBuffer.php @@ -1,4 +1,5 @@ buf_ = $buf; } - protected $buf_ = ''; - public function isOpen() { return true; diff --git a/lib/php/lib/Transport/TPhpStream.php b/lib/php/lib/Transport/TPhpStream.php index 42823ff3372..2350b96f065 100644 --- a/lib/php/lib/Transport/TPhpStream.php +++ b/lib/php/lib/Transport/TPhpStream.php @@ -1,4 +1,5 @@ read_) { - $this->inStream_ = @fopen(self::inStreamName(), 'r'); + $this->inStream_ = @fopen($this->inStreamName(), 'r'); if (!is_resource($this->inStream_)) { throw new TException('TPhpStream: Could not open php://input'); } @@ -113,7 +114,7 @@ public function flush() @fflush($this->outStream_); } - private static function inStreamName() + private function inStreamName() { if (php_sapi_name() == 'cli') { return 'php://stdin'; diff --git a/lib/php/lib/Transport/TSSLSocket.php b/lib/php/lib/Transport/TSSLSocket.php index b4a0adb5430..16956e7d9b1 100644 --- a/lib/php/lib/Transport/TSSLSocket.php +++ b/lib/php/lib/Transport/TSSLSocket.php @@ -36,7 +36,7 @@ class TSSLSocket extends TSocket /** * Remote port * - * @var resource + * @var null|resource */ protected $context_ = null; @@ -57,6 +57,10 @@ public function __construct( ) { $this->host_ = $this->getSSLHost($host); $this->port_ = $port; + // Initialize a stream context if not provided + if ($context === null) { + $context = stream_context_create(); + } $this->context_ = $context; $this->debugHandler_ = $debugHandler ? $debugHandler : 'error_log'; } @@ -87,7 +91,8 @@ public function open() throw new TTransportException('Socket already connected', TTransportException::ALREADY_OPEN); } - if (empty($this->host_)) { + $host = parse_url($this->host_, PHP_URL_HOST); + if (empty($host)) { throw new TTransportException('Cannot open null host', TTransportException::NOT_OPEN); } diff --git a/lib/php/lib/Transport/TSocket.php b/lib/php/lib/Transport/TSocket.php index 8fe60fdaae7..fb74fdbf6aa 100644 --- a/lib/php/lib/Transport/TSocket.php +++ b/lib/php/lib/Transport/TSocket.php @@ -252,8 +252,10 @@ public function open() if (function_exists('socket_import_stream') && function_exists('socket_set_option')) { // warnings silenced due to bug https://bugs.php.net/bug.php?id=70939 - $socket = @socket_import_stream($this->handle_); - @socket_set_option($socket, SOL_TCP, TCP_NODELAY, 1); + $socket = socket_import_stream($this->handle_); + if ($socket !== false) { + @socket_set_option($socket, SOL_TCP, TCP_NODELAY, 1); + } } } diff --git a/lib/php/lib/Transport/TSocketPool.php b/lib/php/lib/Transport/TSocketPool.php index 307885f507a..312e023c60a 100644 --- a/lib/php/lib/Transport/TSocketPool.php +++ b/lib/php/lib/Transport/TSocketPool.php @@ -1,4 +1,5 @@ $host) { - $this->servers_ [] = array('host' => $host, - 'port' => $ports[$key]); + $this->servers_ [] = array( + 'host' => $host, + 'port' => $ports[$key] + ); } + + $this->useApcuCache = function_exists('apcu_fetch'); } /** @@ -206,7 +199,7 @@ public function open() $failtimeKey = 'thrift_failtime:' . $host . ':' . $port . '~'; // Cache miss? Assume it's OK - $lastFailtime = apcu_fetch($failtimeKey); + $lastFailtime = $this->apcuFetch($failtimeKey); if ($lastFailtime === false) { $lastFailtime = 0; } @@ -251,7 +244,7 @@ public function open() // Only clear the failure counts if required to do so if ($lastFailtime > 0) { - apcu_store($failtimeKey, 0); + $this->apcuStore($failtimeKey, 0); } // Successful connection, return now @@ -265,7 +258,7 @@ public function open() $consecfailsKey = 'thrift_consecfails:' . $host . ':' . $port . '~'; // Ignore cache misses - $consecfails = apcu_fetch($consecfailsKey); + $consecfails = $this->apcuFetch($consecfailsKey); if ($consecfails === false) { $consecfails = 0; } @@ -284,12 +277,12 @@ public function open() ); } // Store the failure time - apcu_store($failtimeKey, time()); + $this->apcuStore($failtimeKey, time()); // Clear the count of consecutive failures - apcu_store($consecfailsKey, 0); + $this->apcuStore($consecfailsKey, 0); } else { - apcu_store($consecfailsKey, $consecfails); + $this->apcuStore($consecfailsKey, $consecfails); } } } @@ -307,4 +300,20 @@ public function open() } throw new TException($error); } + + /** + * This library makes use of APCu cache to make hosts as down in a web + * environment. If you are running from the CLI or on a system without APCu + * installed, then these null functions will step in and act like cache + * misses. + */ + private function apcuFetch($key, &$success = null) + { + return $this->useApcuCache ? apcu_fetch($key, $success) : false; + } + + private function apcuStore($key, $var, $ttl = 0) + { + return $this->useApcuCache ? apcu_store($key, $var, $ttl) : false; + } } diff --git a/lib/php/phpunit.xml b/lib/php/phpunit.xml index 53b3f351a9f..2cbea95d345 100644 --- a/lib/php/phpunit.xml +++ b/lib/php/phpunit.xml @@ -28,12 +28,11 @@ stopOnFailure="true" processIsolation="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> - - - ./src + + ./lib - - + + ./test/Unit diff --git a/lib/php/test/Fixtures/Fixtures.php b/lib/php/test/Fixtures/Fixtures.php index eb348fc7101..d48be4061c8 100644 --- a/lib/php/test/Fixtures/Fixtures.php +++ b/lib/php/test/Fixtures/Fixtures.php @@ -17,8 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.test */ namespace Test\Thrift\Fixtures; diff --git a/lib/php/test/Fixtures/TJSONProtocolFixtures.php b/lib/php/test/Fixtures/TJSONProtocolFixtures.php index 81ada779638..77fb270a796 100644 --- a/lib/php/test/Fixtures/TJSONProtocolFixtures.php +++ b/lib/php/test/Fixtures/TJSONProtocolFixtures.php @@ -17,8 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.test */ namespace Test\Thrift\Fixtures; diff --git a/lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php b/lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php index 448eb61261b..0281a879b7e 100644 --- a/lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php +++ b/lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php @@ -17,8 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.test */ namespace Test\Thrift\Fixtures; diff --git a/lib/php/test/Unit/Lib/ClassLoader/Fixtures/A/TestClass.php b/lib/php/test/Unit/Lib/ClassLoader/Fixtures/A/TestClass.php index e39f501e0b9..3652b253ead 100644 --- a/lib/php/test/Unit/Lib/ClassLoader/Fixtures/A/TestClass.php +++ b/lib/php/test/Unit/Lib/ClassLoader/Fixtures/A/TestClass.php @@ -17,11 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * ClassLoader to load Thrift library and definitions - * Inspired from UniversalClassLoader from Symfony 2 - * - * @package thrift.classloader */ namespace A; diff --git a/lib/php/test/Unit/Lib/ClassLoader/Fixtures/B/TestClass.php b/lib/php/test/Unit/Lib/ClassLoader/Fixtures/B/TestClass.php index d2e87e2e2f5..1d5a543be93 100644 --- a/lib/php/test/Unit/Lib/ClassLoader/Fixtures/B/TestClass.php +++ b/lib/php/test/Unit/Lib/ClassLoader/Fixtures/B/TestClass.php @@ -17,11 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * ClassLoader to load Thrift library and definitions - * Inspired from UniversalClassLoader from Symfony 2 - * - * @package thrift.classloader */ namespace B; diff --git a/lib/php/test/Unit/Lib/ClassLoader/Fixtures/C/TestClass.php b/lib/php/test/Unit/Lib/ClassLoader/Fixtures/C/TestClass.php index 9e4000c1f9c..58bae58defb 100644 --- a/lib/php/test/Unit/Lib/ClassLoader/Fixtures/C/TestClass.php +++ b/lib/php/test/Unit/Lib/ClassLoader/Fixtures/C/TestClass.php @@ -17,11 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * ClassLoader to load Thrift library and definitions - * Inspired from UniversalClassLoader from Symfony 2 - * - * @package thrift.classloader */ namespace C; diff --git a/lib/php/test/Unit/Lib/ClassLoader/Fixtures/D/TestClass.php b/lib/php/test/Unit/Lib/ClassLoader/Fixtures/D/TestClass.php index c0cda0cbc33..592fe566e2e 100644 --- a/lib/php/test/Unit/Lib/ClassLoader/Fixtures/D/TestClass.php +++ b/lib/php/test/Unit/Lib/ClassLoader/Fixtures/D/TestClass.php @@ -17,11 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * ClassLoader to load Thrift library and definitions - * Inspired from UniversalClassLoader from Symfony 2 - * - * @package thrift.classloader */ namespace D; diff --git a/lib/php/test/Unit/Lib/ClassLoader/Fixtures/E/TestClass.php b/lib/php/test/Unit/Lib/ClassLoader/Fixtures/E/TestClass.php index b1981b497ef..56b56793de0 100644 --- a/lib/php/test/Unit/Lib/ClassLoader/Fixtures/E/TestClass.php +++ b/lib/php/test/Unit/Lib/ClassLoader/Fixtures/E/TestClass.php @@ -17,11 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * ClassLoader to load Thrift library and definitions - * Inspired from UniversalClassLoader from Symfony 2 - * - * @package thrift.classloader */ namespace E; diff --git a/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php b/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php index 1180211243c..46ed2ec69c0 100644 --- a/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php +++ b/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php @@ -21,6 +21,7 @@ namespace Test\Thrift\Unit\Lib\ClassLoader; +use phpmock\phpunit\PHPMock; use PHPUnit\Framework\TestCase; use Thrift\ClassLoader\ThriftClassLoader; @@ -30,7 +31,7 @@ */ class ThriftClassLoaderTest extends TestCase { - const APCU_PREFIX = 'test'; + use PHPMock; /** * @dataProvider registerNamespaceDataProvider @@ -42,6 +43,16 @@ public function testRegisterNamespace( $useApcu = false, $apcuPrefix = null ) { + $this->getFunctionMock('Thrift\ClassLoader', 'apcu_fetch') + ->expects($useApcu ? $this->once() : $this->never()) + ->with($apcuPrefix . $class) + ->willReturn(false); + + $this->getFunctionMock('Thrift\ClassLoader', 'apcu_store') + ->expects($useApcu ? $this->once() : $this->never()) + ->with($apcuPrefix . $class, $this->anything()) + ->willReturn(true); + $loader = new ThriftClassLoader($useApcu, $apcuPrefix); foreach ($namespaces as $namespace => $paths) { $loader->registerNamespace($namespace, $paths); @@ -97,7 +108,7 @@ public function registerNamespaceDataProvider() 'class' => '\E\TestClass', 'isClassExist' => true, 'useApcu' => true, - 'apcuPrefix' => self::APCU_PREFIX, + 'apcuPrefix' => 'APCU_PREFIX', ]; } @@ -111,6 +122,16 @@ public function testRegisterDefinition( $useApcu = false, $apcuPrefix = null ) { + $this->getFunctionMock('Thrift\ClassLoader', 'apcu_fetch') + ->expects($useApcu ? $this->once() : $this->never()) + ->with($apcuPrefix . $class) + ->willReturn(false); + + $this->getFunctionMock('Thrift\ClassLoader', 'apcu_store') + ->expects($useApcu ? $this->once() : $this->never()) + ->with($apcuPrefix . $class, $this->anything()) + ->willReturn(true); + $loader = new ThriftClassLoader($useApcu, $apcuPrefix); foreach ($definitions as $namespace => $paths) { $loader->registerDefinition($namespace, $paths); @@ -191,33 +212,7 @@ public function registerDefinitionDataProvider() 'class' => '\TestValidators\TestServiceClient', 'checkInterfaceExist' => false, 'useApcu' => true, - 'apcuPrefix' => self::APCU_PREFIX, + 'apcuPrefix' => 'APCU_PREFIX', ]; } } - -namespace Thrift\ClassLoader; - -use Test\Thrift\Unit\Lib\ClassLoader\ThriftClassLoaderTest; - -if (!function_exists('apcu_fetch')) { - { - function apcu_fetch($key, &$success = null) - { - if (strpos($key, ThriftClassLoaderTest::APCU_PREFIX) === false) { - throw new \Exception('apcu_fetch error, invalid key'); - } - - return false; - } - - function apcu_store($key, $var, $ttl = 0) - { - if (strpos($key, ThriftClassLoaderTest::APCU_PREFIX) === false) { - throw new \Exception('apcu_store error, invalid key'); - } - - return false; - } - } -} diff --git a/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php index 5f7c2a25287..76ff187d69d 100644 --- a/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php +++ b/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php @@ -17,8 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.protocol */ namespace Test\Thrift\Unit\Lib\Factory; diff --git a/lib/php/test/Unit/Lib/Factory/TCompactProtocolFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TCompactProtocolFactoryTest.php index f81e789b4c5..1483c6ae2c5 100644 --- a/lib/php/test/Unit/Lib/Factory/TCompactProtocolFactoryTest.php +++ b/lib/php/test/Unit/Lib/Factory/TCompactProtocolFactoryTest.php @@ -17,8 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.protocol */ namespace Test\Thrift\Unit\Lib\Factory; diff --git a/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php index 2cb32d8d3b9..3b8b5cc44f3 100644 --- a/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php +++ b/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php @@ -17,8 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.protocol */ namespace Test\Thrift\Unit\Lib\Factory; diff --git a/lib/php/test/Unit/Lib/Factory/TJSONProtocolFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TJSONProtocolFactoryTest.php index 0685af79707..9c7055dbfbe 100644 --- a/lib/php/test/Unit/Lib/Factory/TJSONProtocolFactoryTest.php +++ b/lib/php/test/Unit/Lib/Factory/TJSONProtocolFactoryTest.php @@ -17,8 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.protocol */ namespace Test\Thrift\Unit\Lib\Factory; diff --git a/lib/php/test/Unit/Lib/Factory/TStringFuncFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TStringFuncFactoryTest.php index eb4df44d045..c6feb2c3916 100644 --- a/lib/php/test/Unit/Lib/Factory/TStringFuncFactoryTest.php +++ b/lib/php/test/Unit/Lib/Factory/TStringFuncFactoryTest.php @@ -17,12 +17,11 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.protocol */ namespace Test\Thrift\Unit\Lib\Factory; +use phpmock\phpunit\PHPMock; use PHPUnit\Framework\TestCase; use Thrift\Factory\TStringFuncFactory; use Thrift\StringFunc\Core; @@ -31,16 +30,21 @@ class TStringFuncFactoryTest extends TestCase { + use PHPMock; + /** - * @return void + * @dataProvider createDataProvider */ - public function testCreate() - { - $factory = new TStringFuncFactory(); - $stringFunc = $factory::create(); - $this->assertInstanceOf(TStringFunc::class, $stringFunc); - $this->assertInstanceOf(Mbstring::class, $stringFunc); + public function testCreate( + $mbstringFuncOverload, + $expectedClass + ) { + $this->getFunctionMock('Thrift\Factory', 'ini_get') + ->expects($this->once()) + ->with('mbstring.func_overload') + ->willReturn($mbstringFuncOverload); + $factory = new TStringFuncFactory(); /** * it is a hack to nullable the instance of TStringFuncFactory, and get a new instance based on the new ini_get value */ @@ -50,25 +54,21 @@ public function testCreate() $refInstance->setValue($factory, null); $stringFunc = $factory::create(); + $this->assertInstanceOf(TStringFunc::class, $stringFunc); - $this->assertInstanceOf(Core::class, $stringFunc); + $this->assertInstanceOf($expectedClass, $stringFunc); } -} + public function createDataProvider() + { + yield 'mbstring' => [ + 'mbstring.func_overload' => 2, + 'expected' => Mbstring::class + ]; -namespace Thrift\Factory; - -function ini_get($key) -{ - static $count = 0; - if ($key === 'mbstring.func_overload') { - if ($count === 0) { - $count++; - return 2; - } else { - return 0; - } - } else { - return \ini_get($key); + yield 'string' => [ + 'mbstring.func_overload' => 0, + 'expected' => Core::class + ]; } } diff --git a/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php index da91b64b355..a8a791ad121 100644 --- a/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php +++ b/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php @@ -17,8 +17,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * - * @package thrift.protocol */ namespace Test\Thrift\Unit\Lib\Factory; diff --git a/lib/php/test/Unit/Lib/Transport/TBufferedTransportTest.php b/lib/php/test/Unit/Lib/Transport/TBufferedTransportTest.php new file mode 100644 index 00000000000..dd6003a8541 --- /dev/null +++ b/lib/php/test/Unit/Lib/Transport/TBufferedTransportTest.php @@ -0,0 +1,286 @@ +createMock(TTransport::class); + $bufferedTransport = new TBufferedTransport($transport); + + $transport + ->expects($this->once()) + ->method('isOpen') + ->willReturn(true); + + $this->assertTrue($bufferedTransport->isOpen()); + } + + public function testOpen() + { + $transport = $this->createMock(TTransport::class); + $bufferedTransport = new TBufferedTransport($transport); + + $transport + ->expects($this->once()) + ->method('open') + ->willReturn(null); + + $this->assertNull($bufferedTransport->open()); + } + + public function testClose() + { + $transport = $this->createMock(TTransport::class); + $bufferedTransport = new TBufferedTransport($transport); + + $transport + ->expects($this->once()) + ->method('close') + ->willReturn(null); + + $this->assertNull($bufferedTransport->close()); + } + + public function testPutBack() + { + $transport = $this->createMock(TTransport::class); + $bufferedTransport = new TBufferedTransport($transport); + $bufferedTransport->putBack('test'); + + $ref = new \ReflectionClass($bufferedTransport); + $property = $ref->getProperty('rBuf_'); + $property->setAccessible(true); + $this->assertEquals('test', $property->getValue($bufferedTransport)); + + $bufferedTransport->putBack('abcde'); + $this->assertEquals('abcdetest', $property->getValue($bufferedTransport)); + } + + /** + * @dataProvider readAllDataProvider + */ + public function testReadAll( + $startBuffer, + $readLength, + $bufferReadLength, + $bufferReadResult, + $expectedBufferValue, + $expectedRead + ) { + $transport = $this->createMock(TTransport::class); + $bufferedTransport = new TBufferedTransport($transport); + $bufferedTransport->putBack($startBuffer); + + $transport + ->expects($bufferReadLength > 0 ? $this->once() : $this->never()) + ->method('readAll') + ->with($bufferReadLength) + ->willReturn($bufferReadResult); + + $this->assertEquals($expectedRead, $bufferedTransport->readAll($readLength)); + + $ref = new \ReflectionClass($bufferedTransport); + $property = $ref->getProperty('rBuf_'); + $property->setAccessible(true); + $this->assertEquals($expectedBufferValue, $property->getValue($bufferedTransport)); + } + + public function readAllDataProvider() + { + yield 'buffer empty' => [ + 'startBuffer' => '', + 'readLength' => 5, + 'bufferReadLength' => 5, + 'bufferReadResult' => '12345', + 'expectedBufferValue' => '', + 'expectedRead' => '12345', + ]; + yield 'buffer have partly loaded data' => [ + 'startBuffer' => '12345', + 'readLength' => 10, + 'bufferReadLength' => 5, + 'bufferReadResult' => '67890', + 'expectedBufferValue' => '', + 'expectedRead' => '1234567890', + ]; + yield 'buffer fully read' => [ + 'startBuffer' => '12345', + 'readLength' => 5, + 'bufferReadLength' => 0, + 'bufferReadResult' => '', + 'expectedBufferValue' => '', + 'expectedRead' => '12345', + ]; + yield 'request less data that we have in buffer' => [ + 'startBuffer' => '12345', + 'readLength' => 3, + 'bufferReadLength' => 0, + 'bufferReadResult' => '', + 'expectedBufferValue' => '45', + 'expectedRead' => '123', + ]; + } + + /** + * @dataProvider readDataProvider + */ + public function testRead( + $readBufferSize, + $startBuffer, + $readLength, + $bufferReadResult, + $expectedBufferValue, + $expectedRead + ) { + $transport = $this->createMock(TTransport::class); + $bufferedTransport = new TBufferedTransport($transport, $readBufferSize); + $bufferedTransport->putBack($startBuffer); + + $transport + ->expects(empty($startBuffer) > 0 ? $this->once() : $this->never()) + ->method('read') + ->with($readBufferSize) + ->willReturn($bufferReadResult); + + $this->assertEquals($expectedRead, $bufferedTransport->read($readLength)); + + $ref = new \ReflectionClass($bufferedTransport); + $property = $ref->getProperty('rBuf_'); + $property->setAccessible(true); + $this->assertEquals($expectedBufferValue, $property->getValue($bufferedTransport)); + } + + public function readDataProvider() + { + yield 'buffer empty' => [ + 'readBufferSize' => 10, + 'startBuffer' => '', + 'readLength' => 5, + 'bufferReadResult' => '12345', + 'expectedBufferValue' => '', + 'expectedRead' => '12345', + ]; + yield 'buffer read partly' => [ + 'readBufferSize' => 10, + 'startBuffer' => '', + 'readLength' => 5, + 'bufferReadResult' => '1234567890', + 'expectedBufferValue' => '67890', + 'expectedRead' => '12345', + ]; + yield 'buffer fully read' => [ + 'readBufferSize' => 10, + 'startBuffer' => '12345', + 'readLength' => 5, + 'bufferReadResult' => '', + 'expectedBufferValue' => '', + 'expectedRead' => '12345', + ]; + } + + /** + * @dataProvider writeDataProvider + */ + public function testWrite( + $writeBufferSize, + $writeData, + $bufferedTransportCall, + $expectedWriteBufferValue + ) { + $transport = $this->createMock(TTransport::class); + $bufferedTransport = new TBufferedTransport($transport, 512, $writeBufferSize); + + $transport + ->expects($this->exactly($bufferedTransportCall)) + ->method('write') + ->with($writeData) + ->willReturn(null); + + $this->assertNull($bufferedTransport->write($writeData)); + + $ref = new \ReflectionClass($bufferedTransport); + $property = $ref->getProperty('wBuf_'); + $property->setAccessible(true); + $this->assertEquals($expectedWriteBufferValue, $property->getValue($bufferedTransport)); + } + + public function writeDataProvider() + { + yield 'store data in buffer' => [ + 'writeBufferSize' => 10, + 'writeData' => '12345', + 'bufferedTransportCall' => 0, + 'expectedWriteBufferValue' => '12345', + ]; + yield 'send data to buffered transport' => [ + 'writeBufferSize' => 10, + 'writeData' => '12345678901', + 'bufferedTransportCall' => 1, + 'expectedWriteBufferValue' => '', + ]; + } + + /** + * @dataProvider flushDataProvider + */ + public function testFlush( + $writeBuffer + ) { + $transport = $this->createMock(TTransport::class); + $bufferedTransport = new TBufferedTransport($transport, 512, 512); + $ref = new \ReflectionClass($bufferedTransport); + $property = $ref->getProperty('wBuf_'); + $property->setAccessible(true); + $property->setValue($bufferedTransport, $writeBuffer); + + $transport + ->expects(!empty($writeBuffer) ? $this->once() : $this->never()) + ->method('write') + ->with($writeBuffer) + ->willReturn(null); + + $transport + ->expects($this->once()) + ->method('flush') + ->willReturn(null); + + $this->assertNull($bufferedTransport->flush()); + + $this->assertEquals('', $property->getValue($bufferedTransport)); + } + + public function flushDataProvider() + { + yield 'empty buffer' => [ + 'writeBuffer' => '', + ]; + yield 'not empty buffer' => [ + 'writeBuffer' => '12345', + ]; + } +} diff --git a/lib/php/test/Unit/Lib/Transport/TCurlClientTest.php b/lib/php/test/Unit/Lib/Transport/TCurlClientTest.php new file mode 100644 index 00000000000..7cd7446bb42 --- /dev/null +++ b/lib/php/test/Unit/Lib/Transport/TCurlClientTest.php @@ -0,0 +1,423 @@ +setTimeoutSecs(1000); + + $ref = new \ReflectionClass($transport); + $prop = $ref->getProperty('timeout_'); + $prop->setAccessible(true); + $this->assertEquals(1000, $prop->getValue($transport)); + } + + public function testSetConnectionTimeoutSecs() + { + $host = 'localhost'; + $transport = new TCurlClient($host); + $transport->setConnectionTimeoutSecs(1000); + + $ref = new \ReflectionClass($transport); + $prop = $ref->getProperty('connectionTimeout_'); + $prop->setAccessible(true); + $this->assertEquals(1000, $prop->getValue($transport)); + } + + public function testIsOpen() + { + $host = 'localhost'; + $transport = new TCurlClient($host); + $this->assertTrue($transport->isOpen()); + } + + public function testOpen() + { + $host = 'localhost'; + $transport = new TCurlClient($host); + $this->assertNull($transport->open()); + } + + public function testClose() + { + $host = 'localhost'; + $transport = new TCurlClient($host); + + $ref = new \ReflectionClass($transport); + $propRequest = $ref->getProperty('request_'); + $propRequest->setAccessible(true); + $propRequest->setValue($transport, 'testRequest'); + $propResponse = $ref->getProperty('response_'); + $propResponse->setAccessible(true); + $propResponse->setValue($transport, 'testResponse'); + + $this->assertNull($transport->close()); + $this->assertEmpty($propRequest->getValue($transport)); + $this->assertEmpty($propResponse->getValue($transport)); + } + + public function testRead() + { + $host = 'localhost'; + $transport = new TCurlClient($host); + + $ref = new \ReflectionClass($transport); + $propResponse = $ref->getProperty('response_'); + $propResponse->setAccessible(true); + $propResponse->setValue($transport, '1234567890'); + + $response = $transport->read(5); + $this->assertEquals('12345', $response); + $this->assertEquals('67890', $propResponse->getValue($transport)); + + $response = $transport->read(5); + $this->assertEquals('67890', $response); + # The response does not cleaned after reading full answer, maybe it should be fixed + $this->assertEquals('67890', $propResponse->getValue($transport)); + } + + public function testReadAll() + { + $host = 'localhost'; + $transport = new TCurlClient($host); + + $ref = new \ReflectionClass($transport); + $propResponse = $ref->getProperty('response_'); + $propResponse->setAccessible(true); + $propResponse->setValue($transport, '1234567890'); + + $response = $transport->readAll(5); + $this->assertEquals('12345', $response); + $this->assertEquals('67890', $propResponse->getValue($transport)); + } + + public function testReadAll_THRIFT_4656() + { + $host = 'localhost'; + $transport = new TCurlClient($host); + + $ref = new \ReflectionClass($transport); + $propResponse = $ref->getProperty('response_'); + $propResponse->setAccessible(true); + $propResponse->setValue($transport, ''); + + $this->expectException(TTransportException::class); + $this->expectExceptionMessage('TCurlClient could not read 5 bytes'); + $this->expectExceptionCode(TTransportException::UNKNOWN); + + $transport->readAll(5); + } + + public function testWrite() + { + $host = 'localhost'; + $transport = new TCurlClient($host); + + $ref = new \ReflectionClass($transport); + $propRequest = $ref->getProperty('request_'); + $propRequest->setAccessible(true); + $propRequest->setValue($transport, '1234567890'); + + $transport->write('12345'); + $this->assertEquals('123456789012345', $propRequest->getValue($transport)); + } + + public function testAddHeaders() + { + $host = 'localhost'; + $transport = new TCurlClient($host); + + $ref = new \ReflectionClass($transport); + $propRequest = $ref->getProperty('headers_'); + $propRequest->setAccessible(true); + $propRequest->setValue($transport, ['test' => '1234567890']); + + $transport->addHeaders(['test2' => '12345']); + $this->assertEquals(['test' => '1234567890', 'test2' => '12345'], $propRequest->getValue($transport)); + } + + /** + * @dataProvider flushDataProvider + */ + public function testFlush( + $host, + $port, + $uri, + $scheme, + $headers, + $request, + $timeout, + $connectionTimeout, + $curlSetOptCalls, + $response, + $responseError, + $responseCode, + $expectedException = null, + $expectedMessage = null, + $expectedCode = null + ) { + $this->getFunctionMock('Thrift\\Transport', 'register_shutdown_function') + ->expects($this->once()) + ->with( + $this->callback( + function ($arg) { + return is_array( + $arg + ) && $arg[0] === 'Thrift\\Transport\\TCurlClient' && $arg[1] === 'closeCurlHandle'; + } + ) + ); + $this->getFunctionMock('Thrift\\Transport', 'curl_init') + ->expects($this->once()); + + $this->getFunctionMock('Thrift\\Transport', 'curl_setopt') + ->expects($this->any()) + ->withConsecutive(...$curlSetOptCalls) + ->willReturn(true); + + $this->getFunctionMock('Thrift\\Transport', 'curl_exec') + ->expects($this->once()) + ->with($this->anything()) + ->willReturn($response); + + $this->getFunctionMock('Thrift\\Transport', 'curl_error') + ->expects($this->once()) + ->with($this->anything()) + ->willReturn($responseError); + + $this->getFunctionMock('Thrift\\Transport', 'curl_getinfo') + ->expects($this->once()) + ->with($this->anything(), CURLINFO_HTTP_CODE) + ->willReturn($responseCode); + + if (!is_null($expectedException)) { + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedMessage); + $this->expectExceptionCode($expectedCode); + + $this->getFunctionMock('Thrift\\Transport', 'curl_close') + ->expects($this->once()) + ->with($this->anything()); + } + + $transport = new TCurlClient($host, $port, $uri, $scheme); + if (!empty($headers)) { + $transport->addHeaders($headers); + } + $transport->write($request); + if (!empty($timeout)) { + $transport->setTimeoutSecs($timeout); + } + if (!empty($connectionTimeout)) { + $transport->setConnectionTimeoutSecs($connectionTimeout); + } + + $transport->flush(); + } + + public function flushDataProvider() + { + $request = 'request'; + + $default = [ + 'host' => 'localhost', + 'port' => 80, + 'uri' => '', + 'scheme' => 'http', + 'headers' => [], + 'request' => $request, + 'timeout' => null, + 'connectionTimeout' => null, + 'curlSetOptCalls' => [ + [$this->anything(), CURLOPT_RETURNTRANSFER, true], + [$this->anything(), CURLOPT_USERAGENT, 'PHP/TCurlClient'], + [$this->anything(), CURLOPT_CUSTOMREQUEST, 'POST'], + [$this->anything(), CURLOPT_FOLLOWLOCATION, true], + [$this->anything(), CURLOPT_MAXREDIRS, 1], + [ + $this->anything(), + CURLOPT_HTTPHEADER, + [ + 'Accept: application/x-thrift', + 'Content-Type: application/x-thrift', + 'Content-Length: ' . strlen($request), + ], + ], + [$this->anything(), CURLOPT_POSTFIELDS, $request], + [$this->anything(), CURLOPT_URL, 'http://localhost'], + ], + 'response' => 'response', + 'responseError' => '', + 'responseCode' => 200, + ]; + + yield 'default' => $default; + yield 'additionalHeaders' => array_merge( + $default, + [ + 'headers' => ['test' => '1234567890'], + 'curlSetOptCalls' => [ + [$this->anything(), CURLOPT_RETURNTRANSFER, true], + [$this->anything(), CURLOPT_USERAGENT, 'PHP/TCurlClient'], + [$this->anything(), CURLOPT_CUSTOMREQUEST, 'POST'], + [$this->anything(), CURLOPT_FOLLOWLOCATION, true], + [$this->anything(), CURLOPT_MAXREDIRS, 1], + [ + $this->anything(), + CURLOPT_HTTPHEADER, + [ + 'Accept: application/x-thrift', + 'Content-Type: application/x-thrift', + 'Content-Length: ' . strlen($request), + 'test: 1234567890', + ], + ], + [$this->anything(), CURLOPT_POSTFIELDS, $request], + [$this->anything(), CURLOPT_URL, 'http://localhost'], + ], + ] + ); + yield 'uri' => array_merge( + $default, + [ + 'uri' => 'test1234567890', + 'curlSetOptCalls' => [ + [$this->anything(), CURLOPT_RETURNTRANSFER, true], + [$this->anything(), CURLOPT_USERAGENT, 'PHP/TCurlClient'], + [$this->anything(), CURLOPT_CUSTOMREQUEST, 'POST'], + [$this->anything(), CURLOPT_FOLLOWLOCATION, true], + [$this->anything(), CURLOPT_MAXREDIRS, 1], + [ + $this->anything(), + CURLOPT_HTTPHEADER, + [ + 'Accept: application/x-thrift', + 'Content-Type: application/x-thrift', + 'Content-Length: ' . strlen($request), + ], + ], + [$this->anything(), CURLOPT_POSTFIELDS, $request], + [$this->anything(), CURLOPT_URL, 'http://localhost/test1234567890'], + ], + ] + ); + yield 'timeout' => array_merge( + $default, + [ + 'timeout' => 10, + 'connectionTimeout' => 10, + 'curlSetOptCalls' => [ + [$this->anything(), CURLOPT_RETURNTRANSFER, true], + [$this->anything(), CURLOPT_USERAGENT, 'PHP/TCurlClient'], + [$this->anything(), CURLOPT_CUSTOMREQUEST, 'POST'], + [$this->anything(), CURLOPT_FOLLOWLOCATION, true], + [$this->anything(), CURLOPT_MAXREDIRS, 1], + [ + $this->anything(), + CURLOPT_HTTPHEADER, + [ + 'Accept: application/x-thrift', + 'Content-Type: application/x-thrift', + 'Content-Length: ' . strlen($request), + ], + ], + [$this->anything(), CURLOPT_TIMEOUT, 10], + [$this->anything(), CURLOPT_CONNECTTIMEOUT, 10], + [$this->anything(), CURLOPT_POSTFIELDS, $request], + [$this->anything(), CURLOPT_URL, 'http://localhost'], + ], + ] + ); + yield 'timeout msec' => array_merge( + $default, + [ + 'timeout' => 0.1, + 'connectionTimeout' => 0.1, + 'curlSetOptCalls' => [ + [$this->anything(), CURLOPT_RETURNTRANSFER, true], + [$this->anything(), CURLOPT_USERAGENT, 'PHP/TCurlClient'], + [$this->anything(), CURLOPT_CUSTOMREQUEST, 'POST'], + [$this->anything(), CURLOPT_FOLLOWLOCATION, true], + [$this->anything(), CURLOPT_MAXREDIRS, 1], + [ + $this->anything(), + CURLOPT_HTTPHEADER, + [ + 'Accept: application/x-thrift', + 'Content-Type: application/x-thrift', + 'Content-Length: ' . strlen($request), + ], + ], + [$this->anything(), CURLOPT_TIMEOUT_MS, 100], + [$this->anything(), CURLOPT_CONNECTTIMEOUT_MS, 100], + [$this->anything(), CURLOPT_POSTFIELDS, $request], + [$this->anything(), CURLOPT_URL, 'http://localhost'], + ], + ] + ); + yield 'curl_exec return false' => array_merge( + $default, + [ + 'response' => false, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'TCurlClient: Could not connect to http://localhost', + 'expectedCode' => TTransportException::UNKNOWN, + ] + ); + yield 'curl_exec return response code 403' => array_merge( + $default, + [ + 'responseError' => 'Access denied', + 'responseCode' => 403, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'TCurlClient: Could not connect to http://localhost, Access denied, HTTP status code: 403', + 'expectedCode' => TTransportException::UNKNOWN, + ] + ); + } + + public function testCloseCurlHandle() + { + $this->getFunctionMock('Thrift\\Transport', 'curl_close') + ->expects($this->once()) + ->with('testHandle'); + + $transport = new TCurlClient('localhost'); + $ref = new \ReflectionClass($transport); + $prop = $ref->getProperty('curlHandle'); + $prop->setAccessible(true); + $prop->setValue($transport, 'testHandle'); + + $transport::closeCurlHandle(); + } +} diff --git a/lib/php/test/Unit/Lib/Transport/TFramedTransportTest.php b/lib/php/test/Unit/Lib/Transport/TFramedTransportTest.php new file mode 100644 index 00000000000..2607ddbf8b6 --- /dev/null +++ b/lib/php/test/Unit/Lib/Transport/TFramedTransportTest.php @@ -0,0 +1,240 @@ +createMock(TTransport::class); + $framedTransport = new TFramedTransport($transport); + + $transport + ->expects($this->once()) + ->method('isOpen') + ->willReturn(true); + + $this->assertTrue($framedTransport->isOpen()); + } + + public function testOpen() + { + $transport = $this->createMock(TTransport::class); + $framedTransport = new TFramedTransport($transport); + + $transport + ->expects($this->once()) + ->method('open') + ->willReturn(null); + + $this->assertNull($framedTransport->open()); + } + + public function testClose() + { + $transport = $this->createMock(TTransport::class); + $framedTransport = new TFramedTransport($transport); + + $transport + ->expects($this->once()) + ->method('close') + ->willReturn(null); + + $this->assertNull($framedTransport->close()); + } + + public function testPutBack() + { + $transport = $this->createMock(TTransport::class); + $framedTransport = new TFramedTransport($transport); + $framedTransport->putBack('test'); + + $ref = new \ReflectionClass($framedTransport); + $property = $ref->getProperty('rBuf_'); + $property->setAccessible(true); + $this->assertEquals('test', $property->getValue($framedTransport)); + + $framedTransport->putBack('abcde'); + $this->assertEquals('abcdetest', $property->getValue($framedTransport)); + } + + /** + * @dataProvider readDataProvider + */ + public function testRead( + $readAllowed, + $readBuffer, + $lowLevelTransportReadResult, + $lowLevelTransportReadAllParams, + $lowLevelTransportReadAllResult, + $readLength, + $expectedReadResult + ) { + $transport = $this->createMock(TTransport::class); + $framedTransport = new TFramedTransport($transport, $readAllowed); + $framedTransport->putBack($readBuffer); + + $transport + ->expects($readAllowed ? $this->never() : $this->once()) + ->method('read') + ->with($readLength) + ->willReturn($lowLevelTransportReadResult); + + $transport + ->expects($this->exactly(count($lowLevelTransportReadAllParams))) + ->method('readAll') + ->withConsecutive(...$lowLevelTransportReadAllParams) + ->willReturnOnConsecutiveCalls(...$lowLevelTransportReadAllResult); + + $this->assertEquals($expectedReadResult, $framedTransport->read($readLength)); + } + + public function readDataProvider() + { + yield 'read not allowed' => [ + 'readAllowed' => false, + 'readBuffer' => '', + 'lowLevelTransportReadResult' => '12345', + 'lowLevelTransportReadAllParams' => [], + 'lowLevelTransportReadAllResult' => [], + 'readLength' => 5, + 'expectedReadResult' => '12345', + ]; + yield 'read fully buffered item' => [ + 'readAllowed' => true, + 'readBuffer' => '', + 'lowLevelTransportReadResult' => '', + 'lowLevelTransportReadAllParams' => [[4], [5]], + 'lowLevelTransportReadAllResult' => [pack('N', '5'), '12345'], + 'readLength' => 5, + 'expectedReadResult' => '12345', + ]; + yield 'read partly buffered item' => [ + 'readAllowed' => true, + 'readBuffer' => '', + 'lowLevelTransportReadResult' => '', + 'lowLevelTransportReadAllParams' => [[4], [10]], + 'lowLevelTransportReadAllResult' => [pack('N', '10'), '1234567890'], + 'readLength' => 5, + 'expectedReadResult' => '12345', + ]; + } + + /** + * @dataProvider writeDataProvider + */ + public function testWrite( + $writeAllowed, + $writeData, + $writeLength, + $expectedWriteBufferValue + ) { + $transport = $this->createMock(TTransport::class); + $framedTransport = new TFramedTransport($transport, true, $writeAllowed); + + $transport + ->expects($writeAllowed ? $this->never() : $this->once()) + ->method('write') + ->with('12345', 5) + ->willReturn(5); + + $framedTransport->write($writeData, $writeLength); + + $ref = new \ReflectionClass($framedTransport); + $property = $ref->getProperty('wBuf_'); + $property->setAccessible(true); + $this->assertEquals($expectedWriteBufferValue, $property->getValue($framedTransport)); + } + + public function writeDataProvider() + { + yield 'write not allowed' => [ + 'writeAllowed' => false, + 'writeData' => '12345', + 'writeLength' => 5, + 'expectedWriteBufferValue' => '', + ]; + yield 'write full' => [ + 'writeAllowed' => true, + 'writeData' => '12345', + 'writeLength' => 5, + 'expectedWriteBufferValue' => '12345', + ]; + yield 'write partly' => [ + 'writeAllowed' => true, + 'writeData' => '1234567890', + 'writeLength' => 5, + 'expectedWriteBufferValue' => '12345', + ]; + } + + /** + * @dataProvider flushDataProvider + */ + public function testFlush( + $writeAllowed, + $writeBuffer, + $lowLevelTransportWrite + ) { + $transport = $this->createMock(TTransport::class); + $framedTransport = new TFramedTransport($transport, true, $writeAllowed); + $ref = new \ReflectionClass($framedTransport); + $property = $ref->getProperty('wBuf_'); + $property->setAccessible(true); + $property->setValue($framedTransport, $writeBuffer); + + $transport + ->expects($this->once()) + ->method('flush'); + + $transport + ->expects($writeAllowed && !empty($writeBuffer) ? $this->once() : $this->never()) + ->method('write') + ->with($lowLevelTransportWrite) + ->willReturn(null); + + $this->assertNull($framedTransport->flush()); + } + + public function flushDataProvider() + { + yield 'write not allowed' => [ + 'writeAllowed' => false, + 'writeBuffer' => '12345', + 'lowLevelTransportWrite' => '', + ]; + yield 'empty buffer' => [ + 'writeAllowed' => true, + 'writeBuffer' => '', + 'lowLevelTransportWrite' => '', + ]; + yield 'write full' => [ + 'writeAllowed' => true, + 'writeBuffer' => '12345', + 'lowLevelTransportWrite' => pack('N', strlen('12345')) . '12345', + ]; + } +} diff --git a/lib/php/test/Unit/Lib/Transport/THttpClientTest.php b/lib/php/test/Unit/Lib/Transport/THttpClientTest.php new file mode 100644 index 00000000000..ce6813c1bd1 --- /dev/null +++ b/lib/php/test/Unit/Lib/Transport/THttpClientTest.php @@ -0,0 +1,332 @@ +setTimeoutSecs(1000); + + $ref = new \ReflectionClass($transport); + $prop = $ref->getProperty('timeout_'); + $prop->setAccessible(true); + $this->assertEquals(1000, $prop->getValue($transport)); + } + + public function testIsOpen() + { + $host = 'localhost'; + $transport = new THttpClient($host); + $this->assertTrue($transport->isOpen()); + } + + public function testOpen() + { + $host = 'localhost'; + $transport = new THttpClient($host); + $this->assertNull($transport->open()); + } + + public function testClose() + { + $handle = fopen('php://temp', 'r+'); + $this->getFunctionMock('Thrift\\Transport', 'fclose') + ->expects($this->once()) + ->with($handle) + ->willReturn(true); + + $host = 'localhost'; + $transport = new THttpClient($host); + + $ref = new \ReflectionClass($transport); + $propRequest = $ref->getProperty('handle_'); + $propRequest->setAccessible(true); + $propRequest->setValue($transport, $handle); + + $this->assertNull($transport->close()); + $this->assertNull($propRequest->getValue($transport)); + } + + /** + * @dataProvider readDataProvider + */ + public function testRead( + $readLen, + $freadResult, + $streamGetMetaDataResult, + $expectedResult, + $expectedException, + $expectedExceptionMessage, + $expectedExceptionCode + ) { + $handle = fopen('php://temp', 'r+'); + $this->getFunctionMock('Thrift\\Transport', 'fread') + ->expects($this->once()) + ->with($handle, $readLen) + ->willReturn($freadResult); + + $this->getFunctionMock('Thrift\\Transport', 'stream_get_meta_data') + ->expects(!empty($streamGetMetaDataResult) ? $this->once() : $this->never()) + ->with($handle) + ->willReturn($streamGetMetaDataResult); + + if ($expectedException) { + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedExceptionMessage); + $this->expectExceptionCode($expectedExceptionCode); + } + + $host = 'localhost'; + $transport = new THttpClient($host); + + $ref = new \ReflectionClass($transport); + $propRequest = $ref->getProperty('handle_'); + $propRequest->setAccessible(true); + $propRequest->setValue($transport, $handle); + + $this->assertEquals($expectedResult, $transport->read($readLen)); + } + + public function readDataProvider() + { + yield 'read success' => [ + 'readLen' => 10, + 'freadResult' => '1234567890', + 'streamGetMetaDataResult' => [], + 'expectedResult' => '1234567890', + 'expectedException' => null, + 'expectedExceptionMessage' => null, + 'expectedExceptionCode' => null, + ]; + yield 'read failed' => [ + 'readLen' => 10, + 'freadResult' => false, + 'streamGetMetaDataResult' => [ + 'timed_out' => false, + ], + 'expectedResult' => '', + 'expectedException' => TTransportException::class, + 'expectedExceptionMessage' => 'THttpClient: Could not read 10 bytes from localhost:80', + 'expectedExceptionCode' => TTransportException::UNKNOWN, + ]; + yield 'read timeout' => [ + 'readLen' => 10, + 'freadResult' => '', + 'streamGetMetaDataResult' => [ + 'timed_out' => true, + ], + 'expectedResult' => '', + 'expectedException' => TTransportException::class, + 'expectedExceptionMessage' => 'THttpClient: timed out reading 10 bytes from localhost:80', + 'expectedExceptionCode' => TTransportException::TIMED_OUT, + ]; + } + + public function testWrite() + { + $host = 'localhost'; + $transport = new THttpClient($host); + + $ref = new \ReflectionClass($transport); + $prop = $ref->getProperty('buf_'); + $prop->setAccessible(true); + + $transport->write('1234567890'); + + $this->assertEquals('1234567890', $prop->getValue($transport)); + } + + /** + * @dataProvider flushDataProvider + */ + public function testFlush( + $host, + $port, + $uri, + $scheme, + $context, + $headers, + $timeout, + $streamContextOptions, + $streamContext, + $fopenResult, + $expectedHost, + $expectedUri, + $expectedException, + $expectedExceptionMessage, + $expectedExceptionCode + ) { + $this->getFunctionMock('Thrift\\Transport', 'stream_context_create') + ->expects($this->once()) + ->with($streamContextOptions) + ->willReturn($streamContext); + + $this->getFunctionMock('Thrift\\Transport', 'fopen') + ->expects($this->once()) + ->with( + $scheme . '://' . $expectedHost . $expectedUri, + 'r', + false, + $streamContext + )->willReturn($fopenResult); + + if ($expectedException) { + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedExceptionMessage); + $this->expectExceptionCode($expectedExceptionCode); + } + + $transport = new THttpClient($host, $port, $uri, $scheme, $context); + if (!empty($headers)) { + $transport->addHeaders($headers); + } + if (!empty($timeout)) { + $transport->setTimeoutSecs($timeout); + } + + $this->assertNull($transport->flush()); + } + + public function flushDataProvider() + { + $default = [ + 'host' => 'localhost', + 'port' => '80', + 'uri' => '', + 'scheme' => 'http', + 'context' => [], + 'headers' => [], + 'timeout' => null, + 'streamContextOptions' => [ + 'http' => [ + 'method' => 'POST', + 'header' => "Host: localhost\r\n" . + "Accept: application/x-thrift\r\n" . + "User-Agent: PHP/THttpClient\r\n" . + "Content-Type: application/x-thrift\r\n" . + "Content-Length: 0", + 'content' => '', + 'max_redirects' => 1, + ], + ], + 'streamContext' => fopen('php://temp', 'r+'), + 'fopenResult' => fopen('php://memory', 'r+'), + 'expectedHost' => 'localhost', + 'expectedUri' => '', + 'expectedException' => '', + 'expectedExceptionMessage' => '', + 'expectedExceptionCode' => '', + ]; + + yield 'success' => $default; + yield 'additionalHeaders' => array_merge( + $default, + [ + 'headers' => [ + 'X-Test-Header' => 'test', + ], + 'streamContextOptions' => [ + 'http' => [ + 'method' => 'POST', + 'header' => "Host: localhost\r\n" . + "Accept: application/x-thrift\r\n" . + "User-Agent: PHP/THttpClient\r\n" . + "Content-Type: application/x-thrift\r\n" . + "Content-Length: 0\r\n" . + "X-Test-Header: test", + 'content' => '', + 'max_redirects' => 1, + ], + ], + ] + ); + yield 'timeout' => array_merge( + $default, + [ + 'timeout' => 1000, + 'streamContextOptions' => [ + 'http' => [ + 'method' => 'POST', + 'header' => "Host: localhost\r\n" . + "Accept: application/x-thrift\r\n" . + "User-Agent: PHP/THttpClient\r\n" . + "Content-Type: application/x-thrift\r\n" . + "Content-Length: 0", + 'content' => '', + 'max_redirects' => 1, + 'timeout' => 1000, + ], + ], + ] + ); + yield 'fopenFailed' => array_merge( + $default, + [ + 'host' => 'localhost', + 'port' => 8080, + 'uri' => 'test', + 'expectedHost' => 'localhost:8080', + 'expectedUri' => '/test', + 'streamContextOptions' => [ + 'http' => [ + 'method' => 'POST', + 'header' => "Host: localhost:8080\r\n" . + "Accept: application/x-thrift\r\n" . + "User-Agent: PHP/THttpClient\r\n" . + "Content-Type: application/x-thrift\r\n" . + "Content-Length: 0", + 'content' => '', + 'max_redirects' => 1, + ], + ], + 'fopenResult' => false, + 'expectedException' => TTransportException::class, + 'expectedExceptionMessage' => 'THttpClient: Could not connect to localhost:8080/test', + 'expectedExceptionCode' => TTransportException::NOT_OPEN, + ] + ); + } + + public function testAddHeaders() + { + $host = 'localhost'; + $transport = new THttpClient($host); + + $ref = new \ReflectionClass($transport); + $propRequest = $ref->getProperty('headers_'); + $propRequest->setAccessible(true); + $propRequest->setValue($transport, ['test' => '1234567890']); + + $transport->addHeaders(['test2' => '12345']); + $this->assertEquals(['test' => '1234567890', 'test2' => '12345'], $propRequest->getValue($transport)); + } +} diff --git a/lib/php/test/Unit/Lib/Transport/TMemoryBufferTest.php b/lib/php/test/Unit/Lib/Transport/TMemoryBufferTest.php new file mode 100644 index 00000000000..06f0012ede5 --- /dev/null +++ b/lib/php/test/Unit/Lib/Transport/TMemoryBufferTest.php @@ -0,0 +1,143 @@ +assertTrue($transport->isOpen()); + } + + public function testOpen() + { + $transport = new TMemoryBuffer(); + $this->assertNull($transport->open()); + } + + public function testClose() + { + $transport = new TMemoryBuffer(); + $this->assertNull($transport->close()); + } + + public function testReadEmptyBuffer() + { + $transport = new TMemoryBuffer(); + $this->expectException(\Thrift\Exception\TTransportException::class); + $this->expectExceptionMessage("TMemoryBuffer: Could not read 1 bytes from buffer."); + $this->expectExceptionCode(TTransportException::UNKNOWN); + $transport->read(1); + } + + /** + * @dataProvider readDataProvider + */ + public function testRead( + $startBuffer, + $readLength, + $expectedRead, + $expectedBuffer + ) { + $transport = new TMemoryBuffer($startBuffer); + $this->assertEquals($expectedRead, $transport->read($readLength)); + $this->assertEquals($expectedBuffer, $transport->getBuffer()); + } + + public function readDataProvider() + { + yield 'Read part of buffer' => [ + 'startBuffer' => '1234567890', + 'readLength' => 5, + 'expectedRead' => '12345', + 'expectedBuffer' => '67890', + ]; + yield 'Read part of buffer UTF' => [ + 'startBuffer' => 'Slovenščina', + 'readLength' => 6, + 'expectedRead' => 'Sloven', + 'expectedBuffer' => 'ščina', + ]; + yield 'Read part of buffer UTF 2' => [ + 'startBuffer' => 'Українська', + 'readLength' => 6, + 'expectedRead' => 'Укр', + 'expectedBuffer' => 'аїнська', + ]; + yield 'Read full' => [ + 'startBuffer' => '123456789', + 'readLength' => 10, + 'expectedRead' => '123456789', + 'expectedBuffer' => '', + ]; + } + + /** + * @dataProvider writeDataProvider + */ + public function testWrite( + $startBuffer, + $writeData, + $expectedBuffer + ) { + $transport = new TMemoryBuffer($startBuffer); + $transport->write($writeData); + $this->assertEquals($expectedBuffer, $transport->getBuffer()); + } + + public function writeDataProvider() + { + yield 'empty start buffer' => [ + 'startBuffer' => '', + 'writeData' => '12345', + 'expectedBuffer' => '12345', + ]; + yield 'not empty start buffer' => [ + 'startBuffer' => '67890', + 'writeData' => '12345', + 'expectedBuffer' => '6789012345', + ]; + yield 'not empty start buffer UTF' => [ + 'startBuffer' => 'Slovenščina', + 'writeData' => 'Українська', + 'expectedBuffer' => 'SlovenščinaУкраїнська', + ]; + } + + public function testAvailable() + { + $transport = new TMemoryBuffer('12345'); + $this->assertEquals('5', $transport->available()); + } + + public function testPutBack() + { + $transport = new TMemoryBuffer('12345'); + $transport->putBack('67890'); + $this->assertEquals('6789012345', $transport->getBuffer()); + } +} diff --git a/lib/php/test/Unit/Lib/Transport/TNullTransportTest.php b/lib/php/test/Unit/Lib/Transport/TNullTransportTest.php new file mode 100644 index 00000000000..044c703571c --- /dev/null +++ b/lib/php/test/Unit/Lib/Transport/TNullTransportTest.php @@ -0,0 +1,62 @@ +assertTrue($transport->isOpen()); + } + + public function testOpen() + { + $transport = new TNullTransport(); + $this->assertNull($transport->open()); + } + + public function testClose() + { + $transport = new TNullTransport(); + $this->assertNull($transport->close()); + } + + public function testRead() + { + $transport = new TNullTransport(); + $this->expectException(TTransportException::class); + $this->expectExceptionMessage("Can't read from TNullTransport."); + $this->expectExceptionCode(0); + $transport->read(1); + } + + public function testWrite() + { + $transport = new TNullTransport(); + $this->assertNull($transport->write('test')); + } +} diff --git a/lib/php/test/Unit/Lib/Transport/TPhpStreamTest.php b/lib/php/test/Unit/Lib/Transport/TPhpStreamTest.php new file mode 100644 index 00000000000..c2f950c106b --- /dev/null +++ b/lib/php/test/Unit/Lib/Transport/TPhpStreamTest.php @@ -0,0 +1,296 @@ + $result) { + $fopenResult[$num] = $result ? fopen(...$result) : $result; + } + + $this->getFunctionMock('Thrift\Transport', 'php_sapi_name') + ->expects(!empty($sapiName) ? $this->once() : $this->never()) + ->willReturn($sapiName); + + $this->getFunctionMock('Thrift\Transport', 'fopen') + ->expects($this->exactly(count($fopenResult))) + ->withConsecutive(...$fopenParams) + ->willReturnOnConsecutiveCalls(...$fopenResult); + + if ($expectedException) { + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedExceptionMessage); + $this->expectExceptionCode($expectedExceptionCode); + } + + $transport = new TPhpStream($mode); + $transport->open(); + } + + public function fopenDataProvider() + { + yield 'readCli' => [ + 'mode' => TPhpStream::MODE_R, + 'sapiName' => 'cli', + 'fopenParams' => [['php://stdin', 'r']], + 'fopenResult' => [['php://temp', 'r']], + 'expectedException' => null, + 'expectedExceptionMessage' => '', + 'expectedExceptionCode' => 0, + ]; + yield 'readNotCli' => [ + 'mode' => TPhpStream::MODE_R, + 'sapiName' => 'apache', + 'fopenParams' => [['php://input', 'r']], + 'fopenResult' => [['php://temp', 'r']], + 'expectedException' => null, + 'expectedExceptionMessage' => '', + 'expectedExceptionCode' => 0, + ]; + yield 'write' => [ + 'mode' => TPhpStream::MODE_W, + 'sapiName' => '', + 'fopenParams' => [['php://output', 'w']], + 'fopenResult' => [['php://temp', 'w']], + 'expectedException' => null, + 'expectedExceptionMessage' => '', + 'expectedExceptionCode' => 0, + ]; + yield 'read and write' => [ + 'mode' => TPhpStream::MODE_R | TPhpStream::MODE_W, + 'sapiName' => 'cli', + 'fopenParams' => [['php://stdin', 'r'], ['php://output', 'w']], + 'fopenResult' => [['php://temp', 'r'], ['php://temp', 'w']], + 'expectedException' => null, + 'expectedExceptionMessage' => '', + 'expectedExceptionCode' => 0, + ]; + yield 'read exception' => [ + 'mode' => TPhpStream::MODE_R, + 'sapiName' => 'cli', + 'fopenParams' => [['php://stdin', 'r']], + 'fopenResult' => [false], + 'expectedException' => TException::class, + 'expectedExceptionMessage' => 'TPhpStream: Could not open php://input', + #should depend on php_sapi_name result + 'expectedExceptionCode' => 0, + ]; + yield 'write exception' => [ + 'mode' => TPhpStream::MODE_W, + 'sapiName' => '', + 'fopenParams' => [['php://output', 'w']], + 'fopenResult' => [false], + 'expectedException' => TException::class, + 'expectedExceptionMessage' => 'TPhpStream: Could not open php://output', + 'expectedExceptionCode' => 0, + ]; + } + + /** + * @dataProvider closeDataProvider + */ + public function testClose( + $mode, + $fopenParams, + $fopenResult + ) { + #due to the running tests in separate process we could not open stream in data provider, so we need to do it here + foreach ($fopenResult as $num => $result) { + $fopenResult[$num] = $result ? fopen(...$result) : $result; + } + + $this->getFunctionMock('Thrift\Transport', 'fopen') + ->expects($this->exactly(count($fopenParams))) + ->withConsecutive(...$fopenParams) + ->willReturnOnConsecutiveCalls(...$fopenResult); + + $this->getFunctionMock('Thrift\Transport', 'fclose') + ->expects($this->exactly(count($fopenParams))) + ->with( + $this->callback(function ($stream) { + return is_resource($stream); + }) + ) + ->willReturn(true); + + $transport = new TPhpStream($mode); + $transport->open(); + $this->assertTrue($transport->isOpen()); + + $transport->close(); + $this->assertFalse($transport->isOpen()); + } + + public function closeDataProvider() + { + $read = ['php://temp', 'r']; + $write = ['php://temp', 'w']; + yield 'read' => [ + 'mode' => TPhpStream::MODE_R, + 'fopenParams' => [['php://stdin', 'r']], + 'fopenResult' => [$read], + ]; + yield 'write' => [ + 'mode' => TPhpStream::MODE_W, + 'fopenParams' => [['php://output', 'w']], + 'fopenResult' => [$write], + ]; + yield 'read and write' => [ + 'mode' => TPhpStream::MODE_R | TPhpStream::MODE_W, + 'fopenParams' => [['php://stdin', 'r'], ['php://output', 'w']], + 'fopenResult' => [$read, $write], + ]; + } + + /** + * @dataProvider readDataProvider + */ + public function testRead( + $freadResult, + $expectedResult, + $expectedException, + $expectedExceptionMessage, + $expectedExceptionCode + ) { + $this->getFunctionMock('Thrift\Transport', 'fread') + ->expects($this->once()) + ->with($this->anything(), 5) + ->willReturn($freadResult); + + if ($expectedException) { + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedExceptionMessage); + $this->expectExceptionCode($expectedExceptionCode); + } + + $transport = new TPhpStream(TPhpStream::MODE_R); + $this->assertEquals($expectedResult, $transport->read(5)); + } + + public function readDataProvider() + { + yield 'success' => [ + 'freadResult' => '12345', + 'expectedResult' => '12345', + 'expectedException' => null, + 'expectedExceptionMessage' => '', + 'expectedExceptionCode' => 0, + ]; + yield 'empty' => [ + 'freadResult' => '', + 'expectedResult' => '', + 'expectedException' => TException::class, + 'expectedExceptionMessage' => 'TPhpStream: Could not read 5 bytes', + 'expectedExceptionCode' => 0, + ]; + yield 'false' => [ + 'freadResult' => false, + 'expectedResult' => false, + 'expectedException' => TException::class, + 'expectedExceptionMessage' => 'TPhpStream: Could not read 5 bytes', + 'expectedExceptionCode' => 0, + ]; + } + + /** + * @dataProvider writeDataProvider + */ + public function testWrite( + $buf, + $fwriteParams, + $fwriteResult, + $expectedException, + $expectedExceptionMessage, + $expectedExceptionCode + ) { + $this->getFunctionMock('Thrift\Transport', 'fwrite') + ->expects($this->exactly(count($fwriteParams))) + ->withConsecutive(...$fwriteParams) + ->willReturnOnConsecutiveCalls(...$fwriteResult); + + if ($expectedException) { + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedExceptionMessage); + $this->expectExceptionCode($expectedExceptionCode); + } + + $transport = new TPhpStream(TPhpStream::MODE_W); + $transport->write($buf); + } + + public function writeDataProvider() + { + yield 'success' => [ + 'buf' => '12345', + 'fwriteParams' => [[$this->anything(), '12345']], + 'fwriteResult' => [5], + 'expectedException' => null, + 'expectedExceptionMessage' => '', + 'expectedExceptionCode' => 0, + ]; + yield 'several iteration' => [ + 'buf' => '1234567890', + 'fwriteParams' => [[$this->anything(), '1234567890'], [$this->anything(), '67890']], + 'fwriteResult' => [5, 5], + 'expectedException' => null, + 'expectedExceptionMessage' => '', + 'expectedExceptionCode' => 0, + ]; + yield 'fail' => [ + 'buf' => '1234567890', + 'fwriteParams' => [[$this->anything(), '1234567890']], + 'fwriteResult' => [false], + 'expectedException' => TException::class, + 'expectedExceptionMessage' => 'TPhpStream: Could not write 10 bytes', + 'expectedExceptionCode' => 0, + ]; + } + + public function testFlush() + { + $this->getFunctionMock('Thrift\Transport', 'fflush') + ->expects($this->once()); + + $transport = new TPhpStream(TPhpStream::MODE_R); + $transport->flush(); + } +} diff --git a/lib/php/test/Unit/Lib/Transport/TSSLSocketTest.php b/lib/php/test/Unit/Lib/Transport/TSSLSocketTest.php new file mode 100644 index 00000000000..71772190bce --- /dev/null +++ b/lib/php/test/Unit/Lib/Transport/TSSLSocketTest.php @@ -0,0 +1,247 @@ +expectException($expectedException); + $this->expectExceptionMessage($expectedMessage); + $this->expectExceptionCode($expectedCode); + + $this->getFunctionMock('Thrift\Transport', 'stream_socket_client') + ->expects($this->exactly($streamSocketClientCallCount)) + ->with( + 'ssl://' . $host . ':' . $port, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything(), #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + STREAM_CLIENT_CONNECT, + $this->anything() #$context + ) + ->willReturn(false); + + $socket = new TSSLSocket( + $host, + $port, + $context, + $debugHandler + ); + $socket->open(); + } + + public function openExceptionDataProvider() + { + yield 'host is empty' => [ + 'host' => '', + 'port' => 9090, + 'context' => null, + 'debugHandler' => null, + 'streamSocketClientCallCount' => 0, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'Cannot open null host', + 'expectedCode' => TTransportException::NOT_OPEN, + ]; + yield 'port is not positive' => [ + 'host' => 'localhost', + 'port' => 0, + 'context' => null, + 'debugHandler' => null, + 'streamSocketClientCallCount' => 0, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'Cannot open without port', + 'expectedCode' => TTransportException::NOT_OPEN, + ]; + yield 'connection failure' => [ + 'host' => 'nonexistent-host', + 'port' => 9090, + 'context' => null, + 'debugHandler' => null, + 'streamSocketClientCallCount' => 1, + 'expectedException' => TException::class, + 'expectedMessage' => 'TSocket: Could not connect to', + 'expectedCode' => TTransportException::UNKNOWN, + ]; + } + + public function testDoubleConnect(): void + { + $host = 'localhost'; + $port = 9090; + $context = null; + $debugHandler = null; + + $this->getFunctionMock('Thrift\Transport', 'stream_socket_client') + ->expects($this->once()) + ->with( + 'ssl://' . $host . ':' . $port, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything(), #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + STREAM_CLIENT_CONNECT, + $this->anything() #$context + ) + ->willReturn(fopen('php://memory', 'r+')); + + $transport = new TSSLSocket( + $host, + $port, + $context, + $debugHandler + ); + + $transport->open(); + $this->expectException(TTransportException::class); + $this->expectExceptionMessage('Socket already connected'); + $this->expectExceptionCode(TTransportException::ALREADY_OPEN); + $transport->open(); + } + + public function testDebugHandler() + { + $host = 'nonexistent-host'; + $port = 9090; + $context = null; + + $debugHandler = function ($error) { + $this->assertEquals( + 'TSocket: Could not connect to ssl://nonexistent-host:9090 (Connection refused [999])', + $error + ); + }; + + $this->getFunctionMock('Thrift\Transport', 'stream_socket_client') + ->expects($this->once()) + ->with( + 'ssl://' . $host . ':' . $port, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything(), #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + STREAM_CLIENT_CONNECT, + $this->anything() #$context + ) + ->willReturnCallback( + function ($host, &$error_code, &$error_message, $timeout, $flags, $context) { + $error_code = 999; + $error_message = 'Connection refused'; + + return false; + } + ); + + $this->expectException(\Exception::class); + $this->expectExceptionMessage('TSocket: Could not connect to'); + $this->expectExceptionCode(0); + + $transport = new TSSLSocket( + $host, + $port, + $context, + $debugHandler + ); + $transport->setDebug(true); + $transport->open(); + } + + public function testOpenWithContext() + { + $host = 'self-signed-localhost'; + $port = 9090; + $context = stream_context_create( + [ + 'ssl' => [ + 'verify_peer' => true, + 'verify_peer_name' => true, + 'allow_self_signed' => true, + ], + ] + ); + $debugHandler = null; + + $this->getFunctionMock('Thrift\Transport', 'stream_socket_client') + ->expects($this->once()) + ->with( + 'ssl://' . $host . ':' . $port, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything(), #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + STREAM_CLIENT_CONNECT, + $context #$context + ) + ->willReturn(fopen('php://memory', 'r+')); + + $transport = new TSSLSocket( + $host, + $port, + $context, + $debugHandler + ); + + + $transport->open(); + $this->assertTrue($transport->isOpen()); + } + + /** + * @dataProvider hostDataProvider + */ + public function testGetHost($host, $expected) + { + $port = 9090; + $context = null; + $debugHandler = null; + $transport = new TSSLSocket( + $host, + $port, + $context, + $debugHandler + ); + $this->assertEquals($expected, $transport->getHost()); + } + + public function hostDataProvider() + { + yield 'localhost' => ['localhost', 'ssl://localhost']; + yield 'ssl_localhost' => ['ssl://localhost', 'ssl://localhost']; + yield 'http_localhost' => ['http://localhost', 'http://localhost']; + } +} diff --git a/lib/php/test/Unit/Lib/Transport/TSocketPoolTest.php b/lib/php/test/Unit/Lib/Transport/TSocketPoolTest.php new file mode 100644 index 00000000000..01e45325bc8 --- /dev/null +++ b/lib/php/test/Unit/Lib/Transport/TSocketPoolTest.php @@ -0,0 +1,541 @@ +getProperty('servers_'); + $serversProp->setAccessible(true); + + $this->assertEquals($expectedServers, $serversProp->getValue($socketPool)); + } + + + public function constructDataProvider() + { + yield 'one server' => [ + ['localhost'], + [9090], + false, + null, + [ + ['host' => 'localhost', 'port' => 9090], + ], + ]; + yield 'two servers' => [ + ['localhost1', 'localhost2'], + [9090, 9091], + false, + null, + [ + ['host' => 'localhost1', 'port' => 9090], + ['host' => 'localhost2', 'port' => 9091], + ], + ]; + yield 'one server with one port' => [ + ['localhost'], + 9090, + false, + null, + [ + ['host' => 'localhost', 'port' => 9090], + ], + ]; + yield 'two servers with one port' => [ + ['localhost1', 'localhost2'], + 9090, + false, + null, + [ + ['host' => 'localhost1', 'port' => 9090], + ['host' => 'localhost2', 'port' => 9090], + ], + ]; + } + + public function testAddServer(): void + { + $socketPool = new TSocketPool([], []); + $socketPool->addServer('localhost', 9090); + + $ref = new \ReflectionObject($socketPool); + $servers = $ref->getProperty('servers_'); + $servers->setAccessible(true); + + $this->assertEquals([['host' => 'localhost', 'port' => 9090]], $servers->getValue($socketPool)); + } + + public function testSetNumRetries(): void + { + $socketPool = new TSocketPool([], []); + $socketPool->setNumRetries(5); + + $ref = new \ReflectionObject($socketPool); + $numRetries = $ref->getProperty('numRetries_'); + $numRetries->setAccessible(true); + + $this->assertEquals(5, $numRetries->getValue($socketPool)); + } + + public function testrSetRetryInterval(): void + { + $socketPool = new TSocketPool([], []); + $socketPool->setRetryInterval(5); + + $ref = new \ReflectionObject($socketPool); + $retryInterval = $ref->getProperty('retryInterval_'); + $retryInterval->setAccessible(true); + + $this->assertEquals(5, $retryInterval->getValue($socketPool)); + } + + public function testrSetMaxConsecutiveFailures(): void + { + $socketPool = new TSocketPool([], []); + $socketPool->setMaxConsecutiveFailures(5); + + $ref = new \ReflectionObject($socketPool); + $maxConsecutiveFailures = $ref->getProperty('maxConsecutiveFailures_'); + $maxConsecutiveFailures->setAccessible(true); + + $this->assertEquals(5, $maxConsecutiveFailures->getValue($socketPool)); + } + + public function testrSetRandomize(): void + { + $socketPool = new TSocketPool([], []); + $socketPool->setRandomize(false); + + $ref = new \ReflectionObject($socketPool); + $randomize = $ref->getProperty('randomize_'); + $randomize->setAccessible(true); + + $this->assertEquals(false, $randomize->getValue($socketPool)); + } + + public function testrSetAlwaysTryLast(): void + { + $socketPool = new TSocketPool([], []); + $socketPool->setAlwaysTryLast(false); + + $ref = new \ReflectionObject($socketPool); + $alwaysTryLast = $ref->getProperty('alwaysTryLast_'); + $alwaysTryLast->setAccessible(true); + + $this->assertEquals(false, $alwaysTryLast->getValue($socketPool)); + } + + /** + * @dataProvider openDataProvider + */ + public function testOpen( + $hosts, + $ports, + $persist, + $debugHandler, + $randomize, + $retryInterval, + $numRetries, + $maxConsecutiveFailures, + $debug, + $servers, + $functionExistCallParams, + $functionExistResult, + $apcuFetchCallParams, + $apcuFetchResult, + $timeResult, + $debugHandlerCall, + $apcuStoreCallParams, + $fsockopenCallParams, + $fsockopenResult, + $expectedException, + $expectedExceptionMessage + ) { + $this->getFunctionMock('Thrift\Transport', 'function_exists') + ->expects($this->exactly(count($functionExistCallParams))) + ->withConsecutive(...$functionExistCallParams) + ->willReturnOnConsecutiveCalls(...$functionExistResult); + + $this->getFunctionMock('Thrift\Transport', 'shuffle') + ->expects($randomize ? $this->once() : $this->never()) + ->with($servers) + ->willReturnCallback(function (array &$servers) { + $servers = array_reverse($servers); + + return true; + }); + + $this->getFunctionMock('Thrift\Transport', 'apcu_fetch') + ->expects($this->exactly(count($apcuFetchCallParams))) + ->withConsecutive(...$apcuFetchCallParams) + ->willReturnOnConsecutiveCalls(...$apcuFetchResult); + + $this->getFunctionMock('Thrift\Transport', 'call_user_func') + ->expects($this->exactly(count($debugHandlerCall))) + ->withConsecutive(...$debugHandlerCall) + ->willReturn(true); + + $this->getFunctionMock('Thrift\Transport', 'apcu_store') + ->expects($this->exactly(count($apcuStoreCallParams))) + ->withConsecutive(...$apcuStoreCallParams) + ->willReturn(true); + + $this->getFunctionMock('Thrift\Transport', 'time') + ->expects($this->exactly(count($timeResult))) + ->willReturnOnConsecutiveCalls(...$timeResult); + + #due to the running tests in separate process we could not open stream in data provider, so we need to do it here + foreach ($fsockopenResult as $num => $result) { + $fsockopenResult[$num] = $result ? fopen(...$result) : $result; + } + + $this->getFunctionMock('Thrift\Transport', $persist ? 'pfsockopen' : 'fsockopen') + ->expects($this->exactly(count($fsockopenCallParams))) + ->withConsecutive(...$fsockopenCallParams) + ->willReturnOnConsecutiveCalls(...$fsockopenResult); + + $this->getFunctionMock('Thrift\Transport', 'socket_import_stream') + ->expects(is_null($expectedException) ? $this->once() : $this->never()) + ->with( + $this->callback(function ($stream) { + return is_resource($stream); + }) + ) + ->willReturn(true); + + $this->getFunctionMock('Thrift\Transport', 'socket_set_option') + ->expects(is_null($expectedException) ? $this->once() : $this->never()) + ->with( + $this->anything(), #$socket, + SOL_TCP, #$level + TCP_NODELAY, #$option + 1 #$value + ) + ->willReturn(true); + + if ($expectedException) { + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedExceptionMessage); + } + + $socketPool = new TSocketPool($hosts, $ports, $persist, $debugHandler); + $socketPool->setRandomize($randomize); + $socketPool->setRetryInterval($retryInterval); + $socketPool->setNumRetries($numRetries); + $socketPool->setMaxConsecutiveFailures($maxConsecutiveFailures); + $socketPool->setDebug($debug); + + $this->assertNull($socketPool->open()); + } + + public function openDataProvider() + { + $default = [ + 'hosts' => ['localhost'], + 'ports' => [9090], + 'persist' => false, + 'debugHandler' => null, + 'randomize' => true, + 'retryInterval' => 5, + 'numRetries' => 1, + 'maxConsecutiveFailures' => 1, + 'debug' => false, + 'servers' => [ + ['host' => 'localhost', 'port' => 9090], + ], + 'functionExistCallParams' => [ + ['apcu_fetch'], + ['socket_import_stream'], + ['socket_set_option'], + ], + 'functionExistResult' => [ + true, + true, + true, + ], + 'apcuFetchCallParams' => [ + ['thrift_failtime:localhost:9090~', $this->anything()], + ], + 'apcuFetchResult' => [ + false, + ], + 'timeResult' => [], + 'debugHandlerCall' => [], + 'apcuStoreCallParams' => [], + 'fsockopenCallParams' => [ + [ + 'localhost', + 9090, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything(), #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + ], + ], + 'fsockopenResult' => [ + ['php://temp', 'r'], + ], + 'expectedException' => null, + 'expectedExceptionMessage' => null, + ]; + + yield 'one server ready' => $default; + yield 'one server failed' => array_merge( + $default, + [ + 'functionExistCallParams' => [ + ['apcu_fetch'], + ], + 'fsockopenResult' => [ + false, + ], + 'apcuFetchCallParams' => [ + ['thrift_failtime:localhost:9090~', $this->anything()], + ['thrift_consecfails:localhost:9090~', $this->anything()], + ], + 'apcuStoreCallParams' => [ + ['thrift_failtime:localhost:9090~', $this->anything()], + ['thrift_consecfails:localhost:9090~', $this->anything(), 0], + ], + 'timeResult' => [ + 1, + ], + 'expectedException' => TException::class, + 'expectedExceptionMessage' => 'TSocketPool: All hosts in pool are down. (localhost:9090)', + ] + ); + yield 'connect to one server on second attempt' => array_merge( + $default, + [ + 'numRetries' => 2, + 'fsockopenCallParams' => [ + [ + 'localhost', + 9090, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything(), #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + ], + [ + 'localhost', + 9090, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything(), #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + ], + ], + 'fsockopenResult' => [ + false, + ['php://temp', 'r'], + ], + 'apcuStoreCallParams' => [], + ] + ); + yield 'last time fail time is not expired' => array_merge( + $default, + [ + 'retryInterval' => 5, + 'apcuFetchResult' => [ + 99, + ], + 'apcuStoreCallParams' => [ + ['thrift_failtime:localhost:9090~', $this->anything()], + ], + 'timeResult' => [ + 100, + ], + ] + ); + yield 'last time fail time is expired, store info to debug' => array_merge( + $default, + [ + 'retryInterval' => 5, + 'apcuFetchResult' => [ + 90, + ], + 'apcuStoreCallParams' => [ + ['thrift_failtime:localhost:9090~', $this->anything()], + ], + 'timeResult' => [ + 100, + ], + 'debug' => true, + 'debugHandlerCall' => [ + ['error_log', 'TSocketPool: retryInterval (5) has passed for host localhost:9090'], + ], + ] + ); + yield 'not accessible server, store info to debug' => array_merge( + $default, + [ + 'retryInterval' => 5, + 'functionExistCallParams' => [ + ['apcu_fetch'], + ], + 'functionExistResult' => [ + true, + ], + 'apcuFetchCallParams' => [ + ['thrift_failtime:localhost:9090~', $this->anything()], + ['thrift_consecfails:localhost:9090~', $this->anything()], + ], + 'apcuFetchResult' => [ + 90, + ], + 'apcuStoreCallParams' => [ + ['thrift_failtime:localhost:9090~', $this->anything()], + ['thrift_consecfails:localhost:9090~', 0], + ], + 'timeResult' => [ + 100, + 101, + ], + 'fsockopenResult' => [ + false, + ], + 'debug' => true, + 'debugHandlerCall' => [ + ['error_log', 'TSocketPool: retryInterval (5) has passed for host localhost:9090'], + ['error_log', 'TSocket: Could not connect to localhost:9090 ( [])'], + ['error_log', 'TSocketPool: marking localhost:9090 as down for 5 secs after 1 failed attempts.'], + ['error_log', 'TSocketPool: All hosts in pool are down. (localhost:9090)'], + ], + 'expectedException' => TException::class, + 'expectedExceptionMessage' => 'TSocketPool: All hosts in pool are down. (localhost:9090)', + ] + ); + yield 'max consecutive failures' => array_merge( + $default, + [ + 'maxConsecutiveFailures' => 5, + 'functionExistCallParams' => [ + ['apcu_fetch'], + ], + 'functionExistResult' => [ + true, + ], + 'apcuFetchCallParams' => [ + ['thrift_failtime:localhost:9090~', $this->anything()], + ['thrift_consecfails:localhost:9090~', $this->anything()], + ], + 'apcuStoreCallParams' => [ + ['thrift_consecfails:localhost:9090~', 1], + ], + 'timeResult' => [], + 'fsockopenResult' => [ + false, + ], + 'expectedException' => TException::class, + 'expectedExceptionMessage' => 'TSocketPool: All hosts in pool are down. (localhost:9090)', + ] + ); + yield 'apcu disabled' => array_merge( + $default, + [ + 'functionExistCallParams' => [ + ['apcu_fetch'], + ], + 'functionExistResult' => [ + false, + ], + 'fsockopenResult' => [ + false, + ], + 'timeResult' => [ + 1, + ], + 'apcuFetchCallParams' => [], + 'apcuStoreCallParams' => [], + 'expectedException' => TException::class, + 'expectedExceptionMessage' => 'TSocketPool: All hosts in pool are down. (localhost:9090)', + ] + ); + yield 'second host accessible' => array_merge( + $default, + [ + 'hosts' => ['host1', 'host2'], + 'ports' => [9090, 9091], + 'servers' => [ + ['host' => 'host1', 'port' => 9090], + ['host' => 'host2', 'port' => 9091], + ], + 'fsockopenCallParams' => [ + [ + 'host2', + 9091, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything(), #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + ], + [ + 'host1', + 9090, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything(), #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + ], + ], + 'fsockopenResult' => [ + false, + ['php://temp', 'r'], + ], + 'apcuFetchCallParams' => [ + ['thrift_failtime:host2:9091~', $this->anything()], + ['thrift_consecfails:host2:9091~', $this->anything()], + ['thrift_failtime:host1:9090~', $this->anything()], + ], + 'apcuStoreCallParams' => [ + ['thrift_failtime:host2:9091~', $this->anything()], + ['thrift_consecfails:host2:9091~', $this->anything(), 0], + ], + 'timeResult' => [ + 1, + ], + ] + ); + } +} diff --git a/lib/php/test/Unit/Lib/Transport/TSocketTest.php b/lib/php/test/Unit/Lib/Transport/TSocketTest.php new file mode 100644 index 00000000000..6bab297ea2d --- /dev/null +++ b/lib/php/test/Unit/Lib/Transport/TSocketTest.php @@ -0,0 +1,669 @@ +expectException($expectedException); + $this->expectExceptionMessage($expectedMessage); + $this->expectExceptionCode($expectedCode); + + $this->getFunctionMock('Thrift\Transport', 'fsockopen') + ->expects($this->exactly($fsockopenCallCount)) + ->with( + $host, + $port, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything() #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + ) + ->willReturn(false); + + $socket = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + $socket->open(); + } + + public function openExceptionDataProvider() + { + yield 'host is empty' => [ + 'host' => '', + 'port' => 9090, + 'persist' => null, + 'debugHandler' => false, + 'fsockopenCallCount' => 0, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'Cannot open null host', + 'expectedCode' => TTransportException::NOT_OPEN, + ]; + yield 'port is not positive' => [ + 'host' => 'localhost', + 'port' => 0, + 'persist' => false, + 'debugHandler' => null, + 'fsockopenCallCount' => 0, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'Cannot open without port', + 'expectedCode' => TTransportException::NOT_OPEN, + ]; + yield 'connection failure' => [ + 'host' => 'nonexistent-host', + 'port' => 9090, + 'persist' => false, + 'debugHandler' => null, + 'fsockopenCallCount' => 1, + 'expectedException' => TException::class, + 'expectedMessage' => 'TSocket: Could not connect to', + 'expectedCode' => TTransportException::UNKNOWN, + ]; + } + + public function testDoubleConnect(): void + { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $handle = fopen('php://memory', 'r+'); + $this->getFunctionMock('Thrift\Transport', 'fsockopen') + ->expects($this->once()) + ->with( + $host, + $port, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything() #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + ) + ->willReturn($handle); + + $this->getFunctionMock('Thrift\Transport', 'socket_import_stream') + ->expects($this->once()) + ->with($handle) + ->willReturn(true); + + $this->getFunctionMock('Thrift\Transport', 'socket_set_option') + ->expects($this->once()) + ->with( + $this->anything(), #$socket, + SOL_TCP, #$level + TCP_NODELAY, #$option + 1 #$value + ) + ->willReturn(true); + + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + + $transport->open(); + $this->expectException(TTransportException::class); + $this->expectExceptionMessage('Socket already connected'); + $this->expectExceptionCode(TTransportException::ALREADY_OPEN); + $transport->open(); + } + + public function testDebugHandler() + { + $host = 'nonexistent-host'; + $port = 9090; + $false = false; + + $debugHandler = function ($error) { + $this->assertEquals( + 'TSocket: Could not connect to nonexistent-host:9090 (Connection refused [999])', + $error + ); + }; + + $this->getFunctionMock('Thrift\Transport', 'fsockopen') + ->expects($this->once()) + ->with( + $host, + $port, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything() #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + ) + ->willReturnCallback( + function ( + string $hostname, + int $port, + &$error_code, + &$error_message, + ?float $timeout + ) { + $error_code = 999; + $error_message = 'Connection refused'; + + return false; + } + ); + + $transport = new TSocket( + $host, + $port, + $false, + $debugHandler + ); + $transport->setDebug(true); + + $this->expectException(\Exception::class); + $this->expectExceptionMessage('TSocket: Could not connect to'); + $this->expectExceptionCode(0); + $transport->open(); + } + + public function testOpenPersist() + { + $host = 'persist-localhost'; + $port = 9090; + $persist = true; + $debugHandler = null; + + $handle = fopen('php://memory', 'r+'); + + $this->getFunctionMock('Thrift\Transport', 'pfsockopen') + ->expects($this->once()) + ->with( + $host, + $port, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything() #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + ) + ->willReturn($handle); + + $this->getFunctionMock('Thrift\Transport', 'socket_import_stream') + ->expects($this->once()) + ->with($handle) + ->willReturn(true); + + $this->getFunctionMock('Thrift\Transport', 'socket_set_option') + ->expects($this->once()) + ->with( + $this->anything(), #$socket, + SOL_TCP, #$level + TCP_NODELAY, #$option + 1 #$value + ) + ->willReturn(true); + + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + + $transport->open(); + $this->assertTrue($transport->isOpen()); + } + + /** + * @dataProvider open_THRIFT_5132_DataProvider + */ + public function testOpen_THRIFT_5132( + $socketImportResult + ) { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + + $this->getFunctionMock('Thrift\Transport', 'fsockopen') + ->expects($this->once()) + ->with( + $host, + $port, + $this->anything(), #$errno, + $this->anything(), #$errstr, + $this->anything() #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + ) + ->willReturn(fopen('php://input', 'r+')); + + $this->getFunctionMock('Thrift\Transport', 'socket_import_stream') + ->expects($this->once()) + ->willReturn($socketImportResult); + + $this->getFunctionMock('Thrift\Transport', 'socket_set_option') + ->expects($socketImportResult ? $this->once() : $this->never()) + ->with( + $this->anything(), #$socket, + SOL_TCP, #$level + TCP_NODELAY, #$option + 1 #$value + ) + ->willReturn(true); + + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + + $transport->open(); + $this->assertTrue($transport->isOpen()); + } + + public function open_THRIFT_5132_DataProvider() + { + yield 'socket_import_stream success' => [ + 'socketImportResult' => true, + ]; + yield 'socket_import_stream fail' => [ + 'socketImportResult' => false, + ]; + } + + public function testSetHandle() + { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + + $this->assertFalse($transport->isOpen()); + $transport->setHandle(fopen('php://memory', 'r+')); + $this->assertTrue($transport->isOpen()); + } + + public function testSetSendTimeout() + { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + + $transport->setSendTimeout(9999); + $reflector = new \ReflectionClass($transport); + $property = $reflector->getProperty('sendTimeoutSec_'); + $property->setAccessible(true); + $this->assertEquals(9.0, $property->getValue($transport)); + $property = $reflector->getProperty('sendTimeoutUsec_'); + $property->setAccessible(true); + $this->assertEquals(999000, $property->getValue($transport)); + } + + public function testSetRecvTimeout() + { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + + $transport->setRecvTimeout(9999); + $reflector = new \ReflectionClass($transport); + $property = $reflector->getProperty('recvTimeoutSec_'); + $property->setAccessible(true); + $this->assertEquals(9.0, $property->getValue($transport)); + $property = $reflector->getProperty('recvTimeoutUsec_'); + $property->setAccessible(true); + $this->assertEquals(999000, $property->getValue($transport)); + } + + /** + * @dataProvider hostDataProvider + */ + public function testGetHost($host, $expected) + { + $port = 9090; + $persist = false; + $debugHandler = null; + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + $this->assertEquals($expected, $transport->getHost()); + } + + public function hostDataProvider() + { + yield 'localhost' => ['localhost', 'localhost']; + yield 'ssl_localhost' => ['ssl://localhost', 'ssl://localhost']; + yield 'http_localhost' => ['http://localhost', 'http://localhost']; + } + + public function testGetPort() + { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + $this->assertEquals($port, $transport->getPort()); + } + + public function testClose() + { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + $transport->setHandle(fopen('php://memory', 'r+')); + $reflector = new \ReflectionClass($transport); + $property = $reflector->getProperty('handle_'); + $property->setAccessible(true); + $this->assertNotNull($property->getValue($transport)); + + $transport->close(); + $reflector = new \ReflectionClass($transport); + $property = $reflector->getProperty('handle_'); + $property->setAccessible(true); + $this->assertNull($property->getValue($transport)); + } + + /** + * @dataProvider writeFailDataProvider + */ + public function testWriteFail( + $streamSelectResult, + $fwriteCallCount, + $expectedException, + $expectedMessage, + $expectedCode + ) { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $handle = fopen('php://memory', 'r+'); + + $this->getFunctionMock('Thrift\Transport', 'stream_select') + ->expects($this->once()) + ->with( + $this->anything(), #$null, + [$handle], + $this->anything(), #$null, + $this->anything(), #$this->sendTimeoutSec_, + $this->anything() #$this->sendTimeoutUsec_ + ) + ->willReturn($streamSelectResult); + + $this->getFunctionMock('Thrift\Transport', 'fwrite') + ->expects($this->exactly($fwriteCallCount)) + ->with( + $handle, + 'test1234456789132456798' + ) + ->willReturn(false); + + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedMessage); + $this->expectExceptionCode($expectedCode); + + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + $transport->setHandle($handle); + + $transport->write('test1234456789132456798'); + } + + public function testWrite() + { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + $fileName = sys_get_temp_dir() . '/' . md5(mt_rand(0, time()) . time()); + touch($fileName); + $handle = fopen($fileName, 'r+'); + $transport->setHandle($handle); + $transport->write('test1234456789132456798'); + $this->assertEquals('test1234456789132456798', file_get_contents($fileName)); + + register_shutdown_function(function () use ($fileName) { + is_file($fileName) && unlink($fileName); + }); + } + + public function writeFailDataProvider() + { + yield 'stream_select timeout' => [ + 'streamSelectResult' => 0, + 'fwriteCallCount' => 0, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'TSocket: timed out writing 23 bytes from localhost:9090', + 'expectedCode' => 0, + ]; + yield 'stream_select fail write' => [ + 'streamSelectResult' => 1, + 'fwriteCallCount' => 1, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'TSocket: Could not write 23 bytes localhost:9090', + 'expectedCode' => 0, + ]; + yield 'stream_select fail' => [ + 'streamSelectResult' => false, + 'fwriteCallCount' => 0, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'TSocket: Could not write 23 bytes localhost:9090', + 'expectedCode' => 0, + ]; + } + + public function testRead() + { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + $fileName = sys_get_temp_dir() . '/' . md5(mt_rand(0, time()) . time()); + file_put_contents($fileName, '12345678901234567890'); + $handle = fopen($fileName, 'r+'); + $transport->setHandle($handle); + $this->assertEquals('12345', $transport->read(5)); + + register_shutdown_function(function () use ($fileName) { + is_file($fileName) && unlink($fileName); + }); + } + + /** + * @dataProvider readFailDataProvider + */ + public function testReadFail( + $streamSelectResult, + $freadResult, + $feofResult, + $expectedException, + $expectedMessage, + $expectedCode + ) { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $handle = fopen('php://memory', 'r+'); + + $this->getFunctionMock('Thrift\Transport', 'stream_select') + ->expects($this->once()) + ->with( + [$handle], + $this->anything(), #$null, + $this->anything(), #$null, + $this->anything(), #$this->recvTimeoutSec_, + $this->anything() #$this->recvTimeoutUsec_ + ) + ->willReturn($streamSelectResult); + + $this->getFunctionMock('Thrift\Transport', 'fread') + ->expects($this->exactly($streamSelectResult ? 1 : 0)) + ->with( + $handle, + 5 + ) + ->willReturn($freadResult); + $this->getFunctionMock('Thrift\Transport', 'feof') + ->expects($this->exactly($feofResult ? 1 : 0)) + ->with($handle) + ->willReturn($feofResult); + + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedMessage); + $this->expectExceptionCode($expectedCode); + + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + $transport->setHandle($handle); + + $transport->read(5); + } + + public function readFailDataProvider() + { + yield 'stream_select timeout' => [ + 'streamSelectResult' => 0, + 'freadResult' => '', + 'feofResult' => false, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'TSocket: timed out reading 5 bytes from localhost:9090', + 'expectedCode' => 0, + ]; + yield 'stream_select fail read' => [ + 'streamSelectResult' => 1, + 'freadResult' => '', + 'feofResult' => true, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'TSocket read 0 bytes', + 'expectedCode' => 0, + ]; + yield 'stream_select fail' => [ + 'streamSelectResult' => false, + 'freadResult' => '', + 'feofResult' => false, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'TSocket: Could not read 5 bytes from localhost:9090', + 'expectedCode' => 0, + ]; + yield 'fread false' => [ + 'streamSelectResult' => 1, + 'freadResult' => false, + 'feofResult' => false, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'TSocket: Could not read 5 bytes from localhost:9090', + 'expectedCode' => 0, + ]; + yield 'fread empty' => [ + 'streamSelectResult' => 1, + 'freadResult' => '', + 'feofResult' => true, + 'expectedException' => TTransportException::class, + 'expectedMessage' => 'TSocket read 0 bytes', + 'expectedCode' => 0, + ]; + } + + public function testFlush() + { + $host = 'localhost'; + $port = 9090; + $persist = false; + $debugHandler = null; + $transport = new TSocket( + $host, + $port, + $persist, + $debugHandler + ); + $this->assertNUll($transport->flush()); + } +} From a4ed94978b53553dd7b018ffd2b57072e9018de3 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Tue, 12 Mar 2024 23:21:00 +0100 Subject: [PATCH 198/250] Add "my own +1 vote" paragraph to mail template --- doc/ReleaseManagement.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/ReleaseManagement.md b/doc/ReleaseManagement.md index e06c9b4468e..51ecead5345 100644 --- a/doc/ReleaseManagement.md +++ b/doc/ReleaseManagement.md @@ -275,9 +275,10 @@ All Apache Thrift releases go through a 72-hour final release candidate voting p The CHANGES list for this release is available at: https://github.com/apache/thrift/blob/release/1.0.0/CHANGES.md - Please download, verify sig/sum, install and test the libraries and languages of your choice. + I start this voting thread with my own +1 vote. + This vote will close in 72 hours on 2019-07-06 21:00 UTC [ ] +1 Release this as Apache Thrift 1.0.0 From 0afcbece464aea1c557cb968a3c2493060783c20 Mon Sep 17 00:00:00 2001 From: Tuomo Jokimies Date: Mon, 18 Mar 2024 16:56:25 +0200 Subject: [PATCH 199/250] THRIFT-5769: fix invalid size error on large messages Client: nodejs --- lib/nodejs/lib/thrift/framed_transport.js | 19 ++++++++----------- lib/nodejs/test/header.test.js | 12 ++++++++++++ lib/nodejs/test/testAll.sh | 1 + 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/nodejs/lib/thrift/framed_transport.js b/lib/nodejs/lib/thrift/framed_transport.js index 9a50a738dde..058d2301ff3 100644 --- a/lib/nodejs/lib/thrift/framed_transport.js +++ b/lib/nodejs/lib/thrift/framed_transport.js @@ -35,30 +35,27 @@ function TFramedTransport(buffer, callback) { Object.setPrototypeOf(TFramedTransport.prototype, THeaderTransport.prototype); TFramedTransport.receiver = function(callback, seqid) { - var residual = []; + var residual = new Buffer(0); return function(data) { - // push received data to residual - for(var i = 0; i < data.length; ++i) { - residual.push(data[i]) - } + residual = Buffer.concat([residual, Buffer.from(data)]); while (residual.length > 0) { if (residual.length < 4) { // Not enough bytes to continue, save and resume on next packet return; } - // get single package sieze - var frameSize = binary.readI32(Buffer.from(residual.slice(0, 4)), 0); + // Get single package size + var frameSize = binary.readI32(residual, 0); // Not enough bytes to continue, save and resume on next packet if (residual.length < 4 + frameSize) { return; } - // splice first 4 bytes - residual.splice(0, 4) - // get package data - var frame = Buffer.from(residual.splice(0, frameSize)); + // Get package data + var frame = residual.subarray(4, 4 + frameSize); + // Remove processed data from residual + residual = residual.subarray(4 + frameSize); callback(new TFramedTransport(frame), seqid); } }; diff --git a/lib/nodejs/test/header.test.js b/lib/nodejs/test/header.test.js index 99bb832bc3c..12f1557a477 100644 --- a/lib/nodejs/test/header.test.js +++ b/lib/nodejs/test/header.test.js @@ -99,6 +99,18 @@ const cases = { assert.equals(headers.otherfoo, undefined); assert.equals(otherHeaders.foo, undefined); assert.equals(otherHeaders.otherfoo, "baz"); + assert.end(); + }, + "Should handle large messages without crashing": function(assert) { + const callback = function() {}; + const onData = TFramedTransport.receiver(callback); + + const largeChunkSize = 2 * 100 * 1024 * 1024; + const largeChunk = Buffer.alloc(largeChunkSize, "A"); + const sizeBuffer = new Buffer(4); + sizeBuffer.writeInt32BE(largeChunkSize + 4, 0); + onData(Buffer.concat([sizeBuffer, largeChunk])); + assert.end(); } }; diff --git a/lib/nodejs/test/testAll.sh b/lib/nodejs/test/testAll.sh index 37b6b438d42..144832ee43d 100755 --- a/lib/nodejs/test/testAll.sh +++ b/lib/nodejs/test/testAll.sh @@ -118,6 +118,7 @@ fi # unit tests node ${DIR}/binary.test.js || TESTOK=1 +node ${DIR}/header.test.js || TESTOK=1 node ${DIR}/int64.test.js || TESTOK=1 node ${DIR}/deep-constructor.test.js || TESTOK=1 From 6e046b0c84d7327aa527dd8a665f7fcea718ed3d Mon Sep 17 00:00:00 2001 From: k-walton <113375522+k-walton@users.noreply.github.com> Date: Mon, 18 Mar 2024 18:26:27 -0400 Subject: [PATCH 200/250] THRIFT-5767: use string builder to parse strings with escaped quotes (#2946) Client: Go --- lib/go/test/Makefile.am | 5 +- lib/go/test/StringParseAllocationTest.thrift | 22 +++++++ .../tests/string_parse_allocation_test.go | 62 +++++++++++++++++++ lib/go/thrift/simple_json_protocol.go | 43 ++++++------- 4 files changed, 107 insertions(+), 25 deletions(-) create mode 100644 lib/go/test/StringParseAllocationTest.thrift create mode 100644 lib/go/test/tests/string_parse_allocation_test.go diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am index 22fad9e42d9..379971e99f9 100644 --- a/lib/go/test/Makefile.am +++ b/lib/go/test/Makefile.am @@ -62,7 +62,8 @@ gopath: $(THRIFT) $(THRIFTTEST) \ ProcessorMiddlewareTest.thrift \ ClientMiddlewareExceptionTest.thrift \ ValidateTest.thrift \ - ForwardType.thrift + ForwardType.thrift \ + StringParseAllocationTest.thrift mkdir -p gopath/src grep -v list.*map.*list.*map $(THRIFTTEST) | grep -v 'set' > ThriftTest.thrift $(THRIFT) $(THRIFTARGS) -r IncludesTest.thrift @@ -98,6 +99,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \ $(THRIFT) $(THRIFTARGS) ClientMiddlewareExceptionTest.thrift $(THRIFT) $(THRIFTARGS) ValidateTest.thrift $(THRIFT) $(THRIFTARGS) ForwardType.thrift + $(THRIFT) $(THRIFTARGS) StringParseAllocationTest.thrift ln -nfs ../../tests gopath/src/tests cp -r ./dontexportrwtest gopath/src touch gopath @@ -171,6 +173,7 @@ EXTRA_DIST = \ RefAnnotationFieldsTest.thrift \ RequiredFieldTest.thrift \ ServicesTest.thrift \ + StringParseAllocationTest.thrift \ TypedefFieldTest.thrift \ UnionBinaryTest.thrift \ UnionDefaultValueTest.thrift \ diff --git a/lib/go/test/StringParseAllocationTest.thrift b/lib/go/test/StringParseAllocationTest.thrift new file mode 100644 index 00000000000..0ede9a52be1 --- /dev/null +++ b/lib/go/test/StringParseAllocationTest.thrift @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +struct StringStruct { + 1: required string example +} diff --git a/lib/go/test/tests/string_parse_allocation_test.go b/lib/go/test/tests/string_parse_allocation_test.go new file mode 100644 index 00000000000..12790c4f078 --- /dev/null +++ b/lib/go/test/tests/string_parse_allocation_test.go @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package tests + +import ( + "context" + "fmt" + "strings" + "testing" + + "github.com/apache/thrift/lib/go/test/gopath/src/stringparseallocationtest" + "github.com/apache/thrift/lib/go/thrift" +) + +func TestSimpleJsonStringParse_Allocations(t *testing.T) { + byteAllocationLimit := 100 * 1024 // 100 KB + res := testing.Benchmark(BenchmarkSimpleJsonStringParse_Allocations) + if res.AllocedBytesPerOp() > int64(byteAllocationLimit) { + t.Errorf("Total memory allocation size too high: %d (> %d)", res.AllocedBytesPerOp(), byteAllocationLimit) + } +} + +func BenchmarkSimpleJsonStringParse_Allocations(b *testing.B) { + b.ReportAllocs() + b.StopTimer() + numEscapedQuotes := 1000 + var sb strings.Builder + for i := 0; i < numEscapedQuotes; i++ { + sb.WriteString(`\"`) + } + + testString := fmt.Sprintf(`{"1": {"str": "this is a test with %d of escaped quotes %s"}}`, numEscapedQuotes, sb.String()) + stringStruct := stringparseallocationtest.NewStringStruct() + transport := thrift.NewTMemoryBuffer() + p := thrift.NewTJSONProtocol(transport) + + for i := 0; i < b.N; i++ { + transport.Reset() + transport.WriteString(testString) + transport.Flush(context.Background()) + b.StartTimer() + _ = stringStruct.Read(context.Background(), p) + b.StopTimer() + } +} diff --git a/lib/go/thrift/simple_json_protocol.go b/lib/go/thrift/simple_json_protocol.go index 8b1284fd1b1..da12248a17f 100644 --- a/lib/go/thrift/simple_json_protocol.go +++ b/lib/go/thrift/simple_json_protocol.go @@ -30,6 +30,7 @@ import ( "io" "math" "strconv" + "strings" ) type _ParseContext int @@ -922,15 +923,7 @@ func (p *TSimpleJSONProtocol) ParseStringBody() (string, error) { if err != nil { return "", NewTProtocolException(err) } - l := len(line) - // count number of escapes to see if we need to keep going - i := 1 - for ; i < l; i++ { - if line[l-i-1] != '\\' { - break - } - } - if i&0x01 == 1 { + if endsWithoutEscapedQuote(line) { v, ok := jsonUnquote(string(JSON_QUOTE) + line) if !ok { return "", NewTProtocolException(err) @@ -951,27 +944,29 @@ func (p *TSimpleJSONProtocol) ParseStringBody() (string, error) { } func (p *TSimpleJSONProtocol) ParseQuotedStringBody() (string, error) { - line, err := p.reader.ReadString(JSON_QUOTE) - if err != nil { - return "", NewTProtocolException(err) + var sb strings.Builder + + for { + line, err := p.reader.ReadString(JSON_QUOTE) + if err != nil { + return "", NewTProtocolException(err) + } + sb.WriteString(line) + if endsWithoutEscapedQuote(line) { + return sb.String(), nil + } } - l := len(line) - // count number of escapes to see if we need to keep going +} + +func endsWithoutEscapedQuote(s string) bool { + l := len(s) i := 1 for ; i < l; i++ { - if line[l-i-1] != '\\' { + if s[l-i-1] != '\\' { break } } - if i&0x01 == 1 { - return line, nil - } - s, err := p.ParseQuotedStringBody() - if err != nil { - return "", NewTProtocolException(err) - } - v := line + s - return v, nil + return i&0x01 == 1 } func (p *TSimpleJSONProtocol) ParseBase64EncodedBody() ([]byte, error) { From e7e79e09af62cd4a8b6fadb1db2cdb6e96959a03 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 17 Mar 2024 09:45:38 +0900 Subject: [PATCH 201/250] THRIFT-5768 Add missing test in configure.ac for kotlin The Kotlin autoconfig script was missing a `test` causing it to try and execute `x/usr/local/bin/gradle` instead of test for its existence. This resulted in the following error: ``` ./configure: line 15049: x/usr/local/bin/gradle: No such file or directory ``` Adding `test` results in the configuration succeeding. Configure output now: ``` thrift 0.21.0 Building C (GLib) Library .... : yes Building C++ Library ......... : yes Building Common Lisp Library.. : yes Building D Library ........... : yes Building Dart Library ........ : yes Building .NET Standard Library : yes Building Erlang Library ...... : yes Building Go Library .......... : yes Building Haxe Library ........ : yes Building Java Library ........ : yes Building Kotlin Library ...... : yes Building Lua Library ......... : yes Building NodeJS Library ...... : yes Building Perl Library ........ : yes Building PHP Library ......... : yes Building Python Library ...... : yes Building Py3 Library ......... : yes Building Ruby Library ........ : yes Building Rust Library ........ : yes Building Swift Library ....... : yes ``` --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 12a1168a8af..c8eaa6db31a 100644 --- a/configure.ac +++ b/configure.ac @@ -214,7 +214,7 @@ if test "$with_kotlin" = "yes"; then AC_PATH_PROG([GRADLE], [gradle]) AC_SUBST(CLASSPATH) AC_SUBST(GRADLE_OPTS) - if test "x$JAVA" != "x" && test "x$JAVAC" != "x" && "x$GRADLE" != "x" ; then + if test "x$JAVA" != "x" && test "x$JAVAC" != "x" && test "x$GRADLE" != "x" ; then have_kotlin="yes" fi fi From 3972b947fec3e67a7318817cfff0ad567cb21e8c Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 15 Mar 2024 19:08:16 +0900 Subject: [PATCH 202/250] THRIFT-5762 Fix spotless errors Run `gradlew :spotlessApply` to apply the correct coding style. Update kotlin compiler to support `getEmptyResultInstance` https://github.com/apache/thrift/pull/2939 added the feature to create an instance of the result object without having to use the ProcessFunction. The Kotlin compiler re-uses the java lib so this commit udpates the Kotlin compiler to support this feature as well. --- .../src/thrift/generate/t_kotlin_generator.cc | 17 ++- .../org/apache/thrift/ProcessFunction.java | 142 +++++++++--------- .../apache/thrift/TBaseAsyncProcessor.java | 6 +- .../org/apache/thrift/TBaseProcessor.java | 3 +- 4 files changed, 90 insertions(+), 78 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc b/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc index a0172720045..78917d99f95 100644 --- a/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc @@ -1615,7 +1615,7 @@ void t_kotlin_generator::generate_service_processor(t_service* tservice) { "org.apache.thrift.AsyncProcessFunction<" << tservice->get_name() << ", out org.apache.thrift.TBase<*, " - "*>, out kotlin.Any>> = mapOf(" + "*>, out kotlin.Any, out org.apache.thrift.TBase<*, *>>> = mapOf(" << endl; indent_up(); { @@ -1656,16 +1656,27 @@ void t_kotlin_generator::generate_service_process_function(ostream& out, t_function* tfunc) { string args_name = tservice->get_name() + "FunctionArgs." + tfunc->get_name() + "_args"; string rtype = type_name(tfunc->get_returntype(), true); + string resultname = tservice->get_name() + "FunctionResult." + tfunc->get_name() + "_result"; indent(out) << "class " << tfunc->get_name() << "get_name() << ">(private val scope: kotlinx.coroutines.CoroutineScope) : " "org.apache.thrift.AsyncProcessFunction(\"" << tfunc->get_name() - << "\"), ProcessFunction {" << endl; + << args_name << ", " << rtype << ", " + << (tfunc->is_oneway() ? "org.apache.thrift.TBase<*, *>" : resultname) + << ">(\"" << tfunc->get_name() << "\"), ProcessFunction {" + << endl; indent_up(); { indent(out) << "override fun isOneway() = " << (tfunc->is_oneway() ? "true" : "false") << endl; indent(out) << "override fun getEmptyArgsInstance() = " << args_name << "()" << endl; + indent(out) << "override fun getEmptyResultInstance() = "; + if (tfunc->is_oneway()) { + out << "null" << endl; + } + else { + out << resultname << "()" << endl; + } + indent(out) << endl; indent(out) << "override fun start(iface: I, args: " << args_name << ", resultHandler: org.apache.thrift.async.AsyncMethodCallback<" << rtype << ">) {" << endl; diff --git a/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java b/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java index 8552863aaef..ac99d8e607d 100644 --- a/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java +++ b/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java @@ -9,90 +9,88 @@ import org.slf4j.LoggerFactory; public abstract class ProcessFunction { - private final String methodName; + private final String methodName; - private static final Logger LOGGER = LoggerFactory.getLogger(ProcessFunction.class.getName()); + private static final Logger LOGGER = LoggerFactory.getLogger(ProcessFunction.class.getName()); - public ProcessFunction(String methodName) { - this.methodName = methodName; - } - - public final void process(int seqid, TProtocol iprot, TProtocol oprot, I iface) - throws TException { - T args = getEmptyArgsInstance(); - try { - args.read(iprot); - } catch (TProtocolException e) { - iprot.readMessageEnd(); - TApplicationException x = - new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage()); - oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid)); - x.write(oprot); - oprot.writeMessageEnd(); - oprot.getTransport().flush(); - return; - } - iprot.readMessageEnd(); - TSerializable result = null; - byte msgType = TMessageType.REPLY; + public ProcessFunction(String methodName) { + this.methodName = methodName; + } - try { - result = getResult(iface, args); - } catch (TTransportException ex) { - LOGGER.error("Transport error while processing " + getMethodName(), ex); - throw ex; - } catch (TApplicationException ex) { - LOGGER.error("Internal application error processing " + getMethodName(), ex); - result = ex; - msgType = TMessageType.EXCEPTION; - } catch (Exception ex) { - LOGGER.error("Internal error processing " + getMethodName(), ex); - if (rethrowUnhandledExceptions()) throw new RuntimeException(ex.getMessage(), ex); - if (!isOneway()) { - result = - new TApplicationException( - TApplicationException.INTERNAL_ERROR, - "Internal error processing " + getMethodName()); - msgType = TMessageType.EXCEPTION; - } - } + public final void process(int seqid, TProtocol iprot, TProtocol oprot, I iface) + throws TException { + T args = getEmptyArgsInstance(); + try { + args.read(iprot); + } catch (TProtocolException e) { + iprot.readMessageEnd(); + TApplicationException x = + new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage()); + oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid)); + x.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); + return; + } + iprot.readMessageEnd(); + TSerializable result = null; + byte msgType = TMessageType.REPLY; - if (!isOneway()) { - oprot.writeMessageBegin(new TMessage(getMethodName(), msgType, seqid)); - result.write(oprot); - oprot.writeMessageEnd(); - oprot.getTransport().flush(); - } + try { + result = getResult(iface, args); + } catch (TTransportException ex) { + LOGGER.error("Transport error while processing " + getMethodName(), ex); + throw ex; + } catch (TApplicationException ex) { + LOGGER.error("Internal application error processing " + getMethodName(), ex); + result = ex; + msgType = TMessageType.EXCEPTION; + } catch (Exception ex) { + LOGGER.error("Internal error processing " + getMethodName(), ex); + if (rethrowUnhandledExceptions()) throw new RuntimeException(ex.getMessage(), ex); + if (!isOneway()) { + result = + new TApplicationException( + TApplicationException.INTERNAL_ERROR, + "Internal error processing " + getMethodName()); + msgType = TMessageType.EXCEPTION; + } } - private void handleException(int seqid, TProtocol oprot) throws TException { - if (!isOneway()) { - TApplicationException x = - new TApplicationException( - TApplicationException.INTERNAL_ERROR, "Internal error processing " + getMethodName()); - oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid)); - x.write(oprot); - oprot.writeMessageEnd(); - oprot.getTransport().flush(); - } + if (!isOneway()) { + oprot.writeMessageBegin(new TMessage(getMethodName(), msgType, seqid)); + result.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); } + } - protected boolean rethrowUnhandledExceptions() { - return false; + private void handleException(int seqid, TProtocol oprot) throws TException { + if (!isOneway()) { + TApplicationException x = + new TApplicationException( + TApplicationException.INTERNAL_ERROR, "Internal error processing " + getMethodName()); + oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid)); + x.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); } + } - public abstract boolean isOneway(); + protected boolean rethrowUnhandledExceptions() { + return false; + } - public abstract TBase getResult(I iface, T args) throws TException; + public abstract boolean isOneway(); - public abstract T getEmptyArgsInstance(); + public abstract TBase getResult(I iface, T args) throws TException; - /** - * Returns null when this is a oneWay function. - */ - public abstract A getEmptyResultInstance(); + public abstract T getEmptyArgsInstance(); - public String getMethodName() { - return methodName; - } + /** Returns null when this is a oneWay function. */ + public abstract A getEmptyResultInstance(); + + public String getMethodName() { + return methodName; + } } diff --git a/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java b/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java index 0a583c05a6a..eedb8cb5058 100644 --- a/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java +++ b/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java @@ -33,12 +33,14 @@ public class TBaseAsyncProcessor implements TAsyncProcessor, TProcessor { final Map> processMap; public TBaseAsyncProcessor( - I iface, Map> processMap) { + I iface, + Map> processMap) { this.iface = iface; this.processMap = processMap; } - public Map> getProcessMapView() { + public Map> + getProcessMapView() { return Collections.unmodifiableMap(processMap); } diff --git a/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java b/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java index ff1ccfcc9c0..2cd805f2f1a 100644 --- a/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java +++ b/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java @@ -13,7 +13,8 @@ public abstract class TBaseProcessor implements TProcessor { private final Map> processMap; protected TBaseProcessor( - I iface, Map> processFunctionMap) { + I iface, + Map> processFunctionMap) { this.iface = iface; this.processMap = processFunctionMap; } From 9f5d628eaedc067cbeed5fd3c79720750c18b1f6 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 23 Mar 2024 00:53:56 +0100 Subject: [PATCH 203/250] We have 2024 --- lib/netstd/Thrift/Thrift.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index 3aa16d25ea1..da93da496ec 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -52,7 +52,7 @@ Apache Thrift RPC https://github.com/apache/thrift/blob/0.21.0/CHANGES.md README.md - Copyright 2023 The Apache Software Foundation + Copyright 2024 The Apache Software Foundation From 3d8ab88e9e13a4364b7bbdff6a575ad55bc1df0a Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Mon, 18 Mar 2024 22:26:00 +0100 Subject: [PATCH 204/250] [THRIFT-5757] Unit tests for php lib --- composer.json | 3 +- .../lib/Factory/TFramedTransportFactory.php | 21 ++- lib/php/lib/Factory/TTransportFactory.php | 22 ++- .../Factory/TTransportFactoryInterface.php | 22 ++- lib/php/lib/Server/TSSLServerSocket.php | 4 + lib/php/lib/Server/TServerTransport.php | 1 + .../Factory/TFramedTransportFactoryTest.php | 2 +- .../Lib/Factory/TTransportFactoryTest.php | 2 +- .../Unit/Lib/Server/Fixture/TestProcessor.php | 30 ++++ .../Unit/Lib/Server/TForkingServerTest.php | 32 ++++ .../Unit/Lib/Server/TSSLServerSocketTest.php | 150 ++++++++++++++++ .../Unit/Lib/Server/TServerSocketTest.php | 128 ++++++++++++++ .../Unit/Lib/Server/TSimpleServerTest.php | 166 ++++++++++++++++++ 13 files changed, 575 insertions(+), 8 deletions(-) create mode 100644 lib/php/test/Unit/Lib/Server/Fixture/TestProcessor.php create mode 100644 lib/php/test/Unit/Lib/Server/TForkingServerTest.php create mode 100644 lib/php/test/Unit/Lib/Server/TSSLServerSocketTest.php create mode 100644 lib/php/test/Unit/Lib/Server/TServerSocketTest.php create mode 100644 lib/php/test/Unit/Lib/Server/TSimpleServerTest.php diff --git a/composer.json b/composer.json index 900fb2854e7..684c1b3875c 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "php-mock/php-mock-phpunit": "^2.10", "ext-json": "*", "ext-xml": "*", - "ext-curl": "*" + "ext-curl": "*", + "ext-pcntl": "*" }, "autoload": { "psr-4": {"Thrift\\": "lib/php/lib/"} diff --git a/lib/php/lib/Factory/TFramedTransportFactory.php b/lib/php/lib/Factory/TFramedTransportFactory.php index 485fca505fb..c0adfd0d038 100644 --- a/lib/php/lib/Factory/TFramedTransportFactory.php +++ b/lib/php/lib/Factory/TFramedTransportFactory.php @@ -1,5 +1,24 @@ getSSLHost($host); parent::__construct($ssl_host, $port); + // Initialize a stream context if not provided + if ($context === null) { + $context = stream_context_create(); + } $this->context_ = $context; } diff --git a/lib/php/lib/Server/TServerTransport.php b/lib/php/lib/Server/TServerTransport.php index 15a27afa8ad..82ee752684b 100644 --- a/lib/php/lib/Server/TServerTransport.php +++ b/lib/php/lib/Server/TServerTransport.php @@ -3,6 +3,7 @@ namespace Thrift\Server; use Thrift\Exception\TTransportException; +use Thrift\Transport\TTransport; /** * Generic class for Server agent. diff --git a/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php index 3b8b5cc44f3..f8a860c9739 100644 --- a/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php +++ b/lib/php/test/Unit/Lib/Factory/TFramedTransportFactoryTest.php @@ -35,7 +35,7 @@ public function testGetTransport() { $transport = $this->createMock(TTransport::class); $factory = new TFramedTransportFactory(); - $framedTransport = $factory::getTransport($transport); + $framedTransport = $factory->getTransport($transport); $this->assertInstanceOf(TFramedTransport::class, $framedTransport); diff --git a/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php b/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php index a8a791ad121..9d3e6402ba6 100644 --- a/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php +++ b/lib/php/test/Unit/Lib/Factory/TTransportFactoryTest.php @@ -34,7 +34,7 @@ public function testGetTransport() { $transport = $this->createMock(TTransport::class); $factory = new TTransportFactory(); - $result = $factory::getTransport($transport); + $result = $factory->getTransport($transport); $this->assertSame($transport, $result); } diff --git a/lib/php/test/Unit/Lib/Server/Fixture/TestProcessor.php b/lib/php/test/Unit/Lib/Server/Fixture/TestProcessor.php new file mode 100644 index 00000000000..8fc689194a5 --- /dev/null +++ b/lib/php/test/Unit/Lib/Server/Fixture/TestProcessor.php @@ -0,0 +1,30 @@ +markTestSkipped('Unit test could not be written for class which use pcntl_fork and exit functions'); + } +} diff --git a/lib/php/test/Unit/Lib/Server/TSSLServerSocketTest.php b/lib/php/test/Unit/Lib/Server/TSSLServerSocketTest.php new file mode 100644 index 00000000000..02ae584db42 --- /dev/null +++ b/lib/php/test/Unit/Lib/Server/TSSLServerSocketTest.php @@ -0,0 +1,150 @@ +assertEquals('ssl://localhost', $socket->getSSLHost('localhost')); + $this->assertEquals('ssl://localhost', $socket->getSSLHost('ssl://localhost')); + $this->assertEquals('tcp://localhost', $socket->getSSLHost('tcp://localhost')); + } + + public function testListenAndClose(): void + { + $options = [ + 'ssl' => [ + 'verify_peer' => true, + 'verify_peer_name' => true, + 'allow_self_signed' => true, + ], + ]; + $context = stream_context_create($options); + $socket = new TSSLServerSocket('somehost', 999, $context); + + $listener = tmpfile(); + $this->getFunctionMock('Thrift\Server', 'stream_socket_server') + ->expects($this->once()) + ->with( + 'ssl://somehost:999', #$address + $this->anything(), #&$error_code + $this->anything(), #&$error_string + STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, #int $flags + $this->callback(function ($context) use ($options) { + $contextOptions = stream_context_get_options($context); + + return is_resource($context) && $options === $contextOptions; + })#resource $context + )->willReturn($listener); + + $socket->listen(); + + $reflection = new \ReflectionClass($socket); + $property = $reflection->getProperty('listener_'); + $property->setAccessible(true); + + $this->assertIsResource($property->getValue($socket)); + + $this->getFunctionMock('Thrift\Server', 'fclose') + ->expects($this->once()) + ->with($this->equalTo($listener)) + ->willReturn(true); + + $socket->close(); + $this->assertNull($property->getValue($socket)); + } + + public function testAccept() + { + $socket = new TSSLServerSocket('somehost', 999); + $socket->setAcceptTimeout(1000); + + $listener = tmpfile(); + $this->getFunctionMock('Thrift\Server', 'stream_socket_server') + ->expects($this->once()) + ->with( + 'ssl://somehost:999', #$address + $this->anything(), #&$error_code + $this->anything(), #&$error_string + STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, #int $flags + $this->callback(function ($context) { + $contextOptions = stream_context_get_options($context); + + return is_resource($context) && $contextOptions === []; + }) #resource $context + )->willReturn($listener); + + $transportHandle = tmpfile(); + $this->getFunctionMock('Thrift\Server', 'stream_socket_accept') + ->expects($this->once()) + ->with( + $this->equalTo($listener), + 1 + )->willReturn($transportHandle); + + $socket->listen(); + $result = $socket->accept(); + $this->assertInstanceOf(TSocket::class, $result); + + $reflection = new \ReflectionClass($result); + $property = $reflection->getProperty('handle_'); + $property->setAccessible(true); + $this->assertEquals($transportHandle, $property->getValue($result)); + } + + public function testAcceptFailed() + { + $socket = new TSSLServerSocket('somehost', 999); + $socket->setAcceptTimeout(1000); + + $listener = tmpfile(); + + $this->getFunctionMock('Thrift\Server', 'stream_socket_server') + ->expects($this->once()) + ->with('ssl://somehost:999') + ->willReturn($listener); + + $this->getFunctionMock('Thrift\Server', 'stream_socket_accept') + ->expects($this->once()) + ->with( + $this->equalTo($listener), + 1 + )->willReturn(null); + + $this->expectException(TTransportException::class); + $this->expectExceptionMessage('accept() may not return NULL'); + + $socket->listen(); + $socket->accept(); + } +} diff --git a/lib/php/test/Unit/Lib/Server/TServerSocketTest.php b/lib/php/test/Unit/Lib/Server/TServerSocketTest.php new file mode 100644 index 00000000000..e9d3b9666f5 --- /dev/null +++ b/lib/php/test/Unit/Lib/Server/TServerSocketTest.php @@ -0,0 +1,128 @@ +setAcceptTimeout(1000); + + $reflection = new \ReflectionClass($socket); + $property = $reflection->getProperty('acceptTimeout_'); + $property->setAccessible(true); + + $this->assertEquals(1000, $property->getValue($socket)); + } + + public function testListenAndClose(): void + { + $socket = new TServerSocket('somehost', 999); + + $listener = tmpfile(); + $this->getFunctionMock('Thrift\Server', 'stream_socket_server') + ->expects($this->once()) + ->with('tcp://somehost:999') + ->willReturn($listener); + + $socket->listen(); + + $reflection = new \ReflectionClass($socket); + $property = $reflection->getProperty('listener_'); + $property->setAccessible(true); + + $this->assertIsResource($property->getValue($socket)); + + $this->getFunctionMock('Thrift\Server', 'fclose') + ->expects($this->once()) + ->with($this->equalTo($listener)) + ->willReturn(true); + + $socket->close(); + $this->assertNull($property->getValue($socket)); + } + + public function testAccept() + { + $socket = new TServerSocket('somehost', 999); + $socket->setAcceptTimeout(1000); + + $listener = tmpfile(); + + $this->getFunctionMock('Thrift\Server', 'stream_socket_server') + ->expects($this->once()) + ->with('tcp://somehost:999') + ->willReturn($listener); + + $transportHandle = tmpfile(); + $this->getFunctionMock('Thrift\Server', 'stream_socket_accept') + ->expects($this->once()) + ->with( + $this->equalTo($listener), + 1 + )->willReturn($transportHandle); + + $socket->listen(); + $result = $socket->accept(); + $this->assertInstanceOf(TSocket::class, $result); + + $reflection = new \ReflectionClass($result); + $property = $reflection->getProperty('handle_'); + $property->setAccessible(true); + $this->assertEquals($transportHandle, $property->getValue($result)); + } + + public function testAcceptFailed() + { + $socket = new TServerSocket('somehost', 999); + $socket->setAcceptTimeout(1000); + + $listener = tmpfile(); + + $this->getFunctionMock('Thrift\Server', 'stream_socket_server') + ->expects($this->once()) + ->with('tcp://somehost:999') + ->willReturn($listener); + + $this->getFunctionMock('Thrift\Server', 'stream_socket_accept') + ->expects($this->once()) + ->with( + $this->equalTo($listener), + 1 + )->willReturn(null); + + $this->expectException(TTransportException::class); + $this->expectExceptionMessage('accept() may not return NULL'); + + $socket->listen(); + $socket->accept(); + } +} diff --git a/lib/php/test/Unit/Lib/Server/TSimpleServerTest.php b/lib/php/test/Unit/Lib/Server/TSimpleServerTest.php new file mode 100644 index 00000000000..269b838592d --- /dev/null +++ b/lib/php/test/Unit/Lib/Server/TSimpleServerTest.php @@ -0,0 +1,166 @@ +processor = $this->createMock(TestProcessor::class); + $this->transport = $this->createMock(TServerTransport::class); + $this->inputTransportFactory = $this->createMock(TTransportFactoryInterface::class); + $this->outputTransportFactory = $this->createMock(TTransportFactoryInterface::class); + $this->inputProtocolFactory = $this->createMock(TProtocolFactory::class); + $this->outputProtocolFactory = $this->createMock(TProtocolFactory::class); + + $this->server = new TSimpleServer( + $this->processor, + $this->transport, + $this->inputTransportFactory, + $this->outputTransportFactory, + $this->inputProtocolFactory, + $this->outputProtocolFactory + ); + } + + protected function tearDown(): void + { + unset( + $this->processor, + $this->transport, + $this->inputTransportFactory, + $this->outputTransportFactory, + $this->inputProtocolFactory, + $this->outputProtocolFactory, + $this->server + ); + } + + /** + * @dataProvider serveDataProvider + */ + public function testServe( + $serveLoopCount, + array $processLoopResult + ): void { + $transport = $this->createMock(TTransport::class); + + $this->transport->expects($this->once()) + ->method('listen'); + $this->transport->expects($this->exactly($serveLoopCount)) + ->method('accept') + ->willReturn($transport); + + $this->inputTransportFactory->expects($this->exactly($serveLoopCount)) + ->method('getTransport') + ->willReturn($this->createMock(TServerTransport::class)); + $this->outputTransportFactory->expects($this->exactly($serveLoopCount)) + ->method('getTransport') + ->willReturn($this->createMock(TServerTransport::class)); + + $inputProtocol = $this->createMock(TServerTransport::class); + $this->inputProtocolFactory->expects($this->exactly($serveLoopCount)) + ->method('getProtocol') + ->willReturn($inputProtocol); + + $outputProtocol = $this->createMock(TServerTransport::class); + $this->outputProtocolFactory->expects($this->exactly($serveLoopCount)) + ->method('getProtocol') + ->willReturn($outputProtocol); + + /** + * ATTENTION! + * it is a hack to stop the server loop in unit test + * last call of process can return any value, but should stop server for removing infinite loop + **/ + $processLoopResult[] = $this->returnCallback(function () { + $this->server->stop(); + + return false; + }); + + $this->processor->expects($this->exactly(count($processLoopResult))) + ->method('process') + ->with( + $this->equalTo($inputProtocol), + $this->equalTo($outputProtocol) + ) + ->willReturnOnConsecutiveCalls(...$processLoopResult); + + $this->server->serve(); + } + + public function serveDataProvider() + { + yield 'one serve loop' => [ + 'serveLoopCount' => 1, + 'processLoopResult' => [ + true, + ] + ]; + yield 'two serve loop' => [ + 'serveLoopCount' => 2, + 'processLoopResult' => [ + true, + false, + ] + ]; + } +} From 3f37d663e45ceca2ec994fe73e2e8f58a49c7829 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sun, 31 Mar 2024 15:36:04 +0200 Subject: [PATCH 205/250] Upgraded appveyor dockerfile reference to zlib to 1.2.13 Patch: JensG --- .gitignore | 2 ++ build/docker/msvc2017/Dockerfile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0ed47297d13..e7f06a77214 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,8 @@ project.lock.json /compiler/cpp/src/thrift/plugin/gen.stamp /compiler/cpp/Debug /compiler/cpp/Release +/compiler/cpp/compiler/Debug +/compiler/cpp/compiler/Release /compiler/cpp/src/thrift/libparse.a /compiler/cpp/src/thrift/thriftl.cc /compiler/cpp/src/thrift/thrifty.cc diff --git a/build/docker/msvc2017/Dockerfile b/build/docker/msvc2017/Dockerfile index d59c19568bc..a5c04b7f927 100644 --- a/build/docker/msvc2017/Dockerfile +++ b/build/docker/msvc2017/Dockerfile @@ -67,7 +67,7 @@ RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 && ` # Install zlib COPY appveyor\build-zlib.bat C:\TEMP\build-zlib.bat -ENV ZLIB_VERSION=1.2.11 +ENV ZLIB_VERSION=1.2.13 ENV WIN3P=C:\TEMP\WIN3P RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 && ` MKDIR C:\TEMP\WIN3P && ` From 2b2010b1005395490217e4bb93110444d2820e85 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sun, 31 Mar 2024 15:42:16 +0200 Subject: [PATCH 206/250] Upgraded dockerfile reference to Win64OpenSSL-1_1_0l.exe --- build/docker/msvc2017/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/docker/msvc2017/Dockerfile b/build/docker/msvc2017/Dockerfile index a5c04b7f927..a29753e0f78 100644 --- a/build/docker/msvc2017/Dockerfile +++ b/build/docker/msvc2017/Dockerfile @@ -76,7 +76,7 @@ RUN C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 && ` RMDIR /S /Q C:\TEMP\WIN3P # Install OpenSSL 1.1.0 -ADD http://slproweb.com/download/Win64OpenSSL-1_1_0j.exe C:\TEMP\openssl.exe +ADD http://slproweb.com/download/Win64OpenSSL-1_1_0l.exe C:\TEMP\openssl.exe RUN C:\TEMP\openssl.exe /silent && ` DEL C:\TEMP\openssl.exe From ee69b50f8445d6934f226aa8599762337a0b52fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 06:20:43 +0000 Subject: [PATCH 207/250] Bump jvm from 1.9.22 to 1.9.23 in /lib/kotlin Bumps [jvm](https://github.com/JetBrains/kotlin) from 1.9.22 to 1.9.23. - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.9.23/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.22...v1.9.23) --- updated-dependencies: - dependency-name: jvm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- lib/kotlin/settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/settings.gradle.kts b/lib/kotlin/settings.gradle.kts index 294cd83c1d6..6bbfd7f6723 100644 --- a/lib/kotlin/settings.gradle.kts +++ b/lib/kotlin/settings.gradle.kts @@ -18,7 +18,7 @@ */ pluginManagement { plugins { - kotlin("jvm") version "1.9.22" + kotlin("jvm") version "1.9.23" id("com.ncorti.ktfmt.gradle") version "0.12.0" } } From 79bc153f595bed2a36839fcb9131a9e20f36b901 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Mon, 1 Apr 2024 22:44:14 +0200 Subject: [PATCH 208/250] THRIFT-5750 Remove "ansistr_binary_" option Client: delphi Patch: Jens Geyer --- .../src/thrift/generate/t_delphi_generator.cc | 33 +++---------------- lib/delphi/src/Thrift.Protocol.pas | 28 ++++++++++++---- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc index c91ff332eab..c5998365664 100644 --- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc @@ -68,7 +68,6 @@ class t_delphi_generator : public t_oop_generator { has_const = false; std::map::const_iterator iter; - ansistr_binary_ = false; register_types_ = false; constprefix_ = false; old_names_ = false; @@ -78,10 +77,7 @@ class t_delphi_generator : public t_oop_generator { com_types_ = false; rtti_ = false; for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) { - if( iter->first.compare("ansistr_binary") == 0) { - ansistr_binary_ = true; - pwarning(0, "The 'ansistr_binary' option is deprecated."); - } else if( iter->first.compare("register_types") == 0) { + if( iter->first.compare("register_types") == 0) { register_types_ = true; } else if( iter->first.compare("old_names") == 0) { old_names_ = true; @@ -102,10 +98,6 @@ class t_delphi_generator : public t_oop_generator { } } - if(com_types_ && ansistr_binary_) { - throw "com_types and ansistr_binary are mutually exclusive"; - } - out_dir_base_ = "gen-delphi"; escape_.clear(); escape_['\''] = "''"; @@ -468,7 +460,6 @@ class t_delphi_generator : public t_oop_generator { void init_known_types_list(); bool is_void(t_type* type); int indent_impl_; - bool ansistr_binary_; bool register_types_; bool constprefix_; bool old_names_; @@ -760,7 +751,6 @@ void t_delphi_generator::close_generator() { f_all << "const" << endl; indent_up(); - indent(f_all) << "c" << tmp_unit << "_Option_AnsiStr_Binary = " << (ansistr_binary_ ? "True" : "False") << ";" << endl; indent(f_all) << "c" << tmp_unit << "_Option_Register_Types = " << (register_types_ ? "True" : "False") << ";" << endl; indent(f_all) << "c" << tmp_unit << "_Option_ConstPrefix = " << (constprefix_ ? "True" : "False") << ";" << endl; indent(f_all) << "c" << tmp_unit << "_Option_Events = " << (events_ ? "True" : "False") << ";" << endl; @@ -2634,11 +2624,7 @@ void t_delphi_generator::generate_deserialize_field(ostream& out, break; case t_base_type::TYPE_STRING: if (type->is_binary()) { - if (ansistr_binary_) { - out << "ReadAnsiString();"; - } else { - out << (com_types_ ? "ReadBinaryCOM();" : "ReadBinary();"); - } + out << (com_types_ ? "ReadBinaryCOM();" : "ReadBinary();"); } else { out << "ReadString();"; } @@ -2837,11 +2823,7 @@ void t_delphi_generator::generate_serialize_field(ostream& out, break; case t_base_type::TYPE_STRING: if (type->is_binary()) { - if (ansistr_binary_) { - out << "WriteAnsiString("; - } else { - out << "WriteBinary("; - } + out << "WriteBinary("; } else { out << "WriteString("; } @@ -3180,8 +3162,6 @@ string t_delphi_generator::base_type_name(t_base_type* tbase) { return ""; case t_base_type::TYPE_STRING: if (tbase->is_binary()) { - if (ansistr_binary_) - return "System.AnsiString"; if( com_types_) return "IThriftBytes"; if( rtti_) @@ -3400,11 +3380,7 @@ string t_delphi_generator::empty_value(t_type* type) { return "0"; case t_base_type::TYPE_STRING: if (type->is_binary()) { - if (ansistr_binary_) { - return "''"; - } else { - return "nil"; - } + return "nil"; } else { return "''"; } @@ -4072,7 +4048,6 @@ std::string t_delphi_generator::display_name() const { THRIFT_REGISTER_GENERATOR( delphi, "Delphi", - " ansistr_binary: Use AnsiString for binary datatype (default is TBytes).\n" " register_types: Enable TypeRegistry, allows for creation of struct, union\n" " and container instances by interface or TypeInfo()\n" " constprefix: Name TConstants classes after IDL to reduce ambiguities\n" diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas index fd92da9b73b..7cfc2ae651b 100644 --- a/lib/delphi/src/Thrift.Protocol.pas +++ b/lib/delphi/src/Thrift.Protocol.pas @@ -232,7 +232,7 @@ TProtocolRecursionTrackerImpl = class abstract( TInterfacedObject, IProtocolRe procedure WriteI64( const i64: Int64); procedure WriteDouble( const d: Double); procedure WriteString( const s: string ); - procedure WriteAnsiString( const s: AnsiString); + procedure WriteAnsiString( const s: AnsiString); deprecated 'AnsiString routines are deprecated, see THRIFT-5750'; procedure WriteBinary( const b: TBytes); overload; procedure WriteBinary( const b: IThriftBytes); overload; procedure WriteUuid( const uuid: TGuid); @@ -259,7 +259,7 @@ TProtocolRecursionTrackerImpl = class abstract( TInterfacedObject, IProtocolRe function ReadBinaryCOM : IThriftBytes; function ReadUuid: TGuid; function ReadString: string; - function ReadAnsiString: AnsiString; + function ReadAnsiString: AnsiString; deprecated 'AnsiString routines are deprecated, see THRIFT-5750'; function NextRecursionLevel : IProtocolRecursionTracker; procedure IncrementRecursionDepth; @@ -311,7 +311,6 @@ TProtocolImpl = class abstract( TInterfacedObject, IProtocol) procedure WriteI64( const i64: Int64); virtual; abstract; procedure WriteDouble( const d: Double); virtual; abstract; procedure WriteString( const s: string ); virtual; - procedure WriteAnsiString( const s: AnsiString); virtual; procedure WriteBinary( const b: TBytes); overload; virtual; abstract; procedure WriteUuid( const b: TGuid); virtual; abstract; @@ -336,7 +335,6 @@ TProtocolImpl = class abstract( TInterfacedObject, IProtocol) function ReadBinary: TBytes; virtual; abstract; function ReadUuid: TGuid; virtual; abstract; function ReadString: string; virtual; - function ReadAnsiString: AnsiString; virtual; // provide generic implementation for all derived classes procedure WriteBinary( const bytes : IThriftBytes); overload; virtual; @@ -344,6 +342,13 @@ TProtocolImpl = class abstract( TInterfacedObject, IProtocol) property Transport: ITransport read GetTransport; + private + // THRIFT-5750 unit visible, but no longer protected - awaiting final removal + // - Note that you can implement whavetever you want in your derived class, but no longer inherit + // - The function can still be called via IProtocol until final removal + function ReadAnsiString: AnsiString; virtual; //deprecated; + procedure WriteAnsiString( const s: AnsiString); virtual; //deprecated; + public constructor Create( const aTransport : ITransport); virtual; end; @@ -508,7 +513,6 @@ TProtocolDecorator = class( TProtocolImpl) procedure WriteI64( const i64: Int64); override; procedure WriteDouble( const d: Double); override; procedure WriteString( const s: string ); override; - procedure WriteAnsiString( const s: AnsiString); override; procedure WriteBinary( const b: TBytes); override; procedure WriteBinary( const bytes : IThriftBytes); overload; override; procedure WriteUuid( const uuid: TGuid); override; @@ -534,7 +538,15 @@ TProtocolDecorator = class( TProtocolImpl) function ReadBinary: TBytes; override; function ReadUuid: TGuid; override; function ReadString: string; override; - function ReadAnsiString: AnsiString; override; + + private + // THRIFT-5750 unit visible, but no longer protected - awaiting final removal + // - Note that you can implement whavetever you want in your derived class, but no longer inherit + // - The function can still be called via IProtocol until final removal + {$WARN SYMBOL_DEPRECATED OFF} + function ReadAnsiString: AnsiString; override; deprecated; + procedure WriteAnsiString( const s: AnsiString); override; deprecated; + {$WARN SYMBOL_DEPRECATED DEFAULT} end; @@ -1520,7 +1532,9 @@ procedure TProtocolDecorator.WriteString( const s: string ); procedure TProtocolDecorator.WriteAnsiString( const s: AnsiString); begin + {$WARN SYMBOL_DEPRECATED OFF} FWrappedProtocol.WriteAnsiString( s); + {$WARN SYMBOL_DEPRECATED DEFAULT} end; @@ -1670,7 +1684,9 @@ function TProtocolDecorator.ReadString: string; function TProtocolDecorator.ReadAnsiString: AnsiString; begin + {$WARN SYMBOL_DEPRECATED OFF} result := FWrappedProtocol.ReadAnsiString; + {$WARN SYMBOL_DEPRECATED DEFAULT} end; From b703935b8e52569e779bc70dca854e60fd0a3609 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 25 Feb 2024 19:58:30 +0900 Subject: [PATCH 209/250] THRIFT-5755 Docker image build fail This PR submits fixes to the focal and jammy docker images. * Bionic support was dropped becaused dotnet 8 no longer supports bionic (Ubuntu 18.04). Moved to `old/` like other unmaintained images. * Focal/Jammy used the wrong apt location for dotnet, endpoint was 18.04 instead of 20.04/22.04 * Jammy cannot build Erlang OPT 23 since it depends on OpenSSL 1.1 which was dropped in favor of 3.0. Using Erlang OPT 25 fixes the problem since it depends on OpenSSL 3.0 * Jammy was installing JDK 11 but lib/java requires Java 17 All containers used the `root` used to volume map the local files into the running container. This creates a hard to maintain working directory on Linux and MacOS since files form the local user and root user are mixed. To solve this the new docker files can be build using the UID and GID of the host so the files dont mix. The script uses UID and GID 1000 since these are the default ids for most Linux distros. Change the travis yml to build with 20.04 instead of 18.04. Removed all traces of 18.04 but it cant be tested locally. Updated the README to reflect the new `build/docker/` directory. --- .travis.yml | 14 +---------- build/docker/README.md | 24 ++++++++++++------- .../docker/{ => old}/ubuntu-bionic/Dockerfile | 24 +++++++++++++++---- build/docker/ubuntu-focal/Dockerfile | 18 ++++++++++++-- build/docker/ubuntu-jammy/Dockerfile | 23 ++++++++++++++---- 5 files changed, 69 insertions(+), 34 deletions(-) rename build/docker/{ => old}/ubuntu-bionic/Dockerfile (93%) diff --git a/.travis.yml b/.travis.yml index b771d70a4a5..99dd2bc0e2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ env: - SCRIPT="cmake.sh" - BUILD_ARG="" - BUILD_ENV="-e CC=gcc -e CXX=g++ -e THRIFT_CROSSTEST_CONCURRENCY=4" - - DISTRO=ubuntu-bionic + - DISTRO=ubuntu-focal - BUILD_LIBS="CPP C_GLIB JAVA PYTHON TESTING TUTORIALS" # only meaningful for CMake builds - TRAVIS_BUILD_STAGE=test # DOCKER_REPO (this works for all builds as a source for docker images - you can override for fork builds in your Travis settings) @@ -58,12 +58,6 @@ env: jobs: include: # ========================= stage: docker ========================= - - stage: docker - script: true - env: - - JOB="Docker Build ubuntu-bionic 18.04 LTS" - - DISTRO=ubuntu-bionic - - TRAVIS_BUILD_STAGE=docker - script: true env: - JOB="Docker Build ubuntu-focal 20.04 LTS" @@ -131,12 +125,6 @@ jobs: - DISTRO=ubuntu-focal - SCRIPT="autotools.sh" - - script: build/docker/run.sh - env: - - JOB="Autotools (Ubuntu Bionic)" - - DISTRO=ubuntu-bionic - - SCRIPT="autotools.sh" - # ------------------------- phase: cmake ------------------------ - script: build/docker/run.sh env: diff --git a/build/docker/README.md b/build/docker/README.md index 9c9175ff824..3cb1a32237c 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -20,12 +20,12 @@ logic to determine their behavior: | Variable | Default | Usage | | -------- | ----- | ------- | -| `DISTRO` | `ubuntu-bionic` | Set by various build jobs in `.travis.yml` to run builds in different containers. Not intended to be set externally.| +| `DISTRO` | `ubuntu-focal` | Set by various build jobs in `.travis.yml` to run builds in different containers. Not intended to be set externally.| | `DOCKER_REPO` | `thrift/thrift-build` | The name of the Docker Hub repository to obtain and store docker images. | | `DOCKER_USER` | `` | The Docker Hub account name containing the repository. | | `DOCKER_PASS` | `` | The Docker Hub account password to use when pushing new tags. | -For example, the default docker image that is used in builds if no overrides are specified would be: `thrift/thrift-build:ubuntu-bionic` +For example, the default docker image that is used in builds if no overrides are specified would be: `thrift/thrift-build:ubuntu-focal` ### Forks ### @@ -46,14 +46,13 @@ Docker Hub and push the resulting tags. ## Supported Containers ## -The Travis CI (continuous integration) builds use the Ubuntu Bionic -(18.04 LTS) and Xenial (16.04 LTS) images to maximize language level +The Travis CI (continuous integration) builds use the Ubuntu Jammy +(22.04 LTS) and Focal (20.04 LTS) images to maximize language level coverage. ### Ubuntu ### * focal (stable, current) -* bionic (previous stable) * jammy (next stable, WIP) ## Unsupported Containers ## @@ -105,16 +104,16 @@ Then, to pull down the current image being used to build (the same way Travis CI does it) - if it is out of date in any way it will build a new one for you: - thrift$ DOCKER_REPO=thrift/thrift-build DISTRO=ubuntu-bionic build/docker/refresh.sh + thrift$ DOCKER_REPO=thrift/thrift-build DISTRO=ubuntu-focal build/docker/refresh.sh To run all unit tests (just like Travis CI does): - thrift$ dockerrun thrift/thrift-build:ubuntu-bionic + thrift$ dockerrun thrift/thrift-build:ubuntu-focal root@8caf56b0ce7b:/thrift/src# build/docker/scripts/autotools.sh To run the cross tests (just like Travis CI does): - thrift$ dockerrun thrift/thrift-build:ubuntu-bionic + thrift$ dockerrun thrift/thrift-build:ubuntu-focal root@8caf56b0ce7b:/thrift/src# build/docker/scripts/cross-test.sh When you are done, you want to clean up occasionally so that docker isn't using lots of extra disk space: @@ -136,7 +135,14 @@ If you do not want to use the same scripts Travis CI does, you can do it manuall Build the image: - thrift$ docker build -t thrift build/docker/ubuntu-bionic +Linux/Mac: + + thrift$ docker build --build-arg uid=$(id -u) --build-arg gid=$(id -g) -t thrift build/docker/ubuntu-jammy + +Windows: + + thrift$ docker build -t thrift build/docker/ubuntu-jammy + Open a command prompt in the image: diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/old/ubuntu-bionic/Dockerfile similarity index 93% rename from build/docker/ubuntu-bionic/Dockerfile rename to build/docker/old/ubuntu-bionic/Dockerfile index 5ece6e10d1c..6d337d7ea32 100644 --- a/build/docker/ubuntu-bionic/Dockerfile +++ b/build/docker/old/ubuntu-bionic/Dockerfile @@ -124,10 +124,10 @@ ENV PATH /usr/lib/dart/bin:$PATH RUN apt-get install -y --no-install-recommends \ `# dotnet core dependencies` \ - dotnet-sdk-8.0 \ - dotnet-runtime-8.0 \ - aspnetcore-runtime-8.0 \ - dotnet-apphost-pack-8.0 + dotnet-sdk-7.0 \ + dotnet-runtime-7.0 \ + aspnetcore-runtime-7.0 \ + dotnet-apphost-pack-7.0 # Erlang dependencies ARG ERLANG_OTP_VERSION=23.3.4.11 @@ -298,7 +298,21 @@ RUN apt-get install -y --no-install-recommends \ # rm -rf /tmp/* && \ # rm -rf /var/tmp/* +ARG user=build +ARG group=build +ARG uid=1000 +ARG gid=1000 + +RUN apt-get install -y --no-install-recommends sudo && \ + echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \ + if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ + adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \ + echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src +RUN mkdir -p $THRIFT_ROOT/src && \ + chown -R ${uid}:${uid} $THRIFT_ROOT/ COPY Dockerfile $THRIFT_ROOT/ WORKDIR $THRIFT_ROOT/src + +USER ${user} diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index 416e806469c..00ab2be95b7 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -39,7 +39,7 @@ RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - & # dotnet (netcore) RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \ - wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/ubuntu/18.04/prod.list && \ + wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/ubuntu/20.04/prod.list && \ chown root:root /etc/apt/trusted.gpg.d/microsoft.gpg && \ chown root:root /etc/apt/sources.list.d/microsoft-prod.list @@ -280,7 +280,21 @@ RUN apt-get install -y --no-install-recommends \ # rm -rf /tmp/* && \ # rm -rf /var/tmp/* +ARG user=build +ARG group=build +ARG uid=1000 +ARG gid=1000 + +RUN apt-get install -y --no-install-recommends sudo && \ + echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \ + if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ + adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \ + echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src +RUN mkdir -p $THRIFT_ROOT/src && \ + chown -R ${uid}:${uid} $THRIFT_ROOT/ COPY Dockerfile $THRIFT_ROOT/ WORKDIR $THRIFT_ROOT/src + +USER ${user} diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index a10fea6500a..d214b9fc7aa 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -39,7 +39,7 @@ RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - & # dotnet (netcore) RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \ - wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/ubuntu/18.04/prod.list && \ + wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/ubuntu/22.04/prod.list && \ chown root:root /etc/apt/trusted.gpg.d/microsoft.gpg && \ chown root:root /etc/apt/sources.list.d/microsoft-prod.list @@ -84,7 +84,6 @@ RUN apt-get install -y --no-install-recommends \ libboost-all-dev \ libevent-dev \ libssl-dev \ - qt5-default \ qtbase5-dev \ qtbase5-dev-tools @@ -131,7 +130,7 @@ RUN apt-get install -y --no-install-recommends \ dotnet-apphost-pack-8.0 # Erlang dependencies -ARG ERLANG_OTP_VERSION=23.3.4.11 +ARG ERLANG_OTP_VERSION=25.3.2.9 ARG ERLANG_REBAR_VERSION=3.18.0 RUN apt-get update && apt-get install -y --no-install-recommends libncurses5-dev && \ curl -ssLo /usr/local/bin/kerl https://raw.githubusercontent.com/kerl/kerl/master/kerl && chmod +x /usr/local/bin/kerl && \ @@ -168,7 +167,7 @@ RUN apt-get install -y --no-install-recommends \ ant \ ant-optional \ maven \ - openjdk-11-jdk-headless && \ + openjdk-17-jdk-headless && \ `# Gradle` \ wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ @@ -280,7 +279,21 @@ RUN apt-get install -y --no-install-recommends \ # rm -rf /tmp/* && \ # rm -rf /var/tmp/* +ARG user=build +ARG group=build +ARG uid=1000 +ARG gid=1000 + +RUN apt-get install -y --no-install-recommends sudo && \ + echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \ + if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ + adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \ + echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src +RUN mkdir -p $THRIFT_ROOT/src && \ + chown -R ${uid}:${uid} $THRIFT_ROOT/ COPY Dockerfile $THRIFT_ROOT/ WORKDIR $THRIFT_ROOT/src + +USER ${user} From 44f0a9df160fef77a1a0a31325598cff842a350e Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 28 Feb 2024 19:27:41 +0900 Subject: [PATCH 210/250] Remove `old/` directory from `build/docker` since its not maintained/used --- build/docker/old/Vagrantfile | 59 ---- build/docker/old/centos-7.3/Dockerfile | 196 ------------- build/docker/old/debian-jessie/Dockerfile | 197 ------------- build/docker/old/debian-stretch/Dockerfile | 225 --------------- build/docker/old/ubuntu-artful/Dockerfile | 260 ----------------- build/docker/old/ubuntu-bionic/Dockerfile | 318 --------------------- build/docker/old/ubuntu-disco/Dockerfile | 296 ------------------- build/docker/old/ubuntu-trusty/Dockerfile | 235 --------------- build/docker/old/ubuntu-xenial/Dockerfile | 273 ------------------ 9 files changed, 2059 deletions(-) delete mode 100644 build/docker/old/Vagrantfile delete mode 100644 build/docker/old/centos-7.3/Dockerfile delete mode 100644 build/docker/old/debian-jessie/Dockerfile delete mode 100644 build/docker/old/debian-stretch/Dockerfile delete mode 100644 build/docker/old/ubuntu-artful/Dockerfile delete mode 100644 build/docker/old/ubuntu-bionic/Dockerfile delete mode 100644 build/docker/old/ubuntu-disco/Dockerfile delete mode 100644 build/docker/old/ubuntu-trusty/Dockerfile delete mode 100644 build/docker/old/ubuntu-xenial/Dockerfile diff --git a/build/docker/old/Vagrantfile b/build/docker/old/Vagrantfile deleted file mode 100644 index 5eac6e6865f..00000000000 --- a/build/docker/old/Vagrantfile +++ /dev/null @@ -1,59 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Base system bootstrap script -$bootstrap_script = <<__BOOTSTRAP__ -echo "Provisioning defaults" - -sudo apt-get update -y -sudo apt-get upgrade -y - -# Install default packages -sudo apt-get install -y build-essential curl git - -# Install latest Docker version -sudo curl -sSL https://get.docker.io/gpg | sudo apt-key add - -sudo echo "deb http://get.docker.io/ubuntu docker main" > /etc/apt/sources.list.d/docker.list -sudo apt-get update -y -sudo apt-get install -y linux-image-extra-`uname -r` aufs-tools -sudo apt-get install -y lxc-docker - -echo "Finished provisioning defaults" -__BOOTSTRAP__ - -Vagrant.configure("2") do |config| - config.vm.box = "trusty64" - config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box" - config.ssh.forward_agent = true - - config.vm.provider :virtualbox do |vbox| - vbox.customize ["modifyvm", :id, "--memory", "1024"] - vbox.customize ["modifyvm", :id, "--cpus", "2"] - end - - # Setup the default bootstrap script for our ubuntu base box image - config.vm.provision "shell", inline: $bootstrap_script - - # Setup the custom docker image from our Ubuntu Dockerfile - config.vm.provision "docker" do |d| - d.build_image "/vagrant/ubuntu", args: "-t thrift" - end - - # Setup the custom docker image from our Centos Dockerfile - #config.vm.provision "docker" do |d| - # d.build_image "/vagrant/centos", args: "-t thrift-centos" - #end - -end diff --git a/build/docker/old/centos-7.3/Dockerfile b/build/docker/old/centos-7.3/Dockerfile deleted file mode 100644 index ba4c54926fd..00000000000 --- a/build/docker/old/centos-7.3/Dockerfile +++ /dev/null @@ -1,196 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Apache Thrift Docker build environment for CentOS -# -# Known missing client libraries: -# - dotnet (will update to 2.0.0 separately) -# - haxe (not in centos) - -FROM centos:7.3.1611 -MAINTAINER Apache Thrift - -RUN yum install -y epel-release - -# General dependencies -RUN yum install -y \ - autoconf \ - bison \ - bison-devel \ - clang \ - clang-analyzer \ - cmake3 \ - curl \ - flex \ - gcc \ - gcc-c++ \ - gdb \ - git \ - libtool \ - m4 \ - make \ - tar \ - unzip \ - valgrind \ - wget && \ - ln -s /usr/bin/cmake3 /usr/bin/cmake && \ - ln -s /usr/bin/cpack3 /usr/bin/cpack && \ - ln -s /usr/bin/ctest3 /usr/bin/ctest - -# C++ dependencies -RUN yum install -y \ - boost-devel-static \ - zlib-devel \ - openssl-devel \ - libevent-devel && \ - cd /usr/lib64 && \ - ln -s libboost_thread-mt.a libboost_thread.a - -# C# Dependencies -RUN yum install -y \ - mono-core \ - mono-devel \ - mono-web-devel \ - mono-extras - -# D Dependencies -RUN yum install -y http://downloads.dlang.org/releases/2.x/2.076.0/dmd-2.076.0-0.fedora.x86_64.rpm xdg-utils -RUN curl -sSL https://github.com/D-Programming-Deimos/openssl/archive/master.tar.gz| tar xz && \ - curl -sSL https://github.com/D-Programming-Deimos/libevent/archive/master.tar.gz| tar xz && \ - mkdir -p /usr/include/dmd/druntime/import/deimos /usr/include/dmd/druntime/import/C && \ - mv libevent-master/deimos/* openssl-master/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv libevent-master/C/* openssl-master/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf libevent-master openssl-master - -# Dart -RUN cd /usr/local && \ - wget -q https://storage.googleapis.com/dart-archive/channels/stable/release/1.24.2/sdk/dartsdk-linux-x64-release.zip && \ - unzip -q dartsdk-linux-x64-release.zip && \ - rm dartsdk-linux-x64-release.zip -ENV PATH /usr/local/dart-sdk/bin:$PATH - -# Erlang Dependencies -RUN curl -sSL http://packages.erlang-solutions.com/rpm/centos/erlang_solutions.repo -o /etc/yum.repos.d/erlang_solutions.repo && \ - yum install -y \ - erlang-kernel \ - erlang-erts \ - erlang-stdlib \ - erlang-eunit \ - erlang-rebar \ - erlang-tools - -# GLibC Dependencies -RUN yum install -y glib2-devel - -# Go Dependencies -RUN curl -sSL https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz | tar -C /usr/local/ -xz -ENV PATH /usr/local/go/bin:$PATH - -# Haxe Dependencies -# Not in debian/stretch - -# Java Dependencies -RUN yum install -y \ - ant \ - junit \ - ant-junit \ - java-1.8.0-openjdk-devel - -# Lua Dependencies -# Lua in epel is too old (5.1.4, need 5.2) so we get the latest -RUN yum install -y readline-devel && \ - wget -q http://www.lua.org/ftp/lua-5.3.4.tar.gz && \ - tar xzf lua-5.3.4.tar.gz && \ - cd lua-5.3.4 && \ - sed -i 's/CFLAGS= /CFLAGS= -fPIC /g' src/Makefile && \ - make linux && \ - make install && \ - cd .. && \ - rm -rf lua-5* - -# MinGW Dependencies -RUN yum install -y \ - mingw32-binutils \ - mingw32-crt \ - mingw32-nsis - -# Node.js Dependencies -# Work around epel issue where they removed http-parser that nodejs depends on! -RUN yum -y install https://opensource.enda.eu/packages/http-parser-2.7.1-3.el7.x86_64.rpm -RUN yum install -y \ - nodejs \ - npm - -# Ocaml Dependencies -RUN yum install -y \ - ocaml \ - ocaml-ocamldoc && \ - wget -q https://raw.github.com/ocaml/opam/master/shell/opam_installer.sh -O - | sh -s /usr/local/bin && \ - opam init --yes && \ - opam install --yes oasis && \ - echo '. /root/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true' >> ~/.bashrc - -# Perl Dependencies -RUN yum install -y \ - perl \ - perl-version \ - perl-Bit-Vector \ - perl-Class-Accessor \ - perl-ExtUtils-MakeMaker \ - perl-Test-Simple \ - perl-IO-Socket-SSL \ - perl-Net-SSLeay \ - perl-Crypt-SSLeay - -# PHP Dependencies -RUN yum install -y \ - php \ - php-devel \ - php-pear \ - re2c \ - php-phpunit-PHPUnit \ - bzip2 - -# Python Dependencies -RUN yum install -y \ - python \ - python-devel \ - python-pip \ - python-setuptools \ - python34 \ - python34-devel \ - python34-pip \ - python34-setuptools -RUN pip2 install --upgrade pip -RUN pip2 install --upgrade backports.ssl_match_hostname ipaddress setuptools six tornado tornado-testing twisted virtualenv zope-interface -RUN pip3 install --upgrade pip -RUN pip3 install --upgrade backports.ssl_match_hostname ipaddress setuptools six tornado tornado-testing twisted virtualenv zope-interface - -# Ruby Dependencies -RUN yum install -y \ - ruby \ - ruby-devel \ - rubygems && \ - gem install bundler rake - -# Rust -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.17.0 -ENV PATH /root/.cargo/bin:$PATH - -# Clean up -RUN rm -rf /tmp/* && \ - yum clean all - -ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src -COPY Dockerfile $THRIFT_ROOT/ -WORKDIR $THRIFT_ROOT/src diff --git a/build/docker/old/debian-jessie/Dockerfile b/build/docker/old/debian-jessie/Dockerfile deleted file mode 100644 index 15e02e9c181..00000000000 --- a/build/docker/old/debian-jessie/Dockerfile +++ /dev/null @@ -1,197 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Apache Thrift Docker build environment for Debian -# -# Known missing client libraries: -# - dotnetcore -# - rust - -FROM buildpack-deps:jessie-scm -MAINTAINER Apache Thrift - -ENV DEBIAN_FRONTEND noninteractive - -# Add apt sources -# jessie-backports for cmake and some ruby bits -RUN echo "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list - -# Dart -RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \ - sed -i /etc/apt/sources.list.d/dart_stable.list -e 's/https:/http:/g' - -RUN apt-get update && apt-get install -y --no-install-recommends \ -`# General dependencies` \ - bison \ - build-essential \ - clang \ - debhelper \ - flex \ - pkg-config && \ - apt-get -t jessie-backports install -y --no-install-recommends cmake - -RUN apt-get install -y --no-install-recommends \ -`# C++ dependencies` \ - libboost-dev \ - libboost-filesystem-dev \ - libboost-program-options-dev \ - libboost-system-dev \ - libboost-test-dev \ - libboost-thread-dev \ - libevent-dev \ - libssl-dev \ - qt5-default \ - qtbase5-dev \ - qtbase5-dev-tools - -RUN apt-get install -y --no-install-recommends \ -`# Java dependencies` \ - ant \ - ant-optional \ - openjdk-7-jdk \ - maven - -RUN apt-get install -y --no-install-recommends \ -`# Python dependencies` \ - python-all \ - python-all-dbg \ - python-all-dev \ - python-pip \ - python-setuptools \ - python-twisted \ - python-zope.interface \ - python3-all \ - python3-all-dbg \ - python3-all-dev \ - python3-setuptools \ - python3-pip - -RUN apt-get install -y --no-install-recommends \ -`# Ruby dependencies` \ - ruby \ - ruby-bundler \ - ruby-dev \ -`# Perl dependencies` \ - libbit-vector-perl \ - libclass-accessor-class-perl \ - libcrypt-ssleay-perl \ - libio-socket-ssl-perl \ - libnet-ssleay-perl - -RUN apt-get -t jessie-backports install -y ruby-bundler -RUN apt-get install -y --no-install-recommends \ -`# Php dependencies` \ - php5 \ - php5-dev \ - php5-cli \ - php-pear \ - re2c \ - phpunit \ -`# GlibC dependencies` \ - libglib2.0-dev - -RUN apt-get update && apt-get install -y --no-install-recommends \ -`# Erlang dependencies` \ - erlang-base \ - erlang-eunit \ - erlang-dev \ - erlang-tools \ - rebar - -RUN apt-get update && apt-get install -y --no-install-recommends \ -`# Haxe dependencies` \ - neko \ - neko-dev \ - libneko0 - -RUN apt-get update && apt-get install -y --no-install-recommends \ -`# Node.js dependencies` \ - nodejs \ - nodejs-dev \ - nodejs-legacy \ - npm - -RUN apt-get update && apt-get install -y --no-install-recommends \ -`# D dependencies` \ - xdg-utils \ -`# Dart dependencies` \ - dart \ -`# Lua dependencies` \ - lua5.2 \ - lua5.2-dev \ -`# MinGW dependencies` \ - mingw32 \ - mingw32-binutils \ -`# mingw32-runtime` \ - nsis \ -`# Clean up` \ - && rm -rf /var/cache/apt/* && \ - rm -rf /var/lib/apt/lists/* && \ - rm -rf /tmp/* && \ - rm -rf /var/tmp/* - -# Ruby -RUN gem install bundler --no-ri --no-rdoc - -# Python optional dependencies -RUN pip2 install -U ipaddress backports.ssl_match_hostname tornado -RUN pip3 install -U backports.ssl_match_hostname tornado - -# Go -RUN curl -sSL https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz -ENV PATH /usr/local/go/bin:$PATH - -# Haxe -RUN mkdir -p /usr/lib/haxe && \ - wget -O - https://github.com/HaxeFoundation/haxe/releases/download/3.2.1/haxe-3.2.1-linux64.tar.gz | \ - tar -C /usr/lib/haxe --strip-components=1 -xz && \ - ln -s /usr/lib/haxe/haxe /usr/bin/haxe && \ - ln -s /usr/lib/haxe/haxelib /usr/bin/haxelib && \ - mkdir -p /usr/lib/haxe/lib && \ - chmod -R 777 /usr/lib/haxe/lib && \ - haxelib setup /usr/lib/haxe/lib && \ - haxelib install hxcpp - -# D -RUN curl -sSL http://downloads.dlang.org/releases/2.x/2.070.0/dmd_2.070.0-0_amd64.deb -o /tmp/dmd_2.070.0-0_amd64.deb && \ - dpkg -i /tmp/dmd_2.070.0-0_amd64.deb && \ - rm /tmp/dmd_2.070.0-0_amd64.deb && \ - curl -sSL https://github.com/D-Programming-Deimos/openssl/archive/master.tar.gz| tar xz && \ - curl -sSL https://github.com/D-Programming-Deimos/libevent/archive/master.tar.gz| tar xz && \ - mkdir -p /usr/include/dmd/druntime/import/deimos /usr/include/dmd/druntime/import/C && \ - mv libevent-master/deimos/* openssl-master/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv libevent-master/C/* openssl-master/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf libevent-master openssl-master && \ - echo 'gcc -Wl,--no-as-needed $*' > /usr/local/bin/gcc-dmd && \ - chmod 755 /usr/local/bin/gcc-dmd && \ - echo 'CC=/usr/local/bin/gcc-dmd' >> /etc/dmd.conf - -# Dart -ENV PATH /usr/lib/dart/bin:$PATH - -# OCaml -RUN echo 'deb http://ppa.launchpad.net/avsm/ppa/ubuntu trusty main' > /etc/apt/sources.list.d/avsm-official-ocaml.list && \ - gpg --keyserver keyserver.ubuntu.com --recv 61707B09 && \ - gpg --export --armor 61707B09 | apt-key add - && \ - apt-get update && \ - apt-get install -y ocaml opam && \ - opam init && \ - opam install oasis - -# Force utf8 locale to successfully build Haskell tf-random -ENV LC_ALL C.UTF-8 - -ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src -COPY Dockerfile $THRIFT_ROOT/ -WORKDIR $THRIFT_ROOT/src diff --git a/build/docker/old/debian-stretch/Dockerfile b/build/docker/old/debian-stretch/Dockerfile deleted file mode 100644 index f584bba9a96..00000000000 --- a/build/docker/old/debian-stretch/Dockerfile +++ /dev/null @@ -1,225 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Apache Thrift Docker build environment for Debian Stretch -# -# Known issues: -# - d: deimos for libevent and openssl disabled - build errors -# - dotnetcore, because netcore is for 1.0.0-preview and 2.0.0 is out -# - rust: cargo not in debian repo - perhaps not needed? - -FROM buildpack-deps:stretch-scm -MAINTAINER Apache Thrift - -ENV DEBIAN_FRONTEND noninteractive - -### Add apt repos - -RUN apt-get update && apt-get install -y --no-install-recommends apt apt-transport-https curl wget apt-utils - -# D -RUN wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list && \ - apt-get update && apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring - -# Dart -RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \ - sed -i /etc/apt/sources.list.d/dart_stable.list -e 's/https:/http:/g' - -# dotnet (core) 2.0.0 - project isn't ready for this yet: -# RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \ -# echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list - -# node.js (this step runs apt-get update internally) -RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - - -### install general dependencies -RUN apt-get install -y --no-install-recommends \ -`# General dependencies` \ - bash-completion \ - bison \ - build-essential \ - clang \ - cmake \ - debhelper \ - flex \ - gdb \ - ninja-build \ - pkg-config \ - valgrind \ - vim - - -### languages - -RUN apt-get install -y --no-install-recommends \ -`# C++ dependencies` \ - libboost-dev \ - libboost-filesystem-dev \ - libboost-program-options-dev \ - libboost-system-dev \ - libboost-test-dev \ - libboost-thread-dev \ - libevent-dev \ - libssl-dev \ - qt5-default \ - qtbase5-dev \ - qtbase5-dev-tools - -RUN apt-get install -y --no-install-recommends \ -`# D dependencies` \ - dmd-bin \ - libevent-dev \ - libssl-dev \ - xdg-utils -# libevent deimos disabled - build errors -# RUN mkdir -p /usr/include/dmd/druntime/import/deimos /usr/include/dmd/druntime/import/C && \ -# curl -sSL https://github.com/D-Programming-Deimos/libevent/archive/master.tar.gz| tar xz && \ -# mv libevent-master/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ -# mv libevent-master/C/* /usr/include/dmd/druntime/import/C/ && \ -# rm -rf libevent-master -# openssl deimos doesn't work with openssl-1.1.0 - disabling it for now: -# RUN curl -sSL https://github.com/D-Programming-Deimos/openssl/archive/master.tar.gz| tar xz && \ -# mv openssl-master/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ -# mv openssl-master/C/* /usr/include/dmd/druntime/import/C/ && \ -# rm -rf openssl-master - -RUN apt-get install -y --no-install-recommends \ -`# Dart dependencies` \ - dart -ENV PATH /usr/lib/dart/bin:$PATH - -# project isn't ready for this quite yet: -# RUN apt-get install -y --no-install-recommends \ -# `# dotnet core dependencies` \ -# dotnet-sdk-8.0 \ -# dotnet-runtime-8.0 \ -# aspnetcore-runtime-8.0 \ -# dotnet-apphost-pack-8.0 - -RUN apt-get install -y --no-install-recommends \ -`# Erlang dependencies` \ - erlang-base \ - erlang-eunit \ - erlang-dev \ - erlang-tools \ - rebar - -RUN apt-get install -y --no-install-recommends \ -`# GlibC dependencies` \ - libglib2.0-dev - -RUN apt-get install -y --no-install-recommends \ -`# golang (go) dependencies` \ - golang-go - -RUN apt-get install -y --no-install-recommends \ -`# Haxe dependencies` \ - haxe \ - neko \ - neko-dev -RUN haxelib setup --always /usr/share/haxe/lib && \ - haxelib install --always hxcpp - -RUN apt-get install -y --no-install-recommends \ -`# Java dependencies` \ - ant \ - ant-optional \ - openjdk-8-jdk \ - maven - -RUN apt-get install -y --no-install-recommends \ -`# Lua dependencies` \ - lua5.2 \ - lua5.2-dev -# https://bugs.launchpad.net/ubuntu/+source/lua5.3/+bug/1707212 -# same for debian stretch -# lua5.3 does not install alternatives so stick with 5.2 here - -RUN apt-get install -y --no-install-recommends \ -`# Node.js dependencies` \ - nodejs - -RUN apt-get install -y --no-install-recommends \ -`# OCaml dependencies` \ - ocaml \ - opam && \ - opam init --yes && \ - opam install --yes oasis - -RUN apt-get install -y --no-install-recommends \ -`# Perl dependencies` \ - libbit-vector-perl \ - libclass-accessor-class-perl \ - libcrypt-ssleay-perl \ - libio-socket-ssl-perl \ - libnet-ssleay-perl - -RUN apt-get install -y --no-install-recommends \ -`# Php dependencies` \ - php7.0 \ - php7.0-cli \ - php7.0-dev \ - php-pear \ - re2c \ - phpunit - -RUN apt-get install -y --no-install-recommends \ -`# Python dependencies` \ - python-all \ - python-all-dbg \ - python-all-dev \ - python-backports.ssl-match-hostname \ - python-ipaddress \ - python-pip \ - python-setuptools \ - python-six \ - python-tornado \ - python-twisted \ - python-wheel \ - python-zope.interface \ - python3-all \ - python3-all-dbg \ - python3-all-dev \ - python3-setuptools \ - python3-six \ - python3-tornado \ - python3-twisted \ - python3-wheel \ - python3-zope.interface && \ - pip install --upgrade backports.ssl_match_hostname - -RUN apt-get install -y --no-install-recommends \ -`# Ruby dependencies` \ - ruby \ - ruby-dev \ - ruby-bundler -RUN gem install bundler --no-ri --no-rdoc - -RUN apt-get install -y --no-install-recommends \ -`# Rust dependencies` \ - rustc - -# Update anything else left hanging -RUN apt-get dist-upgrade -y - -# Clean up -RUN rm -rf /var/cache/apt/* && \ - rm -rf /var/lib/apt/lists/* && \ - rm -rf /tmp/* && \ - rm -rf /var/tmp/* - -ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src -COPY Dockerfile $THRIFT_ROOT/ -WORKDIR $THRIFT_ROOT/src diff --git a/build/docker/old/ubuntu-artful/Dockerfile b/build/docker/old/ubuntu-artful/Dockerfile deleted file mode 100644 index f94b70086b5..00000000000 --- a/build/docker/old/ubuntu-artful/Dockerfile +++ /dev/null @@ -1,260 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Apache Thrift Docker build environment for Ubuntu Artful -# Using all stock Ubuntu Artful packaging except for: -# - cpp: stock boost 1.62 in artful has a nasty bug so we use stock boost 1.63 -# - d: dmd does not come with Ubuntu -# - dart: does not come with Ubuntu. Pinned to last 1.x release -# - dotnet: does not come with Ubuntu -# - haxe: version 3.4.2 that comes with Ubuntu cores in our CI build -# - go: artful comes with 1.9, we want the latest (supported) -# - nodejs: want v8, artful comes with v6 -# - -FROM buildpack-deps:artful-scm -MAINTAINER Apache Thrift -ENV DEBIAN_FRONTEND noninteractive - -### Add apt repos - -RUN apt-get update && \ - apt-get dist-upgrade -y && \ - apt-get install -y --no-install-recommends \ - apt \ - apt-transport-https \ - apt-utils \ - curl \ - dirmngr \ - software-properties-common \ - wget - -# Dart -RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > \ - /etc/apt/sources.list.d/dart_stable.list -ENV DART_VERSION 1.24.3-1 - -# dotnet (netcore) -RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \ - echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-artful-prod artful main" > \ - /etc/apt/sources.list.d/dotnetdev.list - -# haxe (https://haxe.org/download/linux/) -RUN add-apt-repository ppa:haxe/releases -y - -# node.js -RUN curl -sL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \ - echo "deb https://deb.nodesource.com/node_8.x artful main" | tee /etc/apt/sources.list.d/nodesource.list - -### install general dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ -`# General dependencies` \ - bash-completion \ - bison \ - build-essential \ - clang \ - cmake \ - debhelper \ - flex \ - gdb \ - llvm \ - ninja-build \ - pkg-config \ - valgrind \ - vim -ENV PATH /usr/lib/llvm-3.8/bin:$PATH - -# boost-1.62 has a terrible bug in boost::test, see https://svn.boost.org/trac10/ticket/12507 -RUN apt-get install -y --no-install-recommends \ -`# C++ dependencies` \ - libboost1.63-all-dev \ - libevent-dev \ - libssl-dev \ - qt5-default \ - qtbase5-dev \ - qtbase5-dev-tools - -ENV SBCL_VERSION 1.4.5 -RUN \ -`# Common Lisp (sbcl) dependencies` \ - curl --version && \ - curl -O -J -L https://kent.dl.sourceforge.net/project/sbcl/sbcl/${SBCL_VERSION}/sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 && \ - tar xjf sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 && \ - cd sbcl-${SBCL_VERSION}-x86-64-linux && \ - ./install.sh && \ - sbcl --version && \ - rm -rf sbcl* - -ENV D_VERSION 2.080.0 -ENV DMD_DEB dmd_2.080.0-0_amd64.deb -RUN \ -`# D dependencies` \ - wget -q http://downloads.dlang.org/releases/2.x/${D_VERSION}/${DMD_DEB} && \ - dpkg --install ${DMD_DEB} && \ - rm -f ${DMD_DEB} && \ - mkdir -p /usr/include/dmd/druntime/import/deimos /usr/include/dmd/druntime/import/C && \ - curl -sSL https://github.com/D-Programming-Deimos/libevent/archive/master.tar.gz| tar xz && \ - mv libevent-master/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv libevent-master/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf libevent-master && \ - curl -sSL https://github.com/D-Programming-Deimos/openssl/archive/master.tar.gz| tar xz && \ - mv openssl-master/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv openssl-master/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf openssl-master - -RUN apt-get install -y --no-install-recommends \ -`# Dart dependencies` \ - dart=$DART_VERSION -ENV PATH /usr/lib/dart/bin:$PATH - -RUN apt-get install -y --no-install-recommends \ -`# dotnet core dependencies` \ - dotnet-sdk-8.0 \ - dotnet-runtime-8.0 \ - aspnetcore-runtime-8.0 \ - dotnet-apphost-pack-8.0 - -RUN apt-get install -y --no-install-recommends \ -`# Erlang dependencies` \ - erlang-base \ - erlang-eunit \ - erlang-dev \ - erlang-tools \ - rebar - -RUN apt-get install -y --no-install-recommends \ -`# GlibC dependencies` \ - libglib2.0-dev - -# golang -ENV GOLANG_VERSION 1.10 -ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 b5a64335f1490277b585832d1f6c7f8c6c11206cba5cd3f771dcb87b98ad1a33 -RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ - echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \ - tar -C /usr/local -xzf golang.tar.gz && \ - ln -s /usr/local/go/bin/go /usr/local/bin && \ - rm golang.tar.gz - -RUN apt-get install -y --no-install-recommends \ -`# Haxe dependencies` \ - haxe \ - neko \ - neko-dev && \ - haxelib setup --always /usr/share/haxe/lib && \ - haxelib install --always hxcpp 2>&1 > /dev/null - -RUN apt-get install -y --no-install-recommends \ -`# Java dependencies` \ - ant \ - ant-optional \ - openjdk-8-jdk \ - maven - -RUN apt-get install -y --no-install-recommends \ -`# Lua dependencies` \ - lua5.2 \ - lua5.2-dev -# https://bugs.launchpad.net/ubuntu/+source/lua5.3/+bug/1707212 -# lua5.3 does not install alternatives! -# need to update our luasocket code, lua doesn't have luaL_openlib any more - -RUN apt-get install -y --no-install-recommends \ -`# Node.js dependencies` \ - nodejs - -# Test dependencies for running puppeteer -RUN apt-get install -y --no-install-recommends \ -`# JS dependencies` \ - libxss1 - -RUN apt-get install -y --no-install-recommends \ -`# OCaml dependencies` \ - ocaml \ - opam && \ - opam init --yes && \ - opam install --yes oasis - -RUN apt-get install -y --no-install-recommends \ -`# Perl dependencies` \ - libbit-vector-perl \ - libclass-accessor-class-perl \ - libcrypt-ssleay-perl \ - libio-socket-ssl-perl \ - libnet-ssleay-perl - -RUN apt-get install -y --no-install-recommends \ -`# Php dependencies` \ - php \ - php-cli \ - php-dev \ - php-pear \ - re2c \ - composer - -RUN apt-get install -y --no-install-recommends \ -`# Python dependencies` \ - python-all \ - python-all-dbg \ - python-all-dev \ - python-ipaddress \ - python-pip \ - python-setuptools \ - python-six \ - python-tornado \ - python-twisted \ - python-wheel \ - python-zope.interface && \ - pip install --upgrade backports.ssl_match_hostname - -RUN apt-get install -y --no-install-recommends \ -`# Python3 dependencies` \ - python3-all \ - python3-all-dbg \ - python3-all-dev \ - python3-pip \ - python3-setuptools \ - python3-six \ - python3-tornado \ - python3-twisted \ - python3-wheel \ - python3-zope.interface - -RUN apt-get install -y --no-install-recommends \ -`# Ruby dependencies` \ - ruby \ - ruby-dev \ - ruby-bundler - -RUN apt-get install -y --no-install-recommends \ -`# Rust dependencies` \ - cargo \ - rustc - -RUN apt-get install -y --no-install-recommends \ -`# Static Code Analysis dependencies` \ - cppcheck \ - sloccount && \ - pip install flake8 - -# Clean up -RUN rm -rf /var/cache/apt/* && \ - rm -rf /var/lib/apt/lists/* && \ - rm -rf /tmp/* && \ - rm -rf /var/tmp/* - -ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src -COPY Dockerfile $THRIFT_ROOT/ -WORKDIR $THRIFT_ROOT/src diff --git a/build/docker/old/ubuntu-bionic/Dockerfile b/build/docker/old/ubuntu-bionic/Dockerfile deleted file mode 100644 index 6d337d7ea32..00000000000 --- a/build/docker/old/ubuntu-bionic/Dockerfile +++ /dev/null @@ -1,318 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Apache Thrift Docker build environment for Ubuntu Bionic -# with some updated packages. -# - -FROM buildpack-deps:bionic-scm -LABEL MAINTAINER='Apache Thrift ' -ENV DEBIAN_FRONTEND noninteractive - -### Add apt repos - -RUN apt-get update -yq && \ - apt-get dist-upgrade -y && \ - apt-get install -y --no-install-recommends --fix-missing \ - apt \ - apt-transport-https \ - apt-utils \ - curl \ - dirmngr \ - software-properties-common \ - wget - -# Dart -RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > \ - /etc/apt/sources.list.d/dart_stable.list - -# dotnet (netcore) -RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \ - wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/ubuntu/18.04/prod.list && \ - chown root:root /etc/apt/trusted.gpg.d/microsoft.gpg && \ - chown root:root /etc/apt/sources.list.d/microsoft-prod.list - -# node.js -RUN curl -sL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \ - echo "deb https://deb.nodesource.com/node_10.x bionic main" | tee /etc/apt/sources.list.d/nodesource.list - -### install general dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - `# General dependencies` \ - bash-completion \ - bison \ - build-essential \ - clang \ - cmake \ - debhelper \ - flex \ - gdb \ - libasound2 \ - libatk-bridge2.0-0 \ - libgtk-3-0 \ - llvm \ - ninja-build \ - pkg-config \ - unzip \ - valgrind \ - vim -ENV PATH /usr/lib/llvm-6.0/bin:$PATH - -# lib/as3 (ActionScript) -RUN mkdir -p /usr/local/adobe/flex/4.6 && \ - cd /usr/local/adobe/flex/4.6 && \ - wget -q "http://download.macromedia.com/pub/flex/sdk/flex_sdk_4.6.zip" && \ - unzip flex_sdk_4.6.zip -ENV FLEX_HOME /usr/local/adobe/flex/4.6 - -# TODO: "apt-get install" without "apt-get update" in the same "RUN" step can cause cache issues if modified later. -# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run -RUN apt-get install -y --no-install-recommends \ - `# C++ dependencies` \ - libboost-all-dev \ - libevent-dev \ - libssl-dev \ - qt5-default \ - qtbase5-dev \ - qtbase5-dev-tools - -ENV SBCL_VERSION 1.5.3 -RUN \ - `# Common Lisp (sbcl) dependencies` \ - curl --version && \ - curl -o sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 -J -L https://sourceforge.net/projects/sbcl/files/sbcl/${SBCL_VERSION}/sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2/download?use_mirror=managedway# && \ - tar xjf sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 && \ - cd sbcl-${SBCL_VERSION}-x86-64-linux && \ - ./install.sh && \ - sbcl --version && \ - cd .. && \ - rm -rf sbcl* - -ENV D_VERSION 2.087.0 -ENV DMD_DEB dmd_2.087.0-0_amd64.deb -RUN \ - `# D dependencies` \ - wget -q http://downloads.dlang.org/releases/2.x/${D_VERSION}/${DMD_DEB} && \ - dpkg --install ${DMD_DEB} && \ - rm -f ${DMD_DEB} && \ - mkdir -p /usr/include/dmd/druntime/import/deimos /usr/include/dmd/druntime/import/C && \ - git clone -b 'v2.0.2+2.0.16' https://github.com/D-Programming-Deimos/libevent.git deimos-libevent-2.0 && \ - mv deimos-libevent-2.0/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv deimos-libevent-2.0/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf deimos-libevent-2.0 && \ - git clone -b 'v2.0.0+1.1.0h' https://github.com/D-Programming-Deimos/openssl.git deimos-openssl-1.1.0h && \ - mv deimos-openssl-1.1.0h/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv deimos-openssl-1.1.0h/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf deimos-openssl-1.1.0h - -ENV DART_VERSION 2.7.2-1 -RUN apt-get install -y --no-install-recommends \ - `# Dart dependencies` \ - dart=$DART_VERSION -ENV PATH /usr/lib/dart/bin:$PATH - -RUN apt-get install -y --no-install-recommends \ - `# dotnet core dependencies` \ - dotnet-sdk-7.0 \ - dotnet-runtime-7.0 \ - aspnetcore-runtime-7.0 \ - dotnet-apphost-pack-7.0 - -# Erlang dependencies -ARG ERLANG_OTP_VERSION=23.3.4.11 -ARG ERLANG_REBAR_VERSION=3.18.0 -RUN apt-get update && apt-get install -y --no-install-recommends libncurses5-dev && \ - curl -ssLo /usr/local/bin/kerl https://raw.githubusercontent.com/kerl/kerl/master/kerl && chmod +x /usr/local/bin/kerl && \ - kerl build $ERLANG_OTP_VERSION && kerl install $ERLANG_OTP_VERSION /usr/local/lib/otp/ && . /usr/local/lib/otp/activate && \ - curl -ssLo /usr/local/bin/rebar3 https://github.com/erlang/rebar3/releases/download/${ERLANG_REBAR_VERSION}/rebar3 && chmod +x /usr/local/bin/rebar3 && \ - rebar3 --version -ENV PATH /usr/local/lib/otp/bin:$PATH - -RUN apt-get install -y --no-install-recommends \ - `# GlibC dependencies` \ - libglib2.0-dev - -# golang -ENV GOLANG_VERSION 1.19.5 -ENV GOLANG_DOWNLOAD_URL https://go.dev/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 36519702ae2fd573c9869461990ae550c8c0d955cd28d2827a6b159fda81ff95 -RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ - echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \ - tar -C /usr/local -xzf golang.tar.gz && \ - ln -s /usr/local/go/bin/go /usr/local/bin && \ - rm golang.tar.gz - -RUN apt-get install -y --no-install-recommends \ - `# Haxe dependencies` \ - haxe \ - neko \ - neko-dev && \ - haxelib setup --always /usr/share/haxe/lib && \ - haxelib install --always hxcpp 2>&1 > /dev/null - -ENV GRADLE_VERSION="8.4" -RUN apt-get install -y --no-install-recommends \ - `# Java dependencies` \ - ant \ - ant-optional \ - maven \ - openjdk-17-jdk-headless && \ - `# Gradle` \ - wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ - unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ - ln -s /usr/local/gradle/bin/gradle /usr/local/bin - -RUN apt-get install -y --no-install-recommends \ - `# Lua dependencies` \ - lua5.2 \ - lua5.2-dev -# https://bugs.launchpad.net/ubuntu/+source/lua5.3/+bug/1707212 -# lua5.3 does not install alternatives! -# need to update our luasocket code, lua doesn't have luaL_openlib any more - -RUN apt-get install -y --no-install-recommends \ - `# Node.js dependencies` \ - nodejs - -# Test dependencies for running puppeteer -RUN apt-get install -y --no-install-recommends \ - `# JS dependencies` \ - libxss1 \ - libxtst6 - -RUN apt-get install -y --no-install-recommends \ - `# OCaml dependencies` \ - ocaml \ - opam && \ - opam init --yes && \ - opam install --yes oasis - -RUN apt-get install -y --no-install-recommends \ - `# Perl dependencies` \ - libbit-vector-perl \ - libclass-accessor-class-perl \ - libcrypt-ssleay-perl \ - libio-socket-ssl-perl \ - libnet-ssleay-perl \ - libtest-exception-perl - -RUN apt-get install -y --no-install-recommends \ - `# Php dependencies` \ - php \ - php-cli \ - php-dev \ - php-json \ - php-pear \ - php-mbstring \ - php-xml \ - re2c \ - composer - -RUN pecl install xdebug-3.1.1 && \ - echo "zend_extension=xdebug.so" > /etc/php/7.2/cli/conf.d/20-xdebug.ini - -RUN apt-get install -y --no-install-recommends \ - `# Python dependencies` \ - python-all \ - python-all-dbg \ - python-all-dev \ - python-ipaddress \ - python-pip \ - python-setuptools \ - python-six \ - python-tornado \ - python-twisted \ - python-wheel \ - python-zope.interface && \ - pip install --upgrade backports.ssl_match_hostname - -RUN apt-get install -y --no-install-recommends \ - `# Python3 dependencies` \ - python3-all \ - python3-all-dbg \ - python3-all-dev \ - python3-pip \ - python3-setuptools \ - python3-six \ - python3-tornado \ - python3-twisted \ - python3-wheel \ - python3-zope.interface - -RUN apt-get install -y --no-install-recommends \ - `# Ruby dependencies` \ - ruby \ - ruby-dev \ - ruby-bundler - -# Rust dependencies -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y -ENV PATH /root/.cargo/bin:$PATH - -# Swift on Linux for cross tests -RUN apt-get install -yq \ - libedit-dev \ - libz3-dev \ - libpython-dev \ - libxml2-dev && \ - cd / && \ - wget --quiet https://download.swift.org/swift-5.7-release/ubuntu1804/swift-5.7-RELEASE/swift-5.7-RELEASE-ubuntu18.04.tar.gz && \ - tar xf swift-5.7-RELEASE-ubuntu18.04.tar.gz && \ - mv swift-5.7-RELEASE-ubuntu18.04 /usr/share/swift && \ - rm swift-5.7-RELEASE-ubuntu18.04.tar.gz - -ENV PATH /usr/share/swift/usr/bin:$PATH -RUN swift --version - -# Locale(s) for cpp unit tests -RUN apt-get install -y --no-install-recommends \ - `# Locale dependencies` \ - locales && \ - locale-gen en_US.UTF-8 && \ - locale-gen de_DE.UTF-8 && \ - update-locale - -RUN apt-get install -y --no-install-recommends \ - `# Static Code Analysis dependencies` \ - cppcheck \ - sloccount && \ - pip install flake8 - -# NOTE: this does not reduce the image size but adds an additional layer. -# # Clean up -# RUN rm -rf /var/cache/apt/* && \ -# rm -rf /var/lib/apt/lists/* && \ -# rm -rf /tmp/* && \ -# rm -rf /var/tmp/* - -ARG user=build -ARG group=build -ARG uid=1000 -ARG gid=1000 - -RUN apt-get install -y --no-install-recommends sudo && \ - echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \ - if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ - adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \ - echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers - -ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src && \ - chown -R ${uid}:${uid} $THRIFT_ROOT/ -COPY Dockerfile $THRIFT_ROOT/ -WORKDIR $THRIFT_ROOT/src - -USER ${user} diff --git a/build/docker/old/ubuntu-disco/Dockerfile b/build/docker/old/ubuntu-disco/Dockerfile deleted file mode 100644 index 39642cf2b00..00000000000 --- a/build/docker/old/ubuntu-disco/Dockerfile +++ /dev/null @@ -1,296 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Apache Thrift Docker build environment for Ubuntu Disco -# with some updated packages. -# - -FROM buildpack-deps:disco-scm -MAINTAINER Apache Thrift -ENV DEBIAN_FRONTEND noninteractive - -### Add apt repos - -RUN apt-get update && \ - apt-get dist-upgrade -y && \ - apt-get install -y --no-install-recommends \ - apt \ - apt-transport-https \ - apt-utils \ - curl \ - dirmngr \ - software-properties-common \ - wget - -# Dart -RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > \ - /etc/apt/sources.list.d/dart_stable.list - -# dotnet (netcore) -RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \ - wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/ubuntu/18.04/prod.list && \ - chown root:root /etc/apt/trusted.gpg.d/microsoft.gpg && \ - chown root:root /etc/apt/sources.list.d/microsoft-prod.list - -# erlang -RUN wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | apt-key add - && \ - echo "deb https://packages.erlang-solutions.com/ubuntu disco contrib" | tee /etc/apt/sources.list.d/erlang.list - -# node.js -RUN curl -sL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \ - echo "deb https://deb.nodesource.com/node_10.x disco main" | tee /etc/apt/sources.list.d/nodesource.list - -### install general dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - `# General dependencies` \ - bash-completion \ - bison \ - build-essential \ - clang \ - cmake \ - debhelper \ - flex \ - gdb \ - libasound2 \ - libatk-bridge2.0-0 \ - libgtk-3-0 \ - llvm \ - ninja-build \ - pkg-config \ - unzip \ - valgrind \ - vim -ENV PATH /usr/lib/llvm-6.0/bin:$PATH - -# lib/as3 (ActionScript) -RUN mkdir -p /usr/local/adobe/flex/4.6 && \ - cd /usr/local/adobe/flex/4.6 && \ - wget -q "http://download.macromedia.com/pub/flex/sdk/flex_sdk_4.6.zip" && \ - unzip flex_sdk_4.6.zip -ENV FLEX_HOME /usr/local/adobe/flex/4.6 - -RUN apt-get install -y --no-install-recommends \ - `# C++ dependencies` \ - libboost-all-dev \ - libevent-dev \ - libssl-dev \ - qt5-default \ - qtbase5-dev \ - qtbase5-dev-tools - -ENV SBCL_VERSION 1.5.3 -RUN \ - `# Common Lisp (sbcl) dependencies` \ - curl --version && \ - curl -o sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 -J -L https://sourceforge.net/projects/sbcl/files/sbcl/${SBCL_VERSION}/sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2/download?use_mirror=managedway# && \ - tar xjf sbcl-${SBCL_VERSION}-x86-64-linux-binary.tar.bz2 && \ - cd sbcl-${SBCL_VERSION}-x86-64-linux && \ - ./install.sh && \ - sbcl --version && \ - cd .. && \ - rm -rf sbcl* - -ENV D_VERSION 2.087.0 -ENV DMD_DEB dmd_2.087.0-0_amd64.deb -RUN \ - `# D dependencies` \ - wget -q http://downloads.dlang.org/releases/2.x/${D_VERSION}/${DMD_DEB} && \ - dpkg --install ${DMD_DEB} && \ - rm -f ${DMD_DEB} && \ - mkdir -p /usr/include/dmd/druntime/import/deimos /usr/include/dmd/druntime/import/C && \ - git clone -b 'v2.0.2+2.0.16' https://github.com/D-Programming-Deimos/libevent.git deimos-libevent-2.0 && \ - mv deimos-libevent-2.0/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv deimos-libevent-2.0/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf deimos-libevent-2.0 && \ - git clone -b 'v2.0.0+1.1.0h' https://github.com/D-Programming-Deimos/openssl.git deimos-openssl-1.1.0h && \ - mv deimos-openssl-1.1.0h/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv deimos-openssl-1.1.0h/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf deimos-openssl-1.1.0h - -ENV DART_VERSION 2.7.2-1 -RUN apt-get install -y --no-install-recommends \ - `# Dart dependencies` \ - dart=$DART_VERSION -ENV PATH /usr/lib/dart/bin:$PATH - -RUN apt-get install -y --no-install-recommends \ - `# dotnet core dependencies` \ - dotnet-sdk-8.0 \ - dotnet-runtime-8.0 \ - aspnetcore-runtime-8.0 \ - dotnet-apphost-pack-8.0 - -RUN apt-get install -y --no-install-recommends \ - `# Erlang dependencies` \ - erlang && \ - wget https://s3.amazonaws.com/rebar3/rebar3 -O /usr/bin/rebar3 && \ - chmod 755 /usr/bin/rebar3 && \ - rebar3 --version - -RUN apt-get install -y --no-install-recommends \ - `# GlibC dependencies` \ - libglib2.0-dev - -# golang -ENV GOLANG_VERSION 1.19 -ENV GOLANG_DOWNLOAD_URL https://go.dev/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 464b6b66591f6cf055bc5df90a9750bf5fbc9d038722bb84a9d56a2bea974be6 -RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ - echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \ - tar -C /usr/local -xzf golang.tar.gz && \ - ln -s /usr/local/go/bin/go /usr/local/bin && \ - rm golang.tar.gz - -RUN apt-get install -y --no-install-recommends \ - `# Haxe dependencies` \ - haxe \ - neko \ - neko-dev && \ - haxelib setup --always /usr/share/haxe/lib && \ - haxelib install --always hxcpp 2>&1 > /dev/null - -ENV GRADLE_VERSION="8.4" -RUN apt-get install -y --no-install-recommends \ - `# Java dependencies` \ - ant \ - ant-optional \ - maven \ - openjdk-11-jdk-headless && \ - `# Gradle` \ - wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ - unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ - ln -s /usr/local/gradle/bin/gradle /usr/local/bin - -RUN apt-get install -y --no-install-recommends \ - `# Lua dependencies` \ - lua5.2 \ - lua5.2-dev -# https://bugs.launchpad.net/ubuntu/+source/lua5.3/+bug/1707212 -# lua5.3 does not install alternatives! -# need to update our luasocket code, lua doesn't have luaL_openlib any more - -RUN apt-get install -y --no-install-recommends \ - `# Node.js dependencies` \ - nodejs - -# Test dependencies for running puppeteer -RUN apt-get install -y --no-install-recommends \ - `# JS dependencies` \ - libxss1 \ - libxtst6 - -# does not work on disco? -# RUN apt-get install -y --no-install-recommends \ -# `# OCaml dependencies` \ -# ocaml \ -# opam && \ -# opam init --yes && \ -# opam install --yes oasis - -RUN apt-get install -y --no-install-recommends \ - `# Perl dependencies` \ - libbit-vector-perl \ - libclass-accessor-class-perl \ - libcrypt-ssleay-perl \ - libio-socket-ssl-perl \ - libnet-ssleay-perl \ - libtest-exception-perl - -RUN apt-get install -y --no-install-recommends \ - `# Php dependencies` \ - php \ - php-cli \ - php-dev \ - php-json \ - php-pear \ - re2c \ - composer - -RUN apt-get install -y --no-install-recommends \ - `# Python dependencies` \ - python-all \ - python-all-dbg \ - python-all-dev \ - python-ipaddress \ - python-pip \ - python-setuptools \ - python-six \ - python-tornado \ - python-twisted \ - python-wheel \ - python-zope.interface && \ - pip install --upgrade backports.ssl_match_hostname - -RUN apt-get install -y --no-install-recommends \ - `# Python3 dependencies` \ - python3-all \ - python3-all-dbg \ - python3-all-dev \ - python3-pip \ - python3-setuptools \ - python3-six \ - python3-tornado \ - python3-twisted \ - python3-wheel \ - python3-zope.interface - -RUN apt-get install -y --no-install-recommends \ - `# Ruby dependencies` \ - ruby \ - ruby-dev \ - ruby-bundler - -# Rust dependencies -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y -ENV PATH /root/.cargo/bin:$PATH - -# Swift on Linux for cross tests -# does not work on disco -# RUN cd / && \ -# wget --quiet https://swift.org/builds/swift-4.2.1-release/ubuntu1804/swift-4.2.1-RELEASE/swift-4.2.1-RELEASE-ubuntu18.04.tar.gz && \ -# tar xf swift-4.2.1-RELEASE-ubuntu18.04.tar.gz --strip-components=1 && \ -# rm swift-4.2.1-RELEASE-ubuntu18.04.tar.gz && \ -# swift --version - -# Locale(s) for cpp unit tests -RUN apt-get install -y --no-install-recommends \ - `# Locale dependencies` \ - locales && \ - locale-gen en_US.UTF-8 && \ - locale-gen de_DE.UTF-8 && \ - update-locale - -# cppcheck-1.82 has a nasty cpp parser bug, so we're using something newer -# don't need this on disco, nobody uses it -# RUN apt-get install -y --no-install-recommends \ -# `# Static Code Analysis dependencies` \ -# cppcheck \ -# sloccount && \ -# pip install flake8 && \ -# wget -q "https://launchpad.net/ubuntu/+source/cppcheck/1.83-2/+build/14874703/+files/cppcheck_1.83-2_amd64.deb" && \ -# dpkg -i cppcheck_1.83-2_amd64.deb && \ -# rm cppcheck_1.83-2_amd64.deb - -# Clean up -RUN rm -rf /var/cache/apt/* && \ - rm -rf /var/lib/apt/lists/* && \ - rm -rf /tmp/* && \ - rm -rf /var/tmp/* - -ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src -COPY Dockerfile $THRIFT_ROOT/ -WORKDIR $THRIFT_ROOT/src diff --git a/build/docker/old/ubuntu-trusty/Dockerfile b/build/docker/old/ubuntu-trusty/Dockerfile deleted file mode 100644 index 89f683e4bcf..00000000000 --- a/build/docker/old/ubuntu-trusty/Dockerfile +++ /dev/null @@ -1,235 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Apache Thrift Docker build environment for Ubuntu Trusty -# Using all stock Ubuntu Trusty packaging except for: -# - d: does not come with Ubuntu so we're installing 2.070.0 -# - dart: does not come with Ubuntu so we're installing 1.20.1 -# - dotnetcore, disabled because netcore is for 1.0.0-preview and 2.0.0 is out -# - haxe, disabled because the distro comes with 3.0.0 and it cores while installing -# - node.js, disabled because it is at 0.10.0 in the distro which is too old (need 4+) -# - ocaml, disabled because it fails to install properly -# - -FROM buildpack-deps:trusty-scm -MAINTAINER Apache Thrift -ENV DEBIAN_FRONTEND noninteractive - -### Add apt repos - -RUN apt-get update && \ - apt-get dist-upgrade -y && \ - apt-get install -y --no-install-recommends \ - apt \ - apt-transport-https \ - apt-utils \ - curl \ - dirmngr \ - software-properties-common \ - wget - -# D -RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EBCF975E5BA24D5E && \ - wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list && \ - wget -qO - https://dlang.org/d-keyring.gpg | apt-key add - - -# Dart -RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > \ - /etc/apt/sources.list.d/dart_stable.list - -RUN apt-get update && apt-get install -y --no-install-recommends \ -`# General dependencies` \ - bash-completion \ - bison \ - build-essential \ - clang \ - cmake \ - debhelper \ - flex \ - gdb \ - llvm \ - ninja-build \ - pkg-config \ - valgrind \ - vim -ENV PATH /usr/lib/llvm-3.8/bin:$PATH - -RUN apt-get install -y --no-install-recommends \ -`# C++ dependencies` \ - libboost-all-dev \ - libevent-dev \ - libssl-dev \ - qt5-default \ - qtbase5-dev \ - qtbase5-dev-tools - -RUN apt-get install -y --no-install-recommends \ -`# D dependencies` \ - dmd-bin=2.070.2-0 \ - libphobos2-dev=2.070.2-0 \ - dub \ - dfmt \ - dscanner \ - xdg-utils -RUN mkdir -p /usr/include/dmd/druntime/import/deimos /usr/include/dmd/druntime/import/C && \ - curl -sSL https://github.com/D-Programming-Deimos/libevent/archive/master.tar.gz| tar xz && \ - mv libevent-master/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv libevent-master/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf libevent-master -RUN curl -sSL https://github.com/D-Programming-Deimos/openssl/archive/master.tar.gz| tar xz && \ - mv openssl-master/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv openssl-master/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf openssl-master - -RUN apt-get install -y --no-install-recommends \ -`# Dart dependencies` \ - dart=1.20.1-1 -ENV PATH /usr/lib/dart/bin:$PATH - -RUN apt-get install -y --no-install-recommends \ -`# Erlang dependencies` \ - erlang-base \ - erlang-eunit \ - erlang-dev \ - erlang-tools \ - rebar - -RUN apt-get install -y --no-install-recommends \ -`# GlibC dependencies` \ - libglib2.0-dev - -# golang -ENV GOLANG_VERSION 1.7.6 -ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 ad5808bf42b014c22dd7646458f631385003049ded0bb6af2efc7f1f79fa29ea -RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ - echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \ - tar -C /usr/local -xzf golang.tar.gz && \ - ln -s /usr/local/go/bin/go /usr/local/bin && \ - rm golang.tar.gz - -# disabled because it cores while installing -# RUN apt-get install -y --no-install-recommends \ -# `# Haxe dependencies` \ -# haxe \ -# neko \ -# neko-dev && \ -# haxelib setup /usr/share/haxe/lib && \ -# haxelib install hxcpp 3.2.102 - -RUN apt-get install -y --no-install-recommends \ -`# Java dependencies` \ - ant \ - ant-optional \ - openjdk-7-jdk \ - maven - -RUN apt-get install -y --no-install-recommends \ -`# Lua dependencies` \ - lua5.1 \ - lua5.1-dev - -# disabled because it is too old -# RUN apt-get install -y --no-install-recommends \ -# `# Node.js dependencies` \ -# nodejs \ -# npm - -# disabled because it fails to install properly -# RUN apt-get install -y --no-install-recommends \ -# `# OCaml dependencies` \ -# ocaml \ -# opam && \ -# opam init --yes && \ -# opam install --yes oasis - -RUN apt-get install -y --no-install-recommends \ -`# Perl dependencies` \ - libbit-vector-perl \ - libclass-accessor-class-perl \ - libcrypt-ssleay-perl \ - libio-socket-ssl-perl \ - libnet-ssleay-perl - -RUN apt-get install -y --no-install-recommends \ -`# Php dependencies` \ - php5 \ - php5-cli \ - php5-dev \ - php-pear \ - re2c && \ - wget https://getcomposer.org/installer -O - -q | php -- --quiet --install-dir=/usr/local/bin/ --filename=composer - -RUN apt-get install -y --no-install-recommends \ -`# Python dependencies` \ - python-all \ - python-all-dbg \ - python-all-dev \ - python-pip \ - python-setuptools \ - python-six \ - python-twisted \ - python-wheel \ - python-zope.interface \ - python3-all \ - python3-all-dbg \ - python3-all-dev \ - python3-pip \ - python3-setuptools \ - python3-six \ - python3-wheel \ - python3-zope.interface && \ - pip install -U ipaddress backports.ssl_match_hostname tornado && \ - pip3 install -U backports.ssl_match_hostname tornado -# installing tornado by pip/pip3 instead of debian package -# if we install the debian package, the build fails in py2 - -RUN apt-get install -y --no-install-recommends \ -`# Ruby dependencies` \ - ruby \ - ruby-dev \ - ruby-bundler -RUN gem install bundler --no-ri --no-rdoc - -RUN apt-get install -y --no-install-recommends \ -`# Rust dependencies` \ - cargo \ - rustc - -RUN apt-get install -y --no-install-recommends \ -`# Static Code Analysis dependencies` \ - cppcheck \ - sloccount && \ - pip install flake8 - -# Install BouncyCastle provider to fix Java builds issues with JDK 7 -# Builds accessing repote repositories fail as seen here: https://github.com/travis-ci/travis-ci/issues/8503 -RUN apt-get install -y --no-install-recommends \ -`# BouncyCastle JCE Provider dependencies` \ - libbcprov-java && \ - ln -s /usr/share/java/bcprov.jar /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/bcprov.jar && \ - awk -F . -v OFS=. 'BEGIN{n=2}/^security\.provider/ {split($3, posAndEquals, "=");$3=n++"="posAndEquals[2];print;next} 1' /etc/java-7-openjdk/security/java.security > /tmp/java.security && \ - echo "security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider" >> /tmp/java.security && \ - mv /tmp/java.security /etc/java-7-openjdk/security/java.security - -# Clean up -RUN rm -rf /var/cache/apt/* && \ - rm -rf /var/lib/apt/lists/* && \ - rm -rf /tmp/* && \ - rm -rf /var/tmp/* - -ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src -COPY Dockerfile $THRIFT_ROOT/ -WORKDIR $THRIFT_ROOT/src diff --git a/build/docker/old/ubuntu-xenial/Dockerfile b/build/docker/old/ubuntu-xenial/Dockerfile deleted file mode 100644 index d9d87ccaea3..00000000000 --- a/build/docker/old/ubuntu-xenial/Dockerfile +++ /dev/null @@ -1,273 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Apache Thrift Docker build environment for Ubuntu Xenial -# Using all stock Ubuntu Xenial packaging except for: -# - d: does not come with Ubuntu so we're installing 2.087.0 for coverage -# - dart: does not come with Ubuntu so we're installing 2.0.0-1 for coverage -# - dotnet: does not come with Ubuntu -# - go: Xenial comes with 1.6, but we need 1.10 or later -# - nodejs: Xenial comes with 4.2.6 which exits LTS April 2018, so we're installing 10.x -# - ocaml: causes stack overflow error, just started March 2018 not sure why -# - -FROM buildpack-deps:xenial-scm -MAINTAINER Apache Thrift -ENV DEBIAN_FRONTEND noninteractive - -### Add apt repos - -RUN apt-get update && \ - apt-get dist-upgrade -y && \ - apt-get install -y --no-install-recommends \ - apt \ - apt-transport-https \ - apt-utils \ - curl \ - software-properties-common \ - wget && \ - - # Dart - curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > \ - /etc/apt/sources.list.d/dart_stable.list && \ - - # dotnet (core) - curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \ - echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > \ - /etc/apt/sources.list.d/dotnetdev.list && \ - - # node.js - curl -sL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \ - echo "deb https://deb.nodesource.com/node_10.x xenial main" | tee /etc/apt/sources.list.d/nodesource.list && \ - - # ruby 2.4 - apt-add-repository ppa:brightbox/ruby-ng - -### install general dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - `# General dependencies` \ - bash-completion \ - bison \ - build-essential \ - clang \ - cmake \ - debhelper \ - flex \ - gdb \ - llvm \ - ninja-build \ - pkg-config \ - valgrind \ - vim -ENV PATH /usr/lib/llvm-3.8/bin:$PATH - -### languages - -# TODO: "apt-get install" without "apt-get update" in the same "RUN" step can cause cache issues if modified later. -# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run -RUN apt-get install -y --no-install-recommends \ - `# C++ dependencies` \ - libboost-dev \ - libboost-filesystem-dev \ - libboost-program-options-dev \ - libboost-system-dev \ - libboost-test-dev \ - libboost-thread-dev \ - libevent-dev \ - libssl-dev \ - qt5-default \ - qtbase5-dev \ - qtbase5-dev-tools - -ENV D_VERSION 2.087.0 -ENV DMD_DEB dmd_2.087.0-0_amd64.deb -RUN \ - `# D dependencies` \ - wget -q http://downloads.dlang.org/releases/2.x/${D_VERSION}/${DMD_DEB} && \ - dpkg --install ${DMD_DEB} && \ - rm -f ${DMD_DEB} && \ - mkdir -p /usr/include/dmd/druntime/import/deimos /usr/include/dmd/druntime/import/C && \ - git clone -b 'v2.0.2+2.0.16' https://github.com/D-Programming-Deimos/libevent.git deimos-libevent-2.0 && \ - mv deimos-libevent-2.0/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv deimos-libevent-2.0/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf deimos-libevent-2.0 && \ - git clone -b 'v1.1.6+1.0.1g' https://github.com/D-Programming-Deimos/openssl.git deimos-openssl-1.0.1g && \ - mv deimos-openssl-1.0.1g/deimos/* /usr/include/dmd/druntime/import/deimos/ && \ - mv deimos-openssl-1.0.1g/C/* /usr/include/dmd/druntime/import/C/ && \ - rm -rf deimos-openssl-1.0.1g - -ENV DART_VERSION 2.7.2-1 -RUN apt-get install -y --no-install-recommends \ - `# Dart dependencies` \ - dart=$DART_VERSION -ENV PATH /usr/lib/dart/bin:$PATH - -RUN apt-get install -y --no-install-recommends \ - `# dotnet core dependencies` \ - dotnet-sdk-8.0 \ - dotnet-runtime-8.0 \ - aspnetcore-runtime-8.0 \ - dotnet-apphost-pack-8.0 - -# Erlang dependencies -ARG ERLANG_OTP_VERSION=20.3.8.9 -ARG ERLANG_REBAR_VERSION=3.13.2 -RUN apt-get update && apt-get install -y --no-install-recommends automake libncurses5-dev && \ - curl https://raw.githubusercontent.com/kerl/kerl/master/kerl -o /usr/local/bin/kerl && chmod +x /usr/local/bin/kerl && \ - kerl build $ERLANG_OTP_VERSION && kerl install $ERLANG_OTP_VERSION /usr/local/lib/otp/ && . /usr/local/lib/otp/activate && \ - curl https://s3.amazonaws.com/rebar3/rebar3 -o /usr/local/bin/rebar3 && chmod +x /usr/local/bin/rebar3 && \ - curl -ssLo /usr/local/bin/rebar3 https://github.com/erlang/rebar3/releases/download/${ERLANG_REBAR_VERSION}/rebar3 && chmod +x /usr/local/bin/rebar3 && \ - rebar3 --version -ENV PATH /usr/local/lib/otp/bin:$PATH - -RUN apt-get install -y --no-install-recommends \ - `# GlibC dependencies` \ - libglib2.0-dev - -# golang -ENV GOLANG_VERSION 1.18.5 -ENV GOLANG_DOWNLOAD_URL https://go.dev/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 9e5de37f9c49942c601b191ac5fba404b868bfc21d446d6960acc12283d6e5f2 -RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ - echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \ - tar -C /usr/local -xzf golang.tar.gz && \ - ln -s /usr/local/go/bin/go /usr/local/bin && \ - rm golang.tar.gz - -RUN apt-get install -y --no-install-recommends \ - `# Haxe dependencies` \ - haxe \ - neko \ - neko-dev \ - libneko0 && \ - haxelib setup --always /usr/share/haxe/lib && \ - haxelib install --always hxcpp 3.4.64 2>&1 > /dev/null -# note: hxcpp 3.4.185 (latest) no longer ships static libraries, and caused a build failure - -ENV GRADLE_VERSION="8.4" -RUN apt-get install -y --no-install-recommends \ - `# Java dependencies` \ - ant \ - ant-optional \ - openjdk-8-jdk \ - maven \ - unzip && \ - `# Gradle` \ - wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \ - unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip && \ - mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle && \ - ln -s /usr/local/gradle/bin/gradle /usr/local/bin - -# disabled: same as ubuntu-bionic jobs -# RUN apt-get install -y --no-install-recommends \ -# `# Lua dependencies` \ -# lua5.2 \ -# lua5.2-dev -# https://bugs.launchpad.net/ubuntu/+source/lua5.3/+bug/1707212 -# lua5.3 does not install alternatives so stick with 5.2 here - -RUN apt-get install -y --no-install-recommends \ - `# Node.js dependencies` \ - nodejs - -# Test dependencies for running puppeteer -RUN apt-get install -y --no-install-recommends \ - `# JS dependencies` \ - libxss1 \ - libxtst6 \ - libatk-bridge2.0-0 \ - libgtk-3-0 - -# THRIFT-4517: causes stack overflows; version too old; skip ocaml in xenial -# RUN apt-get install -y --no-install-recommends \ -# `# OCaml dependencies` \ -# ocaml \ -# opam && \ -# opam init --yes && \ -# opam install --yes oasis - -RUN apt-get install -y --no-install-recommends \ - `# Perl dependencies` \ - libbit-vector-perl \ - libclass-accessor-class-perl \ - libcrypt-ssleay-perl \ - libio-socket-ssl-perl \ - libnet-ssleay-perl \ - libtest-exception-perl - -RUN apt-get install -y --no-install-recommends \ - `# Php dependencies` \ - php7.0 \ - php7.0-cli \ - php7.0-dev \ - php-json \ - php-pear \ - re2c \ - composer - -RUN apt-get install -y --no-install-recommends \ - `# Python dependencies` \ - python-all \ - python-all-dbg \ - python-all-dev \ - python-backports.ssl-match-hostname \ - python-ipaddress \ - python-pip \ - python-setuptools \ - python-six \ - python-tornado \ - python-twisted \ - python-wheel \ - python-zope.interface \ - python3-all \ - python3-all-dbg \ - python3-all-dev \ - python3-setuptools \ - python3-six \ - python3-tornado \ - python3-twisted \ - python3-wheel \ - python3-zope.interface && \ - pip install --upgrade backports.ssl_match_hostname - -RUN apt-get install -y --no-install-recommends \ - `# Ruby dependencies` \ - ruby2.4 \ - ruby2.4-dev \ - ruby-bundler - -# Rust dependencies -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y - -# Locale(s) for cpp unit tests -RUN apt-get install -y --no-install-recommends \ - `# Locale dependencies` \ - locales && \ - locale-gen en_US.UTF-8 && \ - locale-gen de_DE.UTF-8 && \ - update-locale - -# NOTE: this does not reduce the image size but adds an additional layer. -# # Clean up -# RUN rm -rf /var/cache/apt/* && \ -# rm -rf /var/lib/apt/lists/* && \ -# rm -rf /tmp/* && \ -# rm -rf /var/tmp/* - -ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 -ENV THRIFT_ROOT /thrift -RUN mkdir -p $THRIFT_ROOT/src -COPY Dockerfile $THRIFT_ROOT/ -WORKDIR $THRIFT_ROOT/src From 70799d2de2d1c1064765c082f1368005158f789d Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 28 Feb 2024 20:40:30 +0900 Subject: [PATCH 211/250] Update GO in docker containers to 1.21 --- build/docker/ubuntu-focal/Dockerfile | 4 ++-- build/docker/ubuntu-jammy/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index 00ab2be95b7..2c2b31229b6 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -145,9 +145,9 @@ RUN apt-get install -y --no-install-recommends \ libglib2.0-dev # golang -ENV GOLANG_VERSION 1.20 +ENV GOLANG_VERSION 1.21.7 ENV GOLANG_DOWNLOAD_URL https://go.dev/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 5a9ebcc65c1cce56e0d2dc616aff4c4cedcfbda8cc6f0288cc08cda3b18dcbf1 +ENV GOLANG_DOWNLOAD_SHA256 13b76a9b2a26823e53062fa841b07087d48ae2ef2936445dc34c4ae03293702c RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \ tar -C /usr/local -xzf golang.tar.gz && \ diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index d214b9fc7aa..96f1990a54e 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -144,9 +144,9 @@ RUN apt-get install -y --no-install-recommends \ libglib2.0-dev # golang -ENV GOLANG_VERSION 1.20 +ENV GOLANG_VERSION 1.21.7 ENV GOLANG_DOWNLOAD_URL https://go.dev/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 5a9ebcc65c1cce56e0d2dc616aff4c4cedcfbda8cc6f0288cc08cda3b18dcbf1 +ENV GOLANG_DOWNLOAD_SHA256 13b76a9b2a26823e53062fa841b07087d48ae2ef2936445dc34c4ae03293702c RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \ tar -C /usr/local -xzf golang.tar.gz && \ From c925bd8d086198903f46140555617982dd69e490 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 4 Mar 2024 21:32:26 +0900 Subject: [PATCH 212/250] Add Haxe and fix rust --- build/docker/ubuntu-focal/Dockerfile | 56 +++++++++++++++++----------- build/docker/ubuntu-jammy/Dockerfile | 56 +++++++++++++++++----------- 2 files changed, 70 insertions(+), 42 deletions(-) diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index 2c2b31229b6..d04ef70dac4 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -32,6 +32,18 @@ RUN apt-get update -yq && \ software-properties-common \ wget +# Create a user +ARG user=build +ARG group=build +ARG uid=1000 +ARG gid=1000 + +RUN apt-get install -y --no-install-recommends sudo && \ + echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \ + if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ + adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \ + echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + # Dart RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > \ @@ -154,13 +166,24 @@ RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ ln -s /usr/local/go/bin/go /usr/local/bin && \ rm golang.tar.gz -RUN apt-get install -y --no-install-recommends \ - `# Haxe dependencies` \ - haxe \ - neko \ - neko-dev && \ - haxelib setup --always /usr/share/haxe/lib && \ - haxelib install --always hxcpp 2>&1 > /dev/null +# HAXE +ARG HAXE_VERSION=4.2.1 +ARG NEKO_VERSION=2.3.0 +RUN cd $HOME && \ + `# Haxe dependencies` && \ + wget https://github.com/HaxeFoundation/haxe/releases/download/${HAXE_VERSION}/haxe-${HAXE_VERSION}-linux64.tar.gz && \ + tar xvf haxe-${HAXE_VERSION}-linux64.tar.gz && \ + rm haxe-${HAXE_VERSION}-linux64.tar.gz && \ + mv haxe_* /opt/haxe && \ + wget https://github.com/HaxeFoundation/neko/releases/download/v`echo ${NEKO_VERSION} | sed "s/\./-/g"`/neko-${NEKO_VERSION}-linux64.tar.gz && \ + tar xvf neko-${NEKO_VERSION}-linux64.tar.gz && \ + rm neko-${NEKO_VERSION}-linux64.tar.gz && \ + mv neko-* /opt/neko +ENV PATH /opt/haxe:/opt/neko:$PATH +RUN echo "/opt/neko" > /etc/ld.so.conf.d/neko.conf && \ + ldconfig && \ + haxelib setup --always /usr/share/haxe/lib && \ + haxelib install --always hxcpp 2>&1 > /dev/null ENV GRADLE_VERSION="8.4" RUN apt-get install -y --no-install-recommends \ @@ -240,9 +263,11 @@ RUN apt-get install -y --no-install-recommends \ ruby-dev \ ruby-bundler -# Rust dependencies -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y -ENV PATH /root/.cargo/bin:$PATH +USER ${user} +RUN `# Rust dependencies` \ + curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y +ENV PATH /home/${user}/.cargo/bin:$PATH +USER root # Swift on Linux for cross tests RUN apt-get install -yq \ @@ -280,17 +305,6 @@ RUN apt-get install -y --no-install-recommends \ # rm -rf /tmp/* && \ # rm -rf /var/tmp/* -ARG user=build -ARG group=build -ARG uid=1000 -ARG gid=1000 - -RUN apt-get install -y --no-install-recommends sudo && \ - echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \ - if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ - adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \ - echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers - ENV THRIFT_ROOT /thrift RUN mkdir -p $THRIFT_ROOT/src && \ chown -R ${uid}:${uid} $THRIFT_ROOT/ diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index 96f1990a54e..209cb8c4885 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -32,6 +32,18 @@ RUN apt-get update -yq && \ software-properties-common \ wget +# Create a user +ARG user=build +ARG group=build +ARG uid=1000 +ARG gid=1000 + +RUN apt-get install -y --no-install-recommends sudo && \ + echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \ + if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ + adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \ + echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + # Dart RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > \ @@ -153,13 +165,24 @@ RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \ ln -s /usr/local/go/bin/go /usr/local/bin && \ rm golang.tar.gz -RUN apt-get install -y --no-install-recommends \ - `# Haxe dependencies` \ - haxe \ - neko \ - neko-dev && \ - haxelib setup --always /usr/share/haxe/lib && \ - haxelib install --always hxcpp 2>&1 > /dev/null +# HAXE +ARG HAXE_VERSION=4.2.1 +ARG NEKO_VERSION=2.3.0 +RUN cd $HOME && \ + `# Haxe dependencies` && \ + wget https://github.com/HaxeFoundation/haxe/releases/download/${HAXE_VERSION}/haxe-${HAXE_VERSION}-linux64.tar.gz && \ + tar xvf haxe-${HAXE_VERSION}-linux64.tar.gz && \ + rm haxe-${HAXE_VERSION}-linux64.tar.gz && \ + mv haxe_* /opt/haxe && \ + wget https://github.com/HaxeFoundation/neko/releases/download/v`echo ${NEKO_VERSION} | sed "s/\./-/g"`/neko-${NEKO_VERSION}-linux64.tar.gz && \ + tar xvf neko-${NEKO_VERSION}-linux64.tar.gz && \ + rm neko-${NEKO_VERSION}-linux64.tar.gz && \ + mv neko-* /opt/neko +ENV PATH /opt/haxe:/opt/neko:$PATH +RUN echo "/opt/neko" > /etc/ld.so.conf.d/neko.conf && \ + ldconfig && \ + haxelib setup --always /usr/share/haxe/lib && \ + haxelib install --always hxcpp 2>&1 > /dev/null ENV GRADLE_VERSION="8.4" RUN apt-get install -y --no-install-recommends \ @@ -239,9 +262,11 @@ RUN apt-get install -y --no-install-recommends \ ruby-dev \ ruby-bundler -# Rust dependencies -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y -ENV PATH /root/.cargo/bin:$PATH +USER ${user} +RUN `# Rust dependencies` \ + curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y +ENV PATH /home/${user}/.cargo/bin:$PATH +USER root # Swift on Linux for cross tests RUN apt-get install -yq \ @@ -279,17 +304,6 @@ RUN apt-get install -y --no-install-recommends \ # rm -rf /tmp/* && \ # rm -rf /var/tmp/* -ARG user=build -ARG group=build -ARG uid=1000 -ARG gid=1000 - -RUN apt-get install -y --no-install-recommends sudo && \ - echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \ - if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ - adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \ - echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers - ENV THRIFT_ROOT /thrift RUN mkdir -p $THRIFT_ROOT/src && \ chown -R ${uid}:${uid} $THRIFT_ROOT/ From fb0025c1e39d4e01f55e218757f7bf92f08cabbe Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 5 Mar 2024 22:13:22 +0900 Subject: [PATCH 213/250] Add specific PHP versions and additional dependencies --- build/docker/ubuntu-focal/Dockerfile | 11 +++++++---- build/docker/ubuntu-jammy/Dockerfile | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index d04ef70dac4..4e975e7552f 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -236,10 +236,13 @@ RUN apt-get install -y --no-install-recommends \ RUN apt-get install -y --no-install-recommends \ `# Php dependencies` \ - php \ - php-cli \ - php-dev \ - php-json \ + php7.4 \ + php7.4-cli \ + php7.4-dev \ + php7.4-mbstring \ + php7.4-xml \ + php7.4-curl \ + php7.4-xdebug \ php-pear \ re2c \ composer diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index 209cb8c4885..3d2326ebe26 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -235,10 +235,13 @@ RUN apt-get install -y --no-install-recommends \ RUN apt-get install -y --no-install-recommends \ `# Php dependencies` \ - php \ - php-cli \ - php-dev \ - php-json \ + php8.1 \ + php8.1-cli \ + php8.1-dev \ + php8.1-mbstring \ + php8.1-xml \ + php8.1-curl \ + php8.1-xdebug \ php-pear \ re2c \ composer From 5f27edadf358b647a7feeffced71ee15a9deb34a Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 5 Mar 2024 23:21:05 +0900 Subject: [PATCH 214/250] Update readme version table --- build/docker/README.md | 75 +++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/build/docker/README.md b/build/docker/README.md index 3cb1a32237c..2a338b4b4c1 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -150,53 +150,52 @@ Open a command prompt in the image: ## Core Tool Versions per Dockerfile ## -Last updated: October 1, 2017 +Last updated: March 5, 2024 -| Tool | ubuntu-xenial | ubuntu-bionic | Notes | +| Tool | ubuntu-focal | ubuntu-jammy | Notes | | :-------- | :------------ | :------------ | :---- | -| ant | 1.9.6 | 1.10.3 | | -| autoconf | 2.69 | 2.69 | | -| automake | 1.15 | 1.15.1 | | -| bison | 3.0.4 | 3.0.4 | | -| boost | 1.58.0 | 1.65.1 | | -| cmake | 3.5.1 | 3.10.2 | | -| cppcheck | 1.72 | 1.82 | | -| flex | 2.6.0 | 2.6.4 | | -| libc6 | 2.23 | 2.27 | glibc | -| libevent | 2.0.21 | 2.1.8 | | -| libstdc++ | 5.4.0 | 7.3.0 | | -| make | 4.1 | 4.1 | | -| openssl | 1.0.2g | 1.1.0g | | -| qt5 | 5.5.1 | 5.9.5 | | +| ant | 1.10.7 | 1.10.12 | | +| autoconf | 2.69 | 2.71 | | +| automake | 1.16.1 | 1.16.5 | | +| bison | 3.5.1 | 3.8.2 | | +| boost | 1.71.0 | 1.74.0 | | +| cmake | 3.16.3 | 3.22.1 | | +| cppcheck | 1.90 | 2.7 | | +| flex | 2.6.4 | 2.6.4 | | +| libc6 | 2.31 | 2.35 | glibc | +| libevent | 2.0.16 | 2.0.16 | | +| libstdc++ | 10.5.0 | 10.5.0 | | +| make | 4.2.1 | 4.3 | | +| openssl | 1.1.1f | 3.0.2 | | +| qt5 | 5.12.8 | 5.15.3 | | ## Compiler/Language Versions per Dockerfile ## -| Language | ubuntu-xenial | ubuntu-bionic | Notes | +| Language | ubuntu-focal | ubuntu-jammy | Notes | | :-------- | :------------ | :------------ | :---- | | as of | Mar 06, 2018 | Jul 1, 2019 | | -| as3 | | 4.6.0 | | -| C++ gcc | 5.4.0 | 7.4.0 | | -| C++ clang | 3.8 | 6.0 | | -| C# (mono) | 4.2.1.0 | 4.6.2.7 | | -| c\_glib | 2.48.2 | 2.56.4 | | +| as3 | 4.6.0 | 4.6.0 | | +| C++ gcc | 9.4.0 | 11.4.0 | | +| C++ clang | 13.0.0 | 13.0.0 | | +| c\_glib | 3.2.12 | 3.2.12 | | | cl (sbcl) | | 1.5.3 | | | d | 2.087.0 | 2.087.0 | | -| dart | 2.0.0 | 2.4.0 | | +| dart | 2.7.2-1 | 2.7.2-1 | | | delphi | | | Not in CI | -| erlang | OTP-20 | OTP-25 | | -| go | 1.15.10 | 1.16.2 | | -| haxe | 3.2.1 | 3.4.4 | THRIFT-4352: avoid 3.4.2 | -| java | 1.8.0\_191 | 17 | | -| js | Node.js 6.17.1, V8 5.1.281.111, npm 3.10.10 | Node.js 10.18.0, V8 6.8.275.32, npm 6.13.4 | | -| lua | | 5.2.4 | Lua 5.3: see THRIFT-4386 | -| netstd | 7.0 | 7.0 | | -| nodejs | 6.16.0 | 10.16.0 | | -| ocaml | | 4.05.0 | THRIFT-4517: ocaml 4.02.3 on xenial appears broken | -| perl | 5.22.1 | 5.26.1 | | -| php | 7.0.32 | 7.2.19 | | -| python | 2.7.12 | 2.7.15 | | -| python3 | 3.5.2 | 3.6.8 | | -| ruby | 2.3.1p112 | 2.5.1p57 | | +| erlang | OTP-25.3.2.9 | OTP-25.3.2.9 | | +| go | 1.21.7 | 1.21.7 | | +| haxe | 4.2.1 | 4.2.1 | | +| java | 17 | 17 | | +| js | Node.js 16.20.2, npm 8.19.4 | Node.js 16.20.2, npm 8.19.4 | | +| lua | 5.2.4 | 5.2.4 | Lua 5.3: see THRIFT-4386 | +| netstd | 8.0.200 | 8.0.200 | | +| nodejs | 16.20.2 | 16.20.2 | | +| ocaml | 4.08.1 | 4.13.1 | | +| perl | 5.30.0 | 5.34.0 | | +| php | 7.4.3 | 8.1.2 | | +| python2 | 2.7.18 | | | +| python3 | 3.8.10 | 3.10.12 | | +| ruby | 2.7.0p0 | 3.0.2p107 | | | rust | 1.65.0 | 1.65.0 | | | smalltalk | | | Not in CI | -| swift | | 5.1.4 | | +| swift | 5.7 | 5.7 | | From 705b425fb15d6b3d081160e84f5821e289ef3125 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 6 Mar 2024 23:26:22 +0900 Subject: [PATCH 215/250] Fix haxe setup, allow root users to be used and check for existing users --- build/docker/ubuntu-focal/Dockerfile | 18 ++++++++++++------ build/docker/ubuntu-jammy/Dockerfile | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile index 4e975e7552f..a29ec69531f 100644 --- a/build/docker/ubuntu-focal/Dockerfile +++ b/build/docker/ubuntu-focal/Dockerfile @@ -40,9 +40,11 @@ ARG gid=1000 RUN apt-get install -y --no-install-recommends sudo && \ echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \ - if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ - adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \ - echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + if [ -z `cat /etc/group | grep "${group}:"` ] && [ -z `cat /etc/group | grep ":${gid}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ + if [ -z `cat /etc/passwd | grep "${user}:"` ] && [ -z `cat /etc/passwd | grep ":${uid}:"` ]; then adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos ""; fi && \ + echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \ + mkdir -p /home/${user} && \ + chown -R ${user}:${group} /home/${user} # Dart RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ @@ -181,9 +183,13 @@ RUN cd $HOME && \ mv neko-* /opt/neko ENV PATH /opt/haxe:/opt/neko:$PATH RUN echo "/opt/neko" > /etc/ld.so.conf.d/neko.conf && \ - ldconfig && \ - haxelib setup --always /usr/share/haxe/lib && \ - haxelib install --always hxcpp 2>&1 > /dev/null + ldconfig +USER ${user} +RUN mkdir -p $HOME/haxe/lib && \ + haxelib setup --always $HOME/haxe/lib && \ + haxelib install --always hxcpp 2>&1 > /dev/null && \ + haxelib install --always uuid 2>&1 > /dev/null +USER root ENV GRADLE_VERSION="8.4" RUN apt-get install -y --no-install-recommends \ diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile index 3d2326ebe26..5fa6e6f889d 100644 --- a/build/docker/ubuntu-jammy/Dockerfile +++ b/build/docker/ubuntu-jammy/Dockerfile @@ -40,9 +40,11 @@ ARG gid=1000 RUN apt-get install -y --no-install-recommends sudo && \ echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \ - if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ - adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \ - echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + if [ -z `cat /etc/group | grep "${group}:"` ] && [ -z `cat /etc/group | grep ":${gid}:"` ]; then addgroup --gid ${gid} ${group}; fi && \ + if [ -z `cat /etc/passwd | grep "${user}:"` ] && [ -z `cat /etc/passwd | grep ":${uid}:"` ]; then adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos ""; fi && \ + echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \ + mkdir -p /home/${user} && \ + chown -R ${user}:${group} /home/${user} # Dart RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ @@ -180,9 +182,13 @@ RUN cd $HOME && \ mv neko-* /opt/neko ENV PATH /opt/haxe:/opt/neko:$PATH RUN echo "/opt/neko" > /etc/ld.so.conf.d/neko.conf && \ - ldconfig && \ - haxelib setup --always /usr/share/haxe/lib && \ - haxelib install --always hxcpp 2>&1 > /dev/null + ldconfig +USER ${user} +RUN mkdir -p $HOME/haxe/lib && \ + haxelib setup --always $HOME/haxe/lib && \ + haxelib install --always hxcpp 2>&1 > /dev/null && \ + haxelib install --always uuid 2>&1 > /dev/null +USER root ENV GRADLE_VERSION="8.4" RUN apt-get install -y --no-install-recommends \ From aef2d7b6628783921729679b19a701be17446ca6 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 17 Mar 2024 10:06:24 +0900 Subject: [PATCH 216/250] Fix EXTRA_DIST in php make file --- lib/php/Makefile.am | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/php/Makefile.am b/lib/php/Makefile.am index 91944c48164..a618d24bfe8 100644 --- a/lib/php/Makefile.am +++ b/lib/php/Makefile.am @@ -149,18 +149,7 @@ EXTRA_DIST = \ coding_standards.md \ thrift_protocol.ini \ README.apache.md \ - README.md \ - test/Fixtures.php \ - test/TestValidators.thrift \ - test/JsonSerialize/JsonSerializeTest.php \ - test/Protocol/BinarySerializerTest.php \ - test/Protocol/TJSONProtocolFixtures.php \ - test/Protocol/TJSONProtocolTest.php \ - test/Protocol/TSimpleJSONProtocolFixtures.php \ - test/Protocol/TSimpleJSONProtocolTest.php \ - test/Validator/BaseValidatorTest.php \ - test/Validator/ValidatorTest.php \ - test/Validator/ValidatorTestOop.php + README.md MAINTAINERCLEANFILES = \ From 7f27fbbf3733d0afd09632f0e0d1611b12c7aee9 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 21 Mar 2024 22:51:07 +0900 Subject: [PATCH 217/250] Manually remove $(BUILT_SOURCES) since no-dist-built-sources doesnt work --- Makefile.am | 3 +++ compiler/cpp/Makefile.am | 3 +++ compiler/cpp/src/Makefile.am | 3 +++ compiler/cpp/test/Makefile.am | 3 +++ contrib/fb303/py/Makefile.am | 3 +++ lib/Makefile.am | 3 +++ lib/c_glib/Makefile.am | 3 +++ lib/c_glib/test/Makefile.am | 3 +++ lib/cl/Makefile.am | 3 +++ lib/cpp/Makefile.am | 3 +++ lib/cpp/test/Makefile.am | 3 +++ lib/d/Makefile.am | 3 +++ lib/d/test/Makefile.am | 2 ++ lib/dart/Makefile.am | 3 +++ lib/erl/Makefile.am | 3 +++ lib/go/Makefile.am | 3 +++ lib/go/test/Makefile.am | 3 +++ lib/go/test/fuzz/Makefile.am | 3 +++ lib/haxe/test/Makefile.am | 3 +++ lib/java/Makefile.am | 3 +++ lib/js/Makefile.am | 3 +++ lib/js/test/Makefile.am | 3 +++ lib/json/Makefile.am | 3 +++ lib/json/test/Makefile.am | 3 +++ lib/kotlin/Makefile.am | 3 +++ lib/lua/Makefile.am | 3 +++ lib/netstd/Makefile.am | 3 +++ lib/nodejs/Makefile.am | 3 +++ lib/nodets/Makefile.am | 3 +++ lib/perl/Makefile.am | 3 +++ lib/perl/t/Makefile.am | 3 +++ lib/php/Makefile.am | 5 ++++- lib/php/test/Makefile.am | 3 +++ lib/py/Makefile.am | 3 +++ lib/rb/Makefile.am | 3 +++ lib/rs/Makefile.am | 3 +++ lib/rs/test/Makefile.am | 3 +++ lib/rs/test_recursive/Makefile.am | 3 +++ lib/rs/test_recursive/src/Makefile.am | 3 +++ lib/rs/test_recursive/src/maintenance/Makefile.am | 3 +++ lib/rs/test_recursive/src/transit/Makefile.am | 3 +++ lib/rs/test_recursive/src/transit/light/Makefile.am | 3 +++ lib/rs/test_recursive/src/transit/services/Makefile.am | 3 +++ lib/swift/Makefile.am | 3 +++ lib/ts/Makefile.am | 3 +++ lib/xml/Makefile.am | 3 +++ lib/xml/test/Makefile.am | 3 +++ test/Makefile.am | 3 +++ test/c_glib/Makefile.am | 3 +++ test/cl/Makefile.am | 3 +++ test/cpp/Makefile.am | 3 +++ test/dart/Makefile.am | 3 +++ test/erl/Makefile.am | 3 +++ test/features/Makefile.am | 3 +++ test/go/Makefile.am | 3 +++ test/haxe/Makefile.am | 3 +++ test/lua/Makefile.am | 3 +++ test/netstd/Makefile.am | 3 +++ test/perl/Makefile.am | 3 +++ test/php/Makefile.am | 3 +++ test/py.tornado/Makefile.am | 3 +++ test/py.twisted/Makefile.am | 3 +++ test/py/Makefile.am | 2 ++ test/rb/Makefile.am | 3 +++ test/rs/Makefile.am | 3 +++ test/swift/CrossTests/Makefile.am | 3 +++ test/swift/Makefile.am | 3 +++ tutorial/Makefile.am | 3 +++ tutorial/c_glib/Makefile.am | 3 +++ tutorial/cl/Makefile.am | 3 +++ tutorial/cpp/Makefile.am | 3 +++ tutorial/d/Makefile.am | 3 +++ tutorial/dart/Makefile.am | 3 +++ tutorial/go/Makefile.am | 3 +++ tutorial/haxe/Makefile.am | 3 +++ tutorial/java/Makefile.am | 3 +++ tutorial/js/Makefile.am | 3 +++ tutorial/netstd/Makefile.am | 3 +++ tutorial/nodejs/Makefile.am | 3 +++ tutorial/perl/Makefile.am | 3 +++ tutorial/php/Makefile.am | 3 +++ tutorial/py.tornado/Makefile.am | 3 +++ tutorial/py.twisted/Makefile.am | 3 +++ tutorial/py/Makefile.am | 3 +++ tutorial/rb/Makefile.am | 3 +++ tutorial/rs/Makefile.am | 3 +++ tutorial/swift/Makefile.am | 3 +++ 87 files changed, 260 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 5b9e9709f2f..df7490424fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -131,6 +131,9 @@ skipped_files = $(subst $(space),$(comma),$(codespell_skip_files)) style-local: codespell --write-changes --skip=$(skipped_files) --disable-colors +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ .asf.yaml \ .clang-format \ diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am index bb29d8c47e8..29ef1bd94ca 100644 --- a/compiler/cpp/Makefile.am +++ b/compiler/cpp/Makefile.am @@ -114,6 +114,9 @@ WINDOWS_DIST = \ compiler.vcxproj \ compiler.vcxproj.filters +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ coding_standards.md \ README.md \ diff --git a/compiler/cpp/src/Makefile.am b/compiler/cpp/src/Makefile.am index 5111fd55038..5b6802a4d84 100644 --- a/compiler/cpp/src/Makefile.am +++ b/compiler/cpp/src/Makefile.am @@ -39,6 +39,9 @@ clean-local: $(RM) thrift/thriftl.cc thrift/thrifty.cc thrift/thrifty.h thrift/thrifty.hh +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ thrift/logging.cc \ thrift/windows/config.h diff --git a/compiler/cpp/test/Makefile.am b/compiler/cpp/test/Makefile.am index 10efd073767..6d4d09e938d 100644 --- a/compiler/cpp/test/Makefile.am +++ b/compiler/cpp/test/Makefile.am @@ -23,5 +23,8 @@ AUTOMAKE_OPTIONS = subdir-objects serial-tests nostdinc +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + AM_CPPFLAGS = -I$(top_srcdir)/compiler/cpp/src AM_CXXFLAGS = -Wall -Wextra -pedantic diff --git a/contrib/fb303/py/Makefile.am b/contrib/fb303/py/Makefile.am index 060495e5819..706e10a35e2 100644 --- a/contrib/fb303/py/Makefile.am +++ b/contrib/fb303/py/Makefile.am @@ -18,6 +18,9 @@ # DESTDIR ?= / +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = setup.py src all: diff --git a/lib/Makefile.am b/lib/Makefile.am index 3f717f1afc8..19177ccb537 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -102,6 +102,9 @@ endif # All of the libs that don't use Automake need to go in here # so they will end up in our release tarballs. +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ d \ dart \ diff --git a/lib/c_glib/Makefile.am b/lib/c_glib/Makefile.am index b2061bbc789..80a51650a31 100644 --- a/lib/c_glib/Makefile.am +++ b/lib/c_glib/Makefile.am @@ -112,6 +112,9 @@ include_processor_HEADERS = src/thrift/c_glib/processor/thrift_processor.h \ src/thrift/c_glib/processor/thrift_multiplexed_processor.h +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ CMakeLists.txt \ coding_standards.md \ diff --git a/lib/c_glib/test/Makefile.am b/lib/c_glib/test/Makefile.am index f3a0c30df67..c7c67ab4c73 100644 --- a/lib/c_glib/test/Makefile.am +++ b/lib/c_glib/test/Makefile.am @@ -401,6 +401,9 @@ CLEANFILES = \ *.gcda \ *.gcov +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ CMakeLists.txt \ ContainerTest.thrift diff --git a/lib/cl/Makefile.am b/lib/cl/Makefile.am index 34b38861d23..a54eb922eb4 100644 --- a/lib/cl/Makefile.am +++ b/lib/cl/Makefile.am @@ -32,6 +32,9 @@ clean-local: $(RM) run-tests quicklisp.lisp backport-update.zip $(RM) -rf lib externals quicklisp +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ README.md \ READMES \ diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am index c015b0db60f..2499fdbff6b 100644 --- a/lib/cpp/Makefile.am +++ b/lib/cpp/Makefile.am @@ -252,6 +252,9 @@ WINDOWS_DIST = \ libthriftnb.vcxproj.filters \ 3rdparty.props +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ CMakeLists.txt \ coding_standards.md \ diff --git a/lib/cpp/test/Makefile.am b/lib/cpp/test/Makefile.am index cd401c0f396..a7440392f85 100644 --- a/lib/cpp/test/Makefile.am +++ b/lib/cpp/test/Makefile.am @@ -424,6 +424,9 @@ AM_CXXFLAGS = -Wall -Wextra -pedantic clean-local: $(RM) gen-cpp/* +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ concurrency \ processor \ diff --git a/lib/d/Makefile.am b/lib/d/Makefile.am index 013721720b5..6f014c83189 100644 --- a/lib/d/Makefile.am +++ b/lib/d/Makefile.am @@ -192,6 +192,9 @@ TESTS = $(addprefix unittest/debug/, $(d_test_modules)) \ precross: all-local $(MAKE) -C test precross +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ src \ test \ diff --git a/lib/d/test/Makefile.am b/lib/d/test/Makefile.am index 44364f9d97c..28f3f3ec4a0 100644 --- a/lib/d/test/Makefile.am +++ b/lib/d/test/Makefile.am @@ -38,6 +38,8 @@ thrift_test_gen = $(addprefix gen-d/thrift/test/, SecondService.d \ $(thrift_test_gen): $(top_srcdir)/test/v0.16/ThriftTest.thrift $(THRIFT) --gen d $< +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am # The actual test targets. # There just must be some way to reassign a variable without warnings in diff --git a/lib/dart/Makefile.am b/lib/dart/Makefile.am index bd12a92f020..74f1404b663 100644 --- a/lib/dart/Makefile.am +++ b/lib/dart/Makefile.am @@ -28,6 +28,9 @@ clean-local: check-local: all +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + dist-hook: $(RM) -r $(distdir)/.pub find $(distdir) -type d -name ".dart_tool" | xargs $(RM) -r diff --git a/lib/erl/Makefile.am b/lib/erl/Makefile.am index 23ebb778908..4259a1f5a14 100644 --- a/lib/erl/Makefile.am +++ b/lib/erl/Makefile.am @@ -78,6 +78,9 @@ dist-hook: $(RM) -r $(distdir)/test/gen-erl/ $(RM) $(distdir)/$(THRIFT_OMIT_FILE) +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ include \ src \ diff --git a/lib/go/Makefile.am b/lib/go/Makefile.am index 18b6b75f46e..3bfefbc2209 100644 --- a/lib/go/Makefile.am +++ b/lib/go/Makefile.am @@ -48,6 +48,9 @@ clean-local: all-local: $(GO) build $(GOBUILDEXTRA) ./thrift +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ thrift \ coding_standards.md \ diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am index 379971e99f9..d76f24815dd 100644 --- a/lib/go/test/Makefile.am +++ b/lib/go/test/Makefile.am @@ -136,6 +136,9 @@ clean-local: client: stubs $(GO) run TestClient.go +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ dontexportrwtest \ tests \ diff --git a/lib/go/test/fuzz/Makefile.am b/lib/go/test/fuzz/Makefile.am index 9677f4f0016..a481e9583d9 100644 --- a/lib/go/test/fuzz/Makefile.am +++ b/lib/go/test/fuzz/Makefile.am @@ -27,6 +27,9 @@ check: gopathfuzz clean-local: $(RM) -rf gopathfuzz gen-go +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ fuzz.go \ fuzz_test.go \ diff --git a/lib/haxe/test/Makefile.am b/lib/haxe/test/Makefile.am index 2b8b24524cc..8c658ae7c74 100644 --- a/lib/haxe/test/Makefile.am +++ b/lib/haxe/test/Makefile.am @@ -69,6 +69,9 @@ check: $(BIN_CPP) $(BIN_PHP) $(BIN_CPP) php -f $(BIN_PHP) +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ src \ cpp.hxml \ diff --git a/lib/java/Makefile.am b/lib/java/Makefile.am index 1dd42a7d2ba..fc63af4827f 100644 --- a/lib/java/Makefile.am +++ b/lib/java/Makefile.am @@ -56,6 +56,9 @@ maven-publish: -Pthrift.version=$(PACKAGE_VERSION) \ --console=plain +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ build.gradle \ gradle.properties \ diff --git a/lib/js/Makefile.am b/lib/js/Makefile.am index 4906d7ddbcc..9b7dfb6d30f 100644 --- a/lib/js/Makefile.am +++ b/lib/js/Makefile.am @@ -52,6 +52,9 @@ dist-hook: $(RM) -r $(distdir)/test/build/ $(RM) -r $(distdir)/test/gen-*/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ coding_standards.md \ Gruntfile.js \ diff --git a/lib/js/test/Makefile.am b/lib/js/test/Makefile.am index 14927c40a51..8a817b36621 100644 --- a/lib/js/test/Makefile.am +++ b/lib/js/test/Makefile.am @@ -24,6 +24,9 @@ clean-local: ANT=$(ANT) ; if test -z "$$ANT" ; then ANT=: ; fi ; \ $$ANT $(ANT_FLAGS) clean +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + check-local: all $(ANT) $(ANT_FLAGS) test diff --git a/lib/json/Makefile.am b/lib/json/Makefile.am index 6c8c0ce8116..3c7aa8f3d74 100644 --- a/lib/json/Makefile.am +++ b/lib/json/Makefile.am @@ -28,6 +28,9 @@ clean-local: dist-hook: $(RM) -r $(distdir)/test/build/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ schema.json \ test diff --git a/lib/json/test/Makefile.am b/lib/json/test/Makefile.am index bb87a52038f..16bcfae383f 100644 --- a/lib/json/test/Makefile.am +++ b/lib/json/test/Makefile.am @@ -20,6 +20,9 @@ check: $(ANT) $(ANT_FLAGS) test +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + # Make sure this doesn't fail if ant is not configured. clean-local: ANT=$(ANT) ; if test -z "$$ANT" ; then ANT=: ; fi ; \ diff --git a/lib/kotlin/Makefile.am b/lib/kotlin/Makefile.am index 720f8234fe0..e5685cf7162 100644 --- a/lib/kotlin/Makefile.am +++ b/lib/kotlin/Makefile.am @@ -40,6 +40,9 @@ check-local: $(THRIFT) -Pthrift.compiler=$(THRIFT) \ --console=plain +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ build.gradle.kts \ CMakeLists.txt \ diff --git a/lib/lua/Makefile.am b/lib/lua/Makefile.am index 3b272f56cbe..ae67d942e85 100644 --- a/lib/lua/Makefile.am +++ b/lib/lua/Makefile.am @@ -57,6 +57,9 @@ liblualongnumber_la_CPPFLAGS = $(AM_CPPFLAGS) $(LUA_INCLUDE) -DLUA_COMPAT_MODULE liblualongnumber_la_LDFLAGS = $(AM_LDFLAGS) liblualongnumber_la_LIBADD = $(LUA_LIB) -lm +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ coding_standards.md \ TBinaryProtocol.lua \ diff --git a/lib/netstd/Makefile.am b/lib/netstd/Makefile.am index 47b38030932..ccaef9e4c69 100644 --- a/lib/netstd/Makefile.am +++ b/lib/netstd/Makefile.am @@ -39,6 +39,9 @@ clean-local: $(RM) -r Tests/Thrift.PublicInterfaces.Compile.Tests/bin $(RM) -r Tests/Thrift.PublicInterfaces.Compile.Tests/obj +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ README.md \ Directory.Build.props \ diff --git a/lib/nodejs/Makefile.am b/lib/nodejs/Makefile.am index 6691579624c..9503f04c9e1 100644 --- a/lib/nodejs/Makefile.am +++ b/lib/nodejs/Makefile.am @@ -37,6 +37,9 @@ clean-local: $(RM) -r test/episodic-code-generation-test/gen* $(RM) -r test/episodic-code-generation-test/node_modules +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ examples \ lib \ diff --git a/lib/nodets/Makefile.am b/lib/nodets/Makefile.am index 02d0c11fee7..ac2aa6e1b17 100644 --- a/lib/nodets/Makefile.am +++ b/lib/nodets/Makefile.am @@ -41,6 +41,9 @@ clean-local: $(RM) -r $(top_srcdir)/node_modules $(RM) -r test-compiled +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ test \ coding_standards.md diff --git a/lib/perl/Makefile.am b/lib/perl/Makefile.am index 8b72436c500..9d762b41018 100644 --- a/lib/perl/Makefile.am +++ b/lib/perl/Makefile.am @@ -36,6 +36,9 @@ clean-local: $(RM) Makefile-perl.mk.old $(RM) -r gen-perl gen-perl2 +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ coding_standards.md \ build-cpan-dist.sh \ diff --git a/lib/perl/t/Makefile.am b/lib/perl/t/Makefile.am index de03971869f..7e9d8a0b987 100644 --- a/lib/perl/t/Makefile.am +++ b/lib/perl/t/Makefile.am @@ -17,4 +17,7 @@ # under the License. # +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = memory_buffer.t processor.t multiplex.t diff --git a/lib/php/Makefile.am b/lib/php/Makefile.am index a618d24bfe8..3851294604e 100644 --- a/lib/php/Makefile.am +++ b/lib/php/Makefile.am @@ -134,6 +134,8 @@ phptype_DATA = \ clean-local: if [ -f src/ext/thrift_protocol/Makefile ]; then cd src/ext/thrift_protocol/ && $(MAKE) clean; fi +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am EXTRA_DIST = \ lib \ @@ -149,7 +151,8 @@ EXTRA_DIST = \ coding_standards.md \ thrift_protocol.ini \ README.apache.md \ - README.md + README.md \ + test MAINTAINERCLEANFILES = \ diff --git a/lib/php/test/Makefile.am b/lib/php/test/Makefile.am index 00d51f628f8..1e534cad0f4 100644 --- a/lib/php/test/Makefile.am +++ b/lib/php/test/Makefile.am @@ -41,6 +41,9 @@ check: deps stubs distclean-local: +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + clean-local: $(RM) -r ./Resources/packages $(RM) test-log-junit.xml diff --git a/lib/py/Makefile.am b/lib/py/Makefile.am index 9b6d33b9acc..b76a7dc5dc8 100644 --- a/lib/py/Makefile.am +++ b/lib/py/Makefile.am @@ -69,6 +69,9 @@ dist-hook: find $(distdir) -type f \( -iname "*.pyc" \) | xargs rm -f find $(distdir) -type d \( -iname "__pycache__" -or -iname "_trial_temp" \) | xargs rm -rf +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ CMakeLists.txt \ MANIFEST.in \ diff --git a/lib/rb/Makefile.am b/lib/rb/Makefile.am index 1841065f5a3..ab5d903fe2a 100644 --- a/lib/rb/Makefile.am +++ b/lib/rb/Makefile.am @@ -42,6 +42,9 @@ endif dist-hook: $(RM) -r $(distdir)/spec/gen-rb/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ coding_standards.md \ Rakefile \ diff --git a/lib/rs/Makefile.am b/lib/rs/Makefile.am index 7a9b30a4feb..3a134034d50 100644 --- a/lib/rs/Makefile.am +++ b/lib/rs/Makefile.am @@ -45,6 +45,9 @@ clean-local: $(CARGO) clean -$(RM) Cargo.lock +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ src \ Cargo.toml \ diff --git a/lib/rs/test/Makefile.am b/lib/rs/test/Makefile.am index 017a2c4672f..73fe156cc5f 100644 --- a/lib/rs/test/Makefile.am +++ b/lib/rs/test/Makefile.am @@ -47,6 +47,9 @@ clean-local: -$(RM) src/identifiers.rs -$(RM) -r bin +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ Cargo.toml \ thrifts/Base_One.thrift \ diff --git a/lib/rs/test_recursive/Makefile.am b/lib/rs/test_recursive/Makefile.am index e676ccdca10..ec7d4fc413b 100644 --- a/lib/rs/test_recursive/Makefile.am +++ b/lib/rs/test_recursive/Makefile.am @@ -29,5 +29,8 @@ clean-local: $(CARGO) clean -$(RM) Cargo.lock +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ Cargo.toml diff --git a/lib/rs/test_recursive/src/Makefile.am b/lib/rs/test_recursive/src/Makefile.am index 4bfd557d00c..eeb81abc7ad 100644 --- a/lib/rs/test_recursive/src/Makefile.am +++ b/lib/rs/test_recursive/src/Makefile.am @@ -29,6 +29,9 @@ check: stubs clean-local: -$(RM) vehicles.rs +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ lib.rs \ Vehicles.thrift diff --git a/lib/rs/test_recursive/src/maintenance/Makefile.am b/lib/rs/test_recursive/src/maintenance/Makefile.am index e2526bdc984..a1f0ae8f228 100644 --- a/lib/rs/test_recursive/src/maintenance/Makefile.am +++ b/lib/rs/test_recursive/src/maintenance/Makefile.am @@ -29,6 +29,9 @@ check: stubs clean-local: -$(RM) maintenance_facility.rs +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ mod.rs \ MaintenanceFacility.thrift diff --git a/lib/rs/test_recursive/src/transit/Makefile.am b/lib/rs/test_recursive/src/transit/Makefile.am index 908becb25bf..217227a0e5d 100644 --- a/lib/rs/test_recursive/src/transit/Makefile.am +++ b/lib/rs/test_recursive/src/transit/Makefile.am @@ -34,6 +34,9 @@ clean-local: -$(RM) trains.rs -$(RM) transporters.rs +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ mod.rs \ Buses.thrift \ diff --git a/lib/rs/test_recursive/src/transit/light/Makefile.am b/lib/rs/test_recursive/src/transit/light/Makefile.am index 88fd5310c37..b0e3c76a32d 100644 --- a/lib/rs/test_recursive/src/transit/light/Makefile.am +++ b/lib/rs/test_recursive/src/transit/light/Makefile.am @@ -31,6 +31,9 @@ clean-local: -$(RM) light_rail.rs -$(RM) streetcars.rs +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ mod.rs \ LightRail.thrift \ diff --git a/lib/rs/test_recursive/src/transit/services/Makefile.am b/lib/rs/test_recursive/src/transit/services/Makefile.am index 12e9e293515..a141c6dd558 100644 --- a/lib/rs/test_recursive/src/transit/services/Makefile.am +++ b/lib/rs/test_recursive/src/transit/services/Makefile.am @@ -29,6 +29,9 @@ check: stubs clean-local: -$(RM) city_services.rs +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ mod.rs \ CityServices.thrift diff --git a/lib/swift/Makefile.am b/lib/swift/Makefile.am index 6a6644ac01b..ac61716d6dc 100644 --- a/lib/swift/Makefile.am +++ b/lib/swift/Makefile.am @@ -35,6 +35,9 @@ precross: check-local: swift test +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ Package.swift \ Sources \ diff --git a/lib/ts/Makefile.am b/lib/ts/Makefile.am index 62ea2069f16..05d71e4d364 100644 --- a/lib/ts/Makefile.am +++ b/lib/ts/Makefile.am @@ -48,6 +48,9 @@ dist-hook: $(RM) -r $(distdir)/test/build/ $(RM) -r $(distdir)/test/gen-*/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ coding_standards.md \ Gruntfile.js \ diff --git a/lib/xml/Makefile.am b/lib/xml/Makefile.am index bcad6bdd5af..6a1503a744f 100644 --- a/lib/xml/Makefile.am +++ b/lib/xml/Makefile.am @@ -24,6 +24,9 @@ if WITH_JAVA SUBDIRS += test endif +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ thrift-idl.xsd \ test diff --git a/lib/xml/test/Makefile.am b/lib/xml/test/Makefile.am index bb87a52038f..16bcfae383f 100644 --- a/lib/xml/test/Makefile.am +++ b/lib/xml/test/Makefile.am @@ -20,6 +20,9 @@ check: $(ANT) $(ANT_FLAGS) test +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + # Make sure this doesn't fail if ant is not configured. clean-local: ANT=$(ANT) ; if test -z "$$ANT" ; then ANT=: ; fi ; \ diff --git a/test/Makefile.am b/test/Makefile.am index d3d0075266a..bc0cd633412 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -120,6 +120,9 @@ dist-hook: find $(distdir) -type d -name "__pycache__" | xargs rm -rf find $(distdir) -type f -name "*.pyc" | xargs rm -f +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ audit \ c_glib \ diff --git a/test/c_glib/Makefile.am b/test/c_glib/Makefile.am index f55a977d4ed..44714253ed9 100644 --- a/test/c_glib/Makefile.am +++ b/test/c_glib/Makefile.am @@ -78,5 +78,8 @@ dist-hook: $(RM) $(distdir)/libtestcglib.la find $(distdir) -type f -iname "*.o" | xargs rm -f +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ src diff --git a/test/cl/Makefile.am b/test/cl/Makefile.am index b5e72bcbbb9..c9705f15740 100755 --- a/test/cl/Makefile.am +++ b/test/cl/Makefile.am @@ -35,6 +35,9 @@ clean-local: $(RM) TestServer $(RM) TestClient +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ implementation.lisp \ make-test-client.lisp \ diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am index 9e8b6765b45..595f7a4fc73 100644 --- a/test/cpp/Makefile.am +++ b/test/cpp/Makefile.am @@ -116,6 +116,9 @@ clean-local: style-local: $(CPPSTYLE_CMD) +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ src/TestClient.cpp \ src/TestServer.cpp \ diff --git a/test/dart/Makefile.am b/test/dart/Makefile.am index 81f2f5b1088..3552668f3d8 100644 --- a/test/dart/Makefile.am +++ b/test/dart/Makefile.am @@ -48,5 +48,8 @@ dist-hook: client: stubs ${DART} test_client/bin/main.dart +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ test_client diff --git a/test/erl/Makefile.am b/test/erl/Makefile.am index 5bc90fa8814..665cb7ba051 100644 --- a/test/erl/Makefile.am +++ b/test/erl/Makefile.am @@ -40,6 +40,9 @@ clean: $(RM) -r .rebar/ $(RM) -r src/gen-erl/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + dist-hook: $(RM) $(distdir)/.generated $(RM) -r $(distdir)/.rebar/ diff --git a/test/features/Makefile.am b/test/features/Makefile.am index 337d78950ef..4ee56f016fb 100644 --- a/test/features/Makefile.am +++ b/test/features/Makefile.am @@ -14,6 +14,9 @@ # under the License. # +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ local_thrift \ index.html \ diff --git a/test/go/Makefile.am b/test/go/Makefile.am index 92ddc93c955..a00fc379431 100644 --- a/test/go/Makefile.am +++ b/test/go/Makefile.am @@ -60,6 +60,9 @@ check: gopath genmock genmock: gopath sh genmock.sh +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ src/bin \ src/common \ diff --git a/test/haxe/Makefile.am b/test/haxe/Makefile.am index d37aaa77aca..6274f29bf4e 100644 --- a/test/haxe/Makefile.am +++ b/test/haxe/Makefile.am @@ -84,6 +84,9 @@ check_php_web: $(BIN_PHP_WEB) $(BIN_CPP) sleep 10 +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ src \ cpp.hxml \ diff --git a/test/lua/Makefile.am b/test/lua/Makefile.am index a3ab3e26ad3..00bdf3d2bfb 100644 --- a/test/lua/Makefile.am +++ b/test/lua/Makefile.am @@ -30,5 +30,8 @@ precross: stubs clean-local: $(RM) -r gen-lua/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + dist-hook: $(RM) -r $(distdir)/gen-lua/ diff --git a/test/netstd/Makefile.am b/test/netstd/Makefile.am index 9712fc2a431..bd06cd4b496 100644 --- a/test/netstd/Makefile.am +++ b/test/netstd/Makefile.am @@ -32,6 +32,9 @@ clean-local: $(RM) -r Server/obj $(RM) -r ThriftTest/ThriftTest +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ Client \ README.md \ diff --git a/test/perl/Makefile.am b/test/perl/Makefile.am index 589fe624bf5..0064a6e7355 100644 --- a/test/perl/Makefile.am +++ b/test/perl/Makefile.am @@ -27,5 +27,8 @@ check: stubs clean-local: $(RM) -r gen-perl/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + dist-hook: $(RM) -r $(distdir)/gen-perl/ diff --git a/test/php/Makefile.am b/test/php/Makefile.am index b1ac68683ca..1cffdd4f503 100644 --- a/test/php/Makefile.am +++ b/test/php/Makefile.am @@ -37,6 +37,9 @@ clean-local: $(RM) -r gen-*/ $(RM) -r php_ext_dir +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + dist-hook: $(RM) -r $(distdir)/gen-*/ $(RM) -r $(distdir)/php_ext_dir/ diff --git a/test/py.tornado/Makefile.am b/test/py.tornado/Makefile.am index 3b78793f772..214ded2067d 100644 --- a/test/py.tornado/Makefile.am +++ b/test/py.tornado/Makefile.am @@ -32,6 +32,9 @@ clean-local: find . -type d \( -iname "__pycache__" -or -iname "_trial_temp" \) | xargs rm -rf $(RM) -r gen-py*/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + dist-hook: find $(distdir) -type f \( -iname "*.pyc" \) | xargs rm -f find $(distdir) -type d \( -iname "__pycache__" -or -iname "_trial_temp" \) | xargs rm -rf diff --git a/test/py.twisted/Makefile.am b/test/py.twisted/Makefile.am index bd0cdb1a45a..6461d12f13a 100644 --- a/test/py.twisted/Makefile.am +++ b/test/py.twisted/Makefile.am @@ -32,6 +32,9 @@ clean-local: find . -type d \( -iname "__pycache__" -or -iname "_trial_temp" \) | xargs rm -rf $(RM) -r gen-py*/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + dist-hook: find $(distdir) -type f \( -iname "*.pyc" \) | xargs rm -f find $(distdir) -type d \( -iname "__pycache__" -or -iname "_trial_temp" \) | xargs rm -rf diff --git a/test/py/Makefile.am b/test/py/Makefile.am index 7c78f17da22..e02607758bd 100644 --- a/test/py/Makefile.am +++ b/test/py/Makefile.am @@ -54,6 +54,8 @@ thrift_gen = \ gen-py-enum/DoubleConstantsTest/__init__.py \ gen-py-enum/Recursive/__init__.py +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am precross: $(thrift_gen) BUILT_SOURCES = $(thrift_gen) diff --git a/test/rb/Makefile.am b/test/rb/Makefile.am index 5dd75594618..9c5d557fd0d 100644 --- a/test/rb/Makefile.am +++ b/test/rb/Makefile.am @@ -33,5 +33,8 @@ endif clean-local: $(RM) -r gen-rb/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + dist-hook: $(RM) -r $(distdir)/gen-rb/ diff --git a/test/rs/Makefile.am b/test/rs/Makefile.am index 78db5ee0c5c..6f5cf932052 100644 --- a/test/rs/Makefile.am +++ b/test/rs/Makefile.am @@ -34,6 +34,9 @@ clean-local: -$(RM) src/thrift_test.rs -$(RM) -r bin +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ Cargo.toml \ src/lib.rs \ diff --git a/test/swift/CrossTests/Makefile.am b/test/swift/CrossTests/Makefile.am index b7d8fbb4902..5b332328af4 100644 --- a/test/swift/CrossTests/Makefile.am +++ b/test/swift/CrossTests/Makefile.am @@ -30,5 +30,8 @@ check: stubs clean-local: $(RM) -r Sources/Common/gen-swift/ +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + dist-hook: $(RM) -r $(distdir)/gen-swift/ diff --git a/test/swift/Makefile.am b/test/swift/Makefile.am index 20c2fe5c912..f81fba8786c 100644 --- a/test/swift/Makefile.am +++ b/test/swift/Makefile.am @@ -19,6 +19,9 @@ SUBDIRS = CrossTests +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + precross: $(MAKE) -C CrossTests precross diff --git a/tutorial/Makefile.am b/tutorial/Makefile.am index 24969d13b62..ab87c95eec3 100644 --- a/tutorial/Makefile.am +++ b/tutorial/Makefile.am @@ -101,6 +101,9 @@ clean-local: endif +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + # Any folders or files not listed above being added to SUBDIR need to be placed here in # EXTRA_DIST to be included in the release EXTRA_DIST = \ diff --git a/tutorial/c_glib/Makefile.am b/tutorial/c_glib/Makefile.am index f37649495f4..253f96261f0 100644 --- a/tutorial/c_glib/Makefile.am +++ b/tutorial/c_glib/Makefile.am @@ -79,6 +79,9 @@ tutorialserver: all tutorialclient: all ./tutorial_client +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ c_glib_server.c \ c_glib_client.c diff --git a/tutorial/cl/Makefile.am b/tutorial/cl/Makefile.am index 70c5e0730a5..aef5840f57a 100755 --- a/tutorial/cl/Makefile.am +++ b/tutorial/cl/Makefile.am @@ -57,6 +57,9 @@ clean-local: -$(RM) TutorialServer -$(RM) TutorialClient +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ tutorial-implementation.lisp \ shared-implementation.lisp \ diff --git a/tutorial/cpp/Makefile.am b/tutorial/cpp/Makefile.am index 77fd6d579cd..d093df3efc0 100644 --- a/tutorial/cpp/Makefile.am +++ b/tutorial/cpp/Makefile.am @@ -78,6 +78,9 @@ tutorialclient: all style-local: $(CPPSTYLE_CMD) +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ CMakeLists.txt \ CppClient.cpp \ diff --git a/tutorial/d/Makefile.am b/tutorial/d/Makefile.am index 358294ce56d..3db3d15513f 100644 --- a/tutorial/d/Makefile.am +++ b/tutorial/d/Makefile.am @@ -47,6 +47,9 @@ clean: $(RM) -r gen-d/ find . -type f -name '*.o' | xargs rm -f +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + dist-hook: $(RM) -f $(distdir)/$(PROGS) $(RM) -r $(distdir)/gen-d/ diff --git a/tutorial/dart/Makefile.am b/tutorial/dart/Makefile.am index 860f292b762..e29e3c57caa 100644 --- a/tutorial/dart/Makefile.am +++ b/tutorial/dart/Makefile.am @@ -66,6 +66,9 @@ tutorialclient: pub-get-gen pub-get-client tutorialconsoleclient: pub-get-console-client ${DART} console_client/bin/main.dart +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ client/web/client.dart \ client/web/index.html \ diff --git a/tutorial/go/Makefile.am b/tutorial/go/Makefile.am index b2f70ce120c..16385b00c34 100644 --- a/tutorial/go/Makefile.am +++ b/tutorial/go/Makefile.am @@ -45,6 +45,9 @@ tutorialsecureclient: all clean-local: $(RM) -r gen-* go-tutorial calculator-remote +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ src/client.go \ src/handler.go \ diff --git a/tutorial/haxe/Makefile.am b/tutorial/haxe/Makefile.am index e6f27134680..d2c84f4c7af 100644 --- a/tutorial/haxe/Makefile.am +++ b/tutorial/haxe/Makefile.am @@ -79,6 +79,9 @@ tutorialclient_http: all clean-local: $(RM) -r gen-haxe bin +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ src \ cpp.hxml \ diff --git a/tutorial/java/Makefile.am b/tutorial/java/Makefile.am index 59e68bab2b1..afad8f557e9 100644 --- a/tutorial/java/Makefile.am +++ b/tutorial/java/Makefile.am @@ -39,6 +39,9 @@ tutorialserver: all tutorialclient: all $(ANT) $(ANT_FLAGS) tutorialclient +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ build.properties \ build.xml \ diff --git a/tutorial/js/Makefile.am b/tutorial/js/Makefile.am index 26a3c836ea7..ac0283f9c84 100644 --- a/tutorial/js/Makefile.am +++ b/tutorial/js/Makefile.am @@ -33,6 +33,9 @@ check-local: all tutorialserver: all $(ANT) $(ANT_FLAGS) tutorialserver +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ build.properties \ build.xml \ diff --git a/tutorial/netstd/Makefile.am b/tutorial/netstd/Makefile.am index f295cc0729b..522601d2e3d 100644 --- a/tutorial/netstd/Makefile.am +++ b/tutorial/netstd/Makefile.am @@ -31,6 +31,9 @@ clean-local: $(RM) -r Interfaces/bin $(RM) -r Interfaces/obj +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ Client \ Interfaces \ diff --git a/tutorial/nodejs/Makefile.am b/tutorial/nodejs/Makefile.am index 1516fec2cce..3798a31cb26 100644 --- a/tutorial/nodejs/Makefile.am +++ b/tutorial/nodejs/Makefile.am @@ -38,6 +38,9 @@ tutorialclient_promise: all clean-local: $(RM) -r gen-* +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ NodeServer.js \ NodeClient.js \ diff --git a/tutorial/perl/Makefile.am b/tutorial/perl/Makefile.am index fe77213bbf3..d28165afcba 100644 --- a/tutorial/perl/Makefile.am +++ b/tutorial/perl/Makefile.am @@ -31,6 +31,9 @@ tutorialclient: all clean-local: $(RM) -r gen-* +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ PerlServer.pl \ PerlClient.pl diff --git a/tutorial/php/Makefile.am b/tutorial/php/Makefile.am index 3d30ad999e6..1d11e05cba8 100644 --- a/tutorial/php/Makefile.am +++ b/tutorial/php/Makefile.am @@ -31,6 +31,9 @@ tutorialclient: all clean-local: $(RM) -r gen-* +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ PhpServer.php \ PhpClient.php \ diff --git a/tutorial/py.tornado/Makefile.am b/tutorial/py.tornado/Makefile.am index 4b73c1e72db..d8996a70826 100644 --- a/tutorial/py.tornado/Makefile.am +++ b/tutorial/py.tornado/Makefile.am @@ -31,6 +31,9 @@ tutorialclient: all clean-local: $(RM) -r gen-* +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ PythonServer.py \ PythonClient.py diff --git a/tutorial/py.twisted/Makefile.am b/tutorial/py.twisted/Makefile.am index 50cd3429d9a..f617d7cff56 100644 --- a/tutorial/py.twisted/Makefile.am +++ b/tutorial/py.twisted/Makefile.am @@ -31,6 +31,9 @@ tutorialclient: all clean-local: $(RM) -r gen-* +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ PythonClient.py \ PythonServer.py \ diff --git a/tutorial/py/Makefile.am b/tutorial/py/Makefile.am index 7db816d3bcf..da59815fe7c 100644 --- a/tutorial/py/Makefile.am +++ b/tutorial/py/Makefile.am @@ -31,6 +31,9 @@ tutorialclient: all clean-local: $(RM) -r gen-* +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ setup.cfg \ PythonServer.py \ diff --git a/tutorial/rb/Makefile.am b/tutorial/rb/Makefile.am index 885cd92318e..3dd4e313328 100644 --- a/tutorial/rb/Makefile.am +++ b/tutorial/rb/Makefile.am @@ -31,6 +31,9 @@ tutorialclient: all clean-local: $(RM) -r gen-* +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ RubyServer.rb \ RubyClient.rb diff --git a/tutorial/rs/Makefile.am b/tutorial/rs/Makefile.am index 13f670794f5..bbdf7cb085a 100644 --- a/tutorial/rs/Makefile.am +++ b/tutorial/rs/Makefile.am @@ -45,6 +45,9 @@ clean-local: -$(RM) src/tutorial.rs -$(RM) -r bin +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + EXTRA_DIST = \ Cargo.toml \ src/lib.rs \ diff --git a/tutorial/swift/Makefile.am b/tutorial/swift/Makefile.am index e8b8b2284cb..bb1e61244c6 100644 --- a/tutorial/swift/Makefile.am +++ b/tutorial/swift/Makefile.am @@ -23,6 +23,9 @@ gen_swift: $(THRIFT) --gen swift -r -o Sources/Common $(top_srcdir)/tutorial/tutorial.thrift +distdir: + $(MAKE) $(AM_MAKEFLAGS) distdir-am + tutorial: gen_swift swift run TutorialRunner From 5dd3c853edcac97f2e8400a7e57ff7af25b53133 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Tue, 2 Apr 2024 14:23:42 +0200 Subject: [PATCH 218/250] Updated ReleaseManagement.md according to THRIFT-5755 changes --- doc/ReleaseManagement.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/ReleaseManagement.md b/doc/ReleaseManagement.md index 51ecead5345..7b6f0083a6d 100644 --- a/doc/ReleaseManagement.md +++ b/doc/ReleaseManagement.md @@ -126,12 +126,12 @@ All Apache Thrift releases go through a 72-hour final release candidate voting p THRIFT-123 C++ - Library Drop C++03 [THRIFT-123](https://issues.apache.org/jira/browse/THRIFT-3978) - Drop C++03 ``` - For example, if the row above was row "B" in EXCEL it would look something like: + For example, if the row above was row "1" in EXCEL it would look something like: ```text - =CONCAT("[", B1, "]", + =CONCAT("[", A1, "]", "https://issues.apache.org/jira/browse/", - B1, " - ", B3) + A1, " - ", C1) ``` 1. Create a level 3 section in `CHANGES.md` under the release for each component and copy the items from the RelNote column into the changes file. @@ -148,12 +148,16 @@ All Apache Thrift releases go through a 72-hour final release candidate voting p ~$ git clone -b "release/1.0.0" git@github.com:apache/thrift.git thrift-1.0.0-src ``` - 1. In the clean copy of the release branch, start a docker build container and run `make dist`: - - ```code - ~$ cd thrift-1.0.0-src - ~/thrift-1.0.0-src$ docker run -v $(pwd):/thrift/src:rw \ - -it thrift/thrift-build:ubuntu-bionic /bin/bash + 1. In the clean copy of the release branch, build the container image: + + ```bash + ~$ docker build -t thrift build/docker/ubuntu-jammy + ``` + + 1. Run the container and `make dist`: + + ```bash + ~$ docker run -v $(pwd):/thrift/src -it thrift /bin/bash root@8b4101188aa2:/thrift/src# ./bootstrap.sh && ./configure && make dist ``` From a2b38fd41e18cb536344f7d89b59a5617c449938 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:39:41 +0800 Subject: [PATCH 219/250] Bump org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 in /lib/kotlin (#2941) Bumps [org.jetbrains.kotlinx:kotlinx-coroutines-jdk8](https://github.com/Kotlin/kotlinx.coroutines) from 1.7.3 to 1.8.0. - [Release notes](https://github.com/Kotlin/kotlinx.coroutines/releases) - [Changelog](https://github.com/Kotlin/kotlinx.coroutines/blob/master/CHANGES.md) - [Commits](https://github.com/Kotlin/kotlinx.coroutines/compare/1.7.3...1.8.0) --- updated-dependencies: - dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/kotlin/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/build.gradle.kts b/lib/kotlin/build.gradle.kts index 5c9929bd987..94d39b9bdf0 100644 --- a/lib/kotlin/build.gradle.kts +++ b/lib/kotlin/build.gradle.kts @@ -29,7 +29,7 @@ repositories { dependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom")) implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.8.0") implementation("org.apache.thrift:libthrift:INCLUDED") testImplementation(kotlin("test")) } From b5152cf6b70be2572286e86a42362b1590dc6776 Mon Sep 17 00:00:00 2001 From: CJCombrink Date: Sat, 23 Mar 2024 21:32:28 +0100 Subject: [PATCH 220/250] THRIFT-5772: UUID support for c++ #2952 Client: cpp Patch: CJCombrink This closes #2952 --- .../src/thrift/generate/t_cpp_generator.cc | 51 +++++++++++------ lib/cpp/CMakeLists.txt | 1 + lib/cpp/Makefile.am | 1 + lib/cpp/libthrift.vcxproj | 1 + lib/cpp/libthrift.vcxproj.filters | 3 + lib/cpp/src/thrift/protocol/TBinaryProtocol.h | 4 ++ .../src/thrift/protocol/TBinaryProtocol.tcc | 25 ++++++++- .../src/thrift/protocol/TDebugProtocol.cpp | 25 +++++++-- lib/cpp/src/thrift/protocol/TDebugProtocol.h | 2 + lib/cpp/src/thrift/protocol/TEnum.h | 7 +-- lib/cpp/src/thrift/protocol/TJSONProtocol.cpp | 24 +++++++- lib/cpp/src/thrift/protocol/TJSONProtocol.h | 4 ++ lib/cpp/src/thrift/protocol/TProtocol.h | 14 +++++ .../src/thrift/protocol/TProtocolDecorator.h | 2 + lib/cpp/src/thrift/protocol/TUuidUtils.cpp | 56 +++++++++++++++++++ lib/cpp/src/thrift/protocol/TUuidUtils.hpp | 45 +++++++++++++++ .../src/thrift/protocol/TVirtualProtocol.h | 8 +++ lib/cpp/test/Benchmark.cpp | 1 + lib/cpp/test/CMakeLists.txt | 4 +- lib/cpp/test/DebugProtoTest.cpp | 21 +++++++ lib/cpp/test/JSONProtoTest.cpp | 21 +++++-- lib/cpp/test/SpecializationTest.cpp | 3 + lib/cpp/test/ToStringTest.cpp | 9 +++ test/cpp/CMakeLists.txt | 2 +- test/cpp/src/TestClient.cpp | 23 +++++++- test/cpp/src/TestServer.cpp | 10 ++++ 26 files changed, 329 insertions(+), 38 deletions(-) create mode 100644 lib/cpp/src/thrift/protocol/TUuidUtils.cpp create mode 100644 lib/cpp/src/thrift/protocol/TUuidUtils.hpp diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index a085ada0e7b..e21252e8f6e 100644 --- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc @@ -296,7 +296,7 @@ class t_cpp_generator : public t_oop_generator { (ttype->annotations_.find("cpp.customostream") != ttype->annotations_.end()); } - /** + /** * Determine if all fields of t_struct's storage do not throw * Move/Copy Constructors and Assignments applicable for 'noexcept' * Move defaults to 'noexcept' @@ -318,7 +318,7 @@ class t_cpp_generator : public t_oop_generator { /** * Returns the legal program name to use for a file generated by program, if the - * program name contains dots then replace it with underscores, otherwise return the + * program name contains dots then replace it with underscores, otherwise return the * original program name. */ std::string get_legal_program_name(std::string program_name); @@ -981,7 +981,7 @@ bool t_cpp_generator::has_field_with_default_value(t_struct* tstruct) for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* t = get_true_type((*m_iter)->get_type()); - if (is_reference(*m_iter) || t->is_string()) { + if (is_reference(*m_iter) || t->is_string() || t->is_uuid()) { t_const_value* cv = (*m_iter)->get_value(); if (cv != nullptr) { return true; @@ -1032,7 +1032,7 @@ void t_cpp_generator::generate_default_constructor(ostream& out, } else if (t->is_enum()) { dval += "static_cast<" + type_name(t) + ">(0)"; } else { - dval += (t->is_string() || is_reference(*m_iter)) ? "" : "0"; + dval += (t->is_string() || is_reference(*m_iter) || t->is_uuid()) ? "" : "0"; } if (!init_ctor) { init_ctor = true; @@ -1127,7 +1127,7 @@ void t_cpp_generator::generate_constructor_helper(ostream& out, has_nonrequired_fields = true; indent(out) << (*f_iter)->get_name() << " = " << maybeMove( - tmp_name + "." + (*f_iter)->get_name(), + tmp_name + "." + (*f_iter)->get_name(), is_move && is_complex_type((*f_iter)->get_type())) << ";" << endl; } @@ -1177,7 +1177,7 @@ void t_cpp_generator::generate_assignment_helper(ostream& out, t_struct* tstruct has_nonrequired_fields = true; indent(out) << (*f_iter)->get_name() << " = " << maybeMove( - tmp_name + "." + (*f_iter)->get_name(), + tmp_name + "." + (*f_iter)->get_name(), is_move && is_complex_type((*f_iter)->get_type())) << ";" << endl; } @@ -1276,7 +1276,7 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, // Move constructor if (gen_moveable_) { - indent(out) << tstruct->get_name() << "(" << tstruct->get_name() << "&&) noexcept;" + indent(out) << tstruct->get_name() << "(" << tstruct->get_name() << "&&) noexcept;" << endl; } @@ -1286,12 +1286,12 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, // Move assignment operator if (gen_moveable_) { - indent(out) << tstruct->get_name() << "& operator=(" << tstruct->get_name() << "&&) noexcept;" + indent(out) << tstruct->get_name() << "& operator=(" << tstruct->get_name() << "&&) noexcept;" << endl; } bool has_default_value = has_field_with_default_value(tstruct); - + // Default constructor std::string clsname_ctor = tstruct->get_name() + "()"; indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept") << ";" << endl; @@ -1732,7 +1732,7 @@ void t_cpp_generator::generate_struct_result_writer(ostream& out, void t_cpp_generator::generate_struct_swap(ostream& out, t_struct* tstruct) { if (tstruct->get_name() == "a" || tstruct->get_name() == "b") { out << indent() << "void swap(" << tstruct->get_name() << " &a1, " << tstruct->get_name() - << " &a2) {" << endl; + << " &a2) {" << endl; } else { out << indent() << "void swap(" << tstruct->get_name() << " &a, " << tstruct->get_name() << " &b) {" << endl; @@ -1763,7 +1763,7 @@ void t_cpp_generator::generate_struct_swap(ostream& out, t_struct* tstruct) { if (has_nonrequired_fields) { if (tstruct->get_name() == "a" || tstruct->get_name() == "b") { - out << indent() << "swap(a1.__isset, a2.__isset);" << endl; + out << indent() << "swap(a1.__isset, a2.__isset);" << endl; } else { out << indent() << "swap(a.__isset, b.__isset);" << endl; } @@ -1942,7 +1942,7 @@ void t_cpp_generator::generate_service(t_service* tservice) { << endl; if (gen_cob_style_) { f_header_ << "#include " << endl // TMemoryBuffer - << "#include " << endl + << "#include " << endl << "namespace apache { namespace thrift { namespace async {" << endl << "class TAsyncChannel;" << endl << "}}}" << endl; } @@ -2578,7 +2578,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) f_header_ << ", std::shared_ptr< ::apache::thrift::async::TConcurrentClientSyncInfo> sync"; } f_header_ << ") "; - + if (extends.empty()) { if (style == "Concurrent") { f_header_ << ": sync_(sync)" << endl; @@ -2677,7 +2677,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) vector::const_iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_java_doc(f_header_, *f_iter); - indent(f_header_) << function_signature(*f_iter, ifstyle) + indent(f_header_) << function_signature(*f_iter, ifstyle) << " override;" << endl; // TODO(dreiss): Use private inheritance to avoid generating thise in cob-style. if (style == "Concurrent" && !(*f_iter)->is_oneway()) { @@ -3227,7 +3227,7 @@ void ProcessorGenerator::generate_class_definition() { f_header_ << indent() << "virtual " << ret_type_ << "dispatchCall(" << finish_cob_ << "::apache::thrift::protocol::TProtocol* iprot, " << "::apache::thrift::protocol::TProtocol* oprot, " - << "const std::string& fname, int32_t seqid" << call_context_ + << "const std::string& fname, int32_t seqid" << call_context_ << ") override;" << endl; if (generator_->gen_templates_) { f_header_ << indent() << "virtual " << ret_type_ << "dispatchCallTemplated(" << finish_cob_ @@ -4046,6 +4046,9 @@ void t_cpp_generator::generate_deserialize_field(ostream& out, case t_base_type::TYPE_VOID: throw "compiler error: cannot serialize void field in a struct: " + name; break; + case t_base_type::TYPE_UUID: + out << "readUUID(" << name << ");"; + break; case t_base_type::TYPE_STRING: if (type->is_binary()) { out << "readBinary(" << name << ");"; @@ -4072,13 +4075,13 @@ void t_cpp_generator::generate_deserialize_field(ostream& out, out << "readDouble(" << name << ");"; break; default: - throw "compiler error: no C++ reader for base type " + t_base_type::t_base_name(tbase) + name; + throw "compiler error: no C++ reader for base type " + t_base_type::t_base_name(tbase) + " " + name; } out << endl; } else if (type->is_enum()) { string t = tmp("ecast"); out << indent() << "int32_t " << t << ";" << endl << indent() << "xfer += iprot->readI32(" << t - << ");" << endl << indent() << name << " = static_cast<" + << ");" << endl << indent() << name << " = static_cast<" << type_name(type) << ">(" << t << ");" << endl; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", @@ -4254,6 +4257,9 @@ void t_cpp_generator::generate_serialize_field(ostream& out, case t_base_type::TYPE_VOID: throw "compiler error: cannot serialize void field in a struct: " + name; break; + case t_base_type::TYPE_UUID: + out << "writeUUID(" << name << ");"; + break; case t_base_type::TYPE_STRING: if (type->is_binary()) { out << "writeBinary(" << name << ");"; @@ -4281,7 +4287,7 @@ void t_cpp_generator::generate_serialize_field(ostream& out, break; default: throw "compiler error: no C++ writer for base type " + t_base_type::t_base_name(tbase) - + name; + + " " + name; } } else if (type->is_enum()) { out << "writeI32(static_cast(" << name << "));"; @@ -4568,6 +4574,9 @@ string t_cpp_generator::base_type_name(t_base_type::t_base tbase) { return "int64_t"; case t_base_type::TYPE_DOUBLE: return "double"; + case t_base_type::TYPE_UUID: + // TODO: discuss possibility of a class TUuid; + return "std::string"; default: throw "compiler error: no C++ base type name for base type " + t_base_type::t_base_name(tbase); } @@ -4609,6 +4618,9 @@ string t_cpp_generator::declare_field(t_field* tfield, case t_base_type::TYPE_VOID: case t_base_type::TYPE_STRING: break; + case t_base_type::TYPE_UUID: + result += " = std::string(\"00000000-0000-0000-0000-000000000000\")"; + break; case t_base_type::TYPE_BOOL: result += " = false"; break; @@ -4735,6 +4747,8 @@ string t_cpp_generator::type_to_enum(t_type* type) { return "::apache::thrift::protocol::T_I64"; case t_base_type::TYPE_DOUBLE: return "::apache::thrift::protocol::T_DOUBLE"; + case t_base_type::TYPE_UUID: + return "::apache::thrift::protocol::T_UUID"; default: break; } @@ -4776,6 +4790,7 @@ bool t_cpp_generator::is_struct_storage_not_throwing(t_struct* tstruct) const { continue; case t_base_type::TYPE_VOID: case t_base_type::TYPE_STRING: + case t_base_type::TYPE_UUID: default: return false; } diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index 6a66e5ad1a7..c2f15dd5728 100644 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -43,6 +43,7 @@ set(thriftcpp_SOURCES src/thrift/protocol/TJSONProtocol.cpp src/thrift/protocol/TMultiplexedProtocol.cpp src/thrift/protocol/TProtocol.cpp + src/thrift/protocol/TUuidUtils.cpp src/thrift/transport/TTransportException.cpp src/thrift/transport/TFDTransport.cpp src/thrift/transport/TSimpleFileTransport.cpp diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am index 2499fdbff6b..12b8d82498d 100644 --- a/lib/cpp/Makefile.am +++ b/lib/cpp/Makefile.am @@ -69,6 +69,7 @@ libthrift_la_SOURCES = src/thrift/TApplicationException.cpp \ src/thrift/protocol/TBase64Utils.cpp \ src/thrift/protocol/TMultiplexedProtocol.cpp \ src/thrift/protocol/TProtocol.cpp \ + src/thrift/protocol/TUuidUtils.cpp \ src/thrift/transport/TTransportException.cpp \ src/thrift/transport/TFDTransport.cpp \ src/thrift/transport/TFileTransport.cpp \ diff --git a/lib/cpp/libthrift.vcxproj b/lib/cpp/libthrift.vcxproj index 0b5e16de7c4..1b413f8ae8e 100644 --- a/lib/cpp/libthrift.vcxproj +++ b/lib/cpp/libthrift.vcxproj @@ -49,6 +49,7 @@ + diff --git a/lib/cpp/libthrift.vcxproj.filters b/lib/cpp/libthrift.vcxproj.filters index 98426fac85b..fb94f608730 100644 --- a/lib/cpp/libthrift.vcxproj.filters +++ b/lib/cpp/libthrift.vcxproj.filters @@ -30,6 +30,9 @@ protocol + + protocol + transport diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h index 7b829c76833..24e51f75f4d 100644 --- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h +++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h @@ -119,6 +119,8 @@ class TBinaryProtocolT : public TVirtualProtocol +#include #include #include @@ -193,6 +194,20 @@ uint32_t TBinaryProtocolT::writeBinary(const std::string return TBinaryProtocolT::writeString(str); } +template +uint32_t TBinaryProtocolT::writeUUID(const std::string& str) { + std::string out; + const bool encoded = uuid_encode(str, out); + if(!encoded) + throw TProtocolException(TProtocolException::INVALID_DATA); + // This should not happen, but check for now + if(out.size() != 16) + throw TProtocolException(TProtocolException::UNKNOWN); + // TODO: Consider endian swapping, see lib/delphi/src/Thrift.Utils.pas:377 + this->trans_->write((uint8_t*)out.data(), 16); + return 16; +} + /** * Reading functions */ @@ -286,7 +301,7 @@ uint32_t TBinaryProtocolT::readMapBegin(TType& keyType, throw TProtocolException(TProtocolException::SIZE_LIMIT); } size = (uint32_t)sizei; - + TMap map(keyType, valType, size); checkReadBytesAvailable(map); @@ -428,6 +443,14 @@ uint32_t TBinaryProtocolT::readBinary(std::string& str) return TBinaryProtocolT::readString(str); } +template +uint32_t TBinaryProtocolT::readUUID(std::string& str) { + std::string in; + readStringBody(in, 16); + uuid_decode(in, str); + return 16; +} + template template uint32_t TBinaryProtocolT::readStringBody(StrType& str, int32_t size) { diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp b/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp index 0e6d4a2aac3..0a2eaeda035 100644 --- a/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp +++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -70,10 +71,8 @@ string TDebugProtocol::fieldTypeName(TType type) { return "set"; case T_LIST: return "list"; - case T_UTF8: - return "utf8"; - case T_UTF16: - return "utf16"; + case T_UUID: + return "uuid"; default: return "unknown"; } @@ -388,6 +387,24 @@ uint32_t TDebugProtocol::writeBinary(const string& str) { // XXX Hex? return TDebugProtocol::writeString(str); } + +uint32_t TDebugProtocol::writeUUID(const string& str) { + std::string out_raw; + uuid_encode(str, out_raw); + + std::string out_encoded; + uuid_decode(out_raw, out_encoded); + + size_t size = writePlain("{\n"); + indentUp(); + size += writeIndented("[in ] = \"" + str + "\",\n"); + size += writeIndented("[raw] = "); + size += writeString(out_raw); + size += writeIndented("[enc] = \"" + out_encoded + "\"\n"); + indentDown(); + size += writeIndented("}\n"); + return size; +} } } } // apache::thrift::protocol diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.h b/lib/cpp/src/thrift/protocol/TDebugProtocol.h index 41bb0d4ec94..af89cc5679d 100644 --- a/lib/cpp/src/thrift/protocol/TDebugProtocol.h +++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.h @@ -110,6 +110,8 @@ class TDebugProtocol : public TVirtualProtocol { uint32_t writeBinary(const std::string& str); + uint32_t writeUUID(const std::string& str); + private: void indentUp(); void indentDown(); diff --git a/lib/cpp/src/thrift/protocol/TEnum.h b/lib/cpp/src/thrift/protocol/TEnum.h index 9636785e327..bbd1247dc19 100644 --- a/lib/cpp/src/thrift/protocol/TEnum.h +++ b/lib/cpp/src/thrift/protocol/TEnum.h @@ -18,7 +18,7 @@ */ #ifndef _THRIFT_ENUM_H_ -#define _THRIFT_ENUM_H_ +#define _THRIFT_ENUM_H_ namespace apache { namespace thrift { @@ -46,8 +46,7 @@ enum TType { T_MAP = 13, T_SET = 14, T_LIST = 15, - T_UTF8 = 16, - T_UTF16 = 17 + T_UUID = 16, }; /** @@ -63,4 +62,4 @@ enum TMessageType { }}} // apache::thrift::protocol -#endif // #define _THRIFT_ENUM_H_ +#endif // #define _THRIFT_ENUM_H_ diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp index 6e4e8ef0db6..0899f00eefa 100644 --- a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp +++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp @@ -18,6 +18,7 @@ */ #include +#include #include @@ -68,6 +69,7 @@ static const std::string kTypeNameString("str"); static const std::string kTypeNameMap("map"); static const std::string kTypeNameList("lst"); static const std::string kTypeNameSet("set"); +static const std::string kTypeNameUuid("uid"); static const std::string& getTypeNameForTypeID(TType typeID) { switch (typeID) { @@ -93,6 +95,8 @@ static const std::string& getTypeNameForTypeID(TType typeID) { return kTypeNameSet; case T_LIST: return kTypeNameList; + case T_UUID: + return kTypeNameUuid; default: throw TProtocolException(TProtocolException::NOT_IMPLEMENTED, "Unrecognized type"); } @@ -140,6 +144,9 @@ static TType getTypeIDForTypeName(const std::string& name) { case 't': result = T_BOOL; break; + case 'u': + result = T_UUID; + break; } } if (result == T_STOP) { @@ -710,6 +717,16 @@ uint32_t TJSONProtocol::writeBinary(const std::string& str) { return writeJSONBase64(str); } +uint32_t TJSONProtocol::writeUUID(const std::string& str) { + std::string out_raw; + uuid_encode(str, out_raw); + + std::string out_encoded; + uuid_decode(out_raw, out_encoded); + + return writeJSONString(out_encoded); +} + /** * Reading functions */ @@ -1106,6 +1123,10 @@ uint32_t TJSONProtocol::readBinary(std::string& str) { return readJSONBase64(str); } +uint32_t TJSONProtocol::readUUID(std::string& str) { + return readJSONString(str); +} + // Return the minimum number of bytes a type will consume on the wire int TJSONProtocol::getMinSerializedSize(TType type) { @@ -1113,7 +1134,7 @@ int TJSONProtocol::getMinSerializedSize(TType type) { case T_STOP: return 0; case T_VOID: return 0; - case T_BOOL: return 1; // written as int + case T_BOOL: return 1; // written as int case T_BYTE: return 1; case T_DOUBLE: return 1; case T_I16: return 1; @@ -1124,6 +1145,7 @@ int TJSONProtocol::getMinSerializedSize(TType type) case T_MAP: return 2; // empty map case T_SET: return 2; // empty set case T_LIST: return 2; // empty list + case T_UUID: return 16; // empty UUID default: throw TProtocolException(TProtocolException::UNKNOWN, "unrecognized type code"); } } diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.h b/lib/cpp/src/thrift/protocol/TJSONProtocol.h index d01bdf80141..069a9905f53 100644 --- a/lib/cpp/src/thrift/protocol/TJSONProtocol.h +++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.h @@ -198,6 +198,8 @@ class TJSONProtocol : public TVirtualProtocol { uint32_t writeBinary(const std::string& str); + uint32_t writeUUID(const std::string& str); + /** * Reading functions */ @@ -245,6 +247,8 @@ class TJSONProtocol : public TVirtualProtocol { uint32_t readBinary(std::string& str); + uint32_t readUUID(std::string& str); + int getMinSerializedSize(TType type) override; void checkReadBytesAvailable(TSet& set) override diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h index 237c1e56883..d29df1c8d32 100644 --- a/lib/cpp/src/thrift/protocol/TProtocol.h +++ b/lib/cpp/src/thrift/protocol/TProtocol.h @@ -275,6 +275,8 @@ class TProtocol { virtual uint32_t writeBinary_virt(const std::string& str) = 0; + virtual uint32_t writeUUID_virt(const std::string& str) = 0; + uint32_t writeMessageBegin(const std::string& name, const TMessageType messageType, const int32_t seqid) { @@ -382,6 +384,11 @@ class TProtocol { return writeBinary_virt(str); } + uint32_t writeUUID(const std::string& str) { + T_VIRTUAL_CALL(); + return writeUUID_virt(str); + } + /** * Reading functions */ @@ -430,6 +437,8 @@ class TProtocol { virtual uint32_t readBinary_virt(std::string& str) = 0; + virtual uint32_t readUUID_virt(std::string& str) = 0; + uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid) { T_VIRTUAL_CALL(); return readMessageBegin_virt(name, messageType, seqid); @@ -530,6 +539,11 @@ class TProtocol { return readBinary_virt(str); } + uint32_t readUUID(std::string& str) { + T_VIRTUAL_CALL(); + return readUUID_virt(str); + } + /* * std::vector is specialized for bool, and its elements are individual bits * rather than bools. We need to define a different version of readBool() diff --git a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h index 5258159f149..9eb1566ab75 100644 --- a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h +++ b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h @@ -92,6 +92,7 @@ class TProtocolDecorator : public TProtocol { uint32_t writeDouble_virt(const double dub) override { return protocol->writeDouble(dub); } uint32_t writeString_virt(const std::string& str) override { return protocol->writeString(str); } uint32_t writeBinary_virt(const std::string& str) override { return protocol->writeBinary(str); } + uint32_t writeUUID_virt(const std::string& str) override { return protocol->writeUUID(str); } uint32_t readMessageBegin_virt(std::string& name, TMessageType& messageType, @@ -140,6 +141,7 @@ class TProtocolDecorator : public TProtocol { uint32_t readString_virt(std::string& str) override { return protocol->readString(str); } uint32_t readBinary_virt(std::string& str) override { return protocol->readBinary(str); } + uint32_t readUUID_virt(std::string& str) override { return protocol->readUUID(str); } private: shared_ptr protocol; diff --git a/lib/cpp/src/thrift/protocol/TUuidUtils.cpp b/lib/cpp/src/thrift/protocol/TUuidUtils.cpp new file mode 100644 index 00000000000..e1eab22cb11 --- /dev/null +++ b/lib/cpp/src/thrift/protocol/TUuidUtils.cpp @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include + +#include +#include +#include + +namespace apache { +namespace thrift { +namespace protocol { + +bool uuid_encode(const std::string& in, std::string& out) { + static const boost::uuids::string_generator gen; + static const std::string empty_uuid(boost::uuids::uuid::static_size(), '\0'); + out = empty_uuid; + if (in.empty()) { + return true; + } + try { + const boost::uuids::uuid uuid{gen(in)}; + std::copy(uuid.begin(), uuid.end(), out.begin()); + return true; + } catch (const std::runtime_error&) { + // Invalid string most probably + return false; + } +} + +void uuid_decode(const std::string& in, std::string& out) { + boost::uuids::uuid uuid{}; + const size_t to_copy = std::min(in.size(), uuid.size()); + std::copy(in.begin(), in.begin() + to_copy, uuid.begin()); + out = boost::uuids::to_string(uuid); +} + +} +} +} // apache::thrift::protocol diff --git a/lib/cpp/src/thrift/protocol/TUuidUtils.hpp b/lib/cpp/src/thrift/protocol/TUuidUtils.hpp new file mode 100644 index 00000000000..583147ffd38 --- /dev/null +++ b/lib/cpp/src/thrift/protocol/TUuidUtils.hpp @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _THRIFT_PROTOCOL_TUUIDUTILS_H_ +#define _THRIFT_PROTOCOL_TUUIDUTILS_H_ + +#include + +namespace apache { +namespace thrift { +namespace protocol { + +// Encode canonical UUID string to a 16 char representation +// Supported formats for in: +// - "hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh" +// - "{hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh}" +// - "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh" +// - "{hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh}" +// Returns false if the string was invalid and the value was not encoded. +bool uuid_encode(const std::string& in, std::string& out); + +// Decode 16 char UUID buffer to 36 characted string +void uuid_decode(const std::string& in, std::string& out); + +} +} +} // apache::thrift::protocol + +#endif // #define _THRIFT_PROTOCOL_TUUIDUTILS_H_ diff --git a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h index b7fe929af20..4698081d241 100644 --- a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h +++ b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h @@ -393,6 +393,10 @@ class TVirtualProtocol : public Super_ { return static_cast(this)->writeBinary(str); } + uint32_t writeUUID_virt(const std::string& str) override { + return static_cast(this)->writeUUID(str); + } + /** * Reading functions */ @@ -471,6 +475,10 @@ class TVirtualProtocol : public Super_ { return static_cast(this)->readBinary(str); } + uint32_t readUUID_virt(std::string& str) override { + return static_cast(this)->readUUID(str); + } + uint32_t skip_virt(TType type) override { return static_cast(this)->skip(type); } /* diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp index 56adac0b203..97a531767d0 100644 --- a/lib/cpp/test/Benchmark.cpp +++ b/lib/cpp/test/Benchmark.cpp @@ -66,6 +66,7 @@ int main() { ooe.some_characters = "JSON THIS! \"\1"; ooe.zomg_unicode = "\xd7\n\a\t"; ooe.base64 = "\1\2\3\255"; + ooe.rfc4122_uuid = "{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}"; int num = 100000; std::shared_ptr buf(new TMemoryBuffer(num*1000)); diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt index 1117cd9f36a..87ed1094cb4 100644 --- a/lib/cpp/test/CMakeLists.txt +++ b/lib/cpp/test/CMakeLists.txt @@ -360,7 +360,7 @@ add_custom_command(OUTPUT gen-cpp/AnnotationTest_constants.cpp ) add_custom_command(OUTPUT gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h gen-cpp/EmptyService.cpp gen-cpp/EmptyService.h - COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/v0.16/DebugProtoTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift ) add_custom_command(OUTPUT gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h @@ -384,7 +384,7 @@ add_custom_command(OUTPUT gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp ) add_custom_command(OUTPUT gen-cpp/SecondService.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_types.h - COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/v0.16/ThriftTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift ) add_custom_command(OUTPUT gen-cpp/OneWayService.cpp gen-cpp/OneWayTest_types.h gen-cpp/OneWayService.h diff --git a/lib/cpp/test/DebugProtoTest.cpp b/lib/cpp/test/DebugProtoTest.cpp index 060f3547dd7..cc4e5ff9558 100644 --- a/lib/cpp/test/DebugProtoTest.cpp +++ b/lib/cpp/test/DebugProtoTest.cpp @@ -74,6 +74,11 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_1) { " [1] = 2,\n" " [2] = 3,\n" " },\n" + " 15: rfc4122_uuid (uuid) = {\n" + " [in ] = \"\",\n" + " [raw] = \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n" + " [enc] = \"00000000-0000-0000-0000-000000000000\"\n" + " }\n" "}"); const std::string result(apache::thrift::ThriftDebugString(*ooe)); @@ -98,6 +103,7 @@ void testCaseSetup_2() { "\xb0\xcf\x81\xe2\x84\x8e\x20\xce\x91\x74\x74" "\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80" "\xbc"; + n->my_ooe.rfc4122_uuid = "{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}"; n->my_bonk.type = 31337; n->my_bonk.message = "I am a bonk... xor!"; } @@ -141,6 +147,11 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_2) { " [1] = 2,\n" " [2] = 3,\n" " },\n" + " 15: rfc4122_uuid (uuid) = {\n" + " [in ] = \"{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}\",\n" + " [raw] = \"^*\\xb1\\x88\\x17&Nu\\xa0O\\x1e\\xd9\\xa6\\xa8\\x9cL\",\n" + " [enc] = \"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c\"\n" + " }\n" " },\n" "}"); const std::string result(apache::thrift::ThriftDebugString(*n)); @@ -228,6 +239,11 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_3) { " [1] = 2,\n" " [2] = 3,\n" " },\n" + " 15: rfc4122_uuid (uuid) = {\n" + " [in ] = \"\",\n" + " [raw] = \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n" + " [enc] = \"00000000-0000-0000-0000-000000000000\"\n" + " }\n" " },\n" " [1] = OneOfEach {\n" " 01: im_true (bool) = true,\n" @@ -259,6 +275,11 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_3) { " [1] = 2,\n" " [2] = 3,\n" " },\n" + " 15: rfc4122_uuid (uuid) = {\n" + " [in ] = \"{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}\",\n" + " [raw] = \"^*\\xb1\\x88\\x17&Nu\\xa0O\\x1e\\xd9\\xa6\\xa8\\x9cL\",\n" + " [enc] = \"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c\"\n" + " }\n" " },\n" " },\n" " 02: contain (set) = set[3] {\n" diff --git a/lib/cpp/test/JSONProtoTest.cpp b/lib/cpp/test/JSONProtoTest.cpp index 082c8a28b75..fedf99e4821 100644 --- a/lib/cpp/test/JSONProtoTest.cpp +++ b/lib/cpp/test/JSONProtoTest.cpp @@ -48,6 +48,7 @@ void testCaseSetup_1() { ooe->some_characters = "JSON THIS! \"\1"; ooe->zomg_unicode = "\xd7\n\a\t"; ooe->base64 = "\1\2\3\255"; + ooe->rfc4122_uuid = "00000000-0000-0000-0000-000000000000"; } BOOST_AUTO_TEST_CASE(test_json_proto_1) { @@ -59,7 +60,7 @@ BOOST_AUTO_TEST_CASE(test_json_proto_1) { "535897931},\"8\":{\"str\":\"JSON THIS! \\\"\\u0001\"},\"9\":{\"str\":\"\xd7\\" "n\\u0007\\t\"},\"10\":{\"tf\":0},\"11\":{\"str\":\"AQIDrQ\"},\"12\":{\"lst\"" ":[\"i8\",3,1,2,3]},\"13\":{\"lst\":[\"i16\",3,1,2,3]},\"14\":{\"lst\":[\"i64" - "\",3,1,2,3]}}"); + "\",3,1,2,3]},\"15\":{\"uid\":\"00000000-0000-0000-0000-000000000000\"}}"); const std::string result(apache::thrift::ThriftJSONString(*ooe)); @@ -84,6 +85,7 @@ void testCaseSetup_2() { "\xb0\xcf\x81\xe2\x84\x8e\x20\xce\x91\x74\x74" "\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80" "\xbc"; + n->my_ooe.rfc4122_uuid = "5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"; n->my_bonk.type = 31337; n->my_bonk.message = "I am a bonk... xor!"; } @@ -98,7 +100,8 @@ BOOST_AUTO_TEST_CASE(test_json_proto_2) { "1.6180339887498949},\"8\":{\"str\":\":R (me going \\\"rrrr\\\")\"},\"9\":{" "\"str\":\"ӀⅮΝ Нοⅿоɡгаρℎ Αttαⅽκǃ‼\"},\"10\":{\"tf\":0},\"11\":{\"str\":\"" "AQIDrQ\"},\"12\":{\"lst\":[\"i8\",3,1,2,3]},\"13\":{\"lst\":[\"i16\",3,1,2" - ",3]},\"14\":{\"lst\":[\"i64\",3,1,2,3]}}}}" + ",3]},\"14\":{\"lst\":[\"i64\",3,1,2,3]},\"15\":{\"uid\":\"5e2ab188-1726-" + "4e75-a04f-1ed9a6a89c4c\"}}}}" ); const std::string result(apache::thrift::ThriftJSONString(*n)); @@ -162,12 +165,14 @@ BOOST_AUTO_TEST_CASE(test_json_proto_3) { "},\"7\":{\"dbl\":3.1415926535897931},\"8\":{\"str\":\"JSON THIS! \\\"\\u0001" "\"},\"9\":{\"str\":\"\xd7\\n\\u0007\\t\"},\"10\":{\"tf\":0},\"11\":{\"str\":" "\"AQIDrQ\"},\"12\":{\"lst\":[\"i8\",3,1,2,3]},\"13\":{\"lst\":[\"i16\",3,1,2" - ",3]},\"14\":{\"lst\":[\"i64\",3,1,2,3]}},{\"1\":{\"tf\":1},\"2\":{\"tf\":0}," + ",3]},\"14\":{\"lst\":[\"i64\",3,1,2,3]},\"15\":{\"uid\":\"00000000-0000-0000" + "-0000-000000000000\"}},{\"1\":{\"tf\":1},\"2\":{\"tf\":0}," "\"3\":{\"i8\":51},\"4\":{\"i16\":16},\"5\":{\"i32\":32},\"6\":{\"i64\":64}," "\"7\":{\"dbl\":1.6180339887498949},\"8\":{\"str\":\":R (me going \\\"rrrr\\\"" ")\"},\"9\":{\"str\":\"ӀⅮΝ Нοⅿоɡгаρℎ Αttαⅽκǃ‼\"},\"10\":{\"tf\":0},\"11\":{" "\"str\":\"AQIDrQ\"},\"12\":{\"lst\":[\"i8\",3,1,2,3]},\"13\":{\"lst\":[\"i16" - "\",3,1,2,3]},\"14\":{\"lst\":[\"i64\",3,1,2,3]}}]},\"2\":{\"set\":[\"lst\",3" + "\",3,1,2,3]},\"14\":{\"lst\":[\"i64\",3,1,2,3]},\"15\":{\"uid\":\"5e2ab188-" + "1726-4e75-a04f-1ed9a6a89c4c\"}}]},\"2\":{\"set\":[\"lst\",3" ",[\"str\",0],[\"str\",2,\"and a one\",\"and a two\"],[\"str\",3,\"then a one" ", two\",\"three!\",\"FOUR!!\"]]},\"3\":{\"map\":[\"str\",\"lst\",3,{\"nothin" "g\":[\"rec\",0],\"poe\":[\"rec\",3,{\"1\":{\"i32\":3},\"2\":{\"str\":\"quoth" @@ -192,6 +197,8 @@ BOOST_AUTO_TEST_CASE(test_json_proto_4) { OneOfEach ooe2; ooe2.read(proto.get()); + BOOST_TEST_INFO("written: " << *ooe); + BOOST_TEST_INFO("read : " << ooe2); BOOST_CHECK(*ooe == ooe2); } @@ -205,6 +212,8 @@ BOOST_AUTO_TEST_CASE(test_json_proto_5) { HolyMoley hm2; hm2.read(proto.get()); + BOOST_TEST_INFO("written: " << *hm); + BOOST_TEST_INFO("read : " << hm2); BOOST_CHECK(*hm == hm2); hm2.big[0].a_bite = 0x00; @@ -230,14 +239,14 @@ BOOST_AUTO_TEST_CASE(test_json_proto_6) { ); std::shared_ptr buffer(new TMemoryBuffer()); - std::shared_ptr proto(new TJSONProtocol(buffer)); + std::shared_ptr proto(new TJSONProtocol(buffer)); dub.write(proto.get()); Doubles dub_1; dub_1.read(proto.get()); const std::string result(apache::thrift::ThriftJSONString(dub)); const std::string result_1(apache::thrift::ThriftJSONString(dub_1)); - + BOOST_CHECK_MESSAGE(!expected_result.compare(result), "Expected:\n" << expected_result << "\nGotten:\n" << result); BOOST_CHECK_MESSAGE(!expected_result.compare(result_1), diff --git a/lib/cpp/test/SpecializationTest.cpp b/lib/cpp/test/SpecializationTest.cpp index 008837d319c..097611284a7 100644 --- a/lib/cpp/test/SpecializationTest.cpp +++ b/lib/cpp/test/SpecializationTest.cpp @@ -26,6 +26,7 @@ BOOST_AUTO_TEST_CASE(test_specialization_1) { ooe.some_characters = "JSON THIS! \"\1"; ooe.zomg_unicode = "\xd7\n\a\t"; ooe.base64 = "\1\2\3\255"; + ooe.rfc4122_uuid = "00000000-0000-0000-0000-000000000000"; Nesting n; n.my_ooe = ooe; @@ -89,6 +90,8 @@ BOOST_AUTO_TEST_CASE(test_specialization_1) { OneOfEach ooe2; ooe2.read(proto.get()); + BOOST_TEST_INFO("Write: " << ooe); + BOOST_TEST_INFO("Read : " << ooe2); BOOST_CHECK(ooe == ooe2); hm.write(proto.get()); diff --git a/lib/cpp/test/ToStringTest.cpp b/lib/cpp/test/ToStringTest.cpp index 736b33c0a5b..68c82ad4be1 100644 --- a/lib/cpp/test/ToStringTest.cpp +++ b/lib/cpp/test/ToStringTest.cpp @@ -160,4 +160,13 @@ BOOST_AUTO_TEST_CASE(generated_nested_list_object_to_string) { "ListBonks(bonk=[Bonk(message=a, type=0), Bonk(message=b, type=0)])"); } +BOOST_AUTO_TEST_CASE(generated_uuid_to_string) { + thrift::test::CrazyNesting l; + l.uuid_field = "{4b686716-5f20-4deb-8ce0-9eaf379e8a3d}"; + + BOOST_CHECK_EQUAL(to_string(l), + "CrazyNesting(string_field=, set_field=, list_field=[], binary_field=, " + "uuid_field={4b686716-5f20-4deb-8ce0-9eaf379e8a3d})"); +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt index f693a273daf..a6c1fd5cf4e 100644 --- a/test/cpp/CMakeLists.txt +++ b/test/cpp/CMakeLists.txt @@ -100,7 +100,7 @@ add_test(NAME SpecificNameTest COMMAND SpecificNameTest) # add_custom_command(OUTPUT gen-cpp/SecondService.cpp gen-cpp/SecondService.h gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest.h gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp - COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/v0.16/ThriftTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift ) add_custom_command(OUTPUT gen-cpp/Service.cpp diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index c4146cc5cf5..fd04ed87063 100644 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -70,7 +70,7 @@ using namespace thrift::test; // template -class TPedanticProtocol : public Proto +class TPedanticProtocol : public Proto { public: TPedanticProtocol(std::shared_ptr& transport) @@ -178,6 +178,18 @@ bool print_eq(T expected, T actual) { return_code |= ERR_BASETYPES; \ } +#define UUID_TEST(func, value, expected) \ + cout << #func "(" << value << ") = "; \ + try { \ + if (!print_eq(expected, testClient.func(value))) \ + return_code |= ERR_BASETYPES; \ + } catch (TTransportException&) { \ + throw; \ + } catch (exception & ex) { \ + cout << "*** FAILED ***" << endl << ex.what() << endl; \ + return_code |= ERR_BASETYPES; \ + } + int binary_test(ThriftTestClient& testClient, string::size_type siz); BOOST_CONSTEXPR_OR_CONST int ERR_BASETYPES = 1; @@ -638,6 +650,15 @@ int main(int argc, char** argv) { if (i > 0) { i *= 2; } else { ++i; } } + /** + * UUID TEST + */ + const std::string expected_uuid{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; + UUID_TEST(testUuid, std::string{"{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}"}, expected_uuid); + UUID_TEST(testUuid, std::string{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}, expected_uuid); + UUID_TEST(testUuid, std::string{"5e2ab18817264e75a04f1ed9a6a89c4c"}, expected_uuid); + UUID_TEST(testUuid, std::string{"{5e2ab18817264e75a04f1ed9a6a89c4c}"}, expected_uuid); + UUID_TEST(testUuid, std::string{}, std::string{"00000000-0000-0000-0000-000000000000"}); /** * STRUCT TEST diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index 65317f89c13..6c61f402f8d 100644 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -132,6 +132,11 @@ class TestHandler : public ThriftTestIf { _return = thing; } + std::string testUuid(const std::string thing) override { + printf("testUuid(\"{%s}\")\n", thing.c_str()); + return thing; + } + void testStruct(Xtruct& out, const Xtruct& thing) override { printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n", thing.string_thing.c_str(), @@ -442,6 +447,11 @@ class TestHandlerAsync : public ThriftTestCobSvIf { cob(res); } + void testUuid(::std::function cob, const std::string thing) override { + std::string res = _delegate->testUuid(thing); + cob(res); + } + void testStruct(std::function cob, const Xtruct& thing) override { Xtruct res; _delegate->testStruct(res, thing); From a4d9452e43b4f447c296afadb890f77762e08a98 Mon Sep 17 00:00:00 2001 From: Volodymyr Panivko Date: Tue, 19 Mar 2024 23:14:07 +0100 Subject: [PATCH 221/250] [THRIFT-5757] Unit tests for php lib Client: php Patch: Volodymyr Panivko This closes #2951 --- .github/workflows/build.yml | 10 +- lib/php/lib/Protocol/TCompactProtocol.php | 1 + lib/php/lib/Protocol/TJSONProtocol.php | 88 +- lib/php/lib/Protocol/TSimpleJSONProtocol.php | 1 + lib/php/phpunit.xml | 7 +- lib/php/test/Fixtures/Fixtures.php | 192 ---- .../test/Fixtures/TJSONProtocolFixtures.php | 72 -- .../Fixtures/TSimpleJSONProtocolFixtures.php | 65 -- .../BaseValidatorTest.php | 37 +- .../Lib/ClassLoader/ThriftClassLoaderTest.php | 139 +++ .../Lib/Protocol/TJSONProtocolTest.php | 646 +++++++++++ .../Lib/Protocol/TSimpleJSONProtocolTest.php | 319 ++++++ .../Lib/Serializer}/BinarySerializerTest.php | 19 +- .../Lib/Serializer}/JsonSerializeTest.php | 36 +- .../ValidatorOopTest.php} | 17 +- .../{Unit => Integration}/ValidatorTest.php | 15 +- lib/php/test/Makefile.am | 10 +- .../Lib/ClassLoader/ThriftClassLoaderTest.php | 108 -- .../TBinaryProtocolAcceleratedTest.php | 73 ++ .../Unit/Lib/Protocol/TBinaryProtocolTest.php | 1009 +++++++++++++++++ .../Lib/Protocol/TCompactProtocolTest.php | 843 ++++++++++++++ .../Lib/Protocol/TMultiplexedProtocolTest.php | 85 ++ .../Lib/Protocol/TProtocolDecoratorTest.php | 96 ++ .../Lib/Protocol/TSimpleJSONProtocolTest.php | 133 +++ .../Lib/Serializer/TBinarySerializerTest.php | 38 + lib/php/test/Unit/TJSONProtocolTest.php | 514 --------- lib/php/test/Unit/TSimpleJSONProtocolTest.php | 247 ---- lib/php/test/bootstrap.php | 16 + test/php/Client.php | 26 + test/php/Handler.php | 114 ++ test/php/TestServer.php | 87 ++ test/php/test_php.ini | 6 +- test/tests.json | 25 + 33 files changed, 3722 insertions(+), 1372 deletions(-) delete mode 100644 lib/php/test/Fixtures/Fixtures.php delete mode 100644 lib/php/test/Fixtures/TJSONProtocolFixtures.php delete mode 100644 lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php rename lib/php/test/{Unit => Integration}/BaseValidatorTest.php (76%) create mode 100644 lib/php/test/Integration/Lib/ClassLoader/ThriftClassLoaderTest.php create mode 100644 lib/php/test/Integration/Lib/Protocol/TJSONProtocolTest.php create mode 100644 lib/php/test/Integration/Lib/Protocol/TSimpleJSONProtocolTest.php rename lib/php/test/{Unit => Integration/Lib/Serializer}/BinarySerializerTest.php (66%) rename lib/php/test/{Unit => Integration/Lib/Serializer}/JsonSerializeTest.php (71%) rename lib/php/test/{Unit/ValidatorTestOop.php => Integration/ValidatorOopTest.php} (59%) rename lib/php/test/{Unit => Integration}/ValidatorTest.php (62%) create mode 100644 lib/php/test/Unit/Lib/Protocol/TBinaryProtocolAcceleratedTest.php create mode 100644 lib/php/test/Unit/Lib/Protocol/TBinaryProtocolTest.php create mode 100644 lib/php/test/Unit/Lib/Protocol/TCompactProtocolTest.php create mode 100644 lib/php/test/Unit/Lib/Protocol/TMultiplexedProtocolTest.php create mode 100644 lib/php/test/Unit/Lib/Protocol/TProtocolDecoratorTest.php create mode 100644 lib/php/test/Unit/Lib/Protocol/TSimpleJSONProtocolTest.php create mode 100644 lib/php/test/Unit/Lib/Serializer/TBinarySerializerTest.php delete mode 100644 lib/php/test/Unit/TJSONProtocolTest.php delete mode 100644 lib/php/test/Unit/TSimpleJSONProtocolTest.php create mode 100644 lib/php/test/bootstrap.php create mode 100644 test/php/Client.php create mode 100644 test/php/Handler.php create mode 100644 test/php/TestServer.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b29ddb906e..2472029cafa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -120,11 +120,11 @@ jobs: mkdir -p ./lib/php/test/Resources/packages/phpvo mkdir -p ./lib/php/test/Resources/packages/phpjs mkdir -p ./lib/php/test/Resources/packages/phpcm - compiler/cpp/thrift --gen php -r --out ./lib/php/test/Resources/packages/php lib/php/test/Resources/ThriftTest.thrift - compiler/cpp/thrift --gen php:validate -r --out ./lib/php/test/Resources/packages/phpv lib/php/test/Resources/ThriftTest.thrift - compiler/cpp/thrift --gen php:validate,oop -r --out ./lib/php/test/Resources/packages/phpvo lib/php/test/Resources/ThriftTest.thrift - compiler/cpp/thrift --gen php:json -r --out ./lib/php/test/Resources/packages/phpjs lib/php/test/Resources/ThriftTest.thrift - compiler/cpp/thrift --gen php:classmap,server,rest -r --out ./lib/php/test/Resources/packages/phpcm lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:nsglobal="Basic" -r --out ./lib/php/test/Resources/packages/php lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:validate,nsglobal="Validate" -r --out ./lib/php/test/Resources/packages/phpv lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:validate,oop,nsglobal="ValidateOop" -r --out ./lib/php/test/Resources/packages/phpvo lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:json,nsglobal="Json" -r --out ./lib/php/test/Resources/packages/phpjs lib/php/test/Resources/ThriftTest.thrift + compiler/cpp/thrift --gen php:classmap,server,rest,nsglobal="Classmap" -r --out ./lib/php/test/Resources/packages/phpcm lib/php/test/Resources/ThriftTest.thrift - name: Run Tests run: vendor/bin/phpunit -c lib/php/phpunit.xml diff --git a/lib/php/lib/Protocol/TCompactProtocol.php b/lib/php/lib/Protocol/TCompactProtocol.php index 1af2a274a24..ebe32e52819 100644 --- a/lib/php/lib/Protocol/TCompactProtocol.php +++ b/lib/php/lib/Protocol/TCompactProtocol.php @@ -154,6 +154,7 @@ public function readVarint(&$result) $shift += 7; } + #unreachable statement return $idx; } diff --git a/lib/php/lib/Protocol/TJSONProtocol.php b/lib/php/lib/Protocol/TJSONProtocol.php index e1412cc3acb..cfd3c8b2b53 100644 --- a/lib/php/lib/Protocol/TJSONProtocol.php +++ b/lib/php/lib/Protocol/TJSONProtocol.php @@ -23,6 +23,7 @@ namespace Thrift\Protocol; +use Thrift\Exception\TException; use Thrift\Type\TType; use Thrift\Exception\TProtocolException; use Thrift\Protocol\JSON\BaseContext; @@ -186,8 +187,6 @@ public function reset() $this->reader_ = new LookaheadReader($this); } - private $tmpbuf_ = array(4); - public function readJSONSyntaxChar($b) { $ch = $this->reader_->read(); @@ -197,68 +196,6 @@ public function readJSONSyntaxChar($b) } } - private function hexVal($s) - { - for ($i = 0; $i < strlen($s); $i++) { - $ch = substr($s, $i, 1); - - if (!($ch >= "a" && $ch <= "f") && !($ch >= "0" && $ch <= "9")) { - throw new TProtocolException("Expected hex character " . $ch, TProtocolException::INVALID_DATA); - } - } - - return hexdec($s); - } - - private function hexChar($val) - { - return dechex($val); - } - - private function hasJSONUnescapedUnicode() - { - if (PHP_MAJOR_VERSION > 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4)) { - return true; - } - - return false; - } - - private function unescapedUnicode($str) - { - if ($this->hasJSONUnescapedUnicode()) { - return json_encode($str, JSON_UNESCAPED_UNICODE); - } - - $json = json_encode($str); - - /* - * Unescaped character outside the Basic Multilingual Plane - * High surrogate: 0xD800 - 0xDBFF - * Low surrogate: 0xDC00 - 0xDFFF - */ - $json = preg_replace_callback( - '/\\\\u(d[89ab][0-9a-f]{2})\\\\u(d[cdef][0-9a-f]{2})/i', - function ($matches) { - return mb_convert_encoding(pack('H*', $matches[1] . $matches[2]), 'UTF-8', 'UTF-16BE'); - }, - $json - ); - - /* - * Unescaped characters within the Basic Multilingual Plane - */ - $json = preg_replace_callback( - '/\\\\u([0-9a-f]{4})/i', - function ($matches) { - return mb_convert_encoding(pack('H*', $matches[1]), 'UTF-8', 'UTF-16BE'); - }, - $json - ); - - return $json; - } - private function writeJSONString($b) { $this->context_->write(); @@ -267,7 +204,7 @@ private function writeJSONString($b) $this->trans_->write(self::QUOTE); } - $this->trans_->write($this->unescapedUnicode($b)); + $this->trans_->write(json_encode($b, JSON_UNESCAPED_UNICODE)); if (is_numeric($b) && $this->context_->escapeNum()) { $this->trans_->write(self::QUOTE); @@ -297,6 +234,7 @@ private function writeJSONDouble($num) $this->trans_->write(self::QUOTE); } + #TODO add compatibility with NAN and INF $this->trans_->write(json_encode($num)); if ($this->context_->escapeNum()) { @@ -304,14 +242,6 @@ private function writeJSONDouble($num) } } - private function writeJSONBase64($data) - { - $this->context_->write(); - $this->trans_->write(self::QUOTE); - $this->trans_->write(json_encode(base64_encode($data))); - $this->trans_->write(self::QUOTE); - } - private function writeJSONObjectStart() { $this->context_->write(); @@ -481,18 +411,6 @@ private function readJSONDouble() } } - private function readJSONBase64() - { - $arr = $this->readJSONString(false); - $data = base64_decode($arr, true); - - if ($data === false) { - throw new TProtocolException("Invalid base64 data " . $arr, TProtocolException::INVALID_DATA); - } - - return $data; - } - private function readJSONObjectStart() { $this->context_->read(); diff --git a/lib/php/lib/Protocol/TSimpleJSONProtocol.php b/lib/php/lib/Protocol/TSimpleJSONProtocol.php index 1cf1f640745..22f17423bc4 100644 --- a/lib/php/lib/Protocol/TSimpleJSONProtocol.php +++ b/lib/php/lib/Protocol/TSimpleJSONProtocol.php @@ -115,6 +115,7 @@ private function writeJSONDouble($num) $this->trans_->write(self::QUOTE); } + #TODO add compatibility with NAN and INF $this->trans_->write(json_encode((float)$num)); if ($isMapKey) { diff --git a/lib/php/phpunit.xml b/lib/php/phpunit.xml index 2cbea95d345..58e8f5dc2a9 100644 --- a/lib/php/phpunit.xml +++ b/lib/php/phpunit.xml @@ -18,7 +18,7 @@ under the License. --> - + ./test/Unit + + ./test/Integration + diff --git a/lib/php/test/Fixtures/Fixtures.php b/lib/php/test/Fixtures/Fixtures.php deleted file mode 100644 index d48be4061c8..00000000000 --- a/lib/php/test/Fixtures/Fixtures.php +++ /dev/null @@ -1,192 +0,0 @@ -<><"; - - self::$testArgs['testString3'] = - "string that ends in double-backslash \\\\"; - - self::$testArgs['testUnicodeStringWithNonBMP'] = - "สวัสดี/𝒯"; - - self::$testArgs['testDouble'] = 3.1415926535898; - - // TODO: add testBinary() call - - self::$testArgs['testByte'] = 0x01; - - self::$testArgs['testI32'] = pow(2, 30); - - if (PHP_INT_SIZE == 8) { - self::$testArgs['testI64'] = pow(2, 60); - } else { - self::$testArgs['testI64'] = "1152921504606847000"; - } - - self::$testArgs['testStruct'] = - new Xtruct( - array( - 'string_thing' => 'worked', - 'byte_thing' => 0x01, - 'i32_thing' => pow(2, 30), - 'i64_thing' => self::$testArgs['testI64'] - ) - ); - - self::$testArgs['testNestNested'] = - new Xtruct( - array( - 'string_thing' => 'worked', - 'byte_thing' => 0x01, - 'i32_thing' => pow(2, 30), - 'i64_thing' => self::$testArgs['testI64'] - ) - ); - - self::$testArgs['testNest'] = - new Xtruct2( - array( - 'byte_thing' => 0x01, - 'struct_thing' => self::$testArgs['testNestNested'], - 'i32_thing' => pow(2, 15) - ) - ); - - self::$testArgs['testMap'] = - array( - 7 => 77, - 8 => 88, - 9 => 99 - ); - - self::$testArgs['testStringMap'] = - array( - "a" => "123", - "a b" => "with spaces ", - "same" => "same", - "0" => "numeric key", - "longValue" => self::$testArgs['testString1'], - self::$testArgs['testString1'] => "long key" - ); - - self::$testArgs['testSet'] = array(1 => true, 5 => true, 6 => true); - - self::$testArgs['testList'] = array(1, 2, 3); - - self::$testArgs['testEnum'] = Numberz::ONE; - - self::$testArgs['testTypedef'] = 69; - - self::$testArgs['testMapMapExpectedResult'] = - array( - 4 => array( - 1 => 1, - 2 => 2, - 3 => 3, - 4 => 4, - ), - -4 => array( - -4 => -4, - -3 => -3, - -2 => -2, - -1 => -1 - ) - ); - - // testInsanity ... takes a few steps to set up! - - $xtruct1 = - new Xtruct( - array( - 'string_thing' => 'Goodbye4', - 'byte_thing' => 4, - 'i32_thing' => 4, - 'i64_thing' => 4 - ) - ); - - $xtruct2 = - new Xtruct( - array( - 'string_thing' => 'Hello2', - 'byte_thing' => 2, - 'i32_thing' => 2, - 'i64_thing' => 2 - ) - ); - - $userMap = - array( - Numberz::FIVE => 5, - Numberz::EIGHT => 8 - ); - - $insanity2 = - new Insanity( - array( - 'userMap' => $userMap, - 'xtructs' => array($xtruct1, $xtruct2) - ) - ); - - $insanity3 = $insanity2; - - $insanity6 = - new Insanity( - array( - 'userMap' => null, - 'xtructs' => null - ) - ); - - self::$testArgs['testInsanityExpectedResult'] = - array( - "1" => array( - Numberz::TWO => $insanity2, - Numberz::THREE => $insanity3 - ), - "2" => array( - Numberz::SIX => $insanity6 - ) - ); - } -} diff --git a/lib/php/test/Fixtures/TJSONProtocolFixtures.php b/lib/php/test/Fixtures/TJSONProtocolFixtures.php deleted file mode 100644 index 77fb270a796..00000000000 --- a/lib/php/test/Fixtures/TJSONProtocolFixtures.php +++ /dev/null @@ -1,72 +0,0 @@ -<><"}}'; - - self::$testArgsJSON['testString3'] = '{"1":{"str":"string that ends in double-backslash \\\\\\\\"}}'; - - self::$testArgsJSON['testUnicodeStringWithNonBMP'] = '{"1":{"str":"สวัสดี\/𝒯"}}'; - - self::$testArgsJSON['testDouble'] = '{"1":{"dbl":3.1415926535898}}'; - - self::$testArgsJSON['testByte'] = '{"1":{"i8":1}}'; - - self::$testArgsJSON['testI32'] = '{"1":{"i32":1073741824}}'; - - if (PHP_INT_SIZE == 8) { - self::$testArgsJSON['testI64'] = '{"1":{"i64":' . pow(2, 60) . '}}'; - self::$testArgsJSON['testStruct'] = '{"1":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":' . pow(2, 60) . '}}}}'; - self::$testArgsJSON['testNest'] = '{"1":{"rec":{"1":{"i8":1},"2":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":' . pow(2, 60) . '}}},"3":{"i32":32768}}}}'; - } else { - self::$testArgsJSON['testI64'] = '{"1":{"i64":1152921504606847000}}'; - self::$testArgsJSON['testStruct'] = '{"1":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":1152921504606847000}}}}'; - self::$testArgsJSON['testNest'] = '{"1":{"rec":{"1":{"i8":1},"2":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":1152921504606847000}}},"3":{"i32":32768}}}}'; - } - - self::$testArgsJSON['testMap'] = '{"1":{"map":["i32","i32",3,{"7":77,"8":88,"9":99}]}}'; - - self::$testArgsJSON['testStringMap'] = '{"1":{"map":["str","str",6,{"a":"123","a b":"with spaces ","same":"same","0":"numeric key","longValue":"Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e","Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e":"long key"}]}}'; - - self::$testArgsJSON['testSet'] = '{"1":{"set":["i32",3,1,5,6]}}'; - - self::$testArgsJSON['testList'] = '{"1":{"lst":["i32",3,1,2,3]}}'; - - self::$testArgsJSON['testEnum'] = '{"1":{"i32":1}}'; - - self::$testArgsJSON['testTypedef'] = '{"1":{"i64":69}}'; - - self::$testArgsJSON['testMapMap'] = '{"0":{"map":["i32","map",2,{"4":["i32","i32",4,{"1":1,"2":2,"3":3,"4":4}],"-4":["i32","i32",4,{"-4":-4,"-3":-3,"-2":-2,"-1":-1}]}]}}'; - - self::$testArgsJSON['testInsanity'] = '{"0":{"map":["i64","map",2,{"1":["i32","rec",2,{"2":{"1":{"map":["i32","i64",2,{"5":5,"8":8}]},"2":{"lst":["rec",2,{"1":{"str":"Goodbye4"},"4":{"i8":4},"9":{"i32":4},"11":{"i64":4}},{"1":{"str":"Hello2"},"4":{"i8":2},"9":{"i32":2},"11":{"i64":2}}]}},"3":{"1":{"map":["i32","i64",2,{"5":5,"8":8}]},"2":{"lst":["rec",2,{"1":{"str":"Goodbye4"},"4":{"i8":4},"9":{"i32":4},"11":{"i64":4}},{"1":{"str":"Hello2"},"4":{"i8":2},"9":{"i32":2},"11":{"i64":2}}]}}}],"2":["i32","rec",1,{"6":{}}]}]}}'; - } -} diff --git a/lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php b/lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php deleted file mode 100644 index 0281a879b7e..00000000000 --- a/lib/php/test/Fixtures/TSimpleJSONProtocolFixtures.php +++ /dev/null @@ -1,65 +0,0 @@ -<><"}'; - - self::$testArgsJSON['testDouble'] = '{"thing":3.1415926535898}'; - - self::$testArgsJSON['testByte'] = '{"thing":1}'; - - self::$testArgsJSON['testI32'] = '{"thing":1073741824}'; - - if (PHP_INT_SIZE == 8) { - self::$testArgsJSON['testI64'] = '{"thing":' . pow(2, 60) . '}'; - self::$testArgsJSON['testStruct'] = '{"thing":{"string_thing":"worked","byte_thing":1,"i32_thing":1073741824,"i64_thing":' . pow(2, 60) . '}}'; - self::$testArgsJSON['testNest'] = '{"thing":{"byte_thing":1,"struct_thing":{"string_thing":"worked","byte_thing":1,"i32_thing":1073741824,"i64_thing":' . pow(2, 60) . '},"i32_thing":32768}}'; - } else { - self::$testArgsJSON['testI64'] = '{"thing":1152921504606847000}'; - - self::$testArgsJSON['testStruct'] = '{"thing":{"string_thing":"worked","byte_thing":1,"i32_thing":1073741824,"i64_thing":1152921504606847000}}'; - self::$testArgsJSON['testNest'] = '{"thing":{"byte_thing":1,"struct_thing":{"string_thing":"worked","byte_thing":1,"i32_thing":1073741824,"i64_thing":1152921504606847000},"i32_thing":32768}}'; - } - - self::$testArgsJSON['testMap'] = '{"thing":{"7":77,"8":88,"9":99}}'; - - self::$testArgsJSON['testStringMap'] = '{"thing":{"a":"123","a b":"with spaces ","same":"same","0":"numeric key","longValue":"Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e","Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e":"long key"}}'; - - self::$testArgsJSON['testSet'] = '{"thing":[1,5,6]}'; - - self::$testArgsJSON['testList'] = '{"thing":[1,2,3]}'; - - self::$testArgsJSON['testEnum'] = '{"thing":1}'; - - self::$testArgsJSON['testTypedef'] = '{"thing":69}'; - } -} diff --git a/lib/php/test/Unit/BaseValidatorTest.php b/lib/php/test/Integration/BaseValidatorTest.php similarity index 76% rename from lib/php/test/Unit/BaseValidatorTest.php rename to lib/php/test/Integration/BaseValidatorTest.php index 4404e72ce98..ae9d5844d2e 100644 --- a/lib/php/test/Unit/BaseValidatorTest.php +++ b/lib/php/test/Integration/BaseValidatorTest.php @@ -19,7 +19,7 @@ * under the License. */ -namespace Test\Thrift\Unit; +namespace Test\Thrift\Integration; use PHPUnit\Framework\TestCase; use Thrift\Exception\TProtocolException; @@ -28,38 +28,41 @@ abstract class BaseValidatorTest extends TestCase { + abstract public function getNsGlobal(); + public function testEmptyStructValidator() { - $this->assertNoReadValidator('ThriftTest\EmptyStruct'); - $this->assertNoWriteValidator('ThriftTest\EmptyStruct'); + $this->assertNoReadValidator($this->getNsGlobal() . '\ThriftTest\EmptyStruct'); + $this->assertNoWriteValidator($this->getNsGlobal() . '\ThriftTest\EmptyStruct'); } public function testBonkValidator() { - $this->assertNoReadValidator('ThriftTest\Bonk'); - $this->assertHasWriteValidator('ThriftTest\Bonk'); + $this->assertNoReadValidator($this->getNsGlobal() . '\ThriftTest\Bonk'); + $this->assertHasWriteValidator($this->getNsGlobal() . '\ThriftTest\Bonk'); } public function testStructAValidator() { - $this->assertHasReadValidator('ThriftTest\StructA'); - $this->assertHasWriteValidator('ThriftTest\StructA'); + $this->assertHasReadValidator($this->getNsGlobal() . '\ThriftTest\StructA'); + $this->assertHasWriteValidator($this->getNsGlobal() . '\ThriftTest\StructA'); } public function testUnionOfStringsValidator() { - $this->assertNoWriteValidator('TestValidators\UnionOfStrings'); + $this->assertNoWriteValidator($this->getNsGlobal() . '\TestValidators\UnionOfStrings'); } public function testServiceResultValidator() { - $this->assertNoReadValidator('TestValidators\TestService_test_result'); - $this->assertNoWriteValidator('TestValidators\TestService_test_result'); + $this->assertNoReadValidator($this->getNsGlobal() . '\TestValidators\TestService_test_result'); + $this->assertNoWriteValidator($this->getNsGlobal() . '\TestValidators\TestService_test_result'); } public function testReadEmpty() { - $bonk = new \ThriftTest\Bonk(); + $className = $this->getNsGlobal() . '\ThriftTest\Bonk'; + $bonk = new $className(); $transport = new TMemoryBuffer("\000"); $protocol = new TBinaryProtocol($transport); $bonk->read($protocol); @@ -68,7 +71,8 @@ public function testReadEmpty() public function testWriteEmpty() { - $bonk = new \ThriftTest\Bonk(); + $className = $this->getNsGlobal() . '\ThriftTest\Bonk'; + $bonk = new $className(); $transport = new TMemoryBuffer(); $protocol = new TBinaryProtocol($transport); try { @@ -83,7 +87,8 @@ public function testWriteEmpty() public function testWriteWithMissingRequired() { // Check that we are not able to write StructA with a missing required field - $structa = new \ThriftTest\StructA(); + $className = $this->getNsGlobal() . '\ThriftTest\StructA'; + $structa = new $className(); $transport = new TMemoryBuffer(); $protocol = new TBinaryProtocol($transport); @@ -100,7 +105,8 @@ public function testReadStructA() { $transport = new TMemoryBuffer(base64_decode('CwABAAAAA2FiYwA=')); $protocol = new TBinaryProtocol($transport); - $structa = new \ThriftTest\StructA(); + $className = $this->getNsGlobal() . '\ThriftTest\StructA'; + $structa = new $className(); $structa->read($protocol); $this->assertEquals("abc", $structa->s); } @@ -109,7 +115,8 @@ public function testWriteStructA() { $transport = new TMemoryBuffer(); $protocol = new TBinaryProtocol($transport); - $structa = new \ThriftTest\StructA(); + $className = $this->getNsGlobal() . '\ThriftTest\StructA'; + $structa = new $className(); $structa->s = "abc"; $structa->write($protocol); $writeResult = base64_encode($transport->getBuffer()); diff --git a/lib/php/test/Integration/Lib/ClassLoader/ThriftClassLoaderTest.php b/lib/php/test/Integration/Lib/ClassLoader/ThriftClassLoaderTest.php new file mode 100644 index 00000000000..a43f5c68685 --- /dev/null +++ b/lib/php/test/Integration/Lib/ClassLoader/ThriftClassLoaderTest.php @@ -0,0 +1,139 @@ +getFunctionMock('Thrift\ClassLoader', 'apcu_fetch') + ->expects($useApcu ? $this->any() : $this->never()) + ->with($apcuPrefix . $class) + ->willReturn(false); + + $this->getFunctionMock('Thrift\ClassLoader', 'apcu_store') + ->expects($useApcu ? $this->any() : $this->never()) + ->with($apcuPrefix . $class, $this->anything()) + ->willReturn(true); + + $loader = new ThriftClassLoader($useApcu, $apcuPrefix); + foreach ($definitions as $namespace => $paths) { + $loader->registerDefinition($namespace, $paths); + } + $loader->register(); + + $loader->loadClass($class); + if ($checkInterfaceExist) { + $this->assertTrue(interface_exists($class, false), "->loadClass() loads '$class'"); + } else { + $this->assertTrue(class_exists($class, false), "->loadClass() loads '$class'"); + } + } + + public function registerDefinitionDataProvider() + { + yield 'loadType' => [ + 'definitions' => [ + 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => 'Classmap\ThriftTest\Xtruct', + ]; + yield 'loadInterface' => [ + 'definitions' => [ + 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\Classmap\ThriftTest\ThriftTestIf', + 'checkInterfaceExist' => true, + ]; + yield 'loadClient' => [ + 'definitions' => [ + 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\Classmap\ThriftTest\ThriftTestClient', + ]; + yield 'loadProcessor' => [ + 'definitions' => [ + 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\Classmap\ThriftTest\ThriftTestProcessor', + ]; + yield 'loadRest' => [ + 'definitions' => [ + 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\Classmap\ThriftTest\ThriftTestRest', + ]; + yield 'load_args' => [ + 'definitions' => [ + 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\Classmap\ThriftTest\ThriftTest_testVoid_args', + ]; + yield 'load_result' => [ + 'definitions' => [ + 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', + ], + 'class' => '\Classmap\ThriftTest\ThriftTest_testVoid_result', + ]; + yield 'pathAsArray' => [ + 'definitions' => [ + 'Classmap' => [__DIR__ . '/../../../Resources/packages/phpcm'], + ], + 'class' => 'Classmap\ThriftTest\Xtruct', + ]; + yield 'severalDefinitions' => [ + 'definitions' => [ + 'Classmap\ThriftTest' => [__DIR__ . '/../../../Resources/packages/phpcm'], + 'Classmap\TestValidators' => [__DIR__ . '/../../../Resources/packages/phpcm'], + ], + 'class' => '\Classmap\TestValidators\TestServiceClient', + ]; + yield 'useApcu' => [ + 'definitions' => [ + 'Classmap\ThriftTest' => [__DIR__ . '/../../../Resources/packages/phpcm'], + 'Classmap\TestValidators' => [__DIR__ . '/../../../Resources/packages/phpcm'], + ], + 'class' => '\Classmap\TestValidators\TestServiceClient', + 'checkInterfaceExist' => false, + 'useApcu' => true, + 'apcuPrefix' => 'APCU_PREFIX', + ]; + } +} diff --git a/lib/php/test/Integration/Lib/Protocol/TJSONProtocolTest.php b/lib/php/test/Integration/Lib/Protocol/TJSONProtocolTest.php new file mode 100644 index 00000000000..515cbdb3419 --- /dev/null +++ b/lib/php/test/Integration/Lib/Protocol/TJSONProtocolTest.php @@ -0,0 +1,646 @@ +transport = new TMemoryBuffer(); + $this->protocol = new TJSONProtocol($this->transport); + $this->transport->open(); + } + + public function testMessageReadWrite() + { + $input = new TJSONProtocol(new TMemoryBuffer('[1,"testString",1,0,{"0":{"str":"successResponse"}}]')); + $service = new \Basic\ThriftTest\ThriftTestClient($input, $this->protocol); + $result = $service->testString('test'); + $this->assertSame('successResponse', $result); + } + + /** + * @dataProvider writeDataProvider + */ + public function testWrite( + $argsClassName, + $argsValues, + $expected + ) { + $args = new $argsClassName($argsValues); + $args->write($this->protocol); + + $actual = $this->transport->read(self::BUFFER_SIZE); + + $this->assertEquals($expected, $actual); + } + + public function writeDataProvider() + { + if (!is_dir(__DIR__ . '/../../../Resources/packages/php')) { + throw new \RuntimeException( + 'Before running Integration test suite, you must run the Thrift compiler against the ThriftTest.thrift file in the ./Resources directory.' + ); + } + + yield 'void' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testVoid_args::class, + 'argsValues' => [], + 'expected' => '{}', + ]; + yield 'bool true' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testBool_args::class, + 'argsValues' => [ + 'thing' => true, + ], + 'expected' => '{"1":{"tf":1}}', + ]; + yield 'bool false' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testBool_args::class, + 'argsValues' => [ + 'thing' => false, + ], + 'expected' => '{"1":{"tf":0}}', + ]; + yield 'string1' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsValues' => [ + 'thing' => "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語", + ], + 'expected' => '{"1":{"str":"Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ \/ ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe\'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски \/ Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча\/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語"}}', + ]; + yield 'string2' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsValues' => [ + 'thing' => "quote: \\\" backslash:" . + " forwardslash-escaped: \\/ " . + " backspace: \b formfeed: \f newline: \n return: \r tab: " . + " now-all-of-them-together: \"\\\/\b\n\r\t" . + " now-a-bunch-of-junk: !@#\$%&()(&%$#{}{}<><><", + ], + 'expected' => '{"1":{"str":"quote: \\\\\" backslash: forwardslash-escaped: \\\\\/ backspace: \\\\b formfeed: \f newline: \n return: \r tab: now-all-of-them-together: \"\\\\\\\\\/\\\\b\n\r\t now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><"}}', + ]; + yield 'string3' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsValues' => [ + 'thing' => "string that ends in double-backslash \\\\", + ], + 'expected' => '{"1":{"str":"string that ends in double-backslash \\\\\\\\"}}', + ]; + yield 'string4 testUnicodeStringWithNonBMP' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsValues' => [ + 'thing' => "สวัสดี/𝒯", + ], + 'expected' => '{"1":{"str":"สวัสดี\/𝒯"}}', + ]; + yield 'double' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testDouble_args::class, + 'argsValues' => [ + 'thing' => 3.1415926535898, + ], + 'expected' => '{"1":{"dbl":3.1415926535898}}', + ]; + #TODO Should be fixed in future + yield 'double Nan' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testDouble_args::class, + 'argsValues' => [ + 'thing' => NAN, + ], + 'expected' => '{"1":{"dbl":}}', + ]; + #TODO Should be fixed in future + yield 'double Infinity' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testDouble_args::class, + 'argsValues' => [ + 'thing' => INF, + ], + 'expected' => '{"1":{"dbl":}}', + ]; + yield 'byte' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testByte_args::class, + 'argsValues' => [ + 'thing' => 0x01, + ], + 'expected' => '{"1":{"i8":1}}', + ]; + yield 'i32' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testI32_args::class, + 'argsValues' => [ + 'thing' => pow(2, 30), + ], + 'expected' => '{"1":{"i32":1073741824}}', + ]; + if (PHP_INT_SIZE == 8) { + yield 'i64_64Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testI64_args::class, + 'argsValues' => [ + 'thing' => pow(2, 60), + ], + 'expected' => '{"1":{"i64":' . pow(2, 60) . '}}', + ]; + yield 'struct_64Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testStruct_args::class, + 'argsValues' => [ + 'thing' => new Xtruct( + [ + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => pow(2, 60), + ] + ), + ], + 'expected' => '{"1":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":' . pow(2, 60) . '}}}}', + ]; + yield 'nest_64Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testNest_args::class, + 'argsValues' => [ + 'thing' => new Xtruct2( + [ + 'byte_thing' => 0x01, + 'struct_thing' => new Xtruct( + [ + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => pow(2, 60), + ] + ), + 'i32_thing' => pow(2, 15), + ] + ), + ], + 'expected' => '{"1":{"rec":{"1":{"i8":1},"2":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":' . pow(2, 60) . '}}},"3":{"i32":32768}}}}', + ]; + } else { + yield 'i64_32Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testI64_args::class, + 'argsValues' => [ + 'thing' => "1152921504606847000", + ], + 'expected' => '{"1":{"i64":1152921504606847000}}', + ]; + yield 'struct_32Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testStruct_args::class, + 'argsValues' => [ + 'thing' => new Xtruct( + [ + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => pow(2, 60), + ] + ), + ], + 'expected' => '{"1":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":1152921504606847000}}}}', + ]; + yield 'nest_32Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testNest_args::class, + 'argsValues' => [ + 'thing' => new Xtruct2( + [ + 'byte_thing' => 0x01, + 'struct_thing' => new Xtruct( + [ + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => '1152921504606847000', + ] + ), + 'i32_thing' => pow(2, 15), + ] + ), + ], + 'expected' => '{"1":{"rec":{"1":{"i8":1},"2":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":1152921504606847000}}},"3":{"i32":32768}}}}', + ]; + } + yield 'map' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testMap_args::class, + 'argsValues' => [ + 'thing' => [ + 7 => 77, + 8 => 88, + 9 => 99, + ], + ], + 'expected' => '{"1":{"map":["i32","i32",3,{"7":77,"8":88,"9":99}]}}', + ]; + yield 'stringMap' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testStringMap_args::class, + 'argsValues' => [ + 'thing' => [ + "a" => "123", + "a b" => "with spaces ", + "same" => "same", + "0" => "numeric key", + "longValue" => "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語", + "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語" => "long key", + ], + ], + 'expected' => '{"1":{"map":["str","str",6,{"a":"123","a b":"with spaces ","same":"same","0":"numeric key","longValue":"Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ \/ ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe\'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски \/ Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча\/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語","Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ \/ ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe\'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски \/ Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча\/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語":"long key"}]}}', + ]; + yield 'set' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testSet_args::class, + 'argsValues' => [ + 'thing' => [1 => true, 5 => true, 6 => true], + ], + 'expected' => '{"1":{"set":["i32",3,1,5,6]}}', + ]; + yield 'list' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testList_args::class, + 'argsValues' => [ + 'thing' => [1, 2, 3], + ], + 'expected' => '{"1":{"lst":["i32",3,1,2,3]}}', + ]; + yield 'enum' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testEnum_args::class, + 'argsValues' => [ + 'thing' => \Basic\ThriftTest\Numberz::SIX, + ], + 'expected' => '{"1":{"i32":6}}', + ]; + yield 'typedef' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testTypedef_args::class, + 'argsValues' => [ + 'thing' => 69, + ], + 'expected' => '{"1":{"i64":69}}', + ]; + } + + /** + * @dataProvider readDataProvider + */ + public function testRead( + $buffer, + $argsClassName, + $argsPropertyName, + $expectedValue, + $expectedResult + ): void { + $this->transport->write($buffer); + $args = new $argsClassName(); + $result = $args->read($this->protocol); + + $this->assertEquals($expectedResult, $result); + + if (is_null($argsPropertyName)) { + $this->assertNull($argsPropertyName); + } elseif (is_float($expectedValue) && is_nan($expectedValue)) { + $this->assertNan($args->{$argsPropertyName}); + } elseif (is_float($expectedValue) && is_infinite($expectedValue)) { + $this->assertEquals($expectedValue, $args->{$argsPropertyName}); + } else { + $this->assertEquals($expectedValue, $args->{$argsPropertyName}); + } + } + + public function readDataProvider() + { + yield 'void' => [ + 'buffer' => '{}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testVoid_args::class, + 'argsPropertyName' => null, + 'expectedValue' => null, + 'expectedResult' => 0, + ]; + yield 'bool true' => [ + 'buffer' => '{"1":{"tf":1}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testBool_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => true, + 'expectedResult' => 1, + ]; + yield 'bool false' => [ + 'buffer' => '{"1":{"tf":0}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testBool_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => false, + 'expectedResult' => 1, + ]; + yield 'string1' => [ + 'buffer' => '{"1":{"str":"Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ \/ ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe\'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски \/ Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча\/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語"}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語", + 'expectedResult' => 1, + ]; + yield 'string2' => [ + 'buffer' => '{"1":{"str":"quote: \\\\\" backslash: forwardslash-escaped: \\\\\/ backspace: \\\\b formfeed: \f newline: \n return: \r tab: now-all-of-them-together: \"\\\\\\\\\/\\\\b\n\r\t now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><"}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => "quote: \\\" backslash:" . + " forwardslash-escaped: \\/ " . + " backspace: \b formfeed: \f newline: \n return: \r tab: " . + " now-all-of-them-together: \"\\\/\b\n\r\t" . + " now-a-bunch-of-junk: !@#\$%&()(&%$#{}{}<><><", + 'expectedResult' => 1, + ]; + yield 'string3' => [ + 'buffer' => '{"1":{"str":"string that ends in double-backslash \\\\\\\\"}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => "string that ends in double-backslash \\\\", + 'expectedResult' => 1, + ]; + yield 'string4' => [ + 'buffer' => '{"1":{"str":"สวัสดี\/𝒯"}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => "สวัสดี/𝒯", + 'expectedResult' => 1, + ]; + yield 'double' => [ + 'buffer' => '{"1":{"dbl":3.1415926535898}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testDouble_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => 3.1415926535898, + 'expectedResult' => 1, + ]; + yield 'double Nan' => [ + 'buffer' => '{"1":{"dbl":"NaN"}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testDouble_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => NAN, + 'expectedResult' => 1, + ]; + yield 'double Infinity' => [ + 'buffer' => '{"1":{"dbl":"Infinity"}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testDouble_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => INF, + 'expectedResult' => 1, + ]; + yield 'byte' => [ + 'buffer' => '{"1":{"i8":1}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testByte_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => 0x01, + 'expectedResult' => 1, + ]; + yield 'i32' => [ + 'buffer' => '{"1":{"i32":1073741824}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testI32_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => pow(2, 30), + 'expectedResult' => 1, + ]; + if (PHP_INT_SIZE == 8) { + yield 'i64_64Architecture' => [ + 'buffer' => '{"1":{"i64":' . pow(2, 60) . '}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testI64_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => pow(2, 60), + 'expectedResult' => 1, + ]; + yield 'struct_64Architecture' => [ + 'buffer' => '{"1":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":' . pow(2, 60) . '}}}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testStruct_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => new Xtruct( + array( + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => pow(2, 60), + ) + ), + 'expectedResult' => 4, + ]; + yield 'nest_64Architecture' => [ + 'buffer' => '{"1":{"rec":{"1":{"i8":1},"2":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":' . pow(2, 60) . '}}},"3":{"i32":32768}}}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testNest_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => new Xtruct2( + array( + 'byte_thing' => 0x01, + 'struct_thing' => new Xtruct( + array( + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => pow(2, 60), + ) + ), + 'i32_thing' => pow(2, 15) + ) + ), + 'expectedResult' => 6, + ]; + } else { + yield 'i64_32Architecture' => [ + 'buffer' => '{"1":{"i64":1152921504606847000}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testI64_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => "1152921504606847000", + 'expectedResult' => 1, + ]; + yield 'struct_32Architecture' => [ + 'buffer' => '{"1":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":1152921504606847000}}}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testStruct_args::class, + 'expectedValue' => new Xtruct( + array( + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => "1152921504606847000", + ) + ), + 'expectedResult' => 4, + ]; + yield 'nest_32Architecture' => [ + 'buffer' => '{"1":{"rec":{"1":{"i8":1},"2":{"rec":{"1":{"str":"worked"},"4":{"i8":1},"9":{"i32":1073741824},"11":{"i64":1152921504606847000}}},"3":{"i32":32768}}}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testNest_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => new Xtruct2( + array( + 'byte_thing' => 0x01, + 'struct_thing' => new Xtruct( + array( + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => "1152921504606847000", + ) + ), + 'i32_thing' => pow(2, 15) + ) + ), + 'expectedResult' => 6, + ]; + } + yield 'map' => [ + 'buffer' => '{"1":{"map":["i32","i32",3,{"7":77,"8":88,"9":99}]}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testMap_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => [ + 7 => 77, + 8 => 88, + 9 => 99 + ], + 'expectedResult' => 6, + ]; + yield 'stringMap' => [ + 'buffer' => '{"1":{"map":["str","str",6,{"a":"123","a b":"with spaces ","same":"same","0":"numeric key","longValue":"Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e","Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e":"long key"}]}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testStringMap_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => [ + "a" => "123", + "a b" => "with spaces ", + "same" => "same", + "0" => "numeric key", + "longValue" => "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語", + "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語" => "long key" + ], + 'expectedResult' => 12, + ]; + yield 'set' => [ + 'buffer' => '{"1":{"set":["i32",3,1,5,6]}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testSet_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => [1 => true, 5 => true, 6 => true], + 'expectedResult' => 4, + ]; + yield 'list' => [ + 'buffer' => '{"1":{"lst":["i32",3,1,2,3]}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testList_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => [1, 2, 3], + 'expectedResult' => 4, + ]; + yield 'enum' => [ + 'buffer' => '{"1":{"i32":6}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testEnum_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => Numberz::SIX, + 'expectedResult' => 1, + ]; + yield 'typedef' => [ + 'buffer' => '{"1":{"i64":69}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testTypedef_args::class, + 'argsPropertyName' => 'thing', + 'expectedValue' => 69, + 'expectedResult' => 1, + ]; + yield 'mapmap' => [ + 'buffer' => '{"0":{"map":["i32","map",2,{"4":["i32","i32",4,{"1":1,"2":2,"3":3,"4":4}],"-4":["i32","i32",4,{"-4":-4,"-3":-3,"-2":-2,"-1":-1}]}]}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testMapMap_result::class, + 'argsPropertyName' => 'success', + 'expectedValue' => [ + 4 => [ + 1 => 1, + 2 => 2, + 3 => 3, + 4 => 4, + ], + -4 => [ + -4 => -4, + -3 => -3, + -2 => -2, + -1 => -1 + ] + ], + 'expectedResult' => 18, + ]; + + $xtruct1 = new Xtruct( + [ + 'string_thing' => 'Goodbye4', + 'byte_thing' => 4, + 'i32_thing' => 4, + 'i64_thing' => 4, + ] + ); + + $xtruct2 = new Xtruct( + [ + 'string_thing' => 'Hello2', + 'byte_thing' => 2, + 'i32_thing' => 2, + 'i64_thing' => 2, + ] + ); + + $userMap = [Numberz::FIVE => 5, Numberz::EIGHT => 8]; + + $insanity2 = new Insanity( + [ + 'userMap' => $userMap, + 'xtructs' => [$xtruct1, $xtruct2], + ] + ); + + $insanity3 = $insanity2; + + $insanity6 = + new Insanity( + [ + 'userMap' => null, + 'xtructs' => null, + ] + ); + yield 'insanity' => [ + 'buffer' => '{"0":{"map":["i64","map",2,{"1":["i32","rec",2,{"2":{"1":{"map":["i32","i64",2,{"5":5,"8":8}]},"2":{"lst":["rec",2,{"1":{"str":"Goodbye4"},"4":{"i8":4},"9":{"i32":4},"11":{"i64":4}},{"1":{"str":"Hello2"},"4":{"i8":2},"9":{"i32":2},"11":{"i64":2}}]}},"3":{"1":{"map":["i32","i64",2,{"5":5,"8":8}]},"2":{"lst":["rec",2,{"1":{"str":"Goodbye4"},"4":{"i8":4},"9":{"i32":4},"11":{"i64":4}},{"1":{"str":"Hello2"},"4":{"i8":2},"9":{"i32":2},"11":{"i64":2}}]}}}],"2":["i32","rec",1,{"6":{}}]}]}}', + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testInsanity_result::class, + 'argsPropertyName' => 'success', + 'expectedValue' => [ + "1" => [ + Numberz::TWO => $insanity2, + Numberz::THREE => $insanity3, + ], + "2" => [ + Numberz::SIX => $insanity6, + ], + ], + 'expectedResult' => 31, + ]; + } +} diff --git a/lib/php/test/Integration/Lib/Protocol/TSimpleJSONProtocolTest.php b/lib/php/test/Integration/Lib/Protocol/TSimpleJSONProtocolTest.php new file mode 100644 index 00000000000..e108ffcb7f5 --- /dev/null +++ b/lib/php/test/Integration/Lib/Protocol/TSimpleJSONProtocolTest.php @@ -0,0 +1,319 @@ +transport = new TMemoryBuffer(); + $this->protocol = new TSimpleJSONProtocol($this->transport); + $this->transport->open(); + } + + public function testMessageWrite() + { + $input = new TJSONProtocol(new TMemoryBuffer('[1,"testString",1,0,{"0":{"str":"successResponse"}}]')); + $service = new \Basic\ThriftTest\ThriftTestClient($input, $this->protocol); + $result = $service->testString('test'); + $this->assertSame('successResponse', $result); + $this->assertSame('["testString",1,0,{"thing":"test"}]', $this->protocol->getTransport()->getBuffer()); + } + + /** + * @dataProvider writeDataProvider + */ + public function testWrite( + $argsClassName, + $argsValues, + $expected + ) { + $args = new $argsClassName($argsValues); + $args->write($this->protocol); + + $actual = $this->transport->read(self::BUFFER_SIZE); + + $this->assertEquals($expected, $actual); + } + + public function writeDataProvider() + { + if (!is_dir(__DIR__ . '/../../../Resources/packages/php')) { + throw new \RuntimeException( + 'Before running Integration test suite, you must run the Thrift compiler against the ThriftTest.thrift file in the ./Resources directory.' + ); + } + + yield 'void' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testVoid_args::class, + 'argsValues' => [], + 'expected' => '{}', + ]; + yield 'bool true' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testBool_args::class, + 'argsValues' => [ + 'thing' => true, + ], + 'expected' => '{"thing":1}', + ]; + yield 'bool false' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testBool_args::class, + 'argsValues' => [ + 'thing' => false, + ], + 'expected' => '{"thing":0}', + ]; + yield 'string1' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsValues' => [ + 'thing' => "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語", + ], + 'expected' => '{"thing":"Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e"}', + ]; + yield 'string2' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsValues' => [ + 'thing' => "quote: \\\" backslash:" . + " forwardslash-escaped: \\/ " . + " backspace: \b formfeed: \f newline: \n return: \r tab: " . + " now-all-of-them-together: \"\\\/\b\n\r\t" . + " now-a-bunch-of-junk: !@#\$%&()(&%$#{}{}<><><", + ], + 'expected' => '{"thing":"quote: \\\\\" backslash: forwardslash-escaped: \\\\\/ backspace: \\\\b formfeed: \f newline: \n return: \r tab: now-all-of-them-together: \"\\\\\\\\\/\\\\b\n\r\t now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><"}', + ]; + + yield 'string3' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsValues' => [ + 'thing' => "string that ends in double-backslash \\\\", + ], + 'expected' => '{"thing":"string that ends in double-backslash \\\\\\\\"}', + ]; + yield 'string4 testUnicodeStringWithNonBMP' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testString_args::class, + 'argsValues' => [ + 'thing' => "สวัสดี/𝒯", + ], + 'expected' => '{"thing":"\u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35\/\ud835\udcaf"}', + ]; + yield 'double' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testDouble_args::class, + 'argsValues' => [ + 'thing' => 3.1415926535898, + ], + 'expected' => '{"thing":3.1415926535898}', + ]; + #TODO Should be fixed in future + yield 'double Nan' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testDouble_args::class, + 'argsValues' => [ + 'thing' => NAN, + ], + 'expected' => '{"thing":}', + ]; + #TODO Should be fixed in future + yield 'double Infinity' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testDouble_args::class, + 'argsValues' => [ + 'thing' => INF, + ], + 'expected' => '{"thing":}', + ]; + yield 'byte' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testByte_args::class, + 'argsValues' => [ + 'thing' => 0x01, + ], + 'expected' => '{"thing":1}', + ]; + yield 'i32' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testI32_args::class, + 'argsValues' => [ + 'thing' => pow(2, 30), + ], + 'expected' => '{"thing":1073741824}', + ]; + if (PHP_INT_SIZE == 8) { + yield 'i64_64Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testI64_args::class, + 'argsValues' => [ + 'thing' => pow(2, 60), + ], + 'expected' => '{"thing":' . pow(2, 60) . '}', + ]; + yield 'struct_64Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testStruct_args::class, + 'argsValues' => [ + 'thing' => new Xtruct( + [ + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => pow(2, 60), + ] + ), + ], + 'expected' => '{"thing":{"string_thing":"worked","byte_thing":1,"i32_thing":1073741824,"i64_thing":' . pow(2, 60) . '}}', + ]; + yield 'nest_64Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testNest_args::class, + 'argsValues' => [ + 'thing' => new Xtruct2( + [ + 'byte_thing' => 0x01, + 'struct_thing' => new Xtruct( + [ + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => pow(2, 60), + ] + ), + 'i32_thing' => pow(2, 15), + ] + ), + ], + 'expected' => '{"thing":{"byte_thing":1,"struct_thing":{"string_thing":"worked","byte_thing":1,"i32_thing":1073741824,"i64_thing":' . pow(2, 60) . '},"i32_thing":32768}}', + ]; + } else { + yield 'i64_32Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testI64_args::class, + 'argsValues' => [ + 'thing' => "1152921504606847000", + ], + 'expected' => '{"thing":1152921504606847000}', + ]; + yield 'struct_32Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testStruct_args::class, + 'argsValues' => [ + 'thing' => new Xtruct( + [ + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => pow(2, 60), + ] + ), + ], + 'expected' => '{"thing":{"string_thing":"worked","byte_thing":1,"i32_thing":1073741824,"i64_thing":1152921504606847000}}', + ]; + yield 'nest_32Architecture' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testNest_args::class, + 'argsValues' => [ + 'thing' => new Xtruct2( + [ + 'byte_thing' => 0x01, + 'struct_thing' => new Xtruct( + [ + 'string_thing' => 'worked', + 'byte_thing' => 0x01, + 'i32_thing' => pow(2, 30), + 'i64_thing' => '1152921504606847000', + ] + ), + 'i32_thing' => pow(2, 15), + ] + ), + ], + 'expected' => '{"thing":{"byte_thing":1,"struct_thing":{"string_thing":"worked","byte_thing":1,"i32_thing":1073741824,"i64_thing":1152921504606847000},"i32_thing":32768}}', + ]; + } + yield 'map' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testMap_args::class, + 'argsValues' => [ + 'thing' => [ + 7 => 77, + 8 => 88, + 9 => 99, + ], + ], + 'expected' => '{"thing":{"7":77,"8":88,"9":99}}', + ]; + yield 'stringMap' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testStringMap_args::class, + 'argsValues' => [ + 'thing' => [ + "a" => "123", + "a b" => "with spaces ", + "same" => "same", + "0" => "numeric key", + "longValue" => "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語", + "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語" => "long key" + ], + ], + 'expected' => '{"thing":{"a":"123","a b":"with spaces ","same":"same","0":"numeric key","longValue":"Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e","Afrikaans, Alemannisch, Aragon\u00e9s, \u0627\u0644\u0639\u0631\u0628\u064a\u0629, \u0645\u0635\u0631\u0649, Asturianu, Aymar aru, Az\u0259rbaycan, \u0411\u0430\u0448\u04a1\u043e\u0440\u0442, Boarisch, \u017demait\u0117\u0161ka, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430), \u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438, Bamanankan, \u09ac\u09be\u0982\u09b2\u09be, Brezhoneg, Bosanski, Catal\u00e0, M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304, \u041d\u043e\u0445\u0447\u0438\u0439\u043d, Cebuano, \u13e3\u13b3\u13a9, \u010cesky, \u0421\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f, \u0427\u04d1\u0432\u0430\u0448\u043b\u0430, Cymraeg, Dansk, Zazaki, \u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0, \u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac, Emili\u00e0n e rumagn\u00f2l, English, Esperanto, Espa\u00f1ol, Eesti, Euskara, \u0641\u0627\u0631\u0633\u06cc, Suomi, V\u00f5ro, F\u00f8royskt, Fran\u00e7ais, Arpetan, Furlan, Frysk, Gaeilge, \u8d1b\u8a9e, G\u00e0idhlig, Galego, Ava\u00f1e\'\u1ebd, \u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0, Gaelg, \u05e2\u05d1\u05e8\u05d9\u05ea, \u0939\u093f\u0928\u094d\u0926\u0940, Fiji Hindi, Hrvatski, Krey\u00f2l ayisyen, Magyar, \u0540\u0561\u0575\u0565\u0580\u0565\u0576, Interlingua, Bahasa Indonesia, Ilokano, Ido, \u00cdslenska, Italiano, \u65e5\u672c\u8a9e, Lojban, Basa Jawa, \u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8, Kongo, Kalaallisut, \u0c95\u0ca8\u0ccd\u0ca8\u0ca1, \ud55c\uad6d\uc5b4, \u041a\u044a\u0430\u0440\u0430\u0447\u0430\u0439-\u041c\u0430\u043b\u043a\u044a\u0430\u0440, Ripoarisch, Kurd\u00ee, \u041a\u043e\u043c\u0438, Kernewek, \u041a\u044b\u0440\u0433\u044b\u0437\u0447\u0430, Latina, Ladino, L\u00ebtzebuergesch, Limburgs, Ling\u00e1la, \u0ea5\u0eb2\u0ea7, Lietuvi\u0173, Latvie\u0161u, Basa Banyumasan, Malagasy, \u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438, \u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02, \u092e\u0930\u093e\u0920\u0940, Bahasa Melayu, \u0645\u0627\u0632\u0650\u0631\u0648\u0646\u06cc, Nnapulitano, Nedersaksisch, \u0928\u0947\u092a\u093e\u0932 \u092d\u093e\u0937\u093e, Nederlands, \u202aNorsk (nynorsk)\u202c, \u202aNorsk (bokm\u00e5l)\u202c, Nouormand, Din\u00e9 bizaad, Occitan, \u0418\u0440\u043e\u043d\u0430\u0443, Papiamentu, Deitsch, Norfuk \/ Pitkern, Polski, \u067e\u0646\u062c\u0627\u0628\u06cc, \u067e\u069a\u062a\u0648, Portugu\u00eas, Runa Simi, Rumantsch, Romani, Rom\u00e2n\u0103, \u0420\u0443\u0441\u0441\u043a\u0438\u0439, \u0421\u0430\u0445\u0430 \u0442\u044b\u043b\u0430, Sardu, Sicilianu, Scots, S\u00e1megiella, Simple English, Sloven\u010dina, Sloven\u0161\u010dina, \u0421\u0440\u043f\u0441\u043a\u0438 \/ Srpski, Seeltersk, Svenska, Kiswahili, \u0ba4\u0bae\u0bbf\u0bb4\u0bcd, \u0c24\u0c46\u0c32\u0c41\u0c17\u0c41, \u0422\u043e\u04b7\u0438\u043a\u04e3, \u0e44\u0e17\u0e22, T\u00fcrkmen\u00e7e, Tagalog, T\u00fcrk\u00e7e, \u0422\u0430\u0442\u0430\u0440\u0447\u0430\/Tatar\u00e7a, \u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430, \u0627\u0631\u062f\u0648, Ti\u1ebfng Vi\u1ec7t, Volap\u00fck, Walon, Winaray, \u5434\u8bed, isiXhosa, \u05d9\u05d9\u05b4\u05d3\u05d9\u05e9, Yor\u00f9b\u00e1, Ze\u00eauws, \u4e2d\u6587, B\u00e2n-l\u00e2m-g\u00fa, \u7cb5\u8a9e":"long key"}}', + ]; + yield 'set' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testSet_args::class, + 'argsValues' => [ + 'thing' => [1 => true, 5 => true, 6 => true], + ], + 'expected' => '{"thing":[1,5,6]}', + ]; + yield 'list' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testList_args::class, + 'argsValues' => [ + 'thing' => [1, 2, 3], + ], + 'expected' => '{"thing":[1,2,3]}', + ]; + yield 'enum' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testEnum_args::class, + 'argsValues' => [ + 'thing' => \Basic\ThriftTest\Numberz::SIX, + ], + 'expected' => '{"thing":6}', + ]; + yield 'typedef' => [ + 'argsClassName' => \Basic\ThriftTest\ThriftTest_testTypedef_args::class, + 'argsValues' => [ + 'thing' => 69, + ], + 'expected' => '{"thing":69}', + ]; + } +} diff --git a/lib/php/test/Unit/BinarySerializerTest.php b/lib/php/test/Integration/Lib/Serializer/BinarySerializerTest.php similarity index 66% rename from lib/php/test/Unit/BinarySerializerTest.php rename to lib/php/test/Integration/Lib/Serializer/BinarySerializerTest.php index 744ca7ad130..44eef937c51 100644 --- a/lib/php/test/Unit/BinarySerializerTest.php +++ b/lib/php/test/Integration/Lib/Serializer/BinarySerializerTest.php @@ -19,35 +19,26 @@ * under the License. */ -namespace Test\Thrift\Unit; +namespace Test\Thrift\Integration\Lib\Serializer; use PHPUnit\Framework\TestCase; -use Thrift\ClassLoader\ThriftClassLoader; use Thrift\Serializer\TBinarySerializer; /*** * This test suite depends on running the compiler against the ./Resources/ThriftTest.thrift file: - * lib/php/test$ ../../../compiler/cpp/thrift --gen php -r --out ./Resources/packages/php ./Resources/ThriftTest.thrift + * lib/php/test$ ../../../compiler/cpp/thrift --gen php:nsglobal="Basic" -r --out ./Resources/packages/php ./Resources/ThriftTest.thrift */ class BinarySerializerTest extends TestCase { - public function setUp(): void - { - $loader = new ThriftClassLoader(); - $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/php'); - $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/php'); - $loader->register(); - } - /** * We try to serialize and deserialize a random object to make sure no exceptions are thrown. * @see THRIFT-1579 */ public function testBinarySerializer() { - $struct = new \ThriftTest\Xtruct(array('string_thing' => 'abc')); - $serialized = TBinarySerializer::serialize($struct, 'ThriftTest\\Xtruct'); - $deserialized = TBinarySerializer::deserialize($serialized, 'ThriftTest\\Xtruct'); + $struct = new \Basic\ThriftTest\Xtruct(array('string_thing' => 'abc')); + $serialized = TBinarySerializer::serialize($struct, '\\Basic\\ThriftTest\\Xtruct'); + $deserialized = TBinarySerializer::deserialize($serialized, '\\Basic\\ThriftTest\\Xtruct'); $this->assertEquals($struct, $deserialized); } } diff --git a/lib/php/test/Unit/JsonSerializeTest.php b/lib/php/test/Integration/Lib/Serializer/JsonSerializeTest.php similarity index 71% rename from lib/php/test/Unit/JsonSerializeTest.php rename to lib/php/test/Integration/Lib/Serializer/JsonSerializeTest.php index 66e4d5e376f..d3fe3f78cc1 100644 --- a/lib/php/test/Unit/JsonSerializeTest.php +++ b/lib/php/test/Integration/Lib/Serializer/JsonSerializeTest.php @@ -19,7 +19,7 @@ * under the License. */ -namespace Test\Thrift\Unit; +namespace Test\Thrift\Integration\Lib\Serializer; use PHPUnit\Framework\TestCase; use stdClass; @@ -27,21 +27,13 @@ /*** * This test suite depends on running the compiler against the ./Resources/ThriftTest.thrift file: - * lib/php/test$ ../../../compiler/cpp/thrift --gen php:json -r --out ./Resources/packages/phpjs ./Resources/ThriftTest.thrift + * lib/php/test$ ../../../compiler/cpp/thrift --gen php:json,nsglobal="Json" -r --out ./Resources/packages/phpjs ./Resources/ThriftTest.thrift */ class JsonSerializeTest extends TestCase { - protected function setUp(): void - { - $loader = new ThriftClassLoader(); - $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/phpjs'); - $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/phpjs'); - $loader->register(); - } - public function testEmptyStruct() { - $empty = new \ThriftTest\EmptyStruct(array('non_existing_key' => 'bar')); + $empty = new \Json\ThriftTest\EmptyStruct(array('non_existing_key' => 'bar')); $this->assertEquals(new stdClass(), json_decode(json_encode($empty))); } @@ -51,7 +43,7 @@ public function testStringsAndInts() 'string_thing' => 'foo', 'i64_thing' => 1234567890, ); - $xtruct = new \ThriftTest\Xtruct($input); + $xtruct = new \Json\ThriftTest\Xtruct($input); // Xtruct's 'i32_thing' and 'byte_thing' fields should not be present here! $expected = new stdClass(); @@ -62,9 +54,9 @@ public function testStringsAndInts() public function testNestedStructs() { - $xtruct2 = new \ThriftTest\Xtruct2(array( + $xtruct2 = new \Json\ThriftTest\Xtruct2(array( 'byte_thing' => 42, - 'struct_thing' => new \ThriftTest\Xtruct(array( + 'struct_thing' => new \Json\ThriftTest\Xtruct(array( 'i32_thing' => 123456, )), )); @@ -79,8 +71,8 @@ public function testNestedStructs() public function testInsanity() { $xinput = array('string_thing' => 'foo'); - $xtruct = new \ThriftTest\Xtruct($xinput); - $insanity = new \ThriftTest\Insanity(array( + $xtruct = new \Json\ThriftTest\Xtruct($xinput); + $insanity = new \Json\ThriftTest\Insanity(array( 'xtructs' => array($xtruct, $xtruct, $xtruct) )); $expected = new stdClass(); @@ -90,8 +82,8 @@ public function testInsanity() public function testNestedLists() { - $bonk = new \ThriftTest\Bonk(array('message' => 'foo')); - $nested = new \ThriftTest\NestedListsBonk(array('bonk' => array(array(array($bonk))))); + $bonk = new \Json\ThriftTest\Bonk(array('message' => 'foo')); + $nested = new \Json\ThriftTest\NestedListsBonk(array('bonk' => array(array(array($bonk))))); $expected = new stdClass(); $expected->bonk = array(array(array((object)array('message' => 'foo')))); $this->assertEquals($expected, json_decode(json_encode($nested))); @@ -99,17 +91,17 @@ public function testNestedLists() public function testMaps() { - $intmap = new \ThriftTest\ThriftTest_testMap_args(['thing' => [0 => 'zero']]); - $emptymap = new \ThriftTest\ThriftTest_testMap_args([]); + $intmap = new \Json\ThriftTest\ThriftTest_testMap_args(['thing' => [0 => 'zero']]); + $emptymap = new \Json\ThriftTest\ThriftTest_testMap_args([]); $this->assertEquals('{"thing":{"0":"zero"}}', json_encode($intmap)); $this->assertEquals('{}', json_encode($emptymap)); } public function testScalarTypes() { - $b = new \ThriftTest\Bools(['im_true' => '1', 'im_false' => '0']); + $b = new \Json\ThriftTest\Bools(['im_true' => '1', 'im_false' => '0']); $this->assertEquals('{"im_true":true,"im_false":false}', json_encode($b)); - $s = new \ThriftTest\StructA(['s' => 42]); + $s = new \Json\ThriftTest\StructA(['s' => 42]); $this->assertEquals('{"s":"42"}', json_encode($s)); } } diff --git a/lib/php/test/Unit/ValidatorTestOop.php b/lib/php/test/Integration/ValidatorOopTest.php similarity index 59% rename from lib/php/test/Unit/ValidatorTestOop.php rename to lib/php/test/Integration/ValidatorOopTest.php index 95581825e0c..c3dce030a2c 100644 --- a/lib/php/test/Unit/ValidatorTestOop.php +++ b/lib/php/test/Integration/ValidatorOopTest.php @@ -19,23 +19,16 @@ * under the License. */ -namespace Test\Thrift\Unit; - -use Thrift\ClassLoader\ThriftClassLoader; +namespace Test\Thrift\Integration; /*** * This test suite depends on running the compiler against the ./Resources/ThriftTest.thrift file: - * lib/php/test$ ../../../compiler/cpp/thrift --gen php:validate,oop -r --out ./Resources/packages/phpvo ./Resources/ThriftTest.thrift + * lib/php/test$ ../../../compiler/cpp/thrift --gen php:validate,oop,nsglobal="ValidateOop" -r --out ./Resources/packages/phpvo ./Resources/ThriftTest.thrift */ -class ValidatorTestOop extends BaseValidatorTest +class ValidatorOopTest extends BaseValidatorTest { - public function setUp(): void + public function getNsGlobal() { - $loader = new ThriftClassLoader(); - $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/phpvo'); - $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/phpvo'); - $loader->registerNamespace('TestValidators', __DIR__ . '/../Resources/packages/phpvo'); - $loader->registerDefinition('TestValidators', __DIR__ . '/../Resources/packages/phpvo'); - $loader->register(); + return 'ValidateOop'; } } diff --git a/lib/php/test/Unit/ValidatorTest.php b/lib/php/test/Integration/ValidatorTest.php similarity index 62% rename from lib/php/test/Unit/ValidatorTest.php rename to lib/php/test/Integration/ValidatorTest.php index b125424c15e..0d6a697e4eb 100644 --- a/lib/php/test/Unit/ValidatorTest.php +++ b/lib/php/test/Integration/ValidatorTest.php @@ -19,23 +19,16 @@ * under the License. */ -namespace Test\Thrift\Unit; - -use Thrift\ClassLoader\ThriftClassLoader; +namespace Test\Thrift\Integration; /*** * This test suite depends on running the compiler against the ./Resources/ThriftTest.thrift file: - * lib/php/test$ ../../../compiler/cpp/thrift --gen php:validate -r --out ./Resources/packages/phpv ./Resources/ThriftTest.thrift + * lib/php/test$ ../../../compiler/cpp/thrift --gen php:validate,nsglobal="Validate" -r --out ./Resources/packages/phpv ./Resources/ThriftTest.thrift */ class ValidatorTest extends BaseValidatorTest { - public function setUp(): void + public function getNsGlobal() { - $loader = new ThriftClassLoader(); - $loader->registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/phpv'); - $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/phpv'); - $loader->registerNamespace('TestValidators', __DIR__ . '/../Resources/packages/phpv'); - $loader->registerDefinition('TestValidators', __DIR__ . '/../Resources/packages/phpv'); - $loader->register(); + return 'Validate'; } } diff --git a/lib/php/test/Makefile.am b/lib/php/test/Makefile.am index 1e534cad0f4..b6a53256e2b 100644 --- a/lib/php/test/Makefile.am +++ b/lib/php/test/Makefile.am @@ -25,11 +25,11 @@ stubs: Resources/ThriftTest.thrift mkdir -p ./Resources/packages/phpvo mkdir -p ./Resources/packages/phpjs mkdir -p ./Resources/packages/phpcm - $(THRIFT) --gen php -r --out ./Resources/packages/php Resources/ThriftTest.thrift - $(THRIFT) --gen php:validate -r --out ./Resources/packages/phpv Resources/ThriftTest.thrift - $(THRIFT) --gen php:validate,oop -r --out ./Resources/packages/phpvo Resources/ThriftTest.thrift - $(THRIFT) --gen php:json -r --out ./Resources/packages/phpjs Resources/ThriftTest.thrift - $(THRIFT) --gen php:classmap,server,rest -r --out ./Resources/packages/phpcm Resources/ThriftTest.thrift + $(THRIFT) --gen php:nsglobal="Basic" -r --out ./Resources/packages/php Resources/ThriftTest.thrift + $(THRIFT) --gen php:validate,nsglobal="Validate" -r --out ./Resources/packages/phpv Resources/ThriftTest.thrift + $(THRIFT) --gen php:validate,oop,nsglobal="ValidateOop" -r --out ./Resources/packages/phpvo Resources/ThriftTest.thrift + $(THRIFT) --gen php:json,nsglobal="Json" -r --out ./Resources/packages/phpjs Resources/ThriftTest.thrift + $(THRIFT) --gen php:classmap,server,rest,nsglobal="Classmap" -r --out ./Resources/packages/phpcm Resources/ThriftTest.thrift deps: $(top_srcdir)/composer.json composer install --working-dir=$(top_srcdir) diff --git a/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php b/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php index 46ed2ec69c0..d99edfa2e7b 100644 --- a/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php +++ b/lib/php/test/Unit/Lib/ClassLoader/ThriftClassLoaderTest.php @@ -25,10 +25,6 @@ use PHPUnit\Framework\TestCase; use Thrift\ClassLoader\ThriftClassLoader; -/*** - * This test depends on running the compiler against the ./Resources/ThriftTest.thrift file: - * lib/php/test$ ../../../compiler/cpp/thrift --gen php:classmap,server,rest -r --out ./Resources/packages/phpcm ./Resources/ThriftTest.thrift - */ class ThriftClassLoaderTest extends TestCase { use PHPMock; @@ -111,108 +107,4 @@ public function registerNamespaceDataProvider() 'apcuPrefix' => 'APCU_PREFIX', ]; } - - /** - * @dataProvider registerDefinitionDataProvider - */ - public function testRegisterDefinition( - $definitions, - $class, - $checkInterfaceExist = false, - $useApcu = false, - $apcuPrefix = null - ) { - $this->getFunctionMock('Thrift\ClassLoader', 'apcu_fetch') - ->expects($useApcu ? $this->once() : $this->never()) - ->with($apcuPrefix . $class) - ->willReturn(false); - - $this->getFunctionMock('Thrift\ClassLoader', 'apcu_store') - ->expects($useApcu ? $this->once() : $this->never()) - ->with($apcuPrefix . $class, $this->anything()) - ->willReturn(true); - - $loader = new ThriftClassLoader($useApcu, $apcuPrefix); - foreach ($definitions as $namespace => $paths) { - $loader->registerDefinition($namespace, $paths); - } - $loader->register(); - - $loader->loadClass($class); - if ($checkInterfaceExist) { - $this->assertTrue(interface_exists($class, false), "->loadClass() loads '$class'"); - } else { - $this->assertTrue(class_exists($class, false), "->loadClass() loads '$class'"); - } - } - - public function registerDefinitionDataProvider() - { - yield 'loadType' => [ - 'definitions' => [ - 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', - ], - 'class' => 'ThriftTest\Xtruct', - ]; - yield 'loadInterface' => [ - 'definitions' => [ - 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', - ], - 'class' => '\ThriftTest\ThriftTestIf', - 'checkInterfaceExist' => true, - ]; - yield 'loadClient' => [ - 'definitions' => [ - 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', - ], - 'class' => '\ThriftTest\ThriftTestClient', - ]; - yield 'loadProcessor' => [ - 'definitions' => [ - 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', - ], - 'class' => '\ThriftTest\ThriftTestProcessor', - ]; - yield 'loadRest' => [ - 'definitions' => [ - 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', - ], - 'class' => '\ThriftTest\ThriftTestRest', - ]; - yield 'load_args' => [ - 'definitions' => [ - 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', - ], - 'class' => '\ThriftTest\ThriftTest_testVoid_args', - ]; - yield 'load_result' => [ - 'definitions' => [ - 'ThriftTest' => __DIR__ . '/../../../Resources/packages/phpcm', - ], - 'class' => '\ThriftTest\ThriftTest_testVoid_result', - ]; - yield 'pathAsArray' => [ - 'definitions' => [ - 'ThriftTest' => [__DIR__ . '/../../../Resources/packages/phpcm'], - ], - 'class' => 'ThriftTest\Xtruct', - ]; - yield 'severalDefinitions' => [ - 'definitions' => [ - 'ThriftTest' => [__DIR__ . '/../../../Resources/packages/phpcm'], - 'TestValidators' => [__DIR__ . '/../../../Resources/packages/phpcm'], - ], - 'class' => '\TestValidators\TestServiceClient', - ]; - yield 'useApcu' => [ - 'definitions' => [ - 'ThriftTest' => [__DIR__ . '/../../../Resources/packages/phpcm'], - 'TestValidators' => [__DIR__ . '/../../../Resources/packages/phpcm'], - ], - 'class' => '\TestValidators\TestServiceClient', - 'checkInterfaceExist' => false, - 'useApcu' => true, - 'apcuPrefix' => 'APCU_PREFIX', - ]; - } } diff --git a/lib/php/test/Unit/Lib/Protocol/TBinaryProtocolAcceleratedTest.php b/lib/php/test/Unit/Lib/Protocol/TBinaryProtocolAcceleratedTest.php new file mode 100644 index 00000000000..4a82a5af040 --- /dev/null +++ b/lib/php/test/Unit/Lib/Protocol/TBinaryProtocolAcceleratedTest.php @@ -0,0 +1,73 @@ +assertInstanceOf($expectedTransport, $protocol->getTransport()); + } + + public function constructDataProvider() + { + yield 'not buffered transport' => [ + 'transport' => new TMemoryBuffer(), + 'expectedTransport' => TMemoryBuffer::class, + ]; + yield 'buffered transport' => [ + 'transport' => new TSocket(), + 'expectedTransport' => TBufferedTransport::class, + ]; + } + + /** + * @dataProvider strictParamsDataProvider + */ + public function testStrictParams($strictRead, $strictWrite) + { + $protocol = new TBinaryProtocolAccelerated(new TMemoryBuffer(), $strictRead, $strictWrite); + $this->assertEquals($strictRead, $protocol->isStrictRead()); + $this->assertEquals($strictWrite, $protocol->isStrictWrite()); + } + + public function strictParamsDataProvider() + { + yield 'strict read and write' => [true, true]; + yield 'not strict read and write' => [false, false]; + yield 'strict read and not strict write' => [true, false]; + yield 'not strict read and strict write' => [false, true]; + } +} diff --git a/lib/php/test/Unit/Lib/Protocol/TBinaryProtocolTest.php b/lib/php/test/Unit/Lib/Protocol/TBinaryProtocolTest.php new file mode 100644 index 00000000000..2648b556315 --- /dev/null +++ b/lib/php/test/Unit/Lib/Protocol/TBinaryProtocolTest.php @@ -0,0 +1,1009 @@ +createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, $strictWrite); + + $transport->expects($this->exactly(count($writeCallsParams))) + ->method('write') + ->withConsecutive(...$writeCallsParams) + ->willReturnOnConsecutiveCalls(...$writeCallsResults); + + $result = $protocol->writeMessageBegin($name, $type, $seqid); + $this->assertEquals($expectedResult, $result); + } + + public function writeMessageBeginDataProvider() + { + $type = TType::STRING; + $seqid = 555; + + yield 'strictWrite=true' => [ + 'strictWrite' => true, + 'name' => 'testName', + 'type' => $type, + 'seqid' => $seqid, + 'writeCallsParams' => [ + [pack('N', self::VERSION_1 | $type), 4], #writeI32 + [pack('N', strlen('testName')), 4], #writeStringLen + ['testName', 8], #writeString + [pack('N', $seqid), 4], #writeI32 + ], + 'writeCallsResults' => [ + 4, + 4, + 8, + 4, + ], + 'expectedResult' => 20, + ]; + + yield 'strictWrite=false' => [ + 'strictWrite' => false, + 'name' => 'testName', + 'type' => $type, + 'seqid' => $seqid, + 'writeCallsParams' => [ + [pack('N', strlen('testName')), 4], #writeStringLen + ['testName', 8], #writeString + [pack('c', $type), 1], #writeByte + [pack('N', $seqid), 4], #writeI32 + ], + 'writeCallsResults' => [ + 4, + 8, + 1, + 4, + ], + 'expectedResult' => 17, + ]; + } + + public function testWriteMessageEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->writeMessageEnd()); + } + + public function testWriteStructBegin() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->writeStructBegin('testName')); + } + + public function testWriteStructEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->writeStructEnd()); + } + + public function testWriteFieldBegin() + { + $fieldName = 'testName'; + $fieldType = TType::STRING; + $fieldId = 555; + + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->exactly(2)) + ->method('write') + ->withConsecutive( + ...[ + [pack('c', $fieldType), 1], #writeByte + [pack('n', $fieldId), 2], #writeI16 + ] + )->willReturnOnConsecutiveCalls([1, 2]); + + $this->assertEquals(3, $protocol->writeFieldBegin($fieldName, $fieldType, $fieldId)); + } + + public function testWriteFieldEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->writeFieldEnd()); + } + + public function testWriteFieldStop() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('write') + ->with(pack('c', TType::STOP), 1) #writeByte + ->willReturn(1); + + $this->assertEquals(1, $protocol->writeFieldStop()); + } + + public function testWriteMapBegin() + { + $keyType = TType::I32; + $valType = TType::STRING; + $size = 99; + + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->exactly(3)) + ->method('write') + ->withConsecutive( + ...[ + [pack('c', $keyType), 1], #writeByte + [pack('c', $valType), 1], #writeByte + [pack('N', $size), 4], #writeI32 + ] + )->willReturnOnConsecutiveCalls([1, 1, 4]); + + $this->assertEquals(6, $protocol->writeMapBegin($keyType, $valType, $size)); + } + + public function testWriteMapEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->writeMapEnd()); + } + + public function testWriteListBegin() + { + $elemType = TType::I32; + $size = 99; + + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->exactly(2)) + ->method('write') + ->withConsecutive( + ...[ + [pack('c', $elemType), 1], #writeByte + [pack('N', $size), 4], #writeI32 + ] + )->willReturnOnConsecutiveCalls([1, 4]); + + $this->assertEquals(5, $protocol->writeListBegin($elemType, $size)); + } + + public function testWriteListEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->writeListEnd()); + } + + public function testWriteSetBegin() + { + $elemType = TType::I32; + $size = 99; + + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->exactly(2)) + ->method('write') + ->withConsecutive( + ...[ + [pack('c', $elemType), 1], #writeByte + [pack('N', $size), 4], #writeI32 + ] + )->willReturnOnConsecutiveCalls([1, 4]); + + $this->assertEquals(5, $protocol->writeSetBegin($elemType, $size)); + } + + public function testWriteSetEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->writeSetEnd()); + } + + public function testWriteBool() + { + $value = true; + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('write') + ->with(pack('c', (int)$value), 1) #writeByte + ->willReturn(1); + + $this->assertEquals(1, $protocol->writeBool($value)); + } + + public function testWriteByte() + { + $value = 1; + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('write') + ->with(pack('c', $value), 1) #writeByte + ->willReturn(1); + + $this->assertEquals(1, $protocol->writeByte($value)); + } + + public function testWriteI16() + { + $value = 1; + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('write') + ->with(pack('n', $value), 2) #writeI16 + ->willReturn(2); + + $this->assertEquals(2, $protocol->writeI16($value)); + } + + public function testWriteI32() + { + $value = 1; + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('write') + ->with(pack('N', $value), 4) #writeI32 + ->willReturn(4); + + $this->assertEquals(4, $protocol->writeI32($value)); + } + + public function testWriteI64For32BitArchitecture() + { + if (PHP_INT_SIZE !== 4) { + $this->markTestSkipped('Test is only for 32 bit architecture'); + } + $value = 1; + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $neg = $value < 0; + + if ($neg) { + $value *= -1; + } + + $hi = (int)($value / 4294967296); + $lo = (int)$value; + + if ($neg) { + $hi = ~$hi; + $lo = ~$lo; + if (($lo & (int)0xffffffff) == (int)0xffffffff) { + $lo = 0; + $hi++; + } else { + $lo++; + } + } + + $transport + ->expects($this->once()) + ->method('write') + ->with(pack('N2', $hi, $lo), 8) #writeI64 + ->willReturn(4); + + $this->assertEquals(8, $protocol->writeI64($value)); + } + + public function testWriteI64For64BitArchitecture() + { + if (PHP_INT_SIZE == 4) { + $this->markTestSkipped('Test is only for 64 bit architecture'); + } + $value = 1; + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $hi = $value >> 32; + $lo = $value & 0xFFFFFFFF; + + $transport + ->expects($this->once()) + ->method('write') + ->with(pack('N2', $hi, $lo), 8) #writeI64 + ->willReturn(8); + + $this->assertEquals(8, $protocol->writeI64($value)); + } + + public function testWriteDouble() + { + $value = 1; + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('write') + ->with(strrev(pack('d', $value)), 8) #writeDouble + ->willReturn(8); + + $this->assertEquals(8, $protocol->writeDouble($value)); + } + + public function testWriteString() + { + $value = 'string'; + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->exactly(2)) + ->method('write') + ->withConsecutive( + ...[ + [pack('N', strlen($value))], #writeI32, + [$value, strlen($value)], #write, + ] + )->willReturnOnConsecutiveCalls([4, 6]); + + $this->assertEquals(10, $protocol->writeString($value)); + } + + /** + * @dataProvider readMessageBeginDataProvider + */ + public function testReadMessageBegin( + $strictRead, + $readCallsParams, + $readCallsResults, + $expectedReadLengthResult, + $expectedName, + $expectedType, + $expectedSeqid, + $expectedException = null, + $expectedExceptionMessage = null, + $expectedExceptionCode = null + ) { + if ($expectedException) { + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedExceptionMessage); + $this->expectExceptionCode($expectedExceptionCode); + } + + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, $strictRead, true); + + $transport->expects($this->exactly(count($readCallsParams))) + ->method('readAll') + ->withConsecutive(...$readCallsParams) + ->willReturnOnConsecutiveCalls(...$readCallsResults); + + $result = $protocol->readMessageBegin($name, $type, $seqid); + $this->assertEquals($expectedReadLengthResult, $result); + $this->assertEquals($expectedName, $name); + $this->assertEquals($expectedType, $type); + $this->assertEquals($expectedSeqid, $seqid); + } + + public function readMessageBeginDataProvider() + { + yield 'strictRead=true' => [ + 'strictRead' => true, + 'readCallsParams' => [ + [4], #readI32 + [4], #readStringLen + [8], #readString + [4], #readI32 + ], + 'readCallsResults' => [ + pack('N', 0x80010000 | TType::STRING), #version + pack('N', strlen('testName')), + 'testName', + pack('N', 555), + ], + 'expectedReadLengthResult' => 20, + 'expectedName' => 'testName', + 'expectedType' => TType::STRING, + 'expectedSeqid' => 555, + ]; + + yield 'incorrect version' => [ + 'strictRead' => true, + 'readCallsParams' => [ + [4], #readI32 + ], + 'readCallsResults' => [ + pack('N', 0x80000000 | TType::STRING), #version + ], + 'expectedReadLengthResult' => 4, + 'expectedName' => '', + 'expectedType' => 0, + 'expectedSeqid' => 0, + 'expectedException' => TProtocolException::class, + 'expectedExceptionMessage' => 'Bad version identifier: -2147483637', + 'expectedExceptionCode' => TProtocolException::BAD_VERSION, + ]; + + yield 'strictRead=false' => [ + 'strictRead' => false, + 'readCallsParams' => [ + [4], #readStringLen + [8], #readString + [1], #readByte + [4], #readI32 + ], + 'readCallsResults' => [ + pack('N', strlen('testName')), + 'testName', + pack('c', TType::STRING), + pack('N', 555), + ], + 'expectedReadLengthResult' => 17, + 'expectedName' => 'testName', + 'expectedType' => TType::STRING, + 'expectedSeqid' => 555, + ]; + + yield 'strictRead=true without version' => [ + 'strictRead' => true, + 'readCallsParams' => [ + [4], #readStringLen + ], + 'readCallsResults' => [ + pack('N', strlen('testName')), + ], + 'expectedReadLengthResult' => 17, + 'expectedName' => 'testName', + 'expectedType' => TType::STRING, + 'expectedSeqid' => 555, + 'expectedException' => TProtocolException::class, + 'expectedExceptionMessage' => 'No version identifier, old protocol client?', + 'expectedExceptionCode' => TProtocolException::BAD_VERSION, + ]; + } + + public function testReadMessageEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->readMessageEnd()); + } + + public function testReadStructBegin() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->readStructBegin($name)); + $this->assertEquals('', $name); + } + + public function testReadStructEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->readStructEnd()); + } + + /** + * @dataProvider readFieldBeginDataProvider + */ + public function testReadFieldBegin( + $storedFieldType, + $readCallsParams, + $readCallsResults, + $expectedResult, + $expectedName, + $expectedFieldType, + $expectedFieldId + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->exactly(count($readCallsParams))) + ->method('readAll') + ->withConsecutive(...$readCallsParams) + ->willReturnOnConsecutiveCalls(...$readCallsResults); + + $this->assertEquals($expectedResult, $protocol->readFieldBegin($name, $fieldType, $fieldId)); + $this->assertEquals($expectedName, $name); + $this->assertEquals($expectedFieldType, $fieldType); + $this->assertEquals($expectedFieldId, $fieldId); + } + + public function readFieldBeginDataProvider() + { + yield 'default' => [ + 'storedFieldType' => TType::STRING, + 'readCallsParams' => [ + [1], #readByte + [2], #readI16 + ], + 'readCallsResults' => [ + pack('c', TType::STRING), + pack('n', 555), + ], + 'expectedResult' => 3, + 'exprectedName' => '', + 'expectedFieldType' => TType::STRING, + 'expectedFieldId' => 555, + ]; + + yield 'stop field' => [ + 'storedFieldType' => TType::STOP, + 'readCallsParams' => [ + [1], #readByte + ], + 'readCallsResults' => [ + pack('c', TType::STOP), + ], + 'expectedResult' => 1, + 'exprectedName' => '', + 'expectedFieldType' => 0, + 'expectedFieldId' => 0, + ]; + } + + public function testReadFieldEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->readFieldEnd()); + } + + public function testReadMapBegin() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->exactly(3)) + ->method('readAll') + ->withConsecutive( + ...[ + [1], #readByte + [1], #readByte + [4], #readI32 + ] + )->willReturnOnConsecutiveCalls( + pack('c', TType::I32), + pack('c', TType::STRING), + pack('N', 555) + ); + + $this->assertEquals(6, $protocol->readMapBegin($keyType, $valType, $size)); + $this->assertEquals(TType::I32, $keyType); + $this->assertEquals(TType::STRING, $valType); + $this->assertEquals(555, $size); + } + + public function testReadMapEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->readMapEnd()); + } + + public function testReadListBegin() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->exactly(2)) + ->method('readAll') + ->withConsecutive( + ...[ + [1], #readByte + [4], #readI32 + ] + )->willReturnOnConsecutiveCalls( + pack('c', TType::I32), + pack('N', 555) + ); + + $this->assertEquals(5, $protocol->readListBegin($elemType, $size)); + $this->assertEquals(TType::I32, $elemType); + $this->assertEquals(555, $size); + } + + public function testReadListEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->readListEnd()); + } + + public function testReadSetBegin() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->exactly(2)) + ->method('readAll') + ->withConsecutive( + ...[ + [1], #readByte + [4], #readI32 + ] + )->willReturnOnConsecutiveCalls( + pack('c', TType::I32), + pack('N', 555) + ); + + $this->assertEquals(5, $protocol->readSetBegin($elemType, $size)); + $this->assertEquals(TType::I32, $elemType); + $this->assertEquals(555, $size); + } + + public function testReadSetEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $this->assertEquals(0, $protocol->readSetEnd()); + } + + public function testReadBool() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('readAll') + ->with(1) #readByte + ->willReturn(pack('c', 1)); + + $this->assertEquals(1, $protocol->readBool($value)); + $this->assertTrue($value); + } + + public function testReadByte() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('readAll') + ->with(1) #readByte + ->willReturn(pack('c', 1)); + + $this->assertEquals(1, $protocol->readByte($value)); + $this->assertEquals(1, $value); + } + + /** + * @dataProvider readI16DataProvider + */ + public function testReadI16( + $storedValue, + $expectedValue + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('readAll') + ->with(2) #readI16 + ->willReturn(pack('n', $storedValue)); + + $this->assertEquals(2, $protocol->readI16($value)); + $this->assertEquals($expectedValue, $value); + } + + public function readI16DataProvider() + { + yield 'positive' => [1, 1]; + yield 'negative' => [-1, -1]; + } + + /** + * @dataProvider readI16DataProvider + */ + public function testReadI32( + $storedValue, + $expectedValue + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('readAll') + ->with(4) #readI32 + ->willReturn(pack('N', $storedValue)); + + $this->assertEquals(4, $protocol->readI32($value)); + $this->assertEquals($expectedValue, $value); + } + + public function readI32DataProvider() + { + yield 'positive' => [1, 1]; + yield 'negative' => [-1, -1]; + } + + /** + * @dataProvider readI64For32BitArchitectureDataProvider + */ + public function testReadI64For32BitArchitecture( + $storedValue, + $expectedValue + ) { + if (PHP_INT_SIZE !== 4) { + $this->markTestSkipped('Test is only for 32 bit architecture'); + } + + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $neg = $storedValue < 0; + + if ($neg) { + $storedValue *= -1; + } + + $hi = (int)($storedValue / 4294967296); + $lo = (int)$storedValue; + + if ($neg) { + $hi = ~$hi; + $lo = ~$lo; + if (($lo & (int)0xffffffff) == (int)0xffffffff) { + $lo = 0; + $hi++; + } else { + $lo++; + } + } + + $transport + ->expects($this->once()) + ->method('write') + ->with(pack('N2', $hi, $lo), 8) #writeI64 + ->willReturn(4); + + $this->assertEquals(8, $protocol->readI64($value)); + $this->assertEquals($expectedValue, $value); + } + + public function readI64For32BitArchitectureDataProvider() + { + $storedValueRepresent = function ($value) { + $neg = $value < 0; + + if ($neg) { + $value *= -1; + } + + $hi = (int)($value / 4294967296); + $lo = (int)$value; + + if ($neg) { + $hi = ~$hi; + $lo = ~$lo; + if (($lo & (int)0xffffffff) == (int)0xffffffff) { + $lo = 0; + $hi++; + } else { + $lo++; + } + } + + return pack('N2', $hi, $lo); + }; + + yield 'positive' => [ + 'storedValue' => $storedValueRepresent(1), + 'expectedValue' => 1, + ]; + + yield 'max' => [ + 'storedValue' => $storedValueRepresent(PHP_INT_MAX), + 'expectedValue' => PHP_INT_MAX, + ]; + + yield 'min' => [ + 'storedValue' => $storedValueRepresent(PHP_INT_MIN), + 'expectedValue' => PHP_INT_MIN, + ]; + + yield 'negative' => [ + 'storedValue' => $storedValueRepresent(-1), + 'expectedValue' => -1, + ]; + } + + /** + * @dataProvider readI64For64BitArchitectureDataProvider + */ + public function testReadI64For64BitArchitecture( + $storedValue, + $expectedValue + ) { + if (PHP_INT_SIZE == 4) { + $this->markTestSkipped('Test is only for 64 bit architecture'); + } + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('readAll') + ->with(8) #readI64 + ->willReturn($storedValue); + + $this->assertEquals(8, $protocol->readI64($value)); + $this->assertEquals($expectedValue, $value); + } + + public function readI64For64BitArchitectureDataProvider() + { + $storedValueRepresent = function ($value) { + $hi = $value >> 32; + $lo = $value & 0xFFFFFFFF; + + return pack('N2', $hi, $lo); + }; + + yield 'positive' => [ + 'storedValue' => $storedValueRepresent(1), + 'expectedValue' => 1, + ]; + + yield 'max' => [ + 'storedValue' => $storedValueRepresent(PHP_INT_MAX), + 'expectedValue' => PHP_INT_MAX, + ]; + + yield 'min' => [ + 'storedValue' => $storedValueRepresent(PHP_INT_MIN), + 'expectedValue' => PHP_INT_MIN, + ]; + + yield 'negative' => [ + 'storedValue' => $storedValueRepresent(-1), + 'expectedValue' => -1, + ]; + } + + public function testReadDouble() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->once()) + ->method('readAll') + ->with(8) #readDouble + ->willReturn(strrev(pack('d', 789))); + + $this->assertEquals(8, $protocol->readDouble($value)); + $this->assertEquals(789, $value); + } + + /** + * @dataProvider readStringDataProvider + */ + public function testReadString( + $readCallsParams, + $readCallsResults, + $expectedLength, + $expectedValue + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TBinaryProtocol($transport, false, false); + + $transport + ->expects($this->exactly(count($readCallsParams))) + ->method('readAll') + ->withConsecutive(...$readCallsParams) + ->willReturnOnConsecutiveCalls(...$readCallsResults); + + $this->assertEquals($expectedLength, $protocol->readString($value)); + $this->assertEquals($expectedValue, $value); + } + + public function readStringDataProvider() + { + $storedValue = ''; + yield 'empty' => [ + 'readCallsParams' => [ + [4] + ], + 'readCallsResults' => [ + pack('N', strlen($storedValue)) + ], + 'expectedLength' => 4, + 'expectedValue' => '', + ]; + + $storedValue = 'string'; + yield 'non-empty' => [ + 'readCallsParams' => [ + [4], + [strlen($storedValue)] + ], + 'readCallsResults' => [ + pack('N', strlen($storedValue)), + $storedValue + ], + 'expectedLength' => 10, + 'expectedValue' => 'string', + ]; + } +} diff --git a/lib/php/test/Unit/Lib/Protocol/TCompactProtocolTest.php b/lib/php/test/Unit/Lib/Protocol/TCompactProtocolTest.php new file mode 100644 index 00000000000..95f972cf268 --- /dev/null +++ b/lib/php/test/Unit/Lib/Protocol/TCompactProtocolTest.php @@ -0,0 +1,843 @@ +createMock(TTransport::class)); + $this->assertSame($expected, $protocol->toZigZag($n, $bits)); + } + + public function toZigZagDataProvider() + { + yield ['n' => 0, 'bits' => 16, 'expected' => 0]; + yield ['n' => -1, 'bits' => 16, 'expected' => 1]; + yield ['n' => 1, 'bits' => 16, 'expected' => 2]; + yield ['n' => -2, 'bits' => 16, 'expected' => 3]; + yield ['n' => 2, 'bits' => 16, 'expected' => 4]; + yield ['n' => -1, 'bits' => 32, 'expected' => 1]; + yield ['n' => 1, 'bits' => 32, 'expected' => 2]; + yield ['n' => -1, 'bits' => 64, 'expected' => 1]; + yield ['n' => 1, 'bits' => 64, 'expected' => 2]; + yield ['n' => -0x7fffffff, 'bits' => 64, 'expected' => 4294967293]; + yield ['n' => 0x7fffffff, 'bits' => 64, 'expected' => 4294967294]; + } + + /** + * @dataProvider fromZigZagDataProvider + */ + public function testFromZigZag( + $n, + $expected + ) { + $protocol = new TCompactProtocol($this->createMock(TTransport::class)); + $this->assertSame($expected, $protocol->fromZigZag($n)); + } + + public function fromZigZagDataProvider() + { + yield ['n' => 0, 'expected' => 0]; + yield ['n' => 1, 'expected' => -1]; + yield ['n' => 2, 'expected' => 1]; + yield ['n' => 3, 'expected' => -2]; + yield ['n' => 4, 'expected' => 2]; + yield ['n' => 4294967293, 'expected' => -0x7fffffff]; + yield ['n' => 4294967294, 'expected' => 0x7fffffff]; + } + + /** + * @dataProvider getVarintDataProvider + */ + public function testGetVarint( + $data, + $expected + ) { + $protocol = new TCompactProtocol($this->createMock(TTransport::class)); + $this->assertSame($expected, $protocol->getVarint($data)); + } + + public function getVarintDataProvider() + { + yield ['data' => 0, 'expected' => "\x00"]; + yield ['data' => 1, 'expected' => "\x01"]; + yield ['data' => 97, 'expected' => "a"]; + yield ['data' => 100, 'expected' => "d"]; + yield ['data' => 1000, 'expected' => "\xe8\x07"]; + } + + public function testWriteVarint() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport->expects($this->once()) + ->method('write') + ->with("\xe8\x07", 2); + + $protocol->writeVarint(1000); + } + + public function testReadVarint() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport->expects($this->exactly(2)) + ->method('readAll') + ->with(1) + ->willReturnOnConsecutiveCalls( + ...[ + "\xe8", + "\x07", + ] + ); + + $this->assertSame(2, $protocol->readVarint($result)); + $this->assertSame(1000, $result); + } + + public function testWriteMessageBegin() + { + $name = 'testName'; + $type = TType::STRING; + $seqid = 1; + + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport + ->expects($this->exactly(5)) + ->method('write') + ->withConsecutive( + ...[ + [pack('C', self::PROTOCOL_ID), 1], #protocal id + [pack('C', self::VERSION | ($type << TCompactProtocol::TYPE_SHIFT_AMOUNT)), 1], #version + ["\x01", 1], #seqid + ["\x08", 1], #field name length + ["testName", 8], #field name + ] + )->willReturnOnConsecutiveCalls( + 1, + 1, + 1, + 1, + 8 + ); + + $result = $protocol->writeMessageBegin($name, $type, $seqid); + $this->assertSame(12, $result); + + $ref = new \ReflectionClass($protocol); + $state = $ref->getProperty('state'); + $state->setAccessible(true); + $this->assertSame(self::STATE_VALUE_WRITE, $state->getValue($protocol)); + } + + public function testWriteMessageEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $this->assertSame(0, $protocol->writeMessageEnd()); + $ref = new \ReflectionClass($protocol); + $state = $ref->getProperty('state'); + $state->setAccessible(true); + $this->assertSame(self::STATE_CLEAR, $state->getValue($protocol)); + } + + public function testWriteStruct() + { + $name = 'testName'; + + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + $ref = new \ReflectionClass($protocol); + $state = $ref->getProperty('state'); + $state->setAccessible(true); + $lastFid = $ref->getProperty('lastFid'); + $lastFid->setAccessible(true); + $structs = $ref->getProperty('structs'); + $structs->setAccessible(true); + + $this->assertSame(0, $protocol->writeStructBegin($name)); + $this->assertSame([[self::STATE_CLEAR, 0]], $structs->getValue($protocol)); + $this->assertSame(self::STATE_FIELD_WRITE, $state->getValue($protocol)); + $this->assertSame(0, $lastFid->getValue($protocol)); + + $this->assertSame(0, $protocol->writeStructBegin($name)); + $this->assertSame(self::STATE_FIELD_WRITE, $state->getValue($protocol)); + $this->assertSame(0, $lastFid->getValue($protocol)); + $this->assertSame([[self::STATE_CLEAR, 0], [self::STATE_FIELD_WRITE, 0]], $structs->getValue($protocol)); + + $this->assertSame(0, $protocol->writeStructEnd()); + $this->assertSame(self::STATE_FIELD_WRITE, $state->getValue($protocol)); + $this->assertSame(0, $lastFid->getValue($protocol)); + $this->assertSame([[self::STATE_CLEAR, 0]], $structs->getValue($protocol)); + + $this->assertSame(0, $protocol->writeStructEnd()); + $this->assertSame(self::STATE_CLEAR, $state->getValue($protocol)); + $this->assertSame(0, $lastFid->getValue($protocol)); + $this->assertSame([], $structs->getValue($protocol)); + } + + public function testWriteFieldStop() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport->expects($this->once()) + ->method('write') + ->with("\x00", 1); + + $this->assertSame(1, $protocol->writeFieldStop()); + } + + /** + * @dataProvider writeFieldHeaderDataProvider + */ + public function testWriteFieldHeader( + $type, + $fid, + $writeCallParams, + $writeCallResult, + $expectedResult + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport + ->expects($this->exactly(count($writeCallParams))) + ->method('write') + ->withConsecutive(...$writeCallParams) + ->willReturnOnConsecutiveCalls(...$writeCallResult); + + $this->assertSame($expectedResult, $protocol->writeFieldHeader($type, $fid)); + } + + public function writeFieldHeaderDataProvider() + { + yield 'bool' => [ + 'type' => TType::BOOL, + 'fid' => 1, + 'writeCallParams' => [ + ["\x12", 1], #writeUByte(pack('C', ($delta << 4) | $type)), + ], + 'writeCallResult' => [ + 1, + ], + 'expectedResult' => 1, + ]; + yield 'list' => [ + 'type' => TType::LST, + 'fid' => 16, + 'writeCallParams' => [ + ["\x0f", 1], #writeUByte(pack('C', ($delta << 4) | $type)), + [" ", 1], #writeI16($fid), + ], + 'writeCallResult' => [ + 1, + ], + 'expectedResult' => 2, + ]; + } + + /** + * @dataProvider writeFieldBeginDataProvider + */ + public function testWriteFieldBegin( + $fieldName, + $fieldType, + $fieldId, + $writeCallParams, + $writeCallResult, + $expectedState, + $expectedBoolFid, + $expectedLastFid, + $expectedResult + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport + ->expects($this->exactly(count($writeCallParams))) + ->method('write') + ->withConsecutive(...$writeCallParams) + ->willReturnOnConsecutiveCalls(...$writeCallResult); + + $this->assertSame($expectedResult, $protocol->writeFieldBegin($fieldName, $fieldType, $fieldId)); + + $ref = new \ReflectionClass($protocol); + $state = $ref->getProperty('state'); + $state->setAccessible(true); + $boolFid = $ref->getProperty('boolFid'); + $boolFid->setAccessible(true); + $lastFid = $ref->getProperty('lastFid'); + $lastFid->setAccessible(true); + $this->assertSame($expectedState, $state->getValue($protocol)); + $this->assertSame($expectedBoolFid, $boolFid->getValue($protocol)); + $this->assertSame($expectedLastFid, $lastFid->getValue($protocol)); + } + + public function writeFieldBeginDataProvider() + { + yield 'bool' => [ + 'fieldName' => 'testName', + 'fieldType' => TType::BOOL, + 'fieldId' => 1, + 'writeCallParams' => [], + 'writeCallResult' => [], + 'expectedState' => self::STATE_BOOL_WRITE, + 'expectedBoolFid' => 1, + 'expectedLastFid' => 0, + 'expectedResult' => 0, + ]; + yield 'list' => [ + 'fieldName' => 'testName', + 'fieldType' => TType::LST, + 'fieldId' => 1, + 'writeCallParams' => [ + ["\x19", 1], #writeUByte(pack('C', ($delta << 4) | $type)), + ], + 'writeCallResult' => [ + 1, + ], + 'expectedState' => self::STATE_VALUE_WRITE, + 'expectedBoolFid' => null, + 'expectedLastFid' => 1, + 'expectedResult' => 1, + ]; + } + + public function testWriteFieldEnd() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $this->assertSame(0, $protocol->writeFieldEnd()); + + $ref = new \ReflectionClass($protocol); + $state = $ref->getProperty('state'); + $state->setAccessible(true); + $this->assertSame(self::STATE_FIELD_WRITE, $state->getValue($protocol)); + } + + /** + * @dataProvider writeCollectionDataProvider + */ + public function testWriteCollection( + $etype, + $size, + $writeCallParams, + $writeCallResult, + $expectedState, + $expectedContainers, + $expectedResult + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport + ->expects($this->exactly(count($writeCallParams))) + ->method('write') + ->withConsecutive(...$writeCallParams) + ->willReturnOnConsecutiveCalls(...$writeCallResult); + + $this->assertSame($expectedResult, $protocol->writeCollectionBegin($etype, $size)); + + $ref = new \ReflectionClass($protocol); + $state = $ref->getProperty('state'); + $state->setAccessible(true); + $containers = $ref->getProperty('containers'); + $containers->setAccessible(true); + $this->assertSame($expectedState, $state->getValue($protocol)); + $this->assertSame($expectedContainers, $containers->getValue($protocol)); + + $this->assertSame(0, $protocol->writeCollectionEnd()); + $this->assertSame(TCompactProtocol::STATE_CLEAR, $state->getValue($protocol)); + } + + public function writeCollectionDataProvider() + { + yield 'size < 14' => [ + 'etype' => TType::STRING, + 'size' => 1, + 'writeCallParams' => [ + ["\x18", 1], #writeUByte(pack('C', ($size << 4 | self::$ctypes[$etype])), + ], + 'writeCallResult' => [ + 1, + ], + 'expectedState' => self::STATE_CONTAINER_WRITE, + 'expectedContainers' => [ + 0 => 0, + ], + 'expectedResult' => 1, + ]; + yield 'size > 14' => [ + 'etype' => TType::STRING, + 'size' => 16, + 'writeCallParams' => [ + ["\xf8", 1], #writeUByte(pack('C', 0xf0 | self::$ctypes[$etype])), + ["\x10", 1], #writeVarint(16), + ], + 'writeCallResult' => [ + 1, + 1, + ], + 'expectedState' => self::STATE_CONTAINER_WRITE, + 'expectedContainers' => [ + 0 => 0, + ], + 'expectedResult' => 2, + ]; + } + + /** + * @dataProvider writeMapDataProvider + */ + public function testWriteMap( + $keyType, + $valType, + $size, + $writeCallParams, + $writeCallResult, + $expectedContainers, + $expectedResult + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport + ->expects($this->exactly(count($writeCallParams))) + ->method('write') + ->withConsecutive(...$writeCallParams) + ->willReturnOnConsecutiveCalls(...$writeCallResult); + + $this->assertSame($expectedResult, $protocol->writeMapBegin($keyType, $valType, $size)); + + $ref = new \ReflectionClass($protocol); + $containers = $ref->getProperty('containers'); + $containers->setAccessible(true); + $state = $ref->getProperty('state'); + $state->setAccessible(true); + $this->assertSame($expectedContainers, $containers->getValue($protocol)); + $this->assertSame(TCompactProtocol::STATE_CLEAR, $state->getValue($protocol)); + + $this->assertSame(0, $protocol->writeMapEnd()); + $this->assertSame(TCompactProtocol::STATE_CLEAR, $state->getValue($protocol)); + $this->assertSame([], $containers->getValue($protocol)); + } + + public function writeMapDataProvider() + { + yield 'size zero' => [ + 'keyType' => TType::STRING, + 'valType' => TType::STRING, + 'size' => 0, + 'writeCallParams' => [ + ["\x00", 1], #writeByte(0), + ], + 'writeCallResult' => [ + 1, + ], + 'expectedContainers' => [ + 0 => 0, + ], + 'expectedResult' => 1, + ]; + yield 'size non zero' => [ + 'keyType' => TType::STRING, + 'valType' => TType::STRING, + 'size' => 16, + 'writeCallParams' => [ + ["\x10", 1], #writeVarint(16), + ["\x88", 1], #writeUByte(pack('C', self::$ctypes[$key_type] << 4 | self::$ctypes[$val_type])), + ], + 'writeCallResult' => [ + 1, + 1, + ], + 'expectedContainers' => [ + 0 => 0, + ], + 'expectedResult' => 2, + ]; + } + + public function testWriteListBegin() + { + $protocol = $this->createPartialMock(TCompactProtocol::class, ['writeCollectionBegin']); + + $protocol->expects($this->once()) + ->method('writeCollectionBegin') + ->with(TType::STRING, 1) + ->willReturn(1); + + $this->assertSame(1, $protocol->writeListBegin(TType::STRING, 1)); + } + + public function testWriteListEnd() + { + $protocol = $this->createPartialMock(TCompactProtocol::class, ['writeCollectionEnd']); + + $protocol->expects($this->once()) + ->method('writeCollectionEnd') + ->willReturn(1); + + $this->assertSame(1, $protocol->writeListEnd()); + } + + public function testWriteSettBegin() + { + $protocol = $this->createPartialMock(TCompactProtocol::class, ['writeCollectionBegin']); + + $protocol->expects($this->once()) + ->method('writeCollectionBegin') + ->with(TType::STRING, 1) + ->willReturn(1); + + $this->assertSame(1, $protocol->writeSetBegin(TType::STRING, 1)); + } + + public function testWriteSetEnd() + { + $protocol = $this->createPartialMock(TCompactProtocol::class, ['writeCollectionEnd']); + + $protocol->expects($this->once()) + ->method('writeCollectionEnd') + ->willReturn(1); + + $this->assertSame(1, $protocol->writeSetEnd()); + } + + /** + * @dataProvider writeBinaryDataProvider + */ + public function testWriteBool( + $value, + $startState, + $writeCallParams, + $writeCallResult, + $expectedResult, + $expectedException, + $expectedExceptionMessage + ) { + if ($expectedException) { + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedExceptionMessage); + } + + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + if (!is_null($startState)) { + $ref = new \ReflectionClass($protocol); + $state = $ref->getProperty('state'); + $state->setAccessible(true); + $state->setValue($protocol, $startState); + } + + $transport + ->expects($this->exactly(count($writeCallParams))) + ->method('write') + ->withConsecutive(...$writeCallParams) + ->willReturnOnConsecutiveCalls(...$writeCallResult); + + $this->assertSame($expectedResult, $protocol->writeBool($value)); + } + + public function writeBinaryDataProvider() + { + yield 'invalid state' => [ + 'value' => true, + 'startState' => null, + 'writeCallParams' => [], + 'writeCallResult' => [], + 'expectedResult' => 0, + 'expectedException' => TProtocolException::class, + 'expectedExceptionMessage' => 'Invalid state in compact protocol', + ]; + + yield 'true' => [ + 'value' => true, + 'startState' => TCompactProtocol::STATE_BOOL_WRITE, + 'writeCallParams' => [ + ["\x01", 1], #writeByte + ["\x00", 1], #writeI16 + ], + 'writeCallResult' => [ + 1, + 1, + ], + 'expectedResult' => 2, + 'expectedException' => null, + 'expectedExceptionMessage' => null, + ]; + + yield 'false' => [ + 'value' => false, + 'startState' => TCompactProtocol::STATE_BOOL_WRITE, + 'writeCallParams' => [ + ["\x02", 1], #writeByte + ["\x00", 1], #writeI16 + ], + 'writeCallResult' => [ + 1, + 1, + ], + 'expectedResult' => 2, + 'expectedException' => null, + 'expectedExceptionMessage' => null, + ]; + + yield 'container true' => [ + 'value' => true, + 'startState' => TCompactProtocol::STATE_CONTAINER_WRITE, + 'writeCallParams' => [ + ["\x01", 1], #writeByte + ], + 'writeCallResult' => [ + 1, + ], + 'expectedResult' => 1, + 'expectedException' => null, + 'expectedExceptionMessage' => null, + ]; + } + + /** + * @dataProvider writeByteDataProvider + */ + public function testWriteByte( + $value, + $expectedWriteCallParam + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport->expects($this->once()) + ->method('write') + ->with($expectedWriteCallParam, 1); + + $this->assertSame(1, $protocol->writeByte($value)); + } + + public function writeByteDataProvider() + { + yield 'signed' => [ + 'value' => -1, + 'expectedWriteCallParam' => "\xff", + ]; + yield 'unsigned' => [ + 'value' => 1, + 'expectedWriteCallParam' => "\x01", + ]; + yield 'lowercase' => [ + 'value' => 'a', + 'expectedWriteCallParam' => "\x00", + ]; + yield 'upercase' => [ + 'value' => 'A', + 'expectedWriteCallParam' => "\x00", + ]; + } + + /** + * @dataProvider writeUByteDataProvider + */ + public function testWriteUByte( + $value, + $expectedWriteCallParam + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport->expects($this->once()) + ->method('write') + ->with($expectedWriteCallParam, 1); + + $this->assertSame(1, $protocol->writeUByte($value)); + } + + public function writeUByteDataProvider() + { + yield 'signed' => [ + 'value' => -1, + 'expectedWriteCallParam' => "\xff", + ]; + yield 'unsigned' => [ + 'value' => 1, + 'expectedWriteCallParam' => "\x01", + ]; + yield 'lowercase' => [ + 'value' => 'a', + 'expectedWriteCallParam' => "\x00", + ]; + yield 'upercase' => [ + 'value' => 'A', + 'expectedWriteCallParam' => "\x00", + ]; + } + + public function testWriteI16() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport->expects($this->once()) + ->method('write') + ->with("\x00", 1); + + $this->assertSame(1, $protocol->writeI16(0)); + } + + public function testWriteI32() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport->expects($this->once()) + ->method('write') + ->with("\x00", 1); + + $this->assertSame(1, $protocol->writeI32(0)); + } + + public function testWriteDouble() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport->expects($this->once()) + ->method('write') + ->with(pack('d', 0), 8); + + $this->assertSame(8, $protocol->writeDouble(0)); + } + + public function testWriteString() + { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport->expects($this->exactly(2)) + ->method('write') + ->withConsecutive( + ["\x04", 1], + ["test", 4] + ); + + $this->assertSame(5, $protocol->writeString('test')); + } + + /** + * @dataProvider writeI64DataProvider + */ + public function testWriteI64( + $value, + $expectedWriteCallParam, + $expectedResult + ) { + $transport = $this->createMock(TTransport::class); + $protocol = new TCompactProtocol($transport); + + $transport->expects($this->once()) + ->method('write') + ->with(...$expectedWriteCallParam); + + $this->assertSame($expectedResult, $protocol->writeI64($value)); + } + + public function writeI64DataProvider() + { + yield 'simple' => [ + 'value' => 0, + 'expectedWriteCallParam' => ["\x00", 1], + 'expectedResult' => 1, + ]; + yield 'negative' => [ + 'value' => -1, + 'expectedWriteCallParam' => ["\x01", 1], + 'expectedResult' => 1, + ]; + yield 'big' => [ + 'value' => 5000000000, + 'expectedWriteCallParam' => [hex2bin("80c8afa025"), 5], + 'expectedResult' => 5, + ]; + yield 'small' => [ + 'value' => -5000000000, + 'expectedWriteCallParam' => [hex2bin("ffc7afa025"), 5], + 'expectedResult' => 5, + ]; + yield 'max simple' => [ + 'value' => 0xffffffff, + 'expectedWriteCallParam' => [hex2bin("feffffff1f"), 5], + 'expectedResult' => 5, + ]; + } +} diff --git a/lib/php/test/Unit/Lib/Protocol/TMultiplexedProtocolTest.php b/lib/php/test/Unit/Lib/Protocol/TMultiplexedProtocolTest.php new file mode 100644 index 00000000000..970e3a946c6 --- /dev/null +++ b/lib/php/test/Unit/Lib/Protocol/TMultiplexedProtocolTest.php @@ -0,0 +1,85 @@ +createMock(TProtocol::class); + $multiplexedProtocol = new TMultiplexedProtocol($protocol, $serviceName); + + $protocol->expects($this->once()) + ->method('writeMessageBegin') + ->with($expectedName, $type, $seqid); + + $multiplexedProtocol->writeMessageBegin($name, $type, $seqid); + } + + public function writeMessageBeginDataProvider() + { + yield 'messageTypeCall' => [ + 'serviceName' => 'serviceName', + 'name' => 'testName', + 'type' => TMessageType::CALL, + 'seqid' => 1, + 'expectedName' => 'serviceName:testName' + ]; + yield 'messageTypeOneWay' => [ + 'serviceName' => 'serviceName', + 'name' => 'testName', + 'type' => TMessageType::ONEWAY, + 'seqid' => 1, + 'expectedName' => 'serviceName:testName' + ]; + yield 'messageTypeReply' => [ + 'serviceName' => 'serviceName', + 'name' => 'testName', + 'type' => TMessageType::REPLY, + 'seqid' => 1, + 'expectedName' => 'testName' + ]; + yield 'messageTypeException' => [ + 'serviceName' => 'serviceName', + 'name' => 'testName', + 'type' => TMessageType::EXCEPTION, + 'seqid' => 1, + 'expectedName' => 'testName' + ]; + + } +} diff --git a/lib/php/test/Unit/Lib/Protocol/TProtocolDecoratorTest.php b/lib/php/test/Unit/Lib/Protocol/TProtocolDecoratorTest.php new file mode 100644 index 00000000000..e5dbdb36b29 --- /dev/null +++ b/lib/php/test/Unit/Lib/Protocol/TProtocolDecoratorTest.php @@ -0,0 +1,96 @@ +createMock(TProtocol::class); + $decorator = new class ($concreteProtocol) extends TProtocolDecorator { + public function __construct(TProtocol $protocol) + { + parent::__construct($protocol); + } + }; + + $concreteProtocol->expects($this->once()) + ->method($methodName) + ->with(...$methodArguments); + + $decorator->$methodName(...$methodArguments); + } + + public function methodDecorationDataProvider() + { + yield 'writeMessageBegin' => ['writeMessageBegin', ['name', 'type', 'seqid']]; + yield 'writeMessageEnd' => ['writeMessageEnd', []]; + yield 'writeStructBegin' => ['writeStructBegin', ['name']]; + yield 'writeStructEnd' => ['writeStructEnd', []]; + yield 'writeFieldBegin' => ['writeFieldBegin', ['name', 'type', 'id']]; + yield 'writeFieldEnd' => ['writeFieldEnd', []]; + yield 'writeFieldStop' => ['writeFieldStop', []]; + yield 'writeMapBegin' => ['writeMapBegin', ['keyType', 'valType', 'size']]; + yield 'writeMapEnd' => ['writeMapEnd', []]; + yield 'writeListBegin' => ['writeListBegin', ['elemType', 'size']]; + yield 'writeListEnd' => ['writeListEnd', []]; + yield 'writeSetBegin' => ['writeSetBegin', ['elemType', 'size']]; + yield 'writeSetEnd' => ['writeSetEnd', []]; + yield 'writeBool' => ['writeBool', ['value']]; + yield 'writeByte' => ['writeByte', ['value']]; + yield 'writeI16' => ['writeI16', ['value']]; + yield 'writeI32' => ['writeI32', ['value']]; + yield 'writeI64' => ['writeI64', ['value']]; + yield 'writeDouble' => ['writeDouble', ['value']]; + yield 'writeString' => ['writeString', ['value']]; + yield 'readMessageBegin' => ['readMessageBegin', ['name', 'type', 'seqid']]; + yield 'readMessageEnd' => ['readMessageEnd', []]; + yield 'readStructBegin' => ['readStructBegin', ['name']]; + yield 'readStructEnd' => ['readStructEnd', []]; + yield 'readFieldBegin' => ['readFieldBegin', ['name', 'type', 'id']]; + yield 'readFieldEnd' => ['readFieldEnd', []]; + yield 'readMapBegin' => ['readMapBegin', ['keyType', 'valType', 'size']]; + yield 'readMapEnd' => ['readMapEnd', []]; + yield 'readListBegin' => ['readListBegin', ['elemType', 'size']]; + yield 'readListEnd' => ['readListEnd', []]; + yield 'readSetBegin' => ['readSetBegin', ['elemType', 'size']]; + yield 'readSetEnd' => ['readSetEnd', []]; + yield 'readBool' => ['readBool', ['value']]; + yield 'readByte' => ['readByte', ['value']]; + yield 'readI16' => ['readI16', ['value']]; + yield 'readI32' => ['readI32', ['value']]; + yield 'readI64' => ['readI64', ['value']]; + yield 'readDouble' => ['readDouble', ['value']]; + yield 'readString' => ['readString', ['value']]; + } +} diff --git a/lib/php/test/Unit/Lib/Protocol/TSimpleJSONProtocolTest.php b/lib/php/test/Unit/Lib/Protocol/TSimpleJSONProtocolTest.php new file mode 100644 index 00000000000..e4d005a45ae --- /dev/null +++ b/lib/php/test/Unit/Lib/Protocol/TSimpleJSONProtocolTest.php @@ -0,0 +1,133 @@ +expectException(TException::class); + $this->expectExceptionMessage("Not implemented"); + + $transport = $this->createMock(TTransport::class); + $protocol = new TSimpleJSONProtocol($transport); + $protocol->$methodName(...$methodArguments); + } + + public function readDataProvider() + { + yield 'readMessageBegin' => [ + 'methodName' => 'readMessageBegin', + 'methodArguments' => ['name', 'type', 'seqId'], + ]; + yield 'readMessageEnd' => [ + 'methodName' => 'readMessageEnd', + 'methodArguments' => [], + ]; + yield 'readStructBegin' => [ + 'methodName' => 'readStructBegin', + 'methodArguments' => ['name'], + ]; + yield 'readStructEnd' => [ + 'methodName' => 'readStructEnd', + 'methodArguments' => [], + ]; + yield 'readFieldBegin' => [ + 'methodName' => 'readFieldBegin', + 'methodArguments' => ['name', TType::STRING, 1], + ]; + yield 'readFieldEnd' => [ + 'methodName' => 'readFieldEnd', + 'methodArguments' => [], + ]; + yield 'readMapBegin' => [ + 'methodName' => 'readMapBegin', + 'methodArguments' => [TType::STRING, TType::STRING, 1], + ]; + yield 'readMapEnd' => [ + 'methodName' => 'readMapEnd', + 'methodArguments' => [], + ]; + yield 'readListBegin' => [ + 'methodName' => 'readListBegin', + 'methodArguments' => [TType::STRING, 1], + ]; + yield 'readListEnd' => [ + 'methodName' => 'readListEnd', + 'methodArguments' => [], + ]; + yield 'readSetBegin' => [ + 'methodName' => 'readSetBegin', + 'methodArguments' => [TType::STRING, 1], + ]; + yield 'readSetEnd' => [ + 'methodName' => 'readSetEnd', + 'methodArguments' => [], + ]; + yield 'readBool' => [ + 'methodName' => 'readBool', + 'methodArguments' => [true], + ]; + yield 'readByte' => [ + 'methodName' => 'readByte', + 'methodArguments' => [0x01], + ]; + yield 'readI16' => [ + 'methodName' => 'readI16', + 'methodArguments' => [1], + ]; + yield 'readI32' => [ + 'methodName' => 'readI32', + 'methodArguments' => [1], + ]; + yield 'readI64' => [ + 'methodName' => 'readI64', + 'methodArguments' => [1], + ]; + yield 'readDouble' => [ + 'methodName' => 'readDouble', + 'methodArguments' => [0.1], + ]; + yield 'readString' => [ + 'methodName' => 'readString', + 'methodArguments' => ['string'], + ]; + } +} diff --git a/lib/php/test/Unit/Lib/Serializer/TBinarySerializerTest.php b/lib/php/test/Unit/Lib/Serializer/TBinarySerializerTest.php new file mode 100644 index 00000000000..292f261892c --- /dev/null +++ b/lib/php/test/Unit/Lib/Serializer/TBinarySerializerTest.php @@ -0,0 +1,38 @@ +markTestIncomplete('Could not test static function which create instances during execution'); + } + + public function testDeserialize() + { + $this->markTestIncomplete('Could not test static function which create instances during execution'); + } +} diff --git a/lib/php/test/Unit/TJSONProtocolTest.php b/lib/php/test/Unit/TJSONProtocolTest.php deleted file mode 100644 index 9837803708b..00000000000 --- a/lib/php/test/Unit/TJSONProtocolTest.php +++ /dev/null @@ -1,514 +0,0 @@ -registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/php'); - $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/php'); - $loader->register(); - - Fixtures::populateTestArgs(); - TJSONProtocolFixtures::populateTestArgsJSON(); - } - - public function setUp(): void - { - $this->transport = new TMemoryBuffer(); - $this->protocol = new TJSONProtocol($this->transport); - $this->transport->open(); - } - - /** - * WRITE TESTS - */ - public function testVoidWrite() - { - $args = new \ThriftTest\ThriftTest_testVoid_args(); - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testVoid']; - - $this->assertEquals($expected, $actual); - } - - public function testString1Write() - { - $args = new \ThriftTest\ThriftTest_testString_args(); - $args->thing = Fixtures::$testArgs['testString1']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testString1']; - - $this->assertEquals($expected, $actual); - } - - public function testString2Write() - { - $args = new \ThriftTest\ThriftTest_testString_args(); - $args->thing = Fixtures::$testArgs['testString2']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testString2']; - - $this->assertEquals($expected, $actual); - } - - public function testDoubleWrite() - { - $args = new \ThriftTest\ThriftTest_testDouble_args(); - $args->thing = Fixtures::$testArgs['testDouble']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testDouble']; - - $this->assertEquals($expected, $actual); - } - - public function testByteWrite() - { - $args = new \ThriftTest\ThriftTest_testByte_args(); - $args->thing = Fixtures::$testArgs['testByte']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testByte']; - - $this->assertEquals($expected, $actual); - } - - public function testI32Write() - { - $args = new \ThriftTest\ThriftTest_testI32_args(); - $args->thing = Fixtures::$testArgs['testI32']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testI32']; - - $this->assertEquals($expected, $actual); - } - - public function testI64Write() - { - $args = new \ThriftTest\ThriftTest_testI64_args(); - $args->thing = Fixtures::$testArgs['testI64']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testI64']; - - $this->assertEquals($expected, $actual); - } - - public function testStructWrite() - { - $args = new \ThriftTest\ThriftTest_testStruct_args(); - $args->thing = Fixtures::$testArgs['testStruct']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testStruct']; - - $this->assertEquals($expected, $actual); - } - - public function testNestWrite() - { - $args = new \ThriftTest\ThriftTest_testNest_args(); - $args->thing = Fixtures::$testArgs['testNest']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testNest']; - - $this->assertEquals($expected, $actual); - } - - public function testMapWrite() - { - $args = new \ThriftTest\ThriftTest_testMap_args(); - $args->thing = Fixtures::$testArgs['testMap']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testMap']; - - $this->assertEquals($expected, $actual); - } - - public function testStringMapWrite() - { - $args = new \ThriftTest\ThriftTest_testStringMap_args(); - $args->thing = Fixtures::$testArgs['testStringMap']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testStringMap']; - - /* - * The $actual returns unescaped string. - * It is required to to decode then encode it again - * to get the expected escaped unicode. - */ - $this->assertEquals($expected, json_encode(json_decode($actual))); - } - - public function testSetWrite() - { - $args = new \ThriftTest\ThriftTest_testSet_args(); - $args->thing = Fixtures::$testArgs['testSet']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testSet']; - - $this->assertEquals($expected, $actual); - } - - public function testListWrite() - { - $args = new \ThriftTest\ThriftTest_testList_args(); - $args->thing = Fixtures::$testArgs['testList']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testList']; - - $this->assertEquals($expected, $actual); - } - - public function testEnumWrite() - { - $args = new \ThriftTest\ThriftTest_testEnum_args(); - $args->thing = Fixtures::$testArgs['testEnum']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testEnum']; - - $this->assertEquals($expected, $actual); - } - - public function testTypedefWrite() - { - $args = new \ThriftTest\ThriftTest_testTypedef_args(); - $args->thing = Fixtures::$testArgs['testTypedef']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testTypedef']; - - $this->assertEquals($expected, $actual); - } - - /** - * READ TESTS - */ - public function testVoidRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testVoid'] - ); - $args = new \ThriftTest\ThriftTest_testVoid_args(); - $result = $args->read($this->protocol); - - $this->assertEquals(0, $result); - } - - public function testString1Read() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testString1'] - ); - $args = new \ThriftTest\ThriftTest_testString_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testString1']; - - $this->assertEquals($expected, $actual); - } - - public function testString2Read() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testString2'] - ); - $args = new \ThriftTest\ThriftTest_testString_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testString2']; - - $this->assertEquals($expected, $actual); - } - - public function testString3Write() - { - $args = new \ThriftTest\ThriftTest_testString_args(); - $args->thing = Fixtures::$testArgs['testString3']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testString3']; - - $this->assertEquals($expected, $actual); - } - - public function testString4Write() - { - $args = new \ThriftTest\ThriftTest_testString_args(); - $args->thing = Fixtures::$testArgs['testUnicodeStringWithNonBMP']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TJSONProtocolFixtures::$testArgsJSON['testUnicodeStringWithNonBMP']; - - $this->assertEquals($expected, $actual); - } - - public function testDoubleRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testDouble'] - ); - $args = new \ThriftTest\ThriftTest_testDouble_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testDouble']; - - $this->assertEquals($expected, $actual); - } - - public function testByteRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testByte'] - ); - $args = new \ThriftTest\ThriftTest_testByte_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testByte']; - - $this->assertEquals($expected, $actual); - } - - public function testI32Read() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testI32'] - ); - $args = new \ThriftTest\ThriftTest_testI32_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testI32']; - - $this->assertEquals($expected, $actual); - } - - public function testI64Read() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testI64'] - ); - $args = new \ThriftTest\ThriftTest_testI64_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testI64']; - - $this->assertEquals($expected, $actual); - } - - public function testStructRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testStruct'] - ); - $args = new \ThriftTest\ThriftTest_testStruct_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testStruct']; - - $this->assertEquals($expected, $actual); - } - - public function testNestRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testNest'] - ); - $args = new \ThriftTest\ThriftTest_testNest_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testNest']; - - $this->assertEquals($expected, $actual); - } - - public function testMapRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testMap'] - ); - $args = new \ThriftTest\ThriftTest_testMap_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testMap']; - - $this->assertEquals($expected, $actual); - } - - public function testStringMapRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testStringMap'] - ); - $args = new \ThriftTest\ThriftTest_testStringMap_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testStringMap']; - - $this->assertEquals($expected, $actual); - } - - public function testSetRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testSet'] - ); - $args = new \ThriftTest\ThriftTest_testSet_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testSet']; - - $this->assertEquals($expected, $actual); - } - - public function testListRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testList'] - ); - $args = new \ThriftTest\ThriftTest_testList_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testList']; - - $this->assertEquals($expected, $actual); - } - - public function testEnumRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testEnum'] - ); - $args = new \ThriftTest\ThriftTest_testEnum_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testEnum']; - - $this->assertEquals($expected, $actual); - } - - public function testTypedefRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testTypedef'] - ); - $args = new \ThriftTest\ThriftTest_testTypedef_args(); - $args->read($this->protocol); - - $actual = $args->thing; - $expected = Fixtures::$testArgs['testTypedef']; - - $this->assertEquals($expected, $actual); - } - - public function testMapMapRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testMapMap'] - ); - $result = new \ThriftTest\ThriftTest_testMapMap_result(); - $result->read($this->protocol); - - $actual = $result->success; - $expected = Fixtures::$testArgs['testMapMapExpectedResult']; - - $this->assertEquals($expected, $actual); - } - - public function testInsanityRead() - { - $this->transport->write( - TJSONProtocolFixtures::$testArgsJSON['testInsanity'] - ); - $result = new \ThriftTest\ThriftTest_testInsanity_result(); - $result->read($this->protocol); - - $actual = $result->success; - $expected = Fixtures::$testArgs['testInsanityExpectedResult']; - - $this->assertEquals($expected, $actual); - } -} diff --git a/lib/php/test/Unit/TSimpleJSONProtocolTest.php b/lib/php/test/Unit/TSimpleJSONProtocolTest.php deleted file mode 100644 index 8e6a6d91743..00000000000 --- a/lib/php/test/Unit/TSimpleJSONProtocolTest.php +++ /dev/null @@ -1,247 +0,0 @@ -registerNamespace('ThriftTest', __DIR__ . '/../Resources/packages/php'); - $loader->registerDefinition('ThriftTest', __DIR__ . '/../Resources/packages/php'); - $loader->register(); - - Fixtures::populateTestArgs(); - TSimpleJSONProtocolFixtures::populateTestArgsSimpleJSON(); - } - - public function setUp(): void - { - $this->transport = new TMemoryBuffer(); - $this->protocol = new TSimpleJSONProtocol($this->transport); - $this->transport->open(); - } - - /** - * WRITE TESTS - */ - public function testVoidWrite() - { - $args = new \ThriftTest\ThriftTest_testVoid_args(); - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testVoid']; - - $this->assertEquals($expected, $actual); - } - - public function testString1Write() - { - $args = new \ThriftTest\ThriftTest_testString_args(); - $args->thing = Fixtures::$testArgs['testString1']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testString1']; - - $this->assertEquals($expected, $actual); - } - - public function testString2Write() - { - $args = new \ThriftTest\ThriftTest_testString_args(); - $args->thing = Fixtures::$testArgs['testString2']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testString2']; - - $this->assertEquals($expected, $actual); - } - - public function testDoubleWrite() - { - $args = new \ThriftTest\ThriftTest_testDouble_args(); - $args->thing = Fixtures::$testArgs['testDouble']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testDouble']; - - $this->assertEquals($expected, $actual); - } - - public function testByteWrite() - { - $args = new \ThriftTest\ThriftTest_testByte_args(); - $args->thing = Fixtures::$testArgs['testByte']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testByte']; - - $this->assertEquals($expected, $actual); - } - - public function testI32Write() - { - $args = new \ThriftTest\ThriftTest_testI32_args(); - $args->thing = Fixtures::$testArgs['testI32']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testI32']; - - $this->assertEquals($expected, $actual); - } - - public function testI64Write() - { - $args = new \ThriftTest\ThriftTest_testI64_args(); - $args->thing = Fixtures::$testArgs['testI64']; - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testI64']; - - $this->assertEquals($expected, $actual); - } - - public function testStructWrite() - { - $args = new \ThriftTest\ThriftTest_testStruct_args(); - $args->thing = Fixtures::$testArgs['testStruct']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testStruct']; - - $this->assertEquals($expected, $actual); - } - - public function testNestWrite() - { - $args = new \ThriftTest\ThriftTest_testNest_args(); - $args->thing = Fixtures::$testArgs['testNest']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testNest']; - - $this->assertEquals($expected, $actual); - } - - public function testMapWrite() - { - $args = new \ThriftTest\ThriftTest_testMap_args(); - $args->thing = Fixtures::$testArgs['testMap']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testMap']; - - $this->assertEquals($expected, $actual); - } - - public function testStringMapWrite() - { - $args = new \ThriftTest\ThriftTest_testStringMap_args(); - $args->thing = Fixtures::$testArgs['testStringMap']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testStringMap']; - - $this->assertEquals($expected, $actual); - } - - public function testSetWrite() - { - $args = new \ThriftTest\ThriftTest_testSet_args(); - $args->thing = Fixtures::$testArgs['testSet']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testSet']; - - $this->assertEquals($expected, $actual); - } - - public function testListWrite() - { - $args = new \ThriftTest\ThriftTest_testList_args(); - $args->thing = Fixtures::$testArgs['testList']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testList']; - - $this->assertEquals($expected, $actual); - } - - public function testEnumWrite() - { - $args = new \ThriftTest\ThriftTest_testEnum_args(); - $args->thing = Fixtures::$testArgs['testEnum']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testEnum']; - - $this->assertEquals($expected, $actual); - } - - public function testTypedefWrite() - { - $args = new \ThriftTest\ThriftTest_testTypedef_args(); - $args->thing = Fixtures::$testArgs['testTypedef']; - - $args->write($this->protocol); - - $actual = $this->transport->read(Fixtures::$bufsize); - $expected = TSimpleJSONProtocolFixtures::$testArgsJSON['testTypedef']; - - $this->assertEquals($expected, $actual); - } -} diff --git a/lib/php/test/bootstrap.php b/lib/php/test/bootstrap.php new file mode 100644 index 00000000000..c6291e51798 --- /dev/null +++ b/lib/php/test/bootstrap.php @@ -0,0 +1,16 @@ +registerNamespace('Basic', __DIR__ . '/Resources/packages/php'); +$loader->registerNamespace('Validate', __DIR__ . '/Resources/packages/phpv'); +$loader->registerNamespace('ValidateOop', __DIR__ . '/Resources/packages/phpvo'); +$loader->registerNamespace('Json', __DIR__ . '/Resources/packages/phpjs'); + +#do not load this namespace here, it will be loaded in ClassLoaderTest +//$loader->registerNamespace('Server', __DIR__ . '/Resources/packages/phpcm'); + +$loader->register(); diff --git a/test/php/Client.php b/test/php/Client.php new file mode 100644 index 00000000000..1cd424126e1 --- /dev/null +++ b/test/php/Client.php @@ -0,0 +1,26 @@ +registerDefinition('ThriftTest', __DIR__ . '/../../lib/php/test/Resources/packages/phpcm'); +$loader->register(); + + +$transport = new THttpClient('localhost', 80); + +$transport->setTimeoutSecs($this->timeoutSec); + +$transport->addHeaders($this->generateAuthHeader()); + +$protocol = new TCompactProtocol($transport); + +$transport->open(); + +$client = new \ThriftTest\ThriftTestClient($protocol); +$client->testVoid(); diff --git a/test/php/Handler.php b/test/php/Handler.php new file mode 100644 index 00000000000..5ca06a21d03 --- /dev/null +++ b/test/php/Handler.php @@ -0,0 +1,114 @@ +registerDefinition('ThriftTest', __DIR__ . '/../../lib/php/test/Resources/packages/phpcm'); +$loader->register(); + +$sslOptions = \stream_context_create( + [ + 'ssl' => [ + 'verify_peer' => false, + 'verify_peer_name' => false, + ], + ] +); + +require_once __DIR__ . '/Handler.php'; + +switch ($transport) { + case 'framed': + $serverTransportFactory = new \Thrift\Factory\TFramedTransportFactory(); + break; + default: + $serverTransportFactory = new \Thrift\Factory\TTransportFactory(); +} + +$serverTransport = new \Thrift\Server\TServerSocket('localhost', $port); +$handler = new Handler(); +$processor = new ThriftTest\ThriftTestProcessor($handler); + +$server = new \Thrift\Server\TSimpleServer( + $processor, + $serverTransport, + $serverTransportFactory, + $serverTransportFactory, + new \Thrift\Factory\TBinaryProtocolFactory(), + new \Thrift\Factory\TBinaryProtocolFactory() +); + +echo "Starting the Test server...\n"; +$server->serve(); diff --git a/test/php/test_php.ini b/test/php/test_php.ini index aeb67cbd411..5eecb329618 100644 --- a/test/php/test_php.ini +++ b/test/php/test_php.ini @@ -1,3 +1,3 @@ -extension=thrift_protocol.so -extension=json.so -extension=sockets.so +;extension=thrift_protocol.so +;extension=json.so +;extension=sockets.so diff --git a/test/tests.json b/test/tests.json index 7eb9f65b9dd..91aa767f35c 100644 --- a/test/tests.json +++ b/test/tests.json @@ -539,6 +539,31 @@ }, { "name": "php", + "server": { + "transports": [ + "buffered", + "framed" + ], + "sockets": [ + "ip" + ], + "protocols": [ + "binary", + "binary:accel", + "compact", + "json" + ], + "command": [ + "php", + "-dextension_dir=php_ext_dir", + "--php-ini=test_php.ini", + "--no-php-ini", + "-ddisplay_errors=stderr", + "-dlog_errors=0", + "-derror_reporting=E_ALL", + "TestServer.php" + ] + }, "client": { "timeout": 6, "transports": [ From 1a94bd26b69268a35f58022ba441e1a03936b3f0 Mon Sep 17 00:00:00 2001 From: CJCombrink Date: Thu, 14 Mar 2024 19:57:41 +0100 Subject: [PATCH 222/250] THRIFT-5766 Replace std::endl with "\n" Patch: Carel Combrink This closes #2943 --- .../thrift/generate/go_validator_generator.cc | 204 +- .../src/thrift/generate/t_c_glib_generator.cc | 1936 +++++++------- .../cpp/src/thrift/generate/t_cl_generator.cc | 56 +- .../src/thrift/generate/t_cpp_generator.cc | 1717 +++++++------ .../cpp/src/thrift/generate/t_d_generator.cc | 162 +- .../src/thrift/generate/t_dart_generator.cc | 503 ++-- .../src/thrift/generate/t_delphi_generator.cc | 1258 +++++---- .../src/thrift/generate/t_erl_generator.cc | 120 +- .../cpp/src/thrift/generate/t_generator.cc | 10 +- .../cpp/src/thrift/generate/t_go_generator.cc | 1444 +++++------ .../cpp/src/thrift/generate/t_go_generator.h | 2 - .../cpp/src/thrift/generate/t_gv_generator.cc | 46 +- .../src/thrift/generate/t_haxe_generator.cc | 826 +++--- .../src/thrift/generate/t_html_generator.cc | 136 +- .../src/thrift/generate/t_java_generator.cc | 2255 ++++++++--------- .../src/thrift/generate/t_javame_generator.cc | 1066 ++++---- .../cpp/src/thrift/generate/t_js_generator.cc | 835 +++--- .../src/thrift/generate/t_json_generator.cc | 18 +- .../src/thrift/generate/t_kotlin_generator.cc | 623 +++-- .../src/thrift/generate/t_lua_generator.cc | 292 ++- .../thrift/generate/t_markdown_generator.cc | 181 +- .../src/thrift/generate/t_netstd_generator.cc | 1208 ++++----- .../src/thrift/generate/t_netstd_generator.h | 22 +- .../src/thrift/generate/t_ocaml_generator.cc | 416 ++- .../cpp/src/thrift/generate/t_oop_generator.h | 4 +- .../src/thrift/generate/t_perl_generator.cc | 430 ++-- .../src/thrift/generate/t_php_generator.cc | 812 +++--- .../cpp/src/thrift/generate/t_py_generator.cc | 1084 ++++---- .../cpp/src/thrift/generate/t_rb_generator.cc | 212 +- .../cpp/src/thrift/generate/t_rs_generator.cc | 891 ++++--- .../cpp/src/thrift/generate/t_st_generator.cc | 170 +- .../src/thrift/generate/t_swift_generator.cc | 716 +++--- .../src/thrift/generate/t_xml_generator.cc | 15 +- .../src/thrift/generate/t_xsd_generator.cc | 76 +- .../t_netcore_generator_helpers_tests.cc | 10 +- contrib/fb303/TClientInfo.cpp | 4 +- contrib/fb303/cpp/ServiceTracker.cpp | 2 +- contrib/thrift_dump.cpp | 4 +- contrib/zeromq/test-client.cpp | 2 +- lib/c_glib/test/testthrifttestclient.cpp | 49 +- lib/c_glib/test/testthrifttestzlibclient.cpp | 49 +- .../src/thrift/async/TEvhttpClientChannel.cpp | 3 +- lib/cpp/src/thrift/async/TEvhttpServer.cpp | 7 +- .../src/thrift/transport/TFileTransport.cpp | 6 +- lib/cpp/test/Benchmark.cpp | 25 +- lib/cpp/test/OneWayHTTPTest.cpp | 9 +- lib/cpp/test/TMemoryBufferTest.cpp | 2 - lib/cpp/test/TServerSocketTest.cpp | 2 +- lib/cpp/test/ThrifttReadCheckTests.cpp | 2 - lib/cpp/test/concurrency/Tests.cpp | 70 +- lib/cpp/test/concurrency/ThreadFactoryTests.h | 26 +- lib/cpp/test/concurrency/ThreadManagerTests.h | 82 +- lib/cpp/test/concurrency/TimerManagerTests.h | 10 +- test/cpp/src/StressTest.cpp | 40 +- test/cpp/src/StressTestNonBlocking.cpp | 42 +- test/cpp/src/TestClient.cpp | 186 +- test/cpp/src/TestServer.cpp | 10 +- tutorial/cpp/CppClient.cpp | 18 +- tutorial/cpp/CppServer.cpp | 14 +- 59 files changed, 10171 insertions(+), 10249 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/go_validator_generator.cc b/compiler/cpp/src/thrift/generate/go_validator_generator.cc index 1f5a3ad6eca..0adff2ee984 100644 --- a/compiler/cpp/src/thrift/generate/go_validator_generator.cc +++ b/compiler/cpp/src/thrift/generate/go_validator_generator.cc @@ -82,19 +82,19 @@ void go_validator_generator::generate_field_validator(std::ostream& out, } if (type->is_enum()) { if (context.tgt[0] == '*') { - out << indent() << "if " << context.tgt.substr(1) << " != nil {" << endl; + out << indent() << "if " << context.tgt.substr(1) << " != nil {" << '\n'; indent_up(); } generate_enum_field_validator(out, context); if (context.tgt[0] == '*') { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } return; } else if (type->is_base_type()) { t_base_type::t_base tbase = ((t_base_type*)type)->get_base(); if (context.tgt[0] == '*') { - out << indent() << "if " << context.tgt.substr(1) << " != nil {" << endl; + out << indent() << "if " << context.tgt.substr(1) << " != nil {" << '\n'; indent_up(); } switch (tbase) { @@ -119,7 +119,7 @@ void go_validator_generator::generate_field_validator(std::ostream& out, } if (context.tgt[0] == '*') { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } return; } else if (type->is_list()) { @@ -146,7 +146,7 @@ void go_validator_generator::generate_enum_field_validator(std::ostream& out, if (key == "vt.in") { if (values.size() > 1) { std::string exist = GenID("_exist"); - out << indent() << "var " << exist << " bool" << endl; + out << indent() << "var " << exist << " bool" << '\n'; std::string src = GenID("_src"); out << indent() << src << " := []int64{"; @@ -162,19 +162,19 @@ void go_validator_generator::generate_enum_field_validator(std::ostream& out, } out << ")"; } - out << "}" << endl; + out << "}" << '\n'; - out << indent() << "for _, src := range " << src << " {" << endl; + out << indent() << "for _, src := range " << src << " {" << '\n'; indent_up(); - out << indent() << "if int64(" << context.tgt << ") == src {" << endl; + out << indent() << "if int64(" << context.tgt << ") == src {" << '\n'; indent_up(); - out << indent() << exist << " = true" << endl; - out << indent() << "break" << endl; + out << indent() << exist << " = true" << '\n'; + out << indent() << "break" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl; - out << indent() << "if " << exist << " == false {" << endl; + out << indent() << "}" << '\n'; + out << indent() << "if " << exist << " == false {" << '\n'; } else { out << indent() << "if int64(" << context.tgt << ") != int64("; if (values[0]->is_field_reference()) { @@ -182,18 +182,18 @@ void go_validator_generator::generate_enum_field_validator(std::ostream& out, } else { out << values[0]->get_enum()->get_value(); } - out << ") {" << endl; + out << ") {" << '\n'; } indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.in\", \"" << context.field_symbol << "\", \"" << context.field_symbol - << " not valid, rule vt.in check failed\")" << endl; + << " not valid, rule vt.in check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; if (values.size() > 1) { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } else if (key == "vt.not_in") { if (values.size() > 1) { @@ -211,11 +211,11 @@ void go_validator_generator::generate_enum_field_validator(std::ostream& out, } out << ")"; } - out << "}" << endl; + out << "}" << '\n'; - out << indent() << "for _, src := range " << src << " {" << endl; + out << indent() << "for _, src := range " << src << " {" << '\n'; indent_up(); - out << indent() << "if int64(" << context.tgt << ") == src {" << endl; + out << indent() << "if int64(" << context.tgt << ") == src {" << '\n'; } else { out << indent() << "if int64(" << context.tgt << ") == "; out << "int64("; @@ -224,18 +224,18 @@ void go_validator_generator::generate_enum_field_validator(std::ostream& out, } else { out << values[0]->get_enum()->get_value(); } - out << ") {" << endl; + out << ") {" << '\n'; } indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.not_in\", \"" << context.field_symbol << "\", \"" << context.field_symbol - << " not valid, rule vt.not_in check failed\")" << endl; + << " not valid, rule vt.not_in check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; if (values.size() > 1) { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } else if (key == "vt.defined_only") { if (values[0]->get_bool()) { @@ -243,14 +243,14 @@ void go_validator_generator::generate_enum_field_validator(std::ostream& out, } else { continue; } - out << "{" << endl; + out << "{" << '\n'; indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \"" << context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key - << " check failed\")" << endl; + << " check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } } @@ -276,14 +276,14 @@ void go_validator_generator::generate_bool_field_validator(std::ostream& out, } } } - out << "{" << endl; + out << "{" << '\n'; indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \"" << context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key - << " check failed\")" << endl; + << " check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } @@ -308,19 +308,19 @@ void go_validator_generator::generate_double_field_validator(std::ostream& out, } else { out << values[0]->get_double(); } - out << "{" << endl; + out << "{" << '\n'; indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \"" << context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key - << " check failed\")" << endl; + << " check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; continue; } else if (key == "vt.in") { if (values.size() > 1) { std::string exist = GenID("_exist"); - out << indent() << "var " << exist << " bool" << endl; + out << indent() << "var " << exist << " bool" << '\n'; std::string src = GenID("_src"); out << indent() << src << " := []float64{"; @@ -334,19 +334,19 @@ void go_validator_generator::generate_double_field_validator(std::ostream& out, out << (*it)->get_double(); } } - out << "}" << endl; + out << "}" << '\n'; - out << indent() << "for _, src := range " << src << " {" << endl; + out << indent() << "for _, src := range " << src << " {" << '\n'; indent_up(); - out << indent() << "if " << context.tgt << " == src {" << endl; + out << indent() << "if " << context.tgt << " == src {" << '\n'; indent_up(); - out << indent() << exist << " = true" << endl; - out << indent() << "break" << endl; + out << indent() << exist << " = true" << '\n'; + out << indent() << "break" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl; - out << indent() << "if " << exist << " == false {" << endl; + out << indent() << "}" << '\n'; + out << indent() << "if " << exist << " == false {" << '\n'; } else { out << indent() << "if " << context.tgt << " != "; if (values[0]->is_field_reference()) { @@ -354,16 +354,16 @@ void go_validator_generator::generate_double_field_validator(std::ostream& out, } else { out << values[0]->get_double(); } - out << "{" << endl; + out << "{" << '\n'; } indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.in\", \"" << context.field_symbol << "\", \"" << context.field_symbol - << " not valid, rule vt.in check failed\")" << endl; + << " not valid, rule vt.in check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else if (key == "vt.not_in") { if (values.size() > 1) { std::string src = GenID("_src"); @@ -378,11 +378,11 @@ void go_validator_generator::generate_double_field_validator(std::ostream& out, out << (*it)->get_double(); } } - out << "}" << endl; + out << "}" << '\n'; - out << indent() << "for _, src := range " << src << " {" << endl; + out << indent() << "for _, src := range " << src << " {" << '\n'; indent_up(); - out << indent() << "if " << context.tgt << " == src {" << endl; + out << indent() << "if " << context.tgt << " == src {" << '\n'; } else { out << indent() << "if " << context.tgt << " == "; if (values[0]->is_field_reference()) { @@ -390,18 +390,18 @@ void go_validator_generator::generate_double_field_validator(std::ostream& out, } else { out << values[0]->get_double(); } - out << "{" << endl; + out << "{" << '\n'; } indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.not_in\", \"" << context.field_symbol << "\", \"" << context.field_symbol - << " not valid, rule vt.not_in check failed\")" << endl; + << " not valid, rule vt.not_in check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; if (values.size() > 1) { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } } @@ -460,18 +460,18 @@ void go_validator_generator::generate_integer_field_validator(std::ostream& out, } else { out << values[0]->get_int(); } - out << "{" << endl; + out << "{" << '\n'; indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \"" << context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key - << " check failed\")" << endl; + << " check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else if (key == "vt.in") { if (values.size() > 1) { std::string exist = GenID("_exist"); - out << indent() << "var " << exist << " bool" << endl; + out << indent() << "var " << exist << " bool" << '\n'; std::string src = GenID("_src"); out << indent() << src << " := []"; @@ -499,19 +499,19 @@ void go_validator_generator::generate_integer_field_validator(std::ostream& out, out << (*it)->get_int(); } } - out << "}" << endl; + out << "}" << '\n'; - out << indent() << "for _, src := range " << src << " {" << endl; + out << indent() << "for _, src := range " << src << " {" << '\n'; indent_up(); - out << indent() << "if " << context.tgt << " == src {" << endl; + out << indent() << "if " << context.tgt << " == src {" << '\n'; indent_up(); - out << indent() << exist << " = true" << endl; - out << indent() << "break" << endl; + out << indent() << exist << " = true" << '\n'; + out << indent() << "break" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl; - out << indent() << "if " << exist << " == false {" << endl; + out << indent() << "}" << '\n'; + out << indent() << "if " << exist << " == false {" << '\n'; } else { out << indent() << "if " << context.tgt << " != "; if (values[0]->is_field_reference()) { @@ -531,15 +531,15 @@ void go_validator_generator::generate_integer_field_validator(std::ostream& out, } else { out << values[0]->get_int(); } - out << "{" << endl; + out << "{" << '\n'; } indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.in\", \"" << context.field_symbol << "\", \"" << context.field_symbol - << " not valid, rule vt.in check failed\")" << endl; + << " not valid, rule vt.in check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else if (key == "vt.not_in") { if (values.size() > 1) { std::string src = GenID("_src"); @@ -584,11 +584,11 @@ void go_validator_generator::generate_integer_field_validator(std::ostream& out, out << (*it)->get_int(); } } - out << "}" << endl; + out << "}" << '\n'; - out << indent() << "for _, src := range " << src << " {" << endl; + out << indent() << "for _, src := range " << src << " {" << '\n'; indent_up(); - out << indent() << "if " << context.tgt << " == src {" << endl; + out << indent() << "if " << context.tgt << " == src {" << '\n'; } else { out << indent() << "if " << context.tgt << " == "; if (values[0]->is_field_reference()) { @@ -608,18 +608,18 @@ void go_validator_generator::generate_integer_field_validator(std::ostream& out, } else { out << values[0]->get_int(); } - out << "{" << endl; + out << "{" << '\n'; } indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.not_in\", \"" << context.field_symbol << "\", \"" << context.field_symbol - << " not valid, rule vt.not_in check failed\")" << endl; + << " not valid, rule vt.not_in check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; if (values.size() > 1) { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } } @@ -635,7 +635,7 @@ void go_validator_generator::generate_string_field_validator(std::ostream& out, if (type->is_binary()) { target = GenID("_tgt"); out << indent() << target << " := " - << "string(" << context.tgt << ")" << endl; + << "string(" << context.tgt << ")" << '\n'; } for (auto it = context.rules.begin(); it != context.rules.end(); it++) { const std::vector& values = (*it)->get_values(); @@ -729,14 +729,14 @@ void go_validator_generator::generate_string_field_validator(std::ostream& out, } out << ")"; } - out << "{" << endl; + out << "{" << '\n'; indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \"" << context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key - << " check failed\")" << endl; + << " check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } @@ -764,19 +764,19 @@ void go_validator_generator::generate_list_field_validator(std::ostream& out, } else { out << values[0]->get_int(); } - out << "{" << endl; + out << "{" << '\n'; indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \"" << context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key - << " check failed\")" << endl; + << " check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else if (key == "vt.elem") { - out << indent() << "for i := 0; i < len(" << context.tgt << ");i++ {" << endl; + out << indent() << "for i := 0; i < len(" << context.tgt << ");i++ {" << '\n'; indent_up(); std::string src = GenID("_elem"); - out << indent() << src << " := " << context.tgt << "[i]" << endl; + out << indent() << src << " := " << context.tgt << "[i]" << '\n'; t_type* elem_type; if (context.type->is_list()) { elem_type = ((t_list*)context.type)->get_elem_type(); @@ -791,7 +791,7 @@ void go_validator_generator::generate_list_field_validator(std::ostream& out, std::vector{(*it)->get_inner()}}; generate_field_validator(out, ctx); indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } } @@ -815,17 +815,17 @@ void go_validator_generator::generate_map_field_validator(std::ostream& out, } else { out << values[0]->get_int(); } - out << "{" << endl; + out << "{" << '\n'; indent_up(); out << indent() << "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \"" << context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key - << " check failed\")" << endl; + << " check failed\")" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else if (key == "vt.key") { std::string src = GenID("_key"); - out << indent() << "for " << src << " := range " << context.tgt << " {" << endl; + out << indent() << "for " << src << " := range " << context.tgt << " {" << '\n'; indent_up(); generator_context ctx{context.field_symbol + ".key", "", @@ -835,10 +835,10 @@ void go_validator_generator::generate_map_field_validator(std::ostream& out, std::vector{(*it)->get_inner()}}; generate_field_validator(out, ctx); indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else if (key == "vt.value") { std::string src = GenID("_value"); - out << indent() << "for _, " << src << " := range " << context.tgt << " {" << endl; + out << indent() << "for _, " << src << " := range " << context.tgt << " {" << '\n'; indent_up(); generator_context ctx{context.field_symbol + ".value", "", @@ -848,7 +848,7 @@ void go_validator_generator::generate_map_field_validator(std::ostream& out, std::vector{(*it)->get_inner()}}; generate_field_validator(out, ctx); indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } } @@ -875,31 +875,31 @@ void go_validator_generator::generate_struct_field_validator(std::ostream& out, } if (generate_valid) { if (last_valid_rule == nullptr) { - out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << endl; + out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << '\n'; indent_up(); - out << indent() << "return err" << endl; + out << indent() << "return err" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else { const std::vector& values = last_valid_rule->get_values(); if (!values[0]->get_bool()) { - out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << endl; + out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << '\n'; indent_up(); - out << indent() << "return err" << endl; + out << indent() << "return err" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else if (values[0]->is_field_reference()) { out << indent() << "if !"; out << get_field_reference_name(values[0]->get_field_reference()); - out << "{" << endl; + out << "{" << '\n'; indent_up(); - out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << endl; + out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << '\n'; indent_up(); - out << indent() << "return err" << endl; + out << indent() << "return err" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } } diff --git a/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc b/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc index da25338493c..b5eb6032891 100644 --- a/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc @@ -39,8 +39,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /* forward declarations */ string initial_caps_to_underscores(string name); string underscores_to_initial_caps(string name); @@ -241,18 +239,18 @@ void t_c_glib_generator::init_generator() { f_types_impl_ << autogen_comment(); /* include inclusion guard */ - f_types_ << "#ifndef " << this->nspace_uc << program_name_uc << "_TYPES_H" << endl << "#define " - << this->nspace_uc << program_name_uc << "_TYPES_H" << endl << endl; + f_types_ << "#ifndef " << this->nspace_uc << program_name_uc << "_TYPES_H" << '\n' << "#define " + << this->nspace_uc << program_name_uc << "_TYPES_H" << '\n' << '\n'; /* include base types */ - f_types_ << "/* base includes */" << endl << "#include " << endl - << "#include " << endl - << "#include " << endl; + f_types_ << "/* base includes */" << '\n' << "#include " << '\n' + << "#include " << '\n' + << "#include " << '\n'; /* include other thrift includes */ const vector& includes = program_->get_includes(); if (!includes.empty()) { - f_types_ << "/* other thrift includes */" << endl; + f_types_ << "/* other thrift includes */" << '\n'; for (auto include : includes) { const std::string& include_nspace = include->get_namespace("c_glib"); @@ -260,32 +258,32 @@ void t_c_glib_generator::init_generator() { include_nspace.empty() ? "" : initial_caps_to_underscores(include_nspace) + "_"; f_types_ << "#include \"" << include_nspace_prefix - << initial_caps_to_underscores(include->get_name()) << "_types.h\"" << endl; + << initial_caps_to_underscores(include->get_name()) << "_types.h\"" << '\n'; } - f_types_ << endl; + f_types_ << '\n'; } /* include custom headers */ const vector& c_includes = program_->get_c_includes(); - f_types_ << "/* custom thrift includes */" << endl; + f_types_ << "/* custom thrift includes */" << '\n'; for (const auto & c_include : c_includes) { if (c_include[0] == '<') { - f_types_ << "#include " << c_include << endl; + f_types_ << "#include " << c_include << '\n'; } else { - f_types_ << "#include \"" << c_include << "\"" << endl; + f_types_ << "#include \"" << c_include << "\"" << '\n'; } } - f_types_ << endl; + f_types_ << '\n'; /* include math.h (for "INFINITY") in the implementation file, in case we encounter a struct with a member of type double */ - f_types_impl_ << endl << "#include " << endl; + f_types_impl_ << '\n' << "#include " << '\n'; // include the types file - f_types_impl_ << endl << "#include \"" << this->nspace_lc << program_name_u << "_types.h\"" - << endl << "#include " << endl << endl; + f_types_impl_ << '\n' << "#include \"" << this->nspace_lc << program_name_u << "_types.h\"" + << '\n' << "#include " << '\n' << '\n'; - f_types_ << "/* begin types */" << endl << endl; + f_types_ << "/* begin types */" << '\n' << '\n'; } /** @@ -295,7 +293,7 @@ void t_c_glib_generator::close_generator() { string program_name_uc = to_upper_case(initial_caps_to_underscores(program_name_)); /* end the header inclusion guard */ - f_types_ << "#endif /* " << this->nspace_uc << program_name_uc << "_TYPES_H */" << endl; + f_types_ << "#endif /* " << this->nspace_uc << program_name_uc << "_TYPES_H */" << '\n'; /* close output file */ f_types_.close(); @@ -313,7 +311,7 @@ void t_c_glib_generator::close_generator() { */ void t_c_glib_generator::generate_typedef(t_typedef* ttypedef) { f_types_ << indent() << "typedef " << type_name(ttypedef->get_type(), true) << " " << this->nspace - << ttypedef->get_symbolic() << ";" << endl << endl; + << ttypedef->get_symbolic() << ";" << '\n' << '\n'; } /** @@ -336,7 +334,7 @@ void t_c_glib_generator::generate_enum(t_enum* tenum) { string name = tenum->get_name(); string name_uc = to_upper_case(initial_caps_to_underscores(name)); - f_types_ << indent() << "enum _" << this->nspace << name << " {" << endl; + f_types_ << indent() << "enum _" << this->nspace << name << " {" << '\n'; indent_up(); @@ -349,7 +347,7 @@ void t_c_glib_generator::generate_enum(t_enum* tenum) { if (first) { first = false; } else { - f_types_ << "," << endl; + f_types_ << "," << '\n'; } f_types_ << indent() << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name(); @@ -357,19 +355,19 @@ void t_c_glib_generator::generate_enum(t_enum* tenum) { } indent_down(); - f_types_ << endl << "};" << endl << "typedef enum _" << this->nspace << name << " " - << this->nspace << name << ";" << endl << endl; + f_types_ << '\n' << "};" << '\n' << "typedef enum _" << this->nspace << name << " " + << this->nspace << name << ";" << '\n' << '\n'; - f_types_ << "/* return the name of the constant */" << endl; - f_types_ << "const char *" << endl; - f_types_ << "toString_" << name << "(int value); " << endl << endl; + f_types_ << "/* return the name of the constant */" << '\n'; + f_types_ << "const char *" << '\n'; + f_types_ << "toString_" << name << "(int value); " << '\n' << '\n'; ; - f_types_impl_ << "/* return the name of the constant */" << endl; - f_types_impl_ << "const char *" << endl; - f_types_impl_ << "toString_" << name << "(int value) " << endl; - f_types_impl_ << "{" << endl; - f_types_impl_ << " static __thread char buf[16] = {0};" << endl; - f_types_impl_ << " switch(value) {" << endl; + f_types_impl_ << "/* return the name of the constant */" << '\n'; + f_types_impl_ << "const char *" << '\n'; + f_types_impl_ << "toString_" << name << "(int value) " << '\n'; + f_types_impl_ << "{" << '\n'; + f_types_impl_ << " static __thread char buf[16] = {0};" << '\n'; + f_types_impl_ << " switch(value) {" << '\n'; std::set done; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); @@ -379,20 +377,20 @@ void t_c_glib_generator::generate_enum(t_enum* tenum) { f_types_impl_ << " case " << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name() << ":" << "return \"" << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name() - << "\";" << endl; + << "\";" << '\n'; } } - f_types_impl_ << " default: g_snprintf(buf, 16, \"%d\", value); return buf;" << endl; - f_types_impl_ << " }" << endl; - f_types_impl_ << "}" << endl << endl; + f_types_impl_ << " default: g_snprintf(buf, 16, \"%d\", value); return buf;" << '\n'; + f_types_impl_ << " }" << '\n'; + f_types_impl_ << "}" << '\n' << '\n'; } /** * Generates Thrift constants in C code. */ void t_c_glib_generator::generate_consts(vector consts) { - f_types_ << "/* constants */" << endl; - f_types_impl_ << "/* constants */" << endl; + f_types_ << "/* constants */" << '\n'; + f_types_impl_ << "/* constants */" << '\n'; vector::iterator c_iter; for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { @@ -404,17 +402,17 @@ void t_c_glib_generator::generate_consts(vector consts) { if (is_complex_type(type)) { f_types_ << type_name(type) << indent() << this->nspace_lc << name_lc - << "_constant();" << endl; + << "_constant();" << '\n'; } f_types_ << indent() << "#define " << this->nspace_uc << name_uc << " " - << constant_value(name_lc, type, value) << endl; + << constant_value(name_lc, type, value) << '\n'; generate_const_initializer(name_lc, type, value, true); } - f_types_ << endl; - f_types_impl_ << endl; + f_types_ << '\n'; + f_types_impl_ << '\n'; } /** @@ -439,7 +437,7 @@ void t_c_glib_generator::generate_consts(vector consts) { * // ... additional GObject boilerplate ... */ void t_c_glib_generator::generate_struct(t_struct* tstruct) { - f_types_ << "/* struct " << tstruct->get_name() << " */" << endl; + f_types_ << "/* struct " << tstruct->get_name() << " */" << '\n'; generate_object(tstruct); } @@ -463,21 +461,21 @@ void t_c_glib_generator::generate_service(t_service* tservice) { f_header_ << autogen_comment(); // add an inclusion guard - f_header_ << "#ifndef " << svcname_uc << "_H" << endl << "#define " << svcname_uc << "_H" << endl - << endl; + f_header_ << "#ifndef " << svcname_uc << "_H" << '\n' << "#define " << svcname_uc << "_H" << '\n' + << '\n'; // add standard includes - f_header_ << "#include " << endl << endl; - f_header_ << "#include \"" << this->nspace_lc << program_name_lc << "_types.h\"" << endl; + f_header_ << "#include " << '\n' << '\n'; + f_header_ << "#include \"" << this->nspace_lc << program_name_lc << "_types.h\"" << '\n'; // if we are inheriting from another service, include its header t_service* extends_service = tservice->get_extends(); if (extends_service != nullptr) { f_header_ << "#include \"" << this->nspace_lc << to_lower_case(initial_caps_to_underscores(extends_service->get_name())) << ".h\"" - << endl; + << '\n'; } - f_header_ << endl; + f_header_ << '\n'; // create the service implementation string f_service_name = get_out_dir() + filename + ".c"; @@ -487,9 +485,9 @@ void t_c_glib_generator::generate_service(t_service* tservice) { f_service_ << autogen_comment(); // include the headers - f_service_ << "#include " << endl << "#include " << endl - << "#include " << endl << "#include \"" - << filename << ".h\"" << endl << endl; + f_service_ << "#include " << '\n' << "#include " << '\n' + << "#include " << '\n' << "#include \"" + << filename << ".h\"" << '\n' << '\n'; // generate the service-helper classes generate_service_helpers(tservice); @@ -501,7 +499,7 @@ void t_c_glib_generator::generate_service(t_service* tservice) { generate_service_server(tservice); // end the header inclusion guard - f_header_ << "#endif /* " << svcname_uc << "_H */" << endl; + f_header_ << "#endif /* " << svcname_uc << "_H */" << '\n'; // close the files f_service_.close(); @@ -519,27 +517,27 @@ void t_c_glib_generator::generate_xception(t_struct* tstruct) { generate_object(tstruct); - f_types_ << "/* exception */" << endl - << "typedef enum" << endl - << "{" << endl; + f_types_ << "/* exception */" << '\n' + << "typedef enum" << '\n' + << "{" << '\n'; indent_up(); - f_types_ << indent() << this->nspace_uc << name_uc << "_ERROR_CODE" << endl; + f_types_ << indent() << this->nspace_uc << name_uc << "_ERROR_CODE" << '\n'; indent_down(); - f_types_ << "} " << this->nspace << name << "Error;" << endl - << endl + f_types_ << "} " << this->nspace << name << "Error;" << '\n' + << '\n' << "GQuark " << this->nspace_lc << name_lc - << "_error_quark (void);" << endl + << "_error_quark (void);" << '\n' << "#define " << this->nspace_uc << name_uc << "_ERROR (" - << this->nspace_lc << name_lc << "_error_quark())" << endl - << endl - << endl; + << this->nspace_lc << name_lc << "_error_quark())" << '\n' + << '\n' + << '\n'; - f_types_impl_ << "/* define the GError domain for exceptions */" << endl << "#define " + f_types_impl_ << "/* define the GError domain for exceptions */" << '\n' << "#define " << this->nspace_uc << name_uc << "_ERROR_DOMAIN \"" << this->nspace_lc << name_lc - << "_error_quark\"" << endl << "GQuark" << endl << this->nspace_lc << name_lc - << "_error_quark (void)" << endl << "{" << endl + << "_error_quark\"" << '\n' << "GQuark" << '\n' << this->nspace_lc << name_lc + << "_error_quark (void)" << '\n' << "{" << '\n' << " return g_quark_from_static_string (" << this->nspace_uc << name_uc - << "_ERROR_DOMAIN);" << endl << "}" << endl << endl; + << "_ERROR_DOMAIN);" << '\n' << "}" << '\n' << '\n'; } /******************** @@ -983,12 +981,12 @@ string t_c_glib_generator::constant_value_with_storage(string fname, ostringstream render; if (is_numeric(etype)) { render << " " << type_name(etype) << " *" << fname << " = " - << "g_new (" << base_type_name(etype) << ", 1);" << endl + << "g_new (" << base_type_name(etype) << ", 1);" << '\n' << " *" << fname << " = " << constant_value(fname, (t_type*)etype, value) << ";" - << endl; + << '\n'; } else { render << " " << type_name(etype) << " " << fname << " = " - << constant_value(fname, (t_type*)etype, value) << ";" << endl; + << constant_value(fname, (t_type*)etype, value) << ";" << '\n'; } return render.str(); } @@ -1037,22 +1035,22 @@ void t_c_glib_generator::generate_const_initializer(string name, initializers << " constant->" << v_iter->first->get_string() << " = " << constant_value(name + "_constant_" + field_name, field_type, - v_iter->second) << ";" << endl + v_iter->second) << ";" << '\n' << " constant->__isset_" << v_iter->first->get_string() - << " = TRUE;" << endl; + << " = TRUE;" << '\n'; } // implement the initializer f_types_impl_ << maybe_static << this->nspace << type->get_name() << " *" - << endl - << this->nspace_lc << name_lc << "_constant (void)" << endl; + << '\n' + << this->nspace_lc << name_lc << "_constant (void)" << '\n'; scope_up(f_types_impl_); f_types_impl_ << indent() << "static " << this->nspace << type->get_name() - << " *constant = NULL;" << endl - << indent() << "if (constant == NULL)" << endl; + << " *constant = NULL;" << '\n' + << indent() << "if (constant == NULL)" << '\n'; scope_up(f_types_impl_); f_types_impl_ << indent() << "constant = g_object_new (" << this->nspace_uc - << "TYPE_" << type_uc << ", NULL);" << endl + << "TYPE_" << type_uc << ", NULL);" << '\n' << initializers.str(); scope_down(f_types_impl_); @@ -1074,9 +1072,9 @@ void t_c_glib_generator::generate_const_initializer(string name, field_name = tmp(field_name); } - f_types_impl_ << indent() << "return constant;" << endl; + f_types_impl_ << indent() << "return constant;" << '\n'; scope_down(f_types_impl_); - f_types_impl_ << endl; + f_types_impl_ << '\n'; } else if (type->is_list()) { string list_type = "GPtrArray *"; string free_func @@ -1125,33 +1123,33 @@ void t_c_glib_generator::generate_const_initializer(string name, if (list_variable) { initializers << " " << type_name(etype) << " " << fname << " = " << constant_value(fname, (t_type*)etype, (*v_iter)) << ";" - << endl; + << '\n'; appenders << " " << list_appender << "(constant, " << fname << ");" - << endl; + << '\n'; } else { appenders << " " << list_appender << "(constant, " << constant_value(fname, (t_type*)etype, (*v_iter)) << ");" - << endl; + << '\n'; } } - f_types_impl_ << maybe_static << list_type << endl - << this->nspace_lc << name_lc << "_constant (void)" << endl; + f_types_impl_ << maybe_static << list_type << '\n' + << this->nspace_lc << name_lc << "_constant (void)" << '\n'; scope_up(f_types_impl_); f_types_impl_ << indent() << "static " << list_type << " constant = NULL;" - << endl - << indent() << "if (constant == NULL)" << endl; + << '\n' + << indent() << "if (constant == NULL)" << '\n'; scope_up(f_types_impl_); if (!initializers.str().empty()) { f_types_impl_ << initializers.str() - << endl; + << '\n'; } - f_types_impl_ << indent() << "constant = " << list_initializer << endl + f_types_impl_ << indent() << "constant = " << list_initializer << '\n' << appenders.str(); scope_down(f_types_impl_); - f_types_impl_ << indent() << "return constant;" << endl; + f_types_impl_ << indent() << "return constant;" << '\n'; scope_down(f_types_impl_); - f_types_impl_ << endl; + f_types_impl_ << '\n'; } else if (type->is_set()) { t_type* etype = ((t_set*)type)->get_elem_type(); const vector& val = value->get_list(); @@ -1164,22 +1162,22 @@ void t_c_glib_generator::generate_const_initializer(string name, string ptr = is_numeric(etype) ? "*" : ""; generate_const_initializer(fname, etype, (*v_iter)); initializers << constant_value_with_storage(fname, (t_type*)etype, *v_iter); - appenders << " g_hash_table_insert (constant, " << fname << ", 0);" << endl; + appenders << " g_hash_table_insert (constant, " << fname << ", 0);" << '\n'; } - f_types_impl_ << maybe_static << "GHashTable *" << endl - << this->nspace_lc << name_lc << "_constant (void)" << endl; + f_types_impl_ << maybe_static << "GHashTable *" << '\n' + << this->nspace_lc << name_lc << "_constant (void)" << '\n'; scope_up(f_types_impl_); - f_types_impl_ << indent() << "static GHashTable *constant = NULL;" << endl - << indent() << "if (constant == NULL)" << endl; + f_types_impl_ << indent() << "static GHashTable *constant = NULL;" << '\n' + << indent() << "if (constant == NULL)" << '\n'; scope_up(f_types_impl_); - f_types_impl_ << initializers.str() << endl - << indent() << "constant = " << generate_new_hash_from_type(etype, nullptr) << endl + f_types_impl_ << initializers.str() << '\n' + << indent() << "constant = " << generate_new_hash_from_type(etype, nullptr) << '\n' << appenders.str(); scope_down(f_types_impl_); - f_types_impl_ << indent() << "return constant;" << endl; + f_types_impl_ << indent() << "return constant;" << '\n'; scope_down(f_types_impl_); - f_types_impl_ << endl; + f_types_impl_ << '\n'; } else if (type->is_map()) { t_type* ktype = ((t_map*)type)->get_key_type(); t_type* vtype = ((t_map*)type)->get_val_type(); @@ -1197,22 +1195,22 @@ void t_c_glib_generator::generate_const_initializer(string name, initializers << constant_value_with_storage(kname, (t_type*)ktype, v_iter->first); initializers << constant_value_with_storage(vname, (t_type*)vtype, v_iter->second); - appenders << " g_hash_table_insert (constant, " << kname << ", " << vname << ");" << endl; + appenders << " g_hash_table_insert (constant, " << kname << ", " << vname << ");" << '\n'; } - f_types_impl_ << maybe_static << "GHashTable *" << endl - << this->nspace_lc << name_lc << "_constant (void)" << endl; + f_types_impl_ << maybe_static << "GHashTable *" << '\n' + << this->nspace_lc << name_lc << "_constant (void)" << '\n'; scope_up(f_types_impl_); - f_types_impl_ << indent() << "static GHashTable *constant = NULL;" << endl - << indent() << "if (constant == NULL)" << endl; + f_types_impl_ << indent() << "static GHashTable *constant = NULL;" << '\n' + << indent() << "if (constant == NULL)" << '\n'; scope_up(f_types_impl_); - f_types_impl_ << initializers.str() << endl - << indent() << "constant = " << generate_new_hash_from_type(ktype, vtype) << endl + f_types_impl_ << initializers.str() << '\n' + << indent() << "constant = " << generate_new_hash_from_type(ktype, vtype) << '\n' << appenders.str(); scope_down(f_types_impl_); - f_types_impl_ << indent() << "return constant;" << endl; + f_types_impl_ << indent() << "return constant;" << '\n'; scope_down(f_types_impl_); - f_types_impl_ << endl; + f_types_impl_ << '\n'; } } @@ -1303,13 +1301,13 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { string base_service_name_uc = to_upper_case(base_service_name_lc); // Generate the client interface dummy object in the header. - f_header_ << "/* " << service_name_ << " service interface */" << endl << "typedef struct _" + f_header_ << "/* " << service_name_ << " service interface */" << '\n' << "typedef struct _" << this->nspace << service_name_ << "If " << this->nspace << service_name_ << "If; " - << " /* dummy object */" << endl << endl; + << " /* dummy object */" << '\n' << '\n'; // Generate the client interface object in the header. - f_header_ << "struct _" << this->nspace << service_name_ << "IfInterface" << endl << "{" << endl - << " GTypeInterface parent;" << endl << endl; + f_header_ << "struct _" << this->nspace << service_name_ << "IfInterface" << '\n' << "{" << '\n' + << " GTypeInterface parent;" << '\n' << '\n'; /* write out the functions for this interface */ indent_up(); @@ -1330,26 +1328,26 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { + (has_args ? "" : (", " + argument_list(arglist))) + (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError **error)"; - indent(f_header_) << "gboolean (*" << funname << ") " << params << ";" << endl; + indent(f_header_) << "gboolean (*" << funname << ") " << params << ";" << '\n'; } indent_down(); - f_header_ << "};" << endl << "typedef struct _" << this->nspace << service_name_ << "IfInterface " - << this->nspace << service_name_ << "IfInterface;" << endl << endl; + f_header_ << "};" << '\n' << "typedef struct _" << this->nspace << service_name_ << "IfInterface " + << this->nspace << service_name_ << "IfInterface;" << '\n' << '\n'; // generate all the interface boilerplate - f_header_ << "GType " << this->nspace_lc << service_name_lc << "_if_get_type (void);" << endl + f_header_ << "GType " << this->nspace_lc << service_name_lc << "_if_get_type (void);" << '\n' << "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_IF " - << "(" << this->nspace_lc << service_name_lc << "_if_get_type())" << endl << "#define " + << "(" << this->nspace_lc << service_name_lc << "_if_get_type())" << '\n' << "#define " << this->nspace_uc << service_name_uc << "_IF(obj) " << "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_IF, " << this->nspace << service_name_ << "If))" << endl + << service_name_uc << "_IF, " << this->nspace << service_name_ << "If))" << '\n' << "#define " << this->nspace_uc << "IS_" << service_name_uc << "_IF(obj) " << "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_IF))" << endl << "#define " << this->nspace_uc + << service_name_uc << "_IF))" << '\n' << "#define " << this->nspace_uc << service_name_uc << "_IF_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), " << this->nspace_uc << "TYPE_" << service_name_uc << "_IF, " << this->nspace - << service_name_ << "IfInterface))" << endl << endl; + << service_name_ << "IfInterface))" << '\n' << '\n'; // write out all the interface function prototypes for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -1368,50 +1366,50 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { + (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError **error)"; f_header_ << "gboolean " << this->nspace_lc << service_name_lc << "_if_" << funname << " " - << params << ";" << endl; + << params << ";" << '\n'; } - f_header_ << endl; + f_header_ << '\n'; // Generate the client object instance definition in the header. - f_header_ << "/* " << service_name_ << " service client */" << endl << "struct _" << this->nspace - << service_name_ << "Client" << endl << "{" << endl << " " << parent_class_name - << " parent;" << endl; + f_header_ << "/* " << service_name_ << " service client */" << '\n' << "struct _" << this->nspace + << service_name_ << "Client" << '\n' << "{" << '\n' << " " << parent_class_name + << " parent;" << '\n'; if (!extends_service) { // Define "input_protocol" and "output_protocol" properties only // for base services; child service-client classes will inherit // these - f_header_ << endl << " ThriftProtocol *input_protocol;" << endl - << " ThriftProtocol *output_protocol;" << endl; + f_header_ << '\n' << " ThriftProtocol *input_protocol;" << '\n' + << " ThriftProtocol *output_protocol;" << '\n'; } - f_header_ << "};" << endl << "typedef struct _" << this->nspace << service_name_ << "Client " - << this->nspace << service_name_ << "Client;" << endl << endl; + f_header_ << "};" << '\n' << "typedef struct _" << this->nspace << service_name_ << "Client " + << this->nspace << service_name_ << "Client;" << '\n' << '\n'; // Generate the class definition in the header. - f_header_ << "struct _" << this->nspace << service_name_ << "ClientClass" << endl << "{" << endl - << " " << parent_class_name << "Class parent;" << endl << "};" << endl + f_header_ << "struct _" << this->nspace << service_name_ << "ClientClass" << '\n' << "{" << '\n' + << " " << parent_class_name << "Class parent;" << '\n' << "};" << '\n' << "typedef struct _" << this->nspace << service_name_ << "ClientClass " << this->nspace - << service_name_ << "ClientClass;" << endl << endl; + << service_name_ << "ClientClass;" << '\n' << '\n'; // Create all the GObject boilerplate - f_header_ << "GType " << this->nspace_lc << service_name_lc << "_client_get_type (void);" << endl + f_header_ << "GType " << this->nspace_lc << service_name_lc << "_client_get_type (void);" << '\n' << "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT " - << "(" << this->nspace_lc << service_name_lc << "_client_get_type())" << endl + << "(" << this->nspace_lc << service_name_lc << "_client_get_type())" << '\n' << "#define " << this->nspace_uc << service_name_uc << "_CLIENT(obj) " << "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_CLIENT, " << this->nspace << service_name_ << "Client))" << endl + << service_name_uc << "_CLIENT, " << this->nspace << service_name_ << "Client))" << '\n' << "#define " << this->nspace_uc << service_name_uc << "_CLIENT_CLASS(c) " << "(G_TYPE_CHECK_CLASS_CAST ((c), " << this->nspace_uc << "TYPE_" << service_name_uc - << "_CLIENT, " << this->nspace << service_name_ << "ClientClass))" << endl << "#define " + << "_CLIENT, " << this->nspace << service_name_ << "ClientClass))" << '\n' << "#define " << this->nspace_uc << service_name_uc << "_IS_CLIENT(obj) " << "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_CLIENT))" << endl << "#define " << this->nspace_uc + << service_name_uc << "_CLIENT))" << '\n' << "#define " << this->nspace_uc << service_name_uc << "_IS_CLIENT_CLASS(c) " << "(G_TYPE_CHECK_CLASS_TYPE ((c), " << this->nspace_uc << "TYPE_" << service_name_uc - << "_CLIENT))" << endl << "#define " << this->nspace_uc << service_name_uc + << "_CLIENT))" << '\n' << "#define " << this->nspace_uc << service_name_uc << "_CLIENT_GET_CLASS(obj) " << "(G_TYPE_INSTANCE_GET_CLASS ((obj), " << this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " << this->nspace << service_name_ << "ClientClass))" - << endl << endl; + << '\n' << '\n'; /* write out the function prototypes */ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -1422,12 +1420,12 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { service_name_lc + string("_client_") + funname, (*f_iter)->get_arglist(), (*f_iter)->get_xceptions()); - indent(f_header_) << function_signature(&service_function) << ";" << endl; + indent(f_header_) << function_signature(&service_function) << ";" << '\n'; t_function send_function(g_type_void, service_name_lc + string("_client_send_") + funname, (*f_iter)->get_arglist()); - indent(f_header_) << function_signature(&send_function) << ";" << endl; + indent(f_header_) << function_signature(&send_function) << ";" << '\n'; // implement recv if not a oneway service if (!(*f_iter)->is_oneway()) { @@ -1436,19 +1434,19 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { service_name_lc + string("_client_recv_") + funname, &noargs, (*f_iter)->get_xceptions()); - indent(f_header_) << function_signature(&recv_function) << ";" << endl; + indent(f_header_) << function_signature(&recv_function) << ";" << '\n'; } } /* write out the get/set function prototypes */ f_header_ << "void " + service_name_lc + "_client_set_property (GObject *object, guint " "property_id, const GValue *value, GParamSpec *pspec);" - << endl; + << '\n'; f_header_ << "void " + service_name_lc + "_client_get_property (GObject *object, guint " "property_id, GValue *value, GParamSpec *pspec);" - << endl; + << '\n'; - f_header_ << endl; + f_header_ << '\n'; // end of header code // Generate interface method implementations @@ -1483,76 +1481,76 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { params_without_type += ", "; } - f_service_ << "gboolean" << endl << this->nspace_lc << service_name_lc << "_if_" << funname - << " " << params << endl << "{" << endl << " return " << this->nspace_uc + f_service_ << "gboolean" << '\n' << this->nspace_lc << service_name_lc << "_if_" << funname + << " " << params << '\n' << "{" << '\n' << " return " << this->nspace_uc << service_name_uc << "_IF_GET_INTERFACE (iface)->" << funname << " (" - << params_without_type << "error);" << endl << "}" << endl << endl; + << params_without_type << "error);" << '\n' << "}" << '\n' << '\n'; } // Generate interface boilerplate - f_service_ << "GType" << endl << this->nspace_lc << service_name_lc << "_if_get_type (void)" - << endl << "{" << endl << " static GType type = 0;" << endl << " if (type == 0)" - << endl << " {" << endl << " static const GTypeInfo type_info =" << endl << " {" - << endl << " sizeof (" << this->nspace << service_name_ << "IfInterface)," << endl - << " NULL, /* base_init */" << endl << " NULL, /* base_finalize */" << endl - << " NULL, /* class_init */" << endl << " NULL, /* class_finalize */" - << endl << " NULL, /* class_data */" << endl - << " 0, /* instance_size */" << endl << " 0, /* n_preallocs */" - << endl << " NULL, /* instance_init */" << endl - << " NULL /* value_table */" << endl << " };" << endl - << " type = g_type_register_static (G_TYPE_INTERFACE," << endl + f_service_ << "GType" << '\n' << this->nspace_lc << service_name_lc << "_if_get_type (void)" + << '\n' << "{" << '\n' << " static GType type = 0;" << '\n' << " if (type == 0)" + << '\n' << " {" << '\n' << " static const GTypeInfo type_info =" << '\n' << " {" + << '\n' << " sizeof (" << this->nspace << service_name_ << "IfInterface)," << '\n' + << " NULL, /* base_init */" << '\n' << " NULL, /* base_finalize */" << '\n' + << " NULL, /* class_init */" << '\n' << " NULL, /* class_finalize */" + << '\n' << " NULL, /* class_data */" << '\n' + << " 0, /* instance_size */" << '\n' << " 0, /* n_preallocs */" + << '\n' << " NULL, /* instance_init */" << '\n' + << " NULL /* value_table */" << '\n' << " };" << '\n' + << " type = g_type_register_static (G_TYPE_INTERFACE," << '\n' << " \"" << this->nspace << service_name_ << "If\"," - << endl << " &type_info, 0);" << endl << " }" - << endl << " return type;" << endl << "}" << endl << endl; + << '\n' << " &type_info, 0);" << '\n' << " }" + << '\n' << " return type;" << '\n' << "}" << '\n' << '\n'; // Generate client boilerplate - f_service_ << "static void " << endl << this->nspace_lc << service_name_lc + f_service_ << "static void " << '\n' << this->nspace_lc << service_name_lc << "_if_interface_init (" << this->nspace << service_name_ << "IfInterface *iface);" - << endl << endl << "G_DEFINE_TYPE_WITH_CODE (" << this->nspace << service_name_ - << "Client, " << this->nspace_lc << service_name_lc << "_client," << endl - << " " << parent_type_name << ", " << endl + << '\n' << '\n' << "G_DEFINE_TYPE_WITH_CODE (" << this->nspace << service_name_ + << "Client, " << this->nspace_lc << service_name_lc << "_client," << '\n' + << " " << parent_type_name << ", " << '\n' << " G_IMPLEMENT_INTERFACE (" << this->nspace_uc << "TYPE_" - << service_name_uc << "_IF," << endl + << service_name_uc << "_IF," << '\n' << " " << this->nspace_lc - << service_name_lc << "_if_interface_init))" << endl << endl; + << service_name_lc << "_if_interface_init))" << '\n' << '\n'; // Generate property-related code only for base services---child // service-client classes have only properties inherited from their // parent class if (!extends_service) { // Generate client properties - f_service_ << "enum _" << this->nspace << service_name_ << "ClientProperties" << endl << "{" - << endl << " PROP_0," << endl << " PROP_" << this->nspace_uc << service_name_uc - << "_CLIENT_INPUT_PROTOCOL," << endl << " PROP_" << this->nspace_uc - << service_name_uc << "_CLIENT_OUTPUT_PROTOCOL" << endl << "};" << endl << endl; + f_service_ << "enum _" << this->nspace << service_name_ << "ClientProperties" << '\n' << "{" + << '\n' << " PROP_0," << '\n' << " PROP_" << this->nspace_uc << service_name_uc + << "_CLIENT_INPUT_PROTOCOL," << '\n' << " PROP_" << this->nspace_uc + << service_name_uc << "_CLIENT_OUTPUT_PROTOCOL" << '\n' << "};" << '\n' << '\n'; // generate property setter - f_service_ << "void" << endl << this->nspace_lc << service_name_lc << "_client_set_property (" + f_service_ << "void" << '\n' << this->nspace_lc << service_name_lc << "_client_set_property (" << "GObject *object, guint property_id, const GValue *value, " - << "GParamSpec *pspec)" << endl << "{" << endl << " " << this->nspace + << "GParamSpec *pspec)" << '\n' << "{" << '\n' << " " << this->nspace << service_name_ << "Client *client = " << this->nspace_uc << service_name_uc - << "_CLIENT (object);" << endl << endl << " THRIFT_UNUSED_VAR (pspec);" << endl - << endl << " switch (property_id)" << endl << " {" << endl << " case PROP_" - << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << endl - << " client->input_protocol = g_value_get_object (value);" << endl - << " break;" << endl << " case PROP_" << this->nspace_uc << service_name_uc - << "_CLIENT_OUTPUT_PROTOCOL:" << endl - << " client->output_protocol = g_value_get_object (value);" << endl - << " break;" << endl << " }" << endl << "}" << endl << endl; + << "_CLIENT (object);" << '\n' << '\n' << " THRIFT_UNUSED_VAR (pspec);" << '\n' + << '\n' << " switch (property_id)" << '\n' << " {" << '\n' << " case PROP_" + << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << '\n' + << " client->input_protocol = g_value_get_object (value);" << '\n' + << " break;" << '\n' << " case PROP_" << this->nspace_uc << service_name_uc + << "_CLIENT_OUTPUT_PROTOCOL:" << '\n' + << " client->output_protocol = g_value_get_object (value);" << '\n' + << " break;" << '\n' << " }" << '\n' << "}" << '\n' << '\n'; // generate property getter - f_service_ << "void" << endl << this->nspace_lc << service_name_lc << "_client_get_property (" + f_service_ << "void" << '\n' << this->nspace_lc << service_name_lc << "_client_get_property (" << "GObject *object, guint property_id, GValue *value, " - << "GParamSpec *pspec)" << endl << "{" << endl << " " << this->nspace + << "GParamSpec *pspec)" << '\n' << "{" << '\n' << " " << this->nspace << service_name_ << "Client *client = " << this->nspace_uc << service_name_uc - << "_CLIENT (object);" << endl << endl << " THRIFT_UNUSED_VAR (pspec);" << endl - << endl << " switch (property_id)" << endl << " {" << endl << " case PROP_" - << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << endl - << " g_value_set_object (value, client->input_protocol);" << endl - << " break;" << endl << " case PROP_" << this->nspace_uc << service_name_uc - << "_CLIENT_OUTPUT_PROTOCOL:" << endl - << " g_value_set_object (value, client->output_protocol);" << endl - << " break;" << endl << " }" << endl << "}" << endl << endl; + << "_CLIENT (object);" << '\n' << '\n' << " THRIFT_UNUSED_VAR (pspec);" << '\n' + << '\n' << " switch (property_id)" << '\n' << " {" << '\n' << " case PROP_" + << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << '\n' + << " g_value_set_object (value, client->input_protocol);" << '\n' + << " break;" << '\n' << " case PROP_" << this->nspace_uc << service_name_uc + << "_CLIENT_OUTPUT_PROTOCOL:" << '\n' + << " g_value_set_object (value, client->output_protocol);" << '\n' + << " break;" << '\n' << " }" << '\n' << "}" << '\n' << '\n'; } // Generate client method implementations @@ -1569,31 +1567,31 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { (*f_iter)->get_arglist()); // Open the send function - indent(f_service_) << function_signature(&send_function) << endl; + indent(f_service_) << function_signature(&send_function) << '\n'; scope_up(f_service_); string reqType = (*f_iter)->is_oneway() ? "T_ONEWAY" : "T_CALL"; // Serialize the request - f_service_ << indent() << "gint32 cseqid = 0;" << endl << indent() + f_service_ << indent() << "gint32 cseqid = 0;" << '\n' << indent() << "ThriftProtocol * protocol = " << this->nspace_uc << base_service_name_uc - << "_CLIENT (iface)->output_protocol;" << endl << endl << indent() + << "_CLIENT (iface)->output_protocol;" << '\n' << '\n' << indent() << "if (thrift_protocol_write_message_begin (protocol, \"" << name << "\", " - << reqType << ", cseqid, error) < 0)" << endl << indent() << " return FALSE;" - << endl << endl; + << reqType << ", cseqid, error) < 0)" << '\n' << indent() << " return FALSE;" + << '\n' << '\n'; generate_struct_writer(f_service_, arg_struct, "", "", false); - f_service_ << indent() << "if (thrift_protocol_write_message_end (protocol, error) < 0)" << endl - << indent() << " return FALSE;" << endl << indent() - << "if (!thrift_transport_flush (protocol->transport, error))" << endl << indent() - << " return FALSE;" << endl << indent() - << "if (!thrift_transport_write_end (protocol->transport, error))" << endl - << indent() << " return FALSE;" << endl << endl << indent() << "return TRUE;" - << endl; + f_service_ << indent() << "if (thrift_protocol_write_message_end (protocol, error) < 0)" << '\n' + << indent() << " return FALSE;" << '\n' << indent() + << "if (!thrift_transport_flush (protocol->transport, error))" << '\n' << indent() + << " return FALSE;" << '\n' << indent() + << "if (!thrift_transport_write_end (protocol->transport, error))" << '\n' + << indent() << " return FALSE;" << '\n' << '\n' << indent() << "return TRUE;" + << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate recv function only if not an async function if (!(*f_iter)->is_oneway()) { @@ -1603,78 +1601,78 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { &noargs, (*f_iter)->get_xceptions()); // Open function - indent(f_service_) << function_signature(&recv_function) << endl; + indent(f_service_) << function_signature(&recv_function) << '\n'; scope_up(f_service_); - f_service_ << indent() << "gint32 rseqid;" << endl - << indent() << "gchar * fname = NULL;" << endl - << indent() << "ThriftMessageType mtype;" << endl + f_service_ << indent() << "gint32 rseqid;" << '\n' + << indent() << "gchar * fname = NULL;" << '\n' + << indent() << "ThriftMessageType mtype;" << '\n' << indent() << "ThriftProtocol * protocol = " << this->nspace_uc << base_service_name_uc - << "_CLIENT (iface)->input_protocol;" << endl - << indent() << "ThriftApplicationException *xception;" << endl - << endl + << "_CLIENT (iface)->input_protocol;" << '\n' + << indent() << "ThriftApplicationException *xception;" << '\n' + << '\n' << indent() << "if (thrift_protocol_read_message_begin " - "(protocol, &fname, &mtype, &rseqid, error) < 0) {" << endl; + "(protocol, &fname, &mtype, &rseqid, error) < 0) {" << '\n'; indent_up(); - f_service_ << indent() << "if (fname) g_free (fname);" << endl - << indent() << "return FALSE;" << endl; + f_service_ << indent() << "if (fname) g_free (fname);" << '\n' + << indent() << "return FALSE;" << '\n'; indent_down(); - f_service_ << indent() << "}" << endl - << endl - << indent() << "if (mtype == T_EXCEPTION) {" << endl; + f_service_ << indent() << "}" << '\n' + << '\n' + << indent() << "if (mtype == T_EXCEPTION) {" << '\n'; indent_up(); - f_service_ << indent() << "if (fname) g_free (fname);" << endl + f_service_ << indent() << "if (fname) g_free (fname);" << '\n' << indent() << "xception = g_object_new " - "(THRIFT_TYPE_APPLICATION_EXCEPTION, NULL);" << endl + "(THRIFT_TYPE_APPLICATION_EXCEPTION, NULL);" << '\n' << indent() << "thrift_struct_read (THRIFT_STRUCT (xception), " - "protocol, NULL);" << endl + "protocol, NULL);" << '\n' << indent() << "thrift_protocol_read_message_end " - "(protocol, NULL);" << endl + "(protocol, NULL);" << '\n' << indent() << "thrift_transport_read_end " - "(protocol->transport, NULL);" << endl + "(protocol->transport, NULL);" << '\n' << indent() << "g_set_error (error, " "THRIFT_APPLICATION_EXCEPTION_ERROR,xception->type, " - "\"application error: %s\", xception->message);" << endl - << indent() << "g_object_unref (xception);" << endl - << indent() << "return FALSE;" << endl; + "\"application error: %s\", xception->message);" << '\n' + << indent() << "g_object_unref (xception);" << '\n' + << indent() << "return FALSE;" << '\n'; indent_down(); - f_service_ << indent() << "} else if (mtype != T_REPLY) {" << endl; + f_service_ << indent() << "} else if (mtype != T_REPLY) {" << '\n'; indent_up(); - f_service_ << indent() << "if (fname) g_free (fname);" << endl + f_service_ << indent() << "if (fname) g_free (fname);" << '\n' << indent() << "thrift_protocol_skip (protocol, T_STRUCT, " - "NULL);" << endl + "NULL);" << '\n' << indent() << "thrift_protocol_read_message_end (protocol, " - "NULL);" << endl + "NULL);" << '\n' << indent() << "thrift_transport_read_end (" - "protocol->transport, NULL);" << endl + "protocol->transport, NULL);" << '\n' << indent() << "g_set_error (error, " "THRIFT_APPLICATION_EXCEPTION_ERROR, " "THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_MESSAGE_TYPE, " "\"invalid message type %d, expected T_REPLY\", mtype);" - << endl - << indent() << "return FALSE;" << endl; + << '\n' + << indent() << "return FALSE;" << '\n'; indent_down(); f_service_ << indent() << "} else if (strncmp (fname, \"" << name - << "\", " << name.length() << ") != 0) {" << endl; + << "\", " << name.length() << ") != 0) {" << '\n'; indent_up(); f_service_ << indent() << "thrift_protocol_skip (protocol, T_STRUCT, " - "NULL);" << endl + "NULL);" << '\n' << indent() << "thrift_protocol_read_message_end (protocol," - "error);" << endl + "error);" << '\n' << indent() << "thrift_transport_read_end (" - "protocol->transport, error);" << endl + "protocol->transport, error);" << '\n' << indent() << "g_set_error (error, " "THRIFT_APPLICATION_EXCEPTION_ERROR, " "THRIFT_APPLICATION_EXCEPTION_ERROR_WRONG_METHOD_NAME, " "\"wrong method name %s, expected " << name - << "\", fname);" << endl - << indent() << "if (fname) g_free (fname);" << endl - << indent() << "return FALSE;" << endl; + << "\", fname);" << '\n' + << indent() << "if (fname) g_free (fname);" << '\n' + << indent() << "return FALSE;" << '\n'; indent_down(); - f_service_ << indent() << "}" << endl - << indent() << "if (fname) g_free (fname);" << endl - << endl; + f_service_ << indent() << "}" << '\n' + << indent() << "if (fname) g_free (fname);" << '\n' + << '\n'; t_struct* xs = (*f_iter)->get_xceptions(); const std::vector& xceptions = xs->get_members(); @@ -1699,25 +1697,25 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { } f_service_ << indent() << "if (thrift_protocol_read_message_end (protocol, error) < 0)" - << endl << indent() << " return FALSE;" << endl << endl << indent() - << "if (!thrift_transport_read_end (protocol->transport, error))" << endl - << indent() << " return FALSE;" << endl << endl; + << '\n' << indent() << " return FALSE;" << '\n' << '\n' << indent() + << "if (!thrift_transport_read_end (protocol->transport, error))" << '\n' + << indent() << " return FALSE;" << '\n' << '\n'; // copy over any throw exceptions and return failure for (x_iter = xceptions.begin(); x_iter != xceptions.end(); x_iter++) { - f_service_ << indent() << "if (*" << (*x_iter)->get_name() << " != NULL)" << endl - << indent() << "{" << endl << indent() << " g_set_error (error, " + f_service_ << indent() << "if (*" << (*x_iter)->get_name() << " != NULL)" << '\n' + << indent() << "{" << '\n' << indent() << " g_set_error (error, " << this->nspace_uc << to_upper_case(initial_caps_to_underscores((*x_iter)->get_type()->get_name())) << "_ERROR, " << this->nspace_uc << to_upper_case(initial_caps_to_underscores((*x_iter)->get_type()->get_name())) - << "_ERROR_CODE, \"" << (*x_iter)->get_type()->get_name() << "\");" << endl - << indent() << " return FALSE;" << endl << indent() << "}" << endl; + << "_ERROR_CODE, \"" << (*x_iter)->get_type()->get_name() << "\");" << '\n' + << indent() << " return FALSE;" << '\n' << indent() << "}" << '\n'; } // Close function - indent(f_service_) << "return TRUE;" << endl; + indent(f_service_) << "return TRUE;" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } // Open function @@ -1725,7 +1723,7 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { service_name_lc + string("_client_") + funname, (*f_iter)->get_arglist(), (*f_iter)->get_xceptions()); - indent(f_service_) << function_signature(&service_function) << endl; + indent(f_service_) << function_signature(&service_function) << '\n'; scope_up(f_service_); // wrap each function @@ -1738,7 +1736,7 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_service_ << ", " << (*fld_iter)->get_name(); } - f_service_ << ", error))" << endl << indent() << " return FALSE;" << endl; + f_service_ << ", error))" << '\n' << indent() << " return FALSE;" << '\n'; // if not oneway, implement recv if (!(*f_iter)->is_oneway()) { @@ -1752,20 +1750,20 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { } f_service_ << indent() << "if (!" << this->nspace_lc << service_name_lc << "_client_recv_" - << funname << " (iface, " << ret << "error))" << endl << indent() - << " return FALSE;" << endl; + << funname << " (iface, " << ret << "error))" << '\n' << indent() + << " return FALSE;" << '\n'; } // return TRUE which means all functions were called OK - indent(f_service_) << "return TRUE;" << endl; + indent(f_service_) << "return TRUE;" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } // create the interface initializer - f_service_ << "static void" << endl + f_service_ << "static void" << '\n' << this->nspace_lc << service_name_lc << "_if_interface_init (" - << this->nspace << service_name_ << "IfInterface *iface)" << endl; + << this->nspace << service_name_ << "IfInterface *iface)" << '\n'; scope_up(f_service_); if (functions.size() > 0) { for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -1773,62 +1771,62 @@ void t_c_glib_generator::generate_service_client(t_service* tservice) { string funname = initial_caps_to_underscores((*f_iter)->get_name()); f_service_ << indent() << "iface->" << funname << " = " << this->nspace_lc - << service_name_lc << "_client_" << funname << ";" << endl; + << service_name_lc << "_client_" << funname << ";" << '\n'; } } else { - f_service_ << indent() << "THRIFT_UNUSED_VAR (iface);" << endl; + f_service_ << indent() << "THRIFT_UNUSED_VAR (iface);" << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // create the client instance initializer - f_service_ << "static void" << endl + f_service_ << "static void" << '\n' << this->nspace_lc << service_name_lc << "_client_init (" - << this->nspace << service_name_ << "Client *client)" << endl; + << this->nspace << service_name_ << "Client *client)" << '\n'; scope_up(f_service_); if (!extends_service) { - f_service_ << indent() << "client->input_protocol = NULL;" << endl - << indent() << "client->output_protocol = NULL;" << endl; + f_service_ << indent() << "client->input_protocol = NULL;" << '\n' + << indent() << "client->output_protocol = NULL;" << '\n'; } else { - f_service_ << indent() << "THRIFT_UNUSED_VAR (client);" << endl; + f_service_ << indent() << "THRIFT_UNUSED_VAR (client);" << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // create the client class initializer - f_service_ << "static void" << endl << this->nspace_lc << service_name_lc + f_service_ << "static void" << '\n' << this->nspace_lc << service_name_lc << "_client_class_init (" << this->nspace << service_name_ << "ClientClass *cls)" - << endl << "{" << endl; + << '\n' << "{" << '\n'; if (!extends_service) { - f_service_ << " GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << endl - << " GParamSpec *param_spec;" << endl << endl + f_service_ << " GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << '\n' + << " GParamSpec *param_spec;" << '\n' << '\n' << " gobject_class->set_property = " << this->nspace_lc << service_name_lc - << "_client_set_property;" << endl + << "_client_set_property;" << '\n' << " gobject_class->get_property = " << this->nspace_lc << service_name_lc - << "_client_get_property;" << endl << endl - << " param_spec = g_param_spec_object (\"input_protocol\"," << endl - << " \"input protocol (construct)\"," << endl - << " \"Set the client input protocol\"," << endl - << " THRIFT_TYPE_PROTOCOL," << endl - << " G_PARAM_READWRITE);" << endl - << " g_object_class_install_property (gobject_class," << endl + << "_client_get_property;" << '\n' << '\n' + << " param_spec = g_param_spec_object (\"input_protocol\"," << '\n' + << " \"input protocol (construct)\"," << '\n' + << " \"Set the client input protocol\"," << '\n' + << " THRIFT_TYPE_PROTOCOL," << '\n' + << " G_PARAM_READWRITE);" << '\n' + << " g_object_class_install_property (gobject_class," << '\n' << " PROP_" << this->nspace_uc << service_name_uc - << "_CLIENT_INPUT_PROTOCOL, param_spec);" << endl << endl - << " param_spec = g_param_spec_object (\"output_protocol\"," << endl - << " \"output protocol (construct)\"," << endl - << " \"Set the client output protocol\"," << endl - << " THRIFT_TYPE_PROTOCOL," << endl - << " G_PARAM_READWRITE);" << endl - << " g_object_class_install_property (gobject_class," << endl + << "_CLIENT_INPUT_PROTOCOL, param_spec);" << '\n' << '\n' + << " param_spec = g_param_spec_object (\"output_protocol\"," << '\n' + << " \"output protocol (construct)\"," << '\n' + << " \"Set the client output protocol\"," << '\n' + << " THRIFT_TYPE_PROTOCOL," << '\n' + << " G_PARAM_READWRITE);" << '\n' + << " g_object_class_install_property (gobject_class," << '\n' << " PROP_" << this->nspace_uc << service_name_uc - << "_CLIENT_OUTPUT_PROTOCOL, param_spec);" << endl; + << "_CLIENT_OUTPUT_PROTOCOL, param_spec);" << '\n'; } else { - f_service_ << " THRIFT_UNUSED_VAR (cls);" << endl; + f_service_ << " THRIFT_UNUSED_VAR (cls);" << '\n'; } - f_service_ << "}" << endl << endl; + f_service_ << "}" << '\n' << '\n'; } /** @@ -1874,19 +1872,19 @@ void t_c_glib_generator::generate_service_handler(t_service* tservice) { // Generate the handler class' definition in the header file // Generate the handler instance definition - f_header_ << "/* " << service_name_ << " handler (abstract base class) */" << endl << "struct _" - << class_name << endl << "{" << endl; + f_header_ << "/* " << service_name_ << " handler (abstract base class) */" << '\n' << "struct _" + << class_name << '\n' << "{" << '\n'; indent_up(); - f_header_ << indent() << parent_class_name << " parent;" << endl; + f_header_ << indent() << parent_class_name << " parent;" << '\n'; indent_down(); - f_header_ << "};" << endl << "typedef struct _" << class_name << " " << class_name << ";" << endl - << endl; + f_header_ << "};" << '\n' << "typedef struct _" << class_name << " " << class_name << ";" << '\n' + << '\n'; // Generate the handler class definition, including its class members // (methods) - f_header_ << "struct _" << class_name << "Class" << endl << "{" << endl; + f_header_ << "struct _" << class_name << "Class" << '\n' << "{" << '\n'; indent_up(); - f_header_ << indent() << parent_class_name << "Class parent;" << endl << endl; + f_header_ << indent() << parent_class_name << "Class parent;" << '\n' << '\n'; for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) { string method_name = initial_caps_to_underscores((*function_iter)->get_name()); @@ -1902,31 +1900,31 @@ void t_c_glib_generator::generate_service_handler(t_service* tservice) { + (has_args ? "" : (", " + argument_list(arg_list))) + (has_xceptions ? "" : (", " + xception_list(x_list))) + ", GError **error)"; - indent(f_header_) << "gboolean (*" << method_name << ") " << params << ";" << endl; + indent(f_header_) << "gboolean (*" << method_name << ") " << params << ";" << '\n'; } indent_down(); - f_header_ << "};" << endl << "typedef struct _" << class_name << "Class " << class_name - << "Class;" << endl << endl; + f_header_ << "};" << '\n' << "typedef struct _" << class_name << "Class " << class_name + << "Class;" << '\n' << '\n'; // Generate the remaining header boilerplate - f_header_ << "GType " << class_name_lc << "_get_type (void);" << endl << "#define " + f_header_ << "GType " << class_name_lc << "_get_type (void);" << '\n' << "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_HANDLER " - << "(" << class_name_lc << "_get_type())" << endl << "#define " << class_name_uc + << "(" << class_name_lc << "_get_type())" << '\n' << "#define " << class_name_uc << "(obj) " << "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_HANDLER, " << class_name << "))" << endl << "#define " + << service_name_uc << "_HANDLER, " << class_name << "))" << '\n' << "#define " << this->nspace_uc << "IS_" << service_name_uc << "_HANDLER(obj) " << "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_HANDLER))" << endl << "#define " << class_name_uc + << service_name_uc << "_HANDLER))" << '\n' << "#define " << class_name_uc << "_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_HANDLER, " << class_name << "Class))" << endl << "#define " + << service_name_uc << "_HANDLER, " << class_name << "Class))" << '\n' << "#define " << this->nspace_uc << "IS_" << service_name_uc << "_HANDLER_CLASS(c) " << "(G_TYPE_CHECK_CLASS_TYPE ((c), " << this->nspace_uc << "TYPE_" << service_name_uc - << "_HANDLER))" << endl << "#define " << this->nspace_uc << service_name_uc + << "_HANDLER))" << '\n' << "#define " << this->nspace_uc << service_name_uc << "_HANDLER_GET_CLASS(obj) " << "(G_TYPE_INSTANCE_GET_CLASS ((obj), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_HANDLER, " << class_name << "Class))" << endl << endl; + << service_name_uc << "_HANDLER, " << class_name << "Class))" << '\n' << '\n'; // Generate the handler class' method definitions for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) { @@ -1943,25 +1941,25 @@ void t_c_glib_generator::generate_service_handler(t_service* tservice) { + (has_args ? "" : (", " + argument_list(arg_list))) + (has_xceptions ? "" : (", " + xception_list(x_list))) + ", GError **error)"; - f_header_ << "gboolean " << class_name_lc << "_" << method_name << " " << params << ";" << endl; + f_header_ << "gboolean " << class_name_lc << "_" << method_name << " " << params << ";" << '\n'; } - f_header_ << endl; + f_header_ << '\n'; // Generate the handler's implementation in the implementation file // Generate the implementation boilerplate - f_service_ << "static void" << endl << class_name_lc << "_" << service_name_lc + f_service_ << "static void" << '\n' << class_name_lc << "_" << service_name_lc << "_if_interface_init (" << this->nspace << service_name_ << "IfInterface *iface);" - << endl << endl; + << '\n' << '\n'; args_indent = string(25, ' '); - f_service_ << "G_DEFINE_TYPE_WITH_CODE (" << class_name << ", " << endl << args_indent - << class_name_lc << "," << endl << args_indent << parent_type_name << "," << endl + f_service_ << "G_DEFINE_TYPE_WITH_CODE (" << class_name << ", " << '\n' << args_indent + << class_name_lc << "," << '\n' << args_indent << parent_type_name << "," << '\n' << args_indent << "G_IMPLEMENT_INTERFACE (" << this->nspace_uc << "TYPE_" - << service_name_uc << "_IF," << endl; + << service_name_uc << "_IF," << '\n'; args_indent += string(23, ' '); f_service_ << args_indent << class_name_lc << "_" << service_name_lc << "_if_interface_init))" - << endl << endl; + << '\n' << '\n'; // Generate the handler method implementations for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) { @@ -1982,10 +1980,10 @@ void t_c_glib_generator::generate_service_handler(t_service* tservice) { x_list, (*function_iter)->is_oneway()); - indent(f_service_) << function_signature(&implementing_function) << endl; + indent(f_service_) << function_signature(&implementing_function) << '\n'; scope_up(f_service_); f_service_ << indent() << "g_return_val_if_fail (" << this->nspace_uc << "IS_" - << service_name_uc << "_HANDLER (iface), FALSE);" << endl << endl << indent() + << service_name_uc << "_HANDLER (iface), FALSE);" << '\n' << '\n' << indent() << "return " << class_name_uc << "_GET_CLASS (iface)" << "->" << method_name << " (iface, "; @@ -1998,42 +1996,42 @@ void t_c_glib_generator::generate_service_handler(t_service* tservice) { for (field_iter = xceptions.begin(); field_iter != xceptions.end(); ++field_iter) { f_service_ << (*field_iter)->get_name() << ", "; } - f_service_ << "error);" << endl; + f_service_ << "error);" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } // Generate the handler interface initializer - f_service_ << "static void" << endl << class_name_lc << "_" << service_name_lc + f_service_ << "static void" << '\n' << class_name_lc << "_" << service_name_lc << "_if_interface_init (" << this->nspace << service_name_ << "IfInterface *iface)" - << endl; + << '\n'; scope_up(f_service_); if (functions.size() > 0) { for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) { string method_name = initial_caps_to_underscores((*function_iter)->get_name()); f_service_ << indent() << "iface->" << method_name << " = " << class_name_lc << "_" - << method_name << ";" << endl; + << method_name << ";" << '\n'; } } else { - f_service_ << "THRIFT_UNUSED_VAR (iface);" << endl; + f_service_ << "THRIFT_UNUSED_VAR (iface);" << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate the handler instance initializer - f_service_ << "static void" << endl << class_name_lc << "_init (" << class_name << " *self)" - << endl; + f_service_ << "static void" << '\n' << class_name_lc << "_init (" << class_name << " *self)" + << '\n'; scope_up(f_service_); - f_service_ << indent() << "THRIFT_UNUSED_VAR (self);" << endl; + f_service_ << indent() << "THRIFT_UNUSED_VAR (self);" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate the handler class initializer - f_service_ << "static void" << endl + f_service_ << "static void" << '\n' << class_name_lc << "_class_init (" << class_name << "Class *cls)" - << endl; + << '\n'; scope_up(f_service_); if (functions.size() > 0) { for (function_iter = functions.begin(); @@ -2043,14 +2041,14 @@ void t_c_glib_generator::generate_service_handler(t_service* tservice) { string method_name = initial_caps_to_underscores(function_name); // All methods are pure virtual and must be implemented by subclasses - f_service_ << indent() << "cls->" << method_name << " = NULL;" << endl; + f_service_ << indent() << "cls->" << method_name << " = NULL;" << '\n'; } } else { - f_service_ << indent() << "THRIFT_UNUSED_VAR (cls);" << endl; + f_service_ << indent() << "THRIFT_UNUSED_VAR (cls);" << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } /** @@ -2104,84 +2102,84 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { // Generate the processor class' definition in the header file // Generate the processor instance definition - f_header_ << "/* " << service_name_ << " processor */" << endl << "struct _" << class_name << endl - << "{" << endl; + f_header_ << "/* " << service_name_ << " processor */" << '\n' << "struct _" << class_name << '\n' + << "{" << '\n'; indent_up(); - f_header_ << indent() << parent_class_name << " parent;" << endl << endl << indent() - << "/* protected */" << endl << indent() - << this->nspace + service_name_ + "Handler *handler;" << endl << indent() - << "GHashTable *process_map;" << endl; + f_header_ << indent() << parent_class_name << " parent;" << '\n' << '\n' << indent() + << "/* protected */" << '\n' << indent() + << this->nspace + service_name_ + "Handler *handler;" << '\n' << indent() + << "GHashTable *process_map;" << '\n'; indent_down(); - f_header_ << "};" << endl << "typedef struct _" << class_name << " " << class_name << ";" << endl - << endl; + f_header_ << "};" << '\n' << "typedef struct _" << class_name << " " << class_name << ";" << '\n' + << '\n'; // Generate the processor class definition - f_header_ << "struct _" << class_name << "Class" << endl << "{" << endl; + f_header_ << "struct _" << class_name << "Class" << '\n' << "{" << '\n'; indent_up(); - f_header_ << indent() << parent_class_name << "Class parent;" << endl << endl << indent() - << "/* protected */" << endl << indent() - << "gboolean (*dispatch_call) (ThriftDispatchProcessor *processor," << endl; + f_header_ << indent() << parent_class_name << "Class parent;" << '\n' << '\n' << indent() + << "/* protected */" << '\n' << indent() + << "gboolean (*dispatch_call) (ThriftDispatchProcessor *processor," << '\n'; args_indent = indent() + string(27, ' '); - f_header_ << args_indent << "ThriftProtocol *in," << endl << args_indent << "ThriftProtocol *out," - << endl << args_indent << "gchar *fname," << endl << args_indent << "gint32 seqid," - << endl << args_indent << "GError **error);" << endl; + f_header_ << args_indent << "ThriftProtocol *in," << '\n' << args_indent << "ThriftProtocol *out," + << '\n' << args_indent << "gchar *fname," << '\n' << args_indent << "gint32 seqid," + << '\n' << args_indent << "GError **error);" << '\n'; indent_down(); - f_header_ << "};" << endl << "typedef struct _" << class_name << "Class " << class_name - << "Class;" << endl << endl; + f_header_ << "};" << '\n' << "typedef struct _" << class_name << "Class " << class_name + << "Class;" << '\n' << '\n'; // Generate the remaining header boilerplate - f_header_ << "GType " << class_name_lc << "_get_type (void);" << endl << "#define " + f_header_ << "GType " << class_name_lc << "_get_type (void);" << '\n' << "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_PROCESSOR " - << "(" << class_name_lc << "_get_type())" << endl << "#define " << class_name_uc + << "(" << class_name_lc << "_get_type())" << '\n' << "#define " << class_name_uc << "(obj) " << "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_PROCESSOR, " << class_name << "))" << endl << "#define " + << service_name_uc << "_PROCESSOR, " << class_name << "))" << '\n' << "#define " << this->nspace_uc << "IS_" << service_name_uc << "_PROCESSOR(obj) " << "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_PROCESSOR))" << endl << "#define " << class_name_uc + << service_name_uc << "_PROCESSOR))" << '\n' << "#define " << class_name_uc << "_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_PROCESSOR, " << class_name << "Class))" << endl << "#define " + << service_name_uc << "_PROCESSOR, " << class_name << "Class))" << '\n' << "#define " << this->nspace_uc << "IS_" << service_name_uc << "_PROCESSOR_CLASS(c) " << "(G_TYPE_CHECK_CLASS_TYPE ((c), " << this->nspace_uc << "TYPE_" << service_name_uc - << "_PROCESSOR))" << endl << "#define " << this->nspace_uc << service_name_uc + << "_PROCESSOR))" << '\n' << "#define " << this->nspace_uc << service_name_uc << "_PROCESSOR_GET_CLASS(obj) " << "(G_TYPE_INSTANCE_GET_CLASS ((obj), " << this->nspace_uc << "TYPE_" - << service_name_uc << "_PROCESSOR, " << class_name << "Class))" << endl << endl; + << service_name_uc << "_PROCESSOR, " << class_name << "Class))" << '\n' << '\n'; // Generate the processor's implementation in the implementation file // Generate the processor's properties enum - f_service_ << "enum _" << class_name << "Properties" << endl << "{" << endl; + f_service_ << "enum _" << class_name << "Properties" << '\n' << "{" << '\n'; indent_up(); - f_service_ << indent() << "PROP_" << class_name_uc << "_0," << endl << indent() << "PROP_" - << class_name_uc << "_HANDLER" << endl; + f_service_ << indent() << "PROP_" << class_name_uc << "_0," << '\n' << indent() << "PROP_" + << class_name_uc << "_HANDLER" << '\n'; indent_down(); - f_service_ << "};" << endl << endl; + f_service_ << "};" << '\n' << '\n'; // Generate the implementation boilerplate args_indent = string(15, ' '); - f_service_ << "G_DEFINE_TYPE (" << class_name << "," << endl << args_indent << class_name_lc - << "," << endl << args_indent << parent_type_name << ")" << endl << endl; + f_service_ << "G_DEFINE_TYPE (" << class_name << "," << '\n' << args_indent << class_name_lc + << "," << '\n' << args_indent << parent_type_name << ")" << '\n' << '\n'; // Generate the processor's processing-function type args_indent = string(process_function_type_name.length() + 23, ' '); f_service_ << "typedef gboolean (* " << process_function_type_name << ") (" - << class_name << " *, " << endl - << args_indent << "gint32," << endl - << args_indent << "ThriftProtocol *," << endl - << args_indent << "ThriftProtocol *," << endl - << args_indent << "GError **);" << endl - << endl; + << class_name << " *, " << '\n' + << args_indent << "gint32," << '\n' + << args_indent << "ThriftProtocol *," << '\n' + << args_indent << "ThriftProtocol *," << '\n' + << args_indent << "GError **);" << '\n' + << '\n'; // Generate the processor's processing-function-definition type - f_service_ << "typedef struct" << endl - << "{" << endl; + f_service_ << "typedef struct" << '\n' + << "{" << '\n'; indent_up(); - f_service_ << indent() << "gchar *name;" << endl - << indent() << process_function_type_name << " function;" << endl; + f_service_ << indent() << "gchar *name;" << '\n' + << indent() << process_function_type_name << " function;" << '\n'; indent_down(); - f_service_ << "} " << process_function_def_type_name << ";" << endl - << endl; + f_service_ << "} " << process_function_def_type_name << ";" << '\n' + << '\n'; // Generate forward declarations of the processor's processing functions so we // can refer to them in the processing-function-definition struct below and @@ -2193,23 +2191,23 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { + initial_caps_to_underscores((*function_iter)->get_name()); args_indent = string(function_name.length() + 2, ' '); - f_service_ << "static gboolean" << endl + f_service_ << "static gboolean" << '\n' << function_name << " (" - << class_name << " *," << endl - << args_indent << "gint32," << endl - << args_indent << "ThriftProtocol *," << endl - << args_indent << "ThriftProtocol *," << endl - << args_indent << "GError **);" << endl; + << class_name << " *," << '\n' + << args_indent << "gint32," << '\n' + << args_indent << "ThriftProtocol *," << '\n' + << args_indent << "ThriftProtocol *," << '\n' + << args_indent << "GError **);" << '\n'; } - f_service_ << endl; + f_service_ << '\n'; // Generate the processor's processing-function definitions, if the service // defines any methods if (functions.size() > 0) { f_service_ << indent() << "static " << process_function_def_type_name - << endl + << '\n' << indent() << class_name_lc << "_process_function_defs[" - << functions.size() << "] = {" << endl; + << functions.size() << "] = {" << '\n'; indent_up(); for (function_iter = functions.begin(); function_iter != functions.end(); @@ -2218,17 +2216,17 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { string process_function_name = class_name_lc + "_process_" + initial_caps_to_underscores(service_function_name); - f_service_ << indent() << "{" << endl; + f_service_ << indent() << "{" << '\n'; indent_up(); - f_service_ << indent() << "\"" << service_function_name << "\"," << endl - << indent() << process_function_name << endl; + f_service_ << indent() << "\"" << service_function_name << "\"," << '\n' + << indent() << process_function_name << '\n'; indent_down(); f_service_ << indent() << "}" - << (function_iter == --functions.end() ? "" : ",") << endl; + << (function_iter == --functions.end() ? "" : ",") << '\n'; } indent_down(); - f_service_ << indent() << "};" << endl - << endl; + f_service_ << indent() << "};" << '\n' + << '\n'; } // Generate the processor's processing functions @@ -2262,76 +2260,76 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { + initial_caps_to_underscores(service_function_name); args_indent = string(function_name.length() + 2, ' '); - f_service_ << "static gboolean" << endl << function_name << " (" << class_name << " *self," - << endl << args_indent << "gint32 sequence_id," << endl << args_indent - << "ThriftProtocol *input_protocol," << endl << args_indent - << "ThriftProtocol *output_protocol," << endl << args_indent << "GError **error)" - << endl; + f_service_ << "static gboolean" << '\n' << function_name << " (" << class_name << " *self," + << '\n' << args_indent << "gint32 sequence_id," << '\n' << args_indent + << "ThriftProtocol *input_protocol," << '\n' << args_indent + << "ThriftProtocol *output_protocol," << '\n' << args_indent << "GError **error)" + << '\n'; scope_up(f_service_); - f_service_ << indent() << "gboolean result = TRUE;" << endl - << indent() << "ThriftTransport * transport;" << endl - << indent() << "ThriftApplicationException *xception;" << endl - << indent() << args_class_name + " * args =" << endl; + f_service_ << indent() << "gboolean result = TRUE;" << '\n' + << indent() << "ThriftTransport * transport;" << '\n' + << indent() << "ThriftApplicationException *xception;" << '\n' + << indent() << args_class_name + " * args =" << '\n'; indent_up(); - f_service_ << indent() << "g_object_new (" << args_class_type << ", NULL);" << endl << endl; + f_service_ << indent() << "g_object_new (" << args_class_type << ", NULL);" << '\n' << '\n'; indent_down(); if ((*function_iter)->is_oneway()) { - f_service_ << indent() << "THRIFT_UNUSED_VAR (sequence_id);" << endl << indent() - << "THRIFT_UNUSED_VAR (output_protocol);" << endl << endl; + f_service_ << indent() << "THRIFT_UNUSED_VAR (sequence_id);" << '\n' << indent() + << "THRIFT_UNUSED_VAR (output_protocol);" << '\n' << '\n'; } f_service_ << indent() << "g_object_get (input_protocol, \"transport\", " - << "&transport, NULL);" << endl << endl; + << "&transport, NULL);" << '\n' << '\n'; // Read the method's arguments from the caller f_service_ << indent() << "if ((thrift_struct_read (THRIFT_STRUCT (args), " - << "input_protocol, error) != -1) &&" << endl << indent() + << "input_protocol, error) != -1) &&" << '\n' << indent() << " (thrift_protocol_read_message_end (input_protocol, " - << "error) != -1) &&" << endl << indent() - << " (thrift_transport_read_end (transport, error) != FALSE))" << endl; + << "error) != -1) &&" << '\n' << indent() + << " (thrift_transport_read_end (transport, error) != FALSE))" << '\n'; scope_up(f_service_); for (arg_iter = args.begin(); arg_iter != args.end(); ++arg_iter) { f_service_ << indent() << property_type_name((*arg_iter)->get_type()) << " " - << (*arg_iter)->get_name() << ";" << endl; + << (*arg_iter)->get_name() << ";" << '\n'; } for (xception_iter = xceptions.begin(); xception_iter != xceptions.end(); ++xception_iter) { f_service_ << indent() << type_name((*xception_iter)->get_type()) << " " - << initial_caps_to_underscores((*xception_iter)->get_name()) << " = NULL;" << endl; + << initial_caps_to_underscores((*xception_iter)->get_name()) << " = NULL;" << '\n'; } if (has_return_value) { - f_service_ << indent() << property_type_name(return_type) << " return_value;" << endl; + f_service_ << indent() << property_type_name(return_type) << " return_value;" << '\n'; } if (!(*function_iter)->is_oneway()) { - f_service_ << indent() << result_class_name << " * result_struct;" << endl; + f_service_ << indent() << result_class_name << " * result_struct;" << '\n'; } - f_service_ << endl; + f_service_ << '\n'; if (args.size() > 0) { - f_service_ << indent() << "g_object_get (args," << endl; + f_service_ << indent() << "g_object_get (args," << '\n'; args_indent = indent() + string(14, ' '); for (arg_iter = args.begin(); arg_iter != args.end(); ++arg_iter) { string arg_name = (*arg_iter)->get_name(); - f_service_ << args_indent << "\"" << arg_name << "\", &" << arg_name << "," << endl; + f_service_ << args_indent << "\"" << arg_name << "\", &" << arg_name << "," << '\n'; } - f_service_ << args_indent << "NULL);" << endl << endl; + f_service_ << args_indent << "NULL);" << '\n' << '\n'; } if (!(*function_iter)->is_oneway()) { - f_service_ << indent() << "g_object_unref (transport);" << endl << indent() + f_service_ << indent() << "g_object_unref (transport);" << '\n' << indent() << "g_object_get (output_protocol, \"transport\", " - << "&transport, NULL);" << endl << endl << indent() - << "result_struct = g_object_new (" << result_class_type << ", NULL);" << endl; + << "&transport, NULL);" << '\n' << '\n' << indent() + << "result_struct = g_object_new (" << result_class_type << ", NULL);" << '\n'; if (has_return_value) { f_service_ << indent() << "g_object_get (result_struct, " - "\"success\", &return_value, NULL);" << endl; + "\"success\", &return_value, NULL);" << '\n'; } - f_service_ << endl; + f_service_ << '\n'; } // Pass the arguments to the corresponding method in the handler f_service_ << indent() << "if (" << handler_function_name << " (" << this->nspace_uc - << service_name_uc << "_IF (self->handler)," << endl; + << service_name_uc << "_IF (self->handler)," << '\n'; args_indent = indent() + string(handler_function_name.length() + 6, ' '); if (has_return_value) { string return_type_name = type_name(return_type); @@ -2351,16 +2349,16 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { f_service_ << "(" << return_type_name << ")"; } - f_service_ << "&return_value," << endl; + f_service_ << "&return_value," << '\n'; } for (arg_iter = args.begin(); arg_iter != args.end(); ++arg_iter) { - f_service_ << args_indent << (*arg_iter)->get_name() << "," << endl; + f_service_ << args_indent << (*arg_iter)->get_name() << "," << '\n'; } for (xception_iter = xceptions.begin(); xception_iter != xceptions.end(); ++xception_iter) { f_service_ << args_indent << "&" << initial_caps_to_underscores((*xception_iter)->get_name()) - << "," << endl; + << "," << '\n'; } - f_service_ << args_indent << "error) == TRUE)" << endl; + f_service_ << args_indent << "error) == TRUE)" << '\n'; scope_up(f_service_); // The handler reported success; return the result, if any, to the caller @@ -2373,24 +2371,24 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { << "(" << type_name(return_type) << ")"; } f_service_ << "return_value, " - << "NULL);" << endl; - f_service_ << endl; + << "NULL);" << '\n'; + f_service_ << '\n'; } - f_service_ << indent() << "result =" << endl; + f_service_ << indent() << "result =" << '\n'; indent_up(); - f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << endl; + f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << '\n'; args_indent = indent() + string(39, ' '); - f_service_ << args_indent << "\"" << service_function_name << "\"," << endl << args_indent - << "T_REPLY," << endl << args_indent << "sequence_id," << endl << args_indent - << "error) != -1) &&" << endl << indent() - << " (thrift_struct_write (THRIFT_STRUCT (result_struct)," << endl; + f_service_ << args_indent << "\"" << service_function_name << "\"," << '\n' << args_indent + << "T_REPLY," << '\n' << args_indent << "sequence_id," << '\n' << args_indent + << "error) != -1) &&" << '\n' << indent() + << " (thrift_struct_write (THRIFT_STRUCT (result_struct)," << '\n'; args_indent = indent() + string(23, ' '); - f_service_ << args_indent << "output_protocol," << endl << args_indent << "error) != -1));" - << endl; + f_service_ << args_indent << "output_protocol," << '\n' << args_indent << "error) != -1));" + << '\n'; indent_down(); } scope_down(f_service_); - f_service_ << indent() << "else" << endl; + f_service_ << indent() << "else" << '\n'; scope_up(f_service_); // The handler reported failure; check to see if an application-defined @@ -2399,28 +2397,28 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { if (xceptions.size() > 0) { for (xception_iter = xceptions.begin(); xception_iter != xceptions.end(); ++xception_iter) { f_service_ << "if (" << initial_caps_to_underscores((*xception_iter)->get_name()) - << " != NULL)" << endl; + << " != NULL)" << '\n'; scope_up(f_service_); - f_service_ << indent() << "g_object_set (result_struct," << endl; + f_service_ << indent() << "g_object_set (result_struct," << '\n'; args_indent = indent() + string(14, ' '); f_service_ << args_indent << "\"" << (*xception_iter)->get_name() << "\", " - << (*xception_iter)->get_name() << "," << endl << args_indent << "NULL);" << endl - << endl; - f_service_ << indent() << "g_object_unref ("<< (*xception_iter)->get_name() <<");"<< endl; - f_service_ << indent() << "result =" << endl; + << (*xception_iter)->get_name() << "," << '\n' << args_indent << "NULL);" << '\n' + << '\n'; + f_service_ << indent() << "g_object_unref ("<< (*xception_iter)->get_name() <<");"<< '\n'; + f_service_ << indent() << "result =" << '\n'; indent_up(); - f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << endl; + f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << '\n'; args_indent = indent() + string(39, ' '); - f_service_ << args_indent << "\"" << service_function_name << "\"," << endl << args_indent - << "T_REPLY," << endl << args_indent << "sequence_id," << endl << args_indent - << "error) != -1) &&" << endl << indent() - << " (thrift_struct_write (THRIFT_STRUCT (result_struct)," << endl; + f_service_ << args_indent << "\"" << service_function_name << "\"," << '\n' << args_indent + << "T_REPLY," << '\n' << args_indent << "sequence_id," << '\n' << args_indent + << "error) != -1) &&" << '\n' << indent() + << " (thrift_struct_write (THRIFT_STRUCT (result_struct)," << '\n'; args_indent = indent() + string(23, ' '); - f_service_ << args_indent << "output_protocol," << endl << args_indent << "error) != -1));" - << endl; + f_service_ << args_indent << "output_protocol," << '\n' << args_indent << "error) != -1));" + << '\n'; indent_down(); scope_down(f_service_); - f_service_ << indent() << "else" << endl; + f_service_ << indent() << "else" << '\n'; } scope_up(f_service_); @@ -2430,41 +2428,41 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { // If the handler reported failure but raised no application-defined // exception, return a Thrift application exception with the information // returned via GLib's own error-reporting mechanism - f_service_ << "if (*error == NULL)" << endl; + f_service_ << "if (*error == NULL)" << '\n'; indent_up(); f_service_ << indent() << "g_warning (\"" << service_name_ << "." - << (*function_iter)->get_name() << " implementation returned FALSE \"" << endl - << indent() << string(11, ' ') << "\"but did not set an error\");" << endl << endl; + << (*function_iter)->get_name() << " implementation returned FALSE \"" << '\n' + << indent() << string(11, ' ') << "\"but did not set an error\");" << '\n' << '\n'; indent_down(); - f_service_ << indent() << "xception =" << endl; + f_service_ << indent() << "xception =" << '\n'; indent_up(); - f_service_ << indent() << "g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION," << endl; + f_service_ << indent() << "g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION," << '\n'; args_indent = indent() + string(14, ' '); - f_service_ << args_indent << "\"type\", *error != NULL ? (*error)->code :" << endl + f_service_ << args_indent << "\"type\", *error != NULL ? (*error)->code :" << '\n' << args_indent << string(11, ' ') << "THRIFT_APPLICATION_EXCEPTION_ERROR_UNKNOWN," - << endl << args_indent << "\"message\", *error != NULL ? (*error)->message : NULL," - << endl << args_indent << "NULL);" << endl; + << '\n' << args_indent << "\"message\", *error != NULL ? (*error)->message : NULL," + << '\n' << args_indent << "NULL);" << '\n'; indent_down(); - f_service_ << indent() << "g_clear_error (error);" << endl << endl << indent() - << "result =" << endl; + f_service_ << indent() << "g_clear_error (error);" << '\n' << '\n' << indent() + << "result =" << '\n'; indent_up(); - f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << endl; + f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << '\n'; args_indent = indent() + string(39, ' '); - f_service_ << args_indent << "\"" << service_function_name << "\"," << endl << args_indent - << "T_EXCEPTION," << endl << args_indent << "sequence_id," << endl << args_indent - << "error) != -1) &&" << endl << indent() - << " (thrift_struct_write (THRIFT_STRUCT (xception)," << endl; + f_service_ << args_indent << "\"" << service_function_name << "\"," << '\n' << args_indent + << "T_EXCEPTION," << '\n' << args_indent << "sequence_id," << '\n' << args_indent + << "error) != -1) &&" << '\n' << indent() + << " (thrift_struct_write (THRIFT_STRUCT (xception)," << '\n'; args_indent = indent() + string(23, ' '); - f_service_ << args_indent << "output_protocol," << endl << args_indent << "error) != -1));" - << endl; + f_service_ << args_indent << "output_protocol," << '\n' << args_indent << "error) != -1));" + << '\n'; indent_down(); - f_service_ << endl << indent() << "g_object_unref (xception);" << endl; + f_service_ << '\n' << indent() << "g_object_unref (xception);" << '\n'; if (xceptions.size() > 0) { scope_down(f_service_); } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Dellocate or unref retrieved argument values as necessary for (arg_iter = args.begin(); arg_iter != args.end(); ++arg_iter) { @@ -2475,17 +2473,17 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { t_base_type* base_type = ((t_base_type*)arg_type); if (base_type->get_base() == t_base_type::TYPE_STRING) { - f_service_ << indent() << "if (" << arg_name << " != NULL)" << endl; + f_service_ << indent() << "if (" << arg_name << " != NULL)" << '\n'; indent_up(); if (base_type->is_binary()) { - f_service_ << indent() << "g_byte_array_unref (" << arg_name << ");" << endl; + f_service_ << indent() << "g_byte_array_unref (" << arg_name << ");" << '\n'; } else { - f_service_ << indent() << "g_free (" << arg_name << ");" << endl; + f_service_ << indent() << "g_free (" << arg_name << ");" << '\n'; } indent_down(); } } else if (arg_type->is_container()) { - f_service_ << indent() << "if (" << arg_name << " != NULL)" << endl; + f_service_ << indent() << "if (" << arg_name << " != NULL)" << '\n'; indent_up(); if (arg_type->is_list()) { @@ -2497,16 +2495,16 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { } else { f_service_ << "g_ptr_array_unref"; } - f_service_ << " (" << arg_name << ");" << endl; + f_service_ << " (" << arg_name << ");" << '\n'; } else if (arg_type->is_map() || arg_type->is_set()) { - f_service_ << indent() << "g_hash_table_unref (" << arg_name << ");" << endl; + f_service_ << indent() << "g_hash_table_unref (" << arg_name << ");" << '\n'; } indent_down(); } else if (arg_type->is_struct()) { - f_service_ << indent() << "if (" << arg_name << " != NULL)" << endl; + f_service_ << indent() << "if (" << arg_name << " != NULL)" << '\n'; indent_up(); - f_service_ << indent() << "g_object_unref (" << arg_name << ");" << endl; + f_service_ << indent() << "g_object_unref (" << arg_name << ");" << '\n'; indent_down(); } } @@ -2518,17 +2516,17 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { if (return_type->is_base_type()) { t_base_type* base_type = ((t_base_type*)return_type); if (base_type->get_base() == t_base_type::TYPE_STRING) { - f_service_ << indent() << "if (return_value != NULL)" << endl; + f_service_ << indent() << "if (return_value != NULL)" << '\n'; indent_up(); if (base_type->is_binary()) { - f_service_ << indent() << "g_byte_array_unref (return_value);" << endl; + f_service_ << indent() << "g_byte_array_unref (return_value);" << '\n'; } else { - f_service_ << indent() << "g_free (return_value);" << endl; + f_service_ << indent() << "g_free (return_value);" << '\n'; } indent_down(); } } else if (return_type->is_container()) { - f_service_ << indent() << "if (return_value != NULL)" << endl; + f_service_ << indent() << "if (return_value != NULL)" << '\n'; indent_up(); if (return_type->is_list()) { @@ -2540,81 +2538,81 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { } else { f_service_ << "g_ptr_array_unref"; } - f_service_ << " (return_value);" << endl; + f_service_ << " (return_value);" << '\n'; } else if (return_type->is_map() || return_type->is_set()) { - f_service_ << indent() << "g_hash_table_unref (return_value);" << endl; + f_service_ << indent() << "g_hash_table_unref (return_value);" << '\n'; } indent_down(); } else if (return_type->is_struct()) { - f_service_ << indent() << "if (return_value != NULL)" << endl; + f_service_ << indent() << "if (return_value != NULL)" << '\n'; indent_up(); - f_service_ << indent() << "g_object_unref (return_value);" << endl; + f_service_ << indent() << "g_object_unref (return_value);" << '\n'; indent_down(); } } - f_service_ << indent() << "g_object_unref (result_struct);" << endl << endl << indent() - << "if (result == TRUE)" << endl; + f_service_ << indent() << "g_object_unref (result_struct);" << '\n' << '\n' << indent() + << "if (result == TRUE)" << '\n'; indent_up(); - f_service_ << indent() << "result =" << endl; + f_service_ << indent() << "result =" << '\n'; indent_up(); f_service_ << indent() << "((thrift_protocol_write_message_end " - << "(output_protocol, error) != -1) &&" << endl << indent() + << "(output_protocol, error) != -1) &&" << '\n' << indent() << " (thrift_transport_write_end (transport, error) " - << "!= FALSE) &&" << endl << indent() + << "!= FALSE) &&" << '\n' << indent() << " (thrift_transport_flush (transport, error) " - << "!= FALSE));" << endl; + << "!= FALSE));" << '\n'; indent_down(); indent_down(); } scope_down(f_service_); - f_service_ << indent() << "else" << endl; + f_service_ << indent() << "else" << '\n'; indent_up(); - f_service_ << indent() << "result = FALSE;" << endl; + f_service_ << indent() << "result = FALSE;" << '\n'; indent_down(); - f_service_ << endl << indent() << "g_object_unref (transport);" << endl << indent() - << "g_object_unref (args);" << endl << endl << indent() << "return result;" << endl; + f_service_ << '\n' << indent() << "g_object_unref (transport);" << '\n' << indent() + << "g_object_unref (args);" << '\n' << '\n' << indent() << "return result;" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } // Generate the processor's dispatch_call implementation function_name = class_name_lc + "_dispatch_call"; args_indent = indent() + string(function_name.length() + 2, ' '); - f_service_ << "static gboolean" << endl << function_name - << " (ThriftDispatchProcessor *dispatch_processor," << endl << args_indent - << "ThriftProtocol *input_protocol," << endl << args_indent - << "ThriftProtocol *output_protocol," << endl << args_indent << "gchar *method_name," - << endl << args_indent << "gint32 sequence_id," << endl << args_indent - << "GError **error)" << endl; + f_service_ << "static gboolean" << '\n' << function_name + << " (ThriftDispatchProcessor *dispatch_processor," << '\n' << args_indent + << "ThriftProtocol *input_protocol," << '\n' << args_indent + << "ThriftProtocol *output_protocol," << '\n' << args_indent << "gchar *method_name," + << '\n' << args_indent << "gint32 sequence_id," << '\n' << args_indent + << "GError **error)" << '\n'; scope_up(f_service_); f_service_ << indent() << class_name_lc << "_process_function_def *" - << "process_function_def;" << endl; - f_service_ << indent() << "gboolean dispatch_result = FALSE;" << endl << endl << indent() - << class_name << " *self = " << class_name_uc << " (dispatch_processor);" << endl; + << "process_function_def;" << '\n'; + f_service_ << indent() << "gboolean dispatch_result = FALSE;" << '\n' << '\n' << indent() + << class_name << " *self = " << class_name_uc << " (dispatch_processor);" << '\n'; f_service_ << indent() << parent_class_name << "Class " - "*parent_class =" << endl; + "*parent_class =" << '\n'; indent_up(); f_service_ << indent() << "g_type_class_peek_parent (" << class_name_uc << "_GET_CLASS (self));" - << endl; + << '\n'; indent_down(); - f_service_ << endl + f_service_ << '\n' << indent() << "process_function_def = " - << "g_hash_table_lookup (self->process_map, method_name);" << endl - << indent() << "if (process_function_def != NULL)" << endl; + << "g_hash_table_lookup (self->process_map, method_name);" << '\n' + << indent() << "if (process_function_def != NULL)" << '\n'; scope_up(f_service_); args_indent = indent() + string(53, ' '); - f_service_ << indent() << "g_free (method_name);" << endl + f_service_ << indent() << "g_free (method_name);" << '\n' << indent() << "dispatch_result = " - << "(*process_function_def->function) (self," << endl - << args_indent << "sequence_id," << endl - << args_indent << "input_protocol," << endl - << args_indent << "output_protocol," << endl - << args_indent << "error);" << endl; + << "(*process_function_def->function) (self," << '\n' + << args_indent << "sequence_id," << '\n' + << args_indent << "input_protocol," << '\n' + << args_indent << "output_protocol," << '\n' + << args_indent << "error);" << '\n'; scope_down(f_service_); - f_service_ << indent() << "else" << endl; + f_service_ << indent() << "else" << '\n'; scope_up(f_service_); // Method name not recognized; chain up to our parent processor---note the @@ -2622,160 +2620,160 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) { // will return an application exception to the caller if no class in the // hierarchy recognizes the method name f_service_ << indent() << "dispatch_result = parent_class->dispatch_call " - "(dispatch_processor," << endl; + "(dispatch_processor," << '\n'; args_indent = indent() + string(47, ' '); - f_service_ << args_indent << "input_protocol," << endl << args_indent << "output_protocol," - << endl << args_indent << "method_name," << endl << args_indent << "sequence_id," - << endl << args_indent << "error);" << endl; + f_service_ << args_indent << "input_protocol," << '\n' << args_indent << "output_protocol," + << '\n' << args_indent << "method_name," << '\n' << args_indent << "sequence_id," + << '\n' << args_indent << "error);" << '\n'; scope_down(f_service_); - f_service_ << endl << indent() << "return dispatch_result;" << endl; + f_service_ << '\n' << indent() << "return dispatch_result;" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate the processor's property setter function_name = class_name_lc + "_set_property"; args_indent = string(function_name.length() + 2, ' '); - f_service_ << "static void" << endl << function_name << " (GObject *object," << endl - << args_indent << "guint property_id," << endl << args_indent << "const GValue *value," - << endl << args_indent << "GParamSpec *pspec)" << endl; + f_service_ << "static void" << '\n' << function_name << " (GObject *object," << '\n' + << args_indent << "guint property_id," << '\n' << args_indent << "const GValue *value," + << '\n' << args_indent << "GParamSpec *pspec)" << '\n'; scope_up(f_service_); - f_service_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << endl - << endl << indent() << "switch (property_id)" << endl; + f_service_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << '\n' + << '\n' << indent() << "switch (property_id)" << '\n'; scope_up(f_service_); - f_service_ << indent() << "case PROP_" << class_name_uc << "_HANDLER:" << endl; + f_service_ << indent() << "case PROP_" << class_name_uc << "_HANDLER:" << '\n'; indent_up(); - f_service_ << indent() << "if (self->handler != NULL)" << endl; + f_service_ << indent() << "if (self->handler != NULL)" << '\n'; indent_up(); - f_service_ << indent() << "g_object_unref (self->handler);" << endl; + f_service_ << indent() << "g_object_unref (self->handler);" << '\n'; indent_down(); - f_service_ << indent() << "self->handler = g_value_get_object (value);" << endl << indent() - << "g_object_ref (self->handler);" << endl; + f_service_ << indent() << "self->handler = g_value_get_object (value);" << '\n' << indent() + << "g_object_ref (self->handler);" << '\n'; if (extends_service) { // Chain up to set the handler in every superclass as well - f_service_ << endl << indent() << "G_OBJECT_CLASS (" << class_name_lc << "_parent_class)->" - << endl; + f_service_ << '\n' << indent() << "G_OBJECT_CLASS (" << class_name_lc << "_parent_class)->" + << '\n'; indent_up(); - f_service_ << indent() << "set_property (object, property_id, value, pspec);" << endl; + f_service_ << indent() << "set_property (object, property_id, value, pspec);" << '\n'; indent_down(); } - f_service_ << indent() << "break;" << endl; + f_service_ << indent() << "break;" << '\n'; indent_down(); - f_service_ << indent() << "default:" << endl; + f_service_ << indent() << "default:" << '\n'; indent_up(); f_service_ << indent() << "G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);" - << endl << indent() << "break;" << endl; + << '\n' << indent() << "break;" << '\n'; indent_down(); scope_down(f_service_); scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate processor's property getter function_name = class_name_lc + "_get_property"; args_indent = string(function_name.length() + 2, ' '); - f_service_ << "static void" << endl << function_name << " (GObject *object," << endl - << args_indent << "guint property_id," << endl << args_indent << "GValue *value," - << endl << args_indent << "GParamSpec *pspec)" << endl; + f_service_ << "static void" << '\n' << function_name << " (GObject *object," << '\n' + << args_indent << "guint property_id," << '\n' << args_indent << "GValue *value," + << '\n' << args_indent << "GParamSpec *pspec)" << '\n'; scope_up(f_service_); - f_service_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << endl - << endl << indent() << "switch (property_id)" << endl; + f_service_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << '\n' + << '\n' << indent() << "switch (property_id)" << '\n'; scope_up(f_service_); - f_service_ << indent() << "case PROP_" << class_name_uc << "_HANDLER:" << endl; + f_service_ << indent() << "case PROP_" << class_name_uc << "_HANDLER:" << '\n'; indent_up(); - f_service_ << indent() << "g_value_set_object (value, self->handler);" << endl << indent() - << "break;" << endl; + f_service_ << indent() << "g_value_set_object (value, self->handler);" << '\n' << indent() + << "break;" << '\n'; indent_down(); - f_service_ << indent() << "default:" << endl; + f_service_ << indent() << "default:" << '\n'; indent_up(); f_service_ << indent() << "G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);" - << endl << indent() << "break;" << endl; + << '\n' << indent() << "break;" << '\n'; indent_down(); scope_down(f_service_); scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generator the processor's dispose function - f_service_ << "static void" << endl << class_name_lc << "_dispose (GObject *gobject)" << endl; + f_service_ << "static void" << '\n' << class_name_lc << "_dispose (GObject *gobject)" << '\n'; scope_up(f_service_); - f_service_ << indent() << class_name << " *self = " << class_name_uc << " (gobject);" << endl - << endl << indent() << "if (self->handler != NULL)" << endl; + f_service_ << indent() << class_name << " *self = " << class_name_uc << " (gobject);" << '\n' + << '\n' << indent() << "if (self->handler != NULL)" << '\n'; scope_up(f_service_); - f_service_ << indent() << "g_object_unref (self->handler);" << endl << indent() - << "self->handler = NULL;" << endl; + f_service_ << indent() << "g_object_unref (self->handler);" << '\n' << indent() + << "self->handler = NULL;" << '\n'; scope_down(f_service_); - f_service_ << endl << indent() << "G_OBJECT_CLASS (" << class_name_lc << "_parent_class)" + f_service_ << '\n' << indent() << "G_OBJECT_CLASS (" << class_name_lc << "_parent_class)" "->dispose (gobject);" - << endl; + << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate processor finalize function - f_service_ << "static void" << endl << class_name_lc << "_finalize (GObject *gobject)" << endl; + f_service_ << "static void" << '\n' << class_name_lc << "_finalize (GObject *gobject)" << '\n'; scope_up(f_service_); f_service_ << indent() << this->nspace << service_name_ << "Processor *self = " << this->nspace_uc - << service_name_uc << "_PROCESSOR (gobject);" << endl << endl << indent() - << "thrift_safe_hash_table_destroy (self->process_map);" << endl << endl << indent() + << service_name_uc << "_PROCESSOR (gobject);" << '\n' << '\n' << indent() + << "thrift_safe_hash_table_destroy (self->process_map);" << '\n' << '\n' << indent() << "G_OBJECT_CLASS (" << class_name_lc << "_parent_class)" - "->finalize (gobject);" << endl; + "->finalize (gobject);" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate processor instance initializer - f_service_ << "static void" << endl << class_name_lc << "_init (" << class_name << " *self)" - << endl; + f_service_ << "static void" << '\n' << class_name_lc << "_init (" << class_name << " *self)" + << '\n'; scope_up(f_service_); if (functions.size() > 0) { - f_service_ << indent() << "guint index;" << endl - << endl; + f_service_ << indent() << "guint index;" << '\n' + << '\n'; } - f_service_ << indent() << "self->handler = NULL;" << endl << indent() + f_service_ << indent() << "self->handler = NULL;" << '\n' << indent() << "self->process_map = " - "g_hash_table_new (g_str_hash, g_str_equal);" << endl; + "g_hash_table_new (g_str_hash, g_str_equal);" << '\n'; if (functions.size() > 0) { args_indent = string(21, ' '); - f_service_ << endl + f_service_ << '\n' << indent() << "for (index = 0; index < " - << functions.size() << "; index += 1)" << endl; + << functions.size() << "; index += 1)" << '\n'; indent_up(); - f_service_ << indent() << "g_hash_table_insert (self->process_map," << endl + f_service_ << indent() << "g_hash_table_insert (self->process_map," << '\n' << indent() << args_indent - << class_name_lc << "_process_function_defs[index].name," << endl + << class_name_lc << "_process_function_defs[index].name," << '\n' << indent() << args_indent << "&" << class_name_lc << "_process_function_defs[index]" << ");" - << endl; + << '\n'; indent_down(); } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate processor class initializer - f_service_ << "static void" << endl << class_name_lc << "_class_init (" << class_name - << "Class *cls)" << endl; + f_service_ << "static void" << '\n' << class_name_lc << "_class_init (" << class_name + << "Class *cls)" << '\n'; scope_up(f_service_); - f_service_ << indent() << "GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << endl - << indent() << "ThriftDispatchProcessorClass *dispatch_processor_class =" << endl; + f_service_ << indent() << "GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << '\n' + << indent() << "ThriftDispatchProcessorClass *dispatch_processor_class =" << '\n'; indent_up(); - f_service_ << indent() << "THRIFT_DISPATCH_PROCESSOR_CLASS (cls);" << endl; + f_service_ << indent() << "THRIFT_DISPATCH_PROCESSOR_CLASS (cls);" << '\n'; indent_down(); - f_service_ << indent() << "GParamSpec *param_spec;" << endl << endl << indent() - << "gobject_class->dispose = " << class_name_lc << "_dispose;" << endl << indent() - << "gobject_class->finalize = " << class_name_lc << "_finalize;" << endl << indent() - << "gobject_class->set_property = " << class_name_lc << "_set_property;" << endl + f_service_ << indent() << "GParamSpec *param_spec;" << '\n' << '\n' << indent() + << "gobject_class->dispose = " << class_name_lc << "_dispose;" << '\n' << indent() + << "gobject_class->finalize = " << class_name_lc << "_finalize;" << '\n' << indent() + << "gobject_class->set_property = " << class_name_lc << "_set_property;" << '\n' << indent() << "gobject_class->get_property = " << class_name_lc << "_get_property;" - << endl << endl << indent() + << '\n' << '\n' << indent() << "dispatch_processor_class->dispatch_call = " << class_name_lc << "_dispatch_call;" - << endl << indent() << "cls->dispatch_call = " << class_name_lc << "_dispatch_call;" - << endl << endl << indent() << "param_spec = g_param_spec_object (\"handler\"," - << endl; + << '\n' << indent() << "cls->dispatch_call = " << class_name_lc << "_dispatch_call;" + << '\n' << '\n' << indent() << "param_spec = g_param_spec_object (\"handler\"," + << '\n'; args_indent = indent() + string(34, ' '); - f_service_ << args_indent << "\"Service handler implementation\"," << endl << args_indent - << "\"The service handler implementation \"" << endl << args_indent - << "\"to which method calls are dispatched.\"," << endl << args_indent - << this->nspace_uc + "TYPE_" + service_name_uc + "_HANDLER," << endl << args_indent - << "G_PARAM_READWRITE);" << endl; - f_service_ << indent() << "g_object_class_install_property (gobject_class," << endl; + f_service_ << args_indent << "\"Service handler implementation\"," << '\n' << args_indent + << "\"The service handler implementation \"" << '\n' << args_indent + << "\"to which method calls are dispatched.\"," << '\n' << args_indent + << this->nspace_uc + "TYPE_" + service_name_uc + "_HANDLER," << '\n' << args_indent + << "G_PARAM_READWRITE);" << '\n'; + f_service_ << indent() << "g_object_class_install_property (gobject_class," << '\n'; args_indent = indent() + string(33, ' '); - f_service_ << args_indent << "PROP_" << class_name_uc << "_HANDLER," << endl << args_indent - << "param_spec);" << endl; + f_service_ << args_indent << "PROP_" << class_name_uc << "_HANDLER," << '\n' << args_indent + << "param_spec);" << '\n'; scope_down(f_service_); } @@ -2807,60 +2805,60 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { string args_indent; // write the instance definition - f_types_ << "struct _" << this->nspace << name << endl << "{ " << endl - << " ThriftStruct parent; " << endl << endl << " /* public */" << endl; + f_types_ << "struct _" << this->nspace << name << '\n' << "{ " << '\n' + << " ThriftStruct parent; " << '\n' << '\n' << " /* public */" << '\n'; // for each field, add a member variable vector::const_iterator m_iter; const vector& members = tstruct->get_members(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* t = get_true_type((*m_iter)->get_type()); - f_types_ << " " << type_name(t) << " " << (*m_iter)->get_name() << ";" << endl; + f_types_ << " " << type_name(t) << " " << (*m_iter)->get_name() << ";" << '\n'; if ((*m_iter)->get_req() != t_field::T_REQUIRED) { - f_types_ << " gboolean __isset_" << (*m_iter)->get_name() << ";" << endl; + f_types_ << " gboolean __isset_" << (*m_iter)->get_name() << ";" << '\n'; } } // close the structure definition and create a typedef - f_types_ << "};" << endl << "typedef struct _" << this->nspace << name << " " << this->nspace - << name << ";" << endl << endl; + f_types_ << "};" << '\n' << "typedef struct _" << this->nspace << name << " " << this->nspace + << name << ";" << '\n' << '\n'; // write the class definition - f_types_ << "struct _" << this->nspace << name << "Class" << endl << "{" << endl - << " ThriftStructClass parent;" << endl << "};" << endl << "typedef struct _" - << this->nspace << name << "Class " << this->nspace << name << "Class;" << endl << endl; + f_types_ << "struct _" << this->nspace << name << "Class" << '\n' << "{" << '\n' + << " ThriftStructClass parent;" << '\n' << "};" << '\n' << "typedef struct _" + << this->nspace << name << "Class " << this->nspace << name << "Class;" << '\n' << '\n'; // write the standard GObject boilerplate - f_types_ << "GType " << this->nspace_lc << name_u << "_get_type (void);" << endl << "#define " + f_types_ << "GType " << this->nspace_lc << name_u << "_get_type (void);" << '\n' << "#define " << this->nspace_uc << "TYPE_" << name_uc << " (" << this->nspace_lc << name_u - << "_get_type())" << endl << "#define " << this->nspace_uc << name_uc + << "_get_type())" << '\n' << "#define " << this->nspace_uc << name_uc << "(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_" << name_uc - << ", " << this->nspace << name << "))" << endl << "#define " << this->nspace_uc + << ", " << this->nspace << name << "))" << '\n' << "#define " << this->nspace_uc << name_uc << "_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), " << this->nspace_uc << "_TYPE_" - << name_uc << ", " << this->nspace << name << "Class))" << endl << "#define " + << name_uc << ", " << this->nspace << name << "Class))" << '\n' << "#define " << this->nspace_uc << "IS_" << name_uc << "(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), " - << this->nspace_uc << "TYPE_" << name_uc << "))" << endl << "#define " << this->nspace_uc + << this->nspace_uc << "TYPE_" << name_uc << "))" << '\n' << "#define " << this->nspace_uc << "IS_" << name_uc << "_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), " << this->nspace_uc - << "TYPE_" << name_uc << "))" << endl << "#define " << this->nspace_uc << name_uc + << "TYPE_" << name_uc << "))" << '\n' << "#define " << this->nspace_uc << name_uc << "_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), " << this->nspace_uc << "TYPE_" - << name_uc << ", " << this->nspace << name << "Class))" << endl << endl; + << name_uc << ", " << this->nspace << name << "Class))" << '\n' << '\n'; // start writing the object implementation .c file // generate properties enum if (members.size() > 0) { - f_types_impl_ << "enum _" << class_name << "Properties" << endl << "{" << endl; + f_types_impl_ << "enum _" << class_name << "Properties" << '\n' << "{" << '\n'; indent_up(); f_types_impl_ << indent() << "PROP_" << class_name_uc << "_0"; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { string member_name_uc = to_upper_case(to_lower_case(initial_caps_to_underscores((*m_iter)->get_name()))); - f_types_impl_ << "," << endl << indent() << "PROP_" << class_name_uc << "_" << member_name_uc; + f_types_impl_ << "," << '\n' << indent() << "PROP_" << class_name_uc << "_" << member_name_uc; } - f_types_impl_ << endl; + f_types_impl_ << '\n'; indent_down(); - f_types_impl_ << "};" << endl << endl; + f_types_impl_ << "};" << '\n' << '\n'; } // generate struct I/O methods @@ -2874,12 +2872,12 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { // generate property setter function_name = class_name_lc + "_set_property"; args_indent = string(function_name.length() + 2, ' '); - f_types_impl_ << "static void" << endl << function_name << " (GObject *object," << endl - << args_indent << "guint property_id," << endl << args_indent - << "const GValue *value," << endl << args_indent << "GParamSpec *pspec)" << endl; + f_types_impl_ << "static void" << '\n' << function_name << " (GObject *object," << '\n' + << args_indent << "guint property_id," << '\n' << args_indent + << "const GValue *value," << '\n' << args_indent << "GParamSpec *pspec)" << '\n'; scope_up(f_types_impl_); - f_types_impl_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << endl - << endl << indent() << "switch (property_id)" << endl; + f_types_impl_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << '\n' + << '\n' << indent() << "switch (property_id)" << '\n'; scope_up(f_types_impl_); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* member = (*m_iter); @@ -2890,7 +2888,7 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { string property_identifier = "PROP_" + class_name_uc + "_" + member_name_uc; - f_types_impl_ << indent() << "case " << property_identifier + ":" << endl; + f_types_impl_ << indent() << "case " << property_identifier + ":" << '\n'; indent_up(); if (member_type->is_base_type()) { @@ -2900,7 +2898,7 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { if (base_type->get_base() == t_base_type::TYPE_STRING) { string release_function_name; - f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << endl; + f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << '\n'; indent_up(); if (base_type->is_binary()) { @@ -2912,7 +2910,7 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { } f_types_impl_ << indent() << release_function_name << " (self->" << member_name << ");" - << endl; + << '\n'; indent_down(); } else { switch (base_type->get_base()) { @@ -2944,10 +2942,10 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { } f_types_impl_ << indent() << "self->" << member_name << " = " << assign_function_name - << " (value);" << endl; + << " (value);" << '\n'; } else if (member_type->is_enum()) { f_types_impl_ << indent() << "self->" << member_name << " = g_value_get_int (value);" - << endl; + << '\n'; } else if (member_type->is_container()) { string release_function_name; string assign_function_name; @@ -2969,47 +2967,47 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { assign_function_name = "g_value_dup_boxed"; } - f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << endl; + f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << '\n'; indent_up(); f_types_impl_ << indent() << release_function_name << " (self->" << member_name << ");" - << endl; + << '\n'; indent_down(); f_types_impl_ << indent() << "self->" << member_name << " = " << assign_function_name - << " (value);" << endl; + << " (value);" << '\n'; } else if (member_type->is_struct() || member_type->is_xception()) { - f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << endl; + f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << '\n'; indent_up(); - f_types_impl_ << indent() << "g_object_unref (self->" << member_name << ");" << endl; + f_types_impl_ << indent() << "g_object_unref (self->" << member_name << ");" << '\n'; indent_down(); f_types_impl_ << indent() << "self->" << member_name << " = g_value_dup_object (value);" - << endl; + << '\n'; } if (member->get_req() != t_field::T_REQUIRED) { - f_types_impl_ << indent() << "self->__isset_" << member_name << " = TRUE;" << endl; + f_types_impl_ << indent() << "self->__isset_" << member_name << " = TRUE;" << '\n'; } - f_types_impl_ << indent() << "break;" << endl << endl; + f_types_impl_ << indent() << "break;" << '\n' << '\n'; indent_down(); } - f_types_impl_ << indent() << "default:" << endl; + f_types_impl_ << indent() << "default:" << '\n'; indent_up(); f_types_impl_ << indent() << "G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);" - << endl << indent() << "break;" << endl; + << '\n' << indent() << "break;" << '\n'; indent_down(); scope_down(f_types_impl_); scope_down(f_types_impl_); - f_types_impl_ << endl; + f_types_impl_ << '\n'; // generate property getter function_name = class_name_lc + "_get_property"; args_indent = string(function_name.length() + 2, ' '); - f_types_impl_ << "static void" << endl << function_name << " (GObject *object," << endl - << args_indent << "guint property_id," << endl << args_indent << "GValue *value," - << endl << args_indent << "GParamSpec *pspec)" << endl; + f_types_impl_ << "static void" << '\n' << function_name << " (GObject *object," << '\n' + << args_indent << "guint property_id," << '\n' << args_indent << "GValue *value," + << '\n' << args_indent << "GParamSpec *pspec)" << '\n'; scope_up(f_types_impl_); - f_types_impl_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << endl - << endl << indent() << "switch (property_id)" << endl; + f_types_impl_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << '\n' + << '\n' << indent() << "switch (property_id)" << '\n'; scope_up(f_types_impl_); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* member = (*m_iter); @@ -3070,26 +3068,26 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { "unrecognized type for struct member \"" + member_name + "\""; } - f_types_impl_ << indent() << "case " << property_identifier + ":" << endl; + f_types_impl_ << indent() << "case " << property_identifier + ":" << '\n'; indent_up(); f_types_impl_ << indent() << setter_function_name << " (value, self->" << member_name << ");" - << endl << indent() << "break;" << endl << endl; + << '\n' << indent() << "break;" << '\n' << '\n'; indent_down(); } - f_types_impl_ << indent() << "default:" << endl; + f_types_impl_ << indent() << "default:" << '\n'; indent_up(); f_types_impl_ << indent() << "G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);" - << endl << indent() << "break;" << endl; + << '\n' << indent() << "break;" << '\n'; indent_down(); scope_down(f_types_impl_); scope_down(f_types_impl_); - f_types_impl_ << endl; + f_types_impl_ << '\n'; } // generate the instance init function - f_types_impl_ << "static void " << endl << this->nspace_lc << name_u << "_instance_init (" - << this->nspace << name << " * object)" << endl << "{" << endl; + f_types_impl_ << "static void " << '\n' << this->nspace_lc << name_u << "_instance_init (" + << this->nspace << name << " * object)" << '\n' << "{" << '\n'; indent_up(); // generate default-value structures for container-type members @@ -3109,9 +3107,9 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { // Generate an array with the list literal indent(f_types_impl_) << "static " << type_name(elem_type, false, true) << " __default_" - << member_name << "[" << list.size() << "] = " << endl; + << member_name << "[" << list.size() << "] = " << '\n'; indent_up(); - f_types_impl_ << indent() << constant_literal(member_type, member_value) << ";" << endl; + f_types_impl_ << indent() << constant_literal(member_type, member_value) << ";" << '\n'; indent_down(); constant_declaration_output = true; @@ -3129,15 +3127,15 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { } if (constant_declaration_output) { if (string_list_constant_output) { - indent(f_types_impl_) << "unsigned int list_index;" << endl; + indent(f_types_impl_) << "unsigned int list_index;" << '\n'; } - f_types_impl_ << endl; + f_types_impl_ << '\n'; } // satisfy compilers with -Wall turned on - indent(f_types_impl_) << "/* satisfy -Wall */" << endl << indent() - << "THRIFT_UNUSED_VAR (object);" << endl; + indent(f_types_impl_) << "/* satisfy -Wall */" << '\n' << indent() + << "THRIFT_UNUSED_VAR (object);" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* member_type = (*m_iter)->get_type(); @@ -3153,7 +3151,7 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { } else { dval += t->is_string() ? "NULL" : "0"; } - indent(f_types_impl_) << "object->" << (*m_iter)->get_name() << dval << ";" << endl; + indent(f_types_impl_) << "object->" << (*m_iter)->get_name() << dval << ";" << '\n'; } else if (t->is_struct()) { string name = (*m_iter)->get_name(); t_program* type_program = member_type->get_program(); @@ -3163,10 +3161,10 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { string type_name_uc = to_upper_case(initial_caps_to_underscores(member_type->get_name())); indent(f_types_impl_) << "object->" << name << " = g_object_new (" << to_upper_case(type_nspace_prefix) << "TYPE_" << type_name_uc - << ", NULL);" << endl; + << ", NULL);" << '\n'; } else if (t->is_xception()) { string name = (*m_iter)->get_name(); - indent(f_types_impl_) << "object->" << name << " = NULL;" << endl; + indent(f_types_impl_) << "object->" << name << " = NULL;" << '\n'; } else if (t->is_container()) { string name = (*m_iter)->get_name(); string init_function; @@ -3184,7 +3182,7 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { init_function = generate_new_array_from_type(etype); } - indent(f_types_impl_) << "object->" << name << " = " << init_function << endl; + indent(f_types_impl_) << "object->" << name << " = " << init_function << '\n'; // Pre-populate the container with the specified default values, if any if ((*m_iter)->get_value()) { @@ -3196,17 +3194,17 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { if (is_numeric(etype)) { indent(f_types_impl_) << "g_array_append_vals (object->" << name << ", &__default_" << - name << ", " << list.size() << ");" << endl; + name << ", " << list.size() << ");" << '\n'; } else { indent(f_types_impl_) << "for (list_index = 0; list_index < " << list.size() << "; " << - "list_index += 1)" << endl; + "list_index += 1)" << '\n'; indent_up(); indent(f_types_impl_) << - "g_ptr_array_add (object->" << name << "," << endl << + "g_ptr_array_add (object->" << name << "," << '\n' << indent() << string(17, ' ') << "g_strdup (__default_" << - name << "[list_index]));" << endl; + name << "[list_index]));" << '\n'; indent_down(); } } @@ -3217,36 +3215,36 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { /* if not required, initialize the __isset variable */ if ((*m_iter)->get_req() != t_field::T_REQUIRED) { - indent(f_types_impl_) << "object->__isset_" << (*m_iter)->get_name() << " = FALSE;" << endl; + indent(f_types_impl_) << "object->__isset_" << (*m_iter)->get_name() << " = FALSE;" << '\n'; } } indent_down(); - f_types_impl_ << "}" << endl << endl; + f_types_impl_ << "}" << '\n' << '\n'; /* create the destructor */ - f_types_impl_ << "static void " << endl << this->nspace_lc << name_u - << "_finalize (GObject *object)" << endl << "{" << endl; + f_types_impl_ << "static void " << '\n' << this->nspace_lc << name_u + << "_finalize (GObject *object)" << '\n' << "{" << '\n'; indent_up(); f_types_impl_ << indent() << this->nspace << name << " *tobject = " << this->nspace_uc << name_uc - << " (object);" << endl << endl; + << " (object);" << '\n' << '\n'; - f_types_impl_ << indent() << "/* satisfy -Wall in case we don't use tobject */" << endl - << indent() << "THRIFT_UNUSED_VAR (tobject);" << endl; + f_types_impl_ << indent() << "/* satisfy -Wall in case we don't use tobject */" << '\n' + << indent() << "THRIFT_UNUSED_VAR (tobject);" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* t = get_true_type((*m_iter)->get_type()); if (t->is_container()) { string name = (*m_iter)->get_name(); if (t->is_map() || t->is_set()) { - f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << endl; - f_types_impl_ << indent() << "{" << endl; + f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << '\n'; + f_types_impl_ << indent() << "{" << '\n'; indent_up(); - f_types_impl_ << indent() << "g_hash_table_destroy (tobject->" << name << ");" << endl; - f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << endl; + f_types_impl_ << indent() << "g_hash_table_destroy (tobject->" << name << ");" << '\n'; + f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << '\n'; indent_down(); - f_types_impl_ << indent() << "}" << endl; + f_types_impl_ << indent() << "}" << '\n'; } else if (t->is_list()) { t_type* etype = ((t_list*)t)->get_elem_type(); string destructor_function = "g_ptr_array_unref"; @@ -3273,59 +3271,59 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { destructor_function = "g_array_unref"; } - f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << endl; - f_types_impl_ << indent() << "{" << endl; + f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << '\n'; + f_types_impl_ << indent() << "{" << '\n'; indent_up(); - f_types_impl_ << indent() << destructor_function << " (tobject->" << name << ");" << endl; - f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << endl; + f_types_impl_ << indent() << destructor_function << " (tobject->" << name << ");" << '\n'; + f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << '\n'; indent_down(); - f_types_impl_ << indent() << "}" << endl; + f_types_impl_ << indent() << "}" << '\n'; } } else if (t->is_struct() || t->is_xception()) { string name = (*m_iter)->get_name(); // TODO: g_clear_object needs glib >= 2.28 - // f_types_impl_ << indent() << "g_clear_object (&(tobject->" << name << "));" << endl; + // f_types_impl_ << indent() << "g_clear_object (&(tobject->" << name << "));" << '\n'; // does g_object_unref the trick? - f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << endl; - f_types_impl_ << indent() << "{" << endl; + f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << '\n'; + f_types_impl_ << indent() << "{" << '\n'; indent_up(); - f_types_impl_ << indent() << "g_object_unref(tobject->" << name << ");" << endl; - f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << endl; + f_types_impl_ << indent() << "g_object_unref(tobject->" << name << ");" << '\n'; + f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << '\n'; indent_down(); - f_types_impl_ << indent() << "}" << endl; + f_types_impl_ << indent() << "}" << '\n'; } else if (t->is_string()) { string name = (*m_iter)->get_name(); - f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << endl; - f_types_impl_ << indent() << "{" << endl; + f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << '\n'; + f_types_impl_ << indent() << "{" << '\n'; indent_up(); f_types_impl_ << indent() << generate_free_func_from_type(t) << "(tobject->" << name << ");" - << endl; - f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << endl; + << '\n'; + f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << '\n'; indent_down(); - f_types_impl_ << indent() << "}" << endl; + f_types_impl_ << indent() << "}" << '\n'; } } indent_down(); - f_types_impl_ << "}" << endl << endl; + f_types_impl_ << "}" << '\n' << '\n'; // generate the class init function - f_types_impl_ << "static void" << endl << class_name_lc << "_class_init (" << class_name - << "Class * cls)" << endl; + f_types_impl_ << "static void" << '\n' << class_name_lc << "_class_init (" << class_name + << "Class * cls)" << '\n'; scope_up(f_types_impl_); - f_types_impl_ << indent() << "GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << endl + f_types_impl_ << indent() << "GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << '\n' << indent() << "ThriftStructClass *struct_class = " - << "THRIFT_STRUCT_CLASS (cls);" << endl << endl << indent() - << "struct_class->read = " << class_name_lc << "_read;" << endl << indent() - << "struct_class->write = " << class_name_lc << "_write;" << endl << endl + << "THRIFT_STRUCT_CLASS (cls);" << '\n' << '\n' << indent() + << "struct_class->read = " << class_name_lc << "_read;" << '\n' << indent() + << "struct_class->write = " << class_name_lc << "_write;" << '\n' << '\n' << indent() << "gobject_class->finalize = " << class_name_lc << "_finalize;" - << endl; + << '\n'; if (members.size() > 0) { f_types_impl_ << indent() << "gobject_class->get_property = " << class_name_lc - << "_get_property;" << endl << indent() - << "gobject_class->set_property = " << class_name_lc << "_set_property;" << endl; + << "_get_property;" << '\n' << indent() + << "gobject_class->set_property = " << class_name_lc << "_set_property;" << '\n'; // install a property for each member for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -3338,11 +3336,11 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { string property_identifier = "PROP_" + class_name_uc + "_" + member_name_uc; - f_types_impl_ << endl << indent() << "g_object_class_install_property" << endl; + f_types_impl_ << '\n' << indent() << "g_object_class_install_property" << '\n'; indent_up(); args_indent = indent() + ' '; - f_types_impl_ << indent() << "(gobject_class," << endl << args_indent << property_identifier - << "," << endl << args_indent; + f_types_impl_ << indent() << "(gobject_class," << '\n' << args_indent << property_identifier + << "," << '\n' << args_indent; if (member_type->is_base_type()) { t_base_type::t_base base_type = ((t_base_type*)member_type)->get_base(); @@ -3350,27 +3348,27 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { if (base_type == t_base_type::TYPE_STRING) { if (((t_base_type*)member_type)->is_binary()) { args_indent += string(20, ' '); - f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << endl << args_indent - << "NULL," << endl << args_indent << "NULL," << endl << args_indent - << "G_TYPE_BYTE_ARRAY," << endl << args_indent << "G_PARAM_READWRITE));" - << endl; + f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << '\n' << args_indent + << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent + << "G_TYPE_BYTE_ARRAY," << '\n' << args_indent << "G_PARAM_READWRITE));" + << '\n'; } else { args_indent += string(21, ' '); - f_types_impl_ << "g_param_spec_string (\"" << member_name << "\"," << endl - << args_indent << "NULL," << endl << args_indent << "NULL," << endl + f_types_impl_ << "g_param_spec_string (\"" << member_name << "\"," << '\n' + << args_indent << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent << ((member_value != NULL) ? "\"" + member_value->get_string() + "\"" - : "NULL") << "," << endl << args_indent - << "G_PARAM_READWRITE));" << endl; + : "NULL") << "," << '\n' << args_indent + << "G_PARAM_READWRITE));" << '\n'; } } else if (base_type == t_base_type::TYPE_BOOL) { args_indent += string(22, ' '); - f_types_impl_ << "g_param_spec_boolean (\"" << member_name << "\"," << endl << args_indent - << "NULL," << endl << args_indent << "NULL," << endl << args_indent + f_types_impl_ << "g_param_spec_boolean (\"" << member_name << "\"," << '\n' << args_indent + << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent << (((member_value != NULL) && (member_value->get_integer() != 0)) ? "TRUE" - : "FALSE") << "," << endl << args_indent << "G_PARAM_READWRITE));" - << endl; + : "FALSE") << "," << '\n' << args_indent << "G_PARAM_READWRITE));" + << '\n'; } else if ((base_type == t_base_type::TYPE_I8) || (base_type == t_base_type::TYPE_I16) || (base_type == t_base_type::TYPE_I32) || (base_type == t_base_type::TYPE_I64) || (base_type == t_base_type::TYPE_DOUBLE)) { @@ -3423,11 +3421,11 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { } args_indent += string(param_spec_function_name.length() + 2, ' '); - f_types_impl_ << param_spec_function_name << " (\"" << member_name << "\"," << endl - << args_indent << "NULL," << endl << args_indent << "NULL," << endl - << args_indent << min_value << "," << endl << args_indent << max_value - << "," << endl << args_indent << default_value.str() << "," << endl - << args_indent << "G_PARAM_READWRITE));" << endl; + f_types_impl_ << param_spec_function_name << " (\"" << member_name << "\"," << '\n' + << args_indent << "NULL," << '\n' << args_indent << "NULL," << '\n' + << args_indent << min_value << "," << '\n' << args_indent << max_value + << "," << '\n' << args_indent << default_value.str() << "," << '\n' + << args_indent << "G_PARAM_READWRITE));" << '\n'; } indent_down(); @@ -3438,11 +3436,11 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { int max_value = (enum_max_value != nullptr) ? enum_max_value->get_value() : 0; args_indent += string(18, ' '); - f_types_impl_ << "g_param_spec_int (\"" << member_name << "\"," << endl << args_indent - << "NULL," << endl << args_indent << "NULL," << endl << args_indent - << min_value << "," << endl << args_indent << max_value << "," << endl - << args_indent << min_value << "," << endl << args_indent - << "G_PARAM_READWRITE));" << endl; + f_types_impl_ << "g_param_spec_int (\"" << member_name << "\"," << '\n' << args_indent + << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent + << min_value << "," << '\n' << args_indent << max_value << "," << '\n' + << args_indent << min_value << "," << '\n' << args_indent + << "G_PARAM_READWRITE));" << '\n'; indent_down(); } else if (member_type->is_struct() || member_type->is_xception()) { t_program* type_program = member_type->get_program(); @@ -3454,9 +3452,9 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { + to_upper_case(initial_caps_to_underscores(member_type->get_name())); args_indent += string(20, ' '); - f_types_impl_ << "g_param_spec_object (\"" << member_name << "\"," << endl << args_indent - << "NULL," << endl << args_indent << "NULL," << endl << args_indent - << param_type << "," << endl << args_indent << "G_PARAM_READWRITE));" << endl; + f_types_impl_ << "g_param_spec_object (\"" << member_name << "\"," << '\n' << args_indent + << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent + << param_type << "," << '\n' << args_indent << "G_PARAM_READWRITE));" << '\n'; indent_down(); } else if (member_type->is_list()) { t_type* elem_type = ((t_list*)member_type)->get_elem_type(); @@ -3469,38 +3467,38 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) { } args_indent += string(20, ' '); - f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << endl << args_indent - << "NULL," << endl << args_indent << "NULL," << endl << args_indent - << param_type << "," << endl << args_indent << "G_PARAM_READWRITE));" << endl; + f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << '\n' << args_indent + << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent + << param_type << "," << '\n' << args_indent << "G_PARAM_READWRITE));" << '\n'; indent_down(); } else if (member_type->is_set() || member_type->is_map()) { args_indent += string(20, ' '); - f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << endl << args_indent - << "NULL," << endl << args_indent << "NULL," << endl << args_indent - << "G_TYPE_HASH_TABLE," << endl << args_indent << "G_PARAM_READWRITE));" - << endl; + f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << '\n' << args_indent + << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent + << "G_TYPE_HASH_TABLE," << '\n' << args_indent << "G_PARAM_READWRITE));" + << '\n'; indent_down(); } } } scope_down(f_types_impl_); - f_types_impl_ << endl; - - f_types_impl_ << "GType" << endl << this->nspace_lc << name_u << "_get_type (void)" << endl << "{" - << endl << " static GType type = 0;" << endl << endl << " if (type == 0) " << endl - << " {" << endl << " static const GTypeInfo type_info = " << endl << " {" - << endl << " sizeof (" << this->nspace << name << "Class)," << endl - << " NULL, /* base_init */" << endl << " NULL, /* base_finalize */" - << endl << " (GClassInitFunc) " << this->nspace_lc << name_u << "_class_init," - << endl << " NULL, /* class_finalize */" << endl - << " NULL, /* class_data */" << endl << " sizeof (" << this->nspace - << name << ")," << endl << " 0, /* n_preallocs */" << endl + f_types_impl_ << '\n'; + + f_types_impl_ << "GType" << '\n' << this->nspace_lc << name_u << "_get_type (void)" << '\n' << "{" + << '\n' << " static GType type = 0;" << '\n' << '\n' << " if (type == 0) " << '\n' + << " {" << '\n' << " static const GTypeInfo type_info = " << '\n' << " {" + << '\n' << " sizeof (" << this->nspace << name << "Class)," << '\n' + << " NULL, /* base_init */" << '\n' << " NULL, /* base_finalize */" + << '\n' << " (GClassInitFunc) " << this->nspace_lc << name_u << "_class_init," + << '\n' << " NULL, /* class_finalize */" << '\n' + << " NULL, /* class_data */" << '\n' << " sizeof (" << this->nspace + << name << ")," << '\n' << " 0, /* n_preallocs */" << '\n' << " (GInstanceInitFunc) " << this->nspace_lc << name_u << "_instance_init," - << endl << " NULL, /* value_table */" << endl << " };" << endl << endl - << " type = g_type_register_static (THRIFT_TYPE_STRUCT, " << endl + << '\n' << " NULL, /* value_table */" << '\n' << " };" << '\n' << '\n' + << " type = g_type_register_static (THRIFT_TYPE_STRUCT, " << '\n' << " \"" << this->nspace << name << "Type\"," - << endl << " &type_info, 0);" << endl << " }" - << endl << endl << " return type;" << endl << "}" << endl << endl; + << '\n' << " &type_info, 0);" << '\n' << " }" + << '\n' << '\n' << " return type;" << '\n' << "}" << '\n' << '\n'; } /** @@ -3521,59 +3519,59 @@ void t_c_glib_generator::generate_struct_writer(ostream& out, if (is_function) { error_ret = -1; - indent(out) << "static gint32" << endl << this->nspace_lc << name_u + indent(out) << "static gint32" << '\n' << this->nspace_lc << name_u << "_write (ThriftStruct *object, ThriftProtocol *protocol, GError **error)" - << endl; + << '\n'; } - indent(out) << "{" << endl; + indent(out) << "{" << '\n'; indent_up(); - out << indent() << "gint32 ret;" << endl << indent() << "gint32 xfer = 0;" << endl << endl; + out << indent() << "gint32 ret;" << '\n' << indent() << "gint32 xfer = 0;" << '\n' << '\n'; - indent(out) << this_get << endl; + indent(out) << this_get << '\n'; // satisfy -Wall in the case of an empty struct if (!this_get.empty()) { - indent(out) << "THRIFT_UNUSED_VAR (this_object);" << endl; + indent(out) << "THRIFT_UNUSED_VAR (this_object);" << '\n'; } out << indent() << "if ((ret = thrift_protocol_write_struct_begin (protocol, \"" << name - << "\", error)) < 0)" << endl << indent() << " return " << error_ret << ";" << endl - << indent() << "xfer += ret;" << endl; + << "\", error)) < 0)" << '\n' << indent() << " return " << error_ret << ";" << '\n' + << indent() << "xfer += ret;" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_OPTIONAL) { - indent(out) << "if (this_object->__isset_" << (*f_iter)->get_name() << " == TRUE) {" << endl; + indent(out) << "if (this_object->__isset_" << (*f_iter)->get_name() << " == TRUE) {" << '\n'; indent_up(); } out << indent() << "if ((ret = thrift_protocol_write_field_begin (protocol, " << "\"" << (*f_iter)->get_name() << "\", " << type_to_enum((*f_iter)->get_type()) << ", " - << (*f_iter)->get_key() << ", error)) < 0)" << endl << indent() << " return " << error_ret - << ";" << endl << indent() << "xfer += ret;" << endl; + << (*f_iter)->get_key() << ", error)) < 0)" << '\n' << indent() << " return " << error_ret + << ";" << '\n' << indent() << "xfer += ret;" << '\n'; generate_serialize_field(out, *f_iter, this_name, "", error_ret); - out << indent() << "if ((ret = thrift_protocol_write_field_end (protocol, error)) < 0)" << endl - << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" - << endl; + out << indent() << "if ((ret = thrift_protocol_write_field_end (protocol, error)) < 0)" << '\n' + << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" + << '\n'; if ((*f_iter)->get_req() == t_field::T_OPTIONAL) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } // write the struct map - out << indent() << "if ((ret = thrift_protocol_write_field_stop (protocol, error)) < 0)" << endl - << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" << endl - << indent() << "if ((ret = thrift_protocol_write_struct_end (protocol, error)) < 0)" << endl - << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" << endl - << endl; + out << indent() << "if ((ret = thrift_protocol_write_field_stop (protocol, error)) < 0)" << '\n' + << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" << '\n' + << indent() << "if ((ret = thrift_protocol_write_struct_end (protocol, error)) < 0)" << '\n' + << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" << '\n' + << '\n'; if (is_function) { - indent(out) << "return xfer;" << endl; + indent(out) << "return xfer;" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -3593,127 +3591,127 @@ void t_c_glib_generator::generate_struct_reader(ostream& out, if (is_function) { error_ret = -1; - indent(out) << "/* reads a " << name_u << " object */" << endl << "static gint32" << endl + indent(out) << "/* reads a " << name_u << " object */" << '\n' << "static gint32" << '\n' << this->nspace_lc << name_u - << "_read (ThriftStruct *object, ThriftProtocol *protocol, GError **error)" << endl; + << "_read (ThriftStruct *object, ThriftProtocol *protocol, GError **error)" << '\n'; } - indent(out) << "{" << endl; + indent(out) << "{" << '\n'; indent_up(); // declare stack temp variables - out << indent() << "gint32 ret;" << endl << indent() << "gint32 xfer = 0;" << endl << indent() - << "gchar *name = NULL;" << endl << indent() << "ThriftType ftype;" << endl << indent() - << "gint16 fid;" << endl << indent() << "guint32 len = 0;" << endl << indent() - << "gpointer data = NULL;" << endl << indent() << this_get << endl; + out << indent() << "gint32 ret;" << '\n' << indent() << "gint32 xfer = 0;" << '\n' << indent() + << "gchar *name = NULL;" << '\n' << indent() << "ThriftType ftype;" << '\n' << indent() + << "gint16 fid;" << '\n' << indent() << "guint32 len = 0;" << '\n' << indent() + << "gpointer data = NULL;" << '\n' << indent() << this_get << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { - indent(out) << "gboolean isset_" << (*f_iter)->get_name() << " = FALSE;" << endl; + indent(out) << "gboolean isset_" << (*f_iter)->get_name() << " = FALSE;" << '\n'; } } - out << endl; + out << '\n'; // satisfy -Wall in case we don't use some variables - out << indent() << "/* satisfy -Wall in case these aren't used */" << endl << indent() - << "THRIFT_UNUSED_VAR (len);" << endl << indent() << "THRIFT_UNUSED_VAR (data);" << endl; + out << indent() << "/* satisfy -Wall in case these aren't used */" << '\n' << indent() + << "THRIFT_UNUSED_VAR (len);" << '\n' << indent() << "THRIFT_UNUSED_VAR (data);" << '\n'; if (!this_get.empty()) { - out << indent() << "THRIFT_UNUSED_VAR (this_object);" << endl; + out << indent() << "THRIFT_UNUSED_VAR (this_object);" << '\n'; } - out << endl; + out << '\n'; // read the beginning of the structure marker - out << indent() << "/* read the struct begin marker */" << endl << indent() - << "if ((ret = thrift_protocol_read_struct_begin (protocol, &name, error)) < 0)" << endl - << indent() << "{" << endl << indent() << " if (name) g_free (name);" << endl << indent() - << " return " << error_ret << ";" << endl << indent() << "}" << endl << indent() - << "xfer += ret;" << endl << indent() << "if (name) g_free (name);" << endl << indent() - << "name = NULL;" << endl << endl; + out << indent() << "/* read the struct begin marker */" << '\n' << indent() + << "if ((ret = thrift_protocol_read_struct_begin (protocol, &name, error)) < 0)" << '\n' + << indent() << "{" << '\n' << indent() << " if (name) g_free (name);" << '\n' << indent() + << " return " << error_ret << ";" << '\n' << indent() << "}" << '\n' << indent() + << "xfer += ret;" << '\n' << indent() << "if (name) g_free (name);" << '\n' << indent() + << "name = NULL;" << '\n' << '\n'; // read the struct fields - out << indent() << "/* read the struct fields */" << endl << indent() << "while (1)" << endl; + out << indent() << "/* read the struct fields */" << '\n' << indent() << "while (1)" << '\n'; scope_up(out); // read beginning field marker - out << indent() << "/* read the beginning of a field */" << endl << indent() + out << indent() << "/* read the beginning of a field */" << '\n' << indent() << "if ((ret = thrift_protocol_read_field_begin (protocol, &name, &ftype, &fid, error)) < 0)" - << endl << indent() << "{" << endl << indent() << " if (name) g_free (name);" << endl - << indent() << " return " << error_ret << ";" << endl << indent() << "}" << endl << indent() - << "xfer += ret;" << endl << indent() << "if (name) g_free (name);" << endl << indent() - << "name = NULL;" << endl << endl; + << '\n' << indent() << "{" << '\n' << indent() << " if (name) g_free (name);" << '\n' + << indent() << " return " << error_ret << ";" << '\n' << indent() << "}" << '\n' << indent() + << "xfer += ret;" << '\n' << indent() << "if (name) g_free (name);" << '\n' << indent() + << "name = NULL;" << '\n' << '\n'; // check for field STOP marker - out << indent() << "/* break if we get a STOP field */" << endl << indent() - << "if (ftype == T_STOP)" << endl << indent() << "{" << endl << indent() << " break;" << endl - << indent() << "}" << endl << endl; + out << indent() << "/* break if we get a STOP field */" << '\n' << indent() + << "if (ftype == T_STOP)" << '\n' << indent() << "{" << '\n' << indent() << " break;" << '\n' + << indent() << "}" << '\n' << '\n'; // switch depending on the field type - indent(out) << "switch (fid)" << endl; + indent(out) << "switch (fid)" << '\n'; // start switch scope_up(out); // generate deserialization code for known types for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - indent(out) << "case " << (*f_iter)->get_key() << ":" << endl; + indent(out) << "case " << (*f_iter)->get_key() << ":" << '\n'; indent_up(); - indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ")" << endl; - indent(out) << "{" << endl; + indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ")" << '\n'; + indent(out) << "{" << '\n'; indent_up(); // generate deserialize field generate_deserialize_field(out, *f_iter, this_name, "", error_ret, false); indent_down(); - out << indent() << "} else {" << endl << indent() - << " if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0)" << endl << indent() - << " return " << error_ret << ";" << endl << indent() << " xfer += ret;" << endl - << indent() << "}" << endl << indent() << "break;" << endl; + out << indent() << "} else {" << '\n' << indent() + << " if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0)" << '\n' << indent() + << " return " << error_ret << ";" << '\n' << indent() << " xfer += ret;" << '\n' + << indent() << "}" << '\n' << indent() << "break;" << '\n'; indent_down(); } // create the default case - out << indent() << "default:" << endl << indent() - << " if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0)" << endl << indent() - << " return " << error_ret << ";" << endl << indent() << " xfer += ret;" << endl - << indent() << " break;" << endl; + out << indent() << "default:" << '\n' << indent() + << " if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0)" << '\n' << indent() + << " return " << error_ret << ";" << '\n' << indent() << " xfer += ret;" << '\n' + << indent() << " break;" << '\n'; // end switch scope_down(out); // read field end marker - out << indent() << "if ((ret = thrift_protocol_read_field_end (protocol, error)) < 0)" << endl - << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" << endl; + out << indent() << "if ((ret = thrift_protocol_read_field_end (protocol, error)) < 0)" << '\n' + << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" << '\n'; // end while loop scope_down(out); - out << endl; + out << '\n'; // read the end of the structure - out << indent() << "if ((ret = thrift_protocol_read_struct_end (protocol, error)) < 0)" << endl - << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" << endl - << endl; + out << indent() << "if ((ret = thrift_protocol_read_struct_end (protocol, error)) < 0)" << '\n' + << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" << '\n' + << '\n'; // if a required field is missing, throw an error for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { - out << indent() << "if (!isset_" << (*f_iter)->get_name() << ")" << endl << indent() << "{" - << endl << indent() << " g_set_error (error, THRIFT_PROTOCOL_ERROR," << endl << indent() - << " THRIFT_PROTOCOL_ERROR_INVALID_DATA," << endl << indent() - << " \"missing field\");" << endl << indent() << " return -1;" << endl - << indent() << "}" << endl << endl; + out << indent() << "if (!isset_" << (*f_iter)->get_name() << ")" << '\n' << indent() << "{" + << '\n' << indent() << " g_set_error (error, THRIFT_PROTOCOL_ERROR," << '\n' << indent() + << " THRIFT_PROTOCOL_ERROR_INVALID_DATA," << '\n' << indent() + << " \"missing field\");" << '\n' << indent() << " return -1;" << '\n' + << indent() << "}" << '\n' << '\n'; } } if (is_function) { - indent(out) << "return xfer;" << endl; + indent(out) << "return xfer;" << '\n'; } // end the function/structure indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } void t_c_glib_generator::generate_serialize_field(ostream& out, @@ -3773,9 +3771,9 @@ void t_c_glib_generator::generate_serialize_field(ostream& out, } else { out << "i32 (protocol, (gint32) " << name; } - out << ", error)) < 0)" << endl - << indent() << " return " << error_ret << ";" << endl - << indent() << "xfer += ret;" << endl << endl; + out << ", error)) < 0)" << '\n' + << indent() << " return " << error_ret << ";" << '\n' + << indent() << "xfer += ret;" << '\n' << '\n'; } else { throw std::logic_error("DO NOT KNOW HOW TO SERIALIZE FIELD '" + name + "' TYPE '" + type_name(type)); @@ -3788,8 +3786,8 @@ void t_c_glib_generator::generate_serialize_struct(ostream& out, int error_ret) { (void)tstruct; out << indent() << "if ((ret = thrift_struct_write (THRIFT_STRUCT (" << prefix - << "), protocol, error)) < 0)" << endl << indent() << " return " << error_ret << ";" << endl - << indent() << "xfer += ret;" << endl << endl; + << "), protocol, error)) < 0)" << '\n' << indent() << " return " << error_ret << ";" << '\n' + << indent() << "xfer += ret;" << '\n' << '\n'; } void t_c_glib_generator::generate_serialize_container(ostream& out, @@ -3826,39 +3824,39 @@ void t_c_glib_generator::generate_serialize_container(ostream& out, * This is because we may exit early before we get a chance to free the * GList. */ - out << indent() << "GList *key_list = NULL, *iter = NULL;" << endl - << indent() << tkey_name << tkey_ptr << "* keys;" << endl - << indent() << "int i = 0, key_count;" << endl - << endl + out << indent() << "GList *key_list = NULL, *iter = NULL;" << '\n' + << indent() << tkey_name << tkey_ptr << "* keys;" << '\n' + << indent() << "int i = 0, key_count;" << '\n' + << '\n' << indent() << "if ((ret = thrift_protocol_write_map_begin (protocol, " << type_to_enum(tkey) << ", " << type_to_enum(tval) << ", " << prefix << " ? " << "(gint32) g_hash_table_size ((GHashTable *) " << prefix << ") : 0" - << ", error)) < 0)" << endl; + << ", error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl - << indent() << "if (" << prefix << ")" << endl + out << indent() << "xfer += ret;" << '\n' + << indent() << "if (" << prefix << ")" << '\n' << indent() << " g_hash_table_foreach ((GHashTable *) " << prefix - << ", thrift_hash_table_get_keys, &key_list);" << endl - << indent() << "key_count = g_list_length (key_list);" << endl + << ", thrift_hash_table_get_keys, &key_list);" << '\n' + << indent() << "key_count = g_list_length (key_list);" << '\n' << indent() << "keys = g_newa (" << tkey_name << tkey_ptr - << ", key_count);" << endl + << ", key_count);" << '\n' << indent() << "for (iter = g_list_first (key_list); iter; " - "iter = iter->next)" << endl; + "iter = iter->next)" << '\n'; indent_up(); out << indent() << "keys[i++] = (" << tkey_name << tkey_ptr - << ") iter->data;" << endl; + << ") iter->data;" << '\n'; indent_down(); - out << indent() << "g_list_free (key_list);" << endl - << endl - << indent() << "for (i = 0; i < key_count; ++i)" << endl; + out << indent() << "g_list_free (key_list);" << '\n' + << '\n' + << indent() << "for (i = 0; i < key_count; ++i)" << '\n'; scope_up(out); - out << indent() << keyname << " = keys[i];" << endl + out << indent() << keyname << " = keys[i];" << '\n' << indent() << valname << " = (" << tval_name << tval_ptr << ") g_hash_table_lookup (((GHashTable *) " << prefix - << "), (gpointer) " << keyname << ");" << endl - << endl; + << "), (gpointer) " << keyname << ");" << '\n' + << '\n'; generate_serialize_map_element(out, (t_map*)ttype, tkey_ptr + " " + keyname, @@ -3866,84 +3864,84 @@ void t_c_glib_generator::generate_serialize_container(ostream& out, error_ret); scope_down(out); out << indent() << "if ((ret = thrift_protocol_write_map_end (protocol, " - "error)) < 0)" << endl; + "error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl; + out << indent() << "xfer += ret;" << '\n'; } else if (ttype->is_set()) { t_type* telem = ((t_set*)ttype)->get_elem_type(); string telem_name = type_name(telem); string telem_ptr = telem->is_string() || !telem->is_base_type() ? "" : "*"; - out << indent() << "GList *key_list = NULL, *iter = NULL;" << endl - << indent() << telem_name << telem_ptr << "* keys;" << endl - << indent() << "int i = 0, key_count;" << endl - << indent() << telem_name << telem_ptr << " elem;" << endl - << indent() << "gpointer value;" << endl - << indent() << "THRIFT_UNUSED_VAR (value);" << endl - << endl + out << indent() << "GList *key_list = NULL, *iter = NULL;" << '\n' + << indent() << telem_name << telem_ptr << "* keys;" << '\n' + << indent() << "int i = 0, key_count;" << '\n' + << indent() << telem_name << telem_ptr << " elem;" << '\n' + << indent() << "gpointer value;" << '\n' + << indent() << "THRIFT_UNUSED_VAR (value);" << '\n' + << '\n' << indent() << "if ((ret = thrift_protocol_write_set_begin (protocol, " << type_to_enum(telem) << ", " << prefix << " ? " << "(gint32) g_hash_table_size ((GHashTable *) " << prefix << ") : 0" - << ", error)) < 0)" << endl; + << ", error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl - << indent() << "if (" << prefix << ")" << endl + out << indent() << "xfer += ret;" << '\n' + << indent() << "if (" << prefix << ")" << '\n' << indent() << " g_hash_table_foreach ((GHashTable *) " << prefix - << ", thrift_hash_table_get_keys, &key_list);" << endl - << indent() << "key_count = g_list_length (key_list);" << endl + << ", thrift_hash_table_get_keys, &key_list);" << '\n' + << indent() << "key_count = g_list_length (key_list);" << '\n' << indent() << "keys = g_newa (" << telem_name << telem_ptr - << ", key_count);" << endl + << ", key_count);" << '\n' << indent() << "for (iter = g_list_first (key_list); iter; " - "iter = iter->next)" << endl; + "iter = iter->next)" << '\n'; indent_up(); out << indent() << "keys[i++] = (" << telem_name << telem_ptr - << ") iter->data;" << endl; + << ") iter->data;" << '\n'; indent_down(); - out << indent() << "g_list_free (key_list);" << endl - << endl - << indent() << "for (i = 0; i < key_count; ++i)" << endl; + out << indent() << "g_list_free (key_list);" << '\n' + << '\n' + << indent() << "for (i = 0; i < key_count; ++i)" << '\n'; scope_up(out); - out << indent() << "elem = keys[i];" << endl + out << indent() << "elem = keys[i];" << '\n' << indent() << "value = (gpointer) g_hash_table_lookup " - "(((GHashTable *) " << prefix << "), (gpointer) elem);" << endl - << endl; + "(((GHashTable *) " << prefix << "), (gpointer) elem);" << '\n' + << '\n'; generate_serialize_set_element(out, (t_set*)ttype, telem_ptr + "elem", error_ret); scope_down(out); out << indent() << "if ((ret = thrift_protocol_write_set_end (protocol, " - "error)) < 0)" << endl; + "error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl; + out << indent() << "xfer += ret;" << '\n'; } else if (ttype->is_list()) { string length = "(" + prefix + " ? " + prefix + "->len : 0)"; string i = tmp("i"); - out << indent() << "guint " << i << ";" << endl - << endl + out << indent() << "guint " << i << ";" << '\n' + << '\n' << indent() << "if ((ret = thrift_protocol_write_list_begin (protocol, " << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", (gint32) " - << length << ", error)) < 0)" << endl; + << length << ", error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl + out << indent() << "xfer += ret;" << '\n' << indent() << "for (" << i << " = 0; " << i << " < " << length << "; " - << i << "++)" << endl; + << i << "++)" << '\n'; scope_up(out); generate_serialize_list_element(out, (t_list*)ttype, prefix, i, error_ret); scope_down(out); out << indent() << "if ((ret = thrift_protocol_write_list_end (protocol, " - "error)) < 0)" << endl; + "error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl; + out << indent() << "xfer += ret;" << '\n'; } scope_down(out); @@ -4023,11 +4021,11 @@ void t_c_glib_generator::generate_deserialize_field(ostream& out, } else if (type->is_base_type()) { t_base_type::t_base tbase = ((t_base_type*)type)->get_base(); if (tbase == t_base_type::TYPE_STRING) { - indent(out) << "if (" << name << " != NULL)" << endl << indent() << "{" << endl; + indent(out) << "if (" << name << " != NULL)" << '\n' << indent() << "{" << '\n'; indent_up(); - indent(out) << "g_free(" << name << ");" << endl << indent() << name << " = NULL;" << endl; + indent(out) << "g_free(" << name << ");" << '\n' << indent() << name << " = NULL;" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } indent(out) << "if ((ret = thrift_protocol_read_"; @@ -4063,22 +4061,22 @@ void t_c_glib_generator::generate_deserialize_field(ostream& out, default: throw "compiler error: no C reader for base type " + t_base_type::t_base_name(tbase) + name; } - out << ", error)) < 0)" << endl; - out << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" - << endl; + out << ", error)) < 0)" << '\n'; + out << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" + << '\n'; // load the byte array with the data if (tbase == t_base_type::TYPE_STRING && type->is_binary()) { - indent(out) << name << " = g_byte_array_new();" << endl; - indent(out) << "g_byte_array_append (" << name << ", (guint8 *) data, (guint) len);" << endl; - indent(out) << "g_free (data);" << endl; + indent(out) << name << " = g_byte_array_new();" << '\n'; + indent(out) << "g_byte_array_append (" << name << ", (guint8 *) data, (guint) len);" << '\n'; + indent(out) << "g_free (data);" << '\n'; } } else if (type->is_enum()) { string t = tmp("ecast"); - out << indent() << "gint32 " << t << ";" << endl << indent() - << "if ((ret = thrift_protocol_read_i32 (protocol, &" << t << ", error)) < 0)" << endl - << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" << endl - << indent() << name << " = (" << type_name(type) << ")" << t << ";" << endl; + out << indent() << "gint32 " << t << ";" << '\n' << indent() + << "if ((ret = thrift_protocol_read_i32 (protocol, &" << t << ", error)) < 0)" << '\n' + << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" << '\n' + << indent() << name << " = (" << type_name(type) << ")" << t << ";" << '\n'; } else { throw std::logic_error("DO NOT KNOW HOW TO SERIALIZE FIELD '" + tfield->get_name() + "' TYPE '" + type_name(type)); @@ -4088,9 +4086,9 @@ void t_c_glib_generator::generate_deserialize_field(ostream& out, // set the isset variable. if the type is required, then set the // local variable indicating the value was set, so that we can do // validation later. if (prefix != "" && tfield->get_req() != t_field::T_REQUIRED) { - indent(out) << prefix << "__isset_" << tfield->get_name() << suffix << " = TRUE;" << endl; + indent(out) << prefix << "__isset_" << tfield->get_name() << suffix << " = TRUE;" << '\n'; } else if (prefix != "" && tfield->get_req() == t_field::T_REQUIRED) { - indent(out) << "isset_" << tfield->get_name() << " = TRUE;" << endl; + indent(out) << "isset_" << tfield->get_name() << " = TRUE;" << '\n'; } } @@ -4101,30 +4099,30 @@ void t_c_glib_generator::generate_deserialize_struct(ostream& out, bool allocate) { string name_uc = to_upper_case(initial_caps_to_underscores(tstruct->get_name())); if (tstruct->is_xception()) { - out << indent() << "/* This struct is an exception */" << endl; + out << indent() << "/* This struct is an exception */" << '\n'; allocate = true; } if (allocate) { - out << indent() << "if ( " << prefix << " != NULL)" << endl << indent() << "{" << endl; + out << indent() << "if ( " << prefix << " != NULL)" << '\n' << indent() << "{" << '\n'; indent_up(); - out << indent() << "g_object_unref (" << prefix << ");" << endl; + out << indent() << "g_object_unref (" << prefix << ");" << '\n'; indent_down(); - out << indent() << "}" << endl << indent() << prefix << " = g_object_new (" << this->nspace_uc - << "TYPE_" << name_uc << ", NULL);" << endl; + out << indent() << "}" << '\n' << indent() << prefix << " = g_object_new (" << this->nspace_uc + << "TYPE_" << name_uc << ", NULL);" << '\n'; } out << indent() << "if ((ret = thrift_struct_read (THRIFT_STRUCT (" << prefix - << "), protocol, error)) < 0)" << endl << indent() << "{" << endl; + << "), protocol, error)) < 0)" << '\n' << indent() << "{" << '\n'; indent_up(); if (allocate) { - indent(out) << "g_object_unref (" << prefix << ");" << endl; + indent(out) << "g_object_unref (" << prefix << ");" << '\n'; if (tstruct->is_xception()) { - indent(out) << prefix << " = NULL;" << endl; + indent(out) << prefix << " = NULL;" << '\n'; } } - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "}" << endl << indent() << "xfer += ret;" << endl; + out << indent() << "}" << '\n' << indent() << "xfer += ret;" << '\n'; } void t_c_glib_generator::generate_deserialize_container(ostream& out, @@ -4134,80 +4132,80 @@ void t_c_glib_generator::generate_deserialize_container(ostream& out, scope_up(out); if (ttype->is_map()) { - out << indent() << "guint32 size;" << endl - << indent() << "guint32 i;" << endl - << indent() << "ThriftType key_type;" << endl - << indent() << "ThriftType value_type;" << endl - << endl - << indent() << "/* read the map begin marker */" << endl + out << indent() << "guint32 size;" << '\n' + << indent() << "guint32 i;" << '\n' + << indent() << "ThriftType key_type;" << '\n' + << indent() << "ThriftType value_type;" << '\n' + << '\n' + << indent() << "/* read the map begin marker */" << '\n' << indent() << "if ((ret = thrift_protocol_read_map_begin (protocol, " - "&key_type, &value_type, &size, error)) < 0)" << endl; + "&key_type, &value_type, &size, error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl - << endl; + out << indent() << "xfer += ret;" << '\n' + << '\n'; // iterate over map elements - out << indent() << "/* iterate through each of the map's fields */" << endl - << indent() << "for (i = 0; i < size; i++)" << endl; + out << indent() << "/* iterate through each of the map's fields */" << '\n' + << indent() << "for (i = 0; i < size; i++)" << '\n'; scope_up(out); generate_deserialize_map_element(out, (t_map*)ttype, prefix, error_ret); scope_down(out); - out << endl; + out << '\n'; // read map end - out << indent() << "/* read the map end marker */" << endl + out << indent() << "/* read the map end marker */" << '\n' << indent() << "if ((ret = thrift_protocol_read_map_end (protocol, " - "error)) < 0)" << endl; + "error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl; + out << indent() << "xfer += ret;" << '\n'; } else if (ttype->is_set()) { - out << indent() << "guint32 size;" << endl - << indent() << "guint32 i;" << endl - << indent() << "ThriftType element_type;" << endl - << endl + out << indent() << "guint32 size;" << '\n' + << indent() << "guint32 i;" << '\n' + << indent() << "ThriftType element_type;" << '\n' + << '\n' << indent() << "if ((ret = thrift_protocol_read_set_begin (protocol, " - "&element_type, &size, error)) < 0)" << endl; + "&element_type, &size, error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl - << endl; + out << indent() << "xfer += ret;" << '\n' + << '\n'; // iterate over the elements - out << indent() << "/* iterate through the set elements */" << endl - << indent() << "for (i = 0; i < size; ++i)" << endl; + out << indent() << "/* iterate through the set elements */" << '\n' + << indent() << "for (i = 0; i < size; ++i)" << '\n'; scope_up(out); generate_deserialize_set_element(out, (t_set*)ttype, prefix, error_ret); scope_down(out); // read set end out << indent() << "if ((ret = thrift_protocol_read_set_end (protocol, " - "error)) < 0)" << endl; + "error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl - << endl; + out << indent() << "xfer += ret;" << '\n' + << '\n'; } else if (ttype->is_list()) { - out << indent() << "guint32 size;" << endl - << indent() << "guint32 i;" << endl - << indent() << "ThriftType element_type;" << endl - << endl + out << indent() << "guint32 size;" << '\n' + << indent() << "guint32 i;" << '\n' + << indent() << "ThriftType element_type;" << '\n' + << '\n' << indent() << "if ((ret = thrift_protocol_read_list_begin (protocol, " - "&element_type,&size, error)) < 0)" << endl; + "&element_type,&size, error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl - << endl; + out << indent() << "xfer += ret;" << '\n' + << '\n'; // iterate over the elements - out << indent() << "/* iterate through list elements */" << endl - << indent() << "for (i = 0; i < size; i++)" << endl; + out << indent() << "/* iterate through list elements */" << '\n' + << indent() << "for (i = 0; i < size; i++)" << '\n'; scope_up(out); generate_deserialize_list_element(out, (t_list*)ttype, @@ -4218,11 +4216,11 @@ void t_c_glib_generator::generate_deserialize_container(ostream& out, // read list end out << indent() << "if ((ret = thrift_protocol_read_list_end (protocol, " - "error)) < 0)" << endl; + "error)) < 0)" << '\n'; indent_up(); - out << indent() << "return " << error_ret << ";" << endl; + out << indent() << "return " << error_ret << ";" << '\n'; indent_down(); - out << indent() << "xfer += ret;" << endl; + out << indent() << "xfer += ret;" << '\n'; } scope_down(out); @@ -4239,16 +4237,16 @@ void t_c_glib_generator::declare_local_variable(ostream& out, t_type* ttype, str if (ttype->is_map()) { t_map* tmap = (t_map*)ttype; out << indent() << tname << ptr << " " << name << " = " - << generate_new_hash_from_type(tmap->get_key_type(), tmap->get_val_type()) << endl; + << generate_new_hash_from_type(tmap->get_key_type(), tmap->get_val_type()) << '\n'; } else if (ttype->is_list()) { t_list* tlist = (t_list*)ttype; out << indent() << tname << ptr << " " << name << " = " - << generate_new_array_from_type(tlist->get_elem_type()) << endl; + << generate_new_array_from_type(tlist->get_elem_type()) << '\n'; } else if (for_hash_table && ttype->is_enum()) { - out << indent() << tname << " " << name << ";" << endl; + out << indent() << tname << " " << name << ";" << '\n'; } else { out << indent() << tname << ptr << " " << name - << (ptr != "" ? " = g_new (" + tname + ", 1)" : " = NULL") << ";" << endl; + << (ptr != "" ? " = g_new (" + tname + ", 1)" : " = NULL") << ";" << '\n'; } } @@ -4259,7 +4257,7 @@ void t_c_glib_generator::declore_local_variable_for_write(ostream& out, ttype = get_true_type(ttype); string ptr = ttype->is_string() || !ttype->is_base_type() ? " " : "* "; string init_val = ttype->is_enum() ? "" : " = NULL"; - out << indent() << tname << ptr << name << init_val << ";" << endl; + out << indent() << tname << ptr << name << init_val << ";" << '\n'; } void t_c_glib_generator::generate_deserialize_map_element(ostream& out, @@ -4289,10 +4287,10 @@ void t_c_glib_generator::generate_deserialize_map_element(ostream& out, t_field fval(tval, tval_ptr + valname); generate_deserialize_field(out, &fval, "", "", error_ret); - indent(out) << "if (" << prefix << " && " << keyname << ")" << endl; + indent(out) << "if (" << prefix << " && " << keyname << ")" << '\n'; indent_up(); indent(out) << "g_hash_table_insert ((GHashTable *)" << prefix << ", (gpointer) " << keyname - << ", (gpointer) " << valname << ");" << endl; + << ", (gpointer) " << valname << ");" << '\n'; indent_down(); } @@ -4309,10 +4307,10 @@ void t_c_glib_generator::generate_deserialize_set_element(ostream& out, t_field felem(telem, telem_ptr + elem); generate_deserialize_field(out, &felem, "", "", error_ret); - indent(out) << "if (" << prefix << " && " << elem << ")" << endl; + indent(out) << "if (" << prefix << " && " << elem << ")" << '\n'; indent_up(); indent(out) << "g_hash_table_insert ((GHashTable *) " << prefix << ", (gpointer) " << elem - << ", (gpointer) " << elem << ");" << endl; + << ", (gpointer) " << elem << ");" << '\n'; indent_down(); } @@ -4334,10 +4332,10 @@ void t_c_glib_generator::generate_deserialize_list_element(ostream& out, if (ttype->is_void()) { throw std::runtime_error("compiler error: list element type cannot be void"); } else if (is_numeric(ttype)) { - indent(out) << "g_array_append_vals (" << prefix << ", " << elem << ", 1);" << endl; - indent(out) << "g_free (" << elem << ");" << endl; + indent(out) << "g_array_append_vals (" << prefix << ", " << elem << ", 1);" << '\n'; + indent(out) << "g_free (" << elem << ");" << '\n'; } else { - indent(out) << "g_ptr_array_add (" << prefix << ", " << elem << ");" << endl; + indent(out) << "g_ptr_array_add (" << prefix << ", " << elem << ");" << '\n'; } } diff --git a/compiler/cpp/src/thrift/generate/t_cl_generator.cc b/compiler/cpp/src/thrift/generate/t_cl_generator.cc index e0dcc46af4b..dccecdc53f7 100644 --- a/compiler/cpp/src/thrift/generate/t_cl_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cl_generator.cc @@ -130,9 +130,9 @@ void t_cl_generator::init_generator() { string f_vars_name = program_dir + "/" + program_name_ + "-vars.lisp"; f_types_.open(f_types_name); - f_types_ << cl_autogen_comment() << endl; + f_types_ << cl_autogen_comment() << '\n'; f_vars_.open(f_vars_name); - f_vars_ << cl_autogen_comment() << endl; + f_vars_ << cl_autogen_comment() << '\n'; package_def(f_types_); package_in(f_types_); @@ -141,7 +141,7 @@ void t_cl_generator::init_generator() { if (!no_asd) { string f_asd_name = program_dir + "/" + system_prefix + program_name_ + ".asd"; f_asd_.open(f_asd_name); - f_asd_ << cl_autogen_comment() << endl; + f_asd_ << cl_autogen_comment() << '\n'; asdf_def(f_asd_); } } @@ -197,13 +197,13 @@ string t_cl_generator::generated_package() { } void t_cl_generator::asdf_def(std::ostream &out) { - out << "(asdf:defsystem #:" << system_prefix << program_name_ << endl; + out << "(asdf:defsystem #:" << system_prefix << program_name_ << '\n'; indent_up(); out << indent() << render_includes() - << indent() << ":serial t" << endl + << indent() << ":serial t" << '\n' << indent() << ":components (" << "(:file \"" << program_name_ << "-types\") " - << "(:file \"" << program_name_ << "-vars\")))" << endl; + << "(:file \"" << program_name_ << "-vars\")))" << '\n'; indent_down(); } @@ -221,11 +221,11 @@ void t_cl_generator::package_def(std::ostream &out) { } out << ")"; } - out << ")" << endl << endl; + out << ")" << '\n' << '\n'; } void t_cl_generator::package_in(std::ostream &out) { - out << "(cl:in-package :" << package() << ")" << endl << endl; + out << "(cl:in-package :" << package() << ")" << '\n' << '\n'; } /** @@ -238,7 +238,7 @@ void t_cl_generator::generate_typedef(t_typedef* ttypedef) { } void t_cl_generator::generate_enum(t_enum* tenum) { - f_types_ << "(thrift:def-enum " << prefix(tenum->get_name()) << endl; + f_types_ << "(thrift:def-enum " << prefix(tenum->get_name()) << '\n'; vector constants = tenum->get_constants(); vector::iterator c_iter; @@ -249,12 +249,12 @@ void t_cl_generator::generate_enum(t_enum* tenum) { for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { value = (*c_iter)->get_value(); - if(c_iter != constants.begin()) f_types_ << endl << indent() << " "; + if(c_iter != constants.begin()) f_types_ << '\n' << indent() << " "; f_types_ << "(\"" << (*c_iter)->get_name() << "\" . " << value << ")"; } indent_down(); - f_types_ << "))" << endl << endl; + f_types_ << "))" << '\n' << '\n'; } /** @@ -266,7 +266,7 @@ void t_cl_generator::generate_const(t_const* tconst) { t_const_value* value = tconst->get_value(); f_vars_ << "(thrift:def-constant " << prefix(name) << " " << render_const_value(type, value) << ")" - << endl << endl; + << '\n' << '\n'; } /** @@ -306,7 +306,7 @@ string t_cl_generator::render_const_value(t_type* type, t_const_value* value) { indent(out) << value->get_integer(); } else if (type->is_struct() || type->is_xception()) { out << (type->is_struct() ? "(make-instance '" : "(make-exception '") << - lowercase(type->get_name()) << " " << endl; + lowercase(type->get_name()) << " " << '\n'; indent_up(); const vector& fields = ((t_struct*)type)->get_members(); @@ -326,7 +326,7 @@ string t_cl_generator::render_const_value(t_type* type, t_const_value* value) { } out << indent() << ":" << v_iter->first->get_string() << " " << - render_const_value(field_type, v_iter->second) << endl; + render_const_value(field_type, v_iter->second) << '\n'; } out << indent() << ")"; @@ -340,7 +340,7 @@ string t_cl_generator::render_const_value(t_type* type, t_const_value* value) { const map& val = value->get_map(); map::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { - out << endl << indent() + out << '\n' << indent() << "(cl:cons " << render_const_value(ktype, v_iter->first) << " " << render_const_value(vtype, v_iter->second) << ")"; } @@ -354,16 +354,16 @@ string t_cl_generator::render_const_value(t_type* type, t_const_value* value) { etype = ((t_set*)type)->get_elem_type(); } if (type->is_set()) { - out << "(thrift:set" << endl; + out << "(thrift:set" << '\n'; } else { - out << "(thrift:list" << endl; + out << "(thrift:list" << '\n'; } indent_up(); indent_up(); const vector& val = value->get_list(); vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { - out << indent() << render_const_value(etype, *v_iter) << endl; + out << indent() << render_const_value(etype, *v_iter) << '\n'; } out << indent() << ")"; indent_down(); @@ -394,7 +394,7 @@ void t_cl_generator::generate_cl_struct_internal(std::ostream& out, t_struct* ts t_type* type = (*m_iter)->get_type(); if (m_iter != members.begin()) { - out << endl << indent() << " "; + out << '\n' << indent() << " "; } out << "(" << prefix((*m_iter)->get_name()) << " " << ( (nullptr != value) ? render_const_value(type, value) : "nil" ) << @@ -421,16 +421,16 @@ void t_cl_generator::generate_cl_struct_internal(std::ostream& out, t_struct* ts void t_cl_generator::generate_cl_struct(std::ostream& out, t_struct* tstruct, bool is_exception = false) { std::string name = type_name(tstruct); out << (is_exception ? "(thrift:def-exception " : "(thrift:def-struct ") << - prefix(name) << endl; + prefix(name) << '\n'; indent_up(); if ( tstruct->has_doc() ) { out << indent() ; - out << "\"" << cl_docstring(tstruct->get_doc()) << "\"" << endl; + out << "\"" << cl_docstring(tstruct->get_doc()) << "\"" << '\n'; } out << indent() ; generate_cl_struct_internal(out, tstruct, is_exception); indent_down(); - out << ")" << endl << endl; + out << ")" << '\n' << '\n'; } void t_cl_generator::generate_exception_sig(std::ostream& out, t_function* f) { @@ -454,7 +454,7 @@ void t_cl_generator::generate_service(t_service* tservice) { indent_up(); if ( tservice->has_doc()) { - f_types_ << endl << indent() + f_types_ << '\n' << indent() << "(:documentation \"" << cl_docstring(tservice->get_doc()) << "\")"; } @@ -465,23 +465,23 @@ void t_cl_generator::generate_service(t_service* tservice) { t_struct* exceptions = function->get_xceptions(); const vector& xmembers = exceptions->get_members(); - f_types_ << endl << indent() << "(:method " << prefix(fname); + f_types_ << '\n' << indent() << "(:method " << prefix(fname); f_types_ << " (" << signature << " " << typespec((*f_iter)->get_returntype()) << ")"; if (xmembers.size() > 0) { - f_types_ << endl << indent() << " :exceptions " ; + f_types_ << '\n' << indent() << " :exceptions " ; generate_exception_sig(f_types_, function); } if ( (*f_iter)->is_oneway() ) { - f_types_ << endl << indent() << " :oneway t"; + f_types_ << '\n' << indent() << " :oneway t"; } if ( (*f_iter)->has_doc() ) { - f_types_ << endl << indent() << " :documentation \"" + f_types_ << '\n' << indent() << " :documentation \"" << cl_docstring((*f_iter)->get_doc()) << "\""; } f_types_ << ")"; } - f_types_ << ")" << endl << endl; + f_types_ << ")" << '\n' << '\n'; indent_down(); } diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index e21252e8f6e..dc74a92aa05 100644 --- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc @@ -42,8 +42,6 @@ using std::ostream; using std::string; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * C++ code generator. This is legitimacy incarnate. * @@ -438,69 +436,69 @@ void t_cpp_generator::init_generator() { f_types_tcc_ << autogen_comment(); // Start ifndef - f_types_ << "#ifndef " << program_name_ << "_TYPES_H" << endl << "#define " << program_name_ - << "_TYPES_H" << endl << endl; - f_types_tcc_ << "#ifndef " << program_name_ << "_TYPES_TCC" << endl << "#define " << program_name_ - << "_TYPES_TCC" << endl << endl; + f_types_ << "#ifndef " << program_name_ << "_TYPES_H" << '\n' << "#define " << program_name_ + << "_TYPES_H" << '\n' << '\n'; + f_types_tcc_ << "#ifndef " << program_name_ << "_TYPES_TCC" << '\n' << "#define " << program_name_ + << "_TYPES_TCC" << '\n' << '\n'; // Include base types - f_types_ << "#include " << endl - << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl - << endl; + f_types_ << "#include " << '\n' + << '\n' + << "#include " << '\n' + << "#include " << '\n' + << "#include " << '\n' + << "#include " << '\n' + << "#include " << '\n' + << '\n'; // Include C++xx compatibility header - f_types_ << "#include " << endl; - f_types_ << "#include " << endl; + f_types_ << "#include " << '\n'; + f_types_ << "#include " << '\n'; // Include other Thrift includes const vector& includes = program_->get_includes(); for (auto include : includes) { f_types_ << "#include \"" << get_include_prefix(*include) << include->get_name() - << "_types.h\"" << endl; + << "_types.h\"" << '\n'; // XXX(simpkins): If gen_templates_ is enabled, we currently assume all // included files were also generated with templates enabled. f_types_tcc_ << "#include \"" << get_include_prefix(*include) << include->get_name() - << "_types.tcc\"" << endl; + << "_types.tcc\"" << '\n'; } - f_types_ << endl; + f_types_ << '\n'; // Include custom headers const vector& cpp_includes = program_->get_cpp_includes(); for (const auto & cpp_include : cpp_includes) { if (cpp_include[0] == '<') { - f_types_ << "#include " << cpp_include << endl; + f_types_ << "#include " << cpp_include << '\n'; } else { - f_types_ << "#include \"" << cpp_include << "\"" << endl; + f_types_ << "#include \"" << cpp_include << "\"" << '\n'; } } - f_types_ << endl; + f_types_ << '\n'; // Include the types file f_types_impl_ << "#include \"" << get_include_prefix(*get_program()) << program_name_ - << "_types.h\"" << endl << endl; + << "_types.h\"" << '\n' << '\n'; f_types_tcc_ << "#include \"" << get_include_prefix(*get_program()) << program_name_ - << "_types.h\"" << endl << endl; + << "_types.h\"" << '\n' << '\n'; // The swap() code needs for std::swap() - f_types_impl_ << "#include " << endl; + f_types_impl_ << "#include " << '\n'; // for operator<< - f_types_impl_ << "#include " << endl << endl; - f_types_impl_ << "#include " << endl << endl; + f_types_impl_ << "#include " << '\n' << '\n'; + f_types_impl_ << "#include " << '\n' << '\n'; // Open namespace ns_open_ = namespace_open(program_->get_namespace("cpp")); ns_close_ = namespace_close(program_->get_namespace("cpp")); - f_types_ << ns_open_ << endl << endl; + f_types_ << ns_open_ << '\n' << '\n'; - f_types_impl_ << ns_open_ << endl << endl; + f_types_impl_ << ns_open_ << '\n' << '\n'; - f_types_tcc_ << ns_open_ << endl << endl; + f_types_tcc_ << ns_open_ << '\n' << '\n'; } /** @@ -508,21 +506,21 @@ void t_cpp_generator::init_generator() { */ void t_cpp_generator::close_generator() { // Close namespace - f_types_ << ns_close_ << endl << endl; - f_types_impl_ << ns_close_ << endl; - f_types_tcc_ << ns_close_ << endl << endl; + f_types_ << ns_close_ << '\n' << '\n'; + f_types_impl_ << ns_close_ << '\n'; + f_types_tcc_ << ns_close_ << '\n' << '\n'; // Include the types.tcc file from the types header file, // so clients don't have to explicitly include the tcc file. // TODO(simpkins): Make this a separate option. if (gen_templates_) { f_types_ << "#include \"" << get_include_prefix(*get_program()) << program_name_ - << "_types.tcc\"" << endl << endl; + << "_types.tcc\"" << '\n' << '\n'; } // Close ifndef - f_types_ << "#endif" << endl; - f_types_tcc_ << "#endif" << endl; + f_types_ << "#endif" << '\n'; + f_types_tcc_ << "#endif" << '\n'; // Close output file f_types_.close(); @@ -544,7 +542,7 @@ void t_cpp_generator::close_generator() { void t_cpp_generator::generate_typedef(t_typedef* ttypedef) { generate_java_doc(f_types_, ttypedef); f_types_ << indent() << "typedef " << type_name(ttypedef->get_type(), true) << " " - << ttypedef->get_symbolic() << ";" << endl << endl; + << ttypedef->get_symbolic() << ";" << '\n' << '\n'; } void t_cpp_generator::generate_enum_constant_list(std::ostream& f, @@ -552,7 +550,7 @@ void t_cpp_generator::generate_enum_constant_list(std::ostream& f, const char* prefix, const char* suffix, bool include_values) { - f << " {" << endl; + f << " {" << '\n'; indent_up(); vector::const_iterator c_iter; @@ -561,7 +559,7 @@ void t_cpp_generator::generate_enum_constant_list(std::ostream& f, if (first) { first = false; } else { - f << "," << endl; + f << "," << '\n'; } generate_java_doc(f, *c_iter); indent(f) << prefix << (*c_iter)->get_name() << suffix; @@ -570,9 +568,9 @@ void t_cpp_generator::generate_enum_constant_list(std::ostream& f, } } - f << endl; + f << '\n'; indent_down(); - indent(f) << "};" << endl; + indent(f) << "};" << '\n'; } /** @@ -588,7 +586,7 @@ void t_cpp_generator::generate_enum(t_enum* tenum) { if (!gen_pure_enums_) { enum_name = "type"; generate_java_doc(f_types_, tenum); - f_types_ << indent() << "struct " << tenum->get_name() << " {" << endl; + f_types_ << indent() << "struct " << tenum->get_name() << " {" << '\n'; indent_up(); } f_types_ << indent() << "enum " << enum_name; @@ -597,10 +595,10 @@ void t_cpp_generator::generate_enum(t_enum* tenum) { if (!gen_pure_enums_) { indent_down(); - f_types_ << "};" << endl; + f_types_ << "};" << '\n'; } - f_types_ << endl; + f_types_ << '\n'; /** Generate a character array of enum names for debugging purposes. @@ -617,13 +615,13 @@ void t_cpp_generator::generate_enum(t_enum* tenum) { generate_enum_constant_list(f_types_impl_, constants, "\"", "\"", false); f_types_ << indent() << "extern const std::map _" << tenum->get_name() - << "_VALUES_TO_NAMES;" << endl << endl; + << "_VALUES_TO_NAMES;" << '\n' << '\n'; f_types_impl_ << indent() << "const std::map _" << tenum->get_name() << "_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(" << constants.size() << ", _k" << tenum->get_name() << "Values" << ", _k" << tenum->get_name() << "Names), " - << "::apache::thrift::TEnumIterator(-1, nullptr, nullptr));" << endl << endl; + << "::apache::thrift::TEnumIterator(-1, nullptr, nullptr));" << '\n' << '\n'; generate_enum_ostream_operator_decl(f_types_, tenum); generate_enum_ostream_operator(f_types_impl_, tenum); @@ -642,8 +640,8 @@ void t_cpp_generator::generate_enum_ostream_operator_decl(std::ostream& out, t_e } else { out << tenum->get_name() << "::type&"; } - out << " val);" << endl; - out << endl; + out << " val);" << '\n'; + out << '\n'; } void t_cpp_generator::generate_enum_ostream_operator(std::ostream& out, t_enum* tenum) { @@ -662,20 +660,20 @@ void t_cpp_generator::generate_enum_ostream_operator(std::ostream& out, t_enum* scope_up(out); out << indent() << "std::map::const_iterator it = _" - << tenum->get_name() << "_VALUES_TO_NAMES.find(val);" << endl; - out << indent() << "if (it != _" << tenum->get_name() << "_VALUES_TO_NAMES.end()) {" << endl; + << tenum->get_name() << "_VALUES_TO_NAMES.find(val);" << '\n'; + out << indent() << "if (it != _" << tenum->get_name() << "_VALUES_TO_NAMES.end()) {" << '\n'; indent_up(); - out << indent() << "out << it->second;" << endl; + out << indent() << "out << it->second;" << '\n'; indent_down(); - out << indent() << "} else {" << endl; + out << indent() << "} else {" << '\n'; indent_up(); - out << indent() << "out << static_cast(val);" << endl; + out << indent() << "out << static_cast(val);" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; - out << indent() << "return out;" << endl; + out << indent() << "return out;" << '\n'; scope_down(out); - out << endl; + out << '\n'; } } @@ -686,8 +684,8 @@ void t_cpp_generator::generate_enum_to_string_helper_function_decl(std::ostream& } else { out << tenum->get_name() << "::type&"; } - out << " val);" << endl; - out << endl; + out << " val);" << '\n'; + out << '\n'; } void t_cpp_generator::generate_enum_to_string_helper_function(std::ostream& out, t_enum* tenum) { @@ -702,19 +700,19 @@ void t_cpp_generator::generate_enum_to_string_helper_function(std::ostream& out, scope_up(out); out << indent() << "std::map::const_iterator it = _" - << tenum->get_name() << "_VALUES_TO_NAMES.find(val);" << endl; - out << indent() << "if (it != _" << tenum->get_name() << "_VALUES_TO_NAMES.end()) {" << endl; + << tenum->get_name() << "_VALUES_TO_NAMES.find(val);" << '\n'; + out << indent() << "if (it != _" << tenum->get_name() << "_VALUES_TO_NAMES.end()) {" << '\n'; indent_up(); - out << indent() << "return std::string(it->second);" << endl; + out << indent() << "return std::string(it->second);" << '\n'; indent_down(); - out << indent() << "} else {" << endl; + out << indent() << "} else {" << '\n'; indent_up(); - out << indent() << "return std::to_string(static_cast(val));" << endl; + out << indent() << "return std::to_string(static_cast(val));" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; scope_down(out); - out << endl; + out << '\n'; } } @@ -736,28 +734,28 @@ void t_cpp_generator::generate_consts(std::vector consts) { f_consts_impl << autogen_comment(); // Start ifndef - f_consts << "#ifndef " << program_name_ << "_CONSTANTS_H" << endl << "#define " << program_name_ - << "_CONSTANTS_H" << endl << endl << "#include \"" << get_include_prefix(*get_program()) - << program_name_ << "_types.h\"" << endl << endl << ns_open_ << endl << endl; + f_consts << "#ifndef " << program_name_ << "_CONSTANTS_H" << '\n' << "#define " << program_name_ + << "_CONSTANTS_H" << '\n' << '\n' << "#include \"" << get_include_prefix(*get_program()) + << program_name_ << "_types.h\"" << '\n' << '\n' << ns_open_ << '\n' << '\n'; f_consts_impl << "#include \"" << get_include_prefix(*get_program()) << program_name_ - << "_constants.h\"" << endl << endl << ns_open_ << endl << endl; + << "_constants.h\"" << '\n' << '\n' << ns_open_ << '\n' << '\n'; - f_consts << "class " << program_name_ << "Constants {" << endl << " public:" << endl << " " - << program_name_ << "Constants();" << endl << endl; + f_consts << "class " << program_name_ << "Constants {" << '\n' << " public:" << '\n' << " " + << program_name_ << "Constants();" << '\n' << '\n'; indent_up(); vector::iterator c_iter; for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { string name = (*c_iter)->get_name(); t_type* type = (*c_iter)->get_type(); - f_consts << indent() << type_name(type) << " " << name << ";" << endl; + f_consts << indent() << type_name(type) << " " << name << ";" << '\n'; } indent_down(); - f_consts << "};" << endl; + f_consts << "};" << '\n'; f_consts_impl << "const " << program_name_ << "Constants g_" << program_name_ << "_constants;" - << endl << endl << program_name_ << "Constants::" << program_name_ - << "Constants() {" << endl; + << '\n' << '\n' << program_name_ << "Constants::" << program_name_ + << "Constants() {" << '\n'; indent_up(); for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { print_const_value(f_consts_impl, @@ -766,13 +764,13 @@ void t_cpp_generator::generate_consts(std::vector consts) { (*c_iter)->get_value()); } indent_down(); - indent(f_consts_impl) << "}" << endl; + indent(f_consts_impl) << "}" << '\n'; - f_consts << endl << "extern const " << program_name_ << "Constants g_" << program_name_ - << "_constants;" << endl << endl << ns_close_ << endl << endl << "#endif" << endl; + f_consts << '\n' << "extern const " << program_name_ << "Constants g_" << program_name_ + << "_constants;" << '\n' << '\n' << ns_close_ << '\n' << '\n' << "#endif" << '\n'; f_consts.close(); - f_consts_impl << endl << ns_close_ << endl << endl; + f_consts_impl << '\n' << ns_close_ << '\n' << '\n'; f_consts_impl.close(); } } @@ -789,11 +787,11 @@ void t_cpp_generator::print_const_value(ostream& out, type = get_true_type(type); if (type->is_base_type()) { string v2 = render_const_value(out, name, type, value); - indent(out) << name << " = " << v2 << ";" << endl << endl; + indent(out) << name << " = " << v2 << ";" << '\n' << '\n'; } else if (type->is_enum()) { indent(out) << name << " = static_cast<" << type_name(type) << '>' - << '(' << value->get_integer() << ");" << endl << endl; + << '(' << value->get_integer() << ");" << '\n' << '\n'; } else if (type->is_struct() || type->is_xception()) { const vector& fields = ((t_struct*)type)->get_members(); vector::const_iterator f_iter; @@ -813,12 +811,12 @@ void t_cpp_generator::print_const_value(ostream& out, throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string(); } string item_val = render_const_value(out, name, field_type, v_iter->second); - indent(out) << name << "." << v_iter->first->get_string() << " = " << item_val << ";" << endl; + indent(out) << name << "." << v_iter->first->get_string() << " = " << item_val << ";" << '\n'; if (is_nonrequired_field) { - indent(out) << name << ".__isset." << v_iter->first->get_string() << " = true;" << endl; + indent(out) << name << ".__isset." << v_iter->first->get_string() << " = true;" << '\n'; } } - out << endl; + out << '\n'; } else if (type->is_map()) { t_type* ktype = ((t_map*)type)->get_key_type(); t_type* vtype = ((t_map*)type)->get_val_type(); @@ -827,27 +825,27 @@ void t_cpp_generator::print_const_value(ostream& out, for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string key = render_const_value(out, name, ktype, v_iter->first); string item_val = render_const_value(out, name, vtype, v_iter->second); - indent(out) << name << ".insert(std::make_pair(" << key << ", " << item_val << "));" << endl; + indent(out) << name << ".insert(std::make_pair(" << key << ", " << item_val << "));" << '\n'; } - out << endl; + out << '\n'; } else if (type->is_list()) { t_type* etype = ((t_list*)type)->get_elem_type(); const vector& val = value->get_list(); vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string item_val = render_const_value(out, name, etype, *v_iter); - indent(out) << name << ".push_back(" << item_val << ");" << endl; + indent(out) << name << ".push_back(" << item_val << ");" << '\n'; } - out << endl; + out << '\n'; } else if (type->is_set()) { t_type* etype = ((t_set*)type)->get_elem_type(); const vector& val = value->get_list(); vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string item_val = render_const_value(out, name, etype, *v_iter); - indent(out) << name << ".insert(" << item_val << ");" << endl; + indent(out) << name << ".insert(" << item_val << ");" << '\n'; } - out << endl; + out << '\n'; } else { throw "INVALID TYPE IN print_const_value: " + type->get_name(); } @@ -895,7 +893,7 @@ string t_cpp_generator::render_const_value(ostream& out, << '(' << value->get_integer() << ')'; } else { string t = tmp("tmp"); - indent(out) << type_name(type) << " " << t << ";" << endl; + indent(out) << type_name(type) << " " << t << ";" << '\n'; print_const_value(out, t, type, value); render << t; } @@ -905,7 +903,7 @@ string t_cpp_generator::render_const_value(ostream& out, void t_cpp_generator::generate_forward_declaration(t_struct* tstruct) { // Forward declare struct def - f_types_ << indent() << "class " << tstruct->get_name() << ";" << endl << endl; + f_types_ << indent() << "class " << tstruct->get_name() << ";" << '\n' << '\n'; } /** @@ -953,25 +951,25 @@ void t_cpp_generator::generate_equality_operator(std::ostream& out, t_struct* ts out << indent() << "bool " << tstruct->get_name() << "::operator==(const " << tstruct->get_name() << " & " - << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << endl; + << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << '\n'; scope_up(out); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { // Most existing Thrift code does not use isset or optional/required, // so we treat "default" fields as required. if ((*m_iter)->get_req() != t_field::T_OPTIONAL) { out << indent() << "if (!(" << (*m_iter)->get_name() << " == rhs." - << (*m_iter)->get_name() << "))" << endl << indent() << " return false;" << endl; + << (*m_iter)->get_name() << "))" << '\n' << indent() << " return false;" << '\n'; } else { out << indent() << "if (__isset." << (*m_iter)->get_name() << " != rhs.__isset." - << (*m_iter)->get_name() << ")" << endl << indent() << " return false;" << endl + << (*m_iter)->get_name() << ")" << '\n' << indent() << " return false;" << '\n' << indent() << "else if (__isset." << (*m_iter)->get_name() << " && !(" - << (*m_iter)->get_name() << " == rhs." << (*m_iter)->get_name() << "))" << endl - << indent() << " return false;" << endl; + << (*m_iter)->get_name() << " == rhs." << (*m_iter)->get_name() << "))" << '\n' + << indent() << " return false;" << '\n'; } } - indent(out) << "return true;" << endl; + indent(out) << "return true;" << '\n'; scope_down(out); - out << "\n"; + out << '\n'; } bool t_cpp_generator::has_field_with_default_value(t_struct* tstruct) @@ -1014,7 +1012,7 @@ void t_cpp_generator::generate_default_constructor(ostream& out, // Default-initialize TException, if it is our base type if (is_exception) { - out << "\n"; + out << '\n'; indent(out) << " : "; out << "TException()"; init_ctor = true; @@ -1054,7 +1052,7 @@ void t_cpp_generator::generate_default_constructor(ostream& out, // Start generating body // - out << " {" << endl; + out << " {" << '\n'; indent_up(); // TODO(dreiss): When everything else in Thrift is perfect, // do more of these in the initializer list. @@ -1111,14 +1109,14 @@ void t_cpp_generator::generate_constructor_helper(ostream& out, out << "noexcept "; if (is_exception) out << ": TException() "; - out << "{" << endl; + out << "{" << '\n'; indent_up(); const vector& members = tstruct->get_members(); // eliminate compiler unused warning if (members.empty()) - indent(out) << "(void) " << tmp_name << ";" << endl; + indent(out) << "(void) " << tmp_name << ";" << '\n'; vector::const_iterator f_iter; bool has_nonrequired_fields = false; @@ -1129,15 +1127,15 @@ void t_cpp_generator::generate_constructor_helper(ostream& out, << maybeMove( tmp_name + "." + (*f_iter)->get_name(), is_move && is_complex_type((*f_iter)->get_type())) - << ";" << endl; + << ";" << '\n'; } if (has_nonrequired_fields) { - indent(out) << "__isset = " << maybeMove(tmp_name + ".__isset", false) << ";" << endl; + indent(out) << "__isset = " << maybeMove(tmp_name + ".__isset", false) << ";" << '\n'; } indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_cpp_generator::generate_assignment_operator(ostream& out, t_struct* tstruct) { @@ -1161,14 +1159,14 @@ void t_cpp_generator::generate_assignment_helper(ostream& out, t_struct* tstruct out << tmp_name << ") "; if(is_move || is_struct_storage_not_throwing(tstruct)) out << "noexcept "; - out << "{" << endl; + out << "{" << '\n'; indent_up(); const vector& members = tstruct->get_members(); // eliminate compiler unused warning if (members.empty()) - indent(out) << "(void) " << tmp_name << ";" << endl; + indent(out) << "(void) " << tmp_name << ";" << '\n'; vector::const_iterator f_iter; bool has_nonrequired_fields = false; @@ -1179,15 +1177,15 @@ void t_cpp_generator::generate_assignment_helper(ostream& out, t_struct* tstruct << maybeMove( tmp_name + "." + (*f_iter)->get_name(), is_move && is_complex_type((*f_iter)->get_type())) - << ";" << endl; + << ";" << '\n'; } if (has_nonrequired_fields) { - indent(out) << "__isset = " << maybeMove(tmp_name + ".__isset", false) << ";" << endl; + indent(out) << "__isset = " << maybeMove(tmp_name + ".__isset", false) << ";" << '\n'; } - indent(out) << "return *this;" << endl; + indent(out) << "return *this;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } /** @@ -1230,7 +1228,7 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, if (has_nonrequired_fields && (!pointers || read)) { - out << indent() << "typedef struct _" << tstruct->get_name() << "__isset {" << endl; + out << indent() << "typedef struct _" << tstruct->get_name() << "__isset {" << '\n'; indent_up(); indent(out) << "_" << tstruct->get_name() << "__isset() "; @@ -1247,58 +1245,58 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, out << ", " << (*m_iter)->get_name() << "(" << isSet << ")"; } } - out << " {}" << endl; + out << " {}" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_req() != t_field::T_REQUIRED) { - indent(out) << "bool " << (*m_iter)->get_name() << " :1;" << endl; + indent(out) << "bool " << (*m_iter)->get_name() << " :1;" << '\n'; } } indent_down(); - indent(out) << "} _" << tstruct->get_name() << "__isset;" << endl; + indent(out) << "} _" << tstruct->get_name() << "__isset;" << '\n'; } - out << endl; + out << '\n'; generate_java_doc(out, tstruct); // Open struct def - out << indent() << "class " << tstruct->get_name() << extends << " {" << endl << indent() - << " public:" << endl << endl; + out << indent() << "class " << tstruct->get_name() << extends << " {" << '\n' << indent() + << " public:" << '\n' << '\n'; indent_up(); if (!pointers) { bool ok_noexcept = is_struct_storage_not_throwing(tstruct); // Copy constructor indent(out) << tstruct->get_name() << "(const " << tstruct->get_name() << "&)" - << (ok_noexcept? " noexcept" : "") << ';' << endl; + << (ok_noexcept? " noexcept" : "") << ';' << '\n'; // Move constructor if (gen_moveable_) { indent(out) << tstruct->get_name() << "(" << tstruct->get_name() << "&&) noexcept;" - << endl; + << '\n'; } // Assignment Operator indent(out) << tstruct->get_name() << "& operator=(const " << tstruct->get_name() << "&)" - << (ok_noexcept? " noexcept" : "") << ';' << endl; + << (ok_noexcept? " noexcept" : "") << ';' << '\n'; // Move assignment operator if (gen_moveable_) { indent(out) << tstruct->get_name() << "& operator=(" << tstruct->get_name() << "&&) noexcept;" - << endl; + << '\n'; } bool has_default_value = has_field_with_default_value(tstruct); // Default constructor std::string clsname_ctor = tstruct->get_name() + "()"; - indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept") << ";" << endl; + indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept") << ";" << '\n'; } if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) { - out << endl << indent() << "virtual ~" << tstruct->get_name() << "() noexcept;" << endl; + out << '\n' << indent() << "virtual ~" << tstruct->get_name() << "() noexcept;" << '\n'; } // Declare all fields @@ -1307,12 +1305,12 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, indent(out) << declare_field(*m_iter, false, (pointers && !(*m_iter)->get_type()->is_xception()), - !read) << endl; + !read) << '\n'; } // Add the __isset data member if we need it, using the definition from above if (has_nonrequired_fields && (!pointers || read)) { - out << endl << indent() << "_" << tstruct->get_name() << "__isset __isset;" << endl; + out << '\n' << indent() << "_" << tstruct->get_name() << "__isset __isset;" << '\n'; } // Create a setter function for each field @@ -1321,87 +1319,87 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, continue; } if (is_reference((*m_iter))) { - out << endl << indent() << "void __set_" << (*m_iter)->get_name() << "(::std::shared_ptr<" + out << '\n' << indent() << "void __set_" << (*m_iter)->get_name() << "(::std::shared_ptr<" << type_name((*m_iter)->get_type(), false, false) << ">"; - out << " val);" << endl; + out << " val);" << '\n'; } else { - out << endl << indent() << "void __set_" << (*m_iter)->get_name() << "(" + out << '\n' << indent() << "void __set_" << (*m_iter)->get_name() << "(" << type_name((*m_iter)->get_type(), false, true); - out << " val);" << endl; + out << " val);" << '\n'; } } - out << endl; + out << '\n'; if (!pointers) { // Should we generate default operators? if (!gen_no_default_operators_) { // Generate an equality testing operator. out << indent() << "bool operator == (const " << tstruct->get_name() << " & " - << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const;" << endl; + << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const;" << '\n'; out << indent() << "bool operator != (const " << tstruct->get_name() << " &rhs) const {" - << endl << indent() << " return !(*this == rhs);" << endl << indent() << "}" << endl - << endl; + << '\n' << indent() << " return !(*this == rhs);" << '\n' << indent() << "}" << '\n' + << '\n'; // Generate the declaration of a less-than operator. This must be // implemented by the application developer if they wish to use it. (They // will get a link error if they try to use it without an implementation.) - out << indent() << "bool operator < (const " << tstruct->get_name() << " & ) const;" << endl - << endl; + out << indent() << "bool operator < (const " << tstruct->get_name() << " & ) const;" << '\n' + << '\n'; } } if (read) { if (gen_templates_) { - out << indent() << "template " << endl << indent() - << "uint32_t read(Protocol_* iprot);" << endl; + out << indent() << "template " << '\n' << indent() + << "uint32_t read(Protocol_* iprot);" << '\n'; } else { out << indent() << "uint32_t read(" << "::apache::thrift::protocol::TProtocol* iprot)"; if(!is_exception && !extends.empty()) out << " override"; - out << ';' << endl; + out << ';' << '\n'; } } if (write) { if (gen_templates_) { - out << indent() << "template " << endl << indent() - << "uint32_t write(Protocol_* oprot) const;" << endl; + out << indent() << "template " << '\n' << indent() + << "uint32_t write(Protocol_* oprot) const;" << '\n'; } else { out << indent() << "uint32_t write(" << "::apache::thrift::protocol::TProtocol* oprot) const"; if(!is_exception && !extends.empty()) out << " override"; - out << ';' << endl; + out << ';' << '\n'; } } - out << endl; + out << '\n'; if (is_user_struct && !has_custom_ostream(tstruct)) { out << indent() << "virtual "; generate_struct_print_method_decl(out, nullptr); - out << ";" << endl; + out << ";" << '\n'; } // std::exception::what() if (is_exception) { - out << indent() << "mutable std::string thriftTExceptionMessageHolder_;" << endl; + out << indent() << "mutable std::string thriftTExceptionMessageHolder_;" << '\n'; out << indent(); generate_exception_what_method_decl(out, tstruct, false); - out << ";" << endl; + out << ";" << '\n'; } indent_down(); - indent(out) << "};" << endl << endl; + indent(out) << "};" << '\n' << '\n'; if (swap) { // Generate a namespace-scope swap() function if (tstruct->get_name() == "a" || tstruct->get_name() == "b") { out << indent() << "void swap(" << tstruct->get_name() << " &a1, " << tstruct->get_name() - << " &a2);" << endl << endl; + << " &a2);" << '\n' << '\n'; } else { out << indent() << "void swap(" << tstruct->get_name() << " &a, " << tstruct->get_name() - << " &b);" << endl << endl; + << " &b);" << '\n' << '\n'; } } @@ -1422,12 +1420,12 @@ void t_cpp_generator::generate_struct_definition(ostream& out, // Destructor if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) { - force_cpp_out << endl << indent() << tstruct->get_name() << "::~" << tstruct->get_name() - << "() noexcept {" << endl; + force_cpp_out << '\n' << indent() << tstruct->get_name() << "::~" << tstruct->get_name() + << "() noexcept {" << '\n'; indent_up(); indent_down(); - force_cpp_out << indent() << "}" << endl << endl; + force_cpp_out << indent() << "}" << '\n' << '\n'; } if (!pointers) @@ -1442,32 +1440,32 @@ void t_cpp_generator::generate_struct_definition(ostream& out, if (setters) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if (is_reference((*m_iter))) { - out << endl << indent() << "void " << tstruct->get_name() << "::__set_" + out << '\n' << indent() << "void " << tstruct->get_name() << "::__set_" << (*m_iter)->get_name() << "(::std::shared_ptr<" << type_name((*m_iter)->get_type(), false, false) << ">"; - out << " val) {" << endl; + out << " val) {" << '\n'; } else { - out << endl << indent() << "void " << tstruct->get_name() << "::__set_" + out << '\n' << indent() << "void " << tstruct->get_name() << "::__set_" << (*m_iter)->get_name() << "(" << type_name((*m_iter)->get_type(), false, true); - out << " val) {" << endl; + out << " val) {" << '\n'; } indent_up(); - out << indent() << "this->" << (*m_iter)->get_name() << " = val;" << endl; + out << indent() << "this->" << (*m_iter)->get_name() << " = val;" << '\n'; indent_down(); // assume all fields are required except optional fields. // for optional fields change __isset.name to true bool is_optional = (*m_iter)->get_req() == t_field::T_OPTIONAL; if (is_optional) { - out << indent() << indent() << "__isset." << (*m_iter)->get_name() << " = true;" << endl; + out << indent() << indent() << "__isset." << (*m_iter)->get_name() << " = true;" << '\n'; } - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } if (is_user_struct) { generate_struct_ostream_operator(out, tstruct); } - out << endl; + out << '\n'; } /** @@ -1478,11 +1476,11 @@ void t_cpp_generator::generate_struct_definition(ostream& out, */ void t_cpp_generator::generate_struct_reader(ostream& out, t_struct* tstruct, bool pointers) { if (gen_templates_) { - out << indent() << "template " << endl << indent() << "uint32_t " - << tstruct->get_name() << "::read(Protocol_* iprot) {" << endl; + out << indent() << "template " << '\n' << indent() << "uint32_t " + << tstruct->get_name() << "::read(Protocol_* iprot) {" << '\n'; } else { indent(out) << "uint32_t " << tstruct->get_name() - << "::read(::apache::thrift::protocol::TProtocol* iprot) {" << endl; + << "::read(::apache::thrift::protocol::TProtocol* iprot) {" << '\n'; } indent_up(); @@ -1490,49 +1488,49 @@ void t_cpp_generator::generate_struct_reader(ostream& out, t_struct* tstruct, bo vector::const_iterator f_iter; // Declare stack tmp variables - out << endl - << indent() << "::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);" << endl - << indent() << "uint32_t xfer = 0;" << endl - << indent() << "std::string fname;" << endl - << indent() << "::apache::thrift::protocol::TType ftype;" << endl - << indent() << "int16_t fid;" << endl - << endl - << indent() << "xfer += iprot->readStructBegin(fname);" << endl - << endl - << indent() << "using ::apache::thrift::protocol::TProtocolException;" << endl - << endl; + out << '\n' + << indent() << "::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);" << '\n' + << indent() << "uint32_t xfer = 0;" << '\n' + << indent() << "std::string fname;" << '\n' + << indent() << "::apache::thrift::protocol::TType ftype;" << '\n' + << indent() << "int16_t fid;" << '\n' + << '\n' + << indent() << "xfer += iprot->readStructBegin(fname);" << '\n' + << '\n' + << indent() << "using ::apache::thrift::protocol::TProtocolException;" << '\n' + << '\n'; // Required variables aren't in __isset, so we need tmp vars to check them. for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) - indent(out) << "bool isset_" << (*f_iter)->get_name() << " = false;" << endl; + indent(out) << "bool isset_" << (*f_iter)->get_name() << " = false;" << '\n'; } - out << endl; + out << '\n'; // Loop over reading in fields - indent(out) << "while (true)" << endl; + indent(out) << "while (true)" << '\n'; scope_up(out); // Read beginning field marker - indent(out) << "xfer += iprot->readFieldBegin(fname, ftype, fid);" << endl; + indent(out) << "xfer += iprot->readFieldBegin(fname, ftype, fid);" << '\n'; // Check for field STOP marker - out << indent() << "if (ftype == ::apache::thrift::protocol::T_STOP) {" << endl << indent() - << " break;" << endl << indent() << "}" << endl; + out << indent() << "if (ftype == ::apache::thrift::protocol::T_STOP) {" << '\n' << indent() + << " break;" << '\n' << indent() << "}" << '\n'; if (fields.empty()) { - out << indent() << "xfer += iprot->skip(ftype);" << endl; + out << indent() << "xfer += iprot->skip(ftype);" << '\n'; } else { // Switch statement on the field we are reading - indent(out) << "switch (fid)" << endl; + indent(out) << "switch (fid)" << '\n'; scope_up(out); // Generate deserialization code for known cases for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - indent(out) << "case " << (*f_iter)->get_key() << ":" << endl; + indent(out) << "case " << (*f_iter)->get_key() << ":" << '\n'; indent_up(); - indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl; + indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n'; indent_up(); const char* isset_prefix = ((*f_iter)->get_req() != t_field::T_REQUIRED) ? "this->__isset." @@ -1544,8 +1542,8 @@ void t_cpp_generator::generate_struct_reader(ostream& out, t_struct* tstruct, bo // TODO(dreiss): Generate this code and "if" it out to make it easier // for people recompiling thrift to include it. out << - indent() << "if (" << isset_prefix << (*f_iter)->get_name() << ")" << endl << - indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << endl; + indent() << "if (" << isset_prefix << (*f_iter)->get_name() << ")" << '\n' << + indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << '\n'; #endif if (pointers && !(*f_iter)->get_type()->is_xception()) { @@ -1553,44 +1551,44 @@ void t_cpp_generator::generate_struct_reader(ostream& out, t_struct* tstruct, bo } else { generate_deserialize_field(out, *f_iter, "this->"); } - out << indent() << isset_prefix << (*f_iter)->get_name() << " = true;" << endl; + out << indent() << isset_prefix << (*f_iter)->get_name() << " = true;" << '\n'; indent_down(); - out << indent() << "} else {" << endl << indent() << " xfer += iprot->skip(ftype);" << endl + out << indent() << "} else {" << '\n' << indent() << " xfer += iprot->skip(ftype);" << '\n' << // TODO(dreiss): Make this an option when thrift structs // have a common base class. - // indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << endl << - indent() << "}" << endl << indent() << "break;" << endl; + // indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << '\n' << + indent() << "}" << '\n' << indent() << "break;" << '\n'; indent_down(); } // In the default case we skip the field - out << indent() << "default:" << endl << indent() << " xfer += iprot->skip(ftype);" << endl - << indent() << " break;" << endl; + out << indent() << "default:" << '\n' << indent() << " xfer += iprot->skip(ftype);" << '\n' + << indent() << " break;" << '\n'; scope_down(out); } //!fields.empty() // Read field end marker - indent(out) << "xfer += iprot->readFieldEnd();" << endl; + indent(out) << "xfer += iprot->readFieldEnd();" << '\n'; scope_down(out); - out << endl << indent() << "xfer += iprot->readStructEnd();" << endl; + out << '\n' << indent() << "xfer += iprot->readStructEnd();" << '\n'; // Throw if any required fields are missing. // We do this after reading the struct end so that // there might possibly be a chance of continuing. - out << endl; + out << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) - out << indent() << "if (!isset_" << (*f_iter)->get_name() << ')' << endl << indent() - << " throw TProtocolException(TProtocolException::INVALID_DATA);" << endl; + out << indent() << "if (!isset_" << (*f_iter)->get_name() << ')' << '\n' << indent() + << " throw TProtocolException(TProtocolException::INVALID_DATA);" << '\n'; } - indent(out) << "return xfer;" << endl; + indent(out) << "return xfer;" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -1605,33 +1603,33 @@ void t_cpp_generator::generate_struct_writer(ostream& out, t_struct* tstruct, bo vector::const_iterator f_iter; if (gen_templates_) { - out << indent() << "template " << endl << indent() << "uint32_t " - << tstruct->get_name() << "::write(Protocol_* oprot) const {" << endl; + out << indent() << "template " << '\n' << indent() << "uint32_t " + << tstruct->get_name() << "::write(Protocol_* oprot) const {" << '\n'; } else { indent(out) << "uint32_t " << tstruct->get_name() - << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl; + << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << '\n'; } indent_up(); - out << indent() << "uint32_t xfer = 0;" << endl; + out << indent() << "uint32_t xfer = 0;" << '\n'; - indent(out) << "::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);" << endl; - indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl; + indent(out) << "::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);" << '\n'; + indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool check_if_set = (*f_iter)->get_req() == t_field::T_OPTIONAL || (*f_iter)->get_type()->is_xception(); if (check_if_set) { - out << endl << indent() << "if (this->__isset." << (*f_iter)->get_name() << ") {" << endl; + out << '\n' << indent() << "if (this->__isset." << (*f_iter)->get_name() << ") {" << '\n'; indent_up(); } else { - out << endl; + out << '\n'; } // Write field header out << indent() << "xfer += oprot->writeFieldBegin(" << "\"" << (*f_iter)->get_name() << "\", " << type_to_enum((*f_iter)->get_type()) << ", " - << (*f_iter)->get_key() << ");" << endl; + << (*f_iter)->get_key() << ");" << '\n'; // Write field contents if (pointers && !(*f_iter)->get_type()->is_xception()) { generate_serialize_field(out, *f_iter, "(*(this->", "))"); @@ -1639,22 +1637,22 @@ void t_cpp_generator::generate_struct_writer(ostream& out, t_struct* tstruct, bo generate_serialize_field(out, *f_iter, "this->"); } // Write field closer - indent(out) << "xfer += oprot->writeFieldEnd();" << endl; + indent(out) << "xfer += oprot->writeFieldEnd();" << '\n'; if (check_if_set) { indent_down(); indent(out) << '}'; } } - out << endl; + out << '\n'; // Write the struct map - out << indent() << "xfer += oprot->writeFieldStop();" << endl << indent() - << "xfer += oprot->writeStructEnd();" << endl << indent() - << "return xfer;" << endl; + out << indent() << "xfer += oprot->writeFieldStop();" << '\n' << indent() + << "xfer += oprot->writeStructEnd();" << '\n' << indent() + << "return xfer;" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -1673,35 +1671,35 @@ void t_cpp_generator::generate_struct_result_writer(ostream& out, vector::const_iterator f_iter; if (gen_templates_) { - out << indent() << "template " << endl << indent() << "uint32_t " - << tstruct->get_name() << "::write(Protocol_* oprot) const {" << endl; + out << indent() << "template " << '\n' << indent() << "uint32_t " + << tstruct->get_name() << "::write(Protocol_* oprot) const {" << '\n'; } else { indent(out) << "uint32_t " << tstruct->get_name() - << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl; + << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << '\n'; } indent_up(); - out << endl << indent() << "uint32_t xfer = 0;" << endl << endl; + out << '\n' << indent() << "uint32_t xfer = 0;" << '\n' << '\n'; - indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl; + indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << '\n'; bool first = true; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if (first) { first = false; - out << endl << indent() << "if "; + out << '\n' << indent() << "if "; } else { out << " else if "; } - out << "(this->__isset." << (*f_iter)->get_name() << ") {" << endl; + out << "(this->__isset." << (*f_iter)->get_name() << ") {" << '\n'; indent_up(); // Write field header out << indent() << "xfer += oprot->writeFieldBegin(" << "\"" << (*f_iter)->get_name() << "\", " << type_to_enum((*f_iter)->get_type()) << ", " - << (*f_iter)->get_key() << ");" << endl; + << (*f_iter)->get_key() << ");" << '\n'; // Write field contents if (pointers) { generate_serialize_field(out, *f_iter, "(*(this->", "))"); @@ -1709,18 +1707,18 @@ void t_cpp_generator::generate_struct_result_writer(ostream& out, generate_serialize_field(out, *f_iter, "this->"); } // Write field closer - indent(out) << "xfer += oprot->writeFieldEnd();" << endl; + indent(out) << "xfer += oprot->writeFieldEnd();" << '\n'; indent_down(); indent(out) << "}"; } // Write the struct map - out << endl << indent() << "xfer += oprot->writeFieldStop();" << endl << indent() - << "xfer += oprot->writeStructEnd();" << endl << indent() << "return xfer;" << endl; + out << '\n' << indent() << "xfer += oprot->writeFieldStop();" << '\n' << indent() + << "xfer += oprot->writeStructEnd();" << '\n' << indent() << "return xfer;" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -1732,10 +1730,10 @@ void t_cpp_generator::generate_struct_result_writer(ostream& out, void t_cpp_generator::generate_struct_swap(ostream& out, t_struct* tstruct) { if (tstruct->get_name() == "a" || tstruct->get_name() == "b") { out << indent() << "void swap(" << tstruct->get_name() << " &a1, " << tstruct->get_name() - << " &a2) {" << endl; + << " &a2) {" << '\n'; } else { out << indent() << "void swap(" << tstruct->get_name() << " &a, " << tstruct->get_name() - << " &b) {" << endl; + << " &b) {" << '\n'; } indent_up(); @@ -1743,7 +1741,7 @@ void t_cpp_generator::generate_struct_swap(ostream& out, t_struct* tstruct) { // Let argument-dependent name lookup find the correct swap() function to // use based on the argument types. If none is found in the arguments' // namespaces, fall back to ::std::swap(). - out << indent() << "using ::std::swap;" << endl; + out << indent() << "using ::std::swap;" << '\n'; bool has_nonrequired_fields = false; const vector& fields = tstruct->get_members(); @@ -1754,41 +1752,41 @@ void t_cpp_generator::generate_struct_swap(ostream& out, t_struct* tstruct) { if (tstruct->get_name() == "a" || tstruct->get_name() == "b") { out << indent() << "swap(a1." << tfield->get_name() << ", a2." << tfield->get_name() << ");" - << endl; + << '\n'; } else { out << indent() << "swap(a." << tfield->get_name() << ", b." << tfield->get_name() << ");" - << endl; + << '\n'; } } if (has_nonrequired_fields) { if (tstruct->get_name() == "a" || tstruct->get_name() == "b") { - out << indent() << "swap(a1.__isset, a2.__isset);" << endl; + out << indent() << "swap(a1.__isset, a2.__isset);" << '\n'; } else { - out << indent() << "swap(a.__isset, b.__isset);" << endl; + out << indent() << "swap(a.__isset, b.__isset);" << '\n'; } } // handle empty structs if (fields.size() == 0) { if (tstruct->get_name() == "a" || tstruct->get_name() == "b") { - out << indent() << "(void) a1;" << endl; - out << indent() << "(void) a2;" << endl; + out << indent() << "(void) a1;" << '\n'; + out << indent() << "(void) a2;" << '\n'; } else { - out << indent() << "(void) a;" << endl; - out << indent() << "(void) b;" << endl; + out << indent() << "(void) a;" << '\n'; + out << indent() << "(void) b;" << '\n'; } } scope_down(out); - out << endl; + out << '\n'; } void t_cpp_generator::generate_struct_ostream_operator_decl(std::ostream& out, t_struct* tstruct) { out << "std::ostream& operator<<(std::ostream& out, const " << tstruct->get_name() - << "& obj);" << endl; - out << endl; + << "& obj);" << '\n'; + out << '\n'; } void t_cpp_generator::generate_struct_ostream_operator(std::ostream& out, t_struct* tstruct) { @@ -1796,12 +1794,12 @@ void t_cpp_generator::generate_struct_ostream_operator(std::ostream& out, t_stru // thrift defines this behavior out << "std::ostream& operator<<(std::ostream& out, const " << tstruct->get_name() - << "& obj)" << endl; + << "& obj)" << '\n'; scope_up(out); - out << indent() << "obj.printTo(out);" << endl - << indent() << "return out;" << endl; + out << indent() << "obj.printTo(out);" << '\n' + << indent() << "return out;" << '\n'; scope_down(out); - out << endl; + out << '\n'; } } @@ -1866,7 +1864,7 @@ void generate_fields(std::ostream& out, } generate_field(out, *it); - out << ";" << endl; + out << ";" << '\n'; } } } @@ -1877,17 +1875,17 @@ void generate_fields(std::ostream& out, void t_cpp_generator::generate_struct_print_method(std::ostream& out, t_struct* tstruct) { out << indent(); generate_struct_print_method_decl(out, tstruct); - out << " {" << endl; + out << " {" << '\n'; indent_up(); - out << indent() << "using ::apache::thrift::to_string;" << endl; - out << indent() << "out << \"" << tstruct->get_name() << "(\";" << endl; + out << indent() << "using ::apache::thrift::to_string;" << '\n'; + out << indent() << "out << \"" << tstruct->get_name() << "(\";" << '\n'; struct_ostream_operator_generator::generate_fields(out, tstruct->get_members(), indent()); - out << indent() << "out << \")\";" << endl; + out << indent() << "out << \")\";" << '\n'; indent_down(); - out << "}" << endl << endl; + out << "}" << '\n' << '\n'; } /** @@ -1896,29 +1894,29 @@ void t_cpp_generator::generate_struct_print_method(std::ostream& out, t_struct* void t_cpp_generator::generate_exception_what_method(std::ostream& out, t_struct* tstruct) { out << indent(); generate_exception_what_method_decl(out, tstruct, true); - out << " {" << endl; + out << " {" << '\n'; indent_up(); - out << indent() << "try {" << endl; + out << indent() << "try {" << '\n'; indent_up(); - out << indent() << "std::stringstream ss;" << endl; - out << indent() << "ss << \"TException - service has thrown: \" << *this;" << endl; - out << indent() << "this->thriftTExceptionMessageHolder_ = ss.str();" << endl; - out << indent() << "return this->thriftTExceptionMessageHolder_.c_str();" << endl; + out << indent() << "std::stringstream ss;" << '\n'; + out << indent() << "ss << \"TException - service has thrown: \" << *this;" << '\n'; + out << indent() << "this->thriftTExceptionMessageHolder_ = ss.str();" << '\n'; + out << indent() << "return this->thriftTExceptionMessageHolder_.c_str();" << '\n'; indent_down(); - out << indent() << "} catch (const std::exception&) {" << endl; + out << indent() << "} catch (const std::exception&) {" << '\n'; indent_up(); out << indent() << "return \"TException - service has thrown: " << tstruct->get_name() << "\";" - << endl; + << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << "}" << endl << endl; + out << "}" << '\n' << '\n'; } /** @@ -1938,30 +1936,30 @@ void t_cpp_generator::generate_service(t_service* tservice) { // Print header file includes f_header_ << autogen_comment(); - f_header_ << "#ifndef " << svcname << "_H" << endl << "#define " << svcname << "_H" << endl - << endl; + f_header_ << "#ifndef " << svcname << "_H" << '\n' << "#define " << svcname << "_H" << '\n' + << '\n'; if (gen_cob_style_) { - f_header_ << "#include " << endl // TMemoryBuffer - << "#include " << endl - << "namespace apache { namespace thrift { namespace async {" << endl - << "class TAsyncChannel;" << endl << "}}}" << endl; + f_header_ << "#include " << '\n' // TMemoryBuffer + << "#include " << '\n' + << "namespace apache { namespace thrift { namespace async {" << '\n' + << "class TAsyncChannel;" << '\n' << "}}}" << '\n'; } - f_header_ << "#include " << endl; + f_header_ << "#include " << '\n'; if (gen_cob_style_) { - f_header_ << "#include " << endl; + f_header_ << "#include " << '\n'; } - f_header_ << "#include " << endl; - f_header_ << "#include " << endl; + f_header_ << "#include " << '\n'; + f_header_ << "#include " << '\n'; f_header_ << "#include \"" << get_include_prefix(*get_program()) << program_name_ << "_types.h\"" - << endl; + << '\n'; t_service* extends_service = tservice->get_extends(); if (extends_service != nullptr) { f_header_ << "#include \"" << get_include_prefix(*(extends_service->get_program())) - << extends_service->get_name() << ".h\"" << endl; + << extends_service->get_name() << ".h\"" << '\n'; } - f_header_ << endl << ns_open_ << endl << endl; + f_header_ << '\n' << ns_open_ << '\n' << '\n'; f_header_ << "#ifdef _MSC_VER\n" " #pragma warning( push )\n" @@ -1972,30 +1970,30 @@ void t_cpp_generator::generate_service(t_service* tservice) { string f_service_name = get_out_dir() + svcname + ".cpp"; f_service_.open(f_service_name.c_str()); f_service_ << autogen_comment(); - f_service_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl; + f_service_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << '\n'; if (gen_cob_style_) { - f_service_ << "#include \"thrift/async/TAsyncChannel.h\"" << endl; + f_service_ << "#include \"thrift/async/TAsyncChannel.h\"" << '\n'; } if (gen_templates_) { f_service_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".tcc\"" - << endl; + << '\n'; string f_service_tcc_name = get_out_dir() + svcname + ".tcc"; f_service_tcc_.open(f_service_tcc_name.c_str()); f_service_tcc_ << autogen_comment(); f_service_tcc_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" - << endl; + << '\n'; - f_service_tcc_ << "#ifndef " << svcname << "_TCC" << endl << "#define " << svcname << "_TCC" - << endl << endl; + f_service_tcc_ << "#ifndef " << svcname << "_TCC" << '\n' << "#define " << svcname << "_TCC" + << '\n' << '\n'; if (gen_cob_style_) { - f_service_tcc_ << "#include \"thrift/async/TAsyncChannel.h\"" << endl; + f_service_tcc_ << "#include \"thrift/async/TAsyncChannel.h\"" << '\n'; } } - f_service_ << endl << ns_open_ << endl << endl; - f_service_tcc_ << endl << ns_open_ << endl << endl; + f_service_ << '\n' << ns_open_ << '\n' << '\n'; + f_service_tcc_ << '\n' << ns_open_ << '\n' << '\n'; // Generate all the components generate_service_interface(tservice, ""); @@ -2032,19 +2030,19 @@ void t_cpp_generator::generate_service(t_service* tservice) { "#endif\n\n"; // Close the namespace - f_service_ << ns_close_ << endl << endl; - f_service_tcc_ << ns_close_ << endl << endl; - f_header_ << ns_close_ << endl << endl; + f_service_ << ns_close_ << '\n' << '\n'; + f_service_tcc_ << ns_close_ << '\n' << '\n'; + f_header_ << ns_close_ << '\n' << '\n'; // TODO(simpkins): Make this a separate option if (gen_templates_) { - f_header_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".tcc\"" << endl + f_header_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".tcc\"" << '\n' << "#include \"" << get_include_prefix(*get_program()) << program_name_ - << "_types.tcc\"" << endl << endl; + << "_types.tcc\"" << '\n' << '\n'; } - f_header_ << "#endif" << endl; - f_service_tcc_ << "#endif" << endl; + f_header_ << "#endif" << '\n'; + f_service_tcc_ << "#endif" << '\n'; // Close the files f_service_tcc_.close(); @@ -2098,9 +2096,9 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty if (gen_templates_) { client_name += "T"; service_if_name += "T"; - indent(f_header_) << "template " << endl; + indent(f_header_) << "template " << '\n'; } - indent(f_header_) << "class " << client_name << ";" << endl << endl; + indent(f_header_) << "class " << client_name << ";" << '\n' << '\n'; } string extends = ""; @@ -2114,31 +2112,31 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty } if (style == "CobCl" && gen_templates_) { - f_header_ << "template " << endl; + f_header_ << "template " << '\n'; } generate_java_doc(f_header_, tservice); - f_header_ << "class " << service_if_name << extends << " {" << endl << " public:" << endl; + f_header_ << "class " << service_if_name << extends << " {" << '\n' << " public:" << '\n'; indent_up(); - f_header_ << indent() << "virtual ~" << service_if_name << "() {}" << endl; + f_header_ << indent() << "virtual ~" << service_if_name << "() {}" << '\n'; vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { if ((*f_iter)->has_doc()) - f_header_ << endl; + f_header_ << '\n'; generate_java_doc(f_header_, *f_iter); - f_header_ << indent() << "virtual " << function_signature(*f_iter, style) << " = 0;" << endl; + f_header_ << indent() << "virtual " << function_signature(*f_iter, style) << " = 0;" << '\n'; } indent_down(); - f_header_ << "};" << endl << endl; + f_header_ << "};" << '\n' << '\n'; if (style == "CobCl" && gen_templates_) { // generate a backwards-compatible typedef for clients that do not // know about the new template-style code f_header_ << "typedef " << service_if_name << "< ::apache::thrift::protocol::TProtocol> " - << service_name_ << style << "If;" << endl << endl; + << service_name_ << style << "If;" << '\n' << '\n'; } } @@ -2181,37 +2179,37 @@ void t_cpp_generator::generate_service_interface_factory(t_service* tservice, st extends = " : virtual public " + type_name(tservice->get_extends()) + style + "IfFactory"; } - f_header_ << "class " << factory_name << extends << " {" << endl << " public:" << endl; + f_header_ << "class " << factory_name << extends << " {" << '\n' << " public:" << '\n'; indent_up(); - f_header_ << indent() << "typedef " << service_if_name << " Handler;" << endl << endl << indent() - << "virtual ~" << factory_name << "() {}" << endl << endl << indent() << "virtual " + f_header_ << indent() << "typedef " << service_if_name << " Handler;" << '\n' << '\n' << indent() + << "virtual ~" << factory_name << "() {}" << '\n' << '\n' << indent() << "virtual " << service_if_name << "* getHandler(" << "const ::apache::thrift::TConnectionInfo& connInfo)" - << (extends.empty() ? "" : " override") << " = 0;" << endl << indent() + << (extends.empty() ? "" : " override") << " = 0;" << '\n' << indent() << "virtual void releaseHandler(" << base_if_name << "* /* handler */)" - << (extends.empty() ? "" : " override") << " = 0;" << endl << indent(); + << (extends.empty() ? "" : " override") << " = 0;" << '\n' << indent(); indent_down(); - f_header_ << "};" << endl << endl; + f_header_ << "};" << '\n' << '\n'; // Generate the singleton factory class string singleton_factory_name = service_if_name + "SingletonFactory"; f_header_ << "class " << singleton_factory_name << " : virtual public " << factory_name << " {" - << endl << " public:" << endl; + << '\n' << " public:" << '\n'; indent_up(); f_header_ << indent() << singleton_factory_name << "(const ::std::shared_ptr<" << service_if_name - << ">& iface) : iface_(iface) {}" << endl << indent() << "virtual ~" - << singleton_factory_name << "() {}" << endl << endl << indent() << "virtual " + << ">& iface) : iface_(iface) {}" << '\n' << indent() << "virtual ~" + << singleton_factory_name << "() {}" << '\n' << '\n' << indent() << "virtual " << service_if_name << "* getHandler(" - << "const ::apache::thrift::TConnectionInfo&) override {" << endl << indent() - << " return iface_.get();" << endl << indent() << "}" << endl << indent() - << "virtual void releaseHandler(" << base_if_name << "* /* handler */) override {}" << endl; + << "const ::apache::thrift::TConnectionInfo&) override {" << '\n' << indent() + << " return iface_.get();" << '\n' << indent() << "}" << '\n' << indent() + << "virtual void releaseHandler(" << base_if_name << "* /* handler */) override {}" << '\n'; - f_header_ << endl << " protected:" << endl << indent() << "::std::shared_ptr<" << service_if_name - << "> iface_;" << endl; + f_header_ << '\n' << " protected:" << '\n' << indent() << "::std::shared_ptr<" << service_if_name + << "> iface_;" << '\n'; indent_down(); - f_header_ << "};" << endl << endl; + f_header_ << "};" << '\n' << '\n'; } /** @@ -2225,14 +2223,14 @@ void t_cpp_generator::generate_service_null(t_service* tservice, string style) { extends = " , virtual public " + type_name(tservice->get_extends()) + style + "Null"; } f_header_ << "class " << service_name_ << style << "Null : virtual public " << service_name_ - << style << "If" << extends << " {" << endl << " public:" << endl; + << style << "If" << extends << " {" << '\n' << " public:" << '\n'; indent_up(); - f_header_ << indent() << "virtual ~" << service_name_ << style << "Null() {}" << endl; + f_header_ << indent() << "virtual ~" << service_name_ << style << "Null() {}" << '\n'; vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { f_header_ << indent() << function_signature(*f_iter, style, "", false) - << " override {" << endl; + << " override {" << '\n'; indent_up(); t_type* returntype = (*f_iter)->get_returntype(); @@ -2240,18 +2238,18 @@ void t_cpp_generator::generate_service_null(t_service* tservice, string style) { if (style == "") { if (returntype->is_void() || is_complex_type(returntype)) { - f_header_ << indent() << "return;" << endl; + f_header_ << indent() << "return;" << '\n'; } else { - f_header_ << indent() << declare_field(&returnfield, true) << endl << indent() - << "return _return;" << endl; + f_header_ << indent() << declare_field(&returnfield, true) << '\n' << indent() + << "return _return;" << '\n'; } } else if (style == "CobSv") { if (returntype->is_void()) { - f_header_ << indent() << "return cob();" << endl; + f_header_ << indent() << "return cob();" << '\n'; } else { t_field returnfield(returntype, "_return"); - f_header_ << indent() << declare_field(&returnfield, true) << endl << indent() - << "return cob(_return);" << endl; + f_header_ << indent() << declare_field(&returnfield, true) << '\n' << indent() + << "return cob(_return);" << '\n'; } } else { @@ -2259,10 +2257,10 @@ void t_cpp_generator::generate_service_null(t_service* tservice, string style) { } indent_down(); - f_header_ << indent() << "}" << endl; + f_header_ << indent() << "}" << '\n'; } indent_down(); - f_header_ << "};" << endl << endl; + f_header_ << "};" << '\n' << '\n'; } void t_cpp_generator::generate_function_call(ostream& out, @@ -2293,7 +2291,7 @@ void t_cpp_generator::generate_function_call(ostream& out, } out << arg_prefix << (*f_iter)->get_name(); } - out << ");" << endl; + out << ");" << '\n'; } void t_cpp_generator::generate_service_async_skeleton(t_service* tservice) { @@ -2307,58 +2305,58 @@ void t_cpp_generator::generate_service_async_skeleton(t_service* tservice) { ofstream_with_content_based_conditional_update f_skeleton; f_skeleton.open(f_skeleton_name.c_str()); f_skeleton << "// This autogenerated skeleton file illustrates one way to adapt a synchronous" - << endl << "// interface into an asynchronous interface. You should copy it to another" - << endl + << '\n' << "// interface into an asynchronous interface. You should copy it to another" + << '\n' << "// filename to avoid overwriting it and rewrite as asynchronous any functions" - << endl << "// that would otherwise introduce unwanted latency." << endl << endl - << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl << endl - << "using namespace ::apache::thrift;" << endl - << "using namespace ::apache::thrift::protocol;" << endl - << "using namespace ::apache::thrift::transport;" << endl - << "using namespace ::apache::thrift::async;" << endl << endl; + << '\n' << "// that would otherwise introduce unwanted latency." << '\n' << '\n' + << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << '\n' + << "#include " << '\n' + << "#include " << '\n' + << "#include " << '\n' + << "#include " << '\n' + << "#include " << '\n' << '\n' + << "using namespace ::apache::thrift;" << '\n' + << "using namespace ::apache::thrift::protocol;" << '\n' + << "using namespace ::apache::thrift::transport;" << '\n' + << "using namespace ::apache::thrift::async;" << '\n' << '\n'; // the following code would not compile: // using namespace ; // using namespace ::; if ((!ns.empty()) && (ns.compare(" ::") != 0)) { - f_skeleton << "using namespace " << string(ns, 0, ns.size() - 2) << ";" << endl << endl; + f_skeleton << "using namespace " << string(ns, 0, ns.size() - 2) << ";" << '\n' << '\n'; } - f_skeleton << "class " << svcname << "Handler : virtual public " << svcname << "If {" << endl - << " public:" << endl; + f_skeleton << "class " << svcname << "Handler : virtual public " << svcname << "If {" << '\n' + << " public:" << '\n'; indent_up(); - f_skeleton << indent() << svcname << "Handler() {" << endl << indent() - << " // Your initialization goes here" << endl << indent() << "}" << endl << endl; + f_skeleton << indent() << svcname << "Handler() {" << '\n' << indent() + << " // Your initialization goes here" << '\n' << indent() << "}" << '\n' << '\n'; vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_java_doc(f_skeleton, *f_iter); - f_skeleton << indent() << function_signature(*f_iter, "") << " {" << endl << indent() - << " // Your implementation goes here" << endl << indent() << " printf(\"" - << (*f_iter)->get_name() << "\\n\");" << endl << indent() << "}" << endl << endl; + f_skeleton << indent() << function_signature(*f_iter, "") << " {" << '\n' << indent() + << " // Your implementation goes here" << '\n' << indent() << " printf(\"" + << (*f_iter)->get_name() << "\\n\");" << '\n' << indent() << "}" << '\n' << '\n'; } indent_down(); - f_skeleton << "};" << endl << endl; + f_skeleton << "};" << '\n' << '\n'; f_skeleton << "class " << svcname << "AsyncHandler : " - << "public " << svcname << "CobSvIf {" << endl << " public:" << endl; + << "public " << svcname << "CobSvIf {" << '\n' << " public:" << '\n'; indent_up(); - f_skeleton << indent() << svcname << "AsyncHandler() {" << endl << indent() + f_skeleton << indent() << svcname << "AsyncHandler() {" << '\n' << indent() << " syncHandler_ = std::unique_ptr<" << svcname << "Handler>(new " << svcname - << "Handler);" << endl << indent() << " // Your initialization goes here" << endl - << indent() << "}" << endl; - f_skeleton << indent() << "virtual ~" << service_name_ << "AsyncHandler();" << endl; + << "Handler);" << '\n' << indent() << " // Your initialization goes here" << '\n' + << indent() << "}" << '\n'; + f_skeleton << indent() << "virtual ~" << service_name_ << "AsyncHandler();" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - f_skeleton << endl << indent() << function_signature(*f_iter, "CobSv", "", true) << " {" - << endl; + f_skeleton << '\n' << indent() << function_signature(*f_iter, "CobSv", "", true) << " {" + << '\n'; indent_up(); t_type* returntype = (*f_iter)->get_returntype(); @@ -2366,32 +2364,32 @@ void t_cpp_generator::generate_service_async_skeleton(t_service* tservice) { string target = returntype->is_void() ? "" : "_return"; if (!returntype->is_void()) { - f_skeleton << indent() << declare_field(&returnfield, true) << endl; + f_skeleton << indent() << declare_field(&returnfield, true) << '\n'; } generate_function_call(f_skeleton, *f_iter, target, "syncHandler_", ""); - f_skeleton << indent() << "return cob(" << target << ");" << endl; + f_skeleton << indent() << "return cob(" << target << ");" << '\n'; scope_down(f_skeleton); } - f_skeleton << endl << " protected:" << endl << indent() << "std::unique_ptr<" << svcname - << "Handler> syncHandler_;" << endl; + f_skeleton << '\n' << " protected:" << '\n' << indent() << "std::unique_ptr<" << svcname + << "Handler> syncHandler_;" << '\n'; indent_down(); - f_skeleton << "};" << endl << endl; + f_skeleton << "};" << '\n' << '\n'; - f_skeleton << indent() << "int main(int argc, char **argv) {" << endl; + f_skeleton << indent() << "int main(int argc, char **argv) {" << '\n'; indent_up(); f_skeleton - << indent() << "int port = 9090;" << endl << indent() << "::std::shared_ptr<" << svcname - << "AsyncHandler> handler(new " << svcname << "AsyncHandler());" << endl << indent() - << "::std::shared_ptr<" << svcname << "AsyncProcessor> processor(new " << svcname << "AsyncProcessor(handler));" << endl + << indent() << "int port = 9090;" << '\n' << indent() << "::std::shared_ptr<" << svcname + << "AsyncHandler> handler(new " << svcname << "AsyncHandler());" << '\n' << indent() + << "::std::shared_ptr<" << svcname << "AsyncProcessor> processor(new " << svcname << "AsyncProcessor(handler));" << '\n' << indent() << "::std::shared_ptr protocolFactory(new TBinaryProtocolFactory());" - << endl + << '\n' << indent() << "::std::shared_ptr protocolProcessor(new TAsyncProtocolProcessor(processor, protocolFactory));" - << endl << endl << indent() + << '\n' << '\n' << indent() << "TEvhttpServer server(protocolProcessor, port);" - << endl << indent() << "server.serve();" << endl << indent() << "return 0;" << endl; + << '\n' << indent() << "server.serve();" << '\n' << indent() << "return 0;" << '\n'; indent_down(); - f_skeleton << "}" << endl << endl; + f_skeleton << "}" << '\n' << '\n'; } /** @@ -2417,35 +2415,35 @@ void t_cpp_generator::generate_service_multiface(t_service* tservice) { // Generate the header portion f_header_ << "class " << service_name_ << "Multiface : " - << "virtual public " << service_name_ << "If" << extends_multiface << " {" << endl - << " public:" << endl; + << "virtual public " << service_name_ << "If" << extends_multiface << " {" << '\n' + << " public:" << '\n'; indent_up(); f_header_ << indent() << service_name_ << "Multiface(" << list_type - << "& ifaces) : ifaces_(ifaces) {" << endl; + << "& ifaces) : ifaces_(ifaces) {" << '\n'; if (!extends.empty()) { f_header_ << indent() << " std::vector >::iterator iter;" - << endl << indent() << " for (iter = ifaces.begin(); iter != ifaces.end(); ++iter) {" - << endl << indent() << " " << extends << "Multiface::add(*iter);" << endl - << indent() << " }" << endl; + << '\n' << indent() << " for (iter = ifaces.begin(); iter != ifaces.end(); ++iter) {" + << '\n' << indent() << " " << extends << "Multiface::add(*iter);" << '\n' + << indent() << " }" << '\n'; } - f_header_ << indent() << "}" << endl << indent() << "virtual ~" << service_name_ - << "Multiface() {}" << endl; + f_header_ << indent() << "}" << '\n' << indent() << "virtual ~" << service_name_ + << "Multiface() {}" << '\n'; indent_down(); // Protected data members - f_header_ << " protected:" << endl; + f_header_ << " protected:" << '\n'; indent_up(); - f_header_ << indent() << list_type << " ifaces_;" << endl << indent() << service_name_ - << "Multiface() {}" << endl << indent() << "void add(::std::shared_ptr<" - << service_name_ << "If> iface) {" << endl; + f_header_ << indent() << list_type << " ifaces_;" << '\n' << indent() << service_name_ + << "Multiface() {}" << '\n' << indent() << "void add(::std::shared_ptr<" + << service_name_ << "If> iface) {" << '\n'; if (!extends.empty()) { - f_header_ << indent() << " " << extends << "Multiface::add(iface);" << endl; + f_header_ << indent() << " " << extends << "Multiface::add(iface);" << '\n'; } - f_header_ << indent() << " ifaces_.push_back(iface);" << endl << indent() << "}" << endl; + f_header_ << indent() << " ifaces_.push_back(iface);" << '\n' << indent() << "}" << '\n'; indent_down(); - f_header_ << indent() << " public:" << endl; + f_header_ << indent() << " public:" << '\n'; indent_up(); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -2470,31 +2468,31 @@ void t_cpp_generator::generate_service_multiface(t_service* tservice) { } call += ")"; - f_header_ << indent() << function_signature(*f_iter, "") << " override {" << endl; + f_header_ << indent() << function_signature(*f_iter, "") << " override {" << '\n'; indent_up(); - f_header_ << indent() << "size_t sz = ifaces_.size();" << endl << indent() << "size_t i = 0;" - << endl << indent() << "for (; i < (sz - 1); ++i) {" << endl; + f_header_ << indent() << "size_t sz = ifaces_.size();" << '\n' << indent() << "size_t i = 0;" + << '\n' << indent() << "for (; i < (sz - 1); ++i) {" << '\n'; indent_up(); - f_header_ << indent() << call << ";" << endl; + f_header_ << indent() << call << ";" << '\n'; indent_down(); - f_header_ << indent() << "}" << endl; + f_header_ << indent() << "}" << '\n'; if (!(*f_iter)->get_returntype()->is_void()) { if (is_complex_type((*f_iter)->get_returntype())) { - f_header_ << indent() << call << ";" << endl << indent() << "return;" << endl; + f_header_ << indent() << call << ";" << '\n' << indent() << "return;" << '\n'; } else { - f_header_ << indent() << "return " << call << ";" << endl; + f_header_ << indent() << "return " << call << ";" << '\n'; } } else { - f_header_ << indent() << call << ";" << endl; + f_header_ << indent() << call << ";" << '\n'; } indent_down(); - f_header_ << indent() << "}" << endl << endl; + f_header_ << indent() << "}" << '\n' << '\n'; } indent_down(); - f_header_ << indent() << "};" << endl << endl; + f_header_ << indent() << "};" << '\n' << '\n'; } /** @@ -2545,7 +2543,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) f_header_ << template_header << "class " << service_name_ << style << "Client" << short_suffix << " : " << "virtual public " << service_name_ << ifstyle << if_suffix << extends_client << " {" - << endl << " public:" << endl; + << '\n' << " public:" << '\n'; indent_up(); if (style != "Cob") { @@ -2558,18 +2556,18 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) if (extends.empty()) { if (style == "Concurrent") { - f_header_ << ": sync_(sync)" << endl; + f_header_ << ": sync_(sync)" << '\n'; } - f_header_ << "{" << endl; - f_header_ << indent() << " setProtocol" << short_suffix << "(prot);" << endl << indent() - << "}" << endl; + f_header_ << "{" << '\n'; + f_header_ << indent() << " setProtocol" << short_suffix << "(prot);" << '\n' << indent() + << "}" << '\n'; } else { - f_header_ << ":" << endl; + f_header_ << ":" << '\n'; f_header_ << indent() << " " << extends << style << client_suffix << "(prot, prot"; if (style == "Concurrent") { f_header_ << ", sync"; } - f_header_ << ") {}" << endl; + f_header_ << ") {}" << '\n'; } f_header_ << indent() << service_name_ << style << "Client" << short_suffix << "(" << prot_ptr @@ -2581,38 +2579,38 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) if (extends.empty()) { if (style == "Concurrent") { - f_header_ << ": sync_(sync)" << endl; + f_header_ << ": sync_(sync)" << '\n'; } - f_header_ << "{" << endl; - f_header_ << indent() << " setProtocol" << short_suffix << "(iprot,oprot);" << endl - << indent() << "}" << endl; + f_header_ << "{" << '\n'; + f_header_ << indent() << " setProtocol" << short_suffix << "(iprot,oprot);" << '\n' + << indent() << "}" << '\n'; } else { f_header_ << ":" << indent() << " " << extends << style << client_suffix << "(iprot, oprot"; if (style == "Concurrent") { f_header_ << ", sync"; } - f_header_ << ") {}" << endl; + f_header_ << ") {}" << '\n'; } // create the setProtocol methods if (extends.empty()) { - f_header_ << " private:" << endl; + f_header_ << " private:" << '\n'; // 1: one parameter f_header_ << indent() << "void setProtocol" << short_suffix << "(" << prot_ptr << " prot) {" - << endl; - f_header_ << indent() << "setProtocol" << short_suffix << "(prot,prot);" << endl; - f_header_ << indent() << "}" << endl; + << '\n'; + f_header_ << indent() << "setProtocol" << short_suffix << "(prot,prot);" << '\n'; + f_header_ << indent() << "}" << '\n'; // 2: two parameter f_header_ << indent() << "void setProtocol" << short_suffix << "(" << prot_ptr << " iprot, " - << prot_ptr << " oprot) {" << endl; + << prot_ptr << " oprot) {" << '\n'; - f_header_ << indent() << " piprot_=iprot;" << endl << indent() << " poprot_=oprot;" << endl - << indent() << " iprot_ = iprot.get();" << endl << indent() - << " oprot_ = oprot.get();" << endl; + f_header_ << indent() << " piprot_=iprot;" << '\n' << indent() << " poprot_=oprot;" << '\n' + << indent() << " iprot_ = iprot.get();" << '\n' << indent() + << " oprot_ = oprot.get();" << '\n'; - f_header_ << indent() << "}" << endl; - f_header_ << " public:" << endl; + f_header_ << indent() << "}" << '\n'; + f_header_ << " public:" << '\n'; } // Generate getters for the protocols. @@ -2620,45 +2618,45 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) // TODO(simpkins): should they be templated? f_header_ << indent() << "std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() {" - << endl << indent() << " return " << _this << "piprot_;" << endl << indent() << "}" - << endl; + << '\n' << indent() << " return " << _this << "piprot_;" << '\n' << indent() << "}" + << '\n'; f_header_ << indent() << "std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() {" - << endl << indent() << " return " << _this << "poprot_;" << endl << indent() << "}" - << endl; + << '\n' << indent() << " return " << _this << "poprot_;" << '\n' << indent() << "}" + << '\n'; } else /* if (style == "Cob") */ { f_header_ << indent() << service_name_ << style << "Client" << short_suffix << "(" << "std::shared_ptr< ::apache::thrift::async::TAsyncChannel> channel, " - << "::apache::thrift::protocol::TProtocolFactory* protocolFactory) :" << endl; + << "::apache::thrift::protocol::TProtocolFactory* protocolFactory) :" << '\n'; if (extends.empty()) { - f_header_ << indent() << " channel_(channel)," << endl << indent() - << " itrans_(new ::apache::thrift::transport::TMemoryBuffer())," << endl + f_header_ << indent() << " channel_(channel)," << '\n' << indent() + << " itrans_(new ::apache::thrift::transport::TMemoryBuffer())," << '\n' << indent() << " otrans_(new ::apache::thrift::transport::TMemoryBuffer())," - << endl; + << '\n'; if (gen_templates_) { // TProtocolFactory classes return generic TProtocol pointers. // We have to dynamic cast to the Protocol_ type we are expecting. f_header_ << indent() << " piprot_(::std::dynamic_pointer_cast(" - << "protocolFactory->getProtocol(itrans_)))," << endl << indent() + << "protocolFactory->getProtocol(itrans_)))," << '\n' << indent() << " poprot_(::std::dynamic_pointer_cast(" - << "protocolFactory->getProtocol(otrans_))) {" << endl; + << "protocolFactory->getProtocol(otrans_))) {" << '\n'; // Throw a TException if either dynamic cast failed. - f_header_ << indent() << " if (!piprot_ || !poprot_) {" << endl << indent() + f_header_ << indent() << " if (!piprot_ || !poprot_) {" << '\n' << indent() << " throw ::apache::thrift::TException(\"" << "TProtocolFactory returned unexpected protocol type in " << service_name_ - << style << "Client" << short_suffix << " constructor\");" << endl << indent() - << " }" << endl; + << style << "Client" << short_suffix << " constructor\");" << '\n' << indent() + << " }" << '\n'; } else { - f_header_ << indent() << " piprot_(protocolFactory->getProtocol(itrans_))," << endl - << indent() << " poprot_(protocolFactory->getProtocol(otrans_)) {" << endl; + f_header_ << indent() << " piprot_(protocolFactory->getProtocol(itrans_))," << '\n' + << indent() << " poprot_(protocolFactory->getProtocol(otrans_)) {" << '\n'; } - f_header_ << indent() << " iprot_ = piprot_.get();" << endl << indent() - << " oprot_ = poprot_.get();" << endl << indent() << "}" << endl; + f_header_ << indent() << " iprot_ = piprot_.get();" << '\n' << indent() + << " oprot_ = poprot_.get();" << '\n' << indent() << "}" << '\n'; } else { f_header_ << indent() << " " << extends << style << client_suffix - << "(channel, protocolFactory) {}" << endl; + << "(channel, protocolFactory) {}" << '\n'; } } @@ -2666,10 +2664,10 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) generate_java_doc(f_header_, tservice); f_header_ << indent() - << "::std::shared_ptr< ::apache::thrift::async::TAsyncChannel> getChannel() {" << endl - << indent() << " return " << _this << "channel_;" << endl << indent() << "}" << endl; + << "::std::shared_ptr< ::apache::thrift::async::TAsyncChannel> getChannel() {" << '\n' + << indent() << " return " << _this << "channel_;" << '\n' << indent() << "}" << '\n'; if (!gen_no_client_completion_) { - f_header_ << indent() << "virtual void completed__(bool /* success */) {}" << endl; + f_header_ << indent() << "virtual void completed__(bool /* success */) {}" << '\n'; } } @@ -2678,7 +2676,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_java_doc(f_header_, *f_iter); indent(f_header_) << function_signature(*f_iter, ifstyle) - << " override;" << endl; + << " override;" << '\n'; // TODO(dreiss): Use private inheritance to avoid generating thise in cob-style. if (style == "Concurrent" && !(*f_iter)->is_oneway()) { // concurrent clients need to move the seqid from the send function to the @@ -2687,12 +2685,12 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) t_function send_function(g_type_i32, /*returning seqid*/ string("send_") + (*f_iter)->get_name(), (*f_iter)->get_arglist()); - indent(f_header_) << function_signature(&send_function, "") << ";" << endl; + indent(f_header_) << function_signature(&send_function, "") << ";" << '\n'; } else { t_function send_function(g_type_void, string("send_") + (*f_iter)->get_name(), (*f_iter)->get_arglist()); - indent(f_header_) << function_signature(&send_function, "") << ";" << endl; + indent(f_header_) << function_signature(&send_function, "") << ";" << '\n'; } if (!(*f_iter)->is_oneway()) { if (style == "Concurrent") { @@ -2702,52 +2700,52 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) t_function recv_function((*f_iter)->get_returntype(), string("recv_") + (*f_iter)->get_name(), &seqIdArgStruct); - indent(f_header_) << function_signature(&recv_function, "") << ";" << endl; + indent(f_header_) << function_signature(&recv_function, "") << ";" << '\n'; } else { t_struct noargs(program_); t_function recv_function((*f_iter)->get_returntype(), string("recv_") + (*f_iter)->get_name(), &noargs); - indent(f_header_) << function_signature(&recv_function, "") << ";" << endl; + indent(f_header_) << function_signature(&recv_function, "") << ";" << '\n'; } } } indent_down(); if (extends.empty()) { - f_header_ << " protected:" << endl; + f_header_ << " protected:" << '\n'; indent_up(); if (style == "Cob") { f_header_ << indent() - << "::std::shared_ptr< ::apache::thrift::async::TAsyncChannel> channel_;" << endl + << "::std::shared_ptr< ::apache::thrift::async::TAsyncChannel> channel_;" << '\n' << indent() - << "::std::shared_ptr< ::apache::thrift::transport::TMemoryBuffer> itrans_;" << endl + << "::std::shared_ptr< ::apache::thrift::transport::TMemoryBuffer> itrans_;" << '\n' << indent() << "::std::shared_ptr< ::apache::thrift::transport::TMemoryBuffer> otrans_;" - << endl; + << '\n'; } f_header_ << - indent() << prot_ptr << " piprot_;" << endl << - indent() << prot_ptr << " poprot_;" << endl << - indent() << protocol_type << "* iprot_;" << endl << - indent() << protocol_type << "* oprot_;" << endl; + indent() << prot_ptr << " piprot_;" << '\n' << + indent() << prot_ptr << " poprot_;" << '\n' << + indent() << protocol_type << "* iprot_;" << '\n' << + indent() << protocol_type << "* oprot_;" << '\n'; if (style == "Concurrent") { f_header_ << - indent() << "std::shared_ptr< ::apache::thrift::async::TConcurrentClientSyncInfo> sync_;"< sync_;" << '\n'; } indent_down(); } - f_header_ << "};" << endl << endl; + f_header_ << "};" << '\n' << '\n'; if (gen_templates_) { // Output a backwards compatibility typedef using // TProtocol as the template parameter. f_header_ << "typedef " << service_name_ << style << "ClientT< ::apache::thrift::protocol::TProtocol> " << service_name_ << style - << "Client;" << endl << endl; + << "Client;" << '\n' << '\n'; } string scope = service_name_ + style + client_suffix + "::"; @@ -2769,7 +2767,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) if (gen_templates_) { indent(out) << template_header; } - indent(out) << function_signature(*f_iter, ifstyle, scope) << endl; + indent(out) << function_signature(*f_iter, ifstyle, scope) << '\n'; scope_up(out); indent(out) << seqIdCapture << "send_" << funname << "("; @@ -2788,33 +2786,33 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) } out << (*fld_iter)->get_name(); } - out << ");" << endl; + out << ");" << '\n'; if (style != "Cob") { if (!(*f_iter)->is_oneway()) { out << indent(); if (!(*f_iter)->get_returntype()->is_void()) { if (is_complex_type((*f_iter)->get_returntype())) { - out << "recv_" << funname << "(_return" << seqIdCommaUse << ");" << endl; + out << "recv_" << funname << "(_return" << seqIdCommaUse << ");" << '\n'; } else { - out << "return recv_" << funname << "(" << seqIdUse << ");" << endl; + out << "return recv_" << funname << "(" << seqIdUse << ");" << '\n'; } } else { - out << "recv_" << funname << "(" << seqIdUse << ");" << endl; + out << "recv_" << funname << "(" << seqIdUse << ");" << '\n'; } } } else { if (!(*f_iter)->is_oneway()) { out << indent() << _this << "channel_->sendAndRecvMessage(" << "::std::bind(cob, this), " << _this << "otrans_.get(), " << _this << "itrans_.get());" - << endl; + << '\n'; } else { out << indent() << _this << "channel_->sendMessage(" - << "::std::bind(cob, this), " << _this << "otrans_.get());" << endl; + << "::std::bind(cob, this), " << _this << "otrans_.get());" << '\n'; } } scope_down(out); - out << endl; + out << '\n'; // if (style != "Cob") // TODO(dreiss): Libify the client and don't generate this for cob-style if (true) { @@ -2831,7 +2829,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) if (gen_templates_) { indent(out) << template_header; } - indent(out) << function_signature(&send_function, "", scope) << endl; + indent(out) << function_signature(&send_function, "", scope) << '\n'; scope_up(out); // Function arguments and results @@ -2846,41 +2844,41 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) } // Serialize the request out << - indent() << "int32_t cseqid = " << cseqidVal << ";" << endl; + indent() << "int32_t cseqid = " << cseqidVal << ";" << '\n'; if(style == "Concurrent") { out << - indent() << "::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());" << endl; + indent() << "::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());" << '\n'; } if (style == "Cob") { out << - indent() << _this << "otrans_->resetBuffer();" << endl; + indent() << _this << "otrans_->resetBuffer();" << '\n'; } out << indent() << _this << "oprot_->writeMessageBegin(\"" << (*f_iter)->get_name() << "\", ::apache::thrift::protocol::" << ((*f_iter)->is_oneway() ? "T_ONEWAY" : "T_CALL") << - ", cseqid);" << endl << endl << - indent() << argsname << " args;" << endl; + ", cseqid);" << '\n' << '\n' << + indent() << argsname << " args;" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { out << indent() << "args." << (*fld_iter)->get_name() << " = &" << (*fld_iter)->get_name() - << ";" << endl; + << ";" << '\n'; } - out << indent() << "args.write(" << _this << "oprot_);" << endl << endl << indent() << _this - << "oprot_->writeMessageEnd();" << endl << indent() << _this - << "oprot_->getTransport()->writeEnd();" << endl << indent() << _this - << "oprot_->getTransport()->flush();" << endl; + out << indent() << "args.write(" << _this << "oprot_);" << '\n' << '\n' << indent() << _this + << "oprot_->writeMessageEnd();" << '\n' << indent() << _this + << "oprot_->getTransport()->writeEnd();" << '\n' << indent() << _this + << "oprot_->getTransport()->flush();" << '\n'; if (style == "Concurrent") { - out << endl << indent() << "sentry.commit();" << endl; + out << '\n' << indent() << "sentry.commit();" << '\n'; if (!(*f_iter)->is_oneway()) { - out << indent() << "return cseqid;" << endl; + out << indent() << "return cseqid;" << '\n'; } } scope_down(out); - out << endl; + out << '\n'; // Generate recv function only if not an oneway function if (!(*f_iter)->is_oneway()) { @@ -2902,124 +2900,123 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) if (gen_templates_) { indent(out) << template_header; } - indent(out) << function_signature(&recv_function, "", scope) << endl; + indent(out) << function_signature(&recv_function, "", scope) << '\n'; scope_up(out); - out << endl << - indent() << "int32_t rseqid = 0;" << endl << - indent() << "std::string fname;" << endl << - indent() << "::apache::thrift::protocol::TMessageType mtype;" << endl; + out << '\n' << + indent() << "int32_t rseqid = 0;" << '\n' << + indent() << "std::string fname;" << '\n' << + indent() << "::apache::thrift::protocol::TMessageType mtype;" << '\n'; if(style == "Concurrent") { - out << - endl << - indent() << "// the read mutex gets dropped and reacquired as part of waitForWork()" << endl << - indent() << "// The destructor of this sentry wakes up other clients" << endl << - indent() << "::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid);" << endl; + out << '\n' << + indent() << "// the read mutex gets dropped and reacquired as part of waitForWork()" << '\n' << + indent() << "// The destructor of this sentry wakes up other clients" << '\n' << + indent() << "::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid);" << '\n'; } if (style == "Cob" && !gen_no_client_completion_) { - out << indent() << "bool completed = false;" << endl << endl << indent() << "try {"; + out << indent() << "bool completed = false;" << '\n' << '\n' << indent() << "try {"; indent_up(); } - out << endl; + out << '\n'; if (style == "Concurrent") { out << - indent() << "while(true) {" << endl << - indent() << " if(!this->sync_->getPending(fname, mtype, rseqid)) {" << endl; + indent() << "while(true) {" << '\n' << + indent() << " if(!this->sync_->getPending(fname, mtype, rseqid)) {" << '\n'; indent_up(); indent_up(); } out << - indent() << _this << "iprot_->readMessageBegin(fname, mtype, rseqid);" << endl; + indent() << _this << "iprot_->readMessageBegin(fname, mtype, rseqid);" << '\n'; if (style == "Concurrent") { scope_down(out); - out << indent() << "if(seqid == rseqid) {" << endl; + out << indent() << "if(seqid == rseqid) {" << '\n'; indent_up(); } out << - indent() << "if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {" << endl << - indent() << " ::apache::thrift::TApplicationException x;" << endl << - indent() << " x.read(" << _this << "iprot_);" << endl << - indent() << " " << _this << "iprot_->readMessageEnd();" << endl << - indent() << " " << _this << "iprot_->getTransport()->readEnd();" << endl; + indent() << "if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {" << '\n' << + indent() << " ::apache::thrift::TApplicationException x;" << '\n' << + indent() << " x.read(" << _this << "iprot_);" << '\n' << + indent() << " " << _this << "iprot_->readMessageEnd();" << '\n' << + indent() << " " << _this << "iprot_->getTransport()->readEnd();" << '\n'; if (style == "Cob" && !gen_no_client_completion_) { - out << indent() << " completed = true;" << endl << indent() << " completed__(true);" - << endl; + out << indent() << " completed = true;" << '\n' << indent() << " completed__(true);" + << '\n'; } if (style == "Concurrent") { - out << indent() << " sentry.commit();" << endl; + out << indent() << " sentry.commit();" << '\n'; } out << - indent() << " throw x;" << endl << - indent() << "}" << endl << - indent() << "if (mtype != ::apache::thrift::protocol::T_REPLY) {" << endl << - indent() << " " << _this << "iprot_->skip(" << "::apache::thrift::protocol::T_STRUCT);" << endl << - indent() << " " << _this << "iprot_->readMessageEnd();" << endl << - indent() << " " << _this << "iprot_->getTransport()->readEnd();" << endl; + indent() << " throw x;" << '\n' << + indent() << "}" << '\n' << + indent() << "if (mtype != ::apache::thrift::protocol::T_REPLY) {" << '\n' << + indent() << " " << _this << "iprot_->skip(" << "::apache::thrift::protocol::T_STRUCT);" << '\n' << + indent() << " " << _this << "iprot_->readMessageEnd();" << '\n' << + indent() << " " << _this << "iprot_->getTransport()->readEnd();" << '\n'; if (style == "Cob" && !gen_no_client_completion_) { - out << indent() << " completed = true;" << endl << indent() << " completed__(false);" - << endl; + out << indent() << " completed = true;" << '\n' << indent() << " completed__(false);" + << '\n'; } out << - indent() << "}" << endl << - indent() << "if (fname.compare(\"" << (*f_iter)->get_name() << "\") != 0) {" << endl << - indent() << " " << _this << "iprot_->skip(" << "::apache::thrift::protocol::T_STRUCT);" << endl << - indent() << " " << _this << "iprot_->readMessageEnd();" << endl << - indent() << " " << _this << "iprot_->getTransport()->readEnd();" << endl; + indent() << "}" << '\n' << + indent() << "if (fname.compare(\"" << (*f_iter)->get_name() << "\") != 0) {" << '\n' << + indent() << " " << _this << "iprot_->skip(" << "::apache::thrift::protocol::T_STRUCT);" << '\n' << + indent() << " " << _this << "iprot_->readMessageEnd();" << '\n' << + indent() << " " << _this << "iprot_->getTransport()->readEnd();" << '\n'; if (style == "Cob" && !gen_no_client_completion_) { - out << indent() << " completed = true;" << endl << indent() << " completed__(false);" - << endl; + out << indent() << " completed = true;" << '\n' << indent() << " completed__(false);" + << '\n'; } if (style == "Concurrent") { - out << endl << - indent() << " // in a bad state, don't commit" << endl << - indent() << " using ::apache::thrift::protocol::TProtocolException;" << endl << - indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << endl; + out << '\n' << + indent() << " // in a bad state, don't commit" << '\n' << + indent() << " using ::apache::thrift::protocol::TProtocolException;" << '\n' << + indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << '\n'; } - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; if (!(*f_iter)->get_returntype()->is_void() && !is_complex_type((*f_iter)->get_returntype())) { t_field returnfield((*f_iter)->get_returntype(), "_return"); - out << indent() << declare_field(&returnfield) << endl; + out << indent() << declare_field(&returnfield) << '\n'; } - out << indent() << resultname << " result;" << endl; + out << indent() << resultname << " result;" << '\n'; if (!(*f_iter)->get_returntype()->is_void()) { - out << indent() << "result.success = &_return;" << endl; + out << indent() << "result.success = &_return;" << '\n'; } - out << indent() << "result.read(" << _this << "iprot_);" << endl << indent() << _this - << "iprot_->readMessageEnd();" << endl << indent() << _this - << "iprot_->getTransport()->readEnd();" << endl << endl; + out << indent() << "result.read(" << _this << "iprot_);" << '\n' << indent() << _this + << "iprot_->readMessageEnd();" << '\n' << indent() << _this + << "iprot_->getTransport()->readEnd();" << '\n' << '\n'; // Careful, only look for _result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { if (is_complex_type((*f_iter)->get_returntype())) { out << - indent() << "if (result.__isset.success) {" << endl; + indent() << "if (result.__isset.success) {" << '\n'; out << - indent() << " // _return pointer has now been filled" << endl; + indent() << " // _return pointer has now been filled" << '\n'; if (style == "Cob" && !gen_no_client_completion_) { - out << indent() << " completed = true;" << endl << indent() << " completed__(true);" - << endl; + out << indent() << " completed = true;" << '\n' << indent() << " completed__(true);" + << '\n'; } if (style == "Concurrent") { - out << indent() << " sentry.commit();" << endl; + out << indent() << " sentry.commit();" << '\n'; } out << - indent() << " return;" << endl << - indent() << "}" << endl; + indent() << " return;" << '\n' << + indent() << "}" << '\n'; } else { - out << indent() << "if (result.__isset.success) {" << endl; + out << indent() << "if (result.__isset.success) {" << '\n'; if (style == "Cob" && !gen_no_client_completion_) { - out << indent() << " completed = true;" << endl << indent() << " completed__(true);" - << endl; + out << indent() << " completed = true;" << '\n' << indent() << " completed__(true);" + << '\n'; } if (style == "Concurrent") { - out << indent() << " sentry.commit();" << endl; + out << indent() << " sentry.commit();" << '\n'; } - out << indent() << " return _return;" << endl << indent() << "}" << endl; + out << indent() << " return _return;" << '\n' << indent() << "}" << '\n'; } } @@ -3027,62 +3024,62 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) const std::vector& xceptions = xs->get_members(); vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { - out << indent() << "if (result.__isset." << (*x_iter)->get_name() << ") {" << endl; + out << indent() << "if (result.__isset." << (*x_iter)->get_name() << ") {" << '\n'; if (style == "Cob" && !gen_no_client_completion_) { - out << indent() << " completed = true;" << endl << indent() << " completed__(true);" - << endl; + out << indent() << " completed = true;" << '\n' << indent() << " completed__(true);" + << '\n'; } if (style == "Concurrent") { - out << indent() << " sentry.commit();" << endl; + out << indent() << " sentry.commit();" << '\n'; } - out << indent() << " throw result." << (*x_iter)->get_name() << ";" << endl << indent() - << "}" << endl; + out << indent() << " throw result." << (*x_iter)->get_name() << ";" << '\n' << indent() + << "}" << '\n'; } // We only get here if we are a void function if ((*f_iter)->get_returntype()->is_void()) { if (style == "Cob" && !gen_no_client_completion_) { - out << indent() << "completed = true;" << endl << indent() << "completed__(true);" - << endl; + out << indent() << "completed = true;" << '\n' << indent() << "completed__(true);" + << '\n'; } if (style == "Concurrent") { - out << indent() << "sentry.commit();" << endl; + out << indent() << "sentry.commit();" << '\n'; } - indent(out) << "return;" << endl; + indent(out) << "return;" << '\n'; } else { if (style == "Cob" && !gen_no_client_completion_) { - out << indent() << "completed = true;" << endl << indent() << "completed__(true);" - << endl; + out << indent() << "completed = true;" << '\n' << indent() << "completed__(true);" + << '\n'; } if (style == "Concurrent") { - out << indent() << "// in a bad state, don't commit" << endl; + out << indent() << "// in a bad state, don't commit" << '\n'; } out << indent() << "throw " "::apache::thrift::TApplicationException(::apache::thrift::" "TApplicationException::MISSING_RESULT, \"" << (*f_iter)->get_name() - << " failed: unknown result\");" << endl; + << " failed: unknown result\");" << '\n'; } if (style == "Concurrent") { indent_down(); indent_down(); - out << - indent() << " }" << endl << - indent() << " // seqid != rseqid" << endl << - indent() << " this->sync_->updatePending(fname, mtype, rseqid);" << endl << - endl << - indent() << " // this will temporarily unlock the readMutex, and let other clients get work done" << endl << - indent() << " this->sync_->waitForWork(seqid);" << endl << - indent() << "} // end while(true)" << endl; + out << indent() << " }" << '\n' + << indent() << " // seqid != rseqid" << '\n' + << indent() << " this->sync_->updatePending(fname, mtype, rseqid);" << '\n' + << '\n' + << indent() + << " // this will temporarily unlock the readMutex, and let other clients get work done" << '\n' + << indent() << " this->sync_->waitForWork(seqid);" << '\n' + << indent() << "} // end while(true)" << '\n'; } if (style == "Cob" && !gen_no_client_completion_) { indent_down(); - out << indent() << "} catch (...) {" << endl << indent() << " if (!completed) {" << endl - << indent() << " completed__(false);" << endl << indent() << " }" << endl - << indent() << " throw;" << endl << indent() << "}" << endl; + out << indent() << "} catch (...) {" << '\n' << indent() << " if (!completed) {" << '\n' + << indent() << " completed__(false);" << '\n' << indent() << " }" << '\n' + << indent() << " throw;" << '\n' << indent() << "}" << '\n'; } // Close function scope_down(out); - out << endl; + out << '\n'; } } } @@ -3218,61 +3215,61 @@ void ProcessorGenerator::generate_class_definition() { // Generate the header portion f_header_ << template_header_ << "class " << class_name_ << " : public " << parent_class << " {" - << endl; + << '\n'; // Protected data members - f_header_ << " protected:" << endl; + f_header_ << " protected:" << '\n'; indent_up(); - f_header_ << indent() << "::std::shared_ptr<" << if_name_ << "> iface_;" << endl; + f_header_ << indent() << "::std::shared_ptr<" << if_name_ << "> iface_;" << '\n'; f_header_ << indent() << "virtual " << ret_type_ << "dispatchCall(" << finish_cob_ << "::apache::thrift::protocol::TProtocol* iprot, " << "::apache::thrift::protocol::TProtocol* oprot, " << "const std::string& fname, int32_t seqid" << call_context_ - << ") override;" << endl; + << ") override;" << '\n'; if (generator_->gen_templates_) { f_header_ << indent() << "virtual " << ret_type_ << "dispatchCallTemplated(" << finish_cob_ << "Protocol_* iprot, Protocol_* oprot, " - << "const std::string& fname, int32_t seqid" << call_context_ << ");" << endl; + << "const std::string& fname, int32_t seqid" << call_context_ << ");" << '\n'; } indent_down(); // Process function declarations - f_header_ << " private:" << endl; + f_header_ << " private:" << '\n'; indent_up(); // Declare processMap_ f_header_ << indent() << "typedef void (" << class_name_ << "::*" << "ProcessFunction)(" << finish_cob_decl_ << "int32_t, " << "::apache::thrift::protocol::TProtocol*, " - << "::apache::thrift::protocol::TProtocol*" << call_context_decl_ << ");" << endl; + << "::apache::thrift::protocol::TProtocol*" << call_context_decl_ << ");" << '\n'; if (generator_->gen_templates_) { f_header_ << indent() << "typedef void (" << class_name_ << "::*" << "SpecializedProcessFunction)(" << finish_cob_decl_ << "int32_t, " - << "Protocol_*, Protocol_*" << call_context_decl_ << ");" << endl << indent() - << "struct ProcessFunctions {" << endl << indent() << " ProcessFunction generic;" - << endl << indent() << " SpecializedProcessFunction specialized;" << endl << indent() + << "Protocol_*, Protocol_*" << call_context_decl_ << ");" << '\n' << indent() + << "struct ProcessFunctions {" << '\n' << indent() << " ProcessFunction generic;" + << '\n' << indent() << " SpecializedProcessFunction specialized;" << '\n' << indent() << " ProcessFunctions(ProcessFunction g, " - << "SpecializedProcessFunction s) :" << endl << indent() << " generic(g)," << endl - << indent() << " specialized(s) {}" << endl << indent() + << "SpecializedProcessFunction s) :" << '\n' << indent() << " generic(g)," << '\n' + << indent() << " specialized(s) {}" << '\n' << indent() << " ProcessFunctions() : generic(nullptr), specialized(nullptr) " - << "{}" << endl << indent() << "};" << endl << indent() + << "{}" << '\n' << indent() << "};" << '\n' << indent() << "typedef std::map " - << "ProcessMap;" << endl; + << "ProcessMap;" << '\n'; } else { f_header_ << indent() << "typedef std::map " - << "ProcessMap;" << endl; + << "ProcessMap;" << '\n'; } - f_header_ << indent() << "ProcessMap processMap_;" << endl; + f_header_ << indent() << "ProcessMap processMap_;" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { indent(f_header_) << "void process_" << (*f_iter)->get_name() << "(" << finish_cob_ << "int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, " "::apache::thrift::protocol::TProtocol* oprot" << call_context_ << ");" - << endl; + << '\n'; if (generator_->gen_templates_) { indent(f_header_) << "void process_" << (*f_iter)->get_name() << "(" << finish_cob_ << "int32_t seqid, Protocol_* iprot, Protocol_* oprot" << call_context_ - << ");" << endl; + << ");" << '\n'; } if (style_ == "Cob") { // XXX Factor this out, even if it is a pain. @@ -3282,56 +3279,56 @@ void ProcessorGenerator::generate_class_definition() { f_header_ << indent() << "void return_" << (*f_iter)->get_name() << "(::std::function cob, int32_t seqid, " << "::apache::thrift::protocol::TProtocol* oprot, " - << "void* ctx" << ret_arg << ");" << endl; + << "void* ctx" << ret_arg << ");" << '\n'; if (generator_->gen_templates_) { f_header_ << indent() << "void return_" << (*f_iter)->get_name() << "(::std::function cob, int32_t seqid, " - << "Protocol_* oprot, void* ctx" << ret_arg << ");" << endl; + << "Protocol_* oprot, void* ctx" << ret_arg << ");" << '\n'; } // XXX Don't declare throw if it doesn't exist f_header_ << indent() << "void throw_" << (*f_iter)->get_name() << "(::std::function cob, int32_t seqid, " << "::apache::thrift::protocol::TProtocol* oprot, void* ctx, " - << "::apache::thrift::TDelayedException* _throw);" << endl; + << "::apache::thrift::TDelayedException* _throw);" << '\n'; if (generator_->gen_templates_) { f_header_ << indent() << "void throw_" << (*f_iter)->get_name() << "(::std::function cob, int32_t seqid, " << "Protocol_* oprot, void* ctx, " - << "::apache::thrift::TDelayedException* _throw);" << endl; + << "::apache::thrift::TDelayedException* _throw);" << '\n'; } } } - f_header_ << " public:" << endl << indent() << class_name_ << "(::std::shared_ptr<" << if_name_ - << "> iface) :" << endl; + f_header_ << " public:" << '\n' << indent() << class_name_ << "(::std::shared_ptr<" << if_name_ + << "> iface) :" << '\n'; if (!extends_.empty()) { - f_header_ << indent() << " " << extends_ << "(iface)," << endl; + f_header_ << indent() << " " << extends_ << "(iface)," << '\n'; } - f_header_ << indent() << " iface_(iface) {" << endl; + f_header_ << indent() << " iface_(iface) {" << '\n'; indent_up(); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { f_header_ << indent() << "processMap_[\"" << (*f_iter)->get_name() << "\"] = "; if (generator_->gen_templates_) { - f_header_ << "ProcessFunctions(" << endl; + f_header_ << "ProcessFunctions(" << '\n'; if (generator_->gen_templates_only_) { - indent(f_header_) << " nullptr," << endl; + indent(f_header_) << " nullptr," << '\n'; } else { indent(f_header_) << " &" << class_name_ << "::process_" << (*f_iter)->get_name() << "," - << endl; + << '\n'; } indent(f_header_) << " &" << class_name_ << "::process_" << (*f_iter)->get_name() << ")"; } else { f_header_ << "&" << class_name_ << "::process_" << (*f_iter)->get_name(); } - f_header_ << ";" << endl; + f_header_ << ";" << '\n'; } indent_down(); - f_header_ << indent() << "}" << endl << endl << indent() << "virtual ~" << class_name_ << "() {}" - << endl; + f_header_ << indent() << "}" << '\n' << '\n' << indent() << "virtual ~" << class_name_ << "() {}" + << '\n'; indent_down(); - f_header_ << "};" << endl << endl; + f_header_ << "};" << '\n' << '\n'; if (generator_->gen_templates_) { // Generate a backwards compatible typedef, for callers who don't know @@ -3344,7 +3341,7 @@ void ProcessorGenerator::generate_class_definition() { // Therefore, we define TDummyProtocol solely so we can use it as the // template parameter here. f_header_ << "typedef " << class_name_ << "< ::apache::thrift::protocol::TDummyProtocol > " - << service_name_ << pstyle_ << "Processor;" << endl << endl; + << service_name_ << pstyle_ << "Processor;" << '\n' << '\n'; } } @@ -3366,32 +3363,32 @@ void ProcessorGenerator::generate_dispatch_call(bool template_protocol) { f_out_ << template_header_ << ret_type_ << class_name_ << template_suffix_ << "::dispatchCall" << function_suffix << "(" << finish_cob_ << protocol << "* iprot, " << protocol << "* oprot, " - << "const std::string& fname, int32_t seqid" << call_context_ << ") {" << endl; + << "const std::string& fname, int32_t seqid" << call_context_ << ") {" << '\n'; indent_up(); // HOT: member function pointer map - f_out_ << indent() << typename_str_ << "ProcessMap::iterator pfn;" << endl << indent() - << "pfn = processMap_.find(fname);" << endl << indent() - << "if (pfn == processMap_.end()) {" << endl; + f_out_ << indent() << typename_str_ << "ProcessMap::iterator pfn;" << '\n' << indent() + << "pfn = processMap_.find(fname);" << '\n' << indent() + << "if (pfn == processMap_.end()) {" << '\n'; if (extends_.empty()) { - f_out_ << indent() << " iprot->skip(::apache::thrift::protocol::T_STRUCT);" << endl << indent() - << " iprot->readMessageEnd();" << endl << indent() - << " iprot->getTransport()->readEnd();" << endl << indent() + f_out_ << indent() << " iprot->skip(::apache::thrift::protocol::T_STRUCT);" << '\n' << indent() + << " iprot->readMessageEnd();" << '\n' << indent() + << " iprot->getTransport()->readEnd();" << '\n' << indent() << " ::apache::thrift::TApplicationException " "x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, \"Invalid method name: " - "'\"+fname+\"'\");" << endl << indent() + "'\"+fname+\"'\");" << '\n' << indent() << " oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid);" - << endl << indent() << " x.write(oprot);" << endl << indent() - << " oprot->writeMessageEnd();" << endl << indent() - << " oprot->getTransport()->writeEnd();" << endl << indent() - << " oprot->getTransport()->flush();" << endl << indent() - << (style_ == "Cob" ? " return cob(true);" : " return true;") << endl; + << '\n' << indent() << " x.write(oprot);" << '\n' << indent() + << " oprot->writeMessageEnd();" << '\n' << indent() + << " oprot->getTransport()->writeEnd();" << '\n' << indent() + << " oprot->getTransport()->flush();" << '\n' << indent() + << (style_ == "Cob" ? " return cob(true);" : " return true;") << '\n'; } else { f_out_ << indent() << " return " << extends_ << "::dispatchCall(" << (style_ == "Cob" ? "cob, " : "") << "iprot, oprot, fname, seqid" << call_context_arg_ - << ");" << endl; + << ");" << '\n'; } - f_out_ << indent() << "}" << endl; + f_out_ << indent() << "}" << '\n'; if (template_protocol) { f_out_ << indent() << "(this->*(pfn->second.specialized))"; } else { @@ -3405,17 +3402,17 @@ void ProcessorGenerator::generate_dispatch_call(bool template_protocol) { f_out_ << indent() << "(this->*(pfn->second))"; } } - f_out_ << "(" << cob_arg_ << "seqid, iprot, oprot" << call_context_arg_ << ");" << endl; + f_out_ << "(" << cob_arg_ << "seqid, iprot, oprot" << call_context_arg_ << ");" << '\n'; // TODO(dreiss): return pfn ret? if (style_ == "Cob") { - f_out_ << indent() << "return;" << endl; + f_out_ << indent() << "return;" << '\n'; } else { - f_out_ << indent() << "return true;" << endl; + f_out_ << indent() << "return true;" << '\n'; } indent_down(); - f_out_ << "}" << endl << endl; + f_out_ << "}" << '\n' << '\n'; } void ProcessorGenerator::generate_process_functions() { @@ -3437,49 +3434,49 @@ void ProcessorGenerator::generate_factory() { // Generate the factory class definition f_header_ << template_header_ << "class " << factory_class_name_ << " : public ::apache::thrift::" << (style_ == "Cob" ? "async::TAsyncProcessorFactory" : "TProcessorFactory") << " {" - << endl << " public:" << endl; + << '\n' << " public:" << '\n'; indent_up(); f_header_ << indent() << factory_class_name_ << "(const ::std::shared_ptr< " << if_factory_name - << " >& handlerFactory) noexcept :" << endl << indent() - << " handlerFactory_(handlerFactory) {}" << endl << endl << indent() + << " >& handlerFactory) noexcept :" << '\n' << indent() + << " handlerFactory_(handlerFactory) {}" << '\n' << '\n' << indent() << "::std::shared_ptr< ::apache::thrift::" << (style_ == "Cob" ? "async::TAsyncProcessor" : "TProcessor") << " > " << "getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) override;" - << endl; + << '\n'; - f_header_ << endl << " protected:" << endl << indent() << "::std::shared_ptr< " - << if_factory_name << " > handlerFactory_;" << endl; + f_header_ << '\n' << " protected:" << '\n' << indent() << "::std::shared_ptr< " + << if_factory_name << " > handlerFactory_;" << '\n'; indent_down(); - f_header_ << "};" << endl << endl; + f_header_ << "};" << '\n' << '\n'; // If we are generating templates, output a typedef for the plain // factory name. if (generator_->gen_templates_) { f_header_ << "typedef " << factory_class_name_ << "< ::apache::thrift::protocol::TDummyProtocol > " << service_name_ << pstyle_ - << "ProcessorFactory;" << endl << endl; + << "ProcessorFactory;" << '\n' << '\n'; } // Generate the getProcessor() method f_out_ << template_header_ << indent() << "::std::shared_ptr< ::apache::thrift::" << (style_ == "Cob" ? "async::TAsyncProcessor" : "TProcessor") << " > " << factory_class_name_ << template_suffix_ << "::getProcessor(" - << "const ::apache::thrift::TConnectionInfo& connInfo) {" << endl; + << "const ::apache::thrift::TConnectionInfo& connInfo) {" << '\n'; indent_up(); f_out_ << indent() << "::apache::thrift::ReleaseHandler< " << if_factory_name - << " > cleanup(handlerFactory_);" << endl << indent() << "::std::shared_ptr< " + << " > cleanup(handlerFactory_);" << '\n' << indent() << "::std::shared_ptr< " << if_name_ << " > handler(" - << "handlerFactory_->getHandler(connInfo), cleanup);" << endl << indent() + << "handlerFactory_->getHandler(connInfo), cleanup);" << '\n' << indent() << "::std::shared_ptr< ::apache::thrift::" << (style_ == "Cob" ? "async::TAsyncProcessor" : "TProcessor") << " > " - << "processor(new " << class_name_ << template_suffix_ << "(handler));" << endl << indent() - << "return processor;" << endl; + << "processor(new " << class_name_ << template_suffix_ << "(handler));" << '\n' << indent() + << "return processor;" << '\n'; indent_down(); - f_out_ << indent() << "}" << endl << endl; + f_out_ << indent() << "}" << '\n' << '\n'; } /** @@ -3561,45 +3558,45 @@ void t_cpp_generator::generate_process_function(t_service* tservice, if (style != "Cob") { // Open function if (gen_templates_) { - out << indent() << "template " << endl; + out << indent() << "template " << '\n'; } const bool unnamed_oprot_seqid = tfunction->is_oneway() && !(gen_templates_ && !specialized); out << "void " << tservice->get_name() << "Processor" << class_suffix << "::" << "process_" << tfunction->get_name() << "(" << "int32_t" << (unnamed_oprot_seqid ? ", " : " seqid, ") << prot_type << "* iprot, " << prot_type << "*" << (unnamed_oprot_seqid ? ", " : " oprot, ") << "void* callContext)" - << endl; + << '\n'; scope_up(out); string argsname = tservice->get_name() + "_" + tfunction->get_name() + "_args"; string resultname = tservice->get_name() + "_" + tfunction->get_name() + "_result"; if (tfunction->is_oneway() && !unnamed_oprot_seqid) { - out << indent() << "(void) seqid;" << endl << indent() << "(void) oprot;" << endl; + out << indent() << "(void) seqid;" << '\n' << indent() << "(void) oprot;" << '\n'; } - out << indent() << "void* ctx = nullptr;" << endl << indent() - << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() + out << indent() << "void* ctx = nullptr;" << '\n' << indent() + << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() << " ctx = this->eventHandler_->getContext(" << service_func_name << ", callContext);" - << endl << indent() << "}" << endl << indent() + << '\n' << indent() << "}" << '\n' << indent() << "::apache::thrift::TProcessorContextFreer freer(" - << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl - << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->preRead(ctx, " << service_func_name << ");" << endl << indent() - << "}" << endl << endl << indent() << argsname << " args;" << endl << indent() - << "args.read(iprot);" << endl << indent() << "iprot->readMessageEnd();" << endl << indent() - << "uint32_t bytes = iprot->getTransport()->readEnd();" << endl << endl << indent() - << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->postRead(ctx, " << service_func_name << ", bytes);" << endl - << indent() << "}" << endl << endl; + << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << '\n' << '\n' + << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->preRead(ctx, " << service_func_name << ");" << '\n' << indent() + << "}" << '\n' << '\n' << indent() << argsname << " args;" << '\n' << indent() + << "args.read(iprot);" << '\n' << indent() << "iprot->readMessageEnd();" << '\n' << indent() + << "uint32_t bytes = iprot->getTransport()->readEnd();" << '\n' << '\n' << indent() + << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->postRead(ctx, " << service_func_name << ", bytes);" << '\n' + << indent() << "}" << '\n' << '\n'; // Declare result if (!tfunction->is_oneway()) { - out << indent() << resultname << " result;" << endl; + out << indent() << resultname << " result;" << '\n'; } // Try block for functions with exceptions - out << indent() << "try {" << endl; + out << indent() << "try {" << '\n'; indent_up(); // Generate the function call @@ -3623,11 +3620,11 @@ void t_cpp_generator::generate_process_function(t_service* tservice, } out << "args." << (*f_iter)->get_name(); } - out << ");" << endl; + out << ");" << '\n'; // Set isset on success field if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) { - out << indent() << "result.__isset.success = true;" << endl; + out << indent() << "result.__isset.success = true;" << '\n'; } indent_down(); @@ -3636,12 +3633,12 @@ void t_cpp_generator::generate_process_function(t_service* tservice, if (!tfunction->is_oneway()) { for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { out << " catch (" << type_name((*x_iter)->get_type()) << " &" << (*x_iter)->get_name() - << ") {" << endl; + << ") {" << '\n'; if (!tfunction->is_oneway()) { indent_up(); out << indent() << "result." << (*x_iter)->get_name() - << " = std::move(" << (*x_iter)->get_name() << ");" << endl - << indent() << "result.__isset." << (*x_iter)->get_name() << " = true;" << endl; + << " = std::move(" << (*x_iter)->get_name() << ");" << '\n' + << indent() << "result.__isset." << (*x_iter)->get_name() << " = true;" << '\n'; indent_down(); out << indent() << "}"; } else { @@ -3651,53 +3648,53 @@ void t_cpp_generator::generate_process_function(t_service* tservice, } if (!tfunction->is_oneway()) { - out << " catch (const std::exception& e) {" << endl; + out << " catch (const std::exception& e) {" << '\n'; } else { - out << " catch (const std::exception&) {" << endl; + out << " catch (const std::exception&) {" << '\n'; } indent_up(); - out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << endl - << indent() << "}" << endl; + out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << '\n' + << indent() << "}" << '\n'; if (!tfunction->is_oneway()) { - out << endl << indent() << "::apache::thrift::TApplicationException x(e.what());" << endl + out << '\n' << indent() << "::apache::thrift::TApplicationException x(e.what());" << '\n' << indent() << "oprot->writeMessageBegin(\"" << tfunction->get_name() - << "\", ::apache::thrift::protocol::T_EXCEPTION, seqid);" << endl << indent() - << "x.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();" << endl - << indent() << "oprot->getTransport()->writeEnd();" << endl << indent() - << "oprot->getTransport()->flush();" << endl; + << "\", ::apache::thrift::protocol::T_EXCEPTION, seqid);" << '\n' << indent() + << "x.write(oprot);" << '\n' << indent() << "oprot->writeMessageEnd();" << '\n' + << indent() << "oprot->getTransport()->writeEnd();" << '\n' << indent() + << "oprot->getTransport()->flush();" << '\n'; } - out << indent() << "return;" << endl; + out << indent() << "return;" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; // Shortcut out here for oneway functions if (tfunction->is_oneway()) { - out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->asyncComplete(ctx, " << service_func_name << ");" << endl - << indent() << "}" << endl << endl << indent() << "return;" << endl; + out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->asyncComplete(ctx, " << service_func_name << ");" << '\n' + << indent() << "}" << '\n' << '\n' << indent() << "return;" << '\n'; indent_down(); - out << "}" << endl << endl; + out << "}" << '\n' << '\n'; return; } // Serialize the result into a struct - out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << endl << indent() - << "}" << endl << endl << indent() << "oprot->writeMessageBegin(\"" << tfunction->get_name() - << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << endl << indent() - << "result.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();" << endl - << indent() << "bytes = oprot->getTransport()->writeEnd();" << endl << indent() - << "oprot->getTransport()->flush();" << endl << endl << indent() - << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << endl - << indent() << "}" << endl; + out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << '\n' << indent() + << "}" << '\n' << '\n' << indent() << "oprot->writeMessageBegin(\"" << tfunction->get_name() + << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << '\n' << indent() + << "result.write(oprot);" << '\n' << indent() << "oprot->writeMessageEnd();" << '\n' + << indent() << "bytes = oprot->getTransport()->writeEnd();" << '\n' << indent() + << "oprot->getTransport()->flush();" << '\n' << '\n' << indent() + << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << '\n' + << indent() << "}" << '\n'; // Close function scope_down(out); - out << endl; + out << '\n'; } // Cob style. @@ -3705,11 +3702,11 @@ void t_cpp_generator::generate_process_function(t_service* tservice, // Processor entry point. // TODO(edhall) update for callContext when TEventServer is ready if (gen_templates_) { - out << indent() << "template " << endl; + out << indent() << "template " << '\n'; } out << "void " << tservice->get_name() << "AsyncProcessor" << class_suffix << "::process_" << tfunction->get_name() << "(::std::function cob, int32_t seqid, " - << prot_type << "* iprot, " << prot_type << "* oprot)" << endl; + << prot_type << "* iprot, " << prot_type << "* oprot)" << '\n'; scope_up(out); // TODO(simpkins): we could try to consoldate this @@ -3717,55 +3714,55 @@ void t_cpp_generator::generate_process_function(t_service* tservice, if (gen_templates_ && !specialized) { // If these are instances of Protocol_, instead of any old TProtocol, // use the specialized process function instead. - out << indent() << "Protocol_* _iprot = dynamic_cast(iprot);" << endl << indent() - << "Protocol_* _oprot = dynamic_cast(oprot);" << endl << indent() - << "if (_iprot && _oprot) {" << endl << indent() << " return process_" - << tfunction->get_name() << "(cob, seqid, _iprot, _oprot);" << endl << indent() << "}" - << endl << indent() << "T_GENERIC_PROTOCOL(this, iprot, _iprot);" << endl << indent() - << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" << endl << endl; + out << indent() << "Protocol_* _iprot = dynamic_cast(iprot);" << '\n' << indent() + << "Protocol_* _oprot = dynamic_cast(oprot);" << '\n' << indent() + << "if (_iprot && _oprot) {" << '\n' << indent() << " return process_" + << tfunction->get_name() << "(cob, seqid, _iprot, _oprot);" << '\n' << indent() << "}" + << '\n' << indent() << "T_GENERIC_PROTOCOL(this, iprot, _iprot);" << '\n' << indent() + << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" << '\n' << '\n'; } if (tfunction->is_oneway()) { - out << indent() << "(void) seqid;" << endl << indent() << "(void) oprot;" << endl; + out << indent() << "(void) seqid;" << '\n' << indent() << "(void) oprot;" << '\n'; } - out << indent() << tservice->get_name() + "_" + tfunction->get_name() << "_args args;" << endl - << indent() << "void* ctx = nullptr;" << endl << indent() - << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << endl - << indent() << "}" << endl << indent() << "::apache::thrift::TProcessorContextFreer freer(" - << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl - << indent() << "try {" << endl; + out << indent() << tservice->get_name() + "_" + tfunction->get_name() << "_args args;" << '\n' + << indent() << "void* ctx = nullptr;" << '\n' << indent() + << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << '\n' + << indent() << "}" << '\n' << indent() << "::apache::thrift::TProcessorContextFreer freer(" + << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << '\n' << '\n' + << indent() << "try {" << '\n'; indent_up(); - out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->preRead(ctx, " << service_func_name << ");" << endl << indent() - << "}" << endl << indent() << "args.read(iprot);" << endl << indent() - << "iprot->readMessageEnd();" << endl << indent() - << "uint32_t bytes = iprot->getTransport()->readEnd();" << endl << indent() - << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->postRead(ctx, " << service_func_name << ", bytes);" << endl - << indent() << "}" << endl; + out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->preRead(ctx, " << service_func_name << ");" << '\n' << indent() + << "}" << '\n' << indent() << "args.read(iprot);" << '\n' << indent() + << "iprot->readMessageEnd();" << '\n' << indent() + << "uint32_t bytes = iprot->getTransport()->readEnd();" << '\n' << indent() + << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->postRead(ctx, " << service_func_name << ", bytes);" << '\n' + << indent() << "}" << '\n'; scope_down(out); // TODO(dreiss): Handle TExceptions? Expose to server? - out << indent() << "catch (const std::exception&) {" << endl << indent() - << " if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << endl - << indent() << " }" << endl << indent() << " return cob(false);" << endl << indent() - << "}" << endl; + out << indent() << "catch (const std::exception&) {" << '\n' << indent() + << " if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << '\n' + << indent() << " }" << '\n' << indent() << " return cob(false);" << '\n' << indent() + << "}" << '\n'; if (tfunction->is_oneway()) { - out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->asyncComplete(ctx, " << service_func_name << ");" << endl - << indent() << "}" << endl; + out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->asyncComplete(ctx, " << service_func_name << ");" << '\n' + << indent() << "}" << '\n'; } // TODO(dreiss): Figure out a strategy for exceptions in async handlers. - out << indent() << "freer.unregister();" << endl; + out << indent() << "freer.unregister();" << '\n'; if (tfunction->is_oneway()) { // No return. Just hand off our cob. // TODO(dreiss): Call the cob immediately? out << indent() << "iface_->" << tfunction->get_name() << "(" - << "::std::bind(cob, true)" << endl; + << "::std::bind(cob, true)" << '\n'; indent_up(); indent_up(); } else { @@ -3781,38 +3778,38 @@ void t_cpp_generator::generate_process_function(t_service* tservice, out << indent() << "void (" << tservice->get_name() << "AsyncProcessor" << class_suffix << "::*return_fn)(::std::function " << "cob, int32_t seqid, " << prot_type << "* oprot, void* ctx" << ret_arg - << ") =" << endl; + << ") =" << '\n'; out << indent() << " &" << tservice->get_name() << "AsyncProcessor" << class_suffix - << "::return_" << tfunction->get_name() << ";" << endl; + << "::return_" << tfunction->get_name() << ";" << '\n'; if (!xceptions.empty()) { out << indent() << "void (" << tservice->get_name() << "AsyncProcessor" << class_suffix << "::*throw_fn)(::std::function " << "cob, int32_t seqid, " << prot_type << "* oprot, void* ctx, " - << "::apache::thrift::TDelayedException* _throw) =" << endl; + << "::apache::thrift::TDelayedException* _throw) =" << '\n'; out << indent() << " &" << tservice->get_name() << "AsyncProcessor" << class_suffix - << "::throw_" << tfunction->get_name() << ";" << endl; + << "::throw_" << tfunction->get_name() << ";" << '\n'; } - out << indent() << "iface_->" << tfunction->get_name() << "(" << endl; + out << indent() << "iface_->" << tfunction->get_name() << "(" << '\n'; indent_up(); indent_up(); out << indent() << "::std::bind(return_fn, this, cob, seqid, oprot, ctx" << ret_placeholder << ")"; if (!xceptions.empty()) { - out << ',' << endl << indent() << "::std::bind(throw_fn, this, cob, seqid, oprot, " + out << ',' << '\n' << indent() << "::std::bind(throw_fn, this, cob, seqid, oprot, " << "ctx, ::std::placeholders::_1)"; } } // XXX Whitespace cleanup. for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - out << ',' << endl << indent() << "args." << (*f_iter)->get_name(); + out << ',' << '\n' << indent() << "args." << (*f_iter)->get_name(); } - out << ");" << endl; + out << ");" << '\n'; indent_down(); indent_down(); scope_down(out); - out << endl; + out << '\n'; // Normal return. if (!tfunction->is_oneway()) { @@ -3822,128 +3819,128 @@ void t_cpp_generator::generate_process_function(t_service* tservice, ret_arg_name = ", _return"; } if (gen_templates_) { - out << indent() << "template " << endl; + out << indent() << "template " << '\n'; } out << "void " << tservice->get_name() << "AsyncProcessor" << class_suffix << "::return_" << tfunction->get_name() << "(::std::function cob, int32_t seqid, " - << prot_type << "* oprot, void* ctx" << ret_arg_decl << ')' << endl; + << prot_type << "* oprot, void* ctx" << ret_arg_decl << ')' << '\n'; scope_up(out); if (gen_templates_ && !specialized) { // If oprot is a Protocol_ instance, // use the specialized return function instead. - out << indent() << "Protocol_* _oprot = dynamic_cast(oprot);" << endl - << indent() << "if (_oprot) {" << endl << indent() << " return return_" - << tfunction->get_name() << "(cob, seqid, _oprot, ctx" << ret_arg_name << ");" << endl - << indent() << "}" << endl << indent() << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" - << endl << endl; + out << indent() << "Protocol_* _oprot = dynamic_cast(oprot);" << '\n' + << indent() << "if (_oprot) {" << '\n' << indent() << " return return_" + << tfunction->get_name() << "(cob, seqid, _oprot, ctx" << ret_arg_name << ");" << '\n' + << indent() << "}" << '\n' << indent() << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" + << '\n' << '\n'; } out << indent() << tservice->get_name() << "_" << tfunction->get_name() << "_presult result;" - << endl; + << '\n'; if (!tfunction->get_returntype()->is_void()) { // The const_cast here is unfortunate, but it would be a pain to avoid, // and we only do a write with this struct, which is const-safe. out << indent() << "result.success = const_cast<" << type_name(tfunction->get_returntype()) - << "*>(&_return);" << endl << indent() << "result.__isset.success = true;" << endl; + << "*>(&_return);" << '\n' << indent() << "result.__isset.success = true;" << '\n'; } // Serialize the result into a struct - out << endl << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << endl - << indent() << "}" << endl << indent() + out << '\n' << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << '\n' + << indent() << "}" << '\n' << indent() << "::apache::thrift::TProcessorContextFreer freer(" - << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl - << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << endl - << indent() << "}" << endl << endl << indent() << "oprot->writeMessageBegin(\"" - << tfunction->get_name() << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << endl - << indent() << "result.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();" - << endl << indent() << "uint32_t bytes = oprot->getTransport()->writeEnd();" << endl - << indent() << "oprot->getTransport()->flush();" << endl << indent() - << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << endl - << indent() << "}" << endl << indent() << "return cob(true);" << endl; + << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << '\n' << '\n' + << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << '\n' + << indent() << "}" << '\n' << '\n' << indent() << "oprot->writeMessageBegin(\"" + << tfunction->get_name() << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << '\n' + << indent() << "result.write(oprot);" << '\n' << indent() << "oprot->writeMessageEnd();" + << '\n' << indent() << "uint32_t bytes = oprot->getTransport()->writeEnd();" << '\n' + << indent() << "oprot->getTransport()->flush();" << '\n' << indent() + << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << '\n' + << indent() << "}" << '\n' << indent() << "return cob(true);" << '\n'; scope_down(out); - out << endl; + out << '\n'; } // Exception return. if (!tfunction->is_oneway() && !xceptions.empty()) { if (gen_templates_) { - out << indent() << "template " << endl; + out << indent() << "template " << '\n'; } out << "void " << tservice->get_name() << "AsyncProcessor" << class_suffix << "::throw_" << tfunction->get_name() << "(::std::function cob, int32_t seqid, " << prot_type << "* oprot, void* ctx, " - << "::apache::thrift::TDelayedException* _throw)" << endl; + << "::apache::thrift::TDelayedException* _throw)" << '\n'; scope_up(out); if (gen_templates_ && !specialized) { // If oprot is a Protocol_ instance, // use the specialized throw function instead. - out << indent() << "Protocol_* _oprot = dynamic_cast(oprot);" << endl - << indent() << "if (_oprot) {" << endl << indent() << " return throw_" - << tfunction->get_name() << "(cob, seqid, _oprot, ctx, _throw);" << endl << indent() - << "}" << endl << indent() << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" << endl - << endl; + out << indent() << "Protocol_* _oprot = dynamic_cast(oprot);" << '\n' + << indent() << "if (_oprot) {" << '\n' << indent() << " return throw_" + << tfunction->get_name() << "(cob, seqid, _oprot, ctx, _throw);" << '\n' << indent() + << "}" << '\n' << indent() << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" << '\n' + << '\n'; } // Get the event handler context - out << endl << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << endl - << indent() << "}" << endl << indent() + out << '\n' << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << '\n' + << indent() << "}" << '\n' << indent() << "::apache::thrift::TProcessorContextFreer freer(" - << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl; + << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << '\n' << '\n'; // Throw the TDelayedException, and catch the result out << indent() << tservice->get_name() << "_" << tfunction->get_name() << "_result result;" - << endl << endl << indent() << "try {" << endl; + << '\n' << '\n' << indent() << "try {" << '\n'; indent_up(); - out << indent() << "_throw->throw_it();" << endl << indent() << "return cob(false);" - << endl; // Is this possible? TBD. + out << indent() << "_throw->throw_it();" << '\n' << indent() << "return cob(false);" + << '\n'; // Is this possible? TBD. indent_down(); out << indent() << '}'; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { out << " catch (" << type_name((*x_iter)->get_type()) << " &" << (*x_iter)->get_name() - << ") {" << endl; + << ") {" << '\n'; indent_up(); out << indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() - << ";" << endl << indent() << "result.__isset." << (*x_iter)->get_name() << " = true;" - << endl; + << ";" << '\n' << indent() << "result.__isset." << (*x_iter)->get_name() << " = true;" + << '\n'; scope_down(out); } // Handle the case where an undeclared exception is thrown - out << " catch (std::exception& e) {" << endl; + out << " catch (std::exception& e) {" << '\n'; indent_up(); - out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << endl - << indent() << "}" << endl << endl << indent() - << "::apache::thrift::TApplicationException x(e.what());" << endl << indent() + out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << '\n' + << indent() << "}" << '\n' << '\n' << indent() + << "::apache::thrift::TApplicationException x(e.what());" << '\n' << indent() << "oprot->writeMessageBegin(\"" << tfunction->get_name() - << "\", ::apache::thrift::protocol::T_EXCEPTION, seqid);" << endl << indent() - << "x.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();" << endl - << indent() << "oprot->getTransport()->writeEnd();" << endl << indent() - << "oprot->getTransport()->flush();" << endl << + << "\", ::apache::thrift::protocol::T_EXCEPTION, seqid);" << '\n' << indent() + << "x.write(oprot);" << '\n' << indent() << "oprot->writeMessageEnd();" << '\n' + << indent() << "oprot->getTransport()->writeEnd();" << '\n' << indent() + << "oprot->getTransport()->flush();" << '\n' << // We pass true to the cob here, since we did successfully write a // response, even though it is an exception response. // It looks like the argument is currently ignored, anyway. - indent() << "return cob(true);" << endl; + indent() << "return cob(true);" << '\n'; scope_down(out); // Serialize the result into a struct - out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << endl - << indent() << "}" << endl << endl << indent() << "oprot->writeMessageBegin(\"" - << tfunction->get_name() << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << endl - << indent() << "result.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();" - << endl << indent() << "uint32_t bytes = oprot->getTransport()->writeEnd();" << endl - << indent() << "oprot->getTransport()->flush();" << endl << indent() - << "if (this->eventHandler_.get() != nullptr) {" << endl << indent() - << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << endl - << indent() << "}" << endl << indent() << "return cob(true);" << endl; + out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << '\n' + << indent() << "}" << '\n' << '\n' << indent() << "oprot->writeMessageBegin(\"" + << tfunction->get_name() << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << '\n' + << indent() << "result.write(oprot);" << '\n' << indent() << "oprot->writeMessageEnd();" + << '\n' << indent() << "uint32_t bytes = oprot->getTransport()->writeEnd();" << '\n' + << indent() << "oprot->getTransport()->flush();" << '\n' << indent() + << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent() + << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << '\n' + << indent() << "}" << '\n' << indent() << "return cob(true);" << '\n'; scope_down(out); - out << endl; + out << '\n'; } // for each function } // cob style } @@ -3963,58 +3960,58 @@ void t_cpp_generator::generate_service_skeleton(t_service* tservice) { ofstream_with_content_based_conditional_update f_skeleton; f_skeleton.open(f_skeleton_name.c_str()); - f_skeleton << "// This autogenerated skeleton file illustrates how to build a server." << endl - << "// You should copy it to another filename to avoid overwriting it." << endl << endl - << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl << endl - << "using namespace ::apache::thrift;" << endl - << "using namespace ::apache::thrift::protocol;" << endl - << "using namespace ::apache::thrift::transport;" << endl - << "using namespace ::apache::thrift::server;" << endl << endl; + f_skeleton << "// This autogenerated skeleton file illustrates how to build a server." << '\n' + << "// You should copy it to another filename to avoid overwriting it." << '\n' << '\n' + << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << '\n' + << "#include " << '\n' + << "#include " << '\n' + << "#include " << '\n' + << "#include " << '\n' << '\n' + << "using namespace ::apache::thrift;" << '\n' + << "using namespace ::apache::thrift::protocol;" << '\n' + << "using namespace ::apache::thrift::transport;" << '\n' + << "using namespace ::apache::thrift::server;" << '\n' << '\n'; // the following code would not compile: // using namespace ; // using namespace ::; if ((!ns.empty()) && (ns.compare(" ::") != 0)) { - f_skeleton << "using namespace " << string(ns, 0, ns.size() - 2) << ";" << endl << endl; + f_skeleton << "using namespace " << string(ns, 0, ns.size() - 2) << ";" << '\n' << '\n'; } - f_skeleton << "class " << svcname << "Handler : virtual public " << svcname << "If {" << endl - << " public:" << endl; + f_skeleton << "class " << svcname << "Handler : virtual public " << svcname << "If {" << '\n' + << " public:" << '\n'; indent_up(); - f_skeleton << indent() << svcname << "Handler() {" << endl << indent() - << " // Your initialization goes here" << endl << indent() << "}" << endl << endl; + f_skeleton << indent() << svcname << "Handler() {" << '\n' << indent() + << " // Your initialization goes here" << '\n' << indent() << "}" << '\n' << '\n'; vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_java_doc(f_skeleton, *f_iter); - f_skeleton << indent() << function_signature(*f_iter, "") << " {" << endl << indent() - << " // Your implementation goes here" << endl << indent() << " printf(\"" - << (*f_iter)->get_name() << "\\n\");" << endl << indent() << "}" << endl << endl; + f_skeleton << indent() << function_signature(*f_iter, "") << " {" << '\n' << indent() + << " // Your implementation goes here" << '\n' << indent() << " printf(\"" + << (*f_iter)->get_name() << "\\n\");" << '\n' << indent() << "}" << '\n' << '\n'; } indent_down(); - f_skeleton << "};" << endl << endl; + f_skeleton << "};" << '\n' << '\n'; - f_skeleton << indent() << "int main(int argc, char **argv) {" << endl; + f_skeleton << indent() << "int main(int argc, char **argv) {" << '\n'; indent_up(); f_skeleton - << indent() << "int port = 9090;" << endl << indent() << "::std::shared_ptr<" << svcname - << "Handler> handler(new " << svcname << "Handler());" << endl << indent() - << "::std::shared_ptr processor(new " << svcname << "Processor(handler));" << endl + << indent() << "int port = 9090;" << '\n' << indent() << "::std::shared_ptr<" << svcname + << "Handler> handler(new " << svcname << "Handler());" << '\n' << indent() + << "::std::shared_ptr processor(new " << svcname << "Processor(handler));" << '\n' << indent() << "::std::shared_ptr serverTransport(new TServerSocket(port));" - << endl << indent() - << "::std::shared_ptr transportFactory(new TBufferedTransportFactory());" << endl + << '\n' << indent() + << "::std::shared_ptr transportFactory(new TBufferedTransportFactory());" << '\n' << indent() << "::std::shared_ptr protocolFactory(new TBinaryProtocolFactory());" - << endl << endl << indent() + << '\n' << '\n' << indent() << "TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);" - << endl << indent() << "server.serve();" << endl << indent() << "return 0;" << endl; + << '\n' << indent() << "server.serve();" << '\n' << indent() << "return 0;" << '\n'; indent_down(); - f_skeleton << "}" << endl << endl; + f_skeleton << "}" << '\n' << '\n'; // Close the files f_skeleton.close(); @@ -4077,12 +4074,12 @@ void t_cpp_generator::generate_deserialize_field(ostream& out, default: throw "compiler error: no C++ reader for base type " + t_base_type::t_base_name(tbase) + " " + name; } - out << endl; + out << '\n'; } else if (type->is_enum()) { string t = tmp("ecast"); - out << indent() << "int32_t " << t << ";" << endl << indent() << "xfer += iprot->readI32(" << t - << ");" << endl << indent() << name << " = static_cast<" - << type_name(type) << ">(" << t << ");" << endl; + out << indent() << "int32_t " << t << ";" << '\n' << indent() << "xfer += iprot->readI32(" << t + << ");" << '\n' << indent() << name << " = static_cast<" + << type_name(type) << ">(" << t << ");" << '\n'; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", tfield->get_name().c_str(), @@ -4101,22 +4098,22 @@ void t_cpp_generator::generate_deserialize_struct(ostream& out, string prefix, bool pointer) { if (pointer) { - indent(out) << "if (!" << prefix << ") { " << endl; + indent(out) << "if (!" << prefix << ") { " << '\n'; indent(out) << " " << prefix << " = ::std::shared_ptr<" << type_name(tstruct) << ">(new " - << type_name(tstruct) << ");" << endl; - indent(out) << "}" << endl; - indent(out) << "xfer += " << prefix << "->read(iprot);" << endl; - indent(out) << "bool wasSet = false;" << endl; + << type_name(tstruct) << ");" << '\n'; + indent(out) << "}" << '\n'; + indent(out) << "xfer += " << prefix << "->read(iprot);" << '\n'; + indent(out) << "bool wasSet = false;" << '\n'; const vector& members = tstruct->get_members(); vector::const_iterator f_iter; for (f_iter = members.begin(); f_iter != members.end(); ++f_iter) { indent(out) << "if (" << prefix << "->__isset." << (*f_iter)->get_name() - << ") { wasSet = true; }" << endl; + << ") { wasSet = true; }" << '\n'; } - indent(out) << "if (!wasSet) { " << prefix << ".reset(); }" << endl; + indent(out) << "if (!wasSet) { " << prefix << ".reset(); }" << '\n'; } else { - indent(out) << "xfer += " << prefix << ".read(iprot);" << endl; + indent(out) << "xfer += " << prefix << ".read(iprot);" << '\n'; } } @@ -4131,28 +4128,28 @@ void t_cpp_generator::generate_deserialize_container(ostream& out, t_type* ttype t_container* tcontainer = (t_container*)ttype; bool use_push = tcontainer->has_cpp_name(); - indent(out) << prefix << ".clear();" << endl << indent() << "uint32_t " << size << ";" << endl; + indent(out) << prefix << ".clear();" << '\n' << indent() << "uint32_t " << size << ";" << '\n'; // Declare variables, read header if (ttype->is_map()) { - out << indent() << "::apache::thrift::protocol::TType " << ktype << ";" << endl << indent() - << "::apache::thrift::protocol::TType " << vtype << ";" << endl << indent() - << "xfer += iprot->readMapBegin(" << ktype << ", " << vtype << ", " << size << ");" << endl; + out << indent() << "::apache::thrift::protocol::TType " << ktype << ";" << '\n' << indent() + << "::apache::thrift::protocol::TType " << vtype << ";" << '\n' << indent() + << "xfer += iprot->readMapBegin(" << ktype << ", " << vtype << ", " << size << ");" << '\n'; } else if (ttype->is_set()) { - out << indent() << "::apache::thrift::protocol::TType " << etype << ";" << endl << indent() - << "xfer += iprot->readSetBegin(" << etype << ", " << size << ");" << endl; + out << indent() << "::apache::thrift::protocol::TType " << etype << ";" << '\n' << indent() + << "xfer += iprot->readSetBegin(" << etype << ", " << size << ");" << '\n'; } else if (ttype->is_list()) { - out << indent() << "::apache::thrift::protocol::TType " << etype << ";" << endl << indent() - << "xfer += iprot->readListBegin(" << etype << ", " << size << ");" << endl; + out << indent() << "::apache::thrift::protocol::TType " << etype << ";" << '\n' << indent() + << "xfer += iprot->readListBegin(" << etype << ", " << size << ");" << '\n'; if (!use_push) { - indent(out) << prefix << ".resize(" << size << ");" << endl; + indent(out) << prefix << ".resize(" << size << ");" << '\n'; } } // For loop iterates over elements string i = tmp("_i"); - out << indent() << "uint32_t " << i << ";" << endl << indent() << "for (" << i << " = 0; " << i - << " < " << size << "; ++" << i << ")" << endl; + out << indent() << "uint32_t " << i << ";" << '\n' << indent() << "for (" << i << " = 0; " << i + << " < " << size << "; ++" << i << ")" << '\n'; scope_up(out); @@ -4168,11 +4165,11 @@ void t_cpp_generator::generate_deserialize_container(ostream& out, t_type* ttype // Read container end if (ttype->is_map()) { - indent(out) << "xfer += iprot->readMapEnd();" << endl; + indent(out) << "xfer += iprot->readMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "xfer += iprot->readSetEnd();" << endl; + indent(out) << "xfer += iprot->readSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "xfer += iprot->readListEnd();" << endl; + indent(out) << "xfer += iprot->readListEnd();" << '\n'; } scope_down(out); @@ -4187,11 +4184,11 @@ void t_cpp_generator::generate_deserialize_map_element(ostream& out, t_map* tmap t_field fkey(tmap->get_key_type(), key); t_field fval(tmap->get_val_type(), val); - out << indent() << declare_field(&fkey) << endl; + out << indent() << declare_field(&fkey) << '\n'; generate_deserialize_field(out, &fkey); indent(out) << declare_field(&fval, false, false, false, true) << " = " << prefix << "[" << key - << "];" << endl; + << "];" << '\n'; generate_deserialize_field(out, &fval); } @@ -4200,11 +4197,11 @@ void t_cpp_generator::generate_deserialize_set_element(ostream& out, t_set* tset string elem = tmp("_elem"); t_field felem(tset->get_elem_type(), elem); - indent(out) << declare_field(&felem) << endl; + indent(out) << declare_field(&felem) << '\n'; generate_deserialize_field(out, &felem); - indent(out) << prefix << ".insert(" << elem << ");" << endl; + indent(out) << prefix << ".insert(" << elem << ");" << '\n'; } void t_cpp_generator::generate_deserialize_list_element(ostream& out, @@ -4215,9 +4212,9 @@ void t_cpp_generator::generate_deserialize_list_element(ostream& out, if (use_push) { string elem = tmp("_elem"); t_field felem(tlist->get_elem_type(), elem); - indent(out) << declare_field(&felem) << endl; + indent(out) << declare_field(&felem) << '\n'; generate_deserialize_field(out, &felem); - indent(out) << prefix << ".push_back(" << elem << ");" << endl; + indent(out) << prefix << ".push_back(" << elem << ");" << '\n'; } else { t_field felem(tlist->get_elem_type(), prefix + "[" + index + "]"); generate_deserialize_field(out, &felem); @@ -4292,7 +4289,7 @@ void t_cpp_generator::generate_serialize_field(ostream& out, } else if (type->is_enum()) { out << "writeI32(static_cast(" << name << "));"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s' TYPE '%s'\n", name.c_str(), @@ -4311,15 +4308,15 @@ void t_cpp_generator::generate_serialize_struct(ostream& out, string prefix, bool pointer) { if (pointer) { - indent(out) << "if (" << prefix << ") {" << endl; - indent(out) << " xfer += " << prefix << "->write(oprot); " << endl; + indent(out) << "if (" << prefix << ") {" << '\n'; + indent(out) << " xfer += " << prefix << "->write(oprot); " << '\n'; indent(out) << "} else {" - << "oprot->writeStructBegin(\"" << tstruct->get_name() << "\"); " << endl; - indent(out) << " oprot->writeStructEnd();" << endl; - indent(out) << " oprot->writeFieldStop();" << endl; - indent(out) << "}" << endl; + << "oprot->writeStructBegin(\"" << tstruct->get_name() << "\"); " << '\n'; + indent(out) << " oprot->writeStructEnd();" << '\n'; + indent(out) << " oprot->writeFieldStop();" << '\n'; + indent(out) << "}" << '\n'; } else { - indent(out) << "xfer += " << prefix << ".write(oprot);" << endl; + indent(out) << "xfer += " << prefix << ".write(oprot);" << '\n'; } } @@ -4329,21 +4326,21 @@ void t_cpp_generator::generate_serialize_container(ostream& out, t_type* ttype, if (ttype->is_map()) { indent(out) << "xfer += oprot->writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " - << "static_cast(" << prefix << ".size()));" << endl; + << "static_cast(" << prefix << ".size()));" << '\n'; } else if (ttype->is_set()) { indent(out) << "xfer += oprot->writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " - << "static_cast(" << prefix << ".size()));" << endl; + << "static_cast(" << prefix << ".size()));" << '\n'; } else if (ttype->is_list()) { indent(out) << "xfer += oprot->writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " - << "static_cast(" << prefix << ".size()));" << endl; + << "static_cast(" << prefix << ".size()));" << '\n'; } string iter = tmp("_iter"); - out << indent() << type_name(ttype) << "::const_iterator " << iter << ";" << endl << indent() + out << indent() << type_name(ttype) << "::const_iterator " << iter << ";" << '\n' << indent() << "for (" << iter << " = " << prefix << ".begin(); " << iter << " != " << prefix - << ".end(); ++" << iter << ")" << endl; + << ".end(); ++" << iter << ")" << '\n'; scope_up(out); if (ttype->is_map()) { generate_serialize_map_element(out, (t_map*)ttype, iter); @@ -4355,11 +4352,11 @@ void t_cpp_generator::generate_serialize_container(ostream& out, t_type* ttype, scope_down(out); if (ttype->is_map()) { - indent(out) << "xfer += oprot->writeMapEnd();" << endl; + indent(out) << "xfer += oprot->writeMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "xfer += oprot->writeSetEnd();" << endl; + indent(out) << "xfer += oprot->writeSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "xfer += oprot->writeListEnd();" << endl; + indent(out) << "xfer += oprot->writeListEnd();" << '\n'; } scope_down(out); diff --git a/compiler/cpp/src/thrift/generate/t_d_generator.cc b/compiler/cpp/src/thrift/generate/t_d_generator.cc index 38194c20719..61988dfc491 100644 --- a/compiler/cpp/src/thrift/generate/t_d_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_d_generator.cc @@ -43,8 +43,6 @@ using std::set; using std::string; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * D code generator. * @@ -105,7 +103,7 @@ class t_d_generator : public t_oop_generator { // Print header f_types_ << autogen_comment() << "module " << render_package(*program_) << program_name_ - << "_types;" << endl << endl; + << "_types;" << '\n' << '\n'; print_default_imports(f_types_); @@ -113,10 +111,10 @@ class t_d_generator : public t_oop_generator { const vector& includes = program_->get_includes(); for (auto include : includes) { f_types_ << "public import " << render_package(*include) << include->get_name() - << "_types;" << endl; + << "_types;" << '\n'; } if (!includes.empty()) - f_types_ << endl; + f_types_ << '\n'; } void close_generator() override { @@ -131,22 +129,22 @@ class t_d_generator : public t_oop_generator { f_consts.open(f_consts_name.c_str()); f_consts << autogen_comment() << "module " << render_package(*program_) << program_name_ - << "_constants;" << endl << endl; + << "_constants;" << '\n' << '\n'; print_default_imports(f_consts); - f_consts << "import " << render_package(*get_program()) << program_name_ << "_types;" << endl - << endl; + f_consts << "import " << render_package(*get_program()) << program_name_ << "_types;" << '\n' + << '\n'; vector::iterator c_iter; for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { this->emit_doc(*c_iter, f_consts); string name = suffix_if_reserved((*c_iter)->get_name()); t_type* type = (*c_iter)->get_type(); - indent(f_consts) << "immutable(" << render_type_name(type) << ") " << name << ";" << endl; + indent(f_consts) << "immutable(" << render_type_name(type) << ") " << name << ";" << '\n'; } - f_consts << endl << "shared static this() {" << endl; + f_consts << '\n' << "shared static this() {" << '\n'; indent_up(); bool first = true; @@ -154,24 +152,24 @@ class t_d_generator : public t_oop_generator { if (first) { first = false; } else { - f_consts << endl; + f_consts << '\n'; } t_type* type = (*c_iter)->get_type(); indent(f_consts) << suffix_if_reserved((*c_iter)->get_name()) << " = "; if (!is_immutable_type(type)) { f_consts << "cast(immutable(" << render_type_name(type) << ")) "; } - f_consts << render_const_value(type, (*c_iter)->get_value()) << ";" << endl; + f_consts << render_const_value(type, (*c_iter)->get_value()) << ";" << '\n'; } indent_down(); - indent(f_consts) << "}" << endl; + indent(f_consts) << "}" << '\n'; } } void generate_typedef(t_typedef* ttypedef) override { this->emit_doc(ttypedef, f_types_); f_types_ << indent() << "alias " << render_type_name(ttypedef->get_type()) << " " - << ttypedef->get_symbolic() << ";" << endl << endl; + << ttypedef->get_symbolic() << ";" << '\n' << '\n'; } void generate_enum(t_enum* tenum) override { @@ -179,7 +177,7 @@ class t_d_generator : public t_oop_generator { this->emit_doc(tenum, f_types_); string enum_name = suffix_if_reserved(tenum->get_name()); - f_types_ << indent() << "enum " << enum_name << " {" << endl; + f_types_ << indent() << "enum " << enum_name << " {" << '\n'; indent_up(); @@ -190,11 +188,11 @@ class t_d_generator : public t_oop_generator { f_types_ << " = " << (*c_iter)->get_value() << ","; } - f_types_ << endl; + f_types_ << '\n'; indent_down(); - indent(f_types_) << "}" << endl; + indent(f_types_) << "}" << '\n'; - f_types_ << endl; + f_types_ << '\n'; } void generate_struct(t_struct* tstruct) override { @@ -213,19 +211,19 @@ class t_d_generator : public t_oop_generator { ofstream_with_content_based_conditional_update f_service; f_service.open(f_servicename.c_str()); f_service << autogen_comment() << "module " << suffix_if_reserved(render_package(*program_)) << svc_name << ";" - << endl << endl; + << '\n' << '\n'; print_default_imports(f_service); - f_service << "import " << suffix_if_reserved(render_package(*get_program())) << program_name_ << "_types;" << endl; + f_service << "import " << suffix_if_reserved(render_package(*get_program())) << program_name_ << "_types;" << '\n'; t_service* extends_service = tservice->get_extends(); if (extends_service != nullptr) { f_service << "import " << suffix_if_reserved(render_package(*(extends_service->get_program()))) - << suffix_if_reserved(extends_service->get_name()) << ";" << endl; + << suffix_if_reserved(extends_service->get_name()) << ";" << '\n'; } - f_service << endl; + f_service << '\n'; string extends = ""; if (tservice->get_extends() != nullptr) { @@ -233,7 +231,7 @@ class t_d_generator : public t_oop_generator { } this->emit_doc(tservice, f_service); - f_service << indent() << "interface " << svc_name << extends << " {" << endl; + f_service << indent() << "interface " << svc_name << extends << " {" << '\n'; indent_up(); // Collect all the exception types service methods can throw so we can @@ -247,7 +245,7 @@ class t_d_generator : public t_oop_generator { this->emit_doc(*fn_iter, f_service); f_service << indent(); print_function_signature(f_service, *fn_iter); - f_service << ";" << endl; + f_service << ";" << '\n'; const vector& exceptions = (*fn_iter)->get_xceptions()->get_members(); vector::const_iterator ex_iter; @@ -258,13 +256,13 @@ class t_d_generator : public t_oop_generator { // Alias the exception types into the current scope. if (!exception_types.empty()) - f_service << endl; + f_service << '\n'; set::const_iterator et_iter; for (et_iter = exception_types.begin(); et_iter != exception_types.end(); ++et_iter) { indent(f_service) << "alias " << render_package(*(*et_iter)->get_program()) << (*et_iter)->get_program()->get_name() << "_types" << "." << (*et_iter)->get_name() << " " << (*et_iter)->get_name() << ";" - << endl; + << '\n'; } // Write the method metadata. @@ -283,7 +281,7 @@ class t_d_generator : public t_oop_generator { meta << ","; } - meta << endl << indent() << "TMethodMeta(`" << suffix_if_reserved((*fn_iter)->get_name()) << "`, " << endl; + meta << '\n' << indent() << "TMethodMeta(`" << suffix_if_reserved((*fn_iter)->get_name()) << "`, " << '\n'; indent_up(); indent(meta) << "["; @@ -309,7 +307,7 @@ class t_d_generator : public t_oop_generator { meta << "]"; if (!(*fn_iter)->get_xceptions()->get_members().empty() || (*fn_iter)->is_oneway()) { - meta << "," << endl << indent() << "["; + meta << "," << '\n' << indent() << "["; bool first = true; const vector& exceptions = (*fn_iter)->get_xceptions()->get_members(); @@ -329,22 +327,22 @@ class t_d_generator : public t_oop_generator { } if ((*fn_iter)->is_oneway()) { - meta << "," << endl << indent() << "TMethodType.ONEWAY"; + meta << "," << '\n' << indent() << "TMethodType.ONEWAY"; } indent_down(); - meta << endl << indent() << ")"; + meta << '\n' << indent() << ")"; } indent_down(); string meta_str(meta.str()); if (!meta_str.empty()) { - f_service << endl << indent() << "enum methodMeta = [" << meta_str << endl << indent() << "];" - << endl; + f_service << '\n' << indent() << "enum methodMeta = [" << meta_str << '\n' << indent() << "];" + << '\n'; } indent_down(); - indent(f_service) << "}" << endl; + indent(f_service) << "}" << '\n'; // Server skeleton generation. string f_skeletonname = package_dir_ + svc_name + "_server.skeleton.d"; @@ -358,14 +356,14 @@ class t_d_generator : public t_oop_generator { if (!doc->has_doc()) { return; } - indent(out) << "/**" << std::endl; + indent(out) << "/**" << '\n'; indent_up(); - // No endl -- comments reliably have a newline at the end. + // No line break -- comments reliably have a newline at the end. // This is true even for stuff like: // /** method infos */ void foo(/** huh?*/ 1: i64 stuff) indent(out) << doc->get_doc(); indent_down(); - indent(out) << "*/" << std::endl; + indent(out) << "*/" << '\n'; } private: @@ -376,59 +374,59 @@ class t_d_generator : public t_oop_generator { void print_server_skeleton(ostream& out, t_service* tservice) { string svc_name = suffix_if_reserved(tservice->get_name()); - out << "/*" << endl - << " * This auto-generated skeleton file illustrates how to build a server. If you" << endl - << " * intend to customize it, you should edit a copy with another file name to " << endl - << " * avoid overwriting it when running the generator again." << endl << " */" << endl - << "module " << render_package(*tservice->get_program()) << svc_name << "_server;" << endl - << endl << "import std.stdio;" << endl << "import thrift.codegen.processor;" << endl - << "import thrift.protocol.binary;" << endl << "import thrift.server.simple;" << endl - << "import thrift.server.transport.socket;" << endl << "import thrift.transport.buffered;" - << endl << "import thrift.util.hashset;" << endl << endl << "import " - << render_package(*tservice->get_program()) << svc_name << ";" << endl << "import " - << render_package(*get_program()) << program_name_ << "_types;" << endl << endl << endl - << "class " << svc_name << "Handler : " << svc_name << " {" << endl; + out << "/*" << '\n' + << " * This auto-generated skeleton file illustrates how to build a server. If you" << '\n' + << " * intend to customize it, you should edit a copy with another file name to " << '\n' + << " * avoid overwriting it when running the generator again." << '\n' << " */" << '\n' + << "module " << render_package(*tservice->get_program()) << svc_name << "_server;" << '\n' + << '\n' << "import std.stdio;" << '\n' << "import thrift.codegen.processor;" << '\n' + << "import thrift.protocol.binary;" << '\n' << "import thrift.server.simple;" << '\n' + << "import thrift.server.transport.socket;" << '\n' << "import thrift.transport.buffered;" + << '\n' << "import thrift.util.hashset;" << '\n' << '\n' << "import " + << render_package(*tservice->get_program()) << svc_name << ";" << '\n' << "import " + << render_package(*get_program()) << program_name_ << "_types;" << '\n' << '\n' << '\n' + << "class " << svc_name << "Handler : " << svc_name << " {" << '\n'; indent_up(); - out << indent() << "this() {" << endl << indent() << " // Your initialization goes here." - << endl << indent() << "}" << endl << endl; + out << indent() << "this() {" << '\n' << indent() << " // Your initialization goes here." + << '\n' << indent() << "}" << '\n' << '\n'; vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { out << indent(); print_function_signature(out, *f_iter); - out << " {" << endl; + out << " {" << '\n'; indent_up(); - out << indent() << "// Your implementation goes here." << endl << indent() << "writeln(\"" - << suffix_if_reserved((*f_iter)->get_name()) << " called\");" << endl; + out << indent() << "// Your implementation goes here." << '\n' << indent() << "writeln(\"" + << suffix_if_reserved((*f_iter)->get_name()) << " called\");" << '\n'; t_type* rt = (*f_iter)->get_returntype(); if (!rt->is_void()) { - indent(out) << "return typeof(return).init;" << endl; + indent(out) << "return typeof(return).init;" << '\n'; } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } indent_down(); - out << "}" << endl << endl; + out << "}" << '\n' << '\n'; - out << indent() << "void main() {" << endl; + out << indent() << "void main() {" << '\n'; indent_up(); - out << indent() << "auto protocolFactory = new TBinaryProtocolFactory!();" << endl << indent() + out << indent() << "auto protocolFactory = new TBinaryProtocolFactory!();" << '\n' << indent() << "auto processor = new TServiceProcessor!" << svc_name << "(new " << svc_name - << "Handler);" << endl << indent() << "auto serverTransport = new TServerSocket(9090);" - << endl << indent() << "auto transportFactory = new TBufferedTransportFactory;" << endl - << indent() << "auto server = new TSimpleServer(" << endl << indent() - << " processor, serverTransport, transportFactory, protocolFactory);" << endl << indent() - << "server.serve();" << endl; + << "Handler);" << '\n' << indent() << "auto serverTransport = new TServerSocket(9090);" + << '\n' << indent() << "auto transportFactory = new TBufferedTransportFactory;" << '\n' + << indent() << "auto server = new TSimpleServer(" << '\n' << indent() + << " processor, serverTransport, transportFactory, protocolFactory);" << '\n' << indent() + << "server.serve();" << '\n'; indent_down(); - out << "}" << endl; + out << "}" << '\n'; } /** @@ -439,9 +437,9 @@ class t_d_generator : public t_oop_generator { const vector& members = tstruct->get_members(); if (is_exception) { - indent(out) << "class " << suffix_if_reserved(tstruct->get_name()) << " : TException {" << endl; + indent(out) << "class " << suffix_if_reserved(tstruct->get_name()) << " : TException {" << '\n'; } else { - indent(out) << "struct " << suffix_if_reserved(tstruct->get_name()) << " {" << endl; + indent(out) << "struct " << suffix_if_reserved(tstruct->get_name()) << " {" << '\n'; } indent_up(); @@ -449,11 +447,11 @@ class t_d_generator : public t_oop_generator { vector::const_iterator m_iter; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { indent(out) << render_type_name((*m_iter)->get_type()) << " " << suffix_if_reserved((*m_iter)->get_name()) << ";" - << endl; + << '\n'; } if (!members.empty()) - indent(out) << endl; + indent(out) << '\n'; indent(out) << "mixin TStructHelpers!("; if (!members.empty()) { @@ -471,7 +469,7 @@ class t_d_generator : public t_oop_generator { } else { out << ","; } - out << endl; + out << '\n'; indent(out) << "TFieldMeta(`" << suffix_if_reserved((*m_iter)->get_name()) << "`, " << (*m_iter)->get_key(); @@ -485,13 +483,13 @@ class t_d_generator : public t_oop_generator { } indent_down(); - out << endl << indent() << "]"; + out << '\n' << indent() << "]"; } - out << ");" << endl; + out << ");" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -559,13 +557,13 @@ class t_d_generator : public t_oop_generator { } else if (type->is_enum()) { out << "cast(" << render_type_name(type) << ")" << value->get_integer(); } else { - out << "{" << endl; + out << "{" << '\n'; indent_up(); - indent(out) << render_type_name(type) << " v;" << endl; + indent(out) << render_type_name(type) << " v;" << '\n'; if (type->is_struct() || type->is_xception()) { indent(out) << "v = " << (type->is_xception() ? "new " : "") << render_type_name(type) - << "();" << endl; + << "();" << '\n'; const vector& fields = ((t_struct*)type)->get_members(); vector::const_iterator f_iter; @@ -583,7 +581,7 @@ class t_d_generator : public t_oop_generator { + v_iter->first->get_string(); } string val = render_const_value(field_type, v_iter->second); - indent(out) << "v.set!`" << v_iter->first->get_string() << "`(" << val << ");" << endl; + indent(out) << "v.set!`" << v_iter->first->get_string() << "`(" << val << ");" << '\n'; } } else if (type->is_map()) { t_type* ktype = ((t_map*)type)->get_key_type(); @@ -597,7 +595,7 @@ class t_d_generator : public t_oop_generator { if (!is_immutable_type(ktype)) { out << "cast(immutable(" << render_type_name(ktype) << "))"; } - out << key << "] = " << val << ";" << endl; + out << key << "] = " << val << ";" << '\n'; } } else if (type->is_list()) { t_type* etype = ((t_list*)type)->get_elem_type(); @@ -605,7 +603,7 @@ class t_d_generator : public t_oop_generator { vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string val = render_const_value(etype, *v_iter); - indent(out) << "v ~= " << val << ";" << endl; + indent(out) << "v ~= " << val << ";" << '\n'; } } else if (type->is_set()) { t_type* etype = ((t_set*)type)->get_elem_type(); @@ -613,12 +611,12 @@ class t_d_generator : public t_oop_generator { vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string val = render_const_value(etype, *v_iter); - indent(out) << "v ~= " << val << ";" << endl; + indent(out) << "v ~= " << val << ";" << '\n'; } } else { throw "Compiler error: Invalid type in render_const_value: " + type->get_name(); } - indent(out) << "return v;" << endl; + indent(out) << "return v;" << '\n'; indent_down(); indent(out) << "}()"; @@ -728,8 +726,8 @@ class t_d_generator : public t_oop_generator { */ void print_default_imports(ostream& out) { - indent(out) << "import thrift.base;" << endl << "import thrift.codegen.base;" << endl - << "import thrift.util.hashset;" << endl << endl; + indent(out) << "import thrift.base;" << '\n' << "import thrift.codegen.base;" << '\n' + << "import thrift.util.hashset;" << '\n' << '\n'; } /** diff --git a/compiler/cpp/src/thrift/generate/t_dart_generator.cc b/compiler/cpp/src/thrift/generate/t_dart_generator.cc index fda989b24c6..00550438ed2 100644 --- a/compiler/cpp/src/thrift/generate/t_dart_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_dart_generator.cc @@ -37,9 +37,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes -static const string endl2 = "\n\n"; - /** * Use the current Thrift version for static libraries. When releasing, update * the version in these files. @@ -89,11 +86,11 @@ class t_dart_generator : public t_oop_generator { } void scope_up(std::ostream& out, std::string prefix=" ") { - out << prefix << "{" << endl; + out << prefix << "{" << '\n'; indent_up(); } - void scope_down(std::ostream& out, std::string postfix=endl) { + void scope_down(std::ostream& out, std::string postfix="\n") { indent_down(); indent(out) << "}" << postfix; } @@ -339,7 +336,7 @@ string t_dart_generator::dart_library(string file_name) { * @return List of imports for services */ string t_dart_generator::service_imports() { - return "import 'dart:async';" + endl; + return string("import 'dart:async';") + "\n"; } /** @@ -348,14 +345,14 @@ string t_dart_generator::service_imports() { * @return List of imports necessary for thrift */ string t_dart_generator::dart_thrift_imports() { - string imports = "import 'dart:typed_data' show Uint8List;" + endl + - "import 'package:thrift/thrift.dart';" + endl; + string imports = string("import 'dart:typed_data' show Uint8List;") + "\n" + + string("import 'package:thrift/thrift.dart';") + "\n"; // add import for this library if (package_prefix_.empty()) { - imports += "import 'package:" + library_name_ + "/" + library_name_ + ".dart';" + endl; + imports += "import 'package:" + library_name_ + "/" + library_name_ + ".dart';" + "\n"; } else { - imports += "import 'package:" + package_prefix_ + library_name_ + ".dart';" + endl; + imports += "import 'package:" + package_prefix_ + library_name_ + ".dart';" + "\n"; } // add imports for included thrift files @@ -364,9 +361,9 @@ string t_dart_generator::dart_thrift_imports() { string include_name = find_library_name(include); string named_import = "t_" + include_name; if (package_prefix_.empty()) { - imports += "import 'package:" + include_name + "/" + include_name + ".dart' as " + named_import + ";" + endl; + imports += "import 'package:" + include_name + "/" + include_name + ".dart' as " + named_import + ";" + "\n"; } else { - imports += "import 'package:" + package_prefix_ + include_name + ".dart' as " + named_import + ";" + endl; + imports += "import 'package:" + package_prefix_ + include_name + ".dart' as " + named_import + ";" + "\n"; } } @@ -395,8 +392,8 @@ void t_dart_generator::generate_dart_library() { ofstream_with_content_based_conditional_update f_library; f_library.open(f_library_name.c_str()); - f_library << autogen_comment() << endl; - f_library << "library " << library_prefix_ << library_name_ << ";" << endl2; + f_library << autogen_comment() << '\n'; + f_library << "library " << library_prefix_ << library_name_ << ";" << '\n' << '\n'; f_library << library_exports_; f_library.close(); @@ -409,7 +406,7 @@ void t_dart_generator::export_class_to_library(string file_name, string class_na } else { subdir = library_name_; } - library_exports_ += "export '" + subdir + "/" + file_name + ".dart' show " + class_name + ";" + endl; + library_exports_ += "export '" + subdir + "/" + file_name + ".dart' show " + class_name + ";" + "\n"; } void t_dart_generator::generate_dart_pubspec() { @@ -417,30 +414,30 @@ void t_dart_generator::generate_dart_pubspec() { ofstream_with_content_based_conditional_update f_pubspec; f_pubspec.open(f_pubspec_name.c_str()); - indent(f_pubspec) << "name: " << library_name_ << endl; - indent(f_pubspec) << "version: 0.0.1" << endl; - indent(f_pubspec) << "description: Autogenerated by Thrift Compiler" << endl; - f_pubspec << endl; + indent(f_pubspec) << "name: " << library_name_ << '\n'; + indent(f_pubspec) << "version: 0.0.1" << '\n'; + indent(f_pubspec) << "description: Autogenerated by Thrift Compiler" << '\n'; + f_pubspec << '\n'; - indent(f_pubspec) << "environment:" << endl; + indent(f_pubspec) << "environment:" << '\n'; indent_up(); - indent(f_pubspec) << "sdk: '>=1.24.3 <3.0.0'" << endl; + indent(f_pubspec) << "sdk: '>=1.24.3 <3.0.0'" << '\n'; indent_down(); - f_pubspec << endl; + f_pubspec << '\n'; - indent(f_pubspec) << "dependencies:" << endl; + indent(f_pubspec) << "dependencies:" << '\n'; indent_up(); if (pubspec_lib_.empty()) { // default to relative path within working directory, which works for tests - indent(f_pubspec) << "thrift: # ^" << dart_thrift_version << endl; + indent(f_pubspec) << "thrift: # ^" << dart_thrift_version << '\n'; indent_up(); - indent(f_pubspec) << "path: ../../../../lib/dart" << endl; + indent(f_pubspec) << "path: ../../../../lib/dart" << '\n'; indent_down(); } else { const vector lines = split(pubspec_lib_, '|'); for (const auto & line : lines) { - indent(f_pubspec) << line << endl; + indent(f_pubspec) << line << '\n'; } } @@ -448,14 +445,14 @@ void t_dart_generator::generate_dart_pubspec() { const vector& includes = program_->get_includes(); for (auto include : includes) { string include_name = find_library_name(include); - indent(f_pubspec) << include_name << ":" << endl; + indent(f_pubspec) << include_name << ":" << '\n'; indent_up(); - indent(f_pubspec) << "path: ../" << include_name << endl; + indent(f_pubspec) << "path: ../" << include_name << '\n'; indent_down(); } indent_down(); - f_pubspec << endl; + f_pubspec << '\n'; f_pubspec.close(); } @@ -483,7 +480,7 @@ void t_dart_generator::generate_enum(t_enum* tenum) { f_enum.open(f_enum_name.c_str()); // Comment and add library - f_enum << autogen_comment() << dart_library(file_name) << endl; + f_enum << autogen_comment() << dart_library(file_name) << '\n'; string class_name = tenum->get_name(); export_class_to_library(file_name, class_name); @@ -495,34 +492,34 @@ void t_dart_generator::generate_enum(t_enum* tenum) { for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); indent(f_enum) << "static const int " << (*c_iter)->get_name() << " = " << value << ";" - << endl; + << '\n'; } // Create a static Set with all valid values for this enum - f_enum << endl; + f_enum << '\n'; - indent(f_enum) << "static final Set VALID_VALUES = new Set.from([" << endl; + indent(f_enum) << "static final Set VALID_VALUES = new Set.from([" << '\n'; indent_up(); bool firstValue = true; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { // populate set indent(f_enum) << (firstValue ? "" : ", "); - f_enum << (*c_iter)->get_name() << endl; + f_enum << (*c_iter)->get_name() << '\n'; firstValue = false; } indent_down(); - indent(f_enum) << "]);" << endl; + indent(f_enum) << "]);" << '\n'; - indent(f_enum) << "static final Map VALUES_TO_NAMES = {" << endl; + indent(f_enum) << "static final Map VALUES_TO_NAMES = {" << '\n'; indent_up(); firstValue = true; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { indent(f_enum) << (firstValue ? "" : ", "); - f_enum << (*c_iter)->get_name() << ": '" << (*c_iter)->get_name() << "'" << endl; + f_enum << (*c_iter)->get_name() << ": '" << (*c_iter)->get_name() << "'" << '\n'; firstValue = false; } indent_down(); - indent(f_enum) << "};" << endl; + indent(f_enum) << "};" << '\n'; scope_down(f_enum); // end class @@ -545,8 +542,8 @@ void t_dart_generator::generate_consts(std::vector consts) { f_consts.open(f_consts_name.c_str()); // Print header - f_consts << autogen_comment() << dart_library(file_name) << endl; - f_consts << dart_thrift_imports() << endl; + f_consts << autogen_comment() << dart_library(file_name) << '\n'; + f_consts << dart_thrift_imports() << '\n'; export_class_to_library(file_name, class_name); indent(f_consts) << "class " << class_name; @@ -559,7 +556,7 @@ void t_dart_generator::generate_consts(std::vector consts) { (*c_iter)->get_type(), (*c_iter)->get_value(), false); - f_consts << endl; + f_consts << '\n'; } scope_down(f_consts); @@ -585,13 +582,13 @@ void t_dart_generator::print_const_value(std::ostream& out, } string v2 = render_const_value(out, name, type, value); out << name; - out << " = " << v2 << ";" << endl << endl; + out << " = " << v2 << ";" << '\n' << '\n'; } else if (type->is_enum()) { if (!defval) { out << type_name(type) << " "; } out << name; - out << " = " << value->get_integer() << ";" << endl << endl; + out << " = " << value->get_integer() << ";" << '\n' << '\n'; } else if (type->is_struct() || type->is_xception()) { const vector& fields = ((t_struct*)type)->get_members(); vector::const_iterator f_iter; @@ -610,11 +607,11 @@ void t_dart_generator::print_const_value(std::ostream& out, throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string(); } string val = render_const_value(out, name, field_type, v_iter->second); - out << endl; + out << '\n'; indent(out) << ".." << v_iter->first->get_string() << " = " << val; } indent_down(); - out << ";" << endl; + out << ";" << '\n'; } else if (type->is_map()) { if (!defval) { out << type_name(type) << " "; @@ -630,11 +627,11 @@ void t_dart_generator::print_const_value(std::ostream& out, for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string key = render_const_value(out, name, ktype, v_iter->first); string val = render_const_value(out, name, vtype, v_iter->second); - indent(out) << key << ": " << val << "," << endl; + indent(out) << key << ": " << val << "," << '\n'; } - scope_down(out, ";" + endl); + scope_down(out, string(";") + "\n"); - out << endl; + out << '\n'; } else if (type->is_list() || type->is_set()) { if (!defval) { out << type_name(type) << " "; @@ -642,10 +639,10 @@ void t_dart_generator::print_const_value(std::ostream& out, out << name << " = "; t_type* etype; if (type->is_list()) { - out << "[" << endl; + out << "[" << '\n'; etype = ((t_list*)type)->get_elem_type(); } else { - out << "new " << type_name(type) << ".from([" << endl; + out << "new " << type_name(type) << ".from([" << '\n'; etype = ((t_set*)type)->get_elem_type(); } const vector& val = value->get_list(); @@ -654,14 +651,14 @@ void t_dart_generator::print_const_value(std::ostream& out, indent_up(); for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string val = render_const_value(out, name, etype, *v_iter); - indent(out) << val << "," << endl; + indent(out) << val << "," << '\n'; } indent_down(); if (type->is_list()) { - indent(out) << "];" << endl; + indent(out) << "];" << '\n'; } else { - indent(out) << "]);" << endl; + indent(out) << "]);" << '\n'; } } else { @@ -707,7 +704,7 @@ string t_dart_generator::render_const_value(ostream& out, } else { string t = tmp("tmp"); print_const_value(out, t, type, value, true); - out << endl; + out << '\n'; render << t; } @@ -744,11 +741,11 @@ void t_dart_generator::generate_dart_struct(t_struct* tstruct, bool is_exception ofstream_with_content_based_conditional_update f_struct; f_struct.open(f_struct_name.c_str()); - f_struct << autogen_comment() << dart_library(file_name) << endl; + f_struct << autogen_comment() << dart_library(file_name) << '\n'; string imports; - f_struct << dart_thrift_imports() << endl; + f_struct << dart_thrift_imports() << '\n'; generate_dart_struct_definition(f_struct, tstruct, is_exception, false, file_name); @@ -785,7 +782,7 @@ void t_dart_generator::generate_dart_struct_definition(ostream& out, scope_up(out); indent(out) << "static final TStruct _STRUCT_DESC = new TStruct(\"" << class_name - << "\");" << endl; + << "\");" << '\n'; // Members are public for -dart, private for -dartbean const vector& members = tstruct->get_members(); @@ -795,33 +792,33 @@ void t_dart_generator::generate_dart_struct_definition(ostream& out, indent(out) << "static final TField _" << constant_name((*m_iter)->get_name()) << "_FIELD_DESC = new TField(\"" << (*m_iter)->get_name() << "\", " << type_to_enum((*m_iter)->get_type()) << ", " << (*m_iter)->get_key() << ");" - << endl; + << '\n'; } - out << endl; + out << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { generate_dart_doc(out, *m_iter); indent(out) << type_name((*m_iter)->get_type()) + " _" - << get_member_name((*m_iter)->get_name()) << init_value(*m_iter) << ";" << endl; + << get_member_name((*m_iter)->get_name()) << init_value(*m_iter) << ";" << '\n'; indent(out) << "static const int " << upcase_string((*m_iter)->get_name()) - << " = " << (*m_iter)->get_key() << ";" << endl; + << " = " << (*m_iter)->get_key() << ";" << '\n'; } - out << endl; + out << '\n'; // Inner Isset class if (members.size() > 0) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if (!type_can_be_null((*m_iter)->get_type())) { string field_name = get_member_name((*m_iter)->get_name()); - indent(out) << "bool __isset_" << field_name << " = false;" << endl; + indent(out) << "bool __isset_" << field_name << " = false;" << '\n'; } } } - out << endl; + out << '\n'; // Default constructor indent(out) << tstruct->get_name() << "()"; @@ -838,7 +835,7 @@ void t_dart_generator::generate_dart_struct_definition(ostream& out, } } scope_down(out); - out << endl; + out << '\n'; generate_dart_bean_boilerplate(out, tstruct); generate_generic_field_getters(out, tstruct); @@ -854,7 +851,7 @@ void t_dart_generator::generate_dart_struct_definition(ostream& out, generate_dart_struct_tostring(out, tstruct); generate_dart_validator(out, tstruct); scope_down(out); - out << endl; + out << '\n'; } /** @@ -870,20 +867,20 @@ void t_dart_generator::generate_dart_struct_reader(ostream& out, t_struct* tstru vector::const_iterator f_iter; // Declare stack tmp variables and read struct header - indent(out) << "TField field;" << endl; - indent(out) << "iprot.readStructBegin();" << endl; + indent(out) << "TField field;" << '\n'; + indent(out) << "iprot.readStructBegin();" << '\n'; // Loop over reading in fields indent(out) << "while (true)"; scope_up(out); // Read beginning field marker - indent(out) << "field = iprot.readFieldBegin();" << endl; + indent(out) << "field = iprot.readFieldBegin();" << '\n'; // Check for field STOP marker and break indent(out) << "if (field.type == TType.STOP)"; scope_up(out); - indent(out) << "break;" << endl; + indent(out) << "break;" << '\n'; scope_down(out); // Switch statement on the field we are reading @@ -892,7 +889,7 @@ void t_dart_generator::generate_dart_struct_reader(ostream& out, t_struct* tstru // Generate deserialization code for known cases for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - indent(out) << "case " << upcase_string((*f_iter)->get_name()) << ":" << endl; + indent(out) << "case " << upcase_string((*f_iter)->get_name()) << ":" << '\n'; indent_up(); indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ")"; @@ -903,33 +900,33 @@ void t_dart_generator::generate_dart_struct_reader(ostream& out, t_struct* tstru scope_down(out, " else"); scope_up(out); - indent(out) << "TProtocolUtil.skip(iprot, field.type);" << endl; + indent(out) << "TProtocolUtil.skip(iprot, field.type);" << '\n'; scope_down(out); - indent(out) << "break;" << endl; + indent(out) << "break;" << '\n'; indent_down(); } // In the default case we skip the field - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent_up(); - indent(out) << "TProtocolUtil.skip(iprot, field.type);" << endl; - indent(out) << "break;" << endl; + indent(out) << "TProtocolUtil.skip(iprot, field.type);" << '\n'; + indent(out) << "break;" << '\n'; indent_down(); scope_down(out); // Read field end marker - indent(out) << "iprot.readFieldEnd();" << endl; + indent(out) << "iprot.readFieldEnd();" << '\n'; scope_down(out); - indent(out) << "iprot.readStructEnd();" << endl2; + indent(out) << "iprot.readStructEnd();" << '\n' << '\n'; // in non-beans style, check for required fields of primitive type // (which can be checked here but not in the general validate method) indent(out) << "// check for required fields of primitive type, which can't be " - "checked in the validate method" << endl; + "checked in the validate method" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) { string field_name = get_member_name((*f_iter)->get_name()); @@ -937,15 +934,15 @@ void t_dart_generator::generate_dart_struct_reader(ostream& out, t_struct* tstru scope_up(out); indent(out) << " throw new TProtocolError(TProtocolErrorType.UNKNOWN, \"Required field '" << field_name - << "' was not found in serialized data! Struct: \" + toString());" << endl; - scope_down(out, endl2); + << "' was not found in serialized data! Struct: \" + toString());" << '\n'; + scope_down(out, "\n\n"); } } // performs various checks (e.g. check that all required fields are set) - indent(out) << "validate();" << endl; + indent(out) << "validate();" << '\n'; - scope_down(out, endl2); + scope_down(out, "\n\n"); } // generates dart method to perform various checks @@ -957,7 +954,7 @@ void t_dart_generator::generate_dart_validator(ostream& out, t_struct* tstruct) const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - indent(out) << "// check for required fields" << endl; + indent(out) << "// check for required fields" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { string field_name = get_member_name((*f_iter)->get_name()); @@ -966,17 +963,17 @@ void t_dart_generator::generate_dart_validator(ostream& out, t_struct* tstruct) scope_up(out); indent(out) << "throw new TProtocolError(TProtocolErrorType.UNKNOWN, \"Required field '" << field_name << "' was not present! Struct: \" + toString());" - << endl; + << '\n'; scope_down(out); } else { indent(out) << "// alas, we cannot check '" << field_name - << "' because it's a primitive and you chose the non-beans generator." << endl; + << "' because it's a primitive and you chose the non-beans generator." << '\n'; } } } // check that fields of type enum have valid values - indent(out) << "// check that fields of type enum have valid values" << endl; + indent(out) << "// check that fields of type enum have valid values" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_field* field = (*f_iter); t_type* type = field->get_type(); @@ -988,12 +985,12 @@ void t_dart_generator::generate_dart_validator(ostream& out, t_struct* tstruct) scope_up(out); indent(out) << "throw new TProtocolError(TProtocolErrorType.UNKNOWN, \"The field '" << field_name << "' has been assigned the invalid value " - << "$" << field_name << "\");" << endl; + << "$" << field_name << "\");" << '\n'; scope_down(out); } } - scope_down(out, endl2); + scope_down(out, "\n\n"); } /** @@ -1009,9 +1006,9 @@ void t_dart_generator::generate_dart_struct_writer(ostream& out, t_struct* tstru vector::const_iterator f_iter; // performs various checks (e.g. check that all required fields are set) - indent(out) << "validate();" << endl2; + indent(out) << "validate();" << '\n' << '\n'; - indent(out) << "oprot.writeStructBegin(_STRUCT_DESC);" << endl; + indent(out) << "oprot.writeStructBegin(_STRUCT_DESC);" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { string field_name = get_member_name((*f_iter)->get_name()); @@ -1027,13 +1024,13 @@ void t_dart_generator::generate_dart_struct_writer(ostream& out, t_struct* tstru } indent(out) << "oprot.writeFieldBegin(_" << constant_name((*f_iter)->get_name()) - << "_FIELD_DESC);" << endl; + << "_FIELD_DESC);" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "this."); // Write field closer - indent(out) << "oprot.writeFieldEnd();" << endl; + indent(out) << "oprot.writeFieldEnd();" << '\n'; if (null_allowed) { scope_down(out); @@ -1043,10 +1040,10 @@ void t_dart_generator::generate_dart_struct_writer(ostream& out, t_struct* tstru } } // Write the struct map - indent(out) << "oprot.writeFieldStop();" << endl << indent() << "oprot.writeStructEnd();" - << endl; + indent(out) << "oprot.writeFieldStop();" << '\n' << indent() << "oprot.writeStructEnd();" + << '\n'; - scope_down(out, endl2); + scope_down(out, "\n\n"); } /** @@ -1064,7 +1061,7 @@ void t_dart_generator::generate_dart_struct_result_writer(ostream& out, t_struct const vector& fields = tstruct->get_sorted_members(); vector::const_iterator f_iter; - indent(out) << "oprot.writeStructBegin(_STRUCT_DESC);" << endl2; + indent(out) << "oprot.writeStructBegin(_STRUCT_DESC);" << '\n' << '\n'; bool first = true; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { @@ -1079,23 +1076,23 @@ void t_dart_generator::generate_dart_struct_result_writer(ostream& out, t_struct scope_up(out); indent(out) << "oprot.writeFieldBegin(_" << constant_name((*f_iter)->get_name()) - << "_FIELD_DESC);" << endl; + << "_FIELD_DESC);" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "this."); // Write field closer - indent(out) << "oprot.writeFieldEnd();" << endl; + indent(out) << "oprot.writeFieldEnd();" << '\n'; scope_down(out, ""); } - out << endl; + out << '\n'; // Write the struct map - indent(out) << "oprot.writeFieldStop();" << endl << indent() - << "oprot.writeStructEnd();" << endl; + indent(out) << "oprot.writeFieldStop();" << '\n' << indent() + << "oprot.writeStructEnd();" << '\n'; - scope_down(out, endl2); + scope_down(out, "\n\n"); } void t_dart_generator::generate_generic_field_getters(std::ostream& out, @@ -1113,19 +1110,19 @@ void t_dart_generator::generate_generic_field_getters(std::ostream& out, t_field* field = *f_iter; std::string field_name = get_member_name(field->get_name()); - indent(out) << "case " << upcase_string(field_name) << ":" << endl; + indent(out) << "case " << upcase_string(field_name) << ":" << '\n'; indent_up(); - indent(out) << "return this." << field_name << ";" << endl; + indent(out) << "return this." << field_name << ";" << '\n'; indent_down(); } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent_up(); - indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << endl; + indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << '\n'; indent_down(); scope_down(out); // switch - scope_down(out, endl2); // method + scope_down(out, "\n\n"); // method } void t_dart_generator::generate_generic_field_setters(std::ostream& out, @@ -1145,31 +1142,31 @@ void t_dart_generator::generate_generic_field_setters(std::ostream& out, t_field* field = *f_iter; std::string field_name = get_member_name(field->get_name()); - indent(out) << "case " << upcase_string(field_name) << ":" << endl; + indent(out) << "case " << upcase_string(field_name) << ":" << '\n'; indent_up(); indent(out) << "if (value == null)"; scope_up(out); - indent(out) << "unset" << get_cap_name(field_name) << "();" << endl; + indent(out) << "unset" << get_cap_name(field_name) << "();" << '\n'; scope_down(out, " else"); scope_up(out); - indent(out) << "this." << field_name << " = value;" << endl; + indent(out) << "this." << field_name << " = value;" << '\n'; scope_down(out); - indent(out) << "break;" << endl; + indent(out) << "break;" << '\n'; indent_down(); - out << endl; + out << '\n'; } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent_up(); - indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << endl; + indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << '\n'; indent_down(); scope_down(out); // switch - scope_down(out, endl2); // method + scope_down(out, "\n\n"); // method } // Creates a generic isSet method that takes the field number as argument @@ -1179,7 +1176,7 @@ void t_dart_generator::generate_generic_isset_method(std::ostream& out, t_struct // create the isSet method indent(out) << "// Returns true if field corresponding to fieldID is set (has been assigned a " - "value) and false otherwise" << endl; + "value) and false otherwise" << '\n'; indent(out) << "bool isSet(int fieldID)"; scope_up(out); @@ -1188,19 +1185,19 @@ void t_dart_generator::generate_generic_isset_method(std::ostream& out, t_struct for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_field* field = *f_iter; - indent(out) << "case " << upcase_string(field->get_name()) << ":" << endl; + indent(out) << "case " << upcase_string(field->get_name()) << ":" << '\n'; indent_up(); - indent(out) << "return " << generate_isset_check(field) << ";" << endl; + indent(out) << "return " << generate_isset_check(field) << ";" << '\n'; indent_down(); } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent_up(); - indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << endl; + indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << '\n'; indent_down(); scope_down(out); // switch - scope_down(out, endl2); // method + scope_down(out, "\n\n"); // method } /** @@ -1219,37 +1216,37 @@ void t_dart_generator::generate_dart_bean_boilerplate(ostream& out, std::string field_name = get_member_name(field->get_name()); std::string cap_name = get_cap_name(field_name); - indent(out) << "// " << field_name << endl; + indent(out) << "// " << field_name << '\n'; // Simple getter generate_dart_doc(out, field); - indent(out) << type_name(type) << " get " << field_name << " => this._" << field_name << ";" << endl2; + indent(out) << type_name(type) << " get " << field_name << " => this._" << field_name << ";" << '\n' << '\n'; // Simple setter generate_dart_doc(out, field); indent(out) << "set " << field_name << "(" << type_name(type) << " " << field_name << ")"; scope_up(out); - indent(out) << "this._" << field_name << " = " << field_name << ";" << endl; + indent(out) << "this._" << field_name << " = " << field_name << ";" << '\n'; generate_isset_set(out, field); - scope_down(out, endl2); + scope_down(out, "\n\n"); // isSet method indent(out) << "bool is" << get_cap_name("set") << cap_name << "()"; if (type_can_be_null(type)) { - out << " => this." << field_name << " != null;" << endl2; + out << " => this." << field_name << " != null;" << '\n' << '\n'; } else { - out << " => this.__isset_" << field_name << ";" << endl2; + out << " => this.__isset_" << field_name << ";" << '\n' << '\n'; } // Unsetter indent(out) << "unset" << cap_name << "()"; scope_up(out); if (type_can_be_null(type)) { - indent(out) << "this." << field_name << " = null;" << endl; + indent(out) << "this." << field_name << " = null;" << '\n'; } else { - indent(out) << "this.__isset_" << field_name << " = false;" << endl; + indent(out) << "this.__isset_" << field_name << " = false;" << '\n'; } - scope_down(out, endl2); + scope_down(out, "\n\n"); } } @@ -1264,7 +1261,7 @@ void t_dart_generator::generate_dart_struct_tostring(ostream& out, scope_up(out); indent(out) << "StringBuffer ret = new StringBuffer(\"" - << tstruct->get_name() << "(\");" << endl2; + << tstruct->get_name() << "(\");" << '\n' << '\n'; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -1281,36 +1278,36 @@ void t_dart_generator::generate_dart_struct_tostring(ostream& out, std::string field_name = get_member_name(field->get_name()); if (!first) { - indent(out) << "ret.write(\", \");" << endl; + indent(out) << "ret.write(\", \");" << '\n'; } - indent(out) << "ret.write(\"" << field_name << ":\");" << endl; + indent(out) << "ret.write(\"" << field_name << ":\");" << '\n'; bool can_be_null = type_can_be_null(field->get_type()); if (can_be_null) { indent(out) << "if (this." << field_name << " == null)"; scope_up(out); - indent(out) << "ret.write(\"null\");" << endl; + indent(out) << "ret.write(\"null\");" << '\n'; scope_down(out, " else"); scope_up(out); } if (field->get_type()->is_binary()) { - indent(out) << "ret.write(\"BINARY\");" << endl; + indent(out) << "ret.write(\"BINARY\");" << '\n'; } else if (field->get_type()->is_enum()) { indent(out) << "String " << field_name << "_name = " << get_ttype_class_name(field->get_type()) - << ".VALUES_TO_NAMES[this." << field_name << "];" << endl; + << ".VALUES_TO_NAMES[this." << field_name << "];" << '\n'; indent(out) << "if (" << field_name << "_name != null)"; scope_up(out); - indent(out) << "ret.write(" << field_name << "_name);" << endl; - indent(out) << "ret.write(\" (\");" << endl; + indent(out) << "ret.write(" << field_name << "_name);" << '\n'; + indent(out) << "ret.write(\" (\");" << '\n'; scope_down(out); - indent(out) << "ret.write(this." << field_name << ");" << endl; + indent(out) << "ret.write(this." << field_name << ");" << '\n'; indent(out) << "if (" << field_name << "_name != null)"; scope_up(out); - indent(out) << "ret.write(\")\");" << endl; + indent(out) << "ret.write(\")\");" << '\n'; scope_down(out); } else { - indent(out) << "ret.write(this." << field_name << ");" << endl; + indent(out) << "ret.write(this." << field_name << ");" << '\n'; } if (can_be_null) { @@ -1320,15 +1317,15 @@ void t_dart_generator::generate_dart_struct_tostring(ostream& out, scope_down(out); } - out << endl; + out << '\n'; first = false; } - indent(out) << "ret.write(\")\");" << endl2; + indent(out) << "ret.write(\")\");" << '\n' << '\n'; - indent(out) << "return ret.toString();" << endl; + indent(out) << "return ret.toString();" << '\n'; - scope_down(out, endl2); + scope_down(out, "\n\n"); } /** @@ -1391,9 +1388,9 @@ void t_dart_generator::generate_service(t_service* tservice) { string f_service_name = src_dir_ + "/" + file_name + ".dart"; f_service_.open(f_service_name.c_str()); - f_service_ << autogen_comment() << dart_library(file_name) << endl; - f_service_ << service_imports() << dart_thrift_imports() << endl; - f_service_ << endl; + f_service_ << autogen_comment() << dart_library(file_name) << '\n'; + f_service_ << service_imports() << dart_thrift_imports() << '\n'; + f_service_ << '\n'; generate_service_interface(tservice); generate_service_client(tservice); @@ -1424,12 +1421,12 @@ void t_dart_generator::generate_service_interface(t_service* tservice) { vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - f_service_ << endl; + f_service_ << '\n'; generate_dart_doc(f_service_, *f_iter); - indent(f_service_) << function_signature(*f_iter) << ";" << endl; + indent(f_service_) << function_signature(*f_iter) << ";" << '\n'; } - scope_down(f_service_, endl2); + scope_down(f_service_, "\n\n"); } /** @@ -1465,31 +1462,31 @@ void t_dart_generator::generate_service_client(t_service* tservice) { indent(f_service_) << "class " << class_name << extends_client << " implements " << service_name_; scope_up(f_service_); - f_service_ << endl; + f_service_ << '\n'; indent(f_service_) << class_name << "(TProtocol iprot, [TProtocol oprot = null])"; if (!extends.empty()) { indent_up(); - f_service_ << endl; - indent(f_service_) << ": super(iprot, oprot);" << endl; + f_service_ << '\n'; + indent(f_service_) << ": super(iprot, oprot);" << '\n'; indent_down(); } else { scope_up(f_service_); - indent(f_service_) << "_iprot = iprot;" << endl; - indent(f_service_) << "_oprot = (oprot == null) ? iprot : oprot;" << endl; + indent(f_service_) << "_iprot = iprot;" << '\n'; + indent(f_service_) << "_oprot = (oprot == null) ? iprot : oprot;" << '\n'; scope_down(f_service_); } - f_service_ << endl; + f_service_ << '\n'; if (extends.empty()) { - indent(f_service_) << "TProtocol _iprot;" << endl2; - indent(f_service_) << "TProtocol get iprot => _iprot;" << endl2; - indent(f_service_) << "TProtocol _oprot;" << endl2; - indent(f_service_) << "TProtocol get oprot => _oprot;" << endl2; - indent(f_service_) << "int _seqid = 0;" << endl2; - indent(f_service_) << "int get seqid => _seqid;" << endl2; - indent(f_service_) << "int nextSeqid() => ++_seqid;" << endl2; + indent(f_service_) << "TProtocol _iprot;" << '\n' << '\n'; + indent(f_service_) << "TProtocol get iprot => _iprot;" << '\n' << '\n'; + indent(f_service_) << "TProtocol _oprot;" << '\n' << '\n'; + indent(f_service_) << "TProtocol get oprot => _oprot;" << '\n' << '\n'; + indent(f_service_) << "int _seqid = 0;" << '\n' << '\n'; + indent(f_service_) << "int get seqid => _seqid;" << '\n' << '\n'; + indent(f_service_) << "int nextSeqid() => ++_seqid;" << '\n' << '\n'; } // Generate client method implementations @@ -1510,40 +1507,40 @@ void t_dart_generator::generate_service_client(t_service* tservice) { // Serialize the request indent(f_service_) << "oprot.writeMessageBegin(new TMessage(\"" << (*f_iter)->get_name() << "\", " << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL") - << ", nextSeqid()));" << endl; - indent(f_service_) << argsname << " args = new " << argsname << "();" << endl; + << ", nextSeqid()));" << '\n'; + indent(f_service_) << argsname << " args = new " << argsname << "();" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { string arg_field_name = get_member_name((*fld_iter)->get_name()); indent(f_service_) << "args." << arg_field_name << " = " - << arg_field_name << ";" << endl; + << arg_field_name << ";" << '\n'; } - indent(f_service_) << "args.write(oprot);" << endl; - indent(f_service_) << "oprot.writeMessageEnd();" << endl2; + indent(f_service_) << "args.write(oprot);" << '\n'; + indent(f_service_) << "oprot.writeMessageEnd();" << '\n' << '\n'; - indent(f_service_) << "await oprot.transport.flush();" << endl2; + indent(f_service_) << "await oprot.transport.flush();" << '\n' << '\n'; if (!(*f_iter)->is_oneway()) { - indent(f_service_) << "TMessage msg = iprot.readMessageBegin();" << endl; + indent(f_service_) << "TMessage msg = iprot.readMessageBegin();" << '\n'; indent(f_service_) << "if (msg.type == TMessageType.EXCEPTION)"; scope_up(f_service_); - indent(f_service_) << "TApplicationError error = TApplicationError.read(iprot);" << endl; - indent(f_service_) << "iprot.readMessageEnd();" << endl; - indent(f_service_) << "throw error;" << endl; - scope_down(f_service_, endl2); + indent(f_service_) << "TApplicationError error = TApplicationError.read(iprot);" << '\n'; + indent(f_service_) << "iprot.readMessageEnd();" << '\n'; + indent(f_service_) << "throw error;" << '\n'; + scope_down(f_service_, "\n\n"); string result_class = get_result_class_name((*f_iter)->get_name()); - indent(f_service_) << result_class << " result = new " << result_class << "();" << endl; - indent(f_service_) << "result.read(iprot);" << endl; - indent(f_service_) << "iprot.readMessageEnd();" << endl; + indent(f_service_) << result_class << " result = new " << result_class << "();" << '\n'; + indent(f_service_) << "result.read(iprot);" << '\n'; + indent(f_service_) << "iprot.readMessageEnd();" << '\n'; // Careful, only return _result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { indent(f_service_) << "if (result." << generate_isset_check("success") << ")"; scope_up(f_service_); - indent(f_service_) << "return result.success;" << endl; - scope_down(f_service_, endl2); + indent(f_service_) << "return result.success;" << '\n'; + scope_down(f_service_, "\n\n"); } t_struct* xs = (*f_iter)->get_xceptions(); @@ -1553,23 +1550,23 @@ void t_dart_generator::generate_service_client(t_service* tservice) { string result_field_name = get_member_name((*x_iter)->get_name()); indent(f_service_) << "if (result." << result_field_name << " != null)"; scope_up(f_service_); - indent(f_service_) << "throw result." << result_field_name << ";" << endl; + indent(f_service_) << "throw result." << result_field_name << ";" << '\n'; scope_down(f_service_); } // If you get here it's an exception, unless a void function if ((*f_iter)->get_returntype()->is_void()) { - indent(f_service_) << "return;" << endl; + indent(f_service_) << "return;" << '\n'; } else { indent(f_service_) << "throw new TApplicationError(TApplicationErrorType.MISSING_RESULT, \"" - << (*f_iter)->get_name() << " failed: unknown result\");" << endl; + << (*f_iter)->get_name() << " failed: unknown result\");" << '\n'; } } - scope_down(f_service_, endl2); + scope_down(f_service_, "\n\n"); } - scope_down(f_service_, endl2); + scope_down(f_service_, "\n\n"); } /** @@ -1583,7 +1580,7 @@ void t_dart_generator::generate_service_server(t_service* tservice) { vector::iterator f_iter; // typedef - indent(f_service_) << "typedef void ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot);" << endl2; + indent(f_service_) << "typedef void ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot);" << '\n' << '\n'; // Extends stuff string extends = ""; @@ -1602,57 +1599,57 @@ void t_dart_generator::generate_service_server(t_service* tservice) { indent(f_service_) << class_name << "(" << service_name_ << " iface)"; if (!extends.empty()) { indent_up(); - f_service_ << endl; + f_service_ << '\n'; indent(f_service_) << ": super(iface)"; indent_down(); } scope_up(f_service_); if (extends.empty()) { - indent(f_service_) << "iface_ = iface;" << endl; + indent(f_service_) << "iface_ = iface;" << '\n'; } for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { indent(f_service_) << "PROCESS_MAP[\"" << (*f_iter)->get_name() - << "\"] = " << get_member_name((*f_iter)->get_name()) << ";" << endl; + << "\"] = " << get_member_name((*f_iter)->get_name()) << ";" << '\n'; } - scope_down(f_service_, endl2); + scope_down(f_service_, "\n\n"); - indent(f_service_) << service_name_ << " iface_;" << endl; + indent(f_service_) << service_name_ << " iface_;" << '\n'; if (extends.empty()) { - indent(f_service_) << "final Map PROCESS_MAP = {};" << endl; + indent(f_service_) << "final Map PROCESS_MAP = {};" << '\n'; } - f_service_ << endl; + f_service_ << '\n'; // Generate the server implementation indent(f_service_) << "bool process(TProtocol iprot, TProtocol oprot)"; scope_up(f_service_); - indent(f_service_) << "TMessage msg = iprot.readMessageBegin();" << endl; - indent(f_service_) << "ProcessFunction fn = PROCESS_MAP[msg.name];" << endl; + indent(f_service_) << "TMessage msg = iprot.readMessageBegin();" << '\n'; + indent(f_service_) << "ProcessFunction fn = PROCESS_MAP[msg.name];" << '\n'; indent(f_service_) << "if (fn == null)"; scope_up(f_service_); - indent(f_service_) << "TProtocolUtil.skip(iprot, TType.STRUCT);" << endl; - indent(f_service_) << "iprot.readMessageEnd();" << endl; + indent(f_service_) << "TProtocolUtil.skip(iprot, TType.STRUCT);" << '\n'; + indent(f_service_) << "iprot.readMessageEnd();" << '\n'; indent(f_service_) << "TApplicationError x = new TApplicationError(TApplicationErrorType.UNKNOWN_METHOD, " - "\"Invalid method name: '\"+msg.name+\"'\");" << endl; - indent(f_service_) << "oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << endl; - indent(f_service_) << "x.write(oprot);" << endl; - indent(f_service_) << "oprot.writeMessageEnd();" << endl; - indent(f_service_) << "oprot.transport.flush();" << endl; - indent(f_service_) << "return true;" << endl; + "\"Invalid method name: '\"+msg.name+\"'\");" << '\n'; + indent(f_service_) << "oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << '\n'; + indent(f_service_) << "x.write(oprot);" << '\n'; + indent(f_service_) << "oprot.writeMessageEnd();" << '\n'; + indent(f_service_) << "oprot.transport.flush();" << '\n'; + indent(f_service_) << "return true;" << '\n'; scope_down(f_service_); - indent(f_service_) << "fn(msg.seqid, iprot, oprot);" << endl; - indent(f_service_) << "return true;" << endl; - scope_down(f_service_, endl2); // process function + indent(f_service_) << "fn(msg.seqid, iprot, oprot);" << '\n'; + indent(f_service_) << "return true;" << '\n'; + scope_down(f_service_, "\n\n"); // process function // Generate the process subfunctions for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_process_function(tservice, *f_iter); } - scope_down(f_service_, endl2); // class + scope_down(f_service_, "\n\n"); // class } /** @@ -1700,16 +1697,16 @@ void t_dart_generator::generate_process_function(t_service* tservice, t_function string argsname = get_args_class_name(tfunction->get_name()); string resultname = get_result_class_name(tfunction->get_name()); - indent(f_service_) << argsname << " args = new " << argsname << "();" << endl; - indent(f_service_) << "args.read(iprot);" << endl; - indent(f_service_) << "iprot.readMessageEnd();" << endl; + indent(f_service_) << argsname << " args = new " << argsname << "();" << '\n'; + indent(f_service_) << "args.read(iprot);" << '\n'; + indent(f_service_) << "iprot.readMessageEnd();" << '\n'; t_struct* xs = tfunction->get_xceptions(); const std::vector& xceptions = xs->get_members(); vector::const_iterator x_iter; if (!tfunction->is_oneway()) { - indent(f_service_) << resultname << " result = new " << resultname << "();" << endl; + indent(f_service_) << resultname << " result = new " << resultname << "();" << '\n'; } if (!tfunction->is_oneway() && xceptions.size() > 0) { @@ -1736,7 +1733,7 @@ void t_dart_generator::generate_process_function(t_service* tservice, t_function } f_service_ << "args." << get_member_name((*f_iter)->get_name()); } - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; if (!tfunction->is_oneway() && xceptions.size() > 0) { for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { @@ -1747,36 +1744,36 @@ void t_dart_generator::generate_process_function(t_service* tservice, t_function scope_up(f_service_); if (!tfunction->is_oneway()) { indent(f_service_) << "result." << result_field_name << " = " - << result_field_name << ";" << endl; + << result_field_name << ";" << '\n'; } } scope_down(f_service_, " "); f_service_ << "catch (th)"; scope_up(f_service_); - indent(f_service_) << "// Internal error" << endl; + indent(f_service_) << "// Internal error" << '\n'; indent(f_service_) << "TApplicationError x = new " "TApplicationError(TApplicationErrorType.INTERNAL_ERROR, \"Internal error processing " - << tfunction->get_name() << "\");" << endl; + << tfunction->get_name() << "\");" << '\n'; indent(f_service_) << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() - << "\", TMessageType.EXCEPTION, seqid));" << endl; - indent(f_service_) << "x.write(oprot);" << endl; - indent(f_service_) << "oprot.writeMessageEnd();" << endl; - indent(f_service_) << "oprot.transport.flush();" << endl; - indent(f_service_) << "return;" << endl; + << "\", TMessageType.EXCEPTION, seqid));" << '\n'; + indent(f_service_) << "x.write(oprot);" << '\n'; + indent(f_service_) << "oprot.writeMessageEnd();" << '\n'; + indent(f_service_) << "oprot.transport.flush();" << '\n'; + indent(f_service_) << "return;" << '\n'; scope_down(f_service_); } if (tfunction->is_oneway()) { - indent(f_service_) << "return;" << endl; + indent(f_service_) << "return;" << '\n'; } else { indent(f_service_) << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() - << "\", TMessageType.REPLY, seqid));" << endl; - indent(f_service_) << "result.write(oprot);" << endl; - indent(f_service_) << "oprot.writeMessageEnd();" << endl; - indent(f_service_) << "oprot.transport.flush();" << endl; + << "\", TMessageType.REPLY, seqid));" << '\n'; + indent(f_service_) << "result.write(oprot);" << '\n'; + indent(f_service_) << "oprot.writeMessageEnd();" << '\n'; + indent(f_service_) << "oprot.transport.flush();" << '\n'; } - scope_down(f_service_, endl2); + scope_down(f_service_, "\n\n"); } /** @@ -1840,7 +1837,7 @@ void t_dart_generator::generate_deserialize_field(ostream& out, t_field* tfield, } else if (type->is_enum()) { out << "readI32();"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", field_name.c_str(), @@ -1852,8 +1849,8 @@ void t_dart_generator::generate_deserialize_field(ostream& out, t_field* tfield, * Generates an unserializer for a struct, invokes read() */ void t_dart_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) { - indent(out) << prefix << " = new " << type_name(tstruct) << "();" << endl; - indent(out) << prefix << ".read(iprot);" << endl; + indent(out) << prefix << " = new " << type_name(tstruct) << "();" << '\n'; + indent(out) << prefix << ".read(iprot);" << '\n'; } /** @@ -1875,14 +1872,14 @@ void t_dart_generator::generate_deserialize_container(ostream& out, t_type* ttyp // Declare variables, read header if (ttype->is_map()) { - indent(out) << "TMap " << obj << " = iprot.readMapBegin();" << endl; + indent(out) << "TMap " << obj << " = iprot.readMapBegin();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "TSet " << obj << " = iprot.readSetBegin();" << endl; + indent(out) << "TSet " << obj << " = iprot.readSetBegin();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "TList " << obj << " = iprot.readListBegin();" << endl; + indent(out) << "TList " << obj << " = iprot.readListBegin();" << '\n'; } - indent(out) << prefix << " = new " << type_name(ttype) << "();" << endl; + indent(out) << prefix << " = new " << type_name(ttype) << "();" << '\n'; // For loop iterates over elements string i = tmp("_i"); @@ -1903,11 +1900,11 @@ void t_dart_generator::generate_deserialize_container(ostream& out, t_type* ttyp // Read container end if (ttype->is_map()) { - indent(out) << "iprot.readMapEnd();" << endl; + indent(out) << "iprot.readMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "iprot.readSetEnd();" << endl; + indent(out) << "iprot.readSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "iprot.readListEnd();" << endl; + indent(out) << "iprot.readListEnd();" << '\n'; } scope_down(out); @@ -1922,13 +1919,13 @@ void t_dart_generator::generate_deserialize_map_element(ostream& out, t_map* tma t_field fkey(tmap->get_key_type(), key); t_field fval(tmap->get_val_type(), val); - indent(out) << declare_field(&fkey) << endl; - indent(out) << declare_field(&fval) << endl; + indent(out) << declare_field(&fkey) << '\n'; + indent(out) << declare_field(&fval) << '\n'; generate_deserialize_field(out, &fkey); generate_deserialize_field(out, &fval); - indent(out) << prefix << "[" << key << "] = " << val << ";" << endl; + indent(out) << prefix << "[" << key << "] = " << val << ";" << '\n'; } /** @@ -1938,11 +1935,11 @@ void t_dart_generator::generate_deserialize_set_element(ostream& out, t_set* tse string elem = tmp("_elem"); t_field felem(tset->get_elem_type(), elem); - indent(out) << declare_field(&felem) << endl; + indent(out) << declare_field(&felem) << '\n'; generate_deserialize_field(out, &felem); - indent(out) << prefix << ".add(" << elem << ");" << endl; + indent(out) << prefix << ".add(" << elem << ");" << '\n'; } /** @@ -1954,11 +1951,11 @@ void t_dart_generator::generate_deserialize_list_element(ostream& out, string elem = tmp("_elem"); t_field felem(tlist->get_elem_type(), elem); - indent(out) << declare_field(&felem) << endl; + indent(out) << declare_field(&felem) << '\n'; generate_deserialize_field(out, &felem); - indent(out) << prefix << ".add(" << elem << ");" << endl; + indent(out) << prefix << ".add(" << elem << ");" << '\n'; } /** @@ -2022,7 +2019,7 @@ void t_dart_generator::generate_serialize_field(ostream& out, t_field* tfield, s } else if (type->is_enum()) { out << "writeI32(" << name << ");"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n", prefix.c_str(), @@ -2039,7 +2036,7 @@ void t_dart_generator::generate_serialize_field(ostream& out, t_field* tfield, s */ void t_dart_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - indent(out) << prefix << ".write(oprot);" << endl; + indent(out) << prefix << ".write(oprot);" << '\n'; } /** @@ -2056,14 +2053,14 @@ void t_dart_generator::generate_serialize_container(ostream& out, t_type* ttype, string iter = tmp("_key"); indent(out) << "oprot.writeMapBegin(new TMap(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << prefix << ".length));" - << endl; + << '\n'; } else if (ttype->is_set()) { indent(out) << "oprot.writeSetBegin(new TSet(" << type_to_enum(((t_set*)ttype)->get_elem_type()) - << ", " << prefix << ".length));" << endl; + << ", " << prefix << ".length));" << '\n'; } else if (ttype->is_list()) { indent(out) << "oprot.writeListBegin(new TList(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix << ".length));" - << endl; + << '\n'; } string iter = tmp("elem"); @@ -2086,11 +2083,11 @@ void t_dart_generator::generate_serialize_container(ostream& out, t_type* ttype, scope_down(out); if (ttype->is_map()) { - indent(out) << "oprot.writeMapEnd();" << endl; + indent(out) << "oprot.writeMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "oprot.writeSetEnd();" << endl; + indent(out) << "oprot.writeSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "oprot.writeListEnd();" << endl; + indent(out) << "oprot.writeListEnd();" << '\n'; } scope_down(out); @@ -2496,7 +2493,7 @@ std::string t_dart_generator::generate_isset_check(std::string field_name) { void t_dart_generator::generate_isset_set(ostream& out, t_field* field) { if (!type_can_be_null(field->get_type())) { string field_name = get_member_name(field->get_name()); - indent(out) << "this.__isset_" << field_name << " = true;" << endl; + indent(out) << "this.__isset_" << field_name << " = true;" << '\n'; } } diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc index c5998365664..d5e8d5d2229 100644 --- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc @@ -53,8 +53,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - class t_delphi_generator : public t_oop_generator { public: t_delphi_generator(t_program* program, @@ -409,12 +407,12 @@ class t_delphi_generator : public t_oop_generator { const std::string DELPHI_KEYWORDS[81] = { // keywords - "and", "array", "as", "asm", "at", "automated", "begin", "case", "class", "const", "constructor", - "destructor", "dispinterface", "div", "do", "downto", "else", "end", "except", "exports", "file", - "finalization", "finally", "for", "function", "goto", "if", "implementation", "in", "inherited", - "initialization", "inline", "interface", "is", "label", "library", "mod", "nil", "not", "object", - "of", "on", "or", "out", "packed", "private", "procedure", "program", "property", "protected", - "public", "published", "raise", "record", "repeat", "resourcestring", "set", "shl", "shr", "string", + "and", "array", "as", "asm", "at", "automated", "begin", "case", "class", "const", "constructor", + "destructor", "dispinterface", "div", "do", "downto", "else", "end", "except", "exports", "file", + "finalization", "finally", "for", "function", "goto", "if", "implementation", "in", "inherited", + "initialization", "inline", "interface", "is", "label", "library", "mod", "nil", "not", "object", + "of", "on", "or", "out", "packed", "private", "procedure", "program", "property", "protected", + "public", "published", "raise", "record", "repeat", "resourcestring", "set", "shl", "shr", "string", "then", "threadvar", "to", "try", "type", "unit", "until", "uses", "var", "while", "with", "xor", // predefined types (lowercase!) "ansistring", "boolean", "double", "int64", "integer", "shortint", "smallint", "string", "unicodestring" @@ -427,19 +425,19 @@ class t_delphi_generator : public t_oop_generator { // reserved method names (lowercase!) const std::string DELPHI_RESERVED_METHOD[31] = { - "afterconstruction", "beforedestruction", "classinfo", "classname", "classnameis", "classparent", - "classtype", "cleanupinstance", "create", "defaulthandler", "destroy", "dispatch", "equals", - "fieldaddress", "free", "freeinstance", "gethashcode", "getinterface", "getinterfaceentry", - "getinterfacetable", "inheritsfrom", "initinstance", "instancesize", "methodaddress", "methodname", + "afterconstruction", "beforedestruction", "classinfo", "classname", "classnameis", "classparent", + "classtype", "cleanupinstance", "create", "defaulthandler", "destroy", "dispatch", "equals", + "fieldaddress", "free", "freeinstance", "gethashcode", "getinterface", "getinterfaceentry", + "getinterfacetable", "inheritsfrom", "initinstance", "instancesize", "methodaddress", "methodname", "newinstance", "read", "safecallexception", "tostring", "unitname", "write" }; // reserved exception class method names (lowercase!) const std::string DELPHI_RESERVED_METHOD_EXCEPTION[23] = { - "setinnerexception", "setstackinfo", "getstacktrace", "raisingexception", "createfmt", "createres", - "createresfmt", "createhelp", "createfmthelp", "createreshelp", "createresfmthelp", "getbaseexception", - "baseexception", "helpcontext", "innerexception", "message", "stacktrace", "stackinfo", - "getexceptionstackinfoproc", "getstackinfostringproc", "cleanupstackinfoproc", "raiseouterexception", + "setinnerexception", "setstackinfo", "getstacktrace", "raisingexception", "createfmt", "createres", + "createresfmt", "createhelp", "createfmthelp", "createreshelp", "createresfmthelp", "getbaseexception", + "baseexception", "helpcontext", "innerexception", "message", "stacktrace", "stackinfo", + "getexceptionstackinfoproc", "getstackinfostringproc", "cleanupstackinfoproc", "raiseouterexception", "throwouterexception" }; @@ -628,10 +626,10 @@ std::string t_delphi_generator::normalize_name(std::string name, } // neither reserved nor keyword? - if (!(b_reserved || b_keyword)) { + if (!(b_reserved || b_keyword)) { return name; } - + // apply the rule: old style '_' postfix or more modern '&' prefix? // underscore always on non-keywords or when explicitly asked via arg if( (!b_keyword) || old_names_ || b_force_underscore) { @@ -707,25 +705,25 @@ void t_delphi_generator::close_generator() { } unitname = normalize_name(unitname,false,false,true/*force underscore*/); - + std::string f_name = get_out_dir() + "/" + unitname + ".pas"; ofstream_with_content_based_conditional_update f_all; f_all.open(f_name); - f_all << autogen_comment() << endl; + f_all << autogen_comment() << '\n'; generate_delphi_doc(f_all, program_); - f_all << "unit " << unitname << ";" << endl << endl; - f_all << "{$WARN SYMBOL_DEPRECATED OFF}" << endl; + f_all << "unit " << unitname << ";" << '\n' << '\n'; + f_all << "{$WARN SYMBOL_DEPRECATED OFF}" << '\n'; if(com_types_) { - f_all << "{$MINENUMSIZE 4}" << endl; + f_all << "{$MINENUMSIZE 4}" << '\n'; } if(rtti_) { - f_all << "{$IFOPT M+} {$DEFINE TYPEINFO_WAS_ON} {$ELSE} {$UNDEF TYPEINFO_WAS_ON} {$ENDIF}" << endl; + f_all << "{$IFOPT M+} {$DEFINE TYPEINFO_WAS_ON} {$ELSE} {$UNDEF TYPEINFO_WAS_ON} {$ENDIF}" << '\n'; } - f_all << endl; - f_all << "interface" << endl << endl; - f_all << "uses" << endl; + f_all << '\n'; + f_all << "interface" << '\n' << '\n'; + f_all << "uses" << '\n'; indent_up(); @@ -733,12 +731,12 @@ void t_delphi_generator::close_generator() { for (s_iter = uses_list.begin(); s_iter != uses_list.end(); ++s_iter) { if (s_iter != uses_list.begin()) { f_all << ","; - f_all << endl; + f_all << '\n'; } indent(f_all) << *s_iter; } - f_all << ";" << endl << endl; + f_all << ";" << '\n' << '\n'; indent_down(); @@ -749,70 +747,70 @@ void t_delphi_generator::close_generator() { } } - f_all << "const" << endl; + f_all << "const" << '\n'; indent_up(); - indent(f_all) << "c" << tmp_unit << "_Option_Register_Types = " << (register_types_ ? "True" : "False") << ";" << endl; - indent(f_all) << "c" << tmp_unit << "_Option_ConstPrefix = " << (constprefix_ ? "True" : "False") << ";" << endl; - indent(f_all) << "c" << tmp_unit << "_Option_Events = " << (events_ ? "True" : "False") << ";" << endl; - indent(f_all) << "c" << tmp_unit << "_Option_XmlDoc = " << (xmldoc_ ? "True" : "False") << ";" << endl; - indent(f_all) << "c" << tmp_unit << "_Option_Async = " << (async_ ? "True" : "False") << ";" << endl; - indent(f_all) << "c" << tmp_unit << "_Option_COM_types = " << (com_types_ ? "True" : "False") << ";" << endl; - indent(f_all) << "c" << tmp_unit << "_Option_Old_Names = " << (old_names_ ? "True" : "False") << ";" << endl; - indent(f_all) << "c" << tmp_unit << "_Option_RTTI = " << (rtti_ ? "True" : "False") << ";" << endl; + indent(f_all) << "c" << tmp_unit << "_Option_Register_Types = " << (register_types_ ? "True" : "False") << ";" << '\n'; + indent(f_all) << "c" << tmp_unit << "_Option_ConstPrefix = " << (constprefix_ ? "True" : "False") << ";" << '\n'; + indent(f_all) << "c" << tmp_unit << "_Option_Events = " << (events_ ? "True" : "False") << ";" << '\n'; + indent(f_all) << "c" << tmp_unit << "_Option_XmlDoc = " << (xmldoc_ ? "True" : "False") << ";" << '\n'; + indent(f_all) << "c" << tmp_unit << "_Option_Async = " << (async_ ? "True" : "False") << ";" << '\n'; + indent(f_all) << "c" << tmp_unit << "_Option_COM_types = " << (com_types_ ? "True" : "False") << ";" << '\n'; + indent(f_all) << "c" << tmp_unit << "_Option_Old_Names = " << (old_names_ ? "True" : "False") << ";" << '\n'; + indent(f_all) << "c" << tmp_unit << "_Option_RTTI = " << (rtti_ ? "True" : "False") << ";" << '\n'; indent_down(); - f_all << endl; - f_all << "type" << endl; + f_all << '\n'; + f_all << "type" << '\n'; if (has_forward) { - f_all << s_forward_decr.str() << endl; + f_all << s_forward_decr.str() << '\n'; } if (has_enum) { - indent(f_all) << endl; - indent(f_all) << "{$SCOPEDENUMS ON}" << endl << endl; + indent(f_all) << '\n'; + indent(f_all) << "{$SCOPEDENUMS ON}" << '\n' << '\n'; f_all << s_enum.str(); - indent(f_all) << "{$SCOPEDENUMS OFF}" << endl << endl; + indent(f_all) << "{$SCOPEDENUMS OFF}" << '\n' << '\n'; } f_all << s_struct.str(); f_all << s_service.str(); f_all << s_const.str(); - f_all << "implementation" << endl << endl; + f_all << "implementation" << '\n' << '\n'; f_all << s_struct_impl.str(); f_all << s_service_impl.str(); f_all << s_const_impl.str(); if (register_types_) { - f_all << endl; - f_all << "// Type factory methods and registration" << endl; + f_all << '\n'; + f_all << "// Type factory methods and registration" << '\n'; f_all << s_type_factory_funcs.str(); - f_all << "procedure RegisterTypeFactories;" << endl; - f_all << "begin" << endl; + f_all << "procedure RegisterTypeFactories;" << '\n'; + f_all << "begin" << '\n'; f_all << s_type_factory_registration.str(); - f_all << "end;" << endl; + f_all << "end;" << '\n'; } - f_all << endl; + f_all << '\n'; string constants_class = make_constants_classname(); - f_all << "initialization" << endl; + f_all << "initialization" << '\n'; if (has_const) { - f_all << "{$IF CompilerVersion < 21.0} // D2010" << endl; - f_all << " " << constants_class.c_str() << "_Initialize;" << endl; - f_all << "{$IFEND}" << endl; + f_all << "{$IF CompilerVersion < 21.0} // D2010" << '\n'; + f_all << " " << constants_class.c_str() << "_Initialize;" << '\n'; + f_all << "{$IFEND}" << '\n'; } if (register_types_) { - f_all << " RegisterTypeFactories;" << endl; + f_all << " RegisterTypeFactories;" << '\n'; } - f_all << endl; + f_all << '\n'; - f_all << "finalization" << endl; + f_all << "finalization" << '\n'; if (has_const) { - f_all << "{$IF CompilerVersion < 21.0} // D2010" << endl; - f_all << " " << constants_class.c_str() << "_Finalize;" << endl; - f_all << "{$IFEND}" << endl; + f_all << "{$IF CompilerVersion < 21.0} // D2010" << '\n'; + f_all << " " << constants_class.c_str() << "_Finalize;" << '\n'; + f_all << "{$IFEND}" << '\n'; } - f_all << endl << endl; + f_all << '\n' << '\n'; - f_all << "end." << endl; + f_all << "end." << '\n'; f_all.close(); if (!typedefs_pending.empty()) { @@ -828,8 +826,8 @@ void t_delphi_generator::close_generator() { void t_delphi_generator::delphi_type_usings(ostream& out) { indent_up(); indent(out) << "Classes, SysUtils, Generics.Collections, Thrift.Collections, Thrift.Protocol," - << endl; - indent(out) << "Thrift.Transport;" << endl << endl; + << '\n'; + indent(out) << "Thrift.Transport;" << '\n' << '\n'; indent_down(); } @@ -842,7 +840,7 @@ void t_delphi_generator::generate_forward_declaration(t_struct* tstruct) { indent_up(); indent(s_forward_decr) << type_name(tstruct, tstruct->is_xception(), true) << " = " << what << ";" - << endl; + << '\n'; indent_down(); add_defined_type(tstruct); @@ -867,7 +865,7 @@ void t_delphi_generator::generate_typedef(t_typedef* ttypedef) { // if( ! container) // s_struct << "type "; //the "type A = type B" syntax leads to E2574 with generics - s_struct << type_name(ttypedef->get_type()) << ";" << endl << endl; + s_struct << type_name(ttypedef->get_type()) << ";" << '\n' << '\n'; indent_down(); add_defined_type(ttypedef); @@ -948,7 +946,7 @@ void t_delphi_generator::generate_enum(t_enum* tenum) { indent_up(); generate_delphi_doc(s_enum, tenum); indent(s_enum) << type_name(tenum, true, true) << " = " - << "(" << endl; + << "(" << '\n'; indent_up(); vector constants = tenum->get_constants(); if (constants.empty()) { @@ -959,15 +957,15 @@ void t_delphi_generator::generate_enum(t_enum* tenum) { int value = (*c_iter)->get_value(); if (c_iter != constants.begin()) { s_enum << ","; - s_enum << endl; + s_enum << '\n'; } generate_delphi_doc(s_enum, *c_iter); indent(s_enum) << normalize_name((*c_iter)->get_name()) << " = " << value; } } - s_enum << endl; + s_enum << '\n'; indent_down(); - indent(s_enum) << ");" << endl << endl; + indent(s_enum) << ");" << '\n' << '\n'; indent_down(); } @@ -981,7 +979,7 @@ std::string t_delphi_generator::make_pascal_string_literal(std::string value) { result << "'"; for (signed char const c: value) { if( (c >= 0) && (c < 32)) { // convert ctrl chars, but leave UTF-8 alone - result << "#" << (int)c; + result << "#" << (int)c; } else if (c == '\'') { result << "''"; // duplicate any single quotes we find } else { @@ -989,7 +987,7 @@ std::string t_delphi_generator::make_pascal_string_literal(std::string value) { } } result << "'"; - + return result.str(); } @@ -1037,8 +1035,8 @@ void t_delphi_generator::generate_consts(std::vector consts) { string constants_class = make_constants_classname(); indent_up(); - indent(s_const) << constants_class.c_str() << " = class" << endl; - indent(s_const) << "private" << endl; + indent(s_const) << constants_class.c_str() << " = class" << '\n'; + indent(s_const) << "private" << '\n'; indent_up(); vector::iterator c_iter; for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { @@ -1050,7 +1048,7 @@ void t_delphi_generator::generate_consts(std::vector consts) { } } indent_down(); - indent(s_const) << "public" << endl; + indent(s_const) << "public" << '\n'; indent_up(); for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { generate_delphi_doc(s_const, *c_iter); @@ -1059,12 +1057,12 @@ void t_delphi_generator::generate_consts(std::vector consts) { (*c_iter)->get_type(), (*c_iter)->get_value()); } - indent(s_const) << "{$IF CompilerVersion >= 21.0}" << endl; - indent(s_const) << "class constructor Create;" << endl; - indent(s_const) << "class destructor Destroy;" << endl; - indent(s_const) << "{$IFEND}" << endl; + indent(s_const) << "{$IF CompilerVersion >= 21.0}" << '\n'; + indent(s_const) << "class constructor Create;" << '\n'; + indent(s_const) << "class destructor Destroy;" << '\n'; + indent(s_const) << "{$IFEND}" << '\n'; indent_down(); - indent(s_const) << "end;" << endl << endl; + indent(s_const) << "end;" << '\n' << '\n'; indent_down(); std::ostringstream vars, code; @@ -1079,22 +1077,22 @@ void t_delphi_generator::generate_consts(std::vector consts) { } indent_down_impl(); - indent_impl(s_const_impl) << "{$IF CompilerVersion >= 21.0}" << endl; + indent_impl(s_const_impl) << "{$IF CompilerVersion >= 21.0}" << '\n'; indent_impl(s_const_impl) << "class constructor " << constants_class.c_str() << ".Create;" - << endl; + << '\n'; if (!vars.str().empty()) { - indent_impl(s_const_impl) << "var" << endl; + indent_impl(s_const_impl) << "var" << '\n'; s_const_impl << vars.str(); } - indent_impl(s_const_impl) << "begin" << endl; + indent_impl(s_const_impl) << "begin" << '\n'; if (!code.str().empty()) { s_const_impl << code.str(); } - indent_impl(s_const_impl) << "end;" << endl << endl; + indent_impl(s_const_impl) << "end;" << '\n' << '\n'; indent_impl(s_const_impl) << "class destructor " << constants_class.c_str() << ".Destroy;" - << endl; - indent_impl(s_const_impl) << "begin" << endl; + << '\n'; + indent_impl(s_const_impl) << "begin" << '\n'; indent_up_impl(); for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { if (const_needs_var((*c_iter)->get_type())) { @@ -1104,10 +1102,10 @@ void t_delphi_generator::generate_consts(std::vector consts) { (*c_iter)->get_value()); } } - indent_impl(s_const_impl) << "inherited;" << endl; + indent_impl(s_const_impl) << "inherited;" << '\n'; indent_down_impl(); - indent_impl(s_const_impl) << "end;" << endl; - indent_impl(s_const_impl) << "{$ELSE}" << endl; + indent_impl(s_const_impl) << "end;" << '\n'; + indent_impl(s_const_impl) << "{$ELSE}" << '\n'; vars.str(""); code.str(""); @@ -1124,19 +1122,19 @@ void t_delphi_generator::generate_consts(std::vector consts) { } indent_down_impl(); - indent_impl(s_const_impl) << "procedure " << constants_class.c_str() << "_Initialize;" << endl; + indent_impl(s_const_impl) << "procedure " << constants_class.c_str() << "_Initialize;" << '\n'; if (!vars.str().empty()) { - indent_impl(s_const_impl) << "var" << endl; + indent_impl(s_const_impl) << "var" << '\n'; s_const_impl << vars.str(); } - indent_impl(s_const_impl) << "begin" << endl; + indent_impl(s_const_impl) << "begin" << '\n'; if (!code.str().empty()) { s_const_impl << code.str(); } - indent_impl(s_const_impl) << "end;" << endl << endl; + indent_impl(s_const_impl) << "end;" << '\n' << '\n'; - indent_impl(s_const_impl) << "procedure " << constants_class.c_str() << "_Finalize;" << endl; - indent_impl(s_const_impl) << "begin" << endl; + indent_impl(s_const_impl) << "procedure " << constants_class.c_str() << "_Finalize;" << '\n'; + indent_impl(s_const_impl) << "begin" << '\n'; indent_up_impl(); for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { finalize_field(s_const_impl, @@ -1146,8 +1144,8 @@ void t_delphi_generator::generate_consts(std::vector consts) { constants_class); } indent_down_impl(); - indent_impl(s_const_impl) << "end;" << endl; - indent_impl(s_const_impl) << "{$IFEND}" << endl << endl; + indent_impl(s_const_impl) << "end;" << '\n'; + indent_impl(s_const_impl) << "{$IFEND}" << '\n' << '\n'; } void t_delphi_generator::print_const_def_value(std::ostream& vars, @@ -1183,7 +1181,7 @@ void t_delphi_generator::print_const_def_value(std::ostream& vars, string val = render_const_value(vars, out, name, field_type, v_iter->second); indent_impl(out) << cls_prefix << normalize_name(name) << "." << prop_name(v_iter->first->get_string(), type->is_xception()) - << " := " << val << ";" << endl; + << " := " << val << ";" << '\n'; } } else if (type->is_map()) { t_type* ktype = ((t_map*)type)->get_key_type(); @@ -1194,7 +1192,7 @@ void t_delphi_generator::print_const_def_value(std::ostream& vars, string key = render_const_value(vars, out, name, ktype, v_iter->first); string val = render_const_value(vars, out, name, vtype, v_iter->second); indent_impl(out) << cls_prefix << normalize_name(name) << "[" << key << "]" - << " := " << val << ";" << endl; + << " := " << val << ";" << '\n'; } } else if (type->is_list() || type->is_set()) { t_type* etype; @@ -1208,7 +1206,7 @@ void t_delphi_generator::print_const_def_value(std::ostream& vars, vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string val = render_const_value(vars, out, name, etype, *v_iter); - indent_impl(out) << cls_prefix << normalize_name(name) << ".Add(" << val << ");" << endl; + indent_impl(out) << cls_prefix << normalize_name(name) << ".Add(" << val << ");" << '\n'; } } } @@ -1218,7 +1216,7 @@ void t_delphi_generator::print_private_field(std::ostream& out, t_type* type, t_const_value* value) { (void)value; - indent(out) << "class var F" << name << ": " << type_name(type) << ";" << endl; + indent(out) << "class var F" << name << ": " << type_name(type) << ";" << '\n'; } bool t_delphi_generator::const_needs_var(t_type* type) { @@ -1236,11 +1234,11 @@ void t_delphi_generator::print_const_prop(std::ostream& out, (void)value; if (const_needs_var(type)) { indent(out) << "class property " << name << ": " << type_name(type) << " read F" << name << ";" - << endl; + << '\n'; } else { std::ostringstream vars; // dummy string v2 = render_const_value(vars, out, name, type, value); - indent(out) << "const " << name << " = " << v2 << ";" << endl; + indent(out) << "const " << name << " = " << v2 << ";" << '\n'; } } @@ -1257,14 +1255,14 @@ void t_delphi_generator::print_const_value(std::ostream& vars, if (truetype->is_base_type()) { // already done // string v2 = render_const_value( vars, out, name, type, value); - // indent_impl(out) << name << " := " << v2 << ";" << endl; + // indent_impl(out) << name << " := " << v2 << ";" << '\n'; } else if (truetype->is_enum()) { indent_impl(out) << name << " := " << type_name(type) << "." << value->get_identifier_name() - << ";" << endl; + << ";" << '\n'; } else { string typname; typname = type_name(truetype, true, false, type->is_xception(), type->is_xception()); - indent_impl(out) << name << " := " << typname << ".Create;" << endl; + indent_impl(out) << name << " := " << typname << ".Create;" << '\n'; print_const_def_value(vars, out, name, truetype, value); } } @@ -1341,7 +1339,7 @@ string t_delphi_generator::render_const_value(ostream& vars, render << type_name(type, false) << "." << value->get_identifier_name(); } else { string t = tmp("tmp"); - vars << " " << t << " : " << type_name(type) << ";" << endl; + vars << " " << t << " : " << type_name(type) << ";" << '\n'; print_const_value(vars, out, t, type, value); render << t; } @@ -1418,26 +1416,26 @@ void t_delphi_generator::generate_delphi_struct_impl(ostream& out, (*m_iter)->get_value()); if ((*m_iter)->get_req() != t_field::T_REQUIRED) { indent_impl(code) << prop_name((*m_iter), is_exception, "F__isset_") << " := True;" - << endl; + << '\n'; } } } indent_down_impl(); indent_impl(out) << "constructor " << cls_prefix << cls_nm << "." - << "Create;" << endl; + << "Create;" << '\n'; if (!vars.str().empty()) { - out << "var" << endl; + out << "var" << '\n'; out << vars.str(); } - indent_impl(out) << "begin" << endl; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); if (is_exception && (!is_x_factory)) { - indent_impl(out) << "inherited Create('');" << endl; + indent_impl(out) << "inherited Create('');" << '\n'; } else { - indent_impl(out) << "inherited;" << endl; + indent_impl(out) << "inherited;" << '\n'; } if (!code.str().empty()) { @@ -1445,28 +1443,28 @@ void t_delphi_generator::generate_delphi_struct_impl(ostream& out, } indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; + indent_impl(out) << "end;" << '\n' << '\n'; if ((members.size() > 0) && is_exception && (!is_x_factory)) { indent_impl(out) << "constructor " << cls_prefix << cls_nm << "." << "Create(" << constructor_argument_list(tstruct, indent_impl()) << ");" - << endl; - indent_impl(out) << "begin" << endl; + << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); - indent_impl(out) << "Create;" << endl; + indent_impl(out) << "Create;" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { string propname = prop_name((*m_iter)->get_name(), is_exception); string param_name = constructor_param_name((*m_iter)->get_name()); - indent_impl(out) << propname << " := " << param_name << ";" << endl; + indent_impl(out) << propname << " := " << param_name << ";" << '\n'; } - indent_impl(out) << "UpdateMessageProperty;" << endl; + indent_impl(out) << "UpdateMessageProperty;" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; + indent_impl(out) << "end;" << '\n' << '\n'; } indent_impl(out) << "destructor " << cls_prefix << cls_nm << "." - << "Destroy;" << endl; - indent_impl(out) << "begin" << endl; + << "Destroy;" << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -1477,46 +1475,46 @@ void t_delphi_generator::generate_delphi_struct_impl(ostream& out, finalize_field(out, prop_name(*m_iter, is_exception), t, (*m_iter)->get_value()); } - indent_impl(out) << "inherited;" << endl; + indent_impl(out) << "inherited;" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; + indent_impl(out) << "end;" << '\n' << '\n'; if (is_exception && (!is_x_factory)) { indent_impl(out) << "function " << cls_prefix << cls_nm << "." << exception_factory_name - << ": I" << exception_factory_name << ";" << endl; - indent_impl(out) << "begin" << endl; + << ": I" << exception_factory_name << ";" << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); - indent_impl(out) << "if F" << exception_factory_name << " = nil" << endl; - indent_impl(out) << "then F" << exception_factory_name << " := T" << exception_factory_name << "Impl.Create;" << endl << endl; - indent_impl(out) << "result := F" << exception_factory_name << ";" << endl; + indent_impl(out) << "if F" << exception_factory_name << " = nil" << '\n'; + indent_impl(out) << "then F" << exception_factory_name << " := T" << exception_factory_name << "Impl.Create;" << '\n' << '\n'; + indent_impl(out) << "result := F" << exception_factory_name << ";" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; - indent_impl(out) << "function " << cls_prefix << cls_nm << ".QueryInterface(const IID: TGUID; out Obj): HRESULT;" << endl; - indent_impl(out) << "begin" << endl; + indent_impl(out) << "end;" << '\n' << '\n'; + indent_impl(out) << "function " << cls_prefix << cls_nm << ".QueryInterface(const IID: TGUID; out Obj): HRESULT;" << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); - indent_impl(out) << "if GetInterface(IID, Obj)" << endl; - indent_impl(out) << "then result := S_OK" << endl; - indent_impl(out) << "else result := E_NOINTERFACE;" << endl; + indent_impl(out) << "if GetInterface(IID, Obj)" << '\n'; + indent_impl(out) << "then result := S_OK" << '\n'; + indent_impl(out) << "else result := E_NOINTERFACE;" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; - indent_impl(out) << "function " << cls_prefix << cls_nm << "._AddRef: Integer;" << endl; - indent_impl(out) << "begin" << endl; + indent_impl(out) << "end;" << '\n' << '\n'; + indent_impl(out) << "function " << cls_prefix << cls_nm << "._AddRef: Integer;" << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); - indent_impl(out) << "result := -1; // not refcounted" << endl; + indent_impl(out) << "result := -1; // not refcounted" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; - indent_impl(out) << "function " << cls_prefix << cls_nm << "._Release: Integer;" << endl; - indent_impl(out) << "begin" << endl; + indent_impl(out) << "end;" << '\n' << '\n'; + indent_impl(out) << "function " << cls_prefix << cls_nm << "._Release: Integer;" << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); - indent_impl(out) << "result := -1; // not refcounted" << endl; + indent_impl(out) << "result := -1; // not refcounted" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; + indent_impl(out) << "end;" << '\n' << '\n'; } if (tstruct->is_union()) { indent_impl(out) << "procedure " << cls_prefix << cls_nm << "." - << "ClearUnionValues;" << endl; - indent_impl(out) << "begin" << endl; + << "ClearUnionValues;" << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* t = (*m_iter)->get_type(); @@ -1536,7 +1534,7 @@ void t_delphi_generator::generate_delphi_struct_impl(ostream& out, exception_factory_name); } indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; + indent_impl(out) << "end;" << '\n' << '\n'; } for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -1601,12 +1599,12 @@ void t_delphi_generator::generate_delphi_struct_type_factory(ostream& out, print_delphi_struct_type_factory_func(out, tstruct); out << ": "; out << struct_intf_name; - out << ";" << endl; - out << "begin" << endl; + out << ";" << '\n'; + out << "begin" << '\n'; indent_up(); - indent(out) << "Result := " << cls_nm << ".Create;" << endl; + indent(out) << "Result := " << cls_nm << ".Create;" << '\n'; indent_down(); - out << "end;" << endl << endl; + out << "end;" << '\n' << '\n'; } void t_delphi_generator::generate_delphi_struct_type_factory_registration(ostream& out, @@ -1628,7 +1626,7 @@ void t_delphi_generator::generate_delphi_struct_type_factory_registration(ostrea indent(out) << " TypeRegistry.RegisterTypeFactory<" << struct_intf_name << ">("; print_delphi_struct_type_factory_func(out, tstruct); out << ");"; - out << endl; + out << '\n'; } void t_delphi_generator::generate_delphi_struct_definition(ostream& out, @@ -1662,11 +1660,11 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, generate_delphi_doc(out, tstruct); if(rtti_) { - indent(out) << "{$TYPEINFO ON}" << endl; - indent(out) << "{$RTTI EXPLICIT METHODS([vcPublic, vcPublished]) PROPERTIES([vcPublic, vcPublished])}" << endl; - indent(out) << struct_intf_name << " = interface(IBaseWithTypeInfo)" << endl; + indent(out) << "{$TYPEINFO ON}" << '\n'; + indent(out) << "{$RTTI EXPLICIT METHODS([vcPublic, vcPublished]) PROPERTIES([vcPublic, vcPublished])}" << '\n'; + indent(out) << struct_intf_name << " = interface(IBaseWithTypeInfo)" << '\n'; } else { - indent(out) << struct_intf_name << " = interface(IBase)" << endl; + indent(out) << struct_intf_name << " = interface(IBase)" << '\n'; } indent_up(); @@ -1678,20 +1676,20 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, } if (is_x_factory) { - out << endl; - indent(out) << "// Create Exception Object" << endl; - indent(out) << "function CreateException: " << type_name(tstruct, true, true) << ";" << endl; + out << '\n'; + indent(out) << "// Create Exception Object" << '\n'; + indent(out) << "function CreateException: " << type_name(tstruct, true, true) << ";" << '\n'; } if (members.size() > 0) { - out << endl; + out << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { generate_property(out, *m_iter, true, is_exception); } } if (members.size() > 0) { - out << endl; + out << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_req() != t_field::T_REQUIRED) { generate_delphi_isset_reader_writer_definition(out, *m_iter, is_exception); @@ -1700,22 +1698,22 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, } if (members.size() > 0) { - out << endl; + out << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_req() != t_field::T_REQUIRED) { isset_name = prop_name(*m_iter, is_exception, "__isset_"); indent(out) << "property " << isset_name << ": System.Boolean read Get" << isset_name << " write Set" << isset_name << ";" - << endl; + << '\n'; } } } indent_down(); - indent(out) << "end;" << endl; + indent(out) << "end;" << '\n'; if(rtti_) { - indent(out) << "{$IFNDEF TYPEINFO_WAS_ON} {$TYPEINFO OFF} {$ENDIF}" << endl; + indent(out) << "{$IFNDEF TYPEINFO_WAS_ON} {$TYPEINFO OFF} {$ENDIF}" << '\n'; } - indent(out) << endl; + indent(out) << '\n'; } generate_delphi_doc(out, tstruct); @@ -1729,40 +1727,40 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, } else { out << "TInterfacedObject, IBase, ISupportsToString, " << struct_intf_name; } - out << ")" << endl; + out << ")" << '\n'; if (is_exception && (!is_x_factory)) { - indent(out) << "public" << endl; + indent(out) << "public" << '\n'; indent_up(); - indent(out) << "type" << endl; + indent(out) << "type" << '\n'; indent_up(); generate_delphi_struct_definition(out, tstruct, is_exception, in_class, is_result, true); indent_down(); indent_down(); } - indent(out) << "private" << endl; + indent(out) << "private" << '\n'; indent_up(); if (is_exception && (!is_x_factory)) { - indent(out) << "F" << exception_factory_name << " :" << struct_intf_name << ";" << endl << endl; + indent(out) << "F" << exception_factory_name << " :" << struct_intf_name << ";" << '\n' << '\n'; } for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - indent(out) << declare_field(*m_iter, false, "F", is_exception) << endl; + indent(out) << declare_field(*m_iter, false, "F", is_exception) << '\n'; } if (members.size() > 0) { - indent(out) << endl; + indent(out) << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_req() != t_field::T_REQUIRED) { isset_name = prop_name(*m_iter, is_exception, "F__isset_"); - indent(out) << isset_name << ": System.Boolean;" << endl; + indent(out) << isset_name << ": System.Boolean;" << '\n'; } } } - indent(out) << endl; + indent(out) << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { generate_delphi_property_reader_definition(out, *m_iter, is_exception); @@ -1770,106 +1768,106 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, } if (tstruct->is_union()) { - out << endl; - indent(out) << "// Clear values(for union's property setter)" << endl; - indent(out) << "procedure ClearUnionValues;" << endl; + out << '\n'; + indent(out) << "// Clear values(for union's property setter)" << '\n'; + indent(out) << "procedure ClearUnionValues;" << '\n'; } if (members.size() > 0) { - out << endl; + out << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_req() != t_field::T_REQUIRED) { isset_name = prop_name(*m_iter, is_exception, "__isset_"); - indent(out) << "function Get" << isset_name << ": System.Boolean;" << endl; - indent(out) << "procedure Set" << isset_name << "( const value : System.Boolean);" << endl; + indent(out) << "function Get" << isset_name << ": System.Boolean;" << '\n'; + indent(out) << "procedure Set" << isset_name << "( const value : System.Boolean);" << '\n'; } } } if (is_exception && (!is_x_factory)) { - out << endl; + out << '\n'; indent_down(); - indent(out) << "strict protected" << endl; - indent_up(); - indent(out) << "function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall;" << endl; - indent(out) << "function _AddRef: Integer; stdcall;" << endl; - indent(out) << "function _Release: Integer; stdcall;" << endl; - out << endl; + indent(out) << "strict protected" << '\n'; + indent_up(); + indent(out) << "function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall;" << '\n'; + indent(out) << "function _AddRef: Integer; stdcall;" << '\n'; + indent(out) << "function _Release: Integer; stdcall;" << '\n'; + out << '\n'; } indent_down(); - indent(out) << "public" << endl; + indent(out) << "public" << '\n'; indent_up(); if ((members.size() > 0) && is_exception && (!is_x_factory)) { - indent(out) << "constructor Create; overload;" << endl; + indent(out) << "constructor Create; overload;" << '\n'; indent(out) << "constructor Create(" << constructor_argument_list(tstruct, indent()) - << "); overload;" << endl; + << "); overload;" << '\n'; } else { - indent(out) << "constructor Create;" << endl; + indent(out) << "constructor Create;" << '\n'; } - indent(out) << "destructor Destroy; override;" << endl; + indent(out) << "destructor Destroy; override;" << '\n'; - out << endl; - indent(out) << "function ToString: string; override;" << endl; + out << '\n'; + indent(out) << "function ToString: string; override;" << '\n'; if (is_exception && (!is_x_factory)) { - out << endl; - indent(out) << "// Exception Factory" << endl; - indent(out) << "function " << exception_factory_name << ": " << struct_intf_name << ";" << endl; + out << '\n'; + indent(out) << "// Exception Factory" << '\n'; + indent(out) << "function " << exception_factory_name << ": " << struct_intf_name << ";" << '\n'; } - out << endl; - indent(out) << "// IBase" << endl; - indent(out) << "procedure Read( const iprot: IProtocol);" << endl; - indent(out) << "procedure Write( const oprot: IProtocol);" << endl; + out << '\n'; + indent(out) << "// IBase" << '\n'; + indent(out) << "procedure Read( const iprot: IProtocol);" << '\n'; + indent(out) << "procedure Write( const oprot: IProtocol);" << '\n'; if (is_exception && is_x_factory) { - out << endl; - indent(out) << "// Create Exception Object" << endl; - indent(out) << "function CreateException: " << type_name(tstruct, true, true) << ";" << endl; + out << '\n'; + indent(out) << "// Create Exception Object" << '\n'; + indent(out) << "function CreateException: " << type_name(tstruct, true, true) << ";" << '\n'; } if (members.size() > 0) { - out << endl; - indent(out) << "// Properties" << endl; + out << '\n'; + indent(out) << "// Properties" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { generate_property(out, *m_iter, true, is_exception); } } if (members.size() > 0) { - out << endl; - indent(out) << "// isset" << endl; + out << '\n'; + indent(out) << "// isset" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_req() != t_field::T_REQUIRED) { isset_name = prop_name(*m_iter, is_exception, "__isset_"); indent(out) << "property " << isset_name << ": System.Boolean read Get" << isset_name << " write Set" << isset_name << ";" - << endl; + << '\n'; } } } indent_down(); - indent(out) << "end;" << endl << endl; + indent(out) << "end;" << '\n' << '\n'; } void t_delphi_generator::generate_service(t_service* tservice) { indent_up(); generate_delphi_doc(s_service, tservice); - indent(s_service) << normalize_clsnm(service_name_, "T") << " = class" << endl; - indent(s_service) << "public" << endl; + indent(s_service) << normalize_clsnm(service_name_, "T") << " = class" << '\n'; + indent(s_service) << "public" << '\n'; indent_up(); - indent(s_service) << "type" << endl; + indent(s_service) << "type" << '\n'; generate_service_interface(tservice); generate_service_client(tservice); generate_service_server(tservice); generate_service_helpers(tservice); indent_down(); indent_down(); - indent(s_service) << "end;" << endl; - indent(s_service) << endl; + indent(s_service) << "end;" << '\n'; + indent(s_service) << '\n'; indent_down(); } @@ -1893,9 +1891,9 @@ void t_delphi_generator::generate_service_interface(t_service* tservice, bool fo extends = type_name(tservice->get_extends(), true, true); extends_iface = extends + "." + iface_name; generate_delphi_doc(s_service, tservice); - indent(s_service) << iface_name << " = interface(" << extends_iface << ")" << endl; + indent(s_service) << iface_name << " = interface(" << extends_iface << ")" << '\n'; } else { - indent(s_service) << iface_name << " = interface" << endl; + indent(s_service) << iface_name << " = interface" << '\n'; } indent_up(); @@ -1904,10 +1902,10 @@ void t_delphi_generator::generate_service_interface(t_service* tservice, bool fo vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_delphi_doc(s_service, *f_iter); - indent(s_service) << function_signature(*f_iter, for_async) << endl; + indent(s_service) << function_signature(*f_iter, for_async) << '\n'; } indent_down(); - indent(s_service) << "end;" << endl << endl; + indent(s_service) << "end;" << '\n' << '\n'; indent_down(); } @@ -1921,7 +1919,7 @@ void t_delphi_generator::generate_guid(std::ostream& out) { std::wstring guid_wstr(guid_chars); std::wstring_convert> convert; std::string guid_str = convert.to_bytes(guid_wstr); - indent(out) << "['" << guid_str << "']" << endl; + indent(out) << "['" << guid_str << "']" << '\n'; } } #else @@ -1955,78 +1953,78 @@ void t_delphi_generator::generate_service_client(t_service* tservice) { extends = type_name(tservice->get_extends(), true, true); extends_client = extends + ".TClient"; } - indent(s_service) << "TClient = class( " << extends_client << ", " << implements << ")" << endl; + indent(s_service) << "TClient = class( " << extends_client << ", " << implements << ")" << '\n'; - indent(s_service) << "public" << endl; + indent(s_service) << "public" << '\n'; indent_up(); - indent(s_service) << "constructor Create( prot: IProtocol); overload;" << endl; + indent(s_service) << "constructor Create( prot: IProtocol); overload;" << '\n'; indent_impl(s_service_impl) << "constructor " << normalize_clsnm(service_name_, "T") - << ".TClient.Create( prot: IProtocol);" << endl; - indent_impl(s_service_impl) << "begin" << endl; + << ".TClient.Create( prot: IProtocol);" << '\n'; + indent_impl(s_service_impl) << "begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "Create( prot, prot );" << endl; + indent_impl(s_service_impl) << "Create( prot, prot );" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl << endl; + indent_impl(s_service_impl) << "end;" << '\n' << '\n'; indent(s_service) - << "constructor Create( const iprot: IProtocol; const oprot: IProtocol); overload;" << endl; + << "constructor Create( const iprot: IProtocol; const oprot: IProtocol); overload;" << '\n'; indent_impl(s_service_impl) << "constructor " << normalize_clsnm(service_name_, "T") << ".TClient.Create( const iprot: IProtocol; const oprot: IProtocol);" - << endl; - indent_impl(s_service_impl) << "begin" << endl; + << '\n'; + indent_impl(s_service_impl) << "begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "inherited Create;" << endl; - indent_impl(s_service_impl) << "iprot_ := iprot;" << endl; - indent_impl(s_service_impl) << "oprot_ := oprot;" << endl; + indent_impl(s_service_impl) << "inherited Create;" << '\n'; + indent_impl(s_service_impl) << "iprot_ := iprot;" << '\n'; + indent_impl(s_service_impl) << "oprot_ := oprot;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl << endl; + indent_impl(s_service_impl) << "end;" << '\n' << '\n'; indent_down(); if (extends.empty()) { - indent(s_service) << "protected" << endl; + indent(s_service) << "protected" << '\n'; indent_up(); - indent(s_service) << "iprot_: IProtocol;" << endl; - indent(s_service) << "oprot_: IProtocol;" << endl; - indent(s_service) << "seqid_: System.Integer;" << endl; + indent(s_service) << "iprot_: IProtocol;" << '\n'; + indent(s_service) << "oprot_: IProtocol;" << '\n'; + indent(s_service) << "seqid_: System.Integer;" << '\n'; indent_down(); - indent(s_service) << "public" << endl; + indent(s_service) << "public" << '\n'; indent_up(); - indent(s_service) << "property InputProtocol: IProtocol read iprot_;" << endl; - indent(s_service) << "property OutputProtocol: IProtocol read oprot_;" << endl; + indent(s_service) << "property InputProtocol: IProtocol read iprot_;" << '\n'; + indent(s_service) << "property OutputProtocol: IProtocol read oprot_;" << '\n'; indent_down(); } vector functions = tservice->get_functions(); vector::const_iterator f_iter; - indent(s_service) << "protected" << endl; + indent(s_service) << "protected" << '\n'; indent_up(); - indent(s_service) << "// Iface" << endl; + indent(s_service) << "// Iface" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { string funname = (*f_iter)->get_name(); generate_delphi_doc(s_service, *f_iter); - indent(s_service) << function_signature(*f_iter, false) << endl; + indent(s_service) << function_signature(*f_iter, false) << '\n'; } if( async_) { - indent(s_service) << endl; - indent(s_service) << "// IAsync" << endl; + indent(s_service) << '\n'; + indent(s_service) << "// IAsync" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { string funname = (*f_iter)->get_name(); generate_delphi_doc(s_service, *f_iter); - indent(s_service) << function_signature(*f_iter, true) << endl; + indent(s_service) << function_signature(*f_iter, true) << '\n'; } } indent_down(); - indent(s_service) << "public" << endl; + indent(s_service) << "public" << '\n'; indent_up(); string full_cls = normalize_clsnm(service_name_, "T") + ".TClient"; @@ -2044,20 +2042,20 @@ void t_delphi_generator::generate_service_client(t_service* tservice) { bool for_async = (mode != 0); mode--; - indent_impl(s_service_impl) << function_signature(*f_iter, for_async, full_cls) << endl; - indent_impl(s_service_impl) << "begin" << endl; + indent_impl(s_service_impl) << function_signature(*f_iter, for_async, full_cls) << '\n'; + indent_impl(s_service_impl) << "begin" << '\n'; indent_up_impl(); t_type* ttype = (*f_iter)->get_returntype(); if( for_async) { if (is_void(ttype)) { // Delphi forces us to specify a type with IFuture, so we use Integer=0 for void methods - indent_impl(s_service_impl) << "result := TTask.Future(function: System.Integer" << endl; + indent_impl(s_service_impl) << "result := TTask.Future(function: System.Integer" << '\n'; } else { string rettype = type_name(ttype, false, true, false, true); - indent_impl(s_service_impl) << "result := TTask.Future<" << rettype << ">(function: " << rettype << endl; + indent_impl(s_service_impl) << "result := TTask.Future<" << rettype << ">(function: " << rettype << '\n'; } - indent_impl(s_service_impl) << "begin" << endl; + indent_impl(s_service_impl) << "begin" << '\n'; indent_up_impl(); } @@ -2072,26 +2070,26 @@ void t_delphi_generator::generate_service_client(t_service* tservice) { } s_service_impl << normalize_name((*fld_iter)->get_name()); } - s_service_impl << ");" << endl; + s_service_impl << ");" << '\n'; if (!(*f_iter)->is_oneway()) { s_service_impl << indent_impl(); if (!(*f_iter)->get_returntype()->is_void()) { s_service_impl << "Result := "; } - s_service_impl << "recv_" << funname << "();" << endl; + s_service_impl << "recv_" << funname << "();" << '\n'; } if( for_async) { if (is_void(ttype)) { - indent_impl(s_service_impl) << "Result := 0;" << endl; // no IFuture in Delphi + indent_impl(s_service_impl) << "Result := 0;" << '\n'; // no IFuture in Delphi } indent_down_impl(); - indent_impl(s_service_impl) << "end);" << endl; + indent_impl(s_service_impl) << "end);" << '\n'; } indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl << endl; + indent_impl(s_service_impl) << "end;" << '\n' << '\n'; } t_function send_function(g_type_void, @@ -2105,41 +2103,41 @@ void t_delphi_generator::generate_service_client(t_service* tservice) { string argsvar = tmp("_args"); string msgvar = tmp("_msg"); - indent(s_service) << function_signature(&send_function, false) << endl; - indent_impl(s_service_impl) << function_signature(&send_function, false, full_cls) << endl; - indent_impl(s_service_impl) << "var" << endl; + indent(s_service) << function_signature(&send_function, false) << '\n'; + indent_impl(s_service_impl) << function_signature(&send_function, false, full_cls) << '\n'; + indent_impl(s_service_impl) << "var" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << argsvar << " : " << args_intfnm << ";" << endl; - indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.TThriftMessage;" << endl; + indent_impl(s_service_impl) << argsvar << " : " << args_intfnm << ";" << '\n'; + indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.TThriftMessage;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "begin" << endl; + indent_impl(s_service_impl) << "begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "seqid_ := seqid_ + 1;" << endl; + indent_impl(s_service_impl) << "seqid_ := seqid_ + 1;" << '\n'; indent_impl(s_service_impl) << "Thrift.Protocol.Init( " << msgvar << ", '" << funname << "', " << ((*f_iter)->is_oneway() ? "TMessageType.Oneway" : "TMessageType.Call") - << ", seqid_);" << endl; + << ", seqid_);" << '\n'; - indent_impl(s_service_impl) << "oprot_.WriteMessageBegin( " << msgvar << " );" << endl; - indent_impl(s_service_impl) << argsvar << " := " << args_clsnm << "Impl.Create();" << endl; + indent_impl(s_service_impl) << "oprot_.WriteMessageBegin( " << msgvar << " );" << '\n'; + indent_impl(s_service_impl) << argsvar << " := " << args_clsnm << "Impl.Create();" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { indent_impl(s_service_impl) << argsvar << "." << prop_name(*fld_iter) << " := " << normalize_name((*fld_iter)->get_name()) << ";" - << endl; + << '\n'; } - indent_impl(s_service_impl) << argsvar << ".Write(oprot_);" << endl; + indent_impl(s_service_impl) << argsvar << ".Write(oprot_);" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { indent_impl(s_service_impl) << argsvar << "." << prop_name(*fld_iter) - << " := " << empty_value((*fld_iter)->get_type()) << ";" << endl; + << " := " << empty_value((*fld_iter)->get_type()) << ";" << '\n'; } - indent_impl(s_service_impl) << "oprot_.WriteMessageEnd();" << endl; - indent_impl(s_service_impl) << "oprot_.Transport.Flush();" << endl; + indent_impl(s_service_impl) << "oprot_.WriteMessageEnd();" << '\n'; + indent_impl(s_service_impl) << "oprot_.Transport.Flush();" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl << endl; + indent_impl(s_service_impl) << "end;" << '\n' << '\n'; if (!(*f_iter)->is_oneway()) { string org_resultname = (*f_iter)->get_name() + "_result"; @@ -2159,72 +2157,72 @@ void t_delphi_generator::generate_service_client(t_service* tservice) { string appexvar = tmp("_ax"); string retvar = tmp("_ret"); - indent(s_service) << function_signature(&recv_function, false) << endl; - indent_impl(s_service_impl) << function_signature(&recv_function, false, full_cls) << endl; - indent_impl(s_service_impl) << "var" << endl; + indent(s_service) << function_signature(&recv_function, false) << '\n'; + indent_impl(s_service_impl) << function_signature(&recv_function, false, full_cls) << '\n'; + indent_impl(s_service_impl) << "var" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.TThriftMessage;" << endl; + indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.TThriftMessage;" << '\n'; if (xceptions.size() > 0) { - indent_impl(s_service_impl) << exceptvar << " : Exception;" << endl; + indent_impl(s_service_impl) << exceptvar << " : Exception;" << '\n'; } - indent_impl(s_service_impl) << appexvar << " : TApplicationException;" << endl; - indent_impl(s_service_impl) << retvar << " : " << result_intfnm << ";" << endl; + indent_impl(s_service_impl) << appexvar << " : TApplicationException;" << '\n'; + indent_impl(s_service_impl) << retvar << " : " << result_intfnm << ";" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "begin" << endl; + indent_impl(s_service_impl) << "begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << msgvar << " := iprot_.ReadMessageBegin();" << endl; - indent_impl(s_service_impl) << "if (" << msgvar << ".Type_ = TMessageType.Exception) then begin" << endl; + indent_impl(s_service_impl) << msgvar << " := iprot_.ReadMessageBegin();" << '\n'; + indent_impl(s_service_impl) << "if (" << msgvar << ".Type_ = TMessageType.Exception) then begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << appexvar << " := TApplicationException.Read(iprot_);" << endl; - indent_impl(s_service_impl) << "iprot_.ReadMessageEnd();" << endl; - indent_impl(s_service_impl) << "raise " << appexvar << ";" << endl; + indent_impl(s_service_impl) << appexvar << " := TApplicationException.Read(iprot_);" << '\n'; + indent_impl(s_service_impl) << "iprot_.ReadMessageEnd();" << '\n'; + indent_impl(s_service_impl) << "raise " << appexvar << ";" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; - indent_impl(s_service_impl) << retvar << " := " << result_clsnm << "Impl.Create();" << endl; - indent_impl(s_service_impl) << retvar << ".Read(iprot_);" << endl; - indent_impl(s_service_impl) << "iprot_.ReadMessageEnd();" << endl; + indent_impl(s_service_impl) << retvar << " := " << result_clsnm << "Impl.Create();" << '\n'; + indent_impl(s_service_impl) << retvar << ".Read(iprot_);" << '\n'; + indent_impl(s_service_impl) << "iprot_.ReadMessageEnd();" << '\n'; if (!(*f_iter)->get_returntype()->is_void()) { - indent_impl(s_service_impl) << "if (" << retvar << ".__isset_success) then begin" << endl; + indent_impl(s_service_impl) << "if (" << retvar << ".__isset_success) then begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "Result := " << retvar << ".Success;" << endl; + indent_impl(s_service_impl) << "Result := " << retvar << ".Success;" << '\n'; t_type* type = (*f_iter)->get_returntype(); if (type->is_struct() || type->is_xception() || type->is_map() || type->is_list() || type->is_set()) { - indent_impl(s_service_impl) << retvar << ".Success := nil;" << endl; + indent_impl(s_service_impl) << retvar << ".Success := nil;" << '\n'; } - indent_impl(s_service_impl) << "Exit;" << endl; + indent_impl(s_service_impl) << "Exit;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; } vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { indent_impl(s_service_impl) << "if (" << retvar << "." << prop_name(*x_iter, false, "__isset_") - << ") then begin" << endl; + << ") then begin" << '\n'; indent_up_impl(); indent_impl(s_service_impl) << exceptvar << " := " << retvar << "." << prop_name(*x_iter) - << ".CreateException;" << endl; - indent_impl(s_service_impl) << "raise " << exceptvar << ";" << endl; + << ".CreateException;" << '\n'; + indent_impl(s_service_impl) << "raise " << exceptvar << ";" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; } if (!(*f_iter)->get_returntype()->is_void()) { indent_impl(s_service_impl) << "raise TApplicationExceptionMissingResult.Create('" - << (*f_iter)->get_name() << " failed: unknown result');" << endl; + << (*f_iter)->get_name() << " failed: unknown result');" << '\n'; } indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl << endl; + indent_impl(s_service_impl) << "end;" << '\n' << '\n'; } } indent_down(); - indent(s_service) << "end;" << endl << endl; + indent(s_service) << "end;" << '\n' << '\n'; } void t_delphi_generator::generate_service_server(t_service* tservice) { @@ -2239,164 +2237,164 @@ void t_delphi_generator::generate_service_server(t_service* tservice) { if (tservice->get_extends() != nullptr) { extends = type_name(tservice->get_extends(), true, true); extends_processor = extends + ".TProcessorImpl"; - indent(s_service) << "TProcessorImpl = class(" << extends_processor << ", IProcessor)" << endl; + indent(s_service) << "TProcessorImpl = class(" << extends_processor << ", IProcessor)" << '\n'; } else { - indent(s_service) << "TProcessorImpl = class( TInterfacedObject, IProcessor)" << endl; + indent(s_service) << "TProcessorImpl = class( TInterfacedObject, IProcessor)" << '\n'; } - indent(s_service) << "public" << endl; + indent(s_service) << "public" << '\n'; indent_up(); - indent(s_service) << "constructor Create( iface_: Iface );" << endl; - indent(s_service) << "destructor Destroy; override;" << endl; + indent(s_service) << "constructor Create( iface_: Iface );" << '\n'; + indent(s_service) << "destructor Destroy; override;" << '\n'; indent_down(); - indent_impl(s_service_impl) << "constructor " << full_cls << ".Create( iface_: Iface );" << endl; - indent_impl(s_service_impl) << "begin" << endl; + indent_impl(s_service_impl) << "constructor " << full_cls << ".Create( iface_: Iface );" << '\n'; + indent_impl(s_service_impl) << "begin" << '\n'; indent_up_impl(); if (tservice->get_extends() != nullptr) { - indent_impl(s_service_impl) << "inherited Create( iface_);" << endl; + indent_impl(s_service_impl) << "inherited Create( iface_);" << '\n'; } else { - indent_impl(s_service_impl) << "inherited Create;" << endl; + indent_impl(s_service_impl) << "inherited Create;" << '\n'; } - indent_impl(s_service_impl) << "Self.iface_ := iface_;" << endl; + indent_impl(s_service_impl) << "Self.iface_ := iface_;" << '\n'; if (tservice->get_extends() != nullptr) { - indent_impl(s_service_impl) << "ASSERT( processMap_ <> nil); // inherited" << endl; + indent_impl(s_service_impl) << "ASSERT( processMap_ <> nil); // inherited" << '\n'; } else { indent_impl(s_service_impl) - << "processMap_ := TThriftDictionaryImpl.Create;" << endl; + << "processMap_ := TThriftDictionaryImpl.Create;" << '\n'; } for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { indent_impl(s_service_impl) << "processMap_.AddOrSetValue( '" << (*f_iter)->get_name() << "', " - << (*f_iter)->get_name() << "_Process);" << endl; + << (*f_iter)->get_name() << "_Process);" << '\n'; } indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl << endl; + indent_impl(s_service_impl) << "end;" << '\n' << '\n'; - indent_impl(s_service_impl) << "destructor " << full_cls << ".Destroy;" << endl; - indent_impl(s_service_impl) << "begin" << endl; + indent_impl(s_service_impl) << "destructor " << full_cls << ".Destroy;" << '\n'; + indent_impl(s_service_impl) << "begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "inherited;" << endl; + indent_impl(s_service_impl) << "inherited;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl << endl; + indent_impl(s_service_impl) << "end;" << '\n' << '\n'; - indent(s_service) << "private" << endl; + indent(s_service) << "private" << '\n'; indent_up(); - indent(s_service) << "iface_: Iface;" << endl; + indent(s_service) << "iface_: Iface;" << '\n'; indent_down(); if (tservice->get_extends() == nullptr) { - indent(s_service) << "protected" << endl; + indent(s_service) << "protected" << '\n'; indent_up(); - indent(s_service) << "type" << endl; + indent(s_service) << "type" << '\n'; indent_up(); indent(s_service) << "TProcessFunction = reference to procedure( seqid: System.Integer; const iprot: " "IProtocol; const oprot: IProtocol" - << (events_ ? "; const events : IRequestEvents" : "") << ");" << endl; + << (events_ ? "; const events : IRequestEvents" : "") << ");" << '\n'; indent_down(); indent_down(); - indent(s_service) << "protected" << endl; + indent(s_service) << "protected" << '\n'; indent_up(); - indent(s_service) << "processMap_: IThriftDictionary;" << endl; + indent(s_service) << "processMap_: IThriftDictionary;" << '\n'; indent_down(); } - indent(s_service) << "public" << endl; + indent(s_service) << "public" << '\n'; indent_up(); if (extends.empty()) { indent(s_service) << "function Process( const iprot: IProtocol; const oprot: IProtocol; const " - "events : IProcessorEvents): System.Boolean;" << endl; + "events : IProcessorEvents): System.Boolean;" << '\n'; } else { indent(s_service) << "function Process( const iprot: IProtocol; const oprot: IProtocol; const " - "events : IProcessorEvents): System.Boolean; reintroduce;" << endl; + "events : IProcessorEvents): System.Boolean; reintroduce;" << '\n'; } indent_impl(s_service_impl) << "function " << full_cls << ".Process( const iprot: IProtocol; " "const oprot: IProtocol; const events " - ": IProcessorEvents): System.Boolean;" << endl; + ": IProcessorEvents): System.Boolean;" << '\n'; ; - indent_impl(s_service_impl) << "var" << endl; + indent_impl(s_service_impl) << "var" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "msg : Thrift.Protocol.TThriftMessage;" << endl; - indent_impl(s_service_impl) << "fn : TProcessFunction;" << endl; - indent_impl(s_service_impl) << "x : TApplicationException;" << endl; + indent_impl(s_service_impl) << "msg : Thrift.Protocol.TThriftMessage;" << '\n'; + indent_impl(s_service_impl) << "fn : TProcessFunction;" << '\n'; + indent_impl(s_service_impl) << "x : TApplicationException;" << '\n'; if (events_) { - indent_impl(s_service_impl) << "context : IRequestEvents;" << endl; + indent_impl(s_service_impl) << "context : IRequestEvents;" << '\n'; } indent_down_impl(); - indent_impl(s_service_impl) << "begin" << endl; + indent_impl(s_service_impl) << "begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "try" << endl; + indent_impl(s_service_impl) << "try" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "msg := iprot.ReadMessageBegin();" << endl; - indent_impl(s_service_impl) << "fn := nil;" << endl; - indent_impl(s_service_impl) << "if not processMap_.TryGetValue(msg.Name, fn)" << endl; - indent_impl(s_service_impl) << "or not Assigned(fn) then begin" << endl; + indent_impl(s_service_impl) << "msg := iprot.ReadMessageBegin();" << '\n'; + indent_impl(s_service_impl) << "fn := nil;" << '\n'; + indent_impl(s_service_impl) << "if not processMap_.TryGetValue(msg.Name, fn)" << '\n'; + indent_impl(s_service_impl) << "or not Assigned(fn) then begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "TProtocolUtil.Skip(iprot, TType.Struct);" << endl; - indent_impl(s_service_impl) << "iprot.ReadMessageEnd();" << endl; + indent_impl(s_service_impl) << "TProtocolUtil.Skip(iprot, TType.Struct);" << '\n'; + indent_impl(s_service_impl) << "iprot.ReadMessageEnd();" << '\n'; indent_impl(s_service_impl) << "x := " "TApplicationExceptionUnknownMethod.Create(" - "'Invalid method name: ''' + msg.Name + '''');" << endl; + "'Invalid method name: ''' + msg.Name + '''');" << '\n'; indent_impl(s_service_impl) << "Thrift.Protocol.Init( msg, msg.Name, TMessageType.Exception, msg.SeqID);" - << endl; - indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << endl; - indent_impl(s_service_impl) << "x.Write(oprot);" << endl; - indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << endl; - indent_impl(s_service_impl) << "oprot.Transport.Flush();" << endl; - indent_impl(s_service_impl) << "Result := True;" << endl; - indent_impl(s_service_impl) << "Exit;" << endl; + << '\n'; + indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << '\n'; + indent_impl(s_service_impl) << "x.Write(oprot);" << '\n'; + indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << '\n'; + indent_impl(s_service_impl) << "oprot.Transport.Flush();" << '\n'; + indent_impl(s_service_impl) << "Result := True;" << '\n'; + indent_impl(s_service_impl) << "Exit;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; if (events_) { - indent_impl(s_service_impl) << "if events <> nil" << endl; - indent_impl(s_service_impl) << "then context := events.CreateRequestContext(msg.Name)" << endl; - indent_impl(s_service_impl) << "else context := nil;" << endl; - indent_impl(s_service_impl) << "try" << endl; + indent_impl(s_service_impl) << "if events <> nil" << '\n'; + indent_impl(s_service_impl) << "then context := events.CreateRequestContext(msg.Name)" << '\n'; + indent_impl(s_service_impl) << "else context := nil;" << '\n'; + indent_impl(s_service_impl) << "try" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "fn(msg.SeqID, iprot, oprot, context);" << endl; + indent_impl(s_service_impl) << "fn(msg.SeqID, iprot, oprot, context);" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "finally" << endl; + indent_impl(s_service_impl) << "finally" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "if context <> nil then begin" << endl; + indent_impl(s_service_impl) << "if context <> nil then begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "context.CleanupContext;" << endl; - indent_impl(s_service_impl) << "context := nil;" << endl; + indent_impl(s_service_impl) << "context.CleanupContext;" << '\n'; + indent_impl(s_service_impl) << "context := nil;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; } else { - indent_impl(s_service_impl) << "fn(msg.SeqID, iprot, oprot);" << endl; + indent_impl(s_service_impl) << "fn(msg.SeqID, iprot, oprot);" << '\n'; } indent_down_impl(); - indent_impl(s_service_impl) << "except" << endl; + indent_impl(s_service_impl) << "except" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "on TTransportExceptionTimedOut do begin" << endl; + indent_impl(s_service_impl) << "on TTransportExceptionTimedOut do begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "Result := True;" << endl; - indent_impl(s_service_impl) << "Exit;" << endl; + indent_impl(s_service_impl) << "Result := True;" << '\n'; + indent_impl(s_service_impl) << "Exit;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; - indent_impl(s_service_impl) << "else begin" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; + indent_impl(s_service_impl) << "else begin" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "Result := False;" << endl; - indent_impl(s_service_impl) << "Exit;" << endl; + indent_impl(s_service_impl) << "Result := False;" << '\n'; + indent_impl(s_service_impl) << "Exit;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; - indent_impl(s_service_impl) << "Result := True;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; + indent_impl(s_service_impl) << "Result := True;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl << endl; + indent_impl(s_service_impl) << "end;" << '\n' << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_process_function(tservice, *f_iter); } indent_down(); - indent(s_service) << "end;" << endl << endl; + indent(s_service) << "end;" << '\n' << '\n'; } void t_delphi_generator::generate_function_helpers(t_function* tfunction) { @@ -2439,46 +2437,46 @@ void t_delphi_generator::generate_process_function(t_service* tservice, t_functi indent(s_service) << "procedure " << funcname << "_Process( seqid: System.Integer; const iprot: IProtocol; const oprot: IProtocol" - << (events_ ? "; const events : IRequestEvents" : "") << ");" << endl; + << (events_ ? "; const events : IRequestEvents" : "") << ");" << '\n'; if (tfunction->is_oneway()) { - indent_impl(s_service_impl) << "// one way processor" << endl; + indent_impl(s_service_impl) << "// one way processor" << '\n'; } else { - indent_impl(s_service_impl) << "// both way processor" << endl; + indent_impl(s_service_impl) << "// both way processor" << '\n'; } indent_impl(s_service_impl) << "procedure " << full_cls << "." << funcname << "_Process( seqid: System.Integer; const iprot: IProtocol; const oprot: IProtocol" - << (events_ ? "; const events : IRequestEvents" : "") << ");" << endl; - indent_impl(s_service_impl) << "var" << endl; + << (events_ ? "; const events : IRequestEvents" : "") << ");" << '\n'; + indent_impl(s_service_impl) << "var" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "args: " << args_intfnm << ";" << endl; + indent_impl(s_service_impl) << "args: " << args_intfnm << ";" << '\n'; if (!tfunction->is_oneway()) { - indent_impl(s_service_impl) << "msg: Thrift.Protocol.TThriftMessage;" << endl; - indent_impl(s_service_impl) << "ret: " << result_intfnm << ";" << endl; - indent_impl(s_service_impl) << "appx : TApplicationException;" << endl; + indent_impl(s_service_impl) << "msg: Thrift.Protocol.TThriftMessage;" << '\n'; + indent_impl(s_service_impl) << "ret: " << result_intfnm << ";" << '\n'; + indent_impl(s_service_impl) << "appx : TApplicationException;" << '\n'; } indent_down_impl(); - indent_impl(s_service_impl) << "begin" << endl; + indent_impl(s_service_impl) << "begin" << '\n'; indent_up_impl(); if (!tfunction->is_oneway()) { - indent_impl(s_service_impl) << "ret := " << result_clsnm << "Impl.Create;" << endl; + indent_impl(s_service_impl) << "ret := " << result_clsnm << "Impl.Create;" << '\n'; } - indent_impl(s_service_impl) << "try" << endl; + indent_impl(s_service_impl) << "try" << '\n'; indent_up_impl(); if (events_) { - indent_impl(s_service_impl) << "if events <> nil then events.PreRead;" << endl; + indent_impl(s_service_impl) << "if events <> nil then events.PreRead;" << '\n'; } - indent_impl(s_service_impl) << "args := " << args_clsnm << "Impl.Create;" << endl; - indent_impl(s_service_impl) << "args.Read(iprot);" << endl; - indent_impl(s_service_impl) << "iprot.ReadMessageEnd();" << endl; + indent_impl(s_service_impl) << "args := " << args_clsnm << "Impl.Create;" << '\n'; + indent_impl(s_service_impl) << "args.Read(iprot);" << '\n'; + indent_impl(s_service_impl) << "iprot.ReadMessageEnd();" << '\n'; if (events_) { - indent_impl(s_service_impl) << "if events <> nil then events.PostRead;" << endl; + indent_impl(s_service_impl) << "if events <> nil then events.PostRead;" << '\n'; } t_struct* xs = tfunction->get_xceptions(); @@ -2503,88 +2501,88 @@ void t_delphi_generator::generate_process_function(t_service* tservice, t_functi } s_service_impl << "args." << prop_name(*f_iter); } - s_service_impl << ");" << endl; + s_service_impl << ");" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { indent_impl(s_service_impl) << "args." << prop_name(*f_iter) - << " := " << empty_value((*f_iter)->get_type()) << ";" << endl; + << " := " << empty_value((*f_iter)->get_type()) << ";" << '\n'; } indent_down_impl(); - indent_impl(s_service_impl) << "except" << endl; + indent_impl(s_service_impl) << "except" << '\n'; indent_up_impl(); for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { indent_impl(s_service_impl) << "on E: " << type_name((*x_iter)->get_type(), true, true) - << " do begin" << endl; + << " do begin" << '\n'; indent_up_impl(); if (!tfunction->is_oneway()) { string factory_name = normalize_clsnm((*x_iter)->get_type()->get_name(), "", true) + "Factory"; indent_impl(s_service_impl) << "ret." << prop_name(*x_iter) << " := E." << factory_name << ";" - << endl; + << '\n'; } indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; } - indent_impl(s_service_impl) << "on E: Exception do begin" << endl; + indent_impl(s_service_impl) << "on E: Exception do begin" << '\n'; indent_up_impl(); if(events_) { - indent_impl(s_service_impl) << "if events <> nil then events.UnhandledError(E);" << endl; + indent_impl(s_service_impl) << "if events <> nil then events.UnhandledError(E);" << '\n'; } if (!tfunction->is_oneway()) { indent_impl(s_service_impl) << "appx := TApplicationExceptionInternalError.Create(E.Message);" - << endl; - indent_impl(s_service_impl) << "try" << endl; + << '\n'; + indent_impl(s_service_impl) << "try" << '\n'; indent_up_impl(); if(events_) { - indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << endl; + indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << '\n'; } indent_impl(s_service_impl) << "Thrift.Protocol.Init( msg, '" << tfunction->get_name() << "', TMessageType.Exception, seqid);" - << endl; - indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << endl; - indent_impl(s_service_impl) << "appx.Write(oprot);" << endl; - indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << endl; - indent_impl(s_service_impl) << "oprot.Transport.Flush();" << endl; + << '\n'; + indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << '\n'; + indent_impl(s_service_impl) << "appx.Write(oprot);" << '\n'; + indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << '\n'; + indent_impl(s_service_impl) << "oprot.Transport.Flush();" << '\n'; if(events_) { - indent_impl(s_service_impl) << "if events <> nil then events.PostWrite;" << endl; + indent_impl(s_service_impl) << "if events <> nil then events.PostWrite;" << '\n'; } - indent_impl(s_service_impl) << "Exit;" << endl; + indent_impl(s_service_impl) << "Exit;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "finally" << endl; + indent_impl(s_service_impl) << "finally" << '\n'; indent_up_impl(); - indent_impl(s_service_impl) << "appx.Free;" << endl; + indent_impl(s_service_impl) << "appx.Free;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; } indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl; + indent_impl(s_service_impl) << "end;" << '\n'; if (!tfunction->is_oneway()) { if (events_) { - indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << endl; + indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << '\n'; } indent_impl(s_service_impl) << "Thrift.Protocol.Init( msg, '" << tfunction->get_name() << "', TMessageType.Reply, seqid); " - << endl; - indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg); " << endl; - indent_impl(s_service_impl) << "ret.Write(oprot);" << endl; - indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << endl; - indent_impl(s_service_impl) << "oprot.Transport.Flush();" << endl; + << '\n'; + indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg); " << '\n'; + indent_impl(s_service_impl) << "ret.Write(oprot);" << '\n'; + indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << '\n'; + indent_impl(s_service_impl) << "oprot.Transport.Flush();" << '\n'; if (events_) { - indent_impl(s_service_impl) << "if events <> nil then events.PostWrite;" << endl; + indent_impl(s_service_impl) << "if events <> nil then events.PostWrite;" << '\n'; } } else if (events_) { - indent_impl(s_service_impl) << "if events <> nil then events.OnewayComplete;" << endl; + indent_impl(s_service_impl) << "if events <> nil then events.OnewayComplete;" << '\n'; } indent_down_impl(); - indent_impl(s_service_impl) << "end;" << endl << endl; + indent_impl(s_service_impl) << "end;" << '\n' << '\n'; } void t_delphi_generator::generate_deserialize_field(ostream& out, @@ -2657,7 +2655,7 @@ void t_delphi_generator::generate_deserialize_field(ostream& out, out << "ReadI32()"; out << ");"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", tfield->get_name().c_str(), @@ -2677,8 +2675,8 @@ void t_delphi_generator::generate_deserialize_struct(ostream& out, typ_name = type_name(tstruct, true, false); } - indent_impl(out) << prefix << name << " := " << typ_name << ".Create;" << endl; - indent_impl(out) << prefix << name << ".Read(iprot);" << endl; + indent_impl(out) << prefix << name << " := " << typ_name << ".Create;" << '\n'; + indent_impl(out) << prefix << name << ".Read(iprot);" << '\n'; } void t_delphi_generator::generate_deserialize_container(ostream& out, @@ -2706,22 +2704,22 @@ void t_delphi_generator::generate_deserialize_container(ostream& out, } else if (ttype->is_list()) { local_var = obj + ": TThriftList;"; } - local_vars << " " << local_var << endl; + local_vars << " " << local_var << '\n'; counter = tmp("_i"); local_var = counter + ": System.Integer;"; - local_vars << " " << local_var << endl; + local_vars << " " << local_var << '\n'; - indent_impl(out) << name << " := " << type_name(ttype, true) << ".Create;" << endl; + indent_impl(out) << name << " := " << type_name(ttype, true) << ".Create;" << '\n'; if (ttype->is_map()) { - indent_impl(out) << obj << " := iprot.ReadMapBegin();" << endl; + indent_impl(out) << obj << " := iprot.ReadMapBegin();" << '\n'; } else if (ttype->is_set()) { - indent_impl(out) << obj << " := iprot.ReadSetBegin();" << endl; + indent_impl(out) << obj << " := iprot.ReadSetBegin();" << '\n'; } else if (ttype->is_list()) { - indent_impl(out) << obj << " := iprot.ReadListBegin();" << endl; + indent_impl(out) << obj << " := iprot.ReadListBegin();" << '\n'; } - indent_impl(out) << "for " << counter << " := 0 to " << obj << ".Count - 1 do begin" << endl; + indent_impl(out) << "for " << counter << " := 0 to " << obj << ".Count - 1 do begin" << '\n'; indent_up_impl(); if (ttype->is_map()) { generate_deserialize_map_element(out, is_xception, (t_map*)ttype, name, local_vars); @@ -2731,14 +2729,14 @@ void t_delphi_generator::generate_deserialize_container(ostream& out, generate_deserialize_list_element(out, is_xception, (t_list*)ttype, name, local_vars); } indent_down_impl(); - indent_impl(out) << "end;" << endl; + indent_impl(out) << "end;" << '\n'; if (ttype->is_map()) { - indent_impl(out) << "iprot.ReadMapEnd();" << endl; + indent_impl(out) << "iprot.ReadMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent_impl(out) << "iprot.ReadSetEnd();" << endl; + indent_impl(out) << "iprot.ReadSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent_impl(out) << "iprot.ReadListEnd();" << endl; + indent_impl(out) << "iprot.ReadListEnd();" << '\n'; } } @@ -2755,13 +2753,13 @@ void t_delphi_generator::generate_deserialize_map_element(ostream& out, t_field fkey(tmap->get_key_type(), key); t_field fval(tmap->get_val_type(), val); - local_vars << " " << declare_field(&fkey) << endl; - local_vars << " " << declare_field(&fval) << endl; + local_vars << " " << declare_field(&fkey) << '\n'; + local_vars << " " << declare_field(&fval) << '\n'; generate_deserialize_field(out, is_xception, &fkey, "", local_vars); generate_deserialize_field(out, is_xception, &fval, "", local_vars); - indent_impl(out) << prefix << ".AddOrSetValue( " << key << ", " << val << ");" << endl; + indent_impl(out) << prefix << ".AddOrSetValue( " << key << ", " << val << ");" << '\n'; } void t_delphi_generator::generate_deserialize_set_element(ostream& out, @@ -2771,9 +2769,9 @@ void t_delphi_generator::generate_deserialize_set_element(ostream& out, ostream& local_vars) { string elem = tmp("_elem"); t_field felem(tset->get_elem_type(), elem); - local_vars << " " << declare_field(&felem) << endl; + local_vars << " " << declare_field(&felem) << '\n'; generate_deserialize_field(out, is_xception, &felem, "", local_vars); - indent_impl(out) << prefix << ".Add(" << elem << ");" << endl; + indent_impl(out) << prefix << ".Add(" << elem << ");" << '\n'; } void t_delphi_generator::generate_deserialize_list_element(ostream& out, @@ -2783,9 +2781,9 @@ void t_delphi_generator::generate_deserialize_list_element(ostream& out, ostream& local_vars) { string elem = tmp("_elem"); t_field felem(tlist->get_elem_type(), elem); - local_vars << " " << declare_field(&felem) << endl; + local_vars << " " << declare_field(&felem) << '\n'; generate_deserialize_field(out, is_xception, &felem, "", local_vars); - indent_impl(out) << prefix << ".Add(" << elem << ");" << endl; + indent_impl(out) << prefix << ".Add(" << elem << ");" << '\n'; } void t_delphi_generator::generate_serialize_field(ostream& out, @@ -2856,7 +2854,7 @@ void t_delphi_generator::generate_serialize_field(ostream& out, } else if (type->is_enum()) { out << "WriteI32(System.Integer(" << name << "));"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO SERIALIZE '%s%s' TYPE '%s'\n", prefix.c_str(), @@ -2871,7 +2869,7 @@ void t_delphi_generator::generate_serialize_struct(ostream& out, ostream& local_vars) { (void)local_vars; (void)tstruct; - out << indent_impl() << prefix << ".Write(oprot);" << endl; + out << indent_impl() << prefix << ".Write(oprot);" << '\n'; } void t_delphi_generator::generate_serialize_container(ostream& out, @@ -2882,42 +2880,42 @@ void t_delphi_generator::generate_serialize_container(ostream& out, string obj; if (ttype->is_map()) { obj = tmp("map"); - local_vars << " " << obj << " : TThriftMap;" << endl; + local_vars << " " << obj << " : TThriftMap;" << '\n'; indent_impl(out) << "Thrift.Protocol.Init( " << obj << ", " << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << prefix - << ".Count);" << endl; - indent_impl(out) << "oprot.WriteMapBegin( " << obj << ");" << endl; + << ".Count);" << '\n'; + indent_impl(out) << "oprot.WriteMapBegin( " << obj << ");" << '\n'; } else if (ttype->is_set()) { obj = tmp("set_"); - local_vars << " " << obj << " : TThriftSet;" << endl; + local_vars << " " << obj << " : TThriftSet;" << '\n'; indent_impl(out) << "Thrift.Protocol.Init( " << obj << ", " << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " << prefix - << ".Count);" << endl; - indent_impl(out) << "oprot.WriteSetBegin( " << obj << ");" << endl; + << ".Count);" << '\n'; + indent_impl(out) << "oprot.WriteSetBegin( " << obj << ");" << '\n'; } else if (ttype->is_list()) { obj = tmp("list_"); - local_vars << " " << obj << " : TThriftList;" << endl; + local_vars << " " << obj << " : TThriftList;" << '\n'; indent_impl(out) << "Thrift.Protocol.Init( " << obj << ", " << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix - << ".Count);" << endl; - indent_impl(out) << "oprot.WriteListBegin( " << obj << ");" << endl; + << ".Count);" << '\n'; + indent_impl(out) << "oprot.WriteListBegin( " << obj << ");" << '\n'; } string iter = tmp("_iter"); if (ttype->is_map()) { - local_vars << " " << iter << ": " << type_name(((t_map*)ttype)->get_key_type()) << ";" << endl; - indent_impl(out) << "for " << iter << " in " << prefix << ".Keys do begin" << endl; + local_vars << " " << iter << ": " << type_name(((t_map*)ttype)->get_key_type()) << ";" << '\n'; + indent_impl(out) << "for " << iter << " in " << prefix << ".Keys do begin" << '\n'; indent_up_impl(); } else if (ttype->is_set()) { local_vars << " " << iter << ": " << type_name(((t_set*)ttype)->get_elem_type()) << ";" - << endl; - indent_impl(out) << "for " << iter << " in " << prefix << " do begin" << endl; + << '\n'; + indent_impl(out) << "for " << iter << " in " << prefix << " do begin" << '\n'; indent_up_impl(); } else if (ttype->is_list()) { local_vars << " " << iter << ": " << type_name(((t_list*)ttype)->get_elem_type()) << ";" - << endl; - indent_impl(out) << "for " << iter << " in " << prefix << " do begin" << endl; + << '\n'; + indent_impl(out) << "for " << iter << " in " << prefix << " do begin" << '\n'; indent_up_impl(); } @@ -2930,14 +2928,14 @@ void t_delphi_generator::generate_serialize_container(ostream& out, } indent_down_impl(); - indent_impl(out) << "end;" << endl; + indent_impl(out) << "end;" << '\n'; if (ttype->is_map()) { - indent_impl(out) << "oprot.WriteMapEnd();" << endl; + indent_impl(out) << "oprot.WriteMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent_impl(out) << "oprot.WriteSetEnd();" << endl; + indent_impl(out) << "oprot.WriteSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent_impl(out) << "oprot.WriteListEnd();" << endl; + indent_impl(out) << "oprot.WriteListEnd();" << '\n'; } } @@ -2989,10 +2987,10 @@ void t_delphi_generator::generate_delphi_property(ostream& out, bool is_xception = ftype->is_xception(); generate_delphi_doc(out, tfield); indent(out) << "property " << prop_name(tfield, struct_is_xception) << ": " - << type_name(ftype, false, true, is_xception, true) - << " read " << prop_name(tfield, struct_is_xception, fieldPrefix) - << " write " << prop_name(tfield, struct_is_xception, "Set") - << ";" << endl; + << type_name(ftype, false, true, is_xception, true) + << " read " << prop_name(tfield, struct_is_xception, fieldPrefix) + << " write " << prop_name(tfield, struct_is_xception, "Set") + << ";" << '\n'; } std::string t_delphi_generator::prop_name(t_field* tfield, bool is_xception, std::string prefix) { @@ -3217,7 +3215,7 @@ string t_delphi_generator::function_signature(t_function* tfunction, } string signature = ""; - + if( for_async) { if (is_void(ttype)) { signature = "function " + prefix + normalize_name(tfunction->get_name(), true, is_xception) + "Async(" @@ -3296,10 +3294,10 @@ string t_delphi_generator::constructor_argument_list(t_struct* tstruct, string c if (line.size() > 80) { if (firstline) { - result << endl << newline_indent; + result << '\n' << newline_indent; firstline = false; } - result << line << endl; + result << line << '\n'; line = newline_indent; } else if (line.size() > 0) { line += " "; @@ -3419,7 +3417,7 @@ void t_delphi_generator::generate_delphi_property_writer_definition(ostream& out indent(out) << "procedure " << prop_name(tfield, is_xception_class, "Set") << "( const Value: " << type_name(ftype, false, true, is_xception, true) << ");" - << endl; + << '\n'; } void t_delphi_generator::generate_delphi_property_reader_definition(ostream& out, @@ -3429,14 +3427,14 @@ void t_delphi_generator::generate_delphi_property_reader_definition(ostream& out bool is_xception = ftype->is_xception(); indent(out) << "function " << prop_name(tfield, is_xception_class, "Get") << ": " - << type_name(ftype, false, true, is_xception, true) << ";" << endl; + << type_name(ftype, false, true, is_xception, true) << ";" << '\n'; } void t_delphi_generator::generate_delphi_isset_reader_writer_definition(ostream& out, t_field* tfield, bool is_xception) { - indent(out) << "function " << prop_name(tfield, is_xception,"Get__isset_") << ": System.Boolean;" << endl; - indent(out) << "procedure " << prop_name(tfield, is_xception, "Set__isset_") << "( const value : System.Boolean);" << endl; + indent(out) << "function " << prop_name(tfield, is_xception,"Get__isset_") << ": System.Boolean;" << '\n'; + indent(out) << "procedure " << prop_name(tfield, is_xception, "Set__isset_") << "( const value : System.Boolean);" << '\n'; } void t_delphi_generator::generate_delphi_clear_union_value(ostream& out, @@ -3460,14 +3458,14 @@ void t_delphi_generator::generate_delphi_clear_union_value(ostream& out, bool is_xception = ftype->is_xception(); indent_impl(out) << "if " << prop_name(tfield, is_xception_class,"F__isset_") << " then begin" - << endl; + << '\n'; indent_up_impl(); - indent_impl(out) << prop_name(tfield, is_xception_class,"F__isset_") << " := False;" << endl; + indent_impl(out) << prop_name(tfield, is_xception_class,"F__isset_") << " := False;" << '\n'; indent_impl(out) << prop_name(tfield, is_xception_class,fieldPrefix) << " := " << "Default( " << type_name(ftype, false, true, is_xception, true) << ");" - << endl; + << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl; + indent_impl(out) << "end;" << '\n'; } void t_delphi_generator::generate_delphi_property_writer_impl(ostream& out, @@ -3488,24 +3486,24 @@ void t_delphi_generator::generate_delphi_property_writer_impl(ostream& out, indent_impl(out) << "procedure " << cls_prefix << name << "." << prop_name(tfield, is_xception_class,"Set") << "( const Value: " << type_name(ftype, false, true, is_xception, true) << ");" - << endl; - indent_impl(out) << "begin" << endl; + << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); if (is_union) { - indent_impl(out) << "ClearUnionValues;" << endl; + indent_impl(out) << "ClearUnionValues;" << '\n'; } if (tfield->get_req() != t_field::T_REQUIRED) { - indent_impl(out) << prop_name(tfield, is_xception_class,"F__isset_") << " := True;" << endl; + indent_impl(out) << prop_name(tfield, is_xception_class,"F__isset_") << " := True;" << '\n'; } - indent_impl(out) << prop_name(tfield, is_xception_class,fieldPrefix) << " := Value;" << endl; + indent_impl(out) << prop_name(tfield, is_xception_class,fieldPrefix) << " := Value;" << '\n'; if (is_xception_class && (!is_xception_factory)) { indent_impl(out) << xception_factory_name << "." << prop_name(tfield, is_xception_class) - << " := Value;" << endl; + << " := Value;" << '\n'; } indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; + indent_impl(out) << "end;" << '\n' << '\n'; } void t_delphi_generator::generate_delphi_property_reader_impl(ostream& out, @@ -3522,13 +3520,13 @@ void t_delphi_generator::generate_delphi_property_reader_impl(ostream& out, indent_impl(out) << "function " << cls_prefix << name << "." << prop_name(tfield, is_xception_class,"Get") << ": " - << type_name(ftype, false, true, is_xception, true) << ";" << endl; - indent_impl(out) << "begin" << endl; + << type_name(ftype, false, true, is_xception, true) << ";" << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); indent_impl(out) << "Result := " << prop_name(tfield, is_xception_class,fieldPrefix) << ";" - << endl; + << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; + indent_impl(out) << "end;" << '\n' << '\n'; } void t_delphi_generator::generate_delphi_isset_reader_writer_impl(ostream& out, @@ -3541,22 +3539,22 @@ void t_delphi_generator::generate_delphi_isset_reader_writer_impl(ostream& out, (void)type; string isset_name = prop_name(tfield, is_xception, "__isset_"); - + indent_impl(out) << "function " << cls_prefix << name << "." - << "Get" << isset_name << ": System.Boolean;" << endl; - indent_impl(out) << "begin" << endl; + << "Get" << isset_name << ": System.Boolean;" << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); - indent_impl(out) << "Result := " << fieldPrefix << isset_name << ";" << endl; + indent_impl(out) << "Result := " << fieldPrefix << isset_name << ";" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; - + indent_impl(out) << "end;" << '\n' << '\n'; + indent_impl(out) << "procedure " << cls_prefix << name << "." - << "Set" << isset_name << "( const value: System.Boolean);" << endl; - indent_impl(out) << "begin" << endl; + << "Set" << isset_name << "( const value: System.Boolean);" << '\n'; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); - indent_impl(out) << fieldPrefix << isset_name << " := value;" << endl; + indent_impl(out) << fieldPrefix << isset_name << " := value;" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; + indent_impl(out) << "end;" << '\n' << '\n'; } void t_delphi_generator::generate_delphi_create_exception_impl(ostream& out, @@ -3569,14 +3567,14 @@ void t_delphi_generator::generate_delphi_create_exception_impl(ostream& out, string cls_nm = type_name(tstruct, true, false, is_exception, is_exception); indent_impl(out) << "function " << cls_nm << ".CreateException: " << exception_cls_nm << ";" - << endl; + << '\n'; - indent_impl(out) << "begin" << endl; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); - indent_impl(out) << "Result := " << exception_cls_nm << ".Create;" << endl; + indent_impl(out) << "Result := " << exception_cls_nm << ".Create;" << '\n'; string factory_name = normalize_clsnm(tstruct->get_name(), "", true) + "Factory"; - indent_impl(out) << "Result.F" << factory_name << " := Self;" << endl; + indent_impl(out) << "Result.F" << factory_name << " := Self;" << '\n'; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -3586,20 +3584,20 @@ void t_delphi_generator::generate_delphi_create_exception_impl(ostream& out, for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { propname = prop_name(*f_iter, is_exception); if ((*f_iter)->get_req() != t_field::T_REQUIRED) { - indent_impl(out) << "if " << prop_name(*f_iter, is_exception,"__isset_") << " then begin" << endl; + indent_impl(out) << "if " << prop_name(*f_iter, is_exception,"__isset_") << " then begin" << '\n'; indent_up_impl(); } - indent_impl(out) << "Result." << propname << " := " << propname << ";" << endl; + indent_impl(out) << "Result." << propname << " := " << propname << ";" << '\n'; if ((*f_iter)->get_req() != t_field::T_REQUIRED) { indent_down_impl(); - indent_impl(out) << "end;" << endl; + indent_impl(out) << "end;" << '\n'; } } - indent_impl(out) << "Result.UpdateMessageProperty;" << endl; + indent_impl(out) << "Result.UpdateMessageProperty;" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; + indent_impl(out) << "end;" << '\n' << '\n'; } void t_delphi_generator::generate_delphi_struct_reader_impl(ostream& out, @@ -3614,53 +3612,53 @@ void t_delphi_generator::generate_delphi_struct_reader_impl(ostream& out, const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - indent_impl(code_block) << "begin" << endl; + indent_impl(code_block) << "begin" << '\n'; indent_up_impl(); - indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << endl; - indent_impl(code_block) << "tracker := iprot.NextRecursionLevel;" << endl; + indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << '\n'; + indent_impl(code_block) << "tracker := iprot.NextRecursionLevel;" << '\n'; // local bools for required fields for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { indent_impl(local_vars) << prop_name(*f_iter, is_exception,"_req_isset_") << " : System.Boolean;" - << endl; + << '\n'; indent_impl(code_block) << prop_name(*f_iter, is_exception,"_req_isset_") << " := FALSE;" - << endl; + << '\n'; } } - indent_impl(code_block) << "struc := iprot.ReadStructBegin;" << endl; + indent_impl(code_block) << "struc := iprot.ReadStructBegin;" << '\n'; - indent_impl(code_block) << "try" << endl; + indent_impl(code_block) << "try" << '\n'; indent_up_impl(); - indent_impl(code_block) << "while (true) do begin" << endl; + indent_impl(code_block) << "while (true) do begin" << '\n'; indent_up_impl(); - indent_impl(code_block) << "field_ := iprot.ReadFieldBegin();" << endl; + indent_impl(code_block) << "field_ := iprot.ReadFieldBegin();" << '\n'; - indent_impl(code_block) << "if (field_.Type_ = TType.Stop) then Break;" << endl; + indent_impl(code_block) << "if (field_.Type_ = TType.Stop) then Break;" << '\n'; bool first = true; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if (first) { - code_block << endl; - indent_impl(code_block) << "case field_.ID of" << endl; + code_block << '\n'; + indent_impl(code_block) << "case field_.ID of" << '\n'; indent_up_impl(); } first = false; if (f_iter != fields.begin()) { - code_block << endl; + code_block << '\n'; } - indent_impl(code_block) << (*f_iter)->get_key() << ": begin" << endl; + indent_impl(code_block) << (*f_iter)->get_key() << ": begin" << '\n'; indent_up_impl(); indent_impl(code_block) << "if (field_.Type_ = " << type_to_enum((*f_iter)->get_type()) - << ") then begin" << endl; + << ") then begin" << '\n'; indent_up_impl(); generate_deserialize_field(code_block, is_exception, *f_iter, "Self.", local_vars); @@ -3668,82 +3666,82 @@ void t_delphi_generator::generate_delphi_struct_reader_impl(ostream& out, // required field? if ((*f_iter)->get_req() == t_field::T_REQUIRED) { indent_impl(code_block) << prop_name(*f_iter, is_exception,"_req_isset_") << " := TRUE;" - << endl; + << '\n'; } indent_down_impl(); - indent_impl(code_block) << "end else begin" << endl; + indent_impl(code_block) << "end else begin" << '\n'; indent_up_impl(); - indent_impl(code_block) << "TProtocolUtil.Skip(iprot, field_.Type_);" << endl; + indent_impl(code_block) << "TProtocolUtil.Skip(iprot, field_.Type_);" << '\n'; indent_down_impl(); - indent_impl(code_block) << "end;" << endl; + indent_impl(code_block) << "end;" << '\n'; indent_down_impl(); indent_impl(code_block) << "end;"; } if (!first) { - code_block << endl; + code_block << '\n'; indent_down_impl(); - indent_impl(code_block) << "else" << endl; + indent_impl(code_block) << "else" << '\n'; indent_up_impl(); } - indent_impl(code_block) << "TProtocolUtil.Skip(iprot, field_.Type_);" << endl; + indent_impl(code_block) << "TProtocolUtil.Skip(iprot, field_.Type_);" << '\n'; if (!first) { indent_down_impl(); - indent_impl(code_block) << "end;" << endl; + indent_impl(code_block) << "end;" << '\n'; } - indent_impl(code_block) << "iprot.ReadFieldEnd;" << endl; + indent_impl(code_block) << "iprot.ReadFieldEnd;" << '\n'; indent_down_impl(); - indent_impl(code_block) << "end;" << endl; + indent_impl(code_block) << "end;" << '\n'; indent_down_impl(); - indent_impl(code_block) << "finally" << endl; + indent_impl(code_block) << "finally" << '\n'; indent_up_impl(); - indent_impl(code_block) << "iprot.ReadStructEnd;" << endl; + indent_impl(code_block) << "iprot.ReadStructEnd;" << '\n'; indent_down_impl(); - indent_impl(code_block) << "end;" << endl; + indent_impl(code_block) << "end;" << '\n'; // all required fields have been read? first = true; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { if(first) { - code_block << endl; + code_block << '\n'; first = false; } - indent_impl(code_block) << "if not " << prop_name(*f_iter, is_exception,"_req_isset_") << endl; + indent_impl(code_block) << "if not " << prop_name(*f_iter, is_exception,"_req_isset_") << '\n'; indent_impl(code_block) << "then raise TProtocolExceptionInvalidData.Create(" << "'required field " << prop_name(*f_iter, is_exception) << " not set');" - << endl; + << '\n'; } } - + if( is_exception && (!is_x_factory)) { - code_block << endl; - indent_impl(code_block) << "UpdateMessageProperty;" << endl; + code_block << '\n'; + indent_impl(code_block) << "UpdateMessageProperty;" << '\n'; } indent_down_impl(); - indent_impl(code_block) << "end;" << endl << endl; + indent_impl(code_block) << "end;" << '\n' << '\n'; string cls_nm; cls_nm = type_name(tstruct, true, is_exception && (!is_x_factory), is_x_factory, is_x_factory); indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Read( const iprot: IProtocol);" - << endl; - indent_impl(out) << "var" << endl; + << '\n'; + indent_impl(out) << "var" << '\n'; indent_up_impl(); - indent_impl(out) << "field_ : TThriftField;" << endl; - indent_impl(out) << "struc : TThriftStruct;" << endl; + indent_impl(out) << "field_ : TThriftField;" << '\n'; + indent_impl(out) << "struc : TThriftStruct;" << '\n'; indent_down_impl(); - out << local_vars.str() << endl; + out << local_vars.str() << '\n'; out << code_block.str(); } @@ -3760,51 +3758,51 @@ void t_delphi_generator::generate_delphi_struct_result_writer_impl(ostream& out, const vector& fields = tstruct->get_sorted_members(); vector::const_iterator f_iter; - indent_impl(code_block) << "begin" << endl; + indent_impl(code_block) << "begin" << '\n'; indent_up_impl(); - indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << endl; - indent_impl(code_block) << "tracker := oprot.NextRecursionLevel;" << endl; + indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << '\n'; + indent_impl(code_block) << "tracker := oprot.NextRecursionLevel;" << '\n'; - indent_impl(code_block) << "Thrift.Protocol.Init( struc, '" << name << "');" << endl; - indent_impl(code_block) << "oprot.WriteStructBegin(struc);" << endl; + indent_impl(code_block) << "Thrift.Protocol.Init( struc, '" << name << "');" << '\n'; + indent_impl(code_block) << "oprot.WriteStructBegin(struc);" << '\n'; if (fields.size() > 0) { - indent_impl(code_block) << "Thrift.Protocol.Init( field_);" << endl; + indent_impl(code_block) << "Thrift.Protocol.Init( field_);" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { indent_impl(code_block) << "if (" << prop_name(*f_iter, is_exception,"__isset_") << ") then" - << endl; - indent_impl(code_block) << "begin" << endl; + << '\n'; + indent_impl(code_block) << "begin" << '\n'; indent_up_impl(); - indent_impl(code_block) << "field_.Name := '" << (*f_iter)->get_name() << "';" << endl; + indent_impl(code_block) << "field_.Name := '" << (*f_iter)->get_name() << "';" << '\n'; indent_impl(code_block) << "field_.Type_ := " << type_to_enum((*f_iter)->get_type()) << ";" - << endl; - indent_impl(code_block) << "field_.ID := " << (*f_iter)->get_key() << ";" << endl; - indent_impl(code_block) << "oprot.WriteFieldBegin(field_);" << endl; + << '\n'; + indent_impl(code_block) << "field_.ID := " << (*f_iter)->get_key() << ";" << '\n'; + indent_impl(code_block) << "oprot.WriteFieldBegin(field_);" << '\n'; generate_serialize_field(code_block, is_exception, *f_iter, "Self.", local_vars); - indent_impl(code_block) << "oprot.WriteFieldEnd();" << endl; + indent_impl(code_block) << "oprot.WriteFieldEnd();" << '\n'; indent_down_impl(); } } - indent_impl(code_block) << "oprot.WriteFieldStop();" << endl; - indent_impl(code_block) << "oprot.WriteStructEnd();" << endl; + indent_impl(code_block) << "oprot.WriteFieldStop();" << '\n'; + indent_impl(code_block) << "oprot.WriteStructEnd();" << '\n'; indent_down_impl(); - indent_impl(code_block) << "end;" << endl << endl; + indent_impl(code_block) << "end;" << '\n' << '\n'; string cls_nm; cls_nm = type_name(tstruct, true, is_exception && (!is_x_factory), is_x_factory, is_x_factory); indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Write( const oprot: IProtocol);" - << endl; - indent_impl(out) << "var" << endl; + << '\n'; + indent_impl(out) << "var" << '\n'; indent_up_impl(); - indent_impl(out) << "struc : TThriftStruct;" << endl; + indent_impl(out) << "struc : TThriftStruct;" << '\n'; if (fields.size() > 0) { - indent_impl(out) << "field_ : TThriftField;" << endl; + indent_impl(out) << "field_ : TThriftField;" << '\n'; } out << local_vars.str(); @@ -3825,17 +3823,17 @@ void t_delphi_generator::generate_delphi_struct_writer_impl(ostream& out, const vector& fields = tstruct->get_sorted_members(); vector::const_iterator f_iter; - indent_impl(code_block) << "begin" << endl; + indent_impl(code_block) << "begin" << '\n'; indent_up_impl(); - indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << endl; - indent_impl(code_block) << "tracker := oprot.NextRecursionLevel;" << endl; + indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << '\n'; + indent_impl(code_block) << "tracker := oprot.NextRecursionLevel;" << '\n'; - indent_impl(code_block) << "Thrift.Protocol.Init( struc, '" << name << "');" << endl; - indent_impl(code_block) << "oprot.WriteStructBegin(struc);" << endl; + indent_impl(code_block) << "Thrift.Protocol.Init( struc, '" << name << "');" << '\n'; + indent_impl(code_block) << "oprot.WriteStructBegin(struc);" << '\n'; if (fields.size() > 0) { - indent_impl(code_block) << "Thrift.Protocol.Init( field_);" << endl; + indent_impl(code_block) << "Thrift.Protocol.Init( field_);" << '\n'; } for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { @@ -3846,54 +3844,54 @@ void t_delphi_generator::generate_delphi_struct_writer_impl(ostream& out, bool has_isset = (!is_required); if (is_required && null_allowed) { null_allowed = false; - indent_impl(code_block) << "if (Self." << fieldname << " = nil)" << endl; + indent_impl(code_block) << "if (Self." << fieldname << " = nil)" << '\n'; indent_impl(code_block) << "then raise TProtocolExceptionInvalidData.Create(" << "'required field " << fieldname << " not set');" - << endl; + << '\n'; } if (null_allowed) { indent_impl(code_block) << "if (Self." << fieldname << " <> nil)"; if (has_isset) { code_block << " and " << isset_name; } - code_block << " then begin" << endl; + code_block << " then begin" << '\n'; indent_up_impl(); } else { if (has_isset) { - indent_impl(code_block) << "if (" << isset_name << ") then begin" << endl; + indent_impl(code_block) << "if (" << isset_name << ") then begin" << '\n'; indent_up_impl(); } } - indent_impl(code_block) << "field_.Name := '" << (*f_iter)->get_name() << "';" << endl; + indent_impl(code_block) << "field_.Name := '" << (*f_iter)->get_name() << "';" << '\n'; indent_impl(code_block) << "field_.Type_ := " << type_to_enum((*f_iter)->get_type()) << ";" - << endl; - indent_impl(code_block) << "field_.ID := " << (*f_iter)->get_key() << ";" << endl; - indent_impl(code_block) << "oprot.WriteFieldBegin(field_);" << endl; + << '\n'; + indent_impl(code_block) << "field_.ID := " << (*f_iter)->get_key() << ";" << '\n'; + indent_impl(code_block) << "oprot.WriteFieldBegin(field_);" << '\n'; generate_serialize_field(code_block, is_exception, *f_iter, "Self.", local_vars); - indent_impl(code_block) << "oprot.WriteFieldEnd();" << endl; + indent_impl(code_block) << "oprot.WriteFieldEnd();" << '\n'; if (null_allowed || has_isset) { indent_down_impl(); - indent_impl(code_block) << "end;" << endl; + indent_impl(code_block) << "end;" << '\n'; } } - indent_impl(code_block) << "oprot.WriteFieldStop();" << endl; - indent_impl(code_block) << "oprot.WriteStructEnd();" << endl; + indent_impl(code_block) << "oprot.WriteFieldStop();" << '\n'; + indent_impl(code_block) << "oprot.WriteStructEnd();" << '\n'; indent_down_impl(); - indent_impl(code_block) << "end;" << endl << endl; + indent_impl(code_block) << "end;" << '\n' << '\n'; string cls_nm; cls_nm = type_name(tstruct, true, is_exception && (!is_x_factory), is_x_factory, is_x_factory); indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Write( const oprot: IProtocol);" - << endl; - indent_impl(out) << "var" << endl; + << '\n'; + indent_impl(out) << "var" << '\n'; indent_up_impl(); - indent_impl(out) << "struc : TThriftStruct;" << endl; + indent_impl(out) << "struc : TThriftStruct;" << '\n'; if (fields.size() > 0) { - indent_impl(out) << "field_ : TThriftField;" << endl; + indent_impl(out) << "field_ : TThriftField;" << '\n'; } out << local_vars.str(); indent_down_impl(); @@ -3921,28 +3919,28 @@ void t_delphi_generator::generate_delphi_struct_tostring_impl(ostream& out, string tmp_first = tmp("_first"); bool useFirstFlag = false; - indent_impl(out) << "function " << cls_prefix << cls_nm << ".ToString: string;" << endl; - indent_impl(out) << "var" << endl; + indent_impl(out) << "function " << cls_prefix << cls_nm << ".ToString: string;" << '\n'; + indent_impl(out) << "var" << '\n'; indent_up_impl(); - indent_impl(out) << tmp_sb << " : TThriftStringBuilder;" << endl; + indent_impl(out) << tmp_sb << " : TThriftStringBuilder;" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool is_optional = ((*f_iter)->get_req() != t_field::T_REQUIRED); if (is_optional) { - indent_impl(out) << tmp_first << " : System.Boolean;" << endl; + indent_impl(out) << tmp_first << " : System.Boolean;" << '\n'; useFirstFlag = true; } break; } indent_down_impl(); - indent_impl(out) << "begin" << endl; + indent_impl(out) << "begin" << '\n'; indent_up_impl(); - indent_impl(out) << tmp_sb << " := TThriftStringBuilder.Create('(');" << endl; - indent_impl(out) << "try" << endl; + indent_impl(out) << tmp_sb << " := TThriftStringBuilder.Create('(');" << '\n'; + indent_impl(out) << "try" << '\n'; indent_up_impl(); if (useFirstFlag) { - indent_impl(out) << tmp_first << " := TRUE;" << endl; + indent_impl(out) << tmp_first << " := TRUE;" << '\n'; } bool had_required = false; // set to true after first required field has been processed @@ -3955,26 +3953,26 @@ void t_delphi_generator::generate_delphi_struct_tostring_impl(ostream& out, if (is_optional) { out << " and " << prop_name(*f_iter, is_exception,"__isset_"); } - out << " then begin" << endl; + out << " then begin" << '\n'; indent_up_impl(); } else { if (is_optional) { indent_impl(out) << "if (" << prop_name(*f_iter, is_exception, "__isset_") << ") then begin" - << endl; + << '\n'; indent_up_impl(); } } if (useFirstFlag && (!had_required)) { - indent_impl(out) << "if not " << tmp_first << " then " << tmp_sb << ".Append(',');" << endl; + indent_impl(out) << "if not " << tmp_first << " then " << tmp_sb << ".Append(',');" << '\n'; if (is_optional) { - indent_impl(out) << tmp_first << " := FALSE;" << endl; + indent_impl(out) << tmp_first << " := FALSE;" << '\n'; } indent_impl(out) << tmp_sb << ".Append('" << prop_name((*f_iter), is_exception) << ": ');" - << endl; + << '\n'; } else { indent_impl(out) << tmp_sb << ".Append(', " << prop_name((*f_iter), is_exception) << ": ');" - << endl; + << '\n'; } t_type* ttype = (*f_iter)->get_type(); @@ -3985,23 +3983,23 @@ void t_delphi_generator::generate_delphi_struct_tostring_impl(ostream& out, if (ttype->is_xception() || ttype->is_struct()) { indent_impl(out) << "if (Self." << prop_name((*f_iter), is_exception) << " = nil) then " << tmp_sb << ".Append('') else " << tmp_sb << ".Append( Self." - << prop_name((*f_iter), is_exception) << ".ToString());" << endl; + << prop_name((*f_iter), is_exception) << ".ToString());" << '\n'; } else if (ttype->is_enum()) { - indent_impl(out) << tmp_sb << ".Append(EnumUtils<" - << type_name(ttype, false, true, false, false) - << ">.ToString( System.Ord( Self." - << prop_name((*f_iter), is_exception) << ")));" << endl; + indent_impl(out) << tmp_sb << ".Append(EnumUtils<" + << type_name(ttype, false, true, false, false) + << ">.ToString( System.Ord( Self." + << prop_name((*f_iter), is_exception) << ")));" << '\n'; } else if (ttype->is_uuid()) { indent_impl(out) << tmp_sb << ".Append( GUIDToString(Self." << prop_name((*f_iter), is_exception) << "));" - << endl; + << '\n'; } else { indent_impl(out) << tmp_sb << ".Append( Self." << prop_name((*f_iter), is_exception) << ");" - << endl; + << '\n'; } if (null_allowed || is_optional) { indent_down_impl(); - indent_impl(out) << "end;" << endl; + indent_impl(out) << "end;" << '\n'; } if (!is_optional) { @@ -4009,21 +4007,21 @@ void t_delphi_generator::generate_delphi_struct_tostring_impl(ostream& out, } } - indent_impl(out) << tmp_sb << ".Append(')');" << endl; - indent_impl(out) << "Result := " << tmp_sb << ".ToString;" << endl; + indent_impl(out) << tmp_sb << ".Append(')');" << '\n'; + indent_impl(out) << "Result := " << tmp_sb << ".ToString;" << '\n'; if (useFirstFlag) { - indent_impl(out) << "if " << tmp_first << " then {prevent warning};" << endl; + indent_impl(out) << "if " << tmp_first << " then {prevent warning};" << '\n'; } indent_down_impl(); - indent_impl(out) << "finally" << endl; + indent_impl(out) << "finally" << '\n'; indent_up_impl(); - indent_impl(out) << tmp_sb << ".Free;" << endl; + indent_impl(out) << tmp_sb << ".Free;" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl; + indent_impl(out) << "end;" << '\n'; indent_down_impl(); - indent_impl(out) << "end;" << endl << endl; + indent_impl(out) << "end;" << '\n' << '\n'; } bool t_delphi_generator::is_void(t_type* type) { diff --git a/compiler/cpp/src/thrift/generate/t_erl_generator.cc b/compiler/cpp/src/thrift/generate/t_erl_generator.cc index 72939729668..f28c7fd81d5 100644 --- a/compiler/cpp/src/thrift/generate/t_erl_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_erl_generator.cc @@ -39,8 +39,6 @@ using std::string; using std::stringstream; using std::vector; -static const std::string endl = "\n"; // avoid ostream << std::endl flushes - /** * Erlang code generator. * @@ -268,14 +266,14 @@ void t_erl_generator::init_generator() { hrl_header(f_types_hrl_file_, program_module_name + "_types"); - f_types_file_ << erl_autogen_comment() << endl - << "-module(" << program_module_name << "_types)." << endl - << erl_imports() << endl; + f_types_file_ << erl_autogen_comment() << '\n' + << "-module(" << program_module_name << "_types)." << '\n' + << erl_imports() << '\n'; - f_types_file_ << "-include(\"" << program_module_name << "_types.hrl\")." << endl - << endl; + f_types_file_ << "-include(\"" << program_module_name << "_types.hrl\")." << '\n' + << '\n'; - f_types_hrl_file_ << render_includes() << endl; + f_types_hrl_file_ << render_includes() << '\n'; // consts files string f_consts_name = get_out_dir() + program_module_name + "_constants.erl"; @@ -284,28 +282,28 @@ void t_erl_generator::init_generator() { f_consts_file_.open(f_consts_name.c_str()); f_consts_hrl_file_.open(f_consts_hrl_name.c_str()); - f_consts_file_ << erl_autogen_comment() << endl - << "-module(" << program_module_name << "_constants)." << endl - << erl_imports() << endl - << "-include(\"" << program_module_name << "_types.hrl\")." << endl - << endl; + f_consts_file_ << erl_autogen_comment() << '\n' + << "-module(" << program_module_name << "_constants)." << '\n' + << erl_imports() << '\n' + << "-include(\"" << program_module_name << "_types.hrl\")." << '\n' + << '\n'; - f_consts_hrl_file_ << erl_autogen_comment() << endl << erl_imports() << endl - << "-include(\"" << program_module_name << "_types.hrl\")." << endl << endl; + f_consts_hrl_file_ << erl_autogen_comment() << '\n' << erl_imports() << '\n' + << "-include(\"" << program_module_name << "_types.hrl\")." << '\n' << '\n'; } /** * Boilerplate at beginning and end of header files */ void t_erl_generator::hrl_header(ostream& out, string name) { - out << erl_autogen_comment() << endl - << "-ifndef(_" << name << "_included)." << endl << "-define(_" << name << "_included, yeah)." - << endl; + out << erl_autogen_comment() << '\n' + << "-ifndef(_" << name << "_included)." << '\n' << "-define(_" << name << "_included, yeah)." + << '\n'; } void t_erl_generator::hrl_footer(ostream& out, string name) { (void)name; - out << "-endif." << endl; + out << "-endif." << '\n'; } /** @@ -365,13 +363,13 @@ void t_erl_generator::close_generator() { export_types_string("struct_names", 0); export_types_string("exception_names", 0); - f_types_file_ << "-export([" << export_types_lines_.str() << "])." << endl << endl; + f_types_file_ << "-export([" << export_types_lines_.str() << "])." << '\n' << '\n'; f_types_file_ << f_info_.str(); - f_types_file_ << "struct_info(_) -> erlang:error(function_clause)." << endl << endl; + f_types_file_ << "struct_info(_) -> erlang:error(function_clause)." << '\n' << '\n'; f_types_file_ << f_info_ext_.str(); - f_types_file_ << "struct_info_ext(_) -> erlang:error(function_clause)." << endl << endl; + f_types_file_ << "struct_info_ext(_) -> erlang:error(function_clause)." << '\n' << '\n'; generate_const_functions(); @@ -527,10 +525,10 @@ void t_erl_generator::generate_enum(t_enum* tenum) { string name = (*c_iter)->get_name(); indent(f_types_hrl_file_) << "-define(" << constify(make_safe_for_module_name(program_name_)) << "_" << constify(tenum->get_name()) << "_" << constify(name) << ", " - << value << ")." << endl; + << value << ")." << '\n'; } - f_types_hrl_file_ << endl; + f_types_hrl_file_ << '\n'; } void t_erl_generator::generate_enum_info(t_enum* tenum){ @@ -551,7 +549,7 @@ void t_erl_generator::generate_enum_info(t_enum* tenum){ } indent_down(); } - f_types_file_ << "\n"; + f_types_file_ << '\n'; indent(f_types_file_) << "];\n\n"; indent_down(); } @@ -579,7 +577,7 @@ void t_erl_generator::generate_const(t_const* tconst) { v_consts_.push_back(tconst); f_consts_hrl_file_ << "-define(" << constify(make_safe_for_module_name(program_name_)) << "_" - << constify(name) << ", " << render_const_value(type, value) << ")." << endl << endl; + << constify(name) << ", " << render_const_value(type, value) << ")." << '\n' << '\n'; } /** @@ -809,7 +807,7 @@ void t_erl_generator::generate_erl_struct(t_struct* tstruct, bool is_exception) * @param tstruct The struct definition */ void t_erl_generator::generate_erl_struct_definition(ostream& out, t_struct* tstruct) { - indent(out) << "%% struct " << type_name(tstruct) << endl << endl; + indent(out) << "%% struct " << type_name(tstruct) << '\n' << '\n'; std::stringstream buf; buf << indent() << "-record(" << type_name(tstruct) << ", {"; @@ -819,13 +817,13 @@ void t_erl_generator::generate_erl_struct_definition(ostream& out, t_struct* tst for (vector::const_iterator m_iter = members.begin(); m_iter != members.end();) { generate_erl_struct_member(buf, *m_iter); if (++m_iter != members.end()) { - buf << "," << endl << field_indent; + buf << "," << '\n' << field_indent; } } buf << "})."; - out << buf.str() << endl; - out << "-type " + type_name(tstruct) << "() :: #" + type_name(tstruct) + "{}." << endl << endl; + out << buf.str() << '\n'; + out << "-type " + type_name(tstruct) << "() :: #" + type_name(tstruct) + "{}." << '\n' << '\n'; } /** @@ -871,19 +869,19 @@ string t_erl_generator::render_member_value(t_field* field) { * Generates the read method for a struct */ void t_erl_generator::generate_erl_struct_info(ostream& out, t_struct* tstruct) { - indent(out) << "struct_info(" << type_name(tstruct) << ") ->" << endl; + indent(out) << "struct_info(" << type_name(tstruct) << ") ->" << '\n'; indent_up(); - out << indent() << render_type_term(tstruct, true) << ";" << endl; + out << indent() << render_type_term(tstruct, true) << ";" << '\n'; indent_down(); - out << endl; + out << '\n'; } void t_erl_generator::generate_erl_extended_struct_info(ostream& out, t_struct* tstruct) { - indent(out) << "struct_info_ext(" << type_name(tstruct) << ") ->" << endl; + indent(out) << "struct_info_ext(" << type_name(tstruct) << ") ->" << '\n'; indent_up(); - out << indent() << render_type_term(tstruct, true, true) << ";" << endl; + out << indent() << render_type_term(tstruct, true, true) << ";" << '\n'; indent_down(); - out << endl; + out << '\n'; } /** @@ -909,11 +907,11 @@ void t_erl_generator::generate_service(t_service* tservice) { if (tservice->get_extends() != nullptr) { f_service_hrl_ << "-include(\"" << make_safe_for_module_name(tservice->get_extends()->get_name()) - << "_thrift.hrl\"). % inherit " << endl; + << "_thrift.hrl\"). % inherit " << '\n'; } f_service_hrl_ << "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")." - << endl << endl; + << '\n' << '\n'; // Generate the three main parts of the service (well, two for now in PHP) generate_service_helpers(tservice); // cpiro: New Erlang Order @@ -924,13 +922,13 @@ void t_erl_generator::generate_service(t_service* tservice) { // indent_down(); - f_service_file_ << erl_autogen_comment() << endl << "-module(" << service_name_ << "_thrift)." - << endl << "-behaviour(thrift_service)." << endl << endl << erl_imports() << endl; + f_service_file_ << erl_autogen_comment() << '\n' << "-module(" << service_name_ << "_thrift)." + << '\n' << "-behaviour(thrift_service)." << '\n' << '\n' << erl_imports() << '\n'; f_service_file_ << "-include(\"" << make_safe_for_module_name(tservice->get_name()) - << "_thrift.hrl\")." << endl << endl; + << "_thrift.hrl\")." << '\n' << '\n'; - f_service_file_ << "-export([" << export_lines_.str() << "])." << endl << endl; + f_service_file_ << "-export([" << export_lines_.str() << "])." << '\n' << '\n'; f_service_file_ << f_service_.str(); @@ -946,7 +944,7 @@ void t_erl_generator::generate_service_metadata(t_service* tservice) { vector functions = tservice->get_functions(); size_t num_functions = functions.size(); - indent(f_service_) << "function_names() -> " << endl; + indent(f_service_) << "function_names() -> " << '\n'; indent_up(); indent(f_service_) << "["; @@ -972,14 +970,14 @@ void t_erl_generator::generate_service_helpers(t_service* tservice) { vector::iterator f_iter; // indent(f_service_) << - // "% HELPER FUNCTIONS AND STRUCTURES" << endl << endl; + // "% HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n'; export_string("struct_info", 1); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_erl_function_helpers(*f_iter); } - f_service_ << "struct_info(_) -> erlang:error(function_clause)." << endl; + f_service_ << "struct_info(_) -> erlang:error(function_clause)." << '\n'; } /** @@ -1002,26 +1000,26 @@ void t_erl_generator::generate_service_interface(t_service* tservice) { vector functions = tservice->get_functions(); vector::iterator f_iter; - f_service_ << "%%% interface" << endl; + f_service_ << "%%% interface" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - f_service_ << indent() << "% " << function_signature(*f_iter) << endl; + f_service_ << indent() << "% " << function_signature(*f_iter) << '\n'; generate_function_info(tservice, *f_iter); } // Inheritance - pass unknown functions to base class if (tservice->get_extends() != nullptr) { - indent(f_service_) << "function_info(Function, InfoType) ->" << endl; + indent(f_service_) << "function_info(Function, InfoType) ->" << '\n'; indent_up(); indent(f_service_) << make_safe_for_module_name(tservice->get_extends()->get_name()) - << "_thrift:function_info(Function, InfoType)." << endl; + << "_thrift:function_info(Function, InfoType)." << '\n'; indent_down(); } else { // return function_clause error for non-existent functions - indent(f_service_) << "function_info(_Func, _Info) -> erlang:error(function_clause)." << endl; + indent(f_service_) << "function_info(_Func, _Info) -> erlang:error(function_clause)." << '\n'; } - indent(f_service_) << endl; + indent(f_service_) << '\n'; } /** @@ -1036,30 +1034,30 @@ void t_erl_generator::generate_function_info(t_service* tservice, t_function* tf t_struct* arg_struct = tfunction->get_arglist(); // function_info(Function, params_type): - indent(f_service_) << "function_info(" << name_atom << ", params_type) ->" << endl; + indent(f_service_) << "function_info(" << name_atom << ", params_type) ->" << '\n'; indent_up(); - indent(f_service_) << render_type_term(arg_struct, true) << ";" << endl; + indent(f_service_) << render_type_term(arg_struct, true) << ";" << '\n'; indent_down(); // function_info(Function, reply_type): - indent(f_service_) << "function_info(" << name_atom << ", reply_type) ->" << endl; + indent(f_service_) << "function_info(" << name_atom << ", reply_type) ->" << '\n'; indent_up(); if (!tfunction->get_returntype()->is_void()) - indent(f_service_) << render_type_term(tfunction->get_returntype(), false) << ";" << endl; + indent(f_service_) << render_type_term(tfunction->get_returntype(), false) << ";" << '\n'; else if (tfunction->is_oneway()) - indent(f_service_) << "oneway_void;" << endl; + indent(f_service_) << "oneway_void;" << '\n'; else indent(f_service_) << "{struct, []}" - << ";" << endl; + << ";" << '\n'; indent_down(); // function_info(Function, exceptions): - indent(f_service_) << "function_info(" << name_atom << ", exceptions) ->" << endl; + indent(f_service_) << "function_info(" << name_atom << ", exceptions) ->" << '\n'; indent_up(); - indent(f_service_) << render_type_term(xs, true) << ";" << endl; + indent(f_service_) << render_type_term(xs, true) << ";" << '\n'; indent_down(); } @@ -1246,11 +1244,11 @@ std::string t_erl_generator::render_type_term(t_type* type, } if (++i != end) { - buf << "," << endl << field_indent; + buf << "," << '\n' << field_indent; } } - buf << "]}" << endl; + buf << "]}" << '\n'; return buf.str(); } else { return "{struct, {" + atomify(type_module(type)) + ", " + type_name(type) + "}}"; diff --git a/compiler/cpp/src/thrift/generate/t_generator.cc b/compiler/cpp/src/thrift/generate/t_generator.cc index 970281e74cf..68602377ed5 100644 --- a/compiler/cpp/src/thrift/generate/t_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_generator.cc @@ -77,8 +77,8 @@ void t_generator::generate_program() { } std::set t_generator::lang_keywords_for_validation() const { - // Nothing by default. It makes no sense to restrict the whole world to use non-PHP keywords only. - // Override on a per-generator(!) basis if you cannot live without it, e.g. that particular language has no + // Nothing by default. It makes no sense to restrict the whole world to use non-PHP keywords only. + // Override on a per-generator(!) basis if you cannot live without it, e.g. that particular language has no // mechanism or way to deal with it properly, so we absolutely need to fail on it as the last possible resort. return {}; } @@ -172,11 +172,11 @@ void t_generator::generate_docstring_comment(ostream& out, docs.getline(line, 1024); if (strlen(line) > 0) { - indent(out) << line_prefix << line << std::endl; + indent(out) << line_prefix << line << '\n'; } else if (line_prefix.empty()){ - out << std::endl; + out << '\n'; } else if(!docs.eof()) { - indent(out) << line_prefix << std::endl; + indent(out) << line_prefix << '\n'; } } if (!comment_end.empty()) diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index db30c8bae8c..72a9f065a53 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -518,7 +518,7 @@ void t_go_generator::init_generator() { f_consts_ << go_autogen_comment() << go_package() << render_includes(true); - f_const_values_ << endl << "func init() {" << endl; + f_const_values_ << '\n' << "func init() {" << '\n'; // Create file for the GoUnusedProtection__ variable string f_unused_prot_name_ = package_dir_ + "/" + "GoUnusedProtection__.go"; @@ -744,7 +744,7 @@ string t_go_generator::go_imports_end() { * Closes the type files */ void t_go_generator::close_generator() { - f_const_values_ << "}" << endl << endl; + f_const_values_ << "}" << '\n' << '\n'; f_consts_ << f_const_values_.str(); // Close types and constants files @@ -768,11 +768,11 @@ void t_go_generator::generate_typedef(t_typedef* ttypedef) { return; } - f_types_ << "type " << new_type_name << " " << base_type << endl << endl; + f_types_ << "type " << new_type_name << " " << base_type << '\n' << '\n'; // Generate a convenience function that converts an instance of a type // (which may be a constant) into a pointer to an instance of a type. f_types_ << "func " << new_type_name << "Ptr(v " << new_type_name << ") *" << new_type_name - << " { return &v }" << endl << endl; + << " { return &v }" << '\n' << '\n'; } /** @@ -785,14 +785,14 @@ void t_go_generator::generate_enum(t_enum* tenum) { std::ostringstream to_string_mapping, from_string_mapping; std::string tenum_name(publicize(tenum->get_name())); generate_go_docstring(f_types_, tenum); - f_types_ << "type " << tenum_name << " int64" << endl << "const (" << endl; + f_types_ << "type " << tenum_name << " int64" << '\n' << "const (" << '\n'; - to_string_mapping << indent() << "func (p " << tenum_name << ") String() string {" << endl; - to_string_mapping << indent() << " switch p {" << endl; + to_string_mapping << indent() << "func (p " << tenum_name << ") String() string {" << '\n'; + to_string_mapping << indent() << " switch p {" << '\n'; from_string_mapping << indent() << "func " << tenum_name << "FromString(s string) (" << tenum_name - << ", error) {" << endl; - from_string_mapping << indent() << " switch s {" << endl; + << ", error) {" << '\n'; + from_string_mapping << indent() << " switch s {" << '\n'; vector constants = tenum->get_constants(); vector::iterator c_iter; @@ -804,68 +804,68 @@ void t_go_generator::generate_enum(t_enum* tenum) { string iter_std_name(escape_string((*c_iter)->get_name())); string iter_name((*c_iter)->get_name()); f_types_ << indent() << " " << tenum_name << "_" << iter_name << ' ' << tenum_name << " = " - << value << endl; + << value << '\n'; // Dictionaries to/from string names of enums to_string_mapping << indent() << " case " << tenum_name << "_" << iter_name << ": return \"" - << iter_std_name << "\"" << endl; + << iter_std_name << "\"" << '\n'; if (iter_std_name != escape_string(iter_name)) { from_string_mapping << indent() << " case \"" << iter_std_name << "\", \"" << escape_string(iter_name) << "\": return " << tenum_name << "_" - << iter_name << ", nil " << endl; + << iter_name << ", nil " << '\n'; } else { from_string_mapping << indent() << " case \"" << iter_std_name << "\": return " << tenum_name - << "_" << iter_name << ", nil " << endl; + << "_" << iter_name << ", nil " << '\n'; } } - to_string_mapping << indent() << " }" << endl; - to_string_mapping << indent() << " return \"\"" << endl; - to_string_mapping << indent() << "}" << endl; - from_string_mapping << indent() << " }" << endl; + to_string_mapping << indent() << " }" << '\n'; + to_string_mapping << indent() << " return \"\"" << '\n'; + to_string_mapping << indent() << "}" << '\n'; + from_string_mapping << indent() << " }" << '\n'; from_string_mapping << indent() << " return " << tenum_name << "(0)," - << " fmt.Errorf(\"not a valid " << tenum_name << " string\")" << endl; - from_string_mapping << indent() << "}" << endl; + << " fmt.Errorf(\"not a valid " << tenum_name << " string\")" << '\n'; + from_string_mapping << indent() << "}" << '\n'; - f_types_ << ")" << endl << endl << to_string_mapping.str() << endl << from_string_mapping.str() - << endl << endl; + f_types_ << ")" << '\n' << '\n' << to_string_mapping.str() << '\n' << from_string_mapping.str() + << '\n' << '\n'; // Generate a convenience function that converts an instance of an enum // (which may be a constant) into a pointer to an instance of that enum // type. f_types_ << "func " << tenum_name << "Ptr(v " << tenum_name << ") *" << tenum_name - << " { return &v }" << endl << endl; + << " { return &v }" << '\n' << '\n'; // Generate MarshalText - f_types_ << "func (p " << tenum_name << ") MarshalText() ([]byte, error) {" << endl; - f_types_ << "return []byte(p.String()), nil" << endl; - f_types_ << "}" << endl << endl; + f_types_ << "func (p " << tenum_name << ") MarshalText() ([]byte, error) {" << '\n'; + f_types_ << "return []byte(p.String()), nil" << '\n'; + f_types_ << "}" << '\n' << '\n'; // Generate UnmarshalText - f_types_ << "func (p *" << tenum_name << ") UnmarshalText(text []byte) error {" << endl; - f_types_ << "q, err := " << tenum_name << "FromString(string(text))" << endl; - f_types_ << "if (err != nil) {" << endl << "return err" << endl << "}" << endl; - f_types_ << "*p = q" << endl; - f_types_ << "return nil" << endl; - f_types_ << "}" << endl << endl; + f_types_ << "func (p *" << tenum_name << ") UnmarshalText(text []byte) error {" << '\n'; + f_types_ << "q, err := " << tenum_name << "FromString(string(text))" << '\n'; + f_types_ << "if (err != nil) {" << '\n' << "return err" << '\n' << "}" << '\n'; + f_types_ << "*p = q" << '\n'; + f_types_ << "return nil" << '\n'; + f_types_ << "}" << '\n' << '\n'; // Generate Scan for sql.Scanner interface - f_types_ << "func (p *" << tenum_name << ") Scan(value interface{}) error {" <get_name()); t_const_value* value = tconst->get_value(); if (type->is_enum() || (type->is_base_type() && ((t_base_type*)type)->get_base() != t_base_type::TYPE_UUID)) { - indent(f_consts_) << "const " << name << " = " << render_const_value(type, value, name) << endl; + indent(f_consts_) << "const " << name << " = " << render_const_value(type, value, name) << '\n'; } else { - f_const_values_ << indent() << name << " = " << render_const_value(type, value, name) << endl - << endl; + f_const_values_ << indent() << name << " = " << render_const_value(type, value, name) << '\n' + << '\n'; - f_consts_ << indent() << "var " << name << " " << type_to_go_type(type) << endl; + f_consts_ << indent() << "var " << name << " " << type_to_go_type(type) << '\n'; } } @@ -1079,8 +1079,8 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co if (field_type == nullptr) { throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string(); } - out << endl << indent() << publicize(v_iter->first->get_string()) << ": " - << render_const_value(field_type, v_iter->second, name, is_optional) << "," << endl; + out << '\n' << indent() << publicize(v_iter->first->get_string()) << ": " + << render_const_value(field_type, v_iter->second, name, is_optional) << "," << '\n'; } indent_down(); @@ -1090,13 +1090,13 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co t_type* ktype = ((t_map*)type)->get_key_type(); t_type* vtype = ((t_map*)type)->get_val_type(); const map& val = value->get_map(); - out << "map[" << type_to_go_key_type(ktype) << "]" << type_to_go_type(vtype) << "{" << endl; + out << "map[" << type_to_go_key_type(ktype) << "]" << type_to_go_type(vtype) << "{" << '\n'; indent_up(); map::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { out << indent() << render_const_value(ktype, v_iter->first, name) << ": " - << render_const_value(vtype, v_iter->second, name) << "," << endl; + << render_const_value(vtype, v_iter->second, name) << "," << '\n'; } indent_down(); @@ -1104,7 +1104,7 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co } else if (type->is_list()) { t_type* etype = ((t_list*)type)->get_elem_type(); const vector& val = value->get_list(); - out << "[]" << type_to_go_type(etype) << "{" << endl; + out << "[]" << type_to_go_type(etype) << "{" << '\n'; indent_up(); vector::const_iterator v_iter; @@ -1117,7 +1117,7 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co } else if (type->is_set()) { t_type* etype = ((t_set*)type)->get_elem_type(); const vector& val = value->get_list(); - out << "[]" << type_to_go_type(etype) << "{" << endl; + out << "[]" << type_to_go_type(etype) << "{" << '\n'; indent_up(); vector::const_iterator v_iter; @@ -1158,12 +1158,12 @@ void t_go_generator::generate_go_struct(t_struct* tstruct, bool is_exception) { generate_go_struct_definition(f_types_, tstruct, is_exception); // generate Validate function std::string tstruct_name(publicize(tstruct->get_name(), false)); - f_types_ << "func (p *" << tstruct_name << ") Validate() error {" << endl; + f_types_ << "func (p *" << tstruct_name << ") Validate() error {" << '\n'; indent_up(); go_validator_generator(this).generate_struct_validator(f_types_, tstruct); - f_types_ << indent() << "return nil" << endl; + f_types_ << indent() << "return nil" << '\n'; indent_down(); - f_types_ << "}" << endl; + f_types_ << "}" << '\n'; } void t_go_generator::get_publicized_name_and_def_value(t_field* tfield, @@ -1186,13 +1186,13 @@ void t_go_generator::generate_go_struct_initializer(ostream& out, t_const_value* def_value; get_publicized_name_and_def_value(member, &publicized_name, &def_value); if (!pointer_field && def_value != nullptr && !omit_initialization(member)) { - out << endl << indent() << publicized_name << ": " + out << '\n' << indent() << publicized_name << ": " << render_field_initial_value(member, member->get_name(), pointer_field) << "," - << endl; + << '\n'; } } - out << "}" << endl; + out << "}" << '\n'; } /** @@ -1211,7 +1211,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, std::string tstruct_name(publicize(tstruct->get_name(), is_args || is_result)); generate_go_docstring(out, tstruct); - out << indent() << "type " << tstruct_name << " struct {" << endl; + out << indent() << "type " << tstruct_name << " struct {" << '\n'; /* Here we generate the structure specification for the fastbinary codec. These specifications have the following structure: @@ -1253,9 +1253,9 @@ void t_go_generator::generate_go_struct_definition(ostream& out, } int last_unused = sorted_keys_pos - 1; if (first_unused < last_unused) { - indent(out) << "// unused fields # " << first_unused << " to " << last_unused << endl; + indent(out) << "// unused fields # " << first_unused << " to " << last_unused << '\n'; } else if (first_unused == last_unused) { - indent(out) << "// unused field # " << first_unused << endl; + indent(out) << "// unused field # " << first_unused << '\n'; } } @@ -1296,25 +1296,25 @@ void t_go_generator::generate_go_struct_definition(ostream& out, out << ",required"; } - out << "\" " << gotag << "`" << endl; + out << "\" " << gotag << "`" << '\n'; sorted_keys_pos++; } } else { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { // This fills in default values, as opposed to nulls out << indent() << publicize((*m_iter)->get_name()) << " " - << type_to_go_type((*m_iter)->get_type()) << endl; + << type_to_go_type((*m_iter)->get_type()) << '\n'; } } indent_down(); - out << indent() << "}" << endl << endl; - out << indent() << "func New" << tstruct_name << "() *" << tstruct_name << " {" << endl; + out << indent() << "}" << '\n' << '\n'; + out << indent() << "func New" << tstruct_name << "() *" << tstruct_name << " {" << '\n'; indent_up(); out << indent() << "return &"; generate_go_struct_initializer(out, tstruct, is_result || is_args); indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; // Default values for optional fields for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { string publicized_name; @@ -1328,7 +1328,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, if (def_value != nullptr) { out << " = " << render_const_value(fieldType, def_value, (*m_iter)->get_name()); } - out << endl; + out << '\n'; } // num_setable is used for deciding if Count* methods will be generated for union fields. @@ -1342,24 +1342,24 @@ void t_go_generator::generate_go_struct_definition(ostream& out, string goOptType = type_to_go_type_with_opt(fieldType, true); string maybepointer = goOptType != goType ? "*" : ""; out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() " - << goType << " {" << endl; + << goType << " {" << '\n'; indent_up(); - out << indent() << "if !p.IsSet" << publicized_name << "() {" << endl; + out << indent() << "if !p.IsSet" << publicized_name << "() {" << '\n'; indent_up(); - out << indent() << "return " << def_var_name << endl; + out << indent() << "return " << def_var_name << '\n'; indent_down(); - out << indent() << "}" << endl; - out << indent() << "return " << maybepointer << "p." << publicized_name << endl; + out << indent() << "}" << '\n'; + out << indent() << "return " << maybepointer << "p." << publicized_name << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else { - out << endl; + out << '\n'; out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() " - << goType << " {" << endl; + << goType << " {" << '\n'; indent_up(); - out << indent() << "return p." << publicized_name << endl; + out << indent() << "return p." << publicized_name << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } @@ -1374,57 +1374,57 @@ void t_go_generator::generate_go_struct_definition(ostream& out, generate_go_struct_equals(out, tstruct, tstruct_name); } - out << indent() << "func (p *" << tstruct_name << ") String() string {" << endl; + out << indent() << "func (p *" << tstruct_name << ") String() string {" << '\n'; indent_up(); - out << indent() << "if p == nil {" << endl; + out << indent() << "if p == nil {" << '\n'; indent_up(); - out << indent() << "return \"\"" << endl; + out << indent() << "return \"\"" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; out << indent() << "return fmt.Sprintf(\"" << escape_string(tstruct_name) << "(%+v)\", *p)" - << endl; + << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; if (is_exception) { - out << indent() << "func (p *" << tstruct_name << ") Error() string {" << endl; + out << indent() << "func (p *" << tstruct_name << ") Error() string {" << '\n'; indent_up(); - out << indent() << "return p.String()" << endl; + out << indent() << "return p.String()" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; - out << indent() << "func (" << tstruct_name << ") TExceptionType() thrift.TExceptionType {" << endl; + out << indent() << "func (" << tstruct_name << ") TExceptionType() thrift.TExceptionType {" << '\n'; indent_up(); - out << indent() << "return thrift.TExceptionTypeCompiled" << endl; + out << indent() << "return thrift.TExceptionTypeCompiled" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; out << indent() << "var _ thrift.TException = (*" << tstruct_name << ")(nil)" - << endl << endl; + << '\n' << '\n'; } if (!read_write_private_) { // Generate the implementation of slog.LogValuer, // see: https://issues.apache.org/jira/browse/THRIFT-5745 - out << indent() << "func (p *" << tstruct_name << ") LogValue() slog.Value {" << endl; + out << indent() << "func (p *" << tstruct_name << ") LogValue() slog.Value {" << '\n'; indent_up(); - out << indent() << "if p == nil {" << endl; + out << indent() << "if p == nil {" << '\n'; indent_up(); - out << indent() << "return slog.AnyValue(nil)" << endl; + out << indent() << "return slog.AnyValue(nil)" << '\n'; indent_down(); - out << indent() << "}" << endl; - out << indent() << "v := thrift.SlogTStructWrapper{" << endl; + out << indent() << "}" << '\n'; + out << indent() << "v := thrift.SlogTStructWrapper{" << '\n'; indent_up(); - out << indent() << "Type: \"*" << package_name_ << "." << tstruct_name << "\"," << endl; - out << indent() << "Value: p," << endl; + out << indent() << "Type: \"*" << package_name_ << "." << tstruct_name << "\"," << '\n'; + out << indent() << "Value: p," << '\n'; indent_down(); - out << indent() << "}" << endl; - out << indent() << "return slog.AnyValue(v)" << endl; + out << indent() << "}" << '\n'; + out << indent() << "return slog.AnyValue(v)" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; out << indent() << "var _ slog.LogValuer = (*" << tstruct_name << ")(nil)" - << endl << endl; + << '\n' << '\n'; } } @@ -1444,25 +1444,25 @@ void t_go_generator::generate_isset_helpers(ostream& out, const string field_name(publicize(escape_string((*f_iter)->get_name()))); if ((*f_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*f_iter)) { out << indent() << "func (p *" << tstruct_name << ") IsSet" << field_name << "() bool {" - << endl; + << '\n'; indent_up(); t_type* ttype = (*f_iter)->get_type()->get_true_type(); bool is_byteslice = ttype->is_binary(); bool compare_to_nil_only = ttype->is_set() || ttype->is_list() || ttype->is_map() || (is_byteslice && !(*f_iter)->get_value()); if (is_pointer_field(*f_iter) || compare_to_nil_only) { - out << indent() << "return p." << field_name << " != nil" << endl; + out << indent() << "return p." << field_name << " != nil" << '\n'; } else { string def_var_name = tstruct_name + "_" + field_name + "_DEFAULT"; if (is_byteslice) { out << indent() << "return !bytes.Equal(p." << field_name << ", " << def_var_name << ")" - << endl; + << '\n'; } else { - out << indent() << "return p." << field_name << " != " << def_var_name << endl; + out << indent() << "return p." << field_name << " != " << def_var_name << '\n'; } } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } } } @@ -1480,9 +1480,9 @@ void t_go_generator::generate_countsetfields_helper(ostream& out, const string escaped_tstruct_name(escape_string(tstruct->get_name())); out << indent() << "func (p *" << tstruct_name << ") CountSetFields" << tstruct_name << "() int {" - << endl; + << '\n'; indent_up(); - out << indent() << "count := 0" << endl; + out << indent() << "count := 0" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) continue; @@ -1494,16 +1494,16 @@ void t_go_generator::generate_countsetfields_helper(ostream& out, const string field_name(publicize(escape_string((*f_iter)->get_name()))); - out << indent() << "if (p.IsSet" << field_name << "()) {" << endl; + out << indent() << "if (p.IsSet" << field_name << "()) {" << '\n'; indent_up(); - out << indent() << "count++" << endl; + out << indent() << "count++" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } - out << indent() << "return count" << endl << endl; + out << indent() << "return count" << '\n' << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } /** @@ -1518,33 +1518,33 @@ void t_go_generator::generate_go_struct_reader(ostream& out, vector::const_iterator f_iter; string escaped_tstruct_name(escape_string(tstruct->get_name())); out << indent() << "func (p *" << tstruct_name << ") " << read_method_name_ << "(ctx context.Context, iprot thrift.TProtocol) error {" - << endl; + << '\n'; indent_up(); - out << indent() << "if _, err := iprot.ReadStructBegin(ctx); err != nil {" << endl; + out << indent() << "if _, err := iprot.ReadStructBegin(ctx); err != nil {" << '\n'; out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)" - << endl; - out << indent() << "}" << endl << endl; + << '\n'; + out << indent() << "}" << '\n' << '\n'; // Required variables does not have IsSet functions, so we need tmp vars to check them. for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { const string field_name(publicize(escape_string((*f_iter)->get_name()))); - indent(out) << "var isset" << field_name << " bool = false;" << endl; + indent(out) << "var isset" << field_name << " bool = false;" << '\n'; } } - out << endl; + out << '\n'; // Loop over reading in fields - indent(out) << "for {" << endl; + indent(out) << "for {" << '\n'; indent_up(); // Read beginning field marker - out << indent() << "_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)" << endl; - out << indent() << "if err != nil {" << endl; + out << indent() << "_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)" << '\n'; + out << indent() << "if err != nil {" << '\n'; out << indent() << " return thrift.PrependError(fmt.Sprintf(" - "\"%T field %d read error: \", p, fieldId), err)" << endl; - out << indent() << "}" << endl; + "\"%T field %d read error: \", p, fieldId), err)" << '\n'; + out << indent() << "}" << '\n'; // Check for field STOP marker and break - out << indent() << "if fieldTypeId == thrift.STOP { break; }" << endl; + out << indent() << "if fieldTypeId == thrift.STOP { break; }" << '\n'; string thriftFieldTypeId; // Generate deserialization code for known cases @@ -1553,7 +1553,7 @@ void t_go_generator::generate_go_struct_reader(ostream& out, // Switch statement on the field we are reading, false if no fields present bool have_switch = !fields.empty(); if (have_switch) { - indent(out) << "switch fieldId {" << endl; + indent(out) << "switch fieldId {" << '\n'; } // All the fields we know @@ -1569,7 +1569,7 @@ void t_go_generator::generate_go_struct_reader(ostream& out, field_method_suffix *= -1; } - out << indent() << "case " << field_id << ":" << endl; + out << indent() << "case " << field_id << ":" << '\n'; indent_up(); thriftFieldTypeId = type_to_enum((*f_iter)->get_type()); @@ -1577,23 +1577,23 @@ void t_go_generator::generate_go_struct_reader(ostream& out, thriftFieldTypeId = "thrift.STRING"; } - out << indent() << "if fieldTypeId == " << thriftFieldTypeId << " {" << endl; + out << indent() << "if fieldTypeId == " << thriftFieldTypeId << " {" << '\n'; out << indent() << " if err := p." << field_method_prefix << field_method_suffix << "(ctx, iprot); err != nil {" - << endl; - out << indent() << " return err" << endl; - out << indent() << " }" << endl; + << '\n'; + out << indent() << " return err" << '\n'; + out << indent() << " }" << '\n'; // Mark required field as read if ((*f_iter)->get_req() == t_field::T_REQUIRED) { const string field_name(publicize(escape_string((*f_iter)->get_name()))); - out << indent() << " isset" << field_name << " = true" << endl; + out << indent() << " isset" << field_name << " = true" << '\n'; } - out << indent() << "} else {" << endl; - out << indent() << " if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << endl; - out << indent() << " return err" << endl; - out << indent() << " }" << endl; - out << indent() << "}" << endl; + out << indent() << "} else {" << '\n'; + out << indent() << " if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << '\n'; + out << indent() << " return err" << '\n'; + out << indent() << " }" << '\n'; + out << indent() << "}" << '\n'; indent_down(); @@ -1601,46 +1601,46 @@ void t_go_generator::generate_go_struct_reader(ostream& out, // Begin switch default case if (have_switch) { - out << indent() << "default:" << endl; + out << indent() << "default:" << '\n'; indent_up(); } // Skip unknown fields in either case - out << indent() << "if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << endl; - out << indent() << " return err" << endl; - out << indent() << "}" << endl; + out << indent() << "if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << '\n'; + out << indent() << " return err" << '\n'; + out << indent() << "}" << '\n'; // End switch default case if (have_switch) { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } // Read field end marker - out << indent() << "if err := iprot.ReadFieldEnd(ctx); err != nil {" << endl; - out << indent() << " return err" << endl; - out << indent() << "}" << endl; + out << indent() << "if err := iprot.ReadFieldEnd(ctx); err != nil {" << '\n'; + out << indent() << " return err" << '\n'; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl; - out << indent() << "if err := iprot.ReadStructEnd(ctx); err != nil {" << endl; + out << indent() << "}" << '\n'; + out << indent() << "if err := iprot.ReadStructEnd(ctx); err != nil {" << '\n'; out << indent() << " return thrift.PrependError(fmt.Sprintf(" - "\"%T read struct end error: \", p), err)" << endl; - out << indent() << "}" << endl; + "\"%T read struct end error: \", p), err)" << '\n'; + out << indent() << "}" << '\n'; // Return error if any required fields are missing. for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { const string field_name(publicize(escape_string((*f_iter)->get_name()))); - out << indent() << "if !isset" << field_name << "{" << endl; + out << indent() << "if !isset" << field_name << "{" << '\n'; out << indent() << " return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, " - "fmt.Errorf(\"Required field " << field_name << " is not set\"));" << endl; - out << indent() << "}" << endl; + "fmt.Errorf(\"Required field " << field_name << " is not set\"));" << '\n'; + out << indent() << "}" << '\n'; } } - out << indent() << "return nil" << endl; + out << indent() << "return nil" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { string field_type_name(publicize((*f_iter)->get_type()->get_name())); @@ -1655,12 +1655,12 @@ void t_go_generator::generate_go_struct_reader(ostream& out, } out << indent() << "func (p *" << tstruct_name << ") " << field_method_prefix << field_method_suffix - << "(ctx context.Context, iprot thrift.TProtocol) error {" << endl; + << "(ctx context.Context, iprot thrift.TProtocol) error {" << '\n'; indent_up(); generate_deserialize_field(out, *f_iter, false, "p."); indent_down(); - out << indent() << " return nil" << endl; - out << indent() << "}" << endl << endl; + out << indent() << " return nil" << '\n'; + out << indent() << "}" << '\n' << '\n'; } } @@ -1673,18 +1673,18 @@ void t_go_generator::generate_go_struct_writer(ostream& out, string name(tstruct->get_name()); const vector& fields = tstruct->get_sorted_members(); vector::const_iterator f_iter; - indent(out) << "func (p *" << tstruct_name << ") " << write_method_name_ << "(ctx context.Context, oprot thrift.TProtocol) error {" << endl; + indent(out) << "func (p *" << tstruct_name << ") " << write_method_name_ << "(ctx context.Context, oprot thrift.TProtocol) error {" << '\n'; indent_up(); if (tstruct->is_union() && uses_countsetfields) { std::string tstruct_name(publicize(tstruct->get_name())); - out << indent() << "if c := p.CountSetFields" << tstruct_name << "(); c != 1 {" << endl + out << indent() << "if c := p.CountSetFields" << tstruct_name << "(); c != 1 {" << '\n' << indent() << " return fmt.Errorf(\"%T write union: exactly one field must be set (%d set)\", p, c)" - << endl << indent() << "}" << endl; + << '\n' << indent() << "}" << '\n'; } - out << indent() << "if err := oprot.WriteStructBegin(ctx, \"" << name << "\"); err != nil {" << endl; + out << indent() << "if err := oprot.WriteStructBegin(ctx, \"" << name << "\"); err != nil {" << '\n'; out << indent() << " return thrift.PrependError(fmt.Sprintf(" - "\"%T write struct begin error: \", p), err) }" << endl; + "\"%T write struct begin error: \", p), err) }" << '\n'; string field_name; string escape_field_name; @@ -1692,7 +1692,7 @@ void t_go_generator::generate_go_struct_writer(ostream& out, t_field::e_req field_required; int32_t field_id = -1; - out << indent() << "if p != nil {" << endl; + out << indent() << "if p != nil {" << '\n'; indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { @@ -1708,20 +1708,20 @@ void t_go_generator::generate_go_struct_writer(ostream& out, } out << indent() << "if err := p." << field_method_prefix << field_method_suffix - << "(ctx, oprot); err != nil { return err }" << endl; + << "(ctx, oprot); err != nil { return err }" << '\n'; } indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; // Write the struct map - out << indent() << "if err := oprot.WriteFieldStop(ctx); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"write field stop error: \", err) }" << endl; - out << indent() << "if err := oprot.WriteStructEnd(ctx); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"write struct stop error: \", err) }" << endl; - out << indent() << "return nil" << endl; + out << indent() << "if err := oprot.WriteFieldStop(ctx); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"write field stop error: \", err) }" << '\n'; + out << indent() << "if err := oprot.WriteStructEnd(ctx); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"write struct stop error: \", err) }" << '\n'; + out << indent() << "return nil" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { string field_method_prefix("writeField"); @@ -1738,35 +1738,35 @@ void t_go_generator::generate_go_struct_writer(ostream& out, } out << indent() << "func (p *" << tstruct_name << ") " << field_method_prefix << field_method_suffix - << "(ctx context.Context, oprot thrift.TProtocol) (err error) {" << endl; + << "(ctx context.Context, oprot thrift.TProtocol) (err error) {" << '\n'; indent_up(); if (field_required == t_field::T_OPTIONAL) { - out << indent() << "if p.IsSet" << publicize(field_name) << "() {" << endl; + out << indent() << "if p.IsSet" << publicize(field_name) << "() {" << '\n'; indent_up(); } out << indent() << "if err := oprot.WriteFieldBegin(ctx, \"" << escape_field_name << "\", " - << type_to_enum((*f_iter)->get_type()) << ", " << field_id << "); err != nil {" << endl; + << type_to_enum((*f_iter)->get_type()) << ", " << field_id << "); err != nil {" << '\n'; out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T write field begin error " - << field_id << ":" << escape_field_name << ": \", p), err) }" << endl; + << field_id << ":" << escape_field_name << ": \", p), err) }" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "p."); // Write field closer - out << indent() << "if err := oprot.WriteFieldEnd(ctx); err != nil {" << endl; + out << indent() << "if err := oprot.WriteFieldEnd(ctx); err != nil {" << '\n'; out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T write field end error " - << field_id << ":" << escape_field_name << ": \", p), err) }" << endl; + << field_id << ":" << escape_field_name << ": \", p), err) }" << '\n'; if (field_required == t_field::T_OPTIONAL) { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } indent_down(); - out << indent() << " return err" << endl; - out << indent() << "}" << endl << endl; + out << indent() << " return err" << '\n'; + out << indent() << "}" << '\n' << '\n'; } } @@ -1777,20 +1777,20 @@ void t_go_generator::generate_go_struct_equals(ostream& out, const vector& fields = tstruct->get_sorted_members(); vector::const_iterator f_iter; indent(out) << "func (p *" << tstruct_name << ") " << equals_method_name_ << "(other *" - << tstruct_name << ") bool {" << endl; + << tstruct_name << ") bool {" << '\n'; indent_up(); string field_name; string publicize_field_name; - out << indent() << "if p == other {" << endl; + out << indent() << "if p == other {" << '\n'; indent_up(); - out << indent() << "return true" << endl; + out << indent() << "return true" << '\n'; indent_down(); - out << indent() << "} else if p == nil || other == nil {" << endl; + out << indent() << "} else if p == nil || other == nil {" << '\n'; indent_up(); - out << indent() << "return false" << endl; + out << indent() << "return false" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { field_name = (*f_iter)->get_name(); @@ -1806,23 +1806,23 @@ void t_go_generator::generate_go_struct_equals(ostream& out, && (ttype->is_base_type() || ttype->is_enum() || ttype->is_container())) { string tgtv = "(*" + tgt + ")"; string srcv = "(*" + src + ")"; - out << indent() << "if " << tgt << " != " << src << " {" << endl; + out << indent() << "if " << tgt << " != " << src << " {" << '\n'; indent_up(); - out << indent() << "if " << tgt << " == nil || " << src << " == nil {" << endl; + out << indent() << "if " << tgt << " == nil || " << src << " == nil {" << '\n'; indent_up(); - out << indent() << "return false" << endl; + out << indent() << "return false" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; generate_go_equals(out, field_type, tgtv, srcv); indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else { generate_go_equals(out, field_type, tgt, src); } } - out << indent() << "return true" << endl; + out << indent() << "return true" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } /** @@ -1842,7 +1842,7 @@ void t_go_generator::generate_service(t_service* tservice) { if(!skip_remote_) { generate_service_remote(tservice); } - f_types_ << endl; + f_types_ << '\n'; } /** @@ -1853,7 +1853,7 @@ void t_go_generator::generate_service(t_service* tservice) { void t_go_generator::generate_service_helpers(t_service* tservice) { vector functions = tservice->get_functions(); vector::iterator f_iter; - f_types_ << "// HELPER FUNCTIONS AND STRUCTURES" << endl << endl; + f_types_ << "// HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { t_struct* ts = (*f_iter)->get_arglist(); @@ -1920,17 +1920,17 @@ void t_go_generator::generate_service_interface(t_service* tservice) { vector functions = tservice->get_functions(); if (!functions.empty()) { - f_types_ << endl; + f_types_ << '\n'; vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_go_docstring(f_types_, (*f_iter)); - f_types_ << indent() << function_signature_if(*f_iter, "", true) << endl; + f_types_ << indent() << function_signature_if(*f_iter, "", true) << '\n'; } } indent_down(); - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; } /** @@ -1963,23 +1963,23 @@ void t_go_generator::generate_service_client(t_service* tservice) { extends_field = extends_client.substr(extends_client.find(".") + 1); generate_go_docstring(f_types_, tservice); - f_types_ << indent() << "type " << serviceName << "Client struct {" << endl; + f_types_ << indent() << "type " << serviceName << "Client struct {" << '\n'; indent_up(); if (!extends_client.empty()) { - f_types_ << indent() << "*" << extends_client << endl; + f_types_ << indent() << "*" << extends_client << '\n'; } else { - f_types_ << indent() << "c thrift.TClient" << endl; - f_types_ << indent() << "meta thrift.ResponseMeta" << endl; + f_types_ << indent() << "c thrift.TClient" << '\n'; + f_types_ << indent() << "meta thrift.ResponseMeta" << '\n'; } indent_down(); - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; // Legacy constructor function f_types_ << indent() << "func New" << serviceName << "ClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *" << serviceName - << "Client {" << endl; + << "Client {" << '\n'; indent_up(); f_types_ << indent() << "return &" << serviceName << "Client"; @@ -1987,72 +1987,72 @@ void t_go_generator::generate_service_client(t_service* tservice) { f_types_ << "{" << extends_field << ": " << extends_client_new << "Factory(t, f)}"; } else { indent_up(); - f_types_ << "{" << endl; - f_types_ << indent() << "c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t))," << endl; + f_types_ << "{" << '\n'; + f_types_ << indent() << "c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t))," << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; } indent_down(); - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; // Legacy constructor function with custom input & output protocols f_types_ << indent() << "func New" << serviceName << "ClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *" - << serviceName << "Client {" << endl; + << serviceName << "Client {" << '\n'; indent_up(); f_types_ << indent() << "return &" << serviceName << "Client"; if (!extends.empty()) { f_types_ << "{" << extends_field << ": " << extends_client_new << "Protocol(t, iprot, oprot)}" - << endl; + << '\n'; } else { indent_up(); - f_types_ << "{" << endl; - f_types_ << indent() << "c: thrift.NewTStandardClient(iprot, oprot)," << endl; + f_types_ << "{" << '\n'; + f_types_ << indent() << "c: thrift.NewTStandardClient(iprot, oprot)," << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; } indent_down(); - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; // Constructor function f_types_ << indent() << "func New" << serviceName - << "Client(c thrift.TClient) *" << serviceName << "Client {" << endl; + << "Client(c thrift.TClient) *" << serviceName << "Client {" << '\n'; indent_up(); - f_types_ << indent() << "return &" << serviceName << "Client{" << endl; + f_types_ << indent() << "return &" << serviceName << "Client{" << '\n'; indent_up(); if (!extends.empty()) { - f_types_ << indent() << extends_field << ": " << extends_client_new << "(c)," << endl; + f_types_ << indent() << extends_field << ": " << extends_client_new << "(c)," << '\n'; } else { - f_types_ << indent() << "c: c," << endl; + f_types_ << indent() << "c: c," << '\n'; } indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; if (extends.empty()) { - f_types_ << indent() << "func (p *" << serviceName << "Client) Client_() thrift.TClient {" << endl; + f_types_ << indent() << "func (p *" << serviceName << "Client) Client_() thrift.TClient {" << '\n'; indent_up(); - f_types_ << indent() << "return p.c" << endl; + f_types_ << indent() << "return p.c" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; - f_types_ << indent() << "func (p *" << serviceName << "Client) LastResponseMeta_() thrift.ResponseMeta {" << endl; + f_types_ << indent() << "func (p *" << serviceName << "Client) LastResponseMeta_() thrift.ResponseMeta {" << '\n'; indent_up(); - f_types_ << indent() << "return p.meta" << endl; + f_types_ << indent() << "return p.meta" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; - f_types_ << indent() << "func (p *" << serviceName << "Client) SetLastResponseMeta_(meta thrift.ResponseMeta) {" << endl; + f_types_ << indent() << "func (p *" << serviceName << "Client) SetLastResponseMeta_(meta thrift.ResponseMeta) {" << '\n'; indent_up(); - f_types_ << indent() << "p.meta = meta" << endl; + f_types_ << indent() << "p.meta = meta" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; } // Generate client method implementations @@ -2067,59 +2067,59 @@ void t_go_generator::generate_service_client(t_service* tservice) { // Open function generate_go_docstring(f_types_, (*f_iter)); f_types_ << indent() << "func (p *" << serviceName << "Client) " - << function_signature_if(*f_iter, "", true) << " {" << endl; + << function_signature_if(*f_iter, "", true) << " {" << '\n'; indent_up(); std::string method = (*f_iter)->get_name(); std::string argsType = publicize(method + "_args", true); std::string argsName = tmp("_args"); - f_types_ << indent() << "var " << argsName << " " << argsType << endl; + f_types_ << indent() << "var " << argsName << " " << argsType << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_types_ << indent() << argsName << "." << publicize((*fld_iter)->get_name()) - << " = " << variable_name_to_go_name((*fld_iter)->get_name()) << endl; + << " = " << variable_name_to_go_name((*fld_iter)->get_name()) << '\n'; } if (!(*f_iter)->is_oneway()) { std::string metaName = tmp("_meta"); std::string resultName = tmp("_result"); std::string resultType = publicize(method + "_result", true); - f_types_ << indent() << "var " << resultName << " " << resultType << endl; - f_types_ << indent() << "var " << metaName << " thrift.ResponseMeta" << endl; + f_types_ << indent() << "var " << resultName << " " << resultType << '\n'; + f_types_ << indent() << "var " << metaName << " thrift.ResponseMeta" << '\n'; f_types_ << indent() << metaName << ", _err = p.Client_().Call(ctx, \"" - << method << "\", &" << argsName << ", &" << resultName << ")" << endl; - f_types_ << indent() << "p.SetLastResponseMeta_(" << metaName << ")" << endl; - f_types_ << indent() << "if _err != nil {" << endl; + << method << "\", &" << argsName << ", &" << resultName << ")" << '\n'; + f_types_ << indent() << "p.SetLastResponseMeta_(" << metaName << ")" << '\n'; + f_types_ << indent() << "if _err != nil {" << '\n'; indent_up(); - f_types_ << indent() << "return" << endl; + f_types_ << indent() << "return" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; t_struct* xs = (*f_iter)->get_xceptions(); const std::vector& xceptions = xs->get_members(); vector::const_iterator x_iter; if (!xceptions.empty()) { - f_types_ << indent() << "switch {" << endl; + f_types_ << indent() << "switch {" << '\n'; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { const std::string pubname = publicize((*x_iter)->get_name()); const std::string field = resultName + "." + pubname; - f_types_ << indent() << "case " << field << "!= nil:" << endl; + f_types_ << indent() << "case " << field << "!= nil:" << '\n'; indent_up(); if (!(*f_iter)->get_returntype()->is_void()) { - f_types_ << indent() << "return _r, " << field << endl; + f_types_ << indent() << "return _r, " << field << '\n'; } else { - f_types_ << indent() << "return "<< field << endl; + f_types_ << indent() << "return "<< field << '\n'; } indent_down(); } - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; } if ((*f_iter)->get_returntype()->is_struct()) { @@ -2130,37 +2130,37 @@ void t_go_generator::generate_service_client(t_service* tservice) { // struct in go. std::string retName = tmp("_ret"); f_types_ << indent() << "if " << retName << " := " << resultName - << ".GetSuccess(); " << retName << " != nil {" << endl; + << ".GetSuccess(); " << retName << " != nil {" << '\n'; indent_up(); - f_types_ << indent() << "return " << retName << ", nil" << endl; + f_types_ << indent() << "return " << retName << ", nil" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; f_types_ << indent() << "return nil, " << "thrift.NewTApplicationException(thrift.MISSING_RESULT, \"" - << method << " failed: unknown result\")" << endl; + << method << " failed: unknown result\")" << '\n'; } else if (!(*f_iter)->get_returntype()->is_void()) { - f_types_ << indent() << "return " << resultName << ".GetSuccess(), nil" << endl; + f_types_ << indent() << "return " << resultName << ".GetSuccess(), nil" << '\n'; } else { - f_types_ << indent() << "return nil" << endl; + f_types_ << indent() << "return nil" << '\n'; } } else { // Since we don't have response meta for oneway calls, overwrite it with // an empty one to avoid users getting the meta from last call and // mistaken it as from the oneway call. - f_types_ << indent() << "p.SetLastResponseMeta_(thrift.ResponseMeta{})" << endl; + f_types_ << indent() << "p.SetLastResponseMeta_(thrift.ResponseMeta{})" << '\n'; // TODO: would be nice to not to duplicate the call generation f_types_ << indent() << "if _, err := p.Client_().Call(ctx, \"" - << method << "\", &" << argsName << ", nil); err != nil {" << endl; + << method << "\", &" << argsName << ", nil); err != nil {" << '\n'; indent_up(); - f_types_ << indent() << "return err" << endl; + f_types_ << indent() << "return err" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; - f_types_ << indent() << "return nil" << endl; + f_types_ << indent() << "}" << '\n'; + f_types_ << indent() << "return nil" << '\n'; } indent_down(); - f_types_ << "}" << endl << endl; + f_types_ << "}" << '\n' << '\n'; } } @@ -2223,21 +2223,21 @@ void t_go_generator::generate_service_remote(t_service* tservice) { system_packages.push_back("thrift \"" + gen_thrift_import_ + "\""); f_remote << go_autogen_comment(); - f_remote << indent() << "package main" << endl << endl; - f_remote << indent() << "import (" << endl; + f_remote << indent() << "package main" << '\n' << '\n'; + f_remote << indent() << "import (" << '\n'; f_remote << render_system_packages(system_packages); f_remote << indent() << render_included_programs(unused_protection); f_remote << render_program_import(program_, unused_protection); - f_remote << indent() << ")" << endl; - f_remote << indent() << endl; + f_remote << indent() << ")" << '\n'; + f_remote << indent() << '\n'; f_remote << indent() << unused_protection; // filled in render_included_programs() - f_remote << indent() << endl; - f_remote << indent() << "func Usage() {" << endl; + f_remote << indent() << '\n'; + f_remote << indent() << "func Usage() {" << '\n'; f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Usage of \", os.Args[0], \" " "[-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:\")" - << endl; - f_remote << indent() << " flag.PrintDefaults()" << endl; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"\\nFunctions:\")" << endl; + << '\n'; + f_remote << indent() << " flag.PrintDefaults()" << '\n'; + f_remote << indent() << " fmt.Fprintln(os.Stderr, \"\\nFunctions:\")" << '\n'; string package_name_aliased = package_identifiers_[get_real_go_module(program_)]; @@ -2259,143 +2259,143 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << args[i]->get_type()->get_name() << " " << args[i]->get_name(); } - f_remote << ")\")" << endl; + f_remote << ")\")" << '\n'; } - f_remote << indent() << " fmt.Fprintln(os.Stderr)" << endl; - f_remote << indent() << " os.Exit(0)" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << endl; - - f_remote << indent() << "type httpHeaders map[string]string" << endl; - f_remote << indent() << endl; - f_remote << indent() << "func (h httpHeaders) String() string {" << endl; - f_remote << indent() << " var m map[string]string = h" << endl; - f_remote << indent() << " return fmt.Sprintf(\"%s\", m)" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << endl; - f_remote << indent() << "func (h httpHeaders) Set(value string) error {" << endl; - f_remote << indent() << " parts := strings.Split(value, \": \")" << endl; - f_remote << indent() << " if len(parts) != 2 {" << endl; - f_remote << indent() << " return fmt.Errorf(\"header should be of format 'Key: Value'\")" << endl; - f_remote << indent() << " }" << endl; - f_remote << indent() << " h[parts[0]] = parts[1]" << endl; - f_remote << indent() << " return nil" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << endl; - - f_remote << indent() << "func main() {" << endl; + f_remote << indent() << " fmt.Fprintln(os.Stderr)" << '\n'; + f_remote << indent() << " os.Exit(0)" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << '\n'; + + f_remote << indent() << "type httpHeaders map[string]string" << '\n'; + f_remote << indent() << '\n'; + f_remote << indent() << "func (h httpHeaders) String() string {" << '\n'; + f_remote << indent() << " var m map[string]string = h" << '\n'; + f_remote << indent() << " return fmt.Sprintf(\"%s\", m)" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << '\n'; + f_remote << indent() << "func (h httpHeaders) Set(value string) error {" << '\n'; + f_remote << indent() << " parts := strings.Split(value, \": \")" << '\n'; + f_remote << indent() << " if len(parts) != 2 {" << '\n'; + f_remote << indent() << " return fmt.Errorf(\"header should be of format 'Key: Value'\")" << '\n'; + f_remote << indent() << " }" << '\n'; + f_remote << indent() << " h[parts[0]] = parts[1]" << '\n'; + f_remote << indent() << " return nil" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << '\n'; + + f_remote << indent() << "func main() {" << '\n'; indent_up(); - f_remote << indent() << "flag.Usage = Usage" << endl; - f_remote << indent() << "var host string" << endl; - f_remote << indent() << "var port int" << endl; - f_remote << indent() << "var protocol string" << endl; - f_remote << indent() << "var urlString string" << endl; - f_remote << indent() << "var framed bool" << endl; - f_remote << indent() << "var useHttp bool" << endl; - f_remote << indent() << "headers := make(httpHeaders)" << endl; - f_remote << indent() << "var parsedUrl *url.URL" << endl; - f_remote << indent() << "var trans thrift.TTransport" << endl; - f_remote << indent() << "_ = strconv.Atoi" << endl; - f_remote << indent() << "_ = math.Abs" << endl; - f_remote << indent() << "flag.Usage = Usage" << endl; + f_remote << indent() << "flag.Usage = Usage" << '\n'; + f_remote << indent() << "var host string" << '\n'; + f_remote << indent() << "var port int" << '\n'; + f_remote << indent() << "var protocol string" << '\n'; + f_remote << indent() << "var urlString string" << '\n'; + f_remote << indent() << "var framed bool" << '\n'; + f_remote << indent() << "var useHttp bool" << '\n'; + f_remote << indent() << "headers := make(httpHeaders)" << '\n'; + f_remote << indent() << "var parsedUrl *url.URL" << '\n'; + f_remote << indent() << "var trans thrift.TTransport" << '\n'; + f_remote << indent() << "_ = strconv.Atoi" << '\n'; + f_remote << indent() << "_ = math.Abs" << '\n'; + f_remote << indent() << "flag.Usage = Usage" << '\n'; f_remote << indent() << "flag.StringVar(&host, \"h\", \"localhost\", \"Specify host and port\")" - << endl; - f_remote << indent() << "flag.IntVar(&port, \"p\", 9090, \"Specify port\")" << endl; + << '\n'; + f_remote << indent() << "flag.IntVar(&port, \"p\", 9090, \"Specify port\")" << '\n'; f_remote << indent() << "flag.StringVar(&protocol, \"P\", \"binary\", \"" - "Specify the protocol (binary, compact, simplejson, json)\")" << endl; - f_remote << indent() << "flag.StringVar(&urlString, \"u\", \"\", \"Specify the url\")" << endl; + "Specify the protocol (binary, compact, simplejson, json)\")" << '\n'; + f_remote << indent() << "flag.StringVar(&urlString, \"u\", \"\", \"Specify the url\")" << '\n'; f_remote << indent() << "flag.BoolVar(&framed, \"framed\", false, \"Use framed transport\")" - << endl; - f_remote << indent() << "flag.BoolVar(&useHttp, \"http\", false, \"Use http\")" << endl; - f_remote << indent() << "flag.Var(headers, \"H\", \"Headers to set on the http(s) request (e.g. -H \\\"Key: Value\\\")\")" << endl; - f_remote << indent() << "flag.Parse()" << endl; - f_remote << indent() << endl; - f_remote << indent() << "if len(urlString) > 0 {" << endl; - f_remote << indent() << " var err error" << endl; - f_remote << indent() << " parsedUrl, err = url.Parse(urlString)" << endl; - f_remote << indent() << " if err != nil {" << endl; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << endl; - f_remote << indent() << " flag.Usage()" << endl; - f_remote << indent() << " }" << endl; - f_remote << indent() << " host = parsedUrl.Host" << endl; + << '\n'; + f_remote << indent() << "flag.BoolVar(&useHttp, \"http\", false, \"Use http\")" << '\n'; + f_remote << indent() << "flag.Var(headers, \"H\", \"Headers to set on the http(s) request (e.g. -H \\\"Key: Value\\\")\")" << '\n'; + f_remote << indent() << "flag.Parse()" << '\n'; + f_remote << indent() << '\n'; + f_remote << indent() << "if len(urlString) > 0 {" << '\n'; + f_remote << indent() << " var err error" << '\n'; + f_remote << indent() << " parsedUrl, err = url.Parse(urlString)" << '\n'; + f_remote << indent() << " if err != nil {" << '\n'; + f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << '\n'; + f_remote << indent() << " flag.Usage()" << '\n'; + f_remote << indent() << " }" << '\n'; + f_remote << indent() << " host = parsedUrl.Host" << '\n'; f_remote << indent() << " useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == \"http\" || parsedUrl.Scheme == \"https\"" - << endl; - f_remote << indent() << "} else if useHttp {" << endl; + << '\n'; + f_remote << indent() << "} else if useHttp {" << '\n'; f_remote << indent() << " _, err := url.Parse(fmt.Sprint(\"http://\", host, \":\", port))" - << endl; - f_remote << indent() << " if err != nil {" << endl; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << endl; - f_remote << indent() << " flag.Usage()" << endl; - f_remote << indent() << " }" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << endl; - f_remote << indent() << "cmd := flag.Arg(0)" << endl; - f_remote << indent() << "var err error" << endl; - f_remote << indent() << "var cfg *thrift.TConfiguration = nil" << endl; - f_remote << indent() << "if useHttp {" << endl; - f_remote << indent() << " trans, err = thrift.NewTHttpClient(parsedUrl.String())" << endl; - f_remote << indent() << " if len(headers) > 0 {" << endl; - f_remote << indent() << " httptrans := trans.(*thrift.THttpClient)" << endl; - f_remote << indent() << " for key, value := range headers {" << endl; - f_remote << indent() << " httptrans.SetHeader(key, value)" << endl; - f_remote << indent() << " }" << endl; - f_remote << indent() << " }" << endl; - f_remote << indent() << "} else {" << endl; - f_remote << indent() << " portStr := fmt.Sprint(port)" << endl; - f_remote << indent() << " if strings.Contains(host, \":\") {" << endl; - f_remote << indent() << " host, portStr, err = net.SplitHostPort(host)" << endl; - f_remote << indent() << " if err != nil {" << endl; + << '\n'; + f_remote << indent() << " if err != nil {" << '\n'; + f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << '\n'; + f_remote << indent() << " flag.Usage()" << '\n'; + f_remote << indent() << " }" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << '\n'; + f_remote << indent() << "cmd := flag.Arg(0)" << '\n'; + f_remote << indent() << "var err error" << '\n'; + f_remote << indent() << "var cfg *thrift.TConfiguration = nil" << '\n'; + f_remote << indent() << "if useHttp {" << '\n'; + f_remote << indent() << " trans, err = thrift.NewTHttpClient(parsedUrl.String())" << '\n'; + f_remote << indent() << " if len(headers) > 0 {" << '\n'; + f_remote << indent() << " httptrans := trans.(*thrift.THttpClient)" << '\n'; + f_remote << indent() << " for key, value := range headers {" << '\n'; + f_remote << indent() << " httptrans.SetHeader(key, value)" << '\n'; + f_remote << indent() << " }" << '\n'; + f_remote << indent() << " }" << '\n'; + f_remote << indent() << "} else {" << '\n'; + f_remote << indent() << " portStr := fmt.Sprint(port)" << '\n'; + f_remote << indent() << " if strings.Contains(host, \":\") {" << '\n'; + f_remote << indent() << " host, portStr, err = net.SplitHostPort(host)" << '\n'; + f_remote << indent() << " if err != nil {" << '\n'; f_remote << indent() << " fmt.Fprintln(os.Stderr, \"error with host:\", err)" - << endl; - f_remote << indent() << " os.Exit(1)" << endl; - f_remote << indent() << " }" << endl; - f_remote << indent() << " }" << endl; - f_remote << indent() << " trans = thrift.NewTSocketConf(net.JoinHostPort(host, portStr), cfg)" << endl; - f_remote << indent() << " if err != nil {" << endl; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"error resolving address:\", err)" << endl; - f_remote << indent() << " os.Exit(1)" << endl; - f_remote << indent() << " }" << endl; - f_remote << indent() << " if framed {" << endl; - f_remote << indent() << " trans = thrift.NewTFramedTransportConf(trans, cfg)" << endl; - f_remote << indent() << " }" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << "if err != nil {" << endl; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error creating transport\", err)" << endl; - f_remote << indent() << " os.Exit(1)" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << "defer trans.Close()" << endl; - f_remote << indent() << "var protocolFactory thrift.TProtocolFactory" << endl; - f_remote << indent() << "switch protocol {" << endl; - f_remote << indent() << "case \"compact\":" << endl; - f_remote << indent() << " protocolFactory = thrift.NewTCompactProtocolFactoryConf(cfg)" << endl; - f_remote << indent() << " break" << endl; - f_remote << indent() << "case \"simplejson\":" << endl; - f_remote << indent() << " protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(cfg)" << endl; - f_remote << indent() << " break" << endl; - f_remote << indent() << "case \"json\":" << endl; - f_remote << indent() << " protocolFactory = thrift.NewTJSONProtocolFactory()" << endl; - f_remote << indent() << " break" << endl; - f_remote << indent() << "case \"binary\", \"\":" << endl; - f_remote << indent() << " protocolFactory = thrift.NewTBinaryProtocolFactoryConf(cfg)" << endl; - f_remote << indent() << " break" << endl; - f_remote << indent() << "default:" << endl; + << '\n'; + f_remote << indent() << " os.Exit(1)" << '\n'; + f_remote << indent() << " }" << '\n'; + f_remote << indent() << " }" << '\n'; + f_remote << indent() << " trans = thrift.NewTSocketConf(net.JoinHostPort(host, portStr), cfg)" << '\n'; + f_remote << indent() << " if err != nil {" << '\n'; + f_remote << indent() << " fmt.Fprintln(os.Stderr, \"error resolving address:\", err)" << '\n'; + f_remote << indent() << " os.Exit(1)" << '\n'; + f_remote << indent() << " }" << '\n'; + f_remote << indent() << " if framed {" << '\n'; + f_remote << indent() << " trans = thrift.NewTFramedTransportConf(trans, cfg)" << '\n'; + f_remote << indent() << " }" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << "if err != nil {" << '\n'; + f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error creating transport\", err)" << '\n'; + f_remote << indent() << " os.Exit(1)" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << "defer trans.Close()" << '\n'; + f_remote << indent() << "var protocolFactory thrift.TProtocolFactory" << '\n'; + f_remote << indent() << "switch protocol {" << '\n'; + f_remote << indent() << "case \"compact\":" << '\n'; + f_remote << indent() << " protocolFactory = thrift.NewTCompactProtocolFactoryConf(cfg)" << '\n'; + f_remote << indent() << " break" << '\n'; + f_remote << indent() << "case \"simplejson\":" << '\n'; + f_remote << indent() << " protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(cfg)" << '\n'; + f_remote << indent() << " break" << '\n'; + f_remote << indent() << "case \"json\":" << '\n'; + f_remote << indent() << " protocolFactory = thrift.NewTJSONProtocolFactory()" << '\n'; + f_remote << indent() << " break" << '\n'; + f_remote << indent() << "case \"binary\", \"\":" << '\n'; + f_remote << indent() << " protocolFactory = thrift.NewTBinaryProtocolFactoryConf(cfg)" << '\n'; + f_remote << indent() << " break" << '\n'; + f_remote << indent() << "default:" << '\n'; f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Invalid protocol specified: \", protocol)" - << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " os.Exit(1)" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << "iprot := protocolFactory.GetProtocol(trans)" << endl; - f_remote << indent() << "oprot := protocolFactory.GetProtocol(trans)" << endl; + << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " os.Exit(1)" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << "iprot := protocolFactory.GetProtocol(trans)" << '\n'; + f_remote << indent() << "oprot := protocolFactory.GetProtocol(trans)" << '\n'; f_remote << indent() << "client := " << package_name_aliased << ".New" << publicize(service_name_) - << "Client(thrift.NewTStandardClient(iprot, oprot))" << endl; - f_remote << indent() << "if err := trans.Open(); err != nil {" << endl; + << "Client(thrift.NewTStandardClient(iprot, oprot))" << '\n'; + f_remote << indent() << "if err := trans.Open(); err != nil {" << '\n'; f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error opening socket to \", " - "host, \":\", port, \" \", err)" << endl; - f_remote << indent() << " os.Exit(1)" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << endl; - f_remote << indent() << "switch cmd {" << endl; + "host, \":\", port, \" \", err)" << '\n'; + f_remote << indent() << " os.Exit(1)" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << '\n'; + f_remote << indent() << "switch cmd {" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { t_struct* arg_struct = (*f_iter)->get_arglist(); @@ -2404,13 +2404,13 @@ void t_go_generator::generate_service_remote(t_service* tservice) { string funcName((*f_iter)->get_name()); string pubName(publicize(funcName)); string argumentsName(publicize(funcName + "_args", true, func_to_service[funcName])); - f_remote << indent() << "case \"" << escape_string(funcName) << "\":" << endl; + f_remote << indent() << "case \"" << escape_string(funcName) << "\":" << '\n'; indent_up(); - f_remote << indent() << "if flag.NArg() - 1 != " << num_args << " {" << endl; + f_remote << indent() << "if flag.NArg() - 1 != " << num_args << " {" << '\n'; f_remote << indent() << " fmt.Fprintln(os.Stderr, \"" << escape_string(pubName) << " requires " - << num_args << " args\")" << endl; - f_remote << indent() << " flag.Usage()" << endl; - f_remote << indent() << "}" << endl; + << num_args << " args\")" << '\n'; + f_remote << indent() << " flag.Usage()" << '\n'; + f_remote << indent() << "}" << '\n'; for (std::vector::size_type i = 0; i < num_args; ++i) { std::vector::size_type flagArg = i + 1; @@ -2419,13 +2419,13 @@ void t_go_generator::generate_service_remote(t_service* tservice) { if (the_type2->is_enum()) { f_remote << indent() << "tmp" << i << ", err := (strconv.Atoi(flag.Arg(" << flagArg << ")))" - << endl; - f_remote << indent() << "if err != nil {" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; + << '\n'; + f_remote << indent() << "if err != nil {" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; f_remote << indent() << "argvalue" << i << " := " << package_name_aliased << "." - << publicize(the_type->get_name()) << "(tmp" << i << ")" << endl; + << publicize(the_type->get_name()) << "(tmp" << i << ")" << '\n'; } else if (the_type2->is_base_type()) { t_base_type::t_base e = ((t_base_type*)the_type2)->get_base(); string err(tmp("err")); @@ -2437,72 +2437,72 @@ void t_go_generator::generate_service_remote(t_service* tservice) { case t_base_type::TYPE_STRING: if (the_type2->is_binary()) { f_remote << indent() << "argvalue" << i << " := []byte(flag.Arg(" << flagArg << "))" - << endl; + << '\n'; } else { - f_remote << indent() << "argvalue" << i << " := flag.Arg(" << flagArg << ")" << endl; + f_remote << indent() << "argvalue" << i << " := flag.Arg(" << flagArg << ")" << '\n'; } break; case t_base_type::TYPE_BOOL: f_remote << indent() << "argvalue" << i << " := flag.Arg(" << flagArg << ") == \"true\"" - << endl; + << '\n'; break; case t_base_type::TYPE_I8: f_remote << indent() << "tmp" << i << ", " << err << " := (strconv.Atoi(flag.Arg(" - << flagArg << ")))" << endl; - f_remote << indent() << "if " << err << " != nil {" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << "argvalue" << i << " := int8(tmp" << i << ")" << endl; + << flagArg << ")))" << '\n'; + f_remote << indent() << "if " << err << " != nil {" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << "argvalue" << i << " := int8(tmp" << i << ")" << '\n'; break; case t_base_type::TYPE_I16: f_remote << indent() << "tmp" << i << ", " << err << " := (strconv.Atoi(flag.Arg(" - << flagArg << ")))" << endl; - f_remote << indent() << "if " << err << " != nil {" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << "argvalue" << i << " := int16(tmp" << i << ")" << endl; + << flagArg << ")))" << '\n'; + f_remote << indent() << "if " << err << " != nil {" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << "argvalue" << i << " := int16(tmp" << i << ")" << '\n'; break; case t_base_type::TYPE_I32: f_remote << indent() << "tmp" << i << ", " << err << " := (strconv.Atoi(flag.Arg(" - << flagArg << ")))" << endl; - f_remote << indent() << "if " << err << " != nil {" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << "argvalue" << i << " := int32(tmp" << i << ")" << endl; + << flagArg << ")))" << '\n'; + f_remote << indent() << "if " << err << " != nil {" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << "argvalue" << i << " := int32(tmp" << i << ")" << '\n'; break; case t_base_type::TYPE_I64: f_remote << indent() << "argvalue" << i << ", " << err - << " := (strconv.ParseInt(flag.Arg(" << flagArg << "), 10, 64))" << endl; - f_remote << indent() << "if " << err << " != nil {" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; + << " := (strconv.ParseInt(flag.Arg(" << flagArg << "), 10, 64))" << '\n'; + f_remote << indent() << "if " << err << " != nil {" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; break; case t_base_type::TYPE_DOUBLE: f_remote << indent() << "argvalue" << i << ", " << err - << " := (strconv.ParseFloat(flag.Arg(" << flagArg << "), 64))" << endl; - f_remote << indent() << "if " << err << " != nil {" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; + << " := (strconv.ParseFloat(flag.Arg(" << flagArg << "), 64))" << '\n'; + f_remote << indent() << "if " << err << " != nil {" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; break; case t_base_type::TYPE_UUID: f_remote << indent() << "argvalue" << i << ", " << err - << " := (thrift.ParseTuuid(flag.Arg(" << flagArg << ")))" << endl; - f_remote << indent() << "if " << err << " != nil {" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; + << " := (thrift.ParseTuuid(flag.Arg(" << flagArg << ")))" << '\n'; + f_remote << indent() << "if " << err << " != nil {" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; break; default: @@ -2524,26 +2524,26 @@ void t_go_generator::generate_service_remote(t_service* tservice) { tstruct_module = package_name_aliased; } - f_remote << indent() << arg << " := flag.Arg(" << flagArg << ")" << endl; + f_remote << indent() << arg << " := flag.Arg(" << flagArg << ")" << '\n'; f_remote << indent() << mbTrans << " := thrift.NewTMemoryBufferLen(len(" << arg << "))" - << endl; - f_remote << indent() << "defer " << mbTrans << ".Close()" << endl; + << '\n'; + f_remote << indent() << "defer " << mbTrans << ".Close()" << '\n'; f_remote << indent() << "_, " << err1 << " := " << mbTrans << ".WriteString(" << arg << ")" - << endl; - f_remote << indent() << "if " << err1 << " != nil {" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << factory << " := thrift.NewTJSONProtocolFactory()" << endl; + << '\n'; + f_remote << indent() << "if " << err1 << " != nil {" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << factory << " := thrift.NewTJSONProtocolFactory()" << '\n'; f_remote << indent() << jsProt << " := " << factory << ".GetProtocol(" << mbTrans << ")" - << endl; + << '\n'; f_remote << indent() << "argvalue" << i << " := " << tstruct_module << ".New" << tstruct_name - << "()" << endl; - f_remote << indent() << err2 << " := argvalue" << i << "." << read_method_name_ << "(context.Background(), " << jsProt << ")" << endl; - f_remote << indent() << "if " << err2 << " != nil {" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; + << "()" << '\n'; + f_remote << indent() << err2 << " := argvalue" << i << "." << read_method_name_ << "(context.Background(), " << jsProt << ")" << '\n'; + f_remote << indent() << "if " << err2 << " != nil {" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; } else if (the_type2->is_container() || the_type2->is_xception()) { string arg(tmp("arg")); string mbTrans(tmp("mbTrans")); @@ -2552,29 +2552,29 @@ void t_go_generator::generate_service_remote(t_service* tservice) { string jsProt(tmp("jsProt")); string err2(tmp("err")); std::string argName(publicize(args[i]->get_name())); - f_remote << indent() << arg << " := flag.Arg(" << flagArg << ")" << endl; + f_remote << indent() << arg << " := flag.Arg(" << flagArg << ")" << '\n'; f_remote << indent() << mbTrans << " := thrift.NewTMemoryBufferLen(len(" << arg << "))" - << endl; - f_remote << indent() << "defer " << mbTrans << ".Close()" << endl; + << '\n'; + f_remote << indent() << "defer " << mbTrans << ".Close()" << '\n'; f_remote << indent() << "_, " << err1 << " := " << mbTrans << ".WriteString(" << arg << ")" - << endl; - f_remote << indent() << "if " << err1 << " != nil { " << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; - f_remote << indent() << factory << " := thrift.NewTJSONProtocolFactory()" << endl; + << '\n'; + f_remote << indent() << "if " << err1 << " != nil { " << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; + f_remote << indent() << factory << " := thrift.NewTJSONProtocolFactory()" << '\n'; f_remote << indent() << jsProt << " := " << factory << ".GetProtocol(" << mbTrans << ")" - << endl; + << '\n'; f_remote << indent() << "containerStruct" << i << " := " << package_name_aliased << ".New" - << argumentsName << "()" << endl; + << argumentsName << "()" << '\n'; f_remote << indent() << err2 << " := containerStruct" << i << ".ReadField" << (i + 1) << "(context.Background(), " - << jsProt << ")" << endl; - f_remote << indent() << "if " << err2 << " != nil {" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " return" << endl; - f_remote << indent() << "}" << endl; + << jsProt << ")" << '\n'; + f_remote << indent() << "if " << err2 << " != nil {" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " return" << '\n'; + f_remote << indent() << "}" << '\n'; f_remote << indent() << "argvalue" << i << " := containerStruct" << i << "." << argName - << endl; + << '\n'; } else { throw("Invalid argument type in generate_service_remote"); } @@ -2585,9 +2585,9 @@ void t_go_generator::generate_service_remote(t_service* tservice) { typedef_module = package_name_aliased; } f_remote << indent() << "value" << i << " := " << typedef_module << "." - << publicize(the_type->get_name()) << "(argvalue" << i << ")" << endl; + << publicize(the_type->get_name()) << "(argvalue" << i << ")" << '\n'; } else { - f_remote << indent() << "value" << i << " := argvalue" << i << endl; + f_remote << indent() << "value" << i << " := argvalue" << i << '\n'; } } @@ -2634,20 +2634,20 @@ void t_go_generator::generate_service_remote(t_service* tservice) { } } - f_remote << "))" << endl; - f_remote << indent() << "fmt.Print(\"\\n\")" << endl; - f_remote << indent() << "break" << endl; + f_remote << "))" << '\n'; + f_remote << indent() << "fmt.Print(\"\\n\")" << '\n'; + f_remote << indent() << "break" << '\n'; indent_down(); } - f_remote << indent() << "case \"\":" << endl; - f_remote << indent() << " Usage()" << endl; - f_remote << indent() << " break" << endl; - f_remote << indent() << "default:" << endl; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Invalid function \", cmd)" << endl; - f_remote << indent() << "}" << endl; + f_remote << indent() << "case \"\":" << '\n'; + f_remote << indent() << " Usage()" << '\n'; + f_remote << indent() << " break" << '\n'; + f_remote << indent() << "default:" << '\n'; + f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Invalid function \", cmd)" << '\n'; + f_remote << indent() << "}" << '\n'; indent_down(); - f_remote << indent() << "}" << endl; + f_remote << indent() << "}" << '\n'; // Close service file f_remote.close(); format_go_output(f_remote_name); @@ -2696,80 +2696,80 @@ void t_go_generator::generate_service_server(t_service* tservice) { string self(tmp("self")); if (extends_processor.empty()) { - f_types_ << indent() << "type " << serviceName << "Processor struct {" << endl; - f_types_ << indent() << " processorMap map[string]thrift.TProcessorFunction" << endl; - f_types_ << indent() << " handler " << serviceName << endl; - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "type " << serviceName << "Processor struct {" << '\n'; + f_types_ << indent() << " processorMap map[string]thrift.TProcessorFunction" << '\n'; + f_types_ << indent() << " handler " << serviceName << '\n'; + f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func (p *" << serviceName << "Processor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {" - << endl; - f_types_ << indent() << " p.processorMap[key] = processor" << endl; - f_types_ << indent() << "}" << endl << endl; + << '\n'; + f_types_ << indent() << " p.processorMap[key] = processor" << '\n'; + f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func (p *" << serviceName << "Processor) GetProcessorFunction(key string) " - "(processor thrift.TProcessorFunction, ok bool) {" << endl; - f_types_ << indent() << " processor, ok = p.processorMap[key]" << endl; - f_types_ << indent() << " return processor, ok" << endl; - f_types_ << indent() << "}" << endl << endl; + "(processor thrift.TProcessorFunction, ok bool) {" << '\n'; + f_types_ << indent() << " processor, ok = p.processorMap[key]" << '\n'; + f_types_ << indent() << " return processor, ok" << '\n'; + f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func (p *" << serviceName - << "Processor) ProcessorMap() map[string]thrift.TProcessorFunction {" << endl; - f_types_ << indent() << " return p.processorMap" << endl; - f_types_ << indent() << "}" << endl << endl; + << "Processor) ProcessorMap() map[string]thrift.TProcessorFunction {" << '\n'; + f_types_ << indent() << " return p.processorMap" << '\n'; + f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func New" << serviceName << "Processor(handler " << serviceName - << ") *" << serviceName << "Processor {" << endl << endl; + << ") *" << serviceName << "Processor {" << '\n' << '\n'; f_types_ << indent() << " " << self << " := &" << serviceName << "Processor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)}" - << endl; + << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { string escapedFuncName(escape_string((*f_iter)->get_name())); f_types_ << indent() << " " << self << ".processorMap[\"" << escapedFuncName << "\"] = &" << pServiceName << "Processor" << publicize((*f_iter)->get_name()) - << "{handler:handler}" << endl; + << "{handler:handler}" << '\n'; } string x(tmp("x")); - f_types_ << indent() << "return " << self << endl; - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "return " << self << '\n'; + f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func (p *" << serviceName << "Processor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err " - "thrift.TException) {" << endl; - f_types_ << indent() << " name, _, seqId, err2 := iprot.ReadMessageBegin(ctx)" << endl; - f_types_ << indent() << " if err2 != nil { return false, thrift.WrapTException(err2) }" << endl; - f_types_ << indent() << " if processor, ok := p.GetProcessorFunction(name); ok {" << endl; - f_types_ << indent() << " return processor.Process(ctx, seqId, iprot, oprot)" << endl; - f_types_ << indent() << " }" << endl; - f_types_ << indent() << " iprot.Skip(ctx, thrift.STRUCT)" << endl; - f_types_ << indent() << " iprot.ReadMessageEnd(ctx)" << endl; + "thrift.TException) {" << '\n'; + f_types_ << indent() << " name, _, seqId, err2 := iprot.ReadMessageBegin(ctx)" << '\n'; + f_types_ << indent() << " if err2 != nil { return false, thrift.WrapTException(err2) }" << '\n'; + f_types_ << indent() << " if processor, ok := p.GetProcessorFunction(name); ok {" << '\n'; + f_types_ << indent() << " return processor.Process(ctx, seqId, iprot, oprot)" << '\n'; + f_types_ << indent() << " }" << '\n'; + f_types_ << indent() << " iprot.Skip(ctx, thrift.STRUCT)" << '\n'; + f_types_ << indent() << " iprot.ReadMessageEnd(ctx)" << '\n'; f_types_ << indent() << " " << x << " := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, \"Unknown function " - "\" + name)" << endl; - f_types_ << indent() << " oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId)" << endl; - f_types_ << indent() << " " << x << ".Write(ctx, oprot)" << endl; - f_types_ << indent() << " oprot.WriteMessageEnd(ctx)" << endl; - f_types_ << indent() << " oprot.Flush(ctx)" << endl; - f_types_ << indent() << " return false, " << x << endl; - f_types_ << indent() << "" << endl; - f_types_ << indent() << "}" << endl << endl; + "\" + name)" << '\n'; + f_types_ << indent() << " oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId)" << '\n'; + f_types_ << indent() << " " << x << ".Write(ctx, oprot)" << '\n'; + f_types_ << indent() << " oprot.WriteMessageEnd(ctx)" << '\n'; + f_types_ << indent() << " oprot.Flush(ctx)" << '\n'; + f_types_ << indent() << " return false, " << x << '\n'; + f_types_ << indent() << "" << '\n'; + f_types_ << indent() << "}" << '\n' << '\n'; } else { - f_types_ << indent() << "type " << serviceName << "Processor struct {" << endl; - f_types_ << indent() << " *" << extends_processor << endl; - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "type " << serviceName << "Processor struct {" << '\n'; + f_types_ << indent() << " *" << extends_processor << '\n'; + f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func New" << serviceName << "Processor(handler " << serviceName - << ") *" << serviceName << "Processor {" << endl; + << ") *" << serviceName << "Processor {" << '\n'; f_types_ << indent() << " " << self << " := &" << serviceName << "Processor{" - << extends_processor_new << "(handler)}" << endl; + << extends_processor_new << "(handler)}" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { string escapedFuncName(escape_string((*f_iter)->get_name())); f_types_ << indent() << " " << self << ".AddToProcessorMap(\"" << escapedFuncName << "\", &" << pServiceName << "Processor" << publicize((*f_iter)->get_name()) - << "{handler:handler})" << endl; + << "{handler:handler})" << '\n'; } - f_types_ << indent() << " return " << self << endl; - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << " return " << self << '\n'; + f_types_ << indent() << "}" << '\n' << '\n'; } // Generate the process subfunctions @@ -2777,7 +2777,7 @@ void t_go_generator::generate_service_server(t_service* tservice) { generate_process_function(tservice, *f_iter); } - f_types_ << endl; + f_types_ << '\n'; } /** @@ -2794,90 +2794,90 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* // t_struct* xs = tfunction->get_xceptions(); // const std::vector& xceptions = xs->get_members(); - f_types_ << indent() << "type " << processorName << " struct {" << endl; - f_types_ << indent() << " handler " << publicize(tservice->get_name()) << endl; - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "type " << processorName << " struct {" << '\n'; + f_types_ << indent() << " handler " << publicize(tservice->get_name()) << '\n'; + f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func (p *" << processorName << ") Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err " - "thrift.TException) {" << endl; + "thrift.TException) {" << '\n'; indent_up(); string write_err; if (!tfunction->is_oneway()) { write_err = tmp("_write_err"); - f_types_ << indent() << "var " << write_err << " error" << endl; + f_types_ << indent() << "var " << write_err << " error" << '\n'; } - f_types_ << indent() << "args := " << argsname << "{}" << endl; - f_types_ << indent() << "if err2 := args." << read_method_name_ << "(ctx, iprot); err2 != nil {" << endl; + f_types_ << indent() << "args := " << argsname << "{}" << '\n'; + f_types_ << indent() << "if err2 := args." << read_method_name_ << "(ctx, iprot); err2 != nil {" << '\n'; indent_up(); - f_types_ << indent() << "iprot.ReadMessageEnd(ctx)" << endl; + f_types_ << indent() << "iprot.ReadMessageEnd(ctx)" << '\n'; if (!tfunction->is_oneway()) { f_types_ << indent() << "x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error())" - << endl; + << '\n'; f_types_ << indent() << "oprot.WriteMessageBegin(ctx, \"" << escape_string(tfunction->get_name()) - << "\", thrift.EXCEPTION, seqId)" << endl; - f_types_ << indent() << "x.Write(ctx, oprot)" << endl; - f_types_ << indent() << "oprot.WriteMessageEnd(ctx)" << endl; - f_types_ << indent() << "oprot.Flush(ctx)" << endl; + << "\", thrift.EXCEPTION, seqId)" << '\n'; + f_types_ << indent() << "x.Write(ctx, oprot)" << '\n'; + f_types_ << indent() << "oprot.WriteMessageEnd(ctx)" << '\n'; + f_types_ << indent() << "oprot.Flush(ctx)" << '\n'; } - f_types_ << indent() << "return false, thrift.WrapTException(err2)" << endl; + f_types_ << indent() << "return false, thrift.WrapTException(err2)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; - f_types_ << indent() << "iprot.ReadMessageEnd(ctx)" << endl << endl; + f_types_ << indent() << "}" << '\n'; + f_types_ << indent() << "iprot.ReadMessageEnd(ctx)" << '\n' << '\n'; // Even though we never create the goroutine in oneway handlers, // always have (nop) tickerCancel defined makes the writing part of code // generating easier and less error-prone. - f_types_ << indent() << "tickerCancel := func() {}" << endl; + f_types_ << indent() << "tickerCancel := func() {}" << '\n'; // Only create the goroutine for non-oneways. if (!tfunction->is_oneway()) { - f_types_ << indent() << "// Start a goroutine to do server side connectivity check." << endl; - f_types_ << indent() << "if thrift.ServerConnectivityCheckInterval > 0 {" << endl; + f_types_ << indent() << "// Start a goroutine to do server side connectivity check." << '\n'; + f_types_ << indent() << "if thrift.ServerConnectivityCheckInterval > 0 {" << '\n'; indent_up(); - f_types_ << indent() << "var cancel context.CancelCauseFunc" << endl; - f_types_ << indent() << "ctx, cancel = context.WithCancelCause(ctx)" << endl; - f_types_ << indent() << "defer cancel(nil)" << endl; - f_types_ << indent() << "var tickerCtx context.Context" << endl; - f_types_ << indent() << "tickerCtx, tickerCancel = context.WithCancel(context.Background())" << endl; - f_types_ << indent() << "defer tickerCancel()" << endl; - f_types_ << indent() << "go func(ctx context.Context, cancel context.CancelCauseFunc) {" << endl; + f_types_ << indent() << "var cancel context.CancelCauseFunc" << '\n'; + f_types_ << indent() << "ctx, cancel = context.WithCancelCause(ctx)" << '\n'; + f_types_ << indent() << "defer cancel(nil)" << '\n'; + f_types_ << indent() << "var tickerCtx context.Context" << '\n'; + f_types_ << indent() << "tickerCtx, tickerCancel = context.WithCancel(context.Background())" << '\n'; + f_types_ << indent() << "defer tickerCancel()" << '\n'; + f_types_ << indent() << "go func(ctx context.Context, cancel context.CancelCauseFunc) {" << '\n'; indent_up(); - f_types_ << indent() << "ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval)" << endl; - f_types_ << indent() << "defer ticker.Stop()" << endl; - f_types_ << indent() << "for {" << endl; + f_types_ << indent() << "ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval)" << '\n'; + f_types_ << indent() << "defer ticker.Stop()" << '\n'; + f_types_ << indent() << "for {" << '\n'; indent_up(); - f_types_ << indent() << "select {" << endl; - f_types_ << indent() << "case <-ctx.Done():" << endl; + f_types_ << indent() << "select {" << '\n'; + f_types_ << indent() << "case <-ctx.Done():" << '\n'; indent_up(); - f_types_ << indent() << "return" << endl; + f_types_ << indent() << "return" << '\n'; indent_down(); - f_types_ << indent() << "case <-ticker.C:" << endl; + f_types_ << indent() << "case <-ticker.C:" << '\n'; indent_up(); - f_types_ << indent() << "if !iprot.Transport().IsOpen() {" << endl; + f_types_ << indent() << "if !iprot.Transport().IsOpen() {" << '\n'; indent_up(); - f_types_ << indent() << "cancel(thrift.ErrAbandonRequest)" << endl; - f_types_ << indent() << "return" << endl; + f_types_ << indent() << "cancel(thrift.ErrAbandonRequest)" << '\n'; + f_types_ << indent() << "return" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; indent_down(); - f_types_ << indent() << "}(tickerCtx, cancel)" << endl; + f_types_ << indent() << "}(tickerCtx, cancel)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; } else { // Make sure we don't get the defined but unused compiling error. - f_types_ << indent() << "_ = tickerCancel" << endl << endl; + f_types_ << indent() << "_ = tickerCancel" << '\n' << '\n'; } if (!tfunction->is_oneway()) { - f_types_ << indent() << "result := " << resultname << "{}" << endl; + f_types_ << indent() << "result := " << resultname << "{}" << '\n'; } bool need_reference = type_need_reference(tfunction->get_returntype()); @@ -2908,93 +2908,93 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* f_types_ << "args." << publicize((*f_iter)->get_name()); } - f_types_ << "); err2 != nil {" << endl; + f_types_ << "); err2 != nil {" << '\n'; indent_up(); - f_types_ << indent() << "tickerCancel()" << endl; - f_types_ << indent() << "err = thrift.WrapTException(err2)" << endl; + f_types_ << indent() << "tickerCancel()" << '\n'; + f_types_ << indent() << "err = thrift.WrapTException(err2)" << '\n'; t_struct* exceptions = tfunction->get_xceptions(); const vector& x_fields = exceptions->get_members(); if (!x_fields.empty()) { - f_types_ << indent() << "switch v := err2.(type) {" << endl; + f_types_ << indent() << "switch v := err2.(type) {" << '\n'; vector::const_iterator xf_iter; for (xf_iter = x_fields.begin(); xf_iter != x_fields.end(); ++xf_iter) { f_types_ << indent() << "case " << type_to_go_type(((*xf_iter)->get_type())) << ":" - << endl; + << '\n'; indent_up(); - f_types_ << indent() << "result." << publicize((*xf_iter)->get_name()) << " = v" << endl; + f_types_ << indent() << "result." << publicize((*xf_iter)->get_name()) << " = v" << '\n'; indent_down(); } - f_types_ << indent() << "default:" << endl; + f_types_ << indent() << "default:" << '\n'; indent_up(); } if (!tfunction->is_oneway()) { // Avoid writing the error to the wire if it's ErrAbandonRequest - f_types_ << indent() << "if errors.Is(err2, thrift.ErrAbandonRequest) {" << endl; + f_types_ << indent() << "if errors.Is(err2, thrift.ErrAbandonRequest) {" << '\n'; indent_up(); - f_types_ << indent() << "return false, thrift.WrapTException(err2)" << endl; + f_types_ << indent() << "return false, thrift.WrapTException(err2)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; - f_types_ << indent() << "if errors.Is(err2, context.Canceled) {" << endl; + f_types_ << indent() << "}" << '\n'; + f_types_ << indent() << "if errors.Is(err2, context.Canceled) {" << '\n'; indent_up(); - f_types_ << indent() << "if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) {" << endl; + f_types_ << indent() << "if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) {" << '\n'; indent_up(); - f_types_ << indent() << "return false, thrift.WrapTException(err)" << endl; + f_types_ << indent() << "return false, thrift.WrapTException(err)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; string exc(tmp("_exc")); f_types_ << indent() << exc << " := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, " "\"Internal error processing " << escape_string(tfunction->get_name()) - << ": \" + err2.Error())" << endl; + << ": \" + err2.Error())" << '\n'; f_types_ << indent() << "if err2 := oprot.WriteMessageBegin(ctx, \"" << escape_string(tfunction->get_name()) - << "\", thrift.EXCEPTION, seqId); err2 != nil {" << endl; + << "\", thrift.EXCEPTION, seqId); err2 != nil {" << '\n'; indent_up(); - f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl; + f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; f_types_ << indent() << "if err2 := " << exc << ".Write(ctx, oprot); " - << write_err << " == nil && err2 != nil {" << endl; + << write_err << " == nil && err2 != nil {" << '\n'; indent_up(); - f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl; + f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; f_types_ << indent() << "if err2 := oprot.WriteMessageEnd(ctx); " - << write_err << " == nil && err2 != nil {" << endl; + << write_err << " == nil && err2 != nil {" << '\n'; indent_up(); - f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl; + f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; f_types_ << indent() << "if err2 := oprot.Flush(ctx); " - << write_err << " == nil && err2 != nil {" << endl; + << write_err << " == nil && err2 != nil {" << '\n'; indent_up(); - f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl; + f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; - f_types_ << indent() << "if " << write_err << " != nil {" << endl; + f_types_ << indent() << "if " << write_err << " != nil {" << '\n'; indent_up(); - f_types_ << indent() << "return false, thrift.WrapTException(" << write_err << ")" << endl; + f_types_ << indent() << "return false, thrift.WrapTException(" << write_err << ")" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; // return success=true as long as writing to the wire was successful. - f_types_ << indent() << "return true, err" << endl; + f_types_ << indent() << "return true, err" << '\n'; } if (!x_fields.empty()) { indent_down(); - f_types_ << indent() << "}" << endl; // closes switch + f_types_ << indent() << "}" << '\n'; // closes switch } indent_down(); @@ -3002,63 +3002,63 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* if (!tfunction->is_oneway()) { if (!tfunction->get_returntype()->is_void()) { - f_types_ << " else {" << endl; // make sure we set Success retval only on success + f_types_ << " else {" << '\n'; // make sure we set Success retval only on success indent_up(); f_types_ << indent() << "result.Success = "; if (need_reference) { f_types_ << "&"; } - f_types_ << "retval" << endl; + f_types_ << "retval" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; } else { - f_types_ << endl; + f_types_ << '\n'; } - f_types_ << indent() << "tickerCancel()" << endl; + f_types_ << indent() << "tickerCancel()" << '\n'; f_types_ << indent() << "if err2 := oprot.WriteMessageBegin(ctx, \"" << escape_string(tfunction->get_name()) << "\", thrift.REPLY, seqId); err2 != nil {" - << endl; + << '\n'; indent_up(); - f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl; + f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; f_types_ << indent() << "if err2 := result." << write_method_name_ << "(ctx, oprot); " - << write_err << " == nil && err2 != nil {" << endl; + << write_err << " == nil && err2 != nil {" << '\n'; indent_up(); - f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl; + f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; f_types_ << indent() << "if err2 := oprot.WriteMessageEnd(ctx); " - << write_err << " == nil && err2 != nil {" << endl; + << write_err << " == nil && err2 != nil {" << '\n'; indent_up(); - f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl; + f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; - f_types_ << indent() << "if err2 := oprot.Flush(ctx); " << write_err << " == nil && err2 != nil {" << endl; + f_types_ << indent() << "if err2 := oprot.Flush(ctx); " << write_err << " == nil && err2 != nil {" << '\n'; indent_up(); - f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl; + f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; - f_types_ << indent() << "if " << write_err << " != nil {" << endl; + f_types_ << indent() << "if " << write_err << " != nil {" << '\n'; indent_up(); - f_types_ << indent() << "return false, thrift.WrapTException(" << write_err << ")" << endl; + f_types_ << indent() << "return false, thrift.WrapTException(" << write_err << ")" << '\n'; indent_down(); - f_types_ << indent() << "}" << endl; + f_types_ << indent() << "}" << '\n'; // return success=true as long as writing to the wire was successful. - f_types_ << indent() << "return true, err" << endl; + f_types_ << indent() << "return true, err" << '\n'; } else { - f_types_ << endl; - f_types_ << indent() << "tickerCancel()" << endl; - f_types_ << indent() << "return true, err" << endl; + f_types_ << '\n'; + f_types_ << indent() << "tickerCancel()" << '\n'; + f_types_ << indent() << "return true, err" << '\n'; } indent_down(); - f_types_ << indent() << "}" << endl << endl; + f_types_ << indent() << "}" << '\n' << '\n'; } /** @@ -3096,7 +3096,7 @@ void t_go_generator::generate_deserialize_field(ostream& out, string type_name = inkey ? type_to_go_key_type(tfield->get_type()) : type_to_go_type(tfield->get_type()); - out << "var " << tfield->get_name() << " " << type_name << endl; + out << "var " << tfield->get_name() << " " << type_name << '\n'; } indent(out) << "if v, err := iprot."; @@ -3153,11 +3153,11 @@ void t_go_generator::generate_deserialize_field(ostream& out, out << "ReadI32(ctx)"; } - out << "; err != nil {" << endl; + out << "; err != nil {" << '\n'; out << indent() << "return thrift.PrependError(\"error reading field " << tfield->get_key() - << ": \", err)" << endl; + << ": \", err)" << '\n'; - out << "} else {" << endl; + out << "} else {" << '\n'; string wrap; if (type->is_enum() || orig_type->is_typedef()) { @@ -3168,13 +3168,13 @@ void t_go_generator::generate_deserialize_field(ostream& out, string maybe_address = (is_pointer_field(tfield) ? "&" : ""); if (wrap == "") { - indent(out) << name << " = " << maybe_address << "v" << endl; + indent(out) << name << " = " << maybe_address << "v" << '\n'; } else { - indent(out) << "temp := " << wrap << "(v)" << endl; - indent(out) << name << " = " << maybe_address << "temp" << endl; + indent(out) << "temp := " << wrap << "(v)" << '\n'; + indent(out) << name << " = " << maybe_address << "temp" << '\n'; } - out << "}" << endl; + out << "}" << '\n'; } else { throw "INVALID TYPE IN generate_deserialize_field '" + type->get_name() + "' for field '" + tfield->get_name() + "'"; @@ -3193,10 +3193,10 @@ void t_go_generator::generate_deserialize_struct(ostream& out, out << indent() << prefix << eq << (pointer_field ? "&" : ""); generate_go_struct_initializer(out, tstruct); - out << indent() << "if err := " << prefix << "." << read_method_name_ << "(ctx, iprot); err != nil {" << endl; + out << indent() << "if err := " << prefix << "." << read_method_name_ << "(ctx, iprot); err != nil {" << '\n'; out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", " - << prefix << "), err)" << endl; - out << indent() << "}" << endl; + << prefix << "), err)" << '\n'; + out << indent() << "}" << '\n'; } /** @@ -3217,33 +3217,33 @@ void t_go_generator::generate_deserialize_container(ostream& out, // Declare variables, read header if (ttype->is_map()) { - out << indent() << "_, _, size, err := iprot.ReadMapBegin(ctx)" << endl; - out << indent() << "if err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error reading map begin: \", err)" << endl; - out << indent() << "}" << endl; - out << indent() << "tMap := make(" << type_to_go_type(orig_type) << ", size)" << endl; - out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tMap" << endl; + out << indent() << "_, _, size, err := iprot.ReadMapBegin(ctx)" << '\n'; + out << indent() << "if err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error reading map begin: \", err)" << '\n'; + out << indent() << "}" << '\n'; + out << indent() << "tMap := make(" << type_to_go_type(orig_type) << ", size)" << '\n'; + out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tMap" << '\n'; } else if (ttype->is_set()) { - out << indent() << "_, size, err := iprot.ReadSetBegin(ctx)" << endl; - out << indent() << "if err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error reading set begin: \", err)" << endl; - out << indent() << "}" << endl; - out << indent() << "tSet := make(" << type_to_go_type(orig_type) << ", 0, size)" << endl; - out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSet" << endl; + out << indent() << "_, size, err := iprot.ReadSetBegin(ctx)" << '\n'; + out << indent() << "if err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error reading set begin: \", err)" << '\n'; + out << indent() << "}" << '\n'; + out << indent() << "tSet := make(" << type_to_go_type(orig_type) << ", 0, size)" << '\n'; + out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSet" << '\n'; } else if (ttype->is_list()) { - out << indent() << "_, size, err := iprot.ReadListBegin(ctx)" << endl; - out << indent() << "if err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error reading list begin: \", err)" << endl; - out << indent() << "}" << endl; - out << indent() << "tSlice := make(" << type_to_go_type(orig_type) << ", 0, size)" << endl; - out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSlice" << endl; + out << indent() << "_, size, err := iprot.ReadListBegin(ctx)" << '\n'; + out << indent() << "if err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error reading list begin: \", err)" << '\n'; + out << indent() << "}" << '\n'; + out << indent() << "tSlice := make(" << type_to_go_type(orig_type) << ", 0, size)" << '\n'; + out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSlice" << '\n'; } else { throw "INVALID TYPE IN generate_deserialize_container '" + ttype->get_name() + "' for prefix '" + prefix + "'"; } // For loop iterates over elements - out << indent() << "for i := 0; i < size; i ++ {" << endl; + out << indent() << "for i := 0; i < size; i ++ {" << '\n'; indent_up(); if (pointer_field) { @@ -3258,21 +3258,21 @@ void t_go_generator::generate_deserialize_container(ostream& out, } indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; // Read container end if (ttype->is_map()) { - out << indent() << "if err := iprot.ReadMapEnd(ctx); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error reading map end: \", err)" << endl; - out << indent() << "}" << endl; + out << indent() << "if err := iprot.ReadMapEnd(ctx); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error reading map end: \", err)" << '\n'; + out << indent() << "}" << '\n'; } else if (ttype->is_set()) { - out << indent() << "if err := iprot.ReadSetEnd(ctx); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error reading set end: \", err)" << endl; - out << indent() << "}" << endl; + out << indent() << "if err := iprot.ReadSetEnd(ctx); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error reading set end: \", err)" << '\n'; + out << indent() << "}" << '\n'; } else if (ttype->is_list()) { - out << indent() << "if err := iprot.ReadListEnd(ctx); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error reading list end: \", err)" << endl; - out << indent() << "}" << endl; + out << indent() << "if err := iprot.ReadListEnd(ctx); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error reading list end: \", err)" << '\n'; + out << indent() << "}" << '\n'; } } @@ -3292,7 +3292,7 @@ void t_go_generator::generate_deserialize_map_element(ostream& out, fval.set_req(t_field::T_OPT_IN_REQ_OUT); generate_deserialize_field(out, &fkey, true, "", false, false, true); generate_deserialize_field(out, &fval, true, "", false, false, false, true); - indent(out) << prefix << "[" << key << "] = " << val << endl; + indent(out) << prefix << "[" << key << "] = " << val << '\n'; } /** @@ -3307,7 +3307,7 @@ void t_go_generator::generate_deserialize_set_element(ostream& out, t_field felem(tset->get_elem_type(), elem); felem.set_req(t_field::T_OPT_IN_REQ_OUT); generate_deserialize_field(out, &felem, true, "", false, false, false, true); - indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << endl; + indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << '\n'; } /** @@ -3322,7 +3322,7 @@ void t_go_generator::generate_deserialize_list_element(ostream& out, t_field felem(((t_list*)tlist)->get_elem_type(), elem); felem.set_req(t_field::T_OPT_IN_REQ_OUT); generate_deserialize_field(out, &felem, true, "", false, false, false, true); - indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << endl; + indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << '\n'; } /** @@ -3406,10 +3406,10 @@ void t_go_generator::generate_serialize_field(ostream& out, out << "WriteI32(ctx, int32(" << name << "))"; } - out << "; err != nil {" << endl; + out << "; err != nil {" << '\n'; out << indent() << "return thrift.PrependError(fmt.Sprintf(\"%T." << escape_string(tfield->get_name()) << " (" << tfield->get_key() - << ") field write error: \", p), err) }" << endl; + << ") field write error: \", p), err) }" << '\n'; } else { throw "compiler error: Invalid type in generate_serialize_field '" + type->get_name() + "' for field '" + name + "'"; @@ -3424,10 +3424,10 @@ void t_go_generator::generate_serialize_field(ostream& out, */ void t_go_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - out << indent() << "if err := " << prefix << "." << write_method_name_ << "(ctx, oprot); err != nil {" << endl; + out << indent() << "if err := " << prefix << "." << write_method_name_ << "(ctx, oprot); err != nil {" << '\n'; out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", " - << prefix << "), err)" << endl; - out << indent() << "}" << endl; + << prefix << "), err)" << '\n'; + out << indent() << "}" << '\n'; } void t_go_generator::generate_serialize_container(ostream& out, @@ -3441,21 +3441,21 @@ void t_go_generator::generate_serialize_container(ostream& out, out << indent() << "if err := oprot.WriteMapBegin(ctx, " << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " - << "len(" << prefix << ")); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error writing map begin: \", err)" << endl; - out << indent() << "}" << endl; + << "len(" << prefix << ")); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error writing map begin: \", err)" << '\n'; + out << indent() << "}" << '\n'; } else if (ttype->is_set()) { out << indent() << "if err := oprot.WriteSetBegin(ctx, " << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " - << "len(" << prefix << ")); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error writing set begin: \", err)" << endl; - out << indent() << "}" << endl; + << "len(" << prefix << ")); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error writing set begin: \", err)" << '\n'; + out << indent() << "}" << '\n'; } else if (ttype->is_list()) { out << indent() << "if err := oprot.WriteListBegin(ctx, " << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " - << "len(" << prefix << ")); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error writing list begin: \", err)" << endl; - out << indent() << "}" << endl; + << "len(" << prefix << ")); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error writing list begin: \", err)" << '\n'; + out << indent() << "}" << '\n'; } else { throw "compiler error: Invalid type in generate_serialize_container '" + ttype->get_name() + "' for prefix '" + prefix + "'"; @@ -3463,66 +3463,66 @@ void t_go_generator::generate_serialize_container(ostream& out, if (ttype->is_map()) { t_map* tmap = (t_map*)ttype; - out << indent() << "for k, v := range " << prefix << " {" << endl; + out << indent() << "for k, v := range " << prefix << " {" << '\n'; indent_up(); generate_serialize_map_element(out, tmap, "k", "v"); indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } else if (ttype->is_set()) { t_set* tset = (t_set*)ttype; - out << indent() << "for i := 0; iget_elem_type()); - out << indent() << "if func(tgt, src " << goType << ") bool {" << endl; + out << indent() << "if func(tgt, src " << goType << ") bool {" << '\n'; indent_up(); generate_go_equals(out, tset->get_elem_type(), "tgt", "src"); - out << indent() << "return true" << endl; + out << indent() << "return true" << '\n'; indent_down(); - out << indent() << "}(" << wrapped_prefix << "[i], " << wrapped_prefix << "[j]) {" << endl; + out << indent() << "}(" << wrapped_prefix << "[i], " << wrapped_prefix << "[j]) {" << '\n'; indent_up(); out << indent() << "return thrift.PrependError(\"\", fmt.Errorf(\"%T error writing set field: slice is not " "unique\", " - << wrapped_prefix << "))" << endl; + << wrapped_prefix << "))" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl; - out << indent() << "for _, v := range " << prefix << " {" << endl; + out << indent() << "}" << '\n'; + out << indent() << "for _, v := range " << prefix << " {" << '\n'; indent_up(); generate_serialize_set_element(out, tset, "v"); indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } else if (ttype->is_list()) { t_list* tlist = (t_list*)ttype; - out << indent() << "for _, v := range " << prefix << " {" << endl; + out << indent() << "for _, v := range " << prefix << " {" << '\n'; indent_up(); generate_serialize_list_element(out, tlist, "v"); indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } if (ttype->is_map()) { - out << indent() << "if err := oprot.WriteMapEnd(ctx); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error writing map end: \", err)" << endl; - out << indent() << "}" << endl; + out << indent() << "if err := oprot.WriteMapEnd(ctx); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error writing map end: \", err)" << '\n'; + out << indent() << "}" << '\n'; } else if (ttype->is_set()) { - out << indent() << "if err := oprot.WriteSetEnd(ctx); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error writing set end: \", err)" << endl; - out << indent() << "}" << endl; + out << indent() << "if err := oprot.WriteSetEnd(ctx); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error writing set end: \", err)" << '\n'; + out << indent() << "}" << '\n'; } else if (ttype->is_list()) { - out << indent() << "if err := oprot.WriteListEnd(ctx); err != nil {" << endl; - out << indent() << " return thrift.PrependError(\"error writing list end: \", err)" << endl; - out << indent() << "}" << endl; + out << indent() << "if err := oprot.WriteListEnd(ctx); err != nil {" << '\n'; + out << indent() << " return thrift.PrependError(\"error writing list end: \", err)" << '\n'; + out << indent() << "}" << '\n'; } } @@ -3609,7 +3609,7 @@ void t_go_generator::generate_go_equals(ostream& out, t_type* ori_type, string t out << tgt << " != " << src; } - out << " { return false }" << endl; + out << " { return false }" << '\n'; } else { throw "compiler error: Invalid type in generate_go_equals '" + ttype->get_name() + "' for '" + tgt + "'"; @@ -3625,7 +3625,7 @@ void t_go_generator::generate_go_equals_struct(ostream& out, string src) { (void)ttype; out << indent() << "if !" << tgt << "." << equals_method_name_ << "(" << src - << ") { return false }" << endl; + << ") { return false }" << '\n'; } /** @@ -3635,16 +3635,16 @@ void t_go_generator::generate_go_equals_container(ostream& out, t_type* ttype, string tgt, string src) { - out << indent() << "if len(" << tgt << ") != len(" << src << ") { return false }" << endl; + out << indent() << "if len(" << tgt << ") != len(" << src << ") { return false }" << '\n'; if (ttype->is_map()) { t_map* tmap = (t_map*)ttype; - out << indent() << "for k, _tgt := range " << tgt << " {" << endl; + out << indent() << "for k, _tgt := range " << tgt << " {" << '\n'; indent_up(); string element_source = tmp("_src"); - out << indent() << element_source << " := " << src << "[k]" << endl; + out << indent() << element_source << " := " << src << "[k]" << '\n'; generate_go_equals(out, tmap->get_val_type(), "_tgt", element_source); indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } else if (ttype->is_list() || ttype->is_set()) { t_type* elem; if (ttype->is_list()) { @@ -3654,13 +3654,13 @@ void t_go_generator::generate_go_equals_container(ostream& out, t_set* temp = (t_set*)ttype; elem = temp->get_elem_type(); } - out << indent() << "for i, _tgt := range " << tgt << " {" << endl; + out << indent() << "for i, _tgt := range " << tgt << " {" << '\n'; indent_up(); string element_source = tmp("_src"); - out << indent() << element_source << " := " << src << "[i]" << endl; + out << indent() << element_source << " := " << src << "[i]" << '\n'; generate_go_equals(out, elem, "_tgt", element_source); indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } else { throw "INVALID TYPE IN generate_go_equals_container '" + ttype->get_name(); } @@ -3699,7 +3699,7 @@ void t_go_generator::generate_go_docstring(ostream& out, if (fields.size() > 0) { if (has_doc) { - ss << endl; + ss << '\n'; } has_doc = true; @@ -3713,7 +3713,7 @@ void t_go_generator::generate_go_docstring(ostream& out, if (p->has_doc()) { ss << ": " << p->get_doc(); } else { - ss << endl; + ss << '\n'; } } } diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.h b/compiler/cpp/src/thrift/generate/t_go_generator.h index a67485c5506..55f544e19f8 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.h +++ b/compiler/cpp/src/thrift/generate/t_go_generator.h @@ -44,8 +44,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - const string DEFAULT_THRIFT_IMPORT = "github.com/apache/thrift/lib/go/thrift"; static std::string package_flag; diff --git a/compiler/cpp/src/thrift/generate/t_gv_generator.cc b/compiler/cpp/src/thrift/generate/t_gv_generator.cc index f8616ffb345..c91200b4916 100644 --- a/compiler/cpp/src/thrift/generate/t_gv_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_gv_generator.cc @@ -38,8 +38,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * Graphviz code generator */ @@ -110,10 +108,10 @@ void t_gv_generator::init_generator() { MKDIR(get_out_dir().c_str()); string fname = get_out_dir() + program_->get_name() + ".gv"; f_out_.open(fname.c_str()); - f_out_ << "digraph \"" << escape_string(program_name_) << "\" {" << endl; - f_out_ << "node [style=filled, shape=record];" << endl; - f_out_ << "edge [arrowsize=0.5];" << endl; - f_out_ << "rankdir=LR" << endl; + f_out_ << "digraph \"" << escape_string(program_name_) << "\" {" << '\n'; + f_out_ << "node [style=filled, shape=record];" << '\n'; + f_out_ << "edge [arrowsize=0.5];" << '\n'; + f_out_ << "rankdir=LR" << '\n'; } /** @@ -126,29 +124,29 @@ void t_gv_generator::close_generator() { // Print edges std::list::iterator iter = edges.begin(); for (; iter != edges.end(); iter++) { - f_out_ << (*iter) << endl; + f_out_ << (*iter) << '\n'; } // Print graph end } and close file - f_out_ << "}" << endl; + f_out_ << "}" << '\n'; f_out_.close(); } void t_gv_generator::generate_typedef(t_typedef* ttypedef) { string name = ttypedef->get_name(); - f_out_ << "node [fillcolor=azure];" << endl; + f_out_ << "node [fillcolor=azure];" << '\n'; f_out_ << name << " [label=\""; f_out_ << escape_string(name); f_out_ << " :: "; print_type(ttypedef->get_type(), name); - f_out_ << "\"];" << endl; + f_out_ << "\"];" << '\n'; } void t_gv_generator::generate_enum(t_enum* tenum) { string name = tenum->get_name(); - f_out_ << "node [fillcolor=white];" << endl; + f_out_ << "node [fillcolor=white];" << '\n'; f_out_ << name << " [label=\"enum " << escape_string(name); vector values = tenum->get_constants(); @@ -159,13 +157,13 @@ void t_gv_generator::generate_enum(t_enum* tenum) { f_out_ << (*val_iter)->get_value(); } - f_out_ << "\"];" << endl; + f_out_ << "\"];" << '\n'; } void t_gv_generator::generate_const(t_const* tconst) { string name = tconst->get_name(); - f_out_ << "node [fillcolor=aliceblue];" << endl; + f_out_ << "node [fillcolor=aliceblue];" << '\n'; f_out_ << "const_" << name << " [label=\""; f_out_ << escape_string(name); @@ -174,22 +172,22 @@ void t_gv_generator::generate_const(t_const* tconst) { f_out_ << " :: "; print_type(tconst->get_type(), "const_" + name); - f_out_ << "\"];" << endl; + f_out_ << "\"];" << '\n'; } void t_gv_generator::generate_struct(t_struct* tstruct) { string name = tstruct->get_name(); if (tstruct->is_xception()) { - f_out_ << "node [fillcolor=lightpink];" << endl; + f_out_ << "node [fillcolor=lightpink];" << '\n'; f_out_ << name << " [label=\""; f_out_ << "exception " << escape_string(name); } else if (tstruct->is_union()) { - f_out_ << "node [fillcolor=lightcyan];" << endl; + f_out_ << "node [fillcolor=lightcyan];" << '\n'; f_out_ << name << " [label=\""; f_out_ << "union " << escape_string(name); } else { - f_out_ << "node [fillcolor=beige];" << endl; + f_out_ << "node [fillcolor=beige];" << '\n'; f_out_ << name << " [label=\""; f_out_ << "struct " << escape_string(name); } @@ -208,7 +206,7 @@ void t_gv_generator::generate_struct(t_struct* tstruct) { print_type((*mem_iter)->get_type(), name + ":field_" + field_name); } - f_out_ << "\"];" << endl; + f_out_ << "\"];" << '\n'; } void t_gv_generator::print_type(t_type* ttype, string struct_field_ref) { @@ -296,10 +294,10 @@ void t_gv_generator::print_const_value(t_type* type, t_const_value* tvalue) { void t_gv_generator::generate_service(t_service* tservice) { string service_name = get_service_name(tservice); - f_out_ << "subgraph cluster_" << service_name << " {" << endl; - f_out_ << "node [fillcolor=bisque];" << endl; - f_out_ << "style=dashed;" << endl; - f_out_ << "label = \"" << escape_string(service_name) << " service\";" << endl; + f_out_ << "subgraph cluster_" << service_name << " {" << '\n'; + f_out_ << "node [fillcolor=bisque];" << '\n'; + f_out_ << "style=dashed;" << '\n'; + f_out_ << "label = \"" << escape_string(service_name) << " service\";" << '\n'; // TODO: service extends @@ -327,7 +325,7 @@ void t_gv_generator::generate_service(t_service* tservice) { "function_" + service_name + fn_name + ":param_" + (*arg_iter)->get_name()); } // end of node - f_out_ << "\"];" << endl; + f_out_ << "\"];" << '\n'; // Exception edges if (exception_arrows) { @@ -340,7 +338,7 @@ void t_gv_generator::generate_service(t_service* tservice) { } } - f_out_ << " }" << endl; + f_out_ << " }" << '\n'; } std::string t_gv_generator::display_name() const { diff --git a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc index b236e0bc619..40d4ce2e027 100644 --- a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc @@ -37,8 +37,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * Haxe code generator. * @@ -424,10 +422,10 @@ void t_haxe_generator::generate_enum(t_enum* tenum) { f_enum.open(f_enum_name.c_str()); // Comment and package it - f_enum << autogen_comment() << haxe_package() << ";" << endl << endl; + f_enum << autogen_comment() << haxe_package() << ";" << '\n' << '\n'; // Add haxe imports - f_enum << string() + "import org.apache.thrift.helper.*;" << endl << endl; + f_enum << string() + "import org.apache.thrift.helper.*;" << '\n' << '\n'; generate_rtti_decoration(f_enum); generate_macro_decoration(f_enum); @@ -439,11 +437,11 @@ void t_haxe_generator::generate_enum(t_enum* tenum) { for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); indent(f_enum) << "public static inline var " << (*c_iter)->get_name() << " : Int = " << value - << ";" << endl; + << ";" << '\n'; } // Create a static Set with all valid values for this enum - f_enum << endl; + f_enum << '\n'; indent(f_enum) << "public static var VALID_VALUES = { new IntSet( ["; indent_up(); @@ -454,19 +452,19 @@ void t_haxe_generator::generate_enum(t_enum* tenum) { firstValue = false; } indent_down(); - f_enum << "]); };" << endl; + f_enum << "]); };" << '\n'; indent(f_enum) << "public static var VALUES_TO_NAMES = { ["; indent_up(); firstValue = true; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { - f_enum << (firstValue ? "" : ",") << endl; + f_enum << (firstValue ? "" : ",") << '\n'; indent(f_enum) << (*c_iter)->get_name() << " => \"" << (*c_iter)->get_name() << "\""; firstValue = false; } - f_enum << endl; + f_enum << '\n'; indent_down(); - indent(f_enum) << "]; };" << endl; + indent(f_enum) << "]; };" << '\n'; scope_down(f_enum); // end class @@ -486,15 +484,15 @@ void t_haxe_generator::generate_consts(std::vector consts) { f_consts.open(f_consts_name.c_str()); // Print header - f_consts << autogen_comment() << haxe_package() << ";" << endl << endl; + f_consts << autogen_comment() << haxe_package() << ";" << '\n' << '\n'; - f_consts << endl; + f_consts << '\n'; f_consts << haxe_type_imports(); generate_rtti_decoration(f_consts); generate_macro_decoration(f_consts); - indent(f_consts) << "class " << get_cap_name(program_name_) << "Constants {" << endl << endl; + indent(f_consts) << "class " << get_cap_name(program_name_) << "Constants {" << '\n' << '\n'; indent_up(); vector::iterator c_iter; for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { @@ -504,7 +502,7 @@ void t_haxe_generator::generate_consts(std::vector consts) { (*c_iter)->get_value()); } indent_down(); - indent(f_consts) << "}" << endl; + indent(f_consts) << "}" << '\n'; f_consts.close(); } @@ -527,7 +525,7 @@ void t_haxe_generator::print_const_value(std::ostream& out, } out << " : " << get_cap_name(type_name(type)) << " = "; render_const_value(out, type, value); - out << ";" << endl << endl; + out << ";" << '\n' << '\n'; } std::string t_haxe_generator::render_const_value_str( t_type* type, t_const_value* value) { @@ -594,9 +592,9 @@ void t_haxe_generator::render_const_value(std::ostream& out, void t_haxe_generator::render_struct_initializer(std::ostream& out, t_struct* type, t_const_value* value) { - out << "(function() : " << get_cap_name(type_name(type)) << " {" << endl; + out << "(function() : " << get_cap_name(type_name(type)) << " {" << '\n'; indent_up(); - indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << endl; + indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << '\n'; const vector& fields = ((t_struct*)type)->get_members(); vector::const_iterator f_iter; @@ -615,24 +613,24 @@ void t_haxe_generator::render_struct_initializer(std::ostream& out, } indent(out) << "tmp." << v_iter->first->get_string() << " = "; render_const_value(out, field_type, v_iter->second); - out << ";" << endl; + out << ";" << '\n'; } - indent(out) << "return tmp;" << endl; + indent(out) << "return tmp;" << '\n'; indent_down(); - indent(out) << "})()"; // no endl + indent(out) << "})()"; // no line break } void t_haxe_generator::render_map_initializer(std::ostream& out, t_map* type, t_const_value* value) { - out << "(function() : " << get_cap_name(type_name(type)) << " {" << endl; + out << "(function() : " << get_cap_name(type_name(type)) << " {" << '\n'; indent_up(); - indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << endl; + indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << '\n'; t_type* key_type = ((t_map*)type)->get_key_type(); t_type* val_type = ((t_map*)type)->get_val_type(); - + const map& values = value->get_map(); map::const_iterator v_iter; for (v_iter = values.begin(); v_iter != values.end(); ++v_iter) { @@ -640,56 +638,56 @@ void t_haxe_generator::render_map_initializer(std::ostream& out, render_const_value(out, key_type, v_iter->first); out << ", "; render_const_value(out, val_type, v_iter->second); - out << ");" << endl; + out << ");" << '\n'; } - - indent(out) << "return tmp;" << endl; + + indent(out) << "return tmp;" << '\n'; indent_down(); - indent(out) << "})()"; // no endl + indent(out) << "})()"; // no line break } void t_haxe_generator::render_list_initializer(std::ostream& out, t_list* type, t_const_value* value) { - out << "(function() : " << get_cap_name(type_name(type)) << " {" << endl; + out << "(function() : " << get_cap_name(type_name(type)) << " {" << '\n'; indent_up(); - indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << endl; + indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << '\n'; t_type* elm_type = type->get_elem_type(); - + const vector& values = value->get_list(); vector::const_iterator v_iter; for (v_iter = values.begin(); v_iter != values.end(); ++v_iter) { indent(out) << "tmp.add("; render_const_value(out, elm_type, *v_iter); - out << ");" << endl; + out << ");" << '\n'; } - - indent(out) << "return tmp;" << endl; + + indent(out) << "return tmp;" << '\n'; indent_down(); - indent(out) << "})()"; // no endl + indent(out) << "})()"; // no line break } void t_haxe_generator::render_set_initializer(std::ostream& out, t_set* type, t_const_value* value) { - out << "(function() : " << get_cap_name(type_name(type)) << " {" << endl; + out << "(function() : " << get_cap_name(type_name(type)) << " {" << '\n'; indent_up(); - indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << endl; + indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << '\n'; t_type* elm_type = type->get_elem_type(); - + const vector& values = value->get_list(); vector::const_iterator v_iter; for (v_iter = values.begin(); v_iter != values.end(); ++v_iter) { indent(out) << "tmp.add("; render_const_value(out, elm_type, *v_iter); - out << ");" << endl; + out << ");" << '\n'; } - - indent(out) << "return tmp;" << endl; + + indent(out) << "return tmp;" << '\n'; indent_down(); - indent(out) << "})()"; // no endl + indent(out) << "})()"; // no line break } @@ -723,14 +721,14 @@ void t_haxe_generator::generate_haxe_struct(t_struct* tstruct, bool is_exception ofstream_with_content_based_conditional_update f_struct; f_struct.open(f_struct_name.c_str()); - f_struct << autogen_comment() << haxe_package() << ";" << endl; + f_struct << autogen_comment() << haxe_package() << ";" << '\n'; - f_struct << endl; + f_struct << '\n'; string imports; f_struct << haxe_type_imports() << haxe_thrift_imports() - << haxe_thrift_gen_imports(tstruct, imports) << endl; + << haxe_thrift_gen_imports(tstruct, imports) << '\n'; generate_haxe_struct_definition(f_struct, tstruct, is_exception, is_result); @@ -762,11 +760,11 @@ void t_haxe_generator::generate_haxe_struct_definition(ostream& out, if (is_exception) { out << "extends TException "; } - out << "implements TBase {" << endl << endl; + out << "implements TBase {" << '\n' << '\n'; indent_up(); indent(out) << "static var STRUCT_DESC = { new TStruct(\"" << tstruct->get_name() << "\"); };" - << endl; + << '\n'; const vector& members = tstruct->get_members(); vector::const_iterator m_iter; @@ -775,69 +773,69 @@ void t_haxe_generator::generate_haxe_struct_definition(ostream& out, indent(out) << "static var " << constant_name((*m_iter)->get_name()) << "_FIELD_DESC = { new TField(\"" << (*m_iter)->get_name() << "\", " << type_to_enum((*m_iter)->get_type()) << ", " << (*m_iter)->get_key() << "); };" - << endl; + << '\n'; } - out << endl; + out << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { generate_haxe_doc(out, *m_iter); // indent(out) << "private var _" << (*m_iter)->get_name() + " : " + - // type_name((*m_iter)->get_type()) << ";" << endl; - indent(out) << "@:isVar" << endl; + // type_name((*m_iter)->get_type()) << ";" << '\n'; + indent(out) << "@:isVar" << '\n'; indent(out) << "public var " << (*m_iter)->get_name() + "(get,set) : " - + get_cap_name(type_name((*m_iter)->get_type())) << ";" << endl; + + get_cap_name(type_name((*m_iter)->get_type())) << ";" << '\n'; } - out << endl; + out << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { indent(out) << "inline static var " << upcase_string((*m_iter)->get_name()) - << "_FIELD_ID : Int = " << (*m_iter)->get_key() << ";" << endl; + << "_FIELD_ID : Int = " << (*m_iter)->get_key() << ";" << '\n'; } - out << endl; + out << '\n'; // Inner Isset class if (members.size() > 0) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if (!type_can_be_null((*m_iter)->get_type())) { indent(out) << "private var __isset_" << (*m_iter)->get_name() << " : Bool = false;" - << endl; + << '\n'; } } } - out << endl; + out << '\n'; // Static initializer to populate global class to struct metadata map if (false) { // TODO: reactivate when needed generate_haxe_meta_data_map(out, tstruct); - indent(out) << "{" << endl; + indent(out) << "{" << '\n'; indent_up(); indent(out) << "FieldMetaData.addStructMetaDataMap(" << type_name(tstruct) << ", metaDataMap);" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; + indent(out) << "}" << '\n'; } // Default constructor - indent(out) << "public function new() {" << endl; + indent(out) << "public function new() {" << '\n'; indent_up(); if (is_exception) { - indent(out) << "super();" << endl; + indent(out) << "super();" << '\n'; } for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_value() != nullptr) { indent(out) << "this." << (*m_iter)->get_name() << " = "; render_const_value( out, (*m_iter)->get_type(), (*m_iter)->get_value()); - out << ";" << endl; + out << ";" << '\n'; } } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; generate_property_getters_setters(out, tstruct); generate_generic_field_getters_setters(out, tstruct); @@ -852,7 +850,7 @@ void t_haxe_generator::generate_haxe_struct_definition(ostream& out, generate_haxe_struct_tostring(out, tstruct, is_exception); generate_haxe_validator(out, tstruct); scope_down(out); - out << endl; + out << '\n'; } /** @@ -861,123 +859,123 @@ void t_haxe_generator::generate_haxe_struct_definition(ostream& out, * @param tstruct The struct definition */ void t_haxe_generator::generate_haxe_struct_reader(ostream& out, t_struct* tstruct) { - out << indent() << "public function read( iprot : TProtocol) : Void {" << endl; + out << indent() << "public function read( iprot : TProtocol) : Void {" << '\n'; indent_up(); const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - indent(out) << "iprot.IncrementRecursionDepth();" << endl; - indent(out) << "try" << endl; + indent(out) << "iprot.IncrementRecursionDepth();" << '\n'; + indent(out) << "try" << '\n'; scope_up(out); // Declare stack tmp variables and read struct header - out << indent() << "var field : TField;" << endl << indent() << "iprot.readStructBegin();" - << endl; + out << indent() << "var field : TField;" << '\n' << indent() << "iprot.readStructBegin();" + << '\n'; // Loop over reading in fields - indent(out) << "while (true)" << endl; + indent(out) << "while (true)" << '\n'; scope_up(out); // Read beginning field marker - indent(out) << "field = iprot.readFieldBegin();" << endl; + indent(out) << "field = iprot.readFieldBegin();" << '\n'; // Check for field STOP marker and break - indent(out) << "if (field.type == TType.STOP) { " << endl; + indent(out) << "if (field.type == TType.STOP) { " << '\n'; indent_up(); - indent(out) << "break;" << endl; + indent(out) << "break;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; // Switch statement on the field we are reading - indent(out) << "switch (field.id)" << endl; + indent(out) << "switch (field.id)" << '\n'; scope_up(out); // Generate deserialization code for known cases for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - indent(out) << "case " << upcase_string((*f_iter)->get_name()) << "_FIELD_ID:" << endl; + indent(out) << "case " << upcase_string((*f_iter)->get_name()) << "_FIELD_ID:" << '\n'; indent_up(); - indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl; + indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n'; indent_up(); generate_deserialize_field(out, *f_iter, "this."); generate_isset_set(out, *f_iter); indent_down(); - out << indent() << "} else { " << endl << indent() << " TProtocolUtil.skip(iprot, field.type);" - << endl << indent() << "}" << endl; + out << indent() << "} else { " << '\n' << indent() << " TProtocolUtil.skip(iprot, field.type);" + << '\n' << indent() << "}" << '\n'; indent_down(); } // In the default case we skip the field - out << indent() << "default:" << endl << indent() << " TProtocolUtil.skip(iprot, field.type);" - << endl; + out << indent() << "default:" << '\n' << indent() << " TProtocolUtil.skip(iprot, field.type);" + << '\n'; scope_down(out); // Read field end marker - indent(out) << "iprot.readFieldEnd();" << endl; + indent(out) << "iprot.readFieldEnd();" << '\n'; scope_down(out); - out << indent() << "iprot.readStructEnd();" << endl << endl; + out << indent() << "iprot.readStructEnd();" << '\n' << '\n'; - indent(out) << "iprot.DecrementRecursionDepth();" << endl; + indent(out) << "iprot.DecrementRecursionDepth();" << '\n'; scope_down(out); - indent(out) << "catch(e:Dynamic)" << endl; + indent(out) << "catch(e:Dynamic)" << '\n'; scope_up(out); - indent(out) << "iprot.DecrementRecursionDepth();" << endl; - indent(out) << "throw e;" << endl; + indent(out) << "iprot.DecrementRecursionDepth();" << '\n'; + indent(out) << "throw e;" << '\n'; scope_down(out); // check for required fields of primitive type // (which can be checked here but not in the general validate method) - out << endl << indent() << "// check for required fields of primitive type, which can't be " - "checked in the validate method" << endl; + out << '\n' << indent() << "// check for required fields of primitive type, which can't be " + "checked in the validate method" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) { - out << indent() << "if (!__isset_" << (*f_iter)->get_name() << ") {" << endl << indent() + out << indent() << "if (!__isset_" << (*f_iter)->get_name() << ") {" << '\n' << indent() << " throw new TProtocolException(TProtocolException.UNKNOWN, \"Required field '" << (*f_iter)->get_name() - << "' was not found in serialized data! Struct: \" + toString());" << endl << indent() - << "}" << endl; + << "' was not found in serialized data! Struct: \" + toString());" << '\n' << indent() + << "}" << '\n'; } } // performs various checks (e.g. check that all required fields are set) - indent(out) << "validate();" << endl; + indent(out) << "validate();" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } // generates haxe method to perform various checks // (e.g. check that all required fields are set) void t_haxe_generator::generate_haxe_validator(ostream& out, t_struct* tstruct) { - indent(out) << "public function validate() : Void {" << endl; + indent(out) << "public function validate() : Void {" << '\n'; indent_up(); const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - out << indent() << "// check for required fields" << endl; + out << indent() << "// check for required fields" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { if (type_can_be_null((*f_iter)->get_type())) { - indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << endl; + indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << '\n'; indent(out) << " throw new TProtocolException(TProtocolException.UNKNOWN, \"Required field '" - << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl; - indent(out) << "}" << endl; + << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << '\n'; + indent(out) << "}" << '\n'; } else { indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name() - << "' because it's a primitive." << endl; + << "' because it's a primitive." << '\n'; } } } // check that fields of type enum have valid values - out << indent() << "// check that fields of type enum have valid values" << endl; + out << indent() << "// check that fields of type enum have valid values" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_field* field = (*f_iter); t_type* type = field->get_type(); @@ -985,18 +983,18 @@ void t_haxe_generator::generate_haxe_validator(ostream& out, t_struct* tstruct) if (type->is_enum()) { indent(out) << "if (" << generate_isset_check(field) << " && !" << get_cap_name(get_enum_class_name(type)) << ".VALID_VALUES.contains(" - << field->get_name() << ")){" << endl; + << field->get_name() << ")){" << '\n'; indent_up(); indent(out) << "throw new TProtocolException(TProtocolException.UNKNOWN, \"The field '" << field->get_name() << "' has been assigned the invalid value \" + " - << field->get_name() << ");" << endl; + << field->get_name() << ");" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -1005,7 +1003,7 @@ void t_haxe_generator::generate_haxe_validator(ostream& out, t_struct* tstruct) * @param tstruct The struct definition */ void t_haxe_generator::generate_haxe_struct_writer(ostream& out, t_struct* tstruct) { - out << indent() << "public function write(oprot:TProtocol) : Void {" << endl; + out << indent() << "public function write(oprot:TProtocol) : Void {" << '\n'; indent_up(); string name = tstruct->get_name(); @@ -1013,57 +1011,57 @@ void t_haxe_generator::generate_haxe_struct_writer(ostream& out, t_struct* tstru vector::const_iterator f_iter; // performs various checks (e.g. check that all required fields are set) - indent(out) << "validate();" << endl; - indent(out) << "oprot.IncrementRecursionDepth();" << endl; - indent(out) << "try" << endl; + indent(out) << "validate();" << '\n'; + indent(out) << "oprot.IncrementRecursionDepth();" << '\n'; + indent(out) << "try" << '\n'; scope_up(out); - indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl; + indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL; if (could_be_unset) { - indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl; + indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << '\n'; indent_up(); } bool null_allowed = type_can_be_null((*f_iter)->get_type()); if (null_allowed) { - out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl; + out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << '\n'; indent_up(); } indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) - << "_FIELD_DESC);" << endl; + << "_FIELD_DESC);" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "this."); // Write field closer - indent(out) << "oprot.writeFieldEnd();" << endl; + indent(out) << "oprot.writeFieldEnd();" << '\n'; if (null_allowed) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } if (could_be_unset) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } - indent(out) << "oprot.writeFieldStop();" << endl; - indent(out) << "oprot.writeStructEnd();" << endl; + indent(out) << "oprot.writeFieldStop();" << '\n'; + indent(out) << "oprot.writeStructEnd();" << '\n'; - indent(out) << "oprot.DecrementRecursionDepth();" << endl; + indent(out) << "oprot.DecrementRecursionDepth();" << '\n'; scope_down(out); - indent(out) << "catch(e:Dynamic)" << endl; + indent(out) << "catch(e:Dynamic)" << '\n'; scope_up(out); - indent(out) << "oprot.DecrementRecursionDepth();" << endl; - indent(out) << "throw e;" << endl; + indent(out) << "oprot.DecrementRecursionDepth();" << '\n'; + indent(out) << "throw e;" << '\n'; scope_down(out); indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } /** @@ -1075,59 +1073,59 @@ void t_haxe_generator::generate_haxe_struct_writer(ostream& out, t_struct* tstru * @param tstruct The struct definition */ void t_haxe_generator::generate_haxe_struct_result_writer(ostream& out, t_struct* tstruct) { - out << indent() << "public function write(oprot:TProtocol) : Void {" << endl; + out << indent() << "public function write(oprot:TProtocol) : Void {" << '\n'; indent_up(); string name = tstruct->get_name(); const vector& fields = tstruct->get_sorted_members(); vector::const_iterator f_iter; - indent(out) << "oprot.IncrementRecursionDepth();" << endl; - indent(out) << "try" << endl; + indent(out) << "oprot.IncrementRecursionDepth();" << '\n'; + indent(out) << "try" << '\n'; scope_up(out); - indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl; + indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << '\n'; bool first = true; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if (first) { first = false; - out << endl << indent() << "if "; + out << '\n' << indent() << "if "; } else { out << " else if "; } - out << "(this." << generate_isset_check(*f_iter) << ") {" << endl; + out << "(this." << generate_isset_check(*f_iter) << ") {" << '\n'; indent_up(); indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) - << "_FIELD_DESC);" << endl; + << "_FIELD_DESC);" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "this."); // Write field closer - indent(out) << "oprot.writeFieldEnd();" << endl; + indent(out) << "oprot.writeFieldEnd();" << '\n'; indent_down(); indent(out) << "}"; } - indent(out) << endl; - indent(out) << "oprot.writeFieldStop();" << endl; - indent(out) << "oprot.writeStructEnd();" << endl; + indent(out) << '\n'; + indent(out) << "oprot.writeFieldStop();" << '\n'; + indent(out) << "oprot.writeStructEnd();" << '\n'; - indent(out) << "oprot.DecrementRecursionDepth();" << endl; + indent(out) << "oprot.DecrementRecursionDepth();" << '\n'; scope_down(out); - indent(out) << "catch(e:Dynamic)" << endl; + indent(out) << "catch(e:Dynamic)" << '\n'; scope_up(out); - indent(out) << "oprot.DecrementRecursionDepth();" << endl; - indent(out) << "throw e;" << endl; + indent(out) << "oprot.DecrementRecursionDepth();" << '\n'; + indent(out) << "throw e;" << '\n'; scope_down(out); indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_haxe_generator::generate_reflection_getters(ostringstream& out, @@ -1136,9 +1134,9 @@ void t_haxe_generator::generate_reflection_getters(ostringstream& out, string cap_name) { (void)type; (void)cap_name; - indent(out) << "case " << upcase_string(field_name) << "_FIELD_ID:" << endl; + indent(out) << "case " << upcase_string(field_name) << "_FIELD_ID:" << '\n'; indent_up(); - indent(out) << "return this." << field_name << ";" << endl; + indent(out) << "return this." << field_name << ";" << '\n'; indent_down(); } @@ -1148,13 +1146,13 @@ void t_haxe_generator::generate_reflection_setters(ostringstream& out, string cap_name) { (void)type; (void)cap_name; - indent(out) << "case " << upcase_string(field_name) << "_FIELD_ID:" << endl; + indent(out) << "case " << upcase_string(field_name) << "_FIELD_ID:" << '\n'; indent_up(); - indent(out) << "if (value == null) {" << endl; - indent(out) << " unset" << get_cap_name(field_name) << "();" << endl; - indent(out) << "} else {" << endl; - indent(out) << " this." << field_name << " = value;" << endl; - indent(out) << "}" << endl << endl; + indent(out) << "if (value == null) {" << '\n'; + indent(out) << " unset" << get_cap_name(field_name) << "();" << '\n'; + indent(out) << "} else {" << '\n'; + indent(out) << " this." << field_name << " = value;" << '\n'; + indent(out) << "}" << '\n' << '\n'; indent_down(); } @@ -1181,39 +1179,39 @@ void t_haxe_generator::generate_generic_field_getters_setters(std::ostream& out, } // create the setter - indent(out) << "public function setFieldValue(fieldID : Int, value : Dynamic) : Void {" << endl; + indent(out) << "public function setFieldValue(fieldID : Int, value : Dynamic) : Void {" << '\n'; indent_up(); if (fields.size() > 0) { - indent(out) << "switch (fieldID) {" << endl; + indent(out) << "switch (fieldID) {" << '\n'; out << setter_stream.str(); - indent(out) << "default:" << endl; - indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl; - indent(out) << "}" << endl; + indent(out) << "default:" << '\n'; + indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n'; + indent(out) << "}" << '\n'; } else { - indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl; + indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // create the getter - indent(out) << "public function getFieldValue(fieldID : Int) : Dynamic {" << endl; + indent(out) << "public function getFieldValue(fieldID : Int) : Dynamic {" << '\n'; indent_up(); if (fields.size() > 0) { - indent(out) << "switch (fieldID) {" << endl; + indent(out) << "switch (fieldID) {" << '\n'; out << getter_stream.str(); - indent(out) << "default:" << endl; - indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl; - indent(out) << "}" << endl; + indent(out) << "default:" << '\n'; + indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n'; + indent(out) << "}" << '\n'; } else { - indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl; + indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } // Creates a generic isSet method that takes the field number as argument @@ -1223,29 +1221,29 @@ void t_haxe_generator::generate_generic_isset_method(std::ostream& out, t_struct // create the isSet method indent(out) << "// Returns true if field corresponding to fieldID is set (has been assigned a " - "value) and false otherwise" << endl; - indent(out) << "public function isSet(fieldID : Int) : Bool {" << endl; + "value) and false otherwise" << '\n'; + indent(out) << "public function isSet(fieldID : Int) : Bool {" << '\n'; indent_up(); if (fields.size() > 0) { - indent(out) << "switch (fieldID) {" << endl; + indent(out) << "switch (fieldID) {" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_field* field = *f_iter; - indent(out) << "case " << upcase_string(field->get_name()) << "_FIELD_ID:" << endl; + indent(out) << "case " << upcase_string(field->get_name()) << "_FIELD_ID:" << '\n'; indent_up(); - indent(out) << "return " << generate_isset_check(field) << ";" << endl; + indent(out) << "return " << generate_isset_check(field) << ";" << '\n'; indent_down(); } - indent(out) << "default:" << endl; - indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl; - indent(out) << "}" << endl; + indent(out) << "default:" << '\n'; + indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n'; + indent(out) << "}" << '\n'; } else { - indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl; + indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -1265,48 +1263,48 @@ void t_haxe_generator::generate_property_getters_setters(ostream& out, t_struct* // Simple getter generate_haxe_doc(out, field); indent(out) << "public function get_" << field_name << "() : " << get_cap_name(type_name(type)) - << " {" << endl; + << " {" << '\n'; indent_up(); - indent(out) << "return this." << field_name << ";" << endl; + indent(out) << "return this." << field_name << ";" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // Simple setter generate_haxe_doc(out, field); indent(out) << "public function set_" << field_name << "(" << field_name << ":" << get_cap_name(type_name(type)) << ") : " << get_cap_name(type_name(type)) << " {" - << endl; + << '\n'; indent_up(); - indent(out) << "this." << field_name << " = " << field_name << ";" << endl; + indent(out) << "this." << field_name << " = " << field_name << ";" << '\n'; generate_isset_set(out, field); - indent(out) << "return this." << field_name << ";" << endl; + indent(out) << "return this." << field_name << ";" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // Unsetter - indent(out) << "public function unset" << cap_name << "() : Void {" << endl; + indent(out) << "public function unset" << cap_name << "() : Void {" << '\n'; indent_up(); if (type_can_be_null(type)) { - indent(out) << "this." << field_name << " = null;" << endl; + indent(out) << "this." << field_name << " = null;" << '\n'; } else { - indent(out) << "this.__isset_" << field_name << " = false;" << endl; + indent(out) << "this.__isset_" << field_name << " = false;" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // isSet method indent(out) << "// Returns true if field " << field_name - << " is set (has been assigned a value) and false otherwise" << endl; - indent(out) << "public function is" << get_cap_name("set") << cap_name << "() : Bool {" << endl; + << " is set (has been assigned a value) and false otherwise" << '\n'; + indent(out) << "public function is" << get_cap_name("set") << cap_name << "() : Bool {" << '\n'; indent_up(); if (type_can_be_null(type)) { - indent(out) << "return this." << field_name << " != null;" << endl; + indent(out) << "return this." << field_name << " != null;" << '\n'; } else { - indent(out) << "return this.__isset_" << field_name << ";" << endl; + indent(out) << "return this.__isset_" << field_name << ";" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } } @@ -1320,11 +1318,11 @@ void t_haxe_generator::generate_haxe_struct_tostring(ostream& out, t_struct* tst if( is_override) { out << "override "; } - out << "function toString() : String {" << endl; + out << "function toString() : String {" << '\n'; indent_up(); - out << indent() << "var ret : String = \"" << tstruct->get_name() << "(\";" << endl; - out << indent() << "var first : Bool = true;" << endl << endl; + out << indent() << "var ret : String = \"" << tstruct->get_name() << "(\";" << '\n'; + out << indent() << "var first : Bool = true;" << '\n' << '\n'; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -1332,58 +1330,58 @@ void t_haxe_generator::generate_haxe_struct_tostring(ostream& out, t_struct* tst for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL; if (could_be_unset) { - indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl; + indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << '\n'; indent_up(); } t_field* field = (*f_iter); if (!first) { - indent(out) << "if (!first) ret += \", \";" << endl; + indent(out) << "if (!first) ret += \", \";" << '\n'; } - indent(out) << "ret += \"" << (*f_iter)->get_name() << ":\";" << endl; + indent(out) << "ret += \"" << (*f_iter)->get_name() << ":\";" << '\n'; bool can_be_null = type_can_be_null(field->get_type()); if (can_be_null) { - indent(out) << "if (this." << (*f_iter)->get_name() << " == null) {" << endl; - indent(out) << " ret += \"null\";" << endl; - indent(out) << "} else {" << endl; + indent(out) << "if (this." << (*f_iter)->get_name() << " == null) {" << '\n'; + indent(out) << " ret += \"null\";" << '\n'; + indent(out) << "} else {" << '\n'; indent_up(); } if (field->get_type()->is_binary()) { - indent(out) << " ret += \"BINARY\";" << endl; + indent(out) << " ret += \"BINARY\";" << '\n'; } else if (field->get_type()->is_enum()) { indent(out) << "var " << field->get_name() << "_name : String = " << get_cap_name(get_enum_class_name(field->get_type())) - << ".VALUES_TO_NAMES[this." << (*f_iter)->get_name() << "];" << endl; - indent(out) << "if (" << field->get_name() << "_name != null) {" << endl; - indent(out) << " ret += " << field->get_name() << "_name;" << endl; - indent(out) << " ret += \" (\";" << endl; - indent(out) << "}" << endl; - indent(out) << "ret += this." << field->get_name() << ";" << endl; - indent(out) << "if (" << field->get_name() << "_name != null) {" << endl; - indent(out) << " ret += \")\";" << endl; - indent(out) << "}" << endl; + << ".VALUES_TO_NAMES[this." << (*f_iter)->get_name() << "];" << '\n'; + indent(out) << "if (" << field->get_name() << "_name != null) {" << '\n'; + indent(out) << " ret += " << field->get_name() << "_name;" << '\n'; + indent(out) << " ret += \" (\";" << '\n'; + indent(out) << "}" << '\n'; + indent(out) << "ret += this." << field->get_name() << ";" << '\n'; + indent(out) << "if (" << field->get_name() << "_name != null) {" << '\n'; + indent(out) << " ret += \")\";" << '\n'; + indent(out) << "}" << '\n'; } else { - indent(out) << "ret += this." << (*f_iter)->get_name() << ";" << endl; + indent(out) << "ret += this." << (*f_iter)->get_name() << ";" << '\n'; } if (can_be_null) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - indent(out) << "first = false;" << endl; + indent(out) << "first = false;" << '\n'; if (could_be_unset) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } first = false; } - out << indent() << "ret += \")\";" << endl << indent() << "return ret;" << endl; + out << indent() << "ret += \")\";" << '\n' << indent() << "return ret;" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -1397,7 +1395,7 @@ void t_haxe_generator::generate_haxe_meta_data_map(ostream& out, t_struct* tstru vector::const_iterator f_iter; // Static Map with fieldID -> FieldMetaData mappings - indent(out) << "inline static var metaDataMap : IntMap = new IntMap();" << endl; + indent(out) << "inline static var metaDataMap : IntMap = new IntMap();" << '\n'; if (fields.size() > 0) { // Populate map @@ -1419,7 +1417,7 @@ void t_haxe_generator::generate_haxe_meta_data_map(ostream& out, t_struct* tstru // Create value meta data generate_field_value_meta_data(out, field->get_type()); - out << ");" << endl; + out << ");" << '\n'; } scope_down(out); } @@ -1484,7 +1482,7 @@ std::string t_haxe_generator::get_haxe_type_string(t_type* type) { } void t_haxe_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) { - out << endl; + out << '\n'; indent_up(); indent_up(); if (type->is_struct()) { @@ -1527,20 +1525,20 @@ void t_haxe_generator::generate_service(t_service* tservice) { string f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + "_service.hx"; f_service_.open(f_service_name.c_str()); - f_service_ << autogen_comment() << haxe_package() << ";" << endl; + f_service_ << autogen_comment() << haxe_package() << ";" << '\n'; - f_service_ << endl << haxe_type_imports() << haxe_thrift_imports() + f_service_ << '\n' << haxe_type_imports() << haxe_thrift_imports() << haxe_thrift_gen_imports(tservice); if (tservice->get_extends() != nullptr) { t_type* parent = tservice->get_extends(); string parent_namespace = make_package_name( parent->get_program()->get_namespace("haxe")); if (!parent_namespace.empty() && parent_namespace != package_name_) { - f_service_ << "import " << get_cap_name(type_name(parent)) << "_service;" << endl; + f_service_ << "import " << get_cap_name(type_name(parent)) << "_service;" << '\n'; } } - f_service_ << endl; + f_service_ << '\n'; generate_service_interface(tservice,false); f_service_.close(); @@ -1549,20 +1547,20 @@ void t_haxe_generator::generate_service(t_service* tservice) { f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + ".hx"; f_service_.open(f_service_name.c_str()); - f_service_ << autogen_comment() << haxe_package() << ";" << endl; + f_service_ << autogen_comment() << haxe_package() << ";" << '\n'; - f_service_ << endl << haxe_type_imports() << haxe_thrift_imports() + f_service_ << '\n' << haxe_type_imports() << haxe_thrift_imports() << haxe_thrift_gen_imports(tservice); if (tservice->get_extends() != nullptr) { t_type* parent = tservice->get_extends(); string parent_namespace = make_package_name( parent->get_program()->get_namespace("haxe")); if (!parent_namespace.empty() && parent_namespace != package_name_) { - f_service_ << "import " << get_cap_name(type_name(parent)) << ";" << endl; + f_service_ << "import " << get_cap_name(type_name(parent)) << ";" << '\n'; } } - f_service_ << endl; + f_service_ << '\n'; generate_service_interface(tservice,true); f_service_.close(); @@ -1571,18 +1569,18 @@ void t_haxe_generator::generate_service(t_service* tservice) { f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + "Impl.hx"; f_service_.open(f_service_name.c_str()); - f_service_ << autogen_comment() << haxe_package() << ";" << endl << endl << haxe_type_imports() - << haxe_thrift_imports() << haxe_thrift_gen_imports(tservice) << endl; + f_service_ << autogen_comment() << haxe_package() << ";" << '\n' << '\n' << haxe_type_imports() + << haxe_thrift_imports() << haxe_thrift_gen_imports(tservice) << '\n'; if (tservice->get_extends() != nullptr) { t_type* parent = tservice->get_extends(); string parent_namespace = make_package_name( parent->get_program()->get_namespace("haxe")); if (!parent_namespace.empty() && parent_namespace != package_name_) { - f_service_ << "import " << get_cap_name(type_name(parent)) << "Impl;" << endl; + f_service_ << "import " << get_cap_name(type_name(parent)) << "Impl;" << '\n'; } } - f_service_ << endl; + f_service_ << '\n'; generate_service_client(tservice); f_service_.close(); @@ -1594,17 +1592,17 @@ void t_haxe_generator::generate_service(t_service* tservice) { f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + "Processor.hx"; f_service_.open(f_service_name.c_str()); - f_service_ << autogen_comment() << haxe_package() << ";" << endl - << endl + f_service_ << autogen_comment() << haxe_package() << ";" << '\n' + << '\n' << haxe_type_imports() - << haxe_thrift_imports() - << haxe_thrift_gen_imports(tservice) - << endl; + << haxe_thrift_imports() + << haxe_thrift_gen_imports(tservice) + << '\n'; if (!package_name_.empty()) { - f_service_ << "import " << package_name_ << ".*;" << endl; - f_service_ << "import " << package_name_ << "." << get_cap_name(service_name_).c_str() << "Impl;" << endl; - f_service_ << endl; + f_service_ << "import " << package_name_ << ".*;" << '\n'; + f_service_ << "import " << package_name_ << "." << get_cap_name(service_name_).c_str() << "Impl;" << '\n'; + f_service_ << '\n'; } generate_service_server(tservice); @@ -1668,9 +1666,9 @@ void t_haxe_generator::generate_service_method_signature_normal(t_function* tfun bool is_interface) { if (is_interface) { generate_deprecation_attribute(f_service_, tfunction, true); - indent(f_service_) << function_signature_normal(tfunction) << ";" << endl << endl; + indent(f_service_) << function_signature_normal(tfunction) << ";" << '\n' << '\n'; } else { - indent(f_service_) << "public " << function_signature_normal(tfunction) << " {" << endl; + indent(f_service_) << "public " << function_signature_normal(tfunction) << " {" << '\n'; } } @@ -1683,15 +1681,15 @@ void t_haxe_generator::generate_service_method_signature_combined(t_function* tf bool is_interface) { if (!tfunction->is_oneway()) { std::string on_success_impl = generate_service_method_onsuccess(tfunction, false, false); - indent(f_service_) << "// function onError(Dynamic) : Void;" << endl; - indent(f_service_) << "// function " << on_success_impl.c_str() << ";" << endl; + indent(f_service_) << "// function onError(Dynamic) : Void;" << '\n'; + indent(f_service_) << "// function " << on_success_impl.c_str() << ";" << '\n'; } if (is_interface) { generate_deprecation_attribute(f_service_, tfunction, false); - indent(f_service_) << function_signature_combined(tfunction) << ";" << endl << endl; + indent(f_service_) << function_signature_combined(tfunction) << ";" << '\n' << '\n'; } else { - indent(f_service_) << "public " << function_signature_combined(tfunction) << " {" << endl; + indent(f_service_) << "public " << function_signature_combined(tfunction) << " {" << '\n'; } } @@ -1738,7 +1736,7 @@ void t_haxe_generator::generate_deprecation_attribute(ostream& out, t_function* } } - out << endl; + out << '\n'; } } @@ -1762,14 +1760,14 @@ void t_haxe_generator::generate_service_interface(t_service* tservice, bool comb generate_rtti_decoration(f_service_); generate_macro_decoration(f_service_); f_service_ << indent() << "interface " << get_cap_name(service_name_) << cbk_postfix << extends_iface << " {" - << endl << endl; + << '\n' << '\n'; indent_up(); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_haxe_doc(f_service_, *f_iter); generate_service_method_signature(*f_iter, true, combined); } indent_down(); - f_service_ << indent() << "}" << endl << endl; + f_service_ << indent() << "}" << '\n' << '\n'; } /** @@ -1778,7 +1776,7 @@ void t_haxe_generator::generate_service_interface(t_service* tservice, bool comb * @param tservice The service */ void t_haxe_generator::generate_service_helpers(t_service* tservice) { - f_service_ << endl << endl; + f_service_ << '\n' << '\n'; vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -1804,44 +1802,44 @@ void t_haxe_generator::generate_service_client(t_service* tservice) { generate_rtti_decoration(f_service_); // build macro is inherited from interface indent(f_service_) << "class " << get_cap_name(service_name_) << "Impl" << extends_client - << " implements " << get_cap_name(service_name_) << " {" << endl << endl; + << " implements " << get_cap_name(service_name_) << " {" << '\n' << '\n'; indent_up(); - indent(f_service_) << "public function new( iprot : TProtocol, oprot : TProtocol = null)" << endl; + indent(f_service_) << "public function new( iprot : TProtocol, oprot : TProtocol = null)" << '\n'; scope_up(f_service_); if (extends.empty()) { - f_service_ << indent() << "iprot_ = iprot;" << endl; - f_service_ << indent() << "if (oprot == null) {" << endl; + f_service_ << indent() << "iprot_ = iprot;" << '\n'; + f_service_ << indent() << "if (oprot == null) {" << '\n'; indent_up(); - f_service_ << indent() << "oprot_ = iprot;" << endl; + f_service_ << indent() << "oprot_ = iprot;" << '\n'; indent_down(); - f_service_ << indent() << "} else {" << endl; + f_service_ << indent() << "} else {" << '\n'; indent_up(); - f_service_ << indent() << "oprot_ = oprot;" << endl; + f_service_ << indent() << "oprot_ = oprot;" << '\n'; indent_down(); - f_service_ << indent() << "}" << endl; + f_service_ << indent() << "}" << '\n'; } else { - f_service_ << indent() << "super(iprot, oprot);" << endl; + f_service_ << indent() << "super(iprot, oprot);" << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; if (extends.empty()) { - f_service_ << indent() << "private var iprot_ : TProtocol;" << endl << indent() - << "private var oprot_ : TProtocol;" << endl << indent() - << "private var seqid_ : Int;" << endl << endl; + f_service_ << indent() << "private var iprot_ : TProtocol;" << '\n' << indent() + << "private var oprot_ : TProtocol;" << '\n' << indent() + << "private var seqid_ : Int;" << '\n' << '\n'; - indent(f_service_) << "public function getInputProtocol() : TProtocol" << endl; + indent(f_service_) << "public function getInputProtocol() : TProtocol" << '\n'; scope_up(f_service_); - indent(f_service_) << "return this.iprot_;" << endl; + indent(f_service_) << "return this.iprot_;" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; - indent(f_service_) << "public function getOutputProtocol() : TProtocol" << endl; + indent(f_service_) << "public function getOutputProtocol() : TProtocol" << '\n'; scope_up(f_service_); - indent(f_service_) << "return this.oprot_;" << endl; + indent(f_service_) << "return this.oprot_;" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } // Generate client method implementations @@ -1866,140 +1864,140 @@ void t_haxe_generator::generate_service_client(t_service* tservice) { string args = tmp("args"); string calltype = (*f_iter)->is_oneway() ? "ONEWAY" : "CALL"; f_service_ << indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname - << "\", TMessageType." << calltype << ", seqid_));" << endl << indent() - << "var " << args << " : " << argsname << " = new " << argsname << "();" << endl; + << "\", TMessageType." << calltype << ", seqid_));" << '\n' << indent() + << "var " << args << " : " << argsname << " = new " << argsname << "();" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_service_ << indent() << args << "." << (*fld_iter)->get_name() << " = " - << (*fld_iter)->get_name() << ";" << endl; + << (*fld_iter)->get_name() << ";" << '\n'; } - f_service_ << indent() << args << ".write(oprot_);" << endl << indent() - << "oprot_.writeMessageEnd();" << endl; + f_service_ << indent() << args << ".write(oprot_);" << '\n' << indent() + << "oprot_.writeMessageEnd();" << '\n'; string retval = tmp("retval"); if (!((*f_iter)->is_oneway() || (*f_iter)->get_returntype()->is_void())) { f_service_ << indent() << "var " << retval << " : " << type_name((*f_iter)->get_returntype()) - << " = " << render_default_value_for_type((*f_iter)->get_returntype(),true) - << ";" << endl; + << " = " << render_default_value_for_type((*f_iter)->get_returntype(),true) + << ";" << '\n'; } if ((*f_iter)->is_oneway()) { - f_service_ << indent() << "oprot_.getTransport().flush();" << endl; + f_service_ << indent() << "oprot_.getTransport().flush();" << '\n'; } else { - indent(f_service_) << "oprot_.getTransport().flush(function(error:Dynamic) : Void {" << endl; + indent(f_service_) << "oprot_.getTransport().flush(function(error:Dynamic) : Void {" << '\n'; indent_up(); - indent(f_service_) << "try {" << endl; + indent(f_service_) << "try {" << '\n'; indent_up(); string appex = tmp("appex"); - indent(f_service_) << "var " << appex << " : TApplicationException;" << endl; + indent(f_service_) << "var " << appex << " : TApplicationException;" << '\n'; string resultname = get_cap_name((*f_iter)->get_name() + "_result"); - indent(f_service_) << "if (error != null) {" << endl; + indent(f_service_) << "if (error != null) {" << '\n'; indent_up(); - indent(f_service_) << "if (onError == null)" << endl; + indent(f_service_) << "if (onError == null)" << '\n'; indent_up(); - indent(f_service_) << "throw error;" << endl; + indent(f_service_) << "throw error;" << '\n'; indent_down(); - indent(f_service_) << "onError(error);" << endl; - indent(f_service_) << "return;" << endl; + indent(f_service_) << "onError(error);" << '\n'; + indent(f_service_) << "return;" << '\n'; indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; string msg = tmp("msg"); - indent(f_service_) << "var " << msg << " : TMessage = iprot_.readMessageBegin();" << endl; - indent(f_service_) << "if (" << msg << ".type == TMessageType.EXCEPTION) {" << endl; + indent(f_service_) << "var " << msg << " : TMessage = iprot_.readMessageBegin();" << '\n'; + indent(f_service_) << "if (" << msg << ".type == TMessageType.EXCEPTION) {" << '\n'; indent_up(); - indent(f_service_) << appex << " = TApplicationException.read(iprot_);" << endl; - indent(f_service_) << "iprot_.readMessageEnd();" << endl; - indent(f_service_) << "if (onError == null)" << endl; + indent(f_service_) << appex << " = TApplicationException.read(iprot_);" << '\n'; + indent(f_service_) << "iprot_.readMessageEnd();" << '\n'; + indent(f_service_) << "if (onError == null)" << '\n'; indent_up(); - indent(f_service_) << "throw " << appex << ";" << endl; + indent(f_service_) << "throw " << appex << ";" << '\n'; indent_down(); - indent(f_service_) << "onError(" << appex << ");" << endl; - indent(f_service_) << "return;" << endl; + indent(f_service_) << "onError(" << appex << ");" << '\n'; + indent(f_service_) << "return;" << '\n'; indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; string result = tmp("result"); - indent(f_service_) << "var " << result << " : " << resultname << " = new " << resultname << "();" << endl; - indent(f_service_) << "" << result << ".read(iprot_);" << endl; - indent(f_service_) << "iprot_.readMessageEnd();" << endl; + indent(f_service_) << "var " << result << " : " << resultname << " = new " << resultname << "();" << '\n'; + indent(f_service_) << "" << result << ".read(iprot_);" << '\n'; + indent(f_service_) << "iprot_.readMessageEnd();" << '\n'; // Careful, only return _result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { - indent(f_service_) << "if (" << result << "." << generate_isset_check("success") << ") {" << endl; + indent(f_service_) << "if (" << result << "." << generate_isset_check("success") << ") {" << '\n'; indent_up(); - indent(f_service_) << "if (onSuccess != null)" << endl; + indent(f_service_) << "if (onSuccess != null)" << '\n'; indent_up(); - indent(f_service_) << "onSuccess(" << result << ".success);" << endl; + indent(f_service_) << "onSuccess(" << result << ".success);" << '\n'; indent_down(); - indent(f_service_) << retval << " = " << result << ".success;" << endl; - indent(f_service_) << "return;" << endl; + indent(f_service_) << retval << " = " << result << ".success;" << '\n'; + indent(f_service_) << "return;" << '\n'; indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; } t_struct* xs = (*f_iter)->get_xceptions(); const std::vector& xceptions = xs->get_members(); vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { - indent(f_service_) << "if (" << result << "." << (*x_iter)->get_name() << " != null) {" << endl; + indent(f_service_) << "if (" << result << "." << (*x_iter)->get_name() << " != null) {" << '\n'; indent_up(); - indent(f_service_) << "if (onError == null)" << endl; + indent(f_service_) << "if (onError == null)" << '\n'; indent_up(); - indent(f_service_) << "throw " << result << "." << (*x_iter)->get_name() << ";" << endl; + indent(f_service_) << "throw " << result << "." << (*x_iter)->get_name() << ";" << '\n'; indent_down(); - indent(f_service_) << "onError(" << result << "." << (*x_iter)->get_name() << ");" << endl; - indent(f_service_) << "return;" << endl; + indent(f_service_) << "onError(" << result << "." << (*x_iter)->get_name() << ");" << '\n'; + indent(f_service_) << "return;" << '\n'; indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; } // If you get here it's an exception, unless a void function if ((*f_iter)->get_returntype()->is_void()) { - indent(f_service_) << "if (onSuccess != null)" << endl; + indent(f_service_) << "if (onSuccess != null)" << '\n'; indent_up(); - indent(f_service_) << "onSuccess();" << endl; + indent(f_service_) << "onSuccess();" << '\n'; indent_down(); - indent(f_service_) << "return;" << endl; + indent(f_service_) << "return;" << '\n'; } else { indent(f_service_) << appex << " = new TApplicationException(" << "TApplicationException.MISSING_RESULT," - << "\"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl; - indent(f_service_) << "if (onError == null)" << endl; + << "\"" << (*f_iter)->get_name() << " failed: unknown result\");" << '\n'; + indent(f_service_) << "if (onError == null)" << '\n'; indent_up(); - indent(f_service_) << "throw " << appex << ";" << endl; + indent(f_service_) << "throw " << appex << ";" << '\n'; indent_down(); - indent(f_service_) << "onError(" << appex << ");" << endl; - indent(f_service_) << "return;" << endl; + indent(f_service_) << "onError(" << appex << ");" << '\n'; + indent(f_service_) << "return;" << '\n'; } indent_down(); - indent(f_service_) << endl; - indent(f_service_) << "} catch( e : TException) {" << endl; + indent(f_service_) << '\n'; + indent(f_service_) << "} catch( e : TException) {" << '\n'; indent_up(); - indent(f_service_) << "if (onError == null)" << endl; + indent(f_service_) << "if (onError == null)" << '\n'; indent_up(); - indent(f_service_) << "throw e;" << endl; + indent(f_service_) << "throw e;" << '\n'; indent_down(); - indent(f_service_) << "onError(e);" << endl; - indent(f_service_) << "return;" << endl; + indent(f_service_) << "onError(e);" << '\n'; + indent(f_service_) << "return;" << '\n'; indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; indent_down(); - indent(f_service_) << "});" << endl << endl; + indent(f_service_) << "});" << '\n' << '\n'; } if (!((*f_iter)->is_oneway() || (*f_iter)->get_returntype()->is_void())) { - f_service_ << indent() << "return " << retval << ";" << endl; + f_service_ << indent() << "return " << retval << ";" << '\n'; } // Close function scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } /** @@ -2024,35 +2022,35 @@ void t_haxe_generator::generate_service_server(t_service* tservice) { generate_rtti_decoration(f_service_); generate_macro_decoration(f_service_); indent(f_service_) << "class " << get_cap_name(service_name_) << "Processor" << extends_processor - << " implements TProcessor {" << endl << endl; + << " implements TProcessor {" << '\n' << '\n'; indent_up(); f_service_ << indent() << "private var " << get_cap_name(service_name_) - << "_iface_ : " << get_cap_name(service_name_) << "_service;" << endl; + << "_iface_ : " << get_cap_name(service_name_) << "_service;" << '\n'; if (extends.empty()) { f_service_ << indent() << "private var PROCESS_MAP = new StringMap< Int->TProtocol->TProtocol->Void >();" - << endl; + << '\n'; } - f_service_ << endl; + f_service_ << '\n'; indent(f_service_) << "public function new( iface : " << get_cap_name(service_name_) << "_service)" - << endl; + << '\n'; scope_up(f_service_); if (!extends.empty()) { - f_service_ << indent() << "super(iface);" << endl; + f_service_ << indent() << "super(iface);" << '\n'; } - f_service_ << indent() << get_cap_name(service_name_) << "_iface_ = iface;" << endl; + f_service_ << indent() << get_cap_name(service_name_) << "_iface_ = iface;" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { f_service_ << indent() << "PROCESS_MAP.set(\"" << (*f_iter)->get_name() << "\", " - << (*f_iter)->get_name() << "());" << endl; + << (*f_iter)->get_name() << "());" << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate the server implementation string override = ""; @@ -2061,31 +2059,31 @@ void t_haxe_generator::generate_service_server(t_service* tservice) { } indent(f_service_) << override << "public function process( iprot : TProtocol, oprot : TProtocol) : Bool" - << endl; + << '\n'; scope_up(f_service_); - f_service_ << indent() << "var msg : TMessage = iprot.readMessageBegin();" << endl; + f_service_ << indent() << "var msg : TMessage = iprot.readMessageBegin();" << '\n'; // TODO(mcslee): validate message, was the seqid etc. legit? f_service_ - << indent() << "var fn = PROCESS_MAP.get(msg.name);" << endl - << indent() << "if (fn == null) {" << endl - << indent() << " TProtocolUtil.skip(iprot, TType.STRUCT);" << endl - << indent() << " iprot.readMessageEnd();" << endl + << indent() << "var fn = PROCESS_MAP.get(msg.name);" << '\n' + << indent() << "if (fn == null) {" << '\n' + << indent() << " TProtocolUtil.skip(iprot, TType.STRUCT);" << '\n' + << indent() << " iprot.readMessageEnd();" << '\n' << indent() << " var appex = new TApplicationException(TApplicationException.UNKNOWN_METHOD, " - << "\"Invalid method name: '\"+msg.name+\"'\");" << endl - << indent() << " oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << endl - << indent() << " appex.write(oprot);" << endl << indent() << " oprot.writeMessageEnd();" << endl - << indent() << " oprot.getTransport().flush();" << endl - << indent() << " return true;" << endl << indent() << "}" << endl - << indent() << "fn( msg.seqid, iprot, oprot);" << endl + << "\"Invalid method name: '\"+msg.name+\"'\");" << '\n' + << indent() << " oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << '\n' + << indent() << " appex.write(oprot);" << '\n' << indent() << " oprot.writeMessageEnd();" << '\n' + << indent() << " oprot.getTransport().flush();" << '\n' + << indent() << " return true;" << '\n' << indent() << "}" << '\n' + << indent() << "fn( msg.seqid, iprot, oprot);" << '\n' ; - f_service_ << indent() << "return true;" << endl; + f_service_ << indent() << "return true;" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate the process subfunctions for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -2093,7 +2091,7 @@ void t_haxe_generator::generate_service_server(t_service* tservice) { } indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; } /** @@ -2132,20 +2130,20 @@ void t_haxe_generator::generate_process_function(t_service* tservice, t_function (void)tservice; // Open class indent(f_service_) << "private function " << tfunction->get_name() - << "() : Int->TProtocol->TProtocol->Void {" << endl; + << "() : Int->TProtocol->TProtocol->Void {" << '\n'; indent_up(); // Open function indent(f_service_) << "return function( seqid : Int, iprot : TProtocol, oprot : TProtocol) : Void" - << endl; + << '\n'; scope_up(f_service_); string argsname = get_cap_name(tfunction->get_name() + "_args"); string resultname = get_cap_name(tfunction->get_name() + "_result"); - f_service_ << indent() << "var args : " << argsname << " = new " << argsname << "();" << endl - << indent() << "args.read(iprot);" << endl << indent() << "iprot.readMessageEnd();" - << endl; + f_service_ << indent() << "var args : " << argsname << " = new " << argsname << "();" << '\n' + << indent() << "args.read(iprot);" << '\n' << indent() << "iprot.readMessageEnd();" + << '\n'; t_struct* xs = tfunction->get_xceptions(); const std::vector& xceptions = xs->get_members(); @@ -2153,11 +2151,11 @@ void t_haxe_generator::generate_process_function(t_service* tservice, t_function // Declare result for non oneway function if (!tfunction->is_oneway()) { - f_service_ << indent() << "var result : " << resultname << " = new " << resultname << "();" << endl; + f_service_ << indent() << "var result : " << resultname << " = new " << resultname << "();" << '\n'; } // Try block for any function to catch (defined or undefined) exceptions - f_service_ << indent() << "try {" << endl; + f_service_ << indent() << "try {" << '\n'; indent_up(); @@ -2182,7 +2180,7 @@ void t_haxe_generator::generate_process_function(t_service* tservice, t_function } f_service_ << "args." << (*f_iter)->get_name(); } - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; indent_down(); f_service_ << indent() << "}"; @@ -2190,11 +2188,11 @@ void t_haxe_generator::generate_process_function(t_service* tservice, t_function // catch exceptions defined in the IDL for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << " catch (" << (*x_iter)->get_name() << ":" - << get_cap_name(type_name((*x_iter)->get_type(), false, false)) << ") {" << endl; + << get_cap_name(type_name((*x_iter)->get_type(), false, false)) << ") {" << '\n'; if (!tfunction->is_oneway()) { indent_up(); f_service_ << indent() << "result." << (*x_iter)->get_name() << " = " - << (*x_iter)->get_name() << ";" << endl; + << (*x_iter)->get_name() << ";" << '\n'; indent_down(); f_service_ << indent() << "}"; } else { @@ -2205,45 +2203,45 @@ void t_haxe_generator::generate_process_function(t_service* tservice, t_function // always catch all exceptions to prevent from service denial string appex = tmp("appex"); - f_service_ << " catch (th : Dynamic) {" << endl; + f_service_ << " catch (th : Dynamic) {" << '\n'; indent_up(); - indent(f_service_) << "trace(\"Internal error processing " << tfunction->get_name() << "\", th);" << endl; + indent(f_service_) << "trace(\"Internal error processing " << tfunction->get_name() << "\", th);" << '\n'; if (!tfunction->is_oneway()) { indent(f_service_) << "var appex = new TApplicationException(TApplicationException.INTERNAL_ERROR, " - "\"Internal error processing " << tfunction->get_name() << "\");" << endl; + "\"Internal error processing " << tfunction->get_name() << "\");" << '\n'; indent(f_service_) << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() - << "\", TMessageType.EXCEPTION, seqid));" << endl; - indent(f_service_) << "appex.write(oprot);" << endl; - indent(f_service_) << "oprot.writeMessageEnd();" << endl; - indent(f_service_) << "oprot.getTransport().flush();" << endl; + << "\", TMessageType.EXCEPTION, seqid));" << '\n'; + indent(f_service_) << "appex.write(oprot);" << '\n'; + indent(f_service_) << "oprot.writeMessageEnd();" << '\n'; + indent(f_service_) << "oprot.getTransport().flush();" << '\n'; } - indent(f_service_) << "return;" << endl; + indent(f_service_) << "return;" << '\n'; indent_down(); - f_service_ << indent() << "}" << endl; + f_service_ << indent() << "}" << '\n'; // Shortcut out here for oneway functions if (tfunction->is_oneway()) { - f_service_ << indent() << "return;" << endl; + f_service_ << indent() << "return;" << '\n'; scope_down(f_service_); // Close class indent_down(); - f_service_ << indent() << "}" << endl << endl; + f_service_ << indent() << "}" << '\n' << '\n'; return; } f_service_ << indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() - << "\", TMessageType.REPLY, seqid));" << endl << indent() << "result.write(oprot);" - << endl << indent() << "oprot.writeMessageEnd();" << endl << indent() - << "oprot.getTransport().flush();" << endl; + << "\", TMessageType.REPLY, seqid));" << '\n' << indent() << "result.write(oprot);" + << '\n' << indent() << "oprot.writeMessageEnd();" << '\n' << indent() + << "oprot.getTransport().flush();" << '\n'; // Close function scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Close class indent_down(); - f_service_ << indent() << "}" << endl << endl; + f_service_ << indent() << "}" << '\n' << '\n'; } /** @@ -2309,7 +2307,7 @@ void t_haxe_generator::generate_deserialize_field(ostream& out, t_field* tfield, } else if (type->is_enum()) { out << "readI32();"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", tfield->get_name().c_str(), @@ -2323,8 +2321,8 @@ void t_haxe_generator::generate_deserialize_field(ostream& out, t_field* tfield, void t_haxe_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) { - out << indent() << prefix << " = new " << get_cap_name(type_name(tstruct)) << "();" << endl - << indent() << prefix << ".read(iprot);" << endl; + out << indent() << prefix << " = new " << get_cap_name(type_name(tstruct)) << "();" << '\n' + << indent() << prefix << ".read(iprot);" << '\n'; } /** @@ -2345,21 +2343,21 @@ void t_haxe_generator::generate_deserialize_container(ostream& out, t_type* ttyp // Declare variables, read header if (ttype->is_map()) { - indent(out) << "var " << obj << " = iprot.readMapBegin();" << endl; + indent(out) << "var " << obj << " = iprot.readMapBegin();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "var " << obj << " = iprot.readSetBegin();" << endl; + indent(out) << "var " << obj << " = iprot.readSetBegin();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "var " << obj << " = iprot.readListBegin();" << endl; + indent(out) << "var " << obj << " = iprot.readListBegin();" << '\n'; } indent(out) << prefix << " = new " << type_name(ttype, false, true) // size the collection correctly << "(" - << ");" << endl; + << ");" << '\n'; // For loop iterates over elements string i = tmp("_i"); - indent(out) << "for( " << i << " in 0 ... " << obj << ".size)" << endl; + indent(out) << "for( " << i << " in 0 ... " << obj << ".size)" << '\n'; scope_up(out); @@ -2375,11 +2373,11 @@ void t_haxe_generator::generate_deserialize_container(ostream& out, t_type* ttyp // Read container end if (ttype->is_map()) { - indent(out) << "iprot.readMapEnd();" << endl; + indent(out) << "iprot.readMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "iprot.readSetEnd();" << endl; + indent(out) << "iprot.readSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "iprot.readListEnd();" << endl; + indent(out) << "iprot.readListEnd();" << '\n'; } scope_down(out); @@ -2394,13 +2392,13 @@ void t_haxe_generator::generate_deserialize_map_element(ostream& out, t_map* tma t_field fkey(tmap->get_key_type(), key); t_field fval(tmap->get_val_type(), val); - indent(out) << declare_field(&fkey) << endl; - indent(out) << declare_field(&fval) << endl; + indent(out) << declare_field(&fkey) << '\n'; + indent(out) << declare_field(&fval) << '\n'; generate_deserialize_field(out, &fkey); generate_deserialize_field(out, &fval); - indent(out) << prefix << ".set( " << key << ", " << val << ");" << endl; + indent(out) << prefix << ".set( " << key << ", " << val << ");" << '\n'; } /** @@ -2410,11 +2408,11 @@ void t_haxe_generator::generate_deserialize_set_element(ostream& out, t_set* tse string elem = tmp("_elem"); t_field felem(tset->get_elem_type(), elem); - indent(out) << declare_field(&felem) << endl; + indent(out) << declare_field(&felem) << '\n'; generate_deserialize_field(out, &felem); - indent(out) << prefix << ".add(" << elem << ");" << endl; + indent(out) << prefix << ".add(" << elem << ");" << '\n'; } /** @@ -2426,11 +2424,11 @@ void t_haxe_generator::generate_deserialize_list_element(ostream& out, string elem = tmp("_elem"); t_field felem(tlist->get_elem_type(), elem); - indent(out) << declare_field(&felem) << endl; + indent(out) << declare_field(&felem) << '\n'; generate_deserialize_field(out, &felem); - indent(out) << prefix << ".add(" << elem << ");" << endl; + indent(out) << prefix << ".add(" << elem << ");" << '\n'; } /** @@ -2496,7 +2494,7 @@ void t_haxe_generator::generate_serialize_field(ostream& out, t_field* tfield, s } else if (type->is_enum()) { out << "writeI32(" << name << ");"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n", prefix.c_str(), @@ -2513,7 +2511,7 @@ void t_haxe_generator::generate_serialize_field(ostream& out, t_field* tfield, s */ void t_haxe_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - out << indent() << prefix << ".write(oprot);" << endl; + out << indent() << prefix << ".write(oprot);" << '\n'; } /** @@ -2527,30 +2525,30 @@ void t_haxe_generator::generate_serialize_container(ostream& out, t_type* ttype, if (ttype->is_map()) { string iter = tmp("_key"); string counter = tmp("_sizeCounter"); - indent(out) << "var " << counter << " : Int = 0;" << endl; - indent(out) << "for( " << iter << " in " << prefix << ") {" << endl; - indent(out) << " " << counter << +"++;" << endl; - indent(out) << "}" << endl; + indent(out) << "var " << counter << " : Int = 0;" << '\n'; + indent(out) << "for( " << iter << " in " << prefix << ") {" << '\n'; + indent(out) << " " << counter << +"++;" << '\n'; + indent(out) << "}" << '\n'; indent(out) << "oprot.writeMapBegin(new TMap(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << counter << "));" - << endl; + << '\n'; } else if (ttype->is_set()) { indent(out) << "oprot.writeSetBegin(new TSet(" << type_to_enum(((t_set*)ttype)->get_elem_type()) - << ", " << prefix << ".size));" << endl; + << ", " << prefix << ".size));" << '\n'; } else if (ttype->is_list()) { indent(out) << "oprot.writeListBegin(new TList(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix << ".length));" - << endl; + << '\n'; } string iter = tmp("elem"); if (ttype->is_map()) { - indent(out) << "for( " << iter << " in " << prefix << ".keys())" << endl; + indent(out) << "for( " << iter << " in " << prefix << ".keys())" << '\n'; } else if (ttype->is_set()) { - indent(out) << "for( " << iter << " in " << prefix << ".toArray())" << endl; + indent(out) << "for( " << iter << " in " << prefix << ".toArray())" << '\n'; } else if (ttype->is_list()) { - indent(out) << "for( " << iter << " in " << prefix << ")" << endl; + indent(out) << "for( " << iter << " in " << prefix << ")" << '\n'; } scope_up(out); @@ -2566,11 +2564,11 @@ void t_haxe_generator::generate_serialize_container(ostream& out, t_type* ttype, scope_down(out); if (ttype->is_map()) { - indent(out) << "oprot.writeMapEnd();" << endl; + indent(out) << "oprot.writeMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "oprot.writeSetEnd();" << endl; + indent(out) << "oprot.writeSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "oprot.writeListEnd();" << endl; + indent(out) << "oprot.writeListEnd();" << '\n'; } } @@ -3006,7 +3004,7 @@ string t_haxe_generator::constant_name(string name) { */ void t_haxe_generator::generate_rtti_decoration(ostream& out) { if (rtti_) { - out << "@:rtti" << endl; + out << "@:rtti" << '\n'; } } @@ -3015,10 +3013,10 @@ void t_haxe_generator::generate_rtti_decoration(ostream& out) { */ void t_haxe_generator::generate_macro_decoration(ostream& out) { if (!buildmacro_.empty()) { - out << "#if ! macro" << endl; - out << "@:build( " << buildmacro_ << ")" << endl; // current class/interface - out << "@:autoBuild( " << buildmacro_ << ")" << endl; // inherited classes/interfaces - out << "#end" << endl; + out << "#if ! macro" << '\n'; + out << "@:build( " << buildmacro_ << ")" << '\n'; // current class/interface + out << "@:autoBuild( " << buildmacro_ << ")" << '\n'; // inherited classes/interfaces + out << "#end" << '\n'; } } @@ -3061,7 +3059,7 @@ std::string t_haxe_generator::generate_isset_check(std::string field_name) { void t_haxe_generator::generate_isset_set(ostream& out, t_field* field) { if (!type_can_be_null(field->get_type())) { - indent(out) << "this.__isset_" << field->get_name() << " = true;" << endl; + indent(out) << "this.__isset_" << field->get_name() << " = true;" << '\n'; } } diff --git a/compiler/cpp/src/thrift/generate/t_html_generator.cc b/compiler/cpp/src/thrift/generate/t_html_generator.cc index 15a0401d596..637cd885eff 100644 --- a/compiler/cpp/src/thrift/generate/t_html_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_html_generator.cc @@ -38,8 +38,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - enum input_type { INPUT_UNKNOWN, INPUT_UTF8, INPUT_PLAIN }; /** @@ -129,9 +127,9 @@ class t_html_generator : public t_generator { void t_html_generator::generate_program_toc() { f_out_ << "" - << "" << endl; + << "" << '\n'; generate_program_toc_row(program_); - f_out_ << "
ModuleServicesData typesConstants
Data typesConstants
" << endl; + f_out_ << "" << '\n'; } /** @@ -159,15 +157,15 @@ void t_html_generator::generate_program_toc_rows(t_program* tprog, */ void t_html_generator::generate_program_toc_row(t_program* tprog) { string fname = tprog->get_name() + ".html"; - f_out_ << "" << endl << "" << tprog->get_name() << ""; + f_out_ << "" << '\n' << "" << tprog->get_name() << ""; if (!tprog->get_services().empty()) { vector services = tprog->get_services(); vector::iterator sv_iter; for (sv_iter = services.begin(); sv_iter != services.end(); ++sv_iter) { string name = get_service_name(*sv_iter); f_out_ << "" << name - << "
" << endl; - f_out_ << "
    " << endl; + << "
    " << '\n'; + f_out_ << "
      " << '\n'; map fn_html; vector functions = (*sv_iter)->get_functions(); vector::iterator fn_iter; @@ -178,12 +176,12 @@ void t_html_generator::generate_program_toc_row(t_program* tprog) { fn_html.insert(pair(fn_name, html)); } for (auto & html_iter : fn_html) { - f_out_ << html_iter.second << endl; + f_out_ << html_iter.second << '\n'; } - f_out_ << "
    " << endl; + f_out_ << "
" << '\n'; } } - f_out_ << "" << endl << ""; + f_out_ << "" << '\n' << ""; map data_types; if (!tprog->get_enums().empty()) { vector enums = tprog->get_enums(); @@ -191,7 +189,7 @@ void t_html_generator::generate_program_toc_row(t_program* tprog) { for (en_iter = enums.begin(); en_iter != enums.end(); ++en_iter) { string name = (*en_iter)->get_name(); // f_out_ << "" << name - // << "
" << endl; + // << "
" << '\n'; string html = "" + name + ""; data_types.insert(pair(name, html)); } @@ -202,7 +200,7 @@ void t_html_generator::generate_program_toc_row(t_program* tprog) { for (td_iter = typedefs.begin(); td_iter != typedefs.end(); ++td_iter) { string name = (*td_iter)->get_symbolic(); // f_out_ << "" << name - // << "
" << endl; + // << "
" << '\n'; string html = "" + name + ""; data_types.insert(pair(name, html)); @@ -214,16 +212,16 @@ void t_html_generator::generate_program_toc_row(t_program* tprog) { for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) { string name = (*o_iter)->get_name(); // f_out_ << "" << name - //<< "
" << endl; + //<< "
" << '\n'; string html = "" + name + ""; data_types.insert(pair(name, html)); } } for (auto & data_type : data_types) { - f_out_ << data_type.second << "
" << endl; + f_out_ << data_type.second << "
" << '\n'; } - f_out_ << "" << endl << ""; + f_out_ << "" << '\n' << ""; if (!tprog->get_consts().empty()) { map const_html; vector consts = tprog->get_consts(); @@ -235,10 +233,10 @@ void t_html_generator::generate_program_toc_row(t_program* tprog) { const_html.insert(pair(name, html)); } for (auto & con_iter : const_html) { - f_out_ << con_iter.second << "
" << endl; + f_out_ << con_iter.second << "
" << '\n'; } } - f_out_ << "" << endl << ""; + f_out_ << "" << '\n' << ""; } /** @@ -251,30 +249,30 @@ void t_html_generator::generate_program() { current_file_ = program_->get_name() + ".html"; string fname = get_out_dir() + current_file_; f_out_.open(fname.c_str()); - f_out_ << "" << endl; - f_out_ << "" << endl; - f_out_ << "" << endl; - f_out_ << "" << endl; + f_out_ << "" << '\n'; + f_out_ << "" << '\n'; + f_out_ << "" << '\n'; + f_out_ << "" << '\n'; generate_style_tag(); - f_out_ << "Thrift module: " << program_->get_name() << "" << endl - << "
" << endl - << "

Thrift module: " << program_->get_name() << "

" << endl; + f_out_ << "Thrift module: " << program_->get_name() << "" << '\n' + << "
" << '\n' + << "

Thrift module: " << program_->get_name() << "

" << '\n'; print_doc(program_); generate_program_toc(); if (!program_->get_consts().empty()) { - f_out_ << "

Constants

" << endl; + f_out_ << "

Constants

" << '\n'; vector consts = program_->get_consts(); f_out_ << ""; - f_out_ << "" << endl; + f_out_ << "" << '\n'; generate_consts(consts); f_out_ << "
ConstantTypeValue
ConstantTypeValue
"; } if (!program_->get_enums().empty()) { - f_out_ << "

Enumerations

" << endl; + f_out_ << "

Enumerations

" << '\n'; // Generate enums vector enums = program_->get_enums(); vector::iterator en_iter; @@ -284,7 +282,7 @@ void t_html_generator::generate_program() { } if (!program_->get_typedefs().empty()) { - f_out_ << "

Type declarations

" << endl; + f_out_ << "

Type declarations

" << '\n'; // Generate typedefs vector typedefs = program_->get_typedefs(); vector::iterator td_iter; @@ -294,7 +292,7 @@ void t_html_generator::generate_program() { } if (!program_->get_objects().empty()) { - f_out_ << "

Data structures

" << endl; + f_out_ << "

Data structures

" << '\n'; // Generate structs and exceptions in declared order vector objects = program_->get_objects(); vector::iterator o_iter; @@ -308,7 +306,7 @@ void t_html_generator::generate_program() { } if (!program_->get_services().empty()) { - f_out_ << "

Services

" << endl; + f_out_ << "

Services

" << '\n'; // Generate services vector services = program_->get_services(); vector::iterator sv_iter; @@ -318,7 +316,7 @@ void t_html_generator::generate_program() { } } - f_out_ << "
" << endl; + f_out_ << "
" << '\n'; f_out_.close(); generate_index(); @@ -332,17 +330,17 @@ void t_html_generator::generate_index() { current_file_ = "index.html"; string index_fname = get_out_dir() + current_file_; f_out_.open(index_fname.c_str()); - f_out_ << "" << endl << "" << endl; + f_out_ << "" << '\n' << "" << '\n'; generate_style_tag(); - f_out_ << "All Thrift declarations" << endl - << "
" << endl << "

All Thrift declarations

" << endl; + f_out_ << "All Thrift declarations" << '\n' + << "
" << '\n' << "

All Thrift declarations

" << '\n'; f_out_ << "" - << "" << endl; + << "" << '\n'; vector programs; generate_program_toc_rows(program_, programs); - f_out_ << "
ModuleServicesData typesConstants
Constants
" << endl; - f_out_ << "
" << endl; + f_out_ << "" << '\n'; + f_out_ << "
" << '\n'; f_out_.close(); } @@ -357,17 +355,17 @@ void t_html_generator::generate_css() { } void t_html_generator::generate_css_content(std::ostream& f_target) { - f_target << BOOTSTRAP_CSS() << endl; - f_target << "/* Auto-generated CSS for generated Thrift docs */" << endl; - f_target << "h3, h4 { margin-bottom: 6px; }" << endl; + f_target << BOOTSTRAP_CSS() << '\n'; + f_target << "/* Auto-generated CSS for generated Thrift docs */" << '\n'; + f_target << "h3, h4 { margin-bottom: 6px; }" << '\n'; f_target << "div.definition { border: 1px solid #CCC; margin-bottom: 10px; padding: 10px; }" - << endl; - f_target << "div.extends { margin: -0.5em 0 1em 5em }" << endl; - f_target << "td { vertical-align: top; }" << endl; - f_target << "table { empty-cells: show; }" << endl; - f_target << "code { line-height: 20px; }" << endl; + << '\n'; + f_target << "div.extends { margin: -0.5em 0 1em 5em }" << '\n'; + f_target << "td { vertical-align: top; }" << '\n'; + f_target << "table { empty-cells: show; }" << '\n'; + f_target << "code { line-height: 20px; }" << '\n'; f_target << ".table-bordered th, .table-bordered td { border-bottom: 1px solid #DDDDDD; }" - << endl; + << '\n'; } /** @@ -377,11 +375,11 @@ void t_html_generator::generate_css_content(std::ostream& f_target) { */ void t_html_generator::generate_style_tag() { if (!standalone_) { - f_out_ << "" << endl; + f_out_ << "" << '\n'; } else { - f_out_ << "" << endl; + f_out_ << "-->" << '\n'; } } @@ -856,14 +854,14 @@ void t_html_generator::print_fn_args_doc(t_function* tfunction) { if (has_docs) { arg_iter = args.begin(); f_out_ << "

get_name() - << "\">Parameters

" << endl; + << "\">Parameters" << '\n'; f_out_ << ""; f_out_ << ""; for (; arg_iter != args.end(); arg_iter++) { f_out_ << "" << endl; + f_out_ << "" << '\n'; } f_out_ << "
NameDescription
" << (*arg_iter)->get_name(); f_out_ << ""; f_out_ << escape_html((*arg_iter)->get_doc()); - f_out_ << "
"; } @@ -880,14 +878,14 @@ void t_html_generator::print_fn_args_doc(t_function* tfunction) { if (has_docs) { ex_iter = excepts.begin(); f_out_ << "

get_name() - << "\">Exceptions

" << endl; + << "\">Exceptions" << '\n'; f_out_ << ""; f_out_ << ""; for (; ex_iter != excepts.end(); ex_iter++) { f_out_ << "" << endl; + f_out_ << "" << '\n'; } f_out_ << "
TypeDescription
" << (*ex_iter)->get_type()->get_name(); f_out_ << ""; f_out_ << escape_html((*ex_iter)->get_doc()); - f_out_ << "
"; } @@ -902,12 +900,12 @@ void t_html_generator::print_fn_args_doc(t_function* tfunction) { void t_html_generator::generate_typedef(t_typedef* ttypedef) { string name = ttypedef->get_name(); f_out_ << "
"; - f_out_ << "

Typedef: " << name << "

" << endl; + f_out_ << "

Typedef: " << name << "

" << '\n'; f_out_ << "

Base type: "; print_type(ttypedef->get_type()); - f_out_ << "

" << endl; + f_out_ << "

" << '\n'; print_doc(ttypedef); - f_out_ << "
" << endl; + f_out_ << "" << '\n'; } /** @@ -918,21 +916,21 @@ void t_html_generator::generate_typedef(t_typedef* ttypedef) { void t_html_generator::generate_enum(t_enum* tenum) { string name = tenum->get_name(); f_out_ << "
"; - f_out_ << "

Enumeration: " << name << "

" << endl; + f_out_ << "

Enumeration: " << name << "

" << '\n'; print_doc(tenum); vector values = tenum->get_constants(); vector::iterator val_iter; - f_out_ << "
" << endl; + f_out_ << "
" << '\n'; for (val_iter = values.begin(); val_iter != values.end(); ++val_iter) { f_out_ << "" << endl; + f_out_ << "" << '\n'; } - f_out_ << "
"; f_out_ << (*val_iter)->get_name(); f_out_ << ""; f_out_ << (*val_iter)->get_value(); - f_out_ << "" << endl; + f_out_ << "" << '\n'; print_doc((*val_iter)); - f_out_ << "
" << endl; + f_out_ << "" << '\n'; } /** @@ -968,12 +966,12 @@ void t_html_generator::generate_struct(t_struct* tstruct) { } else { f_out_ << "Struct: "; } - f_out_ << name << "" << endl; + f_out_ << name << "" << '\n'; vector members = tstruct->get_members(); vector::iterator mem_iter = members.begin(); f_out_ << ""; f_out_ << "" << endl; + "th>" << '\n'; for (; mem_iter != members.end(); mem_iter++) { f_out_ << "" << endl; + f_out_ << "" << '\n'; } f_out_ << "
KeyFieldTypeDescriptionRequirednessDefault value
Default value
" << (*mem_iter)->get_key() << ""; f_out_ << (*mem_iter)->get_name(); @@ -996,7 +994,7 @@ void t_html_generator::generate_struct(t_struct* tstruct) { print_const_value((*mem_iter)->get_type(), default_val); f_out_ << ""; } - f_out_ << "

"; print_doc(tstruct); @@ -1018,7 +1016,7 @@ void t_html_generator::generate_xception(t_struct* txception) { * @param tservice The service definition */ void t_html_generator::generate_service(t_service* tservice) { - f_out_ << "

Service: " << service_name_ << "

" << endl; + f_out_ << "

Service: " << service_name_ << "

" << '\n'; if (tservice->get_extends()) { f_out_ << "
extends "; @@ -1032,7 +1030,7 @@ void t_html_generator::generate_service(t_service* tservice) { string fn_name = (*fn_iter)->get_name(); f_out_ << "
"; f_out_ << "

Function: " << service_name_ - << "." << fn_name << "

" << endl; + << "." << fn_name << "" << '\n'; f_out_ << "
";
     std::string::size_type offset = print_type((*fn_iter)->get_returntype());
     bool first = true;
@@ -1042,7 +1040,7 @@ void t_html_generator::generate_service(t_service* tservice) {
     vector::iterator arg_iter = args.begin();
     for (; arg_iter != args.end(); arg_iter++) {
       if (!first) {
-        f_out_ << "," << endl;
+        f_out_ << "," << '\n';
         for (std::string::size_type i = 0; i < offset; ++i) {
           f_out_ << " ";
         }
@@ -1055,7 +1053,7 @@ void t_html_generator::generate_service(t_service* tservice) {
         print_const_value((*arg_iter)->get_type(), (*arg_iter)->get_value());
       }
     }
-    f_out_ << ")" << endl;
+    f_out_ << ")" << '\n';
     first = true;
     vector excepts = (*fn_iter)->get_xceptions()->get_members();
     vector::iterator ex_iter = excepts.begin();
@@ -1068,7 +1066,7 @@ void t_html_generator::generate_service(t_service* tservice) {
         first = false;
         print_type((*ex_iter)->get_type());
       }
-      f_out_ << endl;
+      f_out_ << '\n';
     }
     f_out_ << "
"; print_doc(*fn_iter); diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc index 1985a3d8494..e81744e07b0 100644 --- a/compiler/cpp/src/thrift/generate/t_java_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc @@ -45,8 +45,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - static const string thrift_option_class = "org.apache.thrift.Option"; static const string jdk_option_class = "java.util.Optional"; @@ -511,8 +509,7 @@ string t_java_generator::java_package() { } string t_java_generator::java_suppressions() { - return "@SuppressWarnings({\"cast\", \"rawtypes\", \"serial\", \"unchecked\", \"unused\"})" - + endl; + return "@SuppressWarnings({\"cast\", \"rawtypes\", \"serial\", \"unchecked\", \"unused\"})\n"; } string t_java_generator::java_nullable_annotation() { @@ -567,7 +564,7 @@ void t_java_generator::generate_enum(t_enum* tenum) { f_enum.open(f_enum_name.c_str()); // Comment and package it - f_enum << autogen_comment() << java_package() << endl; + f_enum << autogen_comment() << java_package() << '\n'; generate_java_doc(f_enum, tenum); @@ -576,7 +573,7 @@ void t_java_generator::generate_enum(t_enum* tenum) { } if (is_deprecated) { - indent(f_enum) << "@Deprecated" << endl; + indent(f_enum) << "@Deprecated" << '\n'; } indent(f_enum) << "public enum " << tenum->get_name() << " implements org.apache.thrift.TEnum "; scope_up(f_enum); @@ -590,62 +587,62 @@ void t_java_generator::generate_enum(t_enum* tenum) { if (first) { first = false; } else { - f_enum << "," << endl; + f_enum << "," << '\n'; } generate_java_doc(f_enum, *c_iter); if (this->is_deprecated((*c_iter)->annotations_)) { - indent(f_enum) << "@Deprecated" << endl; + indent(f_enum) << "@Deprecated" << '\n'; } indent(f_enum) << (*c_iter)->get_name() << "(" << value << ")"; } - f_enum << ";" << endl << endl; + f_enum << ";" << '\n' << '\n'; // Field for thriftCode - indent(f_enum) << "private final int value;" << endl << endl; + indent(f_enum) << "private final int value;" << '\n' << '\n'; - indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << endl; - indent(f_enum) << " this.value = value;" << endl; - indent(f_enum) << "}" << endl << endl; + indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << '\n'; + indent(f_enum) << " this.value = value;" << '\n'; + indent(f_enum) << "}" << '\n' << '\n'; - indent(f_enum) << "/**" << endl; + indent(f_enum) << "/**" << '\n'; indent(f_enum) << " * Get the integer value of this enum value, as defined in the Thrift IDL." - << endl; - indent(f_enum) << " */" << endl; - indent(f_enum) << java_override_annotation() << endl; - indent(f_enum) << "public int getValue() {" << endl; - indent(f_enum) << " return value;" << endl; - indent(f_enum) << "}" << endl << endl; - - indent(f_enum) << "/**" << endl; + << '\n'; + indent(f_enum) << " */" << '\n'; + indent(f_enum) << java_override_annotation() << '\n'; + indent(f_enum) << "public int getValue() {" << '\n'; + indent(f_enum) << " return value;" << '\n'; + indent(f_enum) << "}" << '\n' << '\n'; + + indent(f_enum) << "/**" << '\n'; indent(f_enum) << " * Find a the enum type by its integer value, as defined in the Thrift IDL." - << endl; - indent(f_enum) << " * @return null if the value is not found." << endl; - indent(f_enum) << " */" << endl; - indent(f_enum) << java_nullable_annotation() << endl; - indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << endl; + << '\n'; + indent(f_enum) << " * @return null if the value is not found." << '\n'; + indent(f_enum) << " */" << '\n'; + indent(f_enum) << java_nullable_annotation() << '\n'; + indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << '\n'; indent_up(); - indent(f_enum) << "switch (value) {" << endl; + indent(f_enum) << "switch (value) {" << '\n'; indent_up(); for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); - indent(f_enum) << "case " << value << ":" << endl; - indent(f_enum) << " return " << (*c_iter)->get_name() << ";" << endl; + indent(f_enum) << "case " << value << ":" << '\n'; + indent(f_enum) << " return " << (*c_iter)->get_name() << ";" << '\n'; } - indent(f_enum) << "default:" << endl; - indent(f_enum) << " return null;" << endl; + indent(f_enum) << "default:" << '\n'; + indent(f_enum) << " return null;" << '\n'; indent_down(); - indent(f_enum) << "}" << endl; + indent(f_enum) << "}" << '\n'; indent_down(); - indent(f_enum) << "}" << endl; + indent(f_enum) << "}" << '\n'; scope_down(f_enum); @@ -667,8 +664,8 @@ void t_java_generator::generate_consts(std::vector consts) { // Print header f_consts << autogen_comment() << java_package() << java_suppressions(); - f_consts << "public class " << make_valid_java_identifier(program_name_) << "Constants {" << endl - << endl; + f_consts << "public class " << make_valid_java_identifier(program_name_) << "Constants {" << '\n' + << '\n'; indent_up(); vector::iterator c_iter; for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { @@ -677,7 +674,7 @@ void t_java_generator::generate_consts(std::vector consts) { (*c_iter)->get_value(), false); } indent_down(); - indent(f_consts) << "}" << endl; + indent(f_consts) << "}" << '\n'; f_consts.close(); } @@ -700,9 +697,9 @@ void t_java_generator::print_const_value(std::ostream& out, } if (type->is_base_type()) { string v2 = render_const_value(out, type, value); - out << name << " = " << v2 << ";" << endl << endl; + out << name << " = " << v2 << ";" << '\n' << '\n'; } else if (type->is_enum()) { - out << name << " = " << render_const_value(out, type, value) << ";" << endl << endl; + out << name << " = " << render_const_value(out, type, value) << ";" << '\n' << '\n'; } else if (type->is_struct() || type->is_xception()) { const vector& unsorted_fields = ((t_struct*)type)->get_members(); vector fields = unsorted_fields; @@ -710,9 +707,9 @@ void t_java_generator::print_const_value(std::ostream& out, vector::const_iterator f_iter; const map& val = value->get_map(); map::const_iterator v_iter; - out << name << " = new " << type_name(type, false, true) << "();" << endl; + out << name << " = new " << type_name(type, false, true) << "();" << '\n'; if (!in_static) { - indent(out) << "static {" << endl; + indent(out) << "static {" << '\n'; indent_up(); } for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { @@ -728,22 +725,22 @@ void t_java_generator::print_const_value(std::ostream& out, string val = render_const_value(out, field_type, v_iter->second); indent(out) << name << "."; std::string cap_name = get_cap_name(v_iter->first->get_string()); - out << "set" << cap_name << "(" << val << ");" << endl; + out << "set" << cap_name << "(" << val << ");" << '\n'; } if (!in_static) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - out << endl; + out << '\n'; } else if (type->is_map()) { std::string constructor_args; if (is_enum_map(type)) { constructor_args = inner_enum_type_name(type); } out << name << " = new " << type_name(type, false, true) << "(" << constructor_args << ");" - << endl; + << '\n'; if (!in_static) { - indent(out) << "static {" << endl; + indent(out) << "static {" << '\n'; indent_up(); } t_type* ktype = ((t_map*)type)->get_key_type(); @@ -753,22 +750,22 @@ void t_java_generator::print_const_value(std::ostream& out, for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string key = render_const_value(out, ktype, v_iter->first); string val = render_const_value(out, vtype, v_iter->second); - indent(out) << name << ".put(" << key << ", " << val << ");" << endl; + indent(out) << name << ".put(" << key << ", " << val << ");" << '\n'; } if (!in_static) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - out << endl; + out << '\n'; } else if (type->is_list() || type->is_set()) { if (is_enum_set(type)) { out << name << " = " << type_name(type, false, true, true) << ".noneOf(" - << inner_enum_type_name(type) << ");" << endl; + << inner_enum_type_name(type) << ");" << '\n'; } else { - out << name << " = new " << type_name(type, false, true) << "();" << endl; + out << name << " = new " << type_name(type, false, true) << "();" << '\n'; } if (!in_static) { - indent(out) << "static {" << endl; + indent(out) << "static {" << '\n'; indent_up(); } t_type* etype; @@ -781,13 +778,13 @@ void t_java_generator::print_const_value(std::ostream& out, vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string val = render_const_value(out, etype, *v_iter); - indent(out) << name << ".add(" << val << ");" << endl; + indent(out) << name << ".add(" << val << ");" << '\n'; } if (!in_static) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - out << endl; + out << '\n'; } else { throw "compiler error: no const of type " + type->get_name(); } @@ -916,7 +913,7 @@ void t_java_generator::generate_java_union(t_struct* tstruct) { } if (is_deprecated) { - indent(f_struct) << "@Deprecated" << endl; + indent(f_struct) << "@Deprecated" << '\n'; } indent(f_struct) << "public " << (is_final ? "final " : "") << "class " << make_valid_java_identifier(tstruct->get_name()) << " extends org.apache.thrift.TUnion<" << make_valid_java_identifier(tstruct->get_name()) << ", " @@ -927,49 +924,49 @@ void t_java_generator::generate_java_union(t_struct* tstruct) { generate_struct_desc(f_struct, tstruct); generate_field_descs(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_field_name_constants(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_java_meta_data_map(f_struct, tstruct); generate_union_constructor(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_union_abstract_methods(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_java_struct_field_by_id(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_union_getters_and_setters(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_union_is_set_methods(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_union_comparisons(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_union_hashcode(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_java_struct_write_object(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_java_struct_read_object(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; scope_down(f_struct); @@ -980,63 +977,63 @@ void t_java_generator::generate_union_constructor(ostream& out, t_struct* tstruc const vector& members = tstruct->get_members(); vector::const_iterator m_iter; - indent(out) << "public " << type_name(tstruct) << "() {" << endl; + indent(out) << "public " << type_name(tstruct) << "() {" << '\n'; indent_up(); bool default_value = false; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* type = get_true_type((*m_iter)->get_type()); if ((*m_iter)->get_value() != nullptr) { indent(out) << "super(_Fields." << constant_name((*m_iter)->get_name()) << ", " - << render_const_value(out, type, (*m_iter)->get_value()) << ");" << endl; + << render_const_value(out, type, (*m_iter)->get_value()) << ");" << '\n'; default_value = true; break; } } if (default_value == false) { - indent(out) << "super();" << endl; + indent(out) << "super();" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; indent(out) << "public " << type_name(tstruct) << "(_Fields setField, java.lang.Object value) {" - << endl; - indent(out) << " super(setField, value);" << endl; - indent(out) << "}" << endl << endl; + << '\n'; + indent(out) << " super(setField, value);" << '\n'; + indent(out) << "}" << '\n' << '\n'; indent(out) << "public " << type_name(tstruct) << "(" << type_name(tstruct) << " other) {" - << endl; - indent(out) << " super(other);" << endl; - indent(out) << "}" << endl; + << '\n'; + indent(out) << " super(other);" << '\n'; + indent(out) << "}" << '\n'; - indent(out) << java_override_annotation() << endl; - indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << " deepCopy() {" << endl; - indent(out) << " return new " << tstruct->get_name() << "(this);" << endl; - indent(out) << "}" << endl << endl; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << " deepCopy() {" << '\n'; + indent(out) << " return new " << tstruct->get_name() << "(this);" << '\n'; + indent(out) << "}" << '\n' << '\n'; // generate "constructors" for each field for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* type = (*m_iter)->get_type(); indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "(" - << type_name(type) << " value) {" << endl; - indent(out) << " " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << endl; - indent(out) << " x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << endl; - indent(out) << " return x;" << endl; - indent(out) << "}" << endl << endl; + << type_name(type) << " value) {" << '\n'; + indent(out) << " " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << '\n'; + indent(out) << " x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << '\n'; + indent(out) << " return x;" << '\n'; + indent(out) << "}" << '\n' << '\n'; if (type->is_binary()) { indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() - << "(byte[] value) {" << endl; + << "(byte[] value) {" << '\n'; indent(out) << " " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" - << endl; + << '\n'; indent(out) << " x.set" << get_cap_name((*m_iter)->get_name()); if (unsafe_binaries_) { - indent(out) << "(java.nio.ByteBuffer.wrap(value));" << endl; + indent(out) << "(java.nio.ByteBuffer.wrap(value));" << '\n'; } else { - indent(out) << "(java.nio.ByteBuffer.wrap(value.clone()));" << endl; + indent(out) << "(java.nio.ByteBuffer.wrap(value.clone()));" << '\n'; } - indent(out) << " return x;" << endl; - indent(out) << "}" << endl << endl; + indent(out) << " return x;" << '\n'; + indent(out) << "}" << '\n' << '\n'; } } } @@ -1050,7 +1047,7 @@ void t_java_generator::generate_union_getters_and_setters(ostream& out, t_struct if (first) { first = false; } else { - out << endl; + out << '\n'; } t_field* field = (*m_iter); @@ -1061,95 +1058,95 @@ void t_java_generator::generate_union_getters_and_setters(ostream& out, t_struct generate_java_doc(out, field); if (type->is_binary()) { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } - indent(out) << "public byte[] get" << cap_name << "() {" << endl; + indent(out) << "public byte[] get" << cap_name << "() {" << '\n'; indent(out) << " set" << cap_name << "(org.apache.thrift.TBaseHelper.rightSize(buffer" - << get_cap_name("for") << cap_name << "()));" << endl; + << get_cap_name("for") << cap_name << "()));" << '\n'; indent(out) << " java.nio.ByteBuffer b = buffer" << get_cap_name("for") << cap_name << "();" - << endl; - indent(out) << " return b == null ? null : b.array();" << endl; - indent(out) << "}" << endl; + << '\n'; + indent(out) << " return b == null ? null : b.array();" << '\n'; + indent(out) << "}" << '\n'; - out << endl; + out << '\n'; indent(out) << "public java.nio.ByteBuffer buffer" << get_cap_name("for") - << get_cap_name(field->get_name()) << "() {" << endl; + << get_cap_name(field->get_name()) << "() {" << '\n'; indent(out) << " if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {" - << endl; + << '\n'; if (unsafe_binaries_) { - indent(out) << " return (java.nio.ByteBuffer)getFieldValue();" << endl; + indent(out) << " return (java.nio.ByteBuffer)getFieldValue();" << '\n'; } else { indent(out) << " return " "org.apache.thrift.TBaseHelper.copyBinary((java.nio.ByteBuffer)getFieldValue());" - << endl; + << '\n'; } - indent(out) << " } else {" << endl; + indent(out) << " } else {" << '\n'; indent(out) << " throw new java.lang.RuntimeException(\"Cannot get field '" << field->get_name() << "' because union is currently set to \" + getFieldDesc(getSetField()).name);" - << endl; - indent(out) << " }" << endl; - indent(out) << "}" << endl; + << '\n'; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n'; } else { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } indent(out) << "public " << type_name(field->get_type()) << " get" - << get_cap_name(field->get_name()) << "() {" << endl; + << get_cap_name(field->get_name()) << "() {" << '\n'; indent(out) << " if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {" - << endl; + << '\n'; indent(out) << " return (" << type_name(field->get_type(), true) << ")getFieldValue();" - << endl; - indent(out) << " } else {" << endl; + << '\n'; + indent(out) << " } else {" << '\n'; indent(out) << " throw new java.lang.RuntimeException(\"Cannot get field '" << field->get_name() << "' because union is currently set to \" + getFieldDesc(getSetField()).name);" - << endl; - indent(out) << " }" << endl; - indent(out) << "}" << endl; + << '\n'; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n'; } - out << endl; + out << '\n'; generate_java_doc(out, field); if (type->is_binary()) { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } indent(out) << "public void set" << get_cap_name(field->get_name()) << "(byte[] value) {" - << endl; + << '\n'; indent(out) << " set" << get_cap_name(field->get_name()); if (unsafe_binaries_) { - indent(out) << "(java.nio.ByteBuffer.wrap(value));" << endl; + indent(out) << "(java.nio.ByteBuffer.wrap(value));" << '\n'; } else { - indent(out) << "(java.nio.ByteBuffer.wrap(value.clone()));" << endl; + indent(out) << "(java.nio.ByteBuffer.wrap(value.clone()));" << '\n'; } - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; - out << endl; + out << '\n'; } if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } indent(out) << "public void set" << get_cap_name(field->get_name()) << "(" - << type_name(field->get_type()) << " value) {" << endl; + << type_name(field->get_type()) << " value) {" << '\n'; - indent(out) << " setField_ = _Fields." << constant_name(field->get_name()) << ";" << endl; + indent(out) << " setField_ = _Fields." << constant_name(field->get_name()) << ";" << '\n'; if (type_can_be_null(field->get_type())) { indent(out) << " value_ = java.util.Objects.requireNonNull(value,\"" - << "_Fields." << constant_name(field->get_name()) << "\");" << endl; + << "_Fields." << constant_name(field->get_name()) << "\");" << '\n'; } else { - indent(out) << " value_ = value;" << endl; + indent(out) << " value_ = value;" << '\n'; } - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } @@ -1162,49 +1159,49 @@ void t_java_generator::generate_union_is_set_methods(ostream& out, t_struct* tst if (first) { first = false; } else { - out << endl; + out << '\n'; } std::string field_name = (*m_iter)->get_name(); indent(out) << "public boolean is" << get_cap_name("set") << get_cap_name(field_name) << "() {" - << endl; + << '\n'; indent_up(); - indent(out) << "return setField_ == _Fields." << constant_name(field_name) << ";" << endl; + indent(out) << "return setField_ == _Fields." << constant_name(field_name) << ";" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } } void t_java_generator::generate_union_abstract_methods(ostream& out, t_struct* tstruct) { generate_check_type(out, tstruct); - out << endl; + out << '\n'; generate_standard_scheme_read_value(out, tstruct); - out << endl; + out << '\n'; generate_standard_scheme_write_value(out, tstruct); - out << endl; + out << '\n'; generate_tuple_scheme_read_value(out, tstruct); - out << endl; + out << '\n'; generate_tuple_scheme_write_value(out, tstruct); - out << endl; + out << '\n'; generate_get_field_desc(out, tstruct); - out << endl; + out << '\n'; generate_get_struct_desc(out, tstruct); - out << endl; - indent(out) << java_override_annotation() << endl; - indent(out) << "protected _Fields enumForId(short id) {" << endl; - indent(out) << " return _Fields.findByThriftIdOrThrow(id);" << endl; - indent(out) << "}" << endl; + out << '\n'; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "protected _Fields enumForId(short id) {" << '\n'; + indent(out) << " return _Fields.findByThriftIdOrThrow(id);" << '\n'; + indent(out) << "}" << '\n'; } void t_java_generator::generate_check_type(ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "protected void checkType(_Fields setField, java.lang.Object value) throws " "java.lang.ClassCastException {" - << endl; + << '\n'; indent_up(); - indent(out) << "switch (setField) {" << endl; + indent(out) << "switch (setField) {" << '\n'; indent_up(); const vector& members = tstruct->get_members(); @@ -1213,42 +1210,42 @@ void t_java_generator::generate_check_type(ostream& out, t_struct* tstruct) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = (*m_iter); - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; indent(out) << " if (value instanceof " << type_name(field->get_type(), true, false, true) - << ") {" << endl; - indent(out) << " break;" << endl; - indent(out) << " }" << endl; + << ") {" << '\n'; + indent(out) << " break;" << '\n'; + indent(out) << " }" << '\n'; indent(out) << " throw new java.lang.ClassCastException(\"Was expecting value of type " << type_name(field->get_type(), true, false) << " for field '" << field->get_name() - << "', but got \" + value.getClass().getSimpleName());" << endl; + << "', but got \" + value.getClass().getSimpleName());" << '\n'; // do the real check here } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent(out) << " throw new java.lang.IllegalArgumentException(\"Unknown field id \" + setField);" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_java_generator::generate_standard_scheme_read_value(ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "protected java.lang.Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol " "iprot, org.apache.thrift.protocol.TField field) throws " "org.apache.thrift.TException {" - << endl; + << '\n'; indent_up(); - indent(out) << "_Fields setField = _Fields.findByThriftId(field.id);" << endl; - indent(out) << "if (setField != null) {" << endl; + indent(out) << "_Fields setField = _Fields.findByThriftId(field.id);" << '\n'; + indent(out) << "if (setField != null) {" << '\n'; indent_up(); - indent(out) << "switch (setField) {" << endl; + indent(out) << "switch (setField) {" << '\n'; indent_up(); const vector& members = tstruct->get_members(); @@ -1257,53 +1254,53 @@ void t_java_generator::generate_standard_scheme_read_value(ostream& out, t_struc for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = (*m_iter); - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; indent_up(); indent(out) << "if (field.type == " << constant_name(field->get_name()) << "_FIELD_DESC.type) {" - << endl; + << '\n'; indent_up(); indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";" - << endl; + << '\n'; generate_deserialize_field(out, field, ""); - indent(out) << "return " << field->get_name() << ";" << endl; + indent(out) << "return " << field->get_name() << ";" << '\n'; indent_down(); - indent(out) << "} else {" << endl; - indent(out) << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << endl; - indent(out) << " return null;" << endl; - indent(out) << "}" << endl; + indent(out) << "} else {" << '\n'; + indent(out) << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << '\n'; + indent(out) << " return null;" << '\n'; + indent(out) << "}" << '\n'; indent_down(); } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent(out) << " throw new java.lang.IllegalStateException(\"setField wasn't null, but didn't match any " "of the case statements!\");" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent_up(); - indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << endl; - indent(out) << "return null;" << endl; + indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << '\n'; + indent(out) << "return null;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_java_generator::generate_standard_scheme_write_value(ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol " "oprot) throws org.apache.thrift.TException {" - << endl; + << '\n'; indent_up(); - indent(out) << "switch (setField_) {" << endl; + indent(out) << "switch (setField_) {" << '\n'; indent_up(); const vector& members = tstruct->get_members(); @@ -1312,42 +1309,42 @@ void t_java_generator::generate_standard_scheme_write_value(ostream& out, t_stru for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = (*m_iter); - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; indent_up(); indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << " = (" - << type_name(field->get_type(), true, false) << ")value_;" << endl; + << type_name(field->get_type(), true, false) << ")value_;" << '\n'; generate_serialize_field(out, field); - indent(out) << "return;" << endl; + indent(out) << "return;" << '\n'; indent_down(); } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent(out) << " throw new java.lang.IllegalStateException(\"Cannot write union with unknown field \" + " "setField_);" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_java_generator::generate_tuple_scheme_read_value(ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "protected java.lang.Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol " "iprot, short fieldID) throws org.apache.thrift.TException {" - << endl; + << '\n'; indent_up(); - indent(out) << "_Fields setField = _Fields.findByThriftId(fieldID);" << endl; - indent(out) << "if (setField != null) {" << endl; + indent(out) << "_Fields setField = _Fields.findByThriftId(fieldID);" << '\n'; + indent(out) << "if (setField != null) {" << '\n'; indent_up(); - indent(out) << "switch (setField) {" << endl; + indent(out) << "switch (setField) {" << '\n'; indent_up(); const vector& members = tstruct->get_members(); @@ -1356,45 +1353,45 @@ void t_java_generator::generate_tuple_scheme_read_value(ostream& out, t_struct* for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = (*m_iter); - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; indent_up(); indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";" - << endl; + << '\n'; generate_deserialize_field(out, field, ""); - indent(out) << "return " << field->get_name() << ";" << endl; + indent(out) << "return " << field->get_name() << ";" << '\n'; indent_down(); } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent(out) << " throw new java.lang.IllegalStateException(\"setField wasn't null, but didn't match any " "of the case statements!\");" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent_up(); indent(out) << "throw new org.apache.thrift.protocol.TProtocolException(\"Couldn't find a field " "with field id \" + fieldID);" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_java_generator::generate_tuple_scheme_write_value(ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) " "throws org.apache.thrift.TException {" - << endl; + << '\n'; indent_up(); - indent(out) << "switch (setField_) {" << endl; + indent(out) << "switch (setField_) {" << '\n'; indent_up(); const vector& members = tstruct->get_members(); @@ -1403,119 +1400,119 @@ void t_java_generator::generate_tuple_scheme_write_value(ostream& out, t_struct* for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = (*m_iter); - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; indent_up(); indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << " = (" - << type_name(field->get_type(), true, false) << ")value_;" << endl; + << type_name(field->get_type(), true, false) << ")value_;" << '\n'; generate_serialize_field(out, field); - indent(out) << "return;" << endl; + indent(out) << "return;" << '\n'; indent_down(); } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent(out) << " throw new java.lang.IllegalStateException(\"Cannot write union with unknown field \" + " "setField_);" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_java_generator::generate_get_field_desc(ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {" - << endl; + << '\n'; indent_up(); const vector& members = tstruct->get_members(); vector::const_iterator m_iter; - indent(out) << "switch (setField) {" << endl; + indent(out) << "switch (setField) {" << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = (*m_iter); - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; - indent(out) << " return " << constant_name(field->get_name()) << "_FIELD_DESC;" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; + indent(out) << " return " << constant_name(field->get_name()) << "_FIELD_DESC;" << '\n'; } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent(out) << " throw new java.lang.IllegalArgumentException(\"Unknown field id \" + setField);" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_java_generator::generate_get_struct_desc(ostream& out, t_struct* tstruct) { (void)tstruct; - indent(out) << java_override_annotation() << endl; - indent(out) << "protected org.apache.thrift.protocol.TStruct getStructDesc() {" << endl; - indent(out) << " return STRUCT_DESC;" << endl; - indent(out) << "}" << endl; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "protected org.apache.thrift.protocol.TStruct getStructDesc() {" << '\n'; + indent(out) << " return STRUCT_DESC;" << '\n'; + indent(out) << "}" << '\n'; } void t_java_generator::generate_union_comparisons(ostream& out, t_struct* tstruct) { // equality - indent(out) << "public boolean equals(java.lang.Object other) {" << endl; - indent(out) << " if (other instanceof " << make_valid_java_identifier(tstruct->get_name()) << ") {" << endl; - indent(out) << " return equals((" << make_valid_java_identifier(tstruct->get_name()) << ")other);" << endl; - indent(out) << " } else {" << endl; - indent(out) << " return false;" << endl; - indent(out) << " }" << endl; - indent(out) << "}" << endl; + indent(out) << "public boolean equals(java.lang.Object other) {" << '\n'; + indent(out) << " if (other instanceof " << make_valid_java_identifier(tstruct->get_name()) << ") {" << '\n'; + indent(out) << " return equals((" << make_valid_java_identifier(tstruct->get_name()) << ")other);" << '\n'; + indent(out) << " } else {" << '\n'; + indent(out) << " return false;" << '\n'; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n'; - out << endl; + out << '\n'; - indent(out) << "public boolean equals(" << make_valid_java_identifier(tstruct->get_name()) << " other) {" << endl; + indent(out) << "public boolean equals(" << make_valid_java_identifier(tstruct->get_name()) << " other) {" << '\n'; indent(out) << " return other != null && getSetField() == other.getSetField() && " "getFieldValue().equals(other.getFieldValue());" - << endl; - indent(out) << "}" << endl; - out << endl; + << '\n'; + indent(out) << "}" << '\n'; + out << '\n'; - indent(out) << java_override_annotation() << endl; - indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << '\n'; indent(out) << " int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), " "other.getSetField());" - << endl; - indent(out) << " if (lastComparison == 0) {" << endl; + << '\n'; + indent(out) << " if (lastComparison == 0) {" << '\n'; indent(out) << " return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), " "other.getFieldValue());" - << endl; - indent(out) << " }" << endl; - indent(out) << " return lastComparison;" << endl; - indent(out) << "}" << endl; - out << endl; + << '\n'; + indent(out) << " }" << '\n'; + indent(out) << " return lastComparison;" << '\n'; + indent(out) << "}" << '\n'; + out << '\n'; } void t_java_generator::generate_union_hashcode(ostream& out, t_struct* tstruct) { (void)tstruct; - indent(out) << java_override_annotation() << endl; - indent(out) << "public int hashCode() {" << endl; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public int hashCode() {" << '\n'; indent(out) << " java.util.List list = new java.util.ArrayList();" - << endl; - indent(out) << " list.add(this.getClass().getName());" << endl; - indent(out) << " org.apache.thrift.TFieldIdEnum setField = getSetField();" << endl; - indent(out) << " if (setField != null) {" << endl; - indent(out) << " list.add(setField.getThriftFieldId());" << endl; - indent(out) << " java.lang.Object value = getFieldValue();" << endl; - indent(out) << " if (value instanceof org.apache.thrift.TEnum) {" << endl; - indent(out) << " list.add(((org.apache.thrift.TEnum)getFieldValue()).getValue());" << endl; - indent(out) << " } else {" << endl; - indent(out) << " list.add(value);" << endl; - indent(out) << " }" << endl; - indent(out) << " }" << endl; - indent(out) << " return list.hashCode();" << endl; + << '\n'; + indent(out) << " list.add(this.getClass().getName());" << '\n'; + indent(out) << " org.apache.thrift.TFieldIdEnum setField = getSetField();" << '\n'; + indent(out) << " if (setField != null) {" << '\n'; + indent(out) << " list.add(setField.getThriftFieldId());" << '\n'; + indent(out) << " java.lang.Object value = getFieldValue();" << '\n'; + indent(out) << " if (value instanceof org.apache.thrift.TEnum) {" << '\n'; + indent(out) << " list.add(((org.apache.thrift.TEnum)getFieldValue()).getValue());" << '\n'; + indent(out) << " } else {" << '\n'; + indent(out) << " list.add(value);" << '\n'; + indent(out) << " }" << '\n'; + indent(out) << " }" << '\n'; + indent(out) << " return list.hashCode();" << '\n'; indent(out) << "}"; } @@ -1545,7 +1542,7 @@ void t_java_generator::generate_java_struct_definition(ostream& out, } if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } indent(out) << "public " << (is_final ? "final " : "") << (in_class ? "static " : "") << "class " << make_valid_java_identifier(tstruct->get_name()) << " "; @@ -1571,15 +1568,15 @@ void t_java_generator::generate_java_struct_definition(ostream& out, const vector& members = tstruct->get_members(); vector::const_iterator m_iter; - out << endl; + out << '\n'; generate_field_descs(out, tstruct); - out << endl; + out << '\n'; generate_scheme_map(out, tstruct); - out << endl; + out << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if (bean_style_ || private_members_) { @@ -1588,10 +1585,10 @@ void t_java_generator::generate_java_struct_definition(ostream& out, generate_java_doc(out, *m_iter); indent(out) << "public "; } - out << declare_field(*m_iter, false, true) << endl; + out << declare_field(*m_iter, false, true) << '\n'; } - out << endl; + out << '\n'; if (android_style_) { generate_java_struct_parcelable(out, tstruct); @@ -1601,9 +1598,9 @@ void t_java_generator::generate_java_struct_definition(ostream& out, // isset data if (members.size() > 0) { - out << endl; + out << '\n'; - indent(out) << "// isset id assignments" << endl; + indent(out) << "// isset id assignments" << '\n'; int i = 0; int optionals = 0; @@ -1613,7 +1610,7 @@ void t_java_generator::generate_java_struct_definition(ostream& out, } if (!type_can_be_null((*m_iter)->get_type())) { indent(out) << "private static final int " << isset_field_id(*m_iter) << " = " << i << ";" - << endl; + << '\n'; i++; } } @@ -1623,11 +1620,11 @@ void t_java_generator::generate_java_struct_definition(ostream& out, case ISSET_NONE: break; case ISSET_PRIMITIVE: - indent(out) << "private " << primitiveType << " __isset_bitfield = 0;" << endl; + indent(out) << "private " << primitiveType << " __isset_bitfield = 0;" << '\n'; break; case ISSET_BITSET: indent(out) << "private java.util.BitSet __isset_bit_vector = new java.util.BitSet(" << i - << ");" << endl; + << ");" << '\n'; break; } @@ -1638,7 +1635,7 @@ void t_java_generator::generate_java_struct_definition(ostream& out, output_string = output_string + "_Fields." + constant_name((*m_iter)->get_name()) + ","; } } - indent(out) << output_string.substr(0, output_string.length() - 1) << "};" << endl; + indent(out) << output_string.substr(0, output_string.length() - 1) << "};" << '\n'; } } @@ -1647,7 +1644,7 @@ void t_java_generator::generate_java_struct_definition(ostream& out, bool all_optional_members = true; // Default constructor - indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << "() {" << endl; + indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << "() {" << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* t = get_true_type((*m_iter)->get_type()); @@ -1660,27 +1657,27 @@ void t_java_generator::generate_java_struct_definition(ostream& out, } } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; if (!members.empty() && !all_optional_members) { // Full constructor for all fields - indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << "(" << endl; + indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << "(" << '\n'; indent_up(); bool first = true; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_req() != t_field::T_OPTIONAL) { if (!first) { - out << "," << endl; + out << "," << '\n'; } first = false; indent(out) << type_name((*m_iter)->get_type()) << " " << make_valid_java_identifier((*m_iter)->get_name()); } } - out << ")" << endl; + out << ")" << '\n'; indent_down(); - indent(out) << "{" << endl; + indent(out) << "{" << '\n'; indent_up(); - indent(out) << "this();" << endl; + indent(out) << "this();" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_req() != t_field::T_OPTIONAL) { t_type* type = get_true_type((*m_iter)->get_type()); @@ -1688,44 +1685,44 @@ void t_java_generator::generate_java_struct_definition(ostream& out, if (unsafe_binaries_) { indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name()) << " = " << make_valid_java_identifier((*m_iter)->get_name()) << ";" - << endl; + << '\n'; } else { indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name()) << " = org.apache.thrift.TBaseHelper.copyBinary(" << make_valid_java_identifier((*m_iter)->get_name()) - << ");" << endl; + << ");" << '\n'; } } else { indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name()) << " = " << make_valid_java_identifier((*m_iter)->get_name()) << ";" - << endl; + << '\n'; } generate_isset_set(out, (*m_iter), ""); } } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } // copy constructor - indent(out) << "/**" << endl; - indent(out) << " * Performs a deep copy on other." << endl; - indent(out) << " */" << endl; + indent(out) << "/**" << '\n'; + indent(out) << " * Performs a deep copy on other." << '\n'; + indent(out) << " */" << '\n'; indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << "(" << make_valid_java_identifier(tstruct->get_name()) << " other) {" - << endl; + << '\n'; indent_up(); switch (needs_isset(tstruct)) { case ISSET_NONE: break; case ISSET_PRIMITIVE: - indent(out) << "__isset_bitfield = other.__isset_bitfield;" << endl; + indent(out) << "__isset_bitfield = other.__isset_bitfield;" << '\n'; break; case ISSET_BITSET: - indent(out) << "__isset_bit_vector.clear();" << endl; - indent(out) << "__isset_bit_vector.or(other.__isset_bit_vector);" << endl; + indent(out) << "__isset_bit_vector.clear();" << '\n'; + indent(out) << "__isset_bit_vector.or(other.__isset_bit_vector);" << '\n'; break; } @@ -1736,33 +1733,33 @@ void t_java_generator::generate_java_struct_definition(ostream& out, bool can_be_null = type_can_be_null(type); if (can_be_null) { - indent(out) << "if (other." << generate_isset_check(field) << ") {" << endl; + indent(out) << "if (other." << generate_isset_check(field) << ") {" << '\n'; indent_up(); } if (type->is_container()) { generate_deep_copy_container(out, "other", field_name, "__this__" + field_name, type); - indent(out) << "this." << make_valid_java_identifier(field_name) << " = __this__" << field_name << ";" << endl; + indent(out) << "this." << make_valid_java_identifier(field_name) << " = __this__" << field_name << ";" << '\n'; } else { indent(out) << "this." << make_valid_java_identifier(field_name) << " = "; generate_deep_copy_non_container(out, "other." + make_valid_java_identifier(field_name), field_name, type); - out << ";" << endl; + out << ";" << '\n'; } if (can_be_null) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // clone method, so that you can deep copy an object when you don't know its class. - indent(out) << java_override_annotation() << endl; - indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << " deepCopy() {" << endl; - indent(out) << " return new " << make_valid_java_identifier(tstruct->get_name()) << "(this);" << endl; - indent(out) << "}" << endl << endl; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << " deepCopy() {" << '\n'; + indent(out) << " return new " << make_valid_java_identifier(tstruct->get_name()) << "(this);" << '\n'; + indent(out) << "}" << '\n' << '\n'; generate_java_struct_clear(out, tstruct); @@ -1791,7 +1788,7 @@ void t_java_generator::generate_java_struct_definition(ostream& out, generate_java_scheme_lookup(out); scope_down(out); - out << endl; + out << '\n'; } /** @@ -1803,30 +1800,30 @@ void t_java_generator::generate_java_struct_parcelable(ostream& out, t_struct* t const vector& members = tstruct->get_members(); vector::const_iterator m_iter; - out << indent() << java_override_annotation() << endl - << indent() << "public void writeToParcel(android.os.Parcel out, int flags) {" << endl; + out << indent() << java_override_annotation() << '\n' + << indent() << "public void writeToParcel(android.os.Parcel out, int flags) {" << '\n'; indent_up(); string bitsetPrimitiveType = ""; switch (needs_isset(tstruct, &bitsetPrimitiveType)) { case ISSET_NONE: break; case ISSET_PRIMITIVE: - indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << endl; + indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << '\n'; if (bitsetPrimitiveType == "byte") { - indent(out) << "out.writeByte(__isset_bitfield);" << endl; + indent(out) << "out.writeByte(__isset_bitfield);" << '\n'; } else if (bitsetPrimitiveType == "short") { - indent(out) << "out.writeInt(new Short(__isset_bitfield).intValue());" << endl; + indent(out) << "out.writeInt(new Short(__isset_bitfield).intValue());" << '\n'; } else if (bitsetPrimitiveType == "int") { - indent(out) << "out.writeInt(__isset_bitfield);" << endl; + indent(out) << "out.writeInt(__isset_bitfield);" << '\n'; } else if (bitsetPrimitiveType == "long") { - indent(out) << "out.writeLong(__isset_bitfield);" << endl; + indent(out) << "out.writeLong(__isset_bitfield);" << '\n'; } - out << endl; + out << '\n'; break; case ISSET_BITSET: - indent(out) << "//BitSet" << endl; - indent(out) << "out.writeSerializable(__isset_bit_vector);" << endl; - out << endl; + indent(out) << "//BitSet" << '\n'; + indent(out) << "out.writeSerializable(__isset_bit_vector);" << '\n'; + out << '\n'; break; } for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -1834,54 +1831,54 @@ void t_java_generator::generate_java_struct_parcelable(ostream& out, t_struct* t string name = (*m_iter)->get_name(); if (t->is_struct()) { - indent(out) << "out.writeParcelable(" << name << ", flags);" << endl; + indent(out) << "out.writeParcelable(" << name << ", flags);" << '\n'; } else if (type_name(t) == "float") { - indent(out) << "out.writeFloat(" << name << ");" << endl; + indent(out) << "out.writeFloat(" << name << ");" << '\n'; } else if (t->is_enum()) { indent(out) << "out.writeInt(" << name << " != null ? " << name << ".getValue() : -1);" - << endl; + << '\n'; } else if (t->is_list()) { if (((t_list*)t)->get_elem_type()->get_true_type()->is_struct()) { - indent(out) << "out.writeTypedList(" << name << ");" << endl; + indent(out) << "out.writeTypedList(" << name << ");" << '\n'; } else { - indent(out) << "out.writeList(" << name << ");" << endl; + indent(out) << "out.writeList(" << name << ");" << '\n'; } } else if (t->is_map()) { - indent(out) << "out.writeMap(" << name << ");" << endl; + indent(out) << "out.writeMap(" << name << ");" << '\n'; } else if (t->is_base_type()) { if (t->is_binary()) { - indent(out) << "out.writeInt(" << name << "!=null ? 1 : 0);" << endl; - indent(out) << "if(" << name << " != null) { " << endl; + indent(out) << "out.writeInt(" << name << "!=null ? 1 : 0);" << '\n'; + indent(out) << "if(" << name << " != null) { " << '\n'; indent_up(); indent(out) << "out.writeByteArray(" << name << ".array(), " << name << ".position() + " << name << ".arrayOffset(), " << name << ".limit() - " << name - << ".position() );" << endl; + << ".position() );" << '\n'; scope_down(out); } else { switch (((t_base_type*)t)->get_base()) { case t_base_type::TYPE_I16: - indent(out) << "out.writeInt(new Short(" << name << ").intValue());" << endl; + indent(out) << "out.writeInt(new Short(" << name << ").intValue());" << '\n'; break; case t_base_type::TYPE_UUID: - indent(out) << "out.writeUuid(" << name << ");" << endl; + indent(out) << "out.writeUuid(" << name << ");" << '\n'; break; case t_base_type::TYPE_I32: - indent(out) << "out.writeInt(" << name << ");" << endl; + indent(out) << "out.writeInt(" << name << ");" << '\n'; break; case t_base_type::TYPE_I64: - indent(out) << "out.writeLong(" << name << ");" << endl; + indent(out) << "out.writeLong(" << name << ");" << '\n'; break; case t_base_type::TYPE_BOOL: - indent(out) << "out.writeInt(" << name << " ? 1 : 0);" << endl; + indent(out) << "out.writeInt(" << name << " ? 1 : 0);" << '\n'; break; case t_base_type::TYPE_I8: - indent(out) << "out.writeByte(" << name << ");" << endl; + indent(out) << "out.writeByte(" << name << ");" << '\n'; break; case t_base_type::TYPE_DOUBLE: - indent(out) << "out.writeDouble(" << name << ");" << endl; + indent(out) << "out.writeDouble(" << name << ");" << '\n'; break; case t_base_type::TYPE_STRING: - indent(out) << "out.writeString(" << name << ");" << endl; + indent(out) << "out.writeString(" << name << ");" << '\n'; break; case t_base_type::TYPE_VOID: break; @@ -1892,38 +1889,38 @@ void t_java_generator::generate_java_struct_parcelable(ostream& out, t_struct* t } } scope_down(out); - out << endl; + out << '\n'; - out << indent() << java_override_annotation() << endl - << indent() << "public int describeContents() {" << endl; + out << indent() << java_override_annotation() << '\n' + << indent() << "public int describeContents() {" << '\n'; indent_up(); - out << indent() << "return 0;" << endl; + out << indent() << "return 0;" << '\n'; scope_down(out); - out << endl; + out << '\n'; - indent(out) << "public " << tname << "(android.os.Parcel in) {" << endl; + indent(out) << "public " << tname << "(android.os.Parcel in) {" << '\n'; indent_up(); // read in the required bitfield switch (needs_isset(tstruct, &bitsetPrimitiveType)) { case ISSET_NONE: break; case ISSET_PRIMITIVE: - indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << endl; + indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << '\n'; if (bitsetPrimitiveType == "byte") { - indent(out) << "__isset_bitfield = in.readByte();" << endl; + indent(out) << "__isset_bitfield = in.readByte();" << '\n'; } else if (bitsetPrimitiveType == "short") { - indent(out) << "__isset_bitfield = (short) in.readInt();" << endl; + indent(out) << "__isset_bitfield = (short) in.readInt();" << '\n'; } else if (bitsetPrimitiveType == "int") { - indent(out) << "__isset_bitfield = in.readInt();" << endl; + indent(out) << "__isset_bitfield = in.readInt();" << '\n'; } else if (bitsetPrimitiveType == "long") { - indent(out) << "__isset_bitfield = in.readLong();" << endl; + indent(out) << "__isset_bitfield = in.readLong();" << '\n'; } - out << endl; + out << '\n'; break; case ISSET_BITSET: - indent(out) << "//BitSet" << endl; - indent(out) << "__isset_bit_vector = (java.util.BitSet) in.readSerializable();" << endl; - out << endl; + indent(out) << "//BitSet" << '\n'; + indent(out) << "__isset_bit_vector = (java.util.BitSet) in.readSerializable();" << '\n'; + out << '\n'; break; } // read all the fields @@ -1934,57 +1931,57 @@ void t_java_generator::generate_java_struct_parcelable(ostream& out, t_struct* t if (t->is_struct()) { indent(out) << prefix << "= in.readParcelable(" << tname << ".class.getClassLoader());" - << endl; + << '\n'; } else if (t->is_enum()) { - indent(out) << prefix << " = " << type_name(t) << ".findByValue(in.readInt());" << endl; + indent(out) << prefix << " = " << type_name(t) << ".findByValue(in.readInt());" << '\n'; } else if (t->is_list()) { t_list* list = (t_list*)t; - indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << endl; + indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << '\n'; if (list->get_elem_type()->get_true_type()->is_struct()) { indent(out) << "in.readTypedList(" << prefix << ", " << type_name(list->get_elem_type()) - << ".CREATOR);" << endl; + << ".CREATOR);" << '\n'; } else { indent(out) << "in.readList(" << prefix << ", " << tname << ".class.getClassLoader());" - << endl; + << '\n'; } } else if (t->is_map()) { - indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << endl; + indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << '\n'; indent(out) << " in.readMap(" << prefix << ", " << tname << ".class.getClassLoader());" - << endl; + << '\n'; } else if (type_name(t) == "float") { - indent(out) << prefix << " = in.readFloat();" << endl; + indent(out) << prefix << " = in.readFloat();" << '\n'; } else if (t->is_base_type()) { t_base_type* bt = (t_base_type*)t; if (bt->is_binary()) { - indent(out) << "if(in.readInt()==1) {" << endl; + indent(out) << "if(in.readInt()==1) {" << '\n'; indent_up(); - indent(out) << prefix << " = java.nio.ByteBuffer.wrap(in.createByteArray());" << endl; + indent(out) << prefix << " = java.nio.ByteBuffer.wrap(in.createByteArray());" << '\n'; scope_down(out); } else { switch (bt->get_base()) { case t_base_type::TYPE_I8: - indent(out) << prefix << " = in.readByte();" << endl; + indent(out) << prefix << " = in.readByte();" << '\n'; break; case t_base_type::TYPE_I16: - indent(out) << prefix << " = (short) in.readInt();" << endl; + indent(out) << prefix << " = (short) in.readInt();" << '\n'; break; case t_base_type::TYPE_I32: - indent(out) << prefix << " = in.readInt();" << endl; + indent(out) << prefix << " = in.readInt();" << '\n'; break; case t_base_type::TYPE_I64: - indent(out) << prefix << " = in.readLong();" << endl; + indent(out) << prefix << " = in.readLong();" << '\n'; break; case t_base_type::TYPE_UUID: - indent(out) << prefix << " = in.readUuid();" << endl; + indent(out) << prefix << " = in.readUuid();" << '\n'; break; case t_base_type::TYPE_BOOL: - indent(out) << prefix << " = (in.readInt()==1);" << endl; + indent(out) << prefix << " = (in.readInt()==1);" << '\n'; break; case t_base_type::TYPE_DOUBLE: - indent(out) << prefix << " = in.readDouble();" << endl; + indent(out) << prefix << " = in.readDouble();" << '\n'; break; case t_base_type::TYPE_STRING: - indent(out) << prefix << "= in.readString();" << endl; + indent(out) << prefix << "= in.readString();" << '\n'; break; case t_base_type::TYPE_VOID: break; @@ -1996,29 +1993,29 @@ void t_java_generator::generate_java_struct_parcelable(ostream& out, t_struct* t } scope_down(out); - out << endl; + out << '\n'; indent(out) << "public static final android.os.Parcelable.Creator<" << tname - << "> CREATOR = new android.os.Parcelable.Creator<" << tname << ">() {" << endl; + << "> CREATOR = new android.os.Parcelable.Creator<" << tname << ">() {" << '\n'; indent_up(); - indent(out) << java_override_annotation() << endl - << indent() << "public " << tname << "[] newArray(int size) {" << endl; + indent(out) << java_override_annotation() << '\n' + << indent() << "public " << tname << "[] newArray(int size) {" << '\n'; indent_up(); - indent(out) << "return new " << tname << "[size];" << endl; + indent(out) << "return new " << tname << "[size];" << '\n'; scope_down(out); - out << endl; + out << '\n'; - indent(out) << java_override_annotation() << endl + indent(out) << java_override_annotation() << '\n' << indent() << "public " << tname << " createFromParcel(android.os.Parcel in) {" - << endl; + << '\n'; indent_up(); - indent(out) << "return new " << tname << "(in);" << endl; + indent(out) << "return new " << tname << "(in);" << '\n'; scope_down(out); indent_down(); - indent(out) << "};" << endl; - out << endl; + indent(out) << "};" << '\n'; + out << '\n'; } /** @@ -2027,26 +2024,26 @@ void t_java_generator::generate_java_struct_parcelable(ostream& out, t_struct* t * @param tstruct The struct definition */ void t_java_generator::generate_java_struct_equality(ostream& out, t_struct* tstruct) { - out << indent() << java_override_annotation() << endl - << indent() << "public boolean equals(java.lang.Object that) {" << endl; + out << indent() << java_override_annotation() << '\n' + << indent() << "public boolean equals(java.lang.Object that) {" << '\n'; indent_up(); - out << indent() << "if (that instanceof " << make_valid_java_identifier(tstruct->get_name()) << ")" << endl - << indent() << " return this.equals((" << make_valid_java_identifier(tstruct->get_name()) << ")that);" << endl - << indent() << "return false;" << endl; + out << indent() << "if (that instanceof " << make_valid_java_identifier(tstruct->get_name()) << ")" << '\n' + << indent() << " return this.equals((" << make_valid_java_identifier(tstruct->get_name()) << ")that);" << '\n' + << indent() << "return false;" << '\n'; scope_down(out); - out << endl; + out << '\n'; - out << indent() << "public boolean equals(" << make_valid_java_identifier(tstruct->get_name()) << " that) {" << endl; + out << indent() << "public boolean equals(" << make_valid_java_identifier(tstruct->get_name()) << " that) {" << '\n'; indent_up(); - out << indent() << "if (that == null)" << endl - << indent() << " return false;" << endl - << indent() << "if (this == that)" << endl - << indent() << " return true;" << endl; + out << indent() << "if (that == null)" << '\n' + << indent() << " return false;" << '\n' + << indent() << "if (this == that)" << '\n' + << indent() << " return true;" << '\n'; const vector& members = tstruct->get_members(); vector::const_iterator m_iter; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - out << endl; + out << '\n'; t_type* t = get_true_type((*m_iter)->get_type()); // Most existing Thrift code does not use isset or optional/required, @@ -2064,14 +2061,14 @@ void t_java_generator::generate_java_struct_equality(ostream& out, t_struct* tst that_present += " && that." + generate_isset_check(*m_iter); } - out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << endl - << indent() << "boolean that_present_" << name << " = " << that_present << ";" << endl + out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << '\n' + << indent() << "boolean that_present_" << name << " = " << that_present << ";" << '\n' << indent() << "if (" - << "this_present_" << name << " || that_present_" << name << ") {" << endl; + << "this_present_" << name << " || that_present_" << name << ") {" << '\n'; indent_up(); out << indent() << "if (!(" - << "this_present_" << name << " && that_present_" << name << "))" << endl - << indent() << " return false;" << endl; + << "this_present_" << name << " && that_present_" << name << "))" << '\n' + << indent() << " return false;" << '\n'; if (t->is_binary()) { unequal = "!this." + make_valid_java_identifier(name) + ".equals(that." + make_valid_java_identifier(name) + ")"; @@ -2081,25 +2078,25 @@ void t_java_generator::generate_java_struct_equality(ostream& out, t_struct* tst unequal = "this." + make_valid_java_identifier(name) + " != that." + make_valid_java_identifier(name); } - out << indent() << "if (" << unequal << ")" << endl << indent() << " return false;" << endl; + out << indent() << "if (" << unequal << ")" << '\n' << indent() << " return false;" << '\n'; scope_down(out); } - out << endl; - indent(out) << "return true;" << endl; + out << '\n'; + indent(out) << "return true;" << '\n'; scope_down(out); - out << endl; + out << '\n'; const int MUL = 8191; // HashCode multiplier const int B_YES = 131071; const int B_NO = 524287; - out << indent() << java_override_annotation() << endl - << indent() << "public int hashCode() {" << endl; + out << indent() << java_override_annotation() << '\n' + << indent() << "public int hashCode() {" << '\n'; indent_up(); - indent(out) << "int hashCode = 1;" << endl; + indent(out) << "int hashCode = 1;" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - out << endl; + out << '\n'; t_type* t = get_true_type((*m_iter)->get_type()); bool is_optional = (*m_iter)->get_req() == t_field::T_OPTIONAL; @@ -2108,37 +2105,37 @@ void t_java_generator::generate_java_struct_equality(ostream& out, t_struct* tst if (is_optional || can_be_null) { indent(out) << "hashCode = hashCode * " << MUL << " + ((" << generate_isset_check(*m_iter) - << ") ? " << B_YES << " : " << B_NO << ");" << endl; + << ") ? " << B_YES << " : " << B_NO << ");" << '\n'; } if (is_optional || can_be_null) { - indent(out) << "if (" + generate_isset_check(*m_iter) + ")" << endl; + indent(out) << "if (" + generate_isset_check(*m_iter) + ")" << '\n'; indent_up(); } if (t->is_enum()) { - indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".getValue();" << endl; + indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".getValue();" << '\n'; } else if (t->is_base_type()) { switch (((t_base_type*)t)->get_base()) { case t_base_type::TYPE_STRING: case t_base_type::TYPE_UUID: - indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".hashCode();" << endl; + indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".hashCode();" << '\n'; break; case t_base_type::TYPE_BOOL: indent(out) << "hashCode = hashCode * " << MUL << " + ((" << name << ") ? " << B_YES - << " : " << B_NO << ");" << endl; + << " : " << B_NO << ");" << '\n'; break; case t_base_type::TYPE_I8: - indent(out) << "hashCode = hashCode * " << MUL << " + (int) (" << name << ");" << endl; + indent(out) << "hashCode = hashCode * " << MUL << " + (int) (" << name << ");" << '\n'; break; case t_base_type::TYPE_I16: case t_base_type::TYPE_I32: - indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ";" << endl; + indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ";" << '\n'; break; case t_base_type::TYPE_I64: case t_base_type::TYPE_DOUBLE: indent(out) << "hashCode = hashCode * " << MUL - << " + org.apache.thrift.TBaseHelper.hashCode(" << name << ");" << endl; + << " + org.apache.thrift.TBaseHelper.hashCode(" << name << ");" << '\n'; break; case t_base_type::TYPE_VOID: throw std::logic_error("compiler error: a struct field cannot be void"); @@ -2147,7 +2144,7 @@ void t_java_generator::generate_java_struct_equality(ostream& out, t_struct* tst + t_base_type::t_base_name(((t_base_type*)t)->get_base())); } } else { - indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".hashCode();" << endl; + indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".hashCode();" << '\n'; } if (is_optional || can_be_null) { @@ -2155,49 +2152,49 @@ void t_java_generator::generate_java_struct_equality(ostream& out, t_struct* tst } } - out << endl; - indent(out) << "return hashCode;" << endl; + out << '\n'; + indent(out) << "return hashCode;" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } void t_java_generator::generate_java_struct_compare_to(ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; - indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << '\n'; indent_up(); - indent(out) << "if (!getClass().equals(other.getClass())) {" << endl; - indent(out) << " return getClass().getName().compareTo(other.getClass().getName());" << endl; - indent(out) << "}" << endl; - out << endl; + indent(out) << "if (!getClass().equals(other.getClass())) {" << '\n'; + indent(out) << " return getClass().getName().compareTo(other.getClass().getName());" << '\n'; + indent(out) << "}" << '\n'; + out << '\n'; - indent(out) << "int lastComparison = 0;" << endl; - out << endl; + indent(out) << "int lastComparison = 0;" << '\n'; + out << '\n'; const vector& members = tstruct->get_members(); vector::const_iterator m_iter; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = *m_iter; indent(out) << "lastComparison = java.lang.Boolean.compare(" << generate_isset_check(field) - << ", other." << generate_isset_check(field) << ");" << endl; - indent(out) << "if (lastComparison != 0) {" << endl; - indent(out) << " return lastComparison;" << endl; - indent(out) << "}" << endl; + << ", other." << generate_isset_check(field) << ");" << '\n'; + indent(out) << "if (lastComparison != 0) {" << '\n'; + indent(out) << " return lastComparison;" << '\n'; + indent(out) << "}" << '\n'; - indent(out) << "if (" << generate_isset_check(field) << ") {" << endl; + indent(out) << "if (" << generate_isset_check(field) << ") {" << '\n'; indent(out) << " lastComparison = org.apache.thrift.TBaseHelper.compareTo(this." << make_valid_java_identifier(field->get_name()) - << ", other." << make_valid_java_identifier(field->get_name()) << ");" << endl; - indent(out) << " if (lastComparison != 0) {" << endl; - indent(out) << " return lastComparison;" << endl; - indent(out) << " }" << endl; - indent(out) << "}" << endl; + << ", other." << make_valid_java_identifier(field->get_name()) << ");" << '\n'; + indent(out) << " if (lastComparison != 0) {" << '\n'; + indent(out) << " return lastComparison;" << '\n'; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n'; } - indent(out) << "return 0;" << endl; + indent(out) << "return 0;" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -2206,63 +2203,63 @@ void t_java_generator::generate_java_struct_compare_to(ostream& out, t_struct* t * @param tstruct The struct definition */ void t_java_generator::generate_java_struct_reader(ostream& out, t_struct* /*tstruct*/) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "public void read(org.apache.thrift.protocol.TProtocol iprot) throws " "org.apache.thrift.TException {" - << endl; + << '\n'; indent_up(); - indent(out) << "scheme(iprot).read(iprot, this);" << endl; + indent(out) << "scheme(iprot).read(iprot, this);" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } // generates java method to perform various checks // (e.g. check that all required fields are set) void t_java_generator::generate_java_validator(ostream& out, t_struct* tstruct) { - indent(out) << "public void validate() throws org.apache.thrift.TException {" << endl; + indent(out) << "public void validate() throws org.apache.thrift.TException {" << '\n'; indent_up(); const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - out << indent() << "// check for required fields" << endl; + out << indent() << "// check for required fields" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { if (bean_style_) { - out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl + out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << '\n' << indent() << " throw new org.apache.thrift.protocol.TProtocolException(\"Required field '" - << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << endl - << indent() << "}" << endl - << endl; + << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << '\n' + << indent() << "}" << '\n' + << '\n'; } else { if (type_can_be_null((*f_iter)->get_type())) { - indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << endl; + indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << '\n'; indent(out) << " throw new org.apache.thrift.protocol.TProtocolException(\"Required field '" - << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl; - indent(out) << "}" << endl; + << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << '\n'; + indent(out) << "}" << '\n'; } else { indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name() << "' because it's a primitive and you chose the non-beans generator." - << endl; + << '\n'; } } } } - out << indent() << "// check for sub-struct validity" << endl; + out << indent() << "// check for sub-struct validity" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_type* type = get_true_type((*f_iter)->get_type()); if (type->is_struct() && !((t_struct*)type)->is_union()) { - out << indent() << "if (" << make_valid_java_identifier((*f_iter)->get_name()) << " != null) {" << endl; - out << indent() << " " << make_valid_java_identifier((*f_iter)->get_name()) << ".validate();" << endl; - out << indent() << "}" << endl; + out << indent() << "if (" << make_valid_java_identifier((*f_iter)->get_name()) << " != null) {" << '\n'; + out << indent() << " " << make_valid_java_identifier((*f_iter)->get_name()) << ".validate();" << '\n'; + out << indent() << "}" << '\n'; } } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -2271,15 +2268,15 @@ void t_java_generator::generate_java_validator(ostream& out, t_struct* tstruct) * @param tstruct The struct definition */ void t_java_generator::generate_java_struct_writer(ostream& out, t_struct* /*tstruct*/) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "public void write(org.apache.thrift.protocol.TProtocol oprot) throws " "org.apache.thrift.TException {" - << endl; + << '\n'; indent_up(); - indent(out) << "scheme(oprot).write(oprot, this);" << endl; + indent(out) << "scheme(oprot).write(oprot, this);" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -2294,30 +2291,30 @@ void t_java_generator::generate_java_struct_result_writer(ostream& out, t_struct (void)tstruct; indent(out) << "public void write(org.apache.thrift.protocol.TProtocol oprot) throws " "org.apache.thrift.TException {" - << endl; + << '\n'; indent_up(); - indent(out) << "scheme(oprot).write(oprot, this);" << endl; + indent(out) << "scheme(oprot).write(oprot, this);" << '\n'; indent_down(); - indent(out) << " }" << endl << endl; + indent(out) << " }" << '\n' << '\n'; } void t_java_generator::generate_java_struct_field_by_id(ostream& out, t_struct* tstruct) { (void)tstruct; - indent(out) << java_nullable_annotation() << endl; - indent(out) << java_override_annotation() << endl; - indent(out) << "public _Fields fieldForId(int fieldId) {" << endl; - indent(out) << " return _Fields.findByThriftId(fieldId);" << endl; - indent(out) << "}" << endl << endl; + indent(out) << java_nullable_annotation() << '\n'; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public _Fields fieldForId(int fieldId) {" << '\n'; + indent(out) << " return _Fields.findByThriftId(fieldId);" << '\n'; + indent(out) << "}" << '\n' << '\n'; } void t_java_generator::generate_reflection_getters(ostringstream& out, t_type* type, string field_name, string cap_name) { - indent(out) << "case " << constant_name(field_name) << ":" << endl; + indent(out) << "case " << constant_name(field_name) << ":" << '\n'; indent_up(); - indent(out) << "return " << (type->is_bool() ? "is" : "get") << cap_name << "();" << endl << endl; + indent(out) << "return " << (type->is_bool() ? "is" : "get") << cap_name << "();" << '\n' << '\n'; indent_down(); } @@ -2326,24 +2323,24 @@ void t_java_generator::generate_reflection_setters(ostringstream& out, string field_name, string cap_name) { const bool is_binary = type->is_binary(); - indent(out) << "case " << constant_name(field_name) << ":" << endl; + indent(out) << "case " << constant_name(field_name) << ":" << '\n'; indent_up(); - indent(out) << "if (value == null) {" << endl; - indent(out) << " unset" << get_cap_name(field_name) << "();" << endl; - indent(out) << "} else {" << endl; + indent(out) << "if (value == null) {" << '\n'; + indent(out) << " unset" << get_cap_name(field_name) << "();" << '\n'; + indent(out) << "} else {" << '\n'; if (is_binary) { indent_up(); - indent(out) << "if (value instanceof byte[]) {" << endl; - indent(out) << " set" << cap_name << "((byte[])value);" << endl; - indent(out) << "} else {" << endl; + indent(out) << "if (value instanceof byte[]) {" << '\n'; + indent(out) << " set" << cap_name << "((byte[])value);" << '\n'; + indent(out) << "} else {" << '\n'; } - indent(out) << " set" << cap_name << "((" << type_name(type, true, false) << ")value);" << endl; + indent(out) << " set" << cap_name << "((" << type_name(type, true, false) << ")value);" << '\n'; if (is_binary) { - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); } - indent(out) << "}" << endl; - indent(out) << "break;" << endl << endl; + indent(out) << "}" << '\n'; + indent(out) << "break;" << '\n' << '\n'; indent_down(); } @@ -2370,25 +2367,25 @@ void t_java_generator::generate_generic_field_getters_setters(std::ostream& out, // create the setter - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "public void setFieldValue(_Fields field, " << java_nullable_annotation() - << " java.lang.Object value) {" << endl; - indent(out) << " switch (field) {" << endl; + << " java.lang.Object value) {" << '\n'; + indent(out) << " switch (field) {" << '\n'; out << setter_stream.str(); - indent(out) << " }" << endl; - indent(out) << "}" << endl << endl; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n' << '\n'; // create the getter - indent(out) << java_nullable_annotation() << endl; - indent(out) << java_override_annotation() << endl; - indent(out) << "public java.lang.Object getFieldValue(_Fields field) {" << endl; + indent(out) << java_nullable_annotation() << '\n'; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public java.lang.Object getFieldValue(_Fields field) {" << '\n'; indent_up(); - indent(out) << "switch (field) {" << endl; + indent(out) << "switch (field) {" << '\n'; out << getter_stream.str(); - indent(out) << "}" << endl; - indent(out) << "throw new java.lang.IllegalStateException();" << endl; + indent(out) << "}" << '\n'; + indent(out) << "throw new java.lang.IllegalStateException();" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } // Creates a generic isSet method that takes the field number as argument @@ -2399,28 +2396,28 @@ void t_java_generator::generate_generic_isset_method(std::ostream& out, t_struct // create the isSet method indent(out) << "/** Returns true if field corresponding to fieldID is set (has been assigned a " "value) and false otherwise */" - << endl; - indent(out) << java_override_annotation() << endl; - indent(out) << "public boolean isSet(_Fields field) {" << endl; + << '\n'; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public boolean isSet(_Fields field) {" << '\n'; indent_up(); - indent(out) << "if (field == null) {" << endl; - indent(out) << " throw new java.lang.IllegalArgumentException();" << endl; - indent(out) << "}" << endl << endl; + indent(out) << "if (field == null) {" << '\n'; + indent(out) << " throw new java.lang.IllegalArgumentException();" << '\n'; + indent(out) << "}" << '\n' << '\n'; - indent(out) << "switch (field) {" << endl; + indent(out) << "switch (field) {" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_field* field = *f_iter; - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; indent_up(); - indent(out) << "return " << generate_isset_check(field) << ";" << endl; + indent(out) << "return " << generate_isset_check(field) << ";" << '\n'; indent_down(); } - indent(out) << "}" << endl; - indent(out) << "throw new java.lang.IllegalStateException();" << endl; + indent(out) << "}" << '\n'; + indent(out) << "throw new java.lang.IllegalStateException();" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -2445,7 +2442,7 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts // Method to return the size of the collection if (optional) { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } if (use_jdk8_option_type_) { @@ -2454,20 +2451,20 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts indent(out) << "public " << thrift_option_class << " get" << cap_name; } - out << get_cap_name("size() {") << endl; + out << get_cap_name("size() {") << '\n'; indent_up(); - indent(out) << "if (this." << field_name << " == null) {" << endl; + indent(out) << "if (this." << field_name << " == null) {" << '\n'; indent_up(); if (use_jdk8_option_type_) { - indent(out) << "return " << jdk_option_class << ".empty();" << endl; + indent(out) << "return " << jdk_option_class << ".empty();" << '\n'; } else { - indent(out) << "return " << thrift_option_class << ".none();" << endl; + indent(out) << "return " << thrift_option_class << ".none();" << '\n'; } indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent_up(); if (use_jdk8_option_type_) { @@ -2475,24 +2472,24 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts } else { indent(out) << "return " << thrift_option_class << ".some(this."; } - out << field_name << ".size());" << endl; + out << field_name << ".size());" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } else { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } indent(out) << "public int get" << cap_name; - out << get_cap_name("size() {") << endl; + out << get_cap_name("size() {") << '\n'; indent_up(); indent(out) << "return (this." << field_name << " == null) ? 0 : " - << "this." << field_name << ".size();" << endl; + << "this." << field_name << ".size();" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } } @@ -2507,7 +2504,7 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts // Iterator getter for sets and lists if (optional) { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } if (use_jdk8_option_type_) { @@ -2518,20 +2515,20 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts out << "java.util.Iterator<" << type_name(element_type, true, false) << ">> get" << cap_name; - out << get_cap_name("iterator() {") << endl; + out << get_cap_name("iterator() {") << '\n'; indent_up(); - indent(out) << "if (this." << field_name << " == null) {" << endl; + indent(out) << "if (this." << field_name << " == null) {" << '\n'; indent_up(); if (use_jdk8_option_type_) { - indent(out) << "return " << jdk_option_class << ".empty();" << endl; + indent(out) << "return " << jdk_option_class << ".empty();" << '\n'; } else { - indent(out) << "return " << thrift_option_class << ".none();" << endl; + indent(out) << "return " << thrift_option_class << ".none();" << '\n'; } indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent_up(); if (use_jdk8_option_type_) { @@ -2539,104 +2536,104 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts } else { indent(out) << "return " << thrift_option_class << ".some(this."; } - out << field_name << ".iterator());" << endl; + out << field_name << ".iterator());" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } else { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } - indent(out) << java_nullable_annotation() << endl; + indent(out) << java_nullable_annotation() << '\n'; indent(out) << "public java.util.Iterator<" << type_name(element_type, true, false) << "> get" << cap_name; - out << get_cap_name("iterator() {") << endl; + out << get_cap_name("iterator() {") << '\n'; indent_up(); indent(out) << "return (this." << field_name << " == null) ? null : " - << "this." << field_name << ".iterator();" << endl; + << "this." << field_name << ".iterator();" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } // Add to set or list, create if the set/list is null if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } indent(out) << "public void add" << get_cap_name("to"); - out << cap_name << "(" << type_name(element_type) << " elem) {" << endl; + out << cap_name << "(" << type_name(element_type) << " elem) {" << '\n'; indent_up(); - indent(out) << "if (this." << field_name << " == null) {" << endl; + indent(out) << "if (this." << field_name << " == null) {" << '\n'; indent_up(); indent(out) << "this." << field_name; if (is_enum_set(type)) { out << " = " << type_name(type, false, true, true) << ".noneOf(" - << inner_enum_type_name(type) << ");" << endl; + << inner_enum_type_name(type) << ");" << '\n'; } else { - out << " = new " << type_name(type, false, true) << "();" << endl; + out << " = new " << type_name(type, false, true) << "();" << '\n'; } indent_down(); - indent(out) << "}" << endl; - indent(out) << "this." << field_name << ".add(elem);" << endl; + indent(out) << "}" << '\n'; + indent(out) << "this." << field_name << ".add(elem);" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } else if (type->is_map()) { // Put to map t_type* key_type = ((t_map*)type)->get_key_type(); t_type* val_type = ((t_map*)type)->get_val_type(); if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } indent(out) << "public void put" << get_cap_name("to"); out << cap_name << "(" << type_name(key_type) << " key, " << type_name(val_type) << " val) {" - << endl; + << '\n'; indent_up(); - indent(out) << "if (this." << field_name << " == null) {" << endl; + indent(out) << "if (this." << field_name << " == null) {" << '\n'; indent_up(); std::string constructor_args; if (is_enum_map(type)) { constructor_args = inner_enum_type_name(type); } indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "(" - << constructor_args << ");" << endl; + << constructor_args << ");" << '\n'; indent_down(); - indent(out) << "}" << endl; - indent(out) << "this." << field_name << ".put(key, val);" << endl; + indent(out) << "}" << '\n'; + indent(out) << "this." << field_name << ".put(key, val);" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } // Simple getter generate_java_doc(out, field); if (type->is_binary()) { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } - indent(out) << "public byte[] get" << cap_name << "() {" << endl; + indent(out) << "public byte[] get" << cap_name << "() {" << '\n'; indent(out) << " set" << cap_name << "(org.apache.thrift.TBaseHelper.rightSize(" - << field_name << "));" << endl; + << field_name << "));" << '\n'; indent(out) << " return " << field_name << " == null ? null : " << field_name << ".array();" - << endl; - indent(out) << "}" << endl << endl; + << '\n'; + indent(out) << "}" << '\n' << '\n'; indent(out) << "public java.nio.ByteBuffer buffer" << get_cap_name("for") << cap_name - << "() {" << endl; + << "() {" << '\n'; if (unsafe_binaries_) { - indent(out) << " return " << field_name << ";" << endl; + indent(out) << " return " << field_name << ";" << '\n'; } else { indent(out) << " return org.apache.thrift.TBaseHelper.copyBinary(" << field_name << ");" - << endl; + << '\n'; } - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } else { if (optional) { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } if (use_jdk8_option_type_) { @@ -2650,10 +2647,10 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts } else { out << " get"; } - out << cap_name << "() {" << endl; + out << cap_name << "() {" << '\n'; indent_up(); - indent(out) << "if (this.isSet" << cap_name << "()) {" << endl; + indent(out) << "if (this.isSet" << cap_name << "()) {" << '\n'; indent_up(); if (use_jdk8_option_type_) { @@ -2661,28 +2658,28 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts } else { indent(out) << "return " << thrift_option_class << ".some(this."; } - out << field_name << ");" << endl; + out << field_name << ");" << '\n'; indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent_up(); if (use_jdk8_option_type_) { - indent(out) << "return " << jdk_option_class << ".empty();" << endl; + indent(out) << "return " << jdk_option_class << ".empty();" << '\n'; } else { - indent(out) << "return " << thrift_option_class << ".none();" << endl; + indent(out) << "return " << thrift_option_class << ".none();" << '\n'; } indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } else { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } if (type_can_be_null(type)) { - indent(out) << java_nullable_annotation() << endl; + indent(out) << java_nullable_annotation() << '\n'; } indent(out) << "public " << type_name(type); if (type->is_base_type() && ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) { @@ -2690,11 +2687,11 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts } else { out << " get"; } - out << cap_name << "() {" << endl; + out << cap_name << "() {" << '\n'; indent_up(); - indent(out) << "return this." << make_valid_java_identifier(field_name) << ";" << endl; + indent(out) << "return this." << make_valid_java_identifier(field_name) << ";" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } } @@ -2702,7 +2699,7 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts generate_java_doc(out, field); if (type->is_binary()) { if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } indent(out) << "public "; if (bean_style_) { @@ -2710,23 +2707,23 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts } else { out << type_name(tstruct); } - out << " set" << cap_name << "(byte[] " << make_valid_java_identifier(field_name) << ") {" << endl; + out << " set" << cap_name << "(byte[] " << make_valid_java_identifier(field_name) << ") {" << '\n'; indent(out) << " this." << make_valid_java_identifier(field_name) << " = " << make_valid_java_identifier(field_name) << " == null ? (java.nio.ByteBuffer)null"; if (unsafe_binaries_) { - indent(out) << " : java.nio.ByteBuffer.wrap(" << make_valid_java_identifier(field_name) << ");" << endl; + indent(out) << " : java.nio.ByteBuffer.wrap(" << make_valid_java_identifier(field_name) << ");" << '\n'; } else { - indent(out) << " : java.nio.ByteBuffer.wrap(" << make_valid_java_identifier(field_name) << ".clone());" << endl; + indent(out) << " : java.nio.ByteBuffer.wrap(" << make_valid_java_identifier(field_name) << ".clone());" << '\n'; } if (!bean_style_) { - indent(out) << " return this;" << endl; + indent(out) << " return this;" << '\n'; } - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } indent(out) << "public "; if (bean_style_) { @@ -2737,7 +2734,7 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts out << " set" << cap_name << "(" << (type_can_be_null(type) ? (java_nullable_annotation() + " ") : "") << type_name(type) - << " " << make_valid_java_identifier(field_name) << ") {" << endl; + << " " << make_valid_java_identifier(field_name) << ") {" << '\n'; indent_up(); indent(out) << "this." << make_valid_java_identifier(field_name) << " = "; if (type->is_binary() && !unsafe_binaries_) { @@ -2745,70 +2742,70 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts } else { out << make_valid_java_identifier(field_name); } - out << ";" << endl; + out << ";" << '\n'; generate_isset_set(out, field, ""); if (!bean_style_) { - indent(out) << "return this;" << endl; + indent(out) << "return this;" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // Unsetter if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } - indent(out) << "public void unset" << cap_name << "() {" << endl; + indent(out) << "public void unset" << cap_name << "() {" << '\n'; indent_up(); if (type_can_be_null(type)) { - indent(out) << "this." << make_valid_java_identifier(field_name) << " = null;" << endl; + indent(out) << "this." << make_valid_java_identifier(field_name) << " = null;" << '\n'; } else if (issetType == ISSET_PRIMITIVE) { indent(out) << "__isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, " - << isset_field_id(field) << ");" << endl; + << isset_field_id(field) << ");" << '\n'; } else { - indent(out) << "__isset_bit_vector.clear(" << isset_field_id(field) << ");" << endl; + indent(out) << "__isset_bit_vector.clear(" << isset_field_id(field) << ");" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // isSet method indent(out) << "/** Returns true if field " << field_name - << " is set (has been assigned a value) and false otherwise */" << endl; + << " is set (has been assigned a value) and false otherwise */" << '\n'; if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } - indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << endl; + indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << '\n'; indent_up(); if (type_can_be_null(type)) { - indent(out) << "return this." << make_valid_java_identifier(field_name) << " != null;" << endl; + indent(out) << "return this." << make_valid_java_identifier(field_name) << " != null;" << '\n'; } else if (issetType == ISSET_PRIMITIVE) { indent(out) << "return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, " - << isset_field_id(field) << ");" << endl; + << isset_field_id(field) << ");" << '\n'; } else { - indent(out) << "return __isset_bit_vector.get(" << isset_field_id(field) << ");" << endl; + indent(out) << "return __isset_bit_vector.get(" << isset_field_id(field) << ");" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; if (is_deprecated) { - indent(out) << "@Deprecated" << endl; + indent(out) << "@Deprecated" << '\n'; } indent(out) << "public void set" << cap_name << get_cap_name("isSet") << "(boolean value) {" - << endl; + << '\n'; indent_up(); if (type_can_be_null(type)) { - indent(out) << "if (!value) {" << endl; - indent(out) << " this." << make_valid_java_identifier(field_name) << " = null;" << endl; - indent(out) << "}" << endl; + indent(out) << "if (!value) {" << '\n'; + indent(out) << " this." << make_valid_java_identifier(field_name) << " = null;" << '\n'; + indent(out) << "}" << '\n'; } else if (issetType == ISSET_PRIMITIVE) { indent(out) << "__isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, " - << isset_field_id(field) << ", value);" << endl; + << isset_field_id(field) << ", value);" << '\n'; } else { - indent(out) << "__isset_bit_vector.set(" << isset_field_id(field) << ", value);" << endl; + indent(out) << "__isset_bit_vector.set(" << isset_field_id(field) << ", value);" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } } @@ -2818,13 +2815,13 @@ void t_java_generator::generate_java_bean_boilerplate(ostream& out, t_struct* ts * @param tstruct The struct definition */ void t_java_generator::generate_java_struct_tostring(ostream& out, t_struct* tstruct) { - out << indent() << java_override_annotation() << endl - << indent() << "public java.lang.String toString() {" << endl; + out << indent() << java_override_annotation() << '\n' + << indent() << "public java.lang.String toString() {" << '\n'; indent_up(); out << indent() << "java.lang.StringBuilder sb = new java.lang.StringBuilder(\"" - << tstruct->get_name() << "(\");" << endl; - out << indent() << "boolean first = true;" << endl << endl; + << tstruct->get_name() << "(\");" << '\n'; + out << indent() << "boolean first = true;" << '\n' << '\n'; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -2832,55 +2829,55 @@ void t_java_generator::generate_java_struct_tostring(ostream& out, t_struct* tst for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL; if (could_be_unset) { - indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl; + indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << '\n'; indent_up(); } t_field* field = (*f_iter); if (!first) { - indent(out) << "if (!first) sb.append(\", \");" << endl; + indent(out) << "if (!first) sb.append(\", \");" << '\n'; } - indent(out) << "sb.append(\"" << (*f_iter)->get_name() << ":\");" << endl; + indent(out) << "sb.append(\"" << (*f_iter)->get_name() << ":\");" << '\n'; bool can_be_null = type_can_be_null(field->get_type()); if (can_be_null) { - indent(out) << "if (this." << make_valid_java_identifier((*f_iter)->get_name()) << " == null) {" << endl; - indent(out) << " sb.append(\"null\");" << endl; - indent(out) << "} else {" << endl; + indent(out) << "if (this." << make_valid_java_identifier((*f_iter)->get_name()) << " == null) {" << '\n'; + indent(out) << " sb.append(\"null\");" << '\n'; + indent(out) << "} else {" << '\n'; indent_up(); } if (get_true_type(field->get_type())->is_binary()) { indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << make_valid_java_identifier(field->get_name()) << ", sb);" - << endl; + << '\n'; } else if ((field->get_type()->is_set()) && (get_true_type(((t_set*)field->get_type())->get_elem_type())->is_binary())) { indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << make_valid_java_identifier(field->get_name()) << ", sb);" - << endl; + << '\n'; } else if ((field->get_type()->is_list()) && (get_true_type(((t_list*)field->get_type())->get_elem_type())->is_binary())) { indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << make_valid_java_identifier(field->get_name()) << ", sb);" - << endl; + << '\n'; } else { - indent(out) << "sb.append(this." << make_valid_java_identifier((*f_iter)->get_name()) << ");" << endl; + indent(out) << "sb.append(this." << make_valid_java_identifier((*f_iter)->get_name()) << ");" << '\n'; } if (can_be_null) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - indent(out) << "first = false;" << endl; + indent(out) << "first = false;" << '\n'; if (could_be_unset) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } first = false; } - out << indent() << "sb.append(\")\");" << endl << indent() << "return sb.toString();" << endl; + out << indent() << "sb.append(\")\");" << '\n' << indent() << "return sb.toString();" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -2896,14 +2893,14 @@ void t_java_generator::generate_java_meta_data_map(ostream& out, t_struct* tstru // Static Map with fieldID -> org.apache.thrift.meta_data.FieldMetaData mappings indent(out) << "public static final java.util.Map<_Fields, " "org.apache.thrift.meta_data.FieldMetaData> metaDataMap;" - << endl; - indent(out) << "static {" << endl; + << '\n'; + indent(out) << "static {" << '\n'; indent_up(); indent(out) << "java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new " "java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);" - << endl; + << '\n'; // Populate map for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { @@ -2928,15 +2925,15 @@ void t_java_generator::generate_java_meta_data_map(ostream& out, t_struct* tstru if (annotations_as_metadata_) { generate_metadata_for_field_annotations(out, field); } - out << "));" << endl; + out << "));" << '\n'; } - indent(out) << "metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);" << endl; + indent(out) << "metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);" << '\n'; indent(out) << "org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(" - << type_name(tstruct) << ".class, metaDataMap);" << endl; + << type_name(tstruct) << ".class, metaDataMap);" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -3003,19 +3000,19 @@ void t_java_generator::generate_metadata_for_field_annotations(std::ostream& out if (field->annotations_.size() == 0) { return; } - out << ", " << endl; + out << ", " << '\n'; indent_up(); indent_up(); indent(out) << "java.util.stream.Stream.>builder()" - << endl; + << '\n'; indent_up(); indent_up(); for (auto& annotation : field->annotations_) { indent(out) << ".add(new java.util.AbstractMap.SimpleImmutableEntry<>(\"" + annotation.first + "\", \"" + annotation.second.back() + "\"))" - << endl; + << '\n'; } indent(out) << ".build().collect(java.util.stream.Collectors.toMap(java.util.Map.Entry::getKey, " "java.util.Map.Entry::getValue))"; @@ -3028,7 +3025,7 @@ void t_java_generator::generate_metadata_for_field_annotations(std::ostream& out void t_java_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) { t_type* ttype = get_true_type(type); - out << endl; + out << '\n'; indent_up(); indent_up(); if (ttype->is_struct() || ttype->is_xception()) { @@ -3093,7 +3090,7 @@ void t_java_generator::generate_service(t_service* tservice) { generate_javax_generated_annotation(f_service_); } f_service_ << java_suppressions(); - f_service_ << "public class " << make_valid_java_identifier(service_name_) << " {" << endl << endl; + f_service_ << "public class " << make_valid_java_identifier(service_name_) << " {" << '\n' << '\n'; indent_up(); // Generate the three main parts of the service @@ -3112,7 +3109,7 @@ void t_java_generator::generate_service(t_service* tservice) { generate_service_helpers(tservice); indent_down(); - f_service_ << "}" << endl; + f_service_ << "}" << '\n'; f_service_.close(); } @@ -3130,16 +3127,16 @@ void t_java_generator::generate_service_interface(t_service* tservice) { } generate_java_doc(f_service_, tservice); - f_service_ << indent() << "public interface Iface" << extends_iface << " {" << endl << endl; + f_service_ << indent() << "public interface Iface" << extends_iface << " {" << '\n' << '\n'; indent_up(); vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_java_doc(f_service_, *f_iter); - indent(f_service_) << "public " << function_signature(*f_iter) << ";" << endl << endl; + indent(f_service_) << "public " << function_signature(*f_iter) << ";" << '\n' << '\n'; } indent_down(); - f_service_ << indent() << "}" << endl << endl; + f_service_ << indent() << "}" << '\n' << '\n'; } void t_java_generator::generate_service_async_interface(t_service* tservice) { @@ -3150,17 +3147,17 @@ void t_java_generator::generate_service_async_interface(t_service* tservice) { extends_iface = " extends " + extends + ".AsyncIface"; } - f_service_ << indent() << "public interface AsyncIface" << extends_iface << " {" << endl << endl; + f_service_ << indent() << "public interface AsyncIface" << extends_iface << " {" << '\n' << '\n'; indent_up(); vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { indent(f_service_) << "public " << function_signature_async(*f_iter, true) - << " throws org.apache.thrift.TException;" << endl - << endl; + << " throws org.apache.thrift.TException;" << '\n' + << '\n'; } indent_down(); - f_service_ << indent() << "}" << endl << endl; + f_service_ << indent() << "}" << '\n' << '\n'; } void t_java_generator::generate_service_future_interface(t_service* tservice) { @@ -3171,15 +3168,15 @@ void t_java_generator::generate_service_future_interface(t_service* tservice) { extends_iface = " extends " + extends + " .FutureIface"; } - f_service_ << indent() << "public interface FutureIface" << extends_iface << " {" << endl << endl; + f_service_ << indent() << "public interface FutureIface" << extends_iface << " {" << '\n' << '\n'; indent_up(); for (auto tfunc : tservice->get_functions()) { indent(f_service_) << "public " << function_signature_future(tfunc) - << " throws org.apache.thrift.TException;" << endl - << endl; + << " throws org.apache.thrift.TException;" << '\n' + << '\n'; } scope_down(f_service_); - f_service_ << endl << endl; + f_service_ << '\n' << '\n'; } /** @@ -3209,43 +3206,43 @@ void t_java_generator::generate_service_client(t_service* tservice) { } indent(f_service_) << "public static class Client extends " << extends_client - << " implements Iface {" << endl; + << " implements Iface {" << '\n'; indent_up(); indent(f_service_) << "public static class Factory implements org.apache.thrift.TServiceClientFactory {" - << endl; + << '\n'; indent_up(); - indent(f_service_) << "public Factory() {}" << endl; - indent(f_service_) << java_override_annotation() << endl; + indent(f_service_) << "public Factory() {}" << '\n'; + indent(f_service_) << java_override_annotation() << '\n'; indent(f_service_) << "public Client getClient(org.apache.thrift.protocol.TProtocol prot) {" - << endl; + << '\n'; indent_up(); - indent(f_service_) << "return new Client(prot);" << endl; + indent(f_service_) << "return new Client(prot);" << '\n'; indent_down(); - indent(f_service_) << "}" << endl; - indent(f_service_) << java_override_annotation() << endl; + indent(f_service_) << "}" << '\n'; + indent(f_service_) << java_override_annotation() << '\n'; indent(f_service_) << "public Client getClient(org.apache.thrift.protocol.TProtocol iprot, " "org.apache.thrift.protocol.TProtocol oprot) {" - << endl; + << '\n'; indent_up(); - indent(f_service_) << "return new Client(iprot, oprot);" << endl; + indent(f_service_) << "return new Client(iprot, oprot);" << '\n'; indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << "public Client(org.apache.thrift.protocol.TProtocol prot)" << endl; + indent(f_service_) << "public Client(org.apache.thrift.protocol.TProtocol prot)" << '\n'; scope_up(f_service_); - indent(f_service_) << "super(prot, prot);" << endl; + indent(f_service_) << "super(prot, prot);" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; indent(f_service_) << "public Client(org.apache.thrift.protocol.TProtocol iprot, " "org.apache.thrift.protocol.TProtocol oprot) {" - << endl; - indent(f_service_) << " super(iprot, oprot);" << endl; - indent(f_service_) << "}" << endl << endl; + << '\n'; + indent(f_service_) << " super(iprot, oprot);" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; // Generate client method implementations vector functions = tservice->get_functions(); @@ -3260,8 +3257,8 @@ void t_java_generator::generate_service_client(t_service* tservice) { } // Open function - indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "public " << function_signature(*f_iter) << endl; + indent(f_service_) << java_override_annotation() << '\n'; + indent(f_service_) << "public " << function_signature(*f_iter) << '\n'; scope_up(f_service_); indent(f_service_) << "send" << sep << javaname << "("; @@ -3280,17 +3277,17 @@ void t_java_generator::generate_service_client(t_service* tservice) { } f_service_ << make_valid_java_identifier((*fld_iter)->get_name()); } - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; if (!(*f_iter)->is_oneway()) { f_service_ << indent(); if (!(*f_iter)->get_returntype()->is_void()) { f_service_ << "return "; } - f_service_ << "recv" << sep << javaname << "();" << endl; + f_service_ << "recv" << sep << javaname << "();" << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; t_function send_function(g_type_void, string("send") + sep + javaname, (*f_iter)->get_arglist()); @@ -3298,22 +3295,22 @@ void t_java_generator::generate_service_client(t_service* tservice) { string argsname = (*f_iter)->get_name() + "_args"; // Open function - indent(f_service_) << "public " << function_signature(&send_function) << endl; + indent(f_service_) << "public " << function_signature(&send_function) << '\n'; scope_up(f_service_); // Serialize the request - indent(f_service_) << argsname << " args = new " << argsname << "();" << endl; + indent(f_service_) << argsname << " args = new " << argsname << "();" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { indent(f_service_) << "args.set" << get_cap_name((*fld_iter)->get_name()) << "(" - << make_valid_java_identifier((*fld_iter)->get_name()) << ");" << endl; + << make_valid_java_identifier((*fld_iter)->get_name()) << ");" << '\n'; } const string sendBaseName = (*f_iter)->is_oneway() ? "sendBaseOneway" : "sendBase"; - indent(f_service_) << sendBaseName << "(\"" << funname << "\", args);" << endl; + indent(f_service_) << sendBaseName << "(\"" << funname << "\", args);" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; if (!(*f_iter)->is_oneway()) { string resultname = (*f_iter)->get_name() + "_result"; @@ -3322,47 +3319,47 @@ void t_java_generator::generate_service_client(t_service* tservice) { t_function recv_function((*f_iter)->get_returntype(), string("recv") + sep + javaname, &noargs, (*f_iter)->get_xceptions()); // Open function - indent(f_service_) << "public " << function_signature(&recv_function) << endl; + indent(f_service_) << "public " << function_signature(&recv_function) << '\n'; scope_up(f_service_); - f_service_ << indent() << resultname << " result = new " << resultname << "();" << endl - << indent() << "receiveBase(result, \"" << funname << "\");" << endl; + f_service_ << indent() << resultname << " result = new " << resultname << "();" << '\n' + << indent() << "receiveBase(result, \"" << funname << "\");" << '\n'; // Careful, only return _result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { - f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << endl - << indent() << " return result.success;" << endl - << indent() << "}" << endl; + f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << '\n' + << indent() << " return result.success;" << '\n' + << indent() << "}" << '\n'; } t_struct* xs = (*f_iter)->get_xceptions(); const std::vector& xceptions = xs->get_members(); vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { - f_service_ << indent() << "if (result." << make_valid_java_identifier((*x_iter)->get_name()) << " != null) {" << endl - << indent() << " throw result." << make_valid_java_identifier((*x_iter)->get_name()) << ";" << endl - << indent() << "}" << endl; + f_service_ << indent() << "if (result." << make_valid_java_identifier((*x_iter)->get_name()) << " != null) {" << '\n' + << indent() << " throw result." << make_valid_java_identifier((*x_iter)->get_name()) << ";" << '\n' + << indent() << "}" << '\n'; } // If you get here it's an exception, unless a void function if ((*f_iter)->get_returntype()->is_void()) { - indent(f_service_) << "return;" << endl; + indent(f_service_) << "return;" << '\n'; } else { f_service_ << indent() << "throw new " "org.apache.thrift.TApplicationException(org.apache.thrift." "TApplicationException.MISSING_RESULT, \"" - << (*f_iter)->get_name() << " failed: unknown result\");" << endl; + << (*f_iter)->get_name() << " failed: unknown result\");" << '\n'; } // Close function scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } } indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } void t_java_generator::generate_service_future_client(t_service* tservice) { @@ -3373,13 +3370,13 @@ void t_java_generator::generate_service_future_client(t_service* tservice) { static string adapter_class = "org.apache.thrift.async.AsyncMethodFutureAdapter"; indent(f_service_) << "public static class FutureClient " << extends_client - << "implements FutureIface {" << endl; + << "implements FutureIface {" << '\n'; indent_up(); - indent(f_service_) << "public FutureClient(AsyncIface delegate) {" << endl; + indent(f_service_) << "public FutureClient(AsyncIface delegate) {" << '\n'; indent_up(); - indent(f_service_) << "this.delegate = delegate;" << endl; + indent(f_service_) << "this.delegate = delegate;" << '\n'; scope_down(f_service_); - indent(f_service_) << "private final AsyncIface delegate;" << endl; + indent(f_service_) << "private final AsyncIface delegate;" << '\n'; for (auto tfunc : tservice->get_functions()) { string funname = tfunc->get_name(); string sep = "_"; @@ -3396,23 +3393,23 @@ void t_java_generator::generate_service_future_client(t_service* tservice) { string args_name = funname + "_args"; string result_name = funname + "_result"; - indent(f_service_) << "@Override" << endl; + indent(f_service_) << "@Override" << '\n'; indent(f_service_) << "public " << function_signature_future(tfunc) - << " throws org.apache.thrift.TException {" << endl; + << " throws org.apache.thrift.TException {" << '\n'; indent_up(); auto adapter = tmp("asyncMethodFutureAdapter"); indent(f_service_) << adapter_class << "<" << ret_type_name << "> " << adapter << " = " - << adapter_class << ".<" << ret_type_name << ">create();" << endl; + << adapter_class << ".<" << ret_type_name << ">create();" << '\n'; bool empty_args = tfunc->get_arglist()->get_members().empty(); indent(f_service_) << "delegate." << get_rpc_method_name(funname) << "(" << argument_list(tfunc->get_arglist(), false) << (empty_args ? "" : ", ") - << adapter << ");" << endl; - indent(f_service_) << "return " << adapter << ".getFuture();" << endl; + << adapter << ");" << '\n'; + indent(f_service_) << "return " << adapter << ".getFuture();" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } void t_java_generator::generate_service_async_client(t_service* tservice) { @@ -3422,41 +3419,41 @@ void t_java_generator::generate_service_async_client(t_service* tservice) { } indent(f_service_) << "public static class AsyncClient extends " << extends_client - << " implements AsyncIface {" << endl; + << " implements AsyncIface {" << '\n'; indent_up(); // Factory method indent(f_service_) << "public static class Factory implements " "org.apache.thrift.async.TAsyncClientFactory {" - << endl; + << '\n'; indent(f_service_) << " private org.apache.thrift.async.TAsyncClientManager clientManager;" - << endl; + << '\n'; indent(f_service_) << " private org.apache.thrift.protocol.TProtocolFactory protocolFactory;" - << endl; + << '\n'; indent(f_service_) << " public Factory(org.apache.thrift.async.TAsyncClientManager " "clientManager, org.apache.thrift.protocol.TProtocolFactory " "protocolFactory) {" - << endl; - indent(f_service_) << " this.clientManager = clientManager;" << endl; - indent(f_service_) << " this.protocolFactory = protocolFactory;" << endl; - indent(f_service_) << " }" << endl; - indent(f_service_) << java_override_annotation() << endl; + << '\n'; + indent(f_service_) << " this.clientManager = clientManager;" << '\n'; + indent(f_service_) << " this.protocolFactory = protocolFactory;" << '\n'; + indent(f_service_) << " }" << '\n'; + indent(f_service_) << java_override_annotation() << '\n'; indent(f_service_) << " public AsyncClient " "getAsyncClient(org.apache.thrift.transport.TNonblockingTransport " "transport) {" - << endl; + << '\n'; indent(f_service_) << " return new AsyncClient(protocolFactory, clientManager, transport);" - << endl; - indent(f_service_) << " }" << endl; - indent(f_service_) << "}" << endl << endl; + << '\n'; + indent(f_service_) << " }" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; indent(f_service_) << "public AsyncClient(org.apache.thrift.protocol.TProtocolFactory " "protocolFactory, org.apache.thrift.async.TAsyncClientManager " "clientManager, org.apache.thrift.transport.TNonblockingTransport " "transport) {" - << endl; - indent(f_service_) << " super(protocolFactory, clientManager, transport);" << endl; - indent(f_service_) << "}" << endl << endl; + << '\n'; + indent(f_service_) << " super(protocolFactory, clientManager, transport);" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; // Generate client method implementations vector functions = tservice->get_functions(); @@ -3479,35 +3476,35 @@ void t_java_generator::generate_service_async_client(t_service* tservice) { string result_name = (*f_iter)->get_name() + "_result"; // Main method body - indent(f_service_) << java_override_annotation() << endl; + indent(f_service_) << java_override_annotation() << '\n'; indent(f_service_) << "public " << function_signature_async(*f_iter, false) - << " throws org.apache.thrift.TException {" << endl; - indent(f_service_) << " checkReady();" << endl; + << " throws org.apache.thrift.TException {" << '\n'; + indent(f_service_) << " checkReady();" << '\n'; indent(f_service_) << " " << funclassname << " method_call = new " + funclassname + "(" << async_argument_list(*f_iter, arg_struct, ret_type) - << ", this, ___protocolFactory, ___transport);" << endl; - indent(f_service_) << " this.___currentMethod = method_call;" << endl; - indent(f_service_) << " ___manager.call(method_call);" << endl; - indent(f_service_) << "}" << endl; + << ", this, ___protocolFactory, ___transport);" << '\n'; + indent(f_service_) << " this.___currentMethod = method_call;" << '\n'; + indent(f_service_) << " ___manager.call(method_call);" << '\n'; + indent(f_service_) << "}" << '\n'; - f_service_ << endl; + f_service_ << '\n'; // TAsyncMethod object for this function call indent(f_service_) << "public static class " + funclassname + " extends org.apache.thrift.async.TAsyncMethodCall<" + type_name((*f_iter)->get_returntype(), true) + "> {" - << endl; + << '\n'; indent_up(); // Member variables for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { indent(f_service_) << "private " + type_name((*fld_iter)->get_type()) + " " + make_valid_java_identifier((*fld_iter)->get_name()) + ";" - << endl; + << '\n'; } // NOTE since we use a new Client instance to deserialize, let's keep seqid to 0 for now - // indent(f_service_) << "private int seqid;" << endl << endl; + // indent(f_service_) << "private int seqid;" << '\n' << '\n'; // Constructor indent(f_service_) << "public " + funclassname + "(" @@ -3516,22 +3513,22 @@ void t_java_generator::generate_service_async_client(t_service* tservice) { "org.apache.thrift.protocol.TProtocolFactory protocolFactory, " "org.apache.thrift.transport.TNonblockingTransport transport) throws " "org.apache.thrift.TException {" - << endl; + << '\n'; indent(f_service_) << " super(client, protocolFactory, transport, resultHandler, " - << ((*f_iter)->is_oneway() ? "true" : "false") << ");" << endl; + << ((*f_iter)->is_oneway() ? "true" : "false") << ");" << '\n'; // Assign member variables for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { indent(f_service_) << " this." + make_valid_java_identifier((*fld_iter)->get_name()) + " = " + make_valid_java_identifier((*fld_iter)->get_name()) + ";" - << endl; + << '\n'; } - indent(f_service_) << "}" << endl << endl; - indent(f_service_) << java_override_annotation() << endl; + indent(f_service_) << "}" << '\n' << '\n'; + indent(f_service_) << java_override_annotation() << '\n'; indent(f_service_) << "public void write_args(org.apache.thrift.protocol.TProtocol prot) " "throws org.apache.thrift.TException {" - << endl; + << '\n'; indent_up(); // Serialize request @@ -3539,68 +3536,68 @@ void t_java_generator::generate_service_async_client(t_service* tservice) { f_service_ << indent() << "prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage(\"" << funname << "\", org.apache.thrift.protocol." << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL") << ", 0));" - << endl - << indent() << args_name << " args = new " << args_name << "();" << endl; + << '\n' + << indent() << args_name << " args = new " << args_name << "();" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_service_ << indent() << "args.set" << get_cap_name((*fld_iter)->get_name()) << "(" - << make_valid_java_identifier((*fld_iter)->get_name()) << ");" << endl; + << make_valid_java_identifier((*fld_iter)->get_name()) << ");" << '\n'; } - f_service_ << indent() << "args.write(prot);" << endl - << indent() << "prot.writeMessageEnd();" << endl; + f_service_ << indent() << "args.write(prot);" << '\n' + << indent() << "prot.writeMessageEnd();" << '\n'; indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; // Return method - indent(f_service_) << java_override_annotation() << endl; + indent(f_service_) << java_override_annotation() << '\n'; indent(f_service_) << "public " + type_name(ret_type, true) + " getResult() throws "; vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << type_name((*x_iter)->get_type(), false, false) + ", "; } - f_service_ << "org.apache.thrift.TException {" << endl; + f_service_ << "org.apache.thrift.TException {" << '\n'; indent_up(); f_service_ << indent() << "if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {" - << endl + << '\n' << indent() << " throw new java.lang.IllegalStateException(\"Method call not finished!\");" - << endl - << indent() << "}" << endl + << '\n' + << indent() << "}" << '\n' << indent() << "org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new " "org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());" - << endl + << '\n' << indent() << "org.apache.thrift.protocol.TProtocol prot = " "client.getProtocolFactory().getProtocol(memoryTransport);" - << endl; + << '\n'; indent(f_service_); if (ret_type->is_void()) { // NB: Includes oneways which always return void. if (!(*f_iter)->is_oneway()) { - f_service_ << "(new Client(prot)).recv" + sep + javaname + "();" << endl; + f_service_ << "(new Client(prot)).recv" + sep + javaname + "();" << '\n'; indent(f_service_); } - f_service_ << "return null;" << endl; + f_service_ << "return null;" << '\n'; } else { - f_service_ << "return (new Client(prot)).recv" + sep + javaname + "();" << endl; + f_service_ << "return (new Client(prot)).recv" + sep + javaname + "();" << '\n'; } // Close function indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; // Close class indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; } // Close AsyncClient scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } /** @@ -3625,26 +3622,26 @@ void t_java_generator::generate_service_server(t_service* tservice) { // Generate the header portion indent(f_service_) << "public static class Processor extends " - << extends_processor << " implements org.apache.thrift.TProcessor {" << endl; + << extends_processor << " implements org.apache.thrift.TProcessor {" << '\n'; indent_up(); indent(f_service_) << "private static final org.slf4j.Logger _LOGGER = " "org.slf4j.LoggerFactory.getLogger(Processor.class.getName());" - << endl; + << '\n'; - indent(f_service_) << "public Processor(I iface) {" << endl; + indent(f_service_) << "public Processor(I iface) {" << '\n'; indent(f_service_) << " super(iface, getProcessMap(new java.util.HashMap>()));" - << endl; - indent(f_service_) << "}" << endl << endl; + << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; indent(f_service_) << "protected Processor(I iface, java.util.Map> processMap) {" - << endl; - indent(f_service_) << " super(iface, getProcessMap(processMap));" << endl; - indent(f_service_) << "}" << endl << endl; + << '\n'; + indent(f_service_) << " super(iface, getProcessMap(processMap));" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; indent(f_service_) << "private static java.util.Map> processMap) {" - << endl; + << '\n'; indent_up(); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { indent(f_service_) << "processMap.put(\"" << (*f_iter)->get_name() << "\", new " - << make_valid_java_identifier((*f_iter)->get_name()) << "());" << endl; + << make_valid_java_identifier((*f_iter)->get_name()) << "());" << '\n'; } - indent(f_service_) << "return processMap;" << endl; + indent(f_service_) << "return processMap;" << '\n'; indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; // Generate the process subfunctions for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -3668,7 +3665,7 @@ void t_java_generator::generate_service_server(t_service* tservice) { } indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; } /** @@ -3693,26 +3690,26 @@ void t_java_generator::generate_service_async_server(t_service* tservice) { // Generate the header portion indent(f_service_) << "public static class AsyncProcessor extends " - << extends_processor << " {" << endl; + << extends_processor << " {" << '\n'; indent_up(); indent(f_service_) << "private static final org.slf4j.Logger _LOGGER = " "org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName());" - << endl; + << '\n'; - indent(f_service_) << "public AsyncProcessor(I iface) {" << endl; + indent(f_service_) << "public AsyncProcessor(I iface) {" << '\n'; indent(f_service_) << " super(iface, getProcessMap(new java.util.HashMap>()));" - << endl; - indent(f_service_) << "}" << endl << endl; + << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; indent(f_service_) << "protected AsyncProcessor(I iface, java.util.Map> processMap) {" - << endl; - indent(f_service_) << " super(iface, getProcessMap(processMap));" << endl; - indent(f_service_) << "}" << endl << endl; + << '\n'; + indent(f_service_) << " super(iface, getProcessMap(processMap));" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; indent(f_service_) << "private static java.util.Map> getProcessMap(java.util.Map> processMap) {" - << endl; + << '\n'; indent_up(); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { indent(f_service_) << "processMap.put(\"" << (*f_iter)->get_name() << "\", new " - << make_valid_java_identifier((*f_iter)->get_name()) << "());" << endl; + << make_valid_java_identifier((*f_iter)->get_name()) << "());" << '\n'; } - indent(f_service_) << "return processMap;" << endl; + indent(f_service_) << "return processMap;" << '\n'; indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; // Generate the process subfunctions for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -3736,7 +3733,7 @@ void t_java_generator::generate_service_async_server(t_service* tservice) { } indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; } /** @@ -3784,101 +3781,101 @@ void t_java_generator::generate_process_async_function(t_service* tservice, t_fu // Open class indent(f_service_) << "public static class " << make_valid_java_identifier(tfunction->get_name()) << " extends org.apache.thrift.AsyncProcessFunction {" << endl; + << argsname << ", " << resulttype << ", " << resultname << "> {" << '\n'; indent_up(); - indent(f_service_) << "public " << make_valid_java_identifier(tfunction->get_name()) << "() {" << endl; - indent(f_service_) << " super(\"" << tfunction->get_name() << "\");" << endl; - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "public " << make_valid_java_identifier(tfunction->get_name()) << "() {" << '\n'; + indent(f_service_) << " super(\"" << tfunction->get_name() << "\");" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "public " << resultname << " getEmptyResultInstance() {" << endl; + indent(f_service_) << java_override_annotation() << '\n'; + indent(f_service_) << "public " << resultname << " getEmptyResultInstance() {" << '\n'; if (tfunction->is_oneway()) { - indent(f_service_) << " return null;" << endl; + indent(f_service_) << " return null;" << '\n'; } else { - indent(f_service_) << " return new " << resultname << "();" << endl; + indent(f_service_) << " return new " << resultname << "();" << '\n'; } - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "public " << argsname << " getEmptyArgsInstance() {" << endl; - indent(f_service_) << " return new " << argsname << "();" << endl; - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << java_override_annotation() << '\n'; + indent(f_service_) << "public " << argsname << " getEmptyArgsInstance() {" << '\n'; + indent(f_service_) << " return new " << argsname << "();" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << java_override_annotation() << endl; + indent(f_service_) << java_override_annotation() << '\n'; indent(f_service_) << "public org.apache.thrift.async.AsyncMethodCallback<" << resulttype << "> getResultHandler(final " "org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, " "final int seqid) {" - << endl; + << '\n'; indent_up(); - indent(f_service_) << "final org.apache.thrift.AsyncProcessFunction fcall = this;" << endl; + indent(f_service_) << "final org.apache.thrift.AsyncProcessFunction fcall = this;" << '\n'; indent(f_service_) << "return new org.apache.thrift.async.AsyncMethodCallback<" << resulttype - << ">() { " << endl; + << ">() { " << '\n'; indent_up(); - indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "public void onComplete(" << resulttype << " o) {" << endl; + indent(f_service_) << java_override_annotation() << '\n'; + indent(f_service_) << "public void onComplete(" << resulttype << " o) {" << '\n'; indent_up(); if (!tfunction->is_oneway()) { - indent(f_service_) << resultname << " result = new " << resultname << "();" << endl; + indent(f_service_) << resultname << " result = new " << resultname << "();" << '\n'; if (!tfunction->get_returntype()->is_void()) { - indent(f_service_) << "result.success = o;" << endl; + indent(f_service_) << "result.success = o;" << '\n'; // Set isset on success field if (!type_can_be_null(tfunction->get_returntype())) { indent(f_service_) << "result.set" << get_cap_name("success") << get_cap_name("isSet") - << "(true);" << endl; + << "(true);" << '\n'; } } - indent(f_service_) << "try {" << endl; + indent(f_service_) << "try {" << '\n'; indent(f_service_) << " fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);" - << endl; - indent(f_service_) << "} catch (org.apache.thrift.transport.TTransportException e) {" << endl; + << '\n'; + indent(f_service_) << "} catch (org.apache.thrift.transport.TTransportException e) {" << '\n'; indent_up(); f_service_ << indent() << "_LOGGER.error(\"TTransportException writing to internal frame buffer\", e);" - << endl - << indent() << "fb.close();" << endl; + << '\n' + << indent() << "fb.close();" << '\n'; indent_down(); - indent(f_service_) << "} catch (java.lang.Exception e) {" << endl; + indent(f_service_) << "} catch (java.lang.Exception e) {" << '\n'; indent_up(); f_service_ << indent() << "_LOGGER.error(\"Exception writing to internal frame buffer\", e);" - << endl - << indent() << "onError(e);" << endl; + << '\n' + << indent() << "onError(e);" << '\n'; indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; - indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "public void onError(java.lang.Exception e) {" << endl; + indent(f_service_) << java_override_annotation() << '\n'; + indent(f_service_) << "public void onError(java.lang.Exception e) {" << '\n'; indent_up(); if (tfunction->is_oneway()) { indent(f_service_) << "if (e instanceof org.apache.thrift.transport.TTransportException) {" - << endl; + << '\n'; indent_up(); - f_service_ << indent() << "_LOGGER.error(\"TTransportException inside handler\", e);" << endl - << indent() << "fb.close();" << endl; + f_service_ << indent() << "_LOGGER.error(\"TTransportException inside handler\", e);" << '\n' + << indent() << "fb.close();" << '\n'; indent_down(); - indent(f_service_) << "} else {" << endl; + indent(f_service_) << "} else {" << '\n'; indent_up(); - f_service_ << indent() << "_LOGGER.error(\"Exception inside oneway handler\", e);" << endl; + f_service_ << indent() << "_LOGGER.error(\"Exception inside oneway handler\", e);" << '\n'; indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } else { - indent(f_service_) << "byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;" << endl; - indent(f_service_) << "org.apache.thrift.TSerializable msg;" << endl; - indent(f_service_) << resultname << " result = new " << resultname << "();" << endl; + indent(f_service_) << "byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;" << '\n'; + indent(f_service_) << "org.apache.thrift.TSerializable msg;" << '\n'; + indent(f_service_) << resultname << " result = new " << resultname << "();" << '\n'; t_struct* xs = tfunction->get_xceptions(); const std::vector& xceptions = xs->get_members(); @@ -3890,66 +3887,66 @@ void t_java_generator::generate_process_async_function(t_service* tservice, t_fu f_service_ << indent(); string type = type_name((*x_iter)->get_type(), false, false); string name = (*x_iter)->get_name(); - f_service_ << "if (e instanceof " << type << ") {" << endl; + f_service_ << "if (e instanceof " << type << ") {" << '\n'; indent_up(); - f_service_ << indent() << "result." << make_valid_java_identifier(name) << " = (" << type << ") e;" << endl + f_service_ << indent() << "result." << make_valid_java_identifier(name) << " = (" << type << ") e;" << '\n' << indent() << "result.set" << get_cap_name(name) << get_cap_name("isSet") - << "(true);" << endl - << indent() << "msg = result;" << endl; + << "(true);" << '\n' + << indent() << "msg = result;" << '\n'; indent_down(); indent(f_service_) << "} else "; } } else { indent(f_service_); } - f_service_ << "if (e instanceof org.apache.thrift.transport.TTransportException) {" << endl; + f_service_ << "if (e instanceof org.apache.thrift.transport.TTransportException) {" << '\n'; indent_up(); - f_service_ << indent() << "_LOGGER.error(\"TTransportException inside handler\", e);" << endl - << indent() << "fb.close();" << endl - << indent() << "return;" << endl; + f_service_ << indent() << "_LOGGER.error(\"TTransportException inside handler\", e);" << '\n' + << indent() << "fb.close();" << '\n' + << indent() << "return;" << '\n'; indent_down(); indent(f_service_) << "} else if (e instanceof org.apache.thrift.TApplicationException) {" - << endl; + << '\n'; indent_up(); - f_service_ << indent() << "_LOGGER.error(\"TApplicationException inside handler\", e);" << endl - << indent() << "msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;" << endl - << indent() << "msg = (org.apache.thrift.TApplicationException)e;" << endl; + f_service_ << indent() << "_LOGGER.error(\"TApplicationException inside handler\", e);" << '\n' + << indent() << "msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;" << '\n' + << indent() << "msg = (org.apache.thrift.TApplicationException)e;" << '\n'; indent_down(); - indent(f_service_) << "} else {" << endl; + indent(f_service_) << "} else {" << '\n'; indent_up(); - f_service_ << indent() << "_LOGGER.error(\"Exception inside handler\", e);" << endl - << indent() << "msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;" << endl + f_service_ << indent() << "_LOGGER.error(\"Exception inside handler\", e);" << '\n' + << indent() << "msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;" << '\n' << indent() << "msg = new " "org.apache.thrift.TApplicationException(org.apache.thrift." "TApplicationException.INTERNAL_ERROR, e.getMessage());" - << endl; + << '\n'; indent_down(); - f_service_ << indent() << "}" << endl - << indent() << "try {" << endl - << indent() << " fcall.sendResponse(fb,msg,msgType,seqid);" << endl - << indent() << "} catch (java.lang.Exception ex) {" << endl + f_service_ << indent() << "}" << '\n' + << indent() << "try {" << '\n' + << indent() << " fcall.sendResponse(fb,msg,msgType,seqid);" << '\n' + << indent() << "} catch (java.lang.Exception ex) {" << '\n' << indent() << " _LOGGER.error(\"Exception writing to internal frame buffer\", ex);" - << endl - << indent() << " fb.close();" << endl - << indent() << "}" << endl; + << '\n' + << indent() << " fb.close();" << '\n' + << indent() << "}" << '\n'; } indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; indent_down(); - indent(f_service_) << "};" << endl; + indent(f_service_) << "};" << '\n'; indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "public boolean isOneway() {" << endl; - indent(f_service_) << " return " << ((tfunction->is_oneway()) ? "true" : "false") << ";" << endl; - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << java_override_annotation() << '\n'; + indent(f_service_) << "public boolean isOneway() {" << '\n'; + indent(f_service_) << " return " << ((tfunction->is_oneway()) ? "true" : "false") << ";" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << java_override_annotation() << endl; + indent(f_service_) << java_override_annotation() << '\n'; indent(f_service_) << "public void start(I iface, " << argsname << " args, org.apache.thrift.async.AsyncMethodCallback<" << resulttype - << "> resultHandler) throws org.apache.thrift.TException {" << endl; + << "> resultHandler) throws org.apache.thrift.TException {" << '\n'; indent_up(); // Generate the function call @@ -3971,17 +3968,17 @@ void t_java_generator::generate_process_async_function(t_service* tservice, t_fu if (!first) f_service_ << ","; f_service_ << "resultHandler"; - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; indent_down(); indent(f_service_) << "}"; // Close function - f_service_ << endl; + f_service_ << '\n'; // Close class indent_down(); - f_service_ << indent() << "}" << endl << endl; + f_service_ << indent() << "}" << '\n' << '\n'; } /** @@ -4000,45 +3997,45 @@ void t_java_generator::generate_process_function(t_service* tservice, t_function // Open class indent(f_service_) << "public static class " << make_valid_java_identifier(tfunction->get_name()) << " extends org.apache.thrift.ProcessFunction {" << endl; + << argsname << ", " << resultname << "> {" << '\n'; indent_up(); - indent(f_service_) << "public " << make_valid_java_identifier(tfunction->get_name()) << "() {" << endl; - indent(f_service_) << " super(\"" << tfunction->get_name() << "\");" << endl; - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "public " << make_valid_java_identifier(tfunction->get_name()) << "() {" << '\n'; + indent(f_service_) << " super(\"" << tfunction->get_name() << "\");" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "public " << argsname << " getEmptyArgsInstance() {" << endl; - indent(f_service_) << " return new " << argsname << "();" << endl; - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << java_override_annotation() << '\n'; + indent(f_service_) << "public " << argsname << " getEmptyArgsInstance() {" << '\n'; + indent(f_service_) << " return new " << argsname << "();" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "public boolean isOneway() {" << endl; - indent(f_service_) << " return " << ((tfunction->is_oneway()) ? "true" : "false") << ";" << endl; - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << java_override_annotation() << '\n'; + indent(f_service_) << "public boolean isOneway() {" << '\n'; + indent(f_service_) << " return " << ((tfunction->is_oneway()) ? "true" : "false") << ";" << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "protected boolean rethrowUnhandledExceptions() {" << endl; + indent(f_service_) << java_override_annotation() << '\n'; + indent(f_service_) << "protected boolean rethrowUnhandledExceptions() {" << '\n'; indent(f_service_) << " return " << ((rethrow_unhandled_exceptions_) ? "true" : "false") << ";" - << endl; - indent(f_service_) << "}" << endl << endl; + << '\n'; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << java_override_annotation() << endl; - indent(f_service_) << "public " << resultname << " getEmptyResultInstance() {" << endl; + indent(f_service_) << java_override_annotation() << '\n'; + indent(f_service_) << "public " << resultname << " getEmptyResultInstance() {" << '\n'; if (tfunction->is_oneway()) { - indent(f_service_) << " return null;" << endl; + indent(f_service_) << " return null;" << '\n'; } else { - indent(f_service_) << " return new " << resultname << "();" << endl; + indent(f_service_) << " return new " << resultname << "();" << '\n'; } - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; - indent(f_service_) << java_override_annotation() << endl; + indent(f_service_) << java_override_annotation() << '\n'; indent(f_service_) << "public " << resultname << " getResult(I iface, " << argsname - << " args) throws org.apache.thrift.TException {" << endl; + << " args) throws org.apache.thrift.TException {" << '\n'; indent_up(); if (!tfunction->is_oneway()) { - indent(f_service_) << resultname << " result = getEmptyResultInstance();" << endl; + indent(f_service_) << resultname << " result = getEmptyResultInstance();" << '\n'; } t_struct* xs = tfunction->get_xceptions(); @@ -4047,7 +4044,7 @@ void t_java_generator::generate_process_function(t_service* tservice, t_function // Try block for a function with exceptions if (xceptions.size() > 0) { - f_service_ << indent() << "try {" << endl; + f_service_ << indent() << "try {" << '\n'; indent_up(); } @@ -4070,13 +4067,13 @@ void t_java_generator::generate_process_function(t_service* tservice, t_function } f_service_ << "args." << make_valid_java_identifier((*f_iter)->get_name()); } - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; // Set isset on success field if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void() && !type_can_be_null(tfunction->get_returntype())) { indent(f_service_) << "result.set" << get_cap_name("success") << get_cap_name("isSet") - << "(true);" << endl; + << "(true);" << '\n'; } if (!tfunction->is_oneway() && xceptions.size() > 0) { @@ -4084,34 +4081,34 @@ void t_java_generator::generate_process_function(t_service* tservice, t_function f_service_ << indent() << "}"; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " " - << make_valid_java_identifier((*x_iter)->get_name()) << ") {" << endl; + << make_valid_java_identifier((*x_iter)->get_name()) << ") {" << '\n'; if (!tfunction->is_oneway()) { indent_up(); f_service_ << indent() << "result." << make_valid_java_identifier((*x_iter)->get_name()) << " = " - << make_valid_java_identifier((*x_iter)->get_name()) << ";" << endl; + << make_valid_java_identifier((*x_iter)->get_name()) << ";" << '\n'; indent_down(); f_service_ << indent() << "}"; } else { f_service_ << "}"; } } - f_service_ << endl; + f_service_ << '\n'; } if (tfunction->is_oneway()) { - indent(f_service_) << "return null;" << endl; + indent(f_service_) << "return null;" << '\n'; } else { - indent(f_service_) << "return result;" << endl; + indent(f_service_) << "return result;" << '\n'; } indent_down(); indent(f_service_) << "}"; // Close function - f_service_ << endl; + f_service_ << '\n'; // Close class indent_down(); - f_service_ << indent() << "}" << endl << endl; + f_service_ << indent() << "}" << '\n' << '\n'; } /** @@ -4175,12 +4172,12 @@ void t_java_generator::generate_deserialize_field(ostream& out, default: throw "compiler error: no Java name for base type " + t_base_type::t_base_name(tbase); } - out << endl; + out << '\n'; } else if (type->is_enum()) { indent(out) << name << " = " << type_name(tfield->get_type(), true, false, false, true) + ".findByValue(iprot.readI32());" - << endl; + << '\n'; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", tfield->get_name().c_str(), type_name(type).c_str()); @@ -4193,15 +4190,15 @@ void t_java_generator::generate_deserialize_field(ostream& out, void t_java_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) { if (reuse_objects_) { - indent(out) << "if (" << prefix << " == null) {" << endl; + indent(out) << "if (" << prefix << " == null) {" << '\n'; indent_up(); } - indent(out) << prefix << " = new " << type_name(tstruct) << "();" << endl; + indent(out) << prefix << " = new " << type_name(tstruct) << "();" << '\n'; if (reuse_objects_) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - indent(out) << prefix << ".read(iprot);" << endl; + indent(out) << prefix << ".read(iprot);" << '\n'; } /** @@ -4228,31 +4225,31 @@ void t_java_generator::generate_deserialize_container(ostream& out, // Declare variables, read header if (ttype->is_map()) { indent(out) << "org.apache.thrift.protocol.TMap " << obj << " = iprot.readMapBegin();" - << endl; + << '\n'; } else if (ttype->is_set()) { indent(out) << "org.apache.thrift.protocol.TSet " << obj << " = iprot.readSetBegin();" - << endl; + << '\n'; } else if (ttype->is_list()) { indent(out) << "org.apache.thrift.protocol.TList " << obj << " = iprot.readListBegin();" - << endl; + << '\n'; } } else { // Declare variables, read header if (ttype->is_map()) { indent(out) << "org.apache.thrift.protocol.TMap " << obj << " = iprot.readMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " - << type_to_enum(((t_map*)ttype)->get_val_type()) << "); " << endl; + << type_to_enum(((t_map*)ttype)->get_val_type()) << "); " << '\n'; } else if (ttype->is_set()) { indent(out) << "org.apache.thrift.protocol.TSet " << obj << " = iprot.readSetBegin(" - << type_to_enum(((t_set*)ttype)->get_elem_type()) << ");" << endl; + << type_to_enum(((t_set*)ttype)->get_elem_type()) << ");" << '\n'; } else if (ttype->is_list()) { indent(out) << "org.apache.thrift.protocol.TList " << obj << " = iprot.readListBegin(" - << type_to_enum(((t_list*)ttype)->get_elem_type()) << ");" << endl; + << type_to_enum(((t_list*)ttype)->get_elem_type()) << ");" << '\n'; } } if (reuse_objects_) { - indent(out) << "if (" << prefix << " == null) {" << endl; + indent(out) << "if (" << prefix << " == null) {" << '\n'; indent_up(); } @@ -4264,18 +4261,18 @@ void t_java_generator::generate_deserialize_container(ostream& out, // construct the collection correctly i.e. with appropriate size/type if (is_enum_set(ttype) || is_enum_map(ttype)) { - out << "(" << inner_enum_type_name(ttype) << ");" << endl; + out << "(" << inner_enum_type_name(ttype) << ");" << '\n'; } else if (sorted_containers_ && (ttype->is_map() || ttype->is_set())) { // TreeSet and TreeMap don't have any constructor which takes a capacity as an argument - out << "();" << endl; + out << "();" << '\n'; } else { out << "(" << (ttype->is_list() ? "" : "2*") << obj << ".size" - << ");" << endl; + << ");" << '\n'; } if (reuse_objects_) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } if (ttype->is_map()) { @@ -4291,11 +4288,11 @@ void t_java_generator::generate_deserialize_container(ostream& out, if (has_metadata) { // Read container end if (ttype->is_map()) { - indent(out) << "iprot.readMapEnd();" << endl; + indent(out) << "iprot.readMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "iprot.readSetEnd();" << endl; + indent(out) << "iprot.readSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "iprot.readListEnd();" << endl; + indent(out) << "iprot.readListEnd();" << '\n'; } } scope_down(out); @@ -4314,14 +4311,14 @@ void t_java_generator::generate_deserialize_map_element(ostream& out, t_field fkey(tmap->get_key_type(), key); t_field fval(tmap->get_val_type(), val); - indent(out) << declare_field(&fkey, reuse_objects_, false) << endl; - indent(out) << declare_field(&fval, reuse_objects_, false) << endl; + indent(out) << declare_field(&fkey, reuse_objects_, false) << '\n'; + indent(out) << declare_field(&fval, reuse_objects_, false) << '\n'; // For loop iterates over elements string i = tmp("_i"); indent(out) << "for (int " << i << " = 0; " << i << " < " << obj << ".size" << "; " - << "++" << i << ")" << endl; + << "++" << i << ")" << '\n'; scope_up(out); @@ -4329,22 +4326,22 @@ void t_java_generator::generate_deserialize_map_element(ostream& out, generate_deserialize_field(out, &fval, "", has_metadata); if (get_true_type(fkey.get_type())->is_enum()) { - indent(out) << "if (" << key << " != null)" << endl; + indent(out) << "if (" << key << " != null)" << '\n'; scope_up(out); } - indent(out) << prefix << ".put(" << key << ", " << val << ");" << endl; + indent(out) << prefix << ".put(" << key << ", " << val << ");" << '\n'; if (get_true_type(fkey.get_type())->is_enum()) { scope_down(out); } if (reuse_objects_ && !get_true_type(fkey.get_type())->is_base_type()) { - indent(out) << key << " = null;" << endl; + indent(out) << key << " = null;" << '\n'; } if (reuse_objects_ && !get_true_type(fval.get_type())->is_base_type()) { - indent(out) << val << " = null;" << endl; + indent(out) << val << " = null;" << '\n'; } } @@ -4359,30 +4356,30 @@ void t_java_generator::generate_deserialize_set_element(ostream& out, string elem = tmp("_elem"); t_field felem(tset->get_elem_type(), elem); - indent(out) << declare_field(&felem, reuse_objects_, false) << endl; + indent(out) << declare_field(&felem, reuse_objects_, false) << '\n'; // For loop iterates over elements string i = tmp("_i"); indent(out) << "for (int " << i << " = 0; " << i << " < " << obj << ".size" << "; " - << "++" << i << ")" << endl; + << "++" << i << ")" << '\n'; scope_up(out); generate_deserialize_field(out, &felem, "", has_metadata); if (get_true_type(felem.get_type())->is_enum()) { - indent(out) << "if (" << elem << " != null)" << endl; + indent(out) << "if (" << elem << " != null)" << '\n'; scope_up(out); } - indent(out) << prefix << ".add(" << elem << ");" << endl; + indent(out) << prefix << ".add(" << elem << ");" << '\n'; if (get_true_type(felem.get_type())->is_enum()) { scope_down(out); } if (reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) { - indent(out) << elem << " = null;" << endl; + indent(out) << elem << " = null;" << '\n'; } } @@ -4397,30 +4394,30 @@ void t_java_generator::generate_deserialize_list_element(ostream& out, string elem = tmp("_elem"); t_field felem(tlist->get_elem_type(), elem); - indent(out) << declare_field(&felem, reuse_objects_, false) << endl; + indent(out) << declare_field(&felem, reuse_objects_, false) << '\n'; // For loop iterates over elements string i = tmp("_i"); indent(out) << "for (int " << i << " = 0; " << i << " < " << obj << ".size" << "; " - << "++" << i << ")" << endl; + << "++" << i << ")" << '\n'; scope_up(out); generate_deserialize_field(out, &felem, "", has_metadata); if (get_true_type(felem.get_type())->is_enum()) { - indent(out) << "if (" << elem << " != null)" << endl; + indent(out) << "if (" << elem << " != null)" << '\n'; scope_up(out); } - indent(out) << prefix << ".add(" << elem << ");" << endl; + indent(out) << prefix << ".add(" << elem << ");" << '\n'; if (get_true_type(felem.get_type())->is_enum()) { scope_down(out); } if (reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) { - indent(out) << elem << " = null;" << endl; + indent(out) << elem << " = null;" << '\n'; } } @@ -4446,7 +4443,7 @@ void t_java_generator::generate_serialize_field(ostream& out, } else if (type->is_container()) { generate_serialize_container(out, type, prefix + make_valid_java_identifier(tfield->get_name()) + postfix, has_metadata); } else if (type->is_enum()) { - indent(out) << "oprot.writeI32(" << prefix + make_valid_java_identifier(tfield->get_name()) + postfix << ".getValue());" << endl; + indent(out) << "oprot.writeI32(" << prefix + make_valid_java_identifier(tfield->get_name()) + postfix << ".getValue());" << '\n'; } else if (type->is_base_type()) { string name = prefix + make_valid_java_identifier(tfield->get_name()) + postfix; indent(out) << "oprot."; @@ -4491,7 +4488,7 @@ void t_java_generator::generate_serialize_field(ostream& out, } else if (type->is_enum()) { out << "writeI32(struct." << name << ");"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s%s' TYPE '%s'\n", prefix.c_str(), tfield->get_name().c_str(), postfix.c_str(), type_name(type).c_str()); @@ -4506,7 +4503,7 @@ void t_java_generator::generate_serialize_field(ostream& out, */ void t_java_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - out << indent() << prefix << ".write(oprot);" << endl; + out << indent() << prefix << ".write(oprot);" << '\n'; } /** @@ -4526,18 +4523,18 @@ void t_java_generator::generate_serialize_container(ostream& out, indent(out) << "oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << prefix << ".size()));" - << endl; + << '\n'; } else if (ttype->is_set()) { indent(out) << "oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " << prefix - << ".size()));" << endl; + << ".size()));" << '\n'; } else if (ttype->is_list()) { indent(out) << "oprot.writeListBegin(new org.apache.thrift.protocol.TList(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix - << ".size()));" << endl; + << ".size()));" << '\n'; } } else { - indent(out) << "oprot.writeI32(" << prefix << ".size());" << endl; + indent(out) << "oprot.writeI32(" << prefix << ".size());" << '\n'; } string iter = tmp("_iter"); @@ -4554,7 +4551,7 @@ void t_java_generator::generate_serialize_container(ostream& out, << prefix << ")"; } - out << endl; + out << '\n'; scope_up(out); if (ttype->is_map()) { generate_serialize_map_element(out, (t_map*)ttype, iter, prefix, has_metadata); @@ -4567,11 +4564,11 @@ void t_java_generator::generate_serialize_container(ostream& out, if (has_metadata) { if (ttype->is_map()) { - indent(out) << "oprot.writeMapEnd();" << endl; + indent(out) << "oprot.writeMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "oprot.writeSetEnd();" << endl; + indent(out) << "oprot.writeSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "oprot.writeListEnd();" << endl; + indent(out) << "oprot.writeListEnd();" << '\n'; } } @@ -5101,7 +5098,7 @@ void t_java_generator::generate_deep_copy_container(ostream& out, // deep copy of base types can be done much more efficiently than iterating over all the // elements manually indent(out) << type_name(type, true, false) << " " << result_name << " = new " - << type_name(container, false, true) << "(" << source_name << ");" << endl; + << type_name(container, false, true) << "(" << source_name << ");" << '\n'; return; } @@ -5116,10 +5113,10 @@ void t_java_generator::generate_deep_copy_container(ostream& out, if (is_enum_set(container)) { indent(out) << type_name(type, true, false) << " " << result_name << " = " << type_name(container, false, true, true) << ".noneOf(" << constructor_args << ");" - << endl; + << '\n'; } else { indent(out) << type_name(type, true, false) << " " << result_name << " = new " - << type_name(container, false, true) << "(" << constructor_args << ");" << endl; + << type_name(container, false, true) << "(" << constructor_args << ");" << '\n'; } std::string iterator_element_name = source_name_p1 + "_element"; @@ -5131,17 +5128,17 @@ void t_java_generator::generate_deep_copy_container(ostream& out, indent(out) << "for (java.util.Map.Entry<" << type_name(key_type, true, false) << ", " << type_name(val_type, true, false) << "> " << iterator_element_name << " : " - << source_name << ".entrySet()) {" << endl; + << source_name << ".entrySet()) {" << '\n'; indent_up(); - out << endl; + out << '\n'; indent(out) << type_name(key_type, true, false) << " " << iterator_element_name - << "_key = " << iterator_element_name << ".getKey();" << endl; + << "_key = " << iterator_element_name << ".getKey();" << '\n'; indent(out) << type_name(val_type, true, false) << " " << iterator_element_name - << "_value = " << iterator_element_name << ".getValue();" << endl; + << "_value = " << iterator_element_name << ".getValue();" << '\n'; - out << endl; + out << '\n'; if (key_type->is_container()) { generate_deep_copy_container(out, iterator_element_name + "_key", "", @@ -5150,10 +5147,10 @@ void t_java_generator::generate_deep_copy_container(ostream& out, indent(out) << type_name(key_type, true, false) << " " << result_element_name << "_key = "; generate_deep_copy_non_container(out, iterator_element_name + "_key", result_element_name + "_key", key_type); - out << ";" << endl; + out << ";" << '\n'; } - out << endl; + out << '\n'; if (val_type->is_container()) { generate_deep_copy_container(out, iterator_element_name + "_value", "", @@ -5162,16 +5159,16 @@ void t_java_generator::generate_deep_copy_container(ostream& out, indent(out) << type_name(val_type, true, false) << " " << result_element_name << "_value = "; generate_deep_copy_non_container(out, iterator_element_name + "_value", result_element_name + "_value", val_type); - out << ";" << endl; + out << ";" << '\n'; } - out << endl; + out << '\n'; indent(out) << result_name << ".put(" << result_element_name << "_key, " << result_element_name - << "_value);" << endl; + << "_value);" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } else { t_type* elem_type; @@ -5183,32 +5180,32 @@ void t_java_generator::generate_deep_copy_container(ostream& out, } indent(out) << "for (" << type_name(elem_type, true, false) << " " << iterator_element_name - << " : " << source_name << ") {" << endl; + << " : " << source_name << ") {" << '\n'; indent_up(); if (elem_type->is_container()) { // recursive deep copy generate_deep_copy_container(out, iterator_element_name, "", result_element_name, elem_type); - indent(out) << result_name << ".add(" << result_element_name << ");" << endl; + indent(out) << result_name << ".add(" << result_element_name << ");" << '\n'; } else { // iterative copy if (elem_type->is_binary()) { indent(out) << "java.nio.ByteBuffer temp_binary_element = "; generate_deep_copy_non_container(out, iterator_element_name, "temp_binary_element", elem_type); - out << ";" << endl; - indent(out) << result_name << ".add(temp_binary_element);" << endl; + out << ";" << '\n'; + indent(out) << result_name << ".add(temp_binary_element);" << '\n'; } else { indent(out) << result_name << ".add("; generate_deep_copy_non_container(out, iterator_element_name, result_name, elem_type); - out << ");" << endl; + out << ");" << '\n'; } } indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } @@ -5245,14 +5242,14 @@ std::string t_java_generator::generate_isset_check(std::string field_name) { void t_java_generator::generate_isset_set(ostream& out, t_field* field, string prefix) { if (!type_can_be_null(field->get_type())) { indent(out) << prefix << "set" << get_cap_name(field->get_name()) << get_cap_name("isSet") - << "(true);" << endl; + << "(true);" << '\n'; } } void t_java_generator::generate_struct_desc(ostream& out, t_struct* tstruct) { indent(out) << "private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new " "org.apache.thrift.protocol.TStruct(\"" - << tstruct->get_name() << "\");" << endl; + << tstruct->get_name() << "\");" << '\n'; } void t_java_generator::generate_field_descs(ostream& out, t_struct* tstruct) { @@ -5264,24 +5261,24 @@ void t_java_generator::generate_field_descs(ostream& out, t_struct* tstruct) { << constant_name((*m_iter)->get_name()) << "_FIELD_DESC = new org.apache.thrift.protocol.TField(\"" << (*m_iter)->get_name() << "\", " << type_to_enum((*m_iter)->get_type()) << ", " - << "(short)" << (*m_iter)->get_key() << ");" << endl; + << "(short)" << (*m_iter)->get_key() << ");" << '\n'; } } void t_java_generator::generate_scheme_map(ostream& out, t_struct* tstruct) { indent(out) << "private static final org.apache.thrift.scheme.SchemeFactory " "STANDARD_SCHEME_FACTORY = new " - << tstruct->get_name() << "StandardSchemeFactory();" << endl; + << tstruct->get_name() << "StandardSchemeFactory();" << '\n'; indent(out) << "private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new " - << tstruct->get_name() << "TupleSchemeFactory();" << endl; + << tstruct->get_name() << "TupleSchemeFactory();" << '\n'; } void t_java_generator::generate_field_name_constants(ostream& out, t_struct* tstruct) { indent(out) << "/** The set of fields this struct contains, along with convenience methods for " "finding and manipulating them. */" - << endl; - indent(out) << "public enum _Fields implements org.apache.thrift.TFieldIdEnum {" << endl; + << '\n'; + indent(out) << "public enum _Fields implements org.apache.thrift.TFieldIdEnum {" << '\n'; indent_up(); bool first = true; @@ -5289,7 +5286,7 @@ void t_java_generator::generate_field_name_constants(ostream& out, t_struct* tst vector::const_iterator m_iter; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if (!first) { - out << "," << endl; + out << "," << '\n'; } first = false; generate_java_doc(out, *m_iter); @@ -5297,87 +5294,87 @@ void t_java_generator::generate_field_name_constants(ostream& out, t_struct* tst << ", \"" << (*m_iter)->get_name() << "\")"; } - out << ";" << endl << endl; + out << ";" << '\n' << '\n'; indent(out) << "private static final java.util.Map byName = new " "java.util.HashMap();" - << endl; - out << endl; + << '\n'; + out << '\n'; - indent(out) << "static {" << endl; - indent(out) << " for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {" << endl; - indent(out) << " byName.put(field.getFieldName(), field);" << endl; - indent(out) << " }" << endl; - indent(out) << "}" << endl << endl; + indent(out) << "static {" << '\n'; + indent(out) << " for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {" << '\n'; + indent(out) << " byName.put(field.getFieldName(), field);" << '\n'; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n' << '\n'; - indent(out) << "/**" << endl; + indent(out) << "/**" << '\n'; indent(out) << " * Find the _Fields constant that matches fieldId, or null if its not found." - << endl; - indent(out) << " */" << endl; - indent(out) << java_nullable_annotation() << endl; - indent(out) << "public static _Fields findByThriftId(int fieldId) {" << endl; + << '\n'; + indent(out) << " */" << '\n'; + indent(out) << java_nullable_annotation() << '\n'; + indent(out) << "public static _Fields findByThriftId(int fieldId) {" << '\n'; indent_up(); - indent(out) << "switch(fieldId) {" << endl; + indent(out) << "switch(fieldId) {" << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { indent(out) << "case " << (*m_iter)->get_key() << ": // " - << constant_name((*m_iter)->get_name()) << endl; - indent(out) << " return " << constant_name((*m_iter)->get_name()) << ";" << endl; + << constant_name((*m_iter)->get_name()) << '\n'; + indent(out) << " return " << constant_name((*m_iter)->get_name()) << ";" << '\n'; } - indent(out) << "default:" << endl; - indent(out) << " return null;" << endl; + indent(out) << "default:" << '\n'; + indent(out) << " return null;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; - - indent(out) << "/**" << endl; - indent(out) << " * Find the _Fields constant that matches fieldId, throwing an exception" << endl; - indent(out) << " * if it is not found." << endl; - indent(out) << " */" << endl; - indent(out) << "public static _Fields findByThriftIdOrThrow(int fieldId) {" << endl; - indent(out) << " _Fields fields = findByThriftId(fieldId);" << endl; + indent(out) << "}" << '\n' << '\n'; + + indent(out) << "/**" << '\n'; + indent(out) << " * Find the _Fields constant that matches fieldId, throwing an exception" << '\n'; + indent(out) << " * if it is not found." << '\n'; + indent(out) << " */" << '\n'; + indent(out) << "public static _Fields findByThriftIdOrThrow(int fieldId) {" << '\n'; + indent(out) << " _Fields fields = findByThriftId(fieldId);" << '\n'; indent(out) << " if (fields == null) throw new java.lang.IllegalArgumentException(\"Field \" + " "fieldId + " "\" doesn't exist!\");" - << endl; - indent(out) << " return fields;" << endl; - indent(out) << "}" << endl << endl; + << '\n'; + indent(out) << " return fields;" << '\n'; + indent(out) << "}" << '\n' << '\n'; - indent(out) << "/**" << endl; + indent(out) << "/**" << '\n'; indent(out) << " * Find the _Fields constant that matches name, or null if its not found." - << endl; - indent(out) << " */" << endl; - indent(out) << java_nullable_annotation() << endl; - indent(out) << "public static _Fields findByName(java.lang.String name) {" << endl; - indent(out) << " return byName.get(name);" << endl; - indent(out) << "}" << endl << endl; - - indent(out) << "private final short _thriftId;" << endl; - indent(out) << "private final java.lang.String _fieldName;" << endl << endl; - - indent(out) << "_Fields(short thriftId, java.lang.String fieldName) {" << endl; - indent(out) << " _thriftId = thriftId;" << endl; - indent(out) << " _fieldName = fieldName;" << endl; - indent(out) << "}" << endl << endl; - - indent(out) << java_override_annotation() << endl; - indent(out) << "public short getThriftFieldId() {" << endl; - indent(out) << " return _thriftId;" << endl; - indent(out) << "}" << endl << endl; - - indent(out) << java_override_annotation() << endl; - indent(out) << "public java.lang.String getFieldName() {" << endl; - indent(out) << " return _fieldName;" << endl; - indent(out) << "}" << endl; + << '\n'; + indent(out) << " */" << '\n'; + indent(out) << java_nullable_annotation() << '\n'; + indent(out) << "public static _Fields findByName(java.lang.String name) {" << '\n'; + indent(out) << " return byName.get(name);" << '\n'; + indent(out) << "}" << '\n' << '\n'; + + indent(out) << "private final short _thriftId;" << '\n'; + indent(out) << "private final java.lang.String _fieldName;" << '\n' << '\n'; + + indent(out) << "_Fields(short thriftId, java.lang.String fieldName) {" << '\n'; + indent(out) << " _thriftId = thriftId;" << '\n'; + indent(out) << " _fieldName = fieldName;" << '\n'; + indent(out) << "}" << '\n' << '\n'; + + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public short getThriftFieldId() {" << '\n'; + indent(out) << " return _thriftId;" << '\n'; + indent(out) << "}" << '\n' << '\n'; + + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public java.lang.String getFieldName() {" << '\n'; + indent(out) << " return _fieldName;" << '\n'; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } t_java_generator::isset_type t_java_generator::needs_isset(t_struct* tstruct, @@ -5411,8 +5408,8 @@ t_java_generator::isset_type t_java_generator::needs_isset(t_struct* tstruct, } void t_java_generator::generate_java_struct_clear(std::ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; - indent(out) << "public void clear() {" << endl; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public void clear() {" << '\n'; indent_up(); for (auto field : tstruct->get_members()) { @@ -5425,13 +5422,13 @@ void t_java_generator::generate_java_struct_clear(std::ostream& out, t_struct* t if (type_can_be_null(t)) { if (reuse_objects_ && (t->is_container() || t->is_struct())) { - indent(out) << "if (this." << make_valid_java_identifier(field->get_name()) << " != null) {" << endl; + indent(out) << "if (this." << make_valid_java_identifier(field->get_name()) << " != null) {" << '\n'; indent_up(); - indent(out) << "this." << make_valid_java_identifier(field->get_name()) << ".clear();" << endl; + indent(out) << "this." << make_valid_java_identifier(field->get_name()) << ".clear();" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } else { - indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = null;" << endl; + indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = null;" << '\n'; } continue; } @@ -5439,7 +5436,7 @@ void t_java_generator::generate_java_struct_clear(std::ostream& out, t_struct* t // must be a base type // means it also needs to be explicitly unset indent(out) << "set" << get_cap_name(field->get_name()) << get_cap_name("isSet") << "(false);" - << endl; + << '\n'; t_base_type* base_type = (t_base_type*)t; switch (base_type->get_base()) { @@ -5447,13 +5444,13 @@ void t_java_generator::generate_java_struct_clear(std::ostream& out, t_struct* t case t_base_type::TYPE_I16: case t_base_type::TYPE_I32: case t_base_type::TYPE_I64: - indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = 0;" << endl; + indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = 0;" << '\n'; break; case t_base_type::TYPE_DOUBLE: - indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = 0.0;" << endl; + indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = 0.0;" << '\n'; break; case t_base_type::TYPE_BOOL: - indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = false;" << endl; + indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = false;" << '\n'; break; default: throw "unsupported type: " + base_type->get_name() + " for field " + field->get_name(); @@ -5461,7 +5458,7 @@ void t_java_generator::generate_java_struct_clear(std::ostream& out, t_struct* t } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } // generates java method to serialize (in the Java sense) the object @@ -5469,24 +5466,24 @@ void t_java_generator::generate_java_struct_write_object(ostream& out, t_struct* (void)tstruct; indent(out) << "private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {" - << endl; - indent(out) << " try {" << endl; + << '\n'; + indent(out) << " try {" << '\n'; indent(out) << " write(new org.apache.thrift.protocol.TCompactProtocol(new " "org.apache.thrift.transport.TIOStreamTransport(out)));" - << endl; - indent(out) << " } catch (org.apache.thrift.TException te) {" << endl; + << '\n'; + indent(out) << " } catch (org.apache.thrift.TException te) {" << '\n'; indent(out) << " throw new java.io.IOException(te" << (android_legacy_ ? ".getMessage()" : "") - << ");" << endl; - indent(out) << " }" << endl; - indent(out) << "}" << endl << endl; + << ");" << '\n'; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n' << '\n'; } // generates java method to serialize (in the Java sense) the object void t_java_generator::generate_java_struct_read_object(ostream& out, t_struct* tstruct) { indent(out) << "private void readObject(java.io.ObjectInputStream in) throws " "java.io.IOException, java.lang.ClassNotFoundException {" - << endl; - indent(out) << " try {" << endl; + << '\n'; + indent(out) << " try {" << '\n'; if (!tstruct->is_union()) { switch (needs_isset(tstruct)) { case ISSET_NONE: @@ -5494,174 +5491,174 @@ void t_java_generator::generate_java_struct_read_object(ostream& out, t_struct* case ISSET_PRIMITIVE: indent(out) << " // it doesn't seem like you should have to do this, but java " "serialization is wacky, and doesn't call the default constructor." - << endl; - indent(out) << " __isset_bitfield = 0;" << endl; + << '\n'; + indent(out) << " __isset_bitfield = 0;" << '\n'; break; case ISSET_BITSET: indent(out) << " // it doesn't seem like you should have to do this, but java " "serialization is wacky, and doesn't call the default constructor." - << endl; - indent(out) << " __isset_bit_vector = new java.util.BitSet(1);" << endl; + << '\n'; + indent(out) << " __isset_bit_vector = new java.util.BitSet(1);" << '\n'; break; } } indent(out) << " read(new org.apache.thrift.protocol.TCompactProtocol(new " "org.apache.thrift.transport.TIOStreamTransport(in)));" - << endl; - indent(out) << " } catch (org.apache.thrift.TException te) {" << endl; + << '\n'; + indent(out) << " } catch (org.apache.thrift.TException te) {" << '\n'; indent(out) << " throw new java.io.IOException(te" << (android_legacy_ ? ".getMessage()" : "") - << ");" << endl; - indent(out) << " }" << endl; - indent(out) << "}" << endl << endl; + << ");" << '\n'; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n' << '\n'; } void t_java_generator::generate_standard_reader(ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "public void read(org.apache.thrift.protocol.TProtocol iprot, " - << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << endl; + << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << '\n'; indent_up(); const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; // Declare stack tmp variables and read struct header - out << indent() << "org.apache.thrift.protocol.TField schemeField;" << endl - << indent() << "iprot.readStructBegin();" << endl; + out << indent() << "org.apache.thrift.protocol.TField schemeField;" << '\n' + << indent() << "iprot.readStructBegin();" << '\n'; // Loop over reading in fields - indent(out) << "while (true)" << endl; + indent(out) << "while (true)" << '\n'; scope_up(out); // Read beginning field marker - indent(out) << "schemeField = iprot.readFieldBegin();" << endl; + indent(out) << "schemeField = iprot.readFieldBegin();" << '\n'; // Check for field STOP marker and break - indent(out) << "if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { " << endl; + indent(out) << "if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { " << '\n'; indent_up(); - indent(out) << "break;" << endl; + indent(out) << "break;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; // Switch statement on the field we are reading - indent(out) << "switch (schemeField.id) {" << endl; + indent(out) << "switch (schemeField.id) {" << '\n'; indent_up(); // Generate deserialization code for known cases for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { indent(out) << "case " << (*f_iter)->get_key() << ": // " - << constant_name((*f_iter)->get_name()) << endl; + << constant_name((*f_iter)->get_name()) << '\n'; indent_up(); indent(out) << "if (schemeField.type == " << type_to_enum((*f_iter)->get_type()) << ") {" - << endl; + << '\n'; indent_up(); generate_deserialize_field(out, *f_iter, "struct.", true); indent(out) << "struct." << "set" << get_cap_name((*f_iter)->get_name()) << get_cap_name("isSet") - << "(true);" << endl; + << "(true);" << '\n'; indent_down(); - out << indent() << "} else { " << endl + out << indent() << "} else { " << '\n' << indent() << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);" - << endl - << indent() << "}" << endl - << indent() << "break;" << endl; + << '\n' + << indent() << "}" << '\n' + << indent() << "break;" << '\n'; indent_down(); } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent(out) << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; // Read field end marker - indent(out) << "iprot.readFieldEnd();" << endl; + indent(out) << "iprot.readFieldEnd();" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; - out << indent() << "iprot.readStructEnd();" << endl; + out << indent() << "iprot.readStructEnd();" << '\n'; // in non-beans style, check for required fields of primitive type // (which can be checked here but not in the general validate method) if (!bean_style_) { - out << endl + out << '\n' << indent() << "// check for required fields of primitive type, which can't be " "checked in the validate method" - << endl; + << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) { - out << indent() << "if (!struct." << generate_isset_check(*f_iter) << ") {" << endl + out << indent() << "if (!struct." << generate_isset_check(*f_iter) << ") {" << '\n' << indent() << " throw new org.apache.thrift.protocol.TProtocolException(\"Required field '" << (*f_iter)->get_name() - << "' was not found in serialized data! Struct: \" + toString());" << endl - << indent() << "}" << endl; + << "' was not found in serialized data! Struct: \" + toString());" << '\n' + << indent() << "}" << '\n'; } } } // performs various checks (e.g. check that all required fields are set) - indent(out) << "struct.validate();" << endl; + indent(out) << "struct.validate();" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } void t_java_generator::generate_standard_writer(ostream& out, t_struct* tstruct, bool is_result) { indent_up(); - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "public void write(org.apache.thrift.protocol.TProtocol oprot, " - << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << endl; + << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << '\n'; indent_up(); const vector& fields = tstruct->get_sorted_members(); vector::const_iterator f_iter; // performs various checks (e.g. check that all required fields are set) - indent(out) << "struct.validate();" << endl << endl; + indent(out) << "struct.validate();" << '\n' << '\n'; - indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl; + indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool null_allowed = type_can_be_null((*f_iter)->get_type()); if (null_allowed) { - out << indent() << "if (struct." << make_valid_java_identifier((*f_iter)->get_name()) << " != null) {" << endl; + out << indent() << "if (struct." << make_valid_java_identifier((*f_iter)->get_name()) << " != null) {" << '\n'; indent_up(); } bool optional = ((*f_iter)->get_req() == t_field::T_OPTIONAL) || (is_result && !null_allowed); if (optional) { indent(out) << "if (" - << "struct." << generate_isset_check((*f_iter)) << ") {" << endl; + << "struct." << generate_isset_check((*f_iter)) << ") {" << '\n'; indent_up(); } indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) - << "_FIELD_DESC);" << endl; + << "_FIELD_DESC);" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "struct.", "", true); // Write field closer - indent(out) << "oprot.writeFieldEnd();" << endl; + indent(out) << "oprot.writeFieldEnd();" << '\n'; if (optional) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } if (null_allowed) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } // Write the struct map - out << indent() << "oprot.writeFieldStop();" << endl - << indent() << "oprot.writeStructEnd();" << endl; + out << indent() << "oprot.writeFieldStop();" << '\n' + << indent() << "oprot.writeStructEnd();" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; indent_down(); } @@ -5670,38 +5667,38 @@ void t_java_generator::generate_java_struct_standard_scheme(ostream& out, bool is_result) { indent(out) << "private static class " << tstruct->get_name() << "StandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {" - << endl; + << '\n'; indent_up(); - indent(out) << java_override_annotation() << endl; - indent(out) << "public " << tstruct->get_name() << "StandardScheme getScheme() {" << endl; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public " << tstruct->get_name() << "StandardScheme getScheme() {" << '\n'; indent_up(); - indent(out) << "return new " << tstruct->get_name() << "StandardScheme();" << endl; + indent(out) << "return new " << tstruct->get_name() << "StandardScheme();" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; out << indent() << "private static class " << tstruct->get_name() << "StandardScheme extends org.apache.thrift.scheme.StandardScheme<" << make_valid_java_identifier(tstruct->get_name()) - << "> {" << endl - << endl; + << "> {" << '\n' + << '\n'; indent_up(); generate_standard_reader(out, tstruct); indent_down(); - out << endl; + out << '\n'; generate_standard_writer(out, tstruct, is_result); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_java_generator::generate_java_struct_tuple_reader(ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "public void read(org.apache.thrift.protocol.TProtocol prot, " - << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << endl; + << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << '\n'; indent_up(); indent(out) << "org.apache.thrift.protocol.TTupleProtocol iprot = " "(org.apache.thrift.protocol.TTupleProtocol) prot;" - << endl; + << '\n'; int optional_count = 0; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -5713,39 +5710,39 @@ void t_java_generator::generate_java_struct_tuple_reader(ostream& out, t_struct* if ((*f_iter)->get_req() == t_field::T_REQUIRED) { generate_deserialize_field(out, (*f_iter), "struct.", false); indent(out) << "struct.set" << get_cap_name((*f_iter)->get_name()) << get_cap_name("isSet") - << "(true);" << endl; + << "(true);" << '\n'; } } if (optional_count > 0) { indent(out) << "java.util.BitSet incoming = iprot.readBitSet(" << optional_count << ");" - << endl; + << '\n'; int i = 0; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_OPTIONAL || (*f_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT) { - indent(out) << "if (incoming.get(" << i << ")) {" << endl; + indent(out) << "if (incoming.get(" << i << ")) {" << '\n'; indent_up(); generate_deserialize_field(out, (*f_iter), "struct.", false); indent(out) << "struct.set" << get_cap_name((*f_iter)->get_name()) << get_cap_name("isSet") - << "(true);" << endl; + << "(true);" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; i++; } } } indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_java_generator::generate_java_struct_tuple_writer(ostream& out, t_struct* tstruct) { - indent(out) << java_override_annotation() << endl; + indent(out) << java_override_annotation() << '\n'; indent(out) << "public void write(org.apache.thrift.protocol.TProtocol prot, " - << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << endl; + << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << '\n'; indent_up(); indent(out) << "org.apache.thrift.protocol.TTupleProtocol oprot = " "(org.apache.thrift.protocol.TTupleProtocol) prot;" - << endl; + << '\n'; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -5762,70 +5759,70 @@ void t_java_generator::generate_java_struct_tuple_writer(ostream& out, t_struct* } } if (has_optional) { - indent(out) << "java.util.BitSet optionals = new java.util.BitSet();" << endl; + indent(out) << "java.util.BitSet optionals = new java.util.BitSet();" << '\n'; int i = 0; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_OPTIONAL || (*f_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT) { - indent(out) << "if (struct." << generate_isset_check((*f_iter)) << ") {" << endl; + indent(out) << "if (struct." << generate_isset_check((*f_iter)) << ") {" << '\n'; indent_up(); - indent(out) << "optionals.set(" << i << ");" << endl; + indent(out) << "optionals.set(" << i << ");" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; i++; } } - indent(out) << "oprot.writeBitSet(optionals, " << optional_count << ");" << endl; + indent(out) << "oprot.writeBitSet(optionals, " << optional_count << ");" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_OPTIONAL || (*f_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT) { - indent(out) << "if (struct." << generate_isset_check(*f_iter) << ") {" << endl; + indent(out) << "if (struct." << generate_isset_check(*f_iter) << ") {" << '\n'; indent_up(); generate_serialize_field(out, (*f_iter), "struct.", "", false); indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } } indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_java_generator::generate_java_struct_tuple_scheme(ostream& out, t_struct* tstruct) { indent(out) << "private static class " << tstruct->get_name() - << "TupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {" << endl; + << "TupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {" << '\n'; indent_up(); - indent(out) << java_override_annotation() << endl; - indent(out) << "public " << tstruct->get_name() << "TupleScheme getScheme() {" << endl; + indent(out) << java_override_annotation() << '\n'; + indent(out) << "public " << tstruct->get_name() << "TupleScheme getScheme() {" << '\n'; indent_up(); - indent(out) << "return new " << tstruct->get_name() << "TupleScheme();" << endl; + indent(out) << "return new " << tstruct->get_name() << "TupleScheme();" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; out << indent() << "private static class " << tstruct->get_name() << "TupleScheme extends org.apache.thrift.scheme.TupleScheme<" << make_valid_java_identifier(tstruct->get_name()) << "> {" - << endl - << endl; + << '\n' + << '\n'; indent_up(); generate_java_struct_tuple_writer(out, tstruct); - out << endl; + out << '\n'; generate_java_struct_tuple_reader(out, tstruct); indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_java_generator::generate_java_scheme_lookup(ostream& out) { indent(out) << "private static S scheme(" - << "org.apache.thrift.protocol.TProtocol proto) {" << endl; + << "org.apache.thrift.protocol.TProtocol proto) {" << '\n'; indent_up(); indent(out) << "return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) " << "? STANDARD_SCHEME_FACTORY " << ": TUPLE_SCHEME_FACTORY" - << ").getScheme();" << endl; + << ").getScheme();" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_java_generator::generate_javax_generated_annotation(ostream& out) { @@ -5838,11 +5835,11 @@ void t_java_generator::generate_javax_generated_annotation(ostream& out) { } if (undated_generated_annotations_) { - out << ")" << endl; + out << ")" << '\n'; } else { indent(out) << ", date = \"" << (now->tm_year + 1900) << "-" << setfill('0') << setw(2) << (now->tm_mon + 1) << "-" << setfill('0') << setw(2) << now->tm_mday << "\")" - << endl; + << '\n'; } } diff --git a/compiler/cpp/src/thrift/generate/t_javame_generator.cc b/compiler/cpp/src/thrift/generate/t_javame_generator.cc index d8d9056306c..e2c3a395cdc 100644 --- a/compiler/cpp/src/thrift/generate/t_javame_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_javame_generator.cc @@ -37,8 +37,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * Java code generator. * @@ -339,7 +337,7 @@ void t_javame_generator::generate_enum(t_enum* tenum) { generate_java_doc(f_enum, tenum); indent(f_enum) << "public class " << tenum->get_name() << " implements org.apache.thrift.TEnum "; scope_up(f_enum); - f_enum << endl; + f_enum << '\n'; vector constants = tenum->get_constants(); vector::iterator c_iter; @@ -347,53 +345,53 @@ void t_javame_generator::generate_enum(t_enum* tenum) { int value = (*c_iter)->get_value(); generate_java_doc(f_enum, *c_iter); indent(f_enum) << "public static final " << tenum->get_name() << " " << (*c_iter)->get_name() - << " = new " << tenum->get_name() << "(" << value << ");" << endl; + << " = new " << tenum->get_name() << "(" << value << ");" << '\n'; } - f_enum << endl; + f_enum << '\n'; // Field for thriftCode - indent(f_enum) << "private final int value;" << endl << endl; + indent(f_enum) << "private final int value;" << '\n' << '\n'; - indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << endl; - indent(f_enum) << " this.value = value;" << endl; - indent(f_enum) << "}" << endl << endl; + indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << '\n'; + indent(f_enum) << " this.value = value;" << '\n'; + indent(f_enum) << "}" << '\n' << '\n'; - indent(f_enum) << "/**" << endl; + indent(f_enum) << "/**" << '\n'; indent(f_enum) << " * Get the integer value of this enum value, as defined in the Thrift IDL." - << endl; - indent(f_enum) << " */" << endl; - indent(f_enum) << "public int getValue() {" << endl; - indent(f_enum) << " return value;" << endl; - indent(f_enum) << "}" << endl << endl; + << '\n'; + indent(f_enum) << " */" << '\n'; + indent(f_enum) << "public int getValue() {" << '\n'; + indent(f_enum) << " return value;" << '\n'; + indent(f_enum) << "}" << '\n' << '\n'; - indent(f_enum) << "/**" << endl; + indent(f_enum) << "/**" << '\n'; indent(f_enum) << " * Find a the enum type by its integer value, as defined in the Thrift IDL." - << endl; - indent(f_enum) << " * @return null if the value is not found." << endl; - indent(f_enum) << " */" << endl; - indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << endl; + << '\n'; + indent(f_enum) << " * @return null if the value is not found." << '\n'; + indent(f_enum) << " */" << '\n'; + indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << '\n'; indent_up(); - indent(f_enum) << "switch (value) {" << endl; + indent(f_enum) << "switch (value) {" << '\n'; indent_up(); for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); - indent(f_enum) << "case " << value << ":" << endl; - indent(f_enum) << " return " << (*c_iter)->get_name() << ";" << endl; + indent(f_enum) << "case " << value << ":" << '\n'; + indent(f_enum) << " return " << (*c_iter)->get_name() << ";" << '\n'; } - indent(f_enum) << "default:" << endl; - indent(f_enum) << " return null;" << endl; + indent(f_enum) << "default:" << '\n'; + indent(f_enum) << " return null;" << '\n'; indent_down(); - indent(f_enum) << "}" << endl; + indent(f_enum) << "}" << '\n'; indent_down(); - indent(f_enum) << "}" << endl; + indent(f_enum) << "}" << '\n'; scope_down(f_enum); @@ -415,7 +413,7 @@ void t_javame_generator::generate_consts(std::vector consts) { // Print header f_consts << autogen_comment() << java_package() << java_type_imports(); - f_consts << "public class " << program_name_ << "Constants {" << endl << endl; + f_consts << "public class " << program_name_ << "Constants {" << '\n' << '\n'; indent_up(); vector::iterator c_iter; for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { @@ -426,7 +424,7 @@ void t_javame_generator::generate_consts(std::vector consts) { false); } indent_down(); - indent(f_consts) << "}" << endl; + indent(f_consts) << "}" << '\n'; f_consts.close(); } @@ -449,17 +447,17 @@ void t_javame_generator::print_const_value(std::ostream& out, } if (type->is_base_type()) { string v2 = render_const_value(out, name, type, value); - out << name << " = " << v2 << ";" << endl << endl; + out << name << " = " << v2 << ";" << '\n' << '\n'; } else if (type->is_enum()) { - out << name << " = " << render_const_value(out, name, type, value) << ";" << endl << endl; + out << name << " = " << render_const_value(out, name, type, value) << ";" << '\n' << '\n'; } else if (type->is_struct() || type->is_xception()) { const vector& fields = ((t_struct*)type)->get_members(); vector::const_iterator f_iter; const map& val = value->get_map(); map::const_iterator v_iter; - out << name << " = new " << type_name(type, false, true) << "();" << endl; + out << name << " = new " << type_name(type, false, true) << "();" << '\n'; if (!in_static) { - indent(out) << "static {" << endl; + indent(out) << "static {" << '\n'; indent_up(); } for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { @@ -475,17 +473,17 @@ void t_javame_generator::print_const_value(std::ostream& out, string val = render_const_value(out, name, field_type, v_iter->second); indent(out) << name << "."; std::string cap_name = get_cap_name(v_iter->first->get_string()); - out << "set" << cap_name << "(" << val << ");" << endl; + out << "set" << cap_name << "(" << val << ");" << '\n'; } if (!in_static) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - out << endl; + out << '\n'; } else if (type->is_map()) { - out << name << " = new " << type_name(type, false, true) << "();" << endl; + out << name << " = new " << type_name(type, false, true) << "();" << '\n'; if (!in_static) { - indent(out) << "static {" << endl; + indent(out) << "static {" << '\n'; indent_up(); } t_type* ktype = ((t_map*)type)->get_key_type(); @@ -496,17 +494,17 @@ void t_javame_generator::print_const_value(std::ostream& out, string key = render_const_value(out, name, ktype, v_iter->first); string val = render_const_value(out, name, vtype, v_iter->second); indent(out) << name << ".put(" << box_type(ktype, key) << ", " << box_type(vtype, val) << ");" - << endl; + << '\n'; } if (!in_static) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - out << endl; + out << '\n'; } else if (type->is_list() || type->is_set()) { - out << name << " = new " << type_name(type, false, true) << "();" << endl; + out << name << " = new " << type_name(type, false, true) << "();" << '\n'; if (!in_static) { - indent(out) << "static {" << endl; + indent(out) << "static {" << '\n'; indent_up(); } t_type* etype; @@ -520,17 +518,17 @@ void t_javame_generator::print_const_value(std::ostream& out, for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string val = render_const_value(out, name, etype, *v_iter); if (type->is_list()) { - indent(out) << name << ".addElement(" << box_type(etype, val) << ");" << endl; + indent(out) << name << ".addElement(" << box_type(etype, val) << ");" << '\n'; } else { indent(out) << name << ".put(" << box_type(etype, val) << ", " << box_type(etype, val) - << ");" << endl; + << ");" << '\n'; } } if (!in_static) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - out << endl; + out << '\n'; } else { throw "compiler error: no const of type " + type->get_name(); } @@ -673,27 +671,27 @@ void t_javame_generator::generate_java_union(t_struct* tstruct) { generate_struct_desc(f_struct, tstruct); generate_field_descs(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_union_constructor(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_union_abstract_methods(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_union_getters_and_setters(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_union_comparisons(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; generate_union_hashcode(f_struct, tstruct); - f_struct << endl; + f_struct << '\n'; scope_down(f_struct); @@ -701,33 +699,33 @@ void t_javame_generator::generate_java_union(t_struct* tstruct) { } void t_javame_generator::generate_union_constructor(ostream& out, t_struct* tstruct) { - indent(out) << "public " << type_name(tstruct) << "() {" << endl; - indent(out) << " super();" << endl; - indent(out) << "}" << endl << endl; + indent(out) << "public " << type_name(tstruct) << "() {" << '\n'; + indent(out) << " super();" << '\n'; + indent(out) << "}" << '\n' << '\n'; - indent(out) << "public " << type_name(tstruct) << "(_Fields setField, Object value) {" << endl; - indent(out) << " super(setField, value);" << endl; - indent(out) << "}" << endl << endl; + indent(out) << "public " << type_name(tstruct) << "(_Fields setField, Object value) {" << '\n'; + indent(out) << " super(setField, value);" << '\n'; + indent(out) << "}" << '\n' << '\n'; indent(out) << "public " << type_name(tstruct) << "(" << type_name(tstruct) << " other) {" - << endl; - indent(out) << " super(other);" << endl; - indent(out) << "}" << endl; + << '\n'; + indent(out) << " super(other);" << '\n'; + indent(out) << "}" << '\n'; - indent(out) << "public " << tstruct->get_name() << " deepCopy() {" << endl; - indent(out) << " return new " << tstruct->get_name() << "(this);" << endl; - indent(out) << "}" << endl << endl; + indent(out) << "public " << tstruct->get_name() << " deepCopy() {" << '\n'; + indent(out) << " return new " << tstruct->get_name() << "(this);" << '\n'; + indent(out) << "}" << '\n' << '\n'; // generate "constructors" for each field const vector& members = tstruct->get_members(); vector::const_iterator m_iter; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "(" - << type_name((*m_iter)->get_type()) << " value) {" << endl; - indent(out) << " " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << endl; - indent(out) << " x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << endl; - indent(out) << " return x;" << endl; - indent(out) << "}" << endl << endl; + << type_name((*m_iter)->get_type()) << " value) {" << '\n'; + indent(out) << " " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << '\n'; + indent(out) << " x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << '\n'; + indent(out) << " return x;" << '\n'; + indent(out) << "}" << '\n' << '\n'; } } @@ -740,59 +738,59 @@ void t_javame_generator::generate_union_getters_and_setters(ostream& out, t_stru if (first) { first = false; } else { - out << endl; + out << '\n'; } t_field* field = (*m_iter); generate_java_doc(out, field); indent(out) << "public " << type_name(field->get_type()) << " get" - << get_cap_name(field->get_name()) << "() {" << endl; + << get_cap_name(field->get_name()) << "() {" << '\n'; indent(out) << " if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {" - << endl; + << '\n'; indent(out) << " return (" << type_name(field->get_type(), true) << ")getFieldValue();" - << endl; - indent(out) << " } else {" << endl; + << '\n'; + indent(out) << " } else {" << '\n'; indent(out) << " throw new RuntimeException(\"Cannot get field '" << field->get_name() << "' because union is currently set to \" + getFieldDesc(getSetField()).name);" - << endl; - indent(out) << " }" << endl; - indent(out) << "}" << endl; + << '\n'; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n'; - out << endl; + out << '\n'; generate_java_doc(out, field); indent(out) << "public void set" << get_cap_name(field->get_name()) << "(" - << type_name(field->get_type()) << " value) {" << endl; + << type_name(field->get_type()) << " value) {" << '\n'; if (type_can_be_null(field->get_type())) { - indent(out) << " if (value == null) throw new NullPointerException();" << endl; + indent(out) << " if (value == null) throw new NullPointerException();" << '\n'; } - indent(out) << " setField_ = _Fields." << constant_name(field->get_name()) << ";" << endl; - indent(out) << " value_ = value;" << endl; - indent(out) << "}" << endl; + indent(out) << " setField_ = _Fields." << constant_name(field->get_name()) << ";" << '\n'; + indent(out) << " value_ = value;" << '\n'; + indent(out) << "}" << '\n'; } } void t_javame_generator::generate_union_abstract_methods(ostream& out, t_struct* tstruct) { generate_check_type(out, tstruct); - out << endl; + out << '\n'; generate_read_value(out, tstruct); - out << endl; + out << '\n'; generate_write_value(out, tstruct); - out << endl; + out << '\n'; generate_get_field_desc(out, tstruct); - out << endl; + out << '\n'; generate_get_struct_desc(out, tstruct); - out << endl; + out << '\n'; } void t_javame_generator::generate_check_type(ostream& out, t_struct* tstruct) { indent(out) << "protected void checkType(_Fields setField, Object value) throws ClassCastException {" - << endl; + << '\n'; indent_up(); - indent(out) << "switch (setField) {" << endl; + indent(out) << "switch (setField) {" << '\n'; indent_up(); const vector& members = tstruct->get_members(); @@ -801,37 +799,37 @@ void t_javame_generator::generate_check_type(ostream& out, t_struct* tstruct) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = (*m_iter); - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; indent(out) << " if (value instanceof " << type_name(field->get_type(), true, false, true) - << ") {" << endl; - indent(out) << " break;" << endl; - indent(out) << " }" << endl; + << ") {" << '\n'; + indent(out) << " break;" << '\n'; + indent(out) << " }" << '\n'; indent(out) << " throw new ClassCastException(\"Was expecting value of type " << type_name(field->get_type(), true, false) << " for field '" << field->get_name() - << "', but got \" + value.getClass().getSimpleName());" << endl; + << "', but got \" + value.getClass().getSimpleName());" << '\n'; // do the real check here } - indent(out) << "default:" << endl; - indent(out) << " throw new IllegalArgumentException(\"Unknown field id \" + setField);" << endl; + indent(out) << "default:" << '\n'; + indent(out) << " throw new IllegalArgumentException(\"Unknown field id \" + setField);" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_javame_generator::generate_read_value(ostream& out, t_struct* tstruct) { indent(out) << "protected Object readValue(TProtocol iprot, TField field) throws TException {" - << endl; + << '\n'; indent_up(); - indent(out) << "_Fields setField = _Fields.findByThriftId(field.id);" << endl; - indent(out) << "if (setField != null) {" << endl; + indent(out) << "_Fields setField = _Fields.findByThriftId(field.id);" << '\n'; + indent(out) << "if (setField != null) {" << '\n'; indent_up(); - indent(out) << "switch (setField) {" << endl; + indent(out) << "switch (setField) {" << '\n'; indent_up(); const vector& members = tstruct->get_members(); @@ -840,48 +838,48 @@ void t_javame_generator::generate_read_value(ostream& out, t_struct* tstruct) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = (*m_iter); - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; indent_up(); indent(out) << "if (field.type == " << constant_name(field->get_name()) << "_FIELD_DESC.type) {" - << endl; + << '\n'; indent_up(); indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";" - << endl; + << '\n'; generate_deserialize_field(out, field, ""); - indent(out) << "return " << field->get_name() << ";" << endl; + indent(out) << "return " << field->get_name() << ";" << '\n'; indent_down(); - indent(out) << "} else {" << endl; - indent(out) << " TProtocolUtil.skip(iprot, field.type);" << endl; - indent(out) << " return null;" << endl; - indent(out) << "}" << endl; + indent(out) << "} else {" << '\n'; + indent(out) << " TProtocolUtil.skip(iprot, field.type);" << '\n'; + indent(out) << " return null;" << '\n'; + indent(out) << "}" << '\n'; indent_down(); } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent(out) << " throw new IllegalStateException(\"setField wasn't null, but didn't match any " - "of the case statements!\");" << endl; + "of the case statements!\");" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent_up(); - indent(out) << "TProtocolUtil.skip(iprot, field.type);" << endl; - indent(out) << "return null;" << endl; + indent(out) << "TProtocolUtil.skip(iprot, field.type);" << '\n'; + indent(out) << "return null;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_javame_generator::generate_write_value(ostream& out, t_struct* tstruct) { - indent(out) << "protected void writeValue(TProtocol oprot) throws TException {" << endl; + indent(out) << "protected void writeValue(TProtocol oprot) throws TException {" << '\n'; indent_up(); - indent(out) << "switch (setField_) {" << endl; + indent(out) << "switch (setField_) {" << '\n'; indent_up(); const vector& members = tstruct->get_members(); @@ -890,100 +888,100 @@ void t_javame_generator::generate_write_value(ostream& out, t_struct* tstruct) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = (*m_iter); - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; indent_up(); indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << " = (" - << type_name(field->get_type(), true, false) << ")value_;" << endl; + << type_name(field->get_type(), true, false) << ")value_;" << '\n'; generate_serialize_field(out, field, ""); - indent(out) << "return;" << endl; + indent(out) << "return;" << '\n'; indent_down(); } - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent(out) << " throw new IllegalStateException(\"Cannot write union with unknown field \" + " - "setField_);" << endl; + "setField_);" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_javame_generator::generate_get_field_desc(ostream& out, t_struct* tstruct) { - indent(out) << "protected TField getFieldDesc(_Fields setField) {" << endl; + indent(out) << "protected TField getFieldDesc(_Fields setField) {" << '\n'; indent_up(); const vector& members = tstruct->get_members(); vector::const_iterator m_iter; - indent(out) << "switch (setField) {" << endl; + indent(out) << "switch (setField) {" << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = (*m_iter); - indent(out) << "case " << constant_name(field->get_name()) << ":" << endl; - indent(out) << " return " << constant_name(field->get_name()) << "_FIELD_DESC;" << endl; + indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n'; + indent(out) << " return " << constant_name(field->get_name()) << "_FIELD_DESC;" << '\n'; } - indent(out) << "default:" << endl; - indent(out) << " throw new IllegalArgumentException(\"Unknown field id \" + setField);" << endl; + indent(out) << "default:" << '\n'; + indent(out) << " throw new IllegalArgumentException(\"Unknown field id \" + setField);" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_javame_generator::generate_get_struct_desc(ostream& out, t_struct* tstruct) { (void)tstruct; - indent(out) << "protected TStruct getStructDesc() {" << endl; - indent(out) << " return STRUCT_DESC;" << endl; - indent(out) << "}" << endl; + indent(out) << "protected TStruct getStructDesc() {" << '\n'; + indent(out) << " return STRUCT_DESC;" << '\n'; + indent(out) << "}" << '\n'; } void t_javame_generator::generate_union_comparisons(ostream& out, t_struct* tstruct) { // equality - indent(out) << "public boolean equals(Object other) {" << endl; - indent(out) << " if (other instanceof " << tstruct->get_name() << ") {" << endl; - indent(out) << " return equals((" << tstruct->get_name() << ")other);" << endl; - indent(out) << " } else {" << endl; - indent(out) << " return false;" << endl; - indent(out) << " }" << endl; - indent(out) << "}" << endl; + indent(out) << "public boolean equals(Object other) {" << '\n'; + indent(out) << " if (other instanceof " << tstruct->get_name() << ") {" << '\n'; + indent(out) << " return equals((" << tstruct->get_name() << ")other);" << '\n'; + indent(out) << " } else {" << '\n'; + indent(out) << " return false;" << '\n'; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n'; - out << endl; + out << '\n'; - indent(out) << "public boolean equals(" << tstruct->get_name() << " other) {" << endl; + indent(out) << "public boolean equals(" << tstruct->get_name() << " other) {" << '\n'; indent(out) << " return other != null && getSetField() == other.getSetField() && " - "getFieldValue().equals(other.getFieldValue());" << endl; - indent(out) << "}" << endl; - out << endl; + "getFieldValue().equals(other.getFieldValue());" << '\n'; + indent(out) << "}" << '\n'; + out << '\n'; - indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl; + indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << '\n'; indent(out) << " int lastComparison = TBaseHelper.compareTo(getSetField(), other.getSetField());" - << endl; - indent(out) << " if (lastComparison == 0) {" << endl; + << '\n'; + indent(out) << " if (lastComparison == 0) {" << '\n'; indent(out) << " return TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());" - << endl; - indent(out) << " }" << endl; - indent(out) << " return lastComparison;" << endl; - indent(out) << "}" << endl; - out << endl; + << '\n'; + indent(out) << " }" << '\n'; + indent(out) << " return lastComparison;" << '\n'; + indent(out) << "}" << '\n'; + out << '\n'; } void t_javame_generator::generate_union_hashcode(ostream& out, t_struct* tstruct) { (void)tstruct; - indent(out) << "/**" << endl; + indent(out) << "/**" << '\n'; indent(out) << " * If you'd like this to perform more respectably, use the hashcode generator option." - << endl; - indent(out) << " */" << endl; - indent(out) << "public int hashCode() {" << endl; - indent(out) << " return 0;" << endl; - indent(out) << "}" << endl; + << '\n'; + indent(out) << " */" << '\n'; + indent(out) << "public int hashCode() {" << '\n'; + indent(out) << " return 0;" << '\n'; + indent(out) << "}" << '\n'; } /** @@ -1021,43 +1019,43 @@ void t_javame_generator::generate_java_struct_definition(ostream& out, const vector& members = tstruct->get_members(); vector::const_iterator m_iter; - out << endl; + out << '\n'; generate_field_descs(out, tstruct); - out << endl; + out << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { indent(out) << "private "; - out << declare_field(*m_iter, false) << endl; + out << declare_field(*m_iter, false) << '\n'; } // isset data if (members.size() > 0) { - out << endl; + out << '\n'; - indent(out) << "// isset id assignments" << endl; + indent(out) << "// isset id assignments" << '\n'; int i = 0; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if (!type_can_be_null((*m_iter)->get_type())) { indent(out) << "private static final int " << isset_field_id(*m_iter) << " = " << i << ";" - << endl; + << '\n'; i++; } } if (i > 0) { - indent(out) << "private boolean[] __isset_vector = new boolean[" << i << "];" << endl; + indent(out) << "private boolean[] __isset_vector = new boolean[" << i << "];" << '\n'; } - out << endl; + out << '\n'; } bool all_optional_members = true; // Default constructor - indent(out) << "public " << tstruct->get_name() << "() {" << endl; + indent(out) << "public " << tstruct->get_name() << "() {" << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* t = get_true_type((*m_iter)->get_type()); @@ -1074,49 +1072,49 @@ void t_javame_generator::generate_java_struct_definition(ostream& out, } } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; if (!members.empty() && !all_optional_members) { // Full constructor for all fields - indent(out) << "public " << tstruct->get_name() << "(" << endl; + indent(out) << "public " << tstruct->get_name() << "(" << '\n'; indent_up(); bool first = true; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_req() != t_field::T_OPTIONAL) { if (!first) { - out << "," << endl; + out << "," << '\n'; } first = false; indent(out) << type_name((*m_iter)->get_type()) << " " << (*m_iter)->get_name(); } } - out << ")" << endl; + out << ")" << '\n'; indent_down(); - indent(out) << "{" << endl; + indent(out) << "{" << '\n'; indent_up(); - indent(out) << "this();" << endl; + indent(out) << "this();" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if ((*m_iter)->get_req() != t_field::T_OPTIONAL) { indent(out) << "this." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << ";" - << endl; + << '\n'; generate_isset_set(out, (*m_iter)); } } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } // copy constructor - indent(out) << "/**" << endl; - indent(out) << " * Performs a deep copy on other." << endl; - indent(out) << " */" << endl; + indent(out) << "/**" << '\n'; + indent(out) << " * Performs a deep copy on other." << '\n'; + indent(out) << " */" << '\n'; indent(out) << "public " << tstruct->get_name() << "(" << tstruct->get_name() << " other) {" - << endl; + << '\n'; indent_up(); if (has_bit_vector(tstruct)) { indent(out) << "System.arraycopy(other.__isset_vector, 0, __isset_vector, 0, " - "other.__isset_vector.length);" << endl; + "other.__isset_vector.length);" << '\n'; } for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -1126,32 +1124,32 @@ void t_javame_generator::generate_java_struct_definition(ostream& out, bool can_be_null = type_can_be_null(type); if (can_be_null) { - indent(out) << "if (other." << generate_isset_check(field) << ") {" << endl; + indent(out) << "if (other." << generate_isset_check(field) << ") {" << '\n'; indent_up(); } if (type->is_container()) { generate_deep_copy_container(out, "other", field_name, "__this__" + field_name, type); - indent(out) << "this." << field_name << " = __this__" << field_name << ";" << endl; + indent(out) << "this." << field_name << " = __this__" << field_name << ";" << '\n'; } else { indent(out) << "this." << field_name << " = "; generate_deep_copy_non_container(out, "other." + field_name, field_name, type); - out << ";" << endl; + out << ";" << '\n'; } if (can_be_null) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // clone method, so that you can deep copy an object when you don't know its class. - indent(out) << "public " << tstruct->get_name() << " deepCopy() {" << endl; - indent(out) << " return new " << tstruct->get_name() << "(this);" << endl; - indent(out) << "}" << endl << endl; + indent(out) << "public " << tstruct->get_name() << " deepCopy() {" << '\n'; + indent(out) << " return new " << tstruct->get_name() << "(this);" << '\n'; + indent(out) << "}" << '\n' << '\n'; generate_java_struct_clear(out, tstruct); @@ -1170,7 +1168,7 @@ void t_javame_generator::generate_java_struct_definition(ostream& out, generate_java_struct_tostring(out, tstruct); generate_java_validator(out, tstruct); scope_down(out); - out << endl; + out << '\n'; } /** @@ -1179,24 +1177,24 @@ void t_javame_generator::generate_java_struct_definition(ostream& out, * @param tstruct The struct definition */ void t_javame_generator::generate_java_struct_equality(ostream& out, t_struct* tstruct) { - out << indent() << "public boolean equals(Object that) {" << endl; + out << indent() << "public boolean equals(Object that) {" << '\n'; indent_up(); - out << indent() << "if (that == null)" << endl << indent() << " return false;" << endl - << indent() << "if (that instanceof " << tstruct->get_name() << ")" << endl << indent() - << " return this.equals((" << tstruct->get_name() << ")that);" << endl << indent() - << "return false;" << endl; + out << indent() << "if (that == null)" << '\n' << indent() << " return false;" << '\n' + << indent() << "if (that instanceof " << tstruct->get_name() << ")" << '\n' << indent() + << " return this.equals((" << tstruct->get_name() << ")that);" << '\n' << indent() + << "return false;" << '\n'; scope_down(out); - out << endl; + out << '\n'; - out << indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << endl; + out << indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << '\n'; indent_up(); - out << indent() << "if (that == null)" << endl << indent() << " return false;" << endl - << indent() << "if (this == that)" << endl << indent() << " return true;" << endl; + out << indent() << "if (that == null)" << '\n' << indent() << " return false;" << '\n' + << indent() << "if (this == that)" << '\n' << indent() << " return true;" << '\n'; const vector& members = tstruct->get_members(); vector::const_iterator m_iter; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - out << endl; + out << '\n'; t_type* t = get_true_type((*m_iter)->get_type()); // Most existing Thrift code does not use isset or optional/required, @@ -1214,14 +1212,14 @@ void t_javame_generator::generate_java_struct_equality(ostream& out, t_struct* t that_present += " && that." + generate_isset_check(*m_iter); } - out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << endl - << indent() << "boolean that_present_" << name << " = " << that_present << ";" << endl + out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << '\n' + << indent() << "boolean that_present_" << name << " = " << that_present << ";" << '\n' << indent() << "if (" - << "this_present_" << name << " || that_present_" << name << ") {" << endl; + << "this_present_" << name << " || that_present_" << name << ") {" << '\n'; indent_up(); out << indent() << "if (!(" - << "this_present_" << name << " && that_present_" << name << "))" << endl << indent() - << " return false;" << endl; + << "this_present_" << name << " && that_present_" << name << "))" << '\n' << indent() + << " return false;" << '\n'; if (t->is_binary()) { unequal = "TBaseHelper.compareTo(this." + name + ", that." + name + ") != 0"; @@ -1231,66 +1229,66 @@ void t_javame_generator::generate_java_struct_equality(ostream& out, t_struct* t unequal = "this." + name + " != that." + name; } - out << indent() << "if (" << unequal << ")" << endl << indent() << " return false;" << endl; + out << indent() << "if (" << unequal << ")" << '\n' << indent() << " return false;" << '\n'; scope_down(out); } - out << endl; - indent(out) << "return true;" << endl; + out << '\n'; + indent(out) << "return true;" << '\n'; scope_down(out); - out << endl; + out << '\n'; - out << indent() << "public int hashCode() {" << endl; + out << indent() << "public int hashCode() {" << '\n'; indent_up(); - indent(out) << "return 0;" << endl; + indent(out) << "return 0;" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } void t_javame_generator::generate_java_struct_compare_to(ostream& out, t_struct* tstruct) { - indent(out) << "public int compareTo(Object otherObject) {" << endl; - // indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl; + indent(out) << "public int compareTo(Object otherObject) {" << '\n'; + // indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << '\n'; indent_up(); - indent(out) << "if (!getClass().equals(otherObject.getClass())) {" << endl; + indent(out) << "if (!getClass().equals(otherObject.getClass())) {" << '\n'; indent(out) << " return getClass().getName().compareTo(otherObject.getClass().getName());" - << endl; - indent(out) << "}" << endl; - out << endl; + << '\n'; + indent(out) << "}" << '\n'; + out << '\n'; indent(out) << type_name(tstruct) << " other = (" << type_name(tstruct) << ")otherObject;"; - indent(out) << "int lastComparison = 0;" << endl; - out << endl; + indent(out) << "int lastComparison = 0;" << '\n'; + out << '\n'; const vector& members = tstruct->get_members(); vector::const_iterator m_iter; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* field = *m_iter; indent(out) << "lastComparison = TBaseHelper.compareTo(" << generate_isset_check(field) - << ", other." << generate_isset_check(field) << ");" << endl; - indent(out) << "if (lastComparison != 0) {" << endl; - indent(out) << " return lastComparison;" << endl; - indent(out) << "}" << endl; + << ", other." << generate_isset_check(field) << ");" << '\n'; + indent(out) << "if (lastComparison != 0) {" << '\n'; + indent(out) << " return lastComparison;" << '\n'; + indent(out) << "}" << '\n'; - indent(out) << "if (" << generate_isset_check(field) << ") {" << endl; + indent(out) << "if (" << generate_isset_check(field) << ") {" << '\n'; if (field->get_type()->is_struct() || field->get_type()->is_xception()) { indent(out) << " lastComparison = this." << field->get_name() << ".compareTo(other." - << field->get_name() << ");" << endl; + << field->get_name() << ");" << '\n'; } else { indent(out) << " lastComparison = TBaseHelper.compareTo(this." << field->get_name() - << ", other." << field->get_name() << ");" << endl; + << ", other." << field->get_name() << ");" << '\n'; } - indent(out) << " if (lastComparison != 0) {" << endl; - indent(out) << " return lastComparison;" << endl; - indent(out) << " }" << endl; - indent(out) << "}" << endl; + indent(out) << " if (lastComparison != 0) {" << '\n'; + indent(out) << " return lastComparison;" << '\n'; + indent(out) << " }" << '\n'; + indent(out) << "}" << '\n'; } - indent(out) << "return 0;" << endl; + indent(out) << "return 0;" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -1299,91 +1297,91 @@ void t_javame_generator::generate_java_struct_compare_to(ostream& out, t_struct* * @param tstruct The struct definition */ void t_javame_generator::generate_java_struct_reader(ostream& out, t_struct* tstruct) { - out << indent() << "public void read(TProtocol iprot) throws TException {" << endl; + out << indent() << "public void read(TProtocol iprot) throws TException {" << '\n'; indent_up(); const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; // Declare stack tmp variables and read struct header - out << indent() << "TField field;" << endl << indent() << "iprot.readStructBegin();" << endl; + out << indent() << "TField field;" << '\n' << indent() << "iprot.readStructBegin();" << '\n'; // Loop over reading in fields - indent(out) << "while (true)" << endl; + indent(out) << "while (true)" << '\n'; scope_up(out); // Read beginning field marker - indent(out) << "field = iprot.readFieldBegin();" << endl; + indent(out) << "field = iprot.readFieldBegin();" << '\n'; // Check for field STOP marker and break - indent(out) << "if (field.type == TType.STOP) { " << endl; + indent(out) << "if (field.type == TType.STOP) { " << '\n'; indent_up(); - indent(out) << "break;" << endl; + indent(out) << "break;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; // Switch statement on the field we are reading - indent(out) << "switch (field.id) {" << endl; + indent(out) << "switch (field.id) {" << '\n'; indent_up(); // Generate deserialization code for known cases for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { indent(out) << "case " << (*f_iter)->get_key() << ": // " - << constant_name((*f_iter)->get_name()) << endl; + << constant_name((*f_iter)->get_name()) << '\n'; indent_up(); - indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl; + indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n'; indent_up(); generate_deserialize_field(out, *f_iter, "this."); generate_isset_set(out, *f_iter); indent_down(); - out << indent() << "} else { " << endl << indent() << " TProtocolUtil.skip(iprot, field.type);" - << endl << indent() << "}" << endl << indent() << "break;" << endl; + out << indent() << "} else { " << '\n' << indent() << " TProtocolUtil.skip(iprot, field.type);" + << '\n' << indent() << "}" << '\n' << indent() << "break;" << '\n'; indent_down(); } - indent(out) << "default:" << endl; - indent(out) << " TProtocolUtil.skip(iprot, field.type);" << endl; + indent(out) << "default:" << '\n'; + indent(out) << " TProtocolUtil.skip(iprot, field.type);" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; // Read field end marker - indent(out) << "iprot.readFieldEnd();" << endl; + indent(out) << "iprot.readFieldEnd();" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; - out << indent() << "iprot.readStructEnd();" << endl; + out << indent() << "iprot.readStructEnd();" << '\n'; // performs various checks (e.g. check that all required fields are set) - indent(out) << "validate();" << endl; + indent(out) << "validate();" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } // generates java method to perform various checks // (e.g. check that all required fields are set) void t_javame_generator::generate_java_validator(ostream& out, t_struct* tstruct) { - indent(out) << "public void validate() throws TException {" << endl; + indent(out) << "public void validate() throws TException {" << '\n'; indent_up(); const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - out << indent() << "// check for required fields" << endl; + out << indent() << "// check for required fields" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { - out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl << indent() + out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << '\n' << indent() << " throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() - << "' is unset! Struct:\" + toString());" << endl << indent() << "}" << endl << endl; + << "' is unset! Struct:\" + toString());" << '\n' << indent() << "}" << '\n' << '\n'; } } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -1392,7 +1390,7 @@ void t_javame_generator::generate_java_validator(ostream& out, t_struct* tstruct * @param tstruct The struct definition */ void t_javame_generator::generate_java_struct_writer(ostream& out, t_struct* tstruct) { - out << indent() << "public void write(TProtocol oprot) throws TException {" << endl; + out << indent() << "public void write(TProtocol oprot) throws TException {" << '\n'; indent_up(); string name = tstruct->get_name(); @@ -1400,46 +1398,46 @@ void t_javame_generator::generate_java_struct_writer(ostream& out, t_struct* tst vector::const_iterator f_iter; // performs various checks (e.g. check that all required fields are set) - indent(out) << "validate();" << endl << endl; + indent(out) << "validate();" << '\n' << '\n'; - indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl; + indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool null_allowed = type_can_be_null((*f_iter)->get_type()); if (null_allowed) { - out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl; + out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << '\n'; indent_up(); } bool optional = (*f_iter)->get_req() == t_field::T_OPTIONAL; if (optional) { - indent(out) << "if (" << generate_isset_check((*f_iter)) << ") {" << endl; + indent(out) << "if (" << generate_isset_check((*f_iter)) << ") {" << '\n'; indent_up(); } indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) - << "_FIELD_DESC);" << endl; + << "_FIELD_DESC);" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "this."); // Write field closer - indent(out) << "oprot.writeFieldEnd();" << endl; + indent(out) << "oprot.writeFieldEnd();" << '\n'; if (optional) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } if (null_allowed) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } // Write the struct map - out << indent() << "oprot.writeFieldStop();" << endl << indent() << "oprot.writeStructEnd();" - << endl; + out << indent() << "oprot.writeFieldStop();" << '\n' << indent() << "oprot.writeStructEnd();" + << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } /** @@ -1451,62 +1449,62 @@ void t_javame_generator::generate_java_struct_writer(ostream& out, t_struct* tst * @param tstruct The struct definition */ void t_javame_generator::generate_java_struct_result_writer(ostream& out, t_struct* tstruct) { - out << indent() << "public void write(TProtocol oprot) throws TException {" << endl; + out << indent() << "public void write(TProtocol oprot) throws TException {" << '\n'; indent_up(); string name = tstruct->get_name(); const vector& fields = tstruct->get_sorted_members(); vector::const_iterator f_iter; - indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl; + indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << '\n'; bool first = true; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if (first) { first = false; - out << endl << indent() << "if "; + out << '\n' << indent() << "if "; } else { out << " else if "; } - out << "(this." << generate_isset_check(*f_iter) << ") {" << endl; + out << "(this." << generate_isset_check(*f_iter) << ") {" << '\n'; indent_up(); indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) - << "_FIELD_DESC);" << endl; + << "_FIELD_DESC);" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "this."); // Write field closer - indent(out) << "oprot.writeFieldEnd();" << endl; + indent(out) << "oprot.writeFieldEnd();" << '\n'; indent_down(); indent(out) << "}"; } // Write the struct map - out << endl << indent() << "oprot.writeFieldStop();" << endl << indent() - << "oprot.writeStructEnd();" << endl; + out << '\n' << indent() << "oprot.writeFieldStop();" << '\n' << indent() + << "oprot.writeStructEnd();" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_javame_generator::generate_reflection_getters(ostringstream& out, t_type* type, string field_name, string cap_name) { - indent(out) << "case " << constant_name(field_name) << ":" << endl; + indent(out) << "case " << constant_name(field_name) << ":" << '\n'; indent_up(); if (type->is_base_type() && !type->is_string()) { t_base_type* base_type = (t_base_type*)type; indent(out) << "return new " << type_name(type, true, false) << "(" - << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl; + << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << '\n' << '\n'; } else { - indent(out) << "return get" << cap_name << "();" << endl << endl; + indent(out) << "return get" << cap_name << "();" << '\n' << '\n'; } indent_down(); @@ -1516,14 +1514,14 @@ void t_javame_generator::generate_reflection_setters(ostringstream& out, t_type* type, string field_name, string cap_name) { - indent(out) << "case " << constant_name(field_name) << ":" << endl; + indent(out) << "case " << constant_name(field_name) << ":" << '\n'; indent_up(); - indent(out) << "if (value == null) {" << endl; - indent(out) << " unset" << get_cap_name(field_name) << "();" << endl; - indent(out) << "} else {" << endl; - indent(out) << " set" << cap_name << "((" << type_name(type, true, false) << ")value);" << endl; - indent(out) << "}" << endl; - indent(out) << "break;" << endl << endl; + indent(out) << "if (value == null) {" << '\n'; + indent(out) << " unset" << get_cap_name(field_name) << "();" << '\n'; + indent(out) << "} else {" << '\n'; + indent(out) << " set" << cap_name << "((" << type_name(type, true, false) << ")value);" << '\n'; + indent(out) << "}" << '\n'; + indent(out) << "break;" << '\n' << '\n'; indent_down(); } @@ -1568,13 +1566,13 @@ void t_javame_generator::generate_java_bean_boilerplate(ostream& out, t_struct* if (type->is_container()) { // Method to return the size of the collection indent(out) << "public int get" << cap_name; - out << get_cap_name("size() {") << endl; + out << get_cap_name("size() {") << '\n'; indent_up(); indent(out) << "return (this." << field_name << " == null) ? 0 : " - << "this." << field_name << ".size();" << endl; + << "this." << field_name << ".size();" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } if (type->is_set() || type->is_list()) { @@ -1588,35 +1586,35 @@ void t_javame_generator::generate_java_bean_boilerplate(ostream& out, t_struct* // Iterator getter for sets and lists indent(out) << "public Enumeration get" << cap_name; - out << get_cap_name("Enumeration() {") << endl; + out << get_cap_name("Enumeration() {") << '\n'; indent_up(); indent(out) << "return (this." << field_name << " == null) ? null : " - << "this." << field_name << ".elements();" << endl; + << "this." << field_name << ".elements();" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // Add to set or list, create if the set/list is null indent(out); out << "public void add" << get_cap_name("to"); - out << cap_name << "(" << type_name(element_type) << " elem) {" << endl; + out << cap_name << "(" << type_name(element_type) << " elem) {" << '\n'; indent_up(); - indent(out) << "if (this." << field_name << " == null) {" << endl; + indent(out) << "if (this." << field_name << " == null) {" << '\n'; indent_up(); indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; if (type->is_set()) { indent(out) << "this." << field_name << ".put(" << box_type(element_type, "elem") << ", " - << box_type(element_type, "elem") << ");" << endl; + << box_type(element_type, "elem") << ");" << '\n'; } else { indent(out) << "this." << field_name << ".addElement(" << box_type(element_type, "elem") - << ");" << endl; + << ");" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } else if (type->is_map()) { // Put to map @@ -1625,18 +1623,18 @@ void t_javame_generator::generate_java_bean_boilerplate(ostream& out, t_struct* indent(out); out << "public void putTo" << cap_name << "(" << type_name(key_type, true) << " key, " - << type_name(val_type, true) << " val) {" << endl; + << type_name(val_type, true) << " val) {" << '\n'; indent_up(); - indent(out) << "if (this." << field_name << " == null) {" << endl; + indent(out) << "if (this." << field_name << " == null) {" << '\n'; indent_up(); indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();" - << endl; + << '\n'; indent_down(); - indent(out) << "}" << endl; - indent(out) << "this." << field_name << ".put(key, val);" << endl; + indent(out) << "}" << '\n'; + indent(out) << "this." << field_name << ".put(key, val);" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } // Simple getter @@ -1647,60 +1645,60 @@ void t_javame_generator::generate_java_bean_boilerplate(ostream& out, t_struct* } else { out << " get"; } - out << cap_name << "() {" << endl; + out << cap_name << "() {" << '\n'; indent_up(); - indent(out) << "return this." << field_name << ";" << endl; + indent(out) << "return this." << field_name << ";" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // Simple setter generate_java_doc(out, field); indent(out) << "public "; out << "void"; - out << " set" << cap_name << "(" << type_name(type) << " " << field_name << ") {" << endl; + out << " set" << cap_name << "(" << type_name(type) << " " << field_name << ") {" << '\n'; indent_up(); - indent(out) << "this." << field_name << " = " << field_name << ";" << endl; + indent(out) << "this." << field_name << " = " << field_name << ";" << '\n'; generate_isset_set(out, field); indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // Unsetter - indent(out) << "public void unset" << cap_name << "() {" << endl; + indent(out) << "public void unset" << cap_name << "() {" << '\n'; indent_up(); if (type_can_be_null(type)) { - indent(out) << "this." << field_name << " = null;" << endl; + indent(out) << "this." << field_name << " = null;" << '\n'; } else { - indent(out) << "__isset_vector[" << isset_field_id(field) << "] = false;" << endl; + indent(out) << "__isset_vector[" << isset_field_id(field) << "] = false;" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; // isSet method indent(out) << "/** Returns true if field " << field_name - << " is set (has been assigned a value) and false otherwise */" << endl; - indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << endl; + << " is set (has been assigned a value) and false otherwise */" << '\n'; + indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << '\n'; indent_up(); if (type_can_be_null(type)) { - indent(out) << "return this." << field_name << " != null;" << endl; + indent(out) << "return this." << field_name << " != null;" << '\n'; } else { - indent(out) << "return __isset_vector[" << isset_field_id(field) << "];" << endl; + indent(out) << "return __isset_vector[" << isset_field_id(field) << "];" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; indent(out) << "public void set" << cap_name << get_cap_name("isSet") << "(boolean value) {" - << endl; + << '\n'; indent_up(); if (type_can_be_null(type)) { - indent(out) << "if (!value) {" << endl; - indent(out) << " this." << field_name << " = null;" << endl; - indent(out) << "}" << endl; + indent(out) << "if (!value) {" << '\n'; + indent(out) << " this." << field_name << " = null;" << '\n'; + indent(out) << "}" << '\n'; } else { - indent(out) << "__isset_vector[" << isset_field_id(field) << "] = value;" << endl; + indent(out) << "__isset_vector[" << isset_field_id(field) << "] = value;" << '\n'; } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } } @@ -1710,12 +1708,12 @@ void t_javame_generator::generate_java_bean_boilerplate(ostream& out, t_struct* * @param tstruct The struct definition */ void t_javame_generator::generate_java_struct_tostring(ostream& out, t_struct* tstruct) { - out << indent() << "public String toString() {" << endl; + out << indent() << "public String toString() {" << '\n'; indent_up(); out << indent() << "StringBuffer sb = new StringBuffer(\"" << tstruct->get_name() << "(\");" - << endl; - out << indent() << "boolean first = true;" << endl << endl; + << '\n'; + out << indent() << "boolean first = true;" << '\n' << '\n'; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -1723,46 +1721,46 @@ void t_javame_generator::generate_java_struct_tostring(ostream& out, t_struct* t for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL; if (could_be_unset) { - indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl; + indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << '\n'; indent_up(); } t_field* field = (*f_iter); if (!first) { - indent(out) << "if (!first) sb.append(\", \");" << endl; + indent(out) << "if (!first) sb.append(\", \");" << '\n'; } - indent(out) << "sb.append(\"" << (*f_iter)->get_name() << ":\");" << endl; + indent(out) << "sb.append(\"" << (*f_iter)->get_name() << ":\");" << '\n'; bool can_be_null = type_can_be_null(field->get_type()); if (can_be_null) { - indent(out) << "if (this." << (*f_iter)->get_name() << " == null) {" << endl; - indent(out) << " sb.append(\"null\");" << endl; - indent(out) << "} else {" << endl; + indent(out) << "if (this." << (*f_iter)->get_name() << " == null) {" << '\n'; + indent(out) << " sb.append(\"null\");" << '\n'; + indent(out) << "} else {" << '\n'; indent_up(); } if (field->get_type()->is_binary()) { - indent(out) << "TBaseHelper.toString(this." << field->get_name() << ", sb);" << endl; + indent(out) << "TBaseHelper.toString(this." << field->get_name() << ", sb);" << '\n'; } else { - indent(out) << "sb.append(this." << (*f_iter)->get_name() << ");" << endl; + indent(out) << "sb.append(this." << (*f_iter)->get_name() << ");" << '\n'; } if (can_be_null) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - indent(out) << "first = false;" << endl; + indent(out) << "first = false;" << '\n'; if (could_be_unset) { indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } first = false; } - out << indent() << "sb.append(\")\");" << endl << indent() << "return sb.toString();" << endl; + out << indent() << "sb.append(\")\");" << '\n' << indent() << "return sb.toString();" << '\n'; indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } /** @@ -1821,7 +1819,7 @@ std::string t_javame_generator::get_java_type_string(t_type* type) { } void t_javame_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) { - out << endl; + out << '\n'; indent_up(); indent_up(); if (type->is_struct() || type->is_xception()) { @@ -1871,7 +1869,7 @@ void t_javame_generator::generate_service(t_service* tservice) { f_service_ << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports(); - f_service_ << "public class " << service_name_ << " {" << endl << endl; + f_service_ << "public class " << service_name_ << " {" << '\n' << '\n'; indent_up(); // Generate the three main parts of the service @@ -1881,7 +1879,7 @@ void t_javame_generator::generate_service(t_service* tservice) { generate_service_helpers(tservice); indent_down(); - f_service_ << "}" << endl; + f_service_ << "}" << '\n'; f_service_.close(); } @@ -1892,7 +1890,7 @@ void t_javame_generator::generate_service(t_service* tservice) { */ void t_javame_generator::generate_primitive_service_interface(t_service* tservice) { f_service_ << indent() << "public interface Iface extends " << service_name_ << "Iface { }" - << endl << endl; + << '\n' << '\n'; string f_interface_name = package_dir_ + "/" + service_name_ + "Iface.java"; ofstream_with_content_based_conditional_update f_iface; @@ -1905,15 +1903,15 @@ void t_javame_generator::generate_primitive_service_interface(t_service* tservic f_iface << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports(); generate_java_doc(f_iface, tservice); - f_iface << "public interface " << service_name_ << "Iface" << extends_iface << " {" << endl - << endl; + f_iface << "public interface " << service_name_ << "Iface" << extends_iface << " {" << '\n' + << '\n'; vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_java_doc(f_iface, *f_iter); - f_iface << " public " << function_signature(*f_iter) << ";" << endl << endl; + f_iface << " public " << function_signature(*f_iter) << ";" << '\n' << '\n'; } - f_iface << "}" << endl << endl; + f_iface << "}" << '\n' << '\n'; } /** @@ -1930,16 +1928,16 @@ void t_javame_generator::generate_service_interface(t_service* tservice) { } generate_java_doc(f_service_, tservice); - f_service_ << indent() << "public interface Iface" << extends_iface << " {" << endl << endl; + f_service_ << indent() << "public interface Iface" << extends_iface << " {" << '\n' << '\n'; indent_up(); vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_java_doc(f_service_, *f_iter); - indent(f_service_) << "public " << function_signature(*f_iter) << ";" << endl << endl; + indent(f_service_) << "public " << function_signature(*f_iter) << ";" << '\n' << '\n'; } indent_down(); - f_service_ << indent() << "}" << endl << endl; + f_service_ << indent() << "}" << '\n' << '\n'; } /** @@ -1971,41 +1969,41 @@ void t_javame_generator::generate_service_client(t_service* tservice) { } indent(f_service_) << "public static class Client" << extends_client - << " implements TServiceClient, Iface {" << endl; + << " implements TServiceClient, Iface {" << '\n'; indent_up(); - indent(f_service_) << "public Client(TProtocol prot)" << endl; + indent(f_service_) << "public Client(TProtocol prot)" << '\n'; scope_up(f_service_); - indent(f_service_) << "this(prot, prot);" << endl; + indent(f_service_) << "this(prot, prot);" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; - indent(f_service_) << "public Client(TProtocol iprot, TProtocol oprot)" << endl; + indent(f_service_) << "public Client(TProtocol iprot, TProtocol oprot)" << '\n'; scope_up(f_service_); if (extends.empty()) { - f_service_ << indent() << "iprot_ = iprot;" << endl << indent() << "oprot_ = oprot;" << endl; + f_service_ << indent() << "iprot_ = iprot;" << '\n' << indent() << "oprot_ = oprot;" << '\n'; } else { - f_service_ << indent() << "super(iprot, oprot);" << endl; + f_service_ << indent() << "super(iprot, oprot);" << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; if (extends.empty()) { - f_service_ << indent() << "protected TProtocol iprot_;" << endl << indent() - << "protected TProtocol oprot_;" << endl << endl << indent() - << "protected int seqid_;" << endl << endl; + f_service_ << indent() << "protected TProtocol iprot_;" << '\n' << indent() + << "protected TProtocol oprot_;" << '\n' << '\n' << indent() + << "protected int seqid_;" << '\n' << '\n'; - indent(f_service_) << "public TProtocol getInputProtocol()" << endl; + indent(f_service_) << "public TProtocol getInputProtocol()" << '\n'; scope_up(f_service_); - indent(f_service_) << "return this.iprot_;" << endl; + indent(f_service_) << "return this.iprot_;" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; - indent(f_service_) << "public TProtocol getOutputProtocol()" << endl; + indent(f_service_) << "public TProtocol getOutputProtocol()" << '\n'; scope_up(f_service_); - indent(f_service_) << "return this.oprot_;" << endl; + indent(f_service_) << "return this.oprot_;" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } // Generate client method implementations @@ -2015,7 +2013,7 @@ void t_javame_generator::generate_service_client(t_service* tservice) { string funname = (*f_iter)->get_name(); // Open function - indent(f_service_) << "public " << function_signature(*f_iter) << endl; + indent(f_service_) << "public " << function_signature(*f_iter) << '\n'; scope_up(f_service_); indent(f_service_) << "send_" << funname << "("; @@ -2034,17 +2032,17 @@ void t_javame_generator::generate_service_client(t_service* tservice) { } f_service_ << (*fld_iter)->get_name(); } - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; if (!(*f_iter)->is_oneway()) { f_service_ << indent(); if (!(*f_iter)->get_returntype()->is_void()) { f_service_ << "return "; } - f_service_ << "recv_" << funname << "();" << endl; + f_service_ << "recv_" << funname << "();" << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; t_function send_function(g_type_void, string("send_") + (*f_iter)->get_name(), @@ -2053,26 +2051,26 @@ void t_javame_generator::generate_service_client(t_service* tservice) { string argsname = (*f_iter)->get_name() + "_args"; // Open function - indent(f_service_) << "public " << function_signature(&send_function) << endl; + indent(f_service_) << "public " << function_signature(&send_function) << '\n'; scope_up(f_service_); // Serialize the request f_service_ << indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", " << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL") - << ", ++seqid_));" << endl << indent() << argsname << " args = new " << argsname - << "();" << endl; + << ", ++seqid_));" << '\n' << indent() << argsname << " args = new " << argsname + << "();" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_service_ << indent() << "args.set" << get_cap_name((*fld_iter)->get_name()) << "(" - << (*fld_iter)->get_name() << ");" << endl; + << (*fld_iter)->get_name() << ");" << '\n'; } - f_service_ << indent() << "args.write(oprot_);" << endl << indent() - << "oprot_.writeMessageEnd();" << endl << indent() - << "oprot_.getTransport().flush();" << endl; + f_service_ << indent() << "args.write(oprot_);" << '\n' << indent() + << "oprot_.writeMessageEnd();" << '\n' << indent() + << "oprot_.getTransport().flush();" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; if (!(*f_iter)->is_oneway()) { string resultname = (*f_iter)->get_name() + "_result"; @@ -2083,53 +2081,53 @@ void t_javame_generator::generate_service_client(t_service* tservice) { &noargs, (*f_iter)->get_xceptions()); // Open function - indent(f_service_) << "public " << function_signature(&recv_function) << endl; + indent(f_service_) << "public " << function_signature(&recv_function) << '\n'; scope_up(f_service_); - f_service_ << indent() << "TMessage msg = iprot_.readMessageBegin();" << endl << indent() - << "if (msg.type == TMessageType.EXCEPTION) {" << endl << indent() - << " TApplicationException x = TApplicationException.read(iprot_);" << endl - << indent() << " iprot_.readMessageEnd();" << endl << indent() << " throw x;" - << endl << indent() << "}" << endl << indent() << "if (msg.seqid != seqid_) {" - << endl << indent() + f_service_ << indent() << "TMessage msg = iprot_.readMessageBegin();" << '\n' << indent() + << "if (msg.type == TMessageType.EXCEPTION) {" << '\n' << indent() + << " TApplicationException x = TApplicationException.read(iprot_);" << '\n' + << indent() << " iprot_.readMessageEnd();" << '\n' << indent() << " throw x;" + << '\n' << indent() << "}" << '\n' << indent() << "if (msg.seqid != seqid_) {" + << '\n' << indent() << " throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, \"" - << (*f_iter)->get_name() << " failed: out of sequence response\");" << endl - << indent() << "}" << endl << indent() << resultname << " result = new " - << resultname << "();" << endl << indent() << "result.read(iprot_);" << endl - << indent() << "iprot_.readMessageEnd();" << endl; + << (*f_iter)->get_name() << " failed: out of sequence response\");" << '\n' + << indent() << "}" << '\n' << indent() << resultname << " result = new " + << resultname << "();" << '\n' << indent() << "result.read(iprot_);" << '\n' + << indent() << "iprot_.readMessageEnd();" << '\n'; // Careful, only return _result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { - f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << endl - << indent() << " return result.success;" << endl << indent() << "}" << endl; + f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << '\n' + << indent() << " return result.success;" << '\n' << indent() << "}" << '\n'; } t_struct* xs = (*f_iter)->get_xceptions(); const std::vector& xceptions = xs->get_members(); vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { - f_service_ << indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl - << indent() << " throw result." << (*x_iter)->get_name() << ";" << endl - << indent() << "}" << endl; + f_service_ << indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << '\n' + << indent() << " throw result." << (*x_iter)->get_name() << ";" << '\n' + << indent() << "}" << '\n'; } // If you get here it's an exception, unless a void function if ((*f_iter)->get_returntype()->is_void()) { - indent(f_service_) << "return;" << endl; + indent(f_service_) << "return;" << '\n'; } else { f_service_ << indent() << "throw new TApplicationException(TApplicationException.MISSING_RESULT, \"" - << (*f_iter)->get_name() << " failed: unknown result\");" << endl; + << (*f_iter)->get_name() << " failed: unknown result\");" << '\n'; } // Close function scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; } } indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } /** @@ -2152,66 +2150,66 @@ void t_javame_generator::generate_service_server(t_service* tservice) { // Generate the header portion indent(f_service_) << "public static class Processor" << extends_processor - << " implements TProcessor {" << endl; + << " implements TProcessor {" << '\n'; indent_up(); - indent(f_service_) << "public Processor(Iface iface)" << endl; + indent(f_service_) << "public Processor(Iface iface)" << '\n'; scope_up(f_service_); if (!extends.empty()) { - f_service_ << indent() << "super(iface);" << endl; + f_service_ << indent() << "super(iface);" << '\n'; } - f_service_ << indent() << "iface_ = iface;" << endl; + f_service_ << indent() << "iface_ = iface;" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { f_service_ << indent() << "processMap_.put(\"" << (*f_iter)->get_name() << "\", new " - << (*f_iter)->get_name() << "());" << endl; + << (*f_iter)->get_name() << "());" << '\n'; } scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; if (extends.empty()) { f_service_ - << indent() << "protected static interface ProcessFunction {" << endl << indent() + << indent() << "protected static interface ProcessFunction {" << '\n' << indent() << " public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;" - << endl << indent() << "}" << endl << endl; + << '\n' << indent() << "}" << '\n' << '\n'; } - f_service_ << indent() << "private Iface iface_;" << endl; + f_service_ << indent() << "private Iface iface_;" << '\n'; if (extends.empty()) { - f_service_ << indent() << "protected final Hashtable processMap_ = new Hashtable();" << endl; + f_service_ << indent() << "protected final Hashtable processMap_ = new Hashtable();" << '\n'; } - f_service_ << endl; + f_service_ << '\n'; // Generate the server implementation indent(f_service_) << "public boolean process(TProtocol iprot, TProtocol oprot) throws TException" - << endl; + << '\n'; scope_up(f_service_); - f_service_ << indent() << "TMessage msg = iprot.readMessageBegin();" << endl; + f_service_ << indent() << "TMessage msg = iprot.readMessageBegin();" << '\n'; // TODO(mcslee): validate message, was the seqid etc. legit? f_service_ - << indent() << "ProcessFunction fn = (ProcessFunction)processMap_.get(msg.name);" << endl - << indent() << "if (fn == null) {" << endl << indent() - << " TProtocolUtil.skip(iprot, TType.STRUCT);" << endl << indent() - << " iprot.readMessageEnd();" << endl << indent() + << indent() << "ProcessFunction fn = (ProcessFunction)processMap_.get(msg.name);" << '\n' + << indent() << "if (fn == null) {" << '\n' << indent() + << " TProtocolUtil.skip(iprot, TType.STRUCT);" << '\n' << indent() + << " iprot.readMessageEnd();" << '\n' << indent() << " TApplicationException x = new " "TApplicationException(TApplicationException.UNKNOWN_METHOD, \"Invalid method name: " - "'\"+msg.name+\"'\");" << endl << indent() + "'\"+msg.name+\"'\");" << '\n' << indent() << " oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" - << endl << indent() << " x.write(oprot);" << endl << indent() << " oprot.writeMessageEnd();" - << endl << indent() << " oprot.getTransport().flush();" << endl << indent() - << " return true;" << endl << indent() << "}" << endl << indent() - << "fn.process(msg.seqid, iprot, oprot);" << endl; + << '\n' << indent() << " x.write(oprot);" << '\n' << indent() << " oprot.writeMessageEnd();" + << '\n' << indent() << " oprot.getTransport().flush();" << '\n' << indent() + << " return true;" << '\n' << indent() << "}" << '\n' << indent() + << "fn.process(msg.seqid, iprot, oprot);" << '\n'; - f_service_ << indent() << "return true;" << endl; + f_service_ << indent() << "return true;" << '\n'; scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Generate the process subfunctions for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -2219,7 +2217,7 @@ void t_javame_generator::generate_service_server(t_service* tservice) { } indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; } /** @@ -2257,36 +2255,36 @@ void t_javame_generator::generate_process_function(t_service* tservice, t_functi (void)tservice; // Open class indent(f_service_) << "private class " << tfunction->get_name() << " implements ProcessFunction {" - << endl; + << '\n'; indent_up(); // Open function indent(f_service_) << "public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException" - << endl; + << '\n'; scope_up(f_service_); string argsname = tfunction->get_name() + "_args"; string resultname = tfunction->get_name() + "_result"; - f_service_ << indent() << argsname << " args = new " << argsname << "();" << endl << indent() - << "try {" << endl; + f_service_ << indent() << argsname << " args = new " << argsname << "();" << '\n' << indent() + << "try {" << '\n'; indent_up(); - f_service_ << indent() << "args.read(iprot);" << endl; + f_service_ << indent() << "args.read(iprot);" << '\n'; indent_down(); - f_service_ << indent() << "} catch (TProtocolException e) {" << endl; + f_service_ << indent() << "} catch (TProtocolException e) {" << '\n'; indent_up(); - f_service_ << indent() << "iprot.readMessageEnd();" << endl << indent() + f_service_ << indent() << "iprot.readMessageEnd();" << '\n' << indent() << "TApplicationException x = new " "TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());" - << endl << indent() << "oprot.writeMessageBegin(new TMessage(\"" - << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl << indent() - << "x.write(oprot);" << endl << indent() << "oprot.writeMessageEnd();" << endl - << indent() << "oprot.getTransport().flush();" << endl << indent() << "return;" - << endl; + << '\n' << indent() << "oprot.writeMessageBegin(new TMessage(\"" + << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << '\n' << indent() + << "x.write(oprot);" << '\n' << indent() << "oprot.writeMessageEnd();" << '\n' + << indent() << "oprot.getTransport().flush();" << '\n' << indent() << "return;" + << '\n'; indent_down(); - f_service_ << indent() << "}" << endl; - f_service_ << indent() << "iprot.readMessageEnd();" << endl; + f_service_ << indent() << "}" << '\n'; + f_service_ << indent() << "iprot.readMessageEnd();" << '\n'; t_struct* xs = tfunction->get_xceptions(); const std::vector& xceptions = xs->get_members(); @@ -2294,12 +2292,12 @@ void t_javame_generator::generate_process_function(t_service* tservice, t_functi // Declare result for non oneway function if (!tfunction->is_oneway()) { - f_service_ << indent() << resultname << " result = new " << resultname << "();" << endl; + f_service_ << indent() << resultname << " result = new " << resultname << "();" << '\n'; } // Try block for a function with exceptions if (xceptions.size() > 0) { - f_service_ << indent() << "try {" << endl; + f_service_ << indent() << "try {" << '\n'; indent_up(); } @@ -2322,13 +2320,13 @@ void t_javame_generator::generate_process_function(t_service* tservice, t_functi } f_service_ << "args." << (*f_iter)->get_name(); } - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; // Set isset on success field if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void() && !type_can_be_null(tfunction->get_returntype())) { f_service_ << indent() << "result.set" << get_cap_name("success") << get_cap_name("isSet") - << "(true);" << endl; + << "(true);" << '\n'; } if (!tfunction->is_oneway() && xceptions.size() > 0) { @@ -2336,54 +2334,54 @@ void t_javame_generator::generate_process_function(t_service* tservice, t_functi f_service_ << indent() << "}"; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " " - << (*x_iter)->get_name() << ") {" << endl; + << (*x_iter)->get_name() << ") {" << '\n'; if (!tfunction->is_oneway()) { indent_up(); f_service_ << indent() << "result." << (*x_iter)->get_name() << " = " - << (*x_iter)->get_name() << ";" << endl; + << (*x_iter)->get_name() << ";" << '\n'; indent_down(); f_service_ << indent() << "}"; } else { f_service_ << "}"; } } - f_service_ << " catch (Throwable th) {" << endl; + f_service_ << " catch (Throwable th) {" << '\n'; indent_up(); f_service_ << indent() << "TApplicationException x = new " "TApplicationException(TApplicationException.INTERNAL_ERROR, " "\"Internal error processing " << tfunction->get_name() << "\");" - << endl << indent() << "oprot.writeMessageBegin(new TMessage(\"" - << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl - << indent() << "x.write(oprot);" << endl << indent() << "oprot.writeMessageEnd();" - << endl << indent() << "oprot.getTransport().flush();" << endl << indent() - << "return;" << endl; + << '\n' << indent() << "oprot.writeMessageBegin(new TMessage(\"" + << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << '\n' + << indent() << "x.write(oprot);" << '\n' << indent() << "oprot.writeMessageEnd();" + << '\n' << indent() << "oprot.getTransport().flush();" << '\n' << indent() + << "return;" << '\n'; indent_down(); - f_service_ << indent() << "}" << endl; + f_service_ << indent() << "}" << '\n'; } // Shortcut out here for oneway functions if (tfunction->is_oneway()) { - f_service_ << indent() << "return;" << endl; + f_service_ << indent() << "return;" << '\n'; scope_down(f_service_); // Close class indent_down(); - f_service_ << indent() << "}" << endl << endl; + f_service_ << indent() << "}" << '\n' << '\n'; return; } f_service_ << indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() - << "\", TMessageType.REPLY, seqid));" << endl << indent() << "result.write(oprot);" - << endl << indent() << "oprot.writeMessageEnd();" << endl << indent() - << "oprot.getTransport().flush();" << endl; + << "\", TMessageType.REPLY, seqid));" << '\n' << indent() << "result.write(oprot);" + << '\n' << indent() << "oprot.writeMessageEnd();" << '\n' << indent() + << "oprot.getTransport().flush();" << '\n'; // Close function scope_down(f_service_); - f_service_ << endl; + f_service_ << '\n'; // Close class indent_down(); - f_service_ << indent() << "}" << endl << endl; + f_service_ << indent() << "}" << '\n' << '\n'; } /** @@ -2441,11 +2439,11 @@ void t_javame_generator::generate_deserialize_field(ostream& out, t_field* tfiel default: throw "compiler error: no Java name for base type " + t_base_type::t_base_name(tbase); } - out << endl; + out << '\n'; } else if (type->is_enum()) { indent(out) << name << " = " << type_name(tfield->get_type(), true, false) + ".findByValue(iprot.readI32());" - << endl; + << '\n'; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", tfield->get_name().c_str(), @@ -2459,8 +2457,8 @@ void t_javame_generator::generate_deserialize_field(ostream& out, t_field* tfiel void t_javame_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) { - out << indent() << prefix << " = new " << type_name(tstruct) << "();" << endl << indent() - << prefix << ".read(iprot);" << endl; + out << indent() << prefix << " = new " << type_name(tstruct) << "();" << '\n' << indent() + << prefix << ".read(iprot);" << '\n'; } /** @@ -2483,23 +2481,23 @@ void t_javame_generator::generate_deserialize_container(ostream& out, // Declare variables, read header if (ttype->is_map()) { - indent(out) << "TMap " << obj << " = iprot.readMapBegin();" << endl; + indent(out) << "TMap " << obj << " = iprot.readMapBegin();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "TSet " << obj << " = iprot.readSetBegin();" << endl; + indent(out) << "TSet " << obj << " = iprot.readSetBegin();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "TList " << obj << " = iprot.readListBegin();" << endl; + indent(out) << "TList " << obj << " = iprot.readListBegin();" << '\n'; } indent(out) << prefix << " = new " << type_name(ttype, false, true) // size the collection correctly << "(" << (ttype->is_list() ? "" : "2*") << obj << ".size" - << ");" << endl; + << ");" << '\n'; // For loop iterates over elements string i = tmp("_i"); indent(out) << "for (int " << i << " = 0; " << i << " < " << obj << ".size" << "; " - << "++" << i << ")" << endl; + << "++" << i << ")" << '\n'; scope_up(out); @@ -2515,11 +2513,11 @@ void t_javame_generator::generate_deserialize_container(ostream& out, // Read container end if (ttype->is_map()) { - indent(out) << "iprot.readMapEnd();" << endl; + indent(out) << "iprot.readMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "iprot.readSetEnd();" << endl; + indent(out) << "iprot.readSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "iprot.readListEnd();" << endl; + indent(out) << "iprot.readListEnd();" << '\n'; } scope_down(out); @@ -2536,14 +2534,14 @@ void t_javame_generator::generate_deserialize_map_element(ostream& out, t_field fkey(tmap->get_key_type(), key); t_field fval(tmap->get_val_type(), val); - indent(out) << declare_field(&fkey) << endl; - indent(out) << declare_field(&fval) << endl; + indent(out) << declare_field(&fkey) << '\n'; + indent(out) << declare_field(&fval) << '\n'; generate_deserialize_field(out, &fkey); generate_deserialize_field(out, &fval); indent(out) << prefix << ".put(" << box_type(tmap->get_key_type(), key) << ", " - << box_type(tmap->get_val_type(), val) << ");" << endl; + << box_type(tmap->get_val_type(), val) << ");" << '\n'; } /** @@ -2555,12 +2553,12 @@ void t_javame_generator::generate_deserialize_set_element(ostream& out, string elem = tmp("_elem"); t_field felem(tset->get_elem_type(), elem); - indent(out) << declare_field(&felem) << endl; + indent(out) << declare_field(&felem) << '\n'; generate_deserialize_field(out, &felem); indent(out) << prefix << ".put(" << box_type(tset->get_elem_type(), elem) << ", " - << box_type(tset->get_elem_type(), elem) << ");" << endl; + << box_type(tset->get_elem_type(), elem) << ");" << '\n'; } /** @@ -2572,11 +2570,11 @@ void t_javame_generator::generate_deserialize_list_element(ostream& out, string elem = tmp("_elem"); t_field felem(tlist->get_elem_type(), elem); - indent(out) << declare_field(&felem) << endl; + indent(out) << declare_field(&felem) << '\n'; generate_deserialize_field(out, &felem); - indent(out) << prefix << ".addElement(" << box_type(tlist->get_elem_type(), elem) << ");" << endl; + indent(out) << prefix << ".addElement(" << box_type(tlist->get_elem_type(), elem) << ");" << '\n'; } /** @@ -2598,7 +2596,7 @@ void t_javame_generator::generate_serialize_field(ostream& out, t_field* tfield, } else if (type->is_container()) { generate_serialize_container(out, type, prefix + tfield->get_name()); } else if (type->is_enum()) { - indent(out) << "oprot.writeI32(" << prefix + tfield->get_name() << ".getValue());" << endl; + indent(out) << "oprot.writeI32(" << prefix + tfield->get_name() << ".getValue());" << '\n'; } else if (type->is_base_type()) { string name = prefix + tfield->get_name(); indent(out) << "oprot."; @@ -2640,7 +2638,7 @@ void t_javame_generator::generate_serialize_field(ostream& out, t_field* tfield, } else if (type->is_enum()) { out << "writeI32(" << name << ");"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n", prefix.c_str(), @@ -2659,7 +2657,7 @@ void t_javame_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - out << indent() << prefix << ".write(oprot);" << endl; + out << indent() << prefix << ".write(oprot);" << '\n'; } /** @@ -2674,14 +2672,14 @@ void t_javame_generator::generate_serialize_container(ostream& out, t_type* ttyp if (ttype->is_map()) { indent(out) << "oprot.writeMapBegin(new TMap(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << prefix - << ".size()));" << endl; + << ".size()));" << '\n'; } else if (ttype->is_set()) { indent(out) << "oprot.writeSetBegin(new TSet(" << type_to_enum(((t_set*)ttype)->get_elem_type()) - << ", " << prefix << ".size()));" << endl; + << ", " << prefix << ".size()));" << '\n'; } else if (ttype->is_list()) { indent(out) << "oprot.writeListBegin(new TList(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix << ".size()));" - << endl; + << '\n'; } string iter = tmp("_iter"); @@ -2692,7 +2690,7 @@ void t_javame_generator::generate_serialize_container(ostream& out, t_type* ttyp << ".hasMoreElements(); ) "; scope_up(out); indent(out) << key_type << " " << iter << " = (" << key_type << ")" << enumer - << ".nextElement();" << endl; + << ".nextElement();" << '\n'; } else if (ttype->is_set()) { string enumer = iter + "_enum"; string ele_type = type_name(((t_list*)ttype)->get_elem_type(), true); @@ -2700,7 +2698,7 @@ void t_javame_generator::generate_serialize_container(ostream& out, t_type* ttyp << ".hasMoreElements(); ) "; scope_up(out); indent(out) << ele_type << " " << iter << " = (" << ele_type << ")" << enumer - << ".nextElement();" << endl; + << ".nextElement();" << '\n'; } else if (ttype->is_list()) { string enumer = iter + "_enum"; indent(out) << "for (Enumeration " << enumer << " = " << prefix << ".elements(); " << enumer @@ -2708,7 +2706,7 @@ void t_javame_generator::generate_serialize_container(ostream& out, t_type* ttyp scope_up(out); string ele_type = type_name(((t_list*)ttype)->get_elem_type(), true); indent(out) << ele_type << " " << iter << " = (" << ele_type << ")" << enumer - << ".nextElement();" << endl; + << ".nextElement();" << '\n'; } if (ttype->is_map()) { @@ -2721,11 +2719,11 @@ void t_javame_generator::generate_serialize_container(ostream& out, t_type* ttyp scope_down(out); if (ttype->is_map()) { - indent(out) << "oprot.writeMapEnd();" << endl; + indent(out) << "oprot.writeMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "oprot.writeSetEnd();" << endl; + indent(out) << "oprot.writeSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "oprot.writeListEnd();" << endl; + indent(out) << "oprot.writeListEnd();" << '\n'; } scope_down(out); @@ -3056,7 +3054,7 @@ void t_javame_generator::generate_deep_copy_container(ostream& out, source_name = source_name_p1 + "." + source_name_p2; indent(out) << type_name(type, true, false) << " " << result_name << " = new " - << type_name(container, false, true) << "();" << endl; + << type_name(container, false, true) << "();" << '\n'; std::string iterator_element_name = source_name_p1 + "_element"; std::string enumeration_name = source_name_p1 + "_enum"; @@ -3067,19 +3065,19 @@ void t_javame_generator::generate_deep_copy_container(ostream& out, t_type* val_type = ((t_map*)container)->get_val_type(); indent(out) << "for (Enumeration " << enumeration_name << " = " << source_name << ".keys(); " - << enumeration_name << ".hasMoreElements(); ) {" << endl; + << enumeration_name << ".hasMoreElements(); ) {" << '\n'; indent_up(); - out << endl; + out << '\n'; indent(out) << type_name(key_type, true, false) << " " << iterator_element_name << "_key = (" << type_name(key_type, true, false) << ")" << enumeration_name << ".nextElement();" - << endl; + << '\n'; indent(out) << type_name(val_type, true, false) << " " << iterator_element_name << "_value = (" << type_name(val_type, true, false) << ")" << source_name << ".get(" - << iterator_element_name << "_key);" << endl; + << iterator_element_name << "_key);" << '\n'; - out << endl; + out << '\n'; if (key_type->is_container()) { generate_deep_copy_container(out, @@ -3093,10 +3091,10 @@ void t_javame_generator::generate_deep_copy_container(ostream& out, iterator_element_name + "_key", result_element_name + "_key", key_type); - out << ";" << endl; + out << ";" << '\n'; } - out << endl; + out << '\n'; if (val_type->is_container()) { generate_deep_copy_container(out, @@ -3110,16 +3108,16 @@ void t_javame_generator::generate_deep_copy_container(ostream& out, iterator_element_name + "_value", result_element_name + "_value", val_type); - out << ";" << endl; + out << ";" << '\n'; } - out << endl; + out << '\n'; indent(out) << result_name << ".put(" << result_element_name << "_key, " << result_element_name - << "_value);" << endl; + << "_value);" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } else { t_type* elem_type; @@ -3131,19 +3129,19 @@ void t_javame_generator::generate_deep_copy_container(ostream& out, } indent(out) << "for (Enumeration " << enumeration_name << " = " << source_name - << ".elements(); " << enumeration_name << ".hasMoreElements(); ) {" << endl; + << ".elements(); " << enumeration_name << ".hasMoreElements(); ) {" << '\n'; indent_up(); indent(out) << type_name(elem_type, true, false) << " " << iterator_element_name << " = (" << type_name(elem_type, true, false) << ")" << enumeration_name << ".nextElement();" - << endl; + << '\n'; if (elem_type->is_container()) { // recursive deep copy generate_deep_copy_container(out, iterator_element_name, "", result_element_name, elem_type); if (elem_type->is_list()) { - indent(out) << result_name << ".addElement(" << result_element_name << ");" << endl; + indent(out) << result_name << ".addElement(" << result_element_name << ");" << '\n'; } else { indent(out) << result_name << ".put(" << result_element_name << ", " << result_element_name - << ");" << endl; + << ");" << '\n'; } } else { // iterative copy @@ -3153,22 +3151,22 @@ void t_javame_generator::generate_deep_copy_container(ostream& out, iterator_element_name, "temp_binary_element", elem_type); - out << ";" << endl; + out << ";" << '\n'; if (elem_type->is_list()) { - indent(out) << result_name << ".addElement(temp_binary_element);" << endl; + indent(out) << result_name << ".addElement(temp_binary_element);" << '\n'; } else { - indent(out) << result_name << ".put(temp_binary_element, temp_binary_element);" << endl; + indent(out) << result_name << ".put(temp_binary_element, temp_binary_element);" << '\n'; } } else { indent(out) << result_name << ".addElement("; generate_deep_copy_non_container(out, iterator_element_name, result_name, elem_type); - out << ");" << endl; + out << ");" << '\n'; } } indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } @@ -3179,7 +3177,7 @@ void t_javame_generator::generate_deep_copy_non_container(ostream& out, if (type->is_base_type() || type->is_enum() || type->is_typedef()) { // binary fields need to be copied with System.arraycopy if (type->is_binary()) { - out << "new byte[" << source_name << ".length];" << endl; + out << "new byte[" << source_name << ".length];" << '\n'; indent(out) << "System.arraycopy(" << source_name << ", 0, " << dest_name << ", 0, " << source_name << ".length)"; } @@ -3206,7 +3204,7 @@ std::string t_javame_generator::generate_isset_check(std::string field_name) { void t_javame_generator::generate_isset_set(ostream& out, t_field* field) { if (!type_can_be_null(field->get_type())) { indent(out) << "set" << get_cap_name(field->get_name()) << get_cap_name("isSet") << "(true);" - << endl; + << '\n'; } } @@ -3221,7 +3219,7 @@ std::string t_javame_generator::get_enum_class_name(t_type* type) { void t_javame_generator::generate_struct_desc(ostream& out, t_struct* tstruct) { indent(out) << "private static final TStruct STRUCT_DESC = new TStruct(\"" << tstruct->get_name() - << "\");" << endl; + << "\");" << '\n'; } void t_javame_generator::generate_field_descs(ostream& out, t_struct* tstruct) { @@ -3232,7 +3230,7 @@ void t_javame_generator::generate_field_descs(ostream& out, t_struct* tstruct) { indent(out) << "private static final TField " << constant_name((*m_iter)->get_name()) << "_FIELD_DESC = new TField(\"" << (*m_iter)->get_name() << "\", " << type_to_enum((*m_iter)->get_type()) << ", " - << "(short)" << (*m_iter)->get_key() << ");" << endl; + << "(short)" << (*m_iter)->get_key() << ");" << '\n'; } } @@ -3249,7 +3247,7 @@ bool t_javame_generator::has_bit_vector(t_struct* tstruct) { } void t_javame_generator::generate_java_struct_clear(std::ostream& out, t_struct* tstruct) { - indent(out) << "public void clear() {" << endl; + indent(out) << "public void clear() {" << '\n'; const vector& members = tstruct->get_members(); vector::const_iterator m_iter; @@ -3266,24 +3264,24 @@ void t_javame_generator::generate_java_struct_clear(std::ostream& out, t_struct* true); } else { if (type_can_be_null(t)) { - indent(out) << "this." << (*m_iter)->get_name() << " = null;" << endl; + indent(out) << "this." << (*m_iter)->get_name() << " = null;" << '\n'; } else { // must be a base type // means it also needs to be explicitly unset indent(out) << "set" << get_cap_name((*m_iter)->get_name()) << get_cap_name("isSet") - << "(false);" << endl; + << "(false);" << '\n'; switch (((t_base_type*)t)->get_base()) { case t_base_type::TYPE_I8: case t_base_type::TYPE_I16: case t_base_type::TYPE_I32: case t_base_type::TYPE_I64: - indent(out) << "this." << (*m_iter)->get_name() << " = 0;" << endl; + indent(out) << "this." << (*m_iter)->get_name() << " = 0;" << '\n'; break; case t_base_type::TYPE_DOUBLE: - indent(out) << "this." << (*m_iter)->get_name() << " = 0.0;" << endl; + indent(out) << "this." << (*m_iter)->get_name() << " = 0.0;" << '\n'; break; case t_base_type::TYPE_BOOL: - indent(out) << "this." << (*m_iter)->get_name() << " = false;" << endl; + indent(out) << "this." << (*m_iter)->get_name() << " = false;" << '\n'; break; default: // prevent gcc compiler warning break; @@ -3293,7 +3291,7 @@ void t_javame_generator::generate_java_struct_clear(std::ostream& out, t_struct* } indent_down(); - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } std::string t_javame_generator::display_name() const { diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc b/compiler/cpp/src/thrift/generate/t_js_generator.cc index 0e8da5963ee..dfc334bbf0f 100644 --- a/compiler/cpp/src/thrift/generate/t_js_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc @@ -43,7 +43,6 @@ using std::stringstream; using std::unordered_map; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes static const string episode_file_name = "thrift.js.episode"; // largest consecutive integer representable by a double (2 ^ 53 - 1) static const int64_t max_safe_integer = 0x1fffffffffffff; @@ -339,17 +338,17 @@ class t_js_generator : public t_oop_generator { * @return string The documentation */ string ts_print_doc(t_doc* tdoc) { - string result = endl; + string result = "\n"; if (tdoc->has_doc()) { std::stringstream doc(tdoc->get_doc()); string item; - result += ts_indent() + "/**" + endl; + result += ts_indent() + "/**" + "\n"; while (std::getline(doc, item)) { - result += ts_indent() + " * " + item + endl; + result += ts_indent() + " * " + item + "\n"; } - result += ts_indent() + " */" + endl; + result += ts_indent() + " */" + "\n"; } return result; } @@ -457,7 +456,7 @@ void t_js_generator::init_generator() { f_types_.open(f_types_name.c_str()); if (gen_episode_file_) { const auto types_module = program_->get_name() + "_types"; - f_episode_ << types_module << ":" << thrift_package_output_directory_ << "/" << types_module << endl; + f_episode_ << types_module << ":" << thrift_package_output_directory_ << "/" << types_module << '\n'; } if (gen_ts_) { @@ -469,17 +468,17 @@ void t_js_generator::init_generator() { f_types_ << autogen_comment(); if ((gen_node_ || gen_es6_) && no_ns_) { - f_types_ << "\"use strict\";" << endl << endl; + f_types_ << "\"use strict\";" << '\n' << '\n'; } - f_types_ << js_includes() << endl << render_includes() << endl; + f_types_ << js_includes() << '\n' << render_includes() << '\n'; if (gen_ts_) { - f_types_ts_ << autogen_comment() << ts_includes() << endl << render_ts_includes() << endl; + f_types_ts_ << autogen_comment() << ts_includes() << '\n' << render_ts_includes() << '\n'; } if (gen_node_) { - f_types_ << js_const_type_ << "ttypes = module.exports = {};" << endl; + f_types_ << js_const_type_ << "ttypes = module.exports = {};" << '\n'; } string pns; @@ -490,11 +489,11 @@ void t_js_generator::init_generator() { if (ns_pieces.size() > 0) { for (size_t i = 0; i < ns_pieces.size(); ++i) { pns += ((i == 0) ? "" : ".") + ns_pieces[i]; - f_types_ << "if (typeof " << pns << " === 'undefined') {" << endl; - f_types_ << " " << pns << " = {};" << endl; - f_types_ << "}" << endl; - f_types_ << "" << "if (typeof module !== 'undefined' && module.exports) {" << endl; - f_types_ << " module.exports." << pns << " = " << pns << ";" << endl << "}" << endl; + f_types_ << "if (typeof " << pns << " === 'undefined') {" << '\n'; + f_types_ << " " << pns << " = {};" << '\n'; + f_types_ << "}" << '\n'; + f_types_ << "" << "if (typeof module !== 'undefined' && module.exports) {" << '\n'; + f_types_ << " module.exports." << pns << " = " << pns << ";" << '\n' << "}" << '\n'; } if (gen_ts_) { ts_module_ = pns; @@ -639,11 +638,11 @@ void t_js_generator::generate_typedef(t_typedef* ttypedef) { * @param tenum The enumeration */ void t_js_generator::generate_enum(t_enum* tenum) { - f_types_ << js_type_namespace(tenum->get_program()) << tenum->get_name() << " = {" << endl; + f_types_ << js_type_namespace(tenum->get_program()) << tenum->get_name() << " = {" << '\n'; if (gen_ts_) { f_types_ts_ << ts_print_doc(tenum) << ts_indent() << ts_declare() << "enum " - << tenum->get_name() << " {" << endl; + << tenum->get_name() << " {" << '\n'; } indent_up(); @@ -653,23 +652,23 @@ void t_js_generator::generate_enum(t_enum* tenum) { for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); if (gen_ts_) { - f_types_ts_ << ts_indent() << (*c_iter)->get_name() << " = " << value << "," << endl; + f_types_ts_ << ts_indent() << (*c_iter)->get_name() << " = " << value << "," << '\n'; // add 'value: key' in addition to 'key: value' for TypeScript enums - f_types_ << indent() << "'" << value << "' : '" << (*c_iter)->get_name() << "'," << endl; + f_types_ << indent() << "'" << value << "' : '" << (*c_iter)->get_name() << "'," << '\n'; } f_types_ << indent() << "'" << (*c_iter)->get_name() << "' : " << value; if (c_iter != constants.end() - 1) { f_types_ << ","; } - f_types_ << endl; + f_types_ << '\n'; } indent_down(); - f_types_ << "};" << endl; + f_types_ << "};" << '\n'; if (gen_ts_) { - f_types_ts_ << ts_indent() << "}" << endl; + f_types_ts_ << ts_indent() << "}" << '\n'; } } @@ -682,11 +681,11 @@ void t_js_generator::generate_const(t_const* tconst) { t_const_value* value = tconst->get_value(); f_types_ << js_type_namespace(program_) << name << " = "; - f_types_ << render_const_value(type, value) << ";" << endl; + f_types_ << render_const_value(type, value) << ";" << '\n'; if (gen_ts_) { f_types_ts_ << ts_print_doc(tconst) << ts_indent() << ts_declare() << js_const_type_ << name << ": " - << ts_get_type(type) << ";" << endl; + << ts_get_type(type) << ";" << '\n'; } } @@ -755,24 +754,24 @@ string t_js_generator::render_const_value(t_type* type, t_const_value* value) { } if (v_iter != val.begin()) out << ","; - out << endl << indent() << render_const_value(g_type_string, v_iter->first); + out << '\n' << indent() << render_const_value(g_type_string, v_iter->first); out << " : "; out << render_const_value(field_type, v_iter->second); } indent_down(); - out << endl << indent() << "})"; + out << '\n' << indent() << "})"; } else if (type->is_map()) { t_type* ktype = ((t_map*)type)->get_key_type(); t_type* vtype = ((t_map*)type)->get_val_type(); - out << "{" << endl; + out << "{" << '\n'; indent_up(); const map& val = value->get_map(); map::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { if (v_iter != val.begin()) - out << "," << endl; + out << "," << '\n'; if (ktype->is_base_type() && ((t_base_type*)get_true_type(ktype))->get_base() == t_base_type::TYPE_I64){ out << indent() << "\"" << v_iter->first->get_integer() << "\""; @@ -784,7 +783,7 @@ string t_js_generator::render_const_value(t_type* type, t_const_value* value) { out << render_const_value(vtype, v_iter->second); } indent_down(); - out << endl << indent() << "}"; + out << '\n' << indent() << "}"; } else if (type->is_list() || type->is_set()) { t_type* etype; if (type->is_list()) { @@ -866,27 +865,27 @@ void t_js_generator::generate_js_struct_definition(ostream& out, if (gen_ts_) { f_types_ts_ << ts_print_doc(tstruct) << ts_indent() << ts_declare() << "class " << tstruct->get_name() << (is_exception ? " extends Thrift.TException" : "") - << " {" << endl; + << " {" << '\n'; } } else { out << js_namespace(tstruct->get_program()) << tstruct->get_name(); if (gen_ts_) { f_types_ts_ << ts_print_doc(tstruct) << ts_indent() << ts_declare() << "class " << tstruct->get_name() << (is_exception ? " extends Thrift.TException" : "") - << " {" << endl; + << " {" << '\n'; } } if (gen_es6_) { if (gen_node_ && is_exception) { - out << " = class extends Thrift.TException {" << endl; + out << " = class extends Thrift.TException {" << '\n'; } else { - out << " = class {" << endl; + out << " = class {" << '\n'; } indent_up(); - indent(out) << "constructor(args) {" << endl; + indent(out) << "constructor(args) {" << '\n'; } else { - out << " = function(args) {" << endl; + out << " = function(args) {" << '\n'; } indent_up(); @@ -894,13 +893,13 @@ void t_js_generator::generate_js_struct_definition(ostream& out, // Call super() method on inherited Error class if (gen_node_ && is_exception) { if (gen_es6_) { - indent(out) << "super(args);" << endl; + indent(out) << "super(args);" << '\n'; } else { indent(out) << "Thrift.TException.call(this, \"" << js_namespace(tstruct->get_program()) - << tstruct->get_name() << "\");" << endl; + << tstruct->get_name() << "\");" << '\n'; } out << indent() << "this.name = \"" << js_namespace(tstruct->get_program()) - << tstruct->get_name() << "\";" << endl; + << tstruct->get_name() << "\";" << '\n'; } // members with arguments @@ -909,9 +908,9 @@ void t_js_generator::generate_js_struct_definition(ostream& out, t_type* t = get_true_type((*m_iter)->get_type()); if ((*m_iter)->get_value() != nullptr && !(t->is_struct() || t->is_xception())) { dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value()); - out << indent() << "this." << (*m_iter)->get_name() << " = " << dval << ";" << endl; + out << indent() << "this." << (*m_iter)->get_name() << " = " << dval << ";" << '\n'; } else { - out << indent() << dval << ";" << endl; + out << indent() << dval << ";" << '\n'; } if (gen_ts_) { string ts_access = gen_node_ ? "public " : ""; @@ -919,11 +918,11 @@ void t_js_generator::generate_js_struct_definition(ostream& out, // Special case. Exceptions derive from Error, and error has a non optional message field. // Ignore the optional flag in this case, otherwise we will generate a incompatible field - // in the eyes of typescript. + // in the eyes of typescript. string optional_flag = is_exception && member_name == "message" ? "" : ts_get_req(*m_iter); - + f_types_ts_ << ts_indent() << ts_access << member_name << optional_flag << ": " - << ts_get_type((*m_iter)->get_type()) << ";" << endl; + << ts_get_type((*m_iter)->get_type()) << ";" << '\n'; } } @@ -934,7 +933,7 @@ void t_js_generator::generate_js_struct_definition(ostream& out, t_type* t = get_true_type((*m_iter)->get_type()); if ((*m_iter)->get_value() != nullptr && (t->is_struct() || t->is_xception())) { indent(out) << "this." << (*m_iter)->get_name() << " = " - << render_const_value(t, (*m_iter)->get_value()) << ";" << endl; + << render_const_value(t, (*m_iter)->get_value()) << ";" << '\n'; } } @@ -943,28 +942,28 @@ void t_js_generator::generate_js_struct_definition(ostream& out, t_type* t = get_true_type((*m_iter)->get_type()); if (t->is_xception()) { out << indent() << "if (args instanceof " << js_type_namespace(t->get_program()) - << t->get_name() << ") {" << endl << indent() << indent() << "this." - << (*m_iter)->get_name() << " = args;" << endl << indent() << indent() << "return;" - << endl << indent() << "}" << endl; + << t->get_name() << ") {" << '\n' << indent() << indent() << "this." + << (*m_iter)->get_name() << " = args;" << '\n' << indent() << indent() << "return;" + << '\n' << indent() << "}" << '\n'; } } - indent(out) << "if (args) {" << endl; + indent(out) << "if (args) {" << '\n'; indent_up(); if (gen_ts_) { - f_types_ts_ << endl << ts_indent() << "constructor(args?: { "; + f_types_ts_ << '\n' << ts_indent() << "constructor(args?: { "; } for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* t = get_true_type((*m_iter)->get_type()); - indent(out) << "if (args." << (*m_iter)->get_name() << " !== undefined && args." << (*m_iter)->get_name() << " !== null) {" << endl; + indent(out) << "if (args." << (*m_iter)->get_name() << " !== undefined && args." << (*m_iter)->get_name() << " !== null) {" << '\n'; indent_up(); indent(out) << "this." << (*m_iter)->get_name(); if (t->is_struct()) { out << (" = new " + js_type_namespace(t->get_program()) + t->get_name() + "(args."+(*m_iter)->get_name() +");"); - out << endl; + out << '\n'; } else if (t->is_container()) { t_type* etype = get_contained_type(t); string copyFunc = t->is_map() ? "Thrift.copyMap" : "Thrift.copyList"; @@ -993,53 +992,53 @@ void t_js_generator::generate_js_struct_definition(ostream& out, out << (" = " + copyFunc + "(args." + (*m_iter)->get_name() + ", [" + type_list + "]);"); - out << endl; + out << '\n'; } else { - out << " = args." << (*m_iter)->get_name() << ";" << endl; + out << " = args." << (*m_iter)->get_name() << ";" << '\n'; } indent_down(); if (!(*m_iter)->get_req()) { - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent(out) << " throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, " - "'Required field " << (*m_iter)->get_name() << " is unset!');" << endl; + "'Required field " << (*m_iter)->get_name() << " is unset!');" << '\n'; } - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; if (gen_ts_) { f_types_ts_ << (*m_iter)->get_name() << ts_get_req(*m_iter) << ": " << ts_get_type((*m_iter)->get_type()) << "; "; } } indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; if (gen_ts_) { - f_types_ts_ << "});" << endl; + f_types_ts_ << "});" << '\n'; } } // Done with constructor indent_down(); if (gen_es6_) { - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } else { - indent(out) << "};" << endl; + indent(out) << "};" << '\n'; } if (gen_ts_) { - f_types_ts_ << ts_indent() << "}" << endl; + f_types_ts_ << ts_indent() << "}" << '\n'; } if (!gen_es6_) { if (is_exception) { out << "Thrift.inherits(" << js_namespace(tstruct->get_program()) << tstruct->get_name() - << ", Thrift.TException);" << endl; + << ", Thrift.TException);" << '\n'; out << js_namespace(tstruct->get_program()) << tstruct->get_name() << ".prototype.name = '" - << tstruct->get_name() << "';" << endl; + << tstruct->get_name() << "';" << '\n'; } else { // init prototype manually if we aren't using es6 out << js_namespace(tstruct->get_program()) << tstruct->get_name() << ".prototype = {};" - << endl; + << '\n'; } } @@ -1050,7 +1049,7 @@ void t_js_generator::generate_js_struct_definition(ostream& out, // Close out the class definition if (gen_es6_) { indent_down(); - indent(out) << "};" << endl; + indent(out) << "};" << '\n'; } } @@ -1062,84 +1061,84 @@ void t_js_generator::generate_js_struct_reader(ostream& out, t_struct* tstruct) vector::const_iterator f_iter; if (gen_es6_) { - indent(out) << "read (input) {" << endl; + indent(out) << "read (input) {" << '\n'; } else { indent(out) << js_namespace(tstruct->get_program()) << tstruct->get_name() - << ".prototype.read = function(input) {" << endl; + << ".prototype.read = function(input) {" << '\n'; } indent_up(); - indent(out) << "input.readStructBegin();" << endl; + indent(out) << "input.readStructBegin();" << '\n'; // Loop over reading in fields - indent(out) << "while (true) {" << endl; + indent(out) << "while (true) {" << '\n'; indent_up(); - indent(out) << js_const_type_ << "ret = input.readFieldBegin();" << endl; - indent(out) << js_const_type_ << "ftype = ret.ftype;" << endl; + indent(out) << js_const_type_ << "ret = input.readFieldBegin();" << '\n'; + indent(out) << js_const_type_ << "ftype = ret.ftype;" << '\n'; if (!fields.empty()) { - indent(out) << js_const_type_ << "fid = ret.fid;" << endl; + indent(out) << js_const_type_ << "fid = ret.fid;" << '\n'; } // Check for field STOP marker and break - indent(out) << "if (ftype == Thrift.Type.STOP) {" << endl; + indent(out) << "if (ftype == Thrift.Type.STOP) {" << '\n'; indent_up(); - indent(out) << "break;" << endl; + indent(out) << "break;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; if (!fields.empty()) { // Switch statement on the field we are reading - indent(out) << "switch (fid) {" << endl; + indent(out) << "switch (fid) {" << '\n'; indent_up(); // Generate deserialization code for known cases for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - indent(out) << "case " << (*f_iter)->get_key() << ":" << endl; - indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl; + indent(out) << "case " << (*f_iter)->get_key() << ":" << '\n'; + indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n'; indent_up(); generate_deserialize_field(out, *f_iter, "this."); indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; - indent(out) << " input.skip(ftype);" << endl; + indent(out) << " input.skip(ftype);" << '\n'; - out << indent() << "}" << endl << indent() << "break;" << endl; + out << indent() << "}" << '\n' << indent() << "break;" << '\n'; } if (fields.size() == 1) { // pseudo case to make jslint happy - indent(out) << "case 0:" << endl; - indent(out) << " input.skip(ftype);" << endl; - indent(out) << " break;" << endl; + indent(out) << "case 0:" << '\n'; + indent(out) << " input.skip(ftype);" << '\n'; + indent(out) << " break;" << '\n'; } // In the default case we skip the field - indent(out) << "default:" << endl; - indent(out) << " input.skip(ftype);" << endl; + indent(out) << "default:" << '\n'; + indent(out) << " input.skip(ftype);" << '\n'; scope_down(out); } else { - indent(out) << "input.skip(ftype);" << endl; + indent(out) << "input.skip(ftype);" << '\n'; } - indent(out) << "input.readFieldEnd();" << endl; + indent(out) << "input.readFieldEnd();" << '\n'; scope_down(out); - indent(out) << "input.readStructEnd();" << endl; + indent(out) << "input.readStructEnd();" << '\n'; - indent(out) << "return;" << endl; + indent(out) << "return;" << '\n'; indent_down(); if (gen_es6_) { - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } else { - indent(out) << "};" << endl << endl; + indent(out) << "};" << '\n' << '\n'; } } @@ -1152,44 +1151,44 @@ void t_js_generator::generate_js_struct_writer(ostream& out, t_struct* tstruct) vector::const_iterator f_iter; if (gen_es6_) { - indent(out) << "write (output) {" << endl; + indent(out) << "write (output) {" << '\n'; } else { indent(out) << js_namespace(tstruct->get_program()) << tstruct->get_name() - << ".prototype.write = function(output) {" << endl; + << ".prototype.write = function(output) {" << '\n'; } indent_up(); - indent(out) << "output.writeStructBegin('" << name << "');" << endl; + indent(out) << "output.writeStructBegin('" << name << "');" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { out << indent() << "if (this." << (*f_iter)->get_name() << " !== null && this." - << (*f_iter)->get_name() << " !== undefined) {" << endl; + << (*f_iter)->get_name() << " !== undefined) {" << '\n'; indent_up(); indent(out) << "output.writeFieldBegin(" << "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type()) - << ", " << (*f_iter)->get_key() << ");" << endl; + << ", " << (*f_iter)->get_key() << ");" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "this."); - indent(out) << "output.writeFieldEnd();" << endl; + indent(out) << "output.writeFieldEnd();" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - out << indent() << "output.writeFieldStop();" << endl << indent() << "output.writeStructEnd();" - << endl; + out << indent() << "output.writeFieldStop();" << '\n' << indent() << "output.writeStructEnd();" + << '\n'; - out << indent() << "return;" << endl; + out << indent() << "return;" << '\n'; indent_down(); if (gen_es6_) { - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } else { - out << indent() << "};" << endl << endl; + out << indent() << "};" << '\n' << '\n'; } } @@ -1202,7 +1201,7 @@ void t_js_generator::generate_service(t_service* tservice) { string f_service_name = get_out_dir() + service_name_ + ".js"; f_service_.open(f_service_name.c_str()); if (gen_episode_file_) { - f_episode_ << service_name_ << ":" << thrift_package_output_directory_ << "/" << service_name_ << endl; + f_episode_ << service_name_ << ":" << thrift_package_output_directory_ << "/" << service_name_ << '\n'; } if (gen_ts_) { @@ -1213,58 +1212,58 @@ void t_js_generator::generate_service(t_service* tservice) { f_service_ << autogen_comment(); if ((gen_node_ || gen_es6_) && no_ns_) { - f_service_ << "\"use strict\";" << endl << endl; + f_service_ << "\"use strict\";" << '\n' << '\n'; } - f_service_ << js_includes() << endl << render_includes() << endl; + f_service_ << js_includes() << '\n' << render_includes() << '\n'; if (gen_ts_) { if (tservice->get_extends() != nullptr) { f_service_ts_ << "/// get_extends()->get_name() - << ".d.ts\" />" << endl; + << ".d.ts\" />" << '\n'; } - f_service_ts_ << autogen_comment() << endl << ts_includes() << endl << render_ts_includes() << endl; + f_service_ts_ << autogen_comment() << '\n' << ts_includes() << '\n' << render_ts_includes() << '\n'; if (gen_node_) { - f_service_ts_ << "import ttypes = require('./" + program_->get_name() + "_types');" << endl; + f_service_ts_ << "import ttypes = require('./" + program_->get_name() + "_types');" << '\n'; // Generate type aliases // enum vector const& enums = program_->get_enums(); vector::const_iterator e_iter; for (e_iter = enums.begin(); e_iter != enums.end(); ++e_iter) { f_service_ts_ << "import " << (*e_iter)->get_name() << " = ttypes." - << js_namespace(program_) << (*e_iter)->get_name() << endl; + << js_namespace(program_) << (*e_iter)->get_name() << '\n'; } // const vector const& consts = program_->get_consts(); vector::const_iterator c_iter; for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { f_service_ts_ << "import " << (*c_iter)->get_name() << " = ttypes." - << js_namespace(program_) << (*c_iter)->get_name() << endl; + << js_namespace(program_) << (*c_iter)->get_name() << '\n'; } // exception vector const& exceptions = program_->get_xceptions(); vector::const_iterator x_iter; for (x_iter = exceptions.begin(); x_iter != exceptions.end(); ++x_iter) { f_service_ts_ << "import " << (*x_iter)->get_name() << " = ttypes." - << js_namespace(program_) << (*x_iter)->get_name() << endl; + << js_namespace(program_) << (*x_iter)->get_name() << '\n'; } // structs vector const& structs = program_->get_structs(); vector::const_iterator s_iter; for (s_iter = structs.begin(); s_iter != structs.end(); ++s_iter) { f_service_ts_ << "import " << (*s_iter)->get_name() << " = ttypes." - << js_namespace(program_) << (*s_iter)->get_name() << endl; + << js_namespace(program_) << (*s_iter)->get_name() << '\n'; } } else { - f_service_ts_ << "import { " << program_->get_name() << " } from \"./" << program_->get_name() << "_types\";" << endl << endl; + f_service_ts_ << "import { " << program_->get_name() << " } from \"./" << program_->get_name() << "_types\";" << '\n' << '\n'; } if (!ts_module_.empty()) { if (gen_node_) { f_service_ts_ << "declare module " << ts_module_ << " {"; } else { - f_service_ts_ << "declare module \"./" << program_->get_name() << "_types\" {" << endl; + f_service_ts_ << "declare module \"./" << program_->get_name() << "_types\" {" << '\n'; indent_up(); - f_service_ts_ << ts_indent() << "module " << program_->get_name() << " {" << endl; + f_service_ts_ << ts_indent() << "module " << program_->get_name() << " {" << '\n'; indent_up(); } } @@ -1273,17 +1272,17 @@ void t_js_generator::generate_service(t_service* tservice) { if (gen_node_) { if (tservice->get_extends() != nullptr) { f_service_ << js_const_type_ << tservice->get_extends()->get_name() << " = require('./" - << tservice->get_extends()->get_name() << "');" << endl << js_const_type_ + << tservice->get_extends()->get_name() << "');" << '\n' << js_const_type_ << tservice->get_extends()->get_name() - << "Client = " << tservice->get_extends()->get_name() << ".Client;" << endl + << "Client = " << tservice->get_extends()->get_name() << ".Client;" << '\n' << js_const_type_ << tservice->get_extends()->get_name() - << "Processor = " << tservice->get_extends()->get_name() << ".Processor;" << endl; + << "Processor = " << tservice->get_extends()->get_name() << ".Processor;" << '\n'; f_service_ts_ << "import " << tservice->get_extends()->get_name() << " = require('./" - << tservice->get_extends()->get_name() << "');" << endl; + << tservice->get_extends()->get_name() << "');" << '\n'; } - f_service_ << js_const_type_ << "ttypes = require('./" + program_->get_name() + "_types');" << endl; + f_service_ << js_const_type_ << "ttypes = require('./" + program_->get_name() + "_types');" << '\n'; } generate_service_helpers(tservice); @@ -1298,11 +1297,11 @@ void t_js_generator::generate_service(t_service* tservice) { if (gen_ts_) { if (!ts_module_.empty()) { if (gen_node_) { - f_service_ts_ << "}" << endl; + f_service_ts_ << "}" << '\n'; } else { indent_down(); - f_service_ts_ << ts_indent() << "}" << endl; - f_service_ts_ << "}" << endl; + f_service_ts_ << ts_indent() << "}" << '\n'; + f_service_ts_ << "}" << '\n'; } } f_service_ts_.close(); @@ -1322,18 +1321,18 @@ void t_js_generator::generate_service_processor(t_service* tservice) { string prefix = has_js_namespace(tservice->get_program()) ? js_namespace(tservice->get_program()) : js_const_type_; f_service_ << prefix << service_name_ << "Processor = " << "exports.Processor"; if (gen_ts_) { - f_service_ts_ << endl << "declare class Processor "; + f_service_ts_ << '\n' << "declare class Processor "; if (tservice->get_extends() != nullptr) { f_service_ts_ << "extends " << tservice->get_extends()->get_name() << ".Processor "; } - f_service_ts_ << "{" << endl; + f_service_ts_ << "{" << '\n'; indent_up(); if(tservice->get_extends() == nullptr) { - f_service_ts_ << ts_indent() << "private _handler: object;" << endl << endl; + f_service_ts_ << ts_indent() << "private _handler: object;" << '\n' << '\n'; } - f_service_ts_ << ts_indent() << "constructor(handler: object);" << endl; - f_service_ts_ << ts_indent() << "process(input: thrift.TProtocol, output: thrift.TProtocol): void;" << endl; + f_service_ts_ << ts_indent() << "constructor(handler: object);" << '\n'; + f_service_ts_ << ts_indent() << "process(input: thrift.TProtocol, output: thrift.TProtocol): void;" << '\n'; indent_down(); } } else { @@ -1346,65 +1345,65 @@ void t_js_generator::generate_service_processor(t_service* tservice) { // ES6 Constructor if (gen_es6_) { if (is_subclass_service) { - f_service_ << " = class " << service_name_ << "Processor extends " << tservice->get_extends()->get_name() << "Processor {" << endl; + f_service_ << " = class " << service_name_ << "Processor extends " << tservice->get_extends()->get_name() << "Processor {" << '\n'; } else { - f_service_ << " = class " << service_name_ << "Processor {" << endl; + f_service_ << " = class " << service_name_ << "Processor {" << '\n'; } indent_up(); - indent(f_service_) << "constructor(handler) {" << endl; + indent(f_service_) << "constructor(handler) {" << '\n'; } else { - f_service_ << " = function(handler) {" << endl; + f_service_ << " = function(handler) {" << '\n'; } indent_up(); if (gen_es6_ && is_subclass_service) { - indent(f_service_) << "super(handler);" << endl; + indent(f_service_) << "super(handler);" << '\n'; } - indent(f_service_) << "this._handler = handler;" << endl; + indent(f_service_) << "this._handler = handler;" << '\n'; indent_down(); // Done with constructor if (gen_es6_) { - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } else { - indent(f_service_) << "};" << endl; + indent(f_service_) << "};" << '\n'; } // ES5 service inheritance if (!gen_es6_ && is_subclass_service) { indent(f_service_) << "Thrift.inherits(" << js_namespace(tservice->get_program()) << service_name_ << "Processor, " << tservice->get_extends()->get_name() - << "Processor);" << endl; + << "Processor);" << '\n'; } // Generate the server implementation if (gen_es6_) { - indent(f_service_) << "process (input, output) {" << endl; + indent(f_service_) << "process (input, output) {" << '\n'; } else { indent(f_service_) << js_namespace(tservice->get_program()) << service_name_ - << "Processor.prototype.process = function(input, output) {" << endl; + << "Processor.prototype.process = function(input, output) {" << '\n'; } indent_up(); - indent(f_service_) << js_const_type_ << "r = input.readMessageBegin();" << endl << indent() - << "if (this['process_' + r.fname]) {" << endl << indent() - << " return this['process_' + r.fname].call(this, r.rseqid, input, output);" << endl - << indent() << "} else {" << endl << indent() << " input.skip(Thrift.Type.STRUCT);" - << endl << indent() << " input.readMessageEnd();" << endl << indent() + indent(f_service_) << js_const_type_ << "r = input.readMessageBegin();" << '\n' << indent() + << "if (this['process_' + r.fname]) {" << '\n' << indent() + << " return this['process_' + r.fname].call(this, r.rseqid, input, output);" << '\n' + << indent() << "} else {" << '\n' << indent() << " input.skip(Thrift.Type.STRUCT);" + << '\n' << indent() << " input.readMessageEnd();" << '\n' << indent() << " " << js_const_type_ << "x = new " "Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, " - "'Unknown function ' + r.fname);" << endl << indent() + "'Unknown function ' + r.fname);" << '\n' << indent() << " output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);" - << endl << indent() << " x.write(output);" << endl << indent() - << " output.writeMessageEnd();" << endl << indent() << " output.flush();" << endl - << indent() << "}" << endl; + << '\n' << indent() << " x.write(output);" << '\n' << indent() + << " output.writeMessageEnd();" << '\n' << indent() << " output.flush();" << '\n' + << indent() << "}" << '\n'; indent_down(); if (gen_es6_) { - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } else { - indent(f_service_) << "};" << endl; + indent(f_service_) << "};" << '\n'; } // Generate the process subfunctions @@ -1415,10 +1414,10 @@ void t_js_generator::generate_service_processor(t_service* tservice) { // Close off the processor class definition if (gen_es6_) { indent_down(); - indent(f_service_) << "};" << endl; + indent(f_service_) << "};" << '\n'; } if (gen_node_ && gen_ts_) { - f_service_ts_ << "}" << endl; + f_service_ts_ << "}" << '\n'; } } @@ -1429,15 +1428,15 @@ void t_js_generator::generate_service_processor(t_service* tservice) { */ void t_js_generator::generate_process_function(t_service* tservice, t_function* tfunction) { if (gen_es6_) { - indent(f_service_) << "process_" + tfunction->get_name() + " (seqid, input, output) {" << endl; + indent(f_service_) << "process_" + tfunction->get_name() + " (seqid, input, output) {" << '\n'; } else { indent(f_service_) << js_namespace(tservice->get_program()) << service_name_ << "Processor.prototype.process_" + tfunction->get_name() - + " = function(seqid, input, output) {" << endl; + + " = function(seqid, input, output) {" << '\n'; } if (gen_ts_) { indent_up(); - f_service_ts_ << ts_indent() << "process_" << tfunction->get_name() << "(seqid: number, input: thrift.TProtocol, output: thrift.TProtocol): void;" << endl; + f_service_ts_ << ts_indent() << "process_" << tfunction->get_name() << "(seqid: number, input: thrift.TProtocol, output: thrift.TProtocol): void;" << '\n'; indent_down(); } @@ -1447,8 +1446,8 @@ void t_js_generator::generate_process_function(t_service* tservice, t_function* string resultname = js_namespace(program_) + service_name_ + "_" + tfunction->get_name() + "_result"; - indent(f_service_) << js_const_type_ << "args = new " << argsname << "();" << endl << indent() - << "args.read(input);" << endl << indent() << "input.readMessageEnd();" << endl; + indent(f_service_) << js_const_type_ << "args = new " << argsname << "();" << '\n' << indent() + << "args.read(input);" << '\n' << indent() << "input.readMessageEnd();" << '\n'; // Generate the function call t_struct* arg_struct = tfunction->get_arglist(); @@ -1469,58 +1468,58 @@ void t_js_generator::generate_process_function(t_service* tservice, t_function* f_service_ << "args." << (*f_iter)->get_name(); } - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; indent_down(); if (gen_es6_) { - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } else { - indent(f_service_) << "};" << endl; + indent(f_service_) << "};" << '\n'; } return; } // Promise style invocation indent(f_service_) << "if (this._handler." << tfunction->get_name() - << ".length === " << fields.size() << ") {" << endl; + << ".length === " << fields.size() << ") {" << '\n'; indent_up(); if (gen_es6_) { - indent(f_service_) << "new Promise((resolve) => resolve(this._handler." << tfunction->get_name() << ".bind(this._handler)(" << endl; + indent(f_service_) << "new Promise((resolve) => resolve(this._handler." << tfunction->get_name() << ".bind(this._handler)(" << '\n'; } else { string maybeComma = (fields.size() > 0 ? "," : ""); indent(f_service_) << "Q.fcall(this._handler." << tfunction->get_name() << ".bind(this._handler)" - << maybeComma << endl; + << maybeComma << '\n'; } indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { string maybeComma = (f_iter != fields.end() - 1 ? "," : ""); - indent(f_service_) << "args." << (*f_iter)->get_name() << maybeComma << endl; + indent(f_service_) << "args." << (*f_iter)->get_name() << maybeComma << '\n'; } indent_down(); if (gen_es6_) { - indent(f_service_) << "))).then(result => {" << endl; + indent(f_service_) << "))).then(result => {" << '\n'; } else { - indent(f_service_) << ").then(function(result) {" << endl; + indent(f_service_) << ").then(function(result) {" << '\n'; } indent_up(); - f_service_ << indent() << js_const_type_ << "result_obj = new " << resultname << "({success: result});" << endl + f_service_ << indent() << js_const_type_ << "result_obj = new " << resultname << "({success: result});" << '\n' << indent() << "output.writeMessageBegin(\"" << tfunction->get_name() - << "\", Thrift.MessageType.REPLY, seqid);" << endl << indent() - << "result_obj.write(output);" << endl << indent() << "output.writeMessageEnd();" << endl - << indent() << "output.flush();" << endl; + << "\", Thrift.MessageType.REPLY, seqid);" << '\n' << indent() + << "result_obj.write(output);" << '\n' << indent() << "output.writeMessageEnd();" << '\n' + << indent() << "output.flush();" << '\n'; indent_down(); if (gen_es6_) { - indent(f_service_) << "}).catch(err => {" << endl; + indent(f_service_) << "}).catch(err => {" << '\n'; } else { - indent(f_service_) << "}).catch(function (err) {" << endl; + indent(f_service_) << "}).catch(function (err) {" << '\n'; } indent_up(); - indent(f_service_) << js_let_type_ << "result;" << endl; + indent(f_service_) << js_let_type_ << "result;" << '\n'; bool has_exception = false; t_struct* exceptions = tfunction->get_xceptions(); @@ -1542,36 +1541,36 @@ void t_js_generator::generate_process_function(t_service* tservice, t_function* } if (has_exception) { - f_service_ << ") {" << endl; + f_service_ << ") {" << '\n'; indent_up(); - f_service_ << indent() << "result = new " << resultname << "(err);" << endl << indent() + f_service_ << indent() << "result = new " << resultname << "(err);" << '\n' << indent() << "output.writeMessageBegin(\"" << tfunction->get_name() - << "\", Thrift.MessageType.REPLY, seqid);" << endl; + << "\", Thrift.MessageType.REPLY, seqid);" << '\n'; indent_down(); - indent(f_service_) << "} else {" << endl; + indent(f_service_) << "} else {" << '\n'; indent_up(); } f_service_ << indent() << "result = new " "Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN," - " err.message);" << endl << indent() << "output.writeMessageBegin(\"" - << tfunction->get_name() << "\", Thrift.MessageType.EXCEPTION, seqid);" << endl; + " err.message);" << '\n' << indent() << "output.writeMessageBegin(\"" + << tfunction->get_name() << "\", Thrift.MessageType.EXCEPTION, seqid);" << '\n'; if (has_exception) { indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } - f_service_ << indent() << "result.write(output);" << endl << indent() - << "output.writeMessageEnd();" << endl << indent() << "output.flush();" << endl; + f_service_ << indent() << "result.write(output);" << '\n' << indent() + << "output.writeMessageEnd();" << '\n' << indent() << "output.flush();" << '\n'; indent_down(); - indent(f_service_) << "});" << endl; + indent(f_service_) << "});" << '\n'; indent_down(); // End promise style invocation // Callback style invocation - indent(f_service_) << "} else {" << endl; + indent(f_service_) << "} else {" << '\n'; indent_up(); indent(f_service_) << "this._handler." << tfunction->get_name() << "("; @@ -1580,12 +1579,12 @@ void t_js_generator::generate_process_function(t_service* tservice, t_function* } if (gen_es6_) { - f_service_ << "(err, result) => {" << endl; + f_service_ << "(err, result) => {" << '\n'; } else { - f_service_ << "function (err, result) {" << endl; + f_service_ << "function (err, result) {" << '\n'; } indent_up(); - indent(f_service_) << js_let_type_ << "result_obj;" << endl; + indent(f_service_) << js_let_type_ << "result_obj;" << '\n'; indent(f_service_) << "if ((err === null || typeof err === 'undefined')"; if (has_exception) { @@ -1597,35 +1596,35 @@ void t_js_generator::generate_process_function(t_service* tservice, t_function* } } } - f_service_ << ") {" << endl; + f_service_ << ") {" << '\n'; indent_up(); f_service_ << indent() << "result_obj = new " << resultname - << "((err !== null || typeof err === 'undefined') ? err : {success: result});" << endl << indent() + << "((err !== null || typeof err === 'undefined') ? err : {success: result});" << '\n' << indent() << "output.writeMessageBegin(\"" << tfunction->get_name() - << "\", Thrift.MessageType.REPLY, seqid);" << endl; + << "\", Thrift.MessageType.REPLY, seqid);" << '\n'; indent_down(); - indent(f_service_) << "} else {" << endl; + indent(f_service_) << "} else {" << '\n'; indent_up(); f_service_ << indent() << "result_obj = new " "Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN," - " err.message);" << endl << indent() << "output.writeMessageBegin(\"" - << tfunction->get_name() << "\", Thrift.MessageType.EXCEPTION, seqid);" << endl; + " err.message);" << '\n' << indent() << "output.writeMessageBegin(\"" + << tfunction->get_name() << "\", Thrift.MessageType.EXCEPTION, seqid);" << '\n'; indent_down(); - f_service_ << indent() << "}" << endl << indent() << "result_obj.write(output);" << endl << indent() - << "output.writeMessageEnd();" << endl << indent() << "output.flush();" << endl; + f_service_ << indent() << "}" << '\n' << indent() << "result_obj.write(output);" << '\n' << indent() + << "output.writeMessageEnd();" << '\n' << indent() << "output.flush();" << '\n'; indent_down(); - indent(f_service_) << "});" << endl; + indent(f_service_) << "});" << '\n'; indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; // End callback style invocation indent_down(); if (gen_es6_) { - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } else { - indent(f_service_) << "};" << endl; + indent(f_service_) << "};" << '\n'; } } @@ -1642,7 +1641,7 @@ void t_js_generator::generate_service_helpers(t_service* tservice) { vector functions = tservice->get_functions(); vector::iterator f_iter; - f_service_ << "//HELPER FUNCTIONS AND STRUCTURES" << endl << endl; + f_service_ << "//HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { t_struct* ts = (*f_iter)->get_arglist(); @@ -1712,7 +1711,7 @@ void t_js_generator::generate_service_client(t_service* tservice) { if (tservice->get_extends() != nullptr) { f_service_ts_ << "extends " << tservice->get_extends()->get_name() << ".Client "; } - f_service_ts_ << "{" << endl; + f_service_ts_ << "{" << '\n'; } } else { f_service_ << js_namespace(tservice->get_program()) << service_name_ @@ -1723,7 +1722,7 @@ void t_js_generator::generate_service_client(t_service* tservice) { if (is_subclass_service) { f_service_ts_ << "extends " << tservice->get_extends()->get_name() << "Client "; } - f_service_ts_ << "{" << endl; + f_service_ts_ << "{" << '\n'; } } @@ -1732,21 +1731,21 @@ void t_js_generator::generate_service_client(t_service* tservice) { if (is_subclass_service) { f_service_ << " = class " << service_name_ << "Client extends " << js_namespace(tservice->get_extends()->get_program()) - << tservice->get_extends()->get_name() << "Client {" << endl; + << tservice->get_extends()->get_name() << "Client {" << '\n'; } else { - f_service_ << " = class " << service_name_ << "Client {" << endl; + f_service_ << " = class " << service_name_ << "Client {" << '\n'; } indent_up(); if (gen_node_) { - indent(f_service_) << "constructor(output, pClass) {" << endl; + indent(f_service_) << "constructor(output, pClass) {" << '\n'; } else { - indent(f_service_) << "constructor(input, output) {" << endl; + indent(f_service_) << "constructor(input, output) {" << '\n'; } } else { if (gen_node_) { - f_service_ << " = function(output, pClass) {" << endl; + f_service_ << " = function(output, pClass) {" << '\n'; } else { - f_service_ << " = function(input, output) {" << endl; + f_service_ << " = function(input, output) {" << '\n'; } } @@ -1754,65 +1753,65 @@ void t_js_generator::generate_service_client(t_service* tservice) { if (gen_node_) { if (gen_es6_ && is_subclass_service) { - indent(f_service_) << "super(output, pClass);" << endl; + indent(f_service_) << "super(output, pClass);" << '\n'; } - indent(f_service_) << "this.output = output;" << endl; - indent(f_service_) << "this.pClass = pClass;" << endl; - indent(f_service_) << "this._seqid = 0;" << endl; - indent(f_service_) << "this._reqs = {};" << endl; + indent(f_service_) << "this.output = output;" << '\n'; + indent(f_service_) << "this.pClass = pClass;" << '\n'; + indent(f_service_) << "this._seqid = 0;" << '\n'; + indent(f_service_) << "this._reqs = {};" << '\n'; if (gen_ts_) { if(!is_subclass_service) { - f_service_ts_ << ts_indent() << "private output: thrift.TTransport;" << endl - << ts_indent() << "private pClass: thrift.TProtocol;" << endl - << ts_indent() << "private _seqid: number;" << endl - << endl; + f_service_ts_ << ts_indent() << "private output: thrift.TTransport;" << '\n' + << ts_indent() << "private pClass: thrift.TProtocol;" << '\n' + << ts_indent() << "private _seqid: number;" << '\n' + << '\n'; } f_service_ts_ << ts_indent() << "constructor(output: thrift.TTransport, pClass: { new(trans: thrift.TTransport): thrift.TProtocol });" - << endl; + << '\n'; } } else { - indent(f_service_) << "this.input = input;" << endl; - indent(f_service_) << "this.output = (!output) ? input : output;" << endl; - indent(f_service_) << "this.seqid = 0;" << endl; + indent(f_service_) << "this.input = input;" << '\n'; + indent(f_service_) << "this.output = (!output) ? input : output;" << '\n'; + indent(f_service_) << "this.seqid = 0;" << '\n'; if (gen_ts_) { - f_service_ts_ << ts_indent() << "input: Thrift.TJSONProtocol;" << endl << ts_indent() - << "output: Thrift.TJSONProtocol;" << endl << ts_indent() << "seqid: number;" - << endl << endl << ts_indent() + f_service_ts_ << ts_indent() << "input: Thrift.TJSONProtocol;" << '\n' << ts_indent() + << "output: Thrift.TJSONProtocol;" << '\n' << ts_indent() << "seqid: number;" + << '\n' << '\n' << ts_indent() << "constructor(input: Thrift.TJSONProtocol, output?: Thrift.TJSONProtocol);" - << endl; + << '\n'; } } indent_down(); if (gen_es6_) { - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } else { - indent(f_service_) << "};" << endl; + indent(f_service_) << "};" << '\n'; if (is_subclass_service) { indent(f_service_) << "Thrift.inherits(" << js_namespace(tservice->get_program()) << service_name_ << "Client, " << js_namespace(tservice->get_extends()->get_program()) - << tservice->get_extends()->get_name() << "Client);" << endl; + << tservice->get_extends()->get_name() << "Client);" << '\n'; } else { // init prototype indent(f_service_) << js_namespace(tservice->get_program()) << service_name_ - << "Client.prototype = {};" << endl; + << "Client.prototype = {};" << '\n'; } } // utils for multiplexed services if (gen_node_) { if (gen_es6_) { - indent(f_service_) << "seqid () { return this._seqid; }" << endl; - indent(f_service_) << "new_seqid () { return this._seqid += 1; }" << endl; + indent(f_service_) << "seqid () { return this._seqid; }" << '\n'; + indent(f_service_) << "new_seqid () { return this._seqid += 1; }" << '\n'; } else { indent(f_service_) << js_namespace(tservice->get_program()) << service_name_ - << "Client.prototype.seqid = function() { return this._seqid; };" << endl + << "Client.prototype.seqid = function() { return this._seqid; };" << '\n' << js_namespace(tservice->get_program()) << service_name_ << "Client.prototype.new_seqid = function() { return this._seqid += 1; };" - << endl; + << '\n'; } } @@ -1827,144 +1826,144 @@ void t_js_generator::generate_service_client(t_service* tservice) { string arglist = argument_list(arg_struct); // Open function - f_service_ << endl; + f_service_ << '\n'; if (gen_es6_) { - indent(f_service_) << funname << " (" << arglist << ") {" << endl; + indent(f_service_) << funname << " (" << arglist << ") {" << '\n'; } else { indent(f_service_) << js_namespace(tservice->get_program()) << service_name_ << "Client.prototype." - << function_signature(*f_iter, "", !gen_es6_) << " {" << endl; + << function_signature(*f_iter, "", !gen_es6_) << " {" << '\n'; } indent_up(); if (gen_ts_) { // function definition without callback - f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, false) << endl; + f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, false) << '\n'; if (!gen_es6_) { // overload with callback - f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, true) << endl; + f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, true) << '\n'; } else { // overload with callback - f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, true) << endl; + f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, true) << '\n'; } } if (gen_es6_ && gen_node_) { - indent(f_service_) << "this._seqid = this.new_seqid();" << endl; - indent(f_service_) << js_const_type_ << "self = this;" << endl << indent() - << "return new Promise((resolve, reject) => {" << endl; + indent(f_service_) << "this._seqid = this.new_seqid();" << '\n'; + indent(f_service_) << js_const_type_ << "self = this;" << '\n' << indent() + << "return new Promise((resolve, reject) => {" << '\n'; indent_up(); - indent(f_service_) << "self._reqs[self.seqid()] = (error, result) => {" << endl; + indent(f_service_) << "self._reqs[self.seqid()] = (error, result) => {" << '\n'; indent_up(); - indent(f_service_) << "return error ? reject(error) : resolve(result);" << endl; + indent(f_service_) << "return error ? reject(error) : resolve(result);" << '\n'; indent_down(); - indent(f_service_) << "};" << endl; - indent(f_service_) << "self.send_" << funname << "(" << arglist << ");" << endl; + indent(f_service_) << "};" << '\n'; + indent(f_service_) << "self.send_" << funname << "(" << arglist << ");" << '\n'; indent_down(); - indent(f_service_) << "});" << endl; + indent(f_service_) << "});" << '\n'; } else if (gen_node_) { // Node.js output ./gen-nodejs - f_service_ << indent() << "this._seqid = this.new_seqid();" << endl << indent() - << "if (callback === undefined) {" << endl; + f_service_ << indent() << "this._seqid = this.new_seqid();" << '\n' << indent() + << "if (callback === undefined) {" << '\n'; indent_up(); - f_service_ << indent() << js_const_type_ << "_defer = Q.defer();" << endl << indent() - << "this._reqs[this.seqid()] = function(error, result) {" << endl; + f_service_ << indent() << js_const_type_ << "_defer = Q.defer();" << '\n' << indent() + << "this._reqs[this.seqid()] = function(error, result) {" << '\n'; indent_up(); - indent(f_service_) << "if (error) {" << endl; + indent(f_service_) << "if (error) {" << '\n'; indent_up(); - indent(f_service_) << "_defer.reject(error);" << endl; + indent(f_service_) << "_defer.reject(error);" << '\n'; indent_down(); - indent(f_service_) << "} else {" << endl; + indent(f_service_) << "} else {" << '\n'; indent_up(); - indent(f_service_) << "_defer.resolve(result);" << endl; + indent(f_service_) << "_defer.resolve(result);" << '\n'; indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; indent_down(); - indent(f_service_) << "};" << endl; - f_service_ << indent() << "this.send_" << funname << "(" << arglist << ");" << endl - << indent() << "return _defer.promise;" << endl; + indent(f_service_) << "};" << '\n'; + f_service_ << indent() << "this.send_" << funname << "(" << arglist << ");" << '\n' + << indent() << "return _defer.promise;" << '\n'; indent_down(); - indent(f_service_) << "} else {" << endl; + indent(f_service_) << "} else {" << '\n'; indent_up(); - f_service_ << indent() << "this._reqs[this.seqid()] = callback;" << endl << indent() - << "this.send_" << funname << "(" << arglist << ");" << endl; + f_service_ << indent() << "this._reqs[this.seqid()] = callback;" << '\n' << indent() + << "this.send_" << funname << "(" << arglist << ");" << '\n'; indent_down(); - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } else if (gen_es6_) { - f_service_ << indent() << js_const_type_ << "self = this;" << endl << indent() - << "return new Promise((resolve, reject) => {" << endl; + f_service_ << indent() << js_const_type_ << "self = this;" << '\n' << indent() + << "return new Promise((resolve, reject) => {" << '\n'; indent_up(); f_service_ << indent() << "self.send_" << funname << "(" << arglist - << (arglist.empty() ? "" : ", ") << "(error, result) => {" << endl; + << (arglist.empty() ? "" : ", ") << "(error, result) => {" << '\n'; indent_up(); - indent(f_service_) << "return error ? reject(error) : resolve(result);" << endl; + indent(f_service_) << "return error ? reject(error) : resolve(result);" << '\n'; indent_down(); - f_service_ << indent() << "});" << endl; + f_service_ << indent() << "});" << '\n'; indent_down(); - f_service_ << indent() << "});" << endl; + f_service_ << indent() << "});" << '\n'; } else if (gen_jquery_) { // jQuery output ./gen-js - f_service_ << indent() << "if (callback === undefined) {" << endl; + f_service_ << indent() << "if (callback === undefined) {" << '\n'; indent_up(); - f_service_ << indent() << "this.send_" << funname << "(" << arglist << ");" << endl; + f_service_ << indent() << "this.send_" << funname << "(" << arglist << ");" << '\n'; if (!(*f_iter)->is_oneway()) { f_service_ << indent(); if (!(*f_iter)->get_returntype()->is_void()) { f_service_ << "return "; } - f_service_ << "this.recv_" << funname << "();" << endl; + f_service_ << "this.recv_" << funname << "();" << '\n'; } indent_down(); - f_service_ << indent() << "} else {" << endl; + f_service_ << indent() << "} else {" << '\n'; indent_up(); f_service_ << indent() << js_const_type_ << "postData = this.send_" << funname << "(" << arglist - << (arglist.empty() ? "" : ", ") << "true);" << endl; - f_service_ << indent() << "return this.output.getTransport()" << endl; + << (arglist.empty() ? "" : ", ") << "true);" << '\n'; + f_service_ << indent() << "return this.output.getTransport()" << '\n'; indent_up(); f_service_ << indent() << ".jqRequest(this, postData, arguments, this.recv_" << funname - << ");" << endl; + << ");" << '\n'; indent_down(); indent_down(); - f_service_ << indent() << "}" << endl; + f_service_ << indent() << "}" << '\n'; } else { // Standard JavaScript ./gen-js f_service_ << indent() << "this.send_" << funname << "(" << arglist - << (arglist.empty() ? "" : ", ") << "callback); " << endl; + << (arglist.empty() ? "" : ", ") << "callback); " << '\n'; if (!(*f_iter)->is_oneway()) { - f_service_ << indent() << "if (!callback) {" << endl; + f_service_ << indent() << "if (!callback) {" << '\n'; f_service_ << indent(); if (!(*f_iter)->get_returntype()->is_void()) { f_service_ << " return "; } - f_service_ << "this.recv_" << funname << "();" << endl; - f_service_ << indent() << "}" << endl; + f_service_ << "this.recv_" << funname << "();" << '\n'; + f_service_ << indent() << "}" << '\n'; } } indent_down(); if (gen_es6_) { - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; } else { - indent(f_service_) << "};" << endl << endl; + indent(f_service_) << "};" << '\n' << '\n'; } // Send function if (gen_es6_) { if (gen_node_) { - indent(f_service_) << "send_" << funname << " (" << arglist << ") {" << endl; + indent(f_service_) << "send_" << funname << " (" << arglist << ") {" << '\n'; } else { // ES6 js still uses callbacks here. Should refactor this to promise style later.. - indent(f_service_) << "send_" << funname << " (" << argument_list(arg_struct, true) << ") {" << endl; + indent(f_service_) << "send_" << funname << " (" << argument_list(arg_struct, true) << ") {" << '\n'; } } else { indent(f_service_) << js_namespace(tservice->get_program()) << service_name_ << "Client.prototype.send_" - << function_signature(*f_iter, "", !gen_node_) << " {" << endl; + << function_signature(*f_iter, "", !gen_node_) << " {" << '\n'; } indent_up(); std::string outputVar; if (gen_node_) { - f_service_ << indent() << js_const_type_ << "output = new this.pClass(this.output);" << endl; + f_service_ << indent() << js_const_type_ << "output = new this.pClass(this.output);" << '\n'; outputVar = "output"; } else { outputVar = "this.output"; @@ -1980,127 +1979,127 @@ void t_js_generator::generate_service_client(t_service* tservice) { // It is possible that a method argument is named "params", we need to ensure the locally // generated identifier "params" is uniquely named std::string params_identifier = this->next_identifier_name(fields, "params"); - f_service_ << indent() << js_const_type_ << params_identifier << " = {" << endl; + f_service_ << indent() << js_const_type_ << params_identifier << " = {" << '\n'; indent_up(); for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { indent(f_service_) << (*fld_iter)->get_name() << ": " << (*fld_iter)->get_name(); if (fld_iter != fields.end()-1) { - f_service_ << "," << endl; + f_service_ << "," << '\n'; } else { - f_service_ << endl; + f_service_ << '\n'; } } indent_down(); - indent(f_service_) << "};" << endl; + indent(f_service_) << "};" << '\n'; // NOTE: "args" is a reserved keyword, so no need to generate a unique identifier - indent(f_service_) << js_const_type_ << "args = new " << argsname << "(" << params_identifier << ");" << endl; + indent(f_service_) << js_const_type_ << "args = new " << argsname << "(" << params_identifier << ");" << '\n'; } else { - indent(f_service_) << js_const_type_ << "args = new " << argsname << "();" << endl; + indent(f_service_) << js_const_type_ << "args = new " << argsname << "();" << '\n'; } // Serialize the request header within try/catch - indent(f_service_) << "try {" << endl; + indent(f_service_) << "try {" << '\n'; indent_up(); if (gen_node_) { f_service_ << indent() << outputVar << ".writeMessageBegin('" << (*f_iter)->get_name() - << "', " << messageType << ", this.seqid());" << endl; + << "', " << messageType << ", this.seqid());" << '\n'; } else { f_service_ << indent() << outputVar << ".writeMessageBegin('" << (*f_iter)->get_name() - << "', " << messageType << ", this.seqid);" << endl; + << "', " << messageType << ", this.seqid);" << '\n'; } // Write to the stream - f_service_ << indent() << "args.write(" << outputVar << ");" << endl << indent() << outputVar - << ".writeMessageEnd();" << endl; + f_service_ << indent() << "args.write(" << outputVar << ");" << '\n' << indent() << outputVar + << ".writeMessageEnd();" << '\n'; if (gen_node_) { if((*f_iter)->is_oneway()) { - f_service_ << indent() << "this.output.flush();" << endl; - f_service_ << indent() << js_const_type_ << "callback = this._reqs[this.seqid()] || function() {};" << endl; - f_service_ << indent() << "delete this._reqs[this.seqid()];" << endl; - f_service_ << indent() << "callback(null);" << endl; + f_service_ << indent() << "this.output.flush();" << '\n'; + f_service_ << indent() << js_const_type_ << "callback = this._reqs[this.seqid()] || function() {};" << '\n'; + f_service_ << indent() << "delete this._reqs[this.seqid()];" << '\n'; + f_service_ << indent() << "callback(null);" << '\n'; } else { - f_service_ << indent() << "return this.output.flush();" << endl; + f_service_ << indent() << "return this.output.flush();" << '\n'; } } else { if (gen_jquery_) { - f_service_ << indent() << "return this.output.getTransport().flush(callback);" << endl; + f_service_ << indent() << "return this.output.getTransport().flush(callback);" << '\n'; } else if (gen_es6_) { - f_service_ << indent() << js_const_type_ << "self = this;" << endl; + f_service_ << indent() << js_const_type_ << "self = this;" << '\n'; if((*f_iter)->is_oneway()) { - f_service_ << indent() << "this.output.getTransport().flush(true, null);" << endl; - f_service_ << indent() << "callback();" << endl; + f_service_ << indent() << "this.output.getTransport().flush(true, null);" << '\n'; + f_service_ << indent() << "callback();" << '\n'; } else { - f_service_ << indent() << "this.output.getTransport().flush(true, () => {" << endl; + f_service_ << indent() << "this.output.getTransport().flush(true, () => {" << '\n'; indent_up(); - f_service_ << indent() << js_let_type_ << "error = null, result = null;" << endl; - f_service_ << indent() << "try {" << endl; - f_service_ << indent() << " result = self.recv_" << funname << "();" << endl; - f_service_ << indent() << "} catch (e) {" << endl; - f_service_ << indent() << " error = e;" << endl; - f_service_ << indent() << "}" << endl; - f_service_ << indent() << "callback(error, result);" << endl; + f_service_ << indent() << js_let_type_ << "error = null, result = null;" << '\n'; + f_service_ << indent() << "try {" << '\n'; + f_service_ << indent() << " result = self.recv_" << funname << "();" << '\n'; + f_service_ << indent() << "} catch (e) {" << '\n'; + f_service_ << indent() << " error = e;" << '\n'; + f_service_ << indent() << "}" << '\n'; + f_service_ << indent() << "callback(error, result);" << '\n'; indent_down(); - f_service_ << indent() << "});" << endl; + f_service_ << indent() << "});" << '\n'; } } else { - f_service_ << indent() << "if (callback) {" << endl; + f_service_ << indent() << "if (callback) {" << '\n'; indent_up(); if((*f_iter)->is_oneway()) { - f_service_ << indent() << "this.output.getTransport().flush(true, null);" << endl; - f_service_ << indent() << "callback();" << endl; + f_service_ << indent() << "this.output.getTransport().flush(true, null);" << '\n'; + f_service_ << indent() << "callback();" << '\n'; } else { - f_service_ << indent() << js_const_type_ << "self = this;" << endl; - f_service_ << indent() << "this.output.getTransport().flush(true, function() {" << endl; + f_service_ << indent() << js_const_type_ << "self = this;" << '\n'; + f_service_ << indent() << "this.output.getTransport().flush(true, function() {" << '\n'; indent_up(); - f_service_ << indent() << js_let_type_ << "result = null;" << endl; - f_service_ << indent() << "try {" << endl; - f_service_ << indent() << " result = self.recv_" << funname << "();" << endl; - f_service_ << indent() << "} catch (e) {" << endl; - f_service_ << indent() << " result = e;" << endl; - f_service_ << indent() << "}" << endl; - f_service_ << indent() << "callback(result);" << endl; + f_service_ << indent() << js_let_type_ << "result = null;" << '\n'; + f_service_ << indent() << "try {" << '\n'; + f_service_ << indent() << " result = self.recv_" << funname << "();" << '\n'; + f_service_ << indent() << "} catch (e) {" << '\n'; + f_service_ << indent() << " result = e;" << '\n'; + f_service_ << indent() << "}" << '\n'; + f_service_ << indent() << "callback(result);" << '\n'; indent_down(); - f_service_ << indent() << "});" << endl; + f_service_ << indent() << "});" << '\n'; } indent_down(); - f_service_ << indent() << "} else {" << endl; - f_service_ << indent() << " return this.output.getTransport().flush();" << endl; - f_service_ << indent() << "}" << endl; + f_service_ << indent() << "} else {" << '\n'; + f_service_ << indent() << " return this.output.getTransport().flush();" << '\n'; + f_service_ << indent() << "}" << '\n'; } } indent_down(); - f_service_ << indent() << "}" << endl; + f_service_ << indent() << "}" << '\n'; // Reset the transport and delete registered callback if there was a serialization error - f_service_ << indent() << "catch (e) {" << endl; + f_service_ << indent() << "catch (e) {" << '\n'; indent_up(); if (gen_node_) { - f_service_ << indent() << "delete this._reqs[this.seqid()];" << endl; - f_service_ << indent() << "if (typeof " << outputVar << ".reset === 'function') {" << endl; - f_service_ << indent() << " " << outputVar << ".reset();" << endl; - f_service_ << indent() << "}" << endl; + f_service_ << indent() << "delete this._reqs[this.seqid()];" << '\n'; + f_service_ << indent() << "if (typeof " << outputVar << ".reset === 'function') {" << '\n'; + f_service_ << indent() << " " << outputVar << ".reset();" << '\n'; + f_service_ << indent() << "}" << '\n'; } else { - f_service_ << indent() << "if (typeof " << outputVar << ".getTransport().reset === 'function') {" << endl; - f_service_ << indent() << " " << outputVar << ".getTransport().reset();" << endl; - f_service_ << indent() << "}" << endl; + f_service_ << indent() << "if (typeof " << outputVar << ".getTransport().reset === 'function') {" << '\n'; + f_service_ << indent() << " " << outputVar << ".getTransport().reset();" << '\n'; + f_service_ << indent() << "}" << '\n'; } - f_service_ << indent() << "throw e;" << endl; + f_service_ << indent() << "throw e;" << '\n'; indent_down(); - f_service_ << indent() << "}" << endl; + f_service_ << indent() << "}" << '\n'; indent_down(); // Close send function if (gen_es6_) { - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } else { - indent(f_service_) << "};" << endl; + indent(f_service_) << "};" << '\n'; } // Receive function @@ -2108,19 +2107,19 @@ void t_js_generator::generate_service_client(t_service* tservice) { std::string resultname = js_namespace(tservice->get_program()) + service_name_ + "_" + (*f_iter)->get_name() + "_result"; - f_service_ << endl; + f_service_ << '\n'; // Open receive function if (gen_node_) { if (gen_es6_) { - indent(f_service_) << "recv_" << (*f_iter)->get_name() << " (input, mtype, rseqid) {" << endl; + indent(f_service_) << "recv_" << (*f_iter)->get_name() << " (input, mtype, rseqid) {" << '\n'; } else { indent(f_service_) << js_namespace(tservice->get_program()) << service_name_ << "Client.prototype.recv_" << (*f_iter)->get_name() - << " = function(input,mtype,rseqid) {" << endl; + << " = function(input,mtype,rseqid) {" << '\n'; } } else { if (gen_es6_) { - indent(f_service_) << "recv_" << (*f_iter)->get_name() << " () {" << endl; + indent(f_service_) << "recv_" << (*f_iter)->get_name() << " () {" << '\n'; } else { t_struct noargs(program_); @@ -2128,7 +2127,7 @@ void t_js_generator::generate_service_client(t_service* tservice) { string("recv_") + (*f_iter)->get_name(), &noargs); indent(f_service_) << js_namespace(tservice->get_program()) << service_name_ - << "Client.prototype." << function_signature(&recv_function) << " {" << endl; + << "Client.prototype." << function_signature(&recv_function) << " {" << '\n'; } } @@ -2142,68 +2141,68 @@ void t_js_generator::generate_service_client(t_service* tservice) { } if (gen_node_) { - f_service_ << indent() << js_const_type_ << "callback = this._reqs[rseqid] || function() {};" << endl - << indent() << "delete this._reqs[rseqid];" << endl; + f_service_ << indent() << js_const_type_ << "callback = this._reqs[rseqid] || function() {};" << '\n' + << indent() << "delete this._reqs[rseqid];" << '\n'; } else { - f_service_ << indent() << js_const_type_ << "ret = this.input.readMessageBegin();" << endl - << indent() << js_const_type_ << "mtype = ret.mtype;" << endl; + f_service_ << indent() << js_const_type_ << "ret = this.input.readMessageBegin();" << '\n' + << indent() << js_const_type_ << "mtype = ret.mtype;" << '\n'; } - f_service_ << indent() << "if (mtype == Thrift.MessageType.EXCEPTION) {" << endl; + f_service_ << indent() << "if (mtype == Thrift.MessageType.EXCEPTION) {" << '\n'; indent_up(); - f_service_ << indent() << js_const_type_ << "x = new Thrift.TApplicationException();" << endl - << indent() << "x.read(" << inputVar << ");" << endl - << indent() << inputVar << ".readMessageEnd();" << endl - << indent() << render_recv_throw("x") << endl; + f_service_ << indent() << js_const_type_ << "x = new Thrift.TApplicationException();" << '\n' + << indent() << "x.read(" << inputVar << ");" << '\n' + << indent() << inputVar << ".readMessageEnd();" << '\n' + << indent() << render_recv_throw("x") << '\n'; scope_down(f_service_); - f_service_ << indent() << js_const_type_ << "result = new " << resultname << "();" << endl << indent() - << "result.read(" << inputVar << ");" << endl; + f_service_ << indent() << js_const_type_ << "result = new " << resultname << "();" << '\n' << indent() + << "result.read(" << inputVar << ");" << '\n'; - f_service_ << indent() << inputVar << ".readMessageEnd();" << endl << endl; + f_service_ << indent() << inputVar << ".readMessageEnd();" << '\n' << '\n'; t_struct* xs = (*f_iter)->get_xceptions(); const std::vector& xceptions = xs->get_members(); vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { - f_service_ << indent() << "if (null !== result." << (*x_iter)->get_name() << ") {" << endl + f_service_ << indent() << "if (null !== result." << (*x_iter)->get_name() << ") {" << '\n' << indent() << " " << render_recv_throw("result." + (*x_iter)->get_name()) - << endl << indent() << "}" << endl; + << '\n' << indent() << "}" << '\n'; } // Careful, only return result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { - f_service_ << indent() << "if (null !== result.success) {" << endl << indent() << " " - << render_recv_return("result.success") << endl << indent() << "}" << endl; + f_service_ << indent() << "if (null !== result.success) {" << '\n' << indent() << " " + << render_recv_return("result.success") << '\n' << indent() << "}" << '\n'; f_service_ << indent() << render_recv_throw("'" + (*f_iter)->get_name() + " failed: unknown result'") - << endl; + << '\n'; } else { if (gen_node_) { - indent(f_service_) << "callback(null);" << endl; + indent(f_service_) << "callback(null);" << '\n'; } else { - indent(f_service_) << "return;" << endl; + indent(f_service_) << "return;" << '\n'; } } // Close receive function indent_down(); if (gen_es6_) { - indent(f_service_) << "}" << endl; + indent(f_service_) << "}" << '\n'; } else { - indent(f_service_) << "};" << endl; + indent(f_service_) << "};" << '\n'; } } } // Finish class definitions if (gen_ts_) { - f_service_ts_ << ts_indent() << "}" << endl; + f_service_ts_ << ts_indent() << "}" << '\n'; } if (gen_es6_) { indent_down(); - f_service_ << "};" << endl; + f_service_ << "};" << '\n'; } } @@ -2284,7 +2283,7 @@ void t_js_generator::generate_deserialize_field(ostream& out, out << ".value"; } - out << ";" << endl; + out << ";" << '\n'; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", tfield->get_name().c_str(), @@ -2300,7 +2299,7 @@ void t_js_generator::generate_deserialize_field(ostream& out, */ void t_js_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) { out << indent() << prefix << " = new " << js_type_namespace(tstruct->get_program()) - << tstruct->get_name() << "();" << endl << indent() << prefix << ".read(input);" << endl; + << tstruct->get_name() << "();" << '\n' << indent() << prefix << ".read(input);" << '\n'; } void t_js_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) { @@ -2311,36 +2310,36 @@ void t_js_generator::generate_deserialize_container(ostream& out, t_type* ttype, // Declare variables, read header if (ttype->is_map()) { - out << indent() << prefix << " = {};" << endl; + out << indent() << prefix << " = {};" << '\n'; - out << indent() << js_const_type_ << rtmp3 << " = input.readMapBegin();" << endl; - out << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << endl; + out << indent() << js_const_type_ << rtmp3 << " = input.readMapBegin();" << '\n'; + out << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << '\n'; } else if (ttype->is_set()) { - out << indent() << prefix << " = [];" << endl - << indent() << js_const_type_ << rtmp3 << " = input.readSetBegin();" << endl - << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << endl; + out << indent() << prefix << " = [];" << '\n' + << indent() << js_const_type_ << rtmp3 << " = input.readSetBegin();" << '\n' + << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << '\n'; } else if (ttype->is_list()) { - out << indent() << prefix << " = [];" << endl - << indent() << js_const_type_ << rtmp3 << " = input.readListBegin();" << endl - << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << endl; + out << indent() << prefix << " = [];" << '\n' + << indent() << js_const_type_ << rtmp3 << " = input.readListBegin();" << '\n' + << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << '\n'; } // For loop iterates over elements string i = tmp("_i"); - indent(out) << "for (" << js_let_type_ << i << " = 0; " << i << " < " << size << "; ++" << i << ") {" << endl; + indent(out) << "for (" << js_let_type_ << i << " = 0; " << i << " < " << size << "; ++" << i << ") {" << '\n'; indent_up(); if (ttype->is_map()) { if (!gen_node_) { - out << indent() << "if (" << i << " > 0 ) {" << endl << indent() - << " if (input.rstack.length > input.rpos[input.rpos.length -1] + 1) {" << endl - << indent() << " input.rstack.pop();" << endl << indent() << " }" << endl << indent() - << "}" << endl; + out << indent() << "if (" << i << " > 0 ) {" << '\n' << indent() + << " if (input.rstack.length > input.rpos[input.rpos.length -1] + 1) {" << '\n' + << indent() << " input.rstack.pop();" << '\n' << indent() << " }" << '\n' << indent() + << "}" << '\n'; } generate_deserialize_map_element(out, (t_map*)ttype, prefix); @@ -2354,11 +2353,11 @@ void t_js_generator::generate_deserialize_container(ostream& out, t_type* ttype, // Read container end if (ttype->is_map()) { - indent(out) << "input.readMapEnd();" << endl; + indent(out) << "input.readMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "input.readSetEnd();" << endl; + indent(out) << "input.readSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "input.readListEnd();" << endl; + indent(out) << "input.readListEnd();" << '\n'; } } @@ -2371,24 +2370,24 @@ void t_js_generator::generate_deserialize_map_element(ostream& out, t_map* tmap, t_field fkey(tmap->get_key_type(), key); t_field fval(tmap->get_val_type(), val); - indent(out) << declare_field(&fkey, false, false) << ";" << endl; - indent(out) << declare_field(&fval, false, false) << ";" << endl; + indent(out) << declare_field(&fkey, false, false) << ";" << '\n'; + indent(out) << declare_field(&fval, false, false) << ";" << '\n'; generate_deserialize_field(out, &fkey); generate_deserialize_field(out, &fval); - indent(out) << prefix << "[" << key << "] = " << val << ";" << endl; + indent(out) << prefix << "[" << key << "] = " << val << ";" << '\n'; } void t_js_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) { string elem = tmp("elem"); t_field felem(tset->get_elem_type(), elem); - indent(out) << js_let_type_ << elem << " = null;" << endl; + indent(out) << js_let_type_ << elem << " = null;" << '\n'; generate_deserialize_field(out, &felem); - indent(out) << prefix << ".push(" << elem << ");" << endl; + indent(out) << prefix << ".push(" << elem << ");" << '\n'; } void t_js_generator::generate_deserialize_list_element(ostream& out, @@ -2397,11 +2396,11 @@ void t_js_generator::generate_deserialize_list_element(ostream& out, string elem = tmp("elem"); t_field felem(tlist->get_elem_type(), elem); - indent(out) << js_let_type_ << elem << " = null;" << endl; + indent(out) << js_let_type_ << elem << " = null;" << '\n'; generate_deserialize_field(out, &felem); - indent(out) << prefix << ".push(" << elem << ");" << endl; + indent(out) << prefix << ".push(" << elem << ");" << '\n'; } /** @@ -2465,7 +2464,7 @@ void t_js_generator::generate_serialize_field(ostream& out, t_field* tfield, str } else if (type->is_enum()) { out << "writeI32(" << name << ")"; } - out << ";" << endl; + out << ";" << '\n'; } else { printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n", @@ -2483,7 +2482,7 @@ void t_js_generator::generate_serialize_field(ostream& out, t_field* tfield, str */ void t_js_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - indent(out) << prefix << ".write(output);" << endl; + indent(out) << prefix << ".write(output);" << '\n'; } /** @@ -2493,58 +2492,58 @@ void t_js_generator::generate_serialize_container(ostream& out, t_type* ttype, s if (ttype->is_map()) { indent(out) << "output.writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " - << "Thrift.objectLength(" << prefix << "));" << endl; + << "Thrift.objectLength(" << prefix << "));" << '\n'; } else if (ttype->is_set()) { indent(out) << "output.writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " - << prefix << ".length);" << endl; + << prefix << ".length);" << '\n'; } else if (ttype->is_list()) { indent(out) << "output.writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type()) - << ", " << prefix << ".length);" << endl; + << ", " << prefix << ".length);" << '\n'; } if (ttype->is_map()) { string kiter = tmp("kiter"); string viter = tmp("viter"); - indent(out) << "for (" << js_let_type_ << kiter << " in " << prefix << ") {" << endl; + indent(out) << "for (" << js_let_type_ << kiter << " in " << prefix << ") {" << '\n'; indent_up(); - indent(out) << "if (" << prefix << ".hasOwnProperty(" << kiter << ")) {" << endl; + indent(out) << "if (" << prefix << ".hasOwnProperty(" << kiter << ")) {" << '\n'; indent_up(); - indent(out) << js_let_type_ << viter << " = " << prefix << "[" << kiter << "];" << endl; + indent(out) << js_let_type_ << viter << " = " << prefix << "[" << kiter << "];" << '\n'; generate_serialize_map_element(out, (t_map*)ttype, kiter, viter); scope_down(out); scope_down(out); } else if (ttype->is_set()) { string iter = tmp("iter"); - indent(out) << "for (" << js_let_type_ << iter << " in " << prefix << ") {" << endl; + indent(out) << "for (" << js_let_type_ << iter << " in " << prefix << ") {" << '\n'; indent_up(); - indent(out) << "if (" << prefix << ".hasOwnProperty(" << iter << ")) {" << endl; + indent(out) << "if (" << prefix << ".hasOwnProperty(" << iter << ")) {" << '\n'; indent_up(); - indent(out) << iter << " = " << prefix << "[" << iter << "];" << endl; + indent(out) << iter << " = " << prefix << "[" << iter << "];" << '\n'; generate_serialize_set_element(out, (t_set*)ttype, iter); scope_down(out); scope_down(out); } else if (ttype->is_list()) { string iter = tmp("iter"); - indent(out) << "for (" << js_let_type_ << iter << " in " << prefix << ") {" << endl; + indent(out) << "for (" << js_let_type_ << iter << " in " << prefix << ") {" << '\n'; indent_up(); - indent(out) << "if (" << prefix << ".hasOwnProperty(" << iter << ")) {" << endl; + indent(out) << "if (" << prefix << ".hasOwnProperty(" << iter << ")) {" << '\n'; indent_up(); - indent(out) << iter << " = " << prefix << "[" << iter << "];" << endl; + indent(out) << iter << " = " << prefix << "[" << iter << "];" << '\n'; generate_serialize_list_element(out, (t_list*)ttype, iter); scope_down(out); scope_down(out); } if (ttype->is_map()) { - indent(out) << "output.writeMapEnd();" << endl; + indent(out) << "output.writeMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "output.writeSetEnd();" << endl; + indent(out) << "output.writeSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "output.writeListEnd();" << endl; + indent(out) << "output.writeListEnd();" << '\n'; } } diff --git a/compiler/cpp/src/thrift/generate/t_json_generator.cc b/compiler/cpp/src/thrift/generate/t_json_generator.cc index e91d65ad5db..3fb973a4f37 100644 --- a/compiler/cpp/src/thrift/generate/t_json_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_json_generator.cc @@ -42,8 +42,6 @@ using std::stringstream; using std::vector; using std::stack; -static const string endl = "\n"; -static const string quot = "\""; static const bool NO_INDENT = false; static const bool FORCE_STRING = true; @@ -182,20 +180,20 @@ string t_json_generator::escape_json_string(const string& input) { } void t_json_generator::start_object(bool should_indent) { - f_json_ << (should_indent ? indent() : "") << "{" << endl; + f_json_ << (should_indent ? indent() : "") << "{" << '\n'; indent_up(); comma_needed_.push(false); } void t_json_generator::start_array() { - f_json_ << "[" << endl; + f_json_ << "[" << '\n'; indent_up(); comma_needed_.push(false); } void t_json_generator::write_comma_if_needed() { if (comma_needed_.top()) { - f_json_ << "," << endl; + f_json_ << "," << '\n'; } } @@ -230,14 +228,14 @@ void t_json_generator::write_key_and_bool(string key, bool val) { void t_json_generator::end_object() { indent_down(); - f_json_ << endl << indent() << "}"; + f_json_ << '\n' << indent() << "}"; comma_needed_.pop(); } void t_json_generator::end_array() { indent_down(); if (comma_needed_.top()) { - f_json_ << endl; + f_json_ << '\n'; } indent(f_json_) << "]"; comma_needed_.pop(); @@ -296,7 +294,7 @@ void t_json_generator::write_type_spec(t_type* ttype) { } void t_json_generator::close_generator() { - f_json_ << endl; + f_json_ << '\n'; f_json_.close(); } @@ -471,7 +469,7 @@ void t_json_generator::generate_typedef(t_typedef* ttypedef) { } void t_json_generator::write_string(const string& value) { - f_json_ << quot << escape_json_string(value) << quot; + f_json_ << '\"' << escape_json_string(value) << '\"'; } void t_json_generator::write_const_value(t_const_value* value, bool should_force_string) { @@ -537,7 +535,7 @@ void t_json_generator::write_const_value(t_const_value* value, bool should_force } string t_json_generator::json_str(const string& str) { - return quot + escape_json_string(str) + quot; + return string("\"") + escape_json_string(str) + string("\""); } void t_json_generator::generate_constant(t_const* con) { diff --git a/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc b/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc index 78917d99f95..2e81909c48b 100644 --- a/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc @@ -45,8 +45,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - static const string KOTLIN_RESERVED_WORDS[] = { "as", "as?", "break", "class", "continue", "do", "else", "false", "for", "fun", "if", "in", "!in", "interface", @@ -209,7 +207,7 @@ void t_kotlin_generator::init_generator() { * Nothing in Kotlin generator */ void t_kotlin_generator::close_generator() { - f_types_ << endl; + f_types_ << '\n'; f_types_.close(); } @@ -222,7 +220,7 @@ void t_kotlin_generator::close_generator() { */ void t_kotlin_generator::generate_typedef(t_typedef* ttypedef) { f_types_ << "typealias " << ttypedef->get_symbolic() << " = " - << type_name(ttypedef->get_type(), true) << endl; + << type_name(ttypedef->get_type(), true) << '\n'; } void t_kotlin_generator::generate_enum(t_enum* tenum) { @@ -241,32 +239,32 @@ void t_kotlin_generator::generate_enum(t_enum* tenum) { auto first = true; auto enum_values = tenum->get_constants(); for (auto& enum_value : enum_values) { - f_enum << (first ? "" : ",") << endl; + f_enum << (first ? "" : ",") << '\n'; first = false; indent(f_enum) << enum_value->get_name() << "(" << enum_value->get_value() << ")"; } if (first) { indent(f_enum); } - f_enum << ";" << endl << endl; - indent(f_enum) << "override fun getValue() = value" << endl << endl; + f_enum << ";" << '\n' << '\n'; + indent(f_enum) << "override fun getValue() = value" << '\n' << '\n'; { - indent(f_enum) << "companion object {" << endl; + indent(f_enum) << "companion object {" << '\n'; indent_up(); { - indent(f_enum) << "@kotlin.jvm.JvmStatic" << endl; + indent(f_enum) << "@kotlin.jvm.JvmStatic" << '\n'; indent(f_enum) << "fun findByValue(i: kotlin.Int): " << kotlin_safe_name(tenum->get_name()) - << "? {" << endl; + << "? {" << '\n'; indent_up(); { - indent(f_enum) << "return when (i) {" << endl; + indent(f_enum) << "return when (i) {" << '\n'; indent_up(); { auto enum_values = tenum->get_constants(); for (auto& enum_value : enum_values) { - indent(f_enum) << enum_value->get_value() << " -> " << enum_value->get_name() << endl; + indent(f_enum) << enum_value->get_value() << " -> " << enum_value->get_name() << '\n'; } - indent(f_enum) << "else -> null" << endl; + indent(f_enum) << "else -> null" << '\n'; } scope_down(f_enum); } @@ -322,7 +320,7 @@ void t_kotlin_generator::generate_consts(std::vector consts) { } else { // TODO } - f_types_ << endl; + f_types_ << '\n'; } } @@ -442,7 +440,7 @@ void t_kotlin_generator::generate_struct_field_name_constants(std::ostream& out, t_struct* tstruct) { indent(out) << "enum class _Fields(private val thriftFieldId: kotlin.Short, private val " "fieldName: kotlin.String) : org.apache.thrift.TFieldIdEnum {" - << endl; + << '\n'; indent_up(); { // fields @@ -450,7 +448,7 @@ void t_kotlin_generator::generate_struct_field_name_constants(std::ostream& out, bool first = true; for (auto& field : tstruct->get_members()) { if (!first) { - out << "," << endl; + out << "," << '\n'; } first = false; indent(out) << constant_name(field->get_name()) << "(" << field->get_key() << ", \"" @@ -459,49 +457,49 @@ void t_kotlin_generator::generate_struct_field_name_constants(std::ostream& out, if (first) { indent(out); } - out << ";" << endl << endl; + out << ";" << '\n' << '\n'; } // methods - indent(out) << "override fun getThriftFieldId() = thriftFieldId" << endl << endl; - indent(out) << "override fun getFieldName() = fieldName" << endl << endl; + indent(out) << "override fun getThriftFieldId() = thriftFieldId" << '\n' << '\n'; + indent(out) << "override fun getFieldName() = fieldName" << '\n' << '\n'; // companion object - indent(out) << "companion object {" << endl; + indent(out) << "companion object {" << '\n'; indent_up(); { - indent(out) << "@kotlin.jvm.JvmStatic" << endl; - indent(out) << "fun findByValue(value: kotlin.Int): _Fields? {" << endl; + indent(out) << "@kotlin.jvm.JvmStatic" << '\n'; + indent(out) << "fun findByValue(value: kotlin.Int): _Fields? {" << '\n'; indent_up(); { - indent(out) << "return when (value) {" << endl; + indent(out) << "return when (value) {" << '\n'; indent_up(); { for (auto& field : tstruct->get_members()) { - indent(out) << field->get_key() << " -> " << constant_name(field->get_name()) << endl; + indent(out) << field->get_key() << " -> " << constant_name(field->get_name()) << '\n'; } - indent(out) << "else -> null" << endl; + indent(out) << "else -> null" << '\n'; } scope_down(out); } scope_down(out); } - out << endl; + out << '\n'; { - indent(out) << "@kotlin.jvm.JvmStatic" << endl; - indent(out) << "fun findByName(name: kotlin.String): _Fields? {" << endl; + indent(out) << "@kotlin.jvm.JvmStatic" << '\n'; + indent(out) << "fun findByName(name: kotlin.String): _Fields? {" << '\n'; indent_up(); { - indent(out) << "return when (name) {" << endl; + indent(out) << "return when (name) {" << '\n'; indent_up(); { for (auto& field : tstruct->get_members()) { indent(out) << "\"" << field->get_name() << "\"" - << " -> " << constant_name(field->get_name()) << endl; + << " -> " << constant_name(field->get_name()) << '\n'; } - indent(out) << "else -> null" << endl; + indent(out) << "else -> null" << '\n'; } scope_down(out); } @@ -511,16 +509,16 @@ void t_kotlin_generator::generate_struct_field_name_constants(std::ostream& out, scope_down(out); } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_companion_object(std::ostream& out, t_struct* tstruct) { - indent(out) << "companion object {" << endl; + indent(out) << "companion object {" << '\n'; indent_up(); { indent(out) << "private val STRUCT_DESC: org.apache.thrift.protocol.TStruct = " "org.apache.thrift.protocol.TStruct(\"" - << tstruct->get_name() << "\")" << endl; + << tstruct->get_name() << "\")" << '\n'; { for (auto& field : tstruct->get_members()) { // field desc @@ -528,15 +526,15 @@ void t_kotlin_generator::generate_struct_companion_object(std::ostream& out, t_s << "_FIELD_DESC: org.apache.thrift.protocol.TField = " "org.apache.thrift.protocol.TField(\"" << field->get_name() << "\", " << type_to_enum(field->get_type()) << ", " - << field->get_key() << ")" << endl; + << field->get_key() << ")" << '\n'; // field metadata indent(out) << "private val " << constant_name(field->get_name()) << "_FIELD_META_DATA: org.apache.thrift.meta_data.FieldMetaData = " "org.apache.thrift.meta_data.FieldMetaData(" - << endl; + << '\n'; indent_up(); { - indent(out) << '"' << field->get_name() << '"' << ',' << endl; + indent(out) << '"' << field->get_name() << '"' << ',' << '\n'; indent(out) << "org.apache.thrift.TFieldRequirementType."; if (field->get_req() == t_field::T_REQUIRED) { out << "REQUIRED"; @@ -545,12 +543,12 @@ void t_kotlin_generator::generate_struct_companion_object(std::ostream& out, t_s } else { out << "DEFAULT"; } - out << ',' << endl; + out << ',' << '\n'; generate_field_value_meta_data(indent(out), field->get_type()); - out << ',' << endl; + out << ',' << '\n'; generate_metadata_for_field_annotations(indent(out), field); } - out << ")" << endl; + out << ")" << '\n'; indent_down(); } } @@ -558,23 +556,23 @@ void t_kotlin_generator::generate_struct_companion_object(std::ostream& out, t_s // all fields in a map indent(out) << "private val metadata: Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> = mapOf(" - << endl; + << '\n'; indent_up(); for (auto& field : tstruct->get_members()) { indent(out) << "_Fields." << constant_name(field->get_name()) << " to " - << constant_name(field->get_name()) << "_FIELD_META_DATA," << endl; + << constant_name(field->get_name()) << "_FIELD_META_DATA," << '\n'; } indent_down(); - indent(out) << ")" << endl; + indent(out) << ")" << '\n'; - indent(out) << "init {" << endl; + indent(out) << "init {" << '\n'; indent_up(); indent(out) << "org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(" - << tstruct->get_name() << "::class.java, metadata)" << endl; + << tstruct->get_name() << "::class.java, metadata)" << '\n'; scope_down(out); } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_metadata_for_field_annotations(std::ostream& out, @@ -582,10 +580,10 @@ void t_kotlin_generator::generate_metadata_for_field_annotations(std::ostream& o if (field->annotations_.size() == 0) { out << "emptyMap()"; } else { - out << "mapOf(" << endl; + out << "mapOf(" << '\n'; indent_up(); for (auto& annotation : field->annotations_) { - indent(out) << "\"" + annotation.first + "\" to \"" + annotation.second.back() + "\"," << endl; + indent(out) << "\"" + annotation.first + "\" to \"" + annotation.second.back() + "\"," << '\n'; } indent_down(); indent(out) << ")"; @@ -600,24 +598,24 @@ void t_kotlin_generator::generate_field_value_meta_data(std::ostream& out, t_typ out << "StructMetaData(" << ttype_class << "STRUCT, " << type_name(type) << "::class.java"; } else if (type->is_container()) { if (type->is_list()) { - out << "ListMetaData(" << ttype_class << "LIST," << endl; + out << "ListMetaData(" << ttype_class << "LIST," << '\n'; indent_up(); t_type* elem_type = ((t_list*)type)->get_elem_type(); generate_field_value_meta_data(indent(out), elem_type); indent_down(); } else if (type->is_set()) { - out << "SetMetaData(" << ttype_class << "SET," << endl; + out << "SetMetaData(" << ttype_class << "SET," << '\n'; indent_up(); t_type* elem_type = ((t_set*)type)->get_elem_type(); generate_field_value_meta_data(indent(out), elem_type); indent_down(); } else { - out << "MapMetaData(" << ttype_class << "MAP," << endl; + out << "MapMetaData(" << ttype_class << "MAP," << '\n'; indent_up(); t_type* key_type = ((t_map*)type)->get_key_type(); t_type* val_type = ((t_map*)type)->get_val_type(); generate_field_value_meta_data(indent(out), key_type); - out << "," << endl; + out << "," << '\n'; generate_field_value_meta_data(indent(out), val_type); indent_down(); } @@ -635,30 +633,30 @@ void t_kotlin_generator::generate_field_value_meta_data(std::ostream& out, t_typ } void t_kotlin_generator::generate_struct_method_deep_copy(std::ostream& out, t_struct* tstruct) { - indent(out) << "override fun deepCopy(): " << tstruct->get_name() << " {" << endl; + indent(out) << "override fun deepCopy(): " << tstruct->get_name() << " {" << '\n'; indent_up(); { - indent(out) << "return " << tstruct->get_name() << " (" << endl; + indent(out) << "return " << tstruct->get_name() << " (" << '\n'; indent_up(); { for (auto& field : tstruct->get_members()) { - indent(out) << kotlin_safe_name(field->get_name()) << "," << endl; + indent(out) << kotlin_safe_name(field->get_name()) << "," << '\n'; } } indent_down(); - indent(out) << ")" << endl; + indent(out) << ")" << '\n'; } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_method_compare_to(std::ostream& out, t_struct* tstruct) { indent(out) << "override fun compareTo(other: " << tstruct->get_name() << "?): kotlin.Int {" - << endl; + << '\n'; indent_up(); { indent(out) << "val comparator = compareBy<" << tstruct->get_name() - << "> { it::class.java.name }" << endl; + << "> { it::class.java.name }" << '\n'; indent_up(); for (auto& field : tstruct->get_members()) { indent(out) << ".thenBy"; @@ -667,33 +665,33 @@ void t_kotlin_generator::generate_struct_method_compare_to(std::ostream& out, t_ || field_type->is_binary()) { out << "(org.apache.thrift.TBaseHelper::compareTo)"; } - out << " { it." << kotlin_safe_name(field->get_name()) << " } " << endl; + out << " { it." << kotlin_safe_name(field->get_name()) << " } " << '\n'; } indent_down(); - indent(out) << "return nullsFirst(comparator).compare(this, other)" << endl; + indent(out) << "return nullsFirst(comparator).compare(this, other)" << '\n'; } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_method_field_for_id(std::ostream& out, t_struct* /*tstruct*/) { - indent(out) << "override fun fieldForId(fieldId: kotlin.Int): _Fields {" << endl; + indent(out) << "override fun fieldForId(fieldId: kotlin.Int): _Fields {" << '\n'; indent_up(); { indent(out) << "return _Fields.findByValue(fieldId) ?: throw " "kotlin.IllegalArgumentException(\"invalid fieldId $fieldId\")" - << endl; + << '\n'; } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_method_is_set(std::ostream& out, t_struct* tstruct) { - indent(out) << "override fun isSet(field: _Fields): kotlin.Boolean {" << endl; + indent(out) << "override fun isSet(field: _Fields): kotlin.Boolean {" << '\n'; indent_up(); { - indent(out) << "return when (field) {" << endl; + indent(out) << "return when (field) {" << '\n'; indent_up(); { auto members = tstruct->get_members(); @@ -705,67 +703,67 @@ void t_kotlin_generator::generate_struct_method_is_set(std::ostream& out, t_stru } else { out << "this." << kotlin_safe_name(field->get_name()) << " != null"; } - out << endl; + out << '\n'; } } else { - indent(out) << "else -> false" << endl; + indent(out) << "else -> false" << '\n'; } } scope_down(out); } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_method_clear(std::ostream& out, t_struct* tstruct) { - indent(out) << "override fun clear(): kotlin.Unit {" << endl; + indent(out) << "override fun clear(): kotlin.Unit {" << '\n'; indent_up(); { for (auto& field : tstruct->get_members()) { auto is_required = field->get_req() == t_field::T_REQUIRED; indent(out) << (is_required ? "_" + field->get_name() : kotlin_safe_name(field->get_name())) - << " = null" << endl; + << " = null" << '\n'; } } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_method_validate(std::ostream& out, t_struct* tstruct) { - indent(out) << "@kotlin.jvm.Throws(org.apache.thrift.TException::class)" << endl; - indent(out) << "fun validate(): kotlin.Unit {" << endl; + indent(out) << "@kotlin.jvm.Throws(org.apache.thrift.TException::class)" << '\n'; + indent(out) << "fun validate(): kotlin.Unit {" << '\n'; indent_up(); { for (auto& field : tstruct->get_members()) { bool is_required = field->get_req() == t_field::T_REQUIRED; if (is_required) { - indent(out) << "if (_" << field->get_name() << " == null) {" << endl; + indent(out) << "if (_" << field->get_name() << " == null) {" << '\n'; indent_up(); { indent(out) << "throw org.apache.thrift.TException(\"Required field `" << field->get_name() << "' is null, " "struct is: $this\")" - << endl; + << '\n'; } scope_down(out); } } } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_method_set_field_value(std::ostream& out, t_struct* tstruct) { - indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << endl; + indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << '\n'; indent(out) << "override fun setFieldValue(field: _Fields, value: kotlin.Any?): kotlin.Unit {" - << endl; + << '\n'; indent_up(); { const vector& members = tstruct->get_members(); if (members.size() > 0) { - indent(out) << "when (field) {" << endl; + indent(out) << "when (field) {" << '\n'; indent_up(); { for (auto& field : tstruct->get_members()) { @@ -773,155 +771,155 @@ void t_kotlin_generator::generate_struct_method_set_field_value(std::ostream& ou indent(out) << "_Fields." << constant_name(field->get_name()) << " -> this." << (is_required ? "_" + field->get_name() : kotlin_safe_name(field->get_name())) - << " = value as " << type_name(field->get_type()) << "?" << endl; + << " = value as " << type_name(field->get_type()) << "?" << '\n'; } } scope_down(out); } else { - indent(out) << "return" << endl; + indent(out) << "return" << '\n'; } } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_method_get_field_value(std::ostream& out, t_struct* tstruct) { - indent(out) << "override fun getFieldValue(field: _Fields): kotlin.Any? {" << endl; + indent(out) << "override fun getFieldValue(field: _Fields): kotlin.Any? {" << '\n'; indent_up(); { auto members = tstruct->get_members(); if (members.size() > 0) { - indent(out) << "return when (field) {" << endl; + indent(out) << "return when (field) {" << '\n'; indent_up(); { for (auto& field : tstruct->get_members()) { indent(out) << "_Fields." << constant_name(field->get_name()) << " -> this." - << kotlin_safe_name(field->get_name()) << endl; + << kotlin_safe_name(field->get_name()) << '\n'; } } scope_down(out); } else { - indent(out) << "return null" << endl; + indent(out) << "return null" << '\n'; } } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_method_read(std::ostream& out, t_struct* tstruct) { indent(out) << "override fun read(iproto: org.apache.thrift.protocol.TProtocol): kotlin.Unit {" - << endl; + << '\n'; indent_up(); { indent(out) << "require(org.apache.thrift.scheme.StandardScheme::class.java == iproto.scheme) { " "\"only standard scheme is " "supported for now\" }" - << endl; - indent(out) << tstruct->get_name() << "StandardScheme.read(iproto, this)" << endl; + << '\n'; + indent(out) << tstruct->get_name() << "StandardScheme.read(iproto, this)" << '\n'; } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_method_write(std::ostream& out, t_struct* tstruct) { indent(out) << "override fun write(oproto: org.apache.thrift.protocol.TProtocol): kotlin.Unit {" - << endl; + << '\n'; indent_up(); { indent(out) << "require(org.apache.thrift.scheme.StandardScheme::class.java == oproto.scheme) { " "\"only standard scheme is " "supported for now\" }" - << endl; - indent(out) << tstruct->get_name() << "StandardScheme.write(oproto, this)" << endl; + << '\n'; + indent(out) << tstruct->get_name() << "StandardScheme.write(oproto, this)" << '\n'; } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_standard_scheme_read(std::ostream& out, t_struct* tstruct) { indent(out) << "override fun read(iproto: org.apache.thrift.protocol.TProtocol, struct: " - << tstruct->get_name() << ") {" << endl; + << tstruct->get_name() << ") {" << '\n'; indent_up(); { - indent(out) << "iproto.apply {" << endl; + indent(out) << "iproto.apply {" << '\n'; indent_up(); { - indent(out) << "readStruct {" << endl; + indent(out) << "readStruct {" << '\n'; indent_up(); { - indent(out) << "var stopped = false" << endl; - indent(out) << "while (!stopped) {" << endl; + indent(out) << "var stopped = false" << '\n'; + indent(out) << "while (!stopped) {" << '\n'; indent_up(); { - indent(out) << "stopped = readField {" << endl; + indent(out) << "stopped = readField {" << '\n'; indent_up(); { indent(out) << "val skipNext = { " "org.apache.thrift.protocol.TProtocolUtil.skip(iproto, it.type) }" - << endl; + << '\n'; - indent(out) << "when (it.id.toInt()) {" << endl; + indent(out) << "when (it.id.toInt()) {" << '\n'; indent_up(); { for (auto& field : tstruct->get_members()) { - indent(out) << field->get_key() << " -> {" << endl; + indent(out) << field->get_key() << " -> {" << '\n'; indent_up(); { indent(out) << "if (it.type == " << type_to_enum(field->get_type()) << ") {" - << endl; + << '\n'; indent_up(); generate_deserialize_field(out, field, "struct."); indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent_up(); - indent(out) << "skipNext()" << endl; + indent(out) << "skipNext()" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } scope_down(out); } - indent(out) << "else -> skipNext()" << endl; + indent(out) << "else -> skipNext()" << '\n'; } scope_down(out); } scope_down(out); } scope_down(out); - indent(out) << "struct.validate()" << endl; + indent(out) << "struct.validate()" << '\n'; } scope_down(out); } scope_down(out); } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_standard_scheme_write(std::ostream& out, t_struct* tstruct) { indent(out) << "override fun write(oproto: org.apache.thrift.protocol.TProtocol, struct: " - << tstruct->get_name() << ") {" << endl; + << tstruct->get_name() << ") {" << '\n'; indent_up(); { - indent(out) << "struct.validate()" << endl; - indent(out) << "oproto.apply {" << endl; + indent(out) << "struct.validate()" << '\n'; + indent(out) << "oproto.apply {" << '\n'; indent_up(); { - indent(out) << "writeStruct(STRUCT_DESC) {" << endl; + indent(out) << "writeStruct(STRUCT_DESC) {" << '\n'; indent_up(); { for (auto& field : tstruct->get_members()) { auto is_required = field->get_req() == t_field::T_REQUIRED; indent(out) << "struct." << kotlin_safe_name(field->get_name()) << (is_required ? "" : "?") << ".let { " - << kotlin_safe_name(field->get_name()) << " ->" << endl; + << kotlin_safe_name(field->get_name()) << " ->" << '\n'; indent_up(); { indent(out) << "writeField(" << constant_name(field->get_name()) << "_FIELD_DESC) {" - << endl; + << '\n'; indent_up(); generate_serialize_field(out, field); scope_down(out); @@ -929,36 +927,36 @@ void t_kotlin_generator::generate_struct_standard_scheme_write(std::ostream& out scope_down(out); } } - indent(out) << "writeFieldStop()" << endl; + indent(out) << "writeFieldStop()" << '\n'; scope_down(out); } scope_down(out); } scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_struct_standard_scheme(std::ostream& out, t_struct* tstruct) { indent(out) << "private object " << tstruct->get_name() << "StandardScheme : org.apache.thrift.scheme.StandardScheme<" << tstruct->get_name() - << ">() {" << endl; + << ">() {" << '\n'; indent_up(); generate_struct_standard_scheme_read(out, tstruct); generate_struct_standard_scheme_write(out, tstruct); scope_down(out); - out << endl; + out << '\n'; } void t_kotlin_generator::generate_union_tuple_scheme(std::ostream& out, t_struct* /*tunion*/) { indent(out) << "override fun tupleSchemeReadValue(iproto: org.apache.thrift.protocol.TProtocol, " "fieldID: kotlin.Short) = throw kotlin.UnsupportedOperationException(\"only " "standard scheme is supported for now\")" - << endl; + << '\n'; indent(out) << "override fun tupleSchemeWriteValue(oproto: org.apache.thrift.protocol.TProtocol) = " "throw kotlin.UnsupportedOperationException(\"only standard scheme is supported for " "now\")" - << endl; + << '\n'; } void t_kotlin_generator::generate_union_standard_scheme(std::ostream& out, t_struct* tunion) { @@ -970,61 +968,61 @@ void t_kotlin_generator::generate_union_standard_scheme_read(std::ostream& out, indent(out) << "override fun standardSchemeReadValue(iproto: org.apache.thrift.protocol.TProtocol, " "field: org.apache.thrift.protocol.TField): Any? =" - << endl; + << '\n'; indent_up(); - indent(out) << "when (_Fields.findByValue(field.id.toInt())) {" << endl; + indent(out) << "when (_Fields.findByValue(field.id.toInt())) {" << '\n'; indent_up(); for (auto& member : tunion->get_members()) { auto expect_type = type_name(member->get_type()); - indent(out) << "_Fields." << constant_name(member->get_name()) << " -> {" << endl; + indent(out) << "_Fields." << constant_name(member->get_name()) << " -> {" << '\n'; indent_up(); { indent(out) << "if (field.type == " << constant_name(member->get_name()) - << "_FIELD_DESC.type) {" << endl; + << "_FIELD_DESC.type) {" << '\n'; indent_up(); - indent(out) << "iproto.run {" << endl; + indent(out) << "iproto.run {" << '\n'; indent_up(); indent(out); generate_deserialize_value(out, member->get_type()); - out << endl; + out << '\n'; scope_down(out); indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent_up(); - indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iproto, field.type)" << endl; - indent(out) << "null" << endl; + indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iproto, field.type)" << '\n'; + indent(out) << "null" << '\n'; scope_down(out); } scope_down(out); } - indent(out) << "null -> {" << endl; + indent(out) << "null -> {" << '\n'; indent_up(); - indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iproto, field.type)" << endl; - indent(out) << "null" << endl; + indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iproto, field.type)" << '\n'; + indent(out) << "null" << '\n'; scope_down(out); scope_down(out); indent_down(); } void t_kotlin_generator::generate_union_standard_scheme_write(std::ostream& out, t_struct* tunion) { - indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << endl; + indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << '\n'; indent(out) << "override fun standardSchemeWriteValue(oproto: org.apache.thrift.protocol.TProtocol) {" - << endl; + << '\n'; indent_up(); - indent(out) << "when (setField_) {" << endl; + indent(out) << "when (setField_) {" << '\n'; indent_up(); for (auto& member : tunion->get_members()) { - indent(out) << "_Fields." << constant_name(member->get_name()) << " -> {" << endl; + indent(out) << "_Fields." << constant_name(member->get_name()) << " -> {" << '\n'; indent_up(); { - indent(out) << "val it = value_ as " << type_name(member->get_type()) << endl; - indent(out) << "oproto.apply {" << endl; + indent(out) << "val it = value_ as " << type_name(member->get_type()) << '\n'; + indent(out) << "oproto.apply {" << '\n'; indent_up(); { indent(out); generate_serialize_value(out, member->get_type()); - out << endl; + out << '\n'; } scope_down(out); } @@ -1032,7 +1030,7 @@ void t_kotlin_generator::generate_union_standard_scheme_write(std::ostream& out, } indent(out) << "null -> throw kotlin.IllegalStateException(\"Cannot write union with unknown " "field $setField_\")" - << endl; + << '\n'; scope_down(out); scope_down(out); } @@ -1052,25 +1050,25 @@ void t_kotlin_generator::generate_union_methods_definitions(std::ostream& out, t } auto union_class_name = kotlin_safe_name(tunion->get_name()); - { indent(out) << "override fun deepCopy() = " << union_class_name << "(this)" << endl; } - { indent(out) << "override fun enumForId(id: kotlin.Short) = fieldForId(id.toInt())" << endl; } - { indent(out) << "override fun getStructDesc() = STRUCT_DESC" << endl; } + { indent(out) << "override fun deepCopy() = " << union_class_name << "(this)" << '\n'; } + { indent(out) << "override fun enumForId(id: kotlin.Short) = fieldForId(id.toInt())" << '\n'; } + { indent(out) << "override fun getStructDesc() = STRUCT_DESC" << '\n'; } { - indent(out) << "override fun getFieldDesc(setField: _Fields) = when (setField) {" << endl; + indent(out) << "override fun getFieldDesc(setField: _Fields) = when (setField) {" << '\n'; indent_up(); for (auto& member : tunion->get_members()) { indent(out) << "_Fields." << constant_name(member->get_name()) << " -> " - << constant_name(member->get_name()) << "_FIELD_DESC" << endl; + << constant_name(member->get_name()) << "_FIELD_DESC" << '\n'; } scope_down(out); } } void t_kotlin_generator::generate_union_method_check_type(std::ostream& out, t_struct* tunion) { - indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << endl; - indent(out) << "override fun checkType(setField: _Fields, value: kotlin.Any?) {" << endl; + indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << '\n'; + indent(out) << "override fun checkType(setField: _Fields, value: kotlin.Any?) {" << '\n'; indent_up(); - indent(out) << "when (setField) {" << endl; + indent(out) << "when (setField) {" << '\n'; indent_up(); for (auto& member : tunion->get_members()) { auto expect_type = type_name(member->get_type()); @@ -1078,7 +1076,7 @@ void t_kotlin_generator::generate_union_method_check_type(std::ostream& out, t_s << expect_type << " ?: throw kotlin.ClassCastException(\"Was expecting value of type `" << expect_type << "' for field `" << member->get_name() - << "', but got ${value?.javaClass}\")" << endl; + << "', but got ${value?.javaClass}\")" << '\n'; } scope_down(out); scope_down(out); @@ -1089,12 +1087,12 @@ void t_kotlin_generator::generate_union_definition(std::ostream& out, string /*additional interface*/) { auto union_class_name = kotlin_safe_name(tunion->get_name()); indent(out) << "class " << union_class_name << " : org.apache.thrift.TUnion<" << union_class_name - << ", " << union_class_name << "._Fields> {" << endl; + << ", " << union_class_name << "._Fields> {" << '\n'; indent_up(); indent(out) << "constructor(setField: _Fields, value: kotlin.Any) : super(setField, value)" - << endl; - indent(out) << "constructor(other: " << union_class_name << ") : super(other)" << endl; - indent(out) << "constructor() : super()" << endl; + << '\n'; + indent(out) << "constructor(other: " << union_class_name << ") : super(other)" << '\n'; + indent(out) << "constructor() : super()" << '\n'; generate_struct_field_name_constants(out, tunion); generate_struct_companion_object(out, tunion); @@ -1104,7 +1102,7 @@ void t_kotlin_generator::generate_union_definition(std::ostream& out, generate_union_standard_scheme(out, tunion); generate_union_tuple_scheme(out, tunion); indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_kotlin_generator::generate_struct_definition(std::ostream& out, @@ -1123,7 +1121,7 @@ void t_kotlin_generator::generate_struct_definition(std::ostream& out, indent_up(); auto sep = ""; for (auto field : members) { - out << sep << endl; + out << sep << '\n'; sep = ","; generate_kdoc_comment(out, field); auto is_required = field->get_req() == t_field::T_REQUIRED; @@ -1141,7 +1139,7 @@ void t_kotlin_generator::generate_struct_definition(std::ostream& out, out << ": " << type_name(field->get_type()) << "? = null"; } indent_down(); - out << endl; + out << '\n'; indent(out) << ") : "; if (is_exception) { out << "org.apache.thrift.TException(), "; @@ -1150,7 +1148,7 @@ void t_kotlin_generator::generate_struct_definition(std::ostream& out, additional_interface = ", " + additional_interface; } out << "org.apache.thrift.TBase<" << tstruct->get_name() << ", " << tstruct->get_name() - << "._Fields>" << additional_interface << " {" << endl; + << "._Fields>" << additional_interface << " {" << '\n'; indent_up(); @@ -1162,7 +1160,7 @@ void t_kotlin_generator::generate_struct_definition(std::ostream& out, out << "override "; } out << "val " << kotlin_safe_name(field->get_name()) << ": " << type_name(field->get_type()) - << " get() = _" + kotlin_safe_name(field->get_name()) << "!!" << endl; + << " get() = _" + kotlin_safe_name(field->get_name()) << "!!" << '\n'; } } @@ -1181,7 +1179,7 @@ void t_kotlin_generator::generate_struct_definition(std::ostream& out, generate_struct_method_write(out, tstruct); indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } string t_kotlin_generator::base_type_write_expression(t_base_type* tbase, string it) { @@ -1286,7 +1284,7 @@ void t_kotlin_generator::generate_serialize_field(ostream& out, t_field* tfield) } indent(out); generate_serialize_value(out, type, kotlin_safe_name(tfield->get_name())); - out << endl; + out << '\n'; } /** @@ -1305,7 +1303,7 @@ void t_kotlin_generator::generate_deserialize_field(ostream& out, t_field* tfiel = prefix + (is_required ? "_" + tfield->get_name() : kotlin_safe_name(tfield->get_name())); indent(out) << name << " = "; generate_deserialize_value(out, type); - out << endl; + out << '\n'; } /** @@ -1315,33 +1313,33 @@ void t_kotlin_generator::generate_serialize_container(ostream& out, t_type* ttyp if (ttype->is_map()) { out << "writeMap(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << it << ") { (key, value) ->" - << endl; + << '\n'; indent_up(); { generate_serialize_value(indent(out), ((t_map*)ttype)->get_key_type(), "key"); - out << endl; + out << '\n'; generate_serialize_value(indent(out), ((t_map*)ttype)->get_val_type(), "value"); - out << endl; + out << '\n'; indent_down(); } indent(out) << "}"; } else if (ttype->is_set()) { out << "writeSet(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " << it << ") {" - << endl; + << '\n'; indent_up(); { generate_serialize_value(indent(out), ((t_set*)ttype)->get_elem_type()); - out << endl; + out << '\n'; indent_down(); } indent(out) << "}"; } else if (ttype->is_list()) { out << "writeList(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << it << ") {" - << endl; + << '\n'; { indent_up(); generate_serialize_value(indent(out), ((t_list*)ttype)->get_elem_type()); - out << endl; + out << '\n'; indent_down(); } indent(out) << "}"; @@ -1355,41 +1353,41 @@ void t_kotlin_generator::generate_serialize_container(ostream& out, t_type* ttyp */ void t_kotlin_generator::generate_deserialize_container(ostream& out, t_type* ttype) { if (ttype->is_map()) { - out << "readMap { tmap ->" << endl; + out << "readMap { tmap ->" << '\n'; indent_up(); - indent(out) << "kotlin.collections.List(tmap.size) {" << endl; + indent(out) << "kotlin.collections.List(tmap.size) {" << '\n'; indent_up(); indent(out); generate_deserialize_value(out, ((t_map*)ttype)->get_key_type()); out << " to "; generate_deserialize_value(out, ((t_map*)ttype)->get_val_type()); - out << endl; + out << '\n'; indent_down(); - indent(out) << "}.associate { it }" << endl; + indent(out) << "}.associate { it }" << '\n'; indent_down(); indent(out) << "}"; } else if (ttype->is_set()) { - out << "readSet { tset ->" << endl; + out << "readSet { tset ->" << '\n'; indent_up(); - indent(out) << "kotlin.collections.List(tset.size) {" << endl; + indent(out) << "kotlin.collections.List(tset.size) {" << '\n'; indent_up(); indent(out); generate_deserialize_value(out, ((t_set*)ttype)->get_elem_type()); - out << endl; + out << '\n'; indent_down(); - indent(out) << "}.toSet()" << endl; + indent(out) << "}.toSet()" << '\n'; indent_down(); indent(out) << "}"; } else if (ttype->is_list()) { - out << "readList { tlist ->" << endl; + out << "readList { tlist ->" << '\n'; indent_up(); - indent(out) << "kotlin.collections.List(tlist.size) {" << endl; + indent(out) << "kotlin.collections.List(tlist.size) {" << '\n'; indent_up(); indent(out); generate_deserialize_value(out, ((t_list*)ttype)->get_elem_type()); - out << endl; + out << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; indent_down(); indent(out) << "}"; } else { @@ -1419,14 +1417,14 @@ void t_kotlin_generator::generate_service_interface(t_service* tservice) { ofstream_with_content_based_conditional_update out; out.open(f_service_name.c_str()); out << autogen_comment() << kotlin_package(); - out << "interface " << tservice->get_name() << " {" << endl; + out << "interface " << tservice->get_name() << " {" << '\n'; indent_up(); for (auto tfunc : tservice->get_functions()) { generate_kdoc_comment(out, tfunc); - indent(out) << function_signature(tfunc) << endl; + indent(out) << function_signature(tfunc) << '\n'; } scope_down(out); - out << endl << endl; + out << '\n' << '\n'; out.close(); } @@ -1437,22 +1435,22 @@ void t_kotlin_generator::generate_service_client(t_service* tservice) { out << autogen_comment() << warning_surpressions() << kotlin_package(); generate_docstring_comment(out, "/**\n", " * ", "client implementation for [" + tservice->get_name() + "]", " */\n"); - indent(out) << "class " << tservice->get_name() << "Client(" << endl; + indent(out) << "class " << tservice->get_name() << "Client(" << '\n'; indent_up(); - indent(out) << "protocolFactory: org.apache.thrift.protocol.TProtocolFactory," << endl; - indent(out) << "clientManager: org.apache.thrift.async.TAsyncClientManager," << endl; - indent(out) << "transport: org.apache.thrift.transport.TNonblockingTransport" << endl; + indent(out) << "protocolFactory: org.apache.thrift.protocol.TProtocolFactory," << '\n'; + indent(out) << "clientManager: org.apache.thrift.async.TAsyncClientManager," << '\n'; + indent(out) << "transport: org.apache.thrift.transport.TNonblockingTransport" << '\n'; indent_down(); out << "): org.apache.thrift.async.TAsyncClient(protocolFactory, clientManager, transport), " - << tservice->get_name() << " {" << endl - << endl; + << tservice->get_name() << " {" << '\n' + << '\n'; indent_up(); { - indent(out) << "private val seqId = java.util.concurrent.atomic.AtomicInteger()" << endl - << endl; + indent(out) << "private val seqId = java.util.concurrent.atomic.AtomicInteger()" << '\n' + << '\n'; for (auto tfunc : tservice->get_functions()) { - indent(out) << "override " << function_signature(tfunc) << " {" << endl; + indent(out) << "override " << function_signature(tfunc) << " {" << '\n'; indent_up(); { string args_name = tservice->get_name() + "FunctionArgs." + tfunc->get_name() + "_args"; @@ -1465,16 +1463,16 @@ void t_kotlin_generator::generate_service_client(t_service* tservice) { first = false; out << tfield->get_name(); } - out << ")" << endl; - indent(out) << "return transformCallback {" << endl; + out << ")" << '\n'; + indent(out) << "return transformCallback {" << '\n'; indent_up(); { - indent(out) << "checkReady()" << endl; + indent(out) << "checkReady()" << '\n'; indent(out) << "___currentMethod = ProcessCall." << tfunc->get_name() << "Call(args, seqId.getAndIncrement(), this, ___protocolFactory, ___transport, it)" - << endl; - indent(out) << "___manager.call(___currentMethod)" << endl; + << '\n'; + indent(out) << "___manager.call(___currentMethod)" << '\n'; } scope_down(out); } @@ -1484,22 +1482,22 @@ void t_kotlin_generator::generate_service_client(t_service* tservice) { indent(out) << "private suspend fun " "org.apache.thrift.async.TAsyncClient.transformCallback(action: " "(org.apache.thrift.async.AsyncMethodCallback) -> Unit): R {" - << endl; + << '\n'; indent_up(); - indent(out) << "val deferred = kotlinx.coroutines.CompletableDeferred()" << endl; + indent(out) << "val deferred = kotlinx.coroutines.CompletableDeferred()" << '\n'; indent(out) << "val callback = object : org.apache.thrift.async.AsyncMethodCallback {" - << endl; + << '\n'; indent_up(); - indent(out) << "override fun onComplete(response: R) { deferred.complete(response) }" << endl; + indent(out) << "override fun onComplete(response: R) { deferred.complete(response) }" << '\n'; indent(out) << "override fun onError(exception: java.lang.Exception) { " "deferred.completeExceptionally(exception) }" - << endl; + << '\n'; scope_down(out); - indent(out) << "action(callback)" << endl; - indent(out) << "return deferred.await()" << endl; + indent(out) << "action(callback)" << '\n'; + indent(out) << "return deferred.await()" << '\n'; scope_down(out); - indent(out) << "sealed interface ProcessCall {" << endl; + indent(out) << "sealed interface ProcessCall {" << '\n'; indent_up(); for (auto tfunc : tservice->get_functions()) { generate_client_call(out, tservice, tfunc); @@ -1507,7 +1505,7 @@ void t_kotlin_generator::generate_service_client(t_service* tservice) { scope_down(out); } scope_down(out); - out << endl << endl; + out << '\n' << '\n'; out.close(); } @@ -1518,74 +1516,74 @@ void t_kotlin_generator::generate_client_call(std::ostream& out, string funclassname = funname + "Call"; string rtype = type_name(tfunc->get_returntype(), true); - indent(out) << "class " + funclassname + "(" << endl; + indent(out) << "class " + funclassname + "(" << '\n'; indent_up(); string args_name = tservice->get_name() + "FunctionArgs." + tfunc->get_name() + "_args"; - indent(out) << "val args: " << args_name << "," << endl; - indent(out) << "val seqId: kotlin.Int," << endl; - indent(out) << "client: org.apache.thrift.async.TAsyncClient," << endl; - indent(out) << "protocolFactory: org.apache.thrift.protocol.TProtocolFactory," << endl; - indent(out) << "transport: org.apache.thrift.transport.TNonblockingTransport," << endl; + indent(out) << "val args: " << args_name << "," << '\n'; + indent(out) << "val seqId: kotlin.Int," << '\n'; + indent(out) << "client: org.apache.thrift.async.TAsyncClient," << '\n'; + indent(out) << "protocolFactory: org.apache.thrift.protocol.TProtocolFactory," << '\n'; + indent(out) << "transport: org.apache.thrift.transport.TNonblockingTransport," << '\n'; indent(out) << "resultHandler: org.apache.thrift.async.AsyncMethodCallback<" << rtype << ">," - << endl; + << '\n'; indent_down(); indent(out) << ") : org.apache.thrift.async.TAsyncMethodCall<" << rtype << ">(client, protocolFactory, transport, resultHandler, " - << (tfunc->is_oneway() ? "true" : "false") << "), ProcessCall {" << endl; + << (tfunc->is_oneway() ? "true" : "false") << "), ProcessCall {" << '\n'; indent_up(); indent(out) << "override fun write_args(protocol: org.apache.thrift.protocol.TProtocol) {" - << endl; + << '\n'; indent_up(); indent(out) << "val marker = org.apache.thrift.protocol.TMessage(\"" << tfunc->get_name() - << "\", org.apache.thrift.protocol.TMessageType.CALL, seqId)" << endl; - indent(out) << "protocol.writeMessage(marker) { args.write(protocol) }" << endl; + << "\", org.apache.thrift.protocol.TMessageType.CALL, seqId)" << '\n'; + indent(out) << "protocol.writeMessage(marker) { args.write(protocol) }" << '\n'; scope_down(out); - indent(out) << "override fun getResult(): " << rtype << " {" << endl; + indent(out) << "override fun getResult(): " << rtype << " {" << '\n'; indent_up(); indent(out) << "check(state == org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { " "\"Method call not finished!\" }" - << endl; + << '\n'; indent(out) << "val memoryTransport = " "org.apache.thrift.transport.TMemoryInputTransport(frameBuffer.array())" - << endl; - indent(out) << "val protocol = client.protocolFactory.getProtocol(memoryTransport)" << endl; + << '\n'; + indent(out) << "val protocol = client.protocolFactory.getProtocol(memoryTransport)" << '\n'; if (tfunc->is_oneway()) { - indent(out) << "// one way function, nothing to read" << endl; + indent(out) << "// one way function, nothing to read" << '\n'; } else { - indent(out) << "return protocol.readMessage {" << endl; + indent(out) << "return protocol.readMessage {" << '\n'; indent_up(); { - indent(out) << "if (it.type == org.apache.thrift.protocol.TMessageType.EXCEPTION) {" << endl; + indent(out) << "if (it.type == org.apache.thrift.protocol.TMessageType.EXCEPTION) {" << '\n'; indent_up(); indent(out) << "val ex = org.apache.thrift.TApplicationException().apply { read(protocol) }" - << endl; - indent(out) << "throw ex" << endl; + << '\n'; + indent(out) << "throw ex" << '\n'; scope_down(out); - indent(out) << "if (it.seqid != seqId) {" << endl; + indent(out) << "if (it.seqid != seqId) {" << '\n'; indent_up(); - indent(out) << "throw org.apache.thrift.TApplicationException(" << endl; + indent(out) << "throw org.apache.thrift.TApplicationException(" << '\n'; indent_up(); - indent(out) << "org.apache.thrift.TApplicationException.BAD_SEQUENCE_ID," << endl; + indent(out) << "org.apache.thrift.TApplicationException.BAD_SEQUENCE_ID," << '\n'; indent(out) << "\"" << funname << " failed: out of sequence response: expected $seqId but got ${it.seqid}\"" - << endl; + << '\n'; indent_down(); - indent(out) << ")" << endl; + indent(out) << ")" << '\n'; scope_down(out); string result_name = tservice->get_name() + "FunctionResult." + tfunc->get_name() + "_result"; - indent(out) << "val result = " << result_name << "().apply { read(protocol) }" << endl; + indent(out) << "val result = " << result_name << "().apply { read(protocol) }" << '\n'; for (auto xception : tfunc->get_xceptions()->get_members()) { - indent(out) << "result." << xception->get_name() << "?.let { throw it }" << endl; + indent(out) << "result." << xception->get_name() << "?.let { throw it }" << '\n'; } if (!tfunc->get_returntype()->is_void()) { indent(out) << "result.success ?: throw " "org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException." "MISSING_RESULT, \"returnString failed: unknown result\")" - << endl; + << '\n'; } } scope_down(out); @@ -1601,43 +1599,43 @@ void t_kotlin_generator::generate_service_processor(t_service* tservice) { out << autogen_comment() << warning_surpressions() << kotlin_package(); auto service_imports = {"import kotlinx.coroutines.future.future"}; for (auto service_import : service_imports) { - out << service_import << endl; + out << service_import << '\n'; } - out << endl; + out << '\n'; generate_docstring_comment(out, "/**\n", " * ", "server implementation for [" + tservice->get_name() + "]", " */\n"); - indent(out) << "class " << tservice->get_name() << "Processor(" << endl; + indent(out) << "class " << tservice->get_name() << "Processor(" << '\n'; indent_up(); - indent(out) << "handler: " << tservice->get_name() << "," << endl; - indent(out) << "private val scope: kotlinx.coroutines.CoroutineScope," << endl; + indent(out) << "handler: " << tservice->get_name() << "," << '\n'; + indent(out) << "private val scope: kotlinx.coroutines.CoroutineScope," << '\n'; indent(out) << "private val processMap: kotlin.collections.Mapget_name() << ", out org.apache.thrift.TBase<*, " "*>, out kotlin.Any, out org.apache.thrift.TBase<*, *>>> = mapOf(" - << endl; + << '\n'; indent_up(); { for (auto tfunc : tservice->get_functions()) { indent(out) << '"' << tfunc->get_name() << '"' << " to ProcessFunction." << tfunc->get_name() - << "(scope)," << endl; + << "(scope)," << '\n'; } } indent_down(); - indent(out) << ")" << endl; + indent(out) << ")" << '\n'; indent_down(); out << "): org.apache.thrift.TBaseAsyncProcessor<" << tservice->get_name() - << ">(handler, processMap) {" << endl; + << ">(handler, processMap) {" << '\n'; indent_up(); - indent(out) << "companion object {" << endl; + indent(out) << "companion object {" << '\n'; indent_up(); indent(out) << "internal val logger: org.slf4j.Logger = " "org.slf4j.LoggerFactory.getLogger(" - << tservice->get_name() << "Processor::class.java)" << endl; + << tservice->get_name() << "Processor::class.java)" << '\n'; scope_down(out); - indent(out) << "sealed interface ProcessFunction {" << endl; + indent(out) << "sealed interface ProcessFunction {" << '\n'; indent_up(); { @@ -1647,7 +1645,7 @@ void t_kotlin_generator::generate_service_processor(t_service* tservice) { } scope_down(out); scope_down(out); - out << endl << endl; + out << '\n' << '\n'; out.close(); } @@ -1663,25 +1661,25 @@ void t_kotlin_generator::generate_service_process_function(ostream& out, "org.apache.thrift.AsyncProcessFunctionis_oneway() ? "org.apache.thrift.TBase<*, *>" : resultname) - << ">(\"" << tfunc->get_name() << "\"), ProcessFunction {" - << endl; + << ">(\"" << tfunc->get_name() << "\"), ProcessFunction {" + << '\n'; indent_up(); { - indent(out) << "override fun isOneway() = " << (tfunc->is_oneway() ? "true" : "false") << endl; - indent(out) << "override fun getEmptyArgsInstance() = " << args_name << "()" << endl; + indent(out) << "override fun isOneway() = " << (tfunc->is_oneway() ? "true" : "false") << '\n'; + indent(out) << "override fun getEmptyArgsInstance() = " << args_name << "()" << '\n'; indent(out) << "override fun getEmptyResultInstance() = "; if (tfunc->is_oneway()) { - out << "null" << endl; + out << "null" << '\n'; } else { - out << resultname << "()" << endl; + out << resultname << "()" << '\n'; } - indent(out) << endl; + indent(out) << '\n'; indent(out) << "override fun start(iface: I, args: " << args_name << ", resultHandler: org.apache.thrift.async.AsyncMethodCallback<" << rtype - << ">) {" << endl; + << ">) {" << '\n'; indent_up(); - indent(out) << "scope.future {" << endl; + indent(out) << "scope.future {" << '\n'; indent_up(); indent(out) << "iface." << tfunc->get_name() << "("; { @@ -1696,18 +1694,18 @@ void t_kotlin_generator::generate_service_process_function(ostream& out, out << "args." << tfield->get_name() << "!!"; } } - out << ")" << endl; + out << ")" << '\n'; indent_down(); - indent(out) << "}.whenComplete { r, t ->" << endl; + indent(out) << "}.whenComplete { r, t ->" << '\n'; { indent_up(); - indent(out) << "if (t != null) {" << endl; + indent(out) << "if (t != null) {" << '\n'; indent_up(); - indent(out) << "resultHandler.onError(t as java.lang.Exception)" << endl; + indent(out) << "resultHandler.onError(t as java.lang.Exception)" << '\n'; indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent_up(); - indent(out) << "resultHandler.onComplete(r)" << endl; + indent(out) << "resultHandler.onComplete(r)" << '\n'; } scope_down(out); scope_down(out); @@ -1716,106 +1714,106 @@ void t_kotlin_generator::generate_service_process_function(ostream& out, indent(out) << "override fun getResultHandler(fb: " "org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer, seqid: " "Int) =" - << endl; + << '\n'; indent_up(); { indent(out) << "object : org.apache.thrift.async.AsyncMethodCallback<" << rtype << ">{" - << endl; + << '\n'; indent_up(); { - indent(out) << "override fun onComplete(response: " << rtype << ") {" << endl; + indent(out) << "override fun onComplete(response: " << rtype << ") {" << '\n'; indent_up(); if (tfunc->is_oneway()) { - indent(out) << "// one way function, no result handling" << endl; + indent(out) << "// one way function, no result handling" << '\n'; } else { string result_name = tservice->get_name() + "FunctionResult." + tfunc->get_name() + "_result"; - indent(out) << "val result = " << result_name << "()" << endl; + indent(out) << "val result = " << result_name << "()" << '\n'; if (!tfunc->get_returntype()->is_void()) { - indent(out) << "result.success = response" << endl; + indent(out) << "result.success = response" << '\n'; } - indent(out) << "try {" << endl; + indent(out) << "try {" << '\n'; indent_up(); indent(out) << "sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY, seqid)" - << endl; + << '\n'; indent_down(); - indent(out) << "} catch (e: org.apache.thrift.transport.TTransportException) {" << endl; + indent(out) << "} catch (e: org.apache.thrift.transport.TTransportException) {" << '\n'; indent_up(); indent(out) << "logger.error(\"TTransportException writing to internal frame buffer\", e)" - << endl; - indent(out) << "fb.close()" << endl; + << '\n'; + indent(out) << "fb.close()" << '\n'; indent_down(); - indent(out) << "} catch (e: Exception) {" << endl; + indent(out) << "} catch (e: Exception) {" << '\n'; indent_up(); - indent(out) << "logger.error(\"Exception writing to internal frame buffer\", e)" << endl; - indent(out) << "onError(e)" << endl; + indent(out) << "logger.error(\"Exception writing to internal frame buffer\", e)" << '\n'; + indent(out) << "onError(e)" << '\n'; scope_down(out); } scope_down(out); } { - indent(out) << "override fun onError(exception: kotlin.Exception) {" << endl; + indent(out) << "override fun onError(exception: kotlin.Exception) {" << '\n'; indent_up(); if (tfunc->is_oneway()) { indent(out) << "if (exception is org.apache.thrift.transport.TTransportException) {" - << endl; + << '\n'; indent_up(); - indent(out) << "logger.error(\"TTransportException inside handler\", exception)" << endl; - indent(out) << "fb.close()" << endl; + indent(out) << "logger.error(\"TTransportException inside handler\", exception)" << '\n'; + indent(out) << "fb.close()" << '\n'; indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; indent_up(); - indent(out) << "logger.error(\"Exception inside oneway handler\", exception)" << endl; + indent(out) << "logger.error(\"Exception inside oneway handler\", exception)" << '\n'; scope_down(out); } else { - indent(out) << "val (msgType, msg) = when (exception) {" << endl; + indent(out) << "val (msgType, msg) = when (exception) {" << '\n'; indent_up(); auto xceptions = tfunc->get_xceptions()->get_members(); for (auto xception : xceptions) { - indent(out) << "is " << type_name(xception->get_type()) << " -> {" << endl; + indent(out) << "is " << type_name(xception->get_type()) << " -> {" << '\n'; indent_up(); string result_name = tservice->get_name() + "FunctionResult." + tfunc->get_name() + "_result"; - indent(out) << "val result = " << result_name << "()" << endl; - indent(out) << "result." << xception->get_name() << " = exception" << endl; - indent(out) << "org.apache.thrift.protocol.TMessageType.REPLY to result" << endl; + indent(out) << "val result = " << result_name << "()" << '\n'; + indent(out) << "result." << xception->get_name() << " = exception" << '\n'; + indent(out) << "org.apache.thrift.protocol.TMessageType.REPLY to result" << '\n'; scope_down(out); } - indent(out) << "is org.apache.thrift.transport.TTransportException -> {" << endl; + indent(out) << "is org.apache.thrift.transport.TTransportException -> {" << '\n'; indent_up(); - indent(out) << "logger.error(\"TTransportException inside handler\", exception)" << endl; - indent(out) << "fb.close()" << endl; - indent(out) << "return" << endl; + indent(out) << "logger.error(\"TTransportException inside handler\", exception)" << '\n'; + indent(out) << "fb.close()" << '\n'; + indent(out) << "return" << '\n'; scope_down(out); - indent(out) << "is org.apache.thrift.TApplicationException -> {" << endl; + indent(out) << "is org.apache.thrift.TApplicationException -> {" << '\n'; indent_up(); indent(out) << "logger.error(\"TApplicationException inside handler\", exception)" - << endl; - indent(out) << "org.apache.thrift.protocol.TMessageType.EXCEPTION to exception" << endl; + << '\n'; + indent(out) << "org.apache.thrift.protocol.TMessageType.EXCEPTION to exception" << '\n'; scope_down(out); - indent(out) << "else -> {" << endl; + indent(out) << "else -> {" << '\n'; indent_up(); - indent(out) << "logger.error(\"Exception inside handler\", exception)" << endl; + indent(out) << "logger.error(\"Exception inside handler\", exception)" << '\n'; indent(out) << "org.apache.thrift.protocol.TMessageType.EXCEPTION to " "org.apache.thrift.TApplicationException(org.apache.thrift." "TApplicationException.INTERNAL_ERROR, exception.message)" - << endl; + << '\n'; scope_down(out); scope_down(out); - indent(out) << "try {" << endl; + indent(out) << "try {" << '\n'; indent_up(); - indent(out) << "sendResponse(fb, msg, msgType, seqid)" << endl; + indent(out) << "sendResponse(fb, msg, msgType, seqid)" << '\n'; indent_down(); - indent(out) << "} catch (ex: java.lang.Exception) {" << endl; + indent(out) << "} catch (ex: java.lang.Exception) {" << '\n'; indent_up(); - indent(out) << "logger.error(\"Exception writing to internal frame buffer\", ex)" << endl; - indent(out) << "fb.close()" << endl; + indent(out) << "logger.error(\"Exception writing to internal frame buffer\", ex)" << '\n'; + indent(out) << "fb.close()" << '\n'; scope_down(out); } @@ -1836,7 +1834,7 @@ void t_kotlin_generator::generate_service_result_helpers(t_service* tservice) { generate_docstring_comment(out, "/**\n", " * ", "function result for [" + tservice->get_name() + "]", " */\n"); - indent(out) << "sealed interface " << tservice->get_name() << "FunctionResult {" << endl; + indent(out) << "sealed interface " << tservice->get_name() << "FunctionResult {" << '\n'; indent_up(); for (auto func : tservice->get_functions()) { if (func->is_oneway()) { @@ -1863,12 +1861,12 @@ void t_kotlin_generator::generate_service_args_helpers(t_service* tservice) { out << autogen_comment() << warning_surpressions() << kotlin_package(); generate_docstring_comment(out, "/**\n", " * ", "function arguments for [" + tservice->get_name() + "]", " */\n"); - indent(out) << "sealed interface " << tservice->get_name() << "FunctionArgs {" << endl; + indent(out) << "sealed interface " << tservice->get_name() << "FunctionArgs {" << '\n'; indent_up(); for (auto func : tservice->get_functions()) { t_struct* ts = func->get_arglist(); generate_struct_definition(out, ts, false, tservice->get_name() + "FunctionArgs"); - out << endl; + out << '\n'; } scope_down(out); out.close(); @@ -1972,7 +1970,7 @@ bool t_kotlin_generator::is_enum_map(t_type* ttype) { */ string t_kotlin_generator::kotlin_package() { if (!package_name_.empty()) { - return string("package ") + package_name_ + endl + endl; + return string("package ") + package_name_ + "\n" + "\n"; } return ""; } @@ -1980,8 +1978,7 @@ string t_kotlin_generator::kotlin_package() { string t_kotlin_generator::warning_surpressions() { return "@file:Suppress(\"ClassName\", \"PropertyName\", \"RedundantUnitReturnType\", " "\"NestedLambdaShadowedImplicitParameter\", " - "\"RemoveRedundantQualifierName\")" - + endl; + "\"RemoveRedundantQualifierName\")\n"; } string t_kotlin_generator::constant_name(string name) { diff --git a/compiler/cpp/src/thrift/generate/t_lua_generator.cc b/compiler/cpp/src/thrift/generate/t_lua_generator.cc index 0dc7743f479..642dd9c3c68 100644 --- a/compiler/cpp/src/thrift/generate/t_lua_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_lua_generator.cc @@ -26,8 +26,6 @@ using std::string; using std::vector; using std::map; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * LUA code generator. * @@ -190,7 +188,7 @@ void t_lua_generator::init_generator() { f_consts_ << autogen_comment() << lua_includes(); f_types_ << autogen_comment() << lua_includes(); if (gen_requires_) { - f_types_ << endl << "require '" << cur_namespace << "constants'"; + f_types_ << '\n' << "require '" << cur_namespace << "constants'"; } } @@ -207,7 +205,7 @@ void t_lua_generator::generate_typedef(t_typedef* ttypedef) { if (ttypedef->get_type()->get_name().empty()) { return; } - f_types_ << endl << endl << indent() << ttypedef->get_symbolic() << " = " + f_types_ << '\n' << '\n' << indent() << ttypedef->get_symbolic() << " = " << ttypedef->get_type()->get_name(); } @@ -215,7 +213,7 @@ void t_lua_generator::generate_typedef(t_typedef* ttypedef) { * Generates code for an enumerated type (table) */ void t_lua_generator::generate_enum(t_enum* tenum) { - f_types_ << endl << endl << tenum->get_name() << " = {" << endl; + f_types_ << '\n' << '\n' << tenum->get_name() << " = {" << '\n'; vector constants = tenum->get_constants(); vector::iterator c_iter; @@ -227,7 +225,7 @@ void t_lua_generator::generate_enum(t_enum* tenum) { if (c_iter != constants.end()) { f_types_ << ","; } - f_types_ << endl; + f_types_ << '\n'; } f_types_ << "}"; } @@ -240,7 +238,7 @@ void t_lua_generator::generate_const(t_const* tconst) { string name = tconst->get_name(); t_const_value* value = tconst->get_value(); - f_consts_ << endl << endl << name << " = "; + f_consts_ << '\n' << '\n' << name << " = "; f_consts_ << render_const_value(type, value); } @@ -281,7 +279,7 @@ string t_lua_generator::render_const_value(t_type* type, t_const_value* value) { } else if (type->is_enum()) { out << value->get_integer(); } else if (type->is_struct() || type->is_xception()) { - out << type->get_name() << " = {" << endl; + out << type->get_name() << " = {" << '\n'; indent_up(); const vector& fields = ((t_struct*)type)->get_members(); @@ -312,7 +310,7 @@ string t_lua_generator::render_const_value(t_type* type, t_const_value* value) { out << "}"; indent_down(); } else if (type->is_map()) { - out << type->get_name() << "{" << endl; + out << type->get_name() << "{" << '\n'; indent_up(); t_type* ktype = ((t_map*)type)->get_key_type(); @@ -327,7 +325,7 @@ string t_lua_generator::render_const_value(t_type* type, t_const_value* value) { if (v_iter != val.end()) { out << ","; } - out << endl; + out << '\n'; } indent_down(); indent(out) << "}"; @@ -338,7 +336,7 @@ string t_lua_generator::render_const_value(t_type* type, t_const_value* value) { } else { etype = ((t_set*)type)->get_elem_type(); } - out << type->get_name() << " = {" << endl; + out << type->get_name() << " = {" << '\n'; const vector& val = value->get_list(); vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end();) { @@ -351,7 +349,7 @@ string t_lua_generator::render_const_value(t_type* type, t_const_value* value) { } ++v_iter; if (v_iter != val.end()) { - out << "," << endl; + out << "," << '\n'; } } out << "}"; @@ -382,15 +380,15 @@ void t_lua_generator::generate_lua_struct_definition(ostream& out, vector::const_iterator m_iter; const vector& members = tstruct->get_members(); - indent(out) << endl << endl << tstruct->get_name(); + indent(out) << '\n' << '\n' << tstruct->get_name(); if (is_exception) { - out << " = TException:new{" << endl << indent() << " __type = '" << tstruct->get_name() << "'"; + out << " = TException:new{" << '\n' << indent() << " __type = '" << tstruct->get_name() << "'"; if (members.size() > 0) { out << ","; } - out << endl; + out << '\n'; } else { - out << " = __TObject:new{" << endl; + out << " = __TObject:new{" << '\n'; } indent_up(); for (m_iter = members.begin(); m_iter != members.end();) { @@ -398,12 +396,12 @@ void t_lua_generator::generate_lua_struct_definition(ostream& out, out << (*m_iter)->get_name(); ++m_iter; if (m_iter != members.end()) { - out << "," << endl; + out << "," << '\n'; } } indent_down(); indent(out); - out << endl << "}"; + out << '\n' << "}"; generate_lua_struct_reader(out, tstruct); generate_lua_struct_writer(out, tstruct); @@ -417,48 +415,48 @@ void t_lua_generator::generate_lua_struct_reader(ostream& out, t_struct* tstruct vector::const_iterator f_iter; // function - indent(out) << endl << endl << "function " << tstruct->get_name() << ":read(iprot)" << endl; + indent(out) << '\n' << '\n' << "function " << tstruct->get_name() << ":read(iprot)" << '\n'; indent_up(); - indent(out) << "iprot:readStructBegin()" << endl; + indent(out) << "iprot:readStructBegin()" << '\n'; // while: Read in fields - indent(out) << "while true do" << endl; + indent(out) << "while true do" << '\n'; indent_up(); // if: Check what to read - indent(out) << "local fname, ftype, fid = iprot:readFieldBegin()" << endl; - indent(out) << "if ftype == TType.STOP then" << endl; + indent(out) << "local fname, ftype, fid = iprot:readFieldBegin()" << '\n'; + indent(out) << "if ftype == TType.STOP then" << '\n'; indent_up(); - indent(out) << "break" << endl; + indent(out) << "break" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { indent_down(); - indent(out) << "elseif fid == " << (*f_iter)->get_key() << " then" << endl; + indent(out) << "elseif fid == " << (*f_iter)->get_key() << " then" << '\n'; indent_up(); - indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << " then" << endl; + indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << " then" << '\n'; indent_up(); // Read field contents generate_deserialize_field(out, *f_iter, false, "self."); indent_down(); - indent(out) << "else" << endl; - indent(out) << " iprot:skip(ftype)" << endl; - indent(out) << "end" << endl; + indent(out) << "else" << '\n'; + indent(out) << " iprot:skip(ftype)" << '\n'; + indent(out) << "end" << '\n'; } // end if indent_down(); - indent(out) << "else" << endl; - indent(out) << " iprot:skip(ftype)" << endl; - indent(out) << "end" << endl; - indent(out) << "iprot:readFieldEnd()" << endl; + indent(out) << "else" << '\n'; + indent(out) << " iprot:skip(ftype)" << '\n'; + indent(out) << "end" << '\n'; + indent(out) << "iprot:readFieldEnd()" << '\n'; // end while indent_down(); - indent(out) << "end" << endl; - indent(out) << "iprot:readStructEnd()" << endl; + indent(out) << "end" << '\n'; + indent(out) << "iprot:readStructEnd()" << '\n'; // end function indent_down(); @@ -474,28 +472,28 @@ void t_lua_generator::generate_lua_struct_writer(ostream& out, t_struct* tstruct vector::const_iterator f_iter; // function - indent(out) << endl << endl << "function " << tstruct->get_name() << ":write(oprot)" << endl; + indent(out) << '\n' << '\n' << "function " << tstruct->get_name() << ":write(oprot)" << '\n'; indent_up(); - indent(out) << "oprot:writeStructBegin('" << tstruct->get_name() << "')" << endl; + indent(out) << "oprot:writeStructBegin('" << tstruct->get_name() << "')" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { // To check element of self whether nil or not. // avoid the value(false) of BOOL is lost. - indent(out) << "if self." << (*f_iter)->get_name() << " ~= nil then" << endl; + indent(out) << "if self." << (*f_iter)->get_name() << " ~= nil then" << '\n'; indent_up(); indent(out) << "oprot:writeFieldBegin('" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type()) << ", " << (*f_iter)->get_key() << ")" - << endl; + << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "self."); - indent(out) << "oprot:writeFieldEnd()" << endl; + indent(out) << "oprot:writeFieldEnd()" << '\n'; indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; } - indent(out) << "oprot:writeFieldStop()" << endl; - indent(out) << "oprot:writeStructEnd()" << endl; + indent(out) << "oprot:writeFieldStop()" << '\n'; + indent(out) << "oprot:writeStructEnd()" << '\n'; // end function indent_down(); @@ -518,15 +516,15 @@ void t_lua_generator::generate_service(t_service* tservice) { // Headers f_service_ << autogen_comment() << lua_includes(); if (gen_requires_) { - f_service_ << endl << "require '" << cur_ns << "ttypes'" << endl; + f_service_ << '\n' << "require '" << cur_ns << "ttypes'" << '\n'; if (tservice->get_extends() != nullptr) { f_service_ << "require '" << get_namespace(tservice->get_extends()->get_program()) - << tservice->get_extends()->get_name() << "'" << endl; + << tservice->get_extends()->get_name() << "'" << '\n'; } } - f_service_ << endl; + f_service_ << '\n'; generate_service_client(f_service_, tservice); generate_service_interface(f_service_, tservice); @@ -544,11 +542,11 @@ void t_lua_generator::generate_service_interface(ostream& out, t_service* tservi // Interface object definition out << classname << " = "; if (extends_s) { - out << extends_s->get_name() << "Iface:new{" << endl; + out << extends_s->get_name() << "Iface:new{" << '\n'; } else { - out << "__TObject:new{" << endl; + out << "__TObject:new{" << '\n'; } - out << " __type = '" << classname << "'" << endl << "}" << endl << endl; + out << " __type = '" << classname << "'" << '\n' << "}" << '\n' << '\n'; } void t_lua_generator::generate_service_client(ostream& out, t_service* tservice) { @@ -562,7 +560,7 @@ void t_lua_generator::generate_service_client(ostream& out, t_service* tservice) } else { out << "__TClient"; } - out << ", {" << endl << " __type = '" << classname << "'" << endl << "})" << endl; + out << ", {" << '\n' << " __type = '" << classname << "'" << '\n' << "})" << '\n'; // Send/Recv functions vector functions = tservice->get_functions(); @@ -572,28 +570,28 @@ void t_lua_generator::generate_service_client(ostream& out, t_service* tservice) string funcname = (*f_iter)->get_name(); // Wrapper function - indent(out) << endl << "function " << classname << ":" << sig << endl; + indent(out) << '\n' << "function " << classname << ":" << sig << '\n'; indent_up(); - indent(out) << "self:send_" << sig << endl << indent(); + indent(out) << "self:send_" << sig << '\n' << indent(); if (!(*f_iter)->is_oneway()) { if (!(*f_iter)->get_returntype()->is_void()) { out << "return "; } - out << "self:recv_" << sig << endl; + out << "self:recv_" << sig << '\n'; } indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; // Send function - indent(out) << endl << "function " << classname << ":send_" << sig << endl; + indent(out) << '\n' << "function " << classname << ":send_" << sig << '\n'; indent_up(); indent(out) << "self.oprot:writeMessageBegin('" << funcname << "', " << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL") - << ", self._seqid)" << endl; - indent(out) << "local args = " << funcname << "_args:new{}" << endl; + << ", self._seqid)" << '\n'; + indent(out) << "local args = " << funcname << "_args:new{}" << '\n'; // Set the args const vector& args = (*f_iter)->get_arglist()->get_members(); @@ -603,60 +601,60 @@ void t_lua_generator::generate_service_client(ostream& out, t_service* tservice) if ((*fld_iter)->get_value() != nullptr) { // Insert default value for nil arguments t_type* type = get_true_type((*fld_iter)->get_type()); - indent(out) << "if " << argname << " ~= nil then" << endl; + indent(out) << "if " << argname << " ~= nil then" << '\n'; indent_up(); - indent(out) << "args." << argname << " = " << argname << endl; + indent(out) << "args." << argname << " = " << argname << '\n'; indent_down(); - indent(out) << "else" << endl; + indent(out) << "else" << '\n'; indent_up(); - indent(out) << "args." << argname << " = " << render_const_value(type, (*fld_iter)->get_value()) << endl; + indent(out) << "args." << argname << " = " << render_const_value(type, (*fld_iter)->get_value()) << '\n'; indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; } else { - indent(out) << "args." << argname << " = " << argname << endl; + indent(out) << "args." << argname << " = " << argname << '\n'; } } - indent(out) << "args:write(self.oprot)" << endl; - indent(out) << "self.oprot:writeMessageEnd()" << endl; - indent(out) << "self.oprot.trans:flush()" << endl; + indent(out) << "args:write(self.oprot)" << '\n'; + indent(out) << "self.oprot:writeMessageEnd()" << '\n'; + indent(out) << "self.oprot.trans:flush()" << '\n'; indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; // Recv function if (!(*f_iter)->is_oneway()) { - indent(out) << endl << "function " << classname << ":recv_" << sig << endl; + indent(out) << '\n' << "function " << classname << ":recv_" << sig << '\n'; indent_up(); out << indent() << "local fname, mtype, rseqid = self.iprot:" - << "readMessageBegin()" << endl << indent() << "if mtype == TMessageType.EXCEPTION then" - << endl << indent() << " local x = TApplicationException:new{}" << endl << indent() - << " x:read(self.iprot)" << endl << indent() << " self.iprot:readMessageEnd()" << endl - << indent() << " error(x)" << endl << indent() << "end" << endl << indent() - << "local result = " << funcname << "_result:new{}" << endl << indent() - << "result:read(self.iprot)" << endl << indent() << "self.iprot:readMessageEnd()" << endl; + << "readMessageBegin()" << '\n' << indent() << "if mtype == TMessageType.EXCEPTION then" + << '\n' << indent() << " local x = TApplicationException:new{}" << '\n' << indent() + << " x:read(self.iprot)" << '\n' << indent() << " self.iprot:readMessageEnd()" << '\n' + << indent() << " error(x)" << '\n' << indent() << "end" << '\n' << indent() + << "local result = " << funcname << "_result:new{}" << '\n' << indent() + << "result:read(self.iprot)" << '\n' << indent() << "self.iprot:readMessageEnd()" << '\n'; // Return the result if it's not a void function if (!(*f_iter)->get_returntype()->is_void()) { - out << indent() << "if result.success ~= nil then" << endl << indent() << " return result.success" - << endl; + out << indent() << "if result.success ~= nil then" << '\n' << indent() << " return result.success" + << '\n'; // Throw custom exceptions const std::vector& xf = (*f_iter)->get_xceptions()->get_members(); vector::const_iterator x_iter; for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) { - out << indent() << "elseif result." << (*x_iter)->get_name() << " then" << endl - << indent() << " error(result." << (*x_iter)->get_name() << ")" << endl; + out << indent() << "elseif result." << (*x_iter)->get_name() << " then" << '\n' + << indent() << " error(result." << (*x_iter)->get_name() << ")" << '\n'; } - out << indent() << "end" << endl << indent() + out << indent() << "end" << '\n' << indent() << "error(TApplicationException:new{errorCode = " - << "TApplicationException.MISSING_RESULT})" << endl; + << "TApplicationException.MISSING_RESULT})" << '\n'; } indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; } } } @@ -666,40 +664,40 @@ void t_lua_generator::generate_service_processor(ostream& out, t_service* tservi t_service* extends_s = tservice->get_extends(); // Define processor table - out << endl << classname << " = __TObject.new("; + out << '\n' << classname << " = __TObject.new("; if (extends_s != nullptr) { - out << extends_s->get_name() << "Processor" << endl; + out << extends_s->get_name() << "Processor" << '\n'; } else { - out << "__TProcessor" << endl; + out << "__TProcessor" << '\n'; } - out << ", {" << endl << " __type = '" << classname << "'" << endl << "})" << endl; + out << ", {" << '\n' << " __type = '" << classname << "'" << '\n' << "})" << '\n'; // Process function - indent(out) << endl << "function " << classname << ":process(iprot, oprot, server_ctx)" << endl; + indent(out) << '\n' << "function " << classname << ":process(iprot, oprot, server_ctx)" << '\n'; indent_up(); - indent(out) << "local name, mtype, seqid = iprot:readMessageBegin()" << endl; - indent(out) << "local func_name = 'process_' .. name" << endl; - indent(out) << "if not self[func_name] or ttype(self[func_name]) ~= 'function' then" << endl; + indent(out) << "local name, mtype, seqid = iprot:readMessageBegin()" << '\n'; + indent(out) << "local func_name = 'process_' .. name" << '\n'; + indent(out) << "if not self[func_name] or ttype(self[func_name]) ~= 'function' then" << '\n'; indent_up(); indent(out) << "if oprot ~= nil then"; indent_up(); - out << endl << indent() << "iprot:skip(TType.STRUCT)" << endl << indent() - << "iprot:readMessageEnd()" << endl << indent() << "x = TApplicationException:new{" << endl - << indent() << " errorCode = TApplicationException.UNKNOWN_METHOD" << endl << indent() << "}" - << endl << indent() << "oprot:writeMessageBegin(name, TMessageType.EXCEPTION, " - << "seqid)" << endl << indent() << "x:write(oprot)" << endl << indent() - << "oprot:writeMessageEnd()" << endl << indent() << "oprot.trans:flush()" << endl; + out << '\n' << indent() << "iprot:skip(TType.STRUCT)" << '\n' << indent() + << "iprot:readMessageEnd()" << '\n' << indent() << "x = TApplicationException:new{" << '\n' + << indent() << " errorCode = TApplicationException.UNKNOWN_METHOD" << '\n' << indent() << "}" + << '\n' << indent() << "oprot:writeMessageBegin(name, TMessageType.EXCEPTION, " + << "seqid)" << '\n' << indent() << "x:write(oprot)" << '\n' << indent() + << "oprot:writeMessageEnd()" << '\n' << indent() << "oprot.trans:flush()" << '\n'; indent_down(); - out << indent() << "end" << endl << indent() - << "return false, 'Unknown function '..name" << endl; + out << indent() << "end" << '\n' << indent() + << "return false, 'Unknown function '..name" << '\n'; indent_down(); - indent(out) << "else" << endl << indent() - << " return self[func_name](self, seqid, iprot, oprot, server_ctx)" << endl << indent() - << "end" << endl; + indent(out) << "else" << '\n' << indent() + << " return self[func_name](self, seqid, iprot, oprot, server_ctx)" << '\n' << indent() + << "end" << '\n'; indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; // Generate the process subfunctions vector functions = tservice->get_functions(); @@ -717,18 +715,18 @@ void t_lua_generator::generate_process_function(ostream& out, string resultname = tfunction->get_name() + "_result"; string fn_name = tfunction->get_name(); - indent(out) << endl << "function " << classname << ":process_" << fn_name - << "(seqid, iprot, oprot, server_ctx)" << endl; + indent(out) << '\n' << "function " << classname << ":process_" << fn_name + << "(seqid, iprot, oprot, server_ctx)" << '\n'; indent_up(); // Read the request - out << indent() << "local args = " << argsname << ":new{}" << endl << indent() - << "local reply_type = TMessageType.REPLY" << endl << indent() << "args:read(iprot)" << endl - << indent() << "iprot:readMessageEnd()" << endl; + out << indent() << "local args = " << argsname << ":new{}" << '\n' << indent() + << "local reply_type = TMessageType.REPLY" << '\n' << indent() << "args:read(iprot)" << '\n' + << indent() << "iprot:readMessageEnd()" << '\n'; if (!tfunction->is_oneway()) { out << indent() << "local result = " << resultname - << ":new{}" << endl; + << ":new{}" << '\n'; } out << indent() << "local status, res = pcall(self.handler." << fn_name @@ -738,13 +736,13 @@ void t_lua_generator::generate_process_function(ostream& out, if (args->get_members().size() > 0) { out << ", " << argument_list(args, "args."); } - out << ")" << endl; + out << ")" << '\n'; if (!tfunction->is_oneway()) { // Check for errors - out << indent() << "if not status then" << endl << indent() - << " reply_type = TMessageType.EXCEPTION" << endl << indent() - << " result = TApplicationException:new{message = res}" << endl; + out << indent() << "if not status then" << '\n' << indent() + << " reply_type = TMessageType.EXCEPTION" << '\n' << indent() + << " result = TApplicationException:new{message = res}" << '\n'; // Handle custom exceptions const std::vector& xf = tfunction->get_xceptions()->get_members(); @@ -752,19 +750,19 @@ void t_lua_generator::generate_process_function(ostream& out, vector::const_iterator x_iter; for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) { out << indent() << "elseif ttype(res) == '" << (*x_iter)->get_type()->get_name() << "' then" - << endl << indent() << " result." << (*x_iter)->get_name() << " = res" << endl; + << '\n' << indent() << " result." << (*x_iter)->get_name() << " = res" << '\n'; } } // Set the result and write the reply - out << indent() << "else" << endl << indent() << " result.success = res" << endl << indent() - << "end" << endl << indent() << "oprot:writeMessageBegin('" << fn_name << "', reply_type, " - << "seqid)" << endl << indent() << "result:write(oprot)" << endl << indent() - << "oprot:writeMessageEnd()" << endl << indent() << "oprot.trans:flush()" << endl; + out << indent() << "else" << '\n' << indent() << " result.success = res" << '\n' << indent() + << "end" << '\n' << indent() << "oprot:writeMessageBegin('" << fn_name << "', reply_type, " + << "seqid)" << '\n' << indent() << "result:write(oprot)" << '\n' << indent() + << "oprot:writeMessageEnd()" << '\n' << indent() << "oprot.trans:flush()" << '\n'; } - out << indent() << "return status, res" << endl; + out << indent() << "return status, res" << '\n'; indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; } // Service helpers @@ -772,7 +770,7 @@ void t_lua_generator::generate_service_helpers(ostream& out, t_service* tservice vector functions = tservice->get_functions(); vector::iterator f_iter; - out << endl << "-- HELPER FUNCTIONS AND STRUCTURES"; + out << '\n' << "-- HELPER FUNCTIONS AND STRUCTURES"; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { t_struct* ts = (*f_iter)->get_arglist(); generate_lua_struct_definition(out, ts, false); @@ -853,7 +851,7 @@ void t_lua_generator::generate_deserialize_field(ostream& out, } else if (type->is_enum()) { out << "readI32()"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", @@ -867,7 +865,7 @@ void t_lua_generator::generate_deserialize_struct(ostream& out, bool local, string prefix) { indent(out) << (local ? "local " : "") << prefix << " = " << tstruct->get_name() << ":new{}" - << endl << indent() << prefix << ":read(iprot)" << endl; + << '\n' << indent() << prefix << ":read(iprot)" << '\n'; } void t_lua_generator::generate_deserialize_container(ostream& out, @@ -885,18 +883,18 @@ void t_lua_generator::generate_deserialize_container(ostream& out, t_field fetype(g_type_i8, etype); // Declare variables, read header - indent(out) << (local ? "local " : "") << prefix << " = {}" << endl; + indent(out) << (local ? "local " : "") << prefix << " = {}" << '\n'; if (ttype->is_map()) { indent(out) << "local " << ktype << ", " << vtype << ", " << size << " = iprot:readMapBegin() " - << endl; + << '\n'; } else if (ttype->is_set()) { - indent(out) << "local " << etype << ", " << size << " = iprot:readSetBegin()" << endl; + indent(out) << "local " << etype << ", " << size << " = iprot:readSetBegin()" << '\n'; } else if (ttype->is_list()) { - indent(out) << "local " << etype << ", " << size << " = iprot:readListBegin()" << endl; + indent(out) << "local " << etype << ", " << size << " = iprot:readListBegin()" << '\n'; } // Deserialize - indent(out) << "for _i=1," << size << " do" << endl; + indent(out) << "for _i=1," << size << " do" << '\n'; indent_up(); if (ttype->is_map()) { @@ -908,15 +906,15 @@ void t_lua_generator::generate_deserialize_container(ostream& out, } indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; // Read container end if (ttype->is_map()) { - indent(out) << "iprot:readMapEnd()" << endl; + indent(out) << "iprot:readMapEnd()" << '\n'; } else if (ttype->is_set()) { - indent(out) << "iprot:readSetEnd()" << endl; + indent(out) << "iprot:readSetEnd()" << '\n'; } else if (ttype->is_list()) { - indent(out) << "iprot:readListEnd()" << endl; + indent(out) << "iprot:readListEnd()" << '\n'; } } @@ -930,7 +928,7 @@ void t_lua_generator::generate_deserialize_map_element(ostream& out, t_map* tmap generate_deserialize_field(out, &fkey, true); generate_deserialize_field(out, &fval, true); - indent(out) << prefix << "[" << key << "] = " << val << endl; + indent(out) << prefix << "[" << key << "] = " << val << '\n'; } void t_lua_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) { @@ -940,7 +938,7 @@ void t_lua_generator::generate_deserialize_set_element(ostream& out, t_set* tset generate_deserialize_field(out, &felem, true); - indent(out) << prefix << "[" << elem << "] = " << elem << endl; + indent(out) << prefix << "[" << elem << "] = " << elem << '\n'; } void t_lua_generator::generate_deserialize_list_element(ostream& out, @@ -953,7 +951,7 @@ void t_lua_generator::generate_deserialize_list_element(ostream& out, generate_deserialize_field(out, &felem, true); - indent(out) << "table.insert(" << prefix << ", " << elem << ")" << endl; + indent(out) << "table.insert(" << prefix << ", " << elem << ")" << '\n'; } /** @@ -1008,7 +1006,7 @@ void t_lua_generator::generate_serialize_field(ostream& out, t_field* tfield, st } else if (type->is_enum()) { out << "writeI32(" << name << ")"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s' TYPE '%s'\n", name.c_str(), @@ -1018,7 +1016,7 @@ void t_lua_generator::generate_serialize_field(ostream& out, t_field* tfield, st void t_lua_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - indent(out) << prefix << ":write(oprot)" << endl; + indent(out) << prefix << ":write(oprot)" << '\n'; } void t_lua_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) { @@ -1026,48 +1024,48 @@ void t_lua_generator::generate_serialize_container(ostream& out, t_type* ttype, if (ttype->is_map()) { indent(out) << "oprot:writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " - << "ttable_size(" << prefix << "))" << endl; + << "ttable_size(" << prefix << "))" << '\n'; } else if (ttype->is_set()) { indent(out) << "oprot:writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " - << "ttable_size(" << prefix << "))" << endl; + << "ttable_size(" << prefix << "))" << '\n'; } else if (ttype->is_list()) { indent(out) << "oprot:writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " - << "#" << prefix << ")" << endl; + << "#" << prefix << ")" << '\n'; } // Serialize if (ttype->is_map()) { string kiter = tmp("kiter"); string viter = tmp("viter"); - indent(out) << "for " << kiter << "," << viter << " in pairs(" << prefix << ") do" << endl; + indent(out) << "for " << kiter << "," << viter << " in pairs(" << prefix << ") do" << '\n'; indent_up(); generate_serialize_map_element(out, (t_map*)ttype, kiter, viter); indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; } else if (ttype->is_set()) { string iter = tmp("iter"); - indent(out) << "for " << iter << ",_ in pairs(" << prefix << ") do" << endl; + indent(out) << "for " << iter << ",_ in pairs(" << prefix << ") do" << '\n'; indent_up(); generate_serialize_set_element(out, (t_set*)ttype, iter); indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; } else if (ttype->is_list()) { string iter = tmp("iter"); - indent(out) << "for _," << iter << " in ipairs(" << prefix << ") do" << endl; + indent(out) << "for _," << iter << " in ipairs(" << prefix << ") do" << '\n'; indent_up(); generate_serialize_list_element(out, (t_list*)ttype, iter); indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; } // Finish writing if (ttype->is_map()) { - indent(out) << "oprot:writeMapEnd()" << endl; + indent(out) << "oprot:writeMapEnd()" << '\n'; } else if (ttype->is_set()) { - indent(out) << "oprot:writeSetEnd()" << endl; + indent(out) << "oprot:writeSetEnd()" << '\n'; } else if (ttype->is_list()) { - indent(out) << "oprot:writeListEnd()" << endl; + indent(out) << "oprot:writeListEnd()" << '\n'; } } diff --git a/compiler/cpp/src/thrift/generate/t_markdown_generator.cc b/compiler/cpp/src/thrift/generate/t_markdown_generator.cc index 76fe98b4e53..fbcaccca02e 100644 --- a/compiler/cpp/src/thrift/generate/t_markdown_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_markdown_generator.cc @@ -38,9 +38,6 @@ using std::string; using std::stringstream; using std::vector; -static const char endl = '\n'; // avoid ostream << std::endl flushes - - /** * MARKDOWN code generator * @@ -55,7 +52,7 @@ enum input_type { INPUT_UNKNOWN, INPUT_UTF8, INPUT_PLAIN }; const std::map& parsed_options, const std::string& option_string) : t_generator(program) { - + (void)option_string; std::map::const_iterator iter; @@ -128,14 +125,14 @@ enum input_type { INPUT_UNKNOWN, INPUT_UTF8, INPUT_PLAIN }; /** - * string to markdown-id link reference + * string to markdown-id link reference */ std::string t_markdown_generator::str_to_id(const std::string& s) { std::string id; for(auto chr=s.begin();chr<=s.end(); ++chr) { if(*chr == '.' || *chr == 0) continue; - id += tolower(*chr); + id += tolower(*chr); } return id; } @@ -144,10 +141,10 @@ std::string t_markdown_generator::str_to_id(const std::string& s) { * Emits the Table of Contents links at the top of the module's page */ void t_markdown_generator::generate_program_toc() { - f_out_ << "| Module | Services & Functions | Data types | Constants |" << endl - << "| --- | --- | --- | --- |" << endl; + f_out_ << "| Module | Services & Functions | Data types | Constants |" << '\n' + << "| --- | --- | --- | --- |" << '\n'; generate_program_toc_row(program_); - f_out_ << endl; + f_out_ << '\n'; } /** @@ -191,24 +188,24 @@ void t_markdown_generator::generate_program_toc_row(t_program* tprog) { fill = &filling.back(); } string name = get_service_name(*sv_iter); - (*fill)[1] = "[" + name + "](" - + make_file_link(fname) + (*fill)[1] = "[" + name + "](" + + make_file_link(fname) + "#service-" + str_to_id(name) + ")"; - + vector functions = (*sv_iter)->get_functions(); vector::iterator fn_iter; - for (fn_iter = functions.begin(); fn_iter != functions.end(); ++fn_iter) { - string fn_name = (*fn_iter)->get_name(); + for (fn_iter = functions.begin(); fn_iter != functions.end(); ++fn_iter) { + string fn_name = (*fn_iter)->get_name(); filling.emplace_back(); fill = &filling.back(); - (*fill)[1] = " [ • " + fn_name + "](" - + make_file_link(fname) + (*fill)[1] = " [ • " + fn_name + "](" + + make_file_link(fname) + "#function-" + str_to_id(name + fn_name) + ")"; } } } - - // Data Types Column + + // Data Types Column auto it_fill = filling.begin(); if (!tprog->get_enums().empty()) { @@ -224,8 +221,8 @@ void t_markdown_generator::generate_program_toc_row(t_program* tprog) { ++it_fill; } string name = (*en_iter)->get_name(); - (*fill)[2] = "[" + name + "](" - + make_file_link(fname) + (*fill)[2] = "[" + name + "](" + + make_file_link(fname) + "#enumeration-" + str_to_id(name) + ")"; } } @@ -242,15 +239,15 @@ void t_markdown_generator::generate_program_toc_row(t_program* tprog) { ++it_fill; } string name = (*td_iter)->get_symbolic(); - (*fill)[2] = "[" + name + "](" - + make_file_link(fname) + (*fill)[2] = "[" + name + "](" + + make_file_link(fname) + "#typedef-" + str_to_id(name) + ")"; } } if (!tprog->get_objects().empty()) { vector objects = tprog->get_objects(); vector::iterator o_iter; - for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) { + for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) { if(it_fill == filling.end()) { filling.emplace_back(); fill = &filling.back(); @@ -261,7 +258,7 @@ void t_markdown_generator::generate_program_toc_row(t_program* tprog) { } string name = (*o_iter)->get_name(); (*fill)[2] = "[" + name + "](" + make_file_link(fname); - + if ((*o_iter)->is_xception()) { (*fill)[2] += "#exception-"; } else if ((*o_iter)->is_struct() && (*o_iter)->is_union()) { @@ -270,11 +267,11 @@ void t_markdown_generator::generate_program_toc_row(t_program* tprog) { (*fill)[2] += "#struct-"; } (*fill)[2] += str_to_id(name) + ")"; - + } } - - // Constants Column + + // Constants Column it_fill = filling.begin(); if (!tprog->get_consts().empty()) { @@ -291,19 +288,19 @@ void t_markdown_generator::generate_program_toc_row(t_program* tprog) { ++it_fill; } string name = (*con_iter)->get_name(); - (*fill)[3] = "[" + name + "](" - + make_file_link(fname) + (*fill)[3] = "[" + name + "](" + + make_file_link(fname) + "#constant-" + str_to_id(name) + ")"; } - + } - + for(auto& fill : filling) { for(auto& c : fill) - f_out_ << '|' << c; - f_out_ << '|' << endl; + f_out_ << '|' << c; + f_out_ << '|' << '\n'; } - f_out_ << endl; + f_out_ << '\n'; } /** @@ -318,24 +315,24 @@ void t_markdown_generator::generate_program() { current_file_ = make_file_name(pname); string fname = get_out_dir() + current_file_; f_out_.open(fname.c_str()); - f_out_ << "# Thrift module: " << pname << endl << endl; + f_out_ << "# Thrift module: " << pname << '\n' << '\n'; print_doc(program_); - f_out_ << endl << endl; + f_out_ << '\n' << '\n'; generate_program_toc(); if (!program_->get_consts().empty()) { - f_out_ << "***" << endl << "## Constants" << endl << endl; + f_out_ << "***" << '\n' << "## Constants" << '\n' << '\n'; vector consts = program_->get_consts(); - f_out_ << "|Constant|Type|Value||" << endl - << "|---|---|---|---|" << endl; + f_out_ << "|Constant|Type|Value||" << '\n' + << "|---|---|---|---|" << '\n'; generate_consts(consts); - f_out_ << endl; + f_out_ << '\n'; } if (!program_->get_enums().empty()) { - f_out_ << "***" << endl << "## Enumerations" << endl << endl; + f_out_ << "***" << '\n' << "## Enumerations" << '\n' << '\n'; // Generate enums vector enums = program_->get_enums(); vector::iterator en_iter; @@ -345,7 +342,7 @@ void t_markdown_generator::generate_program() { } if (!program_->get_typedefs().empty()) { - f_out_ << "***" << endl << "## Type declarations" << endl << endl; + f_out_ << "***" << '\n' << "## Type declarations" << '\n' << '\n'; // Generate typedefs vector typedefs = program_->get_typedefs(); vector::iterator td_iter; @@ -355,7 +352,7 @@ void t_markdown_generator::generate_program() { } if (!program_->get_objects().empty()) { - f_out_ << "***" << endl << "## Data structures" << endl << endl; + f_out_ << "***" << '\n' << "## Data structures" << '\n' << '\n'; // Generate structs and exceptions in declared order vector objects = program_->get_objects(); vector::iterator o_iter; @@ -369,7 +366,7 @@ void t_markdown_generator::generate_program() { } if (!program_->get_services().empty()) { - f_out_ << "***" << endl << "## Services" << endl << endl; + f_out_ << "***" << '\n' << "## Services" << '\n' << '\n'; // Generate services vector services = program_->get_services(); vector::iterator sv_iter; @@ -379,7 +376,7 @@ void t_markdown_generator::generate_program() { } } - f_out_ << endl; + f_out_ << '\n'; f_out_.close(); generate_index(); @@ -392,15 +389,15 @@ void t_markdown_generator::generate_index() { current_file_ = make_file_name("index"); string index_fname = get_out_dir() + current_file_; f_out_.open(index_fname.c_str()); - - f_out_ << "# Thrift declarations" << endl; - f_out_ << "| Module | Services & Functions | Data types | Constants |" - << endl - << "| --- | --- | --- | --- |" - << endl; + + f_out_ << "# Thrift declarations" << '\n'; + f_out_ << "| Module | Services & Functions | Data types | Constants |" + << '\n' + << "| --- | --- | --- | --- |" + << '\n'; vector programs; generate_program_toc_rows(program_, programs); - f_out_ << endl; + f_out_ << '\n'; f_out_.close(); } @@ -716,13 +713,13 @@ int t_markdown_generator::print_type(t_type* ttype) { f_out_ << ">"; } } else if (ttype->is_base_type()) { - f_out_ << "```" << (ttype->is_binary() ? "binary" : ttype->get_name()) + f_out_ << "```" << (ttype->is_binary() ? "binary" : ttype->get_name()) << "```"; len = ttype->get_name().size(); } else { string prog_name = ttype->get_program()->get_name(); string type_name = ttype->get_name(); - f_out_ << "[```" << type_name << "```](" + f_out_ << "[```" << type_name << "```](" << make_file_link(make_file_name(prog_name)) << "#"; if (ttype->is_typedef()) { f_out_ << "typedef-"; @@ -740,7 +737,7 @@ int t_markdown_generator::print_type(t_type* ttype) { } len = type_name.size(); if (ttype->get_program() != program_) { - f_out_ << str_to_id(prog_name); + f_out_ << str_to_id(prog_name); len += prog_name.size() + 1; } f_out_ << str_to_id(type_name) << ')'; @@ -757,8 +754,8 @@ void t_markdown_generator::print_const_value(t_type* type, t_const_value* tvalue if (tvalue->get_type() == t_const_value::CV_IDENTIFIER) { string fname = make_file_name(program_->get_name()); string name = escape_html(tvalue->get_identifier()); - f_out_ << "[```" << name << "```](" - + make_file_link(fname) + f_out_ << "[```" << name << "```](" + + make_file_link(fname) + "#constant-" + str_to_id(name) + ")"; return; } @@ -773,7 +770,7 @@ void t_markdown_generator::print_const_value(t_type* type, t_const_value* tvalue t_base_type::t_base tbase = ((t_base_type*)truetype)->get_base(); f_out_ << "```"; switch (tbase) { - case t_base_type::TYPE_STRING: + case t_base_type::TYPE_STRING: f_out_ << escape_html(get_escaped_string(tvalue)); break; case t_base_type::TYPE_BOOL: @@ -893,17 +890,17 @@ void t_markdown_generator::print_fn_args_doc(t_function* tfunction) { } if (has_docs) { arg_iter = args.begin(); - f_out_ << endl << "* parameters:" << endl; + f_out_ << '\n' << "* parameters:" << '\n'; for (int n = 1; arg_iter != args.end(); ++arg_iter, ++n ) { f_out_ << n << ". " << (*arg_iter)->get_name(); f_out_ << " - " << escape_html((*arg_iter)->get_doc()); - f_out_ << endl; + f_out_ << '\n'; } - f_out_ << endl; + f_out_ << '\n'; } } - if(!has_docs) - f_out_ << endl; + if(!has_docs) + f_out_ << '\n'; has_docs = false; vector excepts = tfunction->get_xceptions()->get_members(); @@ -917,14 +914,14 @@ void t_markdown_generator::print_fn_args_doc(t_function* tfunction) { } if (has_docs) { ex_iter = excepts.begin(); - f_out_ << "* exceptions:" << endl; + f_out_ << "* exceptions:" << '\n'; for (; ex_iter != excepts.end(); ex_iter++) { f_out_ << " * " << (*ex_iter)->get_type()->get_name(); f_out_ << " - "; f_out_ << escape_html((*ex_iter)->get_doc()); - f_out_ << endl; + f_out_ << '\n'; } - f_out_ << endl; + f_out_ << '\n'; } } } @@ -936,13 +933,13 @@ void t_markdown_generator::print_fn_args_doc(t_function* tfunction) { */ void t_markdown_generator::generate_typedef(t_typedef* ttypedef) { string name = ttypedef->get_name(); - f_out_ << "### Typedef: " << name << endl; + f_out_ << "### Typedef: " << name << '\n'; print_doc(ttypedef); - f_out_ << endl << endl; + f_out_ << '\n' << '\n'; f_out_ << "_Base type_: **"; print_type(ttypedef->get_type()); - f_out_ << "**" << endl << endl; - f_out_ << endl; + f_out_ << "**" << '\n' << '\n'; + f_out_ << '\n'; } /** @@ -952,10 +949,10 @@ void t_markdown_generator::generate_typedef(t_typedef* ttypedef) { */ void t_markdown_generator::generate_enum(t_enum* tenum) { string name = tenum->get_name(); - f_out_ << "### Enumeration: " << name << endl; + f_out_ << "### Enumeration: " << name << '\n'; print_doc(tenum); - f_out_ << endl << endl << "|Name|Value|Description|" << endl - << "|---|---|---|" << endl; + f_out_ << '\n' << '\n' << "|Name|Value|Description|" << '\n' + << "|---|---|---|" << '\n'; vector values = tenum->get_constants(); vector::iterator val_iter; for (val_iter = values.begin(); val_iter != values.end(); ++val_iter) { @@ -965,9 +962,9 @@ void t_markdown_generator::generate_enum(t_enum* tenum) { f_out_ << (*val_iter)->get_value(); f_out_ << "```|"; print_doc((*val_iter)); - f_out_ << "|" << endl; + f_out_ << "|" << '\n'; } - f_out_ << endl; + f_out_ << '\n'; } /** @@ -984,7 +981,7 @@ void t_markdown_generator::generate_const(t_const* tconst) { if (tconst->has_doc()) { print_doc(tconst); } - f_out_ << '|' << endl; + f_out_ << '|' << '\n'; } /** @@ -1002,14 +999,14 @@ void t_markdown_generator::generate_struct(t_struct* tstruct) { } else { f_out_ << "Struct: "; } - f_out_ << name << endl; + f_out_ << name << '\n'; print_doc(tstruct); - f_out_ << endl << endl; + f_out_ << '\n' << '\n'; vector members = tstruct->get_members(); vector::iterator mem_iter = members.begin(); f_out_ << "| Key | Field | Type | Description | Requiredness " - "| Default value |" << endl - << "| --- | --- | --- | --- | --- | --- |" << endl; + "| Default value |" << '\n' + << "| --- | --- | --- | --- | --- | --- |" << '\n'; for (; mem_iter != members.end(); mem_iter++) { f_out_ << '|' << (*mem_iter)->get_key(); f_out_ << '|' << (*mem_iter)->get_name(); @@ -1030,9 +1027,9 @@ void t_markdown_generator::generate_struct(t_struct* tstruct) { print_const_value((*mem_iter)->get_type(), default_val); f_out_ << "```"; } - f_out_ << '|' << endl; + f_out_ << '|' << '\n'; } - f_out_ << endl; + f_out_ << '\n'; } /** @@ -1050,32 +1047,32 @@ void t_markdown_generator::generate_xception(t_struct* txception) { * @param tservice The service definition */ void t_markdown_generator::generate_service(t_service* tservice) { - f_out_ << "### Service: " << service_name_ << endl; + f_out_ << "### Service: " << service_name_ << '\n'; if (tservice->get_extends()) { f_out_ << "**extends ** _"; print_type(tservice->get_extends()); - f_out_ << "_" << endl; + f_out_ << "_" << '\n'; } print_doc(tservice); - f_out_ << endl; + f_out_ << '\n'; vector functions = tservice->get_functions(); vector::iterator fn_iter = functions.begin(); for (; fn_iter != functions.end(); fn_iter++) { string fn_name = (*fn_iter)->get_name(); - f_out_ << "#### Function: " << service_name_ << "." << fn_name << endl; + f_out_ << "#### Function: " << service_name_ << "." << fn_name << '\n'; print_doc(*fn_iter); - f_out_ << endl << endl; + f_out_ << '\n' << '\n'; print_type((*fn_iter)->get_returntype()); bool first = true; - f_out_ << endl << " _" << fn_name << "_("; + f_out_ << '\n' << " _" << fn_name << "_("; vector args = (*fn_iter)->get_arglist()->get_members(); vector::iterator arg_iter = args.begin(); for (; arg_iter != args.end(); arg_iter++) { if (!first) { - f_out_ << "," << endl; + f_out_ << "," << '\n'; } first = false; print_type((*arg_iter)->get_type()); @@ -1085,7 +1082,7 @@ void t_markdown_generator::generate_service(t_service* tservice) { print_const_value((*arg_iter)->get_type(), (*arg_iter)->get_value()); } } - f_out_ << ")" << endl; + f_out_ << ")" << '\n'; first = true; vector excepts = (*fn_iter)->get_xceptions()->get_members(); vector::iterator ex_iter = excepts.begin(); @@ -1098,10 +1095,10 @@ void t_markdown_generator::generate_service(t_service* tservice) { first = false; print_type((*ex_iter)->get_type()); } - f_out_ << endl; + f_out_ << '\n'; } print_fn_args_doc(*fn_iter); - f_out_ << endl; + f_out_ << '\n'; } } diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc index 1a27c0c3b2f..6e464549784 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc @@ -203,26 +203,26 @@ void t_netstd_generator::reset_indent() { void t_netstd_generator::pragmas_and_directives(ostream& out) { if( target_net_version >= 6) { - out << "// Thrift code generated for net" << target_net_version << endl; - out << "#nullable enable // requires C# 8.0" << endl; + out << "// Thrift code generated for net" << target_net_version << '\n'; + out << "#nullable enable // requires C# 8.0" << '\n'; } // this one must be first - out << "#pragma warning disable IDE0079 // remove unnecessary pragmas" << endl; + out << "#pragma warning disable IDE0079 // remove unnecessary pragmas" << '\n'; if( target_net_version >= 8) { - out << "#pragma warning disable IDE0290 // use primary CTOR" << endl; + out << "#pragma warning disable IDE0290 // use primary CTOR" << '\n'; } else { - out << "#pragma warning disable IDE0017 // object init can be simplified" << endl; - out << "#pragma warning disable IDE0028 // collection init can be simplified" << endl; + out << "#pragma warning disable IDE0017 // object init can be simplified" << '\n'; + out << "#pragma warning disable IDE0028 // collection init can be simplified" << '\n'; } - out << "#pragma warning disable IDE1006 // parts of the code use IDL spelling" << endl; - out << "#pragma warning disable CA1822 // empty " << DEEP_COPY_METHOD_NAME << "() methods still non-static" << endl; + out << "#pragma warning disable IDE1006 // parts of the code use IDL spelling" << '\n'; + out << "#pragma warning disable CA1822 // empty " << DEEP_COPY_METHOD_NAME << "() methods still non-static" << '\n'; if( target_net_version < 6) { - out << "#pragma warning disable IDE0083 // pattern matching \"that is not SomeType\" requires net5.0 but we still support earlier versions" << endl; + out << "#pragma warning disable IDE0083 // pattern matching \"that is not SomeType\" requires net5.0 but we still support earlier versions" << '\n'; } - out << endl; + out << '\n'; } @@ -230,7 +230,7 @@ void t_netstd_generator::start_netstd_namespace(ostream& out) { if (!namespace_name_.empty()) { - out << "namespace " << namespace_name_ << endl; + out << "namespace " << namespace_name_ << '\n'; scope_up(out); } } @@ -309,13 +309,13 @@ void t_netstd_generator::generate_enum(t_enum* tenum) void t_netstd_generator::generate_enum(ostream& out, t_enum* tenum) { reset_indent(); - out << autogen_comment() << endl; + out << autogen_comment() << '\n'; pragmas_and_directives(out); start_netstd_namespace(out); generate_netstd_doc(out, tenum); - out << indent() << "public enum " << type_name(tenum,false) << endl; + out << indent() << "public enum " << type_name(tenum,false) << '\n'; scope_up(out); vector constants = tenum->get_constants(); @@ -325,7 +325,7 @@ void t_netstd_generator::generate_enum(ostream& out, t_enum* tenum) { generate_netstd_doc(out, *c_iter); int value = (*c_iter)->get_value(); - out << indent() << normalize_name((*c_iter)->get_name()) << " = " << value << "," << endl; + out << indent() << normalize_name((*c_iter)->get_name()) << " = " << value << "," << '\n'; } scope_down(out); @@ -356,12 +356,12 @@ void t_netstd_generator::generate_consts(ostream& out, vector consts) } reset_indent(); - out << autogen_comment() << netstd_type_usings() << endl << endl; + out << autogen_comment() << netstd_type_usings() << '\n' << '\n'; pragmas_and_directives(out); start_netstd_namespace(out); - out << indent() << "public static class " << make_valid_csharp_identifier(program_name_) << "Constants" << endl; + out << indent() << "public static class " << make_valid_csharp_identifier(program_name_) << "Constants" << '\n'; scope_up(out); @@ -416,7 +416,7 @@ void t_netstd_generator::print_const_def_value(ostream& out, string name, t_type t_type* field_type = field->get_type(); string val = render_const_value(out, name, field_type, v_iter->second); - out << indent() << name << "." << prop_name(field) << " = " << val << ";" << endl; + out << indent() << name << "." << prop_name(field) << " = " << val << ";" << '\n'; } cleanup_member_name_mapping(static_cast(type)); @@ -431,7 +431,7 @@ void t_netstd_generator::print_const_def_value(ostream& out, string name, t_type { string key = render_const_value(out, name, ktype, v_iter->first); string val = render_const_value(out, name, vtype, v_iter->second); - out << indent() << name << "[" << key << "]" << " = " << val << ";" << endl; + out << indent() << name << "[" << key << "]" << " = " << val << ";" << '\n'; } } else if (type->is_list() || type->is_set()) @@ -451,14 +451,14 @@ void t_netstd_generator::print_const_def_value(ostream& out, string name, t_type for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string val = render_const_value(out, name, etype, *v_iter); - out << indent() << name << ".Add(" << val << ");" << endl; + out << indent() << name << ".Add(" << val << ");" << '\n'; } } } void t_netstd_generator::print_const_constructor(ostream& out, vector consts) { - out << indent() << "static " << make_valid_csharp_identifier(program_name_).c_str() << "Constants()" << endl; + out << indent() << "static " << make_valid_csharp_identifier(program_name_).c_str() << "Constants()" << '\n'; scope_up(out); vector::iterator c_iter; @@ -494,30 +494,30 @@ bool t_netstd_generator::print_const_value(ostream& out, string name, t_type* ty if (type->is_base_type()) { string v2 = render_const_value(out, name, type, value); - out << name << " = " << v2 << ";" << endl; + out << name << " = " << v2 << ";" << '\n'; need_static_construction = false; } else if (type->is_enum()) { - out << name << " = " << type_name(type) << "." << value->get_identifier_name() << ";" << endl; + out << name << " = " << type_name(type) << "." << value->get_identifier_name() << ";" << '\n'; need_static_construction = false; } else if (type->is_struct() || type->is_xception()) { if(target_net_version >= 6) { - out << name << " = new();" << endl; + out << name << " = new();" << '\n'; } else { - out << name << " = new " << type_name(type) << "();" << endl; + out << name << " = new " << type_name(type) << "();" << '\n'; } } else if (type->is_map() || type->is_list() || type->is_set()) { if(target_net_version >= 8) { - out << name << " = [];" << endl; + out << name << " = [];" << '\n'; } else if(target_net_version >= 6) { - out << name << " = new();" << endl; + out << name << " = new();" << '\n'; } else { - out << name << " = new " << type_name(type) << "();" << endl; + out << name << " = new " << type_name(type) << "();" << '\n'; } } @@ -672,49 +672,49 @@ void t_netstd_generator::generate_extensions(ostream& out, map reset_indent(); out << autogen_comment() << netstd_type_usings() - << "using Thrift.Protocol;" << endl - << endl << endl; + << "using Thrift.Protocol;" << '\n' + << '\n' << '\n'; pragmas_and_directives(out); start_netstd_namespace(out); - out << indent() << "public static class " << make_valid_csharp_identifier(program_name_) << "Extensions" << endl; + out << indent() << "public static class " << make_valid_csharp_identifier(program_name_) << "Extensions" << '\n'; scope_up(out); bool needs_typecast = false; std::map::const_iterator iter; for( iter = types.begin(); iter != types.end(); ++iter) { - out << indent() << "public static bool Equals(this " << iter->first << " instance, object that)" << endl; + out << indent() << "public static bool Equals(this " << iter->first << " instance, object that)" << '\n'; scope_up(out); if( target_net_version >= 6) { - out << indent() << "if (that is not " << iter->first << " other) return false;" << endl; + out << indent() << "if (that is not " << iter->first << " other) return false;" << '\n'; } else { - out << indent() << "if (!(that is " << iter->first << " other)) return false;" << endl; + out << indent() << "if (!(that is " << iter->first << " other)) return false;" << '\n'; } - out << indent() << "if (ReferenceEquals(instance, other)) return true;" << endl; - out << endl; - out << indent() << "return TCollections.Equals(instance, other);" << endl; + out << indent() << "if (ReferenceEquals(instance, other)) return true;" << '\n'; + out << '\n'; + out << indent() << "return TCollections.Equals(instance, other);" << '\n'; scope_down(out); - out << endl << endl; + out << '\n' << '\n'; - out << indent() << "public static int GetHashCode(this " << iter->first << " instance)" << endl; + out << indent() << "public static int GetHashCode(this " << iter->first << " instance)" << '\n'; scope_up(out); - out << indent() << "return TCollections.GetHashCode(instance);" << endl; + out << indent() << "return TCollections.GetHashCode(instance);" << '\n'; scope_down(out); - out << endl << endl; + out << '\n' << '\n'; if(! suppress_deepcopy) { - out << indent() << "public static " << iter->first << nullable_field_suffix(iter->second) << " " << DEEP_COPY_METHOD_NAME << "(this " << iter->first << nullable_field_suffix(iter->second) << " source)" << endl; + out << indent() << "public static " << iter->first << nullable_field_suffix(iter->second) << " " << DEEP_COPY_METHOD_NAME << "(this " << iter->first << nullable_field_suffix(iter->second) << " source)" << '\n'; scope_up(out); - out << indent() << "if (source == null)" << endl; + out << indent() << "if (source == null)" << '\n'; indent_up(); - out << indent() << "return null;" << endl << endl; + out << indent() << "return null;" << '\n' << '\n'; indent_down(); string suffix(""); string tmp_instance = tmp("tmp"); - out << indent() << "var " << tmp_instance << " = new " << iter->first << "(source.Count);" << endl; + out << indent() << "var " << tmp_instance << " = new " << iter->first << "(source.Count);" << '\n'; if( iter->second->is_map()) { t_map* tmap = static_cast(iter->second); @@ -723,7 +723,7 @@ void t_netstd_generator::generate_extensions(ostream& out, map bool null_key = type_can_be_null(tmap->get_key_type()); bool null_val = type_can_be_null(tmap->get_val_type()); - out << indent() << "foreach (var pair in source)" << endl; + out << indent() << "foreach (var pair in source)" << '\n'; indent_up(); if( target_net_version >= 6) { out << indent() << tmp_instance << ".Add(pair.Key" << copy_key; @@ -742,7 +742,7 @@ void t_netstd_generator::generate_extensions(ostream& out, map out << "pair.Value" << copy_val; } } - out << ");" << endl; + out << ");" << '\n'; indent_down(); } else if( iter->second->is_set() || iter->second->is_list()) { @@ -761,7 +761,7 @@ void t_netstd_generator::generate_extensions(ostream& out, map null_elm = type_can_be_null(tlist->get_elem_type()); } - out << indent() << "foreach (var elem in source)" << endl; + out << indent() << "foreach (var elem in source)" << '\n'; indent_up(); if( target_net_version >= 6) { out << indent() << tmp_instance << ".Add(elem" << copy_elm; @@ -774,13 +774,13 @@ void t_netstd_generator::generate_extensions(ostream& out, map out << "elem" << copy_elm; } } - out << ");" << endl; + out << ");" << '\n'; indent_down(); } - out << indent() << "return " << tmp_instance << ";" << endl; + out << indent() << "return " << tmp_instance << ";" << '\n'; scope_down(out); - out << endl << endl; + out << '\n' << '\n'; } } @@ -818,7 +818,7 @@ void t_netstd_generator::generate_netstd_struct(t_struct* tstruct, bool is_excep f_struct.open(f_struct_name.c_str()); reset_indent(); - f_struct << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << endl << endl; + f_struct << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << '\n' << '\n'; pragmas_and_directives(f_struct); generate_netstd_struct_definition(f_struct, tstruct, is_exception); @@ -835,7 +835,7 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc start_netstd_namespace(out); } - out << endl; + out << '\n'; generate_netstd_doc(out, tstruct); collect_extensions_types(tstruct); @@ -843,7 +843,7 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc if ((is_serialize_enabled() || is_wcf_enabled()) && !is_exception) { - out << indent() << "[DataContract(Namespace=\"" << wcf_namespace_ << "\")]" << endl; + out << indent() << "[DataContract(Namespace=\"" << wcf_namespace_ << "\")]" << '\n'; } bool is_final = tstruct->annotations_.find("final") != tstruct->annotations_.end(); @@ -857,8 +857,8 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc out << "TException, "; } - out << "TBase" << endl - << indent() << "{" << endl; + out << "TBase" << '\n' + << indent() << "{" << '\n'; indent_up(); const vector& members = tstruct->get_members(); @@ -870,10 +870,10 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc // if the field is required, then we use auto-properties if (!field_is_required((*m_iter))) { - out << indent() << "private " << declare_field(*m_iter, false, true, "_") << endl; + out << indent() << "private " << declare_field(*m_iter, false, true, "_") << '\n'; } } - out << endl; + out << '\n'; bool has_non_required_fields = false; bool has_required_fields = false; @@ -895,19 +895,19 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc bool generate_isset = has_non_required_fields; if (generate_isset) { - out << endl; + out << '\n'; if (is_serialize_enabled() || is_wcf_enabled()) { - out << indent() << "[DataMember(Order = 1)]" << endl; + out << indent() << "[DataMember(Order = 1)]" << '\n'; } - out << indent() << "public Isset __isset;" << endl; + out << indent() << "public Isset __isset;" << '\n'; if (is_serialize_enabled() || is_wcf_enabled()) { - out << indent() << "[DataContract]" << endl; + out << indent() << "[DataContract]" << '\n'; } - out << indent() << "public struct Isset" << endl - << indent() << "{" << endl; + out << indent() << "public struct Isset" << '\n' + << indent() << "{" << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) @@ -919,18 +919,18 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc { if (is_serialize_enabled() || is_wcf_enabled()) { - out << indent() << "[DataMember]" << endl; + out << indent() << "[DataMember]" << '\n'; } - out << indent() << "public bool " << get_isset_name(normalize_name((*m_iter)->get_name())) << ";" << endl; + out << indent() << "public bool " << get_isset_name(normalize_name((*m_iter)->get_name())) << ";" << '\n'; } } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; if (generate_isset && (is_serialize_enabled() || is_wcf_enabled())) { - out << indent() << "#region XmlSerializer support" << endl << endl; + out << indent() << "#region XmlSerializer support" << '\n' << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -939,22 +939,22 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc // if it is not required, if it has a default value, we need to generate Isset if (!is_required) { - out << indent() << "public bool ShouldSerialize" << prop_name(*m_iter) << "()" << endl - << indent() << "{" << endl; + out << indent() << "public bool ShouldSerialize" << prop_name(*m_iter) << "()" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "return __isset." << get_isset_name(normalize_name((*m_iter)->get_name())) << ";" << endl; + out << indent() << "return __isset." << get_isset_name(normalize_name((*m_iter)->get_name())) << ";" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } } - out << indent() << "#endregion XmlSerializer support" << endl << endl; + out << indent() << "#endregion XmlSerializer support" << '\n' << '\n'; } } // We always want a default, no argument constructor for Reading - out << indent() << "public " << sharp_struct_name << "()" << endl - << indent() << "{" << endl; + out << indent() << "public " << sharp_struct_name << "()" << '\n' + << indent() << "{" << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) @@ -972,12 +972,12 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc { print_const_value(out, "this._" + (*m_iter)->get_name(), t, (*m_iter)->get_value(), true, true); // Optionals with defaults are marked set - out << indent() << "this.__isset." << get_isset_name(normalize_name((*m_iter)->get_name())) << " = true;" << endl; + out << indent() << "this.__isset." << get_isset_name(normalize_name((*m_iter)->get_name())) << " = true;" << '\n'; } } } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; // if we have required fields, we add that CTOR too if (has_required_fields) @@ -999,20 +999,20 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc out << type_name((*m_iter)->get_type()) << nullable_field_suffix(*m_iter) << " " << normalize_name((*m_iter)->get_name()); } } - out << ") : this()" << endl - << indent() << "{" << endl; + out << ") : this()" << '\n' + << indent() << "{" << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { if (field_is_required(*m_iter)) { - out << indent() << "this." << prop_name(*m_iter) << " = " << normalize_name((*m_iter)->get_name()) << ";" << endl; + out << indent() << "this." << prop_name(*m_iter) << " = " << normalize_name((*m_iter)->get_name()) << ";" << '\n'; } } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } // DeepCopy() @@ -1032,7 +1032,7 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc generate_netstd_struct_tostring(out, tstruct); indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; // generate a corresponding WCF fault to wrap the exception if ((is_serialize_enabled() || is_wcf_enabled()) && is_exception) @@ -1050,13 +1050,13 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc void t_netstd_generator::generate_netstd_wcffault(ostream& out, t_struct* tstruct) { - out << endl; - out << indent() << "[DataContract]" << endl; + out << '\n'; + out << indent() << "[DataContract]" << '\n'; bool is_final = tstruct->annotations_.find("final") != tstruct->annotations_.end(); - out << indent() << "public " << (is_final ? "sealed " : "") << "partial class " << type_name(tstruct,false) << "Fault" << endl - << indent() << "{" << endl; + out << indent() << "public " << (is_final ? "sealed " : "") << "partial class " << type_name(tstruct,false) << "Fault" << '\n' + << indent() << "{" << '\n'; indent_up(); const vector& members = tstruct->get_members(); @@ -1068,10 +1068,10 @@ void t_netstd_generator::generate_netstd_wcffault(ostream& out, t_struct* tstruc // if the field is required, then we use auto-properties if (!field_is_required((*m_iter))) { - out << indent() << "private " << declare_field(*m_iter, false, true, "_") << endl; + out << indent() << "private " << declare_field(*m_iter, false, true, "_") << '\n'; } } - out << endl; + out << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -1079,7 +1079,7 @@ void t_netstd_generator::generate_netstd_wcffault(ostream& out, t_struct* tstruc } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_netstd_generator::generate_netstd_deepcopy_method(ostream& out, t_struct* tstruct, std::string sharp_struct_name) @@ -1091,8 +1091,8 @@ void t_netstd_generator::generate_netstd_deepcopy_method(ostream& out, t_struct* const vector& members = tstruct->get_members(); vector::const_iterator m_iter; - out << indent() << "public " << sharp_struct_name << " " << DEEP_COPY_METHOD_NAME << "()" << endl; - out << indent() << "{" << endl; + out << indent() << "public " << sharp_struct_name << " " << DEEP_COPY_METHOD_NAME << "()" << '\n'; + out << indent() << "{" << '\n'; indent_up(); // return directly if there are only required fields @@ -1100,10 +1100,10 @@ void t_netstd_generator::generate_netstd_deepcopy_method(ostream& out, t_struct* out << indent() << "var " << tmp_instance << " = new " << sharp_struct_name << "()"; bool inline_assignment = (target_net_version >= 6); if(inline_assignment) { - out << endl << indent() << "{" << endl; + out << '\n' << indent() << "{" << '\n'; indent_up(); } else { - out << endl; + out << '\n'; } for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -1118,7 +1118,7 @@ void t_netstd_generator::generate_netstd_deepcopy_method(ostream& out, t_struct* if(inline_assignment) { if( null_allowed || (!is_required)) { // = has isset indent_down(); - out << indent() << "};" << endl; + out << indent() << "};" << '\n'; inline_assignment = false; } } @@ -1134,7 +1134,7 @@ void t_netstd_generator::generate_netstd_deepcopy_method(ostream& out, t_struct* out << "(" << type_name(ttype) << ")"; } out << "this." << prop_name(*m_iter) << copy_op; - out << (inline_assignment ? "," : ";") << endl; + out << (inline_assignment ? "," : ";") << '\n'; generate_null_check_end( out, *m_iter); if( !is_required) { @@ -1144,29 +1144,29 @@ void t_netstd_generator::generate_netstd_deepcopy_method(ostream& out, t_struct* } out << "__isset." << get_isset_name(normalize_name((*m_iter)->get_name())); out << " = this.__isset." << get_isset_name(normalize_name((*m_iter)->get_name())); - out << (inline_assignment ? "," : ";") << endl; + out << (inline_assignment ? "," : ";") << '\n'; } } if(inline_assignment) { indent_down(); - out << indent() << "};" << endl; + out << indent() << "};" << '\n'; } - out << indent() << "return " << tmp_instance << ";" << endl; + out << indent() << "return " << tmp_instance << ";" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_netstd_generator::generate_netstd_struct_reader(ostream& out, t_struct* tstruct) { - out << indent() << "public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl - << indent() << "{" << endl; + out << indent() << "public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "iprot.IncrementRecursionDepth();" << endl - << indent() << "try" << endl - << indent() << "{" << endl; + out << indent() << "iprot.IncrementRecursionDepth();" << '\n' + << indent() << "try" << '\n' + << indent() << "{" << '\n'; indent_up(); const vector& fields = tstruct->get_members(); @@ -1177,90 +1177,90 @@ void t_netstd_generator::generate_netstd_struct_reader(ostream& out, t_struct* t { if (field_is_required(*f_iter)) { - out << indent() << "bool isset_" << (*f_iter)->get_name() << " = false;" << endl; + out << indent() << "bool isset_" << (*f_iter)->get_name() << " = false;" << '\n'; } } - out << indent() << "TField field;" << endl - << indent() << "await iprot.ReadStructBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "while (true)" << endl - << indent() << "{" << endl; + out << indent() << "TField field;" << '\n' + << indent() << "await iprot.ReadStructBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "while (true)" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "field = await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "if (field.Type == TType.Stop)" << endl - << indent() << "{" << endl; + out << indent() << "field = await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "if (field.Type == TType.Stop)" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "break;" << endl; + out << indent() << "break;" << '\n'; indent_down(); - out << indent() << "}" << endl << endl - << indent() << "switch (field.ID)" << endl - << indent() << "{" << endl; + out << indent() << "}" << '\n' << '\n' + << indent() << "switch (field.ID)" << '\n' + << indent() << "{" << '\n'; indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool is_required = field_is_required(*f_iter); - out << indent() << "case " << (*f_iter)->get_key() << ":" << endl; + out << indent() << "case " << (*f_iter)->get_key() << ":" << '\n'; indent_up(); - out << indent() << "if (field.Type == " << type_to_enum((*f_iter)->get_type()) << ")" << endl - << indent() << "{" << endl; + out << indent() << "if (field.Type == " << type_to_enum((*f_iter)->get_type()) << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); generate_deserialize_field(out, *f_iter); if (is_required) { - out << indent() << "isset_" << (*f_iter)->get_name() << " = true;" << endl; + out << indent() << "isset_" << (*f_iter)->get_name() << " = true;" << '\n'; } indent_down(); - out << indent() << "}" << endl - << indent() << "else" << endl - << indent() << "{" << endl; + out << indent() << "}" << '\n' + << indent() << "else" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << '\n'; indent_down(); - out << indent() << "}" << endl - << indent() << "break;" << endl; + out << indent() << "}" << '\n' + << indent() << "break;" << '\n'; indent_down(); } - out << indent() << "default: " << endl; + out << indent() << "default: " << '\n'; indent_up(); - out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "break;" << endl; + out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "break;" << '\n'; indent_down(); indent_down(); - out << indent() << "}" << endl - << endl - << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "}" << '\n' + << '\n' + << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; indent_down(); - out << indent() << "}" << endl - << endl - << indent() << "await iprot.ReadStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "}" << '\n' + << '\n' + << indent() << "await iprot.ReadStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if (field_is_required((*f_iter))) { - out << indent() << "if (!isset_" << (*f_iter)->get_name() << ")" << endl - << indent() << "{" << endl; + out << indent() << "if (!isset_" << (*f_iter)->get_name() << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "throw new TProtocolException(TProtocolException.INVALID_DATA);" << endl; + out << indent() << "throw new TProtocolException(TProtocolException.INVALID_DATA);" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } indent_down(); - out << indent() << "}" << endl; - out << indent() << "finally" << endl - << indent() << "{" << endl; + out << indent() << "}" << '\n'; + out << indent() << "finally" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "iprot.DecrementRecursionDepth();" << endl; + out << indent() << "iprot.DecrementRecursionDepth();" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } @@ -1284,8 +1284,8 @@ void t_netstd_generator::generate_null_check_begin(ostream& out, t_field* tfield out << "__isset." << get_isset_name(normalize_name(tfield->get_name())); } - out << ")" << endl - << indent() << "{" << endl; + out << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); } } @@ -1297,19 +1297,19 @@ void t_netstd_generator::generate_null_check_end(ostream& out, t_field* tfield) if( null_allowed || (!is_required)) { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } void t_netstd_generator::generate_netstd_struct_writer(ostream& out, t_struct* tstruct) { - out << indent() << "public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl - << indent() << "{" << endl; + out << indent() << "public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "oprot.IncrementRecursionDepth();" << endl - << indent() << "try" << endl - << indent() << "{" << endl; + out << indent() << "oprot.IncrementRecursionDepth();" << '\n' + << indent() << "try" << '\n' + << indent() << "{" << '\n'; indent_up(); string name = tstruct->get_name(); @@ -1317,57 +1317,57 @@ void t_netstd_generator::generate_netstd_struct_writer(ostream& out, t_struct* t vector::const_iterator f_iter; string tmpvar = tmp("tmp"); - out << indent() << "var " << tmpvar << " = new TStruct(\"" << name << "\");" << endl - << indent() << "await oprot.WriteStructBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "var " << tmpvar << " = new TStruct(\"" << name << "\");" << '\n' + << indent() << "await oprot.WriteStructBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << '\n'; if (fields.size() > 0) { tmpvar = tmp("tmp"); if(target_net_version >= 8) { - out << indent() << "#pragma warning disable IDE0017 // simplified init" << endl; + out << indent() << "#pragma warning disable IDE0017 // simplified init" << '\n'; } - out << indent() << "var " << tmpvar << " = new TField();" << endl; + out << indent() << "var " << tmpvar << " = new TField();" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { generate_null_check_begin( out, *f_iter); - out << indent() << tmpvar << ".Name = \"" << (*f_iter)->get_name() << "\";" << endl - << indent() << tmpvar << ".Type = " << type_to_enum((*f_iter)->get_type()) << ";" << endl - << indent() << tmpvar << ".ID = " << (*f_iter)->get_key() << ";" << endl - << indent() << "await oprot.WriteFieldBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << tmpvar << ".Name = \"" << (*f_iter)->get_name() << "\";" << '\n' + << indent() << tmpvar << ".Type = " << type_to_enum((*f_iter)->get_type()) << ";" << '\n' + << indent() << tmpvar << ".ID = " << (*f_iter)->get_key() << ";" << '\n' + << indent() << "await oprot.WriteFieldBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << '\n'; generate_serialize_field(out, *f_iter); - out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; generate_null_check_end(out, *f_iter); } if(target_net_version >= 8) { - out << indent() << "#pragma warning restore IDE0017 // simplified init" << endl; + out << indent() << "#pragma warning restore IDE0017 // simplified init" << '\n'; } } - out << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; indent_down(); - out << indent() << "}" << endl - << indent() << "finally" << endl - << indent() << "{" << endl; + out << indent() << "}" << '\n' + << indent() << "finally" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "oprot.DecrementRecursionDepth();" << endl; + out << indent() << "oprot.DecrementRecursionDepth();" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_netstd_generator::generate_netstd_struct_result_writer(ostream& out, t_struct* tstruct) { - out << indent() << "public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl - << indent() << "{" << endl; + out << indent() << "public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "oprot.IncrementRecursionDepth();" << endl - << indent() << "try" << endl - << indent() << "{" << endl; + out << indent() << "oprot.IncrementRecursionDepth();" << '\n' + << indent() << "try" << '\n' + << indent() << "{" << '\n'; indent_up(); string name = tstruct->get_name(); @@ -1375,85 +1375,85 @@ void t_netstd_generator::generate_netstd_struct_result_writer(ostream& out, t_st vector::const_iterator f_iter; string tmpvar = tmp("tmp"); - out << indent() << "var " << tmpvar << " = new TStruct(\"" << name << "\");" << endl - << indent() << "await oprot.WriteStructBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "var " << tmpvar << " = new TStruct(\"" << name << "\");" << '\n' + << indent() << "await oprot.WriteStructBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << '\n'; if (fields.size() > 0) { tmpvar = tmp("tmp"); if(target_net_version >= 8) { - out << indent() << "#pragma warning disable IDE0017 // simplified init" << endl; + out << indent() << "#pragma warning disable IDE0017 // simplified init" << '\n'; } - out << indent() << "var " << tmpvar << " = new TField();" << endl; + out << indent() << "var " << tmpvar << " = new TField();" << '\n'; bool first = true; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if (first) { first = false; - out << endl << indent() << "if"; + out << '\n' << indent() << "if"; } else { out << indent() << "else if"; } - out << "(this.__isset." << get_isset_name(normalize_name((*f_iter)->get_name())) << ")" << endl - << indent() << "{" << endl; + out << "(this.__isset." << get_isset_name(normalize_name((*f_iter)->get_name())) << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); bool null_allowed = type_can_be_null((*f_iter)->get_type()); if (null_allowed) { - out << indent() << "if (" << prop_name(*f_iter) << " != null)" << endl - << indent() << "{" << endl; + out << indent() << "if (" << prop_name(*f_iter) << " != null)" << '\n' + << indent() << "{" << '\n'; indent_up(); } - out << indent() << tmpvar << ".Name = \"" << prop_name(*f_iter) << "\";" << endl - << indent() << tmpvar << ".Type = " << type_to_enum((*f_iter)->get_type()) << ";" << endl - << indent() << tmpvar << ".ID = " << (*f_iter)->get_key() << ";" << endl - << indent() << "await oprot.WriteFieldBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << tmpvar << ".Name = \"" << prop_name(*f_iter) << "\";" << '\n' + << indent() << tmpvar << ".Type = " << type_to_enum((*f_iter)->get_type()) << ";" << '\n' + << indent() << tmpvar << ".ID = " << (*f_iter)->get_key() << ";" << '\n' + << indent() << "await oprot.WriteFieldBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << '\n'; generate_serialize_field(out, *f_iter); - out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; if (null_allowed) { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } if(target_net_version >= 8) { - out << indent() << "#pragma warning restore IDE0017 // simplified init" << endl; + out << indent() << "#pragma warning restore IDE0017 // simplified init" << '\n'; } } - out << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; indent_down(); - out << indent() << "}" << endl - << indent() << "finally" << endl - << indent() << "{" << endl; + out << indent() << "}" << '\n' + << indent() << "finally" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "oprot.DecrementRecursionDepth();" << endl; + out << indent() << "oprot.DecrementRecursionDepth();" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_netstd_generator::generate_netstd_struct_tostring(ostream& out, t_struct* tstruct) { string tmpvar = tmp("tmp"); - out << indent() << "public override string ToString()" << endl - << indent() << "{" << endl; + out << indent() << "public override string ToString()" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "var " << tmpvar << " = new StringBuilder(\"" << tstruct->get_name() << "(\");" << endl; + out << indent() << "var " << tmpvar << " = new StringBuilder(\"" << tstruct->get_name() << "(\");" << '\n'; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -1464,7 +1464,7 @@ void t_netstd_generator::generate_netstd_struct_tostring(ostream& out, t_struct* { if (!field_is_required((*f_iter))) { - out << indent() << "int " << tmp_count.c_str() << " = 0;" << endl; + out << indent() << "int " << tmp_count.c_str() << " = 0;" << '\n'; useFirstFlag = true; } break; @@ -1479,15 +1479,15 @@ void t_netstd_generator::generate_netstd_struct_tostring(ostream& out, t_struct* if (useFirstFlag && (!had_required)) { - out << indent() << "if(0 < " << tmp_count.c_str() << (is_required ? "" : "++") << ") { " << tmpvar << ".Append(\", \"); }" << endl; - out << indent() << tmpvar << ".Append(\"" << prop_name(*f_iter) << ": \");" << endl; + out << indent() << "if(0 < " << tmp_count.c_str() << (is_required ? "" : "++") << ") { " << tmpvar << ".Append(\", \"); }" << '\n'; + out << indent() << tmpvar << ".Append(\"" << prop_name(*f_iter) << ": \");" << '\n'; } else { - out << indent() << tmpvar << ".Append(\", " << prop_name(*f_iter) << ": \");" << endl; + out << indent() << tmpvar << ".Append(\", " << prop_name(*f_iter) << ": \");" << '\n'; } - out << indent() << prop_name(*f_iter) << ".ToString(" << tmpvar << ");" << endl; + out << indent() << prop_name(*f_iter) << ".ToString(" << tmpvar << ");" << '\n'; generate_null_check_end(out, *f_iter); if (is_required) { @@ -1495,10 +1495,10 @@ void t_netstd_generator::generate_netstd_struct_tostring(ostream& out, t_struct* } } - out << indent() << tmpvar << ".Append(')');" << endl - << indent() << "return " << tmpvar << ".ToString();" << endl; + out << indent() << tmpvar << ".Append(')');" << '\n' + << indent() << "return " << tmpvar << ".ToString();" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } void t_netstd_generator::generate_netstd_union(t_struct* tunion) @@ -1511,7 +1511,7 @@ void t_netstd_generator::generate_netstd_union(t_struct* tunion) f_union.open(f_union_name.c_str()); reset_indent(); - f_union << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << endl << endl; + f_union << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << '\n' << '\n'; pragmas_and_directives(f_union); generate_netstd_union_definition(f_union, tunion); @@ -1526,75 +1526,75 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct // Let's define the class first start_netstd_namespace(out); - out << indent() << "public abstract partial class " << normalize_name(tunion->get_name()) << " : TUnionBase" << endl; - out << indent() << "{" << endl; + out << indent() << "public abstract partial class " << normalize_name(tunion->get_name()) << " : TUnionBase" << '\n'; + out << indent() << "{" << '\n'; indent_up(); - out << indent() << "public abstract global::System.Threading.Tasks.Task WriteAsync(TProtocol tProtocol, CancellationToken " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "public readonly int Isset;" << endl - << indent() << "public abstract object" << nullable_suffix() <<" Data { get; }" << endl - << indent() << "protected " << normalize_name(tunion->get_name()) << "(int isset)" << endl - << indent() << "{" << endl; + out << indent() << "public abstract global::System.Threading.Tasks.Task WriteAsync(TProtocol tProtocol, CancellationToken " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "public readonly int Isset;" << '\n' + << indent() << "public abstract object" << nullable_suffix() <<" Data { get; }" << '\n' + << indent() << "protected " << normalize_name(tunion->get_name()) << "(int isset)" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "Isset = isset;" << endl; + out << indent() << "Isset = isset;" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; const vector& fields = tunion->get_members(); vector::const_iterator f_iter; - out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << endl; + out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << '\n'; scope_up(out); if( target_net_version >= 6) { - out << indent() << "if (that is not " << tunion->get_name() << " other) return false;" << endl; + out << indent() << "if (that is not " << tunion->get_name() << " other) return false;" << '\n'; } else { - out << indent() << "if (!(that is " << tunion->get_name() << " other)) return false;" << endl; + out << indent() << "if (!(that is " << tunion->get_name() << " other)) return false;" << '\n'; } - out << indent() << "if (ReferenceEquals(this, other)) return true;" << endl; - out << endl; - out << indent() << "if(this.Isset != other.Isset) return false;" << endl; - out << endl; + out << indent() << "if (ReferenceEquals(this, other)) return true;" << '\n'; + out << '\n'; + out << indent() << "if(this.Isset != other.Isset) return false;" << '\n'; + out << '\n'; if(target_net_version >= 6) { - out << indent() << "return Isset switch" << endl; + out << indent() << "return Isset switch" << '\n'; scope_up(out); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool needs_typecast = false; string suffix(""); get_deep_copy_method_call((*f_iter)->get_type(), false, needs_typecast, suffix); - out << indent() << (*f_iter)->get_key() << " => Equals(As_" << (*f_iter)->get_name() << ", other.As_" << (*f_iter)->get_name() << ")," << endl; + out << indent() << (*f_iter)->get_key() << " => Equals(As_" << (*f_iter)->get_name() << ", other.As_" << (*f_iter)->get_name() << ")," << '\n'; } - out << indent() << "_ => true," << endl; + out << indent() << "_ => true," << '\n'; indent_down(); - out << indent() << "};" << endl; + out << indent() << "};" << '\n'; } else { - out << indent() << "switch (Isset)" << endl; + out << indent() << "switch (Isset)" << '\n'; scope_up(out); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool needs_typecast = false; string suffix(""); get_deep_copy_method_call((*f_iter)->get_type(), false, needs_typecast, suffix); - out << indent() << "case " << (*f_iter)->get_key() << ":" << endl; + out << indent() << "case " << (*f_iter)->get_key() << ":" << '\n'; indent_up(); - out << indent() << "return Equals(As_" << (*f_iter)->get_name() << ", other.As_" << (*f_iter)->get_name() << ");" << endl; + out << indent() << "return Equals(As_" << (*f_iter)->get_name() << ", other.As_" << (*f_iter)->get_name() << ");" << '\n'; indent_down(); } - out << indent() << "default:" << endl; + out << indent() << "default:" << '\n'; indent_up(); - out << indent() << "return true;" << endl; + out << indent() << "return true;" << '\n'; indent_down(); scope_down(out); } scope_down(out); - out << endl; + out << '\n'; - out << indent() << "public override int GetHashCode()" << endl; - out << indent() << "{" << endl; + out << indent() << "public override int GetHashCode()" << '\n'; + out << indent() << "{" << '\n'; indent_up(); if(target_net_version >= 6) { - out << indent() << "return Isset switch" << endl; - out << indent() << "{" << endl; + out << indent() << "return Isset switch" << '\n'; + out << indent() << "{" << '\n'; indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { @@ -1603,108 +1603,108 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct if( null_coalesce.size() > 0) { out << " ?? 0"; } - out << "," << endl; + out << "," << '\n'; } - out << indent() << "_ => (new ___undefined()).GetHashCode()" << endl; + out << indent() << "_ => (new ___undefined()).GetHashCode()" << '\n'; indent_down(); - out << indent() << "};" << endl; + out << indent() << "};" << '\n'; } else { - out << indent() << "switch (Isset)" << endl; - out << indent() << "{" << endl; + out << indent() << "switch (Isset)" << '\n'; + out << indent() << "{" << '\n'; indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { string null_coalesce(is_nullable_type((*f_iter)->get_type()) ? "?" : ""); - out << indent() << "case " << (*f_iter)->get_key() << ":" << endl; + out << indent() << "case " << (*f_iter)->get_key() << ":" << '\n'; indent_up(); out << indent() << "return As_" << (*f_iter)->get_name() << null_coalesce << ".GetHashCode()"; if( null_coalesce.size() > 0) { out << " ?? 0"; } - out << ";" << endl; + out << ";" << '\n'; indent_down(); } - out << indent() << "default:" << endl; + out << indent() << "default:" << '\n'; indent_up(); - out << indent() << "return (new ___undefined()).GetHashCode();" << endl; + out << indent() << "return (new ___undefined()).GetHashCode();" << '\n'; indent_down(); indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; if( ! suppress_deepcopy) { - out << indent() << "public " << tunion->get_name() << " " << DEEP_COPY_METHOD_NAME << "()" << endl; - out << indent() << "{" << endl; + out << indent() << "public " << tunion->get_name() << " " << DEEP_COPY_METHOD_NAME << "()" << '\n'; + out << indent() << "{" << '\n'; indent_up(); if(target_net_version >= 6) { - out << indent() << "return Isset switch" << endl; - out << indent() << "{" << endl; + out << indent() << "return Isset switch" << '\n'; + out << indent() << "{" << '\n'; indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool needs_typecast = false; string suffix(""); string copy_op = get_deep_copy_method_call((*f_iter)->get_type(), false, needs_typecast, suffix); - out << indent() << (*f_iter)->get_key() << " => new " << (*f_iter)->get_name() << "(As_" << (*f_iter)->get_name() << suffix << copy_op << ")," << endl; + out << indent() << (*f_iter)->get_key() << " => new " << (*f_iter)->get_name() << "(As_" << (*f_iter)->get_name() << suffix << copy_op << ")," << '\n'; } - out << indent() << "_ => new ___undefined()" << endl; + out << indent() << "_ => new ___undefined()" << '\n'; indent_down(); - out << indent() << "};" << endl; + out << indent() << "};" << '\n'; } else { - out << indent() << "switch (Isset)" << endl; - out << indent() << "{" << endl; + out << indent() << "switch (Isset)" << '\n'; + out << indent() << "{" << '\n'; indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool needs_typecast = false; string suffix(""); string copy_op = get_deep_copy_method_call((*f_iter)->get_type(), false, needs_typecast, suffix); - out << indent() << "case " << (*f_iter)->get_key() << ":" << endl; + out << indent() << "case " << (*f_iter)->get_key() << ":" << '\n'; indent_up(); - out << indent() << "return new " << (*f_iter)->get_name() << "(As_" << (*f_iter)->get_name() << suffix << copy_op << ");" << endl; + out << indent() << "return new " << (*f_iter)->get_name() << "(As_" << (*f_iter)->get_name() << suffix << copy_op << ");" << '\n'; indent_down(); } - out << indent() << "default:" << endl; + out << indent() << "default:" << '\n'; indent_up(); - out << indent() << "return new ___undefined();" << endl; + out << indent() << "return new ___undefined();" << '\n'; indent_down(); indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } - out << indent() << "public class ___undefined : " << tunion->get_name() << endl; - out << indent() << "{" << endl; + out << indent() << "public class ___undefined : " << tunion->get_name() << '\n'; + out << indent() << "{" << '\n'; indent_up(); - out << indent() << "public override object" << nullable_suffix() <<" Data { get { return null; } }" << endl - << indent() << "public ___undefined() : base(0) {}" << endl << endl; + out << indent() << "public override object" << nullable_suffix() <<" Data { get { return null; } }" << '\n' + << indent() << "public ___undefined() : base(0) {}" << '\n' << '\n'; if( ! suppress_deepcopy) { - out << indent() << "public new ___undefined " << DEEP_COPY_METHOD_NAME << "()" << endl; - out << indent() << "{" << endl; + out << indent() << "public new ___undefined " << DEEP_COPY_METHOD_NAME << "()" << '\n'; + out << indent() << "{" << '\n'; indent_up(); - out << indent() << "return new ___undefined();" << endl; + out << indent() << "return new ___undefined();" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } t_struct undefined_struct(program_,"___undefined"); generate_netstd_struct_equals(out, &undefined_struct); generate_netstd_struct_hashcode(out, &undefined_struct); - out << indent() << "public override global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl - << indent() << "{" << endl; + out << indent() << "public override global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "throw new TProtocolException( TProtocolException.INVALID_DATA, \"Cannot persist an union type which is not set.\");" << endl; + out << indent() << "throw new TProtocolException( TProtocolException.INVALID_DATA, \"Cannot persist an union type which is not set.\");" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { @@ -1714,128 +1714,128 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct generate_netstd_union_reader(out, tunion); indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; end_netstd_namespace(out); } void t_netstd_generator::generate_netstd_union_class(ostream& out, t_struct* tunion, t_field* tfield) { - out << indent() << "public " << type_name(tfield->get_type()) << nullable_field_suffix(tfield) << " As_" << tfield->get_name() << endl; - out << indent() << "{" << endl; + out << indent() << "public " << type_name(tfield->get_type()) << nullable_field_suffix(tfield) << " As_" << tfield->get_name() << '\n'; + out << indent() << "{" << '\n'; indent_up(); - out << indent() << "get" << endl; - out << indent() << "{" << endl; + out << indent() << "get" << '\n'; + out << indent() << "{" << '\n'; indent_up(); out << indent() << "return (" << tfield->get_key() << " == Isset) && (Data != null)" << " ? (" << type_name(tfield->get_type()) << nullable_field_suffix(tfield) << ")Data" << " : default" << (target_net_version >= 6 ? "" : ("(" + type_name(tfield->get_type()) + ")")) - << ";" << endl; + << ";" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl - << endl; + out << indent() << "}" << '\n' + << '\n'; - out << indent() << "public class " << normalize_name(tfield->get_name()) << " : " << normalize_name(tunion->get_name()) << endl; - out << indent() << "{" << endl; + out << indent() << "public class " << normalize_name(tfield->get_name()) << " : " << normalize_name(tunion->get_name()) << '\n'; + out << indent() << "{" << '\n'; indent_up(); - out << indent() << "private readonly " << type_name(tfield->get_type()) << " _data;" << endl - << indent() << "public override object" << nullable_suffix() <<" Data { get { return _data; } }" << endl - << indent() << "public " << normalize_name(tfield->get_name()) << "(" << type_name(tfield->get_type()) << " data) : base("<< tfield->get_key() <<")" << endl - << indent() << "{" << endl; + out << indent() << "private readonly " << type_name(tfield->get_type()) << " _data;" << '\n' + << indent() << "public override object" << nullable_suffix() <<" Data { get { return _data; } }" << '\n' + << indent() << "public " << normalize_name(tfield->get_name()) << "(" << type_name(tfield->get_type()) << " data) : base("<< tfield->get_key() <<")" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "this._data = data;" << endl; + out << indent() << "this._data = data;" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; if( ! suppress_deepcopy) { - out << indent() << "public new " << normalize_name(tfield->get_name()) << " " << DEEP_COPY_METHOD_NAME << "()" << endl; - out << indent() << "{" << endl; + out << indent() << "public new " << normalize_name(tfield->get_name()) << " " << DEEP_COPY_METHOD_NAME << "()" << '\n'; + out << indent() << "{" << '\n'; indent_up(); bool needs_typecast = false; string suffix(""); string copy_op = get_deep_copy_method_call(tfield->get_type(), true, needs_typecast, suffix); - out << indent() << "return new " << normalize_name(tfield->get_name()) << "(_data" << copy_op << ");" << endl; + out << indent() << "return new " << normalize_name(tfield->get_name()) << "(_data" << copy_op << ");" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } - out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << endl; - out << indent() << "{" << endl; + out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << '\n'; + out << indent() << "{" << '\n'; indent_up(); if(target_net_version >= 6) { - out << indent() << "if (that is not " << tunion->get_name() << " other) return false;" << endl; + out << indent() << "if (that is not " << tunion->get_name() << " other) return false;" << '\n'; } else { - out << indent() << "if (!(that is " << tunion->get_name() << " other)) return false;" << endl; + out << indent() << "if (!(that is " << tunion->get_name() << " other)) return false;" << '\n'; } - out << indent() << "if (ReferenceEquals(this, other)) return true;" << endl; - out << endl; - out << indent() << "return Equals( _data, other.As_" << tfield->get_name() << ");" << endl; + out << indent() << "if (ReferenceEquals(this, other)) return true;" << '\n'; + out << '\n'; + out << indent() << "return Equals( _data, other.As_" << tfield->get_name() << ");" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; - out << indent() << "public override int GetHashCode()" << endl; - out << indent() << "{" << endl; + out << indent() << "public override int GetHashCode()" << '\n'; + out << indent() << "{" << '\n'; indent_up(); - out << indent() << "return _data.GetHashCode();" << endl; + out << indent() << "return _data.GetHashCode();" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; - out << indent() << "public override async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ") {" << endl; + out << indent() << "public override async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ") {" << '\n'; indent_up(); - out << indent() << "oprot.IncrementRecursionDepth();" << endl - << indent() << "try" << endl - << indent() << "{" << endl; + out << indent() << "oprot.IncrementRecursionDepth();" << '\n' + << indent() << "try" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "var struc = new TStruct(\"" << tunion->get_name() << "\");" << endl - << indent() << "await oprot.WriteStructBeginAsync(struc, " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "var struc = new TStruct(\"" << tunion->get_name() << "\");" << '\n' + << indent() << "await oprot.WriteStructBeginAsync(struc, " << CANCELLATION_TOKEN_NAME << ");" << '\n'; - out << indent() << "var field = new TField()" << endl; - out << indent() << "{" << endl; + out << indent() << "var field = new TField()" << '\n'; + out << indent() << "{" << '\n'; indent_up(); - out << indent() << "Name = \"" << tfield->get_name() << "\"," << endl - << indent() << "Type = " << type_to_enum(tfield->get_type()) << "," << endl - << indent() << "ID = " << tfield->get_key() << endl; + out << indent() << "Name = \"" << tfield->get_name() << "\"," << '\n' + << indent() << "Type = " << type_to_enum(tfield->get_type()) << "," << '\n' + << indent() << "ID = " << tfield->get_key() << '\n'; indent_down(); - out << indent() << "};" << endl; - out << indent() << "await oprot.WriteFieldBeginAsync(field, " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "};" << '\n'; + out << indent() << "await oprot.WriteFieldBeginAsync(field, " << CANCELLATION_TOKEN_NAME << ");" << '\n'; generate_serialize_field(out, tfield, "_data", true, false); - out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; indent_down(); - out << indent() << "}" << endl - << indent() << "finally" << endl - << indent() << "{" << endl; + out << indent() << "}" << '\n' + << indent() << "finally" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "oprot.DecrementRecursionDepth();" << endl; + out << indent() << "oprot.DecrementRecursionDepth();" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_netstd_generator::generate_netstd_struct_equals(ostream& out, t_struct* tstruct) { - out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << endl - << indent() << "{" << endl; + out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << '\n' + << indent() << "{" << '\n'; indent_up(); if(target_net_version >= 6) { - out << indent() << "if (that is not " << type_name(tstruct,false) << " other) return false;" << endl; + out << indent() << "if (that is not " << type_name(tstruct,false) << " other) return false;" << '\n'; } else { - out << indent() << "if (!(that is " << type_name(tstruct,false) << " other)) return false;" << endl; + out << indent() << "if (!(that is " << type_name(tstruct,false) << " other)) return false;" << '\n'; } - out << indent() << "if (ReferenceEquals(this, other)) return true;" << endl; + out << indent() << "if (ReferenceEquals(this, other)) return true;" << '\n'; const vector& fields = tstruct->get_members(); @@ -1853,7 +1853,7 @@ void t_netstd_generator::generate_netstd_struct_equals(ostream& out, t_struct* t } else { - out << endl; + out << '\n'; out << indent() << "&& "; } if (!field_is_required((*f_iter))) @@ -1879,25 +1879,25 @@ void t_netstd_generator::generate_netstd_struct_equals(ostream& out, t_struct* t } if (first) { - out << indent() << "return true;" << endl; + out << indent() << "return true;" << '\n'; } else { - out << ";" << endl; + out << ";" << '\n'; indent_down(); } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_netstd_generator::generate_netstd_struct_hashcode(ostream& out, t_struct* tstruct) { - out << indent() << "public override int GetHashCode() {" << endl; + out << indent() << "public override int GetHashCode() {" << '\n'; indent_up(); - out << indent() << "int hashcode = 157;" << endl; - out << indent() << "unchecked {" << endl; + out << indent() << "int hashcode = 157;" << '\n'; + out << indent() << "unchecked {" << '\n'; indent_up(); const vector& fields = tstruct->get_members(); @@ -1915,17 +1915,17 @@ void t_netstd_generator::generate_netstd_struct_hashcode(ostream& out, t_struct* else { out << prop_name(*f_iter) << ".GetHashCode()"; } - out << ";" << endl; + out << ";" << '\n'; generate_null_check_end(out, *f_iter); } indent_down(); - out << indent() << "}" << endl; - out << indent() << "return hashcode;" << endl; + out << indent() << "}" << '\n'; + out << indent() << "return hashcode;" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_netstd_generator::generate_service(t_service* tservice) @@ -1937,13 +1937,13 @@ void t_netstd_generator::generate_service(t_service* tservice) f_service.open(f_service_name.c_str()); reset_indent(); - f_service << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << endl << endl; + f_service << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << '\n' << '\n'; pragmas_and_directives(f_service); start_netstd_namespace(f_service); - f_service << indent() << "public partial class " << normalize_name(service_name_) << endl - << indent() << "{" << endl; + f_service << indent() << "public partial class " << normalize_name(service_name_) << '\n' + << indent() << "{" << '\n'; indent_up(); generate_service_interface(f_service, tservice); @@ -1952,7 +1952,7 @@ void t_netstd_generator::generate_service(t_service* tservice) generate_service_helpers(f_service, tservice); indent_down(); - f_service << indent() << "}" << endl; + f_service << indent() << "}" << '\n'; end_netstd_namespace(f_service); f_service.close(); @@ -1970,18 +1970,18 @@ void t_netstd_generator::generate_service_interface(ostream& out, t_service* tse extends_iface = " : " + extends + ".IAsync"; } - //out << endl << endl; + //out << '\n' << '\n'; generate_netstd_doc(out, tservice); if (is_wcf_enabled()) { - out << indent() << "[ServiceContract(Namespace=\"" << wcf_namespace_ << "\")]" << endl; + out << indent() << "[ServiceContract(Namespace=\"" << wcf_namespace_ << "\")]" << '\n'; } prepare_member_name_mapping(tservice); - out << indent() << "public interface IAsync" << extends_iface << endl - << indent() << "{" << endl; + out << indent() << "public interface IAsync" << extends_iface << '\n' + << indent() << "{" << '\n'; indent_up(); vector functions = tservice->get_functions(); @@ -1993,21 +1993,21 @@ void t_netstd_generator::generate_service_interface(ostream& out, t_service* tse // if we're using WCF, add the corresponding attributes if (is_wcf_enabled()) { - out << indent() << "[OperationContract]" << endl; + out << indent() << "[OperationContract]" << '\n'; const vector& xceptions = (*f_iter)->get_xceptions()->get_members(); vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { - out << indent() << "[FaultContract(typeof(" + type_name((*x_iter)->get_type()) + "Fault))]" << endl; + out << indent() << "[FaultContract(typeof(" + type_name((*x_iter)->get_type()) + "Fault))]" << '\n'; } } generate_deprecation_attribute(out, *f_iter); - out << indent() << function_signature_async(*f_iter) << ";" << endl << endl; + out << indent() << function_signature_async(*f_iter) << ";" << '\n' << '\n'; } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; cleanup_member_name_mapping(tservice); } @@ -2020,7 +2020,7 @@ void t_netstd_generator::generate_deprecation_attribute(ostream& out, t_function if ((iter->second.back().length() > 0) && (iter->second.back() != "1")) { out << "(" << make_csharp_string_literal(iter->second.back()) << ")"; } - out << "]" << endl; + out << "]" << '\n'; } } @@ -2030,8 +2030,8 @@ void t_netstd_generator::generate_service_helpers(ostream& out, t_service* tserv vector::iterator f_iter; prepare_member_name_mapping(tservice); - out << indent() << "public class InternalStructs" << endl; - out << indent() << "{" << endl; + out << indent() << "public class InternalStructs" << '\n'; + out << indent() << "{" << '\n'; indent_up(); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) @@ -2043,7 +2043,7 @@ void t_netstd_generator::generate_service_helpers(ostream& out, t_service* tserv } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; cleanup_member_name_mapping(tservice); } @@ -2061,22 +2061,22 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi extends_client = "TBaseClient, IDisposable, "; } - out << endl; + out << '\n'; generate_netstd_doc(out, tservice); prepare_member_name_mapping(tservice); - out << indent() << "public class Client : " << extends_client << "IAsync" << endl - << indent() << "{" << endl; + out << indent() << "public class Client : " << extends_client << "IAsync" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "public Client(TProtocol protocol) : this(protocol, protocol)" << endl - << indent() << "{" << endl - << indent() << "}" << endl - << endl - << indent() << "public Client(TProtocol inputProtocol, TProtocol outputProtocol) : base(inputProtocol, outputProtocol)" << endl - << indent() << "{" << endl - << indent() << "}" << endl - << endl; + out << indent() << "public Client(TProtocol protocol) : this(protocol, protocol)" << '\n' + << indent() << "{" << '\n' + << indent() << "}" << '\n' + << '\n' + << indent() << "public Client(TProtocol inputProtocol, TProtocol outputProtocol) : base(inputProtocol, outputProtocol)" << '\n' + << indent() << "{" << '\n' + << indent() << "}" << '\n' + << '\n'; vector functions = tservice->get_functions(); vector::const_iterator functions_iterator; @@ -2088,26 +2088,26 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi // async generate_deprecation_attribute(out, *functions_iterator); - out << indent() << "public async " << function_signature_async(*functions_iterator, "") << endl - << indent() << "{" << endl; + out << indent() << "public async " << function_signature_async(*functions_iterator, "") << '\n' + << indent() << "{" << '\n'; indent_up(); out << indent() << "await send_" << function_name << "("; string call_args = argument_list((*functions_iterator)->get_arglist(),false); if(! call_args.empty()) { out << call_args << ", "; } - out << CANCELLATION_TOKEN_NAME << ");" << endl; + out << CANCELLATION_TOKEN_NAME << ");" << '\n'; if(! (*functions_iterator)->is_oneway()) { out << indent() << ((*functions_iterator)->get_returntype()->is_void() ? "" : "return ") - << "await recv_" << function_name << "(" << CANCELLATION_TOKEN_NAME << ");" << endl; + << "await recv_" << function_name << "(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; // async send generate_deprecation_attribute(out, *functions_iterator); - out << indent() << "public async " << function_signature_async(*functions_iterator, "send_", MODE_NO_RETURN) << endl - << indent() << "{" << endl; + out << indent() << "public async " << function_signature_async(*functions_iterator, "send_", MODE_NO_RETURN) << '\n' + << indent() << "{" << '\n'; indent_up(); string tmpvar = tmp("tmp"); @@ -2115,9 +2115,9 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi out << indent() << "await OutputProtocol.WriteMessageBeginAsync(new TMessage(\"" << raw_func_name << "\", TMessageType." << ((*functions_iterator)->is_oneway() ? "Oneway" : "Call") - << ", SeqId), " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << endl - << indent() << "var " << tmpvar << " = new InternalStructs." << argsname << "() {" << endl; + << ", SeqId), " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << '\n' + << indent() << "var " << tmpvar << " = new InternalStructs." << argsname << "() {" << '\n'; indent_up(); t_struct* arg_struct = (*functions_iterator)->get_arglist(); @@ -2128,27 +2128,27 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { - out << indent() << prop_name(*fld_iter) << " = " << normalize_name((*fld_iter)->get_name(),true) << "," << endl; + out << indent() << prop_name(*fld_iter) << " = " << normalize_name((*fld_iter)->get_name(),true) << "," << '\n'; } indent_down(); - out << indent() << "};" << endl; + out << indent() << "};" << '\n'; - out << indent() << endl - << indent() << "await " << tmpvar << ".WriteAsync(OutputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await OutputProtocol.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await OutputProtocol.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << '\n' + << indent() << "await " << tmpvar << ".WriteAsync(OutputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await OutputProtocol.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await OutputProtocol.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; if (!(*functions_iterator)->is_oneway()) { // async recv generate_deprecation_attribute(out, *functions_iterator); - out << indent() << "public async " << function_signature_async(*functions_iterator, "recv_", MODE_NO_ARGS) << endl - << indent() << "{" << endl; + out << indent() << "public async " << function_signature_async(*functions_iterator, "recv_", MODE_NO_ARGS) << '\n' + << indent() << "{" << '\n'; indent_up(); string resultname = (*functions_iterator)->get_name() + "_result"; @@ -2158,64 +2158,64 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi prepare_member_name_mapping(xs, xs->get_members(), resultname); tmpvar = tmp("tmp"); - out << indent() << endl - << indent() << "var " << tmpvar << " = await InputProtocol.ReadMessageBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "if (" << tmpvar << ".Type == TMessageType.Exception)" << endl - << indent() << "{" << endl; + out << indent() << '\n' + << indent() << "var " << tmpvar << " = await InputProtocol.ReadMessageBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "if (" << tmpvar << ".Type == TMessageType.Exception)" << '\n' + << indent() << "{" << '\n'; indent_up(); tmpvar = tmp("tmp"); - out << indent() << "var " << tmpvar << " = await TApplicationException.ReadAsync(InputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await InputProtocol.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "throw " << tmpvar << ";" << endl; + out << indent() << "var " << tmpvar << " = await TApplicationException.ReadAsync(InputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await InputProtocol.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "throw " << tmpvar << ";" << '\n'; indent_down(); tmpvar = tmp("tmp"); - out << indent() << "}" << endl - << endl - << indent() << "var " << tmpvar << " = new InternalStructs." << resultname << "();" << endl - << indent() << "await " << tmpvar << ".ReadAsync(InputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await InputProtocol.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "}" << '\n' + << '\n' + << indent() << "var " << tmpvar << " = new InternalStructs." << resultname << "();" << '\n' + << indent() << "await " << tmpvar << ".ReadAsync(InputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await InputProtocol.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; if (!(*functions_iterator)->get_returntype()->is_void()) { - out << indent() << "if (" << tmpvar << ".__isset.success)" << endl - << indent() << "{" << endl; + out << indent() << "if (" << tmpvar << ".__isset.success)" << '\n' + << indent() << "{" << '\n'; indent_up(); string nullable_value = nullable_value_access((*functions_iterator)->get_returntype()); - out << indent() << "return " << tmpvar << ".Success" << nullable_value << ";" << endl; + out << indent() << "return " << tmpvar << ".Success" << nullable_value << ";" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } const vector& xceptions = xs->get_members(); vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { - out << indent() << "if (" << tmpvar << ".__isset." << get_isset_name(normalize_name((*x_iter)->get_name())) << ")" << endl - << indent() << "{" << endl; + out << indent() << "if (" << tmpvar << ".__isset." << get_isset_name(normalize_name((*x_iter)->get_name())) << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "throw " << tmpvar << "." << prop_name(*x_iter) << nullable_value_access((*x_iter)->get_type()) << ";" << endl; + out << indent() << "throw " << tmpvar << "." << prop_name(*x_iter) << nullable_value_access((*x_iter)->get_type()) << ";" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } if (!(*functions_iterator)->get_returntype()->is_void()) { out << indent() << "throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, \"" - << function_name << " failed: unknown result\");" << endl; + << function_name << " failed: unknown result\");" << '\n'; } cleanup_member_name_mapping(xs); indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } cleanup_member_name_mapping(arg_struct); } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; cleanup_member_name_mapping(tservice); } @@ -2233,14 +2233,14 @@ void t_netstd_generator::generate_service_server(ostream& out, t_service* tservi } prepare_member_name_mapping(tservice); - out << indent() << "public class AsyncProcessor : " << extends_processor << "ITAsyncProcessor" << endl - << indent() << "{" << endl; + out << indent() << "public class AsyncProcessor : " << extends_processor << "ITAsyncProcessor" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "private readonly IAsync _iAsync;" << endl - << indent() << "private readonly ILogger" << nullable_suffix() << " _logger;" << endl - << endl + out << indent() << "private readonly IAsync _iAsync;" << '\n' + << indent() << "private readonly ILogger" << nullable_suffix() << " _logger;" << '\n' + << '\n' << indent() << "public AsyncProcessor(IAsync iAsync, ILogger" << nullable_suffix() << " logger = default)"; if (!extends.empty()) @@ -2248,101 +2248,101 @@ void t_netstd_generator::generate_service_server(ostream& out, t_service* tservi out << " : base(iAsync)"; } - out << endl - << indent() << "{" << endl; + out << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "_iAsync = iAsync ?? throw new ArgumentNullException(nameof(iAsync));" << endl; - out << indent() << "_logger = logger;" << endl; + out << indent() << "_iAsync = iAsync ?? throw new ArgumentNullException(nameof(iAsync));" << '\n'; + out << indent() << "_logger = logger;" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { string raw_func_name = (*f_iter)->get_name(); - out << indent() << "processMap_[\"" << raw_func_name << "\"] = " << raw_func_name << "_ProcessAsync;" << endl; + out << indent() << "processMap_[\"" << raw_func_name << "\"] = " << raw_func_name << "_ProcessAsync;" << '\n'; } indent_down(); - out << indent() << "}" << endl - << endl; + out << indent() << "}" << '\n' + << '\n'; if (extends.empty()) { - out << indent() << "protected delegate global::System.Threading.Tasks.Task ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "protected delegate global::System.Threading.Tasks.Task ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ");" << '\n'; } if (extends.empty()) { out << indent() << "protected Dictionary processMap_ = "; if(target_net_version >= 8) { - out << "[];" << endl; + out << "[];" << '\n'; } else if(target_net_version >= 6) { - out << "new();" << endl; + out << "new();" << '\n'; } else { - out << "new Dictionary();" << endl; + out << "new Dictionary();" << '\n'; } } - out << endl; + out << '\n'; if (extends.empty()) { - out << indent() << "public async Task ProcessAsync(TProtocol iprot, TProtocol oprot)" << endl - << indent() << "{" << endl; + out << indent() << "public async Task ProcessAsync(TProtocol iprot, TProtocol oprot)" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "return await ProcessAsync(iprot, oprot, CancellationToken.None);" << endl; + out << indent() << "return await ProcessAsync(iprot, oprot, CancellationToken.None);" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; - out << indent() << "public async Task ProcessAsync(TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl; + out << indent() << "public async Task ProcessAsync(TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n'; } else { - out << indent() << "public new async Task ProcessAsync(TProtocol iprot, TProtocol oprot)" << endl - << indent() << "{" << endl; + out << indent() << "public new async Task ProcessAsync(TProtocol iprot, TProtocol oprot)" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "return await ProcessAsync(iprot, oprot, CancellationToken.None);" << endl; + out << indent() << "return await ProcessAsync(iprot, oprot, CancellationToken.None);" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; - out << indent() << "public new async Task ProcessAsync(TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl; + out << indent() << "public new async Task ProcessAsync(TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n'; } - out << indent() << "{" << endl; + out << indent() << "{" << '\n'; indent_up(); - out << indent() << "try" << endl - << indent() << "{" << endl; + out << indent() << "try" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "var msg = await iprot.ReadMessageBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << endl - << indent() << "processMap_.TryGetValue(msg.Name, out var fn);" << endl - << endl - << indent() << "if (fn == null)" << endl - << indent() << "{" << endl; + out << indent() << "var msg = await iprot.ReadMessageBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << '\n' + << indent() << "processMap_.TryGetValue(msg.Name, out var fn);" << '\n' + << '\n' + << indent() << "if (fn == null)" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "await TProtocolUtil.SkipAsync(iprot, TType.Struct, " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await iprot.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "var x = new TApplicationException (TApplicationException.ExceptionType.UnknownMethod, \"Invalid method name: '\" + msg.Name + \"'\");" << endl - << indent() << "await oprot.WriteMessageBeginAsync(new TMessage(msg.Name, TMessageType.Exception, msg.SeqID), " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await x.WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await oprot.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await oprot.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "return true;" << endl; + out << indent() << "await TProtocolUtil.SkipAsync(iprot, TType.Struct, " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await iprot.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "var x = new TApplicationException (TApplicationException.ExceptionType.UnknownMethod, \"Invalid method name: '\" + msg.Name + \"'\");" << '\n' + << indent() << "await oprot.WriteMessageBeginAsync(new TMessage(msg.Name, TMessageType.Exception, msg.SeqID), " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await x.WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await oprot.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await oprot.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "return true;" << '\n'; indent_down(); - out << indent() << "}" << endl - << endl - << indent() << "await fn(msg.SeqID, iprot, oprot, " << CANCELLATION_TOKEN_NAME << ");" << endl - << endl; + out << indent() << "}" << '\n' + << '\n' + << indent() << "await fn(msg.SeqID, iprot, oprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << '\n'; indent_down(); - out << indent() << "}" << endl; - out << indent() << "catch (IOException)" << endl - << indent() << "{" << endl; + out << indent() << "}" << '\n'; + out << indent() << "catch (IOException)" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "return false;" << endl; + out << indent() << "return false;" << '\n'; indent_down(); - out << indent() << "}" << endl - << endl - << indent() << "return true;" << endl; + out << indent() << "}" << '\n' + << '\n' + << indent() << "return true;" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -2350,7 +2350,7 @@ void t_netstd_generator::generate_service_server(ostream& out, t_service* tservi } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; cleanup_member_name_mapping(tservice); } @@ -2384,26 +2384,26 @@ void t_netstd_generator::generate_process_function_async(ostream& out, t_service { (void)tservice; out << indent() << "public async global::System.Threading.Tasks.Task " << tfunction->get_name() - << "_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl - << indent() << "{" << endl; + << "_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); string argsname = tfunction->get_name() + "_args"; string resultname = tfunction->get_name() + "_result"; string args = tmp("tmp"); - out << indent() << "var " << args << " = new InternalStructs." << argsname << "();" << endl - << indent() << "await " << args << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await iprot.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "var " << args << " = new InternalStructs." << argsname << "();" << '\n' + << indent() << "await " << args << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await iprot.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; string tmpResult = tmp("tmp"); if (!tfunction->is_oneway()) { - out << indent() << "var " << tmpResult << " = new InternalStructs." << resultname << "();" << endl; + out << indent() << "var " << tmpResult << " = new InternalStructs." << resultname << "();" << '\n'; } - out << indent() << "try" << endl - << indent() << "{" << endl; + out << indent() << "try" << '\n' + << indent() << "{" << '\n'; indent_up(); t_struct* xs = tfunction->get_xceptions(); @@ -2411,8 +2411,8 @@ void t_netstd_generator::generate_process_function_async(ostream& out, t_service if (xceptions.size() > 0) { - out << indent() << "try" << endl - << indent() << "{" << endl; + out << indent() << "try" << '\n' + << indent() << "{" << '\n'; indent_up(); } @@ -2422,7 +2422,7 @@ void t_netstd_generator::generate_process_function_async(ostream& out, t_service bool is_deprecated = (tfunction->annotations_.end() != tfunction->annotations_.find("deprecated")); if( is_deprecated) { - out << indent() << "#pragma warning disable CS0618,CS0612" << endl; + out << indent() << "#pragma warning disable CS0618,CS0612" << '\n'; } out << indent(); @@ -2457,10 +2457,10 @@ void t_netstd_generator::generate_process_function_async(ostream& out, t_service out << ", "; } - out << "" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << "" << CANCELLATION_TOKEN_NAME << ");" << '\n'; if( is_deprecated) { - out << indent() << "#pragma warning restore CS0618,CS0612" << endl; + out << indent() << "#pragma warning restore CS0618,CS0612" << '\n'; } vector::const_iterator x_iter; @@ -2470,76 +2470,76 @@ void t_netstd_generator::generate_process_function_async(ostream& out, t_service if (xceptions.size() > 0) { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { string tmpex = tmp("tmp"); - out << indent() << "catch (" << type_name((*x_iter)->get_type()) << " " << tmpex << ")" << endl - << indent() << "{" << endl; + out << indent() << "catch (" << type_name((*x_iter)->get_type()) << " " << tmpex << ")" << '\n' + << indent() << "{" << '\n'; if (!tfunction->is_oneway()) { indent_up(); - out << indent() << tmpResult << "." << prop_name(*x_iter) << " = " << tmpex << ";" << endl; + out << indent() << tmpResult << "." << prop_name(*x_iter) << " = " << tmpex << ";" << '\n'; indent_down(); } - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } if (!tfunction->is_oneway()) { out << indent() << "await oprot.WriteMessageBeginAsync(new TMessage(\"" - << tfunction->get_name() << "\", TMessageType.Reply, seqid), " << CANCELLATION_TOKEN_NAME << "); " << endl - << indent() << "await " << tmpResult << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << endl; + << tfunction->get_name() << "\", TMessageType.Reply, seqid), " << CANCELLATION_TOKEN_NAME << "); " << '\n' + << indent() << "await " << tmpResult << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n'; } indent_down(); cleanup_member_name_mapping(xs); string tmpex = tmp("tmp"); - out << indent() << "}" << endl - << indent() << "catch (TTransportException)" << endl - << indent() << "{" << endl - << indent() << " throw;" << endl - << indent() << "}" << endl - << indent() << "catch (Exception " << tmpex << ")" << endl - << indent() << "{" << endl; + out << indent() << "}" << '\n' + << indent() << "catch (TTransportException)" << '\n' + << indent() << "{" << '\n' + << indent() << " throw;" << '\n' + << indent() << "}" << '\n' + << indent() << "catch (Exception " << tmpex << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); string tmpvar = tmp("tmp"); - out << indent() << "var " << tmpvar << " = $\"Error occurred in {GetType().FullName}: {" << tmpex << ".Message}\";" << endl; - out << indent() << "if(_logger != null)" << endl; + out << indent() << "var " << tmpvar << " = $\"Error occurred in {GetType().FullName}: {" << tmpex << ".Message}\";" << '\n'; + out << indent() << "if(_logger != null)" << '\n'; indent_up(); - out << indent() << "_logger.LogError(\"{Exception}, {Message}\", " << tmpex << ", " << tmpvar << ");" << endl; + out << indent() << "_logger.LogError(\"{Exception}, {Message}\", " << tmpex << ", " << tmpvar << ");" << '\n'; indent_down(); - out << indent() << "else" << endl; + out << indent() << "else" << '\n'; indent_up(); - out << indent() << "Console.Error.WriteLine(" << tmpvar << ");" << endl; + out << indent() << "Console.Error.WriteLine(" << tmpvar << ");" << '\n'; indent_down(); if (tfunction->is_oneway()) { indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } else { tmpvar = tmp("tmp"); - out << indent() << "var " << tmpvar << " = new TApplicationException(TApplicationException.ExceptionType.InternalError,\" Internal error.\");" << endl + out << indent() << "var " << tmpvar << " = new TApplicationException(TApplicationException.ExceptionType.InternalError,\" Internal error.\");" << '\n' << indent() << "await oprot.WriteMessageBeginAsync(new TMessage(\"" << tfunction->get_name() - << "\", TMessageType.Exception, seqid), " << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await " << tmpvar << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << endl; + << "\", TMessageType.Exception, seqid), " << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await " << tmpvar << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n'; indent_down(); - out << indent() << "}" << endl - << indent() << "await oprot.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl - << indent() << "await oprot.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "}" << '\n' + << indent() << "await oprot.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n' + << indent() << "await oprot.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_netstd_generator::generate_netstd_union_reader(ostream& out, t_struct* tunion) @@ -2548,76 +2548,76 @@ void t_netstd_generator::generate_netstd_union_reader(ostream& out, t_struct* tu const vector& fields = tunion->get_members(); vector::const_iterator f_iter; - out << indent() << "public static async Task<" << tunion->get_name() << "> ReadAsync(TProtocol iprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl; + out << indent() << "public static async Task<" << tunion->get_name() << "> ReadAsync(TProtocol iprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n'; scope_up(out); - out << indent() << "iprot.IncrementRecursionDepth();" << endl; - out << indent() << "try" << endl; + out << indent() << "iprot.IncrementRecursionDepth();" << '\n'; + out << indent() << "try" << '\n'; scope_up(out); string tmpRetval = tmp("tmp"); - out << indent() << tunion->get_name() << " " << tmpRetval << ";" << endl; - out << indent() << "await iprot.ReadStructBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; - out << indent() << "TField field = await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << tunion->get_name() << " " << tmpRetval << ";" << '\n'; + out << indent() << "await iprot.ReadStructBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; + out << indent() << "TField field = await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; // we cannot have the first field be a stop -- we must have a single field defined - out << indent() << "if (field.Type == TType.Stop)" << endl; + out << indent() << "if (field.Type == TType.Stop)" << '\n'; scope_up(out); - out << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; - out << indent() << "" << tmpRetval << " = new ___undefined();" << endl; + out << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; + out << indent() << "" << tmpRetval << " = new ___undefined();" << '\n'; scope_down(out); - out << indent() << "else" << endl; + out << indent() << "else" << '\n'; scope_up(out); - out << indent() << "switch (field.ID)" << endl; + out << indent() << "switch (field.ID)" << '\n'; scope_up(out); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - out << indent() << "case " << (*f_iter)->get_key() << ":" << endl; + out << indent() << "case " << (*f_iter)->get_key() << ":" << '\n'; indent_up(); - out << indent() << "if (field.Type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl; + out << indent() << "if (field.Type == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n'; indent_up(); string tmpvar = tmp("tmp"); - out << indent() << type_name((*f_iter)->get_type()) << " " << tmpvar << ";" << endl; + out << indent() << type_name((*f_iter)->get_type()) << " " << tmpvar << ";" << '\n'; generate_deserialize_field(out, (*f_iter), tmpvar, true); - out << indent() << tmpRetval << " = new " << (*f_iter)->get_name() << "(" << tmpvar << ");" << endl; + out << indent() << tmpRetval << " = new " << (*f_iter)->get_name() << "(" << tmpvar << ");" << '\n'; indent_down(); - out << indent() << "} else { " << endl << indent() << " await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" - << endl << indent() << " " << tmpRetval << " = new ___undefined();" << endl << indent() << "}" << endl - << indent() << "break;" << endl; + out << indent() << "} else { " << '\n' << indent() << " await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" + << '\n' << indent() << " " << tmpRetval << " = new ___undefined();" << '\n' << indent() << "}" << '\n' + << indent() << "break;" << '\n'; indent_down(); } - out << indent() << "default: " << endl; + out << indent() << "default: " << '\n'; indent_up(); - out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << endl << indent() - << tmpRetval << " = new ___undefined();" << endl; - out << indent() << "break;" << endl; + out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << '\n' << indent() + << tmpRetval << " = new ___undefined();" << '\n'; + out << indent() << "break;" << '\n'; indent_down(); scope_down(out); - out << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; - out << indent() << "if ((await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ")).Type != TType.Stop)" << endl; + out << indent() << "if ((await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ")).Type != TType.Stop)" << '\n'; scope_up(out); - out << indent() << "throw new TProtocolException(TProtocolException.INVALID_DATA);" << endl; + out << indent() << "throw new TProtocolException(TProtocolException.INVALID_DATA);" << '\n'; scope_down(out); // end of else for TStop scope_down(out); - out << indent() << "await iprot.ReadStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; - out << indent() << "return " << tmpRetval << ";" << endl; + out << indent() << "await iprot.ReadStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; + out << indent() << "return " << tmpRetval << ";" << '\n'; indent_down(); scope_down(out); - out << indent() << "finally" << endl; + out << indent() << "finally" << '\n'; scope_up(out); - out << indent() << "iprot.DecrementRecursionDepth();" << endl; + out << indent() << "iprot.DecrementRecursionDepth();" << '\n'; scope_down(out); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } void t_netstd_generator::generate_deserialize_field(ostream& out, t_field* tfield, string prefix, bool is_propertyless) @@ -2698,7 +2698,7 @@ void t_netstd_generator::generate_deserialize_field(ostream& out, t_field* tfiel { out << "ReadI32Async(" << CANCELLATION_TOKEN_NAME << ");"; } - out << endl; + out << '\n'; } else { @@ -2710,18 +2710,18 @@ void t_netstd_generator::generate_deserialize_struct(ostream& out, t_struct* tst { if (is_union_enabled() && tstruct->is_union()) { - out << indent() << prefix << " = await " << type_name(tstruct) << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << prefix << " = await " << type_name(tstruct) << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n'; } else { - out << indent() << prefix << " = new " << type_name(tstruct) << "();" << endl - << indent() << "await " << prefix << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << prefix << " = new " << type_name(tstruct) << "();" << '\n' + << indent() << "await " << prefix << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n'; } } void t_netstd_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) { - out << indent() << "{" << endl; + out << indent() << "{" << '\n'; indent_up(); string obj; @@ -2741,21 +2741,21 @@ void t_netstd_generator::generate_deserialize_container(ostream& out, t_type* tt if (ttype->is_map()) { - out << indent() << "var " << obj << " = await iprot.ReadMapBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "var " << obj << " = await iprot.ReadMapBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } else if (ttype->is_set()) { - out << indent() << "var " << obj << " = await iprot.ReadSetBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "var " << obj << " = await iprot.ReadSetBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } else if (ttype->is_list()) { - out << indent() << "var " << obj << " = await iprot.ReadListBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "var " << obj << " = await iprot.ReadListBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } - out << indent() << prefix << " = new " << type_name(ttype) << "(" << obj << ".Count);" << endl; + out << indent() << prefix << " = new " << type_name(ttype) << "(" << obj << ".Count);" << '\n'; string i = tmp("_i"); - out << indent() << "for(int " << i << " = 0; " << i << " < " << obj << ".Count; ++" << i << ")" << endl - << indent() << "{" << endl; + out << indent() << "for(int " << i << " = 0; " << i << " < " << obj << ".Count; ++" << i << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); if (ttype->is_map()) @@ -2772,23 +2772,23 @@ void t_netstd_generator::generate_deserialize_container(ostream& out, t_type* tt } indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; if (ttype->is_map()) { - out << indent() << "await iprot.ReadMapEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await iprot.ReadMapEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } else if (ttype->is_set()) { - out << indent() << "await iprot.ReadSetEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await iprot.ReadSetEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } else if (ttype->is_list()) { - out << indent() << "await iprot.ReadListEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await iprot.ReadListEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } void t_netstd_generator::generate_deserialize_map_element(ostream& out, t_map* tmap, string prefix) @@ -2799,13 +2799,13 @@ void t_netstd_generator::generate_deserialize_map_element(ostream& out, t_map* t t_field fkey(tmap->get_key_type(), key); t_field fval(tmap->get_val_type(), val); - out << indent() << declare_field(&fkey, false, false) << endl; - out << indent() << declare_field(&fval, false, false) << endl; + out << indent() << declare_field(&fkey, false, false) << '\n'; + out << indent() << declare_field(&fval, false, false) << '\n'; generate_deserialize_field(out, &fkey); generate_deserialize_field(out, &fval); - out << indent() << prefix << "[" << key << "] = " << val << ";" << endl; + out << indent() << prefix << "[" << key << "] = " << val << ";" << '\n'; } void t_netstd_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) @@ -2813,11 +2813,11 @@ void t_netstd_generator::generate_deserialize_set_element(ostream& out, t_set* t string elem = tmp("_elem"); t_field felem(tset->get_elem_type(), elem); - out << indent() << declare_field(&felem, false, false) << endl; + out << indent() << declare_field(&felem, false, false) << '\n'; generate_deserialize_field(out, &felem); - out << indent() << prefix << ".Add(" << elem << ");" << endl; + out << indent() << prefix << ".Add(" << elem << ");" << '\n'; } void t_netstd_generator::generate_deserialize_list_element(ostream& out, t_list* tlist, string prefix) @@ -2825,11 +2825,11 @@ void t_netstd_generator::generate_deserialize_list_element(ostream& out, t_list* string elem = tmp("_elem"); t_field felem(tlist->get_elem_type(), elem); - out << indent() << declare_field(&felem, false, false) << endl; + out << indent() << declare_field(&felem, false, false) << '\n'; generate_deserialize_field(out, &felem); - out << indent() << prefix << ".Add(" << elem << ");" << endl; + out << indent() << prefix << ".Add(" << elem << ");" << '\n'; } void t_netstd_generator::generate_serialize_field(ostream& out, t_field* tfield, string prefix, bool is_propertyless, bool allow_nullable) @@ -2904,7 +2904,7 @@ void t_netstd_generator::generate_serialize_field(ostream& out, t_field* tfield, { out << "WriteI32Async((int)" << name << ", " << CANCELLATION_TOKEN_NAME << ");"; } - out << endl; + out << '\n'; } else { @@ -2915,7 +2915,7 @@ void t_netstd_generator::generate_serialize_field(ostream& out, t_field* tfield, void t_netstd_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - out << indent() << "await " << prefix << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await " << prefix << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n'; } void t_netstd_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) @@ -2924,18 +2924,18 @@ void t_netstd_generator::generate_serialize_container(ostream& out, t_type* ttyp { out << indent() << "await oprot.WriteMapBeginAsync(new TMap(" << type_to_enum(static_cast(ttype)->get_key_type()) << ", " << type_to_enum(static_cast(ttype)->get_val_type()) << ", " << prefix - << ".Count), " << CANCELLATION_TOKEN_NAME << ");" << endl; + << ".Count), " << CANCELLATION_TOKEN_NAME << ");" << '\n'; } else if (ttype->is_set()) { out << indent() << "await oprot.WriteSetBeginAsync(new TSet(" << type_to_enum(static_cast(ttype)->get_elem_type()) - << ", " << prefix << ".Count), " << CANCELLATION_TOKEN_NAME << ");" << endl; + << ", " << prefix << ".Count), " << CANCELLATION_TOKEN_NAME << ");" << '\n'; } else if (ttype->is_list()) { out << indent() << "await oprot.WriteListBeginAsync(new TList(" << type_to_enum(static_cast(ttype)->get_elem_type()) << ", " << prefix << ".Count), " << CANCELLATION_TOKEN_NAME << ");" - << endl; + << '\n'; } string iter = tmp("_iter"); @@ -2955,8 +2955,8 @@ void t_netstd_generator::generate_serialize_container(ostream& out, t_type* ttyp << " in " << prefix << ")"; } - out << endl; - out << indent() << "{" << endl; + out << '\n'; + out << indent() << "{" << '\n'; indent_up(); if (ttype->is_map()) @@ -2973,19 +2973,19 @@ void t_netstd_generator::generate_serialize_container(ostream& out, t_type* ttyp } indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; if (ttype->is_map()) { - out << indent() << "await oprot.WriteMapEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await oprot.WriteMapEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } else if (ttype->is_set()) { - out << indent() << "await oprot.WriteSetEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await oprot.WriteSetEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } else if (ttype->is_list()) { - out << indent() << "await oprot.WriteListEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl; + out << indent() << "await oprot.WriteListEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'; } } @@ -3018,7 +3018,7 @@ void t_netstd_generator::generate_netstd_property(ostream& out, t_field* tfield, { if ((is_serialize_enabled() || is_wcf_enabled()) && isPublic) { - out << indent() << "[DataMember(Order = 0)]" << endl; + out << indent() << "[DataMember(Order = 0)]" << '\n'; } out << indent() @@ -3036,37 +3036,37 @@ void t_netstd_generator::generate_netstd_property(ostream& out, t_field* tfield, if( (target_net_version >= 6) && (!force_member_nullable(tfield))) { out << initialize_field(tfield) << ";"; } - out << endl; + out << '\n'; } else { - out << endl - << indent() << "{" << endl; + out << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "get" << endl - << indent() << "{" << endl; + out << indent() << "get" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "return " << fieldPrefix + tfield->get_name() << ";" << endl; + out << indent() << "return " << fieldPrefix + tfield->get_name() << ";" << '\n'; indent_down(); - out << indent() << "}" << endl - << indent() << "set" << endl - << indent() << "{" << endl; + out << indent() << "}" << '\n' + << indent() << "set" << '\n' + << indent() << "{" << '\n'; indent_up(); if (generateIsset) { - out << indent() << "__isset." << get_isset_name(normalize_name(tfield->get_name())) << " = true;" << endl; + out << indent() << "__isset." << get_isset_name(normalize_name(tfield->get_name())) << " = true;" << '\n'; } - out << indent() << "this." << fieldPrefix + tfield->get_name() << " = value;" << endl; + out << indent() << "this." << fieldPrefix + tfield->get_name() << " = value;" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } - out << endl; + out << '\n'; } string t_netstd_generator::make_csharp_string_literal( string const& value) @@ -3749,14 +3749,14 @@ string t_netstd_generator::type_to_enum(t_type* type) void t_netstd_generator::generate_netstd_docstring_comment(ostream& out, string contents) { - docstring_comment(out, "/// " + endl, "/// ", contents, "/// " + endl); + docstring_comment(out, "/// " + string("\n"), "/// ", contents, "/// " + string("\n")); } void t_netstd_generator::generate_netstd_doc(ostream& out, t_field* field) { if (field->get_type()->is_enum()) { - string combined_message = field->get_doc() + endl + "get_type()) + "\"/>"; + string combined_message = field->get_doc() + "\n" + "get_type()) + "\"/>"; generate_netstd_docstring_comment(out, combined_message); } else @@ -3783,7 +3783,7 @@ void t_netstd_generator::generate_netstd_doc(ostream& out, t_function* tfunction for (p_iter = fields.begin(); p_iter != fields.end(); ++p_iter) { t_field* p = *p_iter; - ps << endl << "get_name() << "\">"; + ps << '\n' << "get_name() << "\">"; if (p->has_doc()) { string str = p->get_doc(); @@ -3796,7 +3796,7 @@ void t_netstd_generator::generate_netstd_doc(ostream& out, t_function* tfunction docstring_comment(out, "", "/// ", - "" + endl + tfunction->get_doc() + "" + ps.str(), + "" + string("\n") + tfunction->get_doc() + "" + ps.str(), ""); } } @@ -3818,11 +3818,11 @@ void t_netstd_generator::docstring_comment(ostream& out, const string& comment_s // Just prnt a newline when the line & prefix are empty. if (strlen(line) == 0 && line_prefix == "" && !docs.eof()) { - out << endl; + out << '\n'; } else if (strlen(line) > 0 || !docs.eof()) { // skip the empty last line - out << indent() << line_prefix << line << endl; + out << indent() << line_prefix << line << '\n'; } } if (comment_end != "") diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.h b/compiler/cpp/src/thrift/generate/t_netstd_generator.h index ff3cfb1264c..a6e4d90a496 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.h +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.h @@ -44,8 +44,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - static const string DEEP_COPY_METHOD_NAME = "DeepCopy"; static const string CANCELLATION_TOKEN_NAME = "cancellationToken"; @@ -165,7 +163,7 @@ class t_netstd_generator : public t_oop_generator comment += " */\n"; return comment; } - + private: string namespace_name_; @@ -182,15 +180,15 @@ class t_netstd_generator : public t_oop_generator const std::string CSHARP_KEYWORDS[101] = { // C# keywords - "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", - "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", - "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", - "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", - "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", - "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", - "using", "virtual", "void", "volatile", "while", + "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", + "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", + "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", + "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", + "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", + "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", + "using", "virtual", "void", "volatile", "while", // C# contextual keywords - "add", "alias", "ascending", "async", "await", "descending", "dynamic", "from", "get", "global", "group", "into", + "add", "alias", "ascending", "async", "await", "descending", "dynamic", "from", "get", "global", "group", "into", "join", "let", "orderby", "partial", "remove", "select", "set", "value", "var", "when", "where", "yield" }; @@ -199,7 +197,7 @@ class t_netstd_generator : public t_oop_generator vector member_mapping_scopes; map collected_extension_types; map checked_extension_types; - + string normalize_name(string name, bool is_arg_name = false); string make_valid_csharp_identifier(string const& fromName); string make_csharp_string_literal( string const& value); diff --git a/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc b/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc index 5f9b80cf5ec..34dda402a1a 100644 --- a/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc @@ -38,8 +38,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * OCaml code generator. * @@ -241,10 +239,10 @@ void t_ocaml_generator::init_generator() { f_consts_.open(f_consts_name.c_str()); // Print header - f_types_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl; - f_types_i_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl; - f_consts_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl << "open " - << capitalize(program_name_) << "_types" << endl; + f_types_ << ocaml_autogen_comment() << '\n' << ocaml_imports() << '\n'; + f_types_i_ << ocaml_autogen_comment() << '\n' << ocaml_imports() << '\n'; + f_consts_ << ocaml_autogen_comment() << '\n' << ocaml_imports() << '\n' << "open " + << capitalize(program_name_) << "_types" << '\n'; } /** @@ -277,9 +275,9 @@ t_ocaml_generator::~t_ocaml_generator() { */ void t_ocaml_generator::generate_typedef(t_typedef* ttypedef) { f_types_ << indent() << "type " << decapitalize(ttypedef->get_symbolic()) << " = " - << render_ocaml_type(ttypedef->get_type()) << endl << endl; + << render_ocaml_type(ttypedef->get_type()) << '\n' << '\n'; f_types_i_ << indent() << "type " << decapitalize(ttypedef->get_symbolic()) << " = " - << render_ocaml_type(ttypedef->get_type()) << endl << endl; + << render_ocaml_type(ttypedef->get_type()) << '\n' << '\n'; } /** @@ -289,46 +287,46 @@ void t_ocaml_generator::generate_typedef(t_typedef* ttypedef) { * @param tenum The enumeration */ void t_ocaml_generator::generate_enum(t_enum* tenum) { - indent(f_types_) << "module " << capitalize(tenum->get_name()) << " = " << endl << "struct" - << endl; - indent(f_types_i_) << "module " << capitalize(tenum->get_name()) << " : " << endl << "sig" - << endl; + indent(f_types_) << "module " << capitalize(tenum->get_name()) << " = " << '\n' << "struct" + << '\n'; + indent(f_types_i_) << "module " << capitalize(tenum->get_name()) << " : " << '\n' << "sig" + << '\n'; indent_up(); - indent(f_types_) << "type t = " << endl; - indent(f_types_i_) << "type t = " << endl; + indent(f_types_) << "type t = " << '\n'; + indent(f_types_i_) << "type t = " << '\n'; indent_up(); vector constants = tenum->get_constants(); vector::iterator c_iter; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { string name = capitalize((*c_iter)->get_name()); - indent(f_types_) << "| " << name << endl; - indent(f_types_i_) << "| " << name << endl; + indent(f_types_) << "| " << name << '\n'; + indent(f_types_i_) << "| " << name << '\n'; } indent_down(); - indent(f_types_) << "let to_i = function" << endl; - indent(f_types_i_) << "val to_i : t -> Int32.t" << endl; + indent(f_types_) << "let to_i = function" << '\n'; + indent(f_types_i_) << "val to_i : t -> Int32.t" << '\n'; indent_up(); for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); string name = capitalize((*c_iter)->get_name()); - indent(f_types_) << "| " << name << " -> " << value << "l" << endl; + indent(f_types_) << "| " << name << " -> " << value << "l" << '\n'; } indent_down(); - indent(f_types_) << "let of_i = function" << endl; - indent(f_types_i_) << "val of_i : Int32.t -> t" << endl; + indent(f_types_) << "let of_i = function" << '\n'; + indent(f_types_i_) << "val of_i : Int32.t -> t" << '\n'; indent_up(); for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); string name = capitalize((*c_iter)->get_name()); - indent(f_types_) << "| " << value << "l -> " << name << endl; + indent(f_types_) << "| " << value << "l -> " << name << '\n'; } - indent(f_types_) << "| _ -> raise Thrift_error" << endl; + indent(f_types_) << "| _ -> raise Thrift_error" << '\n'; indent_down(); indent_down(); - indent(f_types_) << "end" << endl; - indent(f_types_i_) << "end" << endl; + indent(f_types_) << "end" << '\n'; + indent(f_types_i_) << "end" << '\n'; } /** @@ -339,7 +337,7 @@ void t_ocaml_generator::generate_const(t_const* tconst) { string name = decapitalize(tconst->get_name()); t_const_value* value = tconst->get_value(); - indent(f_consts_) << "let " << name << " = " << render_const_value(type, value) << endl << endl; + indent(f_consts_) << "let " << name << " = " << render_const_value(type, value) << '\n' << '\n'; } /** @@ -395,9 +393,9 @@ string t_ocaml_generator::render_const_value(t_type* type, t_const_value* value) } else if (type->is_struct() || type->is_xception()) { string cname = type_name(type); string ct = tmp("_c"); - out << endl; + out << '\n'; indent_up(); - indent(out) << "(let " << ct << " = new " << cname << " in" << endl; + indent(out) << "(let " << ct << " = new " << cname << " in" << '\n'; indent_up(); const vector& fields = ((t_struct*)type)->get_members(); vector::const_iterator f_iter; @@ -417,7 +415,7 @@ string t_ocaml_generator::render_const_value(t_type* type, t_const_value* value) out << indent(); out << ct << "#set_" << fname << " "; out << render_const_value(field_type, v_iter->second); - out << ";" << endl; + out << ";" << '\n'; } indent(out) << ct << ")"; indent_down(); @@ -428,14 +426,14 @@ string t_ocaml_generator::render_const_value(t_type* type, t_const_value* value) const map& val = value->get_map(); map::const_iterator v_iter; string hm = tmp("_hm"); - out << endl; + out << '\n'; indent_up(); - indent(out) << "(let " << hm << " = Hashtbl.create " << val.size() << " in" << endl; + indent(out) << "(let " << hm << " = Hashtbl.create " << val.size() << " in" << '\n'; indent_up(); for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string key = render_const_value(ktype, v_iter->first); string val = render_const_value(vtype, v_iter->second); - indent(out) << "Hashtbl.add " << hm << " " << key << " " << val << ";" << endl; + indent(out) << "Hashtbl.add " << hm << " " << key << " " << val << ";" << '\n'; } indent(out) << hm << ")"; indent_down(); @@ -443,14 +441,14 @@ string t_ocaml_generator::render_const_value(t_type* type, t_const_value* value) } else if (type->is_list()) { t_type* etype; etype = ((t_list*)type)->get_elem_type(); - out << "[" << endl; + out << "[" << '\n'; indent_up(); const vector& val = value->get_list(); vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { out << indent(); out << render_const_value(etype, *v_iter); - out << ";" << endl; + out << ";" << '\n'; } indent_down(); indent(out) << "]"; @@ -459,15 +457,15 @@ string t_ocaml_generator::render_const_value(t_type* type, t_const_value* value) const vector& val = value->get_list(); vector::const_iterator v_iter; string hm = tmp("_hm"); - indent(out) << "(let " << hm << " = Hashtbl.create " << val.size() << " in" << endl; + indent(out) << "(let " << hm << " = Hashtbl.create " << val.size() << " in" << '\n'; indent_up(); for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { string val = render_const_value(etype, *v_iter); - indent(out) << "Hashtbl.add " << hm << " " << val << " true;" << endl; + indent(out) << "Hashtbl.add " << hm << " " << val << " true;" << '\n'; } - indent(out) << hm << ")" << endl; + indent(out) << hm << ")" << '\n'; indent_down(); - out << endl; + out << '\n'; } else { throw "CANNOT GENERATE CONSTANT FOR TYPE: " + type->get_name(); } @@ -503,15 +501,15 @@ void t_ocaml_generator::generate_ocaml_method_copy(ostream& out, const vector::const_iterator m_iter; /* Create a copy of the current object */ - indent(out) << "method copy =" << endl; + indent(out) << "method copy =" << '\n'; indent_up(); indent_up(); - indent(out) << "let _new = Oo.copy self in" << endl; + indent(out) << "let _new = Oo.copy self in" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) generate_ocaml_member_copy(out, *m_iter); indent_down(); - indent(out) << "_new" << endl; + indent(out) << "_new" << '\n'; indent_down(); } @@ -564,10 +562,10 @@ void t_ocaml_generator::generate_ocaml_member_copy(ostream& out, t_field* tmembe if (copy_of != grab_field) { indent(out); if (!struct_member_persistent(tmember)) { - out << "if _" << mname << " <> None then" << endl; + out << "if _" << mname << " <> None then" << '\n'; indent(out) << " "; } - out << "_new#set_" << mname << " " << copy_of << ";" << endl; + out << "_new#set_" << mname << " " << copy_of << ";" << '\n'; } } @@ -582,24 +580,24 @@ void t_ocaml_generator::generate_ocaml_struct_definition(ostream& out, const vector& members = tstruct->get_members(); vector::const_iterator m_iter; string tname = type_name(tstruct); - indent(out) << "class " << tname << " =" << endl; - indent(out) << "object (self)" << endl; + indent(out) << "class " << tname << " =" << '\n'; + indent(out) << "object (self)" << '\n'; indent_up(); if (members.size() > 0) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { generate_ocaml_struct_member(out, tname, (*m_iter)); - out << endl; + out << '\n'; } } generate_ocaml_method_copy(out, members); generate_ocaml_struct_writer(out, tstruct); indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; if (is_exception) { - indent(out) << "exception " << capitalize(tname) << " of " << tname << endl; + indent(out) << "exception " << capitalize(tname) << " of " << tname << '\n'; } generate_ocaml_struct_reader(out, tstruct); @@ -621,37 +619,37 @@ void t_ocaml_generator::generate_ocaml_struct_member(ostream& out, t_const_value* val = tmember->get_value(); if (val) { if (struct_member_persistent(tmember)) - out << " = " << render_const_value(tmember->get_type(), tmember->get_value()) << endl; + out << " = " << render_const_value(tmember->get_type(), tmember->get_value()) << '\n'; else out << " option = Some " << render_const_value(tmember->get_type(), tmember->get_value()) - << endl; + << '\n'; } else { // assert(!struct_member_persistent(tmember)) - out << " option = None" << endl; + out << " option = None" << '\n'; } if (struct_member_persistent(tmember)) { - indent(out) << "method get_" << mname << " = Some _" << mname << endl; - indent(out) << "method grab_" << mname << " = _" << mname << endl; - indent(out) << "method set_" << mname << " " << x << " = _" << mname << " <- " << x << endl; + indent(out) << "method get_" << mname << " = Some _" << mname << '\n'; + indent(out) << "method grab_" << mname << " = _" << mname << '\n'; + indent(out) << "method set_" << mname << " " << x << " = _" << mname << " <- " << x << '\n'; } else { - indent(out) << "method get_" << mname << " = _" << mname << endl; + indent(out) << "method get_" << mname << " = _" << mname << '\n'; indent(out) << "method grab_" << mname << " = match _" << mname << " with None->raise (Field_empty \"" << tname << "." << mname << "\") | Some " - << x << " -> " << x << endl; + << x << " -> " << x << '\n'; indent(out) << "method set_" << mname << " " << x << " = _" << mname << " <- Some " << x - << endl; - indent(out) << "method unset_" << mname << " = _" << mname << " <- None" << endl; + << '\n'; + indent(out) << "method unset_" << mname << " = _" << mname << " <- None" << '\n'; } indent(out) << "method reset_" << mname << " = _" << mname << " <- "; if (val) { if (struct_member_persistent(tmember)) - out << render_const_value(tmember->get_type(), tmember->get_value()) << endl; + out << render_const_value(tmember->get_type(), tmember->get_value()) << '\n'; else - out << "Some " << render_const_value(tmember->get_type(), tmember->get_value()) << endl; + out << "Some " << render_const_value(tmember->get_type(), tmember->get_value()) << '\n'; } else { - out << "None" << endl; + out << "None" << '\n'; } } @@ -719,8 +717,8 @@ void t_ocaml_generator::generate_ocaml_struct_sig(ostream& out, const vector& members = tstruct->get_members(); vector::const_iterator m_iter; string tname = type_name(tstruct); - indent(out) << "class " << tname << " :" << endl; - indent(out) << "object ('a)" << endl; + indent(out) << "class " << tname << " :" << '\n'; + indent(out) << "object ('a)" << '\n'; indent_up(); @@ -729,24 +727,24 @@ void t_ocaml_generator::generate_ocaml_struct_sig(ostream& out, for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { string mname = decapitalize((*m_iter)->get_name()); string type = render_ocaml_type((*m_iter)->get_type()); - indent(out) << "method get_" << mname << " : " << type << " option" << endl; - indent(out) << "method grab_" << mname << " : " << type << endl; - indent(out) << "method set_" << mname << " : " << type << " -> unit" << endl; + indent(out) << "method get_" << mname << " : " << type << " option" << '\n'; + indent(out) << "method grab_" << mname << " : " << type << '\n'; + indent(out) << "method set_" << mname << " : " << type << " -> unit" << '\n'; if (!struct_member_persistent(*m_iter)) - indent(out) << "method unset_" << mname << " : unit" << endl; - indent(out) << "method reset_" << mname << " : unit" << endl; + indent(out) << "method unset_" << mname << " : unit" << '\n'; + indent(out) << "method reset_" << mname << " : unit" << '\n'; } } - indent(out) << "method copy : 'a" << endl; - indent(out) << "method write : Protocol.t -> unit" << endl; + indent(out) << "method copy : 'a" << '\n'; + indent(out) << "method write : Protocol.t -> unit" << '\n'; indent_down(); - indent(out) << "end" << endl; + indent(out) << "end" << '\n'; if (is_exception) { - indent(out) << "exception " << capitalize(tname) << " of " << tname << endl; + indent(out) << "exception " << capitalize(tname) << " of " << tname << '\n'; } - indent(out) << "val read_" << tname << " : Protocol.t -> " << tname << endl; + indent(out) << "val read_" << tname << " : Protocol.t -> " << tname << '\n'; } /** @@ -759,55 +757,55 @@ void t_ocaml_generator::generate_ocaml_struct_reader(ostream& out, t_struct* tst string str = tmp("_str"); string t = tmp("_t"); string id = tmp("_id"); - indent(out) << "let rec read_" << sname << " (iprot : Protocol.t) =" << endl; + indent(out) << "let rec read_" << sname << " (iprot : Protocol.t) =" << '\n'; indent_up(); - indent(out) << "let " << str << " = new " << sname << " in" << endl; + indent(out) << "let " << str << " = new " << sname << " in" << '\n'; indent_up(); - indent(out) << "ignore(iprot#readStructBegin);" << endl; + indent(out) << "ignore(iprot#readStructBegin);" << '\n'; // Loop over reading in fields - indent(out) << "(try while true do" << endl; + indent(out) << "(try while true do" << '\n'; indent_up(); indent_up(); // Read beginning field marker - indent(out) << "let (_," << t << "," << id << ") = iprot#readFieldBegin in" << endl; + indent(out) << "let (_," << t << "," << id << ") = iprot#readFieldBegin in" << '\n'; // Check for field STOP marker and break - indent(out) << "if " << t << " = Protocol.T_STOP then" << endl; + indent(out) << "if " << t << " = Protocol.T_STOP then" << '\n'; indent_up(); - indent(out) << "raise Break" << endl; + indent(out) << "raise Break" << '\n'; indent_down(); - indent(out) << "else ();" << endl; + indent(out) << "else ();" << '\n'; - indent(out) << "(match " << id << " with " << endl; + indent(out) << "(match " << id << " with " << '\n'; indent_up(); // Generate deserialization code for known cases for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { indent(out) << "| " << (*f_iter)->get_key() << " -> ("; - out << "if " << t << " = " << type_to_enum((*f_iter)->get_type()) << " then" << endl; + out << "if " << t << " = " << type_to_enum((*f_iter)->get_type()) << " then" << '\n'; indent_up(); indent_up(); generate_deserialize_field(out, *f_iter, str); indent_down(); - out << indent() << "else" << endl << indent() << " iprot#skip " << t << ")" << endl; + out << indent() << "else" << '\n' << indent() << " iprot#skip " << t << ")" << '\n'; indent_down(); } // In the default case we skip the field out << indent() << "| _ -> " - << "iprot#skip " << t << ");" << endl; + << "iprot#skip " << t << ");" << '\n'; indent_down(); // Read field end marker - indent(out) << "iprot#readFieldEnd;" << endl; + indent(out) << "iprot#readFieldEnd;" << '\n'; indent_down(); - indent(out) << "done; ()" << endl; + indent(out) << "done; ()" << '\n'; indent_down(); - indent(out) << "with Break -> ());" << endl; + indent(out) << "with Break -> ());" << '\n'; - indent(out) << "iprot#readStructEnd;" << endl; + indent(out) << "iprot#readStructEnd;" << '\n'; - indent(out) << str << endl << endl; + indent(out) << str << '\n' << '\n'; indent_down(); indent_down(); } @@ -819,9 +817,9 @@ void t_ocaml_generator::generate_ocaml_struct_writer(ostream& out, t_struct* tst string str = tmp("_str"); string f = tmp("_f"); - indent(out) << "method write (oprot : Protocol.t) =" << endl; + indent(out) << "method write (oprot : Protocol.t) =" << '\n'; indent_up(); - indent(out) << "oprot#writeStructBegin \"" << name << "\";" << endl; + indent(out) << "oprot#writeStructBegin \"" << name << "\";" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_field* tmember = (*f_iter); @@ -835,10 +833,10 @@ void t_ocaml_generator::generate_ocaml_struct_writer(ostream& out, t_struct* tst // Avoid redundant encoding of members having default values. indent(out) << "(match " << mname << " with " << render_const_value(tmember->get_type(), tmember->get_value()) << " -> () | " - << _v << " -> " << endl; + << _v << " -> " << '\n'; } else { _v = mname; - indent(out) << "(" << endl; + indent(out) << "(" << '\n'; } } else { @@ -853,12 +851,12 @@ void t_ocaml_generator::generate_ocaml_struct_writer(ostream& out, t_struct* tst out << " | Some " << render_const_value(tmember->get_type(), tmember->get_value()) << " -> ()"; } - out << " | Some _v -> " << endl; + out << " | Some _v -> " << '\n'; } else { - out << endl; + out << '\n'; indent(out) << "| None -> raise (Field_empty \"" << type_name(tstruct) << "." << mname - << "\")" << endl; - indent(out) << "| Some _v -> " << endl; + << "\")" << '\n'; + indent(out) << "| Some _v -> " << '\n'; } _v = "_v"; @@ -866,20 +864,20 @@ void t_ocaml_generator::generate_ocaml_struct_writer(ostream& out, t_struct* tst indent_up(); // Write field header indent(out) << "oprot#writeFieldBegin(\"" << tmember->get_name() << "\"," - << type_to_enum(tmember->get_type()) << "," << tmember->get_key() << ");" << endl; + << type_to_enum(tmember->get_type()) << "," << tmember->get_key() << ");" << '\n'; // Write field contents generate_serialize_field(out, tmember, _v); // Write field closer - indent(out) << "oprot#writeFieldEnd" << endl; + indent(out) << "oprot#writeFieldEnd" << '\n'; indent_down(); - indent(out) << ");" << endl; + indent(out) << ");" << '\n'; } // Write the struct map - out << indent() << "oprot#writeFieldStop;" << endl << indent() << "oprot#writeStructEnd" << endl; + out << indent() << "oprot#writeFieldStop;" << '\n' << indent() << "oprot#writeStructEnd" << '\n'; indent_down(); } @@ -895,19 +893,19 @@ void t_ocaml_generator::generate_service(t_service* tservice) { string f_service_i_name = get_out_dir() + capitalize(service_name_) + ".mli"; f_service_i_.open(f_service_i_name.c_str()); - f_service_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl; - f_service_i_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl; + f_service_ << ocaml_autogen_comment() << '\n' << ocaml_imports() << '\n'; + f_service_i_ << ocaml_autogen_comment() << '\n' << ocaml_imports() << '\n'; /* if (tservice->get_extends() != nullptr) { f_service_ << - "open " << capitalize(tservice->get_extends()->get_name()) << endl; + "open " << capitalize(tservice->get_extends()->get_name()) << '\n'; f_service_i_ << - "open " << capitalize(tservice->get_extends()->get_name()) << endl; + "open " << capitalize(tservice->get_extends()->get_name()) << '\n'; } */ - f_service_ << "open " << capitalize(program_name_) << "_types" << endl << endl; + f_service_ << "open " << capitalize(program_name_) << "_types" << '\n' << '\n'; - f_service_i_ << "open " << capitalize(program_name_) << "_types" << endl << endl; + f_service_i_ << "open " << capitalize(program_name_) << "_types" << '\n' << '\n'; // Generate the three main parts of the service generate_service_helpers(tservice); @@ -925,7 +923,7 @@ void t_ocaml_generator::generate_service_helpers(t_service* tservice) { vector functions = tservice->get_functions(); vector::iterator f_iter; - indent(f_service_) << "(* HELPER FUNCTIONS AND STRUCTURES *)" << endl << endl; + indent(f_service_) << "(* HELPER FUNCTIONS AND STRUCTURES *)" << '\n' << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { t_struct* ts = (*f_iter)->get_arglist(); @@ -961,15 +959,15 @@ void t_ocaml_generator::generate_ocaml_function_helpers(t_function* tfunction) { * @param tservice The service to generate a header definition for */ void t_ocaml_generator::generate_service_interface(t_service* tservice) { - f_service_ << indent() << "class virtual iface =" << endl << "object (self)" << endl; - f_service_i_ << indent() << "class virtual iface :" << endl << "object" << endl; + f_service_ << indent() << "class virtual iface =" << '\n' << "object (self)" << '\n'; + f_service_i_ << indent() << "class virtual iface :" << '\n' << "object" << '\n'; indent_up(); if (tservice->get_extends() != nullptr) { string extends = type_name(tservice->get_extends()); - indent(f_service_) << "inherit " << extends << ".iface" << endl; - indent(f_service_i_) << "inherit " << extends << ".iface" << endl; + indent(f_service_) << "inherit " << extends << ".iface" << '\n'; + indent(f_service_i_) << "inherit " << extends << ".iface" << '\n'; } vector functions = tservice->get_functions(); @@ -977,13 +975,13 @@ void t_ocaml_generator::generate_service_interface(t_service* tservice) { for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { string ft = function_type(*f_iter, true, true); f_service_ << indent() << "method virtual " << decapitalize((*f_iter)->get_name()) << " : " - << ft << endl; + << ft << '\n'; f_service_i_ << indent() << "method virtual " << decapitalize((*f_iter)->get_name()) << " : " - << ft << endl; + << ft << '\n'; } indent_down(); - indent(f_service_) << "end" << endl << endl; - indent(f_service_i_) << "end" << endl << endl; + indent(f_service_) << "end" << '\n' << '\n'; + indent(f_service_i_) << "end" << '\n' << '\n'; } /** @@ -995,17 +993,17 @@ void t_ocaml_generator::generate_service_interface(t_service* tservice) { */ void t_ocaml_generator::generate_service_client(t_service* tservice) { string extends = ""; - indent(f_service_) << "class client (iprot : Protocol.t) (oprot : Protocol.t) =" << endl - << "object (self)" << endl; - indent(f_service_i_) << "class client : Protocol.t -> Protocol.t -> " << endl << "object" << endl; + indent(f_service_) << "class client (iprot : Protocol.t) (oprot : Protocol.t) =" << '\n' + << "object (self)" << '\n'; + indent(f_service_i_) << "class client : Protocol.t -> Protocol.t -> " << '\n' << "object" << '\n'; indent_up(); if (tservice->get_extends() != nullptr) { extends = type_name(tservice->get_extends()); - indent(f_service_) << "inherit " << extends << ".client iprot oprot as super" << endl; - indent(f_service_i_) << "inherit " << extends << ".client" << endl; + indent(f_service_) << "inherit " << extends << ".client iprot oprot as super" << '\n'; + indent(f_service_i_) << "inherit " << extends << ".client" << '\n'; } - indent(f_service_) << "val mutable seqid = 0" << endl; + indent(f_service_) << "val mutable seqid = 0" << '\n'; // Generate client method implementations vector functions = tservice->get_functions(); @@ -1017,24 +1015,24 @@ void t_ocaml_generator::generate_service_client(t_service* tservice) { string funname = (*f_iter)->get_name(); // Open function - indent(f_service_) << "method " << function_signature(*f_iter) << " = " << endl; + indent(f_service_) << "method " << function_signature(*f_iter) << " = " << '\n'; indent(f_service_i_) << "method " << decapitalize((*f_iter)->get_name()) << " : " - << function_type(*f_iter, true, false) << endl; + << function_type(*f_iter, true, false) << '\n'; indent_up(); indent(f_service_) << "self#send_" << funname; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_service_ << " " << decapitalize((*fld_iter)->get_name()); } - f_service_ << ";" << endl; + f_service_ << ";" << '\n'; if (!(*f_iter)->is_oneway()) { f_service_ << indent(); - f_service_ << "self#recv_" << funname << endl; + f_service_ << "self#recv_" << funname << '\n'; } indent_down(); - indent(f_service_) << "method private send_" << function_signature(*f_iter) << " = " << endl; + indent(f_service_) << "method private send_" << function_signature(*f_iter) << " = " << '\n'; indent_up(); std::string argsname = decapitalize((*f_iter)->get_name() + "_args"); @@ -1042,19 +1040,19 @@ void t_ocaml_generator::generate_service_client(t_service* tservice) { // Serialize the request header f_service_ << indent() << "oprot#writeMessageBegin (\"" << (*f_iter)->get_name() << "\", " << ((*f_iter)->is_oneway() ? "Protocol.ONEWAY" : "Protocol.CALL") << ", seqid);" - << endl; + << '\n'; - f_service_ << indent() << "let args = new " << argsname << " in" << endl; + f_service_ << indent() << "let args = new " << argsname << " in" << '\n'; indent_up(); for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_service_ << indent() << "args#set_" << (*fld_iter)->get_name() << " " - << (*fld_iter)->get_name() << ";" << endl; + << (*fld_iter)->get_name() << ";" << '\n'; } // Write to the stream - f_service_ << indent() << "args#write oprot;" << endl << indent() << "oprot#writeMessageEnd;" - << endl << indent() << "oprot#getTransport#flush" << endl; + f_service_ << indent() << "args#write oprot;" << '\n' << indent() << "oprot#writeMessageEnd;" + << '\n' << indent() << "oprot#getTransport#flush" << '\n'; indent_down(); indent_down(); @@ -1068,20 +1066,20 @@ void t_ocaml_generator::generate_service_client(t_service* tservice) { &noargs); // Open function f_service_ << indent() << "method private " << function_signature(&recv_function) << " =" - << endl; + << '\n'; indent_up(); // TODO(mcslee): Validate message reply here, seq ids etc. - f_service_ << indent() << "let (fname, mtype, rseqid) = iprot#readMessageBegin in" << endl; + f_service_ << indent() << "let (fname, mtype, rseqid) = iprot#readMessageBegin in" << '\n'; indent_up(); - f_service_ << indent() << "(if mtype = Protocol.EXCEPTION then" << endl << indent() - << " let x = Application_Exn.read iprot in" << endl; + f_service_ << indent() << "(if mtype = Protocol.EXCEPTION then" << '\n' << indent() + << " let x = Application_Exn.read iprot in" << '\n'; indent_up(); f_service_ << indent() << " (iprot#readMessageEnd;" << indent() - << " raise (Application_Exn.E x))" << endl; + << " raise (Application_Exn.E x))" << '\n'; indent_down(); - f_service_ << indent() << "else ());" << endl; + f_service_ << indent() << "else ());" << '\n'; string res = "_"; t_struct* xs = (*f_iter)->get_xceptions(); @@ -1090,32 +1088,32 @@ void t_ocaml_generator::generate_service_client(t_service* tservice) { if (!(*f_iter)->get_returntype()->is_void() || xceptions.size() > 0) { res = "result"; } - f_service_ << indent() << "let " << res << " = read_" << resultname << " iprot in" << endl; + f_service_ << indent() << "let " << res << " = read_" << resultname << " iprot in" << '\n'; indent_up(); - f_service_ << indent() << "iprot#readMessageEnd;" << endl; + f_service_ << indent() << "iprot#readMessageEnd;" << '\n'; // Careful, only return _result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { - f_service_ << indent() << "match result#get_success with Some v -> v | None -> (" << endl; + f_service_ << indent() << "match result#get_success with Some v -> v | None -> (" << '\n'; indent_up(); } vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << indent() << "(match result#get_" << (*x_iter)->get_name() - << " with None -> () | Some _v ->" << endl; + << " with None -> () | Some _v ->" << '\n'; indent(f_service_) << " raise (" << capitalize(exception_ctor((*x_iter)->get_type())) - << " _v));" << endl; + << " _v));" << '\n'; } // Careful, only return _result if not a void function if ((*f_iter)->get_returntype()->is_void()) { - indent(f_service_) << "()" << endl; + indent(f_service_) << "()" << '\n'; } else { f_service_ << indent() << "raise (Application_Exn.E (Application_Exn.create Application_Exn.MISSING_RESULT \"" - << (*f_iter)->get_name() << " failed: unknown result\")))" << endl; + << (*f_iter)->get_name() << " failed: unknown result\")))" << '\n'; indent_down(); } @@ -1127,8 +1125,8 @@ void t_ocaml_generator::generate_service_client(t_service* tservice) { } indent_down(); - indent(f_service_) << "end" << endl << endl; - indent(f_service_i_) << "end" << endl << endl; + indent(f_service_) << "end" << '\n' << '\n'; + indent(f_service_i_) << "end" << '\n' << '\n'; } /** @@ -1142,50 +1140,50 @@ void t_ocaml_generator::generate_service_server(t_service* tservice) { vector::iterator f_iter; // Generate the header portion - indent(f_service_) << "class processor (handler : iface) =" << endl << indent() << "object (self)" - << endl; - indent(f_service_i_) << "class processor : iface ->" << endl << indent() << "object" << endl; + indent(f_service_) << "class processor (handler : iface) =" << '\n' << indent() << "object (self)" + << '\n'; + indent(f_service_i_) << "class processor : iface ->" << '\n' << indent() << "object" << '\n'; indent_up(); - f_service_ << indent() << "inherit Processor.t" << endl << endl; - f_service_i_ << indent() << "inherit Processor.t" << endl << endl; + f_service_ << indent() << "inherit Processor.t" << '\n' << '\n'; + f_service_i_ << indent() << "inherit Processor.t" << '\n' << '\n'; string extends = ""; if (tservice->get_extends() != nullptr) { extends = type_name(tservice->get_extends()); indent(f_service_) << "inherit " + extends + ".processor (handler :> " + extends + ".iface)" - << endl; - indent(f_service_i_) << "inherit " + extends + ".processor" << endl; + << '\n'; + indent(f_service_i_) << "inherit " + extends + ".processor" << '\n'; } if (extends.empty()) { - indent(f_service_) << "val processMap = Hashtbl.create " << functions.size() << endl; + indent(f_service_) << "val processMap = Hashtbl.create " << functions.size() << '\n'; } indent(f_service_i_) - << "val processMap : (string, int * Protocol.t * Protocol.t -> unit) Hashtbl.t" << endl; + << "val processMap : (string, int * Protocol.t * Protocol.t -> unit) Hashtbl.t" << '\n'; // Generate the server implementation - indent(f_service_) << "method process iprot oprot =" << endl; - indent(f_service_i_) << "method process : Protocol.t -> Protocol.t -> bool" << endl; + indent(f_service_) << "method process iprot oprot =" << '\n'; + indent(f_service_i_) << "method process : Protocol.t -> Protocol.t -> bool" << '\n'; indent_up(); - f_service_ << indent() << "let (name, typ, seqid) = iprot#readMessageBegin in" << endl; + f_service_ << indent() << "let (name, typ, seqid) = iprot#readMessageBegin in" << '\n'; indent_up(); // TODO(mcslee): validate message // HOT: dictionary function lookup - f_service_ << indent() << "if Hashtbl.mem processMap name then" << endl << indent() - << " (Hashtbl.find processMap name) (seqid, iprot, oprot)" << endl << indent() - << "else (" << endl << indent() << " iprot#skip(Protocol.T_STRUCT);" << endl - << indent() << " iprot#readMessageEnd;" << endl << indent() + f_service_ << indent() << "if Hashtbl.mem processMap name then" << '\n' << indent() + << " (Hashtbl.find processMap name) (seqid, iprot, oprot)" << '\n' << indent() + << "else (" << '\n' << indent() << " iprot#skip(Protocol.T_STRUCT);" << '\n' + << indent() << " iprot#readMessageEnd;" << '\n' << indent() << " let x = Application_Exn.create Application_Exn.UNKNOWN_METHOD (\"Unknown " - "function \"^name) in" << endl << indent() - << " oprot#writeMessageBegin(name, Protocol.EXCEPTION, seqid);" << endl << indent() - << " x#write oprot;" << endl << indent() << " oprot#writeMessageEnd;" << endl - << indent() << " oprot#getTransport#flush" << endl << indent() << ");" << endl; + "function \"^name) in" << '\n' << indent() + << " oprot#writeMessageBegin(name, Protocol.EXCEPTION, seqid);" << '\n' << indent() + << " x#write oprot;" << '\n' << indent() << " oprot#writeMessageEnd;" << '\n' + << indent() << " oprot#getTransport#flush" << '\n' << indent() << ");" << '\n'; // Read end of args field, the T_STOP, and the struct close - f_service_ << indent() << "true" << endl; + f_service_ << indent() << "true" << '\n'; indent_down(); indent_down(); // Generate the process subfunctions @@ -1193,17 +1191,17 @@ void t_ocaml_generator::generate_service_server(t_service* tservice) { generate_process_function(tservice, *f_iter); } - indent(f_service_) << "initializer" << endl; + indent(f_service_) << "initializer" << '\n'; indent_up(); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { f_service_ << indent() << "Hashtbl.add processMap \"" << (*f_iter)->get_name() - << "\" self#process_" << (*f_iter)->get_name() << ";" << endl; + << "\" self#process_" << (*f_iter)->get_name() << ";" << '\n'; } indent_down(); indent_down(); - indent(f_service_) << "end" << endl << endl; - indent(f_service_i_) << "end" << endl << endl; + indent(f_service_) << "end" << '\n' << '\n'; + indent(f_service_i_) << "end" << '\n' << '\n'; } /** @@ -1215,7 +1213,7 @@ void t_ocaml_generator::generate_process_function(t_service* tservice, t_functio (void)tservice; // Open function indent(f_service_) << "method private process_" << tfunction->get_name() - << " (seqid, iprot, oprot) =" << endl; + << " (seqid, iprot, oprot) =" << '\n'; indent_up(); string argsname = decapitalize(tfunction->get_name()) + "_args"; @@ -1231,9 +1229,9 @@ void t_ocaml_generator::generate_process_function(t_service* tservice, t_functio args = "_"; } - f_service_ << indent() << "let " << args << " = read_" << argsname << " iprot in" << endl; + f_service_ << indent() << "let " << args << " = read_" << argsname << " iprot in" << '\n'; indent_up(); - f_service_ << indent() << "iprot#readMessageEnd;" << endl; + f_service_ << indent() << "iprot#readMessageEnd;" << '\n'; t_struct* xs = tfunction->get_xceptions(); const std::vector& xceptions = xs->get_members(); @@ -1241,13 +1239,13 @@ void t_ocaml_generator::generate_process_function(t_service* tservice, t_functio // Declare result for non oneway function if (!tfunction->is_oneway()) { - f_service_ << indent() << "let result = new " << resultname << " in" << endl; + f_service_ << indent() << "let result = new " << resultname << " in" << '\n'; indent_up(); } // Try block for a function with exceptions if (xceptions.size() > 0) { - f_service_ << indent() << "(try" << endl; + f_service_ << indent() << "(try" << '\n'; indent_up(); } @@ -1259,20 +1257,20 @@ void t_ocaml_generator::generate_process_function(t_service* tservice, t_functio for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { f_service_ << " args#get_" << (*f_iter)->get_name(); } - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; if (xceptions.size() > 0) { indent_down(); - indent(f_service_) << "with" << endl; + indent(f_service_) << "with" << '\n'; indent_up(); for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << indent() << "| " << capitalize(exception_ctor((*x_iter)->get_type())) << " " - << (*x_iter)->get_name() << " -> " << endl; + << (*x_iter)->get_name() << " -> " << '\n'; indent_up(); indent_up(); if (!tfunction->is_oneway()) { f_service_ << indent() << "result#set_" << (*x_iter)->get_name() << " " - << (*x_iter)->get_name() << endl; + << (*x_iter)->get_name() << '\n'; } else { indent(f_service_) << "()"; } @@ -1280,21 +1278,21 @@ void t_ocaml_generator::generate_process_function(t_service* tservice, t_functio indent_down(); } indent_down(); - f_service_ << indent() << ");" << endl; + f_service_ << indent() << ");" << '\n'; } // Shortcut out here for oneway functions if (tfunction->is_oneway()) { - f_service_ << indent() << "()" << endl; + f_service_ << indent() << "()" << '\n'; indent_down(); indent_down(); return; } f_service_ << indent() << "oprot#writeMessageBegin (\"" << tfunction->get_name() - << "\", Protocol.REPLY, seqid);" << endl << indent() << "result#write oprot;" << endl - << indent() << "oprot#writeMessageEnd;" << endl << indent() - << "oprot#getTransport#flush" << endl; + << "\", Protocol.REPLY, seqid);" << '\n' << indent() << "result#write oprot;" << '\n' + << indent() << "oprot#writeMessageEnd;" << '\n' << indent() + << "oprot#getTransport#flush" << '\n'; // Close function indent_down(); @@ -1311,7 +1309,7 @@ void t_ocaml_generator::generate_deserialize_field(ostream& out, t_field* tfield string name = decapitalize(tfield->get_name()); indent(out) << prefix << "#set_" << name << " "; generate_deserialize_type(out, type); - out << endl; + out << '\n'; } /** @@ -1396,46 +1394,46 @@ void t_ocaml_generator::generate_deserialize_container(ostream& out, t_type* tty t_field fvtype(g_type_i8, vtype); t_field fetype(g_type_i8, etype); - out << endl; + out << '\n'; indent_up(); // Declare variables, read header if (ttype->is_map()) { indent(out) << "(let (" << ktype << "," << vtype << "," << size << ") = iprot#readMapBegin in" - << endl; - indent(out) << "let " << con << " = Hashtbl.create " << size << " in" << endl; + << '\n'; + indent(out) << "let " << con << " = Hashtbl.create " << size << " in" << '\n'; indent_up(); - indent(out) << "for i = 1 to " << size << " do" << endl; + indent(out) << "for i = 1 to " << size << " do" << '\n'; indent_up(); indent(out) << "let _k = "; generate_deserialize_type(out, ((t_map*)ttype)->get_key_type()); - out << " in" << endl; + out << " in" << '\n'; indent(out) << "let _v = "; generate_deserialize_type(out, ((t_map*)ttype)->get_val_type()); - out << " in" << endl; + out << " in" << '\n'; indent_up(); - indent(out) << "Hashtbl.add " << con << " _k _v" << endl; + indent(out) << "Hashtbl.add " << con << " _k _v" << '\n'; indent_down(); indent_down(); indent(out) << "done; iprot#readMapEnd; " << con << ")"; indent_down(); } else if (ttype->is_set()) { - indent(out) << "(let (" << etype << "," << size << ") = iprot#readSetBegin in" << endl; - indent(out) << "let " << con << " = Hashtbl.create " << size << " in" << endl; + indent(out) << "(let (" << etype << "," << size << ") = iprot#readSetBegin in" << '\n'; + indent(out) << "let " << con << " = Hashtbl.create " << size << " in" << '\n'; indent_up(); - indent(out) << "for i = 1 to " << size << " do" << endl; + indent(out) << "for i = 1 to " << size << " do" << '\n'; indent_up(); indent(out) << "Hashtbl.add " << con << " "; generate_deserialize_type(out, ((t_set*)ttype)->get_elem_type()); - out << " true" << endl; + out << " true" << '\n'; indent_down(); indent(out) << "done; iprot#readSetEnd; " << con << ")"; indent_down(); } else if (ttype->is_list()) { - indent(out) << "(let (" << etype << "," << size << ") = iprot#readListBegin in" << endl; + indent(out) << "(let (" << etype << "," << size << ") = iprot#readListBegin in" << '\n'; indent_up(); indent(out) << "let " << con << " = (Array.to_list (Array.init " << size << " (fun _ -> "; generate_deserialize_type(out, ((t_list*)ttype)->get_elem_type()); - out << "))) in" << endl; + out << "))) in" << '\n'; indent_up(); indent(out) << "iprot#readListEnd; " << con << ")"; indent_down(); @@ -1510,7 +1508,7 @@ void t_ocaml_generator::generate_serialize_field(ostream& out, t_field* tfield, tfield->get_name().c_str(), type->get_name().c_str()); } - out << ";" << endl; + out << ";" << '\n'; } /** @@ -1528,38 +1526,38 @@ void t_ocaml_generator::generate_serialize_container(ostream& out, t_type* ttype if (ttype->is_map()) { indent(out) << "oprot#writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ","; out << type_to_enum(((t_map*)ttype)->get_val_type()) << ","; - out << "Hashtbl.length " << prefix << ");" << endl; + out << "Hashtbl.length " << prefix << ");" << '\n'; } else if (ttype->is_set()) { indent(out) << "oprot#writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ","; - out << "Hashtbl.length " << prefix << ");" << endl; + out << "Hashtbl.length " << prefix << ");" << '\n'; } else if (ttype->is_list()) { indent(out) << "oprot#writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ","; - out << "List.length " << prefix << ");" << endl; + out << "List.length " << prefix << ");" << '\n'; } if (ttype->is_map()) { string kiter = tmp("_kiter"); string viter = tmp("_viter"); - indent(out) << "Hashtbl.iter (fun " << kiter << " -> fun " << viter << " -> " << endl; + indent(out) << "Hashtbl.iter (fun " << kiter << " -> fun " << viter << " -> " << '\n'; indent_up(); generate_serialize_map_element(out, (t_map*)ttype, kiter, viter); indent_down(); - indent(out) << ") " << prefix << ";" << endl; + indent(out) << ") " << prefix << ";" << '\n'; } else if (ttype->is_set()) { string iter = tmp("_iter"); indent(out) << "Hashtbl.iter (fun " << iter << " -> fun _ -> "; indent_up(); generate_serialize_set_element(out, (t_set*)ttype, iter); indent_down(); - indent(out) << ") " << prefix << ";" << endl; + indent(out) << ") " << prefix << ";" << '\n'; } else if (ttype->is_list()) { string iter = tmp("_iter"); indent(out) << "List.iter (fun " << iter << " -> "; indent_up(); generate_serialize_list_element(out, (t_list*)ttype, iter); indent_down(); - indent(out) << ") " << prefix << ";" << endl; + indent(out) << ") " << prefix << ";" << '\n'; } if (ttype->is_map()) { diff --git a/compiler/cpp/src/thrift/generate/t_oop_generator.h b/compiler/cpp/src/thrift/generate/t_oop_generator.h index 88419620333..07b621639f7 100644 --- a/compiler/cpp/src/thrift/generate/t_oop_generator.h +++ b/compiler/cpp/src/thrift/generate/t_oop_generator.h @@ -42,13 +42,13 @@ class t_oop_generator : public t_generator { */ void scope_up(std::ostream& out) { - indent(out) << "{" << std::endl; + indent(out) << "{" << '\n'; indent_up(); } void scope_down(std::ostream& out) { indent_down(); - indent(out) << "}" << std::endl; + indent(out) << "}" << '\n'; } std::string upcase_string(std::string original) { diff --git a/compiler/cpp/src/thrift/generate/t_perl_generator.cc b/compiler/cpp/src/thrift/generate/t_perl_generator.cc index d133b2455b5..8e533ca2903 100644 --- a/compiler/cpp/src/thrift/generate/t_perl_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_perl_generator.cc @@ -37,8 +37,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * PERL code generator. * @@ -246,8 +244,8 @@ void t_perl_generator::init_generator() { f_types_ << autogen_comment() << perl_includes(); // Print header - f_consts_ << autogen_comment() << "package " << perl_namespace(program_) << "Constants;" << endl - << perl_includes() << endl; + f_consts_ << autogen_comment() << "package " << perl_namespace(program_) << "Constants;" << '\n' + << perl_includes() << '\n'; } /** @@ -271,10 +269,10 @@ string t_perl_generator::perl_includes() { */ void t_perl_generator::close_generator() { // Close types file - f_types_ << "1;" << endl; + f_types_ << "1;" << '\n'; f_types_.close(); - f_consts_ << "1;" << endl; + f_consts_ << "1;" << '\n'; f_consts_.close(); } @@ -294,13 +292,13 @@ void t_perl_generator::generate_typedef(t_typedef* ttypedef) { * @param tenum The enumeration */ void t_perl_generator::generate_enum(t_enum* tenum) { - f_types_ << "package " << perl_namespace(program_) << tenum->get_name() << ";" << endl; + f_types_ << "package " << perl_namespace(program_) << tenum->get_name() << ";" << '\n'; vector constants = tenum->get_constants(); vector::iterator c_iter; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); - f_types_ << "use constant " << (*c_iter)->get_name() << " => " << value << ";" << endl; + f_types_ << "use constant " << (*c_iter)->get_name() << " => " << value << ";" << '\n'; } } @@ -314,7 +312,7 @@ void t_perl_generator::generate_const(t_const* tconst) { f_consts_ << "use constant " << name << " => "; f_consts_ << render_const_value(type, value); - f_consts_ << ";" << endl << endl; + f_consts_ << ";" << '\n' << '\n'; } /** @@ -355,7 +353,7 @@ string t_perl_generator::render_const_value(t_type* type, t_const_value* value) } else if (type->is_enum()) { out << value->get_integer(); } else if (type->is_struct() || type->is_xception()) { - out << perl_namespace(type->get_program()) << type->get_name() << "->new({" << endl; + out << perl_namespace(type->get_program()) << type->get_name() << "->new({" << '\n'; indent_up(); const vector& fields = ((t_struct*)type)->get_members(); @@ -376,14 +374,14 @@ string t_perl_generator::render_const_value(t_type* type, t_const_value* value) out << " => "; out << render_const_value(field_type, v_iter->second); out << ","; - out << endl; + out << '\n'; } indent_down(); indent(out) << "})"; } else if (type->is_map()) { t_type* ktype = ((t_map*)type)->get_key_type(); t_type* vtype = ((t_map*)type)->get_val_type(); - out << "{" << endl; + out << "{" << '\n'; indent_up(); const map& val = value->get_map(); @@ -392,7 +390,7 @@ string t_perl_generator::render_const_value(t_type* type, t_const_value* value) indent(out) << render_const_value(ktype, v_iter->first); out << " => "; out << render_const_value(vtype, v_iter->second); - out << "," << endl; + out << "," << '\n'; } indent_down(); indent(out) << "}"; @@ -403,7 +401,7 @@ string t_perl_generator::render_const_value(t_type* type, t_const_value* value) } else { etype = ((t_set*)type)->get_elem_type(); } - out << "[" << endl; + out << "[" << '\n'; indent_up(); const vector& val = value->get_list(); @@ -414,7 +412,7 @@ string t_perl_generator::render_const_value(t_type* type, t_const_value* value) if (type->is_set()) { out << " => 1"; } - out << "," << endl; + out << "," << '\n'; } indent_down(); indent(out) << "]"; @@ -480,12 +478,12 @@ void t_perl_generator::generate_perl_struct_definition(ostream& out, out << ") );\n"; } - out << endl; + out << '\n'; // new() indent_up(); - out << "sub new {" << endl << indent() << "my $classname = shift;" << endl << indent() - << "my $self = {};" << endl << indent() << "my $vals = shift || {};" << endl; + out << "sub new {" << '\n' << indent() << "my $classname = shift;" << '\n' << indent() + << "my $self = {};" << '\n' << indent() << "my $vals = shift || {};" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { string dval = "undef"; @@ -493,7 +491,7 @@ void t_perl_generator::generate_perl_struct_definition(ostream& out, if ((*m_iter)->get_value() != nullptr && !(t->is_struct() || t->is_xception())) { dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value()); } - out << indent() << "$self->{" << (*m_iter)->get_name() << "} = " << dval << ";" << endl; + out << indent() << "$self->{" << (*m_iter)->get_name() << "} = " << dval << ";" << '\n'; } // Generate constructor from array @@ -503,27 +501,27 @@ void t_perl_generator::generate_perl_struct_definition(ostream& out, t_type* t = get_true_type((*m_iter)->get_type()); if ((*m_iter)->get_value() != nullptr && (t->is_struct() || t->is_xception())) { indent(out) << "$self->{" << (*m_iter)->get_name() - << "} = " << render_const_value(t, (*m_iter)->get_value()) << ";" << endl; + << "} = " << render_const_value(t, (*m_iter)->get_value()) << ";" << '\n'; } } - out << indent() << "if (UNIVERSAL::isa($vals,'HASH')) {" << endl; + out << indent() << "if (UNIVERSAL::isa($vals,'HASH')) {" << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - out << indent() << "if (defined $vals->{" << (*m_iter)->get_name() << "}) {" << endl + out << indent() << "if (defined $vals->{" << (*m_iter)->get_name() << "}) {" << '\n' << indent() << " $self->{" << (*m_iter)->get_name() << "} = $vals->{" - << (*m_iter)->get_name() << "};" << endl << indent() << "}" << endl; + << (*m_iter)->get_name() << "};" << '\n' << indent() << "}" << '\n'; } indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } - out << indent() << "return bless ($self, $classname);" << endl; + out << indent() << "return bless ($self, $classname);" << '\n'; indent_down(); out << "}\n\n"; - out << "sub getName {" << endl << indent() << " return '" << tstruct->get_name() << "';" << endl - << indent() << "}" << endl << endl; + out << "sub getName {" << '\n' << indent() << " return '" << tstruct->get_name() << "';" << '\n' + << indent() << "}" << '\n' << '\n'; generate_perl_struct_reader(out, tstruct); generate_perl_struct_writer(out, tstruct); @@ -536,32 +534,32 @@ void t_perl_generator::generate_perl_struct_reader(ostream& out, t_struct* tstru const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - out << "sub read {" << endl; + out << "sub read {" << '\n'; indent_up(); - out << indent() << "my ($self, $input) = @_;" << endl << indent() << "my $xfer = 0;" << endl - << indent() << "my $fname;" << endl << indent() << "my $ftype = 0;" << endl << indent() - << "my $fid = 0;" << endl; + out << indent() << "my ($self, $input) = @_;" << '\n' << indent() << "my $xfer = 0;" << '\n' + << indent() << "my $fname;" << '\n' << indent() << "my $ftype = 0;" << '\n' << indent() + << "my $fid = 0;" << '\n'; - indent(out) << "$xfer += $input->readStructBegin(\\$fname);" << endl; + indent(out) << "$xfer += $input->readStructBegin(\\$fname);" << '\n'; // Loop over reading in fields - indent(out) << "while (1)" << endl; + indent(out) << "while (1)" << '\n'; scope_up(out); - indent(out) << "$xfer += $input->readFieldBegin(\\$fname, \\$ftype, \\$fid);" << endl; + indent(out) << "$xfer += $input->readFieldBegin(\\$fname, \\$ftype, \\$fid);" << '\n'; // Check for field STOP marker and break - indent(out) << "if ($ftype == Thrift::TType::STOP) {" << endl; + indent(out) << "if ($ftype == Thrift::TType::STOP) {" << '\n'; indent_up(); - indent(out) << "last;" << endl; + indent(out) << "last;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; // Switch statement on the field we are reading - indent(out) << "SWITCH: for($fid)" << endl; + indent(out) << "SWITCH: for($fid)" << '\n'; scope_up(out); @@ -569,34 +567,34 @@ void t_perl_generator::generate_perl_struct_reader(ostream& out, t_struct* tstru for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { indent(out) << "/^" << (*f_iter)->get_key() << "$/ && do{"; - indent(out) << "if ($ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl; + indent(out) << "if ($ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n'; indent_up(); generate_deserialize_field(out, *f_iter, "self->"); indent_down(); - indent(out) << "} else {" << endl; + indent(out) << "} else {" << '\n'; - indent(out) << " $xfer += $input->skip($ftype);" << endl; + indent(out) << " $xfer += $input->skip($ftype);" << '\n'; - out << indent() << "}" << endl << indent() << "last; };" << endl; + out << indent() << "}" << '\n' << indent() << "last; };" << '\n'; } // In the default case we skip the field - indent(out) << " $xfer += $input->skip($ftype);" << endl; + indent(out) << " $xfer += $input->skip($ftype);" << '\n'; scope_down(out); - indent(out) << "$xfer += $input->readFieldEnd();" << endl; + indent(out) << "$xfer += $input->readFieldEnd();" << '\n'; scope_down(out); - indent(out) << "$xfer += $input->readStructEnd();" << endl; + indent(out) << "$xfer += $input->readStructEnd();" << '\n'; - indent(out) << "return $xfer;" << endl; + indent(out) << "return $xfer;" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } /** @@ -607,38 +605,38 @@ void t_perl_generator::generate_perl_struct_writer(ostream& out, t_struct* tstru const vector& fields = tstruct->get_sorted_members(); vector::const_iterator f_iter; - out << "sub write {" << endl; + out << "sub write {" << '\n'; indent_up(); - indent(out) << "my ($self, $output) = @_;" << endl; - indent(out) << "my $xfer = 0;" << endl; + indent(out) << "my ($self, $output) = @_;" << '\n'; + indent(out) << "my $xfer = 0;" << '\n'; - indent(out) << "$xfer += $output->writeStructBegin('" << name << "');" << endl; + indent(out) << "$xfer += $output->writeStructBegin('" << name << "');" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - out << indent() << "if (defined $self->{" << (*f_iter)->get_name() << "}) {" << endl; + out << indent() << "if (defined $self->{" << (*f_iter)->get_name() << "}) {" << '\n'; indent_up(); indent(out) << "$xfer += $output->writeFieldBegin(" << "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type()) - << ", " << (*f_iter)->get_key() << ");" << endl; + << ", " << (*f_iter)->get_key() << ");" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "self->"); - indent(out) << "$xfer += $output->writeFieldEnd();" << endl; + indent(out) << "$xfer += $output->writeFieldEnd();" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } - out << indent() << "$xfer += $output->writeFieldStop();" << endl << indent() - << "$xfer += $output->writeStructEnd();" << endl; + out << indent() << "$xfer += $output->writeFieldStop();" << '\n' << indent() + << "$xfer += $output->writeStructEnd();" << '\n'; - out << indent() << "return $xfer;" << endl; + out << indent() << "return $xfer;" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; } /** @@ -655,13 +653,13 @@ void t_perl_generator::generate_use_includes(std::ostream& os, bool& done, t_typ std::vector& currInc = current->get_includes(); std::vector::size_type numInc = currInc.size(); if (selfish) { - os << "use " << perl_namespace(current) << "Types;" << endl; + os << "use " << perl_namespace(current) << "Types;" << '\n'; } for (std::vector::size_type i = 0; i < numInc; ++i) { t_program* incProgram = currInc.at(i); - os << "use " << perl_namespace(incProgram) << "Types;" << endl; + os << "use " << perl_namespace(incProgram) << "Types;" << '\n'; } - os << endl; + os << '\n'; done = true; } } @@ -683,10 +681,10 @@ void t_perl_generator::generate_service(t_service* tservice) { t_service* extends_s = tservice->get_extends(); if (extends_s != nullptr) { f_service_ << "use " << perl_namespace(extends_s->get_program()) << extends_s->get_name() << ";" - << endl; + << '\n'; } - f_service_ << endl; + f_service_ << '\n'; // Generate the three main parts of the service (well, two for now in PERL) generate_service_helpers(tservice); @@ -696,7 +694,7 @@ void t_perl_generator::generate_service(t_service* tservice) { generate_service_processor(tservice); // Close service file - f_service_ << "1;" << endl; + f_service_ << "1;" << '\n'; f_service_.close(); } @@ -721,59 +719,59 @@ void t_perl_generator::generate_service_processor(t_service* tservice) { indent_up(); // Generate the header portion - f_service_ << "package " << perl_namespace(program_) << service_name_ << "Processor;" << endl - << endl << "use strict;" << endl << extends_processor << endl << endl; + f_service_ << "package " << perl_namespace(program_) << service_name_ << "Processor;" << '\n' + << '\n' << "use strict;" << '\n' << extends_processor << '\n' << '\n'; if (extends.empty()) { - f_service_ << "sub new {" << endl; + f_service_ << "sub new {" << '\n'; indent_up(); - f_service_ << indent() << "my ($classname, $handler) = @_;" << endl << indent() - << "my $self = {};" << endl; + f_service_ << indent() << "my ($classname, $handler) = @_;" << '\n' << indent() + << "my $self = {};" << '\n'; - f_service_ << indent() << "$self->{handler} = $handler;" << endl; + f_service_ << indent() << "$self->{handler} = $handler;" << '\n'; - f_service_ << indent() << "return bless ($self, $classname);" << endl; + f_service_ << indent() << "return bless ($self, $classname);" << '\n'; indent_down(); - f_service_ << "}" << endl << endl; + f_service_ << "}" << '\n' << '\n'; } // Generate the server implementation - f_service_ << "sub process {" << endl; + f_service_ << "sub process {" << '\n'; indent_up(); - f_service_ << indent() << "my ($self, $input, $output) = @_;" << endl; + f_service_ << indent() << "my ($self, $input, $output) = @_;" << '\n'; - f_service_ << indent() << "my $rseqid = 0;" << endl << indent() << "my $fname = undef;" << endl - << indent() << "my $mtype = 0;" << endl << endl; + f_service_ << indent() << "my $rseqid = 0;" << '\n' << indent() << "my $fname = undef;" << '\n' + << indent() << "my $mtype = 0;" << '\n' << '\n'; - f_service_ << indent() << "$input->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);" << endl; + f_service_ << indent() << "$input->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);" << '\n'; // HOT: check for method implementation - f_service_ << indent() << "my $methodname = 'process_'.$fname;" << endl << indent() - << "if (!$self->can($methodname)) {" << endl; + f_service_ << indent() << "my $methodname = 'process_'.$fname;" << '\n' << indent() + << "if (!$self->can($methodname)) {" << '\n'; indent_up(); - f_service_ << indent() << "$input->skip(Thrift::TType::STRUCT);" << endl << indent() - << "$input->readMessageEnd();" << endl << indent() + f_service_ << indent() << "$input->skip(Thrift::TType::STRUCT);" << '\n' << indent() + << "$input->readMessageEnd();" << '\n' << indent() << "my $x = Thrift::TApplicationException->new('Function '.$fname.' not implemented.', " - "Thrift::TApplicationException::UNKNOWN_METHOD);" << endl << indent() - << "$output->writeMessageBegin($fname, Thrift::TMessageType::EXCEPTION, $rseqid);" << endl - << indent() << "$x->write($output);" << endl << indent() - << "$output->writeMessageEnd();" << endl << indent() - << "$output->getTransport()->flush();" << endl << indent() << "return;" << endl; + "Thrift::TApplicationException::UNKNOWN_METHOD);" << '\n' << indent() + << "$output->writeMessageBegin($fname, Thrift::TMessageType::EXCEPTION, $rseqid);" << '\n' + << indent() << "$x->write($output);" << '\n' << indent() + << "$output->writeMessageEnd();" << '\n' << indent() + << "$output->getTransport()->flush();" << '\n' << indent() << "return;" << '\n'; indent_down(); - f_service_ << indent() << "}" << endl << indent() - << "$self->$methodname($rseqid, $input, $output);" << endl << indent() << "return 1;" - << endl; + f_service_ << indent() << "}" << '\n' << indent() + << "$self->$methodname($rseqid, $input, $output);" << '\n' << indent() << "return 1;" + << '\n'; indent_down(); - f_service_ << "}" << endl << endl; + f_service_ << "}" << '\n' << '\n'; // Generate the process subfunctions for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -788,21 +786,21 @@ void t_perl_generator::generate_service_processor(t_service* tservice) { */ void t_perl_generator::generate_process_function(t_service* tservice, t_function* tfunction) { // Open function - f_service_ << "sub process_" << tfunction->get_name() << " {" << endl; + f_service_ << "sub process_" << tfunction->get_name() << " {" << '\n'; indent_up(); - f_service_ << indent() << "my ($self, $seqid, $input, $output) = @_;" << endl; + f_service_ << indent() << "my ($self, $seqid, $input, $output) = @_;" << '\n'; string argsname = perl_namespace(tservice->get_program()) + service_name_ + "_" + tfunction->get_name() + "_args"; string resultname = perl_namespace(tservice->get_program()) + service_name_ + "_" + tfunction->get_name() + "_result"; - f_service_ << indent() << "my $args = " << argsname << "->new();" << endl << indent() - << "$args->read($input);" << endl; + f_service_ << indent() << "my $args = " << argsname << "->new();" << '\n' << indent() + << "$args->read($input);" << '\n'; - f_service_ << indent() << "$input->readMessageEnd();" << endl; + f_service_ << indent() << "$input->readMessageEnd();" << '\n'; t_struct* xs = tfunction->get_xceptions(); const std::vector& xceptions = xs->get_members(); @@ -810,12 +808,12 @@ void t_perl_generator::generate_process_function(t_service* tservice, t_function // Declare result for non oneway function if (!tfunction->is_oneway()) { - f_service_ << indent() << "my $result = " << resultname << "->new();" << endl; + f_service_ << indent() << "my $result = " << resultname << "->new();" << '\n'; } // Try block for a function with exceptions if (xceptions.size() > 0) { - f_service_ << indent() << "eval {" << endl; + f_service_ << indent() << "eval {" << '\n'; indent_up(); } @@ -838,55 +836,55 @@ void t_perl_generator::generate_process_function(t_service* tservice, t_function } f_service_ << "$args->" << (*f_iter)->get_name(); } - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; if (!tfunction->is_oneway() && xceptions.size() > 0) { indent_down(); for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << indent() << "}; if( UNIVERSAL::isa($@,'" << perl_namespace((*x_iter)->get_type()->get_program()) - << (*x_iter)->get_type()->get_name() << "') ){ " << endl; + << (*x_iter)->get_type()->get_name() << "') ){ " << '\n'; indent_up(); - f_service_ << indent() << "$result->{" << (*x_iter)->get_name() << "} = $@;" << endl; - f_service_ << indent() << "$@ = undef;" << endl; + f_service_ << indent() << "$result->{" << (*x_iter)->get_name() << "} = $@;" << '\n'; + f_service_ << indent() << "$@ = undef;" << '\n'; indent_down(); f_service_ << indent(); } - f_service_ << "}" << endl; + f_service_ << "}" << '\n'; // catch-all for unexpected exceptions (THRIFT-3191) - f_service_ << indent() << "if ($@) {" << endl; + f_service_ << indent() << "if ($@) {" << '\n'; indent_up(); - f_service_ << indent() << "$@ =~ s/^\\s+|\\s+$//g;" << endl - << indent() << "my $err = Thrift::TApplicationException->new(\"Unexpected Exception: \" . $@, Thrift::TApplicationException::INTERNAL_ERROR);" << endl - << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', Thrift::TMessageType::EXCEPTION, $seqid);" << endl - << indent() << "$err->write($output);" << endl - << indent() << "$output->writeMessageEnd();" << endl - << indent() << "$output->getTransport()->flush();" << endl - << indent() << "$@ = undef;" << endl - << indent() << "return;" << endl; + f_service_ << indent() << "$@ =~ s/^\\s+|\\s+$//g;" << '\n' + << indent() << "my $err = Thrift::TApplicationException->new(\"Unexpected Exception: \" . $@, Thrift::TApplicationException::INTERNAL_ERROR);" << '\n' + << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', Thrift::TMessageType::EXCEPTION, $seqid);" << '\n' + << indent() << "$err->write($output);" << '\n' + << indent() << "$output->writeMessageEnd();" << '\n' + << indent() << "$output->getTransport()->flush();" << '\n' + << indent() << "$@ = undef;" << '\n' + << indent() << "return;" << '\n'; indent_down(); - f_service_ << indent() << "}" << endl; + f_service_ << indent() << "}" << '\n'; } // Shortcut out here for oneway functions if (tfunction->is_oneway()) { - f_service_ << indent() << "return;" << endl; + f_service_ << indent() << "return;" << '\n'; indent_down(); - f_service_ << "}" << endl; + f_service_ << "}" << '\n'; return; } // Serialize the reply - f_service_ << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', Thrift::TMessageType::REPLY, $seqid);" << endl - << indent() << "$result->write($output);" << endl - << indent() << "$output->writeMessageEnd();" << endl - << indent() << "$output->getTransport()->flush();" << endl; + f_service_ << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', Thrift::TMessageType::REPLY, $seqid);" << '\n' + << indent() << "$result->write($output);" << '\n' + << indent() << "$output->writeMessageEnd();" << '\n' + << indent() << "$output->getTransport()->flush();" << '\n'; // Close function indent_down(); - f_service_ << "}" << endl << endl; + f_service_ << "}" << '\n' << '\n'; } /** @@ -898,7 +896,7 @@ void t_perl_generator::generate_service_helpers(t_service* tservice) { vector functions = tservice->get_functions(); vector::iterator f_iter; - f_service_ << "# HELPER FUNCTIONS AND STRUCTURES" << endl << endl; + f_service_ << "# HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { t_struct* ts = (*f_iter)->get_arglist(); @@ -945,15 +943,15 @@ void t_perl_generator::generate_service_interface(t_service* tservice) { + "If);"; } - f_service_ << "package " << perl_namespace(program_) << service_name_ << "If;" << endl << endl - << "use strict;" << endl << extends_if << endl << endl; + f_service_ << "package " << perl_namespace(program_) << service_name_ << "If;" << '\n' << '\n' + << "use strict;" << '\n' << extends_if << '\n' << '\n'; indent_up(); vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - f_service_ << "sub " << function_signature(*f_iter) << endl << " die 'implement interface';\n}" - << endl << endl; + f_service_ << "sub " << function_signature(*f_iter) << '\n' << " die 'implement interface';\n}" + << '\n' << '\n'; } indent_down(); } @@ -970,31 +968,31 @@ void t_perl_generator::generate_service_rest(t_service* tservice) { extends_if = "use base qw(" + perl_namespace(extends_s->get_program()) + extends_s->get_name() + "Rest);"; } - f_service_ << "package " << perl_namespace(program_) << service_name_ << "Rest;" << endl << endl - << "use strict;" << endl << extends_if << endl << endl; + f_service_ << "package " << perl_namespace(program_) << service_name_ << "Rest;" << '\n' << '\n' + << "use strict;" << '\n' << extends_if << '\n' << '\n'; if (extends.empty()) { - f_service_ << "sub new {" << endl; + f_service_ << "sub new {" << '\n'; indent_up(); - f_service_ << indent() << "my ($classname, $impl) = @_;" << endl << indent() - << "my $self ={ impl => $impl };" << endl << endl << indent() - << "return bless($self,$classname);" << endl; + f_service_ << indent() << "my ($classname, $impl) = @_;" << '\n' << indent() + << "my $self ={ impl => $impl };" << '\n' << '\n' << indent() + << "return bless($self,$classname);" << '\n'; indent_down(); - f_service_ << "}" << endl << endl; + f_service_ << "}" << '\n' << '\n'; } vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - f_service_ << "sub " << (*f_iter)->get_name() << "{" << endl; + f_service_ << "sub " << (*f_iter)->get_name() << "{" << '\n'; indent_up(); - f_service_ << indent() << "my ($self, $request) = @_;" << endl << endl; + f_service_ << indent() << "my ($self, $request) = @_;" << '\n' << '\n'; const vector& args = (*f_iter)->get_arglist()->get_members(); vector::const_iterator a_iter; @@ -1002,19 +1000,19 @@ void t_perl_generator::generate_service_rest(t_service* tservice) { //t_type* atype = get_true_type((*a_iter)->get_type()); string req = "$request->{'" + (*a_iter)->get_name() + "'}"; f_service_ << indent() << "my $" << (*a_iter)->get_name() << " = (" << req << ") ? " << req - << " : undef;" << endl; + << " : undef;" << '\n'; /* slist no longer supported if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) { f_service_ << indent() << "my @" << (*a_iter)->get_name() << " = split(/,/, $" - << (*a_iter)->get_name() << ");" << endl << indent() << "$" - << (*a_iter)->get_name() << " = \\@" << (*a_iter)->get_name() << endl; + << (*a_iter)->get_name() << ");" << '\n' << indent() << "$" + << (*a_iter)->get_name() << " = \\@" << (*a_iter)->get_name() << '\n'; } */ } f_service_ << indent() << "return $self->{impl}->" << (*f_iter)->get_name() << "(" - << argument_list((*f_iter)->get_arglist()) << ");" << endl; + << argument_list((*f_iter)->get_arglist()) << ");" << '\n'; indent_down(); - indent(f_service_) << "}" << endl << endl; + indent(f_service_) << "}" << '\n' << '\n'; } } @@ -1032,31 +1030,31 @@ void t_perl_generator::generate_service_client(t_service* tservice) { extends_client = "use base qw(" + extends + "Client);"; } - f_service_ << "package " << perl_namespace(program_) << service_name_ << "Client;" << endl << endl - << extends_client << endl << "use base qw(" << perl_namespace(program_) - << service_name_ << "If);" << endl; + f_service_ << "package " << perl_namespace(program_) << service_name_ << "Client;" << '\n' << '\n' + << extends_client << '\n' << "use base qw(" << perl_namespace(program_) + << service_name_ << "If);" << '\n'; // Constructor function - f_service_ << "sub new {" << endl; + f_service_ << "sub new {" << '\n'; indent_up(); - f_service_ << indent() << "my ($classname, $input, $output) = @_;" << endl << indent() - << "my $self = {};" << endl; + f_service_ << indent() << "my ($classname, $input, $output) = @_;" << '\n' << indent() + << "my $self = {};" << '\n'; if (!extends.empty()) { - f_service_ << indent() << "$self = $classname->SUPER::new($input, $output);" << endl; + f_service_ << indent() << "$self = $classname->SUPER::new($input, $output);" << '\n'; } else { - f_service_ << indent() << "$self->{input} = $input;" << endl << indent() - << "$self->{output} = defined $output ? $output : $input;" << endl << indent() - << "$self->{seqid} = 0;" << endl; + f_service_ << indent() << "$self->{input} = $input;" << '\n' << indent() + << "$self->{output} = defined $output ? $output : $input;" << '\n' << indent() + << "$self->{seqid} = 0;" << '\n'; } - f_service_ << indent() << "return bless($self,$classname);" << endl; + f_service_ << indent() << "return bless($self,$classname);" << '\n'; indent_down(); - f_service_ << "}" << endl << endl; + f_service_ << "}" << '\n' << '\n'; // Generate client method implementations vector functions = tservice->get_functions(); @@ -1068,7 +1066,7 @@ void t_perl_generator::generate_service_client(t_service* tservice) { string funname = (*f_iter)->get_name(); // Open function - f_service_ << "sub " << function_signature(*f_iter) << endl; + f_service_ << "sub " << function_signature(*f_iter) << '\n'; indent_up(); @@ -1083,21 +1081,21 @@ void t_perl_generator::generate_service_client(t_service* tservice) { } f_service_ << "$" << (*fld_iter)->get_name(); } - f_service_ << ");" << endl; + f_service_ << ");" << '\n'; if (!(*f_iter)->is_oneway()) { f_service_ << indent(); if (!(*f_iter)->get_returntype()->is_void()) { f_service_ << "return "; } - f_service_ << "$self->recv_" << funname << "();" << endl; + f_service_ << "$self->recv_" << funname << "();" << '\n'; } indent_down(); - f_service_ << "}" << endl << endl; + f_service_ << "}" << '\n' << '\n'; - f_service_ << "sub send_" << function_signature(*f_iter) << endl; + f_service_ << "sub send_" << function_signature(*f_iter) << '\n'; indent_up(); @@ -1107,23 +1105,23 @@ void t_perl_generator::generate_service_client(t_service* tservice) { // Serialize the request header f_service_ << indent() << "$self->{output}->writeMessageBegin('" << (*f_iter)->get_name() << "', " << ((*f_iter)->is_oneway() ? "Thrift::TMessageType::ONEWAY" : "Thrift::TMessageType::CALL") - << ", $self->{seqid});" << endl; + << ", $self->{seqid});" << '\n'; - f_service_ << indent() << "my $args = " << argsname << "->new();" << endl; + f_service_ << indent() << "my $args = " << argsname << "->new();" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_service_ << indent() << "$args->{" << (*fld_iter)->get_name() << "} = $" - << (*fld_iter)->get_name() << ";" << endl; + << (*fld_iter)->get_name() << ";" << '\n'; } // Write to the stream - f_service_ << indent() << "$args->write($self->{output});" << endl << indent() - << "$self->{output}->writeMessageEnd();" << endl << indent() - << "$self->{output}->getTransport()->flush();" << endl; + f_service_ << indent() << "$args->write($self->{output});" << '\n' << indent() + << "$self->{output}->writeMessageEnd();" << '\n' << indent() + << "$self->{output}->getTransport()->flush();" << '\n'; indent_down(); - f_service_ << "}" << endl; + f_service_ << "}" << '\n'; if (!(*f_iter)->is_oneway()) { std::string resultname = perl_namespace(tservice->get_program()) + service_name_ + "_" @@ -1134,29 +1132,29 @@ void t_perl_generator::generate_service_client(t_service* tservice) { string("recv_") + (*f_iter)->get_name(), &noargs); // Open function - f_service_ << endl << "sub " << function_signature(&recv_function) << endl; + f_service_ << '\n' << "sub " << function_signature(&recv_function) << '\n'; indent_up(); - f_service_ << indent() << "my $rseqid = 0;" << endl << indent() << "my $fname;" << endl - << indent() << "my $mtype = 0;" << endl << endl; + f_service_ << indent() << "my $rseqid = 0;" << '\n' << indent() << "my $fname;" << '\n' + << indent() << "my $mtype = 0;" << '\n' << '\n'; f_service_ << indent() << "$self->{input}->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);" - << endl << indent() << "if ($mtype == Thrift::TMessageType::EXCEPTION) {" << endl - << indent() << " my $x = Thrift::TApplicationException->new();" << endl << indent() - << " $x->read($self->{input});" << endl << indent() - << " $self->{input}->readMessageEnd();" << endl << indent() << " die $x;" << endl - << indent() << "}" << endl; + << '\n' << indent() << "if ($mtype == Thrift::TMessageType::EXCEPTION) {" << '\n' + << indent() << " my $x = Thrift::TApplicationException->new();" << '\n' << indent() + << " $x->read($self->{input});" << '\n' << indent() + << " $self->{input}->readMessageEnd();" << '\n' << indent() << " die $x;" << '\n' + << indent() << "}" << '\n'; - f_service_ << indent() << "my $result = " << resultname << "->new();" << endl << indent() - << "$result->read($self->{input});" << endl; + f_service_ << indent() << "my $result = " << resultname << "->new();" << '\n' << indent() + << "$result->read($self->{input});" << '\n'; - f_service_ << indent() << "$self->{input}->readMessageEnd();" << endl << endl; + f_service_ << indent() << "$self->{input}->readMessageEnd();" << '\n' << '\n'; // Careful, only return result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { - f_service_ << indent() << "if (defined $result->{success} ) {" << endl << indent() - << " return $result->{success};" << endl << indent() << "}" << endl; + f_service_ << indent() << "if (defined $result->{success} ) {" << '\n' << indent() + << " return $result->{success};" << '\n' << indent() << "}" << '\n'; } t_struct* xs = (*f_iter)->get_xceptions(); @@ -1164,21 +1162,21 @@ void t_perl_generator::generate_service_client(t_service* tservice) { vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << indent() << "if (defined $result->{" << (*x_iter)->get_name() << "}) {" - << endl << indent() << " die $result->{" << (*x_iter)->get_name() << "};" - << endl << indent() << "}" << endl; + << '\n' << indent() << " die $result->{" << (*x_iter)->get_name() << "};" + << '\n' << indent() << "}" << '\n'; } // Careful, only return _result if not a void function if ((*f_iter)->get_returntype()->is_void()) { - indent(f_service_) << "return;" << endl; + indent(f_service_) << "return;" << '\n'; } else { f_service_ << indent() << "die \"" << (*f_iter)->get_name() << " failed: unknown result\";" - << endl; + << '\n'; } // Close function indent_down(); - f_service_ << "}" << endl; + f_service_ << "}" << '\n'; } } } @@ -1244,7 +1242,7 @@ void t_perl_generator::generate_deserialize_field(ostream& out, } else if (type->is_enum()) { out << "readI32(\\$" << name << ");"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", @@ -1263,8 +1261,8 @@ void t_perl_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) { out << indent() << "$" << prefix << " = " << perl_namespace(tstruct->get_program()) - << tstruct->get_name() << "->new();" << endl << indent() << "$xfer += $" << prefix - << "->read($input);" << endl; + << tstruct->get_name() << "->new();" << '\n' << indent() << "$xfer += $" << prefix + << "->read($input);" << '\n'; } void t_perl_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) { @@ -1280,33 +1278,33 @@ void t_perl_generator::generate_deserialize_container(ostream& out, t_type* ttyp t_field fvtype(g_type_i8, vtype); t_field fetype(g_type_i8, etype); - out << indent() << "my $" << size << " = 0;" << endl; + out << indent() << "my $" << size << " = 0;" << '\n'; // Declare variables, read header if (ttype->is_map()) { - out << indent() << "$" << prefix << " = {};" << endl << indent() << "my $" << ktype << " = 0;" - << endl << indent() << "my $" << vtype << " = 0;" << endl; + out << indent() << "$" << prefix << " = {};" << '\n' << indent() << "my $" << ktype << " = 0;" + << '\n' << indent() << "my $" << vtype << " = 0;" << '\n'; out << indent() << "$xfer += $input->readMapBegin(" - << "\\$" << ktype << ", \\$" << vtype << ", \\$" << size << ");" << endl; + << "\\$" << ktype << ", \\$" << vtype << ", \\$" << size << ");" << '\n'; } else if (ttype->is_set()) { - out << indent() << "$" << prefix << " = {};" << endl << indent() << "my $" << etype << " = 0;" - << endl << indent() << "$xfer += $input->readSetBegin(" - << "\\$" << etype << ", \\$" << size << ");" << endl; + out << indent() << "$" << prefix << " = {};" << '\n' << indent() << "my $" << etype << " = 0;" + << '\n' << indent() << "$xfer += $input->readSetBegin(" + << "\\$" << etype << ", \\$" << size << ");" << '\n'; } else if (ttype->is_list()) { - out << indent() << "$" << prefix << " = [];" << endl << indent() << "my $" << etype << " = 0;" - << endl << indent() << "$xfer += $input->readListBegin(" - << "\\$" << etype << ", \\$" << size << ");" << endl; + out << indent() << "$" << prefix << " = [];" << '\n' << indent() << "my $" << etype << " = 0;" + << '\n' << indent() << "$xfer += $input->readListBegin(" + << "\\$" << etype << ", \\$" << size << ");" << '\n'; } // For loop iterates over elements string i = tmp("_i"); indent(out) << "for (my $" << i << " = 0; $" << i << " < $" << size << "; ++$" << i << ")" - << endl; + << '\n'; scope_up(out); @@ -1322,11 +1320,11 @@ void t_perl_generator::generate_deserialize_container(ostream& out, t_type* ttyp // Read container end if (ttype->is_map()) { - indent(out) << "$xfer += $input->readMapEnd();" << endl; + indent(out) << "$xfer += $input->readMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "$xfer += $input->readSetEnd();" << endl; + indent(out) << "$xfer += $input->readSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "$xfer += $input->readListEnd();" << endl; + indent(out) << "$xfer += $input->readListEnd();" << '\n'; } scope_down(out); @@ -1341,24 +1339,24 @@ void t_perl_generator::generate_deserialize_map_element(ostream& out, t_map* tma t_field fkey(tmap->get_key_type(), key); t_field fval(tmap->get_val_type(), val); - indent(out) << declare_field(&fkey, true, true) << endl; - indent(out) << declare_field(&fval, true, true) << endl; + indent(out) << declare_field(&fkey, true, true) << '\n'; + indent(out) << declare_field(&fval, true, true) << '\n'; generate_deserialize_field(out, &fkey); generate_deserialize_field(out, &fval); - indent(out) << "$" << prefix << "->{$" << key << "} = $" << val << ";" << endl; + indent(out) << "$" << prefix << "->{$" << key << "} = $" << val << ";" << '\n'; } void t_perl_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) { string elem = tmp("elem"); t_field felem(tset->get_elem_type(), elem); - indent(out) << "my $" << elem << " = undef;" << endl; + indent(out) << "my $" << elem << " = undef;" << '\n'; generate_deserialize_field(out, &felem); - indent(out) << "$" << prefix << "->{$" << elem << "} = 1;" << endl; + indent(out) << "$" << prefix << "->{$" << elem << "} = 1;" << '\n'; } void t_perl_generator::generate_deserialize_list_element(ostream& out, @@ -1367,11 +1365,11 @@ void t_perl_generator::generate_deserialize_list_element(ostream& out, string elem = tmp("elem"); t_field felem(tlist->get_elem_type(), elem); - indent(out) << "my $" << elem << " = undef;" << endl; + indent(out) << "my $" << elem << " = undef;" << '\n'; generate_deserialize_field(out, &felem); - indent(out) << "push(@{$" << prefix << "},$" << elem << ");" << endl; + indent(out) << "push(@{$" << prefix << "},$" << elem << ");" << '\n'; } /** @@ -1435,7 +1433,7 @@ void t_perl_generator::generate_serialize_field(ostream& out, t_field* tfield, s } else if (type->is_enum()) { out << "writeI32($" << name << ");"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n", @@ -1453,7 +1451,7 @@ void t_perl_generator::generate_serialize_field(ostream& out, t_field* tfield, s */ void t_perl_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - indent(out) << "$xfer += $" << prefix << "->write($output);" << endl; + indent(out) << "$xfer += $" << prefix << "->write($output);" << '\n'; } /** @@ -1466,17 +1464,17 @@ void t_perl_generator::generate_serialize_container(ostream& out, t_type* ttype, indent(out) << "$xfer += $output->writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " - << "scalar(keys %{$" << prefix << "}));" << endl; + << "scalar(keys %{$" << prefix << "}));" << '\n'; } else if (ttype->is_set()) { indent(out) << "$xfer += $output->writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " - << "scalar(@{$" << prefix << "}));" << endl; + << "scalar(@{$" << prefix << "}));" << '\n'; } else if (ttype->is_list()) { indent(out) << "$xfer += $output->writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " - << "scalar(@{$" << prefix << "}));" << endl; + << "scalar(@{$" << prefix << "}));" << '\n'; } scope_up(out); @@ -1485,7 +1483,7 @@ void t_perl_generator::generate_serialize_container(ostream& out, t_type* ttype, string kiter = tmp("kiter"); string viter = tmp("viter"); indent(out) << "while( my ($" << kiter << ",$" << viter << ") = each %{$" << prefix << "}) " - << endl; + << '\n'; scope_up(out); generate_serialize_map_element(out, (t_map*)ttype, kiter, viter); @@ -1493,14 +1491,14 @@ void t_perl_generator::generate_serialize_container(ostream& out, t_type* ttype, } else if (ttype->is_set()) { string iter = tmp("iter"); - indent(out) << "foreach my $" << iter << " (@{$" << prefix << "})" << endl; + indent(out) << "foreach my $" << iter << " (@{$" << prefix << "})" << '\n'; scope_up(out); generate_serialize_set_element(out, (t_set*)ttype, iter); scope_down(out); } else if (ttype->is_list()) { string iter = tmp("iter"); - indent(out) << "foreach my $" << iter << " (@{$" << prefix << "}) " << endl; + indent(out) << "foreach my $" << iter << " (@{$" << prefix << "}) " << '\n'; scope_up(out); generate_serialize_list_element(out, (t_list*)ttype, iter); scope_down(out); @@ -1509,11 +1507,11 @@ void t_perl_generator::generate_serialize_container(ostream& out, t_type* ttype, scope_down(out); if (ttype->is_map()) { - indent(out) << "$xfer += $output->writeMapEnd();" << endl; + indent(out) << "$xfer += $output->writeMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "$xfer += $output->writeSetEnd();" << endl; + indent(out) << "$xfer += $output->writeSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "$xfer += $output->writeListEnd();" << endl; + indent(out) << "$xfer += $output->writeListEnd();" << '\n'; } scope_down(out); diff --git a/compiler/cpp/src/thrift/generate/t_php_generator.cc b/compiler/cpp/src/thrift/generate/t_php_generator.cc index 83738586821..6879501db0f 100644 --- a/compiler/cpp/src/thrift/generate/t_php_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_php_generator.cc @@ -35,8 +35,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - #define NSGLOBAL (nsglobal_.size() ? nsglobal_ : "") #define NSGLOBAL_A ("\\" + NSGLOBAL) #define NSGLOBAL_B (NSGLOBAL + "\\") @@ -62,7 +60,7 @@ class t_php_generator : public t_oop_generator { validate_ = false; json_serializable_ = false; getters_setters_ = false; - + nsglobal_ = ""; // by default global namespace is empty classmap_ = false; for (iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) { @@ -513,28 +511,28 @@ void t_php_generator::generate_typedef(t_typedef* ttypedef) { * Generates service header contains namespace suffix and includes inside file specified */ void t_php_generator::generate_service_header(t_service* tservice, std::ostream& file) { - file << "get_program()).empty()) { - file << "namespace " << php_namespace_suffix(tservice->get_program()) << ";" << endl - << endl; + file << "namespace " << php_namespace_suffix(tservice->get_program()) << ";" << '\n' + << '\n'; } file << autogen_comment() << php_includes(); - file << endl; + file << '\n'; } /** * Generates program header contains namespace suffix and includes inside file specified */ void t_php_generator::generate_program_header(std::ostream& file) { - file << "get_name() << endl - << "{" << endl; + f_enum << "final class " << tenum->get_name() << '\n' + << "{" << '\n'; indent_up(); for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); generate_php_doc(f_enum, *c_iter); - indent(f_enum) << "const " << (*c_iter)->get_name() << " = " << value << ";" << endl - << endl; + indent(f_enum) << "const " << (*c_iter)->get_name() << " = " << value << ";" << '\n' + << '\n'; } - indent(f_enum) << "static public $__names = array(" << endl; + indent(f_enum) << "static public $__names = array(" << '\n'; indent_up(); for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); - indent(f_enum) << value << " => '" << (*c_iter)->get_name() << "'," << endl; + indent(f_enum) << value << " => '" << (*c_iter)->get_name() << "'," << '\n'; } indent_down(); - indent(f_enum) << ");" << endl; + indent(f_enum) << ");" << '\n'; indent_down(); - f_enum << "}" << endl << endl; + f_enum << "}" << '\n' << '\n'; if (!classmap_) { f_enum.close(); } @@ -604,8 +602,8 @@ void t_php_generator::generate_consts(vector consts) { f_consts.open(f_consts_name.c_str()); generate_program_header(f_consts); } - f_consts << "final class Constant extends \\Thrift\\Type\\TConstant"<< endl - << "{" << endl; + f_consts << "final class Constant extends \\Thrift\\Type\\TConstant"<< '\n' + << "{" << '\n'; indent_up(); @@ -613,30 +611,30 @@ void t_php_generator::generate_consts(vector consts) { for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { string name = (*c_iter)->get_name(); - indent(f_consts) << "static protected $" << name << ";" << endl; + indent(f_consts) << "static protected $" << name << ";" << '\n'; } // Create init function for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { string name = (*c_iter)->get_name(); - f_consts << endl; + f_consts << '\n'; - f_consts << indent() << "protected static function init_" << name << "()" <get_type(), (*c_iter)->get_value()); - f_consts << ";" << endl; + f_consts << ";" << '\n'; indent_down(); - indent(f_consts) << "}" << endl; + indent(f_consts) << "}" << '\n'; } indent_down(); - f_consts << "}" << endl; + f_consts << "}" << '\n'; if (!classmap_) { f_consts.close(); } @@ -679,7 +677,7 @@ string t_php_generator::render_const_value(t_type* type, t_const_value* value) { } else if (type->is_enum()) { indent(out) << value->get_integer(); } else if (type->is_struct() || type->is_xception()) { - out << "new " << php_namespace(type->get_program()) << type->get_name() << "(array(" << endl; + out << "new " << php_namespace(type->get_program()) << type->get_name() << "(array(" << '\n'; indent_up(); const vector& fields = ((t_struct*)type)->get_members(); vector::const_iterator f_iter; @@ -699,14 +697,14 @@ string t_php_generator::render_const_value(t_type* type, t_const_value* value) { out << render_const_value(g_type_string, v_iter->first); out << " => "; out << render_const_value(field_type, v_iter->second); - out << "," << endl; + out << "," << '\n'; } indent_down(); indent(out) << "))"; } else if (type->is_map()) { t_type* ktype = ((t_map*)type)->get_key_type(); t_type* vtype = ((t_map*)type)->get_val_type(); - out << "array(" << endl; + out << "array(" << '\n'; indent_up(); const map& val = value->get_map(); map::const_iterator v_iter; @@ -715,7 +713,7 @@ string t_php_generator::render_const_value(t_type* type, t_const_value* value) { out << render_const_value(ktype, v_iter->first); out << " => "; out << render_const_value(vtype, v_iter->second); - out << "," << endl; + out << "," << '\n'; } indent_down(); indent(out) << ")"; @@ -726,7 +724,7 @@ string t_php_generator::render_const_value(t_type* type, t_const_value* value) { } else { etype = ((t_set*)type)->get_elem_type(); } - out << "array(" << endl; + out << "array(" << '\n'; indent_up(); const vector& val = value->get_list(); vector::const_iterator v_iter; @@ -736,7 +734,7 @@ string t_php_generator::render_const_value(t_type* type, t_const_value* value) { if (type->is_set()) { out << " => true"; } - out << "," << endl; + out << "," << '\n'; } indent_down(); indent(out) << ")"; @@ -779,27 +777,27 @@ void t_php_generator::generate_php_struct(t_struct* tstruct, bool is_exception) void t_php_generator::generate_php_type_spec(ostream& out, t_type* t) { t = get_true_type(t); - indent(out) << "'type' => " << type_to_enum(t) << "," << endl; + indent(out) << "'type' => " << type_to_enum(t) << "," << '\n'; if (t->is_base_type()) { // Noop, type is all we need } else if (t->is_struct() || t->is_xception() || t->is_enum()) { indent(out) << "'class' => '" << php_namespace(t->get_program()) << t->get_name() << "'," - << endl; + << '\n'; } else if (t->is_map()) { t_type* ktype = get_true_type(((t_map*)t)->get_key_type()); t_type* vtype = get_true_type(((t_map*)t)->get_val_type()); - indent(out) << "'ktype' => " << type_to_enum(ktype) << "," << endl; - indent(out) << "'vtype' => " << type_to_enum(vtype) << "," << endl; - indent(out) << "'key' => array(" << endl; + indent(out) << "'ktype' => " << type_to_enum(ktype) << "," << '\n'; + indent(out) << "'vtype' => " << type_to_enum(vtype) << "," << '\n'; + indent(out) << "'key' => array(" << '\n'; indent_up(); generate_php_type_spec(out, ktype); indent_down(); - indent(out) << ")," << endl; - indent(out) << "'val' => array(" << endl; + indent(out) << ")," << '\n'; + indent(out) << "'val' => array(" << '\n'; indent_up(); generate_php_type_spec(out, vtype); - indent(out) << ")," << endl; + indent(out) << ")," << '\n'; indent_down(); } else if (t->is_list() || t->is_set()) { t_type* etype; @@ -808,11 +806,11 @@ void t_php_generator::generate_php_type_spec(ostream& out, t_type* t) { } else { etype = get_true_type(((t_set*)t)->get_elem_type()); } - indent(out) << "'etype' => " << type_to_enum(etype) << "," << endl; - indent(out) << "'elem' => array(" << endl; + indent(out) << "'etype' => " << type_to_enum(etype) << "," << '\n'; + indent(out) << "'elem' => array(" << '\n'; indent_up(); generate_php_type_spec(out, etype); - indent(out) << ")," << endl; + indent(out) << ")," << '\n'; indent_down(); } else { throw "compiler error: no type for php struct spec field"; @@ -824,24 +822,24 @@ void t_php_generator::generate_php_type_spec(ostream& out, t_type* t) { * type information to generalize serialization routines. */ void t_php_generator::generate_php_struct_spec(ostream& out, t_struct* tstruct) { - indent(out) << "static public $_TSPEC = array(" << endl; + indent(out) << "static public $_TSPEC = array(" << '\n'; indent_up(); const vector& members = tstruct->get_members(); vector::const_iterator m_iter; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* t = get_true_type((*m_iter)->get_type()); - indent(out) << (*m_iter)->get_key() << " => array(" << endl; + indent(out) << (*m_iter)->get_key() << " => array(" << '\n'; indent_up(); - out << indent() << "'var' => '" << (*m_iter)->get_name() << "'," << endl; - out << indent() << "'isRequired' => " << ((*m_iter)->get_req() == t_field::T_REQUIRED ? "true" : "false") << "," << endl; + out << indent() << "'var' => '" << (*m_iter)->get_name() << "'," << '\n'; + out << indent() << "'isRequired' => " << ((*m_iter)->get_req() == t_field::T_REQUIRED ? "true" : "false") << "," << '\n'; generate_php_type_spec(out, t); indent_down(); - indent(out) << ")," << endl; + indent(out) << ")," << '\n'; } indent_down(); - indent(out) << ");" << endl << endl; + indent(out) << ");" << '\n' << '\n'; } /** * Generates necessary accessors and mutators for the fields @@ -865,10 +863,10 @@ void t_php_generator::generate_generic_field_getters_setters(std::ostream& out, indent_down(); } - indent(out) << endl; + indent(out) << '\n'; out << getter_stream.str(); out << setter_stream.str(); - indent(out) << endl; + indent(out) << '\n'; } /** * Generates a getter for the generated private fields @@ -878,16 +876,16 @@ void t_php_generator::generate_reflection_getters(ostringstream& out, string cap_name) { - out << indent() << "public function " << "get" << cap_name << "()" << endl - << indent() << "{" << endl; + out << indent() << "public function " << "get" << cap_name << "()" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "return $this->" << field_name << ";" << endl; + out << indent() << "return $this->" << field_name << ";" << '\n'; indent_down(); - out << indent() << "}" << endl; - out << endl; + out << indent() << "}" << '\n'; + out << '\n'; } /** * Generates a setter for the generated private fields @@ -896,17 +894,17 @@ void t_php_generator::generate_reflection_setters(ostringstream& out, string field_name, string cap_name) { - out << indent() << "public function set" << cap_name << "(" << "$" << field_name << ")" << endl - << indent() << "{" << endl; + out << indent() << "public function set" << cap_name << "(" << "$" << field_name << ")" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "$this->" << field_name << " = $" << field_name << ";" << endl; + out << indent() << "$this->" << field_name << " = $" << field_name << ";" << '\n'; indent_down(); - out << indent() << "}" << endl; - out << endl; + out << indent() << "}" << '\n'; + out << '\n'; } /** * Gets the first-letter capitalized name for the field @@ -943,11 +941,11 @@ void t_php_generator::generate_php_struct_definition(ostream& out, if (json_serializable_) { out << " implements JsonSerializable"; } - out << endl - << "{" << endl; + out << '\n' + << "{" << '\n'; indent_up(); - out << indent() << "static public $isValidate = " << (validate_ ? "true" : "false") << ";" << endl << endl; + out << indent() << "static public $isValidate = " << (validate_ ? "true" : "false") << ";" << '\n' << '\n'; generate_php_struct_spec(out, tstruct); @@ -959,15 +957,15 @@ void t_php_generator::generate_php_struct_definition(ostream& out, } generate_php_doc(out, *m_iter); string access = (getters_setters_) ? "private" : "public"; - indent(out) << access << " $" << (*m_iter)->get_name() << " = " << dval << ";" << endl; + indent(out) << access << " $" << (*m_iter)->get_name() << " = " << dval << ";" << '\n'; } - out << endl; + out << '\n'; // Generate constructor from array string param = (members.size() > 0) ? "$vals = null" : ""; - out << indent() << "public function __construct(" << param << ")"<< endl - << indent() << "{" << endl; + out << indent() << "public function __construct(" << param << ")"<< '\n' + << indent() << "{" << '\n'; indent_up(); if (members.size() > 0) { @@ -975,62 +973,62 @@ void t_php_generator::generate_php_struct_definition(ostream& out, t_type* t = get_true_type((*m_iter)->get_type()); if ((*m_iter)->get_value() != nullptr && (t->is_struct() || t->is_xception())) { indent(out) << "$this->" << (*m_iter)->get_name() << " = " - << render_const_value(t, (*m_iter)->get_value()) << ";" << endl; + << render_const_value(t, (*m_iter)->get_value()) << ";" << '\n'; } } - out << indent() << "if (is_array($vals)) {" << endl; + out << indent() << "if (is_array($vals)) {" << '\n'; indent_up(); if (oop_) { - out << indent() << "parent::__construct(self::$_TSPEC, $vals);" << endl; + out << indent() << "parent::__construct(self::$_TSPEC, $vals);" << '\n'; } else { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - out << indent() << "if (isset($vals['" << (*m_iter)->get_name() << "'])) {" << endl; + out << indent() << "if (isset($vals['" << (*m_iter)->get_name() << "'])) {" << '\n'; indent_up(); out << indent() << "$this->" << (*m_iter)->get_name() << " = $vals['" - << (*m_iter)->get_name() << "'];" << endl; + << (*m_iter)->get_name() << "'];" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } } indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } scope_down(out); - out << endl; + out << '\n'; - out << indent() << "public function getName()" << endl - << indent() << "{" << endl; + out << indent() << "public function getName()" << '\n' + << indent() << "{" << '\n'; indent_up(); - out << indent() << "return '" << tstruct->get_name() << "';" << endl; + out << indent() << "return '" << tstruct->get_name() << "';" << '\n'; indent_down(); - out << indent() << "}" << endl << endl; + out << indent() << "}" << '\n' << '\n'; - out << endl; + out << '\n'; if (getters_setters_) { generate_generic_field_getters_setters(out, tstruct); } generate_php_struct_reader(out, tstruct, is_result); - out << endl; + out << '\n'; generate_php_struct_writer(out, tstruct, is_result); if (needs_php_read_validator(tstruct, is_result)) { - out << endl; + out << '\n'; generate_php_struct_read_validator(out, tstruct); } if (needs_php_write_validator(tstruct, is_result)) { - out << endl; + out << '\n'; generate_php_struct_write_validator(out, tstruct); } if (json_serializable_) { - out << endl; + out << '\n'; generate_php_struct_json_serialize(out, tstruct, is_result); } indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } /** @@ -1040,34 +1038,34 @@ void t_php_generator::generate_php_struct_reader(ostream& out, t_struct* tstruct const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - indent(out) << "public function read($input)" << endl; + indent(out) << "public function read($input)" << '\n'; scope_up(out); if (oop_) { if (needs_php_read_validator(tstruct, is_result)) { indent(out) << "$tmp = $this->_read('" << tstruct->get_name() << "', self::$_TSPEC, $input);" - << endl; - indent(out) << "$this->_validateForRead();" << endl; - indent(out) << "return $tmp;" << endl; + << '\n'; + indent(out) << "$this->_validateForRead();" << '\n'; + indent(out) << "return $tmp;" << '\n'; } else { indent(out) << "return $this->_read('" << tstruct->get_name() << "', self::$_TSPEC, $input);" - << endl; + << '\n'; } scope_down(out); - out << endl; + out << '\n'; return; } - out << indent() << "$xfer = 0;" << endl << indent() << "$fname = null;" << endl << indent() - << "$ftype = 0;" << endl << indent() << "$fid = 0;" << endl; + out << indent() << "$xfer = 0;" << '\n' << indent() << "$fname = null;" << '\n' << indent() + << "$ftype = 0;" << '\n' << indent() << "$fid = 0;" << '\n'; // Declare stack tmp variables if (!binary_inline_) { - indent(out) << "$xfer += $input->readStructBegin($fname);" << endl; + indent(out) << "$xfer += $input->readStructBegin($fname);" << '\n'; } // Loop over reading in fields - indent(out) << "while (true) {" << endl; + indent(out) << "while (true) {" << '\n'; indent_up(); @@ -1077,80 +1075,80 @@ void t_php_generator::generate_php_struct_reader(ostream& out, t_struct* tstruct t_field ffid(g_type_i16, "fid"); generate_deserialize_field(out, &fftype); out << indent() << "if ($ftype == " - << "TType::STOP) {" << endl << indent() << " break;" << endl << indent() << "}" << endl; + << "TType::STOP) {" << '\n' << indent() << " break;" << '\n' << indent() << "}" << '\n'; generate_deserialize_field(out, &ffid); } else { - indent(out) << "$xfer += $input->readFieldBegin($fname, $ftype, $fid);" << endl; + indent(out) << "$xfer += $input->readFieldBegin($fname, $ftype, $fid);" << '\n'; // Check for field STOP marker and break indent(out) << "if ($ftype == " - << "TType::STOP) {" << endl; + << "TType::STOP) {" << '\n'; indent_up(); - indent(out) << "break;" << endl; + indent(out) << "break;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } // Switch statement on the field we are reading - indent(out) << "switch ($fid) {" << endl; + indent(out) << "switch ($fid) {" << '\n'; indent_up(); // Generate deserialization code for known cases for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - indent(out) << "case " << (*f_iter)->get_key() << ":" << endl; + indent(out) << "case " << (*f_iter)->get_key() << ":" << '\n'; indent_up(); - indent(out) << "if ($ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl; + indent(out) << "if ($ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n'; indent_up(); generate_deserialize_field(out, *f_iter, "this->"); indent_down(); - out << indent() << "} else {" << endl; + out << indent() << "} else {" << '\n'; indent_up(); if (binary_inline_) { - indent(out) << "$xfer += TProtocol::skipBinary($input, $ftype);" << endl; + indent(out) << "$xfer += TProtocol::skipBinary($input, $ftype);" << '\n'; } else { - indent(out) << "$xfer += $input->skip($ftype);" << endl; + indent(out) << "$xfer += $input->skip($ftype);" << '\n'; } indent_down(); - out << indent() << "}" << endl << indent() << "break;" << endl; + out << indent() << "}" << '\n' << indent() << "break;" << '\n'; indent_down(); } // In the default case we skip the field - indent(out) << "default:" << endl; + indent(out) << "default:" << '\n'; indent_up(); if (binary_inline_) { indent(out) << "$xfer += " - << "TProtocol::skipBinary($input, $ftype);" << endl; + << "TProtocol::skipBinary($input, $ftype);" << '\n'; } else { - indent(out) << "$xfer += $input->skip($ftype);" << endl; + indent(out) << "$xfer += $input->skip($ftype);" << '\n'; } - indent(out) << "break;" << endl; + indent(out) << "break;" << '\n'; indent_down(); scope_down(out); if (!binary_inline_) { // Read field end marker - indent(out) << "$xfer += $input->readFieldEnd();" << endl; + indent(out) << "$xfer += $input->readFieldEnd();" << '\n'; } scope_down(out); if (!binary_inline_) { - indent(out) << "$xfer += $input->readStructEnd();" << endl; + indent(out) << "$xfer += $input->readStructEnd();" << '\n'; } if (needs_php_read_validator(tstruct, is_result)) { - indent(out) << "$this->_validateForRead();" << endl; + indent(out) << "$this->_validateForRead();" << '\n'; } - indent(out) << "return $xfer;" << endl; + indent(out) << "return $xfer;" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } /** @@ -1162,33 +1160,33 @@ void t_php_generator::generate_php_struct_writer(ostream& out, t_struct* tstruct vector::const_iterator f_iter; if (binary_inline_) { - indent(out) << "public function write(&$output)" << endl; + indent(out) << "public function write(&$output)" << '\n'; } else { - indent(out) << "public function write($output)" << endl; + indent(out) << "public function write($output)" << '\n'; } - indent(out) << "{" << endl; + indent(out) << "{" << '\n'; indent_up(); if (needs_php_write_validator(tstruct, is_result)) { - indent(out) << "$this->_validateForWrite();" << endl; + indent(out) << "$this->_validateForWrite();" << '\n'; } if (oop_) { indent(out) << "return $this->_write('" << tstruct->get_name() << "', self::$_TSPEC, $output);" - << endl; + << '\n'; scope_down(out); - out << endl; + out << '\n'; return; } - indent(out) << "$xfer = 0;" << endl; + indent(out) << "$xfer = 0;" << '\n'; if (!binary_inline_) { - indent(out) << "$xfer += $output->writeStructBegin('" << name << "');" << endl; + indent(out) << "$xfer += $output->writeStructBegin('" << name << "');" << '\n'; } for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - out << indent() << "if ($this->" << (*f_iter)->get_name() << " !== null) {" << endl; + out << indent() << "if ($this->" << (*f_iter)->get_name() << " !== null) {" << '\n'; indent_up(); t_type* type = get_true_type((*f_iter)->get_type()); @@ -1200,22 +1198,22 @@ void t_php_generator::generate_php_struct_writer(ostream& out, t_struct* tstruct } if (!expect.empty()) { out << indent() << "if (!is_" << expect << "($this->" << (*f_iter)->get_name() << ")) {" - << endl; + << '\n'; indent_up(); out << indent() << "throw new " << "TProtocolException('Bad type in structure.', " - << "TProtocolException::INVALID_DATA);" << endl; + << "TProtocolException::INVALID_DATA);" << '\n'; scope_down(out); } // Write field header if (binary_inline_) { out << indent() << "$output .= pack('c', " << type_to_enum((*f_iter)->get_type()) << ");" - << endl << indent() << "$output .= pack('n', " << (*f_iter)->get_key() << ");" << endl; + << '\n' << indent() << "$output .= pack('n', " << (*f_iter)->get_key() << ");" << '\n'; } else { indent(out) << "$xfer += $output->writeFieldBegin(" << "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type()) - << ", " << (*f_iter)->get_key() << ");" << endl; + << ", " << (*f_iter)->get_key() << ");" << '\n'; } // Write field contents @@ -1223,25 +1221,25 @@ void t_php_generator::generate_php_struct_writer(ostream& out, t_struct* tstruct // Write field closer if (!binary_inline_) { - indent(out) << "$xfer += $output->writeFieldEnd();" << endl; + indent(out) << "$xfer += $output->writeFieldEnd();" << '\n'; } indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } if (binary_inline_) { out << indent() << "$output .= pack('c', " - << "TType::STOP);" << endl; + << "TType::STOP);" << '\n'; } else { - out << indent() << "$xfer += $output->writeFieldStop();" << endl << indent() - << "$xfer += $output->writeStructEnd();" << endl; + out << indent() << "$xfer += $output->writeFieldStop();" << '\n' << indent() + << "$xfer += $output->writeStructEnd();" << '\n'; } - out << indent() << "return $xfer;" << endl; + out << indent() << "return $xfer;" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } void t_php_generator::generate_php_struct_read_validator(ostream& out, t_struct* tstruct) { @@ -1256,7 +1254,7 @@ void t_php_generator::generate_php_struct_required_validator(ostream& out, t_struct* tstruct, std::string method_name, bool write_mode) { - indent(out) << "private function " << method_name << "() {" << endl; + indent(out) << "private function " << method_name << "() {" << '\n'; indent_up(); const vector& fields = tstruct->get_members(); @@ -1268,32 +1266,32 @@ void t_php_generator::generate_php_struct_required_validator(ostream& out, t_field* field = (*f_iter); if (field->get_req() == t_field::T_REQUIRED || (field->get_req() == t_field::T_OPT_IN_REQ_OUT && write_mode)) { - indent(out) << "if ($this->" << field->get_name() << " === null) {" << endl; + indent(out) << "if ($this->" << field->get_name() << " === null) {" << '\n'; indent_up(); indent(out) << "throw new TProtocolException('Required field " << tstruct->get_name() << "." - << field->get_name() << " is unset!');" << endl; + << field->get_name() << " is unset!');" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } } indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } void t_php_generator::generate_php_struct_json_serialize(ostream& out, t_struct* tstruct, bool is_result) { - indent(out) << "#[\\ReturnTypeWillChange]" << endl; - indent(out) << "public function jsonSerialize() {" << endl; + indent(out) << "#[\\ReturnTypeWillChange]" << '\n'; + indent(out) << "public function jsonSerialize() {" << '\n'; indent_up(); if (needs_php_write_validator(tstruct, is_result)) { - indent(out) << "$this->_validateForWrite();" << endl; + indent(out) << "$this->_validateForWrite();" << '\n'; } - indent(out) << "$json = new stdClass;" << endl; + indent(out) << "$json = new stdClass;" << '\n'; const vector& fields = tstruct->get_members(); @@ -1312,7 +1310,7 @@ void t_php_generator::generate_php_struct_json_serialize(ostream& out, continue; } } - indent(out) << "if ($this->" << name << " !== null) {" << endl; + indent(out) << "if ($this->" << name << " !== null) {" << '\n'; indent_up(); indent(out) << "$json->" << name << " = "; if (type->is_map()) { @@ -1320,16 +1318,16 @@ void t_php_generator::generate_php_struct_json_serialize(ostream& out, } else { out << type_to_cast(type); } - out << "$this->" << name << ";" << endl; + out << "$this->" << name << ";" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } - indent(out) << "return $json;" << endl; + indent(out) << "return $json;" << '\n'; indent_down(); - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } int t_php_generator::get_php_num_required_fields(const vector& fields, bool write_mode) { @@ -1382,7 +1380,7 @@ void t_php_generator::generate_service(t_service* tservice) { if(classmap_) { // Close service file - f_service_ << endl; + f_service_ << '\n'; f_service_.close(); } } @@ -1413,34 +1411,34 @@ void t_php_generator::generate_service_processor(t_service* tservice) { } // Generate the header portion - f_service_processor << "class " << service_name_ << "Processor" << extends_processor << endl - << "{" << endl; + f_service_processor << "class " << service_name_ << "Processor" << extends_processor << '\n' + << "{" << '\n'; indent_up(); if (extends.empty()) { - f_service_processor << indent() << "protected $handler_ = null;" << endl; + f_service_processor << indent() << "protected $handler_ = null;" << '\n'; } - f_service_processor << indent() << "public function __construct($handler)"<< endl - << indent() << "{" << endl; + f_service_processor << indent() << "public function __construct($handler)"<< '\n' + << indent() << "{" << '\n'; indent_up(); if (extends.empty()) { - f_service_processor << indent() << "$this->handler_ = $handler;" << endl; + f_service_processor << indent() << "$this->handler_ = $handler;" << '\n'; } else { - f_service_processor << indent() << "parent::__construct($handler);" << endl; + f_service_processor << indent() << "parent::__construct($handler);" << '\n'; } indent_down(); - f_service_processor << indent() << "}" << endl << endl; + f_service_processor << indent() << "}" << '\n' << '\n'; // Generate the server implementation - f_service_processor << indent() << "public function process($input, $output)" << endl - << indent() << "{" << endl; + f_service_processor << indent() << "public function process($input, $output)" << '\n' + << indent() << "{" << '\n'; indent_up(); - f_service_processor << indent() << "$rseqid = 0;" << endl << indent() << "$fname = null;" << endl - << indent() << "$mtype = 0;" << endl << endl; + f_service_processor << indent() << "$rseqid = 0;" << '\n' << indent() << "$fname = null;" << '\n' + << indent() << "$mtype = 0;" << '\n' << '\n'; if (binary_inline_) { t_field ffname(g_type_string, "fname"); @@ -1450,36 +1448,36 @@ void t_php_generator::generate_service_processor(t_service* tservice) { generate_deserialize_field(f_service_processor, &fmtype, "", true); generate_deserialize_field(f_service_processor, &fseqid, "", true); } else { - f_service_processor << indent() << "$input->readMessageBegin($fname, $mtype, $rseqid);" << endl; + f_service_processor << indent() << "$input->readMessageBegin($fname, $mtype, $rseqid);" << '\n'; } // HOT: check for method implementation - f_service_processor << indent() << "$methodname = 'process_'.$fname;" << endl - << indent() << "if (!method_exists($this, $methodname)) {" << endl; + f_service_processor << indent() << "$methodname = 'process_'.$fname;" << '\n' + << indent() << "if (!method_exists($this, $methodname)) {" << '\n'; indent_up(); if (binary_inline_) { - f_service_processor << indent() << "throw new \\Exception('Function '.$fname.' not implemented.');" << endl; + f_service_processor << indent() << "throw new \\Exception('Function '.$fname.' not implemented.');" << '\n'; } else { f_service_processor << indent() << " $input->skip(" - << "TType::STRUCT);" << endl << indent() << " $input->readMessageEnd();" << endl + << "TType::STRUCT);" << '\n' << indent() << " $input->readMessageEnd();" << '\n' << indent() << " $x = new " << "TApplicationException('Function '.$fname.' not implemented.', " - << "TApplicationException::UNKNOWN_METHOD);" << endl << indent() + << "TApplicationException::UNKNOWN_METHOD);" << '\n' << indent() << " $output->writeMessageBegin($fname, " - << "TMessageType::EXCEPTION, $rseqid);" << endl << indent() - << " $x->write($output);" << endl << indent() << " $output->writeMessageEnd();" - << endl << indent() << " $output->getTransport()->flush();" << endl << indent() - << " return;" << endl; + << "TMessageType::EXCEPTION, $rseqid);" << '\n' << indent() + << " $x->write($output);" << '\n' << indent() << " $output->writeMessageEnd();" + << '\n' << indent() << " $output->getTransport()->flush();" << '\n' << indent() + << " return;" << '\n'; } indent_down(); - f_service_processor << indent() << "}" << endl - << indent() << "$this->$methodname($rseqid, $input, $output);" << endl - << indent() << "return true;" << endl; + f_service_processor << indent() << "}" << '\n' + << indent() << "$this->$methodname($rseqid, $input, $output);" << '\n' + << indent() << "return true;" << '\n'; indent_down(); - f_service_processor << indent() << "}" << endl << endl; + f_service_processor << indent() << "}" << '\n' << '\n'; // Generate the process subfunctions for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -1487,7 +1485,7 @@ void t_php_generator::generate_service_processor(t_service* tservice) { } indent_down(); - f_service_processor << "}" << endl; + f_service_processor << "}" << '\n'; if (!classmap_) { f_service_processor.close(); @@ -1501,8 +1499,8 @@ void t_php_generator::generate_service_processor(t_service* tservice) { */ void t_php_generator::generate_process_function(std::ostream& out, t_service* tservice, t_function* tfunction) { // Open function - out << indent() << "protected function process_" << tfunction->get_name() << "($seqid, $input, $output)" << endl - << indent() << "{" << endl; + out << indent() << "protected function process_" << tfunction->get_name() << "($seqid, $input, $output)" << '\n' + << indent() << "{" << '\n'; indent_up(); string argsname = php_namespace(tservice->get_program()) + service_name_ + "_" @@ -1512,32 +1510,32 @@ void t_php_generator::generate_process_function(std::ostream& out, t_service* ts out << indent() << "$bin_accel = ($input instanceof " << "TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary_after_message_begin');" - << endl; - out << indent() << "if ($bin_accel) {" << endl; + << '\n'; + out << indent() << "if ($bin_accel) {" << '\n'; indent_up(); - out << indent() << "$args = thrift_protocol_read_binary_after_message_begin(" <isStrictRead()" <isStrictRead()" << '\n'; indent_down(); - out << indent() <<");" << endl; + out << indent() <<");" << '\n'; indent_down(); - out << indent() << "} else {" << endl; + out << indent() << "} else {" << '\n'; indent_up(); - out << indent() << "$args = new " << argsname << "();" << endl - << indent() << "$args->read($input);" << endl; + out << indent() << "$args = new " << argsname << "();" << '\n' + << indent() << "$args->read($input);" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; if (!binary_inline_) { - out << indent() << "$input->readMessageEnd();" << endl; + out << indent() << "$input->readMessageEnd();" << '\n'; } t_struct* xs = tfunction->get_xceptions(); @@ -1546,12 +1544,12 @@ void t_php_generator::generate_process_function(std::ostream& out, t_service* ts // Declare result for non oneway function if (!tfunction->is_oneway()) { - out << indent() << "$result = new " << resultname << "();" << endl; + out << indent() << "$result = new " << resultname << "();" << '\n'; } // Try block for a function with exceptions if (xceptions.size() > 0) { - out << indent() << "try {" << endl; + out << indent() << "try {" << '\n'; indent_up(); } @@ -1574,7 +1572,7 @@ void t_php_generator::generate_process_function(std::ostream& out, t_service* ts } out << "$args->" << (*f_iter)->get_name(); } - out << ");" << endl; + out << ");" << '\n'; if (!tfunction->is_oneway() && xceptions.size() > 0) { indent_down(); @@ -1582,70 +1580,70 @@ void t_php_generator::generate_process_function(std::ostream& out, t_service* ts out << indent() << "} catch (" << php_namespace(get_true_type((*x_iter)->get_type())->get_program()) << (*x_iter)->get_type()->get_name() << " $" << (*x_iter)->get_name() << ") {" - << endl; + << '\n'; if (!tfunction->is_oneway()) { indent_up(); out << indent() << "$result->" << (*x_iter)->get_name() << " = $" - << (*x_iter)->get_name() << ";" << endl; + << (*x_iter)->get_name() << ";" << '\n'; indent_down(); out << indent(); } } - out << "}" << endl; + out << "}" << '\n'; } // Shortcut out here for oneway functions if (tfunction->is_oneway()) { - out << indent() << "return;" << endl; + out << indent() << "return;" << '\n'; indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; return; } out << indent() << "$bin_accel = ($output instanceof " << "TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');" - << endl; + << '\n'; - out << indent() << "if ($bin_accel) {" << endl; + out << indent() << "if ($bin_accel) {" << '\n'; indent_up(); - out << indent() << "thrift_protocol_write_binary(" << endl; + out << indent() << "thrift_protocol_write_binary(" << '\n'; indent_up(); - out << indent() << "$output,"<get_name()<< "'," <isStrictWrite()"<get_name()<< "'," << '\n' + << indent() << "TMessageType::REPLY,"<< '\n' + << indent() << "$result," << '\n' + << indent() << "$seqid," << '\n' + << indent() << "$output->isStrictWrite()"<< '\n'; indent_down(); - out << indent() << ");" << endl; + out << indent() << ");" << '\n'; indent_down(); - out << indent() << "} else {" << endl; + out << indent() << "} else {" << '\n'; indent_up(); // Serialize the request header if (binary_inline_) { out << indent() << "$buff = pack('N', (0x80010000 | " - << "TMessageType::REPLY)); " << endl << indent() << "$buff .= pack('N', strlen('" - << tfunction->get_name() << "'));" << endl << indent() << "$buff .= '" - << tfunction->get_name() << "';" << endl << indent() << "$buff .= pack('N', $seqid);" - << endl << indent() << "$result->write($buff);" << endl << indent() - << "$output->write($buff);" << endl << indent() << "$output->flush();" << endl; + << "TMessageType::REPLY)); " << '\n' << indent() << "$buff .= pack('N', strlen('" + << tfunction->get_name() << "'));" << '\n' << indent() << "$buff .= '" + << tfunction->get_name() << "';" << '\n' << indent() << "$buff .= pack('N', $seqid);" + << '\n' << indent() << "$result->write($buff);" << '\n' << indent() + << "$output->write($buff);" << '\n' << indent() << "$output->flush();" << '\n'; } else { out << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', " - << "TMessageType::REPLY, $seqid);" << endl << indent() << "$result->write($output);" - << endl << indent() << "$output->writeMessageEnd();" << endl << indent() - << "$output->getTransport()->flush();" << endl; + << "TMessageType::REPLY, $seqid);" << '\n' << indent() << "$result->write($output);" + << '\n' << indent() << "$output->writeMessageEnd();" << '\n' << indent() + << "$output->getTransport()->flush();" << '\n'; } scope_down(out); // Close function indent_down(); - out << indent() << "}" << endl; + out << indent() << "}" << '\n'; } /** @@ -1659,7 +1657,7 @@ void t_php_generator::generate_service_helpers(t_service* tservice) { ofstream_with_content_based_conditional_update& f_struct_definition = f_service_; if (classmap_) { - f_struct_definition << "// HELPER FUNCTIONS AND STRUCTURES" << endl << endl; + f_struct_definition << "// HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n'; } for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -1738,18 +1736,18 @@ void t_php_generator::generate_service_interface(t_service* tservice) { + tservice->get_extends()->get_name() + "If"; } generate_php_doc(f_service_interface, tservice); - f_service_interface << "interface " << php_namespace_declaration(tservice) << "If" << extends_if << endl - << "{" << endl; + f_service_interface << "interface " << php_namespace_declaration(tservice) << "If" << extends_if << '\n' + << "{" << '\n'; indent_up(); vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_php_doc(f_service_interface, *f_iter); - indent(f_service_interface) << "public function " << function_signature(*f_iter) << ";" << endl; + indent(f_service_interface) << "public function " << function_signature(*f_iter) << ";" << '\n'; } indent_down(); - f_service_interface << "}" << endl; + f_service_interface << "}" << '\n'; // Close service interface file if (!classmap_) { @@ -1776,21 +1774,21 @@ void t_php_generator::generate_service_rest(t_service* tservice) { extends_if = " extends " + php_namespace(tservice->get_extends()->get_program()) + tservice->get_extends()->get_name() + "Rest"; } - f_service_rest << "class " << service_name_ << "Rest" << extends_if << endl - << "{" << endl; + f_service_rest << "class " << service_name_ << "Rest" << extends_if << '\n' + << "{" << '\n'; indent_up(); if (extends.empty()) { - f_service_rest << indent() << "protected $impl_;" << endl << endl; + f_service_rest << indent() << "protected $impl_;" << '\n' << '\n'; } - f_service_rest << indent() << "public function __construct($impl) {" << endl << indent() - << " $this->impl_ = $impl;" << endl << indent() << "}" << endl << endl; + f_service_rest << indent() << "public function __construct($impl) {" << '\n' << indent() + << " $this->impl_ = $impl;" << '\n' << indent() << "}" << '\n' << '\n'; vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - indent(f_service_rest) << "public function " << (*f_iter)->get_name() << "($request) {" << endl; + indent(f_service_rest) << "public function " << (*f_iter)->get_name() << "($request) {" << '\n'; indent_up(); const vector& args = (*f_iter)->get_arglist()->get_members(); vector::const_iterator a_iter; @@ -1800,39 +1798,39 @@ void t_php_generator::generate_service_rest(t_service* tservice) { string req = "$request['" + (*a_iter)->get_name() + "']"; if (atype->is_bool()) { f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = " << cast << "(!empty(" << req - << ") && (" << req << " !== 'false'));" << endl; + << ") && (" << req << " !== 'false'));" << '\n'; } else { f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = isset(" << req << ") ? " - << cast << req << " : null;" << endl; + << cast << req << " : null;" << '\n'; } /* slist no longer supported if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) { f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = explode(',', $" - << (*a_iter)->get_name() << ");" << endl; + << (*a_iter)->get_name() << ");" << '\n'; } else */ if (atype->is_map() || atype->is_list()) { f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = json_decode($" - << (*a_iter)->get_name() << ", true);" << endl; + << (*a_iter)->get_name() << ", true);" << '\n'; } else if (atype->is_set()) { f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = array_fill_keys(json_decode($" - << (*a_iter)->get_name() << ", true), 1);" << endl; + << (*a_iter)->get_name() << ", true), 1);" << '\n'; } else if (atype->is_struct() || atype->is_xception()) { - f_service_rest << indent() << "if ($" << (*a_iter)->get_name() << " !== null) {" << endl + f_service_rest << indent() << "if ($" << (*a_iter)->get_name() << " !== null) {" << '\n' << indent() << " $" << (*a_iter)->get_name() << " = new " << php_namespace(atype->get_program()) << atype->get_name() << "(json_decode($" - << (*a_iter)->get_name() << ", true));" << endl << indent() << "}" << endl; + << (*a_iter)->get_name() << ", true));" << '\n' << indent() << "}" << '\n'; } } f_service_rest << indent() << "return $this->impl_->" << (*f_iter)->get_name() << "(" - << argument_list((*f_iter)->get_arglist(), false) << ");" << endl; + << argument_list((*f_iter)->get_arglist(), false) << ");" << '\n'; indent_down(); - indent(f_service_rest) << "}" << endl << endl; + indent(f_service_rest) << "}" << '\n' << '\n'; } indent_down(); - f_service_rest << "}" << endl << endl; + f_service_rest << "}" << '\n' << '\n'; // Close service rest file - f_service_rest << endl; + f_service_rest << '\n'; if (!classmap_) { f_service_rest.close(); } @@ -1860,31 +1858,31 @@ void t_php_generator::generate_service_client(t_service* tservice) { } f_service_client << "class " << php_namespace_declaration(tservice) << "Client" << extends_client - << " implements " << php_namespace(tservice->get_program()) << service_name_ << "If" << endl - <<"{"<< endl; + << " implements " << php_namespace(tservice->get_program()) << service_name_ << "If" << '\n' + <<"{"<< '\n'; indent_up(); // Private members if (extends.empty()) { - f_service_client << indent() << "protected $input_ = null;" << endl << indent() - << "protected $output_ = null;" << endl << endl; - f_service_client << indent() << "protected $seqid_ = 0;" << endl << endl; + f_service_client << indent() << "protected $input_ = null;" << '\n' << indent() + << "protected $output_ = null;" << '\n' << '\n'; + f_service_client << indent() << "protected $seqid_ = 0;" << '\n' << '\n'; } // Constructor function - f_service_client << indent() << "public function __construct($input, $output = null)" << endl - << indent() << "{" << endl; + f_service_client << indent() << "public function __construct($input, $output = null)" << '\n' + << indent() << "{" << '\n'; indent_up(); if (!extends.empty()) { - f_service_client << indent() << "parent::__construct($input, $output);" << endl; + f_service_client << indent() << "parent::__construct($input, $output);" << '\n'; } else { - f_service_client << indent() << "$this->input_ = $input;" << endl - << indent() << "$this->output_ = $output ? $output : $input;" << endl; + f_service_client << indent() << "$this->input_ = $input;" << '\n' + << indent() << "$this->output_ = $output ? $output : $input;" << '\n'; } indent_down(); - f_service_client << indent() << "}" << endl << endl; + f_service_client << indent() << "}" << '\n' << '\n'; // Generate client method implementations vector functions = tservice->get_functions(); @@ -1895,10 +1893,10 @@ void t_php_generator::generate_service_client(t_service* tservice) { vector::const_iterator fld_iter; string funname = (*f_iter)->get_name(); - f_service_client << endl; + f_service_client << '\n'; // Open function - indent(f_service_client) << "public function " << function_signature(*f_iter) << endl; + indent(f_service_client) << "public function " << function_signature(*f_iter) << '\n'; scope_up(f_service_client); indent(f_service_client) << "$this->send_" << funname << "("; @@ -1911,77 +1909,77 @@ void t_php_generator::generate_service_client(t_service* tservice) { } f_service_client << "$" << (*fld_iter)->get_name(); } - f_service_client << ");" << endl; + f_service_client << ");" << '\n'; if (!(*f_iter)->is_oneway()) { f_service_client << indent(); if (!(*f_iter)->get_returntype()->is_void()) { f_service_client << "return "; } - f_service_client << "$this->recv_" << funname << "();" << endl; + f_service_client << "$this->recv_" << funname << "();" << '\n'; } scope_down(f_service_client); - f_service_client << endl; + f_service_client << '\n'; - indent(f_service_client) << "public function send_" << function_signature(*f_iter) << endl; + indent(f_service_client) << "public function send_" << function_signature(*f_iter) << '\n'; scope_up(f_service_client); std::string argsname = php_namespace(tservice->get_program()) + service_name_ + "_" + (*f_iter)->get_name() + "_args"; - f_service_client << indent() << "$args = new " << argsname << "();" << endl; + f_service_client << indent() << "$args = new " << argsname << "();" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_service_client << indent() << "$args->" << (*fld_iter)->get_name() << " = $" - << (*fld_iter)->get_name() << ";" << endl; + << (*fld_iter)->get_name() << ";" << '\n'; } f_service_client << indent() << "$bin_accel = ($this->output_ instanceof " << "TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');" - << endl; + << '\n'; - f_service_client << indent() << "if ($bin_accel) {" << endl; + f_service_client << indent() << "if ($bin_accel) {" << '\n'; indent_up(); string messageType = (*f_iter)->is_oneway() ? "TMessageType::ONEWAY" : "TMessageType::CALL"; - f_service_client << indent() << "thrift_protocol_write_binary(" << endl; + f_service_client << indent() << "thrift_protocol_write_binary(" << '\n'; indent_up(); - f_service_client << indent() << "$this->output_," << endl - << indent() << "'" << (*f_iter)->get_name() << "'," << endl - << indent() << messageType << "," << endl - << indent() << "$args," << endl - << indent() << "$this->seqid_," << endl - << indent() << "$this->output_->isStrictWrite()" << endl; + f_service_client << indent() << "$this->output_," << '\n' + << indent() << "'" << (*f_iter)->get_name() << "'," << '\n' + << indent() << messageType << "," << '\n' + << indent() << "$args," << '\n' + << indent() << "$this->seqid_," << '\n' + << indent() << "$this->output_->isStrictWrite()" << '\n'; indent_down(); - f_service_client << indent() << ");" << endl; + f_service_client << indent() << ");" << '\n'; indent_down(); - f_service_client << indent() << "} else {" << endl; + f_service_client << indent() << "} else {" << '\n'; indent_up(); // Serialize the request header if (binary_inline_) { - f_service_client << indent() << "$buff = pack('N', (0x80010000 | " << messageType << "));" << endl - << indent() << "$buff .= pack('N', strlen('" << funname << "'));" << endl - << indent() << "$buff .= '" << funname << "';" << endl << indent() - << "$buff .= pack('N', $this->seqid_);" << endl; + f_service_client << indent() << "$buff = pack('N', (0x80010000 | " << messageType << "));" << '\n' + << indent() << "$buff .= pack('N', strlen('" << funname << "'));" << '\n' + << indent() << "$buff .= '" << funname << "';" << '\n' << indent() + << "$buff .= pack('N', $this->seqid_);" << '\n'; } else { f_service_client << indent() << "$this->output_->writeMessageBegin('" << (*f_iter)->get_name() - << "', " << messageType << ", $this->seqid_);" << endl; + << "', " << messageType << ", $this->seqid_);" << '\n'; } // Write to the stream if (binary_inline_) { - f_service_client << indent() << "$args->write($buff);" << endl << indent() - << "$this->output_->write($buff);" << endl << indent() - << "$this->output_->flush();" << endl; + f_service_client << indent() << "$args->write($buff);" << '\n' << indent() + << "$this->output_->write($buff);" << '\n' << indent() + << "$this->output_->flush();" << '\n'; } else { - f_service_client << indent() << "$args->write($this->output_);" << endl << indent() - << "$this->output_->writeMessageEnd();" << endl << indent() - << "$this->output_->getTransport()->flush();" << endl; + f_service_client << indent() << "$args->write($this->output_);" << '\n' << indent() + << "$this->output_->writeMessageEnd();" << '\n' << indent() + << "$this->output_->getTransport()->flush();" << '\n'; } scope_down(f_service_client); @@ -1997,98 +1995,98 @@ void t_php_generator::generate_service_client(t_service* tservice) { string("recv_") + (*f_iter)->get_name(), &noargs); // Open function - f_service_client << endl << indent() << "public function " << function_signature(&recv_function) - << endl; + f_service_client << '\n' << indent() << "public function " << function_signature(&recv_function) + << '\n'; scope_up(f_service_client); f_service_client << indent() << "$bin_accel = ($this->input_ instanceof " << "TBinaryProtocolAccelerated)" - << " && function_exists('thrift_protocol_read_binary');" << endl; + << " && function_exists('thrift_protocol_read_binary');" << '\n'; - f_service_client << indent() << "if ($bin_accel) {" << endl; + f_service_client << indent() << "if ($bin_accel) {" << '\n'; indent_up(); - f_service_client << indent() << "$result = thrift_protocol_read_binary(" << endl; + f_service_client << indent() << "$result = thrift_protocol_read_binary(" << '\n'; indent_up(); - f_service_client << indent() << "$this->input_," << endl - << indent() << "'" << resultname << "'," << endl - << indent() << "$this->input_->isStrictRead()" << endl; + f_service_client << indent() << "$this->input_," << '\n' + << indent() << "'" << resultname << "'," << '\n' + << indent() << "$this->input_->isStrictRead()" << '\n'; indent_down(); - f_service_client << indent() << ");" << endl; + f_service_client << indent() << ");" << '\n'; indent_down(); - f_service_client << indent() << "} else {" << endl; + f_service_client << indent() << "} else {" << '\n'; indent_up(); - f_service_client << indent() << "$rseqid = 0;" << endl - << indent() << "$fname = null;" << endl - << indent() << "$mtype = 0;" << endl << endl; + f_service_client << indent() << "$rseqid = 0;" << '\n' + << indent() << "$fname = null;" << '\n' + << indent() << "$mtype = 0;" << '\n' << '\n'; if (binary_inline_) { t_field ffname(g_type_string, "fname"); t_field fseqid(g_type_i32, "rseqid"); - f_service_client << indent() << "$ver = unpack('N', $this->input_->readAll(4));" << endl - << indent() << "$ver = $ver[1];" << endl << indent() << "$mtype = $ver & 0xff;" - << endl << indent() << "$ver = $ver & 0xffff0000;" << endl << indent() + f_service_client << indent() << "$ver = unpack('N', $this->input_->readAll(4));" << '\n' + << indent() << "$ver = $ver[1];" << '\n' << indent() << "$mtype = $ver & 0xff;" + << '\n' << indent() << "$ver = $ver & 0xffff0000;" << '\n' << indent() << "if ($ver != 0x80010000) throw new " << "TProtocolException('Bad version identifier: '.$ver, " - << "TProtocolException::BAD_VERSION);" << endl; + << "TProtocolException::BAD_VERSION);" << '\n'; generate_deserialize_field(f_service_client, &ffname, "", true); generate_deserialize_field(f_service_client, &fseqid, "", true); } else { - f_service_client << indent() << "$this->input_->readMessageBegin($fname, $mtype, $rseqid);" << endl - << indent() << "if ($mtype == TMessageType::EXCEPTION) {" << endl; + f_service_client << indent() << "$this->input_->readMessageBegin($fname, $mtype, $rseqid);" << '\n' + << indent() << "if ($mtype == TMessageType::EXCEPTION) {" << '\n'; indent_up(); - f_service_client << indent() << "$x = new TApplicationException();" << endl - << indent() << "$x->read($this->input_);" << endl - << indent() << "$this->input_->readMessageEnd();" << endl - << indent() << "throw $x;" << endl; + f_service_client << indent() << "$x = new TApplicationException();" << '\n' + << indent() << "$x->read($this->input_);" << '\n' + << indent() << "$this->input_->readMessageEnd();" << '\n' + << indent() << "throw $x;" << '\n'; indent_down(); - f_service_client << indent() << "}" << endl; + f_service_client << indent() << "}" << '\n'; } - f_service_client << indent() << "$result = new " << resultname << "();" << endl - << indent() << "$result->read($this->input_);" << endl; + f_service_client << indent() << "$result = new " << resultname << "();" << '\n' + << indent() << "$result->read($this->input_);" << '\n'; if (!binary_inline_) { - f_service_client << indent() << "$this->input_->readMessageEnd();" << endl; + f_service_client << indent() << "$this->input_->readMessageEnd();" << '\n'; } scope_down(f_service_client); // Careful, only return result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { - f_service_client << indent() << "if ($result->success !== null) {" << endl; + f_service_client << indent() << "if ($result->success !== null) {" << '\n'; indent_up(); - f_service_client << indent() << "return $result->success;" << endl; + f_service_client << indent() << "return $result->success;" << '\n'; indent_down(); - f_service_client << indent() << "}" << endl; + f_service_client << indent() << "}" << '\n'; } t_struct* xs = (*f_iter)->get_xceptions(); const std::vector& xceptions = xs->get_members(); vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { - f_service_client << indent() << "if ($result->" << (*x_iter)->get_name() << " !== null) {" << endl; + f_service_client << indent() << "if ($result->" << (*x_iter)->get_name() << " !== null) {" << '\n'; indent_up(); - f_service_client << indent() << "throw $result->" << (*x_iter)->get_name() << ";" << endl; + f_service_client << indent() << "throw $result->" << (*x_iter)->get_name() << ";" << '\n'; indent_down(); - f_service_client << indent() << "}" << endl; + f_service_client << indent() << "}" << '\n'; } // Careful, only return _result if not a void function if ((*f_iter)->get_returntype()->is_void()) { - indent(f_service_client) << "return;" << endl; + indent(f_service_client) << "return;" << '\n'; } else { f_service_client << indent() << "throw new \\Exception(\"" << (*f_iter)->get_name() - << " failed: unknown result\");" << endl; + << " failed: unknown result\");" << '\n'; } // Close function @@ -2097,7 +2095,7 @@ void t_php_generator::generate_service_client(t_service* tservice) { } indent_down(); - f_service_client << "}" << endl; + f_service_client << "}" << '\n'; // Close service client file if (!classmap_) { @@ -2138,54 +2136,54 @@ void t_php_generator::generate_deserialize_field(ostream& out, throw "compiler error: cannot serialize void field in a struct: " + name; break; case t_base_type::TYPE_STRING: - out << indent() << "$len = unpack('N', " << itrans << "->readAll(4));" << endl - << indent() << "$len = $len[1];" << endl << indent() << "if ($len > 0x7fffffff) {" - << endl << indent() << " $len = 0 - (($len - 1) ^ 0xffffffff);" << endl << indent() - << "}" << endl << indent() << "$" << name << " = " << itrans << "->readAll($len);" - << endl; + out << indent() << "$len = unpack('N', " << itrans << "->readAll(4));" << '\n' + << indent() << "$len = $len[1];" << '\n' << indent() << "if ($len > 0x7fffffff) {" + << '\n' << indent() << " $len = 0 - (($len - 1) ^ 0xffffffff);" << '\n' << indent() + << "}" << '\n' << indent() << "$" << name << " = " << itrans << "->readAll($len);" + << '\n'; break; case t_base_type::TYPE_BOOL: out << indent() << "$" << name << " = unpack('c', " << itrans << "->readAll(1));" - << endl << indent() << "$" << name << " = (bool)$" << name << "[1];" << endl; + << '\n' << indent() << "$" << name << " = (bool)$" << name << "[1];" << '\n'; break; case t_base_type::TYPE_I8: out << indent() << "$" << name << " = unpack('c', " << itrans << "->readAll(1));" - << endl << indent() << "$" << name << " = $" << name << "[1];" << endl; + << '\n' << indent() << "$" << name << " = $" << name << "[1];" << '\n'; break; case t_base_type::TYPE_I16: - out << indent() << "$val = unpack('n', " << itrans << "->readAll(2));" << endl - << indent() << "$val = $val[1];" << endl << indent() << "if ($val > 0x7fff) {" - << endl << indent() << " $val = 0 - (($val - 1) ^ 0xffff);" << endl << indent() - << "}" << endl << indent() << "$" << name << " = $val;" << endl; + out << indent() << "$val = unpack('n', " << itrans << "->readAll(2));" << '\n' + << indent() << "$val = $val[1];" << '\n' << indent() << "if ($val > 0x7fff) {" + << '\n' << indent() << " $val = 0 - (($val - 1) ^ 0xffff);" << '\n' << indent() + << "}" << '\n' << indent() << "$" << name << " = $val;" << '\n'; break; case t_base_type::TYPE_I32: - out << indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << endl - << indent() << "$val = $val[1];" << endl << indent() << "if ($val > 0x7fffffff) {" - << endl << indent() << " $val = 0 - (($val - 1) ^ 0xffffffff);" << endl << indent() - << "}" << endl << indent() << "$" << name << " = $val;" << endl; + out << indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << '\n' + << indent() << "$val = $val[1];" << '\n' << indent() << "if ($val > 0x7fffffff) {" + << '\n' << indent() << " $val = 0 - (($val - 1) ^ 0xffffffff);" << '\n' << indent() + << "}" << '\n' << indent() << "$" << name << " = $val;" << '\n'; break; case t_base_type::TYPE_I64: - out << indent() << "$arr = unpack('N2', " << itrans << "->readAll(8));" << endl - << indent() << "if ($arr[1] & 0x80000000) {" << endl << indent() - << " $arr[1] = $arr[1] ^ 0xFFFFFFFF;" << endl << indent() - << " $arr[2] = $arr[2] ^ 0xFFFFFFFF;" << endl << indent() << " $" << name - << " = 0 - $arr[1]*4294967296 - $arr[2] - 1;" << endl << indent() << "} else {" - << endl << indent() << " $" << name << " = $arr[1]*4294967296 + $arr[2];" << endl - << indent() << "}" << endl; + out << indent() << "$arr = unpack('N2', " << itrans << "->readAll(8));" << '\n' + << indent() << "if ($arr[1] & 0x80000000) {" << '\n' << indent() + << " $arr[1] = $arr[1] ^ 0xFFFFFFFF;" << '\n' << indent() + << " $arr[2] = $arr[2] ^ 0xFFFFFFFF;" << '\n' << indent() << " $" << name + << " = 0 - $arr[1]*4294967296 - $arr[2] - 1;" << '\n' << indent() << "} else {" + << '\n' << indent() << " $" << name << " = $arr[1]*4294967296 + $arr[2];" << '\n' + << indent() << "}" << '\n'; break; case t_base_type::TYPE_DOUBLE: - out << indent() << "$arr = unpack('d', strrev(" << itrans << "->readAll(8)));" << endl - << indent() << "$" << name << " = $arr[1];" << endl; + out << indent() << "$arr = unpack('d', strrev(" << itrans << "->readAll(8)));" << '\n' + << indent() << "$" << name << " = $arr[1];" << '\n'; break; default: throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase) + tfield->get_name(); } } else if (type->is_enum()) { - out << indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << endl << indent() - << "$val = $val[1];" << endl << indent() << "if ($val > 0x7fffffff) {" << endl - << indent() << " $val = 0 - (($val - 1) ^ 0xffffffff);" << endl << indent() << "}" - << endl << indent() << "$" << name << " = $val;" << endl; + out << indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << '\n' << indent() + << "$val = $val[1];" << '\n' << indent() << "if ($val > 0x7fffffff) {" << '\n' + << indent() << " $val = 0 - (($val - 1) ^ 0xffffffff);" << '\n' << indent() << "}" + << '\n' << indent() << "$" << name << " = $val;" << '\n'; } } else { @@ -2224,7 +2222,7 @@ void t_php_generator::generate_deserialize_field(ostream& out, } else if (type->is_enum()) { out << "readI32($" << name << ");"; } - out << endl; + out << '\n'; } } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", @@ -2242,8 +2240,8 @@ void t_php_generator::generate_deserialize_field(ostream& out, */ void t_php_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) { out << indent() << "$" << prefix << " = new " << php_namespace(tstruct->get_program()) - << tstruct->get_name() << "();" << endl << indent() << "$xfer += $" << prefix - << "->read($input);" << endl; + << tstruct->get_name() << "();" << '\n' << indent() << "$xfer += $" << prefix + << "->read($input);" << '\n'; } void t_php_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) { @@ -2257,44 +2255,44 @@ void t_php_generator::generate_deserialize_container(ostream& out, t_type* ttype t_field fvtype(g_type_i8, vtype); t_field fetype(g_type_i8, etype); - out << indent() << "$" << prefix << " = array();" << endl << indent() << "$" << size << " = 0;" - << endl; + out << indent() << "$" << prefix << " = array();" << '\n' << indent() << "$" << size << " = 0;" + << '\n'; // Declare variables, read header if (ttype->is_map()) { - out << indent() << "$" << ktype << " = 0;" << endl << indent() << "$" << vtype << " = 0;" - << endl; + out << indent() << "$" << ktype << " = 0;" << '\n' << indent() << "$" << vtype << " = 0;" + << '\n'; if (binary_inline_) { generate_deserialize_field(out, &fktype); generate_deserialize_field(out, &fvtype); generate_deserialize_field(out, &fsize); } else { out << indent() << "$xfer += $input->readMapBegin(" - << "$" << ktype << ", $" << vtype << ", $" << size << ");" << endl; + << "$" << ktype << ", $" << vtype << ", $" << size << ");" << '\n'; } } else if (ttype->is_set()) { if (binary_inline_) { generate_deserialize_field(out, &fetype); generate_deserialize_field(out, &fsize); } else { - out << indent() << "$" << etype << " = 0;" << endl << indent() + out << indent() << "$" << etype << " = 0;" << '\n' << indent() << "$xfer += $input->readSetBegin(" - << "$" << etype << ", $" << size << ");" << endl; + << "$" << etype << ", $" << size << ");" << '\n'; } } else if (ttype->is_list()) { if (binary_inline_) { generate_deserialize_field(out, &fetype); generate_deserialize_field(out, &fsize); } else { - out << indent() << "$" << etype << " = 0;" << endl << indent() + out << indent() << "$" << etype << " = 0;" << '\n' << indent() << "$xfer += $input->readListBegin(" - << "$" << etype << ", $" << size << ");" << endl; + << "$" << etype << ", $" << size << ");" << '\n'; } } // For loop iterates over elements string i = tmp("_i"); - indent(out) << "for ($" << i << " = 0; $" << i << " < $" << size << "; ++$" << i << ") {" << endl; + indent(out) << "for ($" << i << " = 0; $" << i << " < $" << size << "; ++$" << i << ") {" << '\n'; indent_up(); @@ -2311,11 +2309,11 @@ void t_php_generator::generate_deserialize_container(ostream& out, t_type* ttype if (!binary_inline_) { // Read container end if (ttype->is_map()) { - indent(out) << "$xfer += $input->readMapEnd();" << endl; + indent(out) << "$xfer += $input->readMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "$xfer += $input->readSetEnd();" << endl; + indent(out) << "$xfer += $input->readSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "$xfer += $input->readListEnd();" << endl; + indent(out) << "$xfer += $input->readListEnd();" << '\n'; } } } @@ -2329,28 +2327,28 @@ void t_php_generator::generate_deserialize_map_element(ostream& out, t_map* tmap t_field fkey(tmap->get_key_type(), key); t_field fval(tmap->get_val_type(), val); - indent(out) << declare_field(&fkey, true, true) << endl; - indent(out) << declare_field(&fval, true, true) << endl; + indent(out) << declare_field(&fkey, true, true) << '\n'; + indent(out) << declare_field(&fval, true, true) << '\n'; generate_deserialize_field(out, &fkey); generate_deserialize_field(out, &fval); - indent(out) << "$" << prefix << "[$" << key << "] = $" << val << ";" << endl; + indent(out) << "$" << prefix << "[$" << key << "] = $" << val << ";" << '\n'; } void t_php_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) { string elem = tmp("elem"); t_field felem(tset->get_elem_type(), elem); - indent(out) << "$" << elem << " = null;" << endl; + indent(out) << "$" << elem << " = null;" << '\n'; generate_deserialize_field(out, &felem); t_type* elem_type = tset->get_elem_type(); if(php_is_scalar(elem_type)) { - indent(out) << "$" << prefix << "[$" << elem << "] = true;" << endl; + indent(out) << "$" << prefix << "[$" << elem << "] = true;" << '\n'; } else { - indent(out) << "$" << prefix << "[] = $" << elem << ";" << endl; + indent(out) << "$" << prefix << "[] = $" << elem << ";" << '\n'; } } @@ -2360,11 +2358,11 @@ void t_php_generator::generate_deserialize_list_element(ostream& out, string elem = tmp("elem"); t_field felem(tlist->get_elem_type(), elem); - indent(out) << "$" << elem << " = null;" << endl; + indent(out) << "$" << elem << " = null;" << '\n'; generate_deserialize_field(out, &felem); - indent(out) << "$" << prefix << " []= $" << elem << ";" << endl; + indent(out) << "$" << prefix << " []= $" << elem << ";" << '\n'; } /** @@ -2397,33 +2395,33 @@ void t_php_generator::generate_serialize_field(ostream& out, t_field* tfield, st throw "compiler error: cannot serialize void field in a struct: " + name; break; case t_base_type::TYPE_STRING: - out << indent() << "$output .= pack('N', strlen($" << name << "));" << endl << indent() - << "$output .= $" << name << ";" << endl; + out << indent() << "$output .= pack('N', strlen($" << name << "));" << '\n' << indent() + << "$output .= $" << name << ";" << '\n'; break; case t_base_type::TYPE_BOOL: - out << indent() << "$output .= pack('c', $" << name << " ? 1 : 0);" << endl; + out << indent() << "$output .= pack('c', $" << name << " ? 1 : 0);" << '\n'; break; case t_base_type::TYPE_I8: - out << indent() << "$output .= pack('c', $" << name << ");" << endl; + out << indent() << "$output .= pack('c', $" << name << ");" << '\n'; break; case t_base_type::TYPE_I16: - out << indent() << "$output .= pack('n', $" << name << ");" << endl; + out << indent() << "$output .= pack('n', $" << name << ");" << '\n'; break; case t_base_type::TYPE_I32: - out << indent() << "$output .= pack('N', $" << name << ");" << endl; + out << indent() << "$output .= pack('N', $" << name << ");" << '\n'; break; case t_base_type::TYPE_I64: out << indent() << "$output .= pack('N2', $" << name << " >> 32, $" << name - << " & 0xFFFFFFFF);" << endl; + << " & 0xFFFFFFFF);" << '\n'; break; case t_base_type::TYPE_DOUBLE: - out << indent() << "$output .= strrev(pack('d', $" << name << "));" << endl; + out << indent() << "$output .= strrev(pack('d', $" << name << "));" << '\n'; break; default: throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase); } } else if (type->is_enum()) { - out << indent() << "$output .= pack('N', $" << name << ");" << endl; + out << indent() << "$output .= pack('N', $" << name << ");" << '\n'; } } else { @@ -2462,7 +2460,7 @@ void t_php_generator::generate_serialize_field(ostream& out, t_field* tfield, st } else if (type->is_enum()) { out << "writeI32($" << name << ");"; } - out << endl; + out << '\n'; } } else { printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n", @@ -2480,7 +2478,7 @@ void t_php_generator::generate_serialize_field(ostream& out, t_field* tfield, st */ void t_php_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - indent(out) << "$xfer += $" << prefix << "->write($output);" << endl; + indent(out) << "$xfer += $" << prefix << "->write($output);" << '\n'; } /** @@ -2490,35 +2488,35 @@ void t_php_generator::generate_serialize_container(ostream& out, t_type* ttype, if (ttype->is_map()) { if (binary_inline_) { out << indent() << "$output .= pack('c', " << type_to_enum(((t_map*)ttype)->get_key_type()) - << ");" << endl << indent() << "$output .= pack('c', " - << type_to_enum(((t_map*)ttype)->get_val_type()) << ");" << endl << indent() - << "$output .= strrev(pack('l', count($" << prefix << ")));" << endl; + << ");" << '\n' << indent() << "$output .= pack('c', " + << type_to_enum(((t_map*)ttype)->get_val_type()) << ");" << '\n' << indent() + << "$output .= strrev(pack('l', count($" << prefix << ")));" << '\n'; } else { indent(out) << "$output->writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " - << "count($" << prefix << "));" << endl; + << "count($" << prefix << "));" << '\n'; } } else if (ttype->is_set()) { if (binary_inline_) { out << indent() << "$output .= pack('c', " << type_to_enum(((t_set*)ttype)->get_elem_type()) - << ");" << endl << indent() << "$output .= strrev(pack('l', count($" << prefix << ")));" - << endl; + << ");" << '\n' << indent() << "$output .= strrev(pack('l', count($" << prefix << ")));" + << '\n'; } else { indent(out) << "$output->writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " - << "count($" << prefix << "));" << endl; + << "count($" << prefix << "));" << '\n'; } } else if (ttype->is_list()) { if (binary_inline_) { out << indent() << "$output .= pack('c', " << type_to_enum(((t_list*)ttype)->get_elem_type()) - << ");" << endl << indent() << "$output .= strrev(pack('l', count($" << prefix << ")));" - << endl; + << ");" << '\n' << indent() << "$output .= strrev(pack('l', count($" << prefix << ")));" + << '\n'; } else { indent(out) << "$output->writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " - << "count($" << prefix << "));" << endl; + << "count($" << prefix << "));" << '\n'; } } @@ -2526,14 +2524,14 @@ void t_php_generator::generate_serialize_container(ostream& out, t_type* ttype, string kiter = tmp("kiter"); string viter = tmp("viter"); indent(out) << "foreach ($" << prefix << " as " - << "$" << kiter << " => $" << viter << ") {" << endl; + << "$" << kiter << " => $" << viter << ") {" << '\n'; indent_up(); generate_serialize_map_element(out, (t_map*)ttype, kiter, viter); scope_down(out); } else if (ttype->is_set()) { string iter = tmp("iter"); string iter_val = tmp("iter"); - indent(out) << "foreach ($" << prefix << " as $" << iter << " => $" << iter_val << ") {" << endl; + indent(out) << "foreach ($" << prefix << " as $" << iter << " => $" << iter_val << ") {" << '\n'; indent_up(); t_type* elem_type = ((t_set*)ttype)->get_elem_type(); @@ -2545,7 +2543,7 @@ void t_php_generator::generate_serialize_container(ostream& out, t_type* ttype, scope_down(out); } else if (ttype->is_list()) { string iter = tmp("iter"); - indent(out) << "foreach ($" << prefix << " as $" << iter << ") {" << endl; + indent(out) << "foreach ($" << prefix << " as $" << iter << ") {" << '\n'; indent_up(); generate_serialize_list_element(out, (t_list*)ttype, iter); scope_down(out); @@ -2553,11 +2551,11 @@ void t_php_generator::generate_serialize_container(ostream& out, t_type* ttype, if (!binary_inline_) { if (ttype->is_map()) { - indent(out) << "$output->writeMapEnd();" << endl; + indent(out) << "$output->writeMapEnd();" << '\n'; } else if (ttype->is_set()) { - indent(out) << "$output->writeSetEnd();" << endl; + indent(out) << "$output->writeSetEnd();" << '\n'; } else if (ttype->is_list()) { - indent(out) << "$output->writeListEnd();" << endl; + indent(out) << "$output->writeListEnd();" << '\n'; } } } @@ -2617,12 +2615,12 @@ void t_php_generator::generate_php_doc(ostream& out, t_field* field) { // prepend free-style doc if available if (field->has_doc()) { - ss << field->get_doc() << endl; + ss << field->get_doc() << '\n'; } // append @var tag t_type* type = get_true_type(field->get_type()); - ss << "@var " << type_to_phpdoc(type) << endl; + ss << "@var " << type_to_phpdoc(type) << '\n'; generate_php_docstring_comment(out, ss.str()); } @@ -2633,7 +2631,7 @@ void t_php_generator::generate_php_doc(ostream& out, t_field* field) { void t_php_generator::generate_php_doc(ostream& out, t_function* function) { stringstream ss; if (function->has_doc()) { - ss << function->get_doc() << endl; + ss << function->get_doc() << '\n'; } // generate parameter types doc @@ -2645,7 +2643,7 @@ void t_php_generator::generate_php_doc(ostream& out, t_function* function) { if (arg->has_doc()) { ss << " " << arg->get_doc(); } - ss << endl; + ss << '\n'; } // generate return type doc @@ -2655,7 +2653,7 @@ void t_php_generator::generate_php_doc(ostream& out, t_function* function) { if (ret_type->has_doc()) { ss << " " << ret_type->get_doc(); } - ss << endl; + ss << '\n'; } // generate exceptions doc @@ -2667,7 +2665,7 @@ void t_php_generator::generate_php_doc(ostream& out, t_function* function) { if (exc->has_doc()) { ss << " " << exc->get_doc(); } - ss << endl; + ss << '\n'; } generate_docstring_comment(out, "/**\n", " * ", ss.str(), " */\n"); diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc index ffabd56521f..d3f23b6c89e 100644 --- a/compiler/cpp/src/thrift/generate/t_py_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc @@ -40,8 +40,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * Python code generator. * @@ -414,22 +412,22 @@ void t_py_generator::init_generator() { for (sv_iter = services.begin(); sv_iter != services.end(); ++sv_iter) { f_init << ", '" << (*sv_iter)->get_name() << "'"; } - f_init << "]" << endl; + f_init << "]" << '\n'; f_init.close(); // Print header - f_types_ << py_autogen_comment() << endl - << py_imports() << endl - << render_includes() << endl - << "from thrift.transport import TTransport" << endl + f_types_ << py_autogen_comment() << '\n' + << py_imports() << '\n' + << render_includes() << '\n' + << "from thrift.transport import TTransport" << '\n' << import_dynbase_; - f_types_ << "all_structs = []" << endl; + f_types_ << "all_structs = []" << '\n'; f_consts_ << - py_autogen_comment() << endl << - py_imports() << endl << - "from .ttypes import *" << endl; + py_autogen_comment() << '\n' << + py_imports() << '\n' << + "from .ttypes import *" << '\n'; } /** @@ -464,16 +462,16 @@ string t_py_generator::py_imports() { ostringstream ss; ss << "from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, " "TApplicationException" - << endl + << '\n' << "from thrift.protocol.TProtocol import TProtocolException" - << endl + << '\n' << "from thrift.TRecursive import fix_spec" - << endl; + << '\n'; if (gen_enum_) { - ss << "from enum import IntEnum" << endl; + ss << "from enum import IntEnum" << '\n'; } if (gen_utf8strings_) { - ss << endl << "import sys"; + ss << '\n' << "import sys"; } return ss.str(); } @@ -484,8 +482,8 @@ string t_py_generator::py_imports() { void t_py_generator::close_generator() { // Fix thrift_spec definitions for recursive structs. - f_types_ << "fix_spec(all_structs)" << endl; - f_types_ << "del all_structs" << endl; + f_types_ << "fix_spec(all_structs)" << '\n'; + f_types_ << "del all_structs" << '\n'; // Close types file f_types_.close(); @@ -519,37 +517,37 @@ void t_py_generator::generate_enum(t_enum* tenum) { base_class = gen_dynbaseclass_; } - f_types_ << endl - << endl + f_types_ << '\n' + << '\n' << "class " << tenum->get_name() << (base_class.empty() ? "" : "(" + base_class + ")") << ":" - << endl; + << '\n'; indent_up(); generate_python_docstring(f_types_, tenum); - to_string_mapping << indent() << "_VALUES_TO_NAMES = {" << endl; - from_string_mapping << indent() << "_NAMES_TO_VALUES = {" << endl; + to_string_mapping << indent() << "_VALUES_TO_NAMES = {" << '\n'; + from_string_mapping << indent() << "_NAMES_TO_VALUES = {" << '\n'; vector constants = tenum->get_constants(); vector::iterator c_iter; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); - indent(f_types_) << (*c_iter)->get_name() << " = " << value << endl; + indent(f_types_) << (*c_iter)->get_name() << " = " << value << '\n'; // Dictionaries to/from string names of enums to_string_mapping << indent() << indent() << value << ": \"" - << escape_string((*c_iter)->get_name()) << "\"," << endl; + << escape_string((*c_iter)->get_name()) << "\"," << '\n'; from_string_mapping << indent() << indent() << '"' << escape_string((*c_iter)->get_name()) - << "\": " << value << ',' << endl; + << "\": " << value << ',' << '\n'; } - to_string_mapping << indent() << "}" << endl; - from_string_mapping << indent() << "}" << endl; + to_string_mapping << indent() << "}" << '\n'; + from_string_mapping << indent() << "}" << '\n'; indent_down(); - f_types_ << endl; + f_types_ << '\n'; if (!gen_enum_) { - f_types_ << to_string_mapping.str() << endl << from_string_mapping.str(); + f_types_ << to_string_mapping.str() << '\n' << from_string_mapping.str(); } } @@ -562,7 +560,7 @@ void t_py_generator::generate_const(t_const* tconst) { t_const_value* value = tconst->get_value(); indent(f_consts_) << name << " = " << render_const_value(type, value); - f_consts_ << endl; + f_consts_ << '\n'; } /** @@ -612,7 +610,7 @@ string t_py_generator::render_const_value(t_type* type, t_const_value* value) { out << int_val; } } else if (type->is_struct() || type->is_xception()) { - out << type_name(type) << "(**{" << endl; + out << type_name(type) << "(**{" << '\n'; indent_up(); const vector& fields = ((t_struct*)type)->get_members(); vector::const_iterator f_iter; @@ -629,7 +627,7 @@ string t_py_generator::render_const_value(t_type* type, t_const_value* value) { throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string(); } indent(out) << render_const_value(g_type_string, v_iter->first) << ": " - << render_const_value(field_type, v_iter->second) << "," << endl; + << render_const_value(field_type, v_iter->second) << "," << '\n'; } indent_down(); indent(out) << "})"; @@ -639,13 +637,13 @@ string t_py_generator::render_const_value(t_type* type, t_const_value* value) { if (is_immutable(type)) { out << "TFrozenDict("; } - out << "{" << endl; + out << "{" << '\n'; indent_up(); const map& val = value->get_map(); map::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { indent(out) << render_const_value(ktype, v_iter->first) << ": " - << render_const_value(vtype, v_iter->second) << "," << endl; + << render_const_value(vtype, v_iter->second) << "," << '\n'; } indent_down(); indent(out) << "}"; @@ -666,15 +664,15 @@ string t_py_generator::render_const_value(t_type* type, t_const_value* value) { out << "set("; } if (is_immutable(type) || type->is_set()) { - out << "(" << endl; + out << "(" << '\n'; } else { - out << "[" << endl; + out << "[" << '\n'; } indent_up(); const vector& val = value->get_list(); vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { - indent(out) << render_const_value(etype, *v_iter) << "," << endl; + indent(out) << render_const_value(etype, *v_iter) << "," << '\n'; } indent_down(); if (is_immutable(type) || type->is_set()) { @@ -743,17 +741,17 @@ void t_py_generator::generate_py_thrift_spec(ostream& out, vector::const_iterator m_iter; // Add struct definition to list so thrift_spec can be fixed for recursive structures. - indent(out) << "all_structs.append(" << tstruct->get_name() << ")" << endl; + indent(out) << "all_structs.append(" << tstruct->get_name() << ")" << '\n'; if (sorted_members.empty() || (sorted_members[0]->get_key() >= 0)) { - indent(out) << tstruct->get_name() << ".thrift_spec = (" << endl; + indent(out) << tstruct->get_name() << ".thrift_spec = (" << '\n'; indent_up(); int sorted_keys_pos = 0; for (m_iter = sorted_members.begin(); m_iter != sorted_members.end(); ++m_iter) { for (; sorted_keys_pos != (*m_iter)->get_key(); sorted_keys_pos++) { - indent(out) << "None, # " << sorted_keys_pos << endl; + indent(out) << "None, # " << sorted_keys_pos << '\n'; } indent(out) << "(" << (*m_iter)->get_key() << ", " << type_to_enum((*m_iter)->get_type()) @@ -762,15 +760,15 @@ void t_py_generator::generate_py_thrift_spec(ostream& out, << ", " << type_to_spec_args((*m_iter)->get_type()) << ", " << render_field_default_value(*m_iter) << ", " << ")," - << " # " << sorted_keys_pos << endl; + << " # " << sorted_keys_pos << '\n'; sorted_keys_pos++; } indent_down(); - indent(out) << ")" << endl; + indent(out) << ")" << '\n'; } else { - indent(out) << tstruct->get_name() << ".thrift_spec = ()" << endl; + indent(out) << tstruct->get_name() << ".thrift_spec = ()" << '\n'; } } @@ -786,7 +784,7 @@ void t_py_generator::generate_py_struct_definition(ostream& out, const vector& sorted_members = tstruct->get_sorted_members(); vector::const_iterator m_iter; - out << endl << endl << "class " << tstruct->get_name(); + out << '\n' << '\n' << "class " << tstruct->get_name(); if (is_exception) { if (gen_dynamic_) { if (is_immutable(tstruct)) { @@ -806,11 +804,11 @@ void t_py_generator::generate_py_struct_definition(ostream& out, } else if (gen_newstyle_) { out << "(object)"; } - out << ":" << endl; + out << ":" << '\n'; indent_up(); generate_python_docstring(out, tstruct); - out << endl; + out << '\n'; /* Here we generate the structure specification for the fastbinary codec. @@ -833,13 +831,13 @@ void t_py_generator::generate_py_struct_definition(ostream& out, */ if (gen_slots_) { - indent(out) << "__slots__ = (" << endl; + indent(out) << "__slots__ = (" << '\n'; indent_up(); for (m_iter = sorted_members.begin(); m_iter != sorted_members.end(); ++m_iter) { - indent(out) << "'" << (*m_iter)->get_name() << "'," << endl; + indent(out) << "'" << (*m_iter)->get_name() << "'," << '\n'; } indent_down(); - indent(out) << ")" << endl << endl; + indent(out) << ")" << '\n' << '\n'; } // TODO(dreiss): Look into generating an empty tuple instead of None @@ -848,13 +846,13 @@ void t_py_generator::generate_py_struct_definition(ostream& out, // don't have thrift_spec. if (members.size() > 0) { - out << endl; + out << '\n'; out << indent() << "def __init__(self,"; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { out << " " << declare_argument(*m_iter) << ","; } - out << "):" << endl; + out << "):" << '\n'; indent_up(); @@ -863,10 +861,10 @@ void t_py_generator::generate_py_struct_definition(ostream& out, t_type* type = (*m_iter)->get_type(); if (!type->is_base_type() && !type->is_enum() && (*m_iter)->get_value() != nullptr) { indent(out) << "if " << (*m_iter)->get_name() << " is " - << "self.thrift_spec[" << (*m_iter)->get_key() << "][4]:" << endl; + << "self.thrift_spec[" << (*m_iter)->get_key() << "][4]:" << '\n'; indent_up(); indent(out) << (*m_iter)->get_name() << " = " << render_field_default_value(*m_iter) - << endl; + << '\n'; indent_down(); } @@ -875,16 +873,16 @@ void t_py_generator::generate_py_struct_definition(ostream& out, indent(out) << "super(" << tstruct->get_name() << ", self).__setattr__('" << (*m_iter)->get_name() << "', " << (*m_iter)->get_name() << " if hasattr(" << (*m_iter)->get_name() << ", 'value') else " - << type_name(type) << ".__members__.get(" << (*m_iter)->get_name() << "))" << endl; + << type_name(type) << ".__members__.get(" << (*m_iter)->get_name() << "))" << '\n'; } else if (gen_newstyle_ || gen_dynamic_) { indent(out) << "super(" << tstruct->get_name() << ", self).__setattr__('" - << (*m_iter)->get_name() << "', " << (*m_iter)->get_name() << ")" << endl; + << (*m_iter)->get_name() << "', " << (*m_iter)->get_name() << ")" << '\n'; } else { indent(out) << "self.__dict__['" << (*m_iter)->get_name() - << "'] = " << (*m_iter)->get_name() << endl; + << "'] = " << (*m_iter)->get_name() << '\n'; } } else { - indent(out) << "self." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << endl; + indent(out) << "self." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << '\n'; } } @@ -892,8 +890,8 @@ void t_py_generator::generate_py_struct_definition(ostream& out, } if (is_immutable(tstruct)) { - out << endl; - out << indent() << "def __setattr__(self, *args):" << endl; + out << '\n'; + out << indent() << "def __setattr__(self, *args):" << '\n'; indent_up(); // Not user-provided fields should be editable so that the Python Standard Library can edit @@ -902,16 +900,16 @@ void t_py_generator::generate_py_struct_definition(ostream& out, // trivial because we know which fields are user-provided, without slots we need to build a // way to know which fields are user-provided. if (gen_slots_ && !gen_dynamic_) { - out << indent() << "if args[0] not in self.__slots__:" << endl; + out << indent() << "if args[0] not in self.__slots__:" << '\n'; indent_up(); - out << indent() << "super().__setattr__(*args)" << endl - << indent() << "return" << endl; + out << indent() << "super().__setattr__(*args)" << '\n' + << indent() << "return" << '\n'; indent_down(); } - out << indent() << "raise TypeError(\"can't modify immutable instance\")" << endl; + out << indent() << "raise TypeError(\"can't modify immutable instance\")" << '\n'; indent_down(); - out << endl; - out << indent() << "def __delattr__(self, *args):" << endl; + out << '\n'; + out << indent() << "def __delattr__(self, *args):" << '\n'; indent_up(); // Not user-provided fields should be editable so that the Python Standard Library can edit @@ -920,26 +918,26 @@ void t_py_generator::generate_py_struct_definition(ostream& out, // trivial because we know which fields are user-provided, without slots we need to build a // way to know which fields are user-provided. if (gen_slots_ && !gen_dynamic_) { - out << indent() << "if args[0] not in self.__slots__:" << endl; + out << indent() << "if args[0] not in self.__slots__:" << '\n'; indent_up(); - out << indent() << "super().__delattr__(*args)" << endl - << indent() << "return" << endl; + out << indent() << "super().__delattr__(*args)" << '\n' + << indent() << "return" << '\n'; indent_down(); } - out << indent() << "raise TypeError(\"can't modify immutable instance\")" << endl; + out << indent() << "raise TypeError(\"can't modify immutable instance\")" << '\n'; indent_down(); - out << endl; + out << '\n'; // Hash all of the members in order, and also hash in the class // to avoid collisions for stuff like single-field structures. - out << indent() << "def __hash__(self):" << endl + out << indent() << "def __hash__(self):" << '\n' << indent() << indent_str() << "return hash(self.__class__) ^ hash(("; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { out << "self." << (*m_iter)->get_name() << ", "; } - out << "))" << endl; + out << "))" << '\n'; } else if (gen_enum_) { bool has_enum = false; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -951,25 +949,25 @@ void t_py_generator::generate_py_struct_definition(ostream& out, } if (has_enum) { - out << endl; - indent(out) << "def __setattr__(self, name, value):" << endl; + out << '\n'; + indent(out) << "def __setattr__(self, name, value):" << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_type* type = (*m_iter)->get_type(); if (type->is_enum()) { - out << indent() << "if name == \"" << (*m_iter)->get_name() << "\":" << endl + out << indent() << "if name == \"" << (*m_iter)->get_name() << "\":" << '\n' << indent() << indent_str() << "super().__setattr__(name, value if hasattr(value, 'value') else " - << type_name(type) << ".__members__.get(value))" << endl - << indent() << indent_str() << "return" << endl; + << type_name(type) << ".__members__.get(value))" << '\n' + << indent() << indent_str() << "return" << '\n'; } } - indent(out) << "super().__setattr__(name, value)" << endl << endl; + indent(out) << "super().__setattr__(name, value)" << '\n' << '\n'; indent_down(); } } if (!gen_dynamic_) { - out << endl; + out << '\n'; generate_py_struct_reader(out, tstruct); generate_py_struct_writer(out, tstruct); } @@ -978,64 +976,64 @@ void t_py_generator::generate_py_struct_definition(ostream& out, // because when raised exceptions are printed to the console, __repr__ // isn't used. See python bug #5882 if (is_exception) { - out << endl; - out << indent() << "def __str__(self):" << endl - << indent() << indent_str() << "return repr(self)" << endl; + out << '\n'; + out << indent() << "def __str__(self):" << '\n' + << indent() << indent_str() << "return repr(self)" << '\n'; } if (!gen_slots_) { - out << endl; + out << '\n'; // Printing utilities so that on the command line thrift // structs look pretty like dictionaries - indent(out) << "def __repr__(self):" << endl; + indent(out) << "def __repr__(self):" << '\n'; indent_up(); - out << indent() << "L = ['%s=%r' % (key, value)" << endl - << indent() << " for key, value in self.__dict__.items()]" << endl - << indent() << "return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << endl - << endl; + out << indent() << "L = ['%s=%r' % (key, value)" << '\n' + << indent() << " for key, value in self.__dict__.items()]" << '\n' + << indent() << "return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << '\n' + << '\n'; indent_down(); // Equality and inequality methods that compare by value - out << indent() << "def __eq__(self, other):" << endl; + out << indent() << "def __eq__(self, other):" << '\n'; indent_up(); out << indent() << "return isinstance(other, self.__class__) and " - "self.__dict__ == other.__dict__" << endl; + "self.__dict__ == other.__dict__" << '\n'; indent_down(); - out << endl; + out << '\n'; - out << indent() << "def __ne__(self, other):" << endl; + out << indent() << "def __ne__(self, other):" << '\n'; indent_up(); - out << indent() << "return not (self == other)" << endl; + out << indent() << "return not (self == other)" << '\n'; indent_down(); } else if (!gen_dynamic_) { - out << endl; + out << '\n'; // no base class available to implement __eq__ and __repr__ and __ne__ for us // so we must provide one that uses __slots__ - indent(out) << "def __repr__(self):" << endl; + indent(out) << "def __repr__(self):" << '\n'; indent_up(); - out << indent() << "L = ['%s=%r' % (key, getattr(self, key))" << endl - << indent() << " for key in self.__slots__]" << endl - << indent() << "return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << endl - << endl; + out << indent() << "L = ['%s=%r' % (key, getattr(self, key))" << '\n' + << indent() << " for key in self.__slots__]" << '\n' + << indent() << "return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << '\n' + << '\n'; indent_down(); // Equality method that compares each attribute by value and type, walking __slots__ - out << indent() << "def __eq__(self, other):" << endl; + out << indent() << "def __eq__(self, other):" << '\n'; indent_up(); - out << indent() << "if not isinstance(other, self.__class__):" << endl - << indent() << indent_str() << "return False" << endl - << indent() << "for attr in self.__slots__:" << endl - << indent() << indent_str() << "my_val = getattr(self, attr)" << endl - << indent() << indent_str() << "other_val = getattr(other, attr)" << endl - << indent() << indent_str() << "if my_val != other_val:" << endl - << indent() << indent_str() << indent_str() << "return False" << endl - << indent() << "return True" << endl - << endl; + out << indent() << "if not isinstance(other, self.__class__):" << '\n' + << indent() << indent_str() << "return False" << '\n' + << indent() << "for attr in self.__slots__:" << '\n' + << indent() << indent_str() << "my_val = getattr(self, attr)" << '\n' + << indent() << indent_str() << "other_val = getattr(other, attr)" << '\n' + << indent() << indent_str() << "if my_val != other_val:" << '\n' + << indent() << indent_str() << indent_str() << "return False" << '\n' + << indent() << "return True" << '\n' + << '\n'; indent_down(); - out << indent() << "def __ne__(self, other):" << endl - << indent() << indent_str() << "return not (self == other)" << endl; + out << indent() << "def __ne__(self, other):" << '\n' + << indent() << indent_str() << "return not (self == other)" << '\n'; } indent_down(); } @@ -1048,9 +1046,9 @@ void t_py_generator::generate_py_struct_reader(ostream& out, t_struct* tstruct) vector::const_iterator f_iter; if (is_immutable(tstruct)) { - out << indent() << "@classmethod" << endl << indent() << "def read(cls, iprot):" << endl; + out << indent() << "@classmethod" << '\n' << indent() << "def read(cls, iprot):" << '\n'; } else { - indent(out) << "def read(self, iprot):" << endl; + indent(out) << "def read(self, iprot):" << '\n'; } indent_up(); @@ -1059,18 +1057,18 @@ void t_py_generator::generate_py_struct_reader(ostream& out, t_struct* tstruct) indent(out) << "if iprot._fast_decode is not None " "and isinstance(iprot.trans, TTransport.CReadableTransport) " "and " - << id << ".thrift_spec is not None:" << endl; + << id << ".thrift_spec is not None:" << '\n'; indent_up(); if (is_immutable(tstruct)) { - indent(out) << "return iprot._fast_decode(None, iprot, [cls, cls.thrift_spec])" << endl; + indent(out) << "return iprot._fast_decode(None, iprot, [cls, cls.thrift_spec])" << '\n'; } else { - indent(out) << "iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])" << endl; - indent(out) << "return" << endl; + indent(out) << "iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])" << '\n'; + indent(out) << "return" << '\n'; } indent_down(); - indent(out) << "iprot.readStructBegin()" << endl; + indent(out) << "iprot.readStructBegin()" << '\n'; if (is_immutable(tstruct)) { for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { @@ -1082,21 +1080,21 @@ void t_py_generator::generate_py_struct_reader(ostream& out, t_struct* tstruct) } else { result << "None"; } - indent(out) << result.str() << endl; + indent(out) << result.str() << '\n'; } } // Loop over reading in fields - indent(out) << "while True:" << endl; + indent(out) << "while True:" << '\n'; indent_up(); // Read beginning field marker - indent(out) << "(fname, ftype, fid) = iprot.readFieldBegin()" << endl; + indent(out) << "(fname, ftype, fid) = iprot.readFieldBegin()" << '\n'; // Check for field STOP marker and break - indent(out) << "if ftype == TType.STOP:" << endl; + indent(out) << "if ftype == TType.STOP:" << '\n'; indent_up(); - indent(out) << "break" << endl; + indent(out) << "break" << '\n'; indent_down(); // Switch statement on the field we are reading @@ -1110,9 +1108,9 @@ void t_py_generator::generate_py_struct_reader(ostream& out, t_struct* tstruct) } else { out << indent() << "elif "; } - out << "fid == " << (*f_iter)->get_key() << ":" << endl; + out << "fid == " << (*f_iter)->get_key() << ":" << '\n'; indent_up(); - indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << ":" << endl; + indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << ":" << '\n'; indent_up(); if (is_immutable(tstruct)) { generate_deserialize_field(out, *f_iter); @@ -1120,32 +1118,32 @@ void t_py_generator::generate_py_struct_reader(ostream& out, t_struct* tstruct) generate_deserialize_field(out, *f_iter, "self."); } indent_down(); - out << indent() << "else:" << endl << indent() << indent_str() << "iprot.skip(ftype)" << endl; + out << indent() << "else:" << '\n' << indent() << indent_str() << "iprot.skip(ftype)" << '\n'; indent_down(); } // In the default case we skip the field - out << indent() << "else:" << endl << indent() << indent_str() << "iprot.skip(ftype)" << endl; + out << indent() << "else:" << '\n' << indent() << indent_str() << "iprot.skip(ftype)" << '\n'; // Read field end marker - indent(out) << "iprot.readFieldEnd()" << endl; + indent(out) << "iprot.readFieldEnd()" << '\n'; indent_down(); - indent(out) << "iprot.readStructEnd()" << endl; + indent(out) << "iprot.readStructEnd()" << '\n'; if (is_immutable(tstruct)) { - indent(out) << "return cls(" << endl; + indent(out) << "return cls(" << '\n'; indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - indent(out) << (*f_iter)->get_name() << "=" << (*f_iter)->get_name() << "," << endl; + indent(out) << (*f_iter)->get_name() << "=" << (*f_iter)->get_name() << "," << '\n'; } indent_down(); - indent(out) << ")" << endl; + indent(out) << ")" << '\n'; } indent_down(); - out << endl; + out << '\n'; } void t_py_generator::generate_py_struct_writer(ostream& out, t_struct* tstruct) { @@ -1153,49 +1151,49 @@ void t_py_generator::generate_py_struct_writer(ostream& out, t_struct* tstruct) const vector& fields = tstruct->get_sorted_members(); vector::const_iterator f_iter; - indent(out) << "def write(self, oprot):" << endl; + indent(out) << "def write(self, oprot):" << '\n'; indent_up(); - indent(out) << "if oprot._fast_encode is not None and self.thrift_spec is not None:" << endl; + indent(out) << "if oprot._fast_encode is not None and self.thrift_spec is not None:" << '\n'; indent_up(); indent(out) << "oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))" - << endl; - indent(out) << "return" << endl; + << '\n'; + indent(out) << "return" << '\n'; indent_down(); - indent(out) << "oprot.writeStructBegin('" << name << "')" << endl; + indent(out) << "oprot.writeStructBegin('" << name << "')" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { // Write field header - indent(out) << "if self." << (*f_iter)->get_name() << " is not None:" << endl; + indent(out) << "if self." << (*f_iter)->get_name() << " is not None:" << '\n'; indent_up(); indent(out) << "oprot.writeFieldBegin(" << "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type()) - << ", " << (*f_iter)->get_key() << ")" << endl; + << ", " << (*f_iter)->get_key() << ")" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "self."); // Write field closer - indent(out) << "oprot.writeFieldEnd()" << endl; + indent(out) << "oprot.writeFieldEnd()" << '\n'; indent_down(); } // Write the struct map - out << indent() << "oprot.writeFieldStop()" << endl << indent() << "oprot.writeStructEnd()" - << endl; + out << indent() << "oprot.writeFieldStop()" << '\n' << indent() << "oprot.writeStructEnd()" + << '\n'; - out << endl; + out << '\n'; indent_down(); generate_py_struct_required_validator(out, tstruct); } void t_py_generator::generate_py_struct_required_validator(ostream& out, t_struct* tstruct) { - indent(out) << "def validate(self):" << endl; + indent(out) << "def validate(self):" << '\n'; indent_up(); const vector& fields = tstruct->get_members(); @@ -1206,14 +1204,14 @@ void t_py_generator::generate_py_struct_required_validator(ostream& out, t_struc for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_field* field = (*f_iter); if (field->get_req() == t_field::T_REQUIRED) { - indent(out) << "if self." << field->get_name() << " is None:" << endl; + indent(out) << "if self." << field->get_name() << " is None:" << '\n'; indent(out) << indent_str() << "raise TProtocolException(message='Required field " - << field->get_name() << " is unset!')" << endl; + << field->get_name() << " is unset!')" << '\n'; } } } - indent(out) << "return" << endl; + indent(out) << "return" << '\n'; indent_down(); } @@ -1226,32 +1224,32 @@ void t_py_generator::generate_service(t_service* tservice) { string f_service_name = package_dir_ + "/" + service_name_ + ".py"; f_service_.open(f_service_name.c_str()); - f_service_ << py_autogen_comment() << endl << py_imports() << endl; + f_service_ << py_autogen_comment() << '\n' << py_imports() << '\n'; if (tservice->get_extends() != nullptr) { f_service_ << "import " << get_real_py_module(tservice->get_extends()->get_program(), gen_twisted_, package_prefix_) << "." - << tservice->get_extends()->get_name() << endl; + << tservice->get_extends()->get_name() << '\n'; } - f_service_ << "import logging" << endl - << "from .ttypes import *" << endl - << "from thrift.Thrift import TProcessor" << endl - << "from thrift.transport import TTransport" << endl + f_service_ << "import logging" << '\n' + << "from .ttypes import *" << '\n' + << "from thrift.Thrift import TProcessor" << '\n' + << "from thrift.transport import TTransport" << '\n' << import_dynbase_; if (gen_zope_interface_) { - f_service_ << "from zope.interface import Interface, implementer" << endl; + f_service_ << "from zope.interface import Interface, implementer" << '\n'; } if (gen_twisted_) { - f_service_ << "from twisted.internet import defer" << endl - << "from thrift.transport import TTwisted" << endl; + f_service_ << "from twisted.internet import defer" << '\n' + << "from thrift.transport import TTwisted" << '\n'; } else if (gen_tornado_) { - f_service_ << "from tornado import gen" << endl; - f_service_ << "from tornado import concurrent" << endl; + f_service_ << "from tornado import gen" << '\n'; + f_service_ << "from tornado import concurrent" << '\n'; } - f_service_ << "all_structs = []" << endl; + f_service_ << "all_structs = []" << '\n'; // Generate the three main parts of the service generate_service_interface(tservice); @@ -1261,8 +1259,8 @@ void t_py_generator::generate_service(t_service* tservice) { generate_service_remote(tservice); // Close service file - f_service_ << "fix_spec(all_structs)" << endl - << "del all_structs" << endl; + f_service_ << "fix_spec(all_structs)" << '\n' + << "del all_structs" << '\n'; f_service_.close(); } @@ -1275,7 +1273,7 @@ void t_py_generator::generate_service_helpers(t_service* tservice) { vector functions = tservice->get_functions(); vector::iterator f_iter; - f_service_ << endl << "# HELPER FUNCTIONS AND STRUCTURES" << endl; + f_service_ << '\n' << "# HELPER FUNCTIONS AND STRUCTURES" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { t_struct* ts = (*f_iter)->get_arglist(); @@ -1328,12 +1326,12 @@ void t_py_generator::generate_service_interface(t_service* tservice) { } } - f_service_ << endl << endl << "class Iface" << extends_if << ":" << endl; + f_service_ << '\n' << '\n' << "class Iface" << extends_if << ":" << '\n'; indent_up(); generate_python_docstring(f_service_, tservice); vector functions = tservice->get_functions(); if (functions.empty()) { - f_service_ << indent() << "pass" << endl; + f_service_ << indent() << "pass" << '\n'; } else { vector::iterator f_iter; bool first = true; @@ -1341,12 +1339,12 @@ void t_py_generator::generate_service_interface(t_service* tservice) { if (first) { first = false; } else { - f_service_ << endl; + f_service_ << '\n'; } - f_service_ << indent() << "def " << function_signature(*f_iter, true) << ":" << endl; + f_service_ << indent() << "def " << function_signature(*f_iter, true) << ":" << '\n'; indent_up(); generate_python_docstring(f_service_, (*f_iter)); - f_service_ << indent() << "pass" << endl; + f_service_ << indent() << "pass" << '\n'; indent_down(); } } @@ -1375,91 +1373,91 @@ void t_py_generator::generate_service_client(t_service* tservice) { } } - f_service_ << endl << endl; + f_service_ << '\n' << '\n'; if (gen_zope_interface_) { - f_service_ << "@implementer(Iface)" << endl - << "class Client" << extends_client << ":" << endl - << endl; + f_service_ << "@implementer(Iface)" << '\n' + << "class Client" << extends_client << ":" << '\n' + << '\n'; } else { - f_service_ << "class Client(" << extends_client << "Iface):" << endl; + f_service_ << "class Client(" << extends_client << "Iface):" << '\n'; } indent_up(); generate_python_docstring(f_service_, tservice); // Constructor function if (gen_twisted_) { - f_service_ << indent() << "def __init__(self, transport, oprot_factory):" << endl; + f_service_ << indent() << "def __init__(self, transport, oprot_factory):" << '\n'; } else if (gen_tornado_) { f_service_ << indent() - << "def __init__(self, transport, iprot_factory, oprot_factory=None):" << endl; + << "def __init__(self, transport, iprot_factory, oprot_factory=None):" << '\n'; } else { - f_service_ << indent() << "def __init__(self, iprot, oprot=None):" << endl; + f_service_ << indent() << "def __init__(self, iprot, oprot=None):" << '\n'; } indent_up(); if (extends.empty()) { if (gen_twisted_) { - f_service_ << indent() << "self._transport = transport" << endl - << indent() << "self._oprot_factory = oprot_factory" << endl - << indent() << "self._seqid = 0" << endl - << indent() << "self._reqs = {}" << endl; + f_service_ << indent() << "self._transport = transport" << '\n' + << indent() << "self._oprot_factory = oprot_factory" << '\n' + << indent() << "self._seqid = 0" << '\n' + << indent() << "self._reqs = {}" << '\n'; } else if (gen_tornado_) { - f_service_ << indent() << "self._transport = transport" << endl - << indent() << "self._iprot_factory = iprot_factory" << endl + f_service_ << indent() << "self._transport = transport" << '\n' + << indent() << "self._iprot_factory = iprot_factory" << '\n' << indent() << "self._oprot_factory = (oprot_factory if oprot_factory is not None" - << endl - << indent() << " else iprot_factory)" << endl - << indent() << "self._seqid = 0" << endl - << indent() << "self._reqs = {}" << endl + << '\n' + << indent() << " else iprot_factory)" << '\n' + << indent() << "self._seqid = 0" << '\n' + << indent() << "self._reqs = {}" << '\n' << indent() << "self._transport.io_loop.spawn_callback(self._start_receiving)" - << endl; + << '\n'; } else { - f_service_ << indent() << "self._iprot = self._oprot = iprot" << endl - << indent() << "if oprot is not None:" << endl - << indent() << indent_str() << "self._oprot = oprot" << endl - << indent() << "self._seqid = 0" << endl; + f_service_ << indent() << "self._iprot = self._oprot = iprot" << '\n' + << indent() << "if oprot is not None:" << '\n' + << indent() << indent_str() << "self._oprot = oprot" << '\n' + << indent() << "self._seqid = 0" << '\n'; } } else { if (gen_twisted_) { f_service_ << indent() << extends - << ".Client.__init__(self, transport, oprot_factory)" << endl; + << ".Client.__init__(self, transport, oprot_factory)" << '\n'; } else if (gen_tornado_) { f_service_ << indent() << extends - << ".Client.__init__(self, transport, iprot_factory, oprot_factory)" << endl; + << ".Client.__init__(self, transport, iprot_factory, oprot_factory)" << '\n'; } else { - f_service_ << indent() << extends << ".Client.__init__(self, iprot, oprot)" << endl; + f_service_ << indent() << extends << ".Client.__init__(self, iprot, oprot)" << '\n'; } } indent_down(); if (gen_tornado_ && extends.empty()) { - f_service_ << endl << - indent() << "@gen.engine" << endl << - indent() << "def _start_receiving(self):" << endl; + f_service_ << '\n' << + indent() << "@gen.engine" << '\n' << + indent() << "def _start_receiving(self):" << '\n'; indent_up(); - indent(f_service_) << "while True:" << endl; + indent(f_service_) << "while True:" << '\n'; indent_up(); - f_service_ << indent() << "try:" << endl - << indent() << indent_str() << "frame = yield self._transport.readFrame()" << endl - << indent() << "except TTransport.TTransportException as e:" << endl - << indent() << indent_str() << "for future in self._reqs.values():" << endl - << indent() << indent_str() << indent_str() << "future.set_exception(e)" << endl - << indent() << indent_str() << "self._reqs = {}" << endl - << indent() << indent_str() << "return" << endl - << indent() << "tr = TTransport.TMemoryBuffer(frame)" << endl - << indent() << "iprot = self._iprot_factory.getProtocol(tr)" << endl - << indent() << "(fname, mtype, rseqid) = iprot.readMessageBegin()" << endl - << indent() << "method = getattr(self, 'recv_' + fname)" << endl - << indent() << "future = self._reqs.pop(rseqid, None)" << endl - << indent() << "if not future:" << endl - << indent() << indent_str() << "# future has already been discarded" << endl - << indent() << indent_str() << "continue" << endl - << indent() << "try:" << endl - << indent() << indent_str() << "result = method(iprot, mtype, rseqid)" << endl - << indent() << "except Exception as e:" << endl - << indent() << indent_str() << "future.set_exception(e)" << endl - << indent() << "else:" << endl - << indent() << indent_str() << "future.set_result(result)" << endl; + f_service_ << indent() << "try:" << '\n' + << indent() << indent_str() << "frame = yield self._transport.readFrame()" << '\n' + << indent() << "except TTransport.TTransportException as e:" << '\n' + << indent() << indent_str() << "for future in self._reqs.values():" << '\n' + << indent() << indent_str() << indent_str() << "future.set_exception(e)" << '\n' + << indent() << indent_str() << "self._reqs = {}" << '\n' + << indent() << indent_str() << "return" << '\n' + << indent() << "tr = TTransport.TMemoryBuffer(frame)" << '\n' + << indent() << "iprot = self._iprot_factory.getProtocol(tr)" << '\n' + << indent() << "(fname, mtype, rseqid) = iprot.readMessageBegin()" << '\n' + << indent() << "method = getattr(self, 'recv_' + fname)" << '\n' + << indent() << "future = self._reqs.pop(rseqid, None)" << '\n' + << indent() << "if not future:" << '\n' + << indent() << indent_str() << "# future has already been discarded" << '\n' + << indent() << indent_str() << "continue" << '\n' + << indent() << "try:" << '\n' + << indent() << indent_str() << "result = method(iprot, mtype, rseqid)" << '\n' + << indent() << "except Exception as e:" << '\n' + << indent() << indent_str() << "future.set_exception(e)" << '\n' + << indent() << "else:" << '\n' + << indent() << indent_str() << "future.set_result(result)" << '\n'; indent_down(); indent_down(); } @@ -1473,20 +1471,20 @@ void t_py_generator::generate_service_client(t_service* tservice) { vector::const_iterator fld_iter; string funname = (*f_iter)->get_name(); - f_service_ << endl; + f_service_ << '\n'; // Open function - indent(f_service_) << "def " << function_signature(*f_iter, false) << ":" << endl; + indent(f_service_) << "def " << function_signature(*f_iter, false) << ":" << '\n'; indent_up(); generate_python_docstring(f_service_, (*f_iter)); if (gen_twisted_) { - indent(f_service_) << "seqid = self._seqid = self._seqid + 1" << endl; - indent(f_service_) << "self._reqs[seqid] = defer.Deferred()" << endl << endl; + indent(f_service_) << "seqid = self._seqid = self._seqid + 1" << '\n'; + indent(f_service_) << "self._reqs[seqid] = defer.Deferred()" << '\n' << '\n'; indent(f_service_) << "d = defer.maybeDeferred(self.send_" << funname; } else if (gen_tornado_) { - indent(f_service_) << "self._seqid += 1" << endl; + indent(f_service_) << "self._seqid += 1" << '\n'; if (!(*f_iter)->is_oneway()) { - indent(f_service_) << "future = self._reqs[self._seqid] = concurrent.Future()" << endl; + indent(f_service_) << "future = self._reqs[self._seqid] = concurrent.Future()" << '\n'; } indent(f_service_) << "self.send_" << funname << "("; @@ -1509,19 +1507,19 @@ void t_py_generator::generate_service_client(t_service* tservice) { f_service_ << (*fld_iter)->get_name(); } - f_service_ << ")" << endl; + f_service_ << ")" << '\n'; if (!(*f_iter)->is_oneway()) { if (gen_twisted_) { // nothing. See the next block. } else if (gen_tornado_) { - indent(f_service_) << "return future" << endl; + indent(f_service_) << "return future" << '\n'; } else { f_service_ << indent(); if (!(*f_iter)->get_returntype()->is_void()) { f_service_ << "return "; } - f_service_ << "self.recv_" << funname << "()" << endl; + f_service_ << "self.recv_" << funname << "()" << '\n'; } } indent_down(); @@ -1529,40 +1527,40 @@ void t_py_generator::generate_service_client(t_service* tservice) { if (gen_twisted_) { // This block injects the body of the send_<> method for twisted (and a cb/eb pair) indent_up(); - indent(f_service_) << "d.addCallbacks(" << endl; + indent(f_service_) << "d.addCallbacks(" << '\n'; indent_up(); - f_service_ << indent() << "callback=self.cb_send_" << funname << "," << endl << indent() - << "callbackArgs=(seqid,)," << endl << indent() << "errback=self.eb_send_" - << funname << "," << endl << indent() << "errbackArgs=(seqid,))" << endl; + f_service_ << indent() << "callback=self.cb_send_" << funname << "," << '\n' << indent() + << "callbackArgs=(seqid,)," << '\n' << indent() << "errback=self.eb_send_" + << funname << "," << '\n' << indent() << "errbackArgs=(seqid,))" << '\n'; indent_down(); - indent(f_service_) << "return d" << endl; + indent(f_service_) << "return d" << '\n'; indent_down(); - f_service_ << endl; + f_service_ << '\n'; - indent(f_service_) << "def cb_send_" << funname << "(self, _, seqid):" << endl; + indent(f_service_) << "def cb_send_" << funname << "(self, _, seqid):" << '\n'; indent_up(); if ((*f_iter)->is_oneway()) { // if one-way, fire the deferred & remove it from _reqs - f_service_ << indent() << "d = self._reqs.pop(seqid)" << endl << indent() - << "d.callback(None)" << endl << indent() << "return d" << endl; + f_service_ << indent() << "d = self._reqs.pop(seqid)" << '\n' << indent() + << "d.callback(None)" << '\n' << indent() << "return d" << '\n'; } else { - f_service_ << indent() << "return self._reqs[seqid]" << endl; + f_service_ << indent() << "return self._reqs[seqid]" << '\n'; } indent_down(); - f_service_ << endl; + f_service_ << '\n'; // add an errback to fail the request if the call to send_<> raised an exception - indent(f_service_) << "def eb_send_" << funname << "(self, f, seqid):" << endl; + indent(f_service_) << "def eb_send_" << funname << "(self, f, seqid):" << '\n'; indent_up(); - f_service_ << indent() << "d = self._reqs.pop(seqid)" << endl << indent() << "d.errback(f)" - << endl << indent() << "return d" << endl; + f_service_ << indent() << "d = self._reqs.pop(seqid)" << '\n' << indent() << "d.errback(f)" + << '\n' << indent() << "return d" << '\n'; indent_down(); } - f_service_ << endl; - indent(f_service_) << "def send_" << function_signature(*f_iter, false) << ":" << endl; + f_service_ << '\n'; + indent(f_service_) << "def send_" << function_signature(*f_iter, false) << ":" << '\n'; indent_up(); std::string argsname = (*f_iter)->get_name() + "_args"; @@ -1570,29 +1568,29 @@ void t_py_generator::generate_service_client(t_service* tservice) { // Serialize the request header if (gen_twisted_ || gen_tornado_) { - f_service_ << indent() << "oprot = self._oprot_factory.getProtocol(self._transport)" << endl + f_service_ << indent() << "oprot = self._oprot_factory.getProtocol(self._transport)" << '\n' << indent() << "oprot.writeMessageBegin('" << (*f_iter)->get_name() << "', " - << messageType << ", self._seqid)" << endl; + << messageType << ", self._seqid)" << '\n'; } else { f_service_ << indent() << "self._oprot.writeMessageBegin('" << (*f_iter)->get_name() << "', " - << messageType << ", self._seqid)" << endl; + << messageType << ", self._seqid)" << '\n'; } - f_service_ << indent() << "args = " << argsname << "()" << endl; + f_service_ << indent() << "args = " << argsname << "()" << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { f_service_ << indent() << "args." << (*fld_iter)->get_name() << " = " - << (*fld_iter)->get_name() << endl; + << (*fld_iter)->get_name() << '\n'; } // Write to the stream if (gen_twisted_ || gen_tornado_) { - f_service_ << indent() << "args.write(oprot)" << endl << indent() << "oprot.writeMessageEnd()" - << endl << indent() << "oprot.trans.flush()" << endl; + f_service_ << indent() << "args.write(oprot)" << '\n' << indent() << "oprot.writeMessageEnd()" + << '\n' << indent() << "oprot.trans.flush()" << '\n'; } else { - f_service_ << indent() << "args.write(self._oprot)" << endl << indent() - << "self._oprot.writeMessageEnd()" << endl << indent() - << "self._oprot.trans.flush()" << endl; + f_service_ << indent() << "args.write(self._oprot)" << '\n' << indent() + << "self._oprot.writeMessageEnd()" << '\n' << indent() + << "self._oprot.trans.flush()" << '\n'; } indent_down(); @@ -1600,51 +1598,51 @@ void t_py_generator::generate_service_client(t_service* tservice) { if (!(*f_iter)->is_oneway()) { std::string resultname = (*f_iter)->get_name() + "_result"; // Open function - f_service_ << endl; + f_service_ << '\n'; if (gen_twisted_ || gen_tornado_) { f_service_ << indent() << "def recv_" << (*f_iter)->get_name() - << "(self, iprot, mtype, rseqid):" << endl; + << "(self, iprot, mtype, rseqid):" << '\n'; } else { t_struct noargs(program_); t_function recv_function((*f_iter)->get_returntype(), string("recv_") + (*f_iter)->get_name(), &noargs); - f_service_ << indent() << "def " << function_signature(&recv_function) << ":" << endl; + f_service_ << indent() << "def " << function_signature(&recv_function) << ":" << '\n'; } indent_up(); // TODO(mcslee): Validate message reply here, seq ids etc. if (gen_twisted_) { - f_service_ << indent() << "d = self._reqs.pop(rseqid)" << endl; + f_service_ << indent() << "d = self._reqs.pop(rseqid)" << '\n'; } else if (gen_tornado_) { } else { - f_service_ << indent() << "iprot = self._iprot" << endl << indent() - << "(fname, mtype, rseqid) = iprot.readMessageBegin()" << endl; + f_service_ << indent() << "iprot = self._iprot" << '\n' << indent() + << "(fname, mtype, rseqid) = iprot.readMessageBegin()" << '\n'; } - f_service_ << indent() << "if mtype == TMessageType.EXCEPTION:" << endl - << indent() << indent_str() << "x = TApplicationException()" << endl; + f_service_ << indent() << "if mtype == TMessageType.EXCEPTION:" << '\n' + << indent() << indent_str() << "x = TApplicationException()" << '\n'; if (gen_twisted_) { - f_service_ << indent() << indent_str() << "x.read(iprot)" << endl << indent() - << indent_str() << "iprot.readMessageEnd()" << endl << indent() << indent_str() << "return d.errback(x)" - << endl << indent() << "result = " << resultname << "()" << endl << indent() - << "result.read(iprot)" << endl << indent() << "iprot.readMessageEnd()" << endl; + f_service_ << indent() << indent_str() << "x.read(iprot)" << '\n' << indent() + << indent_str() << "iprot.readMessageEnd()" << '\n' << indent() << indent_str() << "return d.errback(x)" + << '\n' << indent() << "result = " << resultname << "()" << '\n' << indent() + << "result.read(iprot)" << '\n' << indent() << "iprot.readMessageEnd()" << '\n'; } else { - f_service_ << indent() << indent_str() << "x.read(iprot)" << endl << indent() - << indent_str() << "iprot.readMessageEnd()" << endl << indent() << indent_str() << "raise x" << endl - << indent() << "result = " << resultname << "()" << endl << indent() - << "result.read(iprot)" << endl << indent() << "iprot.readMessageEnd()" << endl; + f_service_ << indent() << indent_str() << "x.read(iprot)" << '\n' << indent() + << indent_str() << "iprot.readMessageEnd()" << '\n' << indent() << indent_str() << "raise x" << '\n' + << indent() << "result = " << resultname << "()" << '\n' << indent() + << "result.read(iprot)" << '\n' << indent() << "iprot.readMessageEnd()" << '\n'; } // Careful, only return _result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { - f_service_ << indent() << "if result.success is not None:" << endl; + f_service_ << indent() << "if result.success is not None:" << '\n'; if (gen_twisted_) { - f_service_ << indent() << indent_str() << "return d.callback(result.success)" << endl; + f_service_ << indent() << indent_str() << "return d.callback(result.success)" << '\n'; } else { - f_service_ << indent() << indent_str() << "return result.success" << endl; + f_service_ << indent() << indent_str() << "return result.success" << '\n'; } } @@ -1653,32 +1651,32 @@ void t_py_generator::generate_service_client(t_service* tservice) { vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { const string& xname = (*x_iter)->get_name(); - f_service_ << indent() << "if result." << xname << " is not None:" << endl; + f_service_ << indent() << "if result." << xname << " is not None:" << '\n'; if (gen_twisted_) { f_service_ << indent() << indent_str() << "return d.errback(result." << xname << ")" - << endl; + << '\n'; } else { - f_service_ << indent() << indent_str() << "raise result." << xname << "" << endl; + f_service_ << indent() << indent_str() << "raise result." << xname << "" << '\n'; } } // Careful, only return _result if not a void function if ((*f_iter)->get_returntype()->is_void()) { if (gen_twisted_) { - f_service_ << indent() << "return d.callback(None)" << endl; + f_service_ << indent() << "return d.callback(None)" << '\n'; } else { - f_service_ << indent() << "return" << endl; + f_service_ << indent() << "return" << '\n'; } } else { if (gen_twisted_) { f_service_ << indent() << "return d.errback(TApplicationException(TApplicationException.MISSING_RESULT, \"" - << (*f_iter)->get_name() << " failed: unknown result\"))" << endl; + << (*f_iter)->get_name() << " failed: unknown result\"))" << '\n'; } else { f_service_ << indent() << "raise TApplicationException(TApplicationException.MISSING_RESULT, \"" - << (*f_iter)->get_name() << " failed: unknown result\")" << endl; + << (*f_iter)->get_name() << " failed: unknown result\")" << '\n'; } } @@ -1711,29 +1709,27 @@ void t_py_generator::generate_service_remote(t_service* tservice) { f_remote.open(f_remote_name.c_str()); f_remote << - "#!/usr/bin/env python" << endl << - py_autogen_comment() << endl << - "import sys" << endl << - "import pprint" << endl << - "if sys.version_info[0] > 2:" << endl << - indent_str() << "from urllib.parse import urlparse" << endl << - "else:" << endl << - indent_str() << "from urlparse import urlparse" << endl << - "from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient" << endl << - "from thrift.protocol.TBinaryProtocol import TBinaryProtocol" << endl << - endl; + "#!/usr/bin/env python" << '\n' << + py_autogen_comment() << '\n' << + "import sys" << '\n' << + "import pprint" << '\n' << + "if sys.version_info[0] > 2:" << '\n' << + indent_str() << "from urllib.parse import urlparse" << '\n' << + "else:" << '\n' << + indent_str() << "from urlparse import urlparse" << '\n' << + "from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient" << '\n' << + "from thrift.protocol.TBinaryProtocol import TBinaryProtocol" << '\n' << '\n'; f_remote << - "from " << module_ << " import " << service_name_ << endl << - "from " << module_ << ".ttypes import *" << endl << - endl; + "from " << module_ << " import " << service_name_ << '\n' << + "from " << module_ << ".ttypes import *" << '\n' << '\n'; f_remote << - "if len(sys.argv) <= 1 or sys.argv[1] == '--help':" << endl << - indent_str() << "print('')" << endl << - indent_str() << "print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]')" << endl << - indent_str() << "print('')" << endl << - indent_str() << "print('Functions:')" << endl; + "if len(sys.argv) <= 1 or sys.argv[1] == '--help':" << '\n' << + indent_str() << "print('')" << '\n' << + indent_str() << "print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]')" << '\n' << + indent_str() << "print('')" << '\n' << + indent_str() << "print('Functions:')" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { f_remote << indent_str() << "print(' " << (*f_iter)->get_returntype()->get_name() << " " << (*f_iter)->get_name() << "("; @@ -1749,88 +1745,88 @@ void t_py_generator::generate_service_remote(t_service* tservice) { } f_remote << args[i]->get_type()->get_name() << " " << args[i]->get_name(); } - f_remote << ")')" << endl; - } - f_remote << indent_str() << "print('')" << endl << indent_str() << "sys.exit(0)" << endl << endl; - - f_remote << "pp = pprint.PrettyPrinter(indent=2)" << endl - << "host = 'localhost'" << endl - << "port = 9090" << endl - << "uri = ''" << endl - << "framed = False" << endl - << "ssl = False" << endl - << "validate = True" << endl - << "ca_certs = None" << endl - << "keyfile = None" << endl - << "certfile = None" << endl - << "http = False" << endl - << "argi = 1" << endl - << endl - << "if sys.argv[argi] == '-h':" << endl - << indent_str() << "parts = sys.argv[argi + 1].split(':')" << endl - << indent_str() << "host = parts[0]" << endl - << indent_str() << "if len(parts) > 1:" << endl - << indent_str() << indent_str() << "port = int(parts[1])" << endl - << indent_str() << "argi += 2" << endl - << endl - << "if sys.argv[argi] == '-u':" << endl - << indent_str() << "url = urlparse(sys.argv[argi + 1])" << endl - << indent_str() << "parts = url[1].split(':')" << endl - << indent_str() << "host = parts[0]" << endl - << indent_str() << "if len(parts) > 1:" << endl - << indent_str() << indent_str() << "port = int(parts[1])" << endl - << indent_str() << "else:" << endl - << indent_str() << indent_str() << "port = 80" << endl - << indent_str() << "uri = url[2]" << endl - << indent_str() << "if url[4]:" << endl - << indent_str() << indent_str() << "uri += '?%s' % url[4]" << endl - << indent_str() << "http = True" << endl - << indent_str() << "argi += 2" << endl - << endl - << "if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':" << endl - << indent_str() << "framed = True" << endl - << indent_str() << "argi += 1" << endl - << endl - << "if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl':" << endl - << indent_str() << "ssl = True" << endl - << indent_str() << "argi += 1" << endl - << endl - << "if sys.argv[argi] == '-novalidate':" << endl - << indent_str() << "validate = False" << endl - << indent_str() << "argi += 1" << endl - << endl - << "if sys.argv[argi] == '-ca_certs':" << endl - << indent_str() << "ca_certs = sys.argv[argi+1]" << endl - << indent_str() << "argi += 2" << endl - << endl - << "if sys.argv[argi] == '-keyfile':" << endl - << indent_str() << "keyfile = sys.argv[argi+1]" << endl - << indent_str() << "argi += 2" << endl - << endl - << "if sys.argv[argi] == '-certfile':" << endl - << indent_str() << "certfile = sys.argv[argi+1]" << endl - << indent_str() << "argi += 2" << endl - << endl - << "cmd = sys.argv[argi]" << endl - << "args = sys.argv[argi + 1:]" << endl - << endl - << "if http:" << endl - << indent_str() << "transport = THttpClient.THttpClient(host, port, uri)" << endl - << "else:" << endl - << indent_str() << "if ssl:" << endl + f_remote << ")')" << '\n'; + } + f_remote << indent_str() << "print('')" << '\n' << indent_str() << "sys.exit(0)" << '\n' << '\n'; + + f_remote << "pp = pprint.PrettyPrinter(indent=2)" << '\n' + << "host = 'localhost'" << '\n' + << "port = 9090" << '\n' + << "uri = ''" << '\n' + << "framed = False" << '\n' + << "ssl = False" << '\n' + << "validate = True" << '\n' + << "ca_certs = None" << '\n' + << "keyfile = None" << '\n' + << "certfile = None" << '\n' + << "http = False" << '\n' + << "argi = 1" << '\n' + << '\n' + << "if sys.argv[argi] == '-h':" << '\n' + << indent_str() << "parts = sys.argv[argi + 1].split(':')" << '\n' + << indent_str() << "host = parts[0]" << '\n' + << indent_str() << "if len(parts) > 1:" << '\n' + << indent_str() << indent_str() << "port = int(parts[1])" << '\n' + << indent_str() << "argi += 2" << '\n' + << '\n' + << "if sys.argv[argi] == '-u':" << '\n' + << indent_str() << "url = urlparse(sys.argv[argi + 1])" << '\n' + << indent_str() << "parts = url[1].split(':')" << '\n' + << indent_str() << "host = parts[0]" << '\n' + << indent_str() << "if len(parts) > 1:" << '\n' + << indent_str() << indent_str() << "port = int(parts[1])" << '\n' + << indent_str() << "else:" << '\n' + << indent_str() << indent_str() << "port = 80" << '\n' + << indent_str() << "uri = url[2]" << '\n' + << indent_str() << "if url[4]:" << '\n' + << indent_str() << indent_str() << "uri += '?%s' % url[4]" << '\n' + << indent_str() << "http = True" << '\n' + << indent_str() << "argi += 2" << '\n' + << '\n' + << "if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':" << '\n' + << indent_str() << "framed = True" << '\n' + << indent_str() << "argi += 1" << '\n' + << '\n' + << "if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl':" << '\n' + << indent_str() << "ssl = True" << '\n' + << indent_str() << "argi += 1" << '\n' + << '\n' + << "if sys.argv[argi] == '-novalidate':" << '\n' + << indent_str() << "validate = False" << '\n' + << indent_str() << "argi += 1" << '\n' + << '\n' + << "if sys.argv[argi] == '-ca_certs':" << '\n' + << indent_str() << "ca_certs = sys.argv[argi+1]" << '\n' + << indent_str() << "argi += 2" << '\n' + << '\n' + << "if sys.argv[argi] == '-keyfile':" << '\n' + << indent_str() << "keyfile = sys.argv[argi+1]" << '\n' + << indent_str() << "argi += 2" << '\n' + << '\n' + << "if sys.argv[argi] == '-certfile':" << '\n' + << indent_str() << "certfile = sys.argv[argi+1]" << '\n' + << indent_str() << "argi += 2" << '\n' + << '\n' + << "cmd = sys.argv[argi]" << '\n' + << "args = sys.argv[argi + 1:]" << '\n' + << '\n' + << "if http:" << '\n' + << indent_str() << "transport = THttpClient.THttpClient(host, port, uri)" << '\n' + << "else:" << '\n' + << indent_str() << "if ssl:" << '\n' << indent_str() << indent_str() << "socket = TSSLSocket.TSSLSocket(host, port, " "validate=validate, ca_certs=ca_certs, keyfile=keyfile, certfile=certfile)" - << endl - << indent_str() << "else:" << endl - << indent_str() << indent_str() << "socket = TSocket.TSocket(host, port)" << endl - << indent_str() << "if framed:" << endl - << indent_str() << indent_str() << "transport = TTransport.TFramedTransport(socket)" << endl - << indent_str() << "else:" << endl - << indent_str() << indent_str() << "transport = TTransport.TBufferedTransport(socket)" << endl - << "protocol = TBinaryProtocol(transport)" << endl - << "client = " << service_name_ << ".Client(protocol)" << endl - << "transport.open()" << endl - << endl; + << '\n' + << indent_str() << "else:" << '\n' + << indent_str() << indent_str() << "socket = TSocket.TSocket(host, port)" << '\n' + << indent_str() << "if framed:" << '\n' + << indent_str() << indent_str() << "transport = TTransport.TFramedTransport(socket)" << '\n' + << indent_str() << "else:" << '\n' + << indent_str() << indent_str() << "transport = TTransport.TBufferedTransport(socket)" << '\n' + << "protocol = TBinaryProtocol(transport)" << '\n' + << "client = " << service_name_ << ".Client(protocol)" << '\n' + << "transport.open()" << '\n' + << '\n'; // Generate the dispatch methods bool first = true; @@ -1846,12 +1842,12 @@ void t_py_generator::generate_service_remote(t_service* tservice) { const std::vector& args = arg_struct->get_members(); std::vector::size_type num_args = args.size(); - f_remote << "if cmd == '" << (*f_iter)->get_name() << "':" << endl; + f_remote << "if cmd == '" << (*f_iter)->get_name() << "':" << '\n'; indent_up(); - f_remote << indent() << "if len(args) != " << num_args << ":" << endl + f_remote << indent() << "if len(args) != " << num_args << ":" << '\n' << indent() << indent_str() << "print('" << (*f_iter)->get_name() << " requires " << num_args - << " args')" << endl - << indent() << indent_str() << "sys.exit(1)" << endl + << " args')" << '\n' + << indent() << indent_str() << "sys.exit(1)" << '\n' << indent() << "pp.pprint(client." << (*f_iter)->get_name() << "("; indent_down(); bool first_arg = true; @@ -1866,19 +1862,19 @@ void t_py_generator::generate_service_remote(t_service* tservice) { f_remote << "eval(args[" << i << "]),"; } } - f_remote << "))" << endl; + f_remote << "))" << '\n'; - f_remote << endl; + f_remote << '\n'; } if (functions.size() > 0) { - f_remote << "else:" << endl; - f_remote << indent_str() << "print('Unrecognized method %s' % cmd)" << endl; - f_remote << indent_str() << "sys.exit(1)" << endl; - f_remote << endl; + f_remote << "else:" << '\n'; + f_remote << indent_str() << "print('Unrecognized method %s' % cmd)" << '\n'; + f_remote << indent_str() << "sys.exit(1)" << '\n'; + f_remote << '\n'; } - f_remote << "transport.close()" << endl; + f_remote << "transport.close()" << '\n'; // Close service file f_remote.close(); @@ -1913,100 +1909,100 @@ void t_py_generator::generate_service_server(t_service* tservice) { extends_processor = extends + ".Processor, "; } - f_service_ << endl << endl; + f_service_ << '\n' << '\n'; // Generate the header portion if (gen_zope_interface_) { - f_service_ << "@implementer(Iface)" << endl - << "class Processor(" << extends_processor << "TProcessor):" << endl; + f_service_ << "@implementer(Iface)" << '\n' + << "class Processor(" << extends_processor << "TProcessor):" << '\n'; } else { - f_service_ << "class Processor(" << extends_processor << "Iface, TProcessor):" << endl; + f_service_ << "class Processor(" << extends_processor << "Iface, TProcessor):" << '\n'; } indent_up(); - indent(f_service_) << "def __init__(self, handler):" << endl; + indent(f_service_) << "def __init__(self, handler):" << '\n'; indent_up(); if (extends.empty()) { if (gen_zope_interface_) { - f_service_ << indent() << "self._handler = Iface(handler)" << endl; + f_service_ << indent() << "self._handler = Iface(handler)" << '\n'; } else { - f_service_ << indent() << "self._handler = handler" << endl; + f_service_ << indent() << "self._handler = handler" << '\n'; } - f_service_ << indent() << "self._processMap = {}" << endl; + f_service_ << indent() << "self._processMap = {}" << '\n'; } else { if (gen_zope_interface_) { - f_service_ << indent() << extends << ".Processor.__init__(self, Iface(handler))" << endl; + f_service_ << indent() << extends << ".Processor.__init__(self, Iface(handler))" << '\n'; } else { - f_service_ << indent() << extends << ".Processor.__init__(self, handler)" << endl; + f_service_ << indent() << extends << ".Processor.__init__(self, handler)" << '\n'; } } for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { f_service_ << indent() << "self._processMap[\"" << (*f_iter)->get_name() - << "\"] = Processor.process_" << (*f_iter)->get_name() << endl; + << "\"] = Processor.process_" << (*f_iter)->get_name() << '\n'; } - f_service_ << indent() << "self._on_message_begin = None" << endl; + f_service_ << indent() << "self._on_message_begin = None" << '\n'; indent_down(); - f_service_ << endl; + f_service_ << '\n'; - f_service_ << indent() << "def on_message_begin(self, func):" << endl; + f_service_ << indent() << "def on_message_begin(self, func):" << '\n'; indent_up(); - f_service_ << indent() << "self._on_message_begin = func" << endl; + f_service_ << indent() << "self._on_message_begin = func" << '\n'; indent_down(); - f_service_ << endl; + f_service_ << '\n'; // Generate the server implementation - f_service_ << indent() << "def process(self, iprot, oprot):" << endl; + f_service_ << indent() << "def process(self, iprot, oprot):" << '\n'; indent_up(); - f_service_ << indent() << "(name, type, seqid) = iprot.readMessageBegin()" << endl; - f_service_ << indent() << "if self._on_message_begin:" << endl; + f_service_ << indent() << "(name, type, seqid) = iprot.readMessageBegin()" << '\n'; + f_service_ << indent() << "if self._on_message_begin:" << '\n'; indent_up(); - f_service_ << indent() << "self._on_message_begin(name, type, seqid)" << endl; + f_service_ << indent() << "self._on_message_begin(name, type, seqid)" << '\n'; indent_down(); // TODO(mcslee): validate message // HOT: dictionary function lookup - f_service_ << indent() << "if name not in self._processMap:" << endl; + f_service_ << indent() << "if name not in self._processMap:" << '\n'; indent_up(); - f_service_ << indent() << "iprot.skip(TType.STRUCT)" << endl - << indent() << "iprot.readMessageEnd()" << endl + f_service_ << indent() << "iprot.skip(TType.STRUCT)" << '\n' + << indent() << "iprot.readMessageEnd()" << '\n' << indent() << "x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown " "function %s' % (name))" - << endl - << indent() << "oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)" << endl - << indent() << "x.write(oprot)" << endl - << indent() << "oprot.writeMessageEnd()" << endl - << indent() << "oprot.trans.flush()" << endl; + << '\n' + << indent() << "oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)" << '\n' + << indent() << "x.write(oprot)" << '\n' + << indent() << "oprot.writeMessageEnd()" << '\n' + << indent() << "oprot.trans.flush()" << '\n'; if (gen_twisted_) { - f_service_ << indent() << "return defer.succeed(None)" << endl; + f_service_ << indent() << "return defer.succeed(None)" << '\n'; } else { - f_service_ << indent() << "return" << endl; + f_service_ << indent() << "return" << '\n'; } indent_down(); - f_service_ << indent() << "else:" << endl; + f_service_ << indent() << "else:" << '\n'; if (gen_twisted_ || gen_tornado_) { f_service_ << indent() << indent_str() - << "return self._processMap[name](self, seqid, iprot, oprot)" << endl; + << "return self._processMap[name](self, seqid, iprot, oprot)" << '\n'; } else { f_service_ << indent() << indent_str() << "self._processMap[name](self, seqid, iprot, oprot)" - << endl; + << '\n'; // Read end of args field, the T_STOP, and the struct close - f_service_ << indent() << "return True" << endl; + f_service_ << indent() << "return True" << '\n'; } indent_down(); // Generate the process subfunctions for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - f_service_ << endl; + f_service_ << '\n'; generate_process_function(tservice, *f_iter); } @@ -2022,11 +2018,11 @@ void t_py_generator::generate_process_function(t_service* tservice, t_function* (void)tservice; // Open function if (gen_tornado_) { - f_service_ << indent() << "@gen.coroutine" << endl << indent() << "def process_" - << tfunction->get_name() << "(self, seqid, iprot, oprot):" << endl; + f_service_ << indent() << "@gen.coroutine" << '\n' << indent() << "def process_" + << tfunction->get_name() << "(self, seqid, iprot, oprot):" << '\n'; } else { f_service_ << indent() << "def process_" << tfunction->get_name() - << "(self, seqid, iprot, oprot):" << endl; + << "(self, seqid, iprot, oprot):" << '\n'; } indent_up(); @@ -2034,8 +2030,8 @@ void t_py_generator::generate_process_function(t_service* tservice, t_function* string argsname = tfunction->get_name() + "_args"; string resultname = tfunction->get_name() + "_result"; - f_service_ << indent() << "args = " << argsname << "()" << endl << indent() << "args.read(iprot)" - << endl << indent() << "iprot.readMessageEnd()" << endl; + f_service_ << indent() << "args = " << argsname << "()" << '\n' << indent() << "args.read(iprot)" + << '\n' << indent() << "iprot.readMessageEnd()" << '\n'; t_struct* xs = tfunction->get_xceptions(); const std::vector& xceptions = xs->get_members(); @@ -2043,7 +2039,7 @@ void t_py_generator::generate_process_function(t_service* tservice, t_function* // Declare result for non oneway function if (!tfunction->is_oneway()) { - f_service_ << indent() << "result = " << resultname << "()" << endl; + f_service_ << indent() << "result = " << resultname << "()" << '\n'; } if (gen_twisted_) { @@ -2063,85 +2059,85 @@ void t_py_generator::generate_process_function(t_service* tservice, t_function* } f_service_ << "args." << (*f_iter)->get_name(); } - f_service_ << ")" << endl; + f_service_ << ")" << '\n'; if (tfunction->is_oneway()) { f_service_ << indent() << "d.addErrback(self.handle_exception_" << tfunction->get_name() - << ", seqid)" << endl; + << ", seqid)" << '\n'; } else { f_service_ << indent() << "d.addCallback(self.write_results_success_" << tfunction->get_name() - << ", result, seqid, oprot)" << endl + << ", result, seqid, oprot)" << '\n' << indent() << "d.addErrback(self.write_results_exception_" - << tfunction->get_name() << ", result, seqid, oprot)" << endl; + << tfunction->get_name() << ", result, seqid, oprot)" << '\n'; } - f_service_ << indent() << "return d" << endl << endl; + f_service_ << indent() << "return d" << '\n' << '\n'; indent_down(); if (tfunction->is_oneway()) { indent(f_service_) << "def handle_exception_" << tfunction->get_name() - << "(self, error, seqid):" << endl; + << "(self, error, seqid):" << '\n'; } else { indent(f_service_) << "def write_results_success_" << tfunction->get_name() - << "(self, success, result, seqid, oprot):" << endl; + << "(self, success, result, seqid, oprot):" << '\n'; indent_up(); if (!tfunction->get_returntype()->is_void()) { - f_service_ << indent() << "result.success = success" << endl; + f_service_ << indent() << "result.success = success" << '\n'; } f_service_ << indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name() - << "\", TMessageType.REPLY, seqid)" << endl - << indent() << "result.write(oprot)" << endl - << indent() << "oprot.writeMessageEnd()" << endl - << indent() << "oprot.trans.flush()" << endl - << endl; + << "\", TMessageType.REPLY, seqid)" << '\n' + << indent() << "result.write(oprot)" << '\n' + << indent() << "oprot.writeMessageEnd()" << '\n' + << indent() << "oprot.trans.flush()" << '\n' + << '\n'; indent_down(); indent(f_service_) << "def write_results_exception_" << tfunction->get_name() - << "(self, error, result, seqid, oprot):" << endl; + << "(self, error, result, seqid, oprot):" << '\n'; } indent_up(); if (!tfunction->is_oneway()) { - f_service_ << indent() << "msg_type = TMessageType.REPLY" << endl; + f_service_ << indent() << "msg_type = TMessageType.REPLY" << '\n'; } - f_service_ << indent() << "try:" << endl; + f_service_ << indent() << "try:" << '\n'; // Kinda absurd - f_service_ << indent() << indent_str() << "error.raiseException()" << endl; + f_service_ << indent() << indent_str() << "error.raiseException()" << '\n'; if (!tfunction->is_oneway()) { for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { const string& xname = (*x_iter)->get_name(); f_service_ << indent() << "except " << type_name((*x_iter)->get_type()) << " as " << xname - << ":" << endl; + << ":" << '\n'; indent_up(); - f_service_ << indent() << "result." << xname << " = " << xname << endl; + f_service_ << indent() << "result." << xname << " = " << xname << '\n'; indent_down(); } } - f_service_ << indent() << "except TTransport.TTransportException:" << endl - << indent() << indent_str() << "raise" << endl; + f_service_ << indent() << "except TTransport.TTransportException:" << '\n' + << indent() << indent_str() << "raise" << '\n'; if (!tfunction->is_oneway()) { - f_service_ << indent() << "except TApplicationException as ex:" << endl + f_service_ << indent() << "except TApplicationException as ex:" << '\n' << indent() << indent_str() - << "logging.exception('TApplication exception in handler')" << endl - << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl - << indent() << indent_str() << "result = ex" << endl - << indent() << "except Exception:" << endl + << "logging.exception('TApplication exception in handler')" << '\n' + << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n' + << indent() << indent_str() << "result = ex" << '\n' + << indent() << "except Exception:" << '\n' << indent() << indent_str() - << "logging.exception('Unexpected exception in handler')" << endl - << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl + << "logging.exception('Unexpected exception in handler')" << '\n' + << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n' << indent() << indent_str() << "result = TApplicationException(TApplicationException.INTERNAL_ERROR, " "'Internal error')" - << endl + << '\n' << indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name() - << "\", msg_type, seqid)" << endl - << indent() << "result.write(oprot)" << endl - << indent() << "oprot.writeMessageEnd()" << endl - << indent() << "oprot.trans.flush()" << endl; + << "\", msg_type, seqid)" << '\n' + << indent() << "result.write(oprot)" << '\n' + << indent() << "oprot.writeMessageEnd()" << '\n' + << indent() << "oprot.trans.flush()" << '\n'; } else { - f_service_ << indent() << "except Exception:" << endl + f_service_ << indent() << "except Exception:" << '\n' << indent() << indent_str() - << "logging.exception('Exception in oneway handler')" << endl; + << "logging.exception('Exception in oneway handler')" << '\n'; } indent_down(); @@ -2152,9 +2148,9 @@ void t_py_generator::generate_process_function(t_service* tservice, t_function* vector::const_iterator f_iter; if (!tfunction->is_oneway()) { - indent(f_service_) << "msg_type = TMessageType.REPLY" << endl; + indent(f_service_) << "msg_type = TMessageType.REPLY" << '\n'; } - f_service_ << indent() << "try:" << endl; + f_service_ << indent() << "try:" << '\n'; indent_up(); f_service_ << indent(); if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) { @@ -2170,45 +2166,45 @@ void t_py_generator::generate_process_function(t_service* tservice, t_function* } f_service_ << "args." << (*f_iter)->get_name(); } - f_service_ << "))" << endl; + f_service_ << "))" << '\n'; indent_down(); if (!tfunction->is_oneway()) { for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { const string& xname = (*x_iter)->get_name(); f_service_ << indent() << "except " << type_name((*x_iter)->get_type()) << " as " << xname - << ":" << endl - << indent() << indent_str() << "result." << xname << " = " << xname << endl; + << ":" << '\n' + << indent() << indent_str() << "result." << xname << " = " << xname << '\n'; } } - f_service_ << indent() << "except TTransport.TTransportException:" << endl - << indent() << indent_str() << "raise" << endl; + f_service_ << indent() << "except TTransport.TTransportException:" << '\n' + << indent() << indent_str() << "raise" << '\n'; if (!tfunction->is_oneway()) { - f_service_ << indent() << "except TApplicationException as ex:" << endl + f_service_ << indent() << "except TApplicationException as ex:" << '\n' << indent() << indent_str() - << "logging.exception('TApplication exception in handler')" << endl - << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl - << indent() << indent_str() << "result = ex" << endl - << indent() << "except Exception:" << endl + << "logging.exception('TApplication exception in handler')" << '\n' + << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n' + << indent() << indent_str() << "result = ex" << '\n' + << indent() << "except Exception:" << '\n' << indent() << indent_str() - << "logging.exception('Unexpected exception in handler')" << endl - << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl + << "logging.exception('Unexpected exception in handler')" << '\n' + << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n' << indent() << indent_str() << "result = TApplicationException(TApplicationException.INTERNAL_ERROR, " "'Internal error')" - << endl; + << '\n'; } else { - f_service_ << indent() << "except Exception:" << endl + f_service_ << indent() << "except Exception:" << '\n' << indent() << indent_str() - << "logging.exception('Exception in oneway handler')" << endl; + << "logging.exception('Exception in oneway handler')" << '\n'; } if (!tfunction->is_oneway()) { f_service_ << indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name() - << "\", msg_type, seqid)" << endl - << indent() << "result.write(oprot)" << endl - << indent() << "oprot.writeMessageEnd()" << endl - << indent() << "oprot.trans.flush()" << endl; + << "\", msg_type, seqid)" << '\n' + << indent() << "result.write(oprot)" << '\n' + << indent() << "oprot.writeMessageEnd()" << '\n' + << indent() << "oprot.trans.flush()" << '\n'; } // Close function @@ -2217,7 +2213,7 @@ void t_py_generator::generate_process_function(t_service* tservice, t_function* } else { // py // Try block for a function with exceptions // It also catches arbitrary exceptions raised by handler method to propagate them to the client - f_service_ << indent() << "try:" << endl; + f_service_ << indent() << "try:" << '\n'; indent_up(); // Generate the function call @@ -2239,48 +2235,48 @@ void t_py_generator::generate_process_function(t_service* tservice, t_function* } f_service_ << "args." << (*f_iter)->get_name(); } - f_service_ << ")" << endl; + f_service_ << ")" << '\n'; if (!tfunction->is_oneway()) { - f_service_ << indent() << "msg_type = TMessageType.REPLY" << endl; + f_service_ << indent() << "msg_type = TMessageType.REPLY" << '\n'; } indent_down(); f_service_ << indent() - << "except TTransport.TTransportException:" << endl - << indent() << indent_str() << "raise" << endl; + << "except TTransport.TTransportException:" << '\n' + << indent() << indent_str() << "raise" << '\n'; if (!tfunction->is_oneway()) { for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { const string& xname = (*x_iter)->get_name(); f_service_ << indent() << "except " << type_name((*x_iter)->get_type()) << " as " << xname - << ":" << endl; + << ":" << '\n'; indent_up(); - f_service_ << indent() << "msg_type = TMessageType.REPLY" << endl; - f_service_ << indent() << "result." << xname << " = " << xname << endl; + f_service_ << indent() << "msg_type = TMessageType.REPLY" << '\n'; + f_service_ << indent() << "result." << xname << " = " << xname << '\n'; indent_down(); } - f_service_ << indent() << "except TApplicationException as ex:" << endl + f_service_ << indent() << "except TApplicationException as ex:" << '\n' << indent() << indent_str() - << "logging.exception('TApplication exception in handler')" << endl - << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl - << indent() << indent_str() << "result = ex" << endl - << indent() << "except Exception:" << endl + << "logging.exception('TApplication exception in handler')" << '\n' + << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n' + << indent() << indent_str() << "result = ex" << '\n' + << indent() << "except Exception:" << '\n' << indent() << indent_str() - << "logging.exception('Unexpected exception in handler')" << endl - << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl + << "logging.exception('Unexpected exception in handler')" << '\n' + << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n' << indent() << indent_str() << "result = TApplicationException(TApplicationException.INTERNAL_ERROR, " "'Internal error')" - << endl + << '\n' << indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name() - << "\", msg_type, seqid)" << endl - << indent() << "result.write(oprot)" << endl - << indent() << "oprot.writeMessageEnd()" << endl - << indent() << "oprot.trans.flush()" << endl; + << "\", msg_type, seqid)" << '\n' + << indent() << "result.write(oprot)" << '\n' + << indent() << "oprot.writeMessageEnd()" << '\n' + << indent() << "oprot.trans.flush()" << '\n'; } else { - f_service_ << indent() << "except Exception:" << endl - << indent() << indent_str() << "logging.exception('Exception in oneway handler')" << endl; + f_service_ << indent() << "except Exception:" << '\n' + << indent() << indent_str() << "logging.exception('Exception in oneway handler')" << '\n'; } // Close function @@ -2345,14 +2341,14 @@ void t_py_generator::generate_deserialize_field(ostream& out, throw "compiler error: no Python name for base type " + t_base_type::t_base_name(tbase); } } - out << endl; + out << '\n'; } else if (type->is_enum()) { if (gen_enum_) { indent(out) << name << " = " << type_name(type) << "(iprot.readI32())"; } else { indent(out) << name << " = iprot.readI32()"; } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", tfield->get_name().c_str(), @@ -2365,10 +2361,10 @@ void t_py_generator::generate_deserialize_field(ostream& out, */ void t_py_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) { if (is_immutable(tstruct)) { - out << indent() << prefix << " = " << type_name(tstruct) << ".read(iprot)" << endl; + out << indent() << prefix << " = " << type_name(tstruct) << ".read(iprot)" << '\n'; } else { - out << indent() << prefix << " = " << type_name(tstruct) << "()" << endl - << indent() << prefix << ".read(iprot)" << endl; + out << indent() << prefix << " = " << type_name(tstruct) << "()" << '\n' + << indent() << prefix << ".read(iprot)" << '\n'; } } @@ -2389,20 +2385,20 @@ void t_py_generator::generate_deserialize_container(ostream& out, t_type* ttype, // Declare variables, read header if (ttype->is_map()) { - out << indent() << prefix << " = {}" << endl << indent() << "(" << ktype << ", " << vtype - << ", " << size << ") = iprot.readMapBegin()" << endl; + out << indent() << prefix << " = {}" << '\n' << indent() << "(" << ktype << ", " << vtype + << ", " << size << ") = iprot.readMapBegin()" << '\n'; } else if (ttype->is_set()) { - out << indent() << prefix << " = set()" << endl << indent() << "(" << etype << ", " << size - << ") = iprot.readSetBegin()" << endl; + out << indent() << prefix << " = set()" << '\n' << indent() << "(" << etype << ", " << size + << ") = iprot.readSetBegin()" << '\n'; } else if (ttype->is_list()) { - out << indent() << prefix << " = []" << endl << indent() << "(" << etype << ", " << size - << ") = iprot.readListBegin()" << endl; + out << indent() << prefix << " = []" << '\n' << indent() << "(" << etype << ", " << size + << ") = iprot.readListBegin()" << '\n'; } // For loop iterates over elements string i = tmp("_i"); indent(out) << - "for " << i << " in range(" << size << "):" << endl; + "for " << i << " in range(" << size << "):" << '\n'; indent_up(); @@ -2418,20 +2414,20 @@ void t_py_generator::generate_deserialize_container(ostream& out, t_type* ttype, // Read container end if (ttype->is_map()) { - indent(out) << "iprot.readMapEnd()" << endl; + indent(out) << "iprot.readMapEnd()" << '\n'; if (is_immutable(ttype)) { - indent(out) << prefix << " = TFrozenDict(" << prefix << ")" << endl; + indent(out) << prefix << " = TFrozenDict(" << prefix << ")" << '\n'; } } else if (ttype->is_set()) { - indent(out) << "iprot.readSetEnd()" << endl; + indent(out) << "iprot.readSetEnd()" << '\n'; if (is_immutable(ttype)) { - indent(out) << prefix << " = frozenset(" << prefix << ")" << endl; + indent(out) << prefix << " = frozenset(" << prefix << ")" << '\n'; } } else if (ttype->is_list()) { if (is_immutable(ttype)) { - indent(out) << prefix << " = tuple(" << prefix << ")" << endl; + indent(out) << prefix << " = tuple(" << prefix << ")" << '\n'; } - indent(out) << "iprot.readListEnd()" << endl; + indent(out) << "iprot.readListEnd()" << '\n'; } } @@ -2447,7 +2443,7 @@ void t_py_generator::generate_deserialize_map_element(ostream& out, t_map* tmap, generate_deserialize_field(out, &fkey); generate_deserialize_field(out, &fval); - indent(out) << prefix << "[" << key << "] = " << val << endl; + indent(out) << prefix << "[" << key << "] = " << val << '\n'; } /** @@ -2459,7 +2455,7 @@ void t_py_generator::generate_deserialize_set_element(ostream& out, t_set* tset, generate_deserialize_field(out, &felem); - indent(out) << prefix << ".add(" << elem << ")" << endl; + indent(out) << prefix << ".add(" << elem << ")" << '\n'; } /** @@ -2473,7 +2469,7 @@ void t_py_generator::generate_deserialize_list_element(ostream& out, generate_deserialize_field(out, &felem); - indent(out) << prefix << ".append(" << elem << ")" << endl; + indent(out) << prefix << ".append(" << elem << ")" << '\n'; } /** @@ -2543,7 +2539,7 @@ void t_py_generator::generate_serialize_field(ostream& out, t_field* tfield, str out << "writeI32(" << name << ")"; } } - out << endl; + out << '\n'; } else { printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n", prefix.c_str(), @@ -2560,50 +2556,50 @@ void t_py_generator::generate_serialize_field(ostream& out, t_field* tfield, str */ void t_py_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; - indent(out) << prefix << ".write(oprot)" << endl; + indent(out) << prefix << ".write(oprot)" << '\n'; } void t_py_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) { if (ttype->is_map()) { indent(out) << "oprot.writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " - << "len(" << prefix << "))" << endl; + << "len(" << prefix << "))" << '\n'; } else if (ttype->is_set()) { indent(out) << "oprot.writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " - << "len(" << prefix << "))" << endl; + << "len(" << prefix << "))" << '\n'; } else if (ttype->is_list()) { indent(out) << "oprot.writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " - << "len(" << prefix << "))" << endl; + << "len(" << prefix << "))" << '\n'; } if (ttype->is_map()) { string kiter = tmp("kiter"); string viter = tmp("viter"); - indent(out) << "for " << kiter << ", " << viter << " in " << prefix << ".items():" << endl; + indent(out) << "for " << kiter << ", " << viter << " in " << prefix << ".items():" << '\n'; indent_up(); generate_serialize_map_element(out, (t_map*)ttype, kiter, viter); indent_down(); } else if (ttype->is_set()) { string iter = tmp("iter"); - indent(out) << "for " << iter << " in " << prefix << ":" << endl; + indent(out) << "for " << iter << " in " << prefix << ":" << '\n'; indent_up(); generate_serialize_set_element(out, (t_set*)ttype, iter); indent_down(); } else if (ttype->is_list()) { string iter = tmp("iter"); - indent(out) << "for " << iter << " in " << prefix << ":" << endl; + indent(out) << "for " << iter << " in " << prefix << ":" << '\n'; indent_up(); generate_serialize_list_element(out, (t_list*)ttype, iter); indent_down(); } if (ttype->is_map()) { - indent(out) << "oprot.writeMapEnd()" << endl; + indent(out) << "oprot.writeMapEnd()" << '\n'; } else if (ttype->is_set()) { - indent(out) << "oprot.writeSetEnd()" << endl; + indent(out) << "oprot.writeSetEnd()" << '\n'; } else if (ttype->is_list()) { - indent(out) << "oprot.writeListEnd()" << endl; + indent(out) << "oprot.writeListEnd()" << '\n'; } } @@ -2669,7 +2665,7 @@ void t_py_generator::generate_python_docstring(ostream& out, const vector& fields = tstruct->get_members(); if (fields.size() > 0) { if (has_doc) { - ss << endl; + ss << '\n'; } has_doc = true; ss << subheader << ":\n"; @@ -2680,7 +2676,7 @@ void t_py_generator::generate_python_docstring(ostream& out, if (p->has_doc()) { ss << ": " << p->get_doc(); } else { - ss << endl; + ss << '\n'; } } } diff --git a/compiler/cpp/src/thrift/generate/t_rb_generator.cc b/compiler/cpp/src/thrift/generate/t_rb_generator.cc index 17e57cf95df..e9465736692 100644 --- a/compiler/cpp/src/thrift/generate/t_rb_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_rb_generator.cc @@ -43,8 +43,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * A subclass of std::ofstream that includes indenting functionality. */ @@ -283,11 +281,11 @@ void t_rb_generator::init_generator() { f_consts_.open(f_consts_name.c_str()); // Print header - f_types_ << rb_autogen_comment() << endl << render_require_thrift() << render_includes() << endl; + f_types_ << rb_autogen_comment() << '\n' << render_require_thrift() << render_includes() << '\n'; begin_namespace(f_types_, ruby_modules(program_)); - f_consts_ << rb_autogen_comment() << endl << render_require_thrift() << "require '" - << require_prefix_ << underscore(program_name_) << "_types'" << endl << endl; + f_consts_ << rb_autogen_comment() << '\n' << render_require_thrift() << "require '" + << require_prefix_ << underscore(program_name_) << "_types'" << '\n' << '\n'; begin_namespace(f_consts_, ruby_modules(program_)); } @@ -360,7 +358,7 @@ void t_rb_generator::generate_typedef(t_typedef* ttypedef) { * @param tenum The enumeration */ void t_rb_generator::generate_enum(t_enum* tenum) { - f_types_.indent() << "module " << capitalize(tenum->get_name()) << endl; + f_types_.indent() << "module " << capitalize(tenum->get_name()) << '\n'; f_types_.indent_up(); vector constants = tenum->get_constants(); @@ -374,7 +372,7 @@ void t_rb_generator::generate_enum(t_enum* tenum) { string name = capitalize((*c_iter)->get_name()); generate_rdoc(f_types_, *c_iter); - f_types_.indent() << name << " = " << value << endl; + f_types_.indent() << name << " = " << value << '\n'; } // Create a hash mapping values back to their names (as strings) since ruby has no native enum @@ -387,7 +385,7 @@ void t_rb_generator::generate_enum(t_enum* tenum) { f_types_ << ", "; f_types_ << value << " => \"" << capitalize((*c_iter)->get_name()) << "\""; } - f_types_ << "}" << endl; + f_types_ << "}" << '\n'; // Create a set with valid values for this enum f_types_.indent() << "VALID_VALUES = Set.new(["; @@ -397,10 +395,10 @@ void t_rb_generator::generate_enum(t_enum* tenum) { f_types_ << ", "; f_types_ << capitalize((*c_iter)->get_name()); } - f_types_ << "]).freeze" << endl; + f_types_ << "]).freeze" << '\n'; f_types_.indent_down(); - f_types_.indent() << "end" << endl << endl; + f_types_.indent() << "end" << '\n' << '\n'; } /** @@ -414,7 +412,7 @@ void t_rb_generator::generate_const(t_const* tconst) { name[0] = toupper(name[0]); f_consts_.indent() << name << " = "; - render_const_value(f_consts_, type, value) << endl << endl; + render_const_value(f_consts_, type, value) << '\n' << '\n'; } /** @@ -454,7 +452,7 @@ t_rb_ofstream& t_rb_generator::render_const_value(t_rb_ofstream& out, } else if (type->is_enum()) { out.indent() << value->get_integer(); } else if (type->is_struct() || type->is_xception()) { - out << full_type_name(type) << ".new({" << endl; + out << full_type_name(type) << ".new({" << '\n'; out.indent_up(); const vector& fields = ((t_struct*)type)->get_members(); vector::const_iterator f_iter; @@ -472,21 +470,21 @@ t_rb_ofstream& t_rb_generator::render_const_value(t_rb_ofstream& out, } out.indent(); render_const_value(out, g_type_string, v_iter->first) << " => "; - render_const_value(out, field_type, v_iter->second) << "," << endl; + render_const_value(out, field_type, v_iter->second) << "," << '\n'; } out.indent_down(); out.indent() << "})"; } else if (type->is_map()) { t_type* ktype = ((t_map*)type)->get_key_type(); t_type* vtype = ((t_map*)type)->get_val_type(); - out << "{" << endl; + out << "{" << '\n'; out.indent_up(); const map& val = value->get_map(); map::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { out.indent(); render_const_value(out, ktype, v_iter->first) << " => "; - render_const_value(out, vtype, v_iter->second) << "," << endl; + render_const_value(out, vtype, v_iter->second) << "," << '\n'; } out.indent_down(); out.indent() << "}"; @@ -498,16 +496,16 @@ t_rb_ofstream& t_rb_generator::render_const_value(t_rb_ofstream& out, etype = ((t_set*)type)->get_elem_type(); } if (type->is_set()) { - out << "Set.new([" << endl; + out << "Set.new([" << '\n'; } else { - out << "[" << endl; + out << "[" << '\n'; } out.indent_up(); const vector& val = value->get_list(); vector::const_iterator v_iter; for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { out.indent(); - render_const_value(out, etype, *v_iter) << "," << endl; + render_const_value(out, etype, *v_iter) << "," << '\n'; } out.indent_down(); if (type->is_set()) { @@ -552,7 +550,7 @@ void t_rb_generator::generate_rb_struct_declaration(t_rb_ofstream& out, t_struct if (is_exception) { out << " < ::Thrift::Exception"; } - out << "; end" << endl << endl; + out << "; end" << '\n' << '\n'; } /** @@ -576,10 +574,10 @@ void t_rb_generator::generate_rb_struct(t_rb_ofstream& out, if (is_exception) { out << " < ::Thrift::Exception"; } - out << endl; + out << '\n'; out.indent_up(); - out.indent() << "include ::Thrift::Struct, ::Thrift::Struct_Union" << endl; + out.indent() << "include ::Thrift::Struct, ::Thrift::Struct_Union" << '\n'; if (is_exception) { generate_rb_simple_exception_constructor(out, tstruct); @@ -589,10 +587,10 @@ void t_rb_generator::generate_rb_struct(t_rb_ofstream& out, generate_field_defns(out, tstruct); generate_rb_struct_required_validator(out, tstruct); - out.indent() << "::Thrift::Struct.generate_accessors self" << endl; + out.indent() << "::Thrift::Struct.generate_accessors self" << '\n'; out.indent_down(); - out.indent() << "end" << endl << endl; + out.indent() << "end" << '\n' << '\n'; } /** @@ -603,10 +601,10 @@ void t_rb_generator::generate_rb_union(t_rb_ofstream& out, bool is_exception = false) { (void)is_exception; generate_rdoc(out, tstruct); - out.indent() << "class " << type_name(tstruct) << " < ::Thrift::Union" << endl; + out.indent() << "class " << type_name(tstruct) << " < ::Thrift::Union" << '\n'; out.indent_up(); - out.indent() << "include ::Thrift::Struct_Union" << endl; + out.indent() << "include ::Thrift::Struct_Union" << '\n'; generate_field_constructors(out, tstruct); @@ -614,15 +612,15 @@ void t_rb_generator::generate_rb_union(t_rb_ofstream& out, generate_field_defns(out, tstruct); generate_rb_union_validator(out, tstruct); - out.indent() << "::Thrift::Union.generate_accessors self" << endl; + out.indent() << "::Thrift::Union.generate_accessors self" << '\n'; out.indent_down(); - out.indent() << "end" << endl << endl; + out.indent() << "end" << '\n' << '\n'; } void t_rb_generator::generate_field_constructors(t_rb_ofstream& out, t_struct* tstruct) { - out.indent() << "class << self" << endl; + out.indent() << "class << self" << '\n'; out.indent_up(); const vector& fields = tstruct->get_members(); @@ -630,19 +628,19 @@ void t_rb_generator::generate_field_constructors(t_rb_ofstream& out, t_struct* t for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if (f_iter != fields.begin()) { - out << endl; + out << '\n'; } std::string field_name = (*f_iter)->get_name(); - out.indent() << "def " << field_name << "(val)" << endl; - out.indent() << " " << tstruct->get_name() << ".new(:" << field_name << ", val)" << endl; - out.indent() << "end" << endl; + out.indent() << "def " << field_name << "(val)" << '\n'; + out.indent() << " " << tstruct->get_name() << ".new(:" << field_name << ", val)" << '\n'; + out.indent() << "end" << '\n'; } out.indent_down(); - out.indent() << "end" << endl; + out.indent() << "end" << '\n'; - out << endl; + out << '\n'; } void t_rb_generator::generate_rb_simple_exception_constructor(t_rb_ofstream& out, @@ -655,15 +653,15 @@ void t_rb_generator::generate_rb_simple_exception_constructor(t_rb_ofstream& out if ((*m_iter)->get_type()->is_string()) { string name = (*m_iter)->get_name(); - out.indent() << "def initialize(message=nil)" << endl; + out.indent() << "def initialize(message=nil)" << '\n'; out.indent_up(); - out.indent() << "super()" << endl; - out.indent() << "self." << name << " = message" << endl; + out.indent() << "super()" << '\n'; + out.indent() << "self." << name << " = message" << '\n'; out.indent_down(); - out.indent() << "end" << endl << endl; + out.indent() << "end" << '\n' << '\n'; if (name != "message") { - out.indent() << "def message; " << name << " end" << endl << endl; + out.indent() << "def message; " << name << " end" << '\n' << '\n'; } } } @@ -677,20 +675,20 @@ void t_rb_generator::generate_field_constants(t_rb_ofstream& out, t_struct* tstr std::string field_name = (*f_iter)->get_name(); std::string cap_field_name = upcase_string(field_name); - out.indent() << cap_field_name << " = " << (*f_iter)->get_key() << endl; + out.indent() << cap_field_name << " = " << (*f_iter)->get_key() << '\n'; } - out << endl; + out << '\n'; } void t_rb_generator::generate_field_defns(t_rb_ofstream& out, t_struct* tstruct) { const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - out.indent() << "FIELDS = {" << endl; + out.indent() << "FIELDS = {" << '\n'; out.indent_up(); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if (f_iter != fields.begin()) { - out << "," << endl; + out << "," << '\n'; } // generate the field docstrings within the FIELDS constant. no real better place... @@ -705,10 +703,10 @@ void t_rb_generator::generate_field_defns(t_rb_ofstream& out, t_struct* tstruct) (*f_iter)->get_req() == t_field::T_OPTIONAL); } out.indent_down(); - out << endl; - out.indent() << "}" << endl << endl; + out << '\n'; + out.indent() << "}" << '\n' << '\n'; - out.indent() << "def struct_fields; FIELDS; end" << endl << endl; + out.indent() << "def struct_fields; FIELDS; end" << '\n' << '\n'; } void t_rb_generator::generate_field_data(t_rb_ofstream& out, @@ -765,7 +763,7 @@ void t_rb_generator::generate_field_data(t_rb_ofstream& out, void t_rb_generator::begin_namespace(t_rb_ofstream& out, vector modules) { for (auto & module : modules) { - out.indent() << "module " << module << endl; + out.indent() << "module " << module << '\n'; out.indent_up(); } } @@ -774,7 +772,7 @@ void t_rb_generator::end_namespace(t_rb_ofstream& out, vector modul for (vector::reverse_iterator m_iter = modules.rbegin(); m_iter != modules.rend(); ++m_iter) { out.indent_down(); - out.indent() << "end" << endl; + out.indent() << "end" << '\n'; } } @@ -787,25 +785,25 @@ void t_rb_generator::generate_service(t_service* tservice) { string f_service_name = namespace_dir_ + underscore(service_name_) + ".rb"; f_service_.open(f_service_name.c_str()); - f_service_ << rb_autogen_comment() << endl << render_require_thrift(); + f_service_ << rb_autogen_comment() << '\n' << render_require_thrift(); if (tservice->get_extends() != nullptr) { if (namespaced_) { f_service_ << "require '" << rb_namespace_to_path_prefix( tservice->get_extends()->get_program()->get_namespace("rb")) - << underscore(tservice->get_extends()->get_name()) << "'" << endl; + << underscore(tservice->get_extends()->get_name()) << "'" << '\n'; } else { f_service_ << "require '" << require_prefix_ - << underscore(tservice->get_extends()->get_name()) << "'" << endl; + << underscore(tservice->get_extends()->get_name()) << "'" << '\n'; } } - f_service_ << "require '" << require_prefix_ << underscore(program_name_) << "_types'" << endl - << endl; + f_service_ << "require '" << require_prefix_ << underscore(program_name_) << "_types'" << '\n' + << '\n'; begin_namespace(f_service_, ruby_modules(tservice->get_program())); - f_service_.indent() << "module " << capitalize(tservice->get_name()) << endl; + f_service_.indent() << "module " << capitalize(tservice->get_name()) << '\n'; f_service_.indent_up(); // Generate the three main parts of the service (well, two for now in PHP) @@ -814,7 +812,7 @@ void t_rb_generator::generate_service(t_service* tservice) { generate_service_helpers(tservice); f_service_.indent_down(); - f_service_.indent() << "end" << endl << endl; + f_service_.indent() << "end" << '\n' << '\n'; end_namespace(f_service_, ruby_modules(tservice->get_program())); @@ -831,7 +829,7 @@ void t_rb_generator::generate_service_helpers(t_service* tservice) { vector functions = tservice->get_functions(); vector::iterator f_iter; - f_service_.indent() << "# HELPER FUNCTIONS AND STRUCTURES" << endl << endl; + f_service_.indent() << "# HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { t_struct* ts = (*f_iter)->get_arglist(); @@ -874,10 +872,10 @@ void t_rb_generator::generate_service_client(t_service* tservice) { extends_client = " < " + extends + "::Client "; } - f_service_.indent() << "class Client" << extends_client << endl; + f_service_.indent() << "class Client" << extends_client << '\n'; f_service_.indent_up(); - f_service_.indent() << "include ::Thrift::Client" << endl << endl; + f_service_.indent() << "include ::Thrift::Client" << '\n' << '\n'; // Generate client method implementations vector functions = tservice->get_functions(); @@ -889,7 +887,7 @@ void t_rb_generator::generate_service_client(t_service* tservice) { string funname = (*f_iter)->get_name(); // Open function - f_service_.indent() << "def " << function_signature(*f_iter) << endl; + f_service_.indent() << "def " << function_signature(*f_iter) << '\n'; f_service_.indent_up(); f_service_.indent() << "send_" << funname << "("; @@ -902,20 +900,20 @@ void t_rb_generator::generate_service_client(t_service* tservice) { } f_service_ << (*fld_iter)->get_name(); } - f_service_ << ")" << endl; + f_service_ << ")" << '\n'; if (!(*f_iter)->is_oneway()) { f_service_.indent(); if (!(*f_iter)->get_returntype()->is_void()) { f_service_ << "return "; } - f_service_ << "recv_" << funname << "()" << endl; + f_service_ << "recv_" << funname << "()" << '\n'; } f_service_.indent_down(); - f_service_.indent() << "end" << endl; - f_service_ << endl; + f_service_.indent() << "end" << '\n'; + f_service_ << '\n'; - f_service_.indent() << "def send_" << function_signature(*f_iter) << endl; + f_service_.indent() << "def send_" << function_signature(*f_iter) << '\n'; f_service_.indent_up(); std::string argsname = capitalize((*f_iter)->get_name() + "_args"); @@ -927,10 +925,10 @@ void t_rb_generator::generate_service_client(t_service* tservice) { f_service_ << ", :" << (*fld_iter)->get_name() << " => " << (*fld_iter)->get_name(); } - f_service_ << ")" << endl; + f_service_ << ")" << '\n'; f_service_.indent_down(); - f_service_.indent() << "end" << endl; + f_service_.indent() << "end" << '\n'; if (!(*f_iter)->is_oneway()) { std::string resultname = capitalize((*f_iter)->get_name() + "_result"); @@ -940,22 +938,22 @@ void t_rb_generator::generate_service_client(t_service* tservice) { string("recv_") + (*f_iter)->get_name(), &noargs); // Open function - f_service_ << endl; - f_service_.indent() << "def " << function_signature(&recv_function) << endl; + f_service_ << '\n'; + f_service_.indent() << "def " << function_signature(&recv_function) << '\n'; f_service_.indent_up(); - f_service_.indent() << "fname, mtype, rseqid = receive_message_begin()" << endl; - f_service_.indent() << "handle_exception(mtype)" << endl; + f_service_.indent() << "fname, mtype, rseqid = receive_message_begin()" << '\n'; + f_service_.indent() << "handle_exception(mtype)" << '\n'; - f_service_.indent() << "if reply_seqid(rseqid)==false" << endl; - f_service_.indent() << " raise \"seqid reply faild\"" << endl; - f_service_.indent() << "end" << endl; + f_service_.indent() << "if reply_seqid(rseqid)==false" << '\n'; + f_service_.indent() << " raise \"seqid reply faild\"" << '\n'; + f_service_.indent() << "end" << '\n'; - f_service_.indent() << "result = receive_message(" << resultname << ")" << endl; + f_service_.indent() << "result = receive_message(" << resultname << ")" << '\n'; // Careful, only return _result if not a void function if (!(*f_iter)->get_returntype()->is_void()) { - f_service_.indent() << "return result.success unless result.success.nil?" << endl; + f_service_.indent() << "return result.success unless result.success.nil?" << '\n'; } t_struct* xs = (*f_iter)->get_xceptions(); @@ -963,27 +961,27 @@ void t_rb_generator::generate_service_client(t_service* tservice) { vector::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_.indent() << "raise result." << (*x_iter)->get_name() << " unless result." - << (*x_iter)->get_name() << ".nil?" << endl; + << (*x_iter)->get_name() << ".nil?" << '\n'; } // Careful, only return _result if not a void function if ((*f_iter)->get_returntype()->is_void()) { - f_service_.indent() << "return" << endl; + f_service_.indent() << "return" << '\n'; } else { f_service_.indent() << "raise " "::Thrift::ApplicationException.new(::Thrift::ApplicationException::" "MISSING_RESULT, '" << (*f_iter)->get_name() - << " failed: unknown result')" << endl; + << " failed: unknown result')" << '\n'; } // Close function f_service_.indent_down(); - f_service_.indent() << "end" << endl << endl; + f_service_.indent() << "end" << '\n' << '\n'; } } f_service_.indent_down(); - f_service_.indent() << "end" << endl << endl; + f_service_.indent() << "end" << '\n' << '\n'; } /** @@ -1004,10 +1002,10 @@ void t_rb_generator::generate_service_server(t_service* tservice) { } // Generate the header portion - f_service_.indent() << "class Processor" << extends_processor << endl; + f_service_.indent() << "class Processor" << extends_processor << '\n'; f_service_.indent_up(); - f_service_.indent() << "include ::Thrift::Processor" << endl << endl; + f_service_.indent() << "include ::Thrift::Processor" << '\n' << '\n'; // Generate the process subfunctions for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { @@ -1015,7 +1013,7 @@ void t_rb_generator::generate_service_server(t_service* tservice) { } f_service_.indent_down(); - f_service_.indent() << "end" << endl << endl; + f_service_.indent() << "end" << '\n' << '\n'; } /** @@ -1026,13 +1024,13 @@ void t_rb_generator::generate_service_server(t_service* tservice) { void t_rb_generator::generate_process_function(t_service* tservice, t_function* tfunction) { (void)tservice; // Open function - f_service_.indent() << "def process_" << tfunction->get_name() << "(seqid, iprot, oprot)" << endl; + f_service_.indent() << "def process_" << tfunction->get_name() << "(seqid, iprot, oprot)" << '\n'; f_service_.indent_up(); string argsname = capitalize(tfunction->get_name()) + "_args"; string resultname = capitalize(tfunction->get_name()) + "_result"; - f_service_.indent() << "args = read_args(iprot, " << argsname << ")" << endl; + f_service_.indent() << "args = read_args(iprot, " << argsname << ")" << '\n'; t_struct* xs = tfunction->get_xceptions(); const std::vector& xceptions = xs->get_members(); @@ -1040,12 +1038,12 @@ void t_rb_generator::generate_process_function(t_service* tservice, t_function* // Declare result for non oneway function if (!tfunction->is_oneway()) { - f_service_.indent() << "result = " << resultname << ".new()" << endl; + f_service_.indent() << "result = " << resultname << ".new()" << '\n'; } // Try block for a function with exceptions if (xceptions.size() > 0) { - f_service_.indent() << "begin" << endl; + f_service_.indent() << "begin" << '\n'; f_service_.indent_up(); } @@ -1068,37 +1066,37 @@ void t_rb_generator::generate_process_function(t_service* tservice, t_function* } f_service_ << "args." << (*f_iter)->get_name(); } - f_service_ << ")" << endl; + f_service_ << ")" << '\n'; if (!tfunction->is_oneway() && xceptions.size() > 0) { f_service_.indent_down(); for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_.indent() << "rescue " << full_type_name((*x_iter)->get_type()) << " => " - << (*x_iter)->get_name() << endl; + << (*x_iter)->get_name() << '\n'; if (!tfunction->is_oneway()) { f_service_.indent_up(); f_service_.indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() - << endl; + << '\n'; f_service_.indent_down(); } } - f_service_.indent() << "end" << endl; + f_service_.indent() << "end" << '\n'; } // Shortcut out here for oneway functions if (tfunction->is_oneway()) { - f_service_.indent() << "return" << endl; + f_service_.indent() << "return" << '\n'; f_service_.indent_down(); - f_service_.indent() << "end" << endl << endl; + f_service_.indent() << "end" << '\n' << '\n'; return; } f_service_.indent() << "write_result(result, oprot, '" << tfunction->get_name() << "', seqid)" - << endl; + << '\n'; // Close function f_service_.indent_down(); - f_service_.indent() << "end" << endl << endl; + f_service_.indent() << "end" << '\n' << '\n'; } /** @@ -1219,7 +1217,7 @@ void t_rb_generator::generate_rdoc(t_rb_ofstream& out, t_doc* tdoc) { } void t_rb_generator::generate_rb_struct_required_validator(t_rb_ofstream& out, t_struct* tstruct) { - out.indent() << "def validate" << endl; + out.indent() << "def validate" << '\n'; out.indent_up(); const vector& fields = tstruct->get_members(); @@ -1235,7 +1233,7 @@ void t_rb_generator::generate_rb_struct_required_validator(t_rb_ofstream& out, t } else { out << " unless @" << field->get_name(); } - out << endl; + out << '\n'; } } @@ -1246,21 +1244,21 @@ void t_rb_generator::generate_rb_struct_required_validator(t_rb_ofstream& out, t if (field->get_type()->is_enum()) { out.indent() << "unless @" << field->get_name() << ".nil? || " << full_type_name(field->get_type()) << "::VALID_VALUES.include?(@" - << field->get_name() << ")" << endl; + << field->get_name() << ")" << '\n'; out.indent_up(); out.indent() << "raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, " - "'Invalid value of field " << field->get_name() << "!')" << endl; + "'Invalid value of field " << field->get_name() << "!')" << '\n'; out.indent_down(); - out.indent() << "end" << endl; + out.indent() << "end" << '\n'; } } out.indent_down(); - out.indent() << "end" << endl << endl; + out.indent() << "end" << '\n' << '\n'; } void t_rb_generator::generate_rb_union_validator(t_rb_ofstream& out, t_struct* tstruct) { - out.indent() << "def validate" << endl; + out.indent() << "def validate" << '\n'; out.indent_up(); const vector& fields = tstruct->get_members(); @@ -1268,25 +1266,25 @@ void t_rb_generator::generate_rb_union_validator(t_rb_ofstream& out, t_struct* t out.indent() << "raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?" - << endl; + << '\n'; // if field is an enum, check that its value is valid for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { const t_field* field = (*f_iter); if (field->get_type()->is_enum()) { - out.indent() << "if get_set_field == :" << field->get_name() << endl; + out.indent() << "if get_set_field == :" << field->get_name() << '\n'; out.indent() << " raise " "::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, " "'Invalid value of field " << field->get_name() << "!') unless " << full_type_name(field->get_type()) << "::VALID_VALUES.include?(get_value)" - << endl; - out.indent() << "end" << endl; + << '\n'; + out.indent() << "end" << '\n'; } } out.indent_down(); - out.indent() << "end" << endl << endl; + out.indent() << "end" << '\n' << '\n'; } std::string t_rb_generator::display_name() const { diff --git a/compiler/cpp/src/thrift/generate/t_rs_generator.cc b/compiler/cpp/src/thrift/generate/t_rs_generator.cc index 2742724a605..780c8fd2914 100644 --- a/compiler/cpp/src/thrift/generate/t_rs_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_rs_generator.cc @@ -31,7 +31,6 @@ using std::set; using std::string; using std::vector; -static const string endl("\n"); // avoid ostream << std::endl flushes static const string SERVICE_RESULT_VARIABLE("result_value"); static const string RESULT_STRUCT_SUFFIX("Result"); static const string RUST_RESERVED_WORDS[] @@ -521,9 +520,9 @@ void t_rs_generator::init_generator() { f_gen_.open(f_gen_name.c_str()); // header comment - f_gen_ << "// " << autogen_summary() << endl; - f_gen_ << "// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING" << endl; - f_gen_ << endl; + f_gen_ << "// " << autogen_summary() << '\n'; + f_gen_ << "// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING" << '\n'; + f_gen_ << '\n'; render_attributes_and_includes(); } @@ -532,11 +531,11 @@ void t_rs_generator::render_attributes_and_includes() { // turn off some compiler/clippy warnings // code may not be used - f_gen_ << "#![allow(dead_code)]" << endl; + f_gen_ << "#![allow(dead_code)]" << '\n'; // code always includes BTreeMap/BTreeSet/OrderedFloat - f_gen_ << "#![allow(unused_imports)]" << endl; + f_gen_ << "#![allow(unused_imports)]" << '\n'; // code might not include imports from crates - f_gen_ << "#![allow(unused_extern_crates)]" << endl; + f_gen_ << "#![allow(unused_extern_crates)]" << '\n'; // constructors take *all* struct parameters, which can trigger the "too many arguments" warning // some auto-gen'd types can be deeply nested. clippy recommends factoring them out which is hard // to autogen some methods may start with "is_" @@ -548,38 +547,38 @@ void t_rs_generator::render_attributes_and_includes() { // 2. When you define types out of order f_gen_ << "#![allow(clippy::too_many_arguments, clippy::type_complexity, clippy::vec_box, " "clippy::wrong_self_convention)]" - << endl; + << '\n'; // prevent rustfmt from running against this file // lines are too long, code is (thankfully!) not visual-indented, etc. // can't use #[rustfmt::skip] see: https://github.com/rust-lang/rust/issues/54726 - f_gen_ << "#![cfg_attr(rustfmt, rustfmt_skip)]" << endl; - f_gen_ << endl; + f_gen_ << "#![cfg_attr(rustfmt, rustfmt_skip)]" << '\n'; + f_gen_ << '\n'; // add standard includes - f_gen_ << "use std::cell::RefCell;" << endl; - f_gen_ << "use std::collections::{BTreeMap, BTreeSet};" << endl; - f_gen_ << "use std::convert::{From, TryFrom};" << endl; - f_gen_ << "use std::default::Default;" << endl; - f_gen_ << "use std::error::Error;" << endl; - f_gen_ << "use std::fmt;" << endl; - f_gen_ << "use std::fmt::{Display, Formatter};" << endl; - f_gen_ << "use std::rc::Rc;" << endl; - f_gen_ << endl; - f_gen_ << "use thrift::OrderedFloat;" << endl; + f_gen_ << "use std::cell::RefCell;" << '\n'; + f_gen_ << "use std::collections::{BTreeMap, BTreeSet};" << '\n'; + f_gen_ << "use std::convert::{From, TryFrom};" << '\n'; + f_gen_ << "use std::default::Default;" << '\n'; + f_gen_ << "use std::error::Error;" << '\n'; + f_gen_ << "use std::fmt;" << '\n'; + f_gen_ << "use std::fmt::{Display, Formatter};" << '\n'; + f_gen_ << "use std::rc::Rc;" << '\n'; + f_gen_ << '\n'; + f_gen_ << "use thrift::OrderedFloat;" << '\n'; f_gen_ << "use thrift::{ApplicationError, ApplicationErrorKind, ProtocolError, " "ProtocolErrorKind, TThriftClient};" - << endl; + << '\n'; f_gen_ << "use thrift::protocol::{TFieldIdentifier, TListIdentifier, TMapIdentifier, " "TMessageIdentifier, TMessageType, TInputProtocol, TOutputProtocol, TSerializable, " "TSetIdentifier, TStructIdentifier, TType};" - << endl; - f_gen_ << "use thrift::protocol::field_id;" << endl; - f_gen_ << "use thrift::protocol::verify_expected_message_type;" << endl; - f_gen_ << "use thrift::protocol::verify_expected_sequence_number;" << endl; - f_gen_ << "use thrift::protocol::verify_expected_service_call;" << endl; - f_gen_ << "use thrift::protocol::verify_required_field_exists;" << endl; - f_gen_ << "use thrift::server::TProcessor;" << endl; - f_gen_ << endl; + << '\n'; + f_gen_ << "use thrift::protocol::field_id;" << '\n'; + f_gen_ << "use thrift::protocol::verify_expected_message_type;" << '\n'; + f_gen_ << "use thrift::protocol::verify_expected_sequence_number;" << '\n'; + f_gen_ << "use thrift::protocol::verify_expected_service_call;" << '\n'; + f_gen_ << "use thrift::protocol::verify_required_field_exists;" << '\n'; + f_gen_ << "use thrift::server::TProcessor;" << '\n'; + f_gen_ << '\n'; // add all the program includes // NOTE: this is more involved than you would expect because of service extension @@ -615,13 +614,13 @@ void t_rs_generator::render_attributes_and_includes() { string_replace(module_namespace, ".", "::"); if (module_namespace.empty()) { - f_gen_ << "use crate::" << rust_snake_case(module_name) << ";" << endl; + f_gen_ << "use crate::" << rust_snake_case(module_name) << ";" << '\n'; } else { f_gen_ << "use crate::" << module_namespace << "::" << rust_snake_case(module_name) << ";" - << endl; + << '\n'; } } - f_gen_ << endl; + f_gen_ << '\n'; } } @@ -673,8 +672,8 @@ void t_rs_generator::render_const_value(const string& name, t_type* ttype, t_con f_gen_ << "pub const " << rust_upper_case(name) << ": " << to_rust_const_type(ttype) << " = "; render_const_value(ttype, tvalue, false); - f_gen_ << ";" << endl; - f_gen_ << endl; + f_gen_ << ";" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_const_value_holder(const string& name, @@ -686,19 +685,19 @@ void t_rs_generator::render_const_value_holder(const string& name, string holder_name("Const" + rust_camel_case(name)); - f_gen_ << indent() << "pub struct " << holder_name << ";" << endl; - f_gen_ << indent() << "impl " << holder_name << " {" << endl; + f_gen_ << indent() << "pub struct " << holder_name << ";" << '\n'; + f_gen_ << indent() << "impl " << holder_name << " {" << '\n'; indent_up(); - f_gen_ << indent() << "pub fn const_value() -> " << to_rust_type(ttype) << " {" << endl; + f_gen_ << indent() << "pub fn const_value() -> " << to_rust_type(ttype) << " {" << '\n'; indent_up(); render_const_value(ttype, tvalue, true, false); indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_const_value(t_type* ttype, @@ -748,10 +747,10 @@ void t_rs_generator::render_const_value(t_type* ttype, } else if (ttype->is_typedef()) { render_const_value(get_true_type(ttype), tvalue, is_owned, true); } else if (ttype->is_enum()) { - f_gen_ << "{" << endl; + f_gen_ << "{" << '\n'; indent_up(); f_gen_ << indent() << to_rust_type(ttype) << "::try_from(" << tvalue->get_integer() - << ").expect(\"expecting valid const value\")" << endl; + << ").expect(\"expecting valid const value\")" << '\n'; indent_down(); f_gen_ << indent() << "}"; } else if (ttype->is_struct() || ttype->is_xception()) { @@ -772,21 +771,21 @@ void t_rs_generator::render_const_value(t_type* ttype, } if (!is_inline) { - f_gen_ << endl; + f_gen_ << '\n'; } } void t_rs_generator::render_const_struct(t_type* ttype, t_const_value*) { if (((t_struct*)ttype)->is_union()) { - f_gen_ << "{" << endl; + f_gen_ << "{" << '\n'; indent_up(); - f_gen_ << indent() << "unimplemented!()" << endl; + f_gen_ << indent() << "unimplemented!()" << '\n'; indent_down(); f_gen_ << indent() << "}"; } else { - f_gen_ << "{" << endl; + f_gen_ << "{" << '\n'; indent_up(); - f_gen_ << indent() << "unimplemented!()" << endl; + f_gen_ << indent() << "unimplemented!()" << '\n'; indent_down(); f_gen_ << indent() << "}"; } @@ -794,7 +793,7 @@ void t_rs_generator::render_const_struct(t_type* ttype, t_const_value*) { void t_rs_generator::render_const_list(t_type* ttype, t_const_value* tvalue) { t_type* elem_type = ((t_list*)ttype)->get_elem_type(); - f_gen_ << "vec![" << endl; + f_gen_ << "vec![" << '\n'; indent_up(); const vector& elems = tvalue->get_list(); vector::const_iterator elem_iter; @@ -802,7 +801,7 @@ void t_rs_generator::render_const_list(t_type* ttype, t_const_value* tvalue) { f_gen_ << indent(); t_const_value* elem_value = (*elem_iter); render_const_value(elem_type, elem_value); - f_gen_ << "," << endl; + f_gen_ << "," << '\n'; } indent_down(); f_gen_ << indent() << "]"; @@ -810,7 +809,7 @@ void t_rs_generator::render_const_list(t_type* ttype, t_const_value* tvalue) { void t_rs_generator::render_const_set(t_type* ttype, t_const_value* tvalue) { t_type* elem_type = ((t_set*)ttype)->get_elem_type(); - f_gen_ << "BTreeSet::from([" << endl; + f_gen_ << "BTreeSet::from([" << '\n'; indent_up(); const vector& elems = tvalue->get_list(); vector::const_iterator elem_iter; @@ -818,7 +817,7 @@ void t_rs_generator::render_const_set(t_type* ttype, t_const_value* tvalue) { f_gen_ << indent(); t_const_value* elem_value = (*elem_iter); render_const_value(elem_type, elem_value); - f_gen_ << "," << endl; + f_gen_ << "," << '\n'; } indent_down(); f_gen_ << indent() << "])"; @@ -827,7 +826,7 @@ void t_rs_generator::render_const_set(t_type* ttype, t_const_value* tvalue) { void t_rs_generator::render_const_map(t_type* ttype, t_const_value* tvalue) { t_type* key_type = ((t_map*)ttype)->get_key_type(); t_type* val_type = ((t_map*)ttype)->get_val_type(); - f_gen_ << "BTreeMap::from([" << endl; + f_gen_ << "BTreeMap::from([" << '\n'; indent_up(); const map& elems = tvalue->get_map(); @@ -836,16 +835,16 @@ void t_rs_generator::render_const_map(t_type* ttype, t_const_value* tvalue) { t_const_value* key_value = elem_iter->first; t_const_value* val_value = elem_iter->second; - f_gen_ << indent() << "(" << endl; + f_gen_ << indent() << "(" << '\n'; indent_up(); f_gen_ << indent(); render_const_value(key_type, key_value); - f_gen_ << "," << endl; + f_gen_ << "," << '\n'; f_gen_ << indent(); render_const_value(val_type, val_value); - f_gen_ << "," << endl; + f_gen_ << "," << '\n'; indent_down(); - f_gen_ << indent() << ")," << endl; + f_gen_ << indent() << ")," << '\n'; } indent_down(); f_gen_ << indent() << "])"; @@ -860,8 +859,8 @@ void t_rs_generator::render_const_map(t_type* ttype, t_const_value* tvalue) { void t_rs_generator::generate_typedef(t_typedef* ttypedef) { std::string actual_type = to_rust_type(ttypedef->get_type()); f_gen_ << "pub type " << rust_safe_name(ttypedef->get_symbolic()) << " = " << actual_type << ";" - << endl; - f_gen_ << endl; + << '\n'; + f_gen_ << '\n'; } //----------------------------------------------------------------------------- @@ -879,13 +878,13 @@ void t_rs_generator::generate_enum(t_enum* tenum) { void t_rs_generator::render_enum_definition(t_enum* tenum, const string& enum_name) { render_rustdoc((t_doc*)tenum); - f_gen_ << "#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]" << endl; - f_gen_ << "pub struct " << enum_name << "(pub i32);" << endl; - f_gen_ << endl; + f_gen_ << "#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]" << '\n'; + f_gen_ << "pub struct " << enum_name << "(pub i32);" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_enum_impl(t_enum* tenum, const string& enum_name) { - f_gen_ << "impl " << enum_name << " {" << endl; + f_gen_ << "impl " << enum_name << " {" << '\n'; indent_up(); vector constants = tenum->get_constants(); @@ -898,114 +897,114 @@ void t_rs_generator::render_enum_impl(t_enum* tenum, const string& enum_name) { render_rustdoc((t_doc*)val); f_gen_ << indent() << "pub const " << rust_enum_variant_name(val->get_name()) << ": " << enum_name << " = " << enum_name << "(" << val->get_value() << ")" - << ";" << endl; + << ";" << '\n'; } } // array containing all IDL-defined enum variants { - f_gen_ << indent() << "pub const ENUM_VALUES: &'static [Self] = &[" << endl; + f_gen_ << indent() << "pub const ENUM_VALUES: &'static [Self] = &[" << '\n'; indent_up(); vector::iterator constants_iter; for (constants_iter = constants.begin(); constants_iter != constants.end(); ++constants_iter) { t_enum_value* val = (*constants_iter); - f_gen_ << indent() << "Self::" << rust_enum_variant_name(val->get_name()) << "," << endl; + f_gen_ << indent() << "Self::" << rust_enum_variant_name(val->get_name()) << "," << '\n'; } indent_down(); - f_gen_ << indent() << "];" << endl; + f_gen_ << indent() << "];" << '\n'; } indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; - f_gen_ << "impl TSerializable for " << enum_name << " {" << endl; + f_gen_ << "impl TSerializable for " << enum_name << " {" << '\n'; indent_up(); - f_gen_ << indent() << "#[allow(clippy::trivially_copy_pass_by_ref)]" << endl; + f_gen_ << indent() << "#[allow(clippy::trivially_copy_pass_by_ref)]" << '\n'; f_gen_ << indent() << "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {" - << endl; + << '\n'; indent_up(); - f_gen_ << indent() << "o_prot.write_i32(self.0)" << endl; + f_gen_ << indent() << "o_prot.write_i32(self.0)" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; f_gen_ << indent() << "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<" - << enum_name << "> {" << endl; + << enum_name << "> {" << '\n'; indent_up(); - f_gen_ << indent() << "let enum_value = i_prot.read_i32()?;" << endl; + f_gen_ << indent() << "let enum_value = i_prot.read_i32()?;" << '\n'; f_gen_ << indent() << "Ok(" << enum_name << "::from(enum_value)" - << ")" << endl; + << ")" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_enum_conversion(t_enum* tenum, const string& enum_name) { // From trait: i32 -> ENUM_TYPE - f_gen_ << "impl From for " << enum_name << " {" << endl; + f_gen_ << "impl From for " << enum_name << " {" << '\n'; indent_up(); - f_gen_ << indent() << "fn from(i: i32) -> Self {" << endl; + f_gen_ << indent() << "fn from(i: i32) -> Self {" << '\n'; indent_up(); - f_gen_ << indent() << "match i {" << endl; + f_gen_ << indent() << "match i {" << '\n'; indent_up(); vector constants = tenum->get_constants(); vector::iterator constants_iter; for (constants_iter = constants.begin(); constants_iter != constants.end(); ++constants_iter) { t_enum_value* val = (*constants_iter); f_gen_ << indent() << val->get_value() << " => " << enum_name - << "::" << rust_enum_variant_name(val->get_name()) << "," << endl; + << "::" << rust_enum_variant_name(val->get_name()) << "," << '\n'; } - f_gen_ << indent() << "_ => " << enum_name << "(i)" << endl; + f_gen_ << indent() << "_ => " << enum_name << "(i)" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; // From trait: &i32 -> ENUM_TYPE - f_gen_ << "impl From<&i32> for " << enum_name << " {" << endl; + f_gen_ << "impl From<&i32> for " << enum_name << " {" << '\n'; indent_up(); - f_gen_ << indent() << "fn from(i: &i32) -> Self {" << endl; + f_gen_ << indent() << "fn from(i: &i32) -> Self {" << '\n'; indent_up(); - f_gen_ << indent() << enum_name << "::from(*i)" << endl; + f_gen_ << indent() << enum_name << "::from(*i)" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; // From trait: ENUM_TYPE -> int - f_gen_ << "impl From<" << enum_name << "> for i32 {" << endl; + f_gen_ << "impl From<" << enum_name << "> for i32 {" << '\n'; indent_up(); - f_gen_ << indent() << "fn from(e: " << enum_name << ") -> i32 {" << endl; + f_gen_ << indent() << "fn from(e: " << enum_name << ") -> i32 {" << '\n'; indent_up(); - f_gen_ << indent() << "e.0" << endl; + f_gen_ << indent() << "e.0" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; // From trait: &ENUM_TYPE -> int - f_gen_ << "impl From<&" << enum_name << "> for i32 {" << endl; + f_gen_ << "impl From<&" << enum_name << "> for i32 {" << '\n'; indent_up(); - f_gen_ << indent() << "fn from(e: &" << enum_name << ") -> i32 {" << endl; + f_gen_ << indent() << "fn from(e: &" << enum_name << ") -> i32 {" << '\n'; indent_up(); - f_gen_ << indent() << "e.0" << endl; + f_gen_ << indent() << "e.0" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; } //----------------------------------------------------------------------------- @@ -1056,8 +1055,8 @@ void t_rs_generator::render_struct_definition(const string& struct_name, } } f_gen_ << "#[derive(Clone, Debug" << (need_default ? ", Default" : "") - << ", Eq, Hash, Ord, PartialEq, PartialOrd)]" << endl; - f_gen_ << visibility_qualifier(struct_type) << "struct " << struct_name << " {" << endl; + << ", Eq, Hash, Ord, PartialEq, PartialOrd)]" << '\n'; + f_gen_ << visibility_qualifier(struct_type) << "struct " << struct_name << " {" << '\n'; // render the members if (!members.empty()) { @@ -1072,53 +1071,53 @@ void t_rs_generator::render_struct_definition(const string& struct_name, render_rustdoc((t_doc*)member); f_gen_ << indent() << visibility_qualifier(struct_type) << rust_field_name(member) << ": " - << rust_type << "," << endl; + << rust_type << "," << '\n'; } indent_down(); } - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_exception_struct_error_trait_impls(const string& struct_name, t_struct* tstruct) { // error::Error trait - f_gen_ << "impl Error for " << struct_name << " {}" << endl; - f_gen_ << endl; + f_gen_ << "impl Error for " << struct_name << " {}" << '\n'; + f_gen_ << '\n'; // convert::From trait - f_gen_ << "impl From<" << struct_name << "> for thrift::Error {" << endl; + f_gen_ << "impl From<" << struct_name << "> for thrift::Error {" << '\n'; indent_up(); - f_gen_ << indent() << "fn from(e: " << struct_name << ") -> Self {" << endl; + f_gen_ << indent() << "fn from(e: " << struct_name << ") -> Self {" << '\n'; indent_up(); - f_gen_ << indent() << "thrift::Error::User(Box::new(e))" << endl; + f_gen_ << indent() << "thrift::Error::User(Box::new(e))" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; // fmt::Display trait - f_gen_ << "impl Display for " << struct_name << " {" << endl; + f_gen_ << "impl Display for " << struct_name << " {" << '\n'; indent_up(); - f_gen_ << indent() << "fn fmt(&self, f: &mut Formatter) -> fmt::Result {" << endl; + f_gen_ << indent() << "fn fmt(&self, f: &mut Formatter) -> fmt::Result {" << '\n'; indent_up(); f_gen_ << indent() << "write!(f, " << "\"remote service threw " << tstruct->get_name() << "\"" // use *original* name - << ")" << endl; + << ")" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_struct_impl(const string& struct_name, t_struct* tstruct, t_rs_generator::e_struct_type struct_type) { - f_gen_ << "impl " << struct_name << " {" << endl; + f_gen_ << "impl " << struct_name << " {" << '\n'; indent_up(); if (struct_type == t_rs_generator::T_REGULAR || struct_type == t_rs_generator::T_EXCEPTION) { @@ -1131,10 +1130,10 @@ void t_rs_generator::render_struct_impl(const string& struct_name, if (struct_type == t_rs_generator::T_REGULAR || struct_type == t_rs_generator::T_EXCEPTION) { indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; - f_gen_ << "impl TSerializable for " << struct_name << " {" << endl; + f_gen_ << "impl TSerializable for " << struct_name << " {" << '\n'; indent_up(); } @@ -1142,8 +1141,8 @@ void t_rs_generator::render_struct_impl(const string& struct_name, render_struct_sync_write(tstruct, struct_type); indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_struct_constructor(const string& struct_name, @@ -1213,13 +1212,13 @@ void t_rs_generator::render_struct_constructor(const string& struct_name, string visibility(visibility_qualifier(struct_type)); f_gen_ << indent() << visibility << "fn new" << type_parameter_string << "(" << arg_string - << ") -> " << struct_name << " " << type_qualifier_string << "{" << endl; + << ") -> " << struct_name << " " << type_qualifier_string << "{" << '\n'; indent_up(); if (members.empty()) { - f_gen_ << indent() << struct_name << " {}" << endl; + f_gen_ << indent() << struct_name << " {}" << '\n'; } else { - f_gen_ << indent() << struct_name << " {" << endl; + f_gen_ << indent() << struct_name << " {" << '\n'; indent_up(); for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { @@ -1228,18 +1227,18 @@ void t_rs_generator::render_struct_constructor(const string& struct_name, string member_name(rust_field_name(member)); if (is_optional(member_req)) { - f_gen_ << indent() << member_name << ": " << member_name << ".into()," << endl; + f_gen_ << indent() << member_name << ": " << member_name << ".into()," << '\n'; } else { - f_gen_ << indent() << member_name << "," << endl; + f_gen_ << indent() << member_name << "," << '\n'; } } indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) { @@ -1272,7 +1271,7 @@ void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) { // maintaining a rendered branch count (while a little ugly) got me the // rendering I wanted with code that was reasonably understandable - f_gen_ << indent() << "fn ok_or(self) -> thrift::Result<" << rust_return_type << "> {" << endl; + f_gen_ << indent() << "fn ok_or(self) -> thrift::Result<" << rust_return_type << "> {" << '\n'; indent_up(); int rendered_branch_count = 0; @@ -1284,10 +1283,10 @@ void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) { string field_name("self." + rust_field_name(tfield)); string branch_statement = rendered_branch_count == 0 ? "if" : "} else if"; - f_gen_ << indent() << branch_statement << " " << field_name << ".is_some() {" << endl; + f_gen_ << indent() << branch_statement << " " << field_name << ".is_some() {" << '\n'; indent_up(); f_gen_ << indent() << "Err(thrift::Error::User(Box::new(" << field_name << ".unwrap())))" - << endl; + << '\n'; indent_down(); rendered_branch_count++; @@ -1299,35 +1298,35 @@ void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) { if (rendered_branch_count == 0) { // we have the unit return and this service call has no user-defined // exceptions. this means that we've a trivial return (happens with oneways) - f_gen_ << indent() << "Ok(())" << endl; + f_gen_ << indent() << "Ok(())" << '\n'; } else { // we have the unit return, but there are user-defined exceptions // if we've gotten this far then we have the default return (i.e. call successful) - f_gen_ << indent() << "} else {" << endl; + f_gen_ << indent() << "} else {" << '\n'; indent_up(); - f_gen_ << indent() << "Ok(())" << endl; + f_gen_ << indent() << "Ok(())" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } } else { string branch_statement = rendered_branch_count == 0 ? "if" : "} else if"; f_gen_ << indent() << branch_statement << " self." << SERVICE_RESULT_VARIABLE << ".is_some() {" - << endl; + << '\n'; indent_up(); - f_gen_ << indent() << "Ok(self." << SERVICE_RESULT_VARIABLE << ".unwrap())" << endl; + f_gen_ << indent() << "Ok(self." << SERVICE_RESULT_VARIABLE << ".unwrap())" << '\n'; indent_down(); - f_gen_ << indent() << "} else {" << endl; + f_gen_ << indent() << "} else {" << '\n'; indent_up(); // if we haven't found a valid return value *or* a user exception // then we're in trouble; return a default error render_thrift_error("Application", "ApplicationError", "ApplicationErrorKind::MissingResult", "\"no result received for " + service_call_name + "\""); indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } void t_rs_generator::render_union(t_struct* tstruct) { @@ -1343,32 +1342,32 @@ void t_rs_generator::render_union_definition(const string& union_name, t_struct* throw "cannot generate rust enum with 0 members"; // may be valid thrift, but it's invalid rust } - f_gen_ << "#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]" << endl; - f_gen_ << "pub enum " << union_name << " {" << endl; + f_gen_ << "#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]" << '\n'; + f_gen_ << "pub enum " << union_name << " {" << '\n'; indent_up(); vector::const_iterator member_iter; for (member_iter = members.begin(); member_iter != members.end(); ++member_iter) { t_field* tfield = (*member_iter); f_gen_ << indent() << rust_union_field_name(tfield) << "(" << to_rust_type(tfield->get_type()) - << ")," << endl; + << ")," << '\n'; } indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_union_impl(const string& union_name, t_struct* tstruct) { - f_gen_ << "impl TSerializable for " << union_name << " {" << endl; + f_gen_ << "impl TSerializable for " << union_name << " {" << '\n'; indent_up(); render_union_sync_read(union_name, tstruct); render_union_sync_write(union_name, tstruct); indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; } //----------------------------------------------------------------------------- @@ -1382,14 +1381,14 @@ void t_rs_generator::render_struct_sync_write(t_struct* tstruct, f_gen_ << indent() << "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {" - << endl; + << '\n'; indent_up(); // write struct header to output protocol // note: use the *original* struct name here f_gen_ << indent() - << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << endl; - f_gen_ << indent() << "o_prot.write_struct_begin(&struct_ident)?;" << endl; + << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << '\n'; + f_gen_ << indent() << "o_prot.write_struct_begin(&struct_ident)?;" << '\n'; // write struct members to output protocol vector members = tstruct->get_sorted_members(); @@ -1404,30 +1403,30 @@ void t_rs_generator::render_struct_sync_write(t_struct* tstruct, } // write struct footer to output protocol - f_gen_ << indent() << "o_prot.write_field_stop()?;" << endl; - f_gen_ << indent() << "o_prot.write_struct_end()" << endl; + f_gen_ << indent() << "o_prot.write_field_stop()?;" << '\n'; + f_gen_ << indent() << "o_prot.write_struct_end()" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } void t_rs_generator::render_union_sync_write(const string& union_name, t_struct* tstruct) { f_gen_ << indent() << "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {" - << endl; + << '\n'; indent_up(); // write struct header to output protocol // note: use the *original* struct name here f_gen_ << indent() - << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << endl; - f_gen_ << indent() << "o_prot.write_struct_begin(&struct_ident)?;" << endl; + << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << '\n'; + f_gen_ << indent() << "o_prot.write_struct_begin(&struct_ident)?;" << '\n'; // write the enum field to the output protocol vector members = tstruct->get_sorted_members(); if (!members.empty()) { - f_gen_ << indent() << "match *self {" << endl; + f_gen_ << indent() << "match *self {" << '\n'; indent_up(); vector::iterator members_iter; for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { @@ -1440,22 +1439,22 @@ void t_rs_generator::render_union_sync_write(const string& union_name, t_struct* } string match_var((ttype->is_base_type() && !ttype->is_string()) ? "f" : "ref f"); f_gen_ << indent() << union_name << "::" << rust_union_field_name(member) << "(" << match_var - << ") => {" << endl; + << ") => {" << '\n'; indent_up(); render_struct_field_sync_write("f", true, member, member_req); indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; } indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } // write struct footer to output protocol - f_gen_ << indent() << "o_prot.write_field_stop()?;" << endl; - f_gen_ << indent() << "o_prot.write_struct_end()" << endl; + f_gen_ << indent() << "o_prot.write_field_stop()?;" << '\n'; + f_gen_ << indent() << "o_prot.write_struct_end()" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } void t_rs_generator::render_struct_field_sync_write(const string& field_var, @@ -1475,23 +1474,23 @@ void t_rs_generator::render_struct_field_sync_write(const string& field_var, if (is_optional(req)) { string let_var((actual_type->is_base_type() && !actual_type->is_string()) ? "fld_var" : "ref fld_var"); - f_gen_ << indent() << "if let Some(" << let_var << ") = " << field_var << " {" << endl; + f_gen_ << indent() << "if let Some(" << let_var << ") = " << field_var << " {" << '\n'; indent_up(); - f_gen_ << indent() << "o_prot.write_field_begin(&" << field_ident_string << ")?;" << endl; + f_gen_ << indent() << "o_prot.write_field_begin(&" << field_ident_string << ")?;" << '\n'; render_type_sync_write("fld_var", true, field_type); - f_gen_ << indent() << "o_prot.write_field_end()?" << endl; + f_gen_ << indent() << "o_prot.write_field_end()?" << '\n'; indent_down(); /* FIXME: rethink how I deal with OPT_IN_REQ_OUT if (req == t_field::T_OPT_IN_REQ_OUT) { - f_gen_ << indent() << "let field_ident = " << field_ident_string << ";" << endl; - f_gen_ << indent() << "o_prot.write_field_begin(&field_ident)?;" << endl; - f_gen_ << indent() << "o_prot.write_field_end()?;" << endl; + f_gen_ << indent() << "let field_ident = " << field_ident_string << ";" << '\n'; + f_gen_ << indent() << "o_prot.write_field_begin(&field_ident)?;" << '\n'; + f_gen_ << indent() << "o_prot.write_field_end()?;" << '\n'; }*/ - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } else { - f_gen_ << indent() << "o_prot.write_field_begin(&" << field_ident_string << ")?;" << endl; + f_gen_ << indent() << "o_prot.write_field_begin(&" << field_ident_string << ")?;" << '\n'; render_type_sync_write(field_var, field_var_is_ref, tfield->get_type()); - f_gen_ << indent() << "o_prot.write_field_end()?;" << endl; + f_gen_ << indent() << "o_prot.write_field_end()?;" << '\n'; } } @@ -1506,32 +1505,32 @@ void t_rs_generator::render_type_sync_write(const string& type_var, case t_base_type::TYPE_STRING: { string ref(type_var_is_ref ? "" : "&"); if (tbase_type->is_binary()) { - f_gen_ << indent() << "o_prot.write_bytes(" + ref + type_var + ")?;" << endl; + f_gen_ << indent() << "o_prot.write_bytes(" + ref + type_var + ")?;" << '\n'; } else { - f_gen_ << indent() << "o_prot.write_string(" + ref + type_var + ")?;" << endl; + f_gen_ << indent() << "o_prot.write_string(" + ref + type_var + ")?;" << '\n'; } return; } case t_base_type::TYPE_UUID: - f_gen_ << indent() << "o_prot.write_uuid(&" + type_var + ")?;" << endl; + f_gen_ << indent() << "o_prot.write_uuid(&" + type_var + ")?;" << '\n'; return; case t_base_type::TYPE_BOOL: - f_gen_ << indent() << "o_prot.write_bool(" + type_var + ")?;" << endl; + f_gen_ << indent() << "o_prot.write_bool(" + type_var + ")?;" << '\n'; return; case t_base_type::TYPE_I8: - f_gen_ << indent() << "o_prot.write_i8(" + type_var + ")?;" << endl; + f_gen_ << indent() << "o_prot.write_i8(" + type_var + ")?;" << '\n'; return; case t_base_type::TYPE_I16: - f_gen_ << indent() << "o_prot.write_i16(" + type_var + ")?;" << endl; + f_gen_ << indent() << "o_prot.write_i16(" + type_var + ")?;" << '\n'; return; case t_base_type::TYPE_I32: - f_gen_ << indent() << "o_prot.write_i32(" + type_var + ")?;" << endl; + f_gen_ << indent() << "o_prot.write_i32(" + type_var + ")?;" << '\n'; return; case t_base_type::TYPE_I64: - f_gen_ << indent() << "o_prot.write_i64(" + type_var + ")?;" << endl; + f_gen_ << indent() << "o_prot.write_i64(" + type_var + ")?;" << '\n'; return; case t_base_type::TYPE_DOUBLE: - f_gen_ << indent() << "o_prot.write_double(" + type_var + ".into())?;" << endl; + f_gen_ << indent() << "o_prot.write_double(" + type_var + ".into())?;" << '\n'; return; default: throw "compiler error: unhandled type"; @@ -1541,7 +1540,7 @@ void t_rs_generator::render_type_sync_write(const string& type_var, render_type_sync_write(type_var, type_var_is_ref, ttypedef->get_type()); return; } else if (ttype->is_enum() || ttype->is_struct() || ttype->is_xception()) { - f_gen_ << indent() << type_var + ".write_to_out_protocol(o_prot)?;" << endl; + f_gen_ << indent() << type_var + ".write_to_out_protocol(o_prot)?;" << '\n'; return; } else if (ttype->is_map()) { render_map_sync_write(type_var, type_var_is_ref, (t_map*)ttype); @@ -1566,15 +1565,15 @@ void t_rs_generator::render_list_sync_write(const string& list_var, << "&TListIdentifier::new(" << to_rust_field_type_enum(elem_type) << ", " << list_var << ".len() as i32" << ")" - << ")?;" << endl; + << ")?;" << '\n'; string ref(list_var_is_ref ? "" : "&"); - f_gen_ << indent() << "for e in " << ref << list_var << " {" << endl; + f_gen_ << indent() << "for e in " << ref << list_var << " {" << '\n'; indent_up(); render_type_sync_write(string_container_write_variable(elem_type, "e"), true, elem_type); indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << indent() << "o_prot.write_list_end()?;" << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << indent() << "o_prot.write_list_end()?;" << '\n'; } void t_rs_generator::render_set_sync_write(const string& set_var, @@ -1586,15 +1585,15 @@ void t_rs_generator::render_set_sync_write(const string& set_var, << "&TSetIdentifier::new(" << to_rust_field_type_enum(elem_type) << ", " << set_var << ".len() as i32" << ")" - << ")?;" << endl; + << ")?;" << '\n'; string ref(set_var_is_ref ? "" : "&"); - f_gen_ << indent() << "for e in " << ref << set_var << " {" << endl; + f_gen_ << indent() << "for e in " << ref << set_var << " {" << '\n'; indent_up(); render_type_sync_write(string_container_write_variable(elem_type, "e"), true, elem_type); indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << indent() << "o_prot.write_set_end()?;" << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << indent() << "o_prot.write_set_end()?;" << '\n'; } void t_rs_generator::render_map_sync_write(const string& map_var, @@ -1606,16 +1605,16 @@ void t_rs_generator::render_map_sync_write(const string& map_var, f_gen_ << indent() << "o_prot.write_map_begin(" << "&TMapIdentifier::new(" << to_rust_field_type_enum(key_type) << ", " << to_rust_field_type_enum(val_type) << ", " << map_var << ".len() as i32)" - << ")?;" << endl; + << ")?;" << '\n'; string ref(map_var_is_ref ? "" : "&"); - f_gen_ << indent() << "for (k, v) in " << ref << map_var << " {" << endl; + f_gen_ << indent() << "for (k, v) in " << ref << map_var << " {" << '\n'; indent_up(); render_type_sync_write(string_container_write_variable(key_type, "k"), true, key_type); render_type_sync_write(string_container_write_variable(val_type, "v"), true, val_type); indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << indent() << "o_prot.write_map_end()?;" << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << indent() << "o_prot.write_map_end()?;" << '\n'; } string t_rs_generator::string_container_write_variable(t_type* ttype, const string& base_var) { @@ -1651,11 +1650,11 @@ void t_rs_generator::render_struct_sync_read(const string& struct_name, t_rs_generator::e_struct_type struct_type) { f_gen_ << indent() << "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<" - << struct_name << "> {" << endl; + << struct_name << "> {" << '\n'; indent_up(); - f_gen_ << indent() << "i_prot.read_struct_begin()?;" << endl; + f_gen_ << indent() << "i_prot.read_struct_begin()?;" << '\n'; // create temporary variables: one for each field in the struct const vector members = tstruct->get_sorted_members(); @@ -1671,55 +1670,55 @@ void t_rs_generator::render_struct_sync_read(const string& struct_name, } else { f_gen_ << "None;"; } - f_gen_ << endl; + f_gen_ << '\n'; } // now loop through the fields we've received - f_gen_ << indent() << "loop {" << endl; // start loop + f_gen_ << indent() << "loop {" << '\n'; // start loop indent_up(); // break out if you've found the Stop field - f_gen_ << indent() << "let field_ident = i_prot.read_field_begin()?;" << endl; - f_gen_ << indent() << "if field_ident.field_type == TType::Stop {" << endl; + f_gen_ << indent() << "let field_ident = i_prot.read_field_begin()?;" << '\n'; + f_gen_ << indent() << "if field_ident.field_type == TType::Stop {" << '\n'; indent_up(); - f_gen_ << indent() << "break;" << endl; + f_gen_ << indent() << "break;" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; // now read all the fields found // avoid clippy::match_single_binding if (members.empty()) { - f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << endl; + f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << '\n'; } else { - f_gen_ << indent() << "let field_id = field_id(&field_ident)?;" << endl; - f_gen_ << indent() << "match field_id {" << endl; // start match + f_gen_ << indent() << "let field_id = field_id(&field_ident)?;" << '\n'; + f_gen_ << indent() << "match field_id {" << '\n'; // start match indent_up(); for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* tfield = (*members_iter); - f_gen_ << indent() << rust_safe_field_id(tfield->get_key()) << " => {" << endl; + f_gen_ << indent() << rust_safe_field_id(tfield->get_key()) << " => {" << '\n'; indent_up(); render_type_sync_read("val", tfield->get_type()); - f_gen_ << indent() << struct_field_read_temp_variable(tfield) << " = Some(val);" << endl; + f_gen_ << indent() << struct_field_read_temp_variable(tfield) << " = Some(val);" << '\n'; indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; } // default case (skip fields) - f_gen_ << indent() << "_ => {" << endl; + f_gen_ << indent() << "_ => {" << '\n'; indent_up(); - f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << endl; + f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << '\n'; indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; indent_down(); - f_gen_ << indent() << "};" << endl; // finish match + f_gen_ << indent() << "};" << '\n'; // finish match } - f_gen_ << indent() << "i_prot.read_field_end()?;" << endl; + f_gen_ << indent() << "i_prot.read_field_end()?;" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; // finish loop - f_gen_ << indent() << "i_prot.read_struct_end()?;" << endl; // read message footer from the wire + f_gen_ << indent() << "}" << '\n'; // finish loop + f_gen_ << indent() << "i_prot.read_struct_end()?;" << '\n'; // read message footer from the wire // verify that all required fields exist for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { @@ -1729,15 +1728,15 @@ void t_rs_generator::render_struct_sync_read(const string& struct_name, f_gen_ << indent() << "verify_required_field_exists(" << "\"" << struct_name << "." << rust_field_name(tfield) << "\"" << ", " - << "&" << struct_field_read_temp_variable(tfield) << ")?;" << endl; + << "&" << struct_field_read_temp_variable(tfield) << ")?;" << '\n'; } } // construct the struct if (members.size() == 0) { - f_gen_ << indent() << "let ret = " << struct_name << " {};" << endl; + f_gen_ << indent() << "let ret = " << struct_name << " {};" << '\n'; } else { - f_gen_ << indent() << "let ret = " << struct_name << " {" << endl; + f_gen_ << indent() << "let ret = " << struct_name << " {" << '\n'; indent_up(); for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { @@ -1746,109 +1745,109 @@ void t_rs_generator::render_struct_sync_read(const string& struct_name, string field_name(rust_field_name(tfield)); string field_key = struct_field_read_temp_variable(tfield); if (is_optional(req)) { - f_gen_ << indent() << field_name << ": " << field_key << "," << endl; + f_gen_ << indent() << field_name << ": " << field_key << "," << '\n'; } else { f_gen_ << indent() << field_name << ": " << field_key << ".expect(\"auto-generated code should have checked for presence of required " "fields\")" - << "," << endl; + << "," << '\n'; } } indent_down(); - f_gen_ << indent() << "};" << endl; + f_gen_ << indent() << "};" << '\n'; } // return the constructed value - f_gen_ << indent() << "Ok(ret)" << endl; + f_gen_ << indent() << "Ok(ret)" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } void t_rs_generator::render_union_sync_read(const string& union_name, t_struct* tstruct) { f_gen_ << indent() << "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<" - << union_name << "> {" << endl; + << union_name << "> {" << '\n'; indent_up(); // create temporary variables to hold the // completed union as well as a count of fields read - f_gen_ << indent() << "let mut ret: Option<" << union_name << "> = None;" << endl; - f_gen_ << indent() << "let mut received_field_count = 0;" << endl; + f_gen_ << indent() << "let mut ret: Option<" << union_name << "> = None;" << '\n'; + f_gen_ << indent() << "let mut received_field_count = 0;" << '\n'; // read the struct preamble - f_gen_ << indent() << "i_prot.read_struct_begin()?;" << endl; + f_gen_ << indent() << "i_prot.read_struct_begin()?;" << '\n'; // now loop through the fields we've received - f_gen_ << indent() << "loop {" << endl; // start loop + f_gen_ << indent() << "loop {" << '\n'; // start loop indent_up(); // break out if you've found the Stop field - f_gen_ << indent() << "let field_ident = i_prot.read_field_begin()?;" << endl; - f_gen_ << indent() << "if field_ident.field_type == TType::Stop {" << endl; + f_gen_ << indent() << "let field_ident = i_prot.read_field_begin()?;" << '\n'; + f_gen_ << indent() << "if field_ident.field_type == TType::Stop {" << '\n'; indent_up(); - f_gen_ << indent() << "break;" << endl; + f_gen_ << indent() << "break;" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; // now read all the fields found - f_gen_ << indent() << "let field_id = field_id(&field_ident)?;" << endl; - f_gen_ << indent() << "match field_id {" << endl; // start match + f_gen_ << indent() << "let field_id = field_id(&field_ident)?;" << '\n'; + f_gen_ << indent() << "match field_id {" << '\n'; // start match indent_up(); const vector members = tstruct->get_sorted_members(); vector::const_iterator members_iter; for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) { t_field* member = (*members_iter); - f_gen_ << indent() << rust_safe_field_id(member->get_key()) << " => {" << endl; + f_gen_ << indent() << rust_safe_field_id(member->get_key()) << " => {" << '\n'; indent_up(); render_type_sync_read("val", member->get_type()); - f_gen_ << indent() << "if ret.is_none() {" << endl; + f_gen_ << indent() << "if ret.is_none() {" << '\n'; indent_up(); f_gen_ << indent() << "ret = Some(" << union_name << "::" << rust_union_field_name(member) - << "(val));" << endl; + << "(val));" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << indent() << "received_field_count += 1;" << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << indent() << "received_field_count += 1;" << '\n'; indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; } // default case (skip fields) - f_gen_ << indent() << "_ => {" << endl; + f_gen_ << indent() << "_ => {" << '\n'; indent_up(); - f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << endl; - f_gen_ << indent() << "received_field_count += 1;" << endl; + f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << '\n'; + f_gen_ << indent() << "received_field_count += 1;" << '\n'; indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; indent_down(); - f_gen_ << indent() << "};" << endl; // finish match - f_gen_ << indent() << "i_prot.read_field_end()?;" << endl; + f_gen_ << indent() << "};" << '\n'; // finish match + f_gen_ << indent() << "i_prot.read_field_end()?;" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; // finish loop - f_gen_ << indent() << "i_prot.read_struct_end()?;" << endl; // finish reading message from wire + f_gen_ << indent() << "}" << '\n'; // finish loop + f_gen_ << indent() << "i_prot.read_struct_end()?;" << '\n'; // finish reading message from wire // return the value or an error - f_gen_ << indent() << "if received_field_count == 0 {" << endl; + f_gen_ << indent() << "if received_field_count == 0 {" << '\n'; indent_up(); render_thrift_error("Protocol", "ProtocolError", "ProtocolErrorKind::InvalidData", "\"received empty union from remote " + union_name + "\""); indent_down(); - f_gen_ << indent() << "} else if received_field_count > 1 {" << endl; + f_gen_ << indent() << "} else if received_field_count > 1 {" << '\n'; indent_up(); render_thrift_error("Protocol", "ProtocolError", "ProtocolErrorKind::InvalidData", "\"received multiple fields for union from remote " + union_name + "\""); indent_down(); - f_gen_ << indent() << "} else {" << endl; + f_gen_ << indent() << "} else {" << '\n'; indent_up(); - f_gen_ << indent() << "Ok(ret.expect(\"return value should have been constructed\"))" << endl; + f_gen_ << indent() << "Ok(ret.expect(\"return value should have been constructed\"))" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } // Construct the rust representation of all supported types from the wire. @@ -1860,32 +1859,32 @@ void t_rs_generator::render_type_sync_read(const string& type_var, t_type* ttype throw "cannot read field of type TYPE_VOID from input protocol"; case t_base_type::TYPE_STRING: if (tbase_type->is_binary()) { - f_gen_ << indent() << "let " << type_var << " = i_prot.read_bytes()?;" << endl; + f_gen_ << indent() << "let " << type_var << " = i_prot.read_bytes()?;" << '\n'; } else { - f_gen_ << indent() << "let " << type_var << " = i_prot.read_string()?;" << endl; + f_gen_ << indent() << "let " << type_var << " = i_prot.read_string()?;" << '\n'; } return; case t_base_type::TYPE_UUID: - f_gen_ << indent() << "let " << type_var << " = i_prot.read_uuid()?;" << endl; + f_gen_ << indent() << "let " << type_var << " = i_prot.read_uuid()?;" << '\n'; return; case t_base_type::TYPE_BOOL: - f_gen_ << indent() << "let " << type_var << " = i_prot.read_bool()?;" << endl; + f_gen_ << indent() << "let " << type_var << " = i_prot.read_bool()?;" << '\n'; return; case t_base_type::TYPE_I8: - f_gen_ << indent() << "let " << type_var << " = i_prot.read_i8()?;" << endl; + f_gen_ << indent() << "let " << type_var << " = i_prot.read_i8()?;" << '\n'; return; case t_base_type::TYPE_I16: - f_gen_ << indent() << "let " << type_var << " = i_prot.read_i16()?;" << endl; + f_gen_ << indent() << "let " << type_var << " = i_prot.read_i16()?;" << '\n'; return; case t_base_type::TYPE_I32: - f_gen_ << indent() << "let " << type_var << " = i_prot.read_i32()?;" << endl; + f_gen_ << indent() << "let " << type_var << " = i_prot.read_i32()?;" << '\n'; return; case t_base_type::TYPE_I64: - f_gen_ << indent() << "let " << type_var << " = i_prot.read_i64()?;" << endl; + f_gen_ << indent() << "let " << type_var << " = i_prot.read_i64()?;" << '\n'; return; case t_base_type::TYPE_DOUBLE: f_gen_ << indent() << "let " << type_var << " = OrderedFloat::from(i_prot.read_double()?);" - << endl; + << '\n'; return; default: throw "compiler error: unhandled type"; @@ -1905,7 +1904,7 @@ void t_rs_generator::render_type_sync_read(const string& type_var, t_type* ttype } else if (ttype->is_enum() || ttype->is_struct() || ttype->is_xception()) { string read_call(to_rust_type(ttype) + "::read_from_in_protocol(i_prot)?"); read_call = is_boxed ? "Box::new(" + read_call + ")" : read_call; - f_gen_ << indent() << "let " << type_var << " = " << read_call << ";" << endl; + f_gen_ << indent() << "let " << type_var << " = " << read_call << ";" << '\n'; return; } else if (ttype->is_map()) { render_map_sync_read((t_map*)ttype, type_var); @@ -1925,42 +1924,42 @@ void t_rs_generator::render_type_sync_read(const string& type_var, t_type* ttype void t_rs_generator::render_list_sync_read(t_list* tlist, const string& list_var) { t_type* elem_type = tlist->get_elem_type(); - f_gen_ << indent() << "let list_ident = i_prot.read_list_begin()?;" << endl; + f_gen_ << indent() << "let list_ident = i_prot.read_list_begin()?;" << '\n'; f_gen_ << indent() << "let mut " << list_var << ": " << to_rust_type((t_type*)tlist) - << " = Vec::with_capacity(list_ident.size as usize);" << endl; - f_gen_ << indent() << "for _ in 0..list_ident.size {" << endl; + << " = Vec::with_capacity(list_ident.size as usize);" << '\n'; + f_gen_ << indent() << "for _ in 0..list_ident.size {" << '\n'; indent_up(); string list_elem_var = tmp("list_elem_"); render_type_sync_read(list_elem_var, elem_type); - f_gen_ << indent() << list_var << ".push(" << list_elem_var << ");" << endl; + f_gen_ << indent() << list_var << ".push(" << list_elem_var << ");" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << indent() << "i_prot.read_list_end()?;" << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << indent() << "i_prot.read_list_end()?;" << '\n'; } // Construct the rust representation of a set from the wire. void t_rs_generator::render_set_sync_read(t_set* tset, const string& set_var) { t_type* elem_type = tset->get_elem_type(); - f_gen_ << indent() << "let set_ident = i_prot.read_set_begin()?;" << endl; + f_gen_ << indent() << "let set_ident = i_prot.read_set_begin()?;" << '\n'; f_gen_ << indent() << "let mut " << set_var << ": " << to_rust_type((t_type*)tset) - << " = BTreeSet::new();" << endl; - f_gen_ << indent() << "for _ in 0..set_ident.size {" << endl; + << " = BTreeSet::new();" << '\n'; + f_gen_ << indent() << "for _ in 0..set_ident.size {" << '\n'; indent_up(); string set_elem_var = tmp("set_elem_"); render_type_sync_read(set_elem_var, elem_type); - f_gen_ << indent() << set_var << ".insert(" << set_elem_var << ");" << endl; + f_gen_ << indent() << set_var << ".insert(" << set_elem_var << ");" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << indent() << "i_prot.read_set_end()?;" << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << indent() << "i_prot.read_set_end()?;" << '\n'; } // Construct the rust representation of a map from the wire. @@ -1968,10 +1967,10 @@ void t_rs_generator::render_map_sync_read(t_map* tmap, const string& map_var) { t_type* key_type = tmap->get_key_type(); t_type* val_type = tmap->get_val_type(); - f_gen_ << indent() << "let map_ident = i_prot.read_map_begin()?;" << endl; + f_gen_ << indent() << "let map_ident = i_prot.read_map_begin()?;" << '\n'; f_gen_ << indent() << "let mut " << map_var << ": " << to_rust_type((t_type*)tmap) - << " = BTreeMap::new();" << endl; - f_gen_ << indent() << "for _ in 0..map_ident.size {" << endl; + << " = BTreeMap::new();" << '\n'; + f_gen_ << indent() << "for _ in 0..map_ident.size {" << '\n'; indent_up(); @@ -1980,12 +1979,12 @@ void t_rs_generator::render_map_sync_read(t_map* tmap, const string& map_var) { string val_elem_var = tmp("map_val_"); render_type_sync_read(val_elem_var, val_type); f_gen_ << indent() << map_var << ".insert(" << key_elem_var << ", " << val_elem_var << ");" - << endl; + << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << indent() << "i_prot.read_map_end()?;" << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << indent() << "i_prot.read_map_end()?;" << '\n'; } string t_rs_generator::struct_field_read_temp_variable(t_field* tfield) { @@ -2036,7 +2035,7 @@ void t_rs_generator::render_sync_client(t_service* tservice) { render_sync_client_definition_and_impl(client_impl_name); render_sync_client_tthriftclient_impl(client_impl_name); render_sync_client_marker_trait_impls(tservice, client_impl_name); - f_gen_ << endl; + f_gen_ << '\n'; render_sync_client_process_impl(tservice); } @@ -2048,7 +2047,7 @@ void t_rs_generator::render_sync_client_trait(t_service* tservice) { } render_rustdoc((t_doc*)tservice); - f_gen_ << "pub trait " << rust_sync_client_trait_name(tservice) << extension << " {" << endl; + f_gen_ << "pub trait " << rust_sync_client_trait_name(tservice) << extension << " {" << '\n'; indent_up(); const std::vector functions = tservice->get_functions(); @@ -2060,25 +2059,25 @@ void t_rs_generator::render_sync_client_trait(t_service* tservice) { string func_return = to_rust_type(tfunc->get_returntype()); render_rustdoc((t_doc*)tfunc); f_gen_ << indent() << "fn " << func_name << func_args << " -> thrift::Result<" << func_return - << ">;" << endl; + << ">;" << '\n'; } indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_sync_client_marker_trait(t_service* tservice) { f_gen_ << indent() << "pub trait " << rust_sync_client_marker_trait_name(tservice) << " {}" - << endl; - f_gen_ << endl; + << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_sync_client_marker_trait_impls(t_service* tservice, const string& impl_struct_name) { f_gen_ << indent() << "impl " << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << rust_namespace(tservice) << rust_sync_client_marker_trait_name(tservice) << " for " << impl_struct_name - << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS << " {}" << endl; + << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS << " {}" << '\n'; t_service* extends = tservice->get_extends(); if (extends) { @@ -2090,64 +2089,64 @@ void t_rs_generator::render_sync_client_definition_and_impl(const string& client // render the definition for the client struct f_gen_ << "pub struct " << client_impl_name << SYNC_CLIENT_GENERIC_BOUND_VARS << " " - << SYNC_CLIENT_GENERIC_BOUNDS << " {" << endl; + << SYNC_CLIENT_GENERIC_BOUNDS << " {" << '\n'; indent_up(); - f_gen_ << indent() << "_i_prot: IP," << endl; - f_gen_ << indent() << "_o_prot: OP," << endl; - f_gen_ << indent() << "_sequence_number: i32," << endl; + f_gen_ << indent() << "_i_prot: IP," << '\n'; + f_gen_ << indent() << "_o_prot: OP," << '\n'; + f_gen_ << indent() << "_sequence_number: i32," << '\n'; indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; // render the struct implementation // this includes the new() function as well as the helper send/recv methods for each service call f_gen_ << "impl " << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << client_impl_name - << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS << " {" << endl; + << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS << " {" << '\n'; indent_up(); render_sync_client_lifecycle_functions(client_impl_name); indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_sync_client_lifecycle_functions(const string& client_struct) { f_gen_ << indent() << "pub fn new(input_protocol: IP, output_protocol: OP) -> " << client_struct - << SYNC_CLIENT_GENERIC_BOUND_VARS << " {" << endl; + << SYNC_CLIENT_GENERIC_BOUND_VARS << " {" << '\n'; indent_up(); f_gen_ << indent() << client_struct - << " { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }" << endl; + << " { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } void t_rs_generator::render_sync_client_tthriftclient_impl(const string& client_impl_name) { f_gen_ << indent() << "impl " << SYNC_CLIENT_GENERIC_BOUND_VARS << " TThriftClient for " << client_impl_name << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS - << " {" << endl; + << " {" << '\n'; indent_up(); f_gen_ << indent() << "fn i_prot_mut(&mut self) -> &mut dyn TInputProtocol { &mut self._i_prot }" - << endl; + << '\n'; f_gen_ << indent() << "fn o_prot_mut(&mut self) -> &mut dyn TOutputProtocol { &mut self._o_prot }" - << endl; - f_gen_ << indent() << "fn sequence_number(&self) -> i32 { self._sequence_number }" << endl; + << '\n'; + f_gen_ << indent() << "fn sequence_number(&self) -> i32 { self._sequence_number }" << '\n'; f_gen_ << indent() << "fn increment_sequence_number(&mut self) -> i32 { self._sequence_number += 1; " "self._sequence_number }" - << endl; + << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_sync_client_process_impl(t_service* tservice) { string marker_extension = "" + sync_client_marker_traits_for_extension(tservice); f_gen_ << "impl " << rust_sync_client_trait_name(tservice) << " for C {" << endl; + << marker_extension << "> " << rust_sync_client_trait_name(tservice) << " for C {" << '\n'; indent_up(); const std::vector functions = tservice->get_functions(); @@ -2158,8 +2157,8 @@ void t_rs_generator::render_sync_client_process_impl(t_service* tservice) { } indent_down(); - f_gen_ << "}" << endl; - f_gen_ << endl; + f_gen_ << "}" << '\n'; + f_gen_ << '\n'; } string t_rs_generator::sync_client_marker_traits_for_extension(t_service* tservice) { @@ -2182,35 +2181,35 @@ void t_rs_generator::render_sync_send_recv_wrapper(t_function* tfunc) { string func_return = to_rust_type(tfunc->get_returntype()); f_gen_ << indent() << "fn " << func_name << func_decl_args << " -> thrift::Result<" << func_return - << "> {" << endl; + << "> {" << '\n'; indent_up(); - f_gen_ << indent() << "(" << endl; + f_gen_ << indent() << "(" << '\n'; indent_up(); render_sync_send(tfunc); indent_down(); - f_gen_ << indent() << ")?;" << endl; + f_gen_ << indent() << ")?;" << '\n'; if (tfunc->is_oneway()) { - f_gen_ << indent() << "Ok(())" << endl; + f_gen_ << indent() << "Ok(())" << '\n'; } else { render_sync_recv(tfunc); } indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } void t_rs_generator::render_sync_send(t_function* tfunc) { - f_gen_ << indent() << "{" << endl; + f_gen_ << indent() << "{" << '\n'; indent_up(); // increment the sequence number and generate the call header string message_type = tfunc->is_oneway() ? "TMessageType::OneWay" : "TMessageType::Call"; - f_gen_ << indent() << "self.increment_sequence_number();" << endl; + f_gen_ << indent() << "self.increment_sequence_number();" << '\n'; f_gen_ << indent() << "let message_ident = " << "TMessageIdentifier::new(\"" << tfunc->get_name() << "\", " // note: use *original* name << message_type << ", " - << "self.sequence_number());" << endl; + << "self.sequence_number());" << '\n'; // pack the arguments into the containing struct that we'll write out over the wire // note that this struct is generated even if we have 0 args ostringstream struct_definition; @@ -2226,50 +2225,50 @@ void t_rs_generator::render_sync_send(t_function* tfunc) { struct_fields = struct_fields.substr(0, struct_fields.size() - 2); // strip trailing comma } f_gen_ << indent() << "let call_args = " << service_call_args_struct_name(tfunc) << " { " - << struct_fields << " };" << endl; + << struct_fields << " };" << '\n'; // write everything over the wire - f_gen_ << indent() << "self.o_prot_mut().write_message_begin(&message_ident)?;" << endl; + f_gen_ << indent() << "self.o_prot_mut().write_message_begin(&message_ident)?;" << '\n'; f_gen_ << indent() << "call_args.write_to_out_protocol(self.o_prot_mut())?;" - << endl; // written even if we have 0 args - f_gen_ << indent() << "self.o_prot_mut().write_message_end()?;" << endl; - f_gen_ << indent() << "self.o_prot_mut().flush()" << endl; + << '\n'; // written even if we have 0 args + f_gen_ << indent() << "self.o_prot_mut().write_message_end()?;" << '\n'; + f_gen_ << indent() << "self.o_prot_mut().flush()" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } void t_rs_generator::render_sync_recv(t_function* tfunc) { - f_gen_ << indent() << "{" << endl; + f_gen_ << indent() << "{" << '\n'; indent_up(); - f_gen_ << indent() << "let message_ident = self.i_prot_mut().read_message_begin()?;" << endl; + f_gen_ << indent() << "let message_ident = self.i_prot_mut().read_message_begin()?;" << '\n'; f_gen_ << indent() << "verify_expected_sequence_number(self.sequence_number(), message_ident.sequence_number)?;" - << endl; + << '\n'; f_gen_ << indent() << "verify_expected_service_call(\"" << tfunc->get_name() - << "\", &message_ident.name)?;" << endl; // note: use *original* name + << "\", &message_ident.name)?;" << '\n'; // note: use *original* name // FIXME: replace with a "try" block - f_gen_ << indent() << "if message_ident.message_type == TMessageType::Exception {" << endl; + f_gen_ << indent() << "if message_ident.message_type == TMessageType::Exception {" << '\n'; indent_up(); f_gen_ << indent() << "let remote_error = " "thrift::Error::read_application_error_from_in_protocol(self.i_prot_mut())?;" - << endl; - f_gen_ << indent() << "self.i_prot_mut().read_message_end()?;" << endl; - f_gen_ << indent() << "return Err(thrift::Error::Application(remote_error))" << endl; + << '\n'; + f_gen_ << indent() << "self.i_prot_mut().read_message_end()?;" << '\n'; + f_gen_ << indent() << "return Err(thrift::Error::Application(remote_error))" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; f_gen_ << indent() << "verify_expected_message_type(TMessageType::Reply, message_ident.message_type)?;" - << endl; + << '\n'; f_gen_ << indent() << "let result = " << service_call_result_struct_name(tfunc) - << "::read_from_in_protocol(self.i_prot_mut())?;" << endl; - f_gen_ << indent() << "self.i_prot_mut().read_message_end()?;" << endl; - f_gen_ << indent() << "result.ok_or()" << endl; + << "::read_from_in_protocol(self.i_prot_mut())?;" << '\n'; + f_gen_ << indent() << "self.i_prot_mut().read_message_end()?;" << '\n'; + f_gen_ << indent() << "result.ok_or()" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } string t_rs_generator::rust_sync_service_call_declaration(t_function* tfunc, bool self_is_mutable) { @@ -2400,7 +2399,7 @@ void t_rs_generator::render_sync_handler_trait(t_service* tservice) { std::vector::const_iterator func_iter; render_rustdoc((t_doc*)tservice); - f_gen_ << "pub trait " << rust_sync_handler_trait_name(tservice) << extension << " {" << endl; + f_gen_ << "pub trait " << rust_sync_handler_trait_name(tservice) << extension << " {" << '\n'; indent_up(); for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { t_function* tfunc = (*func_iter); @@ -2409,11 +2408,11 @@ void t_rs_generator::render_sync_handler_trait(t_service* tservice) { string func_return = to_rust_type(tfunc->get_returntype()); render_rustdoc((t_doc*)tfunc); f_gen_ << indent() << "fn " << func_name << func_args << " -> thrift::Result<" << func_return - << ">;" << endl; + << ">;" << '\n'; } indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_sync_processor_definition_and_impl(t_service* tservice) { @@ -2422,36 +2421,36 @@ void t_rs_generator::render_sync_processor_definition_and_impl(t_service* tservi // struct f_gen_ << indent() << "pub struct " << service_processor_name << " {" << endl; + << "> {" << '\n'; indent_up(); - f_gen_ << indent() << "handler: H," << endl; + f_gen_ << indent() << "handler: H," << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << '\n'; // delegating impl f_gen_ << indent() << "impl " << service_processor_name - << " {" << endl; + << " {" << '\n'; indent_up(); - f_gen_ << indent() << "pub fn new(handler: H) -> " << service_processor_name << " {" << endl; + f_gen_ << indent() << "pub fn new(handler: H) -> " << service_processor_name << " {" << '\n'; indent_up(); - f_gen_ << indent() << service_processor_name << " {" << endl; + f_gen_ << indent() << service_processor_name << " {" << '\n'; indent_up(); - f_gen_ << indent() << "handler," << endl; + f_gen_ << indent() << "handler," << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; render_sync_process_delegation_functions(tservice); indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << '\n'; // actual impl string service_actual_processor_name = rust_sync_processor_impl_name(tservice); - f_gen_ << indent() << "pub struct " << service_actual_processor_name << ";" << endl; - f_gen_ << endl; - f_gen_ << indent() << "impl " << service_actual_processor_name << " {" << endl; + f_gen_ << indent() << "pub struct " << service_actual_processor_name << ";" << '\n'; + f_gen_ << '\n'; + f_gen_ << indent() << "impl " << service_actual_processor_name << " {" << '\n'; indent_up(); vector functions = tservice->get_functions(); @@ -2462,44 +2461,44 @@ void t_rs_generator::render_sync_processor_definition_and_impl(t_service* tservi } indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << '\n'; // processor impl f_gen_ << indent() << "impl TProcessor for " - << service_processor_name << " {" << endl; + << service_processor_name << " {" << '\n'; indent_up(); f_gen_ << indent() << "fn process(&self, i_prot: &mut dyn TInputProtocol, o_prot: &mut dyn TOutputProtocol) " "-> thrift::Result<()> {" - << endl; + << '\n'; indent_up(); - f_gen_ << indent() << "let message_ident = i_prot.read_message_begin()?;" << endl; + f_gen_ << indent() << "let message_ident = i_prot.read_message_begin()?;" << '\n'; f_gen_ << indent() << "let res = match &*message_ident.name {" - << endl; // [sigh] explicit deref coercion + << '\n'; // [sigh] explicit deref coercion indent_up(); render_process_match_statements(tservice); - f_gen_ << indent() << "method => {" << endl; + f_gen_ << indent() << "method => {" << '\n'; indent_up(); render_thrift_error("Application", "ApplicationError", "ApplicationErrorKind::UnknownMethod", "format!(\"unknown method {}\", method)"); indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; indent_down(); - f_gen_ << indent() << "};" << endl; + f_gen_ << indent() << "};" << '\n'; f_gen_ << indent() << "thrift::server::handle_process_result(&message_ident, res, o_prot)" - << endl; + << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; - f_gen_ << endl; + f_gen_ << indent() << "}" << '\n'; + f_gen_ << '\n'; } void t_rs_generator::render_sync_process_delegation_functions(t_service* tservice) { @@ -2514,7 +2513,7 @@ void t_rs_generator::render_sync_process_delegation_functions(t_service* tservic << "incoming_sequence_number: i32, " << "i_prot: &mut dyn TInputProtocol, " << "o_prot: &mut dyn TOutputProtocol) " - << "-> thrift::Result<()> {" << endl; + << "-> thrift::Result<()> {" << '\n'; indent_up(); f_gen_ << indent() << actual_processor << "::" << function_name << "(" @@ -2522,10 +2521,10 @@ void t_rs_generator::render_sync_process_delegation_functions(t_service* tservic << "incoming_sequence_number, " << "i_prot, " << "o_prot" - << ")" << endl; + << ")" << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } t_service* extends = tservice->get_extends(); @@ -2540,12 +2539,12 @@ void t_rs_generator::render_process_match_statements(t_service* tservice) { for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) { t_function* tfunc = (*func_iter); f_gen_ << indent() << "\"" << tfunc->get_name() << "\"" - << " => {" << endl; // note: use *original* name + << " => {" << '\n'; // note: use *original* name indent_up(); f_gen_ << indent() << "self.process_" << rust_snake_case(tfunc->get_name()) - << "(message_ident.sequence_number, i_prot, o_prot)" << endl; + << "(message_ident.sequence_number, i_prot, o_prot)" << '\n'; indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; } t_service* extends = tservice->get_extends(); @@ -2568,90 +2567,90 @@ void t_rs_generator::render_sync_process_function(t_function* tfunc, const strin << "(handler: &H, " << sequence_number_param << ": i32, " << "i_prot: &mut dyn TInputProtocol, " << output_protocol_param << ": &mut dyn TOutputProtocol) " - << "-> thrift::Result<()> {" << endl; + << "-> thrift::Result<()> {" << '\n'; indent_up(); // *always* read arguments from the input protocol f_gen_ << indent() << "let " << (has_non_void_args(tfunc) ? "args" : "_") << " = " - << service_call_args_struct_name(tfunc) << "::read_from_in_protocol(i_prot)?;" << endl; + << service_call_args_struct_name(tfunc) << "::read_from_in_protocol(i_prot)?;" << '\n'; f_gen_ << indent() << "match handler." << service_call_handler_function_name(tfunc) - << rust_sync_service_call_invocation(tfunc, "args.") << " {" << endl; // start match + << rust_sync_service_call_invocation(tfunc, "args.") << " {" << '\n'; // start match indent_up(); // handler succeeded string handler_return_variable = tfunc->is_oneway() || tfunc->get_returntype()->is_void() ? "_" : "handler_return"; - f_gen_ << indent() << "Ok(" << handler_return_variable << ") => {" << endl; + f_gen_ << indent() << "Ok(" << handler_return_variable << ") => {" << '\n'; indent_up(); render_sync_handler_succeeded(tfunc); indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; // handler failed - f_gen_ << indent() << "Err(e) => {" << endl; + f_gen_ << indent() << "Err(e) => {" << '\n'; indent_up(); render_sync_handler_failed(tfunc); indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; // end match + f_gen_ << indent() << "}" << '\n'; // end match indent_down(); - f_gen_ << indent() << "}" << endl; // end function + f_gen_ << indent() << "}" << '\n'; // end function } void t_rs_generator::render_sync_handler_succeeded(t_function* tfunc) { if (tfunc->is_oneway()) { - f_gen_ << indent() << "Ok(())" << endl; + f_gen_ << indent() << "Ok(())" << '\n'; } else { f_gen_ << indent() << "let message_ident = TMessageIdentifier::new(" << "\"" << tfunc->get_name() << "\", " // note: use *original* name << "TMessageType::Reply, " - << "incoming_sequence_number);" << endl; - f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << endl; - f_gen_ << indent() << "let ret = " << handler_successful_return_struct(tfunc) << ";" << endl; - f_gen_ << indent() << "ret.write_to_out_protocol(o_prot)?;" << endl; - f_gen_ << indent() << "o_prot.write_message_end()?;" << endl; - f_gen_ << indent() << "o_prot.flush()" << endl; + << "incoming_sequence_number);" << '\n'; + f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << '\n'; + f_gen_ << indent() << "let ret = " << handler_successful_return_struct(tfunc) << ";" << '\n'; + f_gen_ << indent() << "ret.write_to_out_protocol(o_prot)?;" << '\n'; + f_gen_ << indent() << "o_prot.write_message_end()?;" << '\n'; + f_gen_ << indent() << "o_prot.flush()" << '\n'; } } void t_rs_generator::render_sync_handler_failed(t_function* tfunc) { string err_var("e"); - f_gen_ << indent() << "match " << err_var << " {" << endl; + f_gen_ << indent() << "match " << err_var << " {" << '\n'; indent_up(); // if there are any user-defined exceptions for this service call handle them first if (tfunc->get_xceptions() != nullptr && tfunc->get_xceptions()->get_sorted_members().size() > 0) { string user_err_var("usr_err"); - f_gen_ << indent() << "thrift::Error::User(" << user_err_var << ") => {" << endl; + f_gen_ << indent() << "thrift::Error::User(" << user_err_var << ") => {" << '\n'; indent_up(); render_sync_handler_failed_user_exception_branch(tfunc); indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; } // application error string app_err_var("app_err"); - f_gen_ << indent() << "thrift::Error::Application(" << app_err_var << ") => {" << endl; + f_gen_ << indent() << "thrift::Error::Application(" << app_err_var << ") => {" << '\n'; indent_up(); render_sync_handler_failed_application_exception_branch(tfunc, app_err_var); indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; // default case - f_gen_ << indent() << "_ => {" << endl; + f_gen_ << indent() << "_ => {" << '\n'; indent_up(); render_sync_handler_failed_default_exception_branch(tfunc); indent_down(); - f_gen_ << indent() << "}," << endl; + f_gen_ << indent() << "}," << '\n'; indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function* tfunc) { @@ -2670,11 +2669,11 @@ void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function string if_statement(branches_rendered == 0 ? "if usr_err" : "} else if usr_err"); string exception_type(to_rust_type(xception_field->get_type())); f_gen_ << indent() << if_statement << ".downcast_ref::<" << exception_type << ">().is_some() {" - << endl; + << '\n'; indent_up(); f_gen_ << indent() << "let err = usr_err.downcast::<" << exception_type - << ">().expect(\"downcast already checked\");" << endl; + << ">().expect(\"downcast already checked\");" << '\n'; // render the members of the return struct ostringstream members; @@ -2701,17 +2700,17 @@ void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function // now write out the return struct f_gen_ << indent() << "let ret_err = " << service_call_result_struct_name(tfunc) << "{ " - << member_string << "};" << endl; + << member_string << "};" << '\n'; f_gen_ << indent() << "let message_ident = " << "TMessageIdentifier::new(" << "\"" << tfunc->get_name() << "\", " // note: use *original* name << "TMessageType::Reply, " - << "incoming_sequence_number);" << endl; - f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << endl; - f_gen_ << indent() << "ret_err.write_to_out_protocol(o_prot)?;" << endl; - f_gen_ << indent() << "o_prot.write_message_end()?;" << endl; - f_gen_ << indent() << "o_prot.flush()" << endl; + << "incoming_sequence_number);" << '\n'; + f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << '\n'; + f_gen_ << indent() << "ret_err.write_to_out_protocol(o_prot)?;" << '\n'; + f_gen_ << indent() << "o_prot.write_message_end()?;" << '\n'; + f_gen_ << indent() << "o_prot.flush()" << '\n'; indent_down(); @@ -2719,41 +2718,41 @@ void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function } // the catch all, if somehow it was a user exception that we don't support - f_gen_ << indent() << "} else {" << endl; + f_gen_ << indent() << "} else {" << '\n'; indent_up(); // FIXME: same as default block below - f_gen_ << indent() << "let ret_err = {" << endl; + f_gen_ << indent() << "let ret_err = {" << '\n'; indent_up(); render_thrift_error_struct("ApplicationError", "ApplicationErrorKind::Unknown", "usr_err.to_string()"); indent_down(); - f_gen_ << indent() << "};" << endl; + f_gen_ << indent() << "};" << '\n'; render_sync_handler_send_exception_response(tfunc, "ret_err"); indent_down(); - f_gen_ << indent() << "}" << endl; + f_gen_ << indent() << "}" << '\n'; } void t_rs_generator::render_sync_handler_failed_application_exception_branch( t_function* tfunc, const string& app_err_var) { if (tfunc->is_oneway()) { - f_gen_ << indent() << "Err(thrift::Error::Application(" << app_err_var << "))" << endl; + f_gen_ << indent() << "Err(thrift::Error::Application(" << app_err_var << "))" << '\n'; } else { render_sync_handler_send_exception_response(tfunc, app_err_var); } } void t_rs_generator::render_sync_handler_failed_default_exception_branch(t_function* tfunc) { - f_gen_ << indent() << "let ret_err = {" << endl; + f_gen_ << indent() << "let ret_err = {" << '\n'; indent_up(); render_thrift_error_struct("ApplicationError", "ApplicationErrorKind::Unknown", "e.to_string()"); indent_down(); - f_gen_ << indent() << "};" << endl; + f_gen_ << indent() << "};" << '\n'; if (tfunc->is_oneway()) { - f_gen_ << indent() << "Err(thrift::Error::Application(ret_err))" << endl; + f_gen_ << indent() << "Err(thrift::Error::Application(ret_err))" << '\n'; } else { render_sync_handler_send_exception_response(tfunc, "ret_err"); } @@ -2764,12 +2763,12 @@ void t_rs_generator::render_sync_handler_send_exception_response(t_function* tfu f_gen_ << indent() << "let message_ident = TMessageIdentifier::new(" << "\"" << tfunc->get_name() << "\", " // note: use *original* name << "TMessageType::Exception, " - << "incoming_sequence_number);" << endl; - f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << endl; + << "incoming_sequence_number);" << '\n'; + f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << '\n'; f_gen_ << indent() << "thrift::Error::write_application_error_to_out_protocol(&" << err_var - << ", o_prot)?;" << endl; - f_gen_ << indent() << "o_prot.write_message_end()?;" << endl; - f_gen_ << indent() << "o_prot.flush()" << endl; + << ", o_prot)?;" << '\n'; + f_gen_ << indent() << "o_prot.write_message_end()?;" << '\n'; + f_gen_ << indent() << "o_prot.flush()" << '\n'; } string t_rs_generator::handler_successful_return_struct(t_function* tfunc) { @@ -2811,10 +2810,10 @@ string t_rs_generator::handler_successful_return_struct(t_function* tfunc) { //----------------------------------------------------------------------------- void t_rs_generator::render_type_comment(const string& type_name) { - f_gen_ << "//" << endl; - f_gen_ << "// " << type_name << endl; - f_gen_ << "//" << endl; - f_gen_ << endl; + f_gen_ << "//" << '\n'; + f_gen_ << "// " << type_name << '\n'; + f_gen_ << "//" << '\n'; + f_gen_ << '\n'; } // NOTE: do *not* put in an extra newline after doc is generated. @@ -2831,26 +2830,26 @@ void t_rs_generator::render_thrift_error(const string& error_kind, const string& error_struct, const string& sub_error_kind, const string& error_message) { - f_gen_ << indent() << "Err(" << endl; + f_gen_ << indent() << "Err(" << '\n'; indent_up(); - f_gen_ << indent() << "thrift::Error::" << error_kind << "(" << endl; + f_gen_ << indent() << "thrift::Error::" << error_kind << "(" << '\n'; indent_up(); render_thrift_error_struct(error_struct, sub_error_kind, error_message); indent_down(); - f_gen_ << indent() << ")" << endl; + f_gen_ << indent() << ")" << '\n'; indent_down(); - f_gen_ << indent() << ")" << endl; + f_gen_ << indent() << ")" << '\n'; } void t_rs_generator::render_thrift_error_struct(const string& error_struct, const string& sub_error_kind, const string& error_message) { - f_gen_ << indent() << error_struct << "::new(" << endl; + f_gen_ << indent() << error_struct << "::new(" << '\n'; indent_up(); - f_gen_ << indent() << sub_error_kind << "," << endl; - f_gen_ << indent() << error_message << endl; + f_gen_ << indent() << sub_error_kind << "," << '\n'; + f_gen_ << indent() << error_message << '\n'; indent_down(); - f_gen_ << indent() << ")" << endl; + f_gen_ << indent() << ")" << '\n'; } bool t_rs_generator::is_double(t_type* ttype) { diff --git a/compiler/cpp/src/thrift/generate/t_st_generator.cc b/compiler/cpp/src/thrift/generate/t_st_generator.cc index b1411867124..c1ad35577e8 100644 --- a/compiler/cpp/src/thrift/generate/t_st_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_st_generator.cc @@ -43,8 +43,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * Smalltalk code generator. * @@ -177,7 +175,7 @@ void t_st_generator::init_generator() { f_.open(f_name.c_str()); // Print header - f_ << st_autogen_comment() << endl; + f_ << st_autogen_comment() << '\n'; st_class_def(f_, program_name_); generate_class_side_definition(); @@ -219,10 +217,10 @@ string t_st_generator::st_autogen_comment() { void t_st_generator::generate_force_consts() { f_ << prefix(class_name()) << " enums keysAndValuesDo: [:k :v | " << prefix(class_name()) - << " enums at: k put: v value].!" << endl; + << " enums at: k put: v value].!" << '\n'; f_ << prefix(class_name()) << " constants keysAndValuesDo: [:k :v | " << prefix(class_name()) - << " constants at: k put: v value].!" << endl; + << " constants at: k put: v value].!" << '\n'; } void t_st_generator::close_generator() { @@ -252,11 +250,11 @@ void t_st_generator::generate_typedef(t_typedef* ttypedef) { } void t_st_generator::st_class_def(std::ostream& out, string name) { - out << "Object subclass: #" << prefix(name) << endl; + out << "Object subclass: #" << prefix(name) << '\n'; indent_up(); - out << indent() << "instanceVariableNames: ''" << endl << indent() << "classVariableNames: ''" - << endl << indent() << "poolDictionaries: ''" << endl << indent() << "category: '" - << generated_category() << "'!" << endl << endl; + out << indent() << "instanceVariableNames: ''" << '\n' << indent() << "classVariableNames: ''" + << '\n' << indent() << "poolDictionaries: ''" << '\n' << indent() << "category: '" + << generated_category() << "'!" << '\n' << '\n'; } void t_st_generator::st_method(std::ostream& out, string cls, string name) { @@ -281,14 +279,14 @@ void t_st_generator::st_method(std::ostream& out, string cls, string name, strin strftime(timestr, 50, "%m/%d/%Y %H:%M", tinfo); out << "!" << prefix(cls) << " methodsFor: '" + category + "' stamp: 'thrift " << timestr - << "'!\n" << name << endl; + << "'!\n" << name << '\n'; indent_up(); out << indent(); } void t_st_generator::st_close_method(std::ostream& out) { - out << "! !" << endl << endl; + out << "! !" << '\n' << '\n'; indent_down(); } @@ -316,16 +314,16 @@ void t_st_generator::st_accessors(std::ostream& out, } void t_st_generator::generate_class_side_definition() { - f_ << prefix(class_name()) << " class" << endl << "\tinstanceVariableNames: 'constants enums'!" - << endl << endl; + f_ << prefix(class_name()) << " class" << '\n' << "\tinstanceVariableNames: 'constants enums'!" + << '\n' << '\n'; st_accessors(f_, class_name() + " class", "enums"); st_accessors(f_, class_name() + " class", "constants"); - f_ << prefix(class_name()) << " enums: Dictionary new!" << endl; - f_ << prefix(class_name()) << " constants: Dictionary new!" << endl; + f_ << prefix(class_name()) << " enums: Dictionary new!" << '\n'; + f_ << prefix(class_name()) << " constants: Dictionary new!" << '\n'; - f_ << endl; + f_ << '\n'; } /** @@ -338,16 +336,16 @@ void t_st_generator::generate_enum(t_enum* tenum) { string cls_name = program_name_ + capitalize(tenum->get_name()); f_ << prefix(class_name()) << " enums at: '" << tenum->get_name() << "' put: [" - << "(Dictionary new " << endl; + << "(Dictionary new " << '\n'; vector constants = tenum->get_constants(); vector::iterator c_iter; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { int value = (*c_iter)->get_value(); - f_ << "\tat: '" << (*c_iter)->get_name() << "' put: " << value << ";" << endl; + f_ << "\tat: '" << (*c_iter)->get_name() << "' put: " << value << ";" << '\n'; } - f_ << "\tyourself)]!" << endl << endl; + f_ << "\tyourself)]!" << '\n' << '\n'; } /** @@ -359,7 +357,7 @@ void t_st_generator::generate_const(t_const* tconst) { t_const_value* value = tconst->get_value(); f_ << prefix(class_name()) << " constants at: '" << name << "' put: [" - << render_const_value(type, value) << "]!" << endl << endl; + << render_const_value(type, value) << "]!" << '\n' << '\n'; } /** @@ -398,7 +396,7 @@ string t_st_generator::render_const_value(t_type* type, t_const_value* value) { } else if (type->is_enum()) { indent(out) << value->get_integer(); } else if (type->is_struct() || type->is_xception()) { - out << "(" << capitalize(type->get_name()) << " new " << endl; + out << "(" << capitalize(type->get_name()) << " new " << '\n'; indent_up(); const vector& fields = ((t_struct*)type)->get_members(); @@ -418,7 +416,7 @@ string t_st_generator::render_const_value(t_type* type, t_const_value* value) { } out << indent() << v_iter->first->get_string() << ": " - << render_const_value(field_type, v_iter->second) << ";" << endl; + << render_const_value(field_type, v_iter->second) << ";" << '\n'; } out << indent() << "yourself)"; @@ -426,7 +424,7 @@ string t_st_generator::render_const_value(t_type* type, t_const_value* value) { } else if (type->is_map()) { t_type* ktype = ((t_map*)type)->get_key_type(); t_type* vtype = ((t_map*)type)->get_val_type(); - out << "(Dictionary new" << endl; + out << "(Dictionary new" << '\n'; indent_up(); indent_up(); const map& val = value->get_map(); @@ -436,7 +434,7 @@ string t_st_generator::render_const_value(t_type* type, t_const_value* value) { out << "at: " << render_const_value(ktype, v_iter->first); out << " put: "; out << render_const_value(vtype, v_iter->second); - out << ";" << endl; + out << ";" << '\n'; } out << indent() << indent() << "yourself)"; indent_down(); @@ -449,9 +447,9 @@ string t_st_generator::render_const_value(t_type* type, t_const_value* value) { etype = ((t_set*)type)->get_elem_type(); } if (type->is_set()) { - out << "(Set new" << endl; + out << "(Set new" << '\n'; } else { - out << "(OrderedCollection new" << endl; + out << "(OrderedCollection new" << '\n'; } indent_up(); indent_up(); @@ -460,7 +458,7 @@ string t_st_generator::render_const_value(t_type* type, t_const_value* value) { for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) { out << indent() << indent(); out << "add: " << render_const_value(etype, *v_iter); - out << ";" << endl; + out << ";" << '\n'; } out << indent() << indent() << "yourself)"; indent_down(); @@ -502,7 +500,7 @@ void t_st_generator::generate_st_struct(std::ostream& out, else out << "Object"; - out << " subclass: #" << prefix(type_name(tstruct)) << endl << "\tinstanceVariableNames: '"; + out << " subclass: #" << prefix(type_name(tstruct)) << '\n' << "\tinstanceVariableNames: '"; if (members.size() > 0) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -556,7 +554,7 @@ void t_st_generator::generate_accessors(std::ostream& out, t_struct* tstruct) { camelcase((*m_iter)->get_name()), a_type((*m_iter)->get_type())); } - out << endl; + out << '\n'; } } @@ -583,17 +581,17 @@ string t_st_generator::map_writer(t_map* tmap, string fname) { out << "[oprot writeMapBegin: (TMap new keyType: " << type_to_enum(tmap->get_key_type()) << "; valueType: " << type_to_enum(tmap->get_val_type()) << "; size: " << fname << " size)." - << endl; + << '\n'; indent_up(); - out << indent() << fname << " keysAndValuesDo: [:" << key << " :" << val << " |" << endl; + out << indent() << fname << " keysAndValuesDo: [:" << key << " :" << val << " |" << '\n'; indent_up(); - out << indent() << write_val(tmap->get_key_type(), key) << "." << endl << indent() + out << indent() << write_val(tmap->get_key_type(), key) << "." << '\n' << indent() << write_val(tmap->get_val_type(), val); indent_down(); - out << "]." << endl << indent() << "oprot writeMapEnd] value"; + out << "]." << '\n' << indent() << "oprot writeMapEnd] value"; indent_down(); return out.str(); @@ -604,18 +602,18 @@ string t_st_generator::map_reader(t_map* tmap) { string desc = temp_name(); string val = temp_name(); - out << "[|" << desc << " " << val << "| " << endl; + out << "[|" << desc << " " << val << "| " << '\n'; indent_up(); - out << indent() << desc << " := iprot readMapBegin." << endl << indent() << val - << " := Dictionary new." << endl << indent() << desc << " size timesRepeat: [" << endl; + out << indent() << desc << " := iprot readMapBegin." << '\n' << indent() << val + << " := Dictionary new." << '\n' << indent() << desc << " size timesRepeat: [" << '\n'; indent_up(); out << indent() << val << " at: " << read_val(tmap->get_key_type()) << " put: " << read_val(tmap->get_val_type()); indent_down(); - out << "]." << endl << indent() << "iprot readMapEnd." << endl << indent() << val << "] value"; + out << "]." << '\n' << indent() << "iprot readMapEnd." << '\n' << indent() << val << "] value"; indent_down(); return out.str(); @@ -626,16 +624,16 @@ string t_st_generator::list_writer(t_list* tlist, string fname) { string val = temp_name(); out << "[oprot writeListBegin: (TList new elemType: " << type_to_enum(tlist->get_elem_type()) - << "; size: " << fname << " size)." << endl; + << "; size: " << fname << " size)." << '\n'; indent_up(); - out << indent() << fname << " do: [:" << val << "|" << endl; + out << indent() << fname << " do: [:" << val << "|" << '\n'; indent_up(); - out << indent() << write_val(tlist->get_elem_type(), val) << endl; + out << indent() << write_val(tlist->get_elem_type(), val) << '\n'; indent_down(); - out << "]." << endl << indent() << "oprot writeListEnd] value"; + out << "]." << '\n' << indent() << "oprot writeListEnd] value"; indent_down(); return out.str(); @@ -646,17 +644,17 @@ string t_st_generator::list_reader(t_list* tlist) { string desc = temp_name(); string val = temp_name(); - out << "[|" << desc << " " << val << "| " << desc << " := iprot readListBegin." << endl; + out << "[|" << desc << " " << val << "| " << desc << " := iprot readListBegin." << '\n'; indent_up(); - out << indent() << val << " := OrderedCollection new." << endl << indent() << desc - << " size timesRepeat: [" << endl; + out << indent() << val << " := OrderedCollection new." << '\n' << indent() << desc + << " size timesRepeat: [" << '\n'; indent_up(); out << indent() << val << " add: " << read_val(tlist->get_elem_type()); indent_down(); - out << "]." << endl << indent() << "iprot readListEnd." << endl << indent() << val << "] value"; + out << "]." << '\n' << indent() << "iprot readListEnd." << '\n' << indent() << val << "] value"; indent_down(); return out.str(); @@ -667,16 +665,16 @@ string t_st_generator::set_writer(t_set* tset, string fname) { string val = temp_name(); out << "[oprot writeSetBegin: (TSet new elemType: " << type_to_enum(tset->get_elem_type()) - << "; size: " << fname << " size)." << endl; + << "; size: " << fname << " size)." << '\n'; indent_up(); - out << indent() << fname << " do: [:" << val << "|" << endl; + out << indent() << fname << " do: [:" << val << "|" << '\n'; indent_up(); - out << indent() << write_val(tset->get_elem_type(), val) << endl; + out << indent() << write_val(tset->get_elem_type(), val) << '\n'; indent_down(); - out << "]." << endl << indent() << "oprot writeSetEnd] value"; + out << "]." << '\n' << indent() << "oprot writeSetEnd] value"; indent_down(); return out.str(); @@ -687,17 +685,17 @@ string t_st_generator::set_reader(t_set* tset) { string desc = temp_name(); string val = temp_name(); - out << "[|" << desc << " " << val << "| " << desc << " := iprot readSetBegin." << endl; + out << "[|" << desc << " " << val << "| " << desc << " := iprot readSetBegin." << '\n'; indent_up(); - out << indent() << val << " := Set new." << endl << indent() << desc << " size timesRepeat: [" - << endl; + out << indent() << val << " := Set new." << '\n' << indent() << desc << " size timesRepeat: [" + << '\n'; indent_up(); out << indent() << val << " add: " << read_val(tset->get_elem_type()); indent_down(); - out << "]." << endl << indent() << "iprot readSetEnd." << endl << indent() << val << "] value"; + out << "]." << '\n' << indent() << "iprot readSetEnd." << '\n' << indent() << val << "] value"; indent_down(); return out.str(); @@ -709,7 +707,7 @@ string t_st_generator::struct_writer(t_struct* tstruct, string sname) { vector::const_iterator fld_iter; out << "[oprot writeStructBegin: " - << "(TStruct new name: '" + tstruct->get_name() + "')." << endl; + << "(TStruct new name: '" + tstruct->get_name() + "')." << '\n'; indent_up(); for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { @@ -718,15 +716,15 @@ string t_st_generator::struct_writer(t_struct* tstruct, string sname) { string accessor = sname + " " + camelcase(fname); if (optional) { - out << indent() << accessor << " ifNotNil: [" << endl; + out << indent() << accessor << " ifNotNil: [" << '\n'; indent_up(); } out << indent() << "oprot writeFieldBegin: (TField new name: '" << fname << "'; type: " << type_to_enum((*fld_iter)->get_type()) - << "; id: " << (*fld_iter)->get_key() << ")." << endl; + << "; id: " << (*fld_iter)->get_key() << ")." << '\n'; - out << indent() << write_val((*fld_iter)->get_type(), accessor) << "." << endl << indent() + out << indent() << write_val((*fld_iter)->get_type(), accessor) << "." << '\n' << indent() << "oprot writeFieldEnd"; if (optional) { @@ -734,7 +732,7 @@ string t_st_generator::struct_writer(t_struct* tstruct, string sname) { indent_down(); } - out << "." << endl; + out << "." << '\n'; } out << indent() << "oprot writeFieldStop; writeStructEnd] value"; @@ -755,33 +753,33 @@ string t_st_generator::struct_reader(t_struct* tstruct, string clsName = "") { clsName = tstruct->get_name(); } - out << "[|" << desc << " " << val << "|" << endl; + out << "[|" << desc << " " << val << "|" << '\n'; indent_up(); // This is nasty, but without it we'll break things by prefixing TResult. string name = ((capitalize(clsName) == "TResult") ? capitalize(clsName) : prefix(clsName)); - out << indent() << val << " := " << name << " new." << endl; + out << indent() << val << " := " << name << " new." << '\n'; - out << indent() << "iprot readStructBegin." << endl << indent() << "[" << desc - << " := iprot readFieldBegin." << endl << indent() << desc - << " type = TType stop] whileFalse: [|" << found << "|" << endl; + out << indent() << "iprot readStructBegin." << '\n' << indent() << "[" << desc + << " := iprot readFieldBegin." << '\n' << indent() << desc + << " type = TType stop] whileFalse: [|" << found << "|" << '\n'; indent_up(); for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { - out << indent() << desc << " id = " << (*fld_iter)->get_key() << " ifTrue: [" << endl; + out << indent() << desc << " id = " << (*fld_iter)->get_key() << " ifTrue: [" << '\n'; indent_up(); - out << indent() << found << " := true." << endl << indent() << val << " " + out << indent() << found << " := true." << '\n' << indent() << val << " " << camelcase((*fld_iter)->get_name()) << ": " << read_val((*fld_iter)->get_type()); indent_down(); - out << "]." << endl; + out << "]." << '\n'; } - out << indent() << found << " ifNil: [iprot skip: " << desc << " type]]." << endl; + out << indent() << found << " ifNil: [iprot skip: " << desc << " type]]." << '\n'; indent_down(); - out << indent() << "oprot readStructEnd." << endl << indent() << val << "] value"; + out << indent() << "oprot readStructEnd." << '\n' << indent() << val << "] value"; indent_down(); return out.str(); @@ -847,32 +845,32 @@ void t_st_generator::generate_send_method(t_function* function) { vector::const_iterator fld_iter; st_method(f_, client_class_name(), "send" + capitalize(signature)); - f_ << "oprot writeMessageBegin:" << endl; + f_ << "oprot writeMessageBegin:" << '\n'; indent_up(); - f_ << indent() << "(TCallMessage new" << endl; + f_ << indent() << "(TCallMessage new" << '\n'; indent_up(); - f_ << indent() << "name: '" << funname << "'; " << endl << indent() << "seqid: self nextSeqid)." - << endl; + f_ << indent() << "name: '" << funname << "'; " << '\n' << indent() << "seqid: self nextSeqid)." + << '\n'; indent_down(); indent_down(); f_ << indent() << "oprot writeStructBegin: " - << "(TStruct new name: '" + capitalize(camelcase(funname)) + "_args')." << endl; + << "(TStruct new name: '" + capitalize(camelcase(funname)) + "_args')." << '\n'; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { string fname = camelcase((*fld_iter)->get_name()); f_ << indent() << "oprot writeFieldBegin: (TField new name: '" << fname << "'; type: " << type_to_enum((*fld_iter)->get_type()) << "; id: " << (*fld_iter)->get_key() - << ")." << endl; + << ")." << '\n'; - f_ << indent() << write_val((*fld_iter)->get_type(), fname) << "." << endl << indent() - << "oprot writeFieldEnd." << endl; + f_ << indent() << write_val((*fld_iter)->get_type(), fname) << "." << '\n' << indent() + << "oprot writeFieldEnd." << '\n'; } - f_ << indent() << "oprot writeFieldStop; writeStructEnd; writeMessageEnd." << endl; + f_ << indent() << "oprot writeFieldStop; writeStructEnd; writeMessageEnd." << '\n'; f_ << indent() << "oprot transport flush"; st_close_method(f_); @@ -897,11 +895,11 @@ void t_st_generator::generate_recv_method(t_function* function) { } st_method(f_, client_class_name(), "recv" + capitalize(funname)); - f_ << "| f msg res | " << endl << indent() << "msg := oprot readMessageBegin." << endl << indent() - << "self validateRemoteMessage: msg." << endl << indent() - << "res := " << struct_reader(&result) << "." << endl << indent() << "oprot readMessageEnd." - << endl << indent() << "oprot transport flush." << endl << indent() - << "res exception ifNotNil: [res exception signal]." << endl << indent() << "^ res"; + f_ << "| f msg res | " << '\n' << indent() << "msg := oprot readMessageBegin." << '\n' << indent() + << "self validateRemoteMessage: msg." << '\n' << indent() + << "res := " << struct_reader(&result) << "." << '\n' << indent() << "oprot readMessageEnd." + << '\n' << indent() << "oprot transport flush." << '\n' << indent() + << "res exception ifNotNil: [res exception signal]." << '\n' << indent() << "^ res"; st_close_method(f_); } @@ -940,7 +938,7 @@ void t_st_generator::generate_service_client(t_service* tservice) { extends_client = extends + "Client"; } - f_ << extends_client << " subclass: #" << prefix(client_class_name()) << endl + f_ << extends_client << " subclass: #" << prefix(client_class_name()) << '\n' << "\tinstanceVariableNames: ''\n" << "\tclassVariableNames: ''\n" << "\tpoolDictionaries: ''\n" @@ -951,11 +949,11 @@ void t_st_generator::generate_service_client(t_service* tservice) { string signature = function_signature(*f_iter); st_method(f_, client_class_name(), signature); - f_ << function_types_comment(*f_iter) << endl << indent() << "self send" - << capitalize(signature) << "." << endl; + f_ << function_types_comment(*f_iter) << '\n' << indent() << "self send" + << capitalize(signature) << "." << '\n'; if (!(*f_iter)->is_oneway()) { - f_ << indent() << "^ self recv" << capitalize(funname) << " success " << endl; + f_ << indent() << "^ self recv" << capitalize(funname) << " success " << '\n'; } st_close_method(f_); diff --git a/compiler/cpp/src/thrift/generate/t_swift_generator.cc b/compiler/cpp/src/thrift/generate/t_swift_generator.cc index fab14135ae7..98b19ecada0 100644 --- a/compiler/cpp/src/thrift/generate/t_swift_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_swift_generator.cc @@ -37,8 +37,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * Swift 3 code generator. * @@ -51,7 +49,7 @@ class t_swift_generator : public t_oop_generator { const string& option_string) : t_oop_generator(program) { update_keywords_for_validation(); - + (void)option_string; map::const_iterator iter; @@ -226,14 +224,14 @@ class t_swift_generator : public t_oop_generator { private: void block_open(ostream& out) { - out << " {" << endl; + out << " {" << '\n'; indent_up(); } void block_close(ostream& out, bool end_line=true) { indent_down(); indent(out) << "}"; - if (end_line) out << endl; + if (end_line) out << '\n'; } bool field_is_optional(t_field* tfield) { @@ -320,18 +318,18 @@ void t_swift_generator::init_generator() { string f_decl_fullname = module_path + "/" + f_decl_name; f_decl_.open(f_decl_fullname.c_str()); - f_decl_ << autogen_comment() << endl; + f_decl_ << autogen_comment() << '\n'; - f_decl_ << swift_imports() << swift_thrift_imports() << endl; + f_decl_ << swift_imports() << swift_thrift_imports() << '\n'; // ...and a .swift implementation extensions file string f_impl_name = name + "+Exts.swift"; string f_impl_fullname = module_path + "/" + f_impl_name; f_impl_.open(f_impl_fullname.c_str()); - f_impl_ << autogen_comment() << endl; + f_impl_ << autogen_comment() << '\n'; - f_impl_ << swift_imports() << swift_thrift_imports() << endl; + f_impl_ << swift_imports() << swift_thrift_imports() << '\n'; } @@ -349,16 +347,16 @@ string t_swift_generator::swift_imports() { vector::const_iterator i_iter; for (i_iter=includes_list.begin(); i_iter!=includes_list.end(); ++i_iter) { - includes << "import " << *i_iter << endl; + includes << "import " << *i_iter << '\n'; } if (namespaced_) { const vector& program_includes = program_->get_includes(); for (auto program_include : program_includes) { - includes << ("import " + get_real_swift_module(program_include)) << endl; + includes << ("import " + get_real_swift_module(program_include)) << '\n'; } } - includes << endl; + includes << '\n'; return includes.str(); } @@ -381,10 +379,10 @@ string t_swift_generator::swift_thrift_imports() { vector::const_iterator i_iter; for (i_iter=includes_list.begin(); i_iter!=includes_list.end(); ++i_iter) { - includes << "import " << *i_iter << endl; + includes << "import " << *i_iter << '\n'; } - includes << endl; + includes << '\n'; return includes.str(); } @@ -395,7 +393,7 @@ string t_swift_generator::swift_thrift_imports() { void t_swift_generator::close_generator() { // stick our constants declarations at the end of the header file // since they refer to things we are defining. - f_decl_ << constants_declarations_ << endl; + f_decl_ << constants_declarations_ << '\n'; } /** @@ -405,8 +403,8 @@ void t_swift_generator::close_generator() { */ void t_swift_generator::generate_typedef(t_typedef* ttypedef) { f_decl_ << indent() << "public typealias " << ttypedef->get_symbolic() - << " = " << type_name(ttypedef->get_type()) << endl; - f_decl_ << endl; + << " = " << type_name(ttypedef->get_type()) << '\n'; + f_decl_ << '\n'; } @@ -430,80 +428,80 @@ void t_swift_generator::generate_enum(t_enum* tenum) { vector::iterator c_iter; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { - f_decl_ << indent() << "case " << enum_case_name((*c_iter), true) << endl; + f_decl_ << indent() << "case " << enum_case_name((*c_iter), true) << '\n'; } // unknown associated value case for safety and similar behavior to other languages if (safe_enums_) { - f_decl_ << indent() << "case unknown(Int32)" << endl; + f_decl_ << indent() << "case unknown(Int32)" << '\n'; } - f_decl_ << endl; + f_decl_ << '\n'; // TSerializable read(from:) f_decl_ << indent() << "public static func read(from proto: TProtocol) throws -> " << tenum->get_name(); block_open(f_decl_); - f_decl_ << indent() << "let raw: Int32 = try proto.read()" << endl; - f_decl_ << indent() << "let new = " << tenum->get_name() << "(rawValue: raw)" << endl; + f_decl_ << indent() << "let raw: Int32 = try proto.read()" << '\n'; + f_decl_ << indent() << "let new = " << tenum->get_name() << "(rawValue: raw)" << '\n'; - f_decl_ << indent() << "if let unwrapped = new {" << endl; + f_decl_ << indent() << "if let unwrapped = new {" << '\n'; indent_up(); - f_decl_ << indent() << "return unwrapped" << endl; + f_decl_ << indent() << "return unwrapped" << '\n'; indent_down(); - f_decl_ << indent() << "} else {" << endl; + f_decl_ << indent() << "} else {" << '\n'; indent_up(); - f_decl_ << indent() << "throw TProtocolError(error: .invalidData," << endl; + f_decl_ << indent() << "throw TProtocolError(error: .invalidData," << '\n'; f_decl_ << indent() << " message: \"Invalid enum value (\\(raw)) for \\(" - << tenum->get_name() << ".self)\")" << endl; + << tenum->get_name() << ".self)\")" << '\n'; indent_down(); - f_decl_ << indent() << "}" << endl; + f_decl_ << indent() << "}" << '\n'; block_close(f_decl_); // empty init for TSerializable - f_decl_ << endl; + f_decl_ << '\n'; f_decl_ << indent() << "public init()"; block_open(f_decl_); - f_decl_ << indent() << "self = ." << enum_case_name(constants.front(), false) << endl; + f_decl_ << indent() << "self = ." << enum_case_name(constants.front(), false) << '\n'; block_close(f_decl_); - f_decl_ << endl; + f_decl_ << '\n'; // rawValue getter f_decl_ << indent() << "public var rawValue: Int32"; block_open(f_decl_); - f_decl_ << indent() << "switch self {" << endl; + f_decl_ << indent() << "switch self {" << '\n'; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { f_decl_ << indent() << "case ." << enum_case_name((*c_iter), true) - << ": return " << (*c_iter)->get_value() << endl; + << ": return " << (*c_iter)->get_value() << '\n'; } if (safe_enums_) { - f_decl_ << indent() << "case .unknown(let value): return value" << endl; + f_decl_ << indent() << "case .unknown(let value): return value" << '\n'; } - f_decl_ << indent() << "}" << endl; + f_decl_ << indent() << "}" << '\n'; block_close(f_decl_); - f_decl_ << endl; + f_decl_ << '\n'; // convenience rawValue initalizer f_decl_ << indent() << "public init?(rawValue: Int32)"; block_open(f_decl_); - f_decl_ << indent() << "switch rawValue {" << endl;; + f_decl_ << indent() << "switch rawValue {" << '\n';; for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { f_decl_ << indent() << "case " << (*c_iter)->get_value() - << ": self = ." << enum_case_name((*c_iter), true) << endl; + << ": self = ." << enum_case_name((*c_iter), true) << '\n'; } if (!safe_enums_) { - f_decl_ << indent() << "default: return nil" << endl; + f_decl_ << indent() << "default: return nil" << '\n'; } else { - f_decl_ << indent() << "default: self = .unknown(rawValue)" << endl; + f_decl_ << indent() << "default: self = .unknown(rawValue)" << '\n'; } - f_decl_ << indent() << "}" << endl; + f_decl_ << indent() << "}" << '\n'; block_close(f_decl_); block_close(f_decl_); - f_decl_ << endl; + f_decl_ << '\n'; } /** @@ -521,36 +519,36 @@ void t_swift_generator::generate_old_enum(t_enum* tenum) { for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { f_decl_ << indent() << "case " << (*c_iter)->get_name() - << " = " << (*c_iter)->get_value() << endl; + << " = " << (*c_iter)->get_value() << '\n'; } - f_decl_ << endl; - f_decl_ << indent() << "public init() { self.init(rawValue: " << constants.front()->get_value() << ")! }" << endl; + f_decl_ << '\n'; + f_decl_ << indent() << "public init() { self.init(rawValue: " << constants.front()->get_value() << ")! }" << '\n'; block_close(f_decl_); - f_decl_ << endl; + f_decl_ << '\n'; f_impl_ << indent() << "extension " << tenum->get_name() << " : TEnum"; block_open(f_impl_); - f_impl_ << endl; + f_impl_ << '\n'; f_impl_ << indent() << "public static func readValueFromProtocol(proto: TProtocol) throws -> " << tenum->get_name(); block_open(f_impl_); - f_impl_ << indent() << "var raw = Int32()" << endl - << indent() << "try proto.readI32(&raw)" << endl - << indent() << "return " << tenum->get_name() << "(rawValue: raw)!" << endl; + f_impl_ << indent() << "var raw = Int32()" << '\n' + << indent() << "try proto.readI32(&raw)" << '\n' + << indent() << "return " << tenum->get_name() << "(rawValue: raw)!" << '\n'; block_close(f_impl_); - f_impl_ << endl; + f_impl_ << '\n'; f_impl_ << indent() << "public static func writeValue(value: " << tenum->get_name() << ", toProtocol proto: TProtocol) throws"; block_open(f_impl_); - f_impl_ << indent() << "try proto.writeI32(value.rawValue)" << endl; + f_impl_ << indent() << "try proto.writeI32(value.rawValue)" << '\n'; block_close(f_impl_); - f_impl_ << endl; + f_impl_ << '\n'; block_close(f_impl_); - f_impl_ << endl; + f_impl_ << '\n'; } string t_swift_generator::enum_case_name(t_enum_value* tenum_case, bool declaration) { @@ -593,7 +591,7 @@ void t_swift_generator::generate_consts(vector consts) { t_type* type = (*c_iter)->get_type(); const_interface << "public let " << capitalize((*c_iter)->get_name()) << " : " << type_name(type) << " = "; render_const_value(const_interface, type, (*c_iter)->get_value()); - const_interface << endl << endl; + const_interface << '\n' << '\n'; } // this gets spit into the header file in ::close_generator @@ -647,7 +645,7 @@ void t_swift_generator::generate_docstring(ostream& out, string& doc) { vector::const_iterator d_iter; for (d_iter = strings.begin(); d_iter != strings.end(); ++d_iter) { if ((*d_iter) != "") { - out << indent() << "/// " << (*d_iter) << endl; + out << indent() << "/// " << (*d_iter) << '\n'; } } } @@ -685,12 +683,12 @@ void t_swift_generator::generate_swift_struct(ostream& out, out << indent() << "public enum " << tstruct->get_name(); block_open(out); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - out << endl; + out << '\n'; string doc = (*m_iter)->get_doc(); generate_docstring(out, doc); out << indent() << "case " << maybe_escape_identifier((*m_iter)->get_name()) << "(val: " - << type_name((*m_iter)->get_type(), false) << ")" << endl; + << type_name((*m_iter)->get_type(), false) << ")" << '\n'; } } else { // Normal structs @@ -707,20 +705,20 @@ void t_swift_generator::generate_swift_struct(ostream& out, vector sorted = members; sort(sorted.begin(), sorted.end(), [](t_field *a, t_field *b) { return (a->get_key() < b->get_key()); } ); for (m_iter = sorted.begin(); m_iter != sorted.end(); ++m_iter) { - out << endl; + out << '\n'; // TODO: Defaults string doc = (*m_iter)->get_doc(); generate_docstring(out, doc); - out << indent() << declare_property(*m_iter, is_private) << endl; + out << indent() << declare_property(*m_iter, is_private) << '\n'; } - out << endl; - out << endl; + out << '\n'; + out << '\n'; if (!struct_has_required_fields(tstruct)) { - indent(out) << visibility << " init() { }" << endl; + indent(out) << visibility << " init() { }" << '\n'; } if (struct_has_required_fields(tstruct)) { generate_swift_struct_init(out, tstruct, false, is_private); @@ -732,7 +730,7 @@ void t_swift_generator::generate_swift_struct(ostream& out, block_close(out); - out << endl; + out << '\n'; } /** @@ -761,11 +759,11 @@ void t_swift_generator::generate_old_swift_struct(ostream& out, vector::const_iterator m_iter; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - out << endl; - out << indent() << declare_property(*m_iter, is_private) << endl; + out << '\n'; + out << indent() << declare_property(*m_iter, is_private) << '\n'; } - out << endl; + out << '\n'; // init @@ -773,7 +771,7 @@ void t_swift_generator::generate_old_swift_struct(ostream& out, block_open(out); block_close(out); - out << endl; + out << '\n'; if (struct_has_required_fields(tstruct)) { generate_swift_struct_init(out, tstruct, false, is_private); @@ -784,7 +782,7 @@ void t_swift_generator::generate_old_swift_struct(ostream& out, block_close(out); - out << endl; + out << '\n'; } /** @@ -831,20 +829,20 @@ void t_swift_generator::generate_swift_struct_init(ostream& out, should_set = should_set || !field_is_optional((*m_iter)); if (should_set) { out << indent() << "self." << maybe_escape_identifier((*m_iter)->get_name()) << " = " - << maybe_escape_identifier((*m_iter)->get_name()) << endl; + << maybe_escape_identifier((*m_iter)->get_name()) << '\n'; } } else { /** legacy Swift2/Cocoa */ if (all || (*m_iter)->get_req() == t_field::T_REQUIRED || (*m_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT) { out << indent() << "self." << maybe_escape_identifier((*m_iter)->get_name()) << " = " - << maybe_escape_identifier((*m_iter)->get_name()) << endl; + << maybe_escape_identifier((*m_iter)->get_name()) << '\n'; } } } block_close(out); - out << endl; + out << '\n'; } /** @@ -861,7 +859,7 @@ void t_swift_generator::generate_swift_struct_hashable_extension(ostream& out, string visibility = is_private ? (gen_cocoa_ ? "private" : "fileprivate") : "public"; indent(out) << "extension " << tstruct->get_name() << " : Hashable"; block_open(out); - out << endl; + out << '\n'; indent(out) << visibility << " func hash(into hasher: inout Hasher)"; block_open(out); @@ -872,21 +870,21 @@ void t_swift_generator::generate_swift_struct_hashable_extension(ostream& out, if (!tstruct->is_union()) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* tfield = *m_iter; - indent(out) << "hasher.combine(" << maybe_escape_identifier(tfield->get_name()) << ")" << endl; + indent(out) << "hasher.combine(" << maybe_escape_identifier(tfield->get_name()) << ")" << '\n'; } } else { - indent(out) << "switch self {" << endl; + indent(out) << "switch self {" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); m_iter++) { t_field *tfield = *m_iter; - indent(out) << "case ." << tfield->get_name() << "(let val): hasher.combine(val)" << endl; + indent(out) << "case ." << tfield->get_name() << "(let val): hasher.combine(val)" << '\n'; } - indent(out) << "}" << endl << endl; + indent(out) << "}" << '\n' << '\n'; } } block_close(out); - out << endl; + out << '\n'; block_close(out); - out << endl; + out << '\n'; } /** @@ -912,7 +910,7 @@ void t_swift_generator::generate_swift_struct_equatable_extension(ostream& out, if (members.size()) { if (!tstruct->is_union()) { - out << endl; + out << '\n'; indent_up(); for (m_iter = members.begin(); m_iter != members.end();) { @@ -922,30 +920,30 @@ void t_swift_generator::generate_swift_struct_equatable_extension(ostream& out, if (++m_iter != members.end()) { out << " &&"; } - out << endl; + out << '\n'; } indent_down(); } else { block_open(out); - indent(out) << "switch (lhs, rhs) {" << endl; + indent(out) << "switch (lhs, rhs) {" << '\n'; for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { t_field* tfield = *m_iter; indent(out) << "case (." << tfield->get_name() << "(let lval), ." << tfield->get_name() << "(let rval)): return lval == rval" - << endl; + << '\n'; } - indent(out) << "default: return false" << endl; - indent(out) << "}" << endl; + indent(out) << "default: return false" << '\n'; + indent(out) << "}" << '\n'; indent_down(); - indent(out) << "}()" << endl; + indent(out) << "}()" << '\n'; } } else { - out << " true" << endl; + out << " true" << '\n'; } block_close(out); - out << endl; + out << '\n'; } /** @@ -972,7 +970,7 @@ void t_swift_generator::generate_swift_struct_implementation(ostream& out, generate_swift_struct_hashable_extension(out, tstruct, is_private); generate_swift_struct_thrift_extension(out, tstruct, is_result, is_private); - out << endl << endl; + out << '\n' << '\n'; } /** @@ -993,7 +991,7 @@ void t_swift_generator::generate_swift_struct_thrift_extension(ostream& out, block_open(out); - out << endl; + out << '\n'; if (!gen_cocoa_) { /** Swift 3, no writer we just write field ID's */ string access = (is_private) ? (gen_cocoa_ ? "private" : "fileprivate") : "public"; @@ -1012,11 +1010,11 @@ void t_swift_generator::generate_swift_struct_thrift_extension(ostream& out, // pad a colon out << ":"; } - out << "]" << endl; + out << "]" << '\n'; block_close(out); - out << endl; + out << '\n'; out << indent() << access << " static var structName: String { return \"" - << tstruct->get_name() << "\" }" << endl << endl; + << tstruct->get_name() << "\" }" << '\n' << '\n'; if (tstruct->is_union()) { generate_swift_union_reader(out, tstruct); @@ -1037,24 +1035,24 @@ void t_swift_generator::generate_swift_struct_thrift_extension(ostream& out, } block_close(out); - out << endl; + out << '\n'; } void t_swift_generator::generate_swift_union_reader(ostream& out, t_struct* tstruct) { indent(out) << "public static func read(from proto: TProtocol) throws -> " << tstruct->get_name(); block_open(out); - indent(out) << "_ = try proto.readStructBegin()" << endl; + indent(out) << "_ = try proto.readStructBegin()" << '\n'; indent(out) << "var ret: " << tstruct->get_name() << "?"; - out << endl; + out << '\n'; indent(out) << "fields: while true"; block_open(out); - out << endl; - indent(out) << "let (_, fieldType, fieldID) = try proto.readFieldBegin()" << endl << endl; + out << '\n'; + indent(out) << "let (_, fieldType, fieldID) = try proto.readFieldBegin()" << '\n' << '\n'; indent(out) << "switch (fieldID, fieldType)"; block_open(out); - indent(out) << "case (_, .stop): break fields" << endl; + indent(out) << "case (_, .stop): break fields" << '\n'; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -1094,28 +1092,28 @@ void t_swift_generator::generate_swift_union_reader(ostream& out, t_struct* tstr indent(out) << padding << "ret = " << tstruct->get_name() << "." << (*f_iter)->get_name() << "(val: " << "try " << type_name((*f_iter)->get_type(), false, false) - << ".read(from: proto))" << endl; + << ".read(from: proto))" << '\n'; } - indent(out) << "case let (_, unknownType): try proto.skip(type: unknownType)" << endl; + indent(out) << "case let (_, unknownType): try proto.skip(type: unknownType)" << '\n'; block_close(out); - indent(out) << "try proto.readFieldEnd()" << endl; + indent(out) << "try proto.readFieldEnd()" << '\n'; block_close(out); - out << endl; + out << '\n'; - indent(out) << "try proto.readStructEnd()" << endl; + indent(out) << "try proto.readStructEnd()" << '\n'; indent(out) << "if let ret = ret"; block_open(out); - indent(out) << "return ret" << endl; + indent(out) << "return ret" << '\n'; block_close(out); - out << endl; + out << '\n'; indent(out) << "throw TProtocolError(error: .unknown, message: \"Missing required value for type: " << tstruct->get_name() << "\")"; block_close(out); - out << endl; + out << '\n'; } @@ -1139,7 +1137,7 @@ void t_swift_generator::generate_swift_struct_reader(ostream& out, << tstruct->get_name(); block_open(out); - indent(out) << "_ = try proto.readStructBegin()" << endl; + indent(out) << "_ = try proto.readStructBegin()" << '\n'; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -1147,20 +1145,20 @@ void t_swift_generator::generate_swift_struct_reader(ostream& out, for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool optional = field_is_optional(*f_iter); indent(out) << "var " << maybe_escape_identifier((*f_iter)->get_name()) << ": " - << type_name((*f_iter)->get_type(), optional, !optional) << endl; + << type_name((*f_iter)->get_type(), optional, !optional) << '\n'; } - out << endl; + out << '\n'; // Loop over reading in fields indent(out) << "fields: while true"; block_open(out); - out << endl; + out << '\n'; - indent(out) << "let (_, fieldType, fieldID) = try proto.readFieldBegin()" << endl << endl; + indent(out) << "let (_, fieldType, fieldID) = try proto.readFieldBegin()" << '\n' << '\n'; indent(out) << "switch (fieldID, fieldType)"; block_open(out); - indent(out) << "case (_, .stop): break fields" << endl; + indent(out) << "case (_, .stop): break fields" << '\n'; // Generate deserialization code for known cases @@ -1198,33 +1196,33 @@ void t_swift_generator::generate_swift_struct_reader(ostream& out, } out << padding << maybe_escape_identifier((*f_iter)->get_name()) << " = try " - << type_name((*f_iter)->get_type(), false, false) << ".read(from: proto)" << endl; + << type_name((*f_iter)->get_type(), false, false) << ".read(from: proto)" << '\n'; } - indent(out) << "case let (_, unknownType): try proto.skip(type: unknownType)" << endl; + indent(out) << "case let (_, unknownType): try proto.skip(type: unknownType)" << '\n'; block_close(out); - out << endl; + out << '\n'; // Read field end marker - indent(out) << "try proto.readFieldEnd()" << endl; + indent(out) << "try proto.readFieldEnd()" << '\n'; block_close(out); - out << endl; - indent(out) << "try proto.readStructEnd()" << endl; + out << '\n'; + indent(out) << "try proto.readStructEnd()" << '\n'; if (struct_has_required_fields(tstruct)) { // performs various checks (e.g. check that all required fields are set) - indent(out) << "// Required fields" << endl; + indent(out) << "// Required fields" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if (field_is_optional(*f_iter)) { continue; } indent(out) << "try proto.validateValue(" << maybe_escape_identifier((*f_iter)->get_name()) << ", " - << "named: \"" << (*f_iter)->get_name() << "\")" << endl; + << "named: \"" << (*f_iter)->get_name() << "\")" << '\n'; } } - out << endl; + out << '\n'; indent(out) << "return " << tstruct->get_name() << "("; for (f_iter = fields.begin(); f_iter != fields.end();) { @@ -1242,8 +1240,8 @@ void t_swift_generator::generate_swift_struct_reader(ostream& out, << tstruct->get_name(); block_open(out); - out << endl; - indent(out) << "try __proto.readStructBegin()" << endl << endl; + out << '\n'; + indent(out) << "try __proto.readStructBegin()" << '\n' << '\n'; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; @@ -1251,66 +1249,66 @@ void t_swift_generator::generate_swift_struct_reader(ostream& out, for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { bool optional = field_is_optional(*f_iter); indent(out) << "var " << maybe_escape_identifier((*f_iter)->get_name()) << " : " - << type_name((*f_iter)->get_type(), optional, !optional) << endl; + << type_name((*f_iter)->get_type(), optional, !optional) << '\n'; } - out << endl; + out << '\n'; // Loop over reading in fields indent(out) << "fields: while true"; block_open(out); - out << endl; + out << '\n'; - indent(out) << "let (_, fieldType, fieldID) = try __proto.readFieldBegin()" << endl << endl; + indent(out) << "let (_, fieldType, fieldID) = try __proto.readFieldBegin()" << '\n' << '\n'; indent(out) << "switch (fieldID, fieldType)"; block_open(out); - indent(out) << "case (_, .STOP):" << endl; + indent(out) << "case (_, .STOP):" << '\n'; indent_up(); - indent(out) << "break fields" << endl << endl; + indent(out) << "break fields" << '\n' << '\n'; indent_down(); // Generate deserialization code for known cases for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - indent(out) << "case (" << (*f_iter)->get_key() << ", " << type_to_enum((*f_iter)->get_type()) << "):" << endl; + indent(out) << "case (" << (*f_iter)->get_key() << ", " << type_to_enum((*f_iter)->get_type()) << "):" << '\n'; indent_up(); indent(out) << maybe_escape_identifier((*f_iter)->get_name()) << " = try __proto.readValue() as " - << type_name((*f_iter)->get_type()) << endl << endl; + << type_name((*f_iter)->get_type()) << '\n' << '\n'; indent_down(); } - indent(out) << "case let (_, unknownType):" << endl; + indent(out) << "case let (_, unknownType):" << '\n'; indent_up(); - indent(out) << "try __proto.skipType(unknownType)" << endl; + indent(out) << "try __proto.skipType(unknownType)" << '\n'; indent_down(); block_close(out); - out << endl; + out << '\n'; // Read field end marker - indent(out) << "try __proto.readFieldEnd()" << endl; + indent(out) << "try __proto.readFieldEnd()" << '\n'; block_close(out); - out << endl; - indent(out) << "try __proto.readStructEnd()" << endl; - out << endl; + out << '\n'; + indent(out) << "try __proto.readStructEnd()" << '\n'; + out << '\n'; if (struct_has_required_fields(tstruct)) { // performs various checks (e.g. check that all required fields are set) - indent(out) << "// Required fields" << endl; + indent(out) << "// Required fields" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if (field_is_optional(*f_iter)) { continue; } indent(out) << "try __proto.validateValue(" << (*f_iter)->get_name() << ", " - << "named: \"" << (*f_iter)->get_name() << "\")" << endl; + << "named: \"" << (*f_iter)->get_name() << "\")" << '\n'; } } - out << endl; + out << '\n'; indent(out) << "return " << tstruct->get_name() << "("; for (f_iter = fields.begin(); f_iter != fields.end();) { @@ -1320,11 +1318,11 @@ void t_swift_generator::generate_swift_struct_reader(ostream& out, } } } - out << ")" << endl; + out << ")" << '\n'; block_close(out); - out << endl; + out << '\n'; } /** @@ -1344,14 +1342,14 @@ void t_swift_generator::generate_old_swift_struct_writer(ostream& out, indent(out) << visibility << " static func writeValue(__value: " << tstruct->get_name() << ", toProtocol __proto: TProtocol) throws"; block_open(out); - out << endl; + out << '\n'; string name = tstruct->get_name(); const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - indent(out) << "try __proto.writeStructBeginWithName(\"" << name << "\")" << endl; - out << endl; + indent(out) << "try __proto.writeStructBeginWithName(\"" << name << "\")" << '\n'; + out << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_field *tfield = *f_iter; @@ -1367,19 +1365,19 @@ void t_swift_generator::generate_old_swift_struct_writer(ostream& out, << (optional ? "" : "__value.") << maybe_escape_identifier(tfield->get_name()) << ", " << "name: \"" << tfield->get_name() << "\", " << "type: " << type_to_enum(tfield->get_type()) << ", " - << "id: " << tfield->get_key() << ")" << endl; + << "id: " << tfield->get_key() << ")" << '\n'; if (optional) { block_close(out); } - out << endl; + out << '\n'; } - indent(out) << "try __proto.writeFieldStop()" << endl << endl; - indent(out) << "try __proto.writeStructEnd()" << endl; + indent(out) << "try __proto.writeFieldStop()" << '\n' << '\n'; + indent(out) << "try __proto.writeStructEnd()" << '\n'; block_close(out); - out << endl; + out << '\n'; } /** @@ -1396,12 +1394,12 @@ void t_swift_generator::generate_old_swift_struct_result_writer(ostream& out, t_ indent(out) << "private static func writeValue(__value: " << tstruct->get_name() << ", toProtocol __proto: TProtocol) throws"; block_open(out); - out << endl; + out << '\n'; string name = tstruct->get_name(); const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - indent(out) << "try __proto.writeStructBeginWithName(\"" << name << "\")" << endl; - out << endl; + indent(out) << "try __proto.writeStructBeginWithName(\"" << name << "\")" << '\n'; + out << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_field *tfield = *f_iter; @@ -1413,15 +1411,15 @@ void t_swift_generator::generate_old_swift_struct_result_writer(ostream& out, t_ indent(out) << "try __proto.writeFieldValue(result, " << "name: \"" << tfield->get_name() << "\", " << "type: " << type_to_enum(tfield->get_type()) << ", " - << "id: " << tfield->get_key() << ")" << endl; + << "id: " << tfield->get_key() << ")" << '\n'; block_close(out); } // Write the struct map - indent(out) << "try __proto.writeFieldStop()" << endl << endl; - indent(out) << "try __proto.writeStructEnd()" << endl; + indent(out) << "try __proto.writeFieldStop()" << '\n' << '\n'; + indent(out) << "try __proto.writeStructEnd()" << '\n'; block_close(out); - out << endl; + out << '\n'; } /** @@ -1440,50 +1438,50 @@ void t_swift_generator::generate_swift_struct_printable_extension(ostream& out, << (debug_descriptions_ ? "CustomDebugStringConvertible" : "CustomStringConvertible"); block_open(out); - out << endl; + out << '\n'; indent(out) << "public var description : String"; block_open(out); indent(out) << "var desc = \"" << tstruct->get_name(); if (!gen_cocoa_) { if (!tstruct->is_union()) { - out << "(\"" << endl; + out << "(\"" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end();) { indent(out) << "desc += \"" << (*f_iter)->get_name() << "=\\(String(describing: self." << maybe_escape_identifier((*f_iter)->get_name()) << "))"; if (++f_iter != fields.end()) { out << ", "; } - out << "\"" << endl; + out << "\"" << '\n'; } } else { - out << ".\"" << endl; - indent(out) << "switch self {" << endl; + out << ".\"" << '\n'; + indent(out) << "switch self {" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end();f_iter++) { indent(out) << "case ." << (*f_iter)->get_name() << "(let val): " << "desc += \"" << (*f_iter)->get_name() << "(val: \\(val))\"" - << endl; + << '\n'; } - indent(out) << "}" << endl; + indent(out) << "}" << '\n'; } } else { - out << "(\"" << endl; + out << "(\"" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end();) { indent(out) << "desc += \"" << (*f_iter)->get_name() << "=\\(self." << maybe_escape_identifier((*f_iter)->get_name()) << ")"; if (++f_iter != fields.end()) { out << ", "; } - out << "\"" << endl; + out << "\"" << '\n'; } - indent(out) << "desc += \")\"" << endl; + indent(out) << "desc += \")\"" << '\n'; } - indent(out) << "return desc" << endl; + indent(out) << "return desc" << '\n'; block_close(out); - out << endl; + out << '\n'; block_close(out); - out << endl; + out << '\n'; } /** @@ -1606,14 +1604,14 @@ void t_swift_generator::generate_swift_service_protocol(ostream& out, t_service* out << " : " << parent->get_name(); } block_open(out); - out << endl; + out << '\n'; vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { function_docstring(out, *f_iter); - indent(out) << function_signature(*f_iter) << endl << endl; + indent(out) << function_signature(*f_iter) << '\n' << '\n'; } } else { @@ -1624,7 +1622,7 @@ void t_swift_generator::generate_swift_service_protocol(ostream& out, t_service* vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - out << endl; + out << '\n'; indent(out) << function_signature(*f_iter) << " // exceptions: "; t_struct* xs = (*f_iter)->get_xceptions(); const vector& xceptions = xs->get_members(); @@ -1632,11 +1630,11 @@ void t_swift_generator::generate_swift_service_protocol(ostream& out, t_service* for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { out << type_name((*x_iter)->get_type()) + ", "; } - out << endl; + out << '\n'; } } block_close(out); - out << endl; + out << '\n'; } /** @@ -1652,7 +1650,7 @@ void t_swift_generator::generate_swift_service_protocol_async(ostream& out, t_se indent(out) << "public protocol " << tservice->get_name() << "Async"; block_open(out); - if (!gen_cocoa_) { out << endl; } + if (!gen_cocoa_) { out << '\n'; } vector functions = tservice->get_functions(); vector::iterator f_iter; @@ -1660,20 +1658,20 @@ void t_swift_generator::generate_swift_service_protocol_async(ostream& out, t_se if (!gen_cocoa_) { for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { async_function_docstring(out, *f_iter); - indent(out) << async_function_signature(*f_iter) << endl << endl; + indent(out) << async_function_signature(*f_iter) << '\n' << '\n'; } } else { for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - out << endl; - indent(out) << async_function_signature(*f_iter) << endl; + out << '\n'; + indent(out) << async_function_signature(*f_iter) << '\n'; if (promise_kit_) { - indent(out) << promise_function_signature(*f_iter) << endl; + indent(out) << promise_function_signature(*f_iter) << '\n'; } // - out << endl; + out << '\n'; } } block_close(out); - out << endl; + out << '\n'; } /** @@ -1690,33 +1688,33 @@ void t_swift_generator::generate_swift_service_client(ostream& out, t_service* t out << " : " << ((parent == nullptr) ? "TClient" : parent->get_name() + "Client"); out << " /* , " << tservice->get_name() << " */"; block_open(out); - out << endl; + out << '\n'; } else { // a indent(out) << "public class " << tservice->get_name() << "Client /* : " << tservice->get_name() << " */"; block_open(out); - out << endl; + out << '\n'; - indent(out) << "let __inProtocol : TProtocol" << endl << endl; - indent(out) << "let __outProtocol : TProtocol" << endl << endl; + indent(out) << "let __inProtocol : TProtocol" << '\n' << '\n'; + indent(out) << "let __outProtocol : TProtocol" << '\n' << '\n'; indent(out) << "public init(inoutProtocol: TProtocol)"; block_open(out); - indent(out) << "__inProtocol = inoutProtocol" << endl; - indent(out) << "__outProtocol = inoutProtocol" << endl; + indent(out) << "__inProtocol = inoutProtocol" << '\n'; + indent(out) << "__outProtocol = inoutProtocol" << '\n'; block_close(out); - out << endl; + out << '\n'; indent(out) << "public init(inProtocol: TProtocol, outProtocol: TProtocol)"; block_open(out); - indent(out) << "__inProtocol = inProtocol" << endl; - indent(out) << "__outProtocol = outProtocol" << endl; + indent(out) << "__inProtocol = inProtocol" << '\n'; + indent(out) << "__outProtocol = outProtocol" << '\n'; block_close(out); - out << endl; + out << '\n'; } block_close(out); - out << endl; + out << '\n'; } /** @@ -1736,24 +1734,24 @@ void t_swift_generator::generate_swift_service_client_async(ostream& out, t_serv out << " /* , " << tservice->get_name() << " */"; block_open(out); - out << endl; + out << '\n'; } else { indent(out) << "public class " << tservice->get_name() << "AsyncClient /* : " << tservice->get_name() << " */"; block_open(out); - out << endl; + out << '\n'; - indent(out) << "let __protocolFactory : TProtocolFactory" << endl << endl; - indent(out) << "let __transportFactory : TAsyncTransportFactory" << endl << endl; + indent(out) << "let __protocolFactory : TProtocolFactory" << '\n' << '\n'; + indent(out) << "let __transportFactory : TAsyncTransportFactory" << '\n' << '\n'; indent(out) << "public init(protocolFactory: TProtocolFactory, transportFactory: TAsyncTransportFactory)"; block_open(out); - indent(out) << "__protocolFactory = protocolFactory" << endl; - indent(out) << "__transportFactory = transportFactory" << endl; + indent(out) << "__protocolFactory = protocolFactory" << '\n'; + indent(out) << "__transportFactory = transportFactory" << '\n'; block_close(out); - out << endl; + out << '\n'; } block_close(out); - out << endl; + out << '\n'; } /** @@ -1767,34 +1765,34 @@ void t_swift_generator::generate_swift_service_server(ostream& out, t_service* t indent(out) << "open class " << tservice->get_name() << "Processor /* " << tservice->get_name() << " */"; block_open(out); - out << endl; + out << '\n'; out << indent() << "typealias ProcessorHandlerDictionary = " - << "[String: (Int32, TProtocol, TProtocol, " << tservice->get_name() << ") throws -> Void]" << endl - << endl - << indent() << "public var service: " << tservice->get_name() << endl - << endl + << "[String: (Int32, TProtocol, TProtocol, " << tservice->get_name() << ") throws -> Void]" << '\n' + << '\n' + << indent() << "public var service: " << tservice->get_name() << '\n' + << '\n' << indent() << "public required init(service: " << tservice->get_name() << ")"; } else { indent(out) << "public class " << tservice->get_name() << "Processor : NSObject /* " << tservice->get_name() << " */"; block_open(out); - out << endl; + out << '\n'; out << indent() << "typealias ProcessorHandlerDictionary = " - << "[String: (Int, TProtocol, TProtocol, " << tservice->get_name() << ") throws -> Void]" << endl - << endl - << indent() << "let service : " << tservice->get_name() << endl - << endl + << "[String: (Int, TProtocol, TProtocol, " << tservice->get_name() << ") throws -> Void]" << '\n' + << '\n' + << indent() << "let service : " << tservice->get_name() << '\n' + << '\n' << indent() << "public init(service: " << tservice->get_name() << ")"; } block_open(out); - indent(out) << "self.service = service" << endl; + indent(out) << "self.service = service" << '\n'; block_close(out); - out << endl; + out << '\n'; block_close(out); - out << endl; + out << '\n'; } /** @@ -1831,7 +1829,7 @@ void t_swift_generator::generate_swift_service_client_send_function_implementati // Serialize the request indent(out) << "try outProtocol.writeMessageBegin(name: \"" << funname << "\", " << "type: " << (tfunction->is_oneway() ? ".oneway" : ".call") << ", " - << "sequenceID: 0)" << endl; + << "sequenceID: 0)" << '\n'; indent(out) << "let args = " << argsname << "("; @@ -1847,18 +1845,18 @@ void t_swift_generator::generate_swift_service_client_send_function_implementati out << ", "; } } - out << ")" << endl; - indent(out) << "try args.write(to: outProtocol)" << endl; - indent(out) << "try outProtocol.writeMessageEnd()" << endl; + out << ")" << '\n'; + indent(out) << "try args.write(to: outProtocol)" << '\n'; + indent(out) << "try outProtocol.writeMessageEnd()" << '\n'; } else { - out << endl; + out << '\n'; // Serialize the request indent(out) << "try __outProtocol.writeMessageBeginWithName(\"" << funname << "\", " << "type: " << (tfunction->is_oneway() ? ".ONEWAY" : ".CALL") << ", " - << "sequenceID: 0)" << endl; + << "sequenceID: 0)" << '\n'; - out << endl; + out << '\n'; indent(out) << "let __args = " << argsname << "("; @@ -1874,13 +1872,13 @@ void t_swift_generator::generate_swift_service_client_send_function_implementati out << ", "; } } - out << ")" << endl; - indent(out) << "try " << argsname << ".writeValue(__args, toProtocol: __outProtocol)" << endl << endl; - indent(out) << "try __outProtocol.writeMessageEnd()" << endl; + out << ")" << '\n'; + indent(out) << "try " << argsname << ".writeValue(__args, toProtocol: __outProtocol)" << '\n' << '\n'; + indent(out) << "try __outProtocol.writeMessageEnd()" << '\n'; } block_close(out); - out << endl; + out << '\n'; } /** @@ -1913,7 +1911,7 @@ void t_swift_generator::generate_swift_service_client_recv_function_implementati // check for an exception - indent(out) << "try inProtocol.readResultMessageBegin() " << endl; + indent(out) << "try inProtocol.readResultMessageBegin() " << '\n'; string resultname = function_result_helper_struct_type(tservice, tfunction); indent(out); @@ -1924,15 +1922,15 @@ void t_swift_generator::generate_swift_service_client_recv_function_implementati } string return_type_name = type_name(tfunction->get_returntype()); - out << "try " << resultname << ".read(from: inProtocol)" << endl; + out << "try " << resultname << ".read(from: inProtocol)" << '\n'; - indent(out) << "try inProtocol.readMessageEnd()" << endl << endl; + indent(out) << "try inProtocol.readMessageEnd()" << '\n' << '\n'; // Careful, only return _result if not a void function if (!tfunction->get_returntype()->is_void()) { indent(out) << "if let success = result.success"; block_open(out); - indent(out) << "return success" << endl; + indent(out) << "return success" << '\n'; block_close(out); } @@ -1943,14 +1941,14 @@ void t_swift_generator::generate_swift_service_client_recv_function_implementati for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { indent(out) << "if let " << (*x_iter)->get_name() << " = result." << (*x_iter)->get_name(); block_open(out); - indent(out) << "throw " << (*x_iter)->get_name() << endl; + indent(out) << "throw " << (*x_iter)->get_name() << '\n'; block_close(out); } // If you get here it's an exception, unless a void function if (!tfunction->get_returntype()->is_void()) { indent(out) << "throw TApplicationError(error: .missingResult(methodName: \"" - << tfunction->get_name() << "\"))" << endl; + << tfunction->get_name() << "\"))" << '\n'; } } else { if (needs_protocol) { @@ -1966,22 +1964,22 @@ void t_swift_generator::generate_swift_service_client_recv_function_implementati block_open(out); // check for an exception - out << endl; - indent(out) << "try __inProtocol.readResultMessageBegin() " << endl << endl; + out << '\n'; + indent(out) << "try __inProtocol.readResultMessageBegin() " << '\n' << '\n'; string resultname = function_result_helper_struct_type(tservice, tfunction); indent(out); if (!tfunction->get_returntype()->is_void() || !tfunction->get_xceptions()->get_members().empty()) { out << "let __result = "; } - out << "try " << resultname << ".readValueFromProtocol(__inProtocol)" << endl << endl; + out << "try " << resultname << ".readValueFromProtocol(__inProtocol)" << '\n' << '\n'; - indent(out) << "try __inProtocol.readMessageEnd()" << endl << endl; + indent(out) << "try __inProtocol.readMessageEnd()" << '\n' << '\n'; // Careful, only return _result if not a void function if (!tfunction->get_returntype()->is_void()) { indent(out) << "if let __success = __result.success"; block_open(out); - indent(out) << "return __success" << endl; + indent(out) << "return __success" << '\n'; block_close(out); } @@ -1992,24 +1990,24 @@ void t_swift_generator::generate_swift_service_client_recv_function_implementati for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { indent(out) << "if let " << (*x_iter)->get_name() << " = __result." << (*x_iter)->get_name(); block_open(out); - indent(out) << "throw " << (*x_iter)->get_name() << endl; + indent(out) << "throw " << (*x_iter)->get_name() << '\n'; block_close(out); } // If you get here it's an exception, unless a void function if (!tfunction->get_returntype()->is_void()) { - indent(out) << "throw NSError(" << endl; + indent(out) << "throw NSError(" << '\n'; indent_up(); - indent(out) << "domain: TApplicationErrorDomain, " << endl; - indent(out) << "code: Int(TApplicationError.MissingResult.rawValue)," << endl; - indent(out) << "userInfo: [TApplicationErrorMethodKey: \"" << tfunction->get_name() << "\"])" << endl; + indent(out) << "domain: TApplicationErrorDomain, " << '\n'; + indent(out) << "code: Int(TApplicationError.MissingResult.rawValue)," << '\n'; + indent(out) << "userInfo: [TApplicationErrorMethodKey: \"" << tfunction->get_name() << "\"])" << '\n'; indent_down(); } } // Close function block_close(out); - out << endl; + out << '\n'; } /** @@ -2035,7 +2033,7 @@ void t_swift_generator::generate_swift_service_client_send_function_invocation(o } } - out << ")" << endl; + out << ")" << '\n'; } /** @@ -2061,7 +2059,7 @@ void t_swift_generator::generate_swift_service_client_send_async_function_invoca out << ", " << (*f_iter)->get_name() << ": " << (*f_iter)->get_name(); } - out << ")" << endl; + out << ")" << '\n'; } /** @@ -2075,7 +2073,7 @@ void t_swift_generator::generate_swift_service_client_implementation(ostream& ou string name = tservice->get_name() + "Client"; indent(out) << "extension " << name << " : " << tservice->get_name(); block_open(out); - out << endl; + out << '\n'; // generate client method implementations vector functions = tservice->get_functions(); @@ -2092,28 +2090,28 @@ void t_swift_generator::generate_swift_service_client_implementation(ostream& ou indent(out) << "public " << function_signature(*f_iter); block_open(out); - if (gen_cocoa_) { out << endl; } + if (gen_cocoa_) { out << '\n'; } generate_swift_service_client_send_function_invocation(out, *f_iter); if (!gen_cocoa_) { - indent(out) << "try outProtocol.transport.flush()" << endl; + indent(out) << "try outProtocol.transport.flush()" << '\n'; } else { - out << endl; - indent(out) << "try __outProtocol.transport().flush()" << endl << endl; + out << '\n'; + indent(out) << "try __outProtocol.transport().flush()" << '\n' << '\n'; } if (!(*f_iter)->is_oneway()) { if ((*f_iter)->get_returntype()->is_void()) { - indent(out) << "try recv_" << (*f_iter)->get_name() << "()" << endl; + indent(out) << "try recv_" << (*f_iter)->get_name() << "()" << '\n'; } else { - indent(out) << "return try recv_" << (*f_iter)->get_name() << "()" << endl; + indent(out) << "return try recv_" << (*f_iter)->get_name() << "()" << '\n'; } } block_close(out); - out << endl; + out << '\n'; } block_close(out); - out << endl; + out << '\n'; } /** @@ -2131,7 +2129,7 @@ void t_swift_generator::generate_swift_service_client_async_implementation(ostre indent(out) << "extension " << name << " : " << protocol_name; block_open(out); - out << endl; + out << '\n'; // generate client method implementations vector functions = tservice->get_functions(); @@ -2146,10 +2144,10 @@ void t_swift_generator::generate_swift_service_client_async_implementation(ostre indent(out) << "public " << async_function_signature(*f_iter); block_open(out); - out << endl; - out << indent() << "let transport = factory.newTransport()" << endl - << indent() << "let proto = Protocol(on: transport)" << endl - << endl; + out << '\n'; + out << indent() << "let transport = factory.newTransport()" << '\n' + << indent() << "let proto = Protocol(on: transport)" << '\n' + << '\n'; out << indent() << "do"; block_open(out); @@ -2157,12 +2155,12 @@ void t_swift_generator::generate_swift_service_client_async_implementation(ostre generate_swift_service_client_send_async_function_invocation(out, *f_iter); indent_down(); - out << indent() << "} catch let error {" << endl; + out << indent() << "} catch let error {" << '\n'; indent_up(); - out << indent() << "completion(.error(error))" << endl; + out << indent() << "completion(.error(error))" << '\n'; block_close(out); - out << endl; + out << '\n'; bool ret_is_void = (*f_iter)->get_returntype()->is_void(); bool is_oneway = (*f_iter)->is_oneway(); @@ -2170,10 +2168,10 @@ void t_swift_generator::generate_swift_service_client_async_implementation(ostre string error_completion_call = "completion(.error(error))"; indent(out) << "transport.flush"; block_open(out); - out << indent() << "(trans, error) in" << endl << endl; + out << indent() << "(trans, error) in" << '\n' << '\n'; out << indent() << "if let error = error"; block_open(out); - out << indent() << error_completion_call << endl; + out << indent() << error_completion_call << '\n'; block_close(out); if (!is_oneway) { @@ -2183,24 +2181,24 @@ void t_swift_generator::generate_swift_service_client_async_implementation(ostre if (!ret_is_void) { out << "let result = "; } - out << "try self.recv_" << (*f_iter)->get_name() << "(on: proto)" << endl; + out << "try self.recv_" << (*f_iter)->get_name() << "(on: proto)" << '\n'; - out << indent() << (ret_is_void ? "completion(.success(Void()))" : "completion(.success(result))") << endl; + out << indent() << (ret_is_void ? "completion(.success(Void()))" : "completion(.success(result))") << '\n'; indent_down(); - out << indent() << "} catch let error {" << endl; + out << indent() << "} catch let error {" << '\n'; indent_up(); - out << indent() << error_completion_call << endl; + out << indent() << error_completion_call << '\n'; block_close(out); } else { - out << indent() << "completion(.success(Void()))" << endl; + out << indent() << "completion(.success(Void()))" << '\n'; } block_close(out); block_close(out); } block_close(out); - out << endl; + out << '\n'; } void t_swift_generator::generate_old_swift_service_client_async_implementation(ostream& out, @@ -2211,7 +2209,7 @@ void t_swift_generator::generate_old_swift_service_client_async_implementation(o indent(out) << "extension " << name << " : " << protocol_name; block_open(out); - out << endl; + out << '\n'; // generate client method implementations vector functions = tservice->get_functions(); @@ -2226,19 +2224,19 @@ void t_swift_generator::generate_old_swift_service_client_async_implementation(o indent(out) << "public " << async_function_signature(*f_iter); block_open(out); - out << endl; + out << '\n'; - out << indent() << "let __transport = __transportFactory.newTransport()" << endl - << indent() << "let __protocol = __protocolFactory.newProtocolOnTransport(__transport)" << endl - << endl; + out << indent() << "let __transport = __transportFactory.newTransport()" << '\n' + << indent() << "let __protocol = __protocolFactory.newProtocolOnTransport(__transport)" << '\n' + << '\n'; generate_swift_service_client_send_async_function_invocation(out, *f_iter); - out << endl; + out << '\n'; indent(out) << "__transport.flushWithCompletion("; if ((*f_iter)->is_oneway()) { - out << "success, failure: failure)" << endl; + out << "success, failure: failure)" << '\n'; } else { block_open(out); @@ -2249,25 +2247,25 @@ void t_swift_generator::generate_old_swift_service_client_async_implementation(o if (!(*f_iter)->get_returntype()->is_void()) { out << "let result = "; } - out << "try self.recv_" << (*f_iter)->get_name() << "(__protocol)" << endl; + out << "try self.recv_" << (*f_iter)->get_name() << "(__protocol)" << '\n'; out << indent() << "success("; if (!(*f_iter)->get_returntype()->is_void()) { out << "result"; } - out << ")" << endl; + out << ")" << '\n'; block_close(out); indent(out) << "catch let error"; block_open(out); - indent(out) << "failure(error as NSError)" << endl; + indent(out) << "failure(error as NSError)" << '\n'; block_close(out); block_close(out); - indent(out) << ", failure: failure)" << endl; + indent(out) << ", failure: failure)" << '\n'; } block_close(out); - out << endl; + out << '\n'; // Promise function if (promise_kit_) { @@ -2275,17 +2273,17 @@ void t_swift_generator::generate_old_swift_service_client_async_implementation(o indent(out) << "public " << promise_function_signature(*f_iter); block_open(out); - out << indent() << "let (__promise, __fulfill, __reject) = Promise<" << type_name((*f_iter)->get_returntype()) << ">.pendingPromise()" << endl << endl - << indent() << "let __transport = __transportFactory.newTransport()" << endl - << indent() << "let __protocol = __protocolFactory.newProtocolOnTransport(__transport)" << endl - << endl; + out << indent() << "let (__promise, __fulfill, __reject) = Promise<" << type_name((*f_iter)->get_returntype()) << ">.pendingPromise()" << '\n' << '\n' + << indent() << "let __transport = __transportFactory.newTransport()" << '\n' + << indent() << "let __protocol = __protocolFactory.newProtocolOnTransport(__transport)" << '\n' + << '\n'; generate_swift_service_client_send_async_function_invocation(out, *f_iter); - out << endl; + out << '\n'; indent(out) << "__transport.flushWithCompletion("; if ((*f_iter)->is_oneway()) { - out << "{ __fulfill() }, failure: { __reject($0) })" << endl; + out << "{ __fulfill() }, failure: { __reject($0) })" << '\n'; } else { block_open(out); @@ -2296,37 +2294,37 @@ void t_swift_generator::generate_old_swift_service_client_async_implementation(o if (!(*f_iter)->get_returntype()->is_void()) { out << "let result = "; } - out << "try self.recv_" << (*f_iter)->get_name() << "(__protocol)" << endl; + out << "try self.recv_" << (*f_iter)->get_name() << "(__protocol)" << '\n'; out << indent() << "__fulfill("; if (!(*f_iter)->get_returntype()->is_void()) { out << "result"; } - out << ")" << endl; + out << ")" << '\n'; block_close(out); indent(out) << "catch let error"; block_open(out); - indent(out) << "__reject(error)" << endl; + indent(out) << "__reject(error)" << '\n'; block_close(out); block_close(out); - indent(out) << ", failure: { error in " << endl; + indent(out) << ", failure: { error in " << '\n'; indent_up(); - indent(out) << "__reject(error)" << endl; + indent(out) << "__reject(error)" << '\n'; indent_down(); - indent(out) << "})" << endl; + indent(out) << "})" << '\n'; } - indent(out) << "return __promise" << endl; + indent(out) << "return __promise" << '\n'; block_close(out); - out << endl; + out << '\n'; } } block_close(out); - out << endl; + out << '\n'; } /** @@ -2345,12 +2343,12 @@ void t_swift_generator::generate_swift_service_server_implementation(ostream& ou indent(out) << "extension " << name << " : TProcessor"; block_open(out); - out << endl; + out << '\n'; indent(out) << "static let processorHandlers" << (gen_cocoa_ ? " " : "") << ": ProcessorHandlerDictionary ="; block_open(out); - out << endl; - out << indent() << "var processorHandlers = ProcessorHandlerDictionary()" << endl << endl; + out << '\n'; + out << indent() << "var processorHandlers = ProcessorHandlerDictionary()" << '\n' << '\n'; // generate method map for routing incoming calls vector functions = tservice->get_functions(); @@ -2361,25 +2359,25 @@ void t_swift_generator::generate_swift_service_server_implementation(ostream& ou string args_type = function_args_helper_struct_type(tservice, *f_iter); - out << indent() << "processorHandlers[\"" << tfunction->get_name() << "\"] = { sequenceID, inProtocol, outProtocol, handler in" << endl - << endl; + out << indent() << "processorHandlers[\"" << tfunction->get_name() << "\"] = { sequenceID, inProtocol, outProtocol, handler in" << '\n' + << '\n'; indent_up(); if (!gen_cocoa_) { - out << indent() << "let args = try " << args_type << ".read(from: inProtocol)" << endl - << endl - << indent() << "try inProtocol.readMessageEnd()" << endl - << endl; + out << indent() << "let args = try " << args_type << ".read(from: inProtocol)" << '\n' + << '\n' + << indent() << "try inProtocol.readMessageEnd()" << '\n' + << '\n'; } else { - out << indent() << "let args = try " << args_type << ".readValueFromProtocol(inProtocol)" << endl - << endl - << indent() << "try inProtocol.readMessageEnd()" << endl - << endl; + out << indent() << "let args = try " << args_type << ".readValueFromProtocol(inProtocol)" << '\n' + << '\n' + << indent() << "try inProtocol.readMessageEnd()" << '\n' + << '\n'; } if (!tfunction->is_oneway() ) { string result_type = function_result_helper_struct_type(tservice, tfunction); - indent(out) << "var result = " << result_type << "()" << endl; + indent(out) << "var result = " << result_type << "()" << '\n'; indent(out) << "do"; block_open(out); @@ -2406,7 +2404,7 @@ void t_swift_generator::generate_swift_service_server_implementation(ostream& ou } } - out << ")" << endl; + out << ")" << '\n'; block_close(out); t_struct* xs = tfunction->get_xceptions(); @@ -2423,37 +2421,37 @@ void t_swift_generator::generate_swift_service_server_implementation(ostream& ou } out << (*x_iter)->get_type()->get_name(); - out << " { result." << (*x_iter)->get_name() << " = error }" << endl; + out << " { result." << (*x_iter)->get_name() << " = error }" << '\n'; } - indent(out) << "catch let error { throw error }" << endl; - out << endl; + indent(out) << "catch let error { throw error }" << '\n'; + out << '\n'; if (!tfunction->is_oneway()) { - out << indent() << "try outProtocol.writeMessageBegin(name: \"" << tfunction->get_name() << "\", type: .reply, sequenceID: sequenceID)" << endl - << indent() << "try result.write(to: outProtocol)" << endl - << indent() << "try outProtocol.writeMessageEnd()" << endl - << indent() << "try outProtocol.transport.flush()" << endl; + out << indent() << "try outProtocol.writeMessageBegin(name: \"" << tfunction->get_name() << "\", type: .reply, sequenceID: sequenceID)" << '\n' + << indent() << "try result.write(to: outProtocol)" << '\n' + << indent() << "try outProtocol.writeMessageEnd()" << '\n' + << indent() << "try outProtocol.transport.flush()" << '\n'; } } else { for (x_iter = xfields.begin(); x_iter != xfields.end(); ++x_iter) { indent(out) << "catch let error as " << (*x_iter)->get_type()->get_name(); block_open(out); - indent(out) << "result." << (*x_iter)->get_name() << " = error" << endl; + indent(out) << "result." << (*x_iter)->get_name() << " = error" << '\n'; block_close(out); } indent(out) << "catch let error"; block_open(out); - out << indent() << "throw error" << endl; + out << indent() << "throw error" << '\n'; block_close(out); - out << endl; + out << '\n'; if (!tfunction->is_oneway()) { - out << indent() << "try outProtocol.writeMessageBeginWithName(\"" << tfunction->get_name() << "\", type: .REPLY, sequenceID: sequenceID)" << endl - << indent() << "try " << result_type << ".writeValue(result, toProtocol: outProtocol)" << endl - << indent() << "try outProtocol.writeMessageEnd()" << endl; + out << indent() << "try outProtocol.writeMessageBeginWithName(\"" << tfunction->get_name() << "\", type: .REPLY, sequenceID: sequenceID)" << '\n' + << indent() << "try " << result_type << ".writeValue(result, toProtocol: outProtocol)" << '\n' + << indent() << "try outProtocol.writeMessageEnd()" << '\n'; } } } @@ -2461,11 +2459,11 @@ void t_swift_generator::generate_swift_service_server_implementation(ostream& ou } - indent(out) << "return processorHandlers" << endl; + indent(out) << "return processorHandlers" << '\n'; block_close(out,false); - out << "()" << endl; - out << endl; + out << "()" << '\n'; + out << '\n'; if (!gen_cocoa_) { indent(out) << "public func process(on inProtocol: TProtocol, outProtocol: TProtocol) throws"; @@ -2474,47 +2472,47 @@ void t_swift_generator::generate_swift_service_server_implementation(ostream& ou } block_open(out); - out << endl; - out << indent() << "let (messageName, _, sequenceID) = try inProtocol.readMessageBegin()" << endl - << endl + out << '\n'; + out << indent() << "let (messageName, _, sequenceID) = try inProtocol.readMessageBegin()" << '\n' + << '\n' << indent() << "if let processorHandler = " << name << ".processorHandlers[messageName]"; block_open(out); out << indent() << "do"; block_open(out); - out << indent() << "try processorHandler(sequenceID, inProtocol, outProtocol, service)" << endl; + out << indent() << "try processorHandler(sequenceID, inProtocol, outProtocol, service)" << '\n'; block_close(out); if (!gen_cocoa_) { out << indent() << "catch let error as TApplicationError"; block_open(out); - out << indent() << "try outProtocol.writeException(messageName: messageName, sequenceID: sequenceID, ex: error)" << endl - << indent() << "try outProtocol.transport.flush()" << endl; + out << indent() << "try outProtocol.writeException(messageName: messageName, sequenceID: sequenceID, ex: error)" << '\n' + << indent() << "try outProtocol.transport.flush()" << '\n'; block_close(out); block_close(out); out << indent() << "else"; block_open(out); - out << indent() << "try inProtocol.skip(type: .struct)" << endl - << indent() << "try inProtocol.readMessageEnd()" << endl - << indent() << "let ex = TApplicationError(error: .unknownMethod(methodName: messageName))" << endl - << indent() << "try outProtocol.writeException(messageName: messageName, sequenceID: sequenceID, ex: ex)" << endl - << indent() << "try outProtocol.transport.flush()" << endl; + out << indent() << "try inProtocol.skip(type: .struct)" << '\n' + << indent() << "try inProtocol.readMessageEnd()" << '\n' + << indent() << "let ex = TApplicationError(error: .unknownMethod(methodName: messageName))" << '\n' + << indent() << "try outProtocol.writeException(messageName: messageName, sequenceID: sequenceID, ex: ex)" << '\n' + << indent() << "try outProtocol.transport.flush()" << '\n'; } else { out << indent() << "catch let error as NSError"; block_open(out); - out << indent() << "try outProtocol.writeExceptionForMessageName(messageName, sequenceID: sequenceID, ex: error)" << endl; + out << indent() << "try outProtocol.writeExceptionForMessageName(messageName, sequenceID: sequenceID, ex: error)" << '\n'; block_close(out); block_close(out); out << indent() << "else"; block_open(out); - out << indent() << "try inProtocol.skipType(.STRUCT)" << endl - << indent() << "try inProtocol.readMessageEnd()" << endl - << indent() << "try outProtocol.writeExceptionForMessageName(messageName," << endl; + out << indent() << "try inProtocol.skipType(.STRUCT)" << '\n' + << indent() << "try inProtocol.readMessageEnd()" << '\n' + << indent() << "try outProtocol.writeExceptionForMessageName(messageName," << '\n'; indent_up(); - out << indent() << "sequenceID: sequenceID," << endl - << indent() << "ex: NSError(" << endl; + out << indent() << "sequenceID: sequenceID," << '\n' + << indent() << "ex: NSError(" << '\n'; indent_up(); - out << indent() << "domain: TApplicationErrorDomain, " << endl - << indent() << "code: Int(TApplicationError.UnknownMethod.rawValue), " << endl - << indent() << "userInfo: [TApplicationErrorMethodKey: messageName]))" << endl; + out << indent() << "domain: TApplicationErrorDomain, " << '\n' + << indent() << "code: Int(TApplicationError.UnknownMethod.rawValue), " << '\n' + << indent() << "userInfo: [TApplicationErrorMethodKey: messageName]))" << '\n'; indent_down(); indent_down(); } @@ -2522,7 +2520,7 @@ void t_swift_generator::generate_swift_service_server_implementation(ostream& ou block_close(out); block_close(out); block_close(out); - out << endl; + out << '\n'; } /** @@ -2812,27 +2810,27 @@ void t_swift_generator::function_docstring(ostream& out, t_function* tfunction) // Description string doc = tfunction->get_doc(); generate_docstring(out, doc); - indent(out) << "///" << endl; + indent(out) << "///" << '\n'; // Parameters const vector& fields = tfunction->get_arglist()->get_members(); vector::const_iterator f_iter; if (!fields.empty()) { - indent(out) << "/// - Parameters:" << endl; + indent(out) << "/// - Parameters:" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { indent(out) << "/// - " << (*f_iter)->get_name() << ": "; string doc = (*f_iter)->get_doc(); if (!doc.empty() && doc[doc.length()-1] == '\n') { doc.erase(doc.length()-1); } - out << doc << endl; + out << doc << '\n'; } } // Returns t_type* ttype = tfunction->get_returntype(); if (!ttype->is_void()) { - indent(out) << "/// - Returns: " << type_name(ttype) << endl; + indent(out) << "/// - Returns: " << type_name(ttype) << '\n'; } // Throws @@ -2845,7 +2843,7 @@ void t_swift_generator::function_docstring(ostream& out, t_function* tfunction) if (*x_iter != xceptions.back()) { out << ", "; } } - out << endl; + out << '\n'; } /** @@ -2865,20 +2863,20 @@ void t_swift_generator::async_function_docstring(ostream& out, t_function* tfunc // Description string doc = tfunction->get_doc(); generate_docstring(out, doc); - indent(out) << "///" << endl; + indent(out) << "///" << '\n'; // Parameters const vector& fields = tfunction->get_arglist()->get_members(); vector::const_iterator f_iter; if (!fields.empty()) { - indent(out) << "/// - Parameters:" << endl; + indent(out) << "/// - Parameters:" << '\n'; for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { indent(out) << "/// - " << (*f_iter)->get_name() << ": "; string doc = (*f_iter)->get_doc(); if (!doc.empty() && doc[doc.length()-1] == '\n') { doc.erase(doc.length()-1); } - out << doc << endl; + out << doc << '\n'; } } @@ -2894,7 +2892,7 @@ void t_swift_generator::async_function_docstring(ostream& out, t_function* tfunc out << ", "; } } - out << endl; + out << '\n'; } /** diff --git a/compiler/cpp/src/thrift/generate/t_xml_generator.cc b/compiler/cpp/src/thrift/generate/t_xml_generator.cc index 68675cfa157..86c2718cb25 100644 --- a/compiler/cpp/src/thrift/generate/t_xml_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_xml_generator.cc @@ -39,9 +39,6 @@ using std::vector; using std::stack; using std::set; -static const string endl = "\n"; -static const string quot = "\""; - static const string default_ns_prefix = "http://thrift.apache.org/xml/ns/"; /** @@ -196,7 +193,7 @@ void t_xml_generator::write_xml_comment(string msg) { close_top_element(); // TODO: indent any EOLs that may occur with msg // TODO: proper msg escaping needed? - f_xml_ << indent() << "" << endl; + f_xml_ << indent() << "" << '\n'; top_element_is_empty = false; } @@ -204,7 +201,7 @@ void t_xml_generator::close_top_element() { if( top_element_is_open) { top_element_is_open = false; if (elements_.size() > 0 && top_element_is_empty) { - f_xml_ << ">" << endl; + f_xml_ << ">" << '\n'; } } } @@ -224,9 +221,9 @@ void t_xml_generator::write_element_start(string name) { void t_xml_generator::write_element_end() { indent_down(); if (top_element_is_empty && top_element_is_open) { - f_xml_ << " />" << endl; + f_xml_ << " />" << '\n'; } else { - f_xml_ << indent() << "" << endl; + f_xml_ << indent() << "" << '\n'; } top_element_is_empty = false; elements_.pop(); @@ -248,7 +245,7 @@ void t_xml_generator::write_element_string(string name, string val) { top_element_is_empty = false; f_xml_ << indent() << "<" << name << ">" << escape_xml_string(val) << "" - << endl; + << '\n'; } string t_xml_generator::escape_xml_string(const string& input) { @@ -511,7 +508,7 @@ void t_xml_generator::write_const_value(t_const_value* value) { default: indent_up(); - f_xml_ << indent() << "" << endl; + f_xml_ << indent() << "" << '\n'; indent_down(); break; } diff --git a/compiler/cpp/src/thrift/generate/t_xsd_generator.cc b/compiler/cpp/src/thrift/generate/t_xsd_generator.cc index 1f58f3a619f..8dd84f0e13c 100644 --- a/compiler/cpp/src/thrift/generate/t_xsd_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_xsd_generator.cc @@ -36,8 +36,6 @@ using std::string; using std::stringstream; using std::vector; -static const string endl = "\n"; // avoid ostream << std::endl flushes - /** * XSD generator, creates an XSD for the base types etc. * @@ -121,22 +119,22 @@ void t_xsd_generator::init_generator() { string f_php_name = get_out_dir() + program_->get_name() + "_xsd.php"; f_php_.open(f_php_name.c_str()); - f_php_ << "" << endl; + f_php_ << "?>" << '\n'; f_php_.close(); } void t_xsd_generator::generate_typedef(t_typedef* ttypedef) { - indent(s_xsd_types_) << "get_name() << "\">" << endl; + indent(s_xsd_types_) << "get_name() << "\">" << '\n'; indent_up(); indent(s_xsd_types_) << "get_type()) << "\" />" - << endl; + << '\n'; indent_down(); - indent(s_xsd_types_) << "" << endl << endl; + indent(s_xsd_types_) << "" << '\n' << '\n'; } void t_xsd_generator::generate_struct(t_struct* tstruct) { @@ -144,12 +142,12 @@ void t_xsd_generator::generate_struct(t_struct* tstruct) { const vector& members = tstruct->get_members(); bool xsd_all = tstruct->get_xsd_all(); - indent(s_xsd_types_) << "get_name() << "\">" << endl; + indent(s_xsd_types_) << "get_name() << "\">" << '\n'; indent_up(); if (xsd_all) { - indent(s_xsd_types_) << "" << endl; + indent(s_xsd_types_) << "" << '\n'; } else { - indent(s_xsd_types_) << "" << endl; + indent(s_xsd_types_) << "" << '\n'; } indent_up(); @@ -164,12 +162,12 @@ void t_xsd_generator::generate_struct(t_struct* tstruct) { indent_down(); if (xsd_all) { - indent(s_xsd_types_) << "" << endl; + indent(s_xsd_types_) << "" << '\n'; } else { - indent(s_xsd_types_) << "" << endl; + indent(s_xsd_types_) << "" << '\n'; } indent_down(); - indent(s_xsd_types_) << "" << endl << endl; + indent(s_xsd_types_) << "" << '\n' << '\n'; } void t_xsd_generator::generate_element(ostream& out, @@ -185,15 +183,15 @@ void t_xsd_generator::generate_element(ostream& out, string snillable = nillable ? " nillable=\"true\"" : ""; if (ttype->is_void() || ttype->is_list()) { - indent(out) << "" << endl; + indent(out) << "" << '\n'; indent_up(); if (attrs == nullptr && ttype->is_void()) { - indent(out) << "" << endl; + indent(out) << "" << '\n'; } else { - indent(out) << "" << endl; + indent(out) << "" << '\n'; indent_up(); if (ttype->is_list()) { - indent(out) << "" << endl; + indent(out) << "" << '\n'; indent_up(); string subname; t_type* subtype = ((t_list*)ttype)->get_elem_type(); @@ -203,55 +201,55 @@ void t_xsd_generator::generate_element(ostream& out, subname = type_name(subtype); } f_php_ << "$GLOBALS['" << program_->get_name() << "_xsd_elt_" << name << "'] = '" << subname - << "';" << endl; + << "';" << '\n'; generate_element(out, subname, subtype, nullptr, false, false, true); indent_down(); - indent(out) << "" << endl; - indent(out) << "" << endl; + indent(out) << "" << '\n'; + indent(out) << "" << '\n'; } if (attrs != nullptr) { const vector& members = attrs->get_members(); vector::const_iterator a_iter; for (a_iter = members.begin(); a_iter != members.end(); ++a_iter) { indent(out) << "get_name() << "\" type=\"" - << type_name((*a_iter)->get_type()) << "\" />" << endl; + << type_name((*a_iter)->get_type()) << "\" />" << '\n'; } } indent_down(); - indent(out) << "" << endl; + indent(out) << "" << '\n'; } indent_down(); - indent(out) << "" << endl; + indent(out) << "" << '\n'; } else { if (attrs == nullptr) { indent(out) << "" - << endl; + << '\n'; } else { // Wow, all this work for a SIMPLE TYPE with attributes?!?!?! indent(out) << "" - << endl; + << '\n'; indent_up(); - indent(out) << "" << endl; + indent(out) << "" << '\n'; indent_up(); - indent(out) << "" << endl; + indent(out) << "" << '\n'; indent_up(); - indent(out) << "" << endl; + indent(out) << "" << '\n'; indent_up(); const vector& members = attrs->get_members(); vector::const_iterator a_iter; for (a_iter = members.begin(); a_iter != members.end(); ++a_iter) { indent(out) << "get_name() << "\" type=\"" - << type_name((*a_iter)->get_type()) << "\" />" << endl; + << type_name((*a_iter)->get_type()) << "\" />" << '\n'; } indent_down(); - indent(out) << "" << endl; + indent(out) << "" << '\n'; indent_down(); - indent(out) << "" << endl; + indent(out) << "" << '\n'; indent_down(); - indent(out) << "" << endl; + indent(out) << "" << '\n'; indent_down(); - indent(out) << "" << endl; + indent(out) << "" << '\n'; } } } @@ -274,10 +272,10 @@ void t_xsd_generator::generate_service(t_service* tservice) { } // Print the XSD header - f_xsd_ << "" << endl - << "" << endl + f_xsd_ << "" << '\n' + << "" << '\n' << xml_autogen_comment() - << endl; + << '\n'; // Print out the type definitions indent(f_xsd_) << s_xsd_types_.str(); @@ -292,7 +290,7 @@ void t_xsd_generator::generate_service(t_service* tservice) { string elemname = (*f_iter)->get_name() + "_response"; t_type* returntype = (*f_iter)->get_returntype(); generate_element(f_xsd_, elemname, returntype); - f_xsd_ << endl; + f_xsd_ << '\n'; t_struct* xs = (*f_iter)->get_xceptions(); const std::vector& xceptions = xs->get_members(); @@ -308,7 +306,7 @@ void t_xsd_generator::generate_service(t_service* tservice) { } // Close the XSD document - f_xsd_ << endl << "" << endl; + f_xsd_ << '\n' << "" << '\n'; f_xsd_.close(); } diff --git a/compiler/cpp/tests/netcore/t_netcore_generator_helpers_tests.cc b/compiler/cpp/tests/netcore/t_netcore_generator_helpers_tests.cc index 6acedc0f345..348ac9faca9 100644 --- a/compiler/cpp/tests/netcore/t_netcore_generator_helpers_tests.cc +++ b/compiler/cpp/tests/netcore/t_netcore_generator_helpers_tests.cc @@ -5,9 +5,9 @@ // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -36,7 +36,8 @@ TEST_CASE("t_netstd_generator::netstd_type_usings() without option wcf should re "using System.Threading;\n" "using System.Threading.Tasks;\n" "using Thrift;\n" - "using Thrift.Collections;\n" + endl; + "using Thrift.Collections;\n" + "\n"; t_program* program = new t_program(path, name); t_netstd_generator* gen = new t_netstd_generator(program, parsed_options, option_string); @@ -65,7 +66,8 @@ TEST_CASE("t_netstd_generator::netstd_type_usings() with option wcf should retur "using Thrift;\n" "using Thrift.Collections;\n" "using System.ServiceModel;\n" - "using System.Runtime.Serialization;\n" + endl; + "using System.Runtime.Serialization;\n" + "\n"; t_program* program = new t_program(path, name); t_netstd_generator* gen = new t_netstd_generator(program, parsed_options, option_string); diff --git a/contrib/fb303/TClientInfo.cpp b/contrib/fb303/TClientInfo.cpp index a4b00cf2d58..c30b42b6122 100644 --- a/contrib/fb303/TClientInfo.cpp +++ b/contrib/fb303/TClientInfo.cpp @@ -149,7 +149,7 @@ void TClientInfoServerHandler::getStatsStrings(vector& result) { char addrBuf[INET6_ADDRSTRLEN]; const char* addrStr = info->getAddr(addrBuf, sizeof addrBuf); if (addrStr == nullptr) { - // cerr << "no addr!" << endl; + // cerr << "no addr!" << '\n'; continue; } @@ -160,7 +160,7 @@ void TClientInfoServerHandler::getStatsStrings(vector& result) { char buf[256]; snprintf(buf, sizeof buf, "%d %s %s %.3f %llu", i, addrStr, callStr, secs, (uint64_t)info->getNCalls()); - + result.push_back(buf); } } diff --git a/contrib/fb303/cpp/ServiceTracker.cpp b/contrib/fb303/cpp/ServiceTracker.cpp index a2e670c768b..43e88474009 100644 --- a/contrib/fb303/cpp/ServiceTracker.cpp +++ b/contrib/fb303/cpp/ServiceTracker.cpp @@ -344,7 +344,7 @@ ServiceTracker::defaultLogMethod(int level, const string &message) break; } cout << '[' << level_string << "] [" << now_pretty << "] " - << message << endl; + << message << '\n'; } } diff --git a/contrib/thrift_dump.cpp b/contrib/thrift_dump.cpp index 59c8ac863f5..01864d08383 100644 --- a/contrib/thrift_dump.cpp +++ b/contrib/thrift_dump.cpp @@ -80,12 +80,12 @@ int main(int argc, char *argv[]) { } } } catch (TProtocolException exn) { - cout << "Protocol Exception: " << exn.what() << endl; + cout << "Protocol Exception: " << exn.what() << '\n'; } catch (...) { oprot->getTransport()->flush(); } - cout << endl; + cout << '\n'; return 0; } diff --git a/contrib/zeromq/test-client.cpp b/contrib/zeromq/test-client.cpp index 159c25030d5..f2bd2133ed8 100644 --- a/contrib/zeromq/test-client.cpp +++ b/contrib/zeromq/test-client.cpp @@ -33,7 +33,7 @@ int main(int argc, char** argv) { usleep(50000); } else { int value = client.get(); - std::cout << value << std::endl; + std::cout << value << '\n'; } return 0; diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp index 77daf3d37fa..5e0c89471d4 100644 --- a/lib/c_glib/test/testthrifttestclient.cpp +++ b/lib/c_glib/test/testthrifttestclient.cpp @@ -51,7 +51,6 @@ using namespace apache::thrift::transport; using namespace thrift::test; using std::cout; -using std::endl; using std::fixed; using std::make_pair; using std::map; @@ -76,51 +75,51 @@ class TestHandler : public ThriftTestIf { TestHandler() = default; void testVoid() override { - cout << "[C -> C++] testVoid()" << endl; + cout << "[C -> C++] testVoid()" << '\n'; } void testString(string& out, const string &thing) override { - cout << "[C -> C++] testString(\"" << thing << "\")" << endl; + cout << "[C -> C++] testString(\"" << thing << "\")" << '\n'; out = thing; } bool testBool(const bool thing) override { - cout << "[C -> C++] testBool(" << (thing ? "true" : "false") << ")" << endl; + cout << "[C -> C++] testBool(" << (thing ? "true" : "false") << ")" << '\n'; return thing; } int8_t testByte(const int8_t thing) override { - cout << "[C -> C++] testByte(" << (int)thing << ")" << endl; + cout << "[C -> C++] testByte(" << (int)thing << ")" << '\n'; return thing; } int32_t testI32(const int32_t thing) override { - cout << "[C -> C++] testI32(" << thing << ")" << endl; + cout << "[C -> C++] testI32(" << thing << ")" << '\n'; return thing; } int64_t testI64(const int64_t thing) override { - cout << "[C -> C++] testI64(" << thing << ")" << endl; + cout << "[C -> C++] testI64(" << thing << ")" << '\n'; return thing; } double testDouble(const double thing) override { cout.precision(6); - cout << "[C -> C++] testDouble(" << fixed << thing << ")" << endl; + cout << "[C -> C++] testDouble(" << fixed << thing << ")" << '\n'; return thing; } void testBinary(string& out, const string &thing) override { - cout << "[C -> C++] testBinary(\"" << thing << "\")" << endl; + cout << "[C -> C++] testBinary(\"" << thing << "\")" << '\n'; out = thing; } void testStruct(Xtruct& out, const Xtruct &thing) override { - cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << endl; + cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << '\n'; out = thing; } void testNest(Xtruct2& out, const Xtruct2& nest) override { const Xtruct &thing = nest.struct_thing; - cout << "[C -> C++] testNest({" << (int)nest.byte_thing << ", {\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "}, " << nest.i32_thing << "})" << endl; + cout << "[C -> C++] testNest({" << (int)nest.byte_thing << ", {\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "}, " << nest.i32_thing << "})" << '\n'; out = nest; } @@ -136,7 +135,7 @@ class TestHandler : public ThriftTestIf { } cout << m_iter->first << " => " << m_iter->second; } - cout << "})" << endl; + cout << "})" << '\n'; out = thing; } @@ -152,7 +151,7 @@ class TestHandler : public ThriftTestIf { } cout << "\"" << m_iter->first << "\" => \"" << m_iter->second << "\""; } - cout << "})" << endl; + cout << "})" << '\n'; out = thing; } @@ -169,7 +168,7 @@ class TestHandler : public ThriftTestIf { } cout << *s_iter; } - cout << "})" << endl; + cout << "})" << '\n'; out = thing; } @@ -185,21 +184,21 @@ class TestHandler : public ThriftTestIf { } cout << *l_iter; } - cout << "})" << endl; + cout << "})" << '\n'; out = thing; } Numberz::type testEnum(const Numberz::type thing) override { - cout << "[C -> C++] testEnum(" << thing << ")" << endl; + cout << "[C -> C++] testEnum(" << thing << ")" << '\n'; return thing; } UserId testTypedef(const UserId thing) override { - cout << "[C -> C++] testTypedef(" << thing << ")" << endl; + cout << "[C -> C++] testTypedef(" << thing << ")" << '\n'; return thing; } void testMapMap(map > &mapmap, const int32_t hello) override { - cout << "[C -> C++] testMapMap(" << hello << ")" << endl; + cout << "[C -> C++] testMapMap(" << hello << ")" << '\n'; map pos; map neg; @@ -216,7 +215,7 @@ class TestHandler : public ThriftTestIf { void testInsanity(map > &insane, const Insanity &argument) override { THRIFT_UNUSED_VARIABLE (argument); - cout << "[C -> C++] testInsanity()" << endl; + cout << "[C -> C++] testInsanity()" << '\n'; Xtruct hello; hello.string_thing = "Hello2"; @@ -278,7 +277,7 @@ class TestHandler : public ThriftTestIf { } cout << "}, "; } - cout << "}" << endl; + cout << "}" << '\n'; } @@ -288,7 +287,7 @@ class TestHandler : public ThriftTestIf { THRIFT_UNUSED_VARIABLE (arg4); THRIFT_UNUSED_VARIABLE (arg5); - cout << "[C -> C++] testMulti()" << endl; + cout << "[C -> C++] testMulti()" << '\n'; hello.string_thing = "Hello2"; hello.byte_thing = arg0; @@ -299,7 +298,7 @@ class TestHandler : public ThriftTestIf { void testException(const std::string &arg) noexcept(false) override { - cout << "[C -> C++] testException(" << arg << ")" << endl; + cout << "[C -> C++] testException(" << arg << ")" << '\n'; if (arg.compare("Xception") == 0) { Xception e; e.errorCode = 1001; @@ -317,7 +316,7 @@ class TestHandler : public ThriftTestIf { void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) noexcept(false) override { - cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << endl; + cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << '\n'; if (arg0.compare("Xception") == 0) { Xception e; @@ -336,9 +335,9 @@ class TestHandler : public ThriftTestIf { } void testOneway(int sleepFor) override { - cout << "testOneway(" << sleepFor << "): Sleeping..." << endl; + cout << "testOneway(" << sleepFor << "): Sleeping..." << '\n'; sleep(sleepFor); - cout << "testOneway(" << sleepFor << "): done sleeping!" << endl; + cout << "testOneway(" << sleepFor << "): done sleeping!" << '\n'; } }; diff --git a/lib/c_glib/test/testthrifttestzlibclient.cpp b/lib/c_glib/test/testthrifttestzlibclient.cpp index 5c4b931570d..307fd4f5f01 100644 --- a/lib/c_glib/test/testthrifttestzlibclient.cpp +++ b/lib/c_glib/test/testthrifttestzlibclient.cpp @@ -46,7 +46,6 @@ using namespace apache::thrift::transport; using namespace thrift::test; using std::cout; -using std::endl; using std::fixed; using std::make_pair; using std::map; @@ -71,51 +70,51 @@ class TestHandler : public ThriftTestIf { TestHandler() = default; void testVoid() override { - cout << "[C -> C++] testVoid()" << endl; + cout << "[C -> C++] testVoid()" << '\n'; } void testString(string& out, const string &thing) override { - cout << "[C -> C++] testString(\"" << thing << "\")" << endl; + cout << "[C -> C++] testString(\"" << thing << "\")" << '\n'; out = thing; } bool testBool(const bool thing) override { - cout << "[C -> C++] testBool(" << (thing ? "true" : "false") << ")" << endl; + cout << "[C -> C++] testBool(" << (thing ? "true" : "false") << ")" << '\n'; return thing; } int8_t testByte(const int8_t thing) override { - cout << "[C -> C++] testByte(" << (int)thing << ")" << endl; + cout << "[C -> C++] testByte(" << (int)thing << ")" << '\n'; return thing; } int32_t testI32(const int32_t thing) override { - cout << "[C -> C++] testI32(" << thing << ")" << endl; + cout << "[C -> C++] testI32(" << thing << ")" << '\n'; return thing; } int64_t testI64(const int64_t thing) override { - cout << "[C -> C++] testI64(" << thing << ")" << endl; + cout << "[C -> C++] testI64(" << thing << ")" << '\n'; return thing; } double testDouble(const double thing) override { cout.precision(6); - cout << "[C -> C++] testDouble(" << fixed << thing << ")" << endl; + cout << "[C -> C++] testDouble(" << fixed << thing << ")" << '\n'; return thing; } void testBinary(string& out, const string &thing) override { - cout << "[C -> C++] testBinary(\"" << thing << "\")" << endl; + cout << "[C -> C++] testBinary(\"" << thing << "\")" << '\n'; out = thing; } void testStruct(Xtruct& out, const Xtruct &thing) override { - cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << endl; + cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << '\n'; out = thing; } void testNest(Xtruct2& out, const Xtruct2& nest) override { const Xtruct &thing = nest.struct_thing; - cout << "[C -> C++] testNest({" << (int)nest.byte_thing << ", {\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "}, " << nest.i32_thing << "})" << endl; + cout << "[C -> C++] testNest({" << (int)nest.byte_thing << ", {\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "}, " << nest.i32_thing << "})" << '\n'; out = nest; } @@ -131,7 +130,7 @@ class TestHandler : public ThriftTestIf { } cout << m_iter->first << " => " << m_iter->second; } - cout << "})" << endl; + cout << "})" << '\n'; out = thing; } @@ -147,7 +146,7 @@ class TestHandler : public ThriftTestIf { } cout << "\"" << m_iter->first << "\" => \"" << m_iter->second << "\""; } - cout << "})" << endl; + cout << "})" << '\n'; out = thing; } @@ -164,7 +163,7 @@ class TestHandler : public ThriftTestIf { } cout << *s_iter; } - cout << "})" << endl; + cout << "})" << '\n'; out = thing; } @@ -180,21 +179,21 @@ class TestHandler : public ThriftTestIf { } cout << *l_iter; } - cout << "})" << endl; + cout << "})" << '\n'; out = thing; } Numberz::type testEnum(const Numberz::type thing) override { - cout << "[C -> C++] testEnum(" << thing << ")" << endl; + cout << "[C -> C++] testEnum(" << thing << ")" << '\n'; return thing; } UserId testTypedef(const UserId thing) override { - cout << "[C -> C++] testTypedef(" << thing << ")" << endl; + cout << "[C -> C++] testTypedef(" << thing << ")" << '\n'; return thing; } void testMapMap(map > &mapmap, const int32_t hello) override { - cout << "[C -> C++] testMapMap(" << hello << ")" << endl; + cout << "[C -> C++] testMapMap(" << hello << ")" << '\n'; map pos; map neg; @@ -211,7 +210,7 @@ class TestHandler : public ThriftTestIf { void testInsanity(map > &insane, const Insanity &argument) override { THRIFT_UNUSED_VARIABLE (argument); - cout << "[C -> C++] testInsanity()" << endl; + cout << "[C -> C++] testInsanity()" << '\n'; Xtruct hello; hello.string_thing = "Hello2"; @@ -273,7 +272,7 @@ class TestHandler : public ThriftTestIf { } cout << "}, "; } - cout << "}" << endl; + cout << "}" << '\n'; } @@ -283,7 +282,7 @@ class TestHandler : public ThriftTestIf { THRIFT_UNUSED_VARIABLE (arg4); THRIFT_UNUSED_VARIABLE (arg5); - cout << "[C -> C++] testMulti()" << endl; + cout << "[C -> C++] testMulti()" << '\n'; hello.string_thing = "Hello2"; hello.byte_thing = arg0; @@ -294,7 +293,7 @@ class TestHandler : public ThriftTestIf { void testException(const std::string &arg) throw(Xception, apache::thrift::TException) override { - cout << "[C -> C++] testException(" << arg << ")" << endl; + cout << "[C -> C++] testException(" << arg << ")" << '\n'; if (arg.compare("Xception") == 0) { Xception e; e.errorCode = 1001; @@ -312,7 +311,7 @@ class TestHandler : public ThriftTestIf { void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) override { - cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << endl; + cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << '\n'; if (arg0.compare("Xception") == 0) { Xception e; @@ -331,9 +330,9 @@ class TestHandler : public ThriftTestIf { } void testOneway(int sleepFor) override { - cout << "testOneway(" << sleepFor << "): Sleeping..." << endl; + cout << "testOneway(" << sleepFor << "): Sleeping..." << '\n'; sleep(sleepFor); - cout << "testOneway(" << sleepFor << "): done sleeping!" << endl; + cout << "testOneway(" << sleepFor << "): done sleeping!" << '\n'; } }; diff --git a/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp b/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp index 7656596859a..43d4034f618 100644 --- a/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp +++ b/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp @@ -147,8 +147,7 @@ void TEvhttpClientChannel::finish(struct evhttp_request* req) { self->finish(req); } catch (std::exception& e) { // don't propagate a C++ exception in C code (e.g. libevent) - std::cerr << "TEvhttpClientChannel::response exception thrown (ignored): " << e.what() - << std::endl; + std::cerr << "TEvhttpClientChannel::response exception thrown (ignored): " << e.what() << '\n'; } } } diff --git a/lib/cpp/src/thrift/async/TEvhttpServer.cpp b/lib/cpp/src/thrift/async/TEvhttpServer.cpp index 7d2cf21c0fc..bea9001500d 100644 --- a/lib/cpp/src/thrift/async/TEvhttpServer.cpp +++ b/lib/cpp/src/thrift/async/TEvhttpServer.cpp @@ -127,13 +127,13 @@ void TEvhttpServer::complete(RequestContext* ctx, bool success) { int rv = evhttp_add_header(ctx->req->output_headers, "Content-Type", "application/x-thrift"); if (rv != 0) { // TODO: Log an error. - std::cerr << "evhttp_add_header failed " << __FILE__ << ":" << __LINE__ << std::endl; + std::cerr << "evhttp_add_header failed " << __FILE__ << ":" << __LINE__ << '\n'; } struct evbuffer* buf = evbuffer_new(); if (buf == nullptr) { // TODO: Log an error. - std::cerr << "evbuffer_new failed " << __FILE__ << ":" << __LINE__ << std::endl; + std::cerr << "evbuffer_new failed " << __FILE__ << ":" << __LINE__ << '\n'; } else { uint8_t* obuf; uint32_t sz; @@ -141,8 +141,7 @@ void TEvhttpServer::complete(RequestContext* ctx, bool success) { int ret = evbuffer_add(buf, obuf, sz); if (ret != 0) { // TODO: Log an error. - std::cerr << "evhttp_add failed with " << ret << " " << __FILE__ << ":" << __LINE__ - << std::endl; + std::cerr << "evhttp_add failed with " << ret << " " << __FILE__ << ":" << __LINE__ << '\n'; } } diff --git a/lib/cpp/src/thrift/transport/TFileTransport.cpp b/lib/cpp/src/thrift/transport/TFileTransport.cpp index dd7d22925ff..3f4d812c567 100644 --- a/lib/cpp/src/thrift/transport/TFileTransport.cpp +++ b/lib/cpp/src/thrift/transport/TFileTransport.cpp @@ -55,8 +55,6 @@ namespace transport { using std::shared_ptr; using std::cerr; -using std::cout; -using std::endl; using std::string; using namespace apache::thrift::protocol; using namespace apache::thrift::concurrency; @@ -1032,7 +1030,7 @@ void TFileProcessor::process(uint32_t numEvents, bool tail) { break; } } catch (TException& te) { - cerr << te.what() << endl; + cerr << te.what() << '\n'; break; } } @@ -1060,7 +1058,7 @@ void TFileProcessor::processChunk() { } catch (TEOFException&) { break; } catch (TException& te) { - cerr << te.what() << endl; + cerr << te.what() << '\n'; break; } } diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp index 97a531767d0..ba8c3452919 100644 --- a/lib/cpp/test/Benchmark.cpp +++ b/lib/cpp/test/Benchmark.cpp @@ -53,7 +53,6 @@ int main() { using namespace apache::thrift::transport; using namespace apache::thrift::protocol; using std::cout; - using std::endl; OneOfEach ooe; ooe.im_true = true; @@ -84,7 +83,7 @@ int main() { ooe.write(&prot); } elapsed = timer.frame(); - cout << "Write big endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << "Write big endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } buf->getBuffer(&data, &datasize); @@ -100,7 +99,7 @@ int main() { ooe2.read(&prot); } elapsed = timer.frame(); - cout << " Read big endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << " Read big endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } { @@ -113,7 +112,7 @@ int main() { ooe.write(&prot); } elapsed = timer.frame(); - cout << "Write little endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << "Write little endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } { @@ -127,7 +126,7 @@ int main() { ooe2.read(&prot); } elapsed = timer.frame(); - cout << " Read little endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << " Read little endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } { @@ -140,7 +139,7 @@ int main() { ooe.write(&prot); } elapsed = timer.frame(); - cout << "Write big endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << "Write big endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } { @@ -154,7 +153,7 @@ int main() { ooe2.read(&prot); } elapsed = timer.frame(); - cout << " Read big endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << " Read big endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } @@ -177,7 +176,7 @@ int main() { listDoublePerf.write(&prot); elapsed = timer.frame(); - cout << "Double write big endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << "Double write big endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } buf->getBuffer(&data, &datasize); @@ -191,7 +190,7 @@ int main() { listDoublePerf2.read(&prot); elapsed = timer.frame(); - cout << " Double read big endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << " Double read big endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } { @@ -202,7 +201,7 @@ int main() { listDoublePerf.write(&prot); elapsed = timer.frame(); - cout << "Double write little endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << "Double write little endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } { @@ -214,7 +213,7 @@ int main() { listDoublePerf2.read(&prot); elapsed = timer.frame(); - cout << " Double read little endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << " Double read little endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } { @@ -225,7 +224,7 @@ int main() { listDoublePerf.write(&prot); elapsed = timer.frame(); - cout << "Double write big endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << "Double write big endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } { @@ -237,7 +236,7 @@ int main() { listDoublePerf2.read(&prot); elapsed = timer.frame(); - cout << " Double read big endian: " << num / (1000 * elapsed) << " kHz" << endl; + cout << " Double read big endian: " << num / (1000 * elapsed) << " kHz" << '\n'; } diff --git a/lib/cpp/test/OneWayHTTPTest.cpp b/lib/cpp/test/OneWayHTTPTest.cpp index 7823482f1f1..8789c2c8ffb 100644 --- a/lib/cpp/test/OneWayHTTPTest.cpp +++ b/lib/cpp/test/OneWayHTTPTest.cpp @@ -55,9 +55,6 @@ using apache::thrift::transport::TServerSocket; using apache::thrift::transport::TSocket; using apache::thrift::transport::TTransportException; using std::shared_ptr; -using std::cout; -using std::cerr; -using std::endl; using std::string; namespace utf = boost::unit_test; @@ -70,12 +67,12 @@ class OneWayServiceHandler : public onewaytest::OneWayServiceIf { void roundTripRPC() override { #ifdef ENABLE_STDERR_LOGGING - cerr << "roundTripRPC()" << endl; + cerr << "roundTripRPC()" << '\n'; #endif } void oneWayRPC() override { #ifdef ENABLE_STDERR_LOGGING - cerr << "oneWayRPC()" << std::endl ; + cerr << "oneWayRPC()" << '\n'; #endif } }; @@ -201,7 +198,7 @@ BOOST_AUTO_TEST_CASE( JSON_BufferedHTTP ) int port = ss->getPort() ; #ifdef ENABLE_STDERR_LOGGING - cerr << "port " << port << endl ; + cerr << "port " << port << '\n'; #endif { diff --git a/lib/cpp/test/TMemoryBufferTest.cpp b/lib/cpp/test/TMemoryBufferTest.cpp index 2f1aea69411..53e5d15e010 100644 --- a/lib/cpp/test/TMemoryBufferTest.cpp +++ b/lib/cpp/test/TMemoryBufferTest.cpp @@ -36,8 +36,6 @@ using apache::thrift::protocol::TBinaryProtocol; using apache::thrift::transport::TMemoryBuffer; using apache::thrift::transport::TTransportException; using std::shared_ptr; -using std::cout; -using std::endl; using std::string; BOOST_AUTO_TEST_CASE(test_read_write_grow) { diff --git a/lib/cpp/test/TServerSocketTest.cpp b/lib/cpp/test/TServerSocketTest.cpp index 929defa0a89..0860242bc25 100644 --- a/lib/cpp/test/TServerSocketTest.cpp +++ b/lib/cpp/test/TServerSocketTest.cpp @@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(test_bind_to_address) { accepted->close(); sock1.close(); - std::cout << "An error message from getaddrinfo on the console is expected:" << std::endl; + std::cout << "An error message from getaddrinfo on the console is expected:" << '\n'; TServerSocket sock2("257.258.259.260", 0); BOOST_CHECK_THROW(sock2.listen(), TTransportException); sock2.close(); diff --git a/lib/cpp/test/ThrifttReadCheckTests.cpp b/lib/cpp/test/ThrifttReadCheckTests.cpp index eb4ca01b235..481185e7c12 100644 --- a/lib/cpp/test/ThrifttReadCheckTests.cpp +++ b/lib/cpp/test/ThrifttReadCheckTests.cpp @@ -55,8 +55,6 @@ using apache::thrift::transport::TTransportException; using apache::thrift::transport::TBufferedTransport; using apache::thrift::transport::TFramedTransport; using std::shared_ptr; -using std::cout; -using std::endl; using std::string; using std::memset; using namespace apache::thrift; diff --git a/lib/cpp/test/concurrency/Tests.cpp b/lib/cpp/test/concurrency/Tests.cpp index 45054a92ad6..67de7893b5e 100644 --- a/lib/cpp/test/concurrency/Tests.cpp +++ b/lib/cpp/test/concurrency/Tests.cpp @@ -51,52 +51,52 @@ int main(int argc, char** argv) { ThreadFactoryTests threadFactoryTests; - std::cout << "ThreadFactory tests..." << std::endl; + std::cout << "ThreadFactory tests..." << '\n'; const int reapLoops = 2 * WEIGHT; const int reapCount = 100 * WEIGHT; const size_t floodLoops = 3; const size_t floodCount = 500 * WEIGHT; - std::cout << "\t\tThreadFactory reap N threads test: N = " << reapLoops << "x" << reapCount << std::endl; + std::cout << "\t\tThreadFactory reap N threads test: N = " << reapLoops << "x" << reapCount << '\n'; if (!threadFactoryTests.reapNThreads(reapLoops, reapCount)) { - std::cerr << "\t\ttThreadFactory reap N threads FAILED" << std::endl; + std::cerr << "\t\ttThreadFactory reap N threads FAILED" << '\n'; return 1; } - std::cout << "\t\tThreadFactory flood N threads test: N = " << floodLoops << "x" << floodCount << std::endl; + std::cout << "\t\tThreadFactory flood N threads test: N = " << floodLoops << "x" << floodCount << '\n'; if (!threadFactoryTests.floodNTest(floodLoops, floodCount)) { - std::cerr << "\t\ttThreadFactory flood N threads FAILED" << std::endl; + std::cerr << "\t\ttThreadFactory flood N threads FAILED" << '\n'; return 1; } - std::cout << "\t\tThreadFactory synchronous start test" << std::endl; + std::cout << "\t\tThreadFactory synchronous start test" << '\n'; if (!threadFactoryTests.synchStartTest()) { - std::cerr << "\t\ttThreadFactory synchronous start FAILED" << std::endl; + std::cerr << "\t\ttThreadFactory synchronous start FAILED" << '\n'; return 1; } - std::cout << "\t\tThreadFactory monitor timeout test" << std::endl; + std::cout << "\t\tThreadFactory monitor timeout test" << '\n'; if (!threadFactoryTests.monitorTimeoutTest()) { - std::cerr << "\t\ttThreadFactory monitor timeout FAILED" << std::endl; + std::cerr << "\t\ttThreadFactory monitor timeout FAILED" << '\n'; return 1; } } if (runAll || args[0].compare("util") == 0) { - std::cout << "Util tests..." << std::endl; + std::cout << "Util tests..." << '\n'; - std::cout << "\t\tUtil minimum time" << std::endl; + std::cout << "\t\tUtil minimum time" << '\n'; int64_t time00 = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); int64_t time01 = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); - std::cout << "\t\t\tMinimum time: " << time01 - time00 << "ms" << std::endl; + std::cout << "\t\t\tMinimum time: " << time01 - time00 << "ms" << '\n'; time00 = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); time01 = time00; @@ -107,54 +107,54 @@ int main(int argc, char** argv) { time01 = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); } - std::cout << "\t\t\tscall per ms: " << count / (time01 - time00) << std::endl; + std::cout << "\t\t\tscall per ms: " << count / (time01 - time00) << '\n'; } if (runAll || args[0].compare("timer-manager") == 0) { - std::cout << "TimerManager tests..." << std::endl; + std::cout << "TimerManager tests..." << '\n'; - std::cout << "\t\tTimerManager test00" << std::endl; + std::cout << "\t\tTimerManager test00" << '\n'; TimerManagerTests timerManagerTests; if (!timerManagerTests.test00()) { - std::cerr << "\t\tTimerManager tests FAILED" << std::endl; + std::cerr << "\t\tTimerManager tests FAILED" << '\n'; return 1; } - std::cout << "\t\tTimerManager test01" << std::endl; + std::cout << "\t\tTimerManager test01" << '\n'; if (!timerManagerTests.test01()) { - std::cerr << "\t\tTimerManager tests FAILED" << std::endl; + std::cerr << "\t\tTimerManager tests FAILED" << '\n'; return 1; } - std::cout << "\t\tTimerManager test02" << std::endl; + std::cout << "\t\tTimerManager test02" << '\n'; if (!timerManagerTests.test02()) { - std::cerr << "\t\tTimerManager tests FAILED" << std::endl; + std::cerr << "\t\tTimerManager tests FAILED" << '\n'; return 1; } - std::cout << "\t\tTimerManager test03" << std::endl; + std::cout << "\t\tTimerManager test03" << '\n'; if (!timerManagerTests.test03()) { - std::cerr << "\t\tTimerManager tests FAILED" << std::endl; + std::cerr << "\t\tTimerManager tests FAILED" << '\n'; return 1; } - std::cout << "\t\tTimerManager test04" << std::endl; + std::cout << "\t\tTimerManager test04" << '\n'; if (!timerManagerTests.test04()) { - std::cerr << "\t\tTimerManager tests FAILED" << std::endl; + std::cerr << "\t\tTimerManager tests FAILED" << '\n'; return 1; } } if (runAll || args[0].compare("thread-manager") == 0) { - std::cout << "ThreadManager tests..." << std::endl; + std::cout << "ThreadManager tests..." << '\n'; { size_t workerCount = 10 * WEIGHT; @@ -163,26 +163,26 @@ int main(int argc, char** argv) { ThreadManagerTests threadManagerTests; - std::cout << "\t\tThreadManager api test:" << std::endl; + std::cout << "\t\tThreadManager api test:" << '\n'; if (!threadManagerTests.apiTest()) { - std::cerr << "\t\tThreadManager apiTest FAILED" << std::endl; + std::cerr << "\t\tThreadManager apiTest FAILED" << '\n'; return 1; } std::cout << "\t\tThreadManager load test: worker count: " << workerCount - << " task count: " << taskCount << " delay: " << delay << std::endl; + << " task count: " << taskCount << " delay: " << delay << '\n'; if (!threadManagerTests.loadTest(taskCount, delay, workerCount)) { - std::cerr << "\t\tThreadManager loadTest FAILED" << std::endl; + std::cerr << "\t\tThreadManager loadTest FAILED" << '\n'; return 1; } std::cout << "\t\tThreadManager block test: worker count: " << workerCount - << " delay: " << delay << std::endl; + << " delay: " << delay << '\n'; if (!threadManagerTests.blockTest(delay, workerCount)) { - std::cerr << "\t\tThreadManager blockTest FAILED" << std::endl; + std::cerr << "\t\tThreadManager blockTest FAILED" << '\n'; return 1; } } @@ -190,7 +190,7 @@ int main(int argc, char** argv) { if (runAll || args[0].compare("thread-manager-benchmark") == 0) { - std::cout << "ThreadManager benchmark tests..." << std::endl; + std::cout << "ThreadManager benchmark tests..." << '\n'; { @@ -207,19 +207,19 @@ int main(int argc, char** argv) { size_t taskCount = workerCount * tasksPerWorker; std::cout << "\t\tThreadManager load test: worker count: " << workerCount - << " task count: " << taskCount << " delay: " << delay << std::endl; + << " task count: " << taskCount << " delay: " << delay << '\n'; ThreadManagerTests threadManagerTests; if (!threadManagerTests.loadTest(taskCount, delay, workerCount)) { - std::cerr << "\t\tThreadManager loadTest FAILED" << std::endl; + std::cerr << "\t\tThreadManager loadTest FAILED" << '\n'; return 1; } } } } - std::cout << "ALL TESTS PASSED" << std::endl; + std::cout << "ALL TESTS PASSED" << '\n'; return 0; } diff --git a/lib/cpp/test/concurrency/ThreadFactoryTests.h b/lib/cpp/test/concurrency/ThreadFactoryTests.h index 23e46e3de21..a2d55febae1 100644 --- a/lib/cpp/test/concurrency/ThreadFactoryTests.h +++ b/lib/cpp/test/concurrency/ThreadFactoryTests.h @@ -53,7 +53,7 @@ class ThreadFactoryTests { void run() override { Synchronized s(_monitor); - + if (--_count == 0) { _monitor.notify(); } @@ -82,7 +82,7 @@ class ThreadFactoryTests { threadFactory.newThread(shared_ptr(new ReapNTask(*monitor, activeCount)))); } catch (SystemResourceException& e) { std::cout << "\t\t\tfailed to create " << lix* count + tix << " thread " << e.what() - << std::endl; + << '\n'; throw; } } @@ -96,7 +96,7 @@ class ThreadFactoryTests { (*thread)->start(); } catch (SystemResourceException& e) { std::cout << "\t\t\tfailed to start " << lix* count + tix << " thread " << e.what() - << std::endl; + << '\n'; throw; } } @@ -107,11 +107,11 @@ class ThreadFactoryTests { monitor->wait(1000); } } - - std::cout << "\t\t\treaped " << lix* count << " threads" << std::endl; + + std::cout << "\t\t\treaped " << lix* count << " threads" << '\n'; } - std::cout << "\t\t\tSuccess!" << std::endl; + std::cout << "\t\t\tSuccess!" << '\n'; return true; } @@ -202,7 +202,7 @@ class ThreadFactoryTests { bool success = true; - std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "!" << std::endl; + std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "!" << '\n'; return true; } @@ -239,7 +239,7 @@ class ThreadFactoryTests { std::cout << "\t\t\t" << (success ? "Success" : "Failure") << ": minimum required time to elapse " << count * timeout << "ms; actual elapsed time " << endTime - startTime << "ms" - << std::endl; + << '\n'; return success; } @@ -250,14 +250,14 @@ class ThreadFactoryTests { ~FloodTask() override { if (_id % 10000 == 0) { Synchronized sync(_mon); - std::cout << "\t\tthread " << _id << " done" << std::endl; + std::cout << "\t\tthread " << _id << " done" << '\n'; } } void run() override { if (_id % 10000 == 0) { Synchronized sync(_mon); - std::cout << "\t\tthread " << _id << " started" << std::endl; + std::cout << "\t\tthread " << _id << " started" << '\n'; } } const size_t _id; @@ -270,7 +270,7 @@ class ThreadFactoryTests { bool success = false; Monitor mon; - + for (size_t lix = 0; lix < loop; lix++) { ThreadFactory threadFactory = ThreadFactory(); @@ -287,14 +287,14 @@ class ThreadFactoryTests { } catch (TException& e) { std::cout << "\t\t\tfailed to start " << lix* count + tix << " thread " << e.what() - << std::endl; + << '\n'; return success; } } Synchronized sync(mon); - std::cout << "\t\t\tflooded " << (lix + 1) * count << " threads" << std::endl; + std::cout << "\t\t\tflooded " << (lix + 1) * count << " threads" << '\n'; success = true; } diff --git a/lib/cpp/test/concurrency/ThreadManagerTests.h b/lib/cpp/test/concurrency/ThreadManagerTests.h index fee7c7c51a1..b33fc27a5d9 100644 --- a/lib/cpp/test/concurrency/ThreadManagerTests.h +++ b/lib/cpp/test/concurrency/ThreadManagerTests.h @@ -76,7 +76,7 @@ class ThreadManagerTests { { Synchronized s(_monitor); - // std::cout << "Thread " << _count << " completed " << std::endl; + // std::cout << "Thread " << _count << " completed " << '\n'; _count--; if (_count % 10000 == 0) { @@ -131,13 +131,13 @@ class ThreadManagerTests { threadManager->add(*ix); } - std::cout << "\t\t\t\tloaded " << count << " tasks to execute" << std::endl; + std::cout << "\t\t\t\tloaded " << count << " tasks to execute" << '\n'; { Synchronized s(monitor); while (activeCount > 0) { - std::cout << "\t\t\t\tactiveCount = " << activeCount << std::endl; + std::cout << "\t\t\t\tactiveCount = " << activeCount << '\n'; monitor.wait(); } } @@ -184,13 +184,13 @@ class ThreadManagerTests { std::cout << "\t\t\tfirst start: " << firstTime << " Last end: " << lastTime << " min: " << minTime << "ms max: " << maxTime << "ms average: " << averageTime - << "ms" << std::endl; + << "ms" << '\n'; bool success = (time01 - time00) >= ((int64_t)count * timeout) / (int64_t)workerCount; std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "! expected time: " << ((int64_t)count * timeout) / (int64_t)workerCount << "ms elapsed time: " << time01 - time00 - << "ms" << std::endl; + << "ms" << '\n'; return success; } @@ -307,7 +307,7 @@ class ThreadManagerTests { } std::cout << "\t\t\t" - << "Pending tasks " << threadManager->pendingTaskCount() << std::endl; + << "Pending tasks " << threadManager->pendingTaskCount() << '\n'; { Synchronized s(blockMonitor); @@ -323,18 +323,18 @@ class ThreadManagerTests { } std::cout << "\t\t\t" - << "Pending tasks " << threadManager->pendingTaskCount() << std::endl; + << "Pending tasks " << threadManager->pendingTaskCount() << '\n'; try { threadManager->add(extraTask, 1); } catch (TimedOutException&) { std::cout << "\t\t\t" - << "add timed out unexpectedly" << std::endl; + << "add timed out unexpectedly" << '\n'; throw TException("Unexpected timeout adding task"); } catch (TooManyPendingTasksException&) { std::cout << "\t\t\t" - << "add encountered too many pending exepctions" << std::endl; + << "add encountered too many pending exepctions" << '\n'; throw TException("Unexpected timeout adding task"); } @@ -375,10 +375,10 @@ class ThreadManagerTests { } } catch (TException& e) { - std::cout << "ERROR: " << e.what() << std::endl; + std::cout << "ERROR: " << e.what() << '\n'; } - std::cout << "\t\t\t" << (success ? "Success" : "Failure") << std::endl; + std::cout << "\t\t\t" << (success ? "Success" : "Failure") << '\n'; return success; } @@ -390,7 +390,7 @@ class ThreadManagerTests { sleep_(100); int64_t b = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); if (b - a < 50 || b - a > 150) { - std::cerr << "\t\t\texpected 100ms gap, found " << (b-a) << "ms gap instead." << std::endl; + std::cerr << "\t\t\texpected 100ms gap, found " << (b-a) << "ms gap instead." << '\n'; return false; } @@ -403,18 +403,18 @@ class ThreadManagerTests { shared_ptr threadManager = ThreadManager::newSimpleThreadManager(1); threadManager->threadFactory(threadFactory); - std::cout << "\t\t\t\tstarting.. " << std::endl; + std::cout << "\t\t\t\tstarting.. " << '\n'; threadManager->start(); threadManager->setExpireCallback(expiredNotifier); // std::bind(&ThreadManagerTests::expiredNotifier, this)); -#define EXPECT(FUNC, COUNT) { size_t c = FUNC; if (c != COUNT) { std::cerr << "expected " #FUNC" to be " #COUNT ", but was " << c << std::endl; return false; } } +#define EXPECT(FUNC, COUNT) { size_t c = FUNC; if (c != COUNT) { std::cerr << "expected " #FUNC" to be " #COUNT ", but was " << c << '\n'; return false; } } EXPECT(threadManager->workerCount(), 1); EXPECT(threadManager->idleWorkerCount(), 1); EXPECT(threadManager->pendingTaskCount(), 0); - std::cout << "\t\t\t\tadd 2nd worker.. " << std::endl; + std::cout << "\t\t\t\tadd 2nd worker.. " << '\n'; threadManager->addWorker(); @@ -422,7 +422,7 @@ class ThreadManagerTests { EXPECT(threadManager->idleWorkerCount(), 2); EXPECT(threadManager->pendingTaskCount(), 0); - std::cout << "\t\t\t\tremove 2nd worker.. " << std::endl; + std::cout << "\t\t\t\tremove 2nd worker.. " << '\n'; threadManager->removeWorker(); @@ -430,7 +430,7 @@ class ThreadManagerTests { EXPECT(threadManager->idleWorkerCount(), 1); EXPECT(threadManager->pendingTaskCount(), 0); - std::cout << "\t\t\t\tremove 1st worker.. " << std::endl; + std::cout << "\t\t\t\tremove 1st worker.. " << '\n'; threadManager->removeWorker(); @@ -438,7 +438,7 @@ class ThreadManagerTests { EXPECT(threadManager->idleWorkerCount(), 0); EXPECT(threadManager->pendingTaskCount(), 0); - std::cout << "\t\t\t\tadd blocking task.. " << std::endl; + std::cout << "\t\t\t\tadd blocking task.. " << '\n'; // We're going to throw a blocking task into the mix Monitor entryMonitor; // signaled when task is running @@ -454,7 +454,7 @@ class ThreadManagerTests { EXPECT(threadManager->idleWorkerCount(), 0); EXPECT(threadManager->pendingTaskCount(), 1); - std::cout << "\t\t\t\tadd other task.. " << std::endl; + std::cout << "\t\t\t\tadd other task.. " << '\n'; shared_ptr otherTask( new ThreadManagerTests::Task(doneMonitor, activeCount, 0)); @@ -465,7 +465,7 @@ class ThreadManagerTests { EXPECT(threadManager->idleWorkerCount(), 0); EXPECT(threadManager->pendingTaskCount(), 2); - std::cout << "\t\t\t\tremove blocking task specifically.. " << std::endl; + std::cout << "\t\t\t\tremove blocking task specifically.. " << '\n'; threadManager->remove(blockingTask); @@ -473,11 +473,11 @@ class ThreadManagerTests { EXPECT(threadManager->idleWorkerCount(), 0); EXPECT(threadManager->pendingTaskCount(), 1); - std::cout << "\t\t\t\tremove next pending task.." << std::endl; + std::cout << "\t\t\t\tremove next pending task.." << '\n'; shared_ptr nextTask = threadManager->removeNextPending(); if (nextTask != otherTask) { - std::cerr << "\t\t\t\t\texpected removeNextPending to return otherTask" << std::endl; + std::cerr << "\t\t\t\t\texpected removeNextPending to return otherTask" << '\n'; return false; } @@ -485,15 +485,15 @@ class ThreadManagerTests { EXPECT(threadManager->idleWorkerCount(), 0); EXPECT(threadManager->pendingTaskCount(), 0); - std::cout << "\t\t\t\tremove next pending task (none left).." << std::endl; + std::cout << "\t\t\t\tremove next pending task (none left).." << '\n'; nextTask = threadManager->removeNextPending(); if (nextTask) { - std::cerr << "\t\t\t\t\texpected removeNextPending to return an empty Runnable" << std::endl; + std::cerr << "\t\t\t\t\texpected removeNextPending to return an empty Runnable" << '\n'; return false; } - std::cout << "\t\t\t\tadd 2 expired tasks and 1 not.." << std::endl; + std::cout << "\t\t\t\tadd 2 expired tasks and 1 not.." << '\n'; shared_ptr expiredTask( new ThreadManagerTests::Task(doneMonitor, activeCount, 0)); @@ -509,28 +509,28 @@ class ThreadManagerTests { EXPECT(threadManager->pendingTaskCount(), 3); EXPECT(threadManager->expiredTaskCount(), 0); - std::cout << "\t\t\t\tremove expired tasks.." << std::endl; + std::cout << "\t\t\t\tremove expired tasks.." << '\n'; if (!m_expired.empty()) { - std::cerr << "\t\t\t\t\texpected m_expired to be empty" << std::endl; + std::cerr << "\t\t\t\t\texpected m_expired to be empty" << '\n'; return false; } threadManager->removeExpiredTasks(); if (m_expired.size() != 2) { - std::cerr << "\t\t\t\t\texpected m_expired to be set" << std::endl; + std::cerr << "\t\t\t\t\texpected m_expired to be set" << '\n'; return false; } if (m_expired.front() != expiredTask) { - std::cerr << "\t\t\t\t\texpected m_expired[0] to be the expired task" << std::endl; + std::cerr << "\t\t\t\t\texpected m_expired[0] to be the expired task" << '\n'; return false; } m_expired.pop_front(); if (m_expired.front() != expiredTask) { - std::cerr << "\t\t\t\t\texpected m_expired[1] to be the expired task" << std::endl; + std::cerr << "\t\t\t\t\texpected m_expired[1] to be the expired task" << '\n'; return false; } @@ -543,23 +543,23 @@ class ThreadManagerTests { EXPECT(threadManager->pendingTaskCount(), 0); EXPECT(threadManager->expiredTaskCount(), 2); - std::cout << "\t\t\t\tadd expired task (again).." << std::endl; + std::cout << "\t\t\t\tadd expired task (again).." << '\n'; threadManager->add(expiredTask, 0, 1); // expires in 1ms sleep_(50); // make sure enough time elapses for it to expire - the shortest expiration time is 1ms - std::cout << "\t\t\t\tadd worker to consume expired task.." << std::endl; + std::cout << "\t\t\t\tadd worker to consume expired task.." << '\n'; threadManager->addWorker(); sleep_(100); // make sure it has time to spin up and expire the task if (m_expired.empty()) { - std::cerr << "\t\t\t\t\texpected m_expired to be set" << std::endl; + std::cerr << "\t\t\t\t\texpected m_expired to be set" << '\n'; return false; } if (m_expired.front() != expiredTask) { - std::cerr << "\t\t\t\t\texpected m_expired to be the expired task" << std::endl; + std::cerr << "\t\t\t\t\texpected m_expired to be the expired task" << '\n'; return false; } @@ -570,16 +570,16 @@ class ThreadManagerTests { EXPECT(threadManager->pendingTaskCount(), 0); EXPECT(threadManager->expiredTaskCount(), 3); - std::cout << "\t\t\t\ttry to remove too many workers" << std::endl; + std::cout << "\t\t\t\ttry to remove too many workers" << '\n'; try { threadManager->removeWorker(2); - std::cerr << "\t\t\t\t\texpected InvalidArgumentException" << std::endl; + std::cerr << "\t\t\t\t\texpected InvalidArgumentException" << '\n'; return false; } catch (const InvalidArgumentException&) { /* expected */ } - std::cout << "\t\t\t\tremove worker.. " << std::endl; + std::cout << "\t\t\t\tremove worker.. " << '\n'; threadManager->removeWorker(); @@ -588,7 +588,7 @@ class ThreadManagerTests { EXPECT(threadManager->pendingTaskCount(), 0); EXPECT(threadManager->expiredTaskCount(), 3); - std::cout << "\t\t\t\tadd blocking task.. " << std::endl; + std::cout << "\t\t\t\tadd blocking task.. " << '\n'; threadManager->add(blockingTask); @@ -596,7 +596,7 @@ class ThreadManagerTests { EXPECT(threadManager->idleWorkerCount(), 0); EXPECT(threadManager->pendingTaskCount(), 1); - std::cout << "\t\t\t\tadd worker.. " << std::endl; + std::cout << "\t\t\t\tadd worker.. " << '\n'; threadManager->addWorker(); { @@ -610,7 +610,7 @@ class ThreadManagerTests { EXPECT(threadManager->idleWorkerCount(), 0); EXPECT(threadManager->pendingTaskCount(), 0); - std::cout << "\t\t\t\tunblock task and remove worker.. " << std::endl; + std::cout << "\t\t\t\tunblock task and remove worker.. " << '\n'; { Synchronized s(blockMonitor); @@ -623,7 +623,7 @@ class ThreadManagerTests { EXPECT(threadManager->idleWorkerCount(), 0); EXPECT(threadManager->pendingTaskCount(), 0); - std::cout << "\t\t\t\tcleanup.. " << std::endl; + std::cout << "\t\t\t\tcleanup.. " << '\n'; blockingTask.reset(); threadManager.reset(); diff --git a/lib/cpp/test/concurrency/TimerManagerTests.h b/lib/cpp/test/concurrency/TimerManagerTests.h index 2d1a2620ab5..9a532320019 100644 --- a/lib/cpp/test/concurrency/TimerManagerTests.h +++ b/lib/cpp/test/concurrency/TimerManagerTests.h @@ -46,7 +46,7 @@ class TimerManagerTests { _success(false), _done(false) {} - ~Task() override { std::cerr << this << std::endl; } + ~Task() override { std::cerr << this << '\n'; } void run() override { @@ -84,7 +84,7 @@ class TimerManagerTests { timerManager.threadFactory(shared_ptr(new ThreadFactory())); timerManager.start(); if (timerManager.state() != TimerManager::STARTED) { - std::cerr << "timerManager is not in the STARTED state, but should be" << std::endl; + std::cerr << "timerManager is not in the STARTED state, but should be" << '\n'; return false; } @@ -104,15 +104,15 @@ class TimerManagerTests { } if (!task->_done) { - std::cerr << "task is not done, but it should have executed" << std::endl; + std::cerr << "task is not done, but it should have executed" << '\n'; return false; } - std::cout << "\t\t\t" << (task->_success ? "Success" : "Failure") << "!" << std::endl; + std::cout << "\t\t\t" << (task->_success ? "Success" : "Failure") << "!" << '\n'; } if (orphanTask->_done) { - std::cerr << "orphan task is done, but it should not have executed" << std::endl; + std::cerr << "orphan task is done, but it should not have executed" << '\n'; return false; } diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp index 79a708e8f57..a42462059b8 100644 --- a/test/cpp/src/StressTest.cpp +++ b/test/cpp/src/StressTest.cpp @@ -155,7 +155,7 @@ class ClientThread : public Runnable { loopEchoString(); break; default: - cerr << "Unexpected loop type" << _loopType << endl; + cerr << "Unexpected loop type" << _loopType << '\n'; break; } @@ -280,23 +280,23 @@ int main(int argc, char** argv) { usage << argv[0] << " [--port=] [--server] [--server-type=] " "[--protocol-type=] [--workers=] " "[--clients=] [--loop=] " - "[--client-type=]" << endl + "[--client-type=]" << '\n' << "\tclients Number of client threads to create - 0 implies no clients, i.e. " - "server only. Default is " << clientCount << endl - << "\thelp Prints this help text." << endl - << "\tcall Service method to call. Default is " << callName << endl - << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << endl + "server only. Default is " << clientCount << '\n' + << "\thelp Prints this help text." << '\n' + << "\tcall Service method to call. Default is " << callName << '\n' + << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << '\n' << "\tport The port the server and clients should bind to " - "for thrift network connections. Default is " << port << endl - << "\tserver Run the Thrift server in this process. Default is " << runServer << endl - << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << endl - << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << endl - << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << endl - << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl + "for thrift network connections. Default is " << port << '\n' + << "\tserver Run the Thrift server in this process. Default is " << runServer << '\n' + << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << '\n' + << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << '\n' + << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << '\n' + << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << '\n' << "\tworkers Number of thread pools workers. Only valid " - "for thread-pool server type. Default is " << workerCount << endl - << "\tclient-type Type of client, \"regular\" or \"concurrent\". Default is " << clientType << endl - << endl; + "for thread-pool server type. Default is " << workerCount << '\n' + << "\tclient-type Type of client, \"regular\" or \"concurrent\". Default is " << clientType << '\n' + << '\n'; map args; @@ -386,7 +386,7 @@ int main(int argc, char** argv) { } } catch (std::exception& e) { - cerr << e.what() << endl; + cerr << e.what() << '\n'; cerr << usage.str(); } @@ -468,7 +468,7 @@ int main(int argc, char** argv) { server->setServerEventHandler(observer); std::shared_ptr serverThread = threadFactory->newThread(server); - cerr << "Starting the server on port " << port << endl; + cerr << "Starting the server on port " << port << '\n'; serverThread->start(); observer->waitForService(); @@ -538,7 +538,7 @@ int main(int argc, char** argv) { Synchronized s(monitor); threadCount = clientCount; - cerr << "Launch " << clientCount << " " << clientType << " client threads" << endl; + cerr << "Launch " << clientCount << " " << clientType << " client threads" << '\n'; time00 = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); @@ -591,14 +591,14 @@ int main(int argc, char** argv) { averageTime /= clientCount; cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount - << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl; + << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << '\n'; count_map count = serviceHandler->getCount(); count_map::iterator iter; for (iter = count.begin(); iter != count.end(); ++iter) { printf("%s => %d\n", iter->first, iter->second); } - cerr << "done." << endl; + cerr << "done." << '\n'; } return 0; diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp index e94ecb2db11..d9d9ae606b5 100644 --- a/test/cpp/src/StressTestNonBlocking.cpp +++ b/test/cpp/src/StressTestNonBlocking.cpp @@ -152,7 +152,7 @@ class ClientThread : public Runnable { loopEchoString(); break; default: - cerr << "Unexpected loop type" << _loopType << endl; + cerr << "Unexpected loop type" << _loopType << '\n'; break; } @@ -253,24 +253,20 @@ int main(int argc, char** argv) { usage << argv[0] << " [--port=] [--server] [--server-type=] " "[--protocol-type=] [--workers=] " - "[--clients=] [--loop=]" << endl + "[--clients=] [--loop=]" << '\n' << "\tclients Number of client threads to create - 0 implies no clients, i.e. " - "server only. Default is " << clientCount << endl - << "\thelp Prints this help text." << endl - << "\tcall Service method to call. Default is " << callName << endl - << "\tloop The number of remote thrift calls each client makes. Default is " - << loopCount << endl << "\tport The port the server and clients should bind to " - "for thrift network connections. Default is " << port << endl - << "\tserver Run the Thrift server in this process. Default is " << runServer - << endl << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " - << serverType << endl - << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " - << protocolType << endl - << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests - << endl << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " - << replayRequests << endl << "\tworkers Number of thread pools workers. Only valid " - "for thread-pool server type. Default is " << workerCount - << endl; + "server only. Default is " << clientCount << '\n' + << "\thelp Prints this help text." << '\n' + << "\tcall Service method to call. Default is " << callName << '\n' + << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << '\n' + << "\tport The port the server and clients should bind to for thrift network " + "connections. Default is " << port << '\n' + << "\tserver Run the Thrift server in this process. Default is " << runServer << '\n' + << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << '\n' + << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << '\n' + << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << '\n' + << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << '\n' + << "\tworkers Number of thread pools workers. Only valid for thread-pool server type. Default is " << workerCount << '\n'; map args; @@ -338,7 +334,7 @@ int main(int argc, char** argv) { } } catch (std::exception& e) { - cerr << e.what() << endl; + cerr << e.what() << '\n'; cerr << usage.str(); } @@ -416,7 +412,7 @@ int main(int argc, char** argv) { new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2, threadManager))); } - cerr << "Starting the server on port " << port << " and " << (port + 1) << endl; + cerr << "Starting the server on port " << port << " and " << (port + 1) << '\n'; serverThread->start(); serverThread2->start(); @@ -475,7 +471,7 @@ int main(int argc, char** argv) { Synchronized s(monitor); threadCount = clientCount; - cerr << "Launch " << clientCount << " client threads" << endl; + cerr << "Launch " << clientCount << " client threads" << '\n'; time00 = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); @@ -528,14 +524,14 @@ int main(int argc, char** argv) { averageTime /= clientCount; cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount - << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl; + << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << '\n'; count_map count = serviceHandler->getCount(); count_map::iterator iter; for (iter = count.begin(); iter != count.end(); ++iter) { printf("%s => %d\n", iter->first, iter->second); } - cerr << "done." << endl; + cerr << "done." << '\n'; } return 0; diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index fd04ed87063..c15281a6a09 100644 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -98,7 +98,7 @@ class TPedanticProtocol : public Proto ss << "ERROR: send request with seqid " << m_last_seqid << " and got reply with seqid " << seqid; throw std::logic_error(ss.str()); } /* else { - std::cout << "verified seqid " << m_last_seqid << " round trip OK" << std::endl; + std::cout << "verified seqid " << m_last_seqid << " round trip OK" << '\n'; } */ return result; } @@ -127,9 +127,9 @@ static void testString_clientReturn(event_base* base, std::ostringstream os; os << "test" << testNr; const bool ok = (s == os.str()); - cout << "testString: " << s << " " << ((ok) ? "ok" : "failed") << endl; + cout << "testString: " << s << " " << ((ok) ? "ok" : "failed") << '\n'; } catch (TException& exn) { - cout << "Error: " << exn.what() << endl; + cout << "Error: " << exn.what() << '\n'; } if (testNr == 9) @@ -139,7 +139,7 @@ static void testString_clientReturn(event_base* base, static void testVoid_clientReturn(event_base* base, ThriftTestCobClient* client) { try { client->recv_testVoid(); - cout << "testVoid" << endl; + cout << "testVoid" << '\n'; for (int testNr = 0; testNr < 10; ++testNr) { std::ostringstream os; @@ -151,16 +151,16 @@ static void testVoid_clientReturn(event_base* base, ThriftTestCobClient* client) os.str()); } } catch (TException& exn) { - cout << "Error: " << exn.what() << endl; + cout << "Error: " << exn.what() << '\n'; } } // Workaround for absense of C++11 "auto" keyword. template bool print_eq(T expected, T actual) { - cout << "(" << actual << ")" << endl; + cout << "(" << actual << ")" << '\n'; if (expected != actual) { - cout << "*** FAILED ***" << endl << "Expected: " << expected << " but got: " << actual << endl; + cout << "*** FAILED ***" << '\n' << "Expected: " << expected << " but got: " << actual << '\n'; return false; } return true; @@ -174,7 +174,7 @@ bool print_eq(T expected, T actual) { } catch (TTransportException&) { \ throw; \ } catch (exception & ex) { \ - cout << "*** FAILED ***" << endl << ex.what() << endl; \ + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; \ return_code |= ERR_BASETYPES; \ } @@ -186,7 +186,7 @@ bool print_eq(T expected, T actual) { } catch (TTransportException&) { \ throw; \ } catch (exception & ex) { \ - cout << "*** FAILED ***" << endl << ex.what() << endl; \ + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; \ return_code |= ERR_BASETYPES; \ } @@ -258,7 +258,7 @@ int main(int argc, char** argv) { boost::program_options::notify(vm); if (vm.count("help")) { - cout << desc << endl; + cout << desc << '\n'; return ERR_UNKNOWN; } @@ -290,8 +290,8 @@ int main(int argc, char** argv) { } } catch (exception& e) { - cerr << e.what() << endl; - cout << desc << endl; + cerr << e.what() << '\n'; + cout << desc << '\n'; return ERR_UNKNOWN; } @@ -319,9 +319,9 @@ int main(int argc, char** argv) { std::shared_ptr protocol2; // SecondService for multiplexed if (ssl) { - cout << "Client Certificate File: " << certPath << endl; - cout << "Client Key File: " << keyPath << endl; - cout << "CA File: " << caPath << endl; + cout << "Client Certificate File: " << certPath << '\n'; + cout << "Client Key File: " << keyPath << '\n'; + cout << "CA File: " << caPath << '\n'; factory = std::shared_ptr(new TSSLSocketFactory()); factory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); @@ -386,14 +386,14 @@ int main(int argc, char** argv) { if (port != 0) { cout << host << ":" << port; } - cout << endl; + cout << '\n'; if (transport_type.compare("evhttp") == 0) { event_base* base = event_base_new(); - cout << "Libevent Version: " << event_get_version() << endl; - cout << "Libevent Method: " << event_base_get_method(base) << endl; + cout << "Libevent Version: " << event_get_version() << '\n'; + cout << "Libevent Method: " << event_base_get_method(base) << '\n'; #if LIBEVENT_VERSION_NUMBER >= 0x02000000 - cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << endl; + cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << '\n'; #endif std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); @@ -421,7 +421,7 @@ int main(int argc, char** argv) { try { transport->open(); } catch (TTransportException& ex) { - cout << "Connect failed: " << ex.what() << endl; + cout << "Connect failed: " << ex.what() << '\n'; return ERR_UNKNOWN; } @@ -438,12 +438,12 @@ int main(int argc, char** argv) { try { cout << "testVoid()" << flush; testClient.testVoid(); - cout << " = void" << endl; + cout << " = void" << '\n'; } catch (TTransportException&) { // Stop here if transport got broken throw; } catch (exception& ex) { - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_BASETYPES; } @@ -453,9 +453,9 @@ int main(int argc, char** argv) { cout << "testString(\"Test\")" << flush; string s; testClient.testString(s, "Test"); - cout << " = " << s << endl; + cout << " = " << s << '\n'; if (s != "Test") { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_BASETYPES; } @@ -471,9 +471,9 @@ int main(int argc, char** argv) { cout << "secondService.secondTestString(\"foo\") => " << flush; std::string result; ssc.secondtestString(result, "foo"); - cout << "{" << result << "}" << endl; + cout << "{" << result << "}" << '\n'; } catch (std::exception& e) { - cout << " *** FAILED *** " << e.what() << endl; + cout << " *** FAILED *** " << e.what() << '\n'; return_code |= ERR_EXCEPTIONS; } } @@ -514,16 +514,16 @@ int main(int argc, char** argv) { #endif cout << "testString(" << str << ") = " << flush; testClient.testString(s, str); - cout << s << endl; + cout << s << '\n'; if (s != str) { cout.imbue(locale("en_US.UTF8")); - cout << "*** FAILED ***" << endl << "Expected string: " << str << " but got: " << s << endl << "CLEAR"; + cout << "*** FAILED ***" << '\n' << "Expected string: " << str << " but got: " << s << '\n' << "CLEAR"; return_code |= ERR_BASETYPES; } } catch (TTransportException&) { throw; } catch (exception& ex) { - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_BASETYPES; return return_code; } @@ -537,11 +537,11 @@ int main(int argc, char** argv) { " char-to-test-json-parsing: ]] \"]] \\\" }}}{ [[[ "); cout << "testString(" << str << ") = " << flush; testClient.testString(s, str); - cout << s << endl; + cout << s << '\n'; if (s != str) { cout.imbue(locale("en_US.UTF8")); - cout << "*** FAILED ***" << endl - << "Expected string: " << str << " but got: " << s << endl + cout << "*** FAILED ***" << '\n' + << "Expected string: " << str << " but got: " << s << '\n' << "CLEAR"; ; return_code |= ERR_BASETYPES; @@ -549,7 +549,7 @@ int main(int argc, char** argv) { } catch (TTransportException&) { throw; } catch (exception& ex) { - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_BASETYPES; return return_code; } @@ -614,15 +614,15 @@ int main(int argc, char** argv) { double expected = pow(static_cast(10), 307); cout << "testDouble(" << expected << ") = " << flush; double actual = testClient.testDouble(expected); - cout << "(" << actual << ")" << endl; + cout << "(" << actual << ")" << '\n'; if (expected - actual > pow(static_cast(10), 292)) { - cout << "*** FAILED ***" << endl - << "Expected: " << expected << " but got: " << actual << endl; + cout << "*** FAILED ***" << '\n' + << "Expected: " << expected << " but got: " << actual << '\n'; } } catch (TTransportException&) { throw; } catch (exception& ex) { - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_BASETYPES; } @@ -630,15 +630,15 @@ int main(int argc, char** argv) { double expected = pow(static_cast(10), -292); cout << "testDouble(" << expected << ") = " << flush; double actual = testClient.testDouble(expected); - cout << "(" << actual << ")" << endl; + cout << "(" << actual << ")" << '\n'; if (expected - actual > pow(static_cast(10), -307)) { - cout << "*** FAILED ***" << endl - << "Expected: " << expected << " but got: " << actual << endl; + cout << "*** FAILED ***" << '\n' + << "Expected: " << expected << " but got: " << actual << '\n'; } } catch (TTransportException&) { throw; } catch (exception& ex) { - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_BASETYPES; } @@ -677,7 +677,7 @@ int main(int argc, char** argv) { in.i32_thing, in.i64_thing); if (in != out) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_STRUCTS; } @@ -700,7 +700,7 @@ int main(int argc, char** argv) { in.i64_thing, in2.i32_thing); if (in2 != out2) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_STRUCTS; } @@ -735,9 +735,9 @@ int main(int argc, char** argv) { } cout << m_iter->first << " => " << m_iter->second; } - cout << "}" << endl; + cout << "}" << '\n'; if (mapin != mapout) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_CONTAINERS; } @@ -760,15 +760,15 @@ int main(int argc, char** argv) { first = false; cout << it->first << " => " << it->second; } - cout << "}" << endl; + cout << "}" << '\n'; if (smapin != smapout) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_CONTAINERS; } } catch (TTransportException&) { throw; } catch (exception& ex) { - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_CONTAINERS; } @@ -803,9 +803,9 @@ int main(int argc, char** argv) { } cout << *s_iter; } - cout << "}" << endl; + cout << "}" << '\n'; if (setin != setout) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_CONTAINERS; } @@ -817,14 +817,14 @@ int main(int argc, char** argv) { vector listout; testClient.testList(listout, vector()); if (!listout.empty()) { - cout << "*** FAILED ***" << endl; - cout << "invalid length: " << listout.size() << endl; + cout << "*** FAILED ***" << '\n'; + cout << "invalid length: " << listout.size() << '\n'; return_code |= ERR_CONTAINERS; } } catch (TTransportException&) { throw; } catch (exception& ex) { - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_CONTAINERS; } try { @@ -856,15 +856,15 @@ int main(int argc, char** argv) { } cout << *l_iter; } - cout << "}" << endl; + cout << "}" << '\n'; if (listin != listout) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_CONTAINERS; } } catch (TTransportException&) { throw; } catch (exception& ex) { - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_CONTAINERS; } @@ -873,41 +873,41 @@ int main(int argc, char** argv) { */ cout << "testEnum(ONE)" << flush; Numberz::type ret = testClient.testEnum(Numberz::ONE); - cout << " = " << ret << endl; + cout << " = " << ret << '\n'; if (ret != Numberz::ONE) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_STRUCTS; } cout << "testEnum(TWO)" << flush; ret = testClient.testEnum(Numberz::TWO); - cout << " = " << ret << endl; + cout << " = " << ret << '\n'; if (ret != Numberz::TWO) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_STRUCTS; } cout << "testEnum(THREE)" << flush; ret = testClient.testEnum(Numberz::THREE); - cout << " = " << ret << endl; + cout << " = " << ret << '\n'; if (ret != Numberz::THREE) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_STRUCTS; } cout << "testEnum(FIVE)" << flush; ret = testClient.testEnum(Numberz::FIVE); - cout << " = " << ret << endl; + cout << " = " << ret << '\n'; if (ret != Numberz::FIVE) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_STRUCTS; } cout << "testEnum(EIGHT)" << flush; ret = testClient.testEnum(Numberz::EIGHT); - cout << " = " << ret << endl; + cout << " = " << ret << '\n'; if (ret != Numberz::EIGHT) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_STRUCTS; } @@ -916,9 +916,9 @@ int main(int argc, char** argv) { */ cout << "testTypedef(309858235082523)" << flush; UserId uid = testClient.testTypedef(309858235082523LL); - cout << " = " << uid << endl; + cout << " = " << uid << '\n'; if (uid != 309858235082523LL) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_STRUCTS; } @@ -938,7 +938,7 @@ int main(int argc, char** argv) { } cout << "}, "; } - cout << "}" << endl; + cout << "}" << '\n'; if (mm.size() != 2 || mm[-4][-4] != -4 || mm[-4][-3] != -3 || @@ -948,7 +948,7 @@ int main(int argc, char** argv) { mm[4][3] != 3 || mm[4][2] != 2 || mm[4][1] != 1) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_CONTAINERS; } @@ -1005,7 +1005,7 @@ int main(int argc, char** argv) { } cout << "}, "; } - cout << "}" << endl; + cout << "}" << '\n'; bool failed = false; map >::const_iterator it1 = whoa.find(UserId(1)); if (whoa.size() != 2) { @@ -1033,7 +1033,7 @@ int main(int argc, char** argv) { } } if (failed) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_STRUCTS; } } @@ -1041,7 +1041,7 @@ int main(int argc, char** argv) { /** * MULTI TEST */ - cout << "testMulti()" << endl; + cout << "testMulti()" << '\n'; try { map mul_map; Xtruct mul_result; @@ -1054,13 +1054,13 @@ int main(int argc, char** argv) { xxs.i32_thing = 4242; xxs.i64_thing = 424242; if (mul_result != xxs) { - cout << "*** FAILED ***" << endl; + cout << "*** FAILED ***" << '\n'; return_code |= ERR_STRUCTS; } } catch (TTransportException&) { throw; } catch (exception& ex) { - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_STRUCTS; } @@ -1069,7 +1069,7 @@ int main(int argc, char** argv) { try { cout << "testClient.testException(\"Xception\") =>" << flush; testClient.testException("Xception"); - cout << " void\n*** FAILED ***" << endl; + cout << " void\n*** FAILED ***" << '\n'; return_code |= ERR_EXCEPTIONS; } catch (Xception& e) { @@ -1079,19 +1079,19 @@ int main(int argc, char** argv) { try { cout << "testClient.testException(\"TException\") =>" << flush; testClient.testException("TException"); - cout << " void\n*** FAILED ***" << endl; + cout << " void\n*** FAILED ***" << '\n'; return_code |= ERR_EXCEPTIONS; } catch (const TException&) { - cout << " Caught TException" << endl; + cout << " Caught TException" << '\n'; } try { cout << "testClient.testException(\"success\") =>" << flush; testClient.testException("success"); - cout << " void" << endl; + cout << " void" << '\n'; } catch (exception & ex) { \ - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_EXCEPTIONS; } @@ -1101,7 +1101,7 @@ int main(int argc, char** argv) { cout << "testClient.testMultiException(\"Xception\", \"test 1\") =>" << flush; Xtruct result; testClient.testMultiException(result, "Xception", "test 1"); - cout << " result\n*** FAILED ***" << endl; + cout << " result\n*** FAILED ***" << '\n'; return_code |= ERR_EXCEPTIONS; } catch (Xception& e) { printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str()); @@ -1111,7 +1111,7 @@ int main(int argc, char** argv) { cout << "testClient.testMultiException(\"Xception2\", \"test 2\") =>" << flush; Xtruct result; testClient.testMultiException(result, "Xception2", "test 2"); - cout << " result\n*** FAILED ***" << endl; + cout << " result\n*** FAILED ***" << '\n'; return_code |= ERR_EXCEPTIONS; } catch (Xception2& e) { @@ -1124,7 +1124,7 @@ int main(int argc, char** argv) { testClient.testMultiException(result, "success", "test 3"); printf(" {{\"%s\"}}\n", result.string_thing.c_str()); } catch (exception & ex) { \ - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return_code |= ERR_EXCEPTIONS; } @@ -1155,16 +1155,16 @@ int main(int argc, char** argv) { */ cout << "re-test testI32(-1)" << flush; int i32 = testClient.testI32(-1); - cout << " = " << i32 << endl; + cout << " = " << i32 << '\n'; if (i32 != -1) return_code |= ERR_BASETYPES; - cout << endl << "All tests done." << endl << flush; + cout << '\n' << "All tests done." << '\n' << flush; uint64_t stop = now(); uint64_t tot = stop - start; - cout << "Total time: " << stop - start << " us" << endl; + cout << "Total time: " << stop - start << " us" << '\n'; time_tot += tot; if (time_min == 0 || tot < time_min) { @@ -1181,9 +1181,9 @@ int main(int argc, char** argv) { uint64_t time_avg = time_tot / numTests; - cout << "Min time: " << time_min << " us" << endl; - cout << "Max time: " << time_max << " us" << endl; - cout << "Avg time: " << time_avg << " us" << endl; + cout << "Min time: " << time_min << " us" << '\n'; + cout << "Max time: " << time_max << " us" << '\n'; + cout << "Avg time: " << time_avg << " us" << '\n'; return return_code; } @@ -1225,26 +1225,26 @@ int binary_test(ThriftTestClient& testClient, string::size_type siz) string bin_request; string bin_result; - cout << "testBinary(siz = " << siz << ")" << endl; + cout << "testBinary(siz = " << siz << ")" << '\n'; binary_fill(bin_request, siz); try { testClient.testBinary(bin_result, bin_request); if (bin_request.size() != bin_result.size()) { - cout << "*** FAILED: request size " << bin_request.size() << "; result size " << bin_result.size() << endl; + cout << "*** FAILED: request size " << bin_request.size() << "; result size " << bin_result.size() << '\n'; return ERR_BASETYPES; } for (string::size_type i = 0; i < siz; ++i) { if (bin_request.at(i) != bin_result.at(i)) { - cout << "*** FAILED: at position " << i << " request[i] is h" << hex << bin_request.at(i) << " result[i] is h" << hex << bin_result.at(i) << endl; + cout << "*** FAILED: at position " << i << " request[i] is h" << hex << bin_request.at(i) << " result[i] is h" << hex << bin_result.at(i) << '\n'; return ERR_BASETYPES; } } } catch (TTransportException&) { throw; } catch (exception& ex) { - cout << "*** FAILED ***" << endl << ex.what() << endl; + cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; return ERR_BASETYPES; } diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index 6c61f402f8d..afd293814de 100644 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -394,7 +394,7 @@ class TestProcessorEventHandler : public TProcessorEventHandler { } void communicate(const char* event, void* ctx, const char* fn_name) { - std::cout << event << ": " << *static_cast(ctx) << " = " << fn_name << std::endl; + std::cout << event << ": " << *static_cast(ctx) << " = " << fn_name << '\n'; } }; @@ -655,7 +655,7 @@ int main(int argc, char** argv) { } } catch (std::exception& e) { - cerr << e.what() << endl; + cerr << e.what() << '\n'; cout << desc << "\n"; return 1; } @@ -767,7 +767,7 @@ int main(int argc, char** argv) { if (port != 0) { cout << port; } - cout << endl; + cout << '\n'; // Multiplexed Processor if needed if (boost::starts_with(protocol_type, "multi")) { @@ -823,7 +823,7 @@ int main(int argc, char** argv) { : new transport::TNonblockingServerSocket(port)); server.reset(new TNonblockingServer(testProcessor, protocolFactory, nbSocket)); } else { - cerr << "server-type nonblocking requires transport of http or framed" << endl; + cerr << "server-type nonblocking requires transport of http or framed" << '\n'; exit(1); } } @@ -857,6 +857,6 @@ int main(int argc, char** argv) { server.reset(); } - cout << "done." << endl; + cout << "done." << '\n'; return 0; } diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp index 520841143b4..02e7b17ce8c 100644 --- a/tutorial/cpp/CppClient.cpp +++ b/tutorial/cpp/CppClient.cpp @@ -43,9 +43,9 @@ int main() { transport->open(); client.ping(); - cout << "ping()" << endl; + cout << "ping()" << '\n'; - cout << "1 + 1 = " << client.add(1, 1) << endl; + cout << "1 + 1 = " << client.add(1, 1) << '\n'; Work work; work.op = Operation::DIVIDE; @@ -54,27 +54,27 @@ int main() { try { client.calculate(1, work); - cout << "Whoa? We can divide by zero!" << endl; + cout << "Whoa? We can divide by zero!" << '\n'; } catch (InvalidOperation& io) { - cout << "InvalidOperation: " << io.why << endl; - // or using generated operator<<: cout << io << endl; - // or by using std::exception native method what(): cout << io.what() << endl; + cout << "InvalidOperation: " << io.why << '\n'; + // or using generated operator<<: cout << io << '\n'; + // or by using std::exception native method what(): cout << io.what() << '\n'; } work.op = Operation::SUBTRACT; work.num1 = 15; work.num2 = 10; int32_t diff = client.calculate(1, work); - cout << "15 - 10 = " << diff << endl; + cout << "15 - 10 = " << diff << '\n'; // Note that C++ uses return by reference for complex types to avoid // costly copy construction SharedStruct ss; client.getStruct(ss, 1); - cout << "Received log: " << ss << endl; + cout << "Received log: " << ss << '\n'; transport->close(); } catch (TException& tx) { - cout << "ERROR: " << tx.what() << endl; + cout << "ERROR: " << tx.what() << '\n'; } } diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp index 635afefda0d..4c66cb894d5 100644 --- a/tutorial/cpp/CppServer.cpp +++ b/tutorial/cpp/CppServer.cpp @@ -48,15 +48,15 @@ class CalculatorHandler : public CalculatorIf { public: CalculatorHandler() = default; - void ping() override { cout << "ping()" << endl; } + void ping() override { cout << "ping()" << '\n'; } int32_t add(const int32_t n1, const int32_t n2) override { - cout << "add(" << n1 << ", " << n2 << ")" << endl; + cout << "add(" << n1 << ", " << n2 << ")" << '\n'; return n1 + n2; } int32_t calculate(const int32_t logid, const Work& work) override { - cout << "calculate(" << logid << ", " << work << ")" << endl; + cout << "calculate(" << logid << ", " << work << ")" << '\n'; int32_t val; switch (work.op) { @@ -95,11 +95,11 @@ class CalculatorHandler : public CalculatorIf { } void getStruct(SharedStruct& ret, const int32_t logid) override { - cout << "getStruct(" << logid << ")" << endl; + cout << "getStruct(" << logid << ")" << '\n'; ret = log[logid]; } - void zip() override { cout << "zip()" << endl; } + void zip() override { cout << "zip()" << '\n'; } protected: map log; @@ -172,8 +172,8 @@ int main() { threadManager); */ - cout << "Starting the server..." << endl; + cout << "Starting the server..." << '\n'; server.serve(); - cout << "Done." << endl; + cout << "Done." << '\n'; return 0; } From f41fae1995b973d6dfc11d7a62e0d42a9d62838b Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Wed, 24 Apr 2024 23:54:45 +0200 Subject: [PATCH 223/250] THRIFT-5780 Prevent certain warnings related to net8 Client: netstd Patch: Jens Geyer This closes #2965 --- compiler/cpp/src/thrift/generate/t_netstd_generator.cc | 2 ++ lib/netstd/Thrift/Transport/Client/THttpTransport.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc index 6e464549784..c16a0694c0b 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc @@ -2019,6 +2019,8 @@ void t_netstd_generator::generate_deprecation_attribute(ostream& out, t_function // empty annotation values end up with "1" somewhere, ignore these as well if ((iter->second.back().length() > 0) && (iter->second.back() != "1")) { out << "(" << make_csharp_string_literal(iter->second.back()) << ")"; + } else { + out << "(" << make_csharp_string_literal("This code is deprecated.") << ")"; // generic message to prevent CA1041 } out << "]" << '\n'; } diff --git a/lib/netstd/Thrift/Transport/Client/THttpTransport.cs b/lib/netstd/Thrift/Transport/Client/THttpTransport.cs index 1ab1caf729c..e724665fecd 100644 --- a/lib/netstd/Thrift/Transport/Client/THttpTransport.cs +++ b/lib/netstd/Thrift/Transport/Client/THttpTransport.cs @@ -25,6 +25,8 @@ using System.Threading; using System.Threading.Tasks; +#pragma warning disable IDE0079 // unneeded suppression -> all except net8 +#pragma warning disable IDE0301 // simplify collection init -> net8 only namespace Thrift.Transport.Client { From 7dabb7ebdd46ded9f89bf0594357c406b1b8a8f4 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 26 Apr 2024 00:23:35 +0200 Subject: [PATCH 224/250] THRIFT-5781 implement full deprecation support Client: netstd Patch: Jens Geyer --- .../src/thrift/generate/t_netstd_generator.cc | 114 ++++++++++++++++-- .../src/thrift/generate/t_netstd_generator.h | 4 +- 2 files changed, 109 insertions(+), 9 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc index c16a0694c0b..e6176a7e187 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc @@ -219,6 +219,10 @@ void t_netstd_generator::pragmas_and_directives(ostream& out) out << "#pragma warning disable IDE1006 // parts of the code use IDL spelling" << '\n'; out << "#pragma warning disable CA1822 // empty " << DEEP_COPY_METHOD_NAME << "() methods still non-static" << '\n'; + if( any_deprecations()) { + out << "#pragma warning disable CS0618 // silence our own deprecation warnings" << '\n'; + } + if( target_net_version < 6) { out << "#pragma warning disable IDE0083 // pattern matching \"that is not SomeType\" requires net5.0 but we still support earlier versions" << '\n'; } @@ -226,6 +230,86 @@ void t_netstd_generator::pragmas_and_directives(ostream& out) } +bool t_netstd_generator::any_deprecations() +{ + // enums + vector enums = program_->get_enums(); + vector::iterator en_iter; + for (en_iter = enums.begin(); en_iter != enums.end(); ++en_iter) { + if( is_deprecated((*en_iter)->annotations_)) { + return true; + } + + // enum values + vector evals = (*en_iter)->get_constants(); + vector::iterator ev_iter; + for (ev_iter = evals.begin(); ev_iter != evals.end(); ++ev_iter) { + if( is_deprecated((*ev_iter)->annotations_)) { + return true; + } + } + } + + // typedefs + vector typedefs = program_->get_typedefs(); + vector::iterator td_iter; + for (td_iter = typedefs.begin(); td_iter != typedefs.end(); ++td_iter) { + if( is_deprecated((*td_iter)->annotations_)) { + return true; + } + } + + // structs, exceptions, unions + vector objects = program_->get_objects(); + vector::iterator o_iter; + for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) { + if( is_deprecated((*o_iter)->annotations_)) { + return true; + } + + // struct members + const vector& members = (*o_iter)->get_members(); + vector::const_iterator m_iter; + for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + if( is_deprecated((*m_iter)->annotations_)) { + return true; + } + } + } + + /* not yet + // constants + vector consts = program_->get_consts(); + vector::iterator c_iter; + for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) { + if( is_deprecated((*c_iter)->annotations_)) { + return true; + } + } + */ + + // services + vector services = program_->get_services(); + vector::iterator sv_iter; + for (sv_iter = services.begin(); sv_iter != services.end(); ++sv_iter) { + if( is_deprecated((*sv_iter)->annotations_)) { + return true; + } + + // service methods + vector functions = (*sv_iter)->get_functions(); + vector::iterator f_iter; + for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { + if( is_deprecated((*f_iter)->annotations_)) { + return true; + } + } + } + + return false; +} + + void t_netstd_generator::start_netstd_namespace(ostream& out) { if (!namespace_name_.empty()) @@ -315,6 +399,7 @@ void t_netstd_generator::generate_enum(ostream& out, t_enum* tenum) start_netstd_namespace(out); generate_netstd_doc(out, tenum); + generate_deprecation_attribute(out, tenum->annotations_); out << indent() << "public enum " << type_name(tenum,false) << '\n'; scope_up(out); @@ -325,6 +410,7 @@ void t_netstd_generator::generate_enum(ostream& out, t_enum* tenum) { generate_netstd_doc(out, *c_iter); int value = (*c_iter)->get_value(); + generate_deprecation_attribute(out, (*c_iter)->annotations_); out << indent() << normalize_name((*c_iter)->get_name()) << " = " << value << "," << '\n'; } @@ -850,6 +936,7 @@ void t_netstd_generator::generate_netstd_struct_definition(ostream& out, t_struc string sharp_struct_name = type_name(tstruct, false); + generate_deprecation_attribute(out, tstruct->annotations_); out << indent() << "public " << (is_final ? "sealed " : "") << "partial class " << sharp_struct_name << " : "; if (is_exception) @@ -1055,6 +1142,7 @@ void t_netstd_generator::generate_netstd_wcffault(ostream& out, t_struct* tstruc bool is_final = tstruct->annotations_.find("final") != tstruct->annotations_.end(); + generate_deprecation_attribute(out, tstruct->annotations_); out << indent() << "public " << (is_final ? "sealed " : "") << "partial class " << type_name(tstruct,false) << "Fault" << '\n' << indent() << "{" << '\n'; indent_up(); @@ -1103,7 +1191,7 @@ void t_netstd_generator::generate_netstd_deepcopy_method(ostream& out, t_struct* out << '\n' << indent() << "{" << '\n'; indent_up(); } else { - out << '\n'; + out << ";\n"; } for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { @@ -1526,6 +1614,7 @@ void t_netstd_generator::generate_netstd_union_definition(ostream& out, t_struct // Let's define the class first start_netstd_namespace(out); + generate_deprecation_attribute(out, tunion->annotations_); out << indent() << "public abstract partial class " << normalize_name(tunion->get_name()) << " : TUnionBase" << '\n'; out << indent() << "{" << '\n'; indent_up(); @@ -1979,6 +2068,7 @@ void t_netstd_generator::generate_service_interface(ostream& out, t_service* tse out << indent() << "[ServiceContract(Namespace=\"" << wcf_namespace_ << "\")]" << '\n'; } + generate_deprecation_attribute(out, tservice->annotations_); prepare_member_name_mapping(tservice); out << indent() << "public interface IAsync" << extends_iface << '\n' << indent() << "{" << '\n'; @@ -2003,7 +2093,7 @@ void t_netstd_generator::generate_service_interface(ostream& out, t_service* tse } } - generate_deprecation_attribute(out, *f_iter); + generate_deprecation_attribute(out, (*f_iter)->annotations_); out << indent() << function_signature_async(*f_iter) << ";" << '\n' << '\n'; } indent_down(); @@ -2011,10 +2101,16 @@ void t_netstd_generator::generate_service_interface(ostream& out, t_service* tse cleanup_member_name_mapping(tservice); } -void t_netstd_generator::generate_deprecation_attribute(ostream& out, t_function* func) +bool t_netstd_generator::is_deprecated(std::map>& annotations) +{ + auto iter = annotations.find("deprecated"); + return (annotations.end() != iter); +} + +void t_netstd_generator::generate_deprecation_attribute(ostream& out, std::map>& annotations) { - auto iter = func->annotations_.find("deprecated"); - if( func->annotations_.end() != iter) { + auto iter = annotations.find("deprecated"); + if( annotations.end() != iter) { out << indent() << "[Obsolete"; // empty annotation values end up with "1" somewhere, ignore these as well if ((iter->second.back().length() > 0) && (iter->second.back() != "1")) { @@ -2066,6 +2162,7 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi out << '\n'; generate_netstd_doc(out, tservice); + generate_deprecation_attribute(out, tservice->annotations_); prepare_member_name_mapping(tservice); out << indent() << "public class Client : " << extends_client << "IAsync" << '\n' << indent() << "{" << '\n'; @@ -2089,7 +2186,7 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi string function_name = raw_func_name + (add_async_postfix ? "Async" : ""); // async - generate_deprecation_attribute(out, *functions_iterator); + generate_deprecation_attribute(out, (*functions_iterator)->annotations_); out << indent() << "public async " << function_signature_async(*functions_iterator, "") << '\n' << indent() << "{" << '\n'; indent_up(); @@ -2107,7 +2204,7 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi out << indent() << "}" << '\n' << '\n'; // async send - generate_deprecation_attribute(out, *functions_iterator); + generate_deprecation_attribute(out, (*functions_iterator)->annotations_); out << indent() << "public async " << function_signature_async(*functions_iterator, "send_", MODE_NO_RETURN) << '\n' << indent() << "{" << '\n'; indent_up(); @@ -2148,7 +2245,7 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi if (!(*functions_iterator)->is_oneway()) { // async recv - generate_deprecation_attribute(out, *functions_iterator); + generate_deprecation_attribute(out, (*functions_iterator)->annotations_); out << indent() << "public async " << function_signature_async(*functions_iterator, "recv_", MODE_NO_ARGS) << '\n' << indent() << "{" << '\n'; indent_up(); @@ -3022,6 +3119,7 @@ void t_netstd_generator::generate_netstd_property(ostream& out, t_field* tfield, { out << indent() << "[DataMember(Order = 0)]" << '\n'; } + generate_deprecation_attribute(out, tfield->annotations_); out << indent() << (isPublic ? "public " : "private ") diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.h b/compiler/cpp/src/thrift/generate/t_netstd_generator.h index a6e4d90a496..c65414a4cdc 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.h +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.h @@ -104,7 +104,7 @@ class t_netstd_generator : public t_oop_generator void generate_netstd_union_reader(ostream& out, t_struct* tunion); void generate_function_helpers(ostream& out, t_function* tfunction); void generate_service_interface(ostream& out, t_service* tservice); - void generate_deprecation_attribute(ostream& out, t_function* func); + void generate_deprecation_attribute(ostream& out, std::map>& annotations); void generate_service_helpers(ostream& out, t_service* tservice); void generate_service_client(ostream& out, t_service* tservice); void generate_service_server(ostream& out, t_service* tservice); @@ -218,6 +218,8 @@ class t_netstd_generator : public t_oop_generator string initialize_field(t_field* tfield); void pragmas_and_directives(ostream& out); + bool any_deprecations(); + bool is_deprecated(std::map>& annotations); bool is_nullable_type(t_type* ttype); bool force_member_nullable(t_field* tfield); // see there string nullable_suffix(); // unconditionally From 5eb74762f7395c300879839277b6d5300e853214 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 27 Apr 2024 00:08:15 +0200 Subject: [PATCH 225/250] THRIFT-5782 implement full deprecation support Client: Delphi Patch: Jens Geyer plus a minor netstd fix --- .../src/thrift/generate/t_delphi_generator.cc | 70 ++++++++++++++----- .../src/thrift/generate/t_netstd_generator.cc | 5 +- 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc index d5e8d5d2229..f624bb048bb 100644 --- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc @@ -191,6 +191,9 @@ class t_delphi_generator : public t_oop_generator { t_struct* tstruct, bool is_exception); + bool is_deprecated(std::map>& annotations); + std::string render_deprecation_attribute(std::map>& annotations, std::string prefix, std::string postfix); + bool const_needs_var(t_type* type); void print_const_prop(std::ostream& out, string name, t_type* type, t_const_value* value); void print_private_field(std::ostream& out, string name, t_type* type, t_const_value* value); @@ -961,11 +964,12 @@ void t_delphi_generator::generate_enum(t_enum* tenum) { } generate_delphi_doc(s_enum, *c_iter); indent(s_enum) << normalize_name((*c_iter)->get_name()) << " = " << value; + s_enum << render_deprecation_attribute((*c_iter)->annotations_, " // ", ""); } } s_enum << '\n'; indent_down(); - indent(s_enum) << ");" << '\n' << '\n'; + indent(s_enum) << ")" << render_deprecation_attribute(tenum->annotations_, " ", "") << ";" << '\n' << '\n'; indent_down(); } @@ -1709,7 +1713,9 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, } indent_down(); - indent(out) << "end;" << '\n'; + indent(out) << "end;" + << render_deprecation_attribute(tstruct->annotations_, " // ", "") + << '\n'; if(rtti_) { indent(out) << "{$IFNDEF TYPEINFO_WAS_ON} {$TYPEINFO OFF} {$ENDIF}" << '\n'; } @@ -1800,11 +1806,11 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, indent_up(); if ((members.size() > 0) && is_exception && (!is_x_factory)) { - indent(out) << "constructor Create; overload;" << '\n'; + indent(out) << "constructor Create; overload;" << render_deprecation_attribute(tstruct->annotations_," ",";") << '\n'; indent(out) << "constructor Create(" << constructor_argument_list(tstruct, indent()) - << "); overload;" << '\n'; + << "); overload;" << render_deprecation_attribute(tstruct->annotations_," ",";") << '\n'; } else { - indent(out) << "constructor Create;" << '\n'; + indent(out) << "constructor Create;" << render_deprecation_attribute(tstruct->annotations_," ",";") << '\n'; } indent(out) << "destructor Destroy; override;" << '\n'; @@ -1905,7 +1911,9 @@ void t_delphi_generator::generate_service_interface(t_service* tservice, bool fo indent(s_service) << function_signature(*f_iter, for_async) << '\n'; } indent_down(); - indent(s_service) << "end;" << '\n' << '\n'; + indent(s_service) << "end;" + << render_deprecation_attribute( tservice->annotations_, " // ", "") + << '\n' << '\n'; indent_down(); } @@ -2222,7 +2230,9 @@ void t_delphi_generator::generate_service_client(t_service* tservice) { } indent_down(); - indent(s_service) << "end;" << '\n' << '\n'; + indent(s_service) << "end;" + << render_deprecation_attribute( tservice->annotations_, " // ", "") + << '\n' << '\n'; } void t_delphi_generator::generate_service_server(t_service* tservice) { @@ -2990,7 +3000,9 @@ void t_delphi_generator::generate_delphi_property(ostream& out, << type_name(ftype, false, true, is_xception, true) << " read " << prop_name(tfield, struct_is_xception, fieldPrefix) << " write " << prop_name(tfield, struct_is_xception, "Set") - << ";" << '\n'; + << ";" + << render_deprecation_attribute(tfield->annotations_, " // ", ";") + << '\n'; } std::string t_delphi_generator::prop_name(t_field* tfield, bool is_xception, std::string prefix) { @@ -3238,15 +3250,7 @@ string t_delphi_generator::function_signature(t_function* tfunction, // deprecated method? only at intf decl! if( full_cls == "") { - auto iter = tfunction->annotations_.find("deprecated"); - if( tfunction->annotations_.end() != iter && !iter->second.empty()) { - signature += " deprecated"; - // empty annotation values end up with "1" somewhere, ignore these as well - if ((iter->second.back().length() > 0) && (iter->second.back() != "1")) { - signature += " " + make_pascal_string_literal(iter->second.back()); - } - signature += ";"; - } + signature += render_deprecation_attribute(tfunction->annotations_, " ", ";"); } return signature; @@ -3417,6 +3421,7 @@ void t_delphi_generator::generate_delphi_property_writer_definition(ostream& out indent(out) << "procedure " << prop_name(tfield, is_xception_class, "Set") << "( const Value: " << type_name(ftype, false, true, is_xception, true) << ");" + << render_deprecation_attribute(tfield->annotations_, " ", ";") << '\n'; } @@ -3427,7 +3432,9 @@ void t_delphi_generator::generate_delphi_property_reader_definition(ostream& out bool is_xception = ftype->is_xception(); indent(out) << "function " << prop_name(tfield, is_xception_class, "Get") << ": " - << type_name(ftype, false, true, is_xception, true) << ";" << '\n'; + << type_name(ftype, false, true, is_xception, true) << ";" + << render_deprecation_attribute(tfield->annotations_, " ", ";") + << '\n'; } void t_delphi_generator::generate_delphi_isset_reader_writer_definition(ostream& out, @@ -4043,6 +4050,33 @@ std::string t_delphi_generator::display_name() const { } +bool t_delphi_generator::is_deprecated(std::map>& annotations) +{ + auto iter = annotations.find("deprecated"); + return (annotations.end() != iter); +} + +std::string t_delphi_generator::render_deprecation_attribute(std::map>& annotations, std::string prefix, std::string postfix) +{ + std::string result = ""; + auto iter = annotations.find("deprecated"); + if( annotations.end() != iter) { + result += prefix; + result += "deprecated"; + + // empty annotation values end up with "1" somewhere, ignore these as well + if ((iter->second.back().length() > 0) && (iter->second.back() != "1")) { + result += " " + make_pascal_string_literal(iter->second.back()); + } + + result += postfix; + } + return result; +} + + + + THRIFT_REGISTER_GENERATOR( delphi, "Delphi", diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc index e6176a7e187..feb58a0aa2e 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc @@ -2519,8 +2519,7 @@ void t_netstd_generator::generate_process_function_async(ostream& out, t_service const vector& fields = arg_struct->get_members(); vector::const_iterator f_iter; - bool is_deprecated = (tfunction->annotations_.end() != tfunction->annotations_.find("deprecated")); - if( is_deprecated) { + if( is_deprecated(tfunction->annotations_)) { out << indent() << "#pragma warning disable CS0618,CS0612" << '\n'; } @@ -2558,7 +2557,7 @@ void t_netstd_generator::generate_process_function_async(ostream& out, t_service out << "" << CANCELLATION_TOKEN_NAME << ");" << '\n'; - if( is_deprecated) { + if( is_deprecated(tfunction->annotations_)) { out << indent() << "#pragma warning restore CS0618,CS0612" << '\n'; } From b46493db010f875ece03d3f14eac95aebd00c1f3 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Mon, 29 Apr 2024 15:16:39 -0700 Subject: [PATCH 226/250] go: Define a bytePool for TRichTransport Client: go TBinaryProtocol and TCompactProtocol (and as an extension, THeaderProtocol) use TRichTransport's ReadByte/WriteByte functions a lot under the hood, and in some extreme cases those ReadByte/WriteByte calls can generate a lot of allocations for the byte they used. Use a resource pool to help reduce the allocations. --- lib/go/thrift/rich_transport.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/go/thrift/rich_transport.go b/lib/go/thrift/rich_transport.go index 83fdf29f5cb..f3d819e2330 100644 --- a/lib/go/thrift/rich_transport.go +++ b/lib/go/thrift/rich_transport.go @@ -49,9 +49,15 @@ func (r *RichTransport) RemainingBytes() (num_bytes uint64) { return r.TTransport.RemainingBytes() } +var bytePool = newPool(nil, func(b *[1]byte) { + b[0] = 0 +}) + func readByte(r io.Reader) (c byte, err error) { - v := [1]byte{0} - n, err := r.Read(v[0:1]) + v := bytePool.get() + defer bytePool.put(&v) + + n, err := r.Read(v[:]) if n > 0 && (err == nil || errors.Is(err, io.EOF)) { return v[0], nil } @@ -65,7 +71,10 @@ func readByte(r io.Reader) (c byte, err error) { } func writeByte(w io.Writer, c byte) error { - v := [1]byte{c} - _, err := w.Write(v[0:1]) + v := bytePool.get() + defer bytePool.put(&v) + + v[0] = c + _, err := w.Write(v[:]) return err } From d30fe96a5c7e03fef4eabda0a1a7b72a7735351e Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Wed, 1 May 2024 09:17:09 -0700 Subject: [PATCH 227/250] Revert "go: Define a bytePool for TRichTransport" This reverts commit 344498b67f42af38118cc250b0b1ec212f09d927. In our extreme case this actually made things worse. On 30s cpu profiles, although mallocgc reduced from 27.13s to 26.30s, the byte pool itself costed 11.9s. Looking at writeByte and readByte, writeByte increased from 3.69s to 5.89s, and readByte increased from 11.36s to 16.09s. --- lib/go/thrift/rich_transport.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/go/thrift/rich_transport.go b/lib/go/thrift/rich_transport.go index f3d819e2330..83fdf29f5cb 100644 --- a/lib/go/thrift/rich_transport.go +++ b/lib/go/thrift/rich_transport.go @@ -49,15 +49,9 @@ func (r *RichTransport) RemainingBytes() (num_bytes uint64) { return r.TTransport.RemainingBytes() } -var bytePool = newPool(nil, func(b *[1]byte) { - b[0] = 0 -}) - func readByte(r io.Reader) (c byte, err error) { - v := bytePool.get() - defer bytePool.put(&v) - - n, err := r.Read(v[:]) + v := [1]byte{0} + n, err := r.Read(v[0:1]) if n > 0 && (err == nil || errors.Is(err, io.EOF)) { return v[0], nil } @@ -71,10 +65,7 @@ func readByte(r io.Reader) (c byte, err error) { } func writeByte(w io.Writer, c byte) error { - v := bytePool.get() - defer bytePool.put(&v) - - v[0] = c - _, err := w.Write(v[:]) + v := [1]byte{c} + _, err := w.Write(v[0:1]) return err } From db838881602c4aebf116187a06bcb31bb76ce6dd Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Wed, 1 May 2024 18:49:15 +0200 Subject: [PATCH 228/250] THRIFT-5783 drop net7 support Client: netstd Patch: Jens Geyer --- .../Thrift.Benchmarks/Thrift.Benchmarks.csproj | 2 +- .../Thrift.IntegrationTests.csproj | 10 +++++----- .../Thrift.PublicInterfaces.Compile.Tests.csproj | 2 +- lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj | 8 ++++---- lib/netstd/Thrift/Thrift.csproj | 4 ++-- test/netstd/Client/Client.csproj | 2 +- test/netstd/Server/Server.csproj | 2 +- tutorial/netstd/Interfaces/Interfaces.csproj | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj index a8543a3bf37..fefaaadcb87 100644 --- a/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj +++ b/lib/netstd/Benchmarks/Thrift.Benchmarks/Thrift.Benchmarks.csproj @@ -28,7 +28,7 @@ - + diff --git a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj index 5602f91292b..2cb634937a0 100644 --- a/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj +++ b/lib/netstd/Tests/Thrift.IntegrationTests/Thrift.IntegrationTests.csproj @@ -35,11 +35,11 @@ - - - - - + + + + + diff --git a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj index 5745bd9dae9..e96d2fe3ac8 100644 --- a/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj +++ b/lib/netstd/Tests/Thrift.PublicInterfaces.Compile.Tests/Thrift.PublicInterfaces.Compile.Tests.csproj @@ -38,7 +38,7 @@ - + diff --git a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj index 7f9dcb7cbb5..0a9cff0c94c 100644 --- a/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj +++ b/lib/netstd/Tests/Thrift.Tests/Thrift.Tests.csproj @@ -26,10 +26,10 @@ - - - - + + + + diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj index da93da496ec..da0057d8583 100644 --- a/lib/netstd/Thrift/Thrift.csproj +++ b/lib/netstd/Thrift/Thrift.csproj @@ -19,7 +19,7 @@ --> - netstandard2.1;netstandard2.0;net6.0;net7.0;net8.0 + netstandard2.1;netstandard2.0;net6.0;net8.0 Thrift ApacheThrift true @@ -89,7 +89,7 @@ - 8.0.0 + 8.0.4 diff --git a/test/netstd/Client/Client.csproj b/test/netstd/Client/Client.csproj index 977303bbc58..8a904dde1e4 100644 --- a/test/netstd/Client/Client.csproj +++ b/test/netstd/Client/Client.csproj @@ -37,7 +37,7 @@ - + diff --git a/test/netstd/Server/Server.csproj b/test/netstd/Server/Server.csproj index 359578a4e29..1bf48d9638a 100644 --- a/test/netstd/Server/Server.csproj +++ b/test/netstd/Server/Server.csproj @@ -38,7 +38,7 @@ - + diff --git a/tutorial/netstd/Interfaces/Interfaces.csproj b/tutorial/netstd/Interfaces/Interfaces.csproj index 576722ba591..73a09358ac1 100644 --- a/tutorial/netstd/Interfaces/Interfaces.csproj +++ b/tutorial/netstd/Interfaces/Interfaces.csproj @@ -19,7 +19,7 @@ --> - net6.0 + net8.0 Interfaces Interfaces 0.21.0.0 @@ -34,7 +34,7 @@ - + From 504d3eb5be776dc1b6bf6dd6089a533b951888f3 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Thu, 2 May 2024 10:28:38 +0200 Subject: [PATCH 229/250] THRIFT-5782 implement full deprecation support Client: Delphi Patch: Jens Geyer FIX: end-of-line comments may cause uncompileable code --- compiler/cpp/src/thrift/generate/t_delphi_generator.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc index f624bb048bb..2a428dc1cb1 100644 --- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc @@ -964,7 +964,7 @@ void t_delphi_generator::generate_enum(t_enum* tenum) { } generate_delphi_doc(s_enum, *c_iter); indent(s_enum) << normalize_name((*c_iter)->get_name()) << " = " << value; - s_enum << render_deprecation_attribute((*c_iter)->annotations_, " // ", ""); + s_enum << render_deprecation_attribute((*c_iter)->annotations_, " {", "}"); } } s_enum << '\n'; @@ -1714,7 +1714,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out, indent_down(); indent(out) << "end;" - << render_deprecation_attribute(tstruct->annotations_, " // ", "") + << render_deprecation_attribute(tstruct->annotations_, " {", "}") << '\n'; if(rtti_) { indent(out) << "{$IFNDEF TYPEINFO_WAS_ON} {$TYPEINFO OFF} {$ENDIF}" << '\n'; @@ -1912,7 +1912,7 @@ void t_delphi_generator::generate_service_interface(t_service* tservice, bool fo } indent_down(); indent(s_service) << "end;" - << render_deprecation_attribute( tservice->annotations_, " // ", "") + << render_deprecation_attribute( tservice->annotations_, " {", "}") << '\n' << '\n'; indent_down(); @@ -2231,7 +2231,7 @@ void t_delphi_generator::generate_service_client(t_service* tservice) { indent_down(); indent(s_service) << "end;" - << render_deprecation_attribute( tservice->annotations_, " // ", "") + << render_deprecation_attribute( tservice->annotations_, " {", "}") << '\n' << '\n'; } @@ -3001,7 +3001,7 @@ void t_delphi_generator::generate_delphi_property(ostream& out, << " read " << prop_name(tfield, struct_is_xception, fieldPrefix) << " write " << prop_name(tfield, struct_is_xception, "Set") << ";" - << render_deprecation_attribute(tfield->annotations_, " // ", ";") + << render_deprecation_attribute(tfield->annotations_, " {", "}") << '\n'; } From e0cb6b41a67dcc87033cb5d7d841003c3e4e1082 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 9 May 2024 17:58:43 -0700 Subject: [PATCH 230/250] go: Use errors.Is over == Client: go Fix 2 instances we are using == to check on error but should have used errors.Is instead. --- lib/go/thrift/header_transport.go | 4 ++-- lib/go/thrift/simple_json_protocol.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/go/thrift/header_transport.go b/lib/go/thrift/header_transport.go index 3aea5a9888d..772d922a456 100644 --- a/lib/go/thrift/header_transport.go +++ b/lib/go/thrift/header_transport.go @@ -128,7 +128,7 @@ var _ io.ReadCloser = (*TransformReader)(nil) // // If you don't know the closers capacity beforehand, just use // -// &TransformReader{Reader: baseReader} +// &TransformReader{Reader: baseReader} // // instead would be sufficient. func NewTransformReaderWithCapacity(baseReader io.Reader, capacity int) *TransformReader { @@ -544,7 +544,7 @@ func (t *THeaderTransport) Read(p []byte) (read int, err error) { // the last Read finished the frame, do endOfFrame // handling here. err = t.endOfFrame() - } else if err == io.EOF { + } else if errors.Is(err, io.EOF) { err = t.endOfFrame() if err != nil { return diff --git a/lib/go/thrift/simple_json_protocol.go b/lib/go/thrift/simple_json_protocol.go index da12248a17f..f7fe68c23d2 100644 --- a/lib/go/thrift/simple_json_protocol.go +++ b/lib/go/thrift/simple_json_protocol.go @@ -1195,7 +1195,7 @@ func (p *TSimpleJSONProtocol) readNumeric() (Numeric, error) { for continueFor { c, err := p.reader.ReadByte() if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { break } return NUMERIC_NULL, NewTProtocolException(err) From 64ef20997e87d37536a5d0fd512343457e502a0d Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 2 May 2024 16:50:08 -0700 Subject: [PATCH 231/250] THRIFT-5784: Add THeaderTransforms to TConfiguration Client: go While I'm here, also auto add compression transforms read (currently only zlib is supported) to writeTransforms so that a server will auto use the same compression on the responses as the client chose to use in the requests. --- lib/go/test/tests/header_zlib_test.go | 206 ++++++++++++++++++++++++++ lib/go/thrift/configuration.go | 76 ++++++---- lib/go/thrift/header_protocol.go | 5 + lib/go/thrift/header_protocol_test.go | 20 +++ lib/go/thrift/header_transport.go | 46 +++++- 5 files changed, 316 insertions(+), 37 deletions(-) create mode 100644 lib/go/test/tests/header_zlib_test.go diff --git a/lib/go/test/tests/header_zlib_test.go b/lib/go/test/tests/header_zlib_test.go new file mode 100644 index 00000000000..cf2f849358a --- /dev/null +++ b/lib/go/test/tests/header_zlib_test.go @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package tests + +import ( + "context" + "errors" + "io" + "net" + "sync/atomic" + "testing" + "time" + + "github.com/apache/thrift/lib/go/test/gopath/src/servicestest" + "github.com/apache/thrift/lib/go/thrift" +) + +type zlibTestHandler struct { + servicestest.AServ + + tb testing.TB + text string +} + +func (z zlibTestHandler) Stringfunc_1int_1s(ctx context.Context, i int64, s string) (string, error) { + if s != z.text { + z.tb.Errorf("string arg got %q want %q", s, z.text) + } + return z.text, nil +} + +type countingProxy struct { + // Need to fill when constructing + tb testing.TB + remoteAddr net.Addr + + // internal states + listener net.Listener + clientWritten atomic.Int64 + serverWritten atomic.Int64 +} + +func (cp *countingProxy) getAndResetCounters() (req, resp int64) { + req = cp.clientWritten.Swap(0) + resp = cp.serverWritten.Swap(0) + return req, resp +} + +func (cp *countingProxy) serve() { + cp.tb.Helper() + + listener, err := net.Listen("tcp", ":0") + if err != nil { + cp.tb.Fatalf("Failed to listen proxy: %v", err) + } + go func() { + for { + client, err := listener.Accept() + if err != nil { + if !errors.Is(err, io.EOF) && !errors.Is(err, net.ErrClosed) { + cp.tb.Errorf("proxy accept error: %v", err) + } + return + } + server, err := net.Dial(cp.remoteAddr.Network(), cp.remoteAddr.String()) + if err != nil { + cp.tb.Logf("proxy failed to dial server %v: %v", cp.remoteAddr, err) + } + proxy := func(read, write net.Conn, count *atomic.Int64) { + var buf [1024]byte + for { + n, err := read.Read(buf[:]) + if n > 0 { + count.Add(int64(n)) + if _, err := write.Write(buf[:n]); err != nil { + cp.tb.Errorf("proxy write error: %v", err) + } + } + if err != nil { + if !errors.Is(err, io.EOF) && !errors.Is(err, net.ErrClosed) { + cp.tb.Errorf("proxy read error: %v", err) + } + read.Close() + write.Close() + return + } + } + } + // Read from client + go proxy(client, server, &cp.clientWritten) + // Read from server + go proxy(server, client, &cp.serverWritten) + } + }() + cp.listener = listener +} + +func TestTHeaderZlibClient(t *testing.T) { + // Some text that zlib should be able to compress + const text = `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.` + + socket, err := thrift.NewTServerSocket(":0") + if err != nil { + t.Fatalf("Failed to create server socket: %v", err) + } + // Call listen to reserve a port and check for any issues early + if err := socket.Listen(); err != nil { + t.Fatalf("Failed to listen server socket: %v", err) + } + server := thrift.NewTSimpleServer4( + servicestest.NewAServProcessor(zlibTestHandler{ + tb: t, + text: text, + }), + socket, + thrift.NewTHeaderTransportFactoryConf(nil, nil), + thrift.NewTHeaderProtocolFactoryConf(nil), + ) + go server.Serve() + // give the server a little time to start serving + time.Sleep(10 * time.Millisecond) + t.Cleanup(func() { + server.Stop() + }) + t.Logf("server running on %v", socket.Addr()) + + proxy := countingProxy{ + tb: t, + remoteAddr: socket.Addr(), + } + proxy.serve() + t.Cleanup(func() { + proxy.listener.Close() + }) + t.Logf("proxy running on %v", proxy.listener.Addr()) + + clientRoundtrip := func(cfg *thrift.TConfiguration) { + t.Helper() + + socket := thrift.NewTSocketConf(proxy.listener.Addr().String(), cfg) + if err := socket.Open(); err != nil { + t.Errorf("failed to open socket: %v", err) + return + } + defer socket.Close() + protoFactory := thrift.NewTHeaderProtocolFactoryConf(cfg) + client := thrift.NewTStandardClient( + protoFactory.GetProtocol(socket), + protoFactory.GetProtocol(socket), + ) + c := servicestest.NewAServClient(client) + got, err := c.Stringfunc_1int_1s(context.Background(), 0, text) + if err != nil { + t.Errorf("Stringfunc_1int_1s call failed: %v", err) + return + } + if got != text { + t.Errorf("Stringfunc_1int_1s got %q want %q", got, text) + } + } + + clientRoundtrip(nil) + nozlibReq, nozlibResp := proxy.getAndResetCounters() + t.Logf("nozlib request size: %d, response size: %d", nozlibReq, nozlibResp) + + clientRoundtrip(&thrift.TConfiguration{ + THeaderTransforms: []thrift.THeaderTransformID{thrift.TransformZlib}, + }) + zlibReq, zlibResp := proxy.getAndResetCounters() + t.Logf("zlib request size: %d, response size: %d", zlibReq, zlibResp) + + if zlibReq >= nozlibReq { + t.Errorf("zlib request size %d >= nozlib request size %d", zlibReq, nozlibReq) + } + if zlibResp >= nozlibResp { + t.Errorf("zlib response size %d >= nozlib response size %d", zlibResp, nozlibResp) + } + + clientRoundtrip(nil) + nozlibReq2, nozlibResp2 := proxy.getAndResetCounters() + t.Logf("nozlib2 request size: %d, response size: %d", nozlibReq, nozlibResp) + + if nozlibReq2 != nozlibReq { + t.Errorf("nozlib request 2 size %d != nozlib request size %d", nozlibReq2, nozlibReq) + } + if nozlibResp2 != nozlibResp { + t.Errorf("nozlib response 2 size %d != nozlib response size %d", nozlibResp2, nozlibResp) + } +} diff --git a/lib/go/thrift/configuration.go b/lib/go/thrift/configuration.go index de27edd674c..a9565d399df 100644 --- a/lib/go/thrift/configuration.go +++ b/lib/go/thrift/configuration.go @@ -56,47 +56,47 @@ const ( // // For example, say you want to migrate this old code into using TConfiguration: // -// sccket, err := thrift.NewTSocketTimeout("host:port", time.Second, time.Second) -// transFactory := thrift.NewTFramedTransportFactoryMaxLength( -// thrift.NewTTransportFactory(), -// 1024 * 1024 * 256, -// ) -// protoFactory := thrift.NewTBinaryProtocolFactory(true, true) +// socket, err := thrift.NewTSocketTimeout("host:port", time.Second, time.Second) +// transFactory := thrift.NewTFramedTransportFactoryMaxLength( +// thrift.NewTTransportFactory(), +// 1024 * 1024 * 256, +// ) +// protoFactory := thrift.NewTBinaryProtocolFactory(true, true) // // This is the wrong way to do it because in the end the TConfiguration used by // socket and transFactory will be overwritten by the one used by protoFactory // because of TConfiguration propagation: // -// // bad example, DO NOT USE -// sccket := thrift.NewTSocketConf("host:port", &thrift.TConfiguration{ -// ConnectTimeout: time.Second, -// SocketTimeout: time.Second, -// }) -// transFactory := thrift.NewTFramedTransportFactoryConf( -// thrift.NewTTransportFactory(), -// &thrift.TConfiguration{ -// MaxFrameSize: 1024 * 1024 * 256, -// }, -// ) -// protoFactory := thrift.NewTBinaryProtocolFactoryConf(&thrift.TConfiguration{ -// TBinaryStrictRead: thrift.BoolPtr(true), -// TBinaryStrictWrite: thrift.BoolPtr(true), -// }) +// // bad example, DO NOT USE +// socket := thrift.NewTSocketConf("host:port", &thrift.TConfiguration{ +// ConnectTimeout: time.Second, +// SocketTimeout: time.Second, +// }) +// transFactory := thrift.NewTFramedTransportFactoryConf( +// thrift.NewTTransportFactory(), +// &thrift.TConfiguration{ +// MaxFrameSize: 1024 * 1024 * 256, +// }, +// ) +// protoFactory := thrift.NewTBinaryProtocolFactoryConf(&thrift.TConfiguration{ +// TBinaryStrictRead: thrift.BoolPtr(true), +// TBinaryStrictWrite: thrift.BoolPtr(true), +// }) // // This is the correct way to do it: // -// conf := &thrift.TConfiguration{ -// ConnectTimeout: time.Second, -// SocketTimeout: time.Second, +// conf := &thrift.TConfiguration{ +// ConnectTimeout: time.Second, +// SocketTimeout: time.Second, // -// MaxFrameSize: 1024 * 1024 * 256, +// MaxFrameSize: 1024 * 1024 * 256, // -// TBinaryStrictRead: thrift.BoolPtr(true), -// TBinaryStrictWrite: thrift.BoolPtr(true), -// } -// sccket := thrift.NewTSocketConf("host:port", conf) -// transFactory := thrift.NewTFramedTransportFactoryConf(thrift.NewTTransportFactory(), conf) -// protoFactory := thrift.NewTBinaryProtocolFactoryConf(conf) +// TBinaryStrictRead: thrift.BoolPtr(true), +// TBinaryStrictWrite: thrift.BoolPtr(true), +// } +// socket := thrift.NewTSocketConf("host:port", conf) +// transFactory := thrift.NewTFramedTransportFactoryConf(thrift.NewTTransportFactory(), conf) +// protoFactory := thrift.NewTBinaryProtocolFactoryConf(conf) // // [1]: https://github.com/apache/thrift/blob/master/doc/specs/thrift-tconfiguration.md type TConfiguration struct { @@ -132,6 +132,8 @@ type TConfiguration struct { // THeaderProtocolIDPtr and THeaderProtocolIDPtrMust helper functions // are provided to help filling this value. THeaderProtocolID *THeaderProtocolID + // The write transforms to be applied to THeaderTransport. + THeaderTransforms []THeaderTransformID // Used internally by deprecated constructors, to avoid overriding // underlying TTransport/TProtocol's cfg by accidental propagations. @@ -245,6 +247,18 @@ func (tc *TConfiguration) GetTHeaderProtocolID() THeaderProtocolID { return protoID } +// GetTHeaderTransforms returns the THeaderTransformIDs to be applied on +// THeaderTransport writing. +// +// It's nil-safe. If tc is nil, empty slice will be returned (meaning no +// transforms to be applied). +func (tc *TConfiguration) GetTHeaderTransforms() []THeaderTransformID { + if tc == nil { + return nil + } + return tc.THeaderTransforms +} + // THeaderProtocolIDPtr validates and returns the pointer to id. // // If id is not a valid THeaderProtocolID, a pointer to THeaderProtocolDefault diff --git a/lib/go/thrift/header_protocol.go b/lib/go/thrift/header_protocol.go index 36777b4ca00..bec84b85c49 100644 --- a/lib/go/thrift/header_protocol.go +++ b/lib/go/thrift/header_protocol.go @@ -119,6 +119,11 @@ func (p *THeaderProtocol) ClearWriteHeaders() { } // AddTransform add a transform for writing. +// +// Deprecated: This only applies to the next message written, and the next read +// message will cause write transforms to be reset from what's configured in +// TConfiguration. For sticky transforms, use TConfiguration.THeaderTransforms +// instead. func (p *THeaderProtocol) AddTransform(transform THeaderTransformID) error { return p.transport.AddTransform(transform) } diff --git a/lib/go/thrift/header_protocol_test.go b/lib/go/thrift/header_protocol_test.go index 48a69bf23b0..dfd84f83012 100644 --- a/lib/go/thrift/header_protocol_test.go +++ b/lib/go/thrift/header_protocol_test.go @@ -39,4 +39,24 @@ func TestReadWriteHeaderProtocol(t *testing.T) { })) }, ) + + t.Run( + "binary-zlib", + func(t *testing.T) { + ReadWriteProtocolTest(t, NewTHeaderProtocolFactoryConf(&TConfiguration{ + THeaderProtocolID: THeaderProtocolIDPtrMust(THeaderProtocolBinary), + THeaderTransforms: []THeaderTransformID{TransformZlib}, + })) + }, + ) + + t.Run( + "compact-zlib", + func(t *testing.T) { + ReadWriteProtocolTest(t, NewTHeaderProtocolFactoryConf(&TConfiguration{ + THeaderProtocolID: THeaderProtocolIDPtrMust(THeaderProtocolCompact), + THeaderTransforms: []THeaderTransformID{TransformZlib}, + })) + }, + ) } diff --git a/lib/go/thrift/header_transport.go b/lib/go/thrift/header_transport.go index 772d922a456..d81fb29d31f 100644 --- a/lib/go/thrift/header_transport.go +++ b/lib/go/thrift/header_transport.go @@ -151,6 +151,11 @@ func (tr *TransformReader) Close() error { } // AddTransform adds a transform. +// +// Deprecated: This only applies to the next message written, and the next read +// message will cause write transforms to be reset from what's configured in +// TConfiguration. For sticky transforms, use TConfiguration.THeaderTransforms +// instead. func (tr *TransformReader) AddTransform(id THeaderTransformID) error { switch id { default: @@ -300,11 +305,12 @@ func NewTHeaderTransportConf(trans TTransport, conf *TConfiguration) *THeaderTra } PropagateTConfiguration(trans, conf) return &THeaderTransport{ - transport: trans, - reader: bufio.NewReader(trans), - writeHeaders: make(THeaderMap), - protocolID: conf.GetTHeaderProtocolID(), - cfg: conf, + transport: trans, + reader: bufio.NewReader(trans), + writeHeaders: make(THeaderMap), + writeTransforms: conf.GetTHeaderTransforms(), + protocolID: conf.GetTHeaderProtocolID(), + cfg: conf, } } @@ -449,6 +455,11 @@ func (t *THeaderTransport) parseHeaders(ctx context.Context, frameSize uint32) e } t.protocolID = THeaderProtocolID(protoID) + // Reset writeTransforms to the ones from cfg, as we are going to add + // compression transforms from what we read, we don't want to accumulate + // different transforms read from different requests + t.writeTransforms = t.cfg.GetTHeaderTransforms() + var transformCount int32 transformCount, err = hp.readVarint32() if err != nil { @@ -466,7 +477,16 @@ func (t *THeaderTransport) parseHeaders(ctx context.Context, frameSize uint32) e if err != nil { return err } - transformIDs[i] = THeaderTransformID(id) + tID := THeaderTransformID(id) + transformIDs[i] = tID + + // For compression transforms, we should also add them + // to writeTransforms so that the response (assuming we + // are reading a request) would do the same compression. + switch tID { + case TransformZlib: + t.addWriteTransformsDedupe(tID) + } } // The transform IDs on the wire was added based on the order of // writing, so on the reading side we need to reverse the order. @@ -726,6 +746,9 @@ func (t *THeaderTransport) ClearWriteHeaders() { } // AddTransform add a transform for writing. +// +// NOTE: This is provided as a low-level API, but in general you should use +// TConfiguration.THeaderTransforms to set transforms for writing instead. func (t *THeaderTransport) AddTransform(transform THeaderTransformID) error { if !supportedTransformIDs[transform] { return NewTProtocolExceptionWithType( @@ -758,6 +781,17 @@ func (t *THeaderTransport) isFramed() bool { } } +// addWriteTransformsDedupe adds id to writeTransforms only if it's not already +// there. +func (t *THeaderTransport) addWriteTransformsDedupe(id THeaderTransformID) { + for _, existingID := range t.writeTransforms { + if existingID == id { + return + } + } + t.writeTransforms = append(t.writeTransforms, id) +} + // SetTConfiguration implements TConfigurationSetter. func (t *THeaderTransport) SetTConfiguration(cfg *TConfiguration) { PropagateTConfiguration(t.transport, cfg) From 854b17e4cbb7d02a420010b9f5f353c8986270b5 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Mon, 13 May 2024 17:03:17 +0200 Subject: [PATCH 232/250] THRIFT-5781 implement full deprecation support -> fix uncompileable issue at deprecated enums Client: netstd Patch: Jens Geyer --- compiler/cpp/src/thrift/generate/t_netstd_generator.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc index feb58a0aa2e..aa570ec7f0f 100644 --- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc @@ -393,7 +393,8 @@ void t_netstd_generator::generate_enum(t_enum* tenum) void t_netstd_generator::generate_enum(ostream& out, t_enum* tenum) { reset_indent(); - out << autogen_comment() << '\n'; + out << autogen_comment(); + out << "using System;" << '\n' << '\n'; // needed for Obsolete() attribute pragmas_and_directives(out); start_netstd_namespace(out); From 42d30efa88bf37a0d7825c8f07d9c64ae57b2c8c Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Tue, 14 May 2024 14:08:00 -0700 Subject: [PATCH 233/250] go: Proper indent in compiler This is a "trivial" change for go compiler to always use the combination of indent_up, indent_down, and indent, over manual indentation (by adding 2 spaces at the beginning of the string). Also change go compiler's indent_str to tab over 2 spaces. While I'm here, also made a few minor tweaks on generated go code. --- .../cpp/src/thrift/generate/t_go_generator.cc | 591 ++++++++++++------ .../cpp/src/thrift/generate/t_go_generator.h | 4 + 2 files changed, 394 insertions(+), 201 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index 72a9f065a53..c135d64edc2 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -785,46 +785,54 @@ void t_go_generator::generate_enum(t_enum* tenum) { std::ostringstream to_string_mapping, from_string_mapping; std::string tenum_name(publicize(tenum->get_name())); generate_go_docstring(f_types_, tenum); - f_types_ << "type " << tenum_name << " int64" << '\n' << "const (" << '\n'; + f_types_ << '\n' << "type " << tenum_name << " int64" << '\n' << "const (" << '\n'; to_string_mapping << indent() << "func (p " << tenum_name << ") String() string {" << '\n'; - to_string_mapping << indent() << " switch p {" << '\n'; + indent_up(); + to_string_mapping << indent() << "switch p {" << '\n'; + indent_down(); from_string_mapping << indent() << "func " << tenum_name << "FromString(s string) (" << tenum_name << ", error) {" << '\n'; - from_string_mapping << indent() << " switch s {" << '\n'; + indent_up(); + from_string_mapping << indent() << "switch s {" << '\n'; + indent_down(); vector constants = tenum->get_constants(); vector::iterator c_iter; int value = -1; + indent_up(); for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { value = (*c_iter)->get_value(); string iter_std_name(escape_string((*c_iter)->get_name())); string iter_name((*c_iter)->get_name()); - f_types_ << indent() << " " << tenum_name << "_" << iter_name << ' ' << tenum_name << " = " + f_types_ << indent() << tenum_name << "_" << iter_name << ' ' << tenum_name << " = " << value << '\n'; // Dictionaries to/from string names of enums - to_string_mapping << indent() << " case " << tenum_name << "_" << iter_name << ": return \"" + to_string_mapping << indent() << "case " << tenum_name << "_" << iter_name << ": return \"" << iter_std_name << "\"" << '\n'; if (iter_std_name != escape_string(iter_name)) { - from_string_mapping << indent() << " case \"" << iter_std_name << "\", \"" + from_string_mapping << indent() << "case \"" << iter_std_name << "\", \"" << escape_string(iter_name) << "\": return " << tenum_name << "_" << iter_name << ", nil " << '\n'; } else { - from_string_mapping << indent() << " case \"" << iter_std_name << "\": return " << tenum_name + from_string_mapping << indent() << "case \"" << iter_std_name << "\": return " << tenum_name << "_" << iter_name << ", nil " << '\n'; } } - to_string_mapping << indent() << " }" << '\n'; - to_string_mapping << indent() << " return \"\"" << '\n'; to_string_mapping << indent() << "}" << '\n'; - from_string_mapping << indent() << " }" << '\n'; - from_string_mapping << indent() << " return " << tenum_name << "(0)," + to_string_mapping << indent() << "return \"\"" << '\n'; + indent_down(); + to_string_mapping << indent() << "}" << '\n'; + indent_up(); + from_string_mapping << indent() << "}" << '\n'; + from_string_mapping << indent() << "return " << tenum_name << "(0)," << " fmt.Errorf(\"not a valid " << tenum_name << " string\")" << '\n'; + indent_down(); from_string_mapping << indent() << "}" << '\n'; f_types_ << ")" << '\n' << '\n' << to_string_mapping.str() << '\n' << from_string_mapping.str() @@ -838,33 +846,49 @@ void t_go_generator::generate_enum(t_enum* tenum) { // Generate MarshalText f_types_ << "func (p " << tenum_name << ") MarshalText() ([]byte, error) {" << '\n'; - f_types_ << "return []byte(p.String()), nil" << '\n'; + indent_up(); + f_types_ << indent() << "return []byte(p.String()), nil" << '\n'; + indent_down(); f_types_ << "}" << '\n' << '\n'; // Generate UnmarshalText f_types_ << "func (p *" << tenum_name << ") UnmarshalText(text []byte) error {" << '\n'; - f_types_ << "q, err := " << tenum_name << "FromString(string(text))" << '\n'; - f_types_ << "if (err != nil) {" << '\n' << "return err" << '\n' << "}" << '\n'; - f_types_ << "*p = q" << '\n'; - f_types_ << "return nil" << '\n'; + indent_up(); + f_types_ << indent() << "q, err := " << tenum_name << "FromString(string(text))" << '\n'; + f_types_ << indent() << "if err != nil {" << '\n'; + indent_up(); + f_types_ << indent() << "return err" << '\n'; + indent_down(); + f_types_ << indent() << "}" << '\n'; + f_types_ << indent() << "*p = q" << '\n'; + f_types_ << indent() << "return nil" << '\n'; + indent_down(); f_types_ << "}" << '\n' << '\n'; // Generate Scan for sql.Scanner interface f_types_ << "func (p *" << tenum_name << ") Scan(value interface{}) error {" << '\n'; - f_types_ << "v, ok := value.(int64)" << '\n'; - f_types_ << "if !ok {" << '\n'; - f_types_ << "return errors.New(\"Scan value is not int64\")" << '\n'; - f_types_ << "}" << '\n'; - f_types_ << "*p = " << tenum_name << "(v)" << '\n'; - f_types_ << "return nil" << '\n'; + indent_up(); + f_types_ << indent() << "v, ok := value.(int64)" << '\n'; + f_types_ << indent() << "if !ok {" << '\n'; + indent_up(); + f_types_ << indent() << "return errors.New(\"Scan value is not int64\")" << '\n'; + indent_down(); + f_types_ << indent() << "}" << '\n'; + f_types_ << indent() << "*p = " << tenum_name << "(v)" << '\n'; + f_types_ << indent() << "return nil" << '\n'; + indent_down(); f_types_ << "}" << '\n' << '\n'; // Generate Value for driver.Valuer interface - f_types_ << "func (p * " << tenum_name << ") Value() (driver.Value, error) {" << '\n'; - f_types_ << " if p == nil {" << '\n'; - f_types_ << " return nil, nil" << '\n'; - f_types_ << " }" << '\n'; - f_types_ << "return int64(*p), nil" << '\n'; + f_types_ << "func (p *" << tenum_name << ") Value() (driver.Value, error) {" << '\n'; + indent_up(); + f_types_ << indent() << "if p == nil {" << '\n'; + indent_up(); + f_types_ << indent() << "return nil, nil" << '\n'; + indent_down(); + f_types_ << indent() << "}" << '\n'; + f_types_ << indent() << "return int64(*p), nil" << '\n'; + indent_down(); f_types_ << "}" << '\n'; } @@ -1330,6 +1354,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, } out << '\n'; } + out << '\n'; // num_setable is used for deciding if Count* methods will be generated for union fields. // This applies to all nullable fields including slices (used for set, list and binary) and maps, not just pointers. @@ -1521,8 +1546,10 @@ void t_go_generator::generate_go_struct_reader(ostream& out, << '\n'; indent_up(); out << indent() << "if _, err := iprot.ReadStructBegin(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)" + indent_up(); + out << indent() << "return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)" << '\n'; + indent_down(); out << indent() << "}" << '\n' << '\n'; // Required variables does not have IsSet functions, so we need tmp vars to check them. @@ -1540,11 +1567,17 @@ void t_go_generator::generate_go_struct_reader(ostream& out, // Read beginning field marker out << indent() << "_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)" << '\n'; out << indent() << "if err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(fmt.Sprintf(" + indent_up(); + out << indent() << "return thrift.PrependError(fmt.Sprintf(" "\"%T field %d read error: \", p, fieldId), err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; // Check for field STOP marker and break - out << indent() << "if fieldTypeId == thrift.STOP { break; }" << '\n'; + out << indent() << "if fieldTypeId == thrift.STOP {" << '\n'; + indent_up(); + out << indent() << "break" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; string thriftFieldTypeId; // Generate deserialization code for known cases @@ -1578,21 +1611,29 @@ void t_go_generator::generate_go_struct_reader(ostream& out, } out << indent() << "if fieldTypeId == " << thriftFieldTypeId << " {" << '\n'; - out << indent() << " if err := p." << field_method_prefix << field_method_suffix << "(ctx, iprot); err != nil {" + indent_up(); + out << indent() << "if err := p." << field_method_prefix << field_method_suffix << "(ctx, iprot); err != nil {" << '\n'; - out << indent() << " return err" << '\n'; - out << indent() << " }" << '\n'; + indent_up(); + out << indent() << "return err" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; // Mark required field as read if ((*f_iter)->get_req() == t_field::T_REQUIRED) { const string field_name(publicize(escape_string((*f_iter)->get_name()))); - out << indent() << " isset" << field_name << " = true" << '\n'; + out << indent() << "isset" << field_name << " = true" << '\n'; } + indent_down(); out << indent() << "} else {" << '\n'; - out << indent() << " if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << '\n'; - out << indent() << " return err" << '\n'; - out << indent() << " }" << '\n'; + indent_up(); + out << indent() << "if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << '\n'; + indent_up(); + out << indent() << "return err" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; + indent_down(); out << indent() << "}" << '\n'; @@ -1607,7 +1648,9 @@ void t_go_generator::generate_go_struct_reader(ostream& out, // Skip unknown fields in either case out << indent() << "if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << '\n'; - out << indent() << " return err" << '\n'; + indent_up(); + out << indent() << "return err" << '\n'; + indent_down(); out << indent() << "}" << '\n'; // End switch default case @@ -1618,13 +1661,17 @@ void t_go_generator::generate_go_struct_reader(ostream& out, // Read field end marker out << indent() << "if err := iprot.ReadFieldEnd(ctx); err != nil {" << '\n'; - out << indent() << " return err" << '\n'; + indent_up(); + out << indent() << "return err" << '\n'; + indent_down(); out << indent() << "}" << '\n'; indent_down(); out << indent() << "}" << '\n'; out << indent() << "if err := iprot.ReadStructEnd(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(fmt.Sprintf(" + indent_up(); + out << indent() << "return thrift.PrependError(fmt.Sprintf(" "\"%T read struct end error: \", p), err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; // Return error if any required fields are missing. @@ -1632,8 +1679,10 @@ void t_go_generator::generate_go_struct_reader(ostream& out, if ((*f_iter)->get_req() == t_field::T_REQUIRED) { const string field_name(publicize(escape_string((*f_iter)->get_name()))); out << indent() << "if !isset" << field_name << "{" << '\n'; - out << indent() << " return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, " + indent_up(); + out << indent() << "return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, " "fmt.Errorf(\"Required field " << field_name << " is not set\"));" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } } @@ -1654,12 +1703,12 @@ void t_go_generator::generate_go_struct_reader(ostream& out, field_method_suffix *= -1; } - out << indent() << "func (p *" << tstruct_name << ") " << field_method_prefix << field_method_suffix + out << indent() << "func (p *" << tstruct_name << ") " << field_method_prefix << field_method_suffix << "(ctx context.Context, iprot thrift.TProtocol) error {" << '\n'; indent_up(); generate_deserialize_field(out, *f_iter, false, "p."); + out << indent() << "return nil" << '\n'; indent_down(); - out << indent() << " return nil" << '\n'; out << indent() << "}" << '\n' << '\n'; } } @@ -1677,14 +1726,18 @@ void t_go_generator::generate_go_struct_writer(ostream& out, indent_up(); if (tstruct->is_union() && uses_countsetfields) { std::string tstruct_name(publicize(tstruct->get_name())); - out << indent() << "if c := p.CountSetFields" << tstruct_name << "(); c != 1 {" << '\n' - << indent() - << " return fmt.Errorf(\"%T write union: exactly one field must be set (%d set)\", p, c)" - << '\n' << indent() << "}" << '\n'; + out << indent() << "if c := p.CountSetFields" << tstruct_name << "(); c != 1 {" << '\n'; + indent_up(); + out << indent() << "return fmt.Errorf(\"%T write union: exactly one field must be set (%d set)\", p, c)" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; } out << indent() << "if err := oprot.WriteStructBegin(ctx, \"" << name << "\"); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(fmt.Sprintf(" - "\"%T write struct begin error: \", p), err) }" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(fmt.Sprintf(" + "\"%T write struct begin error: \", p), err)" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; string field_name; string escape_field_name; @@ -1716,9 +1769,15 @@ void t_go_generator::generate_go_struct_writer(ostream& out, // Write the struct map out << indent() << "if err := oprot.WriteFieldStop(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"write field stop error: \", err) }" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"write field stop error: \", err)" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; out << indent() << "if err := oprot.WriteStructEnd(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"write struct stop error: \", err) }" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"write struct stop error: \", err)" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; out << indent() << "return nil" << '\n'; indent_down(); out << indent() << "}" << '\n' << '\n'; @@ -1748,24 +1807,30 @@ void t_go_generator::generate_go_struct_writer(ostream& out, out << indent() << "if err := oprot.WriteFieldBegin(ctx, \"" << escape_field_name << "\", " << type_to_enum((*f_iter)->get_type()) << ", " << field_id << "); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T write field begin error " - << field_id << ":" << escape_field_name << ": \", p), err) }" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(fmt.Sprintf(\"%T write field begin error " + << field_id << ":" << escape_field_name << ": \", p), err)" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; // Write field contents generate_serialize_field(out, *f_iter, "p."); // Write field closer out << indent() << "if err := oprot.WriteFieldEnd(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T write field end error " - << field_id << ":" << escape_field_name << ": \", p), err) }" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(fmt.Sprintf(\"%T write field end error " + << field_id << ":" << escape_field_name << ": \", p), err)" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; if (field_required == t_field::T_OPTIONAL) { indent_down(); out << indent() << "}" << '\n'; } + out << indent() << "return err" << '\n'; indent_down(); - out << indent() << " return err" << '\n'; out << indent() << "}" << '\n' << '\n'; } } @@ -1906,12 +1971,14 @@ void t_go_generator::generate_service_interface(t_service* tservice) { extends = type_name(tservice->get_extends()); size_t index = extends.rfind("."); + indent_up(); if (index != string::npos) { - extends_if = "\n" + indent() + " " + extends.substr(0, index + 1) + extends_if = "\n" + indent() + extends.substr(0, index + 1) + publicize(extends.substr(index + 1)) + "\n"; } else { extends_if = "\n" + indent() + publicize(extends) + "\n"; } + indent_down(); } f_types_ << indent() << "type " << interfaceName << " interface {" << extends_if; @@ -2233,16 +2300,17 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << unused_protection; // filled in render_included_programs() f_remote << indent() << '\n'; f_remote << indent() << "func Usage() {" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Usage of \", os.Args[0], \" " + indent_up(); + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"Usage of \", os.Args[0], \" " "[-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:\")" << '\n'; - f_remote << indent() << " flag.PrintDefaults()" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"\\nFunctions:\")" << '\n'; + f_remote << indent() << "flag.PrintDefaults()" << '\n'; + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"\\nFunctions:\")" << '\n'; string package_name_aliased = package_identifiers_[get_real_go_module(program_)]; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - f_remote << " fmt.Fprintln(os.Stderr, \" " << (*f_iter)->get_returntype()->get_name() << " " + f_remote << indent() << "fmt.Fprintln(os.Stderr, \" " << (*f_iter)->get_returntype()->get_name() << " " << (*f_iter)->get_name() << "("; t_struct* arg_struct = (*f_iter)->get_arglist(); const std::vector& args = arg_struct->get_members(); @@ -2262,25 +2330,32 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << ")\")" << '\n'; } - f_remote << indent() << " fmt.Fprintln(os.Stderr)" << '\n'; - f_remote << indent() << " os.Exit(0)" << '\n'; + f_remote << indent() << "fmt.Fprintln(os.Stderr)" << '\n'; + f_remote << indent() << "os.Exit(0)" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << '\n'; f_remote << indent() << "type httpHeaders map[string]string" << '\n'; f_remote << indent() << '\n'; f_remote << indent() << "func (h httpHeaders) String() string {" << '\n'; - f_remote << indent() << " var m map[string]string = h" << '\n'; - f_remote << indent() << " return fmt.Sprintf(\"%s\", m)" << '\n'; + indent_up(); + f_remote << indent() << "var m map[string]string = h" << '\n'; + f_remote << indent() << "return fmt.Sprintf(\"%s\", m)" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << '\n'; f_remote << indent() << "func (h httpHeaders) Set(value string) error {" << '\n'; - f_remote << indent() << " parts := strings.Split(value, \": \")" << '\n'; - f_remote << indent() << " if len(parts) != 2 {" << '\n'; - f_remote << indent() << " return fmt.Errorf(\"header should be of format 'Key: Value'\")" << '\n'; - f_remote << indent() << " }" << '\n'; - f_remote << indent() << " h[parts[0]] = parts[1]" << '\n'; - f_remote << indent() << " return nil" << '\n'; + indent_up(); + f_remote << indent() << "parts := strings.Split(value, \": \")" << '\n'; + f_remote << indent() << "if len(parts) != 2 {" << '\n'; + indent_up(); + f_remote << indent() << "return fmt.Errorf(\"header should be of format 'Key: Value'\")" << '\n'; + indent_down(); + f_remote << indent() << "}" << '\n'; + f_remote << indent() << "h[parts[0]] = parts[1]" << '\n'; + f_remote << indent() << "return nil" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << '\n'; @@ -2312,87 +2387,120 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "flag.Parse()" << '\n'; f_remote << indent() << '\n'; f_remote << indent() << "if len(urlString) > 0 {" << '\n'; - f_remote << indent() << " var err error" << '\n'; - f_remote << indent() << " parsedUrl, err = url.Parse(urlString)" << '\n'; - f_remote << indent() << " if err != nil {" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << '\n'; - f_remote << indent() << " flag.Usage()" << '\n'; - f_remote << indent() << " }" << '\n'; - f_remote << indent() << " host = parsedUrl.Host" << '\n'; - f_remote << indent() << " useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == \"http\" || parsedUrl.Scheme == \"https\"" + indent_up(); + f_remote << indent() << "var err error" << '\n'; + f_remote << indent() << "parsedUrl, err = url.Parse(urlString)" << '\n'; + f_remote << indent() << "if err != nil {" << '\n'; + indent_up(); + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << '\n'; + f_remote << indent() << "flag.Usage()" << '\n'; + indent_down(); + f_remote << indent() << "}" << '\n'; + f_remote << indent() << "host = parsedUrl.Host" << '\n'; + f_remote << indent() << "useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == \"http\" || parsedUrl.Scheme == \"https\"" << '\n'; + indent_down(); f_remote << indent() << "} else if useHttp {" << '\n'; - f_remote << indent() << " _, err := url.Parse(fmt.Sprint(\"http://\", host, \":\", port))" + indent_up(); + f_remote << indent() << "_, err := url.Parse(fmt.Sprint(\"http://\", host, \":\", port))" << '\n'; - f_remote << indent() << " if err != nil {" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << '\n'; - f_remote << indent() << " flag.Usage()" << '\n'; - f_remote << indent() << " }" << '\n'; + f_remote << indent() << "if err != nil {" << '\n'; + indent_up(); + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << '\n'; + f_remote << indent() << "flag.Usage()" << '\n'; + indent_down(); + f_remote << indent() << "}" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << '\n'; f_remote << indent() << "cmd := flag.Arg(0)" << '\n'; f_remote << indent() << "var err error" << '\n'; f_remote << indent() << "var cfg *thrift.TConfiguration = nil" << '\n'; f_remote << indent() << "if useHttp {" << '\n'; - f_remote << indent() << " trans, err = thrift.NewTHttpClient(parsedUrl.String())" << '\n'; - f_remote << indent() << " if len(headers) > 0 {" << '\n'; - f_remote << indent() << " httptrans := trans.(*thrift.THttpClient)" << '\n'; - f_remote << indent() << " for key, value := range headers {" << '\n'; - f_remote << indent() << " httptrans.SetHeader(key, value)" << '\n'; - f_remote << indent() << " }" << '\n'; - f_remote << indent() << " }" << '\n'; + indent_up(); + f_remote << indent() << "trans, err = thrift.NewTHttpClient(parsedUrl.String())" << '\n'; + f_remote << indent() << "if len(headers) > 0 {" << '\n'; + indent_up(); + f_remote << indent() << "httptrans := trans.(*thrift.THttpClient)" << '\n'; + f_remote << indent() << "for key, value := range headers {" << '\n'; + indent_up(); + f_remote << indent() << "httptrans.SetHeader(key, value)" << '\n'; + indent_down(); + f_remote << indent() << "}" << '\n'; + indent_down(); + f_remote << indent() << "}" << '\n'; + indent_down(); f_remote << indent() << "} else {" << '\n'; - f_remote << indent() << " portStr := fmt.Sprint(port)" << '\n'; - f_remote << indent() << " if strings.Contains(host, \":\") {" << '\n'; - f_remote << indent() << " host, portStr, err = net.SplitHostPort(host)" << '\n'; - f_remote << indent() << " if err != nil {" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"error with host:\", err)" + indent_up(); + f_remote << indent() << "portStr := fmt.Sprint(port)" << '\n'; + f_remote << indent() << "if strings.Contains(host, \":\") {" << '\n'; + indent_up(); + f_remote << indent() << "host, portStr, err = net.SplitHostPort(host)" << '\n'; + f_remote << indent() << "if err != nil {" << '\n'; + indent_up(); + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"error with host:\", err)" << '\n'; - f_remote << indent() << " os.Exit(1)" << '\n'; - f_remote << indent() << " }" << '\n'; - f_remote << indent() << " }" << '\n'; - f_remote << indent() << " trans = thrift.NewTSocketConf(net.JoinHostPort(host, portStr), cfg)" << '\n'; - f_remote << indent() << " if err != nil {" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"error resolving address:\", err)" << '\n'; - f_remote << indent() << " os.Exit(1)" << '\n'; - f_remote << indent() << " }" << '\n'; - f_remote << indent() << " if framed {" << '\n'; - f_remote << indent() << " trans = thrift.NewTFramedTransportConf(trans, cfg)" << '\n'; - f_remote << indent() << " }" << '\n'; + f_remote << indent() << "os.Exit(1)" << '\n'; + indent_down(); + f_remote << indent() << "}" << '\n'; + indent_down(); + f_remote << indent() << "}" << '\n'; + f_remote << indent() << "trans = thrift.NewTSocketConf(net.JoinHostPort(host, portStr), cfg)" << '\n'; + f_remote << indent() << "if err != nil {" << '\n'; + indent_up(); + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"error resolving address:\", err)" << '\n'; + f_remote << indent() << "os.Exit(1)" << '\n'; + indent_down(); + f_remote << indent() << "}" << '\n'; + f_remote << indent() << "if framed {" << '\n'; + indent_up(); + f_remote << indent() << "trans = thrift.NewTFramedTransportConf(trans, cfg)" << '\n'; + indent_down(); + f_remote << indent() << "}" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << "if err != nil {" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error creating transport\", err)" << '\n'; - f_remote << indent() << " os.Exit(1)" << '\n'; + indent_up(); + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"Error creating transport\", err)" << '\n'; + f_remote << indent() << "os.Exit(1)" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << "defer trans.Close()" << '\n'; f_remote << indent() << "var protocolFactory thrift.TProtocolFactory" << '\n'; f_remote << indent() << "switch protocol {" << '\n'; f_remote << indent() << "case \"compact\":" << '\n'; - f_remote << indent() << " protocolFactory = thrift.NewTCompactProtocolFactoryConf(cfg)" << '\n'; - f_remote << indent() << " break" << '\n'; + indent_up(); + f_remote << indent() << "protocolFactory = thrift.NewTCompactProtocolFactoryConf(cfg)" << '\n'; + indent_down(); f_remote << indent() << "case \"simplejson\":" << '\n'; - f_remote << indent() << " protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(cfg)" << '\n'; - f_remote << indent() << " break" << '\n'; + indent_up(); + f_remote << indent() << "protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(cfg)" << '\n'; f_remote << indent() << "case \"json\":" << '\n'; - f_remote << indent() << " protocolFactory = thrift.NewTJSONProtocolFactory()" << '\n'; - f_remote << indent() << " break" << '\n'; + indent_up(); + f_remote << indent() << "protocolFactory = thrift.NewTJSONProtocolFactory()" << '\n'; + indent_down(); f_remote << indent() << "case \"binary\", \"\":" << '\n'; - f_remote << indent() << " protocolFactory = thrift.NewTBinaryProtocolFactoryConf(cfg)" << '\n'; - f_remote << indent() << " break" << '\n'; + indent_up(); + f_remote << indent() << "protocolFactory = thrift.NewTBinaryProtocolFactoryConf(cfg)" << '\n'; + indent_down(); f_remote << indent() << "default:" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Invalid protocol specified: \", protocol)" + indent_up(); + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"Invalid protocol specified: \", protocol)" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " os.Exit(1)" << '\n'; + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "os.Exit(1)" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << "iprot := protocolFactory.GetProtocol(trans)" << '\n'; f_remote << indent() << "oprot := protocolFactory.GetProtocol(trans)" << '\n'; f_remote << indent() << "client := " << package_name_aliased << ".New" << publicize(service_name_) << "Client(thrift.NewTStandardClient(iprot, oprot))" << '\n'; f_remote << indent() << "if err := trans.Open(); err != nil {" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error opening socket to \", " + indent_up(); + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"Error opening socket to \", " "host, \":\", port, \" \", err)" << '\n'; - f_remote << indent() << " os.Exit(1)" << '\n'; + f_remote << indent() << "os.Exit(1)" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << '\n'; f_remote << indent() << "switch cmd {" << '\n'; @@ -2407,9 +2515,11 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "case \"" << escape_string(funcName) << "\":" << '\n'; indent_up(); f_remote << indent() << "if flag.NArg() - 1 != " << num_args << " {" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"" << escape_string(pubName) << " requires " + indent_up(); + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"" << escape_string(pubName) << " requires " << num_args << " args\")" << '\n'; - f_remote << indent() << " flag.Usage()" << '\n'; + f_remote << indent() << "flag.Usage()" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; for (std::vector::size_type i = 0; i < num_args; ++i) { @@ -2421,8 +2531,10 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "tmp" << i << ", err := (strconv.Atoi(flag.Arg(" << flagArg << ")))" << '\n'; f_remote << indent() << "if err != nil {" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << "argvalue" << i << " := " << package_name_aliased << "." << publicize(the_type->get_name()) << "(tmp" << i << ")" << '\n'; @@ -2452,8 +2564,10 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "tmp" << i << ", " << err << " := (strconv.Atoi(flag.Arg(" << flagArg << ")))" << '\n'; f_remote << indent() << "if " << err << " != nil {" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << "argvalue" << i << " := int8(tmp" << i << ")" << '\n'; break; @@ -2462,8 +2576,10 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "tmp" << i << ", " << err << " := (strconv.Atoi(flag.Arg(" << flagArg << ")))" << '\n'; f_remote << indent() << "if " << err << " != nil {" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << "argvalue" << i << " := int16(tmp" << i << ")" << '\n'; break; @@ -2472,8 +2588,10 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "tmp" << i << ", " << err << " := (strconv.Atoi(flag.Arg(" << flagArg << ")))" << '\n'; f_remote << indent() << "if " << err << " != nil {" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << "argvalue" << i << " := int32(tmp" << i << ")" << '\n'; break; @@ -2482,8 +2600,10 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "argvalue" << i << ", " << err << " := (strconv.ParseInt(flag.Arg(" << flagArg << "), 10, 64))" << '\n'; f_remote << indent() << "if " << err << " != nil {" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; break; @@ -2491,8 +2611,10 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "argvalue" << i << ", " << err << " := (strconv.ParseFloat(flag.Arg(" << flagArg << "), 64))" << '\n'; f_remote << indent() << "if " << err << " != nil {" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; break; @@ -2500,8 +2622,10 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "argvalue" << i << ", " << err << " := (thrift.ParseTuuid(flag.Arg(" << flagArg << ")))" << '\n'; f_remote << indent() << "if " << err << " != nil {" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; break; @@ -2531,18 +2655,22 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "_, " << err1 << " := " << mbTrans << ".WriteString(" << arg << ")" << '\n'; f_remote << indent() << "if " << err1 << " != nil {" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << factory << " := thrift.NewTJSONProtocolFactory()" << '\n'; f_remote << indent() << jsProt << " := " << factory << ".GetProtocol(" << mbTrans << ")" << '\n'; f_remote << indent() << "argvalue" << i << " := " << tstruct_module << ".New" << tstruct_name << "()" << '\n'; - f_remote << indent() << err2 << " := argvalue" << i << "." << read_method_name_ << "(context.Background(), " << jsProt << ")" << '\n'; + f_remote << indent() << err2 << " := argvalue" << i << "." << read_method_name_ << "(context.Background(), " << jsProt << ")" << '\n'; f_remote << indent() << "if " << err2 << " != nil {" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; } else if (the_type2->is_container() || the_type2->is_xception()) { string arg(tmp("arg")); @@ -2559,8 +2687,10 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "_, " << err1 << " := " << mbTrans << ".WriteString(" << arg << ")" << '\n'; f_remote << indent() << "if " << err1 << " != nil { " << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << factory << " := thrift.NewTJSONProtocolFactory()" << '\n'; f_remote << indent() << jsProt << " := " << factory << ".GetProtocol(" << mbTrans << ")" @@ -2570,8 +2700,10 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << err2 << " := containerStruct" << i << ".ReadField" << (i + 1) << "(context.Background(), " << jsProt << ")" << '\n'; f_remote << indent() << "if " << err2 << " != nil {" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " return" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + f_remote << indent() << "return" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; f_remote << indent() << "argvalue" << i << " := containerStruct" << i << "." << argName << '\n'; @@ -2641,10 +2773,13 @@ void t_go_generator::generate_service_remote(t_service* tservice) { } f_remote << indent() << "case \"\":" << '\n'; - f_remote << indent() << " Usage()" << '\n'; - f_remote << indent() << " break" << '\n'; + indent_up(); + f_remote << indent() << "Usage()" << '\n'; + indent_down(); f_remote << indent() << "default:" << '\n'; - f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Invalid function \", cmd)" << '\n'; + indent_up(); + f_remote << indent() << "fmt.Fprintln(os.Stderr, \"Invalid function \", cmd)" << '\n'; + indent_down(); f_remote << indent() << "}" << '\n'; indent_down(); f_remote << indent() << "}" << '\n'; @@ -2697,78 +2832,95 @@ void t_go_generator::generate_service_server(t_service* tservice) { if (extends_processor.empty()) { f_types_ << indent() << "type " << serviceName << "Processor struct {" << '\n'; - f_types_ << indent() << " processorMap map[string]thrift.TProcessorFunction" << '\n'; - f_types_ << indent() << " handler " << serviceName << '\n'; + indent_up(); + f_types_ << indent() << "processorMap map[string]thrift.TProcessorFunction" << '\n'; + f_types_ << indent() << "handler " << serviceName << '\n'; + indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func (p *" << serviceName << "Processor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {" << '\n'; - f_types_ << indent() << " p.processorMap[key] = processor" << '\n'; + indent_up(); + f_types_ << indent() << "p.processorMap[key] = processor" << '\n'; + indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func (p *" << serviceName << "Processor) GetProcessorFunction(key string) " "(processor thrift.TProcessorFunction, ok bool) {" << '\n'; - f_types_ << indent() << " processor, ok = p.processorMap[key]" << '\n'; - f_types_ << indent() << " return processor, ok" << '\n'; + indent_up(); + f_types_ << indent() << "processor, ok = p.processorMap[key]" << '\n'; + f_types_ << indent() << "return processor, ok" << '\n'; + indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func (p *" << serviceName << "Processor) ProcessorMap() map[string]thrift.TProcessorFunction {" << '\n'; - f_types_ << indent() << " return p.processorMap" << '\n'; + indent_up(); + f_types_ << indent() << "return p.processorMap" << '\n'; + indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func New" << serviceName << "Processor(handler " << serviceName << ") *" << serviceName << "Processor {" << '\n' << '\n'; + indent_up(); f_types_ - << indent() << " " << self << " := &" << serviceName + << indent() << self << " := &" << serviceName << "Processor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)}" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { string escapedFuncName(escape_string((*f_iter)->get_name())); - f_types_ << indent() << " " << self << ".processorMap[\"" << escapedFuncName << "\"] = &" + f_types_ << indent() << self << ".processorMap[\"" << escapedFuncName << "\"] = &" << pServiceName << "Processor" << publicize((*f_iter)->get_name()) << "{handler:handler}" << '\n'; } string x(tmp("x")); f_types_ << indent() << "return " << self << '\n'; + indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func (p *" << serviceName << "Processor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err " "thrift.TException) {" << '\n'; - f_types_ << indent() << " name, _, seqId, err2 := iprot.ReadMessageBegin(ctx)" << '\n'; - f_types_ << indent() << " if err2 != nil { return false, thrift.WrapTException(err2) }" << '\n'; - f_types_ << indent() << " if processor, ok := p.GetProcessorFunction(name); ok {" << '\n'; - f_types_ << indent() << " return processor.Process(ctx, seqId, iprot, oprot)" << '\n'; - f_types_ << indent() << " }" << '\n'; - f_types_ << indent() << " iprot.Skip(ctx, thrift.STRUCT)" << '\n'; - f_types_ << indent() << " iprot.ReadMessageEnd(ctx)" << '\n'; - f_types_ << indent() << " " << x + indent_up(); + f_types_ << indent() << "name, _, seqId, err2 := iprot.ReadMessageBegin(ctx)" << '\n'; + f_types_ << indent() << "if err2 != nil { return false, thrift.WrapTException(err2) }" << '\n'; + f_types_ << indent() << "if processor, ok := p.GetProcessorFunction(name); ok {" << '\n'; + indent_up(); + f_types_ << indent() << "return processor.Process(ctx, seqId, iprot, oprot)" << '\n'; + indent_down(); + f_types_ << indent() << "}" << '\n'; + f_types_ << indent() << "iprot.Skip(ctx, thrift.STRUCT)" << '\n'; + f_types_ << indent() << "iprot.ReadMessageEnd(ctx)" << '\n'; + f_types_ << indent() << "" << x << " := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, \"Unknown function " "\" + name)" << '\n'; - f_types_ << indent() << " oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId)" << '\n'; - f_types_ << indent() << " " << x << ".Write(ctx, oprot)" << '\n'; - f_types_ << indent() << " oprot.WriteMessageEnd(ctx)" << '\n'; - f_types_ << indent() << " oprot.Flush(ctx)" << '\n'; - f_types_ << indent() << " return false, " << x << '\n'; - f_types_ << indent() << "" << '\n'; + f_types_ << indent() << "oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId)" << '\n'; + f_types_ << indent() << "" << x << ".Write(ctx, oprot)" << '\n'; + f_types_ << indent() << "oprot.WriteMessageEnd(ctx)" << '\n'; + f_types_ << indent() << "oprot.Flush(ctx)" << '\n'; + f_types_ << indent() << "return false, " << x << '\n'; + indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; } else { f_types_ << indent() << "type " << serviceName << "Processor struct {" << '\n'; - f_types_ << indent() << " *" << extends_processor << '\n'; + indent_up(); + f_types_ << indent() << "*" << extends_processor << '\n'; + indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func New" << serviceName << "Processor(handler " << serviceName << ") *" << serviceName << "Processor {" << '\n'; - f_types_ << indent() << " " << self << " := &" << serviceName << "Processor{" + indent_up(); + f_types_ << indent() << self << " := &" << serviceName << "Processor{" << extends_processor_new << "(handler)}" << '\n'; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { string escapedFuncName(escape_string((*f_iter)->get_name())); - f_types_ << indent() << " " << self << ".AddToProcessorMap(\"" << escapedFuncName + f_types_ << indent() << self << ".AddToProcessorMap(\"" << escapedFuncName << "\", &" << pServiceName << "Processor" << publicize((*f_iter)->get_name()) << "{handler:handler})" << '\n'; } - f_types_ << indent() << " return " << self << '\n'; + f_types_ << indent() << "return " << self << '\n'; + indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; } @@ -2795,7 +2947,9 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* // t_struct* xs = tfunction->get_xceptions(); // const std::vector& xceptions = xs->get_members(); f_types_ << indent() << "type " << processorName << " struct {" << '\n'; - f_types_ << indent() << " handler " << publicize(tservice->get_name()) << '\n'; + indent_up(); + f_types_ << indent() << "handler " << publicize(tservice->get_name()) << '\n'; + indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; f_types_ << indent() << "func (p *" << processorName << ") Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err " @@ -2807,7 +2961,7 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* f_types_ << indent() << "var " << write_err << " error" << '\n'; } f_types_ << indent() << "args := " << argsname << "{}" << '\n'; - f_types_ << indent() << "if err2 := args." << read_method_name_ << "(ctx, iprot); err2 != nil {" << '\n'; + f_types_ << indent() << "if err2 := args." << read_method_name_ << "(ctx, iprot); err2 != nil {" << '\n'; indent_up(); f_types_ << indent() << "iprot.ReadMessageEnd(ctx)" << '\n'; if (!tfunction->is_oneway()) { @@ -3096,7 +3250,7 @@ void t_go_generator::generate_deserialize_field(ostream& out, string type_name = inkey ? type_to_go_key_type(tfield->get_type()) : type_to_go_type(tfield->get_type()); - out << "var " << tfield->get_name() << " " << type_name << '\n'; + out << indent() << "var " << tfield->get_name() << " " << type_name << '\n'; } indent(out) << "if v, err := iprot."; @@ -3154,10 +3308,13 @@ void t_go_generator::generate_deserialize_field(ostream& out, } out << "; err != nil {" << '\n'; + indent_up(); out << indent() << "return thrift.PrependError(\"error reading field " << tfield->get_key() << ": \", err)" << '\n'; - out << "} else {" << '\n'; + indent_down(); + out << indent() << "} else {" << '\n'; + indent_up(); string wrap; if (type->is_enum() || orig_type->is_typedef()) { @@ -3174,7 +3331,8 @@ void t_go_generator::generate_deserialize_field(ostream& out, indent(out) << name << " = " << maybe_address << "temp" << '\n'; } - out << "}" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; } else { throw "INVALID TYPE IN generate_deserialize_field '" + type->get_name() + "' for field '" + tfield->get_name() + "'"; @@ -3193,9 +3351,11 @@ void t_go_generator::generate_deserialize_struct(ostream& out, out << indent() << prefix << eq << (pointer_field ? "&" : ""); generate_go_struct_initializer(out, tstruct); - out << indent() << "if err := " << prefix << "." << read_method_name_ << "(ctx, iprot); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", " + out << indent() << "if err := " << prefix << "." << read_method_name_ << "(ctx, iprot); err != nil {" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", " << prefix << "), err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } @@ -3219,31 +3379,37 @@ void t_go_generator::generate_deserialize_container(ostream& out, if (ttype->is_map()) { out << indent() << "_, _, size, err := iprot.ReadMapBegin(ctx)" << '\n'; out << indent() << "if err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error reading map begin: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error reading map begin: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; out << indent() << "tMap := make(" << type_to_go_type(orig_type) << ", size)" << '\n'; - out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tMap" << '\n'; + out << indent() << prefix << eq << (pointer_field ? "&" : "") << "tMap" << '\n'; } else if (ttype->is_set()) { out << indent() << "_, size, err := iprot.ReadSetBegin(ctx)" << '\n'; out << indent() << "if err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error reading set begin: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error reading set begin: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; out << indent() << "tSet := make(" << type_to_go_type(orig_type) << ", 0, size)" << '\n'; - out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSet" << '\n'; + out << indent() << prefix << eq << (pointer_field ? "&" : "") << "tSet" << '\n'; } else if (ttype->is_list()) { out << indent() << "_, size, err := iprot.ReadListBegin(ctx)" << '\n'; out << indent() << "if err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error reading list begin: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error reading list begin: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; out << indent() << "tSlice := make(" << type_to_go_type(orig_type) << ", 0, size)" << '\n'; - out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSlice" << '\n'; + out << indent() << prefix << eq << (pointer_field ? "&" : "") << "tSlice" << '\n'; } else { throw "INVALID TYPE IN generate_deserialize_container '" + ttype->get_name() + "' for prefix '" + prefix + "'"; } // For loop iterates over elements - out << indent() << "for i := 0; i < size; i ++ {" << '\n'; + out << indent() << "for i := 0; i < size; i++ {" << '\n'; indent_up(); if (pointer_field) { @@ -3263,15 +3429,21 @@ void t_go_generator::generate_deserialize_container(ostream& out, // Read container end if (ttype->is_map()) { out << indent() << "if err := iprot.ReadMapEnd(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error reading map end: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error reading map end: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } else if (ttype->is_set()) { out << indent() << "if err := iprot.ReadSetEnd(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error reading set end: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error reading set end: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } else if (ttype->is_list()) { out << indent() << "if err := iprot.ReadListEnd(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error reading list end: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error reading list end: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } } @@ -3407,9 +3579,12 @@ void t_go_generator::generate_serialize_field(ostream& out, } out << "; err != nil {" << '\n'; + indent_up(); out << indent() << "return thrift.PrependError(fmt.Sprintf(\"%T." << escape_string(tfield->get_name()) << " (" << tfield->get_key() - << ") field write error: \", p), err) }" << '\n'; + << ") field write error: \", p), err)" << '\n'; + indent_down(); + out << indent() << "}" << '\n'; } else { throw "compiler error: Invalid type in generate_serialize_field '" + type->get_name() + "' for field '" + name + "'"; @@ -3425,8 +3600,10 @@ void t_go_generator::generate_serialize_field(ostream& out, void t_go_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) { (void)tstruct; out << indent() << "if err := " << prefix << "." << write_method_name_ << "(ctx, oprot); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", " + indent_up(); + out << indent() << "return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", " << prefix << "), err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } @@ -3442,19 +3619,25 @@ void t_go_generator::generate_serialize_container(ostream& out, << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << "len(" << prefix << ")); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error writing map begin: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error writing map begin: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } else if (ttype->is_set()) { out << indent() << "if err := oprot.WriteSetBegin(ctx, " << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " << "len(" << prefix << ")); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error writing set begin: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error writing set begin: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } else if (ttype->is_list()) { out << indent() << "if err := oprot.WriteListBegin(ctx, " << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << "len(" << prefix << ")); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error writing list begin: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error writing list begin: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } else { throw "compiler error: Invalid type in generate_serialize_container '" + ttype->get_name() @@ -3513,15 +3696,21 @@ void t_go_generator::generate_serialize_container(ostream& out, if (ttype->is_map()) { out << indent() << "if err := oprot.WriteMapEnd(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error writing map end: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error writing map end: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } else if (ttype->is_set()) { out << indent() << "if err := oprot.WriteSetEnd(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error writing set end: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error writing set end: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } else if (ttype->is_list()) { out << indent() << "if err := oprot.WriteListEnd(ctx); err != nil {" << '\n'; - out << indent() << " return thrift.PrependError(\"error writing list end: \", err)" << '\n'; + indent_up(); + out << indent() << "return thrift.PrependError(\"error writing list end: \", err)" << '\n'; + indent_down(); out << indent() << "}" << '\n'; } } diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.h b/compiler/cpp/src/thrift/generate/t_go_generator.h index 55f544e19f8..1efa32daa33 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.h +++ b/compiler/cpp/src/thrift/generate/t_go_generator.h @@ -286,6 +286,10 @@ class t_go_generator : public t_generator { static bool is_pointer_field(t_field* tfield, bool in_container = false); + std::string indent_str() const { + return "\t"; + } + private: std::string gen_package_prefix_; std::string gen_thrift_import_; From 004adaf9b6f7d48c32f77d34be8e02eb5f1a2a84 Mon Sep 17 00:00:00 2001 From: Nicholas La Roux Date: Fri, 17 May 2024 11:09:09 +0900 Subject: [PATCH 234/250] Remove deprecated has_rdoc from gemspec --- lib/rb/thrift.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/rb/thrift.gemspec b/lib/rb/thrift.gemspec index 86d21897bc2..1977ec4766f 100644 --- a/lib/rb/thrift.gemspec +++ b/lib/rb/thrift.gemspec @@ -12,7 +12,6 @@ Gem::Specification.new do |s| s.license = 'Apache-2.0' s.extensions = ['ext/extconf.rb'] - s.has_rdoc = true s.rdoc_options = %w[--line-numbers --inline-source --title Thrift --main README] s.rubyforge_project = 'thrift' From 9d2d5c023a3839065d548bfbb6d266aa33caa1cf Mon Sep 17 00:00:00 2001 From: Steven Mitcham Date: Wed, 22 May 2024 13:30:37 -0500 Subject: [PATCH 235/250] THRIFT-5787 restoring binary compatibility of Factory constructor Client: netstd Patch: Steven Mitcham This closes #2979 --- lib/netstd/Thrift/Protocol/TBinaryProtocol.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs b/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs index 6389184a41c..186d220cbf7 100644 --- a/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs +++ b/lib/netstd/Thrift/Protocol/TBinaryProtocol.cs @@ -475,7 +475,13 @@ public class Factory : TProtocolFactory protected readonly bool StrictRead; protected readonly bool StrictWrite; - public Factory(bool strictRead = false, bool strictWrite = true) + // emtpy default CTOR required + public Factory() + : this(false, true) + { + } + + public Factory(bool strictRead, bool strictWrite) { StrictRead = strictRead; StrictWrite = strictWrite; From 6c84a44eb4ce594e28c1e31fbe769ef04fbcc28d Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 24 May 2024 21:09:42 +0200 Subject: [PATCH 236/250] THRIFT-5788 Refactor and streamline hash set implementation Client: delphi Patch: Jens Geyer --- lib/delphi/src/Thrift.Collections.pas | 97 +++++++++------------------ 1 file changed, 33 insertions(+), 64 deletions(-) diff --git a/lib/delphi/src/Thrift.Collections.pas b/lib/delphi/src/Thrift.Collections.pas index 2cb2395adcc..c0fe3231946 100644 --- a/lib/delphi/src/Thrift.Collections.pas +++ b/lib/delphi/src/Thrift.Collections.pas @@ -191,127 +191,96 @@ TThriftListImpl = class( TInterfacedObject, IThriftList, IThriftContaine function ToString : string; override; end; - IThriftHashSet = interface(IThriftContainer) - ['{0923A3B5-D4D4-48A8-91AD-40238E2EAD66}'] - function GetEnumerator: TEnumerator; - function GetIsReadOnly: Boolean; + IThriftHashSet = interface(IThriftContainer) + ['{733E2B57-C374-4359-BBD5-2B9CD8DF737C}'] + function GetEnumerator: TEnumerator; function GetCount: Integer; property Count: Integer read GetCount; - property IsReadOnly: Boolean read GetIsReadOnly; - procedure Add( const item: TValue); + function Add( const item: T) : Boolean; procedure Clear; - function Contains( const item: TValue): Boolean; - procedure CopyTo(var A: TArray; arrayIndex: Integer); - function Remove( const item: TValue ): Boolean; + function Contains( const item: T): Boolean; + function Remove( const item: T): Boolean; end; // compatibility - IHashSet = interface( IThriftHashSet) + IHashSet = interface( IThriftHashSet) ['{C3CF557F-21D9-4524-B899-D3145B0389BB}'] end deprecated 'use IThriftHashSet'; {$WARN SYMBOL_DEPRECATED OFF} - TThriftHashSetImpl = class( TInterfacedObject, IHashSet, IThriftHashSet, IThriftContainer, ISupportsToString) + TThriftHashSetImpl = class( TInterfacedObject, IHashSet, IThriftHashSet, IThriftContainer, ISupportsToString) {$WARN SYMBOL_DEPRECATED DEFAULT} strict private - FDictionary : IThriftDictionary; - FIsReadOnly: Boolean; + FDictionary : TDictionary; // there is no THashSet in older Delphi versions strict protected - function GetEnumerator: TEnumerator; - function GetIsReadOnly: Boolean; + function GetEnumerator: TEnumerator; function GetCount: Integer; property Count: Integer read GetCount; - property IsReadOnly: Boolean read FIsReadOnly; - procedure Add( const item: TValue); + function Add( const item: T) : Boolean; procedure Clear; - function Contains( const item: TValue): Boolean; - procedure CopyTo(var A: TArray; arrayIndex: Integer); - function Remove( const item: TValue ): Boolean; + function Contains( const item: T): Boolean; + function Remove( const item: T): Boolean; public constructor Create( const aCapacity: Integer = 0); overload; - constructor Create( const aCapacity: Integer; const aComparer : IEqualityComparer); overload; + constructor Create( const aCapacity: Integer; const aComparer : IEqualityComparer); overload; function ToString : string; override; end; // compatibility - THashSetImpl = class( TThriftHashSetImpl) + THashSetImpl = class( TThriftHashSetImpl) end deprecated 'use TThriftHashSetImpl'; implementation -{ TThriftHashSetImpl. } +{ TThriftHashSetImpl. } -procedure TThriftHashSetImpl.Add( const item: TValue); +function TThriftHashSetImpl.Add( const item: T) : Boolean; begin - if not FDictionary.ContainsKey(item) then - begin - FDictionary.Add( item, 0); - end; + result := not FDictionary.ContainsKey(item); + if result then FDictionary.Add( item, 0); end; -procedure TThriftHashSetImpl.Clear; +procedure TThriftHashSetImpl.Clear; begin FDictionary.Clear; end; -function TThriftHashSetImpl.Contains( const item: TValue): Boolean; +function TThriftHashSetImpl.Contains( const item: T): Boolean; begin Result := FDictionary.ContainsKey(item); end; -procedure TThriftHashSetImpl.CopyTo(var A: TArray; arrayIndex: Integer); -var - i : Integer; - Enumlator : TEnumerator; -begin - Enumlator := GetEnumerator; - while Enumlator.MoveNext do - begin - A[arrayIndex] := Enumlator.Current; - Inc(arrayIndex); - end; -end; - -constructor TThriftHashSetImpl.Create( const aCapacity: Integer); +constructor TThriftHashSetImpl.Create( const aCapacity: Integer); begin inherited Create; - FDictionary := TThriftDictionaryImpl.Create( aCapacity); + FDictionary := TDictionary.Create( aCapacity); end; -constructor TThriftHashSetImpl.Create( const aCapacity: Integer; const aComparer : IEqualityComparer); +constructor TThriftHashSetImpl.Create( const aCapacity: Integer; const aComparer : IEqualityComparer); begin inherited Create; - FDictionary := TThriftDictionaryImpl.Create( aCapacity, aComparer); + FDictionary := TDictionary.Create( aCapacity, aComparer); end; -function TThriftHashSetImpl.GetCount: Integer; +function TThriftHashSetImpl.GetCount: Integer; begin Result := FDictionary.Count; end; -function TThriftHashSetImpl.GetEnumerator: TEnumerator; +function TThriftHashSetImpl.GetEnumerator: TEnumerator; begin Result := FDictionary.Keys.GetEnumerator; end; -function TThriftHashSetImpl.GetIsReadOnly: Boolean; +function TThriftHashSetImpl.Remove( const item: T): Boolean; begin - Result := FIsReadOnly; + Result := FDictionary.ContainsKey( item); + if Result then FDictionary.Remove( item ); end; -function TThriftHashSetImpl.Remove( const item: TValue): Boolean; -begin - Result := False; - if FDictionary.ContainsKey( item ) then - begin - FDictionary.Remove( item ); - Result := not FDictionary.ContainsKey( item ); - end; -end; - -function TThriftHashSetImpl.ToString : string; -var elm : TValue; +function TThriftHashSetImpl.ToString : string; +var elm : T; sb : TThriftStringBuilder; first : Boolean; begin @@ -323,7 +292,7 @@ function TThriftHashSetImpl.ToString : string; then first := FALSE else sb.Append(', '); - sb.Append( StringUtils.ToString(elm)); + sb.Append( StringUtils.ToString(elm)); end; sb.Append('}'); Result := sb.ToString; From 9b575df6e9f35249c9f7f5e823e4cc347ea53dcb Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 24 May 2024 23:36:07 +0200 Subject: [PATCH 237/250] THRIFT-5789 Refactor test suite client implementation Client: Delphi Patch: Jens Geyer --- lib/delphi/test/client.dpr | 10 +- lib/delphi/test/client.dproj | 12 +- lib/delphi/test/server.dpr | 5 +- lib/delphi/test/server.dproj | 5 +- .../test/{ => testsuite}/TestConstants.pas | 48 +++ .../client}/Performance/DataFactory.pas | 0 .../client}/Performance/PerfTests.pas | 0 .../{ => testsuite/client}/TestClient.pas | 313 ++-------------- .../test/testsuite/client/TestLogger.pas | 193 ++++++++++ .../test/testsuite/client/UnitTests.pas | 350 ++++++++++++++++++ .../{ => testsuite/server}/TestServer.pas | 0 .../server}/TestServerEvents.pas | 0 12 files changed, 634 insertions(+), 302 deletions(-) rename lib/delphi/test/{ => testsuite}/TestConstants.pas (85%) rename lib/delphi/test/{ => testsuite/client}/Performance/DataFactory.pas (100%) rename lib/delphi/test/{ => testsuite/client}/Performance/PerfTests.pas (100%) rename lib/delphi/test/{ => testsuite/client}/TestClient.pas (80%) create mode 100644 lib/delphi/test/testsuite/client/TestLogger.pas create mode 100644 lib/delphi/test/testsuite/client/UnitTests.pas rename lib/delphi/test/{ => testsuite/server}/TestServer.pas (100%) rename lib/delphi/test/{ => testsuite/server}/TestServerEvents.pas (100%) diff --git a/lib/delphi/test/client.dpr b/lib/delphi/test/client.dpr index eaeeee0a28d..db62995559e 100644 --- a/lib/delphi/test/client.dpr +++ b/lib/delphi/test/client.dpr @@ -24,9 +24,13 @@ program client; uses SysUtils, - DataFactory in 'Performance\DataFactory.pas', - PerfTests in 'Performance\PerfTests.pas', - TestClient in 'TestClient.pas', + ConsoleHelper in 'ConsoleHelper.pas', + TestConstants in 'testsuite\TestConstants.pas', + TestClient in 'testsuite\client\TestClient.pas', + TestLogger in 'testsuite\client\TestLogger.pas', + UnitTests in 'testsuite\client\UnitTests.pas', + PerfTests in 'testsuite\client\Performance\PerfTests.pas', + DataFactory in 'testsuite\client\Performance\DataFactory.pas', Thrift.Test in 'gen-delphi\Thrift.Test.pas', Thrift in '..\src\Thrift.pas', Thrift.Transport in '..\src\Thrift.Transport.pas', diff --git a/lib/delphi/test/client.dproj b/lib/delphi/test/client.dproj index ae6683d992d..ae31ba050e5 100644 --- a/lib/delphi/test/client.dproj +++ b/lib/delphi/test/client.dproj @@ -50,9 +50,13 @@ MainSource - - - + + + + + + + @@ -125,7 +129,7 @@ - --protocol=compact + --protocol=compact diff --git a/lib/delphi/test/server.dpr b/lib/delphi/test/server.dpr index 79942816980..0cab02f3395 100644 --- a/lib/delphi/test/server.dpr +++ b/lib/delphi/test/server.dpr @@ -23,8 +23,9 @@ program server; uses SysUtils, - TestServer in 'TestServer.pas', - TestServerEvents in 'TestServerEvents.pas', + TestConstants in 'testsuite\TestConstants.pas', + TestServer in 'testsuite\server\TestServer.pas', + TestServerEvents in 'testsuite\server\TestServerEvents.pas', Thrift.Test in 'gen-delphi\Thrift.Test.pas', Thrift in '..\src\Thrift.pas', Thrift.Exception in '..\src\Thrift.Exception.pas', diff --git a/lib/delphi/test/server.dproj b/lib/delphi/test/server.dproj index 8e9b99dd72d..37ef9c9a6ed 100644 --- a/lib/delphi/test/server.dproj +++ b/lib/delphi/test/server.dproj @@ -50,8 +50,9 @@ MainSource - - + + + diff --git a/lib/delphi/test/TestConstants.pas b/lib/delphi/test/testsuite/TestConstants.pas similarity index 85% rename from lib/delphi/test/TestConstants.pas rename to lib/delphi/test/testsuite/TestConstants.pas index 9ac4808c056..e51b60084b9 100644 --- a/lib/delphi/test/TestConstants.pas +++ b/lib/delphi/test/testsuite/TestConstants.pas @@ -55,6 +55,18 @@ interface TLayeredTransports = set of TLayeredTransport; + {$SCOPEDENUMS ON} + TTestSize = ( + Empty, // Edge case: the zero-length empty binary + Normal, // Fairly small array of usual size (256 bytes) + ByteArrayTest, // THRIFT-4454 Large writes/reads may cause range check errors in debug mode + PipeWriteLimit, // THRIFT-4372 Pipe write operations across a network are limited to 65,535 bytes per write. + FifteenMB // quite a bit of data, but still below the default max frame size + ); + {$SCOPEDENUMS OFF} + + + const PROTOCOL_CLASSES : array[TKnownProtocol] of TProtocolImplClass = ( TBinaryProtocolImpl, @@ -151,6 +163,8 @@ interface function BytesToHex( const bytes : TBytes) : string; +function PrepareBinaryData( aRandomDist : Boolean; aSize : TTestSize) : TBytes; + implementation @@ -165,4 +179,38 @@ function BytesToHex( const bytes : TBytes) : string; end; +function PrepareBinaryData( aRandomDist : Boolean; aSize : TTestSize) : TBytes; +var i : Integer; +begin + case aSize of + TTestSize.Empty : SetLength( result, 0); + TTestSize.Normal : SetLength( result, $100); + TTestSize.ByteArrayTest : SetLength( result, SizeOf(TByteArray) + 128); + TTestSize.PipeWriteLimit : SetLength( result, 65535 + 128); + TTestSize.FifteenMB : SetLength( result, 15 * 1024 * 1024); + else + raise EArgumentException.Create('aSize'); + end; + + ASSERT( Low(result) = 0); + if Length(result) = 0 then Exit; + + // linear distribution, unless random is requested + if not aRandomDist then begin + for i := Low(result) to High(result) do begin + result[i] := i mod $100; + end; + Exit; + end; + + // random distribution of all 256 values + FillChar( result[0], Length(result) * SizeOf(result[0]), $0); + for i := Low(result) to High(result) do begin + result[i] := Byte( Random($100)); + end; +end; + + + + end. diff --git a/lib/delphi/test/Performance/DataFactory.pas b/lib/delphi/test/testsuite/client/Performance/DataFactory.pas similarity index 100% rename from lib/delphi/test/Performance/DataFactory.pas rename to lib/delphi/test/testsuite/client/Performance/DataFactory.pas diff --git a/lib/delphi/test/Performance/PerfTests.pas b/lib/delphi/test/testsuite/client/Performance/PerfTests.pas similarity index 100% rename from lib/delphi/test/Performance/PerfTests.pas rename to lib/delphi/test/testsuite/client/Performance/PerfTests.pas diff --git a/lib/delphi/test/TestClient.pas b/lib/delphi/test/testsuite/client/TestClient.pas similarity index 80% rename from lib/delphi/test/TestClient.pas rename to lib/delphi/test/testsuite/client/TestClient.pas index 1b09d3cf450..aca64410c17 100644 --- a/lib/delphi/test/TestClient.pas +++ b/lib/delphi/test/testsuite/client/TestClient.pas @@ -39,8 +39,10 @@ interface DateUtils, Generics.Collections, TestConstants, + TestLogger, ConsoleHelper, PerfTests, + UnitTests, Thrift, Thrift.Protocol.Compact, Thrift.Protocol.JSON, @@ -82,25 +84,6 @@ TTestSetup = record end; TClientThread = class( TThread ) - private type - TTestGroup = ( - test_Unknown, - test_BaseTypes, - test_Structs, - test_Containers, - test_Exceptions - // new values here - ); - TTestGroups = set of TTestGroup; - - TTestSize = ( - Empty, // Edge case: the zero-length empty binary - Normal, // Fairly small array of usual size (256 bytes) - ByteArrayTest, // THRIFT-4454 Large writes/reads may cause range check errors in debug mode - PipeWriteLimit, // THRIFT-4372 Pipe write operations across a network are limited to 65,535 bytes per write. - FifteenMB // quite a bit of data, but still below the default max frame size - ); - strict private FSetup : TTestSetup; FTransport : ITransport; @@ -109,18 +92,7 @@ TClientThread = class( TThread ) FThreadNo : Integer; FConsole : TThreadConsole; - - // test reporting, will be refactored out into separate class later - FTestGroup : string; - FCurrentTest : TTestGroup; - FSuccesses : Integer; - FErrors : TStringList; - FFailed : TTestGroups; - FExecuted : TTestGroups; - procedure StartTestGroup( const aGroup : string; const aTest : TTestGroup); - procedure Expect( aTestResult : Boolean; const aTestInfo : string); - procedure ReportResults; - function CalculateExitCode : Byte; + FLogger : ITestLogger; procedure ClientTest; {$IFDEF SupportsAsync} @@ -131,14 +103,13 @@ TClientThread = class( TThread ) procedure ShutdownProtocolTransportStack; function InitializeHttpTransport( const aTimeoutSetting : Integer; const aConfig : IThriftConfiguration = nil) : IHTTPClient; - procedure JSONProtocolReadWriteTest; - function PrepareBinaryData( aRandomDist : Boolean; aSize : TTestSize) : TBytes; {$IFDEF StressTest} procedure StressTest(const client : TThriftTest.Iface); {$ENDIF} - {$IFDEF Win64} - procedure UseInterlockedExchangeAdd64; - {$ENDIF} + + procedure StartTestGroup( const aGroup : string; const aTest : TClientTestGroup); inline; + procedure Expect( aTestResult : Boolean; const aTestInfo : string); inline; + function CalculateExitCode : Byte; strict protected procedure Execute; override; @@ -174,7 +145,7 @@ implementation EXITCODE_FAILBIT_CONTAINERS = $04; EXITCODE_FAILBIT_EXCEPTIONS = $08; - MAP_FAILURES_TO_EXITCODE_BITS : array[TClientThread.TTestGroup] of Byte = ( + MAP_FAILURES_TO_EXITCODE_BITS : array[TClientTestGroup] of Byte = ( EXITCODE_SUCCESS, // no bits here EXITCODE_FAILBIT_BASETYPES, EXITCODE_FAILBIT_STRUCTS, @@ -1052,260 +1023,26 @@ procedure TClientThread.StressTest(const client : TThriftTest.Iface); {$ENDIF} -function TClientThread.PrepareBinaryData( aRandomDist : Boolean; aSize : TTestSize) : TBytes; -var i : Integer; +procedure TClientThread.StartTestGroup( const aGroup : string; const aTest : TClientTestGroup); begin - case aSize of - Empty : SetLength( result, 0); - Normal : SetLength( result, $100); - ByteArrayTest : SetLength( result, SizeOf(TByteArray) + 128); - PipeWriteLimit : SetLength( result, 65535 + 128); - FifteenMB : SetLength( result, 15 * 1024 * 1024); - else - raise EArgumentException.Create('aSize'); - end; - - ASSERT( Low(result) = 0); - if Length(result) = 0 then Exit; - - // linear distribution, unless random is requested - if not aRandomDist then begin - for i := Low(result) to High(result) do begin - result[i] := i mod $100; - end; - Exit; - end; - - // random distribution of all 256 values - FillChar( result[0], Length(result) * SizeOf(result[0]), $0); - for i := Low(result) to High(result) do begin - result[i] := Byte( Random($100)); - end; -end; - - -{$IFDEF Win64} -procedure TClientThread.UseInterlockedExchangeAdd64; -var a,b : Int64; -begin - a := 1; - b := 2; - Thrift.Utils.InterlockedExchangeAdd64( a,b); - Expect( a = 3, 'InterlockedExchangeAdd64'); -end; -{$ENDIF} - - -procedure TClientThread.JSONProtocolReadWriteTest; -// Tests only then read/write procedures of the JSON protocol -// All tests succeed, if we can read what we wrote before -// Note that passing this test does not imply, that our JSON is really compatible to what -// other clients or servers expect as the real JSON. This is beyond the scope of this test. -var prot : IProtocol; - stm : TStringStream; - list : TThriftList; - config : IThriftConfiguration; - binary, binRead, emptyBinary : TBytes; - i,iErr : Integer; -const - TEST_SHORT = ShortInt( $FE); - TEST_SMALL = SmallInt( $FEDC); - TEST_LONG = LongInt( $FEDCBA98); - TEST_I64 = Int64( $FEDCBA9876543210); - TEST_DOUBLE = -1.234e-56; - DELTA_DOUBLE = TEST_DOUBLE * 1e-14; - TEST_STRING = 'abc-'#$00E4#$00f6#$00fc; // german umlauts (en-us: "funny chars") - // Test THRIFT-2336 and THRIFT-3404 with U+1D11E (G Clef symbol) and 'Русское Название'; - G_CLEF_AND_CYRILLIC_TEXT = #$1d11e' '#$0420#$0443#$0441#$0441#$043a#$043e#$0435' '#$041d#$0430#$0437#$0432#$0430#$043d#$0438#$0435; - G_CLEF_AND_CYRILLIC_JSON = '"\ud834\udd1e \u0420\u0443\u0441\u0441\u043a\u043e\u0435 \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435"'; - // test both possible solidus encodings - SOLIDUS_JSON_DATA = '"one/two\/three"'; - SOLIDUS_EXCPECTED = 'one/two/three'; -begin - stm := TStringStream.Create; - try - StartTestGroup( 'JsonProtocolTest', test_Unknown); - - config := TThriftConfigurationImpl.Create; - - // prepare binary data - binary := PrepareBinaryData( FALSE, Normal); - SetLength( emptyBinary, 0); // empty binary data block - - // output setup - prot := TJSONProtocolImpl.Create( - TStreamTransportImpl.Create( - nil, TThriftStreamAdapterDelphi.Create( stm, FALSE), config)); - - // write - Init( list, TType.String_, 9); - prot.WriteListBegin( list); - prot.WriteBool( TRUE); - prot.WriteBool( FALSE); - prot.WriteByte( TEST_SHORT); - prot.WriteI16( TEST_SMALL); - prot.WriteI32( TEST_LONG); - prot.WriteI64( TEST_I64); - prot.WriteDouble( TEST_DOUBLE); - prot.WriteString( TEST_STRING); - prot.WriteBinary( binary); - prot.WriteString( ''); // empty string - prot.WriteBinary( emptyBinary); // empty binary data block - prot.WriteListEnd; - - // input setup - Expect( stm.Position = stm.Size, 'Stream position/length after write'); - stm.Position := 0; - prot := TJSONProtocolImpl.Create( - TStreamTransportImpl.Create( - TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config)); - - // read and compare - list := prot.ReadListBegin; - Expect( list.ElementType = TType.String_, 'list element type'); - Expect( list.Count = 9, 'list element count'); - Expect( prot.ReadBool, 'WriteBool/ReadBool: TRUE'); - Expect( not prot.ReadBool, 'WriteBool/ReadBool: FALSE'); - Expect( prot.ReadByte = TEST_SHORT, 'WriteByte/ReadByte'); - Expect( prot.ReadI16 = TEST_SMALL, 'WriteI16/ReadI16'); - Expect( prot.ReadI32 = TEST_LONG, 'WriteI32/ReadI32'); - Expect( prot.ReadI64 = TEST_I64, 'WriteI64/ReadI64'); - Expect( abs(prot.ReadDouble-TEST_DOUBLE) < abs(DELTA_DOUBLE), 'WriteDouble/ReadDouble'); - Expect( prot.ReadString = TEST_STRING, 'WriteString/ReadString'); - binRead := prot.ReadBinary; - Expect( Length(prot.ReadString) = 0, 'WriteString/ReadString (empty string)'); - Expect( Length(prot.ReadBinary) = 0, 'empty WriteBinary/ReadBinary (empty data block)'); - prot.ReadListEnd; - - // test binary data - Expect( Length(binary) = Length(binRead), 'Binary data length check'); - iErr := -1; - for i := Low(binary) to High(binary) do begin - if binary[i] <> binRead[i] then begin - iErr := i; - Break; - end; - end; - if iErr < 0 - then Expect( TRUE, 'Binary data check ('+IntToStr(Length(binary))+' Bytes)') - else Expect( FALSE, 'Binary data check at offset '+IntToStr(iErr)); - - Expect( stm.Position = stm.Size, 'Stream position after read'); - - - // Solidus can be encoded in two ways. Make sure we can read both - stm.Position := 0; - stm.Size := 0; - stm.WriteString(SOLIDUS_JSON_DATA); - stm.Position := 0; - prot := TJSONProtocolImpl.Create( - TStreamTransportImpl.Create( - TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config)); - Expect( prot.ReadString = SOLIDUS_EXCPECTED, 'Solidus encoding'); - - - // Widechars should work too. Do they? - // After writing, we ensure that we are able to read it back - // We can't assume hex-encoding, since (nearly) any Unicode char is valid JSON - stm.Position := 0; - stm.Size := 0; - prot := TJSONProtocolImpl.Create( - TStreamTransportImpl.Create( - nil, TThriftStreamAdapterDelphi.Create( stm, FALSE), config)); - prot.WriteString( G_CLEF_AND_CYRILLIC_TEXT); - stm.Position := 0; - prot := TJSONProtocolImpl.Create( - TStreamTransportImpl.Create( - TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config)); - Expect( prot.ReadString = G_CLEF_AND_CYRILLIC_TEXT, 'Writing JSON with chars > 8 bit'); - - // Widechars should work with hex-encoding too. Do they? - stm.Position := 0; - stm.Size := 0; - stm.WriteString( G_CLEF_AND_CYRILLIC_JSON); - stm.Position := 0; - prot := TJSONProtocolImpl.Create( - TStreamTransportImpl.Create( - TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config)); - Expect( prot.ReadString = G_CLEF_AND_CYRILLIC_TEXT, 'Reading JSON with chars > 8 bit'); - - - finally - stm.Free; - prot := nil; //-> Release - StartTestGroup( '', test_Unknown); // no more tests here - end; -end; - - -procedure TClientThread.StartTestGroup( const aGroup : string; const aTest : TTestGroup); -begin - FTestGroup := aGroup; - FCurrentTest := aTest; - - Include( FExecuted, aTest); - - if FTestGroup <> '' then begin - Console.WriteLine(''); - Console.WriteLine( aGroup+' tests'); - Console.WriteLine( StringOfChar('-',60)); - end; + FLogger.StartTestGroup( aGroup, aTest); end; procedure TClientThread.Expect( aTestResult : Boolean; const aTestInfo : string); begin - if aTestResult then begin - Inc(FSuccesses); - Console.WriteLine( aTestInfo+': passed'); - end - else begin - FErrors.Add( FTestGroup+': '+aTestInfo); - Include( FFailed, FCurrentTest); - Console.WriteLine( aTestInfo+': *** FAILED ***'); - - // We have a failed test! - // -> issue DebugBreak ONLY if a debugger is attached, - // -> unhandled DebugBreaks would cause Windows to terminate the app otherwise - if IsDebuggerPresent - then {$IFDEF CPUX64} DebugBreak {$ELSE} asm int 3 end {$ENDIF}; - end; -end; - - -procedure TClientThread.ReportResults; -var nTotal : Integer; - sLine : string; -begin - // prevent us from stupid DIV/0 errors - nTotal := FSuccesses + FErrors.Count; - if nTotal = 0 then begin - Console.WriteLine('No results logged'); - Exit; - end; - - Console.WriteLine(''); - Console.WriteLine( StringOfChar('=',60)); - Console.WriteLine( IntToStr(nTotal)+' tests performed'); - Console.WriteLine( IntToStr(FSuccesses)+' tests succeeded ('+IntToStr(round(100*FSuccesses/nTotal))+'%)'); - Console.WriteLine( IntToStr(FErrors.Count)+' tests failed ('+IntToStr(round(100*FErrors.Count/nTotal))+'%)'); - Console.WriteLine( StringOfChar('=',60)); - if FErrors.Count > 0 then begin - Console.WriteLine('FAILED TESTS:'); - for sLine in FErrors do Console.WriteLine('- '+sLine); - Console.WriteLine( StringOfChar('=',60)); - InterlockedIncrement( ExitCode); // return <> 0 on errors - end; - Console.WriteLine(''); + FLogger.Expect( aTestResult, aTestInfo); end; function TClientThread.CalculateExitCode : Byte; -var test : TTestGroup; +var test : TClientTestGroup; + failed, executed : TClientTestGroups; begin result := EXITCODE_SUCCESS; - for test := Low(TTestGroup) to High(TTestGroup) do begin - if (test in FFailed) or not (test in FExecuted) + FLogger.QueryTestStats( failed, executed); + for test := Low(TClientTestGroup) to High(TClientTestGroup) do begin + if (test in failed) or not (test in executed) then result := result or MAP_FAILURES_TO_EXITCODE_BITS[test]; end; end; @@ -1318,12 +1055,7 @@ constructor TClientThread.Create( const aSetup : TTestSetup; const aNumIteration FNumIterations := aNumIteration; FConsole := TThreadConsole.Create( Self, aLogThreadID); - FCurrentTest := test_Unknown; - - // error list: keep correct order, allow for duplicates - FErrors := TStringList.Create; - FErrors.Sorted := FALSE; - FErrors.Duplicates := dupAccept; + FLogger := TTestLoggerImpl.Create; inherited Create( TRUE); end; @@ -1331,7 +1063,7 @@ constructor TClientThread.Create( const aSetup : TTestSetup; const aNumIteration destructor TClientThread.Destroy; begin FreeAndNil( FConsole); - FreeAndNil( FErrors); + FLogger := nil; //-> Release inherited; end; @@ -1341,10 +1073,9 @@ procedure TClientThread.Execute; begin // perform all tests try - {$IFDEF Win64} - UseInterlockedExchangeAdd64; - {$ENDIF} - JSONProtocolReadWriteTest; + // builtin (quick) unit tests on one thread only + if ThreadNo = 0 + then TQuickUnitTests.Execute(FLogger); // must be run in the context of the thread InitializeProtocolTransportStack; @@ -1357,7 +1088,7 @@ procedure TClientThread.Execute; end; // report the outcome - ReportResults; + FLogger.ReportResults; SetReturnValue( CalculateExitCode); finally diff --git a/lib/delphi/test/testsuite/client/TestLogger.pas b/lib/delphi/test/testsuite/client/TestLogger.pas new file mode 100644 index 00000000000..10ddfc74c1a --- /dev/null +++ b/lib/delphi/test/testsuite/client/TestLogger.pas @@ -0,0 +1,193 @@ +(* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *) + +unit TestLogger; + +{$I ../src/Thrift.Defines.inc} + +interface + +uses + Classes, Windows, SysUtils, Math, ActiveX, ComObj, + {$IFDEF SupportsAsync} System.Threading, {$ENDIF} + DateUtils, + Generics.Collections, + TestConstants, + ConsoleHelper, + Thrift, + Thrift.Protocol.Compact, + Thrift.Protocol.JSON, + Thrift.Protocol, + Thrift.Transport.Pipes, + Thrift.Transport.WinHTTP, + Thrift.Transport.MsxmlHTTP, + Thrift.Transport, + Thrift.Stream, + Thrift.Test, + Thrift.WinHTTP, + Thrift.Utils, + Thrift.Configuration, + Thrift.Collections; + + +type + TClientTestGroup = ( + test_Unknown, + test_BaseTypes, + test_Structs, + test_Containers, + test_Exceptions + // new values here + ); + TClientTestGroups = set of TClientTestGroup; + + + ITestLogger = interface + ['{26693ED5-1469-48AD-B1F3-04281B053DD4}'] + procedure StartTestGroup( const aGroup : string; const aTest : TClientTestGroup); + procedure Expect( aTestResult : Boolean; const aTestInfo : string); + procedure QueryTestStats( out failed, executed : TClientTestGroups); + procedure ReportResults; + end; + + + // test reporting helper + TTestLoggerImpl = class( TInterfacedObject, ITestLogger) + strict private + FTestGroup : string; + FCurrentTest : TClientTestGroup; + FSuccesses : Integer; + FErrors : TStringList; + FFailed : TClientTestGroups; + FExecuted : TClientTestGroups; + + strict protected + // ITestLogger = interface + procedure StartTestGroup( const aGroup : string; const aTest : TClientTestGroup); + procedure Expect( aTestResult : Boolean; const aTestInfo : string); + procedure QueryTestStats( out failed, executed : TClientTestGroups); + procedure ReportResults; + + public + constructor Create; + destructor Destroy; override; + + end; + + +implementation + + +constructor TTestLoggerImpl.Create; +begin + inherited Create; + FCurrentTest := test_Unknown; + + // error list: keep correct order, allow for duplicates + FErrors := TStringList.Create; + FErrors.Sorted := FALSE; + FErrors.Duplicates := dupAccept; +end; + + +destructor TTestLoggerImpl.Destroy; +begin + try + FreeAndNil( FErrors); + finally + inherited Destroy; + end; +end; + + +procedure TTestLoggerImpl.StartTestGroup( const aGroup : string; const aTest : TClientTestGroup); +begin + FTestGroup := aGroup; + FCurrentTest := aTest; + + Include( FExecuted, aTest); + + if FTestGroup <> '' then begin + Console.WriteLine(''); + Console.WriteLine( aGroup+' tests'); + Console.WriteLine( StringOfChar('-',60)); + end; +end; + + +procedure TTestLoggerImpl.Expect( aTestResult : Boolean; const aTestInfo : string); +begin + if aTestResult then begin + Inc(FSuccesses); + Console.WriteLine( aTestInfo+': passed'); + end + else begin + FErrors.Add( FTestGroup+': '+aTestInfo); + Include( FFailed, FCurrentTest); + Console.WriteLine( aTestInfo+': *** FAILED ***'); + + // We have a failed test! + // -> issue DebugBreak ONLY if a debugger is attached, + // -> unhandled DebugBreaks would cause Windows to terminate the app otherwise + if IsDebuggerPresent + then {$IFDEF CPUX64} DebugBreak {$ELSE} asm int 3 end {$ENDIF}; + end; +end; + + +procedure TTestLoggerImpl.QueryTestStats( out failed, executed : TClientTestGroups); +begin + failed := FFailed; + executed := FExecuted; +end; + + + +procedure TTestLoggerImpl.ReportResults; +var nTotal : Integer; + sLine : string; +begin + // prevent us from stupid DIV/0 errors + nTotal := FSuccesses + FErrors.Count; + if nTotal = 0 then begin + Console.WriteLine('No results logged'); + Exit; + end; + + Console.WriteLine(''); + Console.WriteLine( StringOfChar('=',60)); + Console.WriteLine( IntToStr(nTotal)+' tests performed'); + Console.WriteLine( IntToStr(FSuccesses)+' tests succeeded ('+IntToStr(round(100*FSuccesses/nTotal))+'%)'); + Console.WriteLine( IntToStr(FErrors.Count)+' tests failed ('+IntToStr(round(100*FErrors.Count/nTotal))+'%)'); + Console.WriteLine( StringOfChar('=',60)); + if FErrors.Count > 0 then begin + Console.WriteLine('FAILED TESTS:'); + for sLine in FErrors do Console.WriteLine('- '+sLine); + Console.WriteLine( StringOfChar('=',60)); + InterlockedIncrement( ExitCode); // return <> 0 on errors + end; + Console.WriteLine(''); +end; + + + + + + +end. diff --git a/lib/delphi/test/testsuite/client/UnitTests.pas b/lib/delphi/test/testsuite/client/UnitTests.pas new file mode 100644 index 00000000000..3726c873594 --- /dev/null +++ b/lib/delphi/test/testsuite/client/UnitTests.pas @@ -0,0 +1,350 @@ +(* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *) + +unit UnitTests; + +{$I ../src/Thrift.Defines.inc} + +interface + +uses + Classes, Windows, SysUtils, Math, ActiveX, ComObj, + {$IFDEF SupportsAsync} System.Threading, {$ENDIF} + DateUtils, + Generics.Collections, + TestConstants, + TestLogger, + ConsoleHelper, + Thrift, + Thrift.Protocol.Compact, + Thrift.Protocol.JSON, + Thrift.Protocol, + Thrift.Transport.Pipes, + Thrift.Transport.WinHTTP, + Thrift.Transport.MsxmlHTTP, + Thrift.Transport, + Thrift.Stream, + Thrift.Test, + Thrift.WinHTTP, + Thrift.Utils, + Thrift.Configuration, + Thrift.Collections; + +type + TQuickUnitTests = class sealed + strict private + FLogger : ITestLogger; + + strict protected + // Helper + procedure StartTestGroup( const aGroup : string; const aTest : TClientTestGroup); inline; + procedure Expect( aTestResult : Boolean; const aTestInfo : string); inline; + + // Test impl + procedure JSONProtocolReadWriteTest; + procedure HashSetTest; + {$IFDEF Win64} + procedure UseInterlockedExchangeAdd64; + {$ENDIF} + + // main execution part + constructor Create( const logger : ITestLogger); reintroduce; + procedure Execute; overload; + public + destructor Destroy; override; + + class procedure Execute( const logger : ITestLogger); overload; static; + end; + + +implementation + + +constructor TQuickUnitTests.Create( const logger : ITestLogger); +begin + inherited Create; + FLogger := logger; +end; + + +destructor TQuickUnitTests.Destroy; +begin + try + FLogger := nil; //-> Release + finally + inherited Destroy; + end; +end; + + +class procedure TQuickUnitTests.Execute( const logger : ITestLogger); +var instance : TQuickUnitTests; +begin + instance := TQuickUnitTests.Create(logger); + try + instance.Execute; + finally + instance.Free; + end; +end; + + +procedure TQuickUnitTests.Execute; +begin + {$IFDEF Win64} + UseInterlockedExchangeAdd64; + {$ENDIF} + + JSONProtocolReadWriteTest; + HashSetTest; +end; + + +procedure TQuickUnitTests.StartTestGroup( const aGroup : string; const aTest : TClientTestGroup); +begin + FLogger.StartTestGroup( aGroup, aTest); +end; + + +procedure TQuickUnitTests.Expect( aTestResult : Boolean; const aTestInfo : string); +begin + FLogger.Expect( aTestResult, aTestInfo); +end; + + +{$IFDEF Win64} +procedure TQuickUnitTests.UseInterlockedExchangeAdd64; +var a,b : Int64; +begin + a := 1; + b := 2; + Thrift.Utils.InterlockedExchangeAdd64( a,b); + Expect( a = 3, 'InterlockedExchangeAdd64'); +end; +{$ENDIF} + + +procedure TQuickUnitTests.JSONProtocolReadWriteTest; +// Tests only then read/write procedures of the JSON protocol +// All tests succeed, if we can read what we wrote before +// Note that passing this test does not imply, that our JSON is really compatible to what +// other clients or servers expect as the real JSON. This is beyond the scope of this test. +var prot : IProtocol; + stm : TStringStream; + list : TThriftList; + config : IThriftConfiguration; + binary, binRead, emptyBinary : TBytes; + i,iErr : Integer; +const + TEST_SHORT = ShortInt( $FE); + TEST_SMALL = SmallInt( $FEDC); + TEST_LONG = LongInt( $FEDCBA98); + TEST_I64 = Int64( $FEDCBA9876543210); + TEST_DOUBLE = -1.234e-56; + DELTA_DOUBLE = TEST_DOUBLE * 1e-14; + TEST_STRING = 'abc-'#$00E4#$00f6#$00fc; // german umlauts (en-us: "funny chars") + // Test THRIFT-2336 and THRIFT-3404 with U+1D11E (G Clef symbol) and 'Русское Название'; + G_CLEF_AND_CYRILLIC_TEXT = #$1d11e' '#$0420#$0443#$0441#$0441#$043a#$043e#$0435' '#$041d#$0430#$0437#$0432#$0430#$043d#$0438#$0435; + G_CLEF_AND_CYRILLIC_JSON = '"\ud834\udd1e \u0420\u0443\u0441\u0441\u043a\u043e\u0435 \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435"'; + // test both possible solidus encodings + SOLIDUS_JSON_DATA = '"one/two\/three"'; + SOLIDUS_EXCPECTED = 'one/two/three'; +begin + stm := TStringStream.Create; + try + FLogger.StartTestGroup( 'JsonProtocolTest', test_Unknown); + + config := TThriftConfigurationImpl.Create; + + // prepare binary data + binary := PrepareBinaryData( FALSE, TTestSize.Normal); + SetLength( emptyBinary, 0); // empty binary data block + + // output setup + prot := TJSONProtocolImpl.Create( + TStreamTransportImpl.Create( + nil, TThriftStreamAdapterDelphi.Create( stm, FALSE), config)); + + // write + Init( list, TType.String_, 9); + prot.WriteListBegin( list); + prot.WriteBool( TRUE); + prot.WriteBool( FALSE); + prot.WriteByte( TEST_SHORT); + prot.WriteI16( TEST_SMALL); + prot.WriteI32( TEST_LONG); + prot.WriteI64( TEST_I64); + prot.WriteDouble( TEST_DOUBLE); + prot.WriteString( TEST_STRING); + prot.WriteBinary( binary); + prot.WriteString( ''); // empty string + prot.WriteBinary( emptyBinary); // empty binary data block + prot.WriteListEnd; + + // input setup + Expect( stm.Position = stm.Size, 'Stream position/length after write'); + stm.Position := 0; + prot := TJSONProtocolImpl.Create( + TStreamTransportImpl.Create( + TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config)); + + // read and compare + list := prot.ReadListBegin; + Expect( list.ElementType = TType.String_, 'list element type'); + Expect( list.Count = 9, 'list element count'); + Expect( prot.ReadBool, 'WriteBool/ReadBool: TRUE'); + Expect( not prot.ReadBool, 'WriteBool/ReadBool: FALSE'); + Expect( prot.ReadByte = TEST_SHORT, 'WriteByte/ReadByte'); + Expect( prot.ReadI16 = TEST_SMALL, 'WriteI16/ReadI16'); + Expect( prot.ReadI32 = TEST_LONG, 'WriteI32/ReadI32'); + Expect( prot.ReadI64 = TEST_I64, 'WriteI64/ReadI64'); + Expect( abs(prot.ReadDouble-TEST_DOUBLE) < abs(DELTA_DOUBLE), 'WriteDouble/ReadDouble'); + Expect( prot.ReadString = TEST_STRING, 'WriteString/ReadString'); + binRead := prot.ReadBinary; + Expect( Length(prot.ReadString) = 0, 'WriteString/ReadString (empty string)'); + Expect( Length(prot.ReadBinary) = 0, 'empty WriteBinary/ReadBinary (empty data block)'); + prot.ReadListEnd; + + // test binary data + Expect( Length(binary) = Length(binRead), 'Binary data length check'); + iErr := -1; + for i := Low(binary) to High(binary) do begin + if binary[i] <> binRead[i] then begin + iErr := i; + Break; + end; + end; + if iErr < 0 + then Expect( TRUE, 'Binary data check ('+IntToStr(Length(binary))+' Bytes)') + else Expect( FALSE, 'Binary data check at offset '+IntToStr(iErr)); + + Expect( stm.Position = stm.Size, 'Stream position after read'); + + + // Solidus can be encoded in two ways. Make sure we can read both + stm.Position := 0; + stm.Size := 0; + stm.WriteString(SOLIDUS_JSON_DATA); + stm.Position := 0; + prot := TJSONProtocolImpl.Create( + TStreamTransportImpl.Create( + TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config)); + Expect( prot.ReadString = SOLIDUS_EXCPECTED, 'Solidus encoding'); + + + // Widechars should work too. Do they? + // After writing, we ensure that we are able to read it back + // We can't assume hex-encoding, since (nearly) any Unicode char is valid JSON + stm.Position := 0; + stm.Size := 0; + prot := TJSONProtocolImpl.Create( + TStreamTransportImpl.Create( + nil, TThriftStreamAdapterDelphi.Create( stm, FALSE), config)); + prot.WriteString( G_CLEF_AND_CYRILLIC_TEXT); + stm.Position := 0; + prot := TJSONProtocolImpl.Create( + TStreamTransportImpl.Create( + TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config)); + FLogger.Expect( prot.ReadString = G_CLEF_AND_CYRILLIC_TEXT, 'Writing JSON with chars > 8 bit'); + + // Widechars should work with hex-encoding too. Do they? + stm.Position := 0; + stm.Size := 0; + stm.WriteString( G_CLEF_AND_CYRILLIC_JSON); + stm.Position := 0; + prot := TJSONProtocolImpl.Create( + TStreamTransportImpl.Create( + TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config)); + FLogger.Expect( prot.ReadString = G_CLEF_AND_CYRILLIC_TEXT, 'Reading JSON with chars > 8 bit'); + + + finally + stm.Free; + prot := nil; //-> Release + FLogger.StartTestGroup( '', test_Unknown); // no more tests here + end; +end; + + +procedure TQuickUnitTests.HashSetTest; +var container : IThriftHashSet; + testdata : array of Integer; + i : Integer; +const + TEST_COUNT = 4096; +begin + StartTestGroup( 'IThriftHashSet implementation', test_Containers); + + // prepare test data + SetLength( testdata, 5); + testdata[0] := -2; + testdata[1] := 0; + testdata[2] := 42; + testdata[3] := MaxInt; + testdata[4] := Low(Integer); + + // first insert + container := TThriftHashSetImpl.Create; + for i in testdata do begin + Expect( container.Add( i), 'add first '+IntToStr(i)); + Expect( container.Contains( i), 'contains '+IntToStr(i)); + end; + Expect( container.Count = Length(testdata), 'container size'); + + // insert again + for i in testdata do begin + Expect( not container.Add( i), 'add second '+IntToStr(i)); + Expect( container.Contains( i), 'contains '+IntToStr(i)); + end; + Expect( container.Count = Length(testdata), 'container size'); + + // remove + for i in testdata do begin + Expect( container.Remove( i), 'first remove '+IntToStr(i)); + Expect( not container.Contains( i), 'not contains '+IntToStr(i)); + end; + Expect( container.Count = 0, 'container size'); + + // remove again + for i in testdata do begin + Expect( not container.Remove( i), 'second remove '+IntToStr(i)); + Expect( not container.Contains( i), 'not contains '+IntToStr(i)); + end; + Expect( container.Count = 0, 'container size'); + + // append and clear + for i := 0 to TEST_COUNT-1 do begin + container.Add(-i); + container.Add(+i); + end; + Expect( container.Count = 2*TEST_COUNT-1, 'container size check'); + Expect( not container.Contains( -TEST_COUNT), 'element not contained'); + Expect( not container.Contains( TEST_COUNT), 'element not contained'); + container.Clear; + Expect( container.Count = 0, 'count=0 after clear'); +end; + + + + + + + + +end. diff --git a/lib/delphi/test/TestServer.pas b/lib/delphi/test/testsuite/server/TestServer.pas similarity index 100% rename from lib/delphi/test/TestServer.pas rename to lib/delphi/test/testsuite/server/TestServer.pas diff --git a/lib/delphi/test/TestServerEvents.pas b/lib/delphi/test/testsuite/server/TestServerEvents.pas similarity index 100% rename from lib/delphi/test/TestServerEvents.pas rename to lib/delphi/test/testsuite/server/TestServerEvents.pas From 994727d6b246b701d8645b54e574ea5c0dcfd51e Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 25 May 2024 08:58:48 +0200 Subject: [PATCH 238/250] THRIFT-5788 Refactor and streamline hash set implementation Client: delphi Patch: Jens Geyer Follow-up: fix memory leak --- lib/delphi/src/Thrift.Collections.pas | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/delphi/src/Thrift.Collections.pas b/lib/delphi/src/Thrift.Collections.pas index c0fe3231946..0500d4936a2 100644 --- a/lib/delphi/src/Thrift.Collections.pas +++ b/lib/delphi/src/Thrift.Collections.pas @@ -224,6 +224,7 @@ TThriftHashSetImpl = class( TInterfacedObject, IHashSet, IThriftHashSet< public constructor Create( const aCapacity: Integer = 0); overload; constructor Create( const aCapacity: Integer; const aComparer : IEqualityComparer); overload; + destructor Destroy; override; function ToString : string; override; end; @@ -263,6 +264,14 @@ constructor TThriftHashSetImpl.Create( const aCapacity: Integer; const aCompa FDictionary := TDictionary.Create( aCapacity, aComparer); end; + +destructor TThriftHashSetImpl.Destroy; +begin + FDictionary.Free; + inherited Destroy; +end; + + function TThriftHashSetImpl.GetCount: Integer; begin Result := FDictionary.Count; From 9ae4fdc36dbc46d776c527801d0d8ef4ec5ba827 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 16 May 2024 17:16:22 -0700 Subject: [PATCH 239/250] THRIFT-5786: Full deprecation support in go Client: go This should got most of them. Also fixed an indentation bug from 4930ca. --- .../cpp/src/thrift/generate/t_go_generator.cc | 61 +++++++++++++++++-- .../cpp/src/thrift/generate/t_go_generator.h | 2 + 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index c135d64edc2..65574dd0a40 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -768,9 +768,11 @@ void t_go_generator::generate_typedef(t_typedef* ttypedef) { return; } + generate_deprecation_comment(f_types_, ttypedef->annotations_); f_types_ << "type " << new_type_name << " " << base_type << '\n' << '\n'; // Generate a convenience function that converts an instance of a type // (which may be a constant) into a pointer to an instance of a type. + generate_deprecation_comment(f_types_, ttypedef->annotations_); f_types_ << "func " << new_type_name << "Ptr(v " << new_type_name << ") *" << new_type_name << " { return &v }" << '\n' << '\n'; } @@ -785,13 +787,15 @@ void t_go_generator::generate_enum(t_enum* tenum) { std::ostringstream to_string_mapping, from_string_mapping; std::string tenum_name(publicize(tenum->get_name())); generate_go_docstring(f_types_, tenum); - f_types_ << '\n' << "type " << tenum_name << " int64" << '\n' << "const (" << '\n'; + generate_deprecation_comment(f_types_, tenum->annotations_); + f_types_ << "type " << tenum_name << " int64" << '\n' << "const (" << '\n'; to_string_mapping << indent() << "func (p " << tenum_name << ") String() string {" << '\n'; indent_up(); to_string_mapping << indent() << "switch p {" << '\n'; indent_down(); + generate_deprecation_comment(from_string_mapping, tenum->annotations_); from_string_mapping << indent() << "func " << tenum_name << "FromString(s string) (" << tenum_name << ", error) {" << '\n'; indent_up(); @@ -808,6 +812,7 @@ void t_go_generator::generate_enum(t_enum* tenum) { string iter_std_name(escape_string((*c_iter)->get_name())); string iter_name((*c_iter)->get_name()); + generate_deprecation_comment(f_types_, (*c_iter)->annotations_); f_types_ << indent() << tenum_name << "_" << iter_name << ' ' << tenum_name << " = " << value << '\n'; // Dictionaries to/from string names of enums @@ -841,6 +846,7 @@ void t_go_generator::generate_enum(t_enum* tenum) { // Generate a convenience function that converts an instance of an enum // (which may be a constant) into a pointer to an instance of that enum // type. + generate_deprecation_comment(f_types_, tenum->annotations_); f_types_ << "func " << tenum_name << "Ptr(v " << tenum_name << ") *" << tenum_name << " { return &v }" << '\n' << '\n'; @@ -889,7 +895,7 @@ void t_go_generator::generate_enum(t_enum* tenum) { f_types_ << indent() << "}" << '\n'; f_types_ << indent() << "return int64(*p), nil" << '\n'; indent_down(); - f_types_ << "}" << '\n'; + f_types_ << "}" << '\n' << '\n'; } @@ -1187,7 +1193,7 @@ void t_go_generator::generate_go_struct(t_struct* tstruct, bool is_exception) { go_validator_generator(this).generate_struct_validator(f_types_, tstruct); f_types_ << indent() << "return nil" << '\n'; indent_down(); - f_types_ << "}" << '\n'; + f_types_ << "}" << '\n' << '\n'; } void t_go_generator::get_publicized_name_and_def_value(t_field* tfield, @@ -1235,6 +1241,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, std::string tstruct_name(publicize(tstruct->get_name(), is_args || is_result)); generate_go_docstring(out, tstruct); + generate_deprecation_comment(out, tstruct->annotations_); out << indent() << "type " << tstruct_name << " struct {" << '\n'; /* Here we generate the structure specification for the fastbinary codec. @@ -1314,6 +1321,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, // Trailing whitespace gotag.resize(gotag.size()-1); + generate_deprecation_comment(out, (*m_iter)->annotations_); indent(out) << publicize((*m_iter)->get_name()) << " " << goType << " `thrift:\"" << escape_string((*m_iter)->get_name()) << "," << sorted_keys_pos; if ((*m_iter)->get_req() == t_field::T_REQUIRED) { @@ -1325,6 +1333,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, } } else { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + generate_deprecation_comment(out, (*m_iter)->annotations_); // This fills in default values, as opposed to nulls out << indent() << publicize((*m_iter)->get_name()) << " " << type_to_go_type((*m_iter)->get_type()) << '\n'; @@ -1333,6 +1342,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, indent_down(); out << indent() << "}" << '\n' << '\n'; + generate_deprecation_comment(out, tstruct->annotations_); out << indent() << "func New" << tstruct_name << "() *" << tstruct_name << " {" << '\n'; indent_up(); out << indent() << "return &"; @@ -1348,6 +1358,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, string goType = type_to_go_type_with_opt(fieldType, false); string def_var_name = tstruct_name + "_" + publicized_name + "_DEFAULT"; if ((*m_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*m_iter)) { + generate_deprecation_comment(out, (*m_iter)->annotations_); out << indent() << "var " << def_var_name << " " << goType; if (def_value != nullptr) { out << " = " << render_const_value(fieldType, def_value, (*m_iter)->get_name()); @@ -1366,6 +1377,7 @@ void t_go_generator::generate_go_struct_definition(ostream& out, if (is_pointer_field(*m_iter)) { string goOptType = type_to_go_type_with_opt(fieldType, true); string maybepointer = goOptType != goType ? "*" : ""; + generate_deprecation_comment(out, (*m_iter)->annotations_); out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() " << goType << " {" << '\n'; indent_up(); @@ -1376,15 +1388,16 @@ void t_go_generator::generate_go_struct_definition(ostream& out, out << indent() << "}" << '\n'; out << indent() << "return " << maybepointer << "p." << publicized_name << '\n'; indent_down(); - out << indent() << "}" << '\n'; + out << indent() << "}" << '\n' << '\n'; } else { out << '\n'; + generate_deprecation_comment(out, (*m_iter)->annotations_); out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() " << goType << " {" << '\n'; indent_up(); out << indent() << "return p." << publicized_name << '\n'; indent_down(); - out << indent() << "}" << '\n'; + out << indent() << "}" << '\n' << '\n'; } } @@ -1468,6 +1481,7 @@ void t_go_generator::generate_isset_helpers(ostream& out, for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { const string field_name(publicize(escape_string((*f_iter)->get_name()))); if ((*f_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*f_iter)) { + generate_deprecation_comment(out, (*f_iter)->annotations_); out << indent() << "func (p *" << tstruct_name << ") IsSet" << field_name << "() bool {" << '\n'; indent_up(); @@ -1981,6 +1995,7 @@ void t_go_generator::generate_service_interface(t_service* tservice) { indent_down(); } + generate_deprecation_comment(f_types_, tservice->annotations_); f_types_ << indent() << "type " << interfaceName << " interface {" << extends_if; indent_up(); generate_go_docstring(f_types_, tservice); @@ -1992,6 +2007,7 @@ void t_go_generator::generate_service_interface(t_service* tservice) { for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { generate_go_docstring(f_types_, (*f_iter)); + generate_deprecation_comment(f_types_, (*f_iter)->annotations_); f_types_ << indent() << function_signature_if(*f_iter, "", true) << '\n'; } } @@ -2030,6 +2046,7 @@ void t_go_generator::generate_service_client(t_service* tservice) { extends_field = extends_client.substr(extends_client.find(".") + 1); generate_go_docstring(f_types_, tservice); + generate_deprecation_comment(f_types_, tservice->annotations_); f_types_ << indent() << "type " << serviceName << "Client struct {" << '\n'; indent_up(); @@ -2044,6 +2061,7 @@ void t_go_generator::generate_service_client(t_service* tservice) { f_types_ << indent() << "}" << '\n' << '\n'; // Legacy constructor function + generate_deprecation_comment(f_types_, tservice->annotations_); f_types_ << indent() << "func New" << serviceName << "ClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *" << serviceName << "Client {" << '\n'; @@ -2063,6 +2081,7 @@ void t_go_generator::generate_service_client(t_service* tservice) { indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; // Legacy constructor function with custom input & output protocols + generate_deprecation_comment(f_types_, tservice->annotations_); f_types_ << indent() << "func New" << serviceName << "ClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *" @@ -2085,6 +2104,7 @@ void t_go_generator::generate_service_client(t_service* tservice) { f_types_ << indent() << "}" << '\n' << '\n'; // Constructor function + generate_deprecation_comment(f_types_, tservice->annotations_); f_types_ << indent() << "func New" << serviceName << "Client(c thrift.TClient) *" << serviceName << "Client {" << '\n'; indent_up(); @@ -2133,6 +2153,7 @@ void t_go_generator::generate_service_client(t_service* tservice) { string funname = publicize((*f_iter)->get_name()); // Open function generate_go_docstring(f_types_, (*f_iter)); + generate_deprecation_comment(f_types_, (*f_iter)->annotations_); f_types_ << indent() << "func (p *" << serviceName << "Client) " << function_signature_if(*f_iter, "", true) << " {" << '\n'; indent_up(); @@ -2475,6 +2496,7 @@ void t_go_generator::generate_service_remote(t_service* tservice) { f_remote << indent() << "case \"simplejson\":" << '\n'; indent_up(); f_remote << indent() << "protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(cfg)" << '\n'; + indent_down(); f_remote << indent() << "case \"json\":" << '\n'; indent_up(); f_remote << indent() << "protocolFactory = thrift.NewTJSONProtocolFactory()" << '\n'; @@ -2831,6 +2853,7 @@ void t_go_generator::generate_service_server(t_service* tservice) { string self(tmp("self")); if (extends_processor.empty()) { + generate_deprecation_comment(f_types_, tservice->annotations_); f_types_ << indent() << "type " << serviceName << "Processor struct {" << '\n'; indent_up(); f_types_ << indent() << "processorMap map[string]thrift.TProcessorFunction" << '\n'; @@ -2858,6 +2881,7 @@ void t_go_generator::generate_service_server(t_service* tservice) { f_types_ << indent() << "return p.processorMap" << '\n'; indent_down(); f_types_ << indent() << "}" << '\n' << '\n'; + generate_deprecation_comment(f_types_, tservice->annotations_); f_types_ << indent() << "func New" << serviceName << "Processor(handler " << serviceName << ") *" << serviceName << "Processor {" << '\n' << '\n'; indent_up(); @@ -3905,6 +3929,7 @@ void t_go_generator::generate_go_docstring(ostream& out, ss << '\n'; } } + ss << '\n'; } if (has_doc) { @@ -4286,6 +4311,32 @@ void t_go_generator::parse_go_tags(map* tags, const string in) { } } +void t_go_generator::generate_deprecation_comment(ostream& out, const map>& annotations) { + auto iter = annotations.find("deprecated"); + if (annotations.end() != iter) { + out << indent() << "// Deprecated: "; + + bool first = true; + for (auto str_iter = iter->second.begin(); str_iter != iter->second.end(); ++str_iter) { + if (*str_iter == "1") { + // Empty annotations will generate "1", skip those. + continue; + } + if (first) { + first = false; + } else { + out << "; "; + } + out << *str_iter; + } + if (first) { + // All deprecation annotations are empty, put a generic reason here + out << "(no reason given)"; + } + out << '\n'; + } +} + bool format_go_output(const string& file_path) { // formatting via gofmt deactivated due to THRIFT-3893 diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.h b/compiler/cpp/src/thrift/generate/t_go_generator.h index 1efa32daa33..d84b18686f1 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.h +++ b/compiler/cpp/src/thrift/generate/t_go_generator.h @@ -266,6 +266,8 @@ class t_go_generator : public t_generator { std::string type_to_go_key_type(t_type* ttype); std::string type_to_spec_args(t_type* ttype); + void generate_deprecation_comment(std::ostream& os, const std::map>& annotations); + void indent_up() { t_generator::indent_up(); } void indent_down() { t_generator::indent_down(); } std::string indent() { return t_generator::indent(); } From feb6a3d155acb921e65901d0c08a6a3632354f5f Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Tue, 4 Jun 2024 22:21:39 +0200 Subject: [PATCH 240/250] fix: TProtocol::skip fix parameter type Client: php Patch: Ilya Urvachev & Volodymyr Panivko This closes #2983 --- lib/php/lib/Protocol/TProtocol.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/php/lib/Protocol/TProtocol.php b/lib/php/lib/Protocol/TProtocol.php index f7b581f7bef..0de2cf5d42a 100644 --- a/lib/php/lib/Protocol/TProtocol.php +++ b/lib/php/lib/Protocol/TProtocol.php @@ -181,7 +181,7 @@ abstract public function readString(&$str); * The skip function is a utility to parse over unrecognized date without * causing corruption. * - * @param TType $type What type is it + * @param int $type What type is it (defined in TType::class) */ public function skip($type) { From cd223d40a88d56a8237cc1fee317551d90efe846 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jun 2024 06:57:34 +0000 Subject: [PATCH 241/250] Bump org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 in /lib/kotlin Bumps [org.jetbrains.kotlinx:kotlinx-coroutines-jdk8](https://github.com/Kotlin/kotlinx.coroutines) from 1.8.0 to 1.8.1. - [Release notes](https://github.com/Kotlin/kotlinx.coroutines/releases) - [Changelog](https://github.com/Kotlin/kotlinx.coroutines/blob/master/CHANGES.md) - [Commits](https://github.com/Kotlin/kotlinx.coroutines/compare/1.8.0...1.8.1) --- updated-dependencies: - dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-jdk8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- lib/kotlin/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kotlin/build.gradle.kts b/lib/kotlin/build.gradle.kts index 94d39b9bdf0..6b1c7c98618 100644 --- a/lib/kotlin/build.gradle.kts +++ b/lib/kotlin/build.gradle.kts @@ -29,7 +29,7 @@ repositories { dependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom")) implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.8.1") implementation("org.apache.thrift:libthrift:INCLUDED") testImplementation(kotlin("test")) } From 3f7e27b2060f92297d71dc3fe0abcc1261dda989 Mon Sep 17 00:00:00 2001 From: Alkis Evlogimenos Date: Mon, 27 May 2024 16:16:02 +0000 Subject: [PATCH 242/250] Update compact-protocol docs This updates the compact protocol documentation to simplify the explanation of Zigzag and ULEB128 encoding, along with links to wikipedia. In addition it uses varing instead of var int since the former is more common. --- doc/specs/thrift-compact-protocol.md | 72 +++++++++++++--------------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/doc/specs/thrift-compact-protocol.md b/doc/specs/thrift-compact-protocol.md index a31a2d329c0..95145b769fe 100644 --- a/doc/specs/thrift-compact-protocol.md +++ b/doc/specs/thrift-compact-protocol.md @@ -48,43 +48,38 @@ For background on Thrift see the [Thrift whitepaper (pdf)](https://thrift.apache ### Integer encoding -The _compact protocol_ uses multiple encodings for ints: the _zigzag int_, and the _var int_. +The _compact protocol_ uses [ZigZag](https://en.wikipedia.org/wiki/Variable-length_quantity#Zigzag_encoding)'ed +varint (aka [ULEB128](https://en.wikipedia.org/wiki/LEB128)) encoding. -Values of type `int32` and `int64` are first transformed to a *zigzag int*. A zigzag int folds positive and negative -numbers into the positive number space. When we read 0, 1, 2, 3, 4 or 5 from the wire, this is translated to 0, -1, 1, --2 or 2 respectively. Here are the (Scala) formulas to convert from int32/int64 to a zigzag int and back: +Values of type `int8` are encoded as one byte, rest are converted to `int64`, Zigzag'ed then encoded as varint. +Zigzag encoding maps signed integers to another domain, one where the sign bit is encoded in the least significant +bit (LSB). For example 0 maps to 0, -1 to 1, 1 to 2, -2 to 3, etc. Hence the term zigzag. Mapping the sign bit to +the LSB is important for compactness when the absolute value of the value is small, as ULEB encoding is more +efficient for small values. Here are the (Scala) formulas to convert from `int64` to a zigzag `int64` and back: ```scala -def intToZigZag(n: Int): Int = (n << 1) ^ (n >> 31) -def zigzagToInt(n: Int): Int = (n >>> 1) ^ - (n & 1) -def longToZigZag(n: Long): Long = (n << 1) ^ (n >> 63) -def zigzagToLong(n: Long): Long = (n >>> 1) ^ - (n & 1) +def ToZigzag(n: Long): Long = (n << 1) ^ (n >> 63) +def FromZigzag(n: Long): Long = (n >>> 1) ^ - (n & 1) ``` -The zigzag int is then encoded as a *var int*, also known as *Unsigned LEB128*. Var ints take 1 to 5 bytes (int32) or -1 to 10 bytes (int64). The process consists in taking a Big Endian unsigned integer, left-padding the bit-string to -make it a multiple of 7 bits, splitting it into 7-bit groups, prefixing the most-significant 7-bit group with the 0 -bit, prefixing the remaining 7-bit groups with the 1 bit and encoding the resulting bit-string in Little Endian. +A ULEB128 is encoded 7-bits at a time, starting from the LSB. Each 7-bits are encoded as 8-bits with the top bit set +if this is not the last byte, unset otherwise. For example, the integer 50399 is encoded as follows: ``` -50399 = 1100 0100 1101 1111 (Big Endian representation) - = 00000 1100 0100 1101 1111 (Left-padding) - = 0000011 0001001 1011111 (7-bit groups) - = 00000011 10001001 11011111 (Most-significant bit prefixes) - = 11011111 10001001 00000011 (Little Endian representation) - = 0xDF 0x89 0x03 +50399 = 11000100 11011111 (LSB) + = 0000011 0001001 1011111 (7-bit groups) + = 00000011 10001001 11011111 (add continuation bits) + = 0x03 0x89 0xDF (hex) +→ 0xDF 0x89 0x03 (write to ram LSB first) ``` -Var ints are sometimes used directly inside the compact protocol to represent positive numbers. - -To encode an `int16` as zigzag int, it is first converted to an `int32` and then encoded as such. The type `int8` simply -uses a single byte as in the binary protocol. +Varints are sometimes used directly inside the compact protocol to represent positive numbers. ### Enum encoding -The generated code encodes `Enum`s by taking the ordinal value and then encoding that as an int32. +The generated code encodes `Enum`s by taking the ordinal value and then encoding that as an `int32`. ### Binary encoding @@ -99,36 +94,33 @@ Binary protocol, binary data, 1+ bytes: Where: -* `byte length` is the length of the byte array, using var int encoding (must be >= 0). +* `byte length` is the length of the byte array, using varint encoding (must be >= 0). * `bytes` are the bytes of the byte array. ### String encoding -*String*s are first encoded to UTF-8, and then send as binary. They do not -include a NUL delimiter. +*String*s are first encoded to UTF-8, and then send as binary. They do not include a NUL delimiter. ### Double encoding -Values of type `double` are first converted to an int64 according to the IEEE 754 floating-point "double format" bit -layout. Most run-times provide a library to make this conversion. But while the binary protocol encodes the int64 -in 8 bytes in big endian order, the compact protocol encodes it in little endian order - this is due to an early -implementation bug that finally became the de-facto standard. +Values of type `double` are first converted to an `int64` according to the IEEE 754 floating-point "double format" +bit layout. Most run-times provide a library to make this conversion. But while the binary protocol encodes the +`int64` in 8 bytes in big endian order, the compact protocol encodes it in little endian order - this is due to an +early implementation bug that finally became the de-facto standard. ### Boolean encoding Booleans are encoded differently depending on whether it is a field value (in a struct) or an element value (in a set, -list or map). Field values are encoded directly in the field header. Element values of type `bool` are sent as an int8; -true as `1` and false as `0`. +list or map). Field values are encoded directly in the field header. Element values of type `bool` are sent as an +`int8`; true as `1` and false as `0`. ### Universal unique identifier encoding -Values of `uuid` type are expected as 16-byte binary in big endian (or "network") order. Byte order conversion -might be necessary on certain platforms, e.g. Windows holds GUIDs in a complex record-like structure whose -memory layout differs. +Values of `uuid` type are expected as 16-byte binary in big endian order. Byte order conversion might be necessary on +certain platforms, e.g. Windows holds GUIDs in a complex record-like structure whose memory layout differs. *Note*: Since the length is fixed, no `byte length` prefix is necessary and the field is always 16 bytes long. - ## Message A `Message` on the wire looks as follows: @@ -145,8 +137,8 @@ Where: * `pppppppp` is the protocol id, fixed to `1000 0010`, 0x82. * `mmm` is the message type, an unsigned 3 bit integer. * `vvvvv` is the version, an unsigned 5 bit integer, fixed to `00001`. -* `seq id` is the sequence id, a signed 32 bit integer encoded as a var int. -* `name length` is the byte length of the name field, a signed 32 bit integer encoded as a var int (must be >= 0). +* `seq id` is the sequence id, a signed 32 bit integer encoded as a varint. +* `name length` is the byte length of the name field, a signed 32 bit integer encoded as a varint (must be >= 0). * `name` is the method name to invoke, a UTF-8 encoded string. Message types are encoded with the following values: @@ -204,7 +196,7 @@ Where: * `dddd` is the field id delta, an unsigned 4 bits integer, strictly positive. * `tttt` is field-type id, an unsigned 4 bit integer. -* `field id` the field id, a signed 16 bit integer encoded as zigzag int. +* `field id` the field id, a varint (int16). Max field id is 32767. * `field-value` the encoded field value. The field id delta can be computed by `current-field-id - previous-field-id`, or just `current-field-id` if this is the @@ -250,7 +242,7 @@ Where: * `ssss` is the size, 4 bit unsigned int, values `0` - `14` * `tttt` is the element-type, a 4 bit unsigned int -* `size` is the size, a var int (int32), positive values `15` or higher +* `size` is the size, a varint (int32), positive values `15` or higher * `elements` are the encoded elements The short form should be used when the length is in the range 0 - 14 (inclusive). From fcd693b162766f95874e63bd2d09563471c68524 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Tue, 11 Jun 2024 22:15:17 +0200 Subject: [PATCH 243/250] FIX: features documentation --- LANGUAGES.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LANGUAGES.md b/LANGUAGES.md index 4952ade158b..b0aaa7c14eb 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -164,7 +164,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr 0.7.0 Yes 1.211.22 - +Yes YesYesYes YesYesYesYes YesYesYesYes @@ -176,7 +176,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr 0.9.3 Yes 4.1.54.2.5 - +Yes YesYes YesYes YesYesYesYes @@ -344,7 +344,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr 0.12.0 Yes 5.7 - +Yes YesYesYesYes YesYes YesYesYes From 6372ef8a105f84faf0a1a17f5109b36939f7c547 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 13 Jun 2024 10:13:25 -0700 Subject: [PATCH 244/250] go: Fix indentation in compiler This fixes a small case I missed in 4930caca. Before: func NewFoo() *Foo { return &Foo{ DefDef: 10, DefOpt: 11, } } After: func NewFoo() *Foo { return &Foo{ DefDef: 10, DefOpt: 11, } } --- compiler/cpp/src/thrift/generate/t_go_generator.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index 65574dd0a40..a42c71ad5e6 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -1209,19 +1209,25 @@ void t_go_generator::generate_go_struct_initializer(ostream& out, t_struct* tstruct, bool is_args_or_result) { out << publicize(type_name(tstruct), is_args_or_result) << "{"; + indent_up(); const vector& members = tstruct->get_members(); + bool empty = true; for (auto member : members) { bool pointer_field = is_pointer_field(member); string publicized_name; t_const_value* def_value; get_publicized_name_and_def_value(member, &publicized_name, &def_value); if (!pointer_field && def_value != nullptr && !omit_initialization(member)) { + empty = false; out << '\n' << indent() << publicized_name << ": " - << render_field_initial_value(member, member->get_name(), pointer_field) << "," - << '\n'; + << render_field_initial_value(member, member->get_name(), pointer_field) << ","; } } + indent_down(); + if (!empty) { + out << '\n' << indent(); + } out << "}" << '\n'; } From f4a243fd5dc872dc61438bb3160d9eec2d6b1390 Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Mon, 10 Jun 2024 11:39:23 -0700 Subject: [PATCH 245/250] go: Improve efficiency with zlib in THeaderTransport When enabled zlib in THeaderTransport we observed very high cpu overhead, use a pool for zlib writers to improve efficiency. --- lib/go/thrift/header_transport.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/go/thrift/header_transport.go b/lib/go/thrift/header_transport.go index d81fb29d31f..8148796c7e7 100644 --- a/lib/go/thrift/header_transport.go +++ b/lib/go/thrift/header_transport.go @@ -211,6 +211,25 @@ func (tw *TransformWriter) Close() error { return nil } +var zlibDefaultLevelWriterPool = newPool( + func() *zlib.Writer { + return zlib.NewWriter(nil) + }, + nil, +) + +type zlibPoolCloser struct { + writer *zlib.Writer +} + +func (z *zlibPoolCloser) Close() error { + defer func() { + z.writer.Reset(nil) + zlibDefaultLevelWriterPool.put(&z.writer) + }() + return z.writer.Close() +} + // AddTransform adds a transform. func (tw *TransformWriter) AddTransform(id THeaderTransformID) error { switch id { @@ -222,9 +241,12 @@ func (tw *TransformWriter) AddTransform(id THeaderTransformID) error { case TransformNone: // no-op case TransformZlib: - writeCloser := zlib.NewWriter(tw.Writer) + writeCloser := zlibDefaultLevelWriterPool.get() + writeCloser.Reset(tw.Writer) tw.Writer = writeCloser - tw.closers = append(tw.closers, writeCloser) + tw.closers = append(tw.closers, &zlibPoolCloser{ + writer: writeCloser, + }) } return nil } From 6fb8fa808a4b0b4391cca13716f904032cc3fd74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 16 Jun 2024 09:53:07 +0000 Subject: [PATCH 246/250] Bump braces from 3.0.2 to 3.0.3 in /lib/js Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3. - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3) --- updated-dependencies: - dependency-name: braces dependency-type: indirect ... Signed-off-by: dependabot[bot] --- lib/js/package-lock.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/js/package-lock.json b/lib/js/package-lock.json index 88026612efb..4b283fc3acb 100644 --- a/lib/js/package-lock.json +++ b/lib/js/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "thrift", - "version": "0.20.0", + "version": "0.21.0", "license": "Apache-2.0", "devDependencies": { "browserify": "~16.5", @@ -235,12 +235,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -1225,9 +1225,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" From cb54ba2d066d73a56c5aa7d51ab7f28b0b95703f Mon Sep 17 00:00:00 2001 From: CJCombrink Date: Sat, 27 Apr 2024 19:51:39 +0200 Subject: [PATCH 247/250] THRIFT-5773 Strong UUID wrapper for C++ Client: cpp/CMakeLists.txt Patch: Carel Combrink This closes #2958 --- LANGUAGES.md | 2 +- .../src/thrift/generate/t_cpp_generator.cc | 7 +- lib/c_glib/test/CMakeLists.txt | 2 +- lib/c_glib/test/Makefile.am | 2 +- lib/c_glib/test/testthrifttestclient.cpp | 5 + lib/c_glib/test/testthrifttestzlibclient.cpp | 8 +- lib/cpp/CMakeLists.txt | 2 +- lib/cpp/Makefile.am | 3 +- lib/cpp/README.md | 26 +++ lib/cpp/libthrift.vcxproj | 3 +- lib/cpp/libthrift.vcxproj.filters | 5 +- .../{protocol/TUuidUtils.cpp => TUuid.cpp} | 43 ++-- lib/cpp/src/thrift/TUuid.h | 171 ++++++++++++++++ lib/cpp/src/thrift/protocol/TBinaryProtocol.h | 4 +- .../src/thrift/protocol/TBinaryProtocol.tcc | 18 +- .../src/thrift/protocol/TDebugProtocol.cpp | 14 +- lib/cpp/src/thrift/protocol/TDebugProtocol.h | 2 +- lib/cpp/src/thrift/protocol/TJSONProtocol.cpp | 18 +- lib/cpp/src/thrift/protocol/TJSONProtocol.h | 4 +- lib/cpp/src/thrift/protocol/TProtocol.h | 13 +- .../src/thrift/protocol/TProtocolDecorator.h | 4 +- lib/cpp/src/thrift/protocol/TUuidUtils.hpp | 45 ----- .../src/thrift/protocol/TVirtualProtocol.h | 8 +- lib/cpp/test/Benchmark.cpp | 2 +- lib/cpp/test/CMakeLists.txt | 20 ++ lib/cpp/test/DebugProtoTest.cpp | 6 +- lib/cpp/test/JSONProtoTest.cpp | 4 +- lib/cpp/test/Makefile.am | 33 +++- lib/cpp/test/SpecializationTest.cpp | 2 +- lib/cpp/test/TUuidTest.cpp | 186 ++++++++++++++++++ lib/cpp/test/TUuidTestBoost.cpp | 65 ++++++ lib/cpp/test/TUuidTestBoostNoDirective.cpp | 82 ++++++++ lib/cpp/test/ToStringTest.cpp | 4 +- test/cpp/src/TestClient.cpp | 12 +- test/cpp/src/TestServer.cpp | 8 +- 35 files changed, 677 insertions(+), 156 deletions(-) rename lib/cpp/src/thrift/{protocol/TUuidUtils.cpp => TUuid.cpp} (59%) create mode 100644 lib/cpp/src/thrift/TUuid.h delete mode 100644 lib/cpp/src/thrift/protocol/TUuidUtils.hpp create mode 100644 lib/cpp/test/TUuidTest.cpp create mode 100644 lib/cpp/test/TUuidTestBoost.cpp create mode 100644 lib/cpp/test/TUuidTestBoostNoDirective.cpp diff --git a/LANGUAGES.md b/LANGUAGES.md index b0aaa7c14eb..ccb44436af0 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -80,7 +80,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr 0.2.0 YesYes C++11 - +Yes YesYesYesYesYesYes YesYesYesYes YesYesYesYes diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index dc74a92aa05..69842689296 100644 --- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc @@ -4572,8 +4572,7 @@ string t_cpp_generator::base_type_name(t_base_type::t_base tbase) { case t_base_type::TYPE_DOUBLE: return "double"; case t_base_type::TYPE_UUID: - // TODO: discuss possibility of a class TUuid; - return "std::string"; + return "apache::thrift::TUuid"; default: throw "compiler error: no C++ base type name for base type " + t_base_type::t_base_name(tbase); } @@ -4614,9 +4613,7 @@ string t_cpp_generator::declare_field(t_field* tfield, switch (tbase) { case t_base_type::TYPE_VOID: case t_base_type::TYPE_STRING: - break; case t_base_type::TYPE_UUID: - result += " = std::string(\"00000000-0000-0000-0000-000000000000\")"; break; case t_base_type::TYPE_BOOL: result += " = false"; @@ -4784,10 +4781,10 @@ bool t_cpp_generator::is_struct_storage_not_throwing(t_struct* tstruct) const { case t_base_type::TYPE_I32: case t_base_type::TYPE_I64: case t_base_type::TYPE_DOUBLE: + case t_base_type::TYPE_UUID: continue; case t_base_type::TYPE_VOID: case t_base_type::TYPE_STRING: - case t_base_type::TYPE_UUID: default: return false; } diff --git a/lib/c_glib/test/CMakeLists.txt b/lib/c_glib/test/CMakeLists.txt index 4d3092fb8a1..4f60473b25c 100644 --- a/lib/c_glib/test/CMakeLists.txt +++ b/lib/c_glib/test/CMakeLists.txt @@ -231,7 +231,7 @@ add_custom_command(OUTPUT gen-cpp/ThriftTest.h gen-cpp/ThriftTest_constants.h gen-cpp/ThriftTest_types.h - COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/v0.16/ThriftTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift ) # TODO: Add memory checks using ctest_memcheck or similar diff --git a/lib/c_glib/test/Makefile.am b/lib/c_glib/test/Makefile.am index c7c67ab4c73..0a5f220ac91 100644 --- a/lib/c_glib/test/Makefile.am +++ b/lib/c_glib/test/Makefile.am @@ -335,7 +335,7 @@ gen-c_glib/t_test_optional_required_test_types.c gen-c_glib/t_test_optional_requ gen-c_glib/t_test_second_service.c gen-c_glib/t_test_thrift_test.c gen-c_glib/t_test_thrift_test_types.c gen-c_glib/t_test_second_service.h gen-c_glib/t_test_thrift_test.h gen-c_glib/t_test_thrift_test_types.h: ../../../test/v0.16/ThriftTest.thrift $(THRIFT) $(THRIFT) --gen c_glib $< -gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest_types.cpp: ../../../test/v0.16/ThriftTest.thrift $(THRIFT) +gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest_types.cpp: ../../../test/ThriftTest.thrift $(THRIFT) $(THRIFT) --gen cpp $< TESTS = \ diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp index 5e0c89471d4..77cd24a8f22 100644 --- a/lib/c_glib/test/testthrifttestclient.cpp +++ b/lib/c_glib/test/testthrifttestclient.cpp @@ -112,6 +112,11 @@ class TestHandler : public ThriftTestIf { out = thing; } + std::string testUuid(const std::string thing) override { + cout << "[C -> C++] testUuid(\"" << std::hex << thing << "\")" << '\n'; + return thing; + } + void testStruct(Xtruct& out, const Xtruct &thing) override { cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << '\n'; out = thing; diff --git a/lib/c_glib/test/testthrifttestzlibclient.cpp b/lib/c_glib/test/testthrifttestzlibclient.cpp index 307fd4f5f01..7c0f24a5ed0 100644 --- a/lib/c_glib/test/testthrifttestzlibclient.cpp +++ b/lib/c_glib/test/testthrifttestzlibclient.cpp @@ -107,6 +107,11 @@ class TestHandler : public ThriftTestIf { out = thing; } + std::string testUuid(const std::string thing) override { + cout << "[C -> C++] testUuid(\"" << std::hex << thing << "\")" << '\n'; + return thing; + } + void testStruct(Xtruct& out, const Xtruct &thing) override { cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << '\n'; out = thing; @@ -190,7 +195,8 @@ class TestHandler : public ThriftTestIf { UserId testTypedef(const UserId thing) override { cout << "[C -> C++] testTypedef(" << thing << ")" << '\n'; - return thing; } + return thing; + } void testMapMap(map > &mapmap, const int32_t hello) override { cout << "[C -> C++] testMapMap(" << hello << ")" << '\n'; diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index c2f15dd5728..5980734f380 100644 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -31,6 +31,7 @@ endif() set(thriftcpp_SOURCES src/thrift/TApplicationException.cpp src/thrift/TOutput.cpp + src/thrift/TUuid.cpp src/thrift/async/TAsyncChannel.cpp src/thrift/async/TAsyncProtocolProcessor.cpp src/thrift/async/TConcurrentClientSyncInfo.h @@ -43,7 +44,6 @@ set(thriftcpp_SOURCES src/thrift/protocol/TJSONProtocol.cpp src/thrift/protocol/TMultiplexedProtocol.cpp src/thrift/protocol/TProtocol.cpp - src/thrift/protocol/TUuidUtils.cpp src/thrift/transport/TTransportException.cpp src/thrift/transport/TFDTransport.cpp src/thrift/transport/TSimpleFileTransport.cpp diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am index 12b8d82498d..3d7beab68ae 100644 --- a/lib/cpp/Makefile.am +++ b/lib/cpp/Makefile.am @@ -57,6 +57,7 @@ AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(OPENSSL_INCLUDES) -I$(srcdir)/src -D__STDC_FOR libthrift_la_SOURCES = src/thrift/TApplicationException.cpp \ src/thrift/TOutput.cpp \ + src/thrift/TUuid.cpp \ src/thrift/VirtualProfiling.cpp \ src/thrift/async/TAsyncChannel.cpp \ src/thrift/async/TAsyncProtocolProcessor.cpp \ @@ -69,7 +70,6 @@ libthrift_la_SOURCES = src/thrift/TApplicationException.cpp \ src/thrift/protocol/TBase64Utils.cpp \ src/thrift/protocol/TMultiplexedProtocol.cpp \ src/thrift/protocol/TProtocol.cpp \ - src/thrift/protocol/TUuidUtils.cpp \ src/thrift/transport/TTransportException.cpp \ src/thrift/transport/TFDTransport.cpp \ src/thrift/transport/TFileTransport.cpp \ @@ -137,6 +137,7 @@ include_thrift_HEADERS = \ src/thrift/thrift-config.h \ src/thrift/thrift_export.h \ src/thrift/TDispatchProcessor.h \ + src/thrift/TUuid.h \ src/thrift/Thrift.h \ src/thrift/TOutput.h \ src/thrift/TProcessor.h \ diff --git a/lib/cpp/README.md b/lib/cpp/README.md index 8074484f197..74983aeb1ff 100644 --- a/lib/cpp/README.md +++ b/lib/cpp/README.md @@ -232,6 +232,32 @@ OpenSSL's RAND_poll() when OpenSSL library is first initialized. The PRNG seed is key to the application security. This method should be overridden if it's not strong enough for you. +# Thrift UUID + +The `uuid` `BaseType` is implemented in C++ by the `apache::thrift::TUuid` class. This class +is a strong wrapper class around an internal buffer of 16 bytes. + +The `apache::thrift::TUuid` supports construction from different UUID string representations. +Some examples of supported string formats are: + +* `"hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh"` +* `"{hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh}"` +* `"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"` +* `"{hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh}"` + +## `TUuid` and `boost::uuids::uuid` + +Internally the TUuid class is implemented using the `boost::uuids::uuid` library. As a result the TUuid +can seamlessly interoperate with the boost UUID type since the underlying data structure is the same. + +For convenience, when boost is already used by a project the `THRIFT_TUUID_SUPPORT_BOOST_UUID` preprocessor +directive can be set when including the thrift library to enable construction of a `TUuid` from a +`boost::uuids::uuid`. By default this is an implicit constructor that can be changed to be explicit +by defining the `THRIFT_TUUID_BOOST_CONSTRUCTOR_EXPLICIT` preprocessor directive. + +The thrift library does not need to be compiled differently when this constructor is needed. The preprocessor +directives can be set on the project that uses the thrift library. + # Deprecations ## 0.12.0 diff --git a/lib/cpp/libthrift.vcxproj b/lib/cpp/libthrift.vcxproj index 1b413f8ae8e..7fcccfe99ee 100644 --- a/lib/cpp/libthrift.vcxproj +++ b/lib/cpp/libthrift.vcxproj @@ -49,7 +49,6 @@ - @@ -58,6 +57,7 @@ + @@ -97,6 +97,7 @@ + diff --git a/lib/cpp/libthrift.vcxproj.filters b/lib/cpp/libthrift.vcxproj.filters index fb94f608730..4b2ba3b2782 100644 --- a/lib/cpp/libthrift.vcxproj.filters +++ b/lib/cpp/libthrift.vcxproj.filters @@ -4,6 +4,7 @@ transport + @@ -30,9 +31,6 @@ protocol - - protocol - transport @@ -109,6 +107,7 @@ protocol + diff --git a/lib/cpp/src/thrift/protocol/TUuidUtils.cpp b/lib/cpp/src/thrift/TUuid.cpp similarity index 59% rename from lib/cpp/src/thrift/protocol/TUuidUtils.cpp rename to lib/cpp/src/thrift/TUuid.cpp index e1eab22cb11..a0c45f9de6f 100644 --- a/lib/cpp/src/thrift/protocol/TUuidUtils.cpp +++ b/lib/cpp/src/thrift/TUuid.cpp @@ -17,7 +17,7 @@ * under the License. */ -#include +#include #include #include @@ -25,32 +25,37 @@ namespace apache { namespace thrift { -namespace protocol { - -bool uuid_encode(const std::string& in, std::string& out) { - static const boost::uuids::string_generator gen; - static const std::string empty_uuid(boost::uuids::uuid::static_size(), '\0'); - out = empty_uuid; - if (in.empty()) { - return true; + +namespace { +static const boost::uuids::string_generator gen; +} + +TUuid::TUuid(const std::string& str) noexcept { + std::fill(this->begin(), this->end(), 0); + if (str.empty()) { + return ; } + try { - const boost::uuids::uuid uuid{gen(in)}; - std::copy(uuid.begin(), uuid.end(), out.begin()); - return true; + const boost::uuids::uuid uuid{gen(str)}; + std::copy(uuid.begin(), uuid.end(), this->begin()); } catch (const std::runtime_error&) { // Invalid string most probably - return false; } } -void uuid_decode(const std::string& in, std::string& out) { - boost::uuids::uuid uuid{}; - const size_t to_copy = std::min(in.size(), uuid.size()); - std::copy(in.begin(), in.begin() + to_copy, uuid.begin()); - out = boost::uuids::to_string(uuid); +bool TUuid::is_nil() const noexcept { + boost::uuids::uuid uuid_tmp{}; + std::copy(this->begin(), this->end(), std::begin(uuid_tmp)); + return uuid_tmp.is_nil(); } +std::string to_string(const TUuid& in) { + boost::uuids::uuid uuid_tmp{}; + std::copy(std::begin(in), std::end(in), std::begin(uuid_tmp)); + return boost::uuids::to_string(uuid_tmp); } + + } -} // apache::thrift::protocol +} // apache::thrift \ No newline at end of file diff --git a/lib/cpp/src/thrift/TUuid.h b/lib/cpp/src/thrift/TUuid.h new file mode 100644 index 00000000000..bcf0160bcdb --- /dev/null +++ b/lib/cpp/src/thrift/TUuid.h @@ -0,0 +1,171 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _THRIFT_TUUID_H_ +#define _THRIFT_TUUID_H_ 1 + +#include + +#ifdef THRIFT_TUUID_SUPPORT_BOOST_UUID +#include +#endif // THRIFT_TUUID_SUPPORT_BOOST_UUID + +#include + +namespace apache { +namespace thrift { + +/** + * Thrift wrapper class for a UUID type. + * + * The UUID is stored as a 16 byte buffer. + * This class stores the UUID in network order when assigned from a string. + */ +class TUuid { +public: + typedef uint8_t value_type; + typedef uint8_t* iterator; + typedef uint8_t const* const_iterator; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + TUuid() = default; + TUuid(const TUuid& other) = default; + TUuid(TUuid&& other) = default; + TUuid& operator=(const TUuid&) = default; + TUuid& operator=(TUuid&&) = default; + ~TUuid() = default; + + /** + * Construct the object from a 16 byte buffer. + */ + explicit TUuid(const uint8_t (&data)[16]) noexcept + { + std::copy(std::begin(data), std::end(data), std::begin(this->data_)); + } + + /** + * Construct the object from the specified string. + * + * Supported string formats are: + * - "hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh" + * - "{hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh}" + * - "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh" + * - "{hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh}" + * + * If the string is invalid, the object will be set to a + * nil (empty) UUID. + */ + explicit TUuid(const std::string& str) noexcept; + +#ifdef THRIFT_TUUID_SUPPORT_BOOST_UUID + /** + * Construct the TUuid from a boost::uuids::uuid. + * + * This constructor will only be available if the THRIFT_TUUID_SUPPORT_BOOST_UUID + * compiler directive is set when this file is included. + * + * This constructor is by default implicit. It can be made explicit by defining the + * THRIFT_TUUID_BOOST_CONSTRUCTOR_EXPLICIT compiler directive. + */ + #ifdef THRIFT_TUUID_BOOST_CONSTRUCTOR_EXPLICIT + explicit + #endif // THRIFT_TUUID_BOOST_CONSTRUCTOR_EXPLICIT + TUuid(const boost::uuids::uuid& buuid) noexcept + { + std::copy(std::begin(buuid.data), std::end(buuid.data), std::begin(this->data_)); + } +#endif // THRIFT_TUUID_SUPPORT_BOOST_UUID + + /** + * Check if the UUID is nil. + */ + bool is_nil() const noexcept; + + /** + * Compare two TUuid objects for equality. + */ + inline bool operator==(const TUuid& other) const; + + /** + * Compare two TUuid objects for inequality. + */ + inline bool operator!=(const TUuid& other) const; + + iterator begin() noexcept { return data_; } + const_iterator begin() const noexcept { return data_; } + iterator end() noexcept { return data_ + size(); } + const_iterator end() const noexcept { return data_ + size(); } + size_type size() const noexcept { return 16; } + inline const_iterator data() const { return data_; } + inline iterator data() { return data_; } + + void swap(TUuid& other) noexcept { std::swap(data_, other.data_); } + +private: + /** + * The UUID data. + */ + uint8_t data_[16] = {}; +}; + +/** + * Get the String representation of a TUUID. + * + * The format returned is: + * - "hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh" + */ +std::string to_string(const TUuid& uuid) noexcept(false); + +/** + * Swap two TUuid objects + */ +inline void swap(TUuid& lhs, TUuid& rhs) noexcept { + lhs.swap(rhs); +} + +/** + * TUuid equality comparison operator implementation + */ +inline bool TUuid::operator==(const TUuid& other) const { + // Compare using temporary strings. + // Can't use strcmp() since we expect embeded zeros + // Perhaps the reason we should use std::array instead + return std::string(this->begin(), this->end()) == std::string(other.begin(), other.end()); +} + +/** + * TUuid inequality comparison operator implementation + */ +inline bool TUuid::operator!=(const TUuid& other) const { + return !(*this == other); +} + +/** + * TUuid ostream stream operator implementation + */ +inline std::ostream& operator<<(std::ostream& out, const TUuid& obj) { + out << to_string(obj); + return out; +} + +} // namespace thrift +} // namespace apache + +#endif // #ifndef _THRIFT_TUUID_H_ diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h index 24e51f75f4d..cba6e69485d 100644 --- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h +++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h @@ -119,7 +119,7 @@ class TBinaryProtocolT : public TVirtualProtocol -#include #include #include @@ -195,16 +194,9 @@ uint32_t TBinaryProtocolT::writeBinary(const std::string } template -uint32_t TBinaryProtocolT::writeUUID(const std::string& str) { - std::string out; - const bool encoded = uuid_encode(str, out); - if(!encoded) - throw TProtocolException(TProtocolException::INVALID_DATA); - // This should not happen, but check for now - if(out.size() != 16) - throw TProtocolException(TProtocolException::UNKNOWN); +uint32_t TBinaryProtocolT::writeUUID(const TUuid& uuid) { // TODO: Consider endian swapping, see lib/delphi/src/Thrift.Utils.pas:377 - this->trans_->write((uint8_t*)out.data(), 16); + this->trans_->write(uuid.data(), uuid.size()); return 16; } @@ -444,10 +436,8 @@ uint32_t TBinaryProtocolT::readBinary(std::string& str) } template -uint32_t TBinaryProtocolT::readUUID(std::string& str) { - std::string in; - readStringBody(in, 16); - uuid_decode(in, str); +uint32_t TBinaryProtocolT::readUUID(TUuid& uuid) { + this->trans_->readAll(uuid.begin(), uuid.size()); return 16; } diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp b/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp index 0a2eaeda035..6e88313db64 100644 --- a/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp +++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp @@ -18,7 +18,6 @@ */ #include -#include #include #include @@ -388,19 +387,12 @@ uint32_t TDebugProtocol::writeBinary(const string& str) { return TDebugProtocol::writeString(str); } -uint32_t TDebugProtocol::writeUUID(const string& str) { - std::string out_raw; - uuid_encode(str, out_raw); - - std::string out_encoded; - uuid_decode(out_raw, out_encoded); - +uint32_t TDebugProtocol::writeUUID(const TUuid& uuid) { size_t size = writePlain("{\n"); indentUp(); - size += writeIndented("[in ] = \"" + str + "\",\n"); size += writeIndented("[raw] = "); - size += writeString(out_raw); - size += writeIndented("[enc] = \"" + out_encoded + "\"\n"); + size += writeString(std::string(std::begin(uuid), std::end(uuid))); + size += writeIndented("[enc] = \"" + to_string(uuid) + "\"\n"); indentDown(); size += writeIndented("}\n"); return size; diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.h b/lib/cpp/src/thrift/protocol/TDebugProtocol.h index af89cc5679d..02662f1ab15 100644 --- a/lib/cpp/src/thrift/protocol/TDebugProtocol.h +++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.h @@ -110,7 +110,7 @@ class TDebugProtocol : public TVirtualProtocol { uint32_t writeBinary(const std::string& str); - uint32_t writeUUID(const std::string& str); + uint32_t writeUUID(const TUuid& uuid); private: void indentUp(); diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp index 0899f00eefa..3805869a936 100644 --- a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp +++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp @@ -18,7 +18,6 @@ */ #include -#include #include @@ -717,14 +716,8 @@ uint32_t TJSONProtocol::writeBinary(const std::string& str) { return writeJSONBase64(str); } -uint32_t TJSONProtocol::writeUUID(const std::string& str) { - std::string out_raw; - uuid_encode(str, out_raw); - - std::string out_encoded; - uuid_decode(out_raw, out_encoded); - - return writeJSONString(out_encoded); +uint32_t TJSONProtocol::writeUUID(const TUuid& uuid) { + return writeJSONString(to_string(uuid)); } /** @@ -1123,8 +1116,11 @@ uint32_t TJSONProtocol::readBinary(std::string& str) { return readJSONBase64(str); } -uint32_t TJSONProtocol::readUUID(std::string& str) { - return readJSONString(str); +uint32_t TJSONProtocol::readUUID(TUuid& uuid) { + std::string uuid_str; + const uint32_t result = readJSONString(uuid_str); + uuid = TUuid{uuid_str}; + return result; } // Return the minimum number of bytes a type will consume on the wire diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.h b/lib/cpp/src/thrift/protocol/TJSONProtocol.h index 069a9905f53..09eb6eab1bf 100644 --- a/lib/cpp/src/thrift/protocol/TJSONProtocol.h +++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.h @@ -198,7 +198,7 @@ class TJSONProtocol : public TVirtualProtocol { uint32_t writeBinary(const std::string& str); - uint32_t writeUUID(const std::string& str); + uint32_t writeUUID(const TUuid& uuid); /** * Reading functions @@ -247,7 +247,7 @@ class TJSONProtocol : public TVirtualProtocol { uint32_t readBinary(std::string& str); - uint32_t readUUID(std::string& str); + uint32_t readUUID(TUuid& uuid); int getMinSerializedSize(TType type) override; diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h index d29df1c8d32..035b7454d0c 100644 --- a/lib/cpp/src/thrift/protocol/TProtocol.h +++ b/lib/cpp/src/thrift/protocol/TProtocol.h @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -275,7 +276,7 @@ class TProtocol { virtual uint32_t writeBinary_virt(const std::string& str) = 0; - virtual uint32_t writeUUID_virt(const std::string& str) = 0; + virtual uint32_t writeUUID_virt(const TUuid& uuid) = 0; uint32_t writeMessageBegin(const std::string& name, const TMessageType messageType, @@ -384,9 +385,9 @@ class TProtocol { return writeBinary_virt(str); } - uint32_t writeUUID(const std::string& str) { + uint32_t writeUUID(const TUuid& uuid) { T_VIRTUAL_CALL(); - return writeUUID_virt(str); + return writeUUID_virt(uuid); } /** @@ -437,7 +438,7 @@ class TProtocol { virtual uint32_t readBinary_virt(std::string& str) = 0; - virtual uint32_t readUUID_virt(std::string& str) = 0; + virtual uint32_t readUUID_virt(TUuid& uuid) = 0; uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid) { T_VIRTUAL_CALL(); @@ -539,9 +540,9 @@ class TProtocol { return readBinary_virt(str); } - uint32_t readUUID(std::string& str) { + uint32_t readUUID(TUuid& uuid) { T_VIRTUAL_CALL(); - return readUUID_virt(str); + return readUUID_virt(uuid); } /* diff --git a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h index 9eb1566ab75..88fbbdeb1c2 100644 --- a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h +++ b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h @@ -92,7 +92,7 @@ class TProtocolDecorator : public TProtocol { uint32_t writeDouble_virt(const double dub) override { return protocol->writeDouble(dub); } uint32_t writeString_virt(const std::string& str) override { return protocol->writeString(str); } uint32_t writeBinary_virt(const std::string& str) override { return protocol->writeBinary(str); } - uint32_t writeUUID_virt(const std::string& str) override { return protocol->writeUUID(str); } + uint32_t writeUUID_virt(const TUuid& uuid) override { return protocol->writeUUID(uuid); } uint32_t readMessageBegin_virt(std::string& name, TMessageType& messageType, @@ -141,7 +141,7 @@ class TProtocolDecorator : public TProtocol { uint32_t readString_virt(std::string& str) override { return protocol->readString(str); } uint32_t readBinary_virt(std::string& str) override { return protocol->readBinary(str); } - uint32_t readUUID_virt(std::string& str) override { return protocol->readUUID(str); } + uint32_t readUUID_virt(TUuid& uuid) override { return protocol->readUUID(uuid); } private: shared_ptr protocol; diff --git a/lib/cpp/src/thrift/protocol/TUuidUtils.hpp b/lib/cpp/src/thrift/protocol/TUuidUtils.hpp deleted file mode 100644 index 583147ffd38..00000000000 --- a/lib/cpp/src/thrift/protocol/TUuidUtils.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _THRIFT_PROTOCOL_TUUIDUTILS_H_ -#define _THRIFT_PROTOCOL_TUUIDUTILS_H_ - -#include - -namespace apache { -namespace thrift { -namespace protocol { - -// Encode canonical UUID string to a 16 char representation -// Supported formats for in: -// - "hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh" -// - "{hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh}" -// - "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh" -// - "{hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh}" -// Returns false if the string was invalid and the value was not encoded. -bool uuid_encode(const std::string& in, std::string& out); - -// Decode 16 char UUID buffer to 36 characted string -void uuid_decode(const std::string& in, std::string& out); - -} -} -} // apache::thrift::protocol - -#endif // #define _THRIFT_PROTOCOL_TUUIDUTILS_H_ diff --git a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h index 4698081d241..8789e473c73 100644 --- a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h +++ b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h @@ -393,8 +393,8 @@ class TVirtualProtocol : public Super_ { return static_cast(this)->writeBinary(str); } - uint32_t writeUUID_virt(const std::string& str) override { - return static_cast(this)->writeUUID(str); + uint32_t writeUUID_virt(const TUuid& uuid) override { + return static_cast(this)->writeUUID(uuid); } /** @@ -475,8 +475,8 @@ class TVirtualProtocol : public Super_ { return static_cast(this)->readBinary(str); } - uint32_t readUUID_virt(std::string& str) override { - return static_cast(this)->readUUID(str); + uint32_t readUUID_virt(TUuid& uuid) override { + return static_cast(this)->readUUID(uuid); } uint32_t skip_virt(TType type) override { return static_cast(this)->skip(type); } diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp index ba8c3452919..22ec86c54a6 100644 --- a/lib/cpp/test/Benchmark.cpp +++ b/lib/cpp/test/Benchmark.cpp @@ -65,7 +65,7 @@ int main() { ooe.some_characters = "JSON THIS! \"\1"; ooe.zomg_unicode = "\xd7\n\a\t"; ooe.base64 = "\1\2\3\255"; - ooe.rfc4122_uuid = "{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}"; + ooe.rfc4122_uuid = apache::thrift::TUuid{"{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}"}; int num = 100000; std::shared_ptr buf(new TMemoryBuffer(num*1000)); diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt index 87ed1094cb4..5ad8d74a845 100644 --- a/lib/cpp/test/CMakeLists.txt +++ b/lib/cpp/test/CMakeLists.txt @@ -82,6 +82,7 @@ set(UnitTest_SOURCES TServerSocketTest.cpp TServerTransportTest.cpp ThrifttReadCheckTests.cpp + TUuidTest.cpp ) add_executable(UnitTests ${UnitTest_SOURCES}) @@ -94,6 +95,25 @@ if(MSVC) set_property( TARGET UnitTests APPEND_STRING PROPERTY COMPILE_FLAGS /wd4503 ) endif() +# Test the THRIFT_TUUID_SUPPORT_BOOST_UUID compiler directive globally set on the target +add_executable(UnitTestsUuid + UnitTestMain.cpp + TUuidTestBoost.cpp +) +target_link_libraries(UnitTestsUuid testgencpp ${Boost_LIBRARIES}) +target_link_libraries(UnitTestsUuid thrift) +target_compile_definitions(UnitTestsUuid PUBLIC THRIFT_TUUID_SUPPORT_BOOST_UUID) +add_test(NAME UnitTestsUuid COMMAND UnitTestsUuid) + +# Test not setting the THRIFT_TUUID_SUPPORT_BOOST_UUID compiler directive as with the test above. +# The test does set the directive before including the thrift header to test the behaviour +add_executable(UnitTestsUuidNoDirective + UnitTestMain.cpp + TUuidTestBoostNoDirective.cpp +) +target_link_libraries(UnitTestsUuidNoDirective testgencpp ${Boost_LIBRARIES}) +target_link_libraries(UnitTestsUuidNoDirective thrift) +add_test(NAME UnitTestsUuidNoDirective COMMAND UnitTestsUuidNoDirective) set( TInterruptTest_SOURCES TSocketInterruptTest.cpp diff --git a/lib/cpp/test/DebugProtoTest.cpp b/lib/cpp/test/DebugProtoTest.cpp index cc4e5ff9558..44eeef768d6 100644 --- a/lib/cpp/test/DebugProtoTest.cpp +++ b/lib/cpp/test/DebugProtoTest.cpp @@ -75,7 +75,6 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_1) { " [2] = 3,\n" " },\n" " 15: rfc4122_uuid (uuid) = {\n" - " [in ] = \"\",\n" " [raw] = \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n" " [enc] = \"00000000-0000-0000-0000-000000000000\"\n" " }\n" @@ -103,7 +102,7 @@ void testCaseSetup_2() { "\xb0\xcf\x81\xe2\x84\x8e\x20\xce\x91\x74\x74" "\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80" "\xbc"; - n->my_ooe.rfc4122_uuid = "{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}"; + n->my_ooe.rfc4122_uuid = apache::thrift::TUuid{"{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}"}; n->my_bonk.type = 31337; n->my_bonk.message = "I am a bonk... xor!"; } @@ -148,7 +147,6 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_2) { " [2] = 3,\n" " },\n" " 15: rfc4122_uuid (uuid) = {\n" - " [in ] = \"{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}\",\n" " [raw] = \"^*\\xb1\\x88\\x17&Nu\\xa0O\\x1e\\xd9\\xa6\\xa8\\x9cL\",\n" " [enc] = \"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c\"\n" " }\n" @@ -240,7 +238,6 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_3) { " [2] = 3,\n" " },\n" " 15: rfc4122_uuid (uuid) = {\n" - " [in ] = \"\",\n" " [raw] = \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n" " [enc] = \"00000000-0000-0000-0000-000000000000\"\n" " }\n" @@ -276,7 +273,6 @@ BOOST_AUTO_TEST_CASE(test_debug_proto_3) { " [2] = 3,\n" " },\n" " 15: rfc4122_uuid (uuid) = {\n" - " [in ] = \"{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}\",\n" " [raw] = \"^*\\xb1\\x88\\x17&Nu\\xa0O\\x1e\\xd9\\xa6\\xa8\\x9cL\",\n" " [enc] = \"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c\"\n" " }\n" diff --git a/lib/cpp/test/JSONProtoTest.cpp b/lib/cpp/test/JSONProtoTest.cpp index fedf99e4821..b96638e7ad9 100644 --- a/lib/cpp/test/JSONProtoTest.cpp +++ b/lib/cpp/test/JSONProtoTest.cpp @@ -48,7 +48,7 @@ void testCaseSetup_1() { ooe->some_characters = "JSON THIS! \"\1"; ooe->zomg_unicode = "\xd7\n\a\t"; ooe->base64 = "\1\2\3\255"; - ooe->rfc4122_uuid = "00000000-0000-0000-0000-000000000000"; + ooe->rfc4122_uuid = apache::thrift::TUuid{"00000000-0000-0000-0000-000000000000"}; } BOOST_AUTO_TEST_CASE(test_json_proto_1) { @@ -85,7 +85,7 @@ void testCaseSetup_2() { "\xb0\xcf\x81\xe2\x84\x8e\x20\xce\x91\x74\x74" "\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80" "\xbc"; - n->my_ooe.rfc4122_uuid = "5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"; + n->my_ooe.rfc4122_uuid = apache::thrift::TUuid{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; n->my_bonk.type = 31337; n->my_bonk.message = "I am a bonk... xor!"; } diff --git a/lib/cpp/test/Makefile.am b/lib/cpp/test/Makefile.am index a7440392f85..adb923a10b7 100644 --- a/lib/cpp/test/Makefile.am +++ b/lib/cpp/test/Makefile.am @@ -83,6 +83,8 @@ Benchmark_LDADD = libtestgencpp.la check_PROGRAMS = \ UnitTests \ + UnitTestsUuid \ + UnitTestsUuidNoDirective \ TFDTransportTest \ TPipedTransportTest \ DebugProtoTest \ @@ -131,7 +133,8 @@ UnitTests_SOURCES = \ TServerSocketTest.cpp \ TServerTransportTest.cpp \ TTransportCheckThrow.h \ - ThrifttReadCheckTests.cpp + ThrifttReadCheckTests.cpp \ + TUuidTest.cpp UnitTests_LDADD = \ libtestgencpp.la \ @@ -139,6 +142,30 @@ UnitTests_LDADD = \ $(BOOST_SYSTEM_LDADD) \ $(BOOST_THREAD_LDADD) +UnitTestsUuid_SOURCES = \ + UnitTestMain.cpp \ + TUuidTestBoost.cpp + +UnitTestsUuid_LDADD = \ + libtestgencpp.la \ + $(BOOST_TEST_LDADD) \ + $(BOOST_SYSTEM_LDADD) \ + $(BOOST_THREAD_LDADD) + +UnitTestsUuid_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -DTHRIFT_TUUID_SUPPORT_BOOST_UUID + +UnitTestsUuidNoDirective_SOURCES = \ + UnitTestMain.cpp \ + TUuidTestBoostNoDirective.cpp + +UnitTestsUuidNoDirective_LDADD = \ + libtestgencpp.la \ + $(BOOST_TEST_LDADD) \ + $(BOOST_SYSTEM_LDADD) \ + $(BOOST_THREAD_LDADD) + TInterruptTest_SOURCES = \ TSocketInterruptTest.cpp \ TSSLSocketInterruptTest.cpp @@ -386,7 +413,7 @@ OpenSSLManualInitTest_LDADD = \ gen-cpp/AnnotationTest_constants.cpp gen-cpp/AnnotationTest_constants.h gen-cpp/AnnotationTest_types.cpp gen-cpp/AnnotationTest_types.h: $(top_srcdir)/test/AnnotationTest.thrift $(THRIFT) --gen cpp $< -gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h gen-cpp/EmptyService.cpp gen-cpp/EmptyService.h: $(top_srcdir)/test/v0.16/DebugProtoTest.thrift +gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h gen-cpp/EmptyService.cpp gen-cpp/EmptyService.h: $(top_srcdir)/test/DebugProtoTest.thrift $(THRIFT) --gen cpp $< gen-cpp/DoubleConstantsTest_constants.cpp gen-cpp/DoubleConstantsTest_constants.h: $(top_srcdir)/test/DoubleConstantsTest.thrift @@ -408,7 +435,7 @@ gen-cpp/Recursive_types.cpp gen-cpp/Recursive_types.h: $(top_srcdir)/test/Recurs gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp: $(top_srcdir)/test/StressTest.thrift $(THRIFT) --gen cpp $< -gen-cpp/SecondService.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_types.h: $(top_srcdir)/test/v0.16/ThriftTest.thrift +gen-cpp/SecondService.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_types.h: $(top_srcdir)/test/ThriftTest.thrift $(THRIFT) --gen cpp $< gen-cpp/OneWayService.cpp gen-cpp/OneWayTest_types.h gen-cpp/OneWayService.h: OneWayTest.thrift diff --git a/lib/cpp/test/SpecializationTest.cpp b/lib/cpp/test/SpecializationTest.cpp index 097611284a7..7256c202998 100644 --- a/lib/cpp/test/SpecializationTest.cpp +++ b/lib/cpp/test/SpecializationTest.cpp @@ -26,7 +26,7 @@ BOOST_AUTO_TEST_CASE(test_specialization_1) { ooe.some_characters = "JSON THIS! \"\1"; ooe.zomg_unicode = "\xd7\n\a\t"; ooe.base64 = "\1\2\3\255"; - ooe.rfc4122_uuid = "00000000-0000-0000-0000-000000000000"; + ooe.rfc4122_uuid = apache::thrift::TUuid{"00000000-0000-0000-0000-000000000000"}; Nesting n; n.my_ooe = ooe; diff --git a/lib/cpp/test/TUuidTest.cpp b/lib/cpp/test/TUuidTest.cpp new file mode 100644 index 00000000000..4a521cf50f9 --- /dev/null +++ b/lib/cpp/test/TUuidTest.cpp @@ -0,0 +1,186 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +#include +#include +#include +#include + +#include + +using apache::thrift::TUuid; + +BOOST_AUTO_TEST_SUITE(TUuidTest) + +BOOST_AUTO_TEST_CASE(construction) { + BOOST_TEST(TUuid().is_nil()); +} + +BOOST_AUTO_TEST_CASE(construction_string_valid) { + const std::string expected_1{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; + + BOOST_TEST(to_string(TUuid("5e2ab188-1726-4e75-a04f-1ed9a6a89c4c")) == expected_1); + BOOST_TEST(to_string(TUuid("{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}")) == expected_1); + BOOST_TEST(to_string(TUuid("{5e2ab18817264e75a04f1ed9a6a89c4c}")) == expected_1); + BOOST_TEST(to_string(TUuid("5e2ab18817264e75a04f1ed9a6a89c4c")) == expected_1); +} + +BOOST_AUTO_TEST_CASE(construction_string_invalid) { + // This test also ensures that the constructor does not throw + const std::string expected{"00000000-0000-0000-0000-000000000000"}; + + BOOST_TEST(to_string(TUuid("5e2ab188-1726-4e75-a04f")) == expected); + BOOST_TEST(to_string(TUuid("{}")) == expected); + BOOST_TEST(to_string(TUuid("{5e2ab18817264e75a04f1ed9a6a89c4c")) == expected); + BOOST_TEST(to_string(TUuid("5e2ab18817264e75a04f1ed9a689c4c")) == expected); +} + +BOOST_AUTO_TEST_CASE(compare) { + BOOST_TEST(TUuid("5e2ab188-1726-4e75-a04f-1ed9a6a89c4c") + == TUuid("5e2ab188-1726-4e75-a04f-1ed9a6a89c4c")); + BOOST_TEST(TUuid("5e2ab188-1726-4e75-a04f-1ed9a6a89c4c") + != TUuid("00000000-1726-4e75-a04f-1ed9a6a89c4c")); + BOOST_TEST(TUuid("{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}") + == TUuid("5e2ab188-1726-4e75-a04f-1ed9a6a89c4c")); + + // This comparison is expected to fail if strcmp is used + TUuid uuid_1{}; + TUuid uuid_2{}; + uuid_2.data()[15] = 0x64; + BOOST_TEST(uuid_1 != uuid_2); +} + +BOOST_AUTO_TEST_CASE(assign_valid) { + TUuid uuid_1{}; + BOOST_TEST(uuid_1.is_nil()); + uuid_1 = TUuid{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; + BOOST_TEST(!uuid_1.is_nil()); + + BOOST_TEST(uuid_1 == TUuid("5e2ab188-1726-4e75-a04f-1ed9a6a89c4c")); + + uuid_1 = TUuid{"{12345678-1726-4e75-a04f-1ed9a6a89c4c}"}; + BOOST_TEST(uuid_1 != TUuid("5e2ab188-1726-4e75-a04f-1ed9a6a89c4c")); + BOOST_TEST(uuid_1 == TUuid("{12345678-1726-4e75-a04f-1ed9a6a89c4c}")); +} + +BOOST_AUTO_TEST_CASE(assign_invalid) { + TUuid uuid_1{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; + BOOST_TEST(!uuid_1.is_nil()); + + BOOST_CHECK_NO_THROW(uuid_1 = TUuid{"123"}); + BOOST_TEST(uuid_1.is_nil()); + BOOST_TEST(to_string(uuid_1) == std::string{"00000000-0000-0000-0000-000000000000"}); +} + +BOOST_AUTO_TEST_CASE(swap) { + TUuid uuid_1{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; + TUuid uuid_2{}; + BOOST_TEST(!uuid_1.is_nil()); + BOOST_TEST(uuid_2.is_nil()); + + using std::swap; + swap(uuid_1, uuid_2); + + BOOST_TEST(uuid_1.is_nil()); + BOOST_TEST(!uuid_2.is_nil()); + + BOOST_TEST(to_string(uuid_1) == std::string{"00000000-0000-0000-0000-000000000000"}); + BOOST_TEST(to_string(uuid_2) == std::string{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}); +} + +BOOST_AUTO_TEST_CASE(begin_end) { + TUuid uuid_1{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; + BOOST_TEST(std::distance(std::begin(uuid_1), std::end(uuid_1)) == uuid_1.size()); +} + +BOOST_AUTO_TEST_CASE(into_boost_uuid) { + TUuid uuid{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; + boost::uuids::uuid boost_uuid{}; + BOOST_TEST(boost_uuid.is_nil()); + std::copy(std::begin(uuid), std::end(uuid), boost_uuid.begin()); + BOOST_TEST(!boost_uuid.is_nil()); + BOOST_TEST(boost::uuids::to_string(boost_uuid) == "5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"); + BOOST_TEST(boost::uuids::to_string(boost_uuid) == to_string(uuid)); +} + +BOOST_AUTO_TEST_CASE(from_boost_uuid) { + static boost::uuids::string_generator gen; + boost::uuids::uuid boost_uuid{gen("1f610073-db33-4d21-adf2-75460d4955cc")}; + BOOST_TEST(!boost_uuid.is_nil()); + TUuid uuid; + BOOST_TEST(uuid.is_nil()); + + std::copy(std::begin(boost_uuid), std::end(boost_uuid), uuid.begin()); + BOOST_TEST(!uuid.is_nil()); + + BOOST_TEST(to_string(boost_uuid) == to_string(uuid)); +} + +BOOST_AUTO_TEST_CASE(test_byte_order_variant) { + TUuid uuid{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; + boost::uuids::uuid boost_uuid{}; + BOOST_TEST(boost_uuid.is_nil()); + std::copy(std::begin(uuid), std::end(uuid), boost_uuid.begin()); + BOOST_TEST(!boost_uuid.is_nil()); + BOOST_TEST(boost_uuid.variant() == boost::uuids::uuid::variant_rfc_4122); +} + +BOOST_AUTO_TEST_CASE(test_byte_order_verify_network) { + const TUuid uuid{"{00112233-4455-6677-8899-aabbccddeeff}"}; + + for (uint8_t idx = 0; idx < uuid.size(); ++idx) { + const uint8_t expected = idx * 0x11; + BOOST_TEST(*(std::begin(uuid) + idx) == expected); + } + + const uint8_t test[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; + + TUuid new_uuid; + std::copy(std::begin(test), std::end(test), std::begin(new_uuid)); + + BOOST_TEST(!new_uuid.is_nil()); + BOOST_TEST(to_string(new_uuid) == std::string{"00112233-4455-6677-8899-aabbccddeeff"}); + + BOOST_TEST(new_uuid == uuid); +} + +BOOST_AUTO_TEST_CASE(test_character_buffer) { + + const uint8_t test[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; + + const TUuid uuid{test}; + + BOOST_TEST(to_string(uuid) == std::string{"00112233-4455-6677-8899-aabbccddeeff"}); +} + +BOOST_AUTO_TEST_CASE(test_boost_buffer) { + + static boost::uuids::string_generator gen; + boost::uuids::uuid boost_uuid{gen("1f610073-db33-4d21-adf2-75460d4955cc")}; + BOOST_TEST(!boost_uuid.is_nil()); + + const TUuid uuid{boost_uuid.data}; + + BOOST_TEST(to_string(boost_uuid) == to_string(uuid)); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/lib/cpp/test/TUuidTestBoost.cpp b/lib/cpp/test/TUuidTestBoost.cpp new file mode 100644 index 00000000000..81c35596e32 --- /dev/null +++ b/lib/cpp/test/TUuidTestBoost.cpp @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +#include +#include +#include +#include + +#include + +using apache::thrift::TUuid; + +BOOST_AUTO_TEST_SUITE(TUuidBoostTest) + +BOOST_AUTO_TEST_CASE(compiler_directive) { + // Test if the macro is set as expected + #ifdef THRIFT_TUUID_SUPPORT_BOOST_UUID + BOOST_TEST(true); + #else + BOOST_TEST(false, "The 'THRIFT_TUUID_SUPPORT_BOOST_UUID' preprocessor directive must be set for these tests"); + #endif // THRIFT_TUUID_SUPPORT_BOOST_UUID +} + +BOOST_AUTO_TEST_CASE(from_boost_uuid_constructor) { + static boost::uuids::string_generator gen; + boost::uuids::uuid boost_uuid{gen("1f610073-db33-4d21-adf2-75460d4955cc")}; + BOOST_TEST(!boost_uuid.is_nil()); + const TUuid uuid{boost_uuid}; + BOOST_TEST(!uuid.is_nil()); + + BOOST_TEST(to_string(boost_uuid) == to_string(uuid)); + BOOST_TEST(to_string(uuid) == std::string{"1f610073-db33-4d21-adf2-75460d4955cc"}); +} + +BOOST_AUTO_TEST_CASE(from_boost_uuid_assignment) { + static boost::uuids::string_generator gen; + boost::uuids::uuid boost_uuid{gen("5cb719a4-cd15-4476-8bcc-f1834b2527ee")}; + BOOST_TEST(!boost_uuid.is_nil()); + TUuid uuid{}; + BOOST_TEST(uuid.is_nil()); + + uuid = boost_uuid; + + BOOST_TEST(to_string(boost_uuid) == to_string(uuid)); + BOOST_TEST(to_string(uuid) == std::string{"5cb719a4-cd15-4476-8bcc-f1834b2527ee"}); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/lib/cpp/test/TUuidTestBoostNoDirective.cpp b/lib/cpp/test/TUuidTestBoostNoDirective.cpp new file mode 100644 index 00000000000..8af9c3572eb --- /dev/null +++ b/lib/cpp/test/TUuidTestBoostNoDirective.cpp @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include + +BOOST_AUTO_TEST_SUITE(TUuidBoostTestNoDirective) + +BOOST_AUTO_TEST_CASE(compiler_directive_not_set) { + // Test if the macro is set as expected + #ifdef THRIFT_TUUID_SUPPORT_BOOST_UUID + BOOST_TEST(false, "The 'THRIFT_TUUID_SUPPORT_BOOST_UUID' preprocessor must NOT be set for these tests"); + #else + BOOST_TEST(true); + #endif // THRIFT_TUUID_SUPPORT_BOOST_UUID +} +BOOST_AUTO_TEST_SUITE_END() + +// This inclusion order is unconventional: This test specifcially tests that +// the THRIFT_TUUID_SUPPORT_BOOST_UUID directive can be set before including the header +// to enable boost::uuid support without causing linking or other errors with +// the compiled thrift library. + +#define THRIFT_TUUID_SUPPORT_BOOST_UUID +#define THRIFT_TUUID_BOOST_CONSTRUCTOR_EXPLICIT + +#include +#include + +#include +using apache::thrift::TUuid; + +BOOST_AUTO_TEST_SUITE(TUuidBoostTestNoDirective) + +BOOST_AUTO_TEST_CASE(compiler_directive_set) { + // Test if the macro is set as expected + #ifdef THRIFT_TUUID_SUPPORT_BOOST_UUID + BOOST_TEST(true); + #else + BOOST_TEST(false, "The 'THRIFT_TUUID_SUPPORT_BOOST_UUID' preprocessor must now be set for these tests"); + #endif // THRIFT_TUUID_SUPPORT_BOOST_UUID +} + +BOOST_AUTO_TEST_CASE(from_boost_uuid_constructor) { + static boost::uuids::string_generator gen; + boost::uuids::uuid boost_uuid{gen("5cb719a4-cd15-4476-8bcc-f1834b2527ee")}; + BOOST_TEST(!boost_uuid.is_nil()); + const TUuid uuid{boost_uuid}; + BOOST_TEST(!uuid.is_nil()); + + BOOST_TEST(to_string(boost_uuid) == to_string(uuid)); + BOOST_TEST(to_string(uuid) == std::string{"5cb719a4-cd15-4476-8bcc-f1834b2527ee"}); +} + +BOOST_AUTO_TEST_CASE(from_boost_uuid_assignment) { + static boost::uuids::string_generator gen; + boost::uuids::uuid boost_uuid{gen("1f610073-db33-4d21-adf2-75460d4955cc")}; + BOOST_TEST(!boost_uuid.is_nil()); + TUuid uuid{}; + BOOST_TEST(uuid.is_nil()); + + uuid = TUuid{boost_uuid}; + + BOOST_TEST(to_string(boost_uuid) == to_string(uuid)); + BOOST_TEST(to_string(uuid) == std::string{"1f610073-db33-4d21-adf2-75460d4955cc"}); +} +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/lib/cpp/test/ToStringTest.cpp b/lib/cpp/test/ToStringTest.cpp index 68c82ad4be1..cb792df67b7 100644 --- a/lib/cpp/test/ToStringTest.cpp +++ b/lib/cpp/test/ToStringTest.cpp @@ -162,11 +162,11 @@ BOOST_AUTO_TEST_CASE(generated_nested_list_object_to_string) { BOOST_AUTO_TEST_CASE(generated_uuid_to_string) { thrift::test::CrazyNesting l; - l.uuid_field = "{4b686716-5f20-4deb-8ce0-9eaf379e8a3d}"; + l.uuid_field = apache::thrift::TUuid{"{4b686716-5f20-4deb-8ce0-9eaf379e8a3d}"}; BOOST_CHECK_EQUAL(to_string(l), "CrazyNesting(string_field=, set_field=, list_field=[], binary_field=, " - "uuid_field={4b686716-5f20-4deb-8ce0-9eaf379e8a3d})"); + "uuid_field=4b686716-5f20-4deb-8ce0-9eaf379e8a3d)"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index c15281a6a09..6bda29431ef 100644 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -653,12 +653,12 @@ int main(int argc, char** argv) { /** * UUID TEST */ - const std::string expected_uuid{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; - UUID_TEST(testUuid, std::string{"{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}"}, expected_uuid); - UUID_TEST(testUuid, std::string{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}, expected_uuid); - UUID_TEST(testUuid, std::string{"5e2ab18817264e75a04f1ed9a6a89c4c"}, expected_uuid); - UUID_TEST(testUuid, std::string{"{5e2ab18817264e75a04f1ed9a6a89c4c}"}, expected_uuid); - UUID_TEST(testUuid, std::string{}, std::string{"00000000-0000-0000-0000-000000000000"}); + const TUuid expected_uuid{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}; + UUID_TEST(testUuid, TUuid{"{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}"}, expected_uuid); + UUID_TEST(testUuid, TUuid{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}, expected_uuid); + UUID_TEST(testUuid, TUuid{"5e2ab18817264e75a04f1ed9a6a89c4c"}, expected_uuid); + UUID_TEST(testUuid, TUuid{"{5e2ab18817264e75a04f1ed9a6a89c4c}"}, expected_uuid); + UUID_TEST(testUuid, TUuid{}, TUuid{"00000000-0000-0000-0000-000000000000"}); /** * STRUCT TEST diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index afd293814de..dc6e69f6f0d 100644 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -132,8 +132,8 @@ class TestHandler : public ThriftTestIf { _return = thing; } - std::string testUuid(const std::string thing) override { - printf("testUuid(\"{%s}\")\n", thing.c_str()); + TUuid testUuid(const TUuid thing) override { + printf("testUuid(\"{%s}\")\n", to_string(thing).c_str()); return thing; } @@ -447,8 +447,8 @@ class TestHandlerAsync : public ThriftTestCobSvIf { cob(res); } - void testUuid(::std::function cob, const std::string thing) override { - std::string res = _delegate->testUuid(thing); + void testUuid(::std::function cob, const TUuid thing) override { + TUuid res = _delegate->testUuid(thing); cob(res); } From f0a865d41230026c498195818e6b906c39cabc92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 20:01:43 +0000 Subject: [PATCH 248/250] Bump braces from 3.0.2 to 3.0.3 in /lib/ts Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3. - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3) --- updated-dependencies: - dependency-name: braces dependency-type: indirect ... Signed-off-by: dependabot[bot] --- lib/ts/package-lock.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ts/package-lock.json b/lib/ts/package-lock.json index 31e0c52d69f..61a3a27d48c 100644 --- a/lib/ts/package-lock.json +++ b/lib/ts/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "thrift", - "version": "0.20.0", + "version": "0.21.0", "license": "Apache-2.0", "dependencies": { "bufferutil": "^4.0.1", @@ -427,12 +427,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -1465,9 +1465,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" From 4ffd6c08f70efa54e94462f810632788b1928dab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 20:01:33 +0000 Subject: [PATCH 249/250] Bump ws from 6.2.2 to 6.2.3 in /lib/ts Bumps [ws](https://github.com/websockets/ws) from 6.2.2 to 6.2.3. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/6.2.2...6.2.3) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] --- lib/ts/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ts/package-lock.json b/lib/ts/package-lock.json index 61a3a27d48c..ee1592ea654 100644 --- a/lib/ts/package-lock.json +++ b/lib/ts/package-lock.json @@ -4951,9 +4951,9 @@ "dev": true }, "node_modules/ws": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", - "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.3.tgz", + "integrity": "sha512-jmTjYU0j60B+vHey6TfR3Z7RD61z/hmxBS3VMSGIrroOWXQEneK1zNuotOUrGyBHQj0yrpsLHPWtigEFd13ndA==", "dev": true, "dependencies": { "async-limiter": "~1.0.0" From 455abda9ab5cf4369527a01e88d87cf1c85cbff5 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Thu, 26 Jan 2023 08:08:34 -0500 Subject: [PATCH 250/250] module: add zephyr module dir and yaml Temporarily add a basic `zephyr/module.yaml` entry to enable integration with Zephyr's build system. Zephyr module integration will be done in the main Zephyr tree. This change itself should eventually go upstream and the preference for this project would be to have all changes go upstream first. So in a sense, the fork of `apache/thrift` to `zephyrproject-rtos/thrift` should be kept as redundant as possible so that it could be replaced with the upstream project at any time. Signed-off-by: Chris Friedt --- zephyr/module.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 zephyr/module.yml diff --git a/zephyr/module.yml b/zephyr/module.yml new file mode 100644 index 00000000000..51428d96865 --- /dev/null +++ b/zephyr/module.yml @@ -0,0 +1,5 @@ +name: thrift +build: + cmake-ext: True + kconfig-ext: True +