From 1bffa05093140815334c5ca46dc4fc0c2c5b3c77 Mon Sep 17 00:00:00 2001 From: Will Date: Tue, 14 Jun 2022 15:33:20 -0400 Subject: [PATCH 01/50] gRPC: initial commit moving from demo to public repo --- common/config/rush/pnpm-lock.yaml | 22 +- packages/grpc/.c8rc.json | 3 + packages/grpc/.eslintrc.cjs | 7 + packages/grpc/.mocharc.yaml | 4 + packages/grpc/CHANGELOG.json | 566 ++++++++++++++++++++++++++++++ packages/grpc/CHANGELOG.md | 176 ++++++++++ packages/grpc/LICENSE | 21 ++ packages/grpc/package.json | 45 +++ packages/grpc/src/grpc.ts | 142 ++++++++ packages/grpc/src/lib.ts | 52 +++ packages/grpc/src/proto.ts | 220 ++++++++++++ packages/grpc/src/transform.ts | 418 ++++++++++++++++++++++ packages/grpc/src/write.ts | 174 +++++++++ packages/grpc/test/test.spec.ts | 3 + packages/grpc/tsconfig.json | 15 + rush.json | 6 + 16 files changed, 1872 insertions(+), 2 deletions(-) create mode 100644 packages/grpc/.c8rc.json create mode 100644 packages/grpc/.eslintrc.cjs create mode 100644 packages/grpc/.mocharc.yaml create mode 100644 packages/grpc/CHANGELOG.json create mode 100644 packages/grpc/CHANGELOG.md create mode 100644 packages/grpc/LICENSE create mode 100644 packages/grpc/package.json create mode 100644 packages/grpc/src/grpc.ts create mode 100644 packages/grpc/src/lib.ts create mode 100644 packages/grpc/src/proto.ts create mode 100644 packages/grpc/src/transform.ts create mode 100644 packages/grpc/src/write.ts create mode 100644 packages/grpc/test/test.spec.ts create mode 100644 packages/grpc/tsconfig.json diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 24a125ee62c..a882146c8f6 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -15,6 +15,7 @@ specifiers: '@rush-temp/compiler': file:./projects/compiler.tgz '@rush-temp/eslint-config-cadl': file:./projects/eslint-config-cadl.tgz '@rush-temp/eslint-plugin': file:./projects/eslint-plugin.tgz + '@rush-temp/grpc': file:./projects/grpc.tgz '@rush-temp/html-program-viewer': file:./projects/html-program-viewer.tgz '@rush-temp/internal-build-utils': file:./projects/internal-build-utils.tgz '@rush-temp/library-linter': file:./projects/library-linter.tgz @@ -110,6 +111,7 @@ dependencies: '@rush-temp/compiler': file:projects/compiler.tgz '@rush-temp/eslint-config-cadl': file:projects/eslint-config-cadl.tgz_prettier@2.6.2 '@rush-temp/eslint-plugin': file:projects/eslint-plugin.tgz + '@rush-temp/grpc': file:projects/grpc.tgz '@rush-temp/html-program-viewer': file:projects/html-program-viewer.tgz '@rush-temp/internal-build-utils': file:projects/internal-build-utils.tgz '@rush-temp/library-linter': file:projects/library-linter.tgz @@ -4489,7 +4491,7 @@ packages: dev: false file:projects/cadl-vscode.tgz: - resolution: {integrity: sha512-68kXFqY44huSWrukCumhFMpzpocmdMZ8wIbQ/zbxuf1LdP8+eFRK1oRFeWRvv7YlJTqE6N26H+R68w6Oa/i2Qw==, tarball: file:projects/cadl-vscode.tgz} + resolution: {integrity: sha512-hDslhVK07IwiqiKCxNTbTSBlXbycph+EqO/b1YD2xm68Yr/uAcDYOKXXYYC5278DdUIECHO/M5+pknjXYqP86Q==, tarball: file:projects/cadl-vscode.tgz} name: '@rush-temp/cadl-vscode' version: 0.0.0 dependencies: @@ -4515,7 +4517,7 @@ packages: dev: false file:projects/compiler.tgz: - resolution: {integrity: sha512-2qKHtYjKAjODqLE5rKLe+2vQdglIzHLuLUTjUyYRmaLaAi/rt1GGe2R7S8LxtWtNdHaNnOrVwcuh/lj3+obs2A==, tarball: file:projects/compiler.tgz} + resolution: {integrity: sha512-e452DNSSiMG5TRQbUtCeFZmL0Wkt0GrgSv/KGLSZFauXo1mdLuqBceUSYgJT2svMmD6rPqBhSf+Ns5bup5q2iw==, tarball: file:projects/compiler.tgz} name: '@rush-temp/compiler' version: 0.0.0 dependencies: @@ -4592,6 +4594,22 @@ packages: - supports-color dev: false + file:projects/grpc.tgz: + resolution: {integrity: sha512-cZxw8AU0va1CFX9dAfibid5SadMXzGurOpj3KaQjIW1nsKdcy9MTmLK/Q9WV0CFeRo8kr2x0ro8DIQ9NvTbDaQ==, tarball: file:projects/grpc.tgz} + name: '@rush-temp/grpc' + version: 0.0.0 + dependencies: + '@types/mocha': 9.1.1 + '@types/node': 16.0.3 + c8: 7.11.3 + eslint: 8.16.0 + mocha: 9.2.2 + rimraf: 3.0.2 + typescript: 4.7.2 + transitivePeerDependencies: + - supports-color + dev: false + file:projects/html-program-viewer.tgz: resolution: {integrity: sha512-/xNk/C0RWDUNz4muSwJWZY7+u4/snpP+UB11elzlVHAYm7Cr2SILH9mLypzsJc60Al4PC9DNty0HgXx09daUhA==, tarball: file:projects/html-program-viewer.tgz} name: '@rush-temp/html-program-viewer' diff --git a/packages/grpc/.c8rc.json b/packages/grpc/.c8rc.json new file mode 100644 index 00000000000..df1397419db --- /dev/null +++ b/packages/grpc/.c8rc.json @@ -0,0 +1,3 @@ +{ + "reporter": ["cobertura", "json", "text"] +} diff --git a/packages/grpc/.eslintrc.cjs b/packages/grpc/.eslintrc.cjs new file mode 100644 index 00000000000..45f086cb1a8 --- /dev/null +++ b/packages/grpc/.eslintrc.cjs @@ -0,0 +1,7 @@ +require("@cadl-lang/eslint-config-cadl/patch/modern-module-resolution"); + +module.exports = { + plugins: ["@cadl-lang/eslint-plugin"], + extends: ["@cadl-lang/eslint-config-cadl", "plugin:@cadl-lang/eslint-plugin/recommended"], + parserOptions: { tsconfigRootDir: __dirname }, +}; diff --git a/packages/grpc/.mocharc.yaml b/packages/grpc/.mocharc.yaml new file mode 100644 index 00000000000..2c757438b54 --- /dev/null +++ b/packages/grpc/.mocharc.yaml @@ -0,0 +1,4 @@ +timeout: 5000 +require: source-map-support/register +spec: "dist/test/**/*.js" +ignore: "dist/test/manual/**/*.js" diff --git a/packages/grpc/CHANGELOG.json b/packages/grpc/CHANGELOG.json new file mode 100644 index 00000000000..4c629c00737 --- /dev/null +++ b/packages/grpc/CHANGELOG.json @@ -0,0 +1,566 @@ +{ + "name": "@cadl-lang/openapi3", + "entries": [ + { + "version": "0.11.0", + "tag": "@cadl-lang/openapi3_v0.11.0", + "date": "Fri, 06 May 2022 17:19:57 GMT", + "comments": { + "minor": [ + { + "comment": "Uptake change in compiler with children references" + }, + { + "comment": "Move decorators to `OpenAPI` namespace" + }, + { + "comment": "Uptake change to versioning library" + }, + { + "comment": "Remove node 14 support" + } + ], + "patch": [ + { + "comment": "Fix issue not excluding template models from derived models causing crash" + }, + { + "comment": "Fix duplicate `description` in parameters" + }, + { + "comment": "Rearrange some aspects of operation output in the OpenAPI emitter" + }, + { + "comment": "URI-encode refs" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.30.0` to `~0.31.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.13.0` to `~0.14.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.8.0` to `~0.9.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.4.0` to `~0.5.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.4.0` to `~0.5.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.30.0` to `~0.31.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.13.0` to `~0.14.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.8.0` to `~0.9.0`" + } + ] + } + }, + { + "version": "0.10.0", + "tag": "@cadl-lang/openapi3_v0.10.0", + "date": "Thu, 31 Mar 2022 17:10:49 GMT", + "comments": { + "minor": [ + { + "comment": "Include discriminator property in base schema with a boilerplace description" + }, + { + "comment": "Add support for `void` type" + }, + { + "comment": "Moved http response interpretation to @cadl-lang/rest library." + }, + { + "comment": "implement multiple response content types" + }, + { + "comment": "Uptake change to allow versioned dependency with unversioned service" + } + ], + "patch": [ + { + "comment": "Fix bug with number enums that reference `0`." + }, + { + "comment": "Use parent .model of ModelTypeProperty" + }, + { + "comment": "Support browser builds" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.29.0` to `~0.30.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.12.0` to `~0.13.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.7.0` to `~0.8.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.2` to `~0.4.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/eslint-config-cadl\" from `~0.2.0` to `~0.3.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.2` to `~0.4.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.29.0` to `~0.30.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.12.0` to `~0.13.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.7.0` to `~0.8.0`" + } + ] + } + }, + { + "version": "0.9.0", + "tag": "@cadl-lang/openapi3_v0.9.0", + "date": "Wed, 09 Mar 2022 17:42:09 GMT", + "comments": { + "minor": [ + { + "comment": "@doc and @summary will set the description and summary on extended primitive types" + }, + { + "comment": "Emit child models to OpenAPI when parent is emitted" + }, + { + "comment": "**Added** support for `@externalDocs` decorator" + }, + { + "comment": "Added support for `@knownValues` decorator" + }, + { + "comment": "@doc on service namespace set openapi description" + }, + { + "comment": "Uptake change to intrinsic types" + }, + { + "comment": "Fix issue where a model name the same as Cadl Intrinsic type would be treated the same." + } + ], + "patch": [ + { + "comment": "Fix duplicate parameter type definitions in OpenAPI 3 output" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.28.0` to `~0.29.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.11.0` to `~0.12.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.6.1` to `~0.7.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.1` to `~0.3.2`" + }, + { + "comment": "Updating dependency \"@cadl-lang/eslint-config-cadl\" from `~0.1.0` to `~0.2.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.1` to `~0.3.2`" + }, + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.28.0` to `~0.29.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.11.0` to `~0.12.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.6.1` to `~0.7.0`" + } + ] + } + }, + { + "version": "0.8.0", + "tag": "@cadl-lang/openapi3_v0.8.0", + "date": "Tue, 15 Feb 2022 22:35:02 GMT", + "comments": { + "patch": [ + { + "comment": "Add support for separate `@summary` from `@doc`" + } + ], + "minor": [ + { + "comment": "Add validation to oneOf decorator" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.27.0` to `~0.28.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.10.0` to `~0.11.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.6.0` to `~0.6.1`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.0` to `~0.3.1`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.0` to `~0.3.1`" + }, + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.27.0` to `~0.28.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.10.0` to `~0.11.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.6.0` to `~0.6.1`" + } + ] + } + }, + { + "version": "0.7.0", + "tag": "@cadl-lang/openapi3_v0.7.0", + "date": "Mon, 14 Feb 2022 03:01:07 GMT", + "comments": { + "minor": [ + { + "comment": "refactor status code handling to http library" + }, + { + "comment": "Take change in openapi upstream library" + }, + { + "comment": "Update decorators to take in api change" + } + ], + "patch": [ + { + "comment": "Bump dependency versions" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.26.0` to `~0.27.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.9.0` to `~0.10.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.5.1` to `~0.6.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.2.0` to `~0.3.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.2.0` to `~0.3.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.26.0` to `~0.27.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.9.0` to `~0.10.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.5.1` to `~0.6.0`" + } + ] + } + }, + { + "version": "0.6.0", + "tag": "@cadl-lang/openapi3_v0.6.0", + "date": "Fri, 04 Feb 2022 18:00:18 GMT", + "comments": { + "minor": [ + { + "comment": "Support union values for status-code and content-type in responses" + }, + { + "comment": "Openapi3 support for discriminated unions" + }, + { + "comment": "openapi3 emitter support for @error decorator" + }, + { + "comment": "Configure for new emitter syntax" + }, + { + "comment": "Internals: switch to internal path manipulation" + }, + { + "comment": "Extracted decorators into own library `@cadl-lang/openapi`" + }, + { + "comment": "Uptake changes in @cadl-lang/rest library improving operation parameter handling" + }, + { + "comment": "Update cadl depdendencies to peerDependencies" + }, + { + "comment": "Add support for versioned services" + }, + { + "comment": "Add statusCode decorator for http status code" + } + ], + "patch": [ + { + "comment": "Adding @format decorator support for openapi3 to emit \"format\" for string types" + }, + { + "comment": "**Fix** Added support for nullable array `xzy[] | null`" + }, + { + "comment": "**Fix** issue with @body body: bytes producing `type: string, format: bytes` instead of `type: string, format: binary` for requests and responses" + }, + { + "comment": "Use assigned @friendlyName on model types when emitting schema definitions and refs" + }, + { + "comment": "Refactor and improve openapi3 return type tests" + }, + { + "comment": "Fix status code validation and other minor cleanup" + }, + { + "comment": "Support nullable in openapi3 emitter" + }, + { + "comment": "Renaming @format decorator to @pattern." + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.25.0` to `~0.26.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.8.0` to `~0.9.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.5.0` to `~0.5.1`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `0.1.0` to `0.2.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/versioning\" from `0.1.0` to `0.2.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.25.0` to `~0.26.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.8.0` to `~0.9.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.5.0` to `~0.5.1`" + } + ] + } + }, + { + "version": "0.5.0", + "tag": "@cadl-lang/openapi3_v0.5.0", + "date": "Thu, 16 Dec 2021 08:02:20 GMT", + "comments": { + "patch": [ + { + "comment": "Update openapi3 emitter to consume new Cadl.Rest route generation API" + } + ], + "minor": [ + { + "comment": "Generate anyOf or oneOf schemas for Cadl unions in openapi3" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.24.1` to `0.25.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `0.7.1` to `0.8.0`" + } + ] + } + }, + { + "version": "0.4.2", + "tag": "@cadl-lang/openapi3_v0.4.2", + "date": "Wed, 01 Dec 2021 22:56:11 GMT", + "comments": { + "patch": [ + { + "comment": "Add support for extension decorator on parameters and tests" + }, + { + "comment": "Add openapi3 support for Cadl safeint" + }, + { + "comment": "Add README" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.24.0` to `0.24.1`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `0.7.0` to `0.7.1`" + } + ] + } + }, + { + "version": "0.4.1", + "tag": "@cadl-lang/openapi3_v0.4.1", + "date": "Thu, 18 Nov 2021 13:58:15 GMT", + "comments": { + "patch": [ + { + "comment": "Enable operation generation from interfaces" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.23.0` to `0.24.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `0.6.4` to `0.7.0`" + } + ] + } + }, + { + "version": "0.4.0", + "tag": "@cadl-lang/openapi3_v0.4.0", + "date": "Thu, 11 Nov 2021 21:46:21 GMT", + "comments": { + "minor": [ + { + "comment": "**Added** Support for duration type" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.22.0` to `0.23.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `0.6.3` to `0.6.4`" + } + ] + } + }, + { + "version": "0.3.1", + "tag": "@cadl-lang/openapi3_v0.3.1", + "date": "Thu, 28 Oct 2021 21:17:50 GMT", + "comments": { + "patch": [ + { + "comment": "Use strict diagnostics" + }, + { + "comment": "Fix crash on empty enum in openapi3 emitter" + }, + { + "comment": "Set shared param definitions in components.parameters" + }, + { + "comment": "Fix param default to be in schema" + }, + { + "comment": "Fix handling of decorators on parameters in openapi3" + }, + { + "comment": "Fix generation of openapi3 response headers" + }, + { + "comment": "Define response body for primitive response type" + }, + { + "comment": "Remove management.azure.com service host default" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.21.0` to `0.22.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `0.6.2` to `0.6.3`" + } + ] + } + }, + { + "version": "0.3.0", + "tag": "@cadl-lang/openapi3_v0.3.0", + "date": "Fri, 15 Oct 2021 21:33:37 GMT", + "comments": { + "minor": [ + { + "comment": "**Added** Support for server default" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.20.0` to `0.21.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `0.6.1` to `0.6.2`" + } + ] + } + }, + { + "version": "0.2.0", + "tag": "@cadl-lang/openapi3_v0.2.0", + "date": "Fri, 17 Sep 2021 00:49:37 GMT", + "comments": { + "minor": [ + { + "comment": "Add emitter for OpenAPI 3.0" + }, + { + "comment": "Remove support for multiple inheritance" + } + ], + "patch": [ + { + "comment": "Adding changelog for openapi3 package" + }, + { + "comment": "Updates for cadl namespace addition" + }, + { + "comment": "This is a test" + }, + { + "comment": "Support for emitting `bytes` and new number types" + } + ], + "dependency": [ + { + "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.19.0` to `0.20.0`" + }, + { + "comment": "Updating dependency \"@cadl-lang/rest\" from `0.6.0` to `0.6.1`" + } + ] + } + } + ] +} diff --git a/packages/grpc/CHANGELOG.md b/packages/grpc/CHANGELOG.md new file mode 100644 index 00000000000..4e4422fa357 --- /dev/null +++ b/packages/grpc/CHANGELOG.md @@ -0,0 +1,176 @@ +# Change Log - @cadl-lang/openapi3 + +This log was last generated on Fri, 06 May 2022 17:19:57 GMT and should not be manually modified. + +## 0.11.0 +Fri, 06 May 2022 17:19:57 GMT + +### Minor changes + +- Uptake change in compiler with children references +- Move decorators to `OpenAPI` namespace +- Uptake change to versioning library +- Remove node 14 support + +### Patches + +- Fix issue not excluding template models from derived models causing crash +- Fix duplicate `description` in parameters +- Rearrange some aspects of operation output in the OpenAPI emitter +- URI-encode refs + +## 0.10.0 +Thu, 31 Mar 2022 17:10:49 GMT + +### Minor changes + +- Include discriminator property in base schema with a boilerplace description +- Add support for `void` type +- Moved http response interpretation to @cadl-lang/rest library. +- implement multiple response content types +- Uptake change to allow versioned dependency with unversioned service + +### Patches + +- Fix bug with number enums that reference `0`. +- Use parent .model of ModelTypeProperty +- Support browser builds + +## 0.9.0 +Wed, 09 Mar 2022 17:42:09 GMT + +### Minor changes + +- @doc and @summary will set the description and summary on extended primitive types +- Emit child models to OpenAPI when parent is emitted +- **Added** support for `@externalDocs` decorator +- Added support for `@knownValues` decorator +- @doc on service namespace set openapi description +- Uptake change to intrinsic types +- Fix issue where a model name the same as Cadl Intrinsic type would be treated the same. + +### Patches + +- Fix duplicate parameter type definitions in OpenAPI 3 output + +## 0.8.0 +Tue, 15 Feb 2022 22:35:02 GMT + +### Minor changes + +- Add validation to oneOf decorator + +### Patches + +- Add support for separate `@summary` from `@doc` + +## 0.7.0 +Mon, 14 Feb 2022 03:01:07 GMT + +### Minor changes + +- refactor status code handling to http library +- Take change in openapi upstream library +- Update decorators to take in api change + +### Patches + +- Bump dependency versions + +## 0.6.0 +Fri, 04 Feb 2022 18:00:18 GMT + +### Minor changes + +- Support union values for status-code and content-type in responses +- Openapi3 support for discriminated unions +- openapi3 emitter support for @error decorator +- Configure for new emitter syntax +- Internals: switch to internal path manipulation +- Extracted decorators into own library `@cadl-lang/openapi` +- Uptake changes in @cadl-lang/rest library improving operation parameter handling +- Update cadl depdendencies to peerDependencies +- Add support for versioned services +- Add statusCode decorator for http status code + +### Patches + +- Adding @format decorator support for openapi3 to emit "format" for string types +- **Fix** Added support for nullable array `xzy[] | null` +- **Fix** issue with @body body: bytes producing `type: string, format: bytes` instead of `type: string, format: binary` for requests and responses +- Use assigned @friendlyName on model types when emitting schema definitions and refs +- Refactor and improve openapi3 return type tests +- Fix status code validation and other minor cleanup +- Support nullable in openapi3 emitter +- Renaming @format decorator to @pattern. + +## 0.5.0 +Thu, 16 Dec 2021 08:02:20 GMT + +### Minor changes + +- Generate anyOf or oneOf schemas for Cadl unions in openapi3 + +### Patches + +- Update openapi3 emitter to consume new Cadl.Rest route generation API + +## 0.4.2 +Wed, 01 Dec 2021 22:56:11 GMT + +### Patches + +- Add support for extension decorator on parameters and tests +- Add openapi3 support for Cadl safeint +- Add README + +## 0.4.1 +Thu, 18 Nov 2021 13:58:15 GMT + +### Patches + +- Enable operation generation from interfaces + +## 0.4.0 +Thu, 11 Nov 2021 21:46:21 GMT + +### Minor changes + +- **Added** Support for duration type + +## 0.3.1 +Thu, 28 Oct 2021 21:17:50 GMT + +### Patches + +- Use strict diagnostics +- Fix crash on empty enum in openapi3 emitter +- Set shared param definitions in components.parameters +- Fix param default to be in schema +- Fix handling of decorators on parameters in openapi3 +- Fix generation of openapi3 response headers +- Define response body for primitive response type +- Remove management.azure.com service host default + +## 0.3.0 +Fri, 15 Oct 2021 21:33:37 GMT + +### Minor changes + +- **Added** Support for server default + +## 0.2.0 +Fri, 17 Sep 2021 00:49:37 GMT + +### Minor changes + +- Add emitter for OpenAPI 3.0 +- Remove support for multiple inheritance + +### Patches + +- Adding changelog for openapi3 package +- Updates for cadl namespace addition +- This is a test +- Support for emitting `bytes` and new number types + diff --git a/packages/grpc/LICENSE b/packages/grpc/LICENSE new file mode 100644 index 00000000000..21071075c24 --- /dev/null +++ b/packages/grpc/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/packages/grpc/package.json b/packages/grpc/package.json new file mode 100644 index 00000000000..f03eef774e1 --- /dev/null +++ b/packages/grpc/package.json @@ -0,0 +1,45 @@ +{ + "name": "@cadl-lang/grpc", + "version": "0.1.0", + "author": "Microsoft Corporation", + "description": "Cadl library and emitter for gRPC/Protobuf", + "homepage": "https://github.com/Microsoft/cadl", + "readme": "https://github.com/Microsoft/cadl/blob/master/README.md", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/Microsoft/cadl.git" + }, + "bugs": { + "url": "https://github.com/Microsoft/cadl/issues" + }, + "keywords": [ + "cadl" + ], + "main": "dist/lib.js", + "type": "module", + "cadlMain": "dist/grpc.js", + "scripts": { + "clean": "rimraf ./dist ./temp", + "build": "tsc -p .", + "watch": "tsc -p . --watch", + "test": "mocha", + "test-official": "c8 mocha --forbid-only", + "lint": "eslint . --ext .ts --max-warnings=0", + "lint:fix": "eslint . --fix --ext .ts" + }, + "dependencies": { + "@cadl-lang/compiler": "~0.31.0" + }, + "devDependencies": { + "@cadl-lang/eslint-config-cadl": "~0.3.0", + "@cadl-lang/eslint-plugin": "~0.1.0", + "@types/mocha": "~9.1.0", + "@types/node": "~16.0.3", + "c8": "~7.11.0", + "eslint": "^8.12.0", + "mocha": "~9.2.0", + "rimraf": "~3.0.2", + "typescript": "~4.7.2" + } +} diff --git a/packages/grpc/src/grpc.ts b/packages/grpc/src/grpc.ts new file mode 100644 index 00000000000..769a7f6f96f --- /dev/null +++ b/packages/grpc/src/grpc.ts @@ -0,0 +1,142 @@ +import { + createDecoratorDefinition, + DecoratorContext, + ModelTypeProperty, + NamespaceType, + Program, + setDecoratorNamespace, + Type, + validateDecoratorTarget, +} from "@cadl-lang/compiler"; + +import { fieldIndexKey, packageKey, reportDiagnostic, serviceKey } from "./lib.js"; +import { createGrpcEmitter } from "./transform.js"; + +/** + * # cadl-grpc : gRPC/Protobuf Emitter and Decorators for CADL + * + * This module defines an emitter and decorator library for CADL that enables specifying gRPC services and Protobuf + * models. + */ + +/** + * The maximum field index allowed by Protocol Buffers. + */ +const MAX_FIELD_INDEX = 2 ** 29 - 1; + +/** + * The field range between 19000 and 19999 is reserved for Protobuf client implementations. + */ +const IMPLEMENTATION_RESERVED_RANGE = [19000, 19999] as const; + +const packageDecorator = createDecoratorDefinition({ + name: "@package", + args: [{ kind: "String", optional: true }], + target: "Namespace", +} as const); + +/** + * Decorate a namespace as a package, indicating that it represents a single Protobuf unit (a single file with a + * `package` declaration). + * + * @param ctx - decorator context + * @param target - the decorated namespace + * @param name - the package's name (not optional) + */ +export function $package(ctx: DecoratorContext, target: NamespaceType, name: string) { + if (!packageDecorator.validate(ctx, target, [name])) { + return; + } + + ctx.program.stateMap(packageKey).set(target, name); +} + +/** + * Decorate an interface as a service, indicating that it represents a gRPC `service` declaration. + * + * @param ctx - decorator context + * @param target - the decorated interface + */ +export function $service(ctx: DecoratorContext, target: Type) { + if (!validateDecoratorTarget(ctx, target, "@service", "Interface")) { + return; + } + + // TODO: do we allow service interfaces to extend/compose other interfaces? + + for (const _operation of target.operations.values()) { + // TODO: validate operations here, don't defer to $onEmit, so that we have a good editor experience. + } + + ctx.program.stateSet(serviceKey).add(target); +} + +const fieldDecorator = createDecoratorDefinition({ + name: "@field", + args: [{ kind: "Number", optional: false }], + target: "ModelProperty", +} as const); + +/** + * Decorate a model property with a field index. Field indices are required for all fields of emitted messages. + * + * @param param0 + * @param target + * @param fieldIndex + * @returns + */ +export function $field(ctx: DecoratorContext, target: ModelTypeProperty, fieldIndex: number) { + if (!fieldDecorator.validate(ctx, target, [fieldIndex])) { + return; + } + + if (!Number.isInteger(fieldIndex) || fieldIndex <= 0) { + reportDiagnostic(ctx.program, { + code: "field-index", + messageId: "invalid", + format: { + index: String(fieldIndex), + }, + target, + }); + return; + } else if (fieldIndex > MAX_FIELD_INDEX) { + reportDiagnostic(ctx.program, { + code: "field-index", + messageId: "out-of-bounds", + format: { + index: String(fieldIndex), + max: String(MAX_FIELD_INDEX), + }, + target, + }); + return; + } else if ( + fieldIndex >= IMPLEMENTATION_RESERVED_RANGE[0] && + fieldIndex <= IMPLEMENTATION_RESERVED_RANGE[1] + ) { + reportDiagnostic(ctx.program, { + code: "field-index", + messageId: "reserved", + format: { + index: String(fieldIndex), + }, + target, + }); + } + + ctx.program.stateMap(fieldIndexKey).set(target, fieldIndex); +} + +/** + * Emitter main function. + * + * @param program - the program to emit + */ +export async function $onEmit(program: Program) { + const emitter = createGrpcEmitter(program); + + await emitter(/* TODO: options? */); +} + +setDecoratorNamespace("Cadl.Grpc", $field, $package, $service); diff --git a/packages/grpc/src/lib.ts b/packages/grpc/src/lib.ts new file mode 100644 index 00000000000..64a5b8e30e9 --- /dev/null +++ b/packages/grpc/src/lib.ts @@ -0,0 +1,52 @@ +import { createCadlLibrary, paramMessage } from "@cadl-lang/compiler"; + +const { reportDiagnostic } = createCadlLibrary({ + name: "cadl-grpc", + diagnostics: { + "field-index": { + severity: "error", + messages: { + invalid: paramMessage`field index ${"index"} is invalid (must be an integer greater than zero)`, + "out-of-bounds": paramMessage`field index ${"index"} is out of bounds (must be less than ${"max"})`, + reserved: paramMessage`field index ${"index"} falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher)`, + }, + }, + "root-operation": { + severity: "error", + messages: { + default: "operations in the root namespace are not supported (no associated gRPC service)", + }, + }, + "unsupported-return-type": { + severity: "error", + messages: { + default: "gRPC operations must return a named Model", + }, + }, + "unsupported-input-type": { + severity: "error", + messages: { + "wrong-number": + "gRPC operations must accept exactly one Model input (an empty model will do)", + "wrong-type": "gRPC operations may only accept a named Model as an input", + unconvertible: "input parameters cannot be converted to a gRPC model", + }, + }, + "unsupported-field-type": { + severity: "error", + messages: { + unconvertible: paramMessage`cannot convert a ${"type"} to a protobuf type (only intrinsic types and models are supported)`, + "unknown-intrinsic": paramMessage`no known protobuf scalar for intrinsic type ${"name"}`, + "recursive-map": "a protobuf map's 'value' type may not refer to another map", + }, + }, + }, + emitter: { names: ["grpc"] }, +}); + +export { reportDiagnostic }; + +// Decorator state keys +export const fieldIndexKey = Symbol("cadl-grpc::fields"); +export const serviceKey = Symbol("cadl-grpc::service"); +export const packageKey = Symbol("cadl-grpc::package"); diff --git a/packages/grpc/src/proto.ts b/packages/grpc/src/proto.ts new file mode 100644 index 00000000000..d3705ca8f98 --- /dev/null +++ b/packages/grpc/src/proto.ts @@ -0,0 +1,220 @@ +/** + * This module describes an AST for Protobuf. + */ + +/** + * A single .proto file. + */ +export interface ProtoFile { + /** + * The package name, if one is known. + */ + package?: string; + /** + * The `option` specifiers to include in the file. + */ + options: Partial; + + /** + * The declarations in the file. + * + * Only `service` and `message` declarations may exist at the root of the file. + */ + declarations: Array; +} + +/** + * The built-in options that are defined by Protobuf. + */ +export interface DefaultFileOptions { + java_package: string; + java_outer_classname: string; + + optimize_for: "SPEED" | "CODE_SIZE" | "LITE_RUNTIME"; + + cc_enable_arenas: boolean; +} + +/** + * A declaration. One of `service`, `message`, a field within a message, `one_of`, `enum`, or an `rpc` method. + */ +export type ProtoDeclaration = + | ProtoServiceDeclaration + | ProtoMessageDeclaration + | ProtoFieldDeclaration + | ProtoOneOfDeclaration + | ProtoEnumDeclaration + | ProtoMethodDeclaration; + +/** + * A Protobuf scalar type. + */ +export type ScalarName = ScalarIntegralName | "double" | "float" | "bytes" | "string"; + +/** + * A Protobuf integral type. + */ +export type ScalarIntegralName = ScalarIntegerName | ScalarFixedName | "bool"; + +/** + * A Protobuf variable-length integer type. + */ +export type ScalarIntegerName = `${"u" | "s" | ""}int${"32" | "64"}`; + +/** + * A Protobuf fixed-length integer type. + */ +export type ScalarFixedName = `${"s" | ""}fixed${"32" | "64"}`; + +// Symbols for type destructuring +export const $scalar = Symbol("$scalar"); +export const $ref = Symbol("$ref"); +export const $map = Symbol("$map"); + +/** + * A map type. Map keys can be any integral or string type (any scalar except float, double, and bytes). + * + * The value may be any type other than another map. + */ +export type ProtoMap = [typeof $map, ScalarIntegralName | "string", ProtoRef | ProtoScalar]; + +/** + * A reference to a named message type. + */ +export type ProtoRef = [typeof $ref, string]; + +/** + * A scalar type. + */ +export type ProtoScalar = [typeof $scalar, ScalarName]; + +/** + * A Protobuf type. + */ +export type ProtoType = ProtoScalar | ProtoRef | ProtoMap; + +/** + * Create a scalar type by name. + */ +export function scalar(t: ScalarName): ProtoScalar { + return [$scalar, t]; +} + +/** + * Create a type reference (symbol) to a named message. + */ +export function ref(t: string): ProtoRef { + return [$ref, t]; +} + +/** + * Create a map from a key type to a value type. + */ +export function map(k: ScalarIntegralName | "string", v: Exclude): ProtoMap { + return [$map, k, v]; +} + +/** + * A "pattern" object with variants for each Protobuf type. + */ +export interface ProtoTypeMatchPattern { + scalar: (s: ScalarName) => T; + ref: (r: string) => T; + map: (k: ScalarIntegralName | "string", v: Exclude) => T; +} + +/** + * A helper function that matches and delegates a Protobuf type to a handler per type. + * + * @param type - the Protobuf type to match and delegate + * @param pat + * @returns + */ +export function matchType(type: ProtoType, pat: ProtoTypeMatchPattern): Result { + switch (type[0]) { + case $ref: + return pat.ref(type[1]); + case $scalar: + return pat.scalar(type[1]); + case $map: + return pat.map(type[1], type[2] as Exclude); + default: + const __exhaust: never = type[0]; + throw new Error(`Unreachable: matchType variant ${__exhaust}`); // unreachable + } +} + +/** + * A `service` declaration. + */ +export interface ProtoServiceDeclaration { + kind: "service"; + name: string; + operations: ProtoMethodDeclaration[]; +} + +/** + * An `rfc` method declaration. + */ +export interface ProtoMethodDeclaration { + kind: "method"; + name: string; + input: ProtoRef; + returns: ProtoRef; +} + +/** + * A `message` declaration. + */ +export interface ProtoMessageDeclaration { + kind: "message"; + name: string; + declarations: Array; + reservations?: Array; +} + +/** + * A field declaration within a message. + */ +export interface ProtoFieldDeclaration { + kind: "field"; + name: string; + /** + * Whether or not the field is repeated (i.e. an array). + */ + repeated?: true; + options?: Partial; + type: ProtoType; + index: number; +} + +/** + * The options for fields defined by the Protobuf specification. + */ +export interface DefaultFieldOptions { + packed: true; + deprecated: true; +} + +/** + * A `one_of` declaration. + */ +export interface ProtoOneOfDeclaration { + kind: "oneof"; + name: string; + declarations: [ProtoFieldDeclaration, ...ProtoFieldDeclaration[]]; +} + +/** + * An `enum` declaration. + * + * TODO: this node type is currently disconnected from the proto AST. Can this + * appear anywhere other than messages? Do we need to emit it _directly_ before + * it's used? + */ +export interface ProtoEnumDeclaration { + kind: "enum"; + name: string; + allowAlias?: true; + variants: [string, number][]; +} diff --git a/packages/grpc/src/transform.ts b/packages/grpc/src/transform.ts new file mode 100644 index 00000000000..cc41315e3b2 --- /dev/null +++ b/packages/grpc/src/transform.ts @@ -0,0 +1,418 @@ +import { + getIntrinsicModelName, + InterfaceType, + isIntrinsic, + ModelType, + ModelTypeProperty, + NamespaceType, + Node, + OperationType, + Program, + resolvePath, + SyntaxKind, + Type, +} from "@cadl-lang/compiler"; +import { fieldIndexKey, packageKey, reportDiagnostic, serviceKey } from "./lib.js"; +import { + $map, + map, + ProtoFieldDeclaration, + ProtoFile, + ProtoMessageDeclaration, + ProtoMethodDeclaration, + ProtoRef, + ProtoType, + ref, + scalar, + ScalarIntegralName, +} from "./proto.js"; +import { writeProtoFile } from "./write.js"; + +/** + * Options that the gRPC emitter accepts. + */ +interface GrpcEmitterOptions { + /** + * The directory where the emitter will write the Protobuf output tree. + */ + outDir: string; +} + +// Default options +const DEFAULT_GRPC_EMITTER_OPTIONS: GrpcEmitterOptions = { + // TODO: shouldn't this be configured by default? + outDir: "./cadl-output/", +}; + +/** + * Create a worker function that converts the CADL program to Protobuf and writes it to the file system. + */ +export function createGrpcEmitter( + program: Program +): (emitterOptions?: Partial) => Promise { + return async function doEmit(emitterOptions) { + const options = { + ...DEFAULT_GRPC_EMITTER_OPTIONS, + ...emitterOptions, + }; + + const outDir = resolvePath(options.outDir); + + // Convert the program to a set of proto files. + const files = cadlToProto(program); + + if (!program.compilerOptions.noEmit && !program.hasError()) { + for (const file of files) { + // If the file has a package, emit it to a path that is shaped like the package name. Otherwise emit to + // main.proto + // TODO: What do we do if there are multiple files without packages, or multiple files with the same package? + const packageSlug = file.package?.split(".") ?? ["main"]; + const filePath = resolvePath(outDir, ...packageSlug.slice(0, -1)); + + await program.host.mkdirp(filePath); + await program.host.writeFile( + resolvePath(filePath, packageSlug[packageSlug.length - 1] + ".proto"), + writeProtoFile(file) + ); + } + } + }; +} + +/** + * Create a set of proto files that represent the CADL program. + * + * This is the meat of the emitter. + */ +function cadlToProto(program: Program): ProtoFile[] { + const packages = program.stateMap(packageKey) as Map; + + // Emit a file per package. + return [...packages].map( + ([namespace, packageName]) => + ({ + package: packageName, + options: {}, + declarations: declarationsFromNamespace(namespace), + } as ProtoFile) + ); + + /** + * Recursively searches a namespace for declarations that should be reified as Protobuf. + * + * @param namespace - the namespace to analyze + * @returns an array of declarations + */ + function declarationsFromNamespace(namespace: NamespaceType): ProtoFile["declarations"] { + const serviceInterfaces = new Set(); + + // This IIFE adds all interfaces decorated with `service` that are reachable from `namespace` + (function recursiveAddInterfaces(namespace: NamespaceType) { + for (const memberInterface of namespace.interfaces.values()) { + if (program.stateSet(serviceKey).has(memberInterface)) { + serviceInterfaces.add(memberInterface); + } + } + + for (const nested of namespace.namespaces.values()) { + // !! We only want to recurse on namespaces that are not, themselves, packages. + if (!packages.has(nested)) recursiveAddInterfaces(nested); + } + })(namespace); + + const declarations: ProtoFile["declarations"] = []; + const visitedTypes = new Set(); + + /** + * Visits a model type, converting it into a message definition and adding it if it has not already been visited. + * @param model - the model type to consider + */ + function visitType(model: ModelType) { + // TODO: when can the node be undefined? + if (model.node && !visitedTypes.has(model.node)) { + visitedTypes.add(model.node); + declarations.push(toMessage(model)); + } + } + + function visitSynthetic(model: SyntheticModel) { + if (!visitedTypes.has(model.trueModelNode)) { + visitedTypes.add(model.trueModelNode); + declarations.push({ + kind: "message", + name: model.name, + declarations: model.properties.map(toField), + }); + } + } + + const effectiveModelTypeCache = new Map(); + + // Each interface will be reified as a `service` declaration. + for (const iface of serviceInterfaces) { + declarations.push({ + kind: "service", + name: iface.name, + // The service's methods are just projections of the interface operations. + operations: [...iface.operations.values()].map(toMethodFromOperation), + }); + } + + return declarations; + + /** + * @param operation - the operation to convert + * @returns a corresponding method declaration + */ + function toMethodFromOperation(operation: OperationType): ProtoMethodDeclaration { + return { + kind: "method", + name: operation.name, + input: addInputParams(operation.parameters, operation.name), + returns: addReturnType(operation.returnType), + }; + } + + /** + * Checks a parameter Model satisfies the constraints for a gRPC method input and adds it to the declarations, + * returning a ProtoRef to the generated named message. + * + * @param model - the model to add + * @returns a reference to the model's message + */ + function addInputParams(paramsModel: ModelType, operationName: string): ProtoRef { + const messageLike = getEffectiveModelType(paramsModel, capitalize(operationName) + "Request"); + + if (messageLike) { + return ref(messageLike.name); + } + + reportDiagnostic(program, { + code: "unsupported-input-type", + messageId: "unconvertible", + target: paramsModel, + }); + + return ref(""); + } + + /** + * Checks that a return type is a Model and converts it to a message, adding it to the declarations and returning + * a reference to its name. + * + * @param t - the model to add + * @returns a reference to the model's message + */ + function addReturnType(t: Type): ProtoRef { + /* TODO: need to support importing google/protobuf/empty.proto and others + This is also very important for handling datetime values. + + if (t.kind === "Intrinsic" && t.name === "void") { + return ref("google.protobuf.Empty"); + } + */ + + switch (t.kind) { + case "Model": + visitType(t); + return ref(t.name); + default: + reportDiagnostic(program, { + code: "unsupported-return-type", + target: t, + }); + return ref(""); + } + } + + /** + * Converts a CADL type to a Protobuf type, adding a corresponding message if necessary. + * + * @param t - the type to add to the ProtoFile. + * @returns a Protobuf type corresponding to the given type + */ + function addType(t: Type): ProtoType { + // We will handle all intrinsics separately, including maps. + if (isIntrinsic(program, t)) return intrinsicToProto(getIntrinsicModelName(program, t), t); + + // TODO: streams. + + switch (t.kind) { + case "Model": + visitType(t); + return ref(t.name); + case "Array": + if (t.elementType.kind === "Model") { + visitType(t.elementType); + return ref(t.elementType.name); + } + // eslint-disable-next-line no-fallthrough + default: + reportDiagnostic(program, { + code: "unsupported-field-type", + messageId: "unconvertible", + format: { + type: t.kind, + }, + target: t, + }); + return ref(""); + } + } + + function intrinsicToProto(name: string, t: Type): ProtoType { + // Maps are considered intrinsics, so we check if the type is an instance of Cadl.Map + if (t.kind === "Model" && t.name === "Map" && t.namespace?.name === "Cadl") { + // Intrinsic map. + const [keyType, valueType] = t.templateArguments ?? []; + + // This is a core compile error. + if (!keyType || !valueType) return ref(""); + + const keyProto = addType(keyType); + const valueProto = addType(valueType); + + // A map's value cannot be another map. + if (valueProto[0] === $map) { + reportDiagnostic(program, { + code: "unsupported-field-type", + messageId: "recursive-map", + target: valueType, + }); + return ref(""); + } + + return map(keyProto[1] as "string" | ScalarIntegralName, valueProto); + } + + // TODO: there are way more scalars in proto than this. How do we expose those knobs to the API writer? + const protoType = { + bytes: scalar("bytes"), + boolean: scalar("bool"), + int32: scalar("int32"), + int64: scalar("int64"), + uint32: scalar("uint32"), + uint64: scalar("uint64"), + string: scalar("string"), + float32: scalar("float"), + float64: scalar("double"), + }[name]; + + if (!protoType) { + reportDiagnostic(program, { + code: "unsupported-field-type", + messageId: "unknown-intrinsic", + format: { + name: name, + }, + target: t, + }); + return ref(""); + } + + return protoType; + } + + /** + * @param model - the Model to convert + * @returns a corresponding message declaration + */ + function toMessage(model: ModelType): ProtoMessageDeclaration { + return { + kind: "message", + name: model.name, + declarations: [...model.properties.values()].map(toField), + }; + } + + /** + * @param property - the ModelProperty to convert + * @returns a corresponding field declaration + */ + function toField(property: ModelTypeProperty): ProtoFieldDeclaration { + const field: ProtoFieldDeclaration = { + kind: "field", + name: property.name, + type: addType(property.type), + index: program.stateMap(fieldIndexKey).get(property), + }; + + if (property.type.kind === "Array") field.repeated = true; + + return field; + } + + function getEffectiveModelType( + model: ModelType, + anonymousModelName?: string + ): SyntheticModel | undefined { + if (effectiveModelTypeCache.has(model)) return effectiveModelTypeCache.get(model); + + const properties = [...model.properties.values()]; + + const source = properties[0]?.sourceProperty?.node.parent; + + if ( + source && + source.kind === SyntaxKind.ModelStatement && + properties.length > 0 && + properties.every((p) => p.sourceProperty?.node.parent === source) + ) { + // TODO: horrible hack: id.sv? + const messageLike: SyntheticModel = { + name: (source as any).id.sv, + properties, + trueModelNode: source, + }; + + effectiveModelTypeCache.set(model, messageLike); + + visitSynthetic(messageLike); + return messageLike; + } else if (model.node && model.name === "" && anonymousModelName) { + const messageLike: SyntheticModel = { + name: anonymousModelName, + properties, + trueModelNode: model.node, + }; + + effectiveModelTypeCache.set(model, messageLike); + + visitSynthetic(messageLike); + return messageLike; + } + + effectiveModelTypeCache.set(model, undefined); + return undefined; + } + } +} + +/** + * A synthetic (created ad-hoc during transformation) model for conversion to a gRPC message. + * + * A synthetic model is named, whereas the underlying model may not be. + */ +interface SyntheticModel { + /** + * The message's model name. + */ + name: string; + + /** + * The property entries in the messag + */ + properties: ModelTypeProperty[]; + + /** + * The AST Node that this model is tied to (used for deduplication). + */ + trueModelNode: Node; +} + +/** + * Simple utility function to capitalize a string. + */ +function capitalize(s: S) { + return (s.slice(0, 1).toUpperCase() + s.slice(1)) as Capitalize; +} diff --git a/packages/grpc/src/write.ts b/packages/grpc/src/write.ts new file mode 100644 index 00000000000..bd23ba74dab --- /dev/null +++ b/packages/grpc/src/write.ts @@ -0,0 +1,174 @@ +import { + matchType, + ProtoDeclaration, + ProtoEnumDeclaration, + ProtoFieldDeclaration, + ProtoFile, + ProtoMessageDeclaration, + ProtoMethodDeclaration, + ProtoOneOfDeclaration, + ProtoServiceDeclaration, + ProtoType, +} from "./proto.js"; + +// This module defines how to emit the text representation of a ProtoFile AST. + +export const PROTO_HEADER = + '/* Generated by Microsoft CADL - Canonical API Definition Language */\n\nsyntax = "proto3";\n'; + +export function writeProtoFile(file: ProtoFile): string { + let result = PROTO_HEADER; + + if (file.package) result += `\npackage ${file.package};\n`; + + const opts = Object.entries(file.options); + for (const [name, valueData] of opts) { + const value = typeof valueData === "string" ? `"${valueData}"` : valueData.toString(); + result += `\noption (${name}) = ${value}`; + } + + // Give the declarations a little breathing room if options were provided + if (opts.length > 0) result += "\n"; + + for (const decl of file.declarations) { + result += "\n" + collect(writeDeclaration(decl)).join("\n") + "\n"; + } + + return result; +} + +function* writeDeclaration(decl: ProtoDeclaration): Iterable { + switch (decl.kind) { + case "message": + yield* writeMessage(decl); + return; + case "service": + yield* writeService(decl); + return; + case "field": + yield writeField(decl); + return; + case "oneof": + yield* writeOneOf(decl); + return; + case "enum": + yield* writeEnum(decl); + return; + case "method": + yield writeMethod(decl); + return; + default: + const __exhaust: never = decl; + throw __exhaust; + } +} + +function* writeMessage(decl: ProtoMessageDeclaration): Iterable { + const head = `message ${decl.name} {`; + const tail = "}"; + + if (decl.declarations.length > 0 || decl.reservations?.length) { + const { reservedNumbers, reservedNames } = selectMap( + decl.reservations ?? [], + (v) => (typeof v === "number" || Array.isArray(v) ? "reservedNumbers" : "reservedNames"), + { + reservedNumbers: (v) => (Array.isArray(v) ? v[0] + " to " + v[1] : v.toString()), + reservedNames: (v) => `"${v.toString()}"`, + } + ); + yield head; + if (reservedNumbers.length + reservedNames.length > 0) { + if (reservedNumbers.length > 0) yield ` reserved ${reservedNumbers.join(", ")};`; + if (reservedNames.length > 0) yield ` reserved ${reservedNames.join(", ")};`; + yield ""; + } + yield* indent(flatMap(decl.declarations, writeDeclaration)); + yield tail; + } else yield head + tail; +} + +function* writeService(decl: ProtoServiceDeclaration): Iterable { + const head = `service ${decl.name} {`; + const tail = "}"; + + if (decl.operations.length > 0) { + yield head; + yield* indent(flatMap(decl.operations, writeMethod)); + yield tail; + } else yield head + tail; +} + +function writeMethod(decl: ProtoMethodDeclaration): string { + return `rpc ${decl.name} (${writeType(decl.input)}) returns (${writeType(decl.returns)});`; +} + +function* writeOneOf(decl: ProtoOneOfDeclaration): Iterable { + // OneOf declarations must have at least one element, so no need to check for declarations + yield `oneof ${decl.name} {`; + yield* indent(flatMap(decl.declarations, writeDeclaration)); + yield "}"; +} + +function* writeEnum(decl: ProtoEnumDeclaration): Iterable { + yield `enum ${decl.name} {`; + yield* indent(flatMap(decl.variants, ([name, idx]) => `${name} = ${idx};`)); + yield "}"; +} + +function writeField(decl: ProtoFieldDeclaration): string { + const prefix = decl.repeated ? "repeated " : ""; + return prefix + `${writeType(decl.type)} ${decl.name} = ${decl.index};`; +} + +function writeType(type: ProtoType): string { + return matchType(type, { + map: (k, v) => `map<${k}, ${writeType(v)}>`, + ref: (r) => r, + scalar: (s) => s, + }); +} + +// #region utils + +function* indent(it: Iterable, depth: number = 2): Iterable { + for (const value of it) { + yield " ".repeat(depth) + value; + } +} + +function* flatMap(it: Iterable, f: (v: T1) => T2 | Iterable): Iterable { + for (const value of it) { + const result = f(value); + if (typeof result === "object" && result !== null && Symbol.iterator in result) { + yield* result as Iterable; + } else { + yield result as T2; + } + } +} + +function collect(it: Iterable): T[] { + const result = []; + + for (const value of it) result.push(value); + + return result; +} + +function selectMap unknown }>( + source: Iterable, + select: (v: TIn) => keyof Delegates, + delegates: Delegates +) { + const result = Object.fromEntries(Object.keys(delegates).map((k) => [k, []])) as unknown as { + [K in keyof Delegates]: ReturnType[]; + }; + for (const value of source) { + const k = select(value); + result[k].push(delegates[k](value) as any); + } + + return result; +} + +// #endregion diff --git a/packages/grpc/test/test.spec.ts b/packages/grpc/test/test.spec.ts new file mode 100644 index 00000000000..2b764cc8861 --- /dev/null +++ b/packages/grpc/test/test.spec.ts @@ -0,0 +1,3 @@ +it("test", function() { + throw new Error("Write some tests :)"); +}) diff --git a/packages/grpc/tsconfig.json b/packages/grpc/tsconfig.json new file mode 100644 index 00000000000..3723ffd27d0 --- /dev/null +++ b/packages/grpc/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../tsconfig.json", + "references": [ + { "path": "../compiler/tsconfig.json" }, + { "path": "../rest/tsconfig.json" }, + { "path": "../openapi/tsconfig.json" } + ], + "compilerOptions": { + "outDir": "dist", + "rootDir": ".", + "tsBuildInfoFile": "temp/tsconfig.tsbuildinfo", + "types": ["node", "mocha"] + }, + "include": ["src/**/*.ts", "test/**/*.ts"] +} diff --git a/rush.json b/rush.json index 961bbec5884..003bcd622f7 100644 --- a/rush.json +++ b/rush.json @@ -161,6 +161,12 @@ "projectFolder": "packages/bundler", "reviewCategory": "production", "shouldPublish": false + }, + { + "packageName": "@cadl-lang/grpc", + "projectFolder": "packages/grpc", + "reviewCategory": "production", + "shouldPublish": false } ] } From b8af1539fad6582270dea1ae23532fd7e07a23ea Mon Sep 17 00:00:00 2001 From: Will Date: Tue, 14 Jun 2022 17:22:55 -0400 Subject: [PATCH 02/50] Added a README --- packages/grpc/README.md | 28 ++++++++++++++++++++++++++++ packages/grpc/src/grpc.ts | 3 +++ packages/grpc/src/lib.ts | 3 +++ packages/grpc/src/proto.ts | 3 +++ packages/grpc/src/transform.ts | 3 +++ packages/grpc/src/write.ts | 3 +++ 6 files changed, 43 insertions(+) create mode 100644 packages/grpc/README.md diff --git a/packages/grpc/README.md b/packages/grpc/README.md new file mode 100644 index 00000000000..8f3b0f1ed66 --- /dev/null +++ b/packages/grpc/README.md @@ -0,0 +1,28 @@ +# Cadl gRPC library and emitter + +This package provides support for defining gRPC services in [Cadl](https://github.com/microsoft/cadl) and an emitter that generates Protobuf output from Cadl sources. + +## Install + +In your project root: + +```bash +npm install @cadl-lang/grpc +``` + +## Using the gRPC emitter + +1. Using the `cadl` CLI: + +```bash +cadl compile . --emit @cadl-lang/grpc +``` + +2. Using the Cadl project configuration file: + +Add the following to your `cadl-project.yaml` file. + +```yaml +emitters: + @cadl-lang/grpc: true +``` diff --git a/packages/grpc/src/grpc.ts b/packages/grpc/src/grpc.ts index 769a7f6f96f..6bace43d7ec 100644 --- a/packages/grpc/src/grpc.ts +++ b/packages/grpc/src/grpc.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { createDecoratorDefinition, DecoratorContext, diff --git a/packages/grpc/src/lib.ts b/packages/grpc/src/lib.ts index 64a5b8e30e9..146afe2136a 100644 --- a/packages/grpc/src/lib.ts +++ b/packages/grpc/src/lib.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { createCadlLibrary, paramMessage } from "@cadl-lang/compiler"; const { reportDiagnostic } = createCadlLibrary({ diff --git a/packages/grpc/src/proto.ts b/packages/grpc/src/proto.ts index d3705ca8f98..af8c012e3ae 100644 --- a/packages/grpc/src/proto.ts +++ b/packages/grpc/src/proto.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + /** * This module describes an AST for Protobuf. */ diff --git a/packages/grpc/src/transform.ts b/packages/grpc/src/transform.ts index cc41315e3b2..8413b9368d9 100644 --- a/packages/grpc/src/transform.ts +++ b/packages/grpc/src/transform.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { getIntrinsicModelName, InterfaceType, diff --git a/packages/grpc/src/write.ts b/packages/grpc/src/write.ts index bd23ba74dab..18635f5dd22 100644 --- a/packages/grpc/src/write.ts +++ b/packages/grpc/src/write.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { matchType, ProtoDeclaration, From df8b76bb6579064df23918e92116180e848c9ee5 Mon Sep 17 00:00:00 2001 From: Will Date: Tue, 14 Jun 2022 17:33:33 -0400 Subject: [PATCH 03/50] remove copied changelogs --- packages/grpc/CHANGELOG.json | 566 ----------------------------------- packages/grpc/CHANGELOG.md | 176 ----------- 2 files changed, 742 deletions(-) delete mode 100644 packages/grpc/CHANGELOG.json delete mode 100644 packages/grpc/CHANGELOG.md diff --git a/packages/grpc/CHANGELOG.json b/packages/grpc/CHANGELOG.json deleted file mode 100644 index 4c629c00737..00000000000 --- a/packages/grpc/CHANGELOG.json +++ /dev/null @@ -1,566 +0,0 @@ -{ - "name": "@cadl-lang/openapi3", - "entries": [ - { - "version": "0.11.0", - "tag": "@cadl-lang/openapi3_v0.11.0", - "date": "Fri, 06 May 2022 17:19:57 GMT", - "comments": { - "minor": [ - { - "comment": "Uptake change in compiler with children references" - }, - { - "comment": "Move decorators to `OpenAPI` namespace" - }, - { - "comment": "Uptake change to versioning library" - }, - { - "comment": "Remove node 14 support" - } - ], - "patch": [ - { - "comment": "Fix issue not excluding template models from derived models causing crash" - }, - { - "comment": "Fix duplicate `description` in parameters" - }, - { - "comment": "Rearrange some aspects of operation output in the OpenAPI emitter" - }, - { - "comment": "URI-encode refs" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.30.0` to `~0.31.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.13.0` to `~0.14.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.8.0` to `~0.9.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.4.0` to `~0.5.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.4.0` to `~0.5.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.30.0` to `~0.31.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.13.0` to `~0.14.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.8.0` to `~0.9.0`" - } - ] - } - }, - { - "version": "0.10.0", - "tag": "@cadl-lang/openapi3_v0.10.0", - "date": "Thu, 31 Mar 2022 17:10:49 GMT", - "comments": { - "minor": [ - { - "comment": "Include discriminator property in base schema with a boilerplace description" - }, - { - "comment": "Add support for `void` type" - }, - { - "comment": "Moved http response interpretation to @cadl-lang/rest library." - }, - { - "comment": "implement multiple response content types" - }, - { - "comment": "Uptake change to allow versioned dependency with unversioned service" - } - ], - "patch": [ - { - "comment": "Fix bug with number enums that reference `0`." - }, - { - "comment": "Use parent .model of ModelTypeProperty" - }, - { - "comment": "Support browser builds" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.29.0` to `~0.30.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.12.0` to `~0.13.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.7.0` to `~0.8.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.2` to `~0.4.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/eslint-config-cadl\" from `~0.2.0` to `~0.3.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.2` to `~0.4.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.29.0` to `~0.30.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.12.0` to `~0.13.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.7.0` to `~0.8.0`" - } - ] - } - }, - { - "version": "0.9.0", - "tag": "@cadl-lang/openapi3_v0.9.0", - "date": "Wed, 09 Mar 2022 17:42:09 GMT", - "comments": { - "minor": [ - { - "comment": "@doc and @summary will set the description and summary on extended primitive types" - }, - { - "comment": "Emit child models to OpenAPI when parent is emitted" - }, - { - "comment": "**Added** support for `@externalDocs` decorator" - }, - { - "comment": "Added support for `@knownValues` decorator" - }, - { - "comment": "@doc on service namespace set openapi description" - }, - { - "comment": "Uptake change to intrinsic types" - }, - { - "comment": "Fix issue where a model name the same as Cadl Intrinsic type would be treated the same." - } - ], - "patch": [ - { - "comment": "Fix duplicate parameter type definitions in OpenAPI 3 output" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.28.0` to `~0.29.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.11.0` to `~0.12.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.6.1` to `~0.7.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.1` to `~0.3.2`" - }, - { - "comment": "Updating dependency \"@cadl-lang/eslint-config-cadl\" from `~0.1.0` to `~0.2.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.1` to `~0.3.2`" - }, - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.28.0` to `~0.29.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.11.0` to `~0.12.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.6.1` to `~0.7.0`" - } - ] - } - }, - { - "version": "0.8.0", - "tag": "@cadl-lang/openapi3_v0.8.0", - "date": "Tue, 15 Feb 2022 22:35:02 GMT", - "comments": { - "patch": [ - { - "comment": "Add support for separate `@summary` from `@doc`" - } - ], - "minor": [ - { - "comment": "Add validation to oneOf decorator" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.27.0` to `~0.28.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.10.0` to `~0.11.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.6.0` to `~0.6.1`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.0` to `~0.3.1`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.3.0` to `~0.3.1`" - }, - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.27.0` to `~0.28.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.10.0` to `~0.11.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.6.0` to `~0.6.1`" - } - ] - } - }, - { - "version": "0.7.0", - "tag": "@cadl-lang/openapi3_v0.7.0", - "date": "Mon, 14 Feb 2022 03:01:07 GMT", - "comments": { - "minor": [ - { - "comment": "refactor status code handling to http library" - }, - { - "comment": "Take change in openapi upstream library" - }, - { - "comment": "Update decorators to take in api change" - } - ], - "patch": [ - { - "comment": "Bump dependency versions" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.26.0` to `~0.27.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.9.0` to `~0.10.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.5.1` to `~0.6.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.2.0` to `~0.3.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `~0.2.0` to `~0.3.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.26.0` to `~0.27.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.9.0` to `~0.10.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.5.1` to `~0.6.0`" - } - ] - } - }, - { - "version": "0.6.0", - "tag": "@cadl-lang/openapi3_v0.6.0", - "date": "Fri, 04 Feb 2022 18:00:18 GMT", - "comments": { - "minor": [ - { - "comment": "Support union values for status-code and content-type in responses" - }, - { - "comment": "Openapi3 support for discriminated unions" - }, - { - "comment": "openapi3 emitter support for @error decorator" - }, - { - "comment": "Configure for new emitter syntax" - }, - { - "comment": "Internals: switch to internal path manipulation" - }, - { - "comment": "Extracted decorators into own library `@cadl-lang/openapi`" - }, - { - "comment": "Uptake changes in @cadl-lang/rest library improving operation parameter handling" - }, - { - "comment": "Update cadl depdendencies to peerDependencies" - }, - { - "comment": "Add support for versioned services" - }, - { - "comment": "Add statusCode decorator for http status code" - } - ], - "patch": [ - { - "comment": "Adding @format decorator support for openapi3 to emit \"format\" for string types" - }, - { - "comment": "**Fix** Added support for nullable array `xzy[] | null`" - }, - { - "comment": "**Fix** issue with @body body: bytes producing `type: string, format: bytes` instead of `type: string, format: binary` for requests and responses" - }, - { - "comment": "Use assigned @friendlyName on model types when emitting schema definitions and refs" - }, - { - "comment": "Refactor and improve openapi3 return type tests" - }, - { - "comment": "Fix status code validation and other minor cleanup" - }, - { - "comment": "Support nullable in openapi3 emitter" - }, - { - "comment": "Renaming @format decorator to @pattern." - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.25.0` to `~0.26.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.8.0` to `~0.9.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.5.0` to `~0.5.1`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `0.1.0` to `0.2.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/versioning\" from `0.1.0` to `0.2.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `~0.25.0` to `~0.26.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `~0.8.0` to `~0.9.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/openapi\" from `~0.5.0` to `~0.5.1`" - } - ] - } - }, - { - "version": "0.5.0", - "tag": "@cadl-lang/openapi3_v0.5.0", - "date": "Thu, 16 Dec 2021 08:02:20 GMT", - "comments": { - "patch": [ - { - "comment": "Update openapi3 emitter to consume new Cadl.Rest route generation API" - } - ], - "minor": [ - { - "comment": "Generate anyOf or oneOf schemas for Cadl unions in openapi3" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.24.1` to `0.25.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `0.7.1` to `0.8.0`" - } - ] - } - }, - { - "version": "0.4.2", - "tag": "@cadl-lang/openapi3_v0.4.2", - "date": "Wed, 01 Dec 2021 22:56:11 GMT", - "comments": { - "patch": [ - { - "comment": "Add support for extension decorator on parameters and tests" - }, - { - "comment": "Add openapi3 support for Cadl safeint" - }, - { - "comment": "Add README" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.24.0` to `0.24.1`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `0.7.0` to `0.7.1`" - } - ] - } - }, - { - "version": "0.4.1", - "tag": "@cadl-lang/openapi3_v0.4.1", - "date": "Thu, 18 Nov 2021 13:58:15 GMT", - "comments": { - "patch": [ - { - "comment": "Enable operation generation from interfaces" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.23.0` to `0.24.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `0.6.4` to `0.7.0`" - } - ] - } - }, - { - "version": "0.4.0", - "tag": "@cadl-lang/openapi3_v0.4.0", - "date": "Thu, 11 Nov 2021 21:46:21 GMT", - "comments": { - "minor": [ - { - "comment": "**Added** Support for duration type" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.22.0` to `0.23.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `0.6.3` to `0.6.4`" - } - ] - } - }, - { - "version": "0.3.1", - "tag": "@cadl-lang/openapi3_v0.3.1", - "date": "Thu, 28 Oct 2021 21:17:50 GMT", - "comments": { - "patch": [ - { - "comment": "Use strict diagnostics" - }, - { - "comment": "Fix crash on empty enum in openapi3 emitter" - }, - { - "comment": "Set shared param definitions in components.parameters" - }, - { - "comment": "Fix param default to be in schema" - }, - { - "comment": "Fix handling of decorators on parameters in openapi3" - }, - { - "comment": "Fix generation of openapi3 response headers" - }, - { - "comment": "Define response body for primitive response type" - }, - { - "comment": "Remove management.azure.com service host default" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.21.0` to `0.22.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `0.6.2` to `0.6.3`" - } - ] - } - }, - { - "version": "0.3.0", - "tag": "@cadl-lang/openapi3_v0.3.0", - "date": "Fri, 15 Oct 2021 21:33:37 GMT", - "comments": { - "minor": [ - { - "comment": "**Added** Support for server default" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.20.0` to `0.21.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `0.6.1` to `0.6.2`" - } - ] - } - }, - { - "version": "0.2.0", - "tag": "@cadl-lang/openapi3_v0.2.0", - "date": "Fri, 17 Sep 2021 00:49:37 GMT", - "comments": { - "minor": [ - { - "comment": "Add emitter for OpenAPI 3.0" - }, - { - "comment": "Remove support for multiple inheritance" - } - ], - "patch": [ - { - "comment": "Adding changelog for openapi3 package" - }, - { - "comment": "Updates for cadl namespace addition" - }, - { - "comment": "This is a test" - }, - { - "comment": "Support for emitting `bytes` and new number types" - } - ], - "dependency": [ - { - "comment": "Updating dependency \"@cadl-lang/compiler\" from `0.19.0` to `0.20.0`" - }, - { - "comment": "Updating dependency \"@cadl-lang/rest\" from `0.6.0` to `0.6.1`" - } - ] - } - } - ] -} diff --git a/packages/grpc/CHANGELOG.md b/packages/grpc/CHANGELOG.md deleted file mode 100644 index 4e4422fa357..00000000000 --- a/packages/grpc/CHANGELOG.md +++ /dev/null @@ -1,176 +0,0 @@ -# Change Log - @cadl-lang/openapi3 - -This log was last generated on Fri, 06 May 2022 17:19:57 GMT and should not be manually modified. - -## 0.11.0 -Fri, 06 May 2022 17:19:57 GMT - -### Minor changes - -- Uptake change in compiler with children references -- Move decorators to `OpenAPI` namespace -- Uptake change to versioning library -- Remove node 14 support - -### Patches - -- Fix issue not excluding template models from derived models causing crash -- Fix duplicate `description` in parameters -- Rearrange some aspects of operation output in the OpenAPI emitter -- URI-encode refs - -## 0.10.0 -Thu, 31 Mar 2022 17:10:49 GMT - -### Minor changes - -- Include discriminator property in base schema with a boilerplace description -- Add support for `void` type -- Moved http response interpretation to @cadl-lang/rest library. -- implement multiple response content types -- Uptake change to allow versioned dependency with unversioned service - -### Patches - -- Fix bug with number enums that reference `0`. -- Use parent .model of ModelTypeProperty -- Support browser builds - -## 0.9.0 -Wed, 09 Mar 2022 17:42:09 GMT - -### Minor changes - -- @doc and @summary will set the description and summary on extended primitive types -- Emit child models to OpenAPI when parent is emitted -- **Added** support for `@externalDocs` decorator -- Added support for `@knownValues` decorator -- @doc on service namespace set openapi description -- Uptake change to intrinsic types -- Fix issue where a model name the same as Cadl Intrinsic type would be treated the same. - -### Patches - -- Fix duplicate parameter type definitions in OpenAPI 3 output - -## 0.8.0 -Tue, 15 Feb 2022 22:35:02 GMT - -### Minor changes - -- Add validation to oneOf decorator - -### Patches - -- Add support for separate `@summary` from `@doc` - -## 0.7.0 -Mon, 14 Feb 2022 03:01:07 GMT - -### Minor changes - -- refactor status code handling to http library -- Take change in openapi upstream library -- Update decorators to take in api change - -### Patches - -- Bump dependency versions - -## 0.6.0 -Fri, 04 Feb 2022 18:00:18 GMT - -### Minor changes - -- Support union values for status-code and content-type in responses -- Openapi3 support for discriminated unions -- openapi3 emitter support for @error decorator -- Configure for new emitter syntax -- Internals: switch to internal path manipulation -- Extracted decorators into own library `@cadl-lang/openapi` -- Uptake changes in @cadl-lang/rest library improving operation parameter handling -- Update cadl depdendencies to peerDependencies -- Add support for versioned services -- Add statusCode decorator for http status code - -### Patches - -- Adding @format decorator support for openapi3 to emit "format" for string types -- **Fix** Added support for nullable array `xzy[] | null` -- **Fix** issue with @body body: bytes producing `type: string, format: bytes` instead of `type: string, format: binary` for requests and responses -- Use assigned @friendlyName on model types when emitting schema definitions and refs -- Refactor and improve openapi3 return type tests -- Fix status code validation and other minor cleanup -- Support nullable in openapi3 emitter -- Renaming @format decorator to @pattern. - -## 0.5.0 -Thu, 16 Dec 2021 08:02:20 GMT - -### Minor changes - -- Generate anyOf or oneOf schemas for Cadl unions in openapi3 - -### Patches - -- Update openapi3 emitter to consume new Cadl.Rest route generation API - -## 0.4.2 -Wed, 01 Dec 2021 22:56:11 GMT - -### Patches - -- Add support for extension decorator on parameters and tests -- Add openapi3 support for Cadl safeint -- Add README - -## 0.4.1 -Thu, 18 Nov 2021 13:58:15 GMT - -### Patches - -- Enable operation generation from interfaces - -## 0.4.0 -Thu, 11 Nov 2021 21:46:21 GMT - -### Minor changes - -- **Added** Support for duration type - -## 0.3.1 -Thu, 28 Oct 2021 21:17:50 GMT - -### Patches - -- Use strict diagnostics -- Fix crash on empty enum in openapi3 emitter -- Set shared param definitions in components.parameters -- Fix param default to be in schema -- Fix handling of decorators on parameters in openapi3 -- Fix generation of openapi3 response headers -- Define response body for primitive response type -- Remove management.azure.com service host default - -## 0.3.0 -Fri, 15 Oct 2021 21:33:37 GMT - -### Minor changes - -- **Added** Support for server default - -## 0.2.0 -Fri, 17 Sep 2021 00:49:37 GMT - -### Minor changes - -- Add emitter for OpenAPI 3.0 -- Remove support for multiple inheritance - -### Patches - -- Adding changelog for openapi3 package -- Updates for cadl namespace addition -- This is a test -- Support for emitting `bytes` and new number types - From 5c3f3dc893e027e1931a83cca1ca3f749b1fcc94 Mon Sep 17 00:00:00 2001 From: Will Date: Tue, 14 Jun 2022 17:42:25 -0400 Subject: [PATCH 04/50] added fresh changelog.json --- packages/grpc/CHANGELOG.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 packages/grpc/CHANGELOG.json diff --git a/packages/grpc/CHANGELOG.json b/packages/grpc/CHANGELOG.json new file mode 100644 index 00000000000..0c3da0e0847 --- /dev/null +++ b/packages/grpc/CHANGELOG.json @@ -0,0 +1,4 @@ +{ + "name": "@cadl-lang/grpc", + "entries": [] +} From 18b76c0b7348e7bb1cb0c0aaf67c30803180a73f Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 07:42:32 -0400 Subject: [PATCH 05/50] Some cleanup, removed synthetic models --- packages/grpc/package.json | 8 +-- packages/grpc/src/grpc.ts | 7 +-- packages/grpc/src/transform.ts | 90 +++++++--------------------------- 3 files changed, 26 insertions(+), 79 deletions(-) diff --git a/packages/grpc/package.json b/packages/grpc/package.json index f03eef774e1..677576df7c3 100644 --- a/packages/grpc/package.json +++ b/packages/grpc/package.json @@ -16,9 +16,9 @@ "keywords": [ "cadl" ], - "main": "dist/lib.js", + "main": "dist/src/grpc.js", "type": "module", - "cadlMain": "dist/grpc.js", + "cadlMain": "dist/src/grpc.js", "scripts": { "clean": "rimraf ./dist ./temp", "build": "tsc -p .", @@ -40,6 +40,8 @@ "eslint": "^8.12.0", "mocha": "~9.2.0", "rimraf": "~3.0.2", - "typescript": "~4.7.2" + "typescript": "~4.7.2", + "micromatch": "~4.0.5", + "@types/micromatch": "~4.0.2" } } diff --git a/packages/grpc/src/grpc.ts b/packages/grpc/src/grpc.ts index 6bace43d7ec..e5d98577eff 100644 --- a/packages/grpc/src/grpc.ts +++ b/packages/grpc/src/grpc.ts @@ -7,7 +7,6 @@ import { ModelTypeProperty, NamespaceType, Program, - setDecoratorNamespace, Type, validateDecoratorTarget, } from "@cadl-lang/compiler"; @@ -139,7 +138,9 @@ export function $field(ctx: DecoratorContext, target: ModelTypeProperty, fieldIn export async function $onEmit(program: Program) { const emitter = createGrpcEmitter(program); - await emitter(/* TODO: options? */); + await emitter({ + outDir: program.compilerOptions.outputPath, + }); } -setDecoratorNamespace("Cadl.Grpc", $field, $package, $service); +export const namespace = "Cadl.Grpc"; diff --git a/packages/grpc/src/transform.ts b/packages/grpc/src/transform.ts index 8413b9368d9..0f751fe5b73 100644 --- a/packages/grpc/src/transform.ts +++ b/packages/grpc/src/transform.ts @@ -8,11 +8,9 @@ import { ModelType, ModelTypeProperty, NamespaceType, - Node, OperationType, Program, resolvePath, - SyntaxKind, Type, } from "@cadl-lang/compiler"; import { fieldIndexKey, packageKey, reportDiagnostic, serviceKey } from "./lib.js"; @@ -124,7 +122,7 @@ function cadlToProto(program: Program): ProtoFile[] { })(namespace); const declarations: ProtoFile["declarations"] = []; - const visitedTypes = new Set(); + const visitedTypes = new Set(); /** * Visits a model type, converting it into a message definition and adding it if it has not already been visited. @@ -132,24 +130,13 @@ function cadlToProto(program: Program): ProtoFile[] { */ function visitType(model: ModelType) { // TODO: when can the node be undefined? - if (model.node && !visitedTypes.has(model.node)) { - visitedTypes.add(model.node); + if (!visitedTypes.has(model)) { + visitedTypes.add(model); declarations.push(toMessage(model)); } } - function visitSynthetic(model: SyntheticModel) { - if (!visitedTypes.has(model.trueModelNode)) { - visitedTypes.add(model.trueModelNode); - declarations.push({ - kind: "message", - name: model.name, - declarations: model.properties.map(toField), - }); - } - } - - const effectiveModelTypeCache = new Map(); + const effectiveModelTypeCache = new Map(); // Each interface will be reified as a `service` declaration. for (const iface of serviceInterfaces) { @@ -347,72 +334,29 @@ function cadlToProto(program: Program): ProtoFile[] { function getEffectiveModelType( model: ModelType, - anonymousModelName?: string - ): SyntheticModel | undefined { + anonymousModelName: string + ): ModelType | undefined { if (effectiveModelTypeCache.has(model)) return effectiveModelTypeCache.get(model); - const properties = [...model.properties.values()]; - - const source = properties[0]?.sourceProperty?.node.parent; - - if ( - source && - source.kind === SyntaxKind.ModelStatement && - properties.length > 0 && - properties.every((p) => p.sourceProperty?.node.parent === source) - ) { - // TODO: horrible hack: id.sv? - const messageLike: SyntheticModel = { - name: (source as any).id.sv, - properties, - trueModelNode: source, - }; - - effectiveModelTypeCache.set(model, messageLike); - - visitSynthetic(messageLike); - return messageLike; - } else if (model.node && model.name === "" && anonymousModelName) { - const messageLike: SyntheticModel = { + let effectiveModel = program.checker.getEffectiveModelType(model); + + if (model.name === "") { + // Name the model automatically if it is anonymous + effectiveModel = program.checker.createAndFinishType({ + ...model, name: anonymousModelName, - properties, - trueModelNode: model.node, - }; + }); + } - effectiveModelTypeCache.set(model, messageLike); + visitType(effectiveModel); - visitSynthetic(messageLike); - return messageLike; - } + effectiveModelTypeCache.set(model, effectiveModel); - effectiveModelTypeCache.set(model, undefined); - return undefined; + return effectiveModel; } } } -/** - * A synthetic (created ad-hoc during transformation) model for conversion to a gRPC message. - * - * A synthetic model is named, whereas the underlying model may not be. - */ -interface SyntheticModel { - /** - * The message's model name. - */ - name: string; - - /** - * The property entries in the messag - */ - properties: ModelTypeProperty[]; - - /** - * The AST Node that this model is tied to (used for deduplication). - */ - trueModelNode: Node; -} - /** * Simple utility function to capitalize a string. */ From 88b3a6f4b48d024cf90848315eee7210bc707ec3 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 07:43:07 -0400 Subject: [PATCH 06/50] WIP testing system --- common/config/rush/pnpm-lock.yaml | 53 ++++++- packages/grpc/test/scenarios.spec.ts | 129 ++++++++++++++++++ .../test/scenarios/simple/input/main.cadl | 16 +++ packages/grpc/test/test.spec.ts | 3 - 4 files changed, 197 insertions(+), 4 deletions(-) create mode 100644 packages/grpc/test/scenarios.spec.ts create mode 100644 packages/grpc/test/scenarios/simple/input/main.cadl delete mode 100644 packages/grpc/test/test.spec.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index a882146c8f6..d4b92315b8d 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -64,6 +64,7 @@ specifiers: grammarkdown: ~3.1.2 js-yaml: ~4.1.0 lzutf8: ~0.6.1 + micromatch: ~4.0.5 mkdirp: ~1.0.4 mocha: ~9.2.0 monaco-editor: ~0.32.1 @@ -160,6 +161,7 @@ dependencies: grammarkdown: 3.1.2 js-yaml: 4.1.0 lzutf8: 0.6.2 + micromatch: 4.0.5 mkdirp: 1.0.4 mocha: 9.2.2 monaco-editor: 0.32.1 @@ -768,6 +770,10 @@ packages: resolution: {integrity: sha512-2TN6oiwtNjOezilFVl77zwdNPwQWaDBBCCWWxyo1ctiO3vAtd7H/aB/CBJdw9+kqq3+latD0SXoedIuHySSZWw==} dev: false + /@types/braces/3.0.1: + resolution: {integrity: sha512-+euflG6ygo4bn0JHtn4pYqcXwRtLvElQ7/nnjDu7iYG56H0+OhCd7d6Ug0IE3WcFpZozBKW2+80FUbv5QGk5AQ==} + dev: false + /@types/debounce/1.2.1: resolution: {integrity: sha512-epMsEE85fi4lfmJUH/89/iV/LI+F5CvNIvmgs5g5jYFPfhO2S/ae8WSsLOKWdwtoaZw9Q2IhJ4tQ5tFCcS/4HA==} dev: false @@ -780,6 +786,13 @@ packages: resolution: {integrity: sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==} dev: false + /@types/glob/7.2.0: + resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} + dependencies: + '@types/minimatch': 3.0.5 + '@types/node': 16.0.3 + dev: false + /@types/hoist-non-react-statics/3.3.1: resolution: {integrity: sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==} dependencies: @@ -803,6 +816,16 @@ packages: resolution: {integrity: sha512-j6G1e8DULJx3ONf6NdR5JiR2ZY3K3PaaqiEuKYkLQO0Czfi1AzrtjfnfCROyWGeDd5IVMKCwsgSmMip9OWijow==} dev: false + /@types/micromatch/4.0.2: + resolution: {integrity: sha512-oqXqVb0ci19GtH0vOA/U2TmHTcRY9kuZl4mqUxe0QmJAlIW13kzhuK5pi1i9+ngav8FjpSb9FVS/GE00GLX1VA==} + dependencies: + '@types/braces': 3.0.1 + dev: false + + /@types/minimatch/3.0.5: + resolution: {integrity: sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==} + dev: false + /@types/mkdirp/1.0.2: resolution: {integrity: sha512-o0K1tSO0Dx5X6xlU5F1D6625FawhC3dU3iqr25lluNv/+/QIVH8RLNEiVokgIZo+mz+87w/3Mkg/VvQS+J51fQ==} dependencies: @@ -1303,6 +1326,12 @@ packages: concat-map: 0.0.1 dev: false + /brace-expansion/2.0.1: + resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + dependencies: + balanced-match: 1.0.2 + dev: false + /braces/3.0.2: resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} engines: {node: '>=8'} @@ -2496,6 +2525,17 @@ packages: path-is-absolute: 1.0.1 dev: false + /glob/8.0.3: + resolution: {integrity: sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==} + engines: {node: '>=12'} + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 5.1.0 + once: 1.4.0 + dev: false + /globals/11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} engines: {node: '>=4'} @@ -3066,6 +3106,13 @@ packages: brace-expansion: 1.1.11 dev: false + /minimatch/5.1.0: + resolution: {integrity: sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + dev: false + /minimist/1.2.6: resolution: {integrity: sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==} dev: false @@ -4595,14 +4642,18 @@ packages: dev: false file:projects/grpc.tgz: - resolution: {integrity: sha512-cZxw8AU0va1CFX9dAfibid5SadMXzGurOpj3KaQjIW1nsKdcy9MTmLK/Q9WV0CFeRo8kr2x0ro8DIQ9NvTbDaQ==, tarball: file:projects/grpc.tgz} + resolution: {integrity: sha512-h1JixUmZBjCL7geOOpLJylYZG8VPAmqzNgLV3n7tjK4LNzT3eYEjd7V+qMYeUZPH/E9buQl2qy/4tSzIYSORpQ==, tarball: file:projects/grpc.tgz} name: '@rush-temp/grpc' version: 0.0.0 dependencies: + '@types/glob': 7.2.0 + '@types/micromatch': 4.0.2 '@types/mocha': 9.1.1 '@types/node': 16.0.3 c8: 7.11.3 eslint: 8.16.0 + glob: 8.0.3 + micromatch: 4.0.5 mocha: 9.2.2 rimraf: 3.0.2 typescript: 4.7.2 diff --git a/packages/grpc/test/scenarios.spec.ts b/packages/grpc/test/scenarios.spec.ts new file mode 100644 index 00000000000..553bf083241 --- /dev/null +++ b/packages/grpc/test/scenarios.spec.ts @@ -0,0 +1,129 @@ +import assert from "assert"; +import fs from "fs"; +import path from "path"; +import url from "url"; + +import micromatch from "micromatch"; + +import { CadlTestLibrary, createTestHost, resolveVirtualPath } from "@cadl-lang/compiler/testing"; + +const SCENARIOS_DIRECTORY = url.fileURLToPath(new url.URL("../../test/scenarios", import.meta.url)); + +const patternsToRecord = process.env.RECORD_SCENARIOS?.split(",") ?? []; + +const CadlGrpcTestLibrary: CadlTestLibrary = { + name: "@cadl-lang/grpc", + packageRoot: path.resolve(url.fileURLToPath(import.meta.url), "../../../"), + files: [ + { realDir: "", pattern: "package.json", virtualPath: "./node_modules/@cadl-lang/grpc" }, + { + realDir: "dist/src", + pattern: "*.js", + virtualPath: "./node_modules/@cadl-lang/grpc/dist/src", + }, + ], +}; + +describe("gRPC scenarios", function () { + const scenarios = fs + .readdirSync(SCENARIOS_DIRECTORY) + .map((dn) => path.join(SCENARIOS_DIRECTORY, dn)) + .filter((dn) => fs.statSync(dn).isDirectory()); + + for (const scenario of scenarios) { + const scenarioName = path.basename(scenario); + + it(scenarioName, async function () { + const inputFiles = await readdirRecursive(path.join(scenario, "input")); + const outputFiles = await doEmit(inputFiles); + + const shouldRecord = micromatch.isMatch(scenarioName, patternsToRecord); + + const expectationDirectory = path.resolve(scenario, "output"); + + if (shouldRecord) { + // Write new output to the scenario's output folder. + console.log("Should record :)"); + + await fs.promises.rm(expectationDirectory, { recursive: true, force: true }); + + await fs.promises.mkdir(expectationDirectory); + + for (const [fn, content] of Object.entries(outputFiles)) { + const fullPath = path.join(expectationDirectory, fn); + await fs.promises.writeFile(fullPath, content); + } + } else { + // It's an error if any file in the expected files is missing, if any file in the output files doesn't have a + // corresponding expectation, or if any file in the output files doesn't match its corresponding output file + // character for character. + const expectedFiles = await readdirRecursive(expectationDirectory); + + for (const fn of Object.keys(expectedFiles)) { + assert.ok( + Object.prototype.hasOwnProperty.call(outputFiles, fn), + `expected file ${fn} was not produced` + ); + } + + for (const [fn, content] of Object.entries(outputFiles)) { + const expectedContent = expectedFiles[fn]; + + assert.ok(expectedContent, `output file ${fn} has no corresponding expectation`); + + assert.strictEqual(content, expectedContent); + } + } + }); + } + + async function doEmit(files: Record): Promise> { + const baseOutputPath = resolveVirtualPath("test-output/"); + + const host = await createTestHost({ + libraries: [CadlGrpcTestLibrary], + }); + + for (const [fileName, content] of Object.entries(files)) { + host.addCadlFile(fileName, content); + } + + await host.compile("main.cadl", { + outputPath: baseOutputPath, + noEmit: false, + emitters: ["@cadl-lang/grpc"], + }); + + return Object.fromEntries( + [...host.fs.entries()] + .filter(([name]) => name.startsWith(baseOutputPath)) + .map(([name, value]) => [name.replace(baseOutputPath, ""), value]) + ); + } +}); + +// #region readdir recursive + +async function readdirRecursive(dir: string, base: string = dir): Promise> { + const res: Record = {}; + + for (const entry of (await fs.promises.readdir(dir)).map((e) => path.join(dir, e))) { + const stat = await fs.promises.stat(entry); + + if (stat.isDirectory()) { + for (const [name, content] of Object.entries(await readdirRecursive(entry, base))) { + res[name] = content; + } + } else if (stat.isFile()) { + const content = await (await fs.promises.readFile(entry)).toString("utf-8"); + + res[path.relative(base, entry)] = content; + } else { + throw new Error("Unsupported file type."); + } + } + + return res; +} + +// #endregion diff --git a/packages/grpc/test/scenarios/simple/input/main.cadl b/packages/grpc/test/scenarios/simple/input/main.cadl new file mode 100644 index 00000000000..940a47c7c42 --- /dev/null +++ b/packages/grpc/test/scenarios/simple/input/main.cadl @@ -0,0 +1,16 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@package("com.azure.test") +namespace Test; + +@service +interface Service { + foo(@field(1) testField: string): Output; +} + +model Output { + @field(1) testOutputField: int32; + @field(2) secondField: string; +} diff --git a/packages/grpc/test/test.spec.ts b/packages/grpc/test/test.spec.ts deleted file mode 100644 index 2b764cc8861..00000000000 --- a/packages/grpc/test/test.spec.ts +++ /dev/null @@ -1,3 +0,0 @@ -it("test", function() { - throw new Error("Write some tests :)"); -}) From 59a7c5c9c55444ffec3a31e13f6ea8b6b1ad6f0a Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 07:50:58 -0400 Subject: [PATCH 07/50] Recorded a test --- packages/grpc/test/scenarios.spec.ts | 98 ++++++++++--------- .../simple/output/com/azure/test.proto | 18 ++++ 2 files changed, 72 insertions(+), 44 deletions(-) create mode 100644 packages/grpc/test/scenarios/simple/output/com/azure/test.proto diff --git a/packages/grpc/test/scenarios.spec.ts b/packages/grpc/test/scenarios.spec.ts index 553bf083241..ea0d2d6428e 100644 --- a/packages/grpc/test/scenarios.spec.ts +++ b/packages/grpc/test/scenarios.spec.ts @@ -43,66 +43,78 @@ describe("gRPC scenarios", function () { if (shouldRecord) { // Write new output to the scenario's output folder. - console.log("Should record :)"); - await fs.promises.rm(expectationDirectory, { recursive: true, force: true }); - - await fs.promises.mkdir(expectationDirectory); - - for (const [fn, content] of Object.entries(outputFiles)) { - const fullPath = path.join(expectationDirectory, fn); - await fs.promises.writeFile(fullPath, content); - } + await writeExpectationDirectory(expectationDirectory, outputFiles); } else { // It's an error if any file in the expected files is missing, if any file in the output files doesn't have a // corresponding expectation, or if any file in the output files doesn't match its corresponding output file // character for character. const expectedFiles = await readdirRecursive(expectationDirectory); - for (const fn of Object.keys(expectedFiles)) { - assert.ok( - Object.prototype.hasOwnProperty.call(outputFiles, fn), - `expected file ${fn} was not produced` - ); - } - - for (const [fn, content] of Object.entries(outputFiles)) { - const expectedContent = expectedFiles[fn]; - - assert.ok(expectedContent, `output file ${fn} has no corresponding expectation`); - - assert.strictEqual(content, expectedContent); - } + assertFilesAsExpected(outputFiles, expectedFiles); } }); } +}); - async function doEmit(files: Record): Promise> { - const baseOutputPath = resolveVirtualPath("test-output/"); +async function doEmit(files: Record): Promise> { + const baseOutputPath = resolveVirtualPath("test-output/"); - const host = await createTestHost({ - libraries: [CadlGrpcTestLibrary], - }); + const host = await createTestHost({ + libraries: [CadlGrpcTestLibrary], + }); - for (const [fileName, content] of Object.entries(files)) { - host.addCadlFile(fileName, content); - } + for (const [fileName, content] of Object.entries(files)) { + host.addCadlFile(fileName, content); + } - await host.compile("main.cadl", { - outputPath: baseOutputPath, - noEmit: false, - emitters: ["@cadl-lang/grpc"], - }); + await host.compile("main.cadl", { + outputPath: baseOutputPath, + noEmit: false, + emitters: ["@cadl-lang/grpc"], + }); + + return Object.fromEntries( + [...host.fs.entries()] + .filter(([name]) => name.startsWith(baseOutputPath)) + .map(([name, value]) => [name.replace(baseOutputPath, ""), value]) + ); +} - return Object.fromEntries( - [...host.fs.entries()] - .filter(([name]) => name.startsWith(baseOutputPath)) - .map(([name, value]) => [name.replace(baseOutputPath, ""), value]) +function assertFilesAsExpected( + outputFiles: Record, + expectedFiles: Record +) { + for (const fn of Object.keys(expectedFiles)) { + assert.ok( + Object.prototype.hasOwnProperty.call(outputFiles, fn), + `expected file ${fn} was not produced` ); } -}); -// #region readdir recursive + for (const [fn, content] of Object.entries(outputFiles)) { + const expectedContent = expectedFiles[fn]; + + assert.ok(expectedContent, `output file ${fn} has no corresponding expectation`); + + assert.strictEqual(content, expectedContent); + } +} + +async function writeExpectationDirectory( + expectationDirectory: string, + outputFiles: Record +) { + await fs.promises.rm(expectationDirectory, { recursive: true, force: true }); + + await fs.promises.mkdir(expectationDirectory); + + for (const [fn, content] of Object.entries(outputFiles)) { + const fullPath = path.join(expectationDirectory, fn); + await fs.promises.mkdir(path.dirname(fullPath), { recursive: true }); + await fs.promises.writeFile(fullPath, content); + } +} async function readdirRecursive(dir: string, base: string = dir): Promise> { const res: Record = {}; @@ -125,5 +137,3 @@ async function readdirRecursive(dir: string, base: string = dir): Promise Date: Thu, 23 Jun 2022 08:01:59 -0400 Subject: [PATCH 08/50] Fixed bug bypassing effective type calculation. --- packages/grpc/src/transform.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/grpc/src/transform.ts b/packages/grpc/src/transform.ts index 0f751fe5b73..12527cfc8d6 100644 --- a/packages/grpc/src/transform.ts +++ b/packages/grpc/src/transform.ts @@ -340,7 +340,7 @@ function cadlToProto(program: Program): ProtoFile[] { let effectiveModel = program.checker.getEffectiveModelType(model); - if (model.name === "") { + if (effectiveModel.name === "") { // Name the model automatically if it is anonymous effectiveModel = program.checker.createAndFinishType({ ...model, From 186494f0dbb7700776ab7b43cb5a27c8df00436c Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 08:02:46 -0400 Subject: [PATCH 09/50] Made 'simple' even simpler. --- packages/grpc/test/scenarios/simple/input/main.cadl | 6 +++++- .../grpc/test/scenarios/simple/output/com/azure/test.proto | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/grpc/test/scenarios/simple/input/main.cadl b/packages/grpc/test/scenarios/simple/input/main.cadl index 940a47c7c42..63872f4e7ef 100644 --- a/packages/grpc/test/scenarios/simple/input/main.cadl +++ b/packages/grpc/test/scenarios/simple/input/main.cadl @@ -7,7 +7,11 @@ namespace Test; @service interface Service { - foo(@field(1) testField: string): Output; + foo(...Input): Output; +} + +model Input { + @field(1) testInputField: string; } model Output { diff --git a/packages/grpc/test/scenarios/simple/output/com/azure/test.proto b/packages/grpc/test/scenarios/simple/output/com/azure/test.proto index 11184559ae7..7f9a3dd8dc3 100644 --- a/packages/grpc/test/scenarios/simple/output/com/azure/test.proto +++ b/packages/grpc/test/scenarios/simple/output/com/azure/test.proto @@ -4,8 +4,8 @@ syntax = "proto3"; package com.azure.test; -message FooRequest { - string testField = 1; +message Input { + string testInputField = 1; } message Output { @@ -14,5 +14,5 @@ message Output { } service Service { - rpc foo (FooRequest) returns (Output); + rpc foo (Input) returns (Output); } From f0aa1ba1f0ef00c522f30edf63110a4b4d437a96 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 08:43:00 -0400 Subject: [PATCH 10/50] Added test for inferring message names from context --- .../inferred-message-names/input/main.cadl | 14 ++++++++++++++ .../output/com/azure/test.proto | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 packages/grpc/test/scenarios/inferred-message-names/input/main.cadl create mode 100644 packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto diff --git a/packages/grpc/test/scenarios/inferred-message-names/input/main.cadl b/packages/grpc/test/scenarios/inferred-message-names/input/main.cadl new file mode 100644 index 00000000000..bc4c5319121 --- /dev/null +++ b/packages/grpc/test/scenarios/inferred-message-names/input/main.cadl @@ -0,0 +1,14 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@package("com.azure.test") +namespace Test; + +@service +interface Service { + foo(@field(1) testInputField: string): { + @field(1) testOutputField: int32; + @field(2) secondField: string; + }; +} diff --git a/packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto b/packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto new file mode 100644 index 00000000000..83b7258309d --- /dev/null +++ b/packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto @@ -0,0 +1,18 @@ +/* Generated by Microsoft CADL - Canonical API Definition Language */ + +syntax = "proto3"; + +package com.azure.test; + +message FooRequest { + string testInputField = 1; +} + +message FooResponse { + int32 testOutputField = 1; + string secondField = 2; +} + +service Service { + rpc foo (FooRequest) returns (FooResponse); +} From afeb49fe5cd183ab90efb76c88c811170077e833 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 08:43:18 -0400 Subject: [PATCH 11/50] Supported output message name inference and refactored unreachable types. --- packages/grpc/src/proto.ts | 8 ++++++++ packages/grpc/src/transform.ts | 35 +++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/packages/grpc/src/proto.ts b/packages/grpc/src/proto.ts index af8c012e3ae..fb6c354839d 100644 --- a/packages/grpc/src/proto.ts +++ b/packages/grpc/src/proto.ts @@ -73,6 +73,7 @@ export type ScalarFixedName = `${"s" | ""}fixed${"32" | "64"}`; export const $scalar = Symbol("$scalar"); export const $ref = Symbol("$ref"); export const $map = Symbol("$map"); +export const $unreachable = Symbol("$unreachable"); /** * A map type. Map keys can be any integral or string type (any scalar except float, double, and bytes). @@ -117,6 +118,10 @@ export function map(k: ScalarIntegralName | "string", v: Exclude(type: ProtoType, pat: ProtoTypeMatchPattern); default: const __exhaust: never = type[0]; + if (type[0] === $unreachable) { + throw new Error(`Unreachable: ${type[1]}`); + } throw new Error(`Unreachable: matchType variant ${__exhaust}`); // unreachable } } diff --git a/packages/grpc/src/transform.ts b/packages/grpc/src/transform.ts index 12527cfc8d6..04ebf11cf4c 100644 --- a/packages/grpc/src/transform.ts +++ b/packages/grpc/src/transform.ts @@ -26,6 +26,7 @@ import { ref, scalar, ScalarIntegralName, + unreachable, } from "./proto.js"; import { writeProtoFile } from "./write.js"; @@ -159,7 +160,7 @@ function cadlToProto(program: Program): ProtoFile[] { kind: "method", name: operation.name, input: addInputParams(operation.parameters, operation.name), - returns: addReturnType(operation.returnType), + returns: addReturnType(operation.returnType, operation.name), }; } @@ -171,10 +172,13 @@ function cadlToProto(program: Program): ProtoFile[] { * @returns a reference to the model's message */ function addInputParams(paramsModel: ModelType, operationName: string): ProtoRef { - const messageLike = getEffectiveModelType(paramsModel, capitalize(operationName) + "Request"); + const effectiveModel = getEffectiveModelType( + paramsModel, + capitalize(operationName) + "Request" + ); - if (messageLike) { - return ref(messageLike.name); + if (effectiveModel) { + return ref(effectiveModel.name); } reportDiagnostic(program, { @@ -183,7 +187,7 @@ function cadlToProto(program: Program): ProtoFile[] { target: paramsModel, }); - return ref(""); + return unreachable("unsupported input type"); } /** @@ -191,9 +195,10 @@ function cadlToProto(program: Program): ProtoFile[] { * a reference to its name. * * @param t - the model to add + * @param operationName - the name of the originating operation, used to compute a synthetic model name if required * @returns a reference to the model's message */ - function addReturnType(t: Type): ProtoRef { + function addReturnType(t: Type, operationName: string): ProtoRef { /* TODO: need to support importing google/protobuf/empty.proto and others This is also very important for handling datetime values. @@ -204,14 +209,18 @@ function cadlToProto(program: Program): ProtoFile[] { switch (t.kind) { case "Model": - visitType(t); - return ref(t.name); + const effectiveModel = getEffectiveModelType(t, capitalize(operationName) + "Response"); + if (effectiveModel) { + return ref(effectiveModel.name); + } + // eslint-disable-next-line no-fallthrough default: reportDiagnostic(program, { code: "unsupported-return-type", target: t, }); - return ref(""); + + return unreachable("unsupported return type"); } } @@ -246,7 +255,7 @@ function cadlToProto(program: Program): ProtoFile[] { }, target: t, }); - return ref(""); + return unreachable("unsupported field type"); } } @@ -257,7 +266,7 @@ function cadlToProto(program: Program): ProtoFile[] { const [keyType, valueType] = t.templateArguments ?? []; // This is a core compile error. - if (!keyType || !valueType) return ref(""); + if (!keyType || !valueType) return unreachable("nonexistent map key or value type"); const keyProto = addType(keyType); const valueProto = addType(valueType); @@ -269,7 +278,7 @@ function cadlToProto(program: Program): ProtoFile[] { messageId: "recursive-map", target: valueType, }); - return ref(""); + return unreachable("recursive map"); } return map(keyProto[1] as "string" | ScalarIntegralName, valueProto); @@ -297,7 +306,7 @@ function cadlToProto(program: Program): ProtoFile[] { }, target: t, }); - return ref(""); + return unreachable("unknown intrinsic"); } return protoType; From b6042542301f397431b468b050c0ec6da59b7215 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 09:44:09 -0400 Subject: [PATCH 12/50] Unleaked discriminated union tags. --- packages/grpc/src/transform.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/grpc/src/transform.ts b/packages/grpc/src/transform.ts index 04ebf11cf4c..be99c49c5d1 100644 --- a/packages/grpc/src/transform.ts +++ b/packages/grpc/src/transform.ts @@ -15,13 +15,13 @@ import { } from "@cadl-lang/compiler"; import { fieldIndexKey, packageKey, reportDiagnostic, serviceKey } from "./lib.js"; import { - $map, map, ProtoFieldDeclaration, ProtoFile, ProtoMessageDeclaration, ProtoMethodDeclaration, ProtoRef, + ProtoScalar, ProtoType, ref, scalar, @@ -236,6 +236,8 @@ function cadlToProto(program: Program): ProtoFile[] { // TODO: streams. + // TODO: reject anonymous models at this stage + switch (t.kind) { case "Model": visitType(t); @@ -261,18 +263,12 @@ function cadlToProto(program: Program): ProtoFile[] { function intrinsicToProto(name: string, t: Type): ProtoType { // Maps are considered intrinsics, so we check if the type is an instance of Cadl.Map - if (t.kind === "Model" && t.name === "Map" && t.namespace?.name === "Cadl") { + if (isMap(t)) { // Intrinsic map. - const [keyType, valueType] = t.templateArguments ?? []; - - // This is a core compile error. - if (!keyType || !valueType) return unreachable("nonexistent map key or value type"); - - const keyProto = addType(keyType); - const valueProto = addType(valueType); + const [keyType, valueType] = (t as ModelType).templateArguments ?? []; // A map's value cannot be another map. - if (valueProto[0] === $map) { + if (isMap(valueType)) { reportDiagnostic(program, { code: "unsupported-field-type", messageId: "recursive-map", @@ -281,6 +277,12 @@ function cadlToProto(program: Program): ProtoFile[] { return unreachable("recursive map"); } + // This is a core compile error. + if (!keyType || !valueType) return unreachable("nonexistent map key or value type"); + + const keyProto = addType(keyType); + const valueProto = addType(valueType) as ProtoRef | ProtoScalar; + return map(keyProto[1] as "string" | ScalarIntegralName, valueProto); } @@ -366,6 +368,10 @@ function cadlToProto(program: Program): ProtoFile[] { } } +function isMap(t: Type) { + return t.kind === "Model" && t.name === "Map" && t.namespace?.name === "Cadl"; +} + /** * Simple utility function to capitalize a string. */ From 375e447ae54f512fd3d319be56633811f1a11f86 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 09:59:45 -0400 Subject: [PATCH 13/50] Updated some documentation. --- packages/grpc/src/proto.ts | 21 +++++++++++---------- packages/grpc/src/write.ts | 34 +++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/packages/grpc/src/proto.ts b/packages/grpc/src/proto.ts index fb6c354839d..84a32536e01 100644 --- a/packages/grpc/src/proto.ts +++ b/packages/grpc/src/proto.ts @@ -70,10 +70,10 @@ export type ScalarIntegerName = `${"u" | "s" | ""}int${"32" | "64"}`; export type ScalarFixedName = `${"s" | ""}fixed${"32" | "64"}`; // Symbols for type destructuring -export const $scalar = Symbol("$scalar"); -export const $ref = Symbol("$ref"); -export const $map = Symbol("$map"); -export const $unreachable = Symbol("$unreachable"); +const $scalar = Symbol("$scalar"); +const $ref = Symbol("$ref"); +const $map = Symbol("$map"); +const $unreachable = Symbol("$unreachable"); /** * A map type. Map keys can be any integral or string type (any scalar except float, double, and bytes). @@ -135,23 +135,24 @@ export interface ProtoTypeMatchPattern { * A helper function that matches and delegates a Protobuf type to a handler per type. * * @param type - the Protobuf type to match and delegate - * @param pat + * @param pattern - the matching pattern of delegates to apply * @returns */ -export function matchType(type: ProtoType, pat: ProtoTypeMatchPattern): Result { +export function matchType(type: ProtoType, pattern: ProtoTypeMatchPattern): Result { switch (type[0]) { case $ref: - return pat.ref(type[1]); + return pattern.ref(type[1]); case $scalar: - return pat.scalar(type[1]); + return pattern.scalar(type[1]); case $map: - return pat.map(type[1], type[2] as Exclude); + return pattern.map(type[1], type[2] as Exclude); default: const __exhaust: never = type[0]; if (type[0] === $unreachable) { + // This might happen if we produce an `$unreachable`-tagged type without preventing emit. throw new Error(`Unreachable: ${type[1]}`); } - throw new Error(`Unreachable: matchType variant ${__exhaust}`); // unreachable + throw new Error(`Unreachable: matchType variant ${__exhaust}`); } } diff --git a/packages/grpc/src/write.ts b/packages/grpc/src/write.ts index 18635f5dd22..58a9dc4e78a 100644 --- a/packages/grpc/src/write.ts +++ b/packages/grpc/src/write.ts @@ -133,12 +133,25 @@ function writeType(type: ProtoType): string { // #region utils +/** + * Indents an iterable of strings by prepending an amount of spaces to each item + * in the iterable. + * + * @param it - the string iterable to indent + * @param depth - the indentation depth in spaces, defaults to 2 + */ function* indent(it: Iterable, depth: number = 2): Iterable { for (const value of it) { yield " ".repeat(depth) + value; } } +/** + * A version of flatMap that works with generic iterables. + * + * @param it - the iterable to flatten and map + * @param f - the function to run on the items of `it` + */ function* flatMap(it: Iterable, f: (v: T1) => T2 | Iterable): Iterable { for (const value of it) { const result = f(value); @@ -150,14 +163,25 @@ function* flatMap(it: Iterable, f: (v: T1) => T2 | Iterable): It } } +/** + * Collects an iterable into an array. Having this as a callable function is useful for writing functional combinations. + * + * @param it - the iterable to collect + * @returns an array with all the items in the iterable + */ function collect(it: Iterable): T[] { - const result = []; - - for (const value of it) result.push(value); - - return result; + return [...it]; } +/** + * A helper function that allows categorizing items from an iterable into groups and running a different map function + * for each group. + * + * @param source - the iterable to apply the selection and mapping to + * @param select - a function that is applied to each item and produces a selector + * @param delegates - a record of selectors to mapping functions + * @returns a record of selectors to arrays of results produced by each delegate + */ function selectMap unknown }>( source: Iterable, select: (v: TIn) => keyof Delegates, From 4e7d0474714b5b50acb7c84c72566fb64578590b Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 10:04:03 -0400 Subject: [PATCH 14/50] Capitalize method names, remove space between method name and input type. --- packages/grpc/src/transform.ts | 2 +- packages/grpc/src/write.ts | 2 +- .../inferred-message-names/output/com/azure/test.proto | 2 +- packages/grpc/test/scenarios/simple/output/com/azure/test.proto | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/grpc/src/transform.ts b/packages/grpc/src/transform.ts index be99c49c5d1..e5238c794c2 100644 --- a/packages/grpc/src/transform.ts +++ b/packages/grpc/src/transform.ts @@ -158,7 +158,7 @@ function cadlToProto(program: Program): ProtoFile[] { function toMethodFromOperation(operation: OperationType): ProtoMethodDeclaration { return { kind: "method", - name: operation.name, + name: capitalize(operation.name), input: addInputParams(operation.parameters, operation.name), returns: addReturnType(operation.returnType, operation.name), }; diff --git a/packages/grpc/src/write.ts b/packages/grpc/src/write.ts index 58a9dc4e78a..5838aae2d30 100644 --- a/packages/grpc/src/write.ts +++ b/packages/grpc/src/write.ts @@ -102,7 +102,7 @@ function* writeService(decl: ProtoServiceDeclaration): Iterable { } function writeMethod(decl: ProtoMethodDeclaration): string { - return `rpc ${decl.name} (${writeType(decl.input)}) returns (${writeType(decl.returns)});`; + return `rpc ${decl.name}(${writeType(decl.input)}) returns (${writeType(decl.returns)});`; } function* writeOneOf(decl: ProtoOneOfDeclaration): Iterable { diff --git a/packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto b/packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto index 83b7258309d..f9a05a14dd7 100644 --- a/packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto +++ b/packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto @@ -14,5 +14,5 @@ message FooResponse { } service Service { - rpc foo (FooRequest) returns (FooResponse); + rpc Foo(FooRequest) returns (FooResponse); } diff --git a/packages/grpc/test/scenarios/simple/output/com/azure/test.proto b/packages/grpc/test/scenarios/simple/output/com/azure/test.proto index 7f9a3dd8dc3..d668d7ae43a 100644 --- a/packages/grpc/test/scenarios/simple/output/com/azure/test.proto +++ b/packages/grpc/test/scenarios/simple/output/com/azure/test.proto @@ -14,5 +14,5 @@ message Output { } service Service { - rpc foo (Input) returns (Output); + rpc Foo(Input) returns (Output); } From ba8da030cd299f36a2b790d291616cb144b8733c Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 10:06:48 -0400 Subject: [PATCH 15/50] Tweaked proto header --- packages/grpc/src/write.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/grpc/src/write.ts b/packages/grpc/src/write.ts index 5838aae2d30..177a75aafc8 100644 --- a/packages/grpc/src/write.ts +++ b/packages/grpc/src/write.ts @@ -16,8 +16,10 @@ import { // This module defines how to emit the text representation of a ProtoFile AST. -export const PROTO_HEADER = - '/* Generated by Microsoft CADL - Canonical API Definition Language */\n\nsyntax = "proto3";\n'; +export const PROTO_HEADER = `/* Generated by Microsoft CADL - Canonical API Definition Language */ + +syntax = "proto3"; +`; export function writeProtoFile(file: ProtoFile): string { let result = PROTO_HEADER; From 792cf874bea36561ff6d8da3772af7b0e69a3206 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 10:10:47 -0400 Subject: [PATCH 16/50] Extracted writing reservations into own function --- packages/grpc/src/write.ts | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/grpc/src/write.ts b/packages/grpc/src/write.ts index 177a75aafc8..e945e29328f 100644 --- a/packages/grpc/src/write.ts +++ b/packages/grpc/src/write.ts @@ -73,25 +73,30 @@ function* writeMessage(decl: ProtoMessageDeclaration): Iterable { const tail = "}"; if (decl.declarations.length > 0 || decl.reservations?.length) { - const { reservedNumbers, reservedNames } = selectMap( - decl.reservations ?? [], - (v) => (typeof v === "number" || Array.isArray(v) ? "reservedNumbers" : "reservedNames"), - { - reservedNumbers: (v) => (Array.isArray(v) ? v[0] + " to " + v[1] : v.toString()), - reservedNames: (v) => `"${v.toString()}"`, - } - ); yield head; - if (reservedNumbers.length + reservedNames.length > 0) { - if (reservedNumbers.length > 0) yield ` reserved ${reservedNumbers.join(", ")};`; - if (reservedNames.length > 0) yield ` reserved ${reservedNames.join(", ")};`; - yield ""; - } + yield* indent(writeReservations(decl)); yield* indent(flatMap(decl.declarations, writeDeclaration)); yield tail; } else yield head + tail; } +function* writeReservations(decl: ProtoMessageDeclaration): Iterable { + const { reservedNumbers, reservedNames } = selectMap( + decl.reservations ?? [], + (v) => (typeof v === "number" || Array.isArray(v) ? "reservedNumbers" : "reservedNames"), + { + reservedNumbers: (v) => (Array.isArray(v) ? v[0] + " to " + v[1] : v.toString()), + reservedNames: (v) => `"${v.toString()}"`, + } + ); + + if (reservedNumbers.length + reservedNames.length > 0) { + if (reservedNumbers.length > 0) yield `reserved ${reservedNumbers.join(", ")};`; + if (reservedNames.length > 0) yield `reserved ${reservedNames.join(", ")};`; + yield ""; + } +} + function* writeService(decl: ProtoServiceDeclaration): Iterable { const head = `service ${decl.name} {`; const tail = "}"; @@ -144,7 +149,9 @@ function writeType(type: ProtoType): string { */ function* indent(it: Iterable, depth: number = 2): Iterable { for (const value of it) { - yield " ".repeat(depth) + value; + if (value !== "") { + yield " ".repeat(depth) + value; + } else yield value; } } From f51d3bbf89a6f27e93ff5299bd06f2c73013d9b0 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 12:13:37 -0400 Subject: [PATCH 17/50] Taught the expectation system to look for diagnostics. --- packages/grpc/test/scenarios.spec.ts | 69 +++++++++++++++---- .../scenarios/simple-error/diagnostics.txt | 0 .../scenarios/simple-error/input/main.cadl | 20 ++++++ 3 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 packages/grpc/test/scenarios/simple-error/diagnostics.txt create mode 100644 packages/grpc/test/scenarios/simple-error/input/main.cadl diff --git a/packages/grpc/test/scenarios.spec.ts b/packages/grpc/test/scenarios.spec.ts index 71f6951bd94..d64fe7dcaed 100644 --- a/packages/grpc/test/scenarios.spec.ts +++ b/packages/grpc/test/scenarios.spec.ts @@ -5,6 +5,7 @@ import url from "url"; import micromatch from "micromatch"; +import { formatDiagnostic } from "@cadl-lang/compiler"; import { CadlTestLibrary, createTestHost, resolveVirtualPath } from "@cadl-lang/compiler/testing"; const SCENARIOS_DIRECTORY = url.fileURLToPath(new url.URL("../../test/scenarios", import.meta.url)); @@ -35,29 +36,63 @@ describe("gRPC scenarios", function () { it(scenarioName, async function () { const inputFiles = await readdirRecursive(path.join(scenario, "input")); - const outputFiles = await doEmit(inputFiles); + const emitResult = await doEmit(inputFiles); const shouldRecord = micromatch.isMatch(scenarioName, patternsToRecord); const expectationDirectory = path.resolve(scenario, "output"); + const diagnosticsExpectationPath = path.resolve(scenario, "diagnostics.txt"); if (shouldRecord) { // Write new output to the scenario's output folder. - await writeExpectationDirectory(expectationDirectory, outputFiles); + await writeExpectationDirectory(expectationDirectory, emitResult.files); + + if (emitResult.diagnostics.length > 0) { + const diagnostics = emitResult.diagnostics.join("\n"); + + await fs.promises.writeFile(diagnosticsExpectationPath, diagnostics); + } } else { // It's an error if any file in the expected files is missing, if any file in the output files doesn't have a // corresponding expectation, or if any file in the output files doesn't match its corresponding output file // character for character. - const expectedFiles = await readdirRecursive(expectationDirectory); - assertFilesAsExpected(outputFiles, expectedFiles); + // `throwIfNoEntry` is not supported with promisified fs.promises.stat. + if (!fs.statSync(expectationDirectory, { throwIfNoEntry: false })) { + assert.strictEqual( + Object.entries(emitResult.files).length, + 0, + "no expectations exist, but output files were generated" + ); + } else { + const expectedFiles = await readdirRecursive(expectationDirectory); + + assertFilesAsExpected(emitResult.files, expectedFiles); + } + + if (emitResult.diagnostics.length > 0) { + // Check the diagnostics. + + const diagnostics = emitResult.diagnostics.join("\n"); + + const expectedDiagnostics = await ( + await fs.promises.readFile(diagnosticsExpectationPath) + ).toString("utf-8"); + + assert.strictEqual(diagnostics, expectedDiagnostics); + } } }); } }); -async function doEmit(files: Record): Promise> { +interface EmitResult { + files: Record; + diagnostics: string[]; +} + +async function doEmit(files: Record): Promise { const baseOutputPath = resolveVirtualPath("test-output/"); const host = await createTestHost({ @@ -68,7 +103,7 @@ async function doEmit(files: Record): Promise): Promise name.startsWith(baseOutputPath)) - .map(([name, value]) => [name.replace(baseOutputPath, ""), value]) - ); + return { + files: Object.fromEntries( + [...host.fs.entries()] + .filter(([name]) => name.startsWith(baseOutputPath)) + .map(([name, value]) => [name.replace(baseOutputPath, ""), value]) + ), + diagnostics: diagnostics.map(formatDiagnostic), + }; } function assertFilesAsExpected( @@ -109,11 +147,18 @@ async function writeExpectationDirectory( expectationDirectory: string, outputFiles: Record ) { + const fileEntries = Object.entries(outputFiles); + + // It'll be annoying to fiddle with .gitkeep files, so let's omit the `output` directory if it's empty. + if (fileEntries.length === 0) { + return; + } + await fs.promises.rm(expectationDirectory, { recursive: true, force: true }); await fs.promises.mkdir(expectationDirectory); - for (const [fn, content] of Object.entries(outputFiles)) { + for (const [fn, content] of fileEntries) { const fullPath = path.join(expectationDirectory, fn); await fs.promises.mkdir(path.dirname(fullPath), { recursive: true }); await fs.promises.writeFile(fullPath, content); diff --git a/packages/grpc/test/scenarios/simple-error/diagnostics.txt b/packages/grpc/test/scenarios/simple-error/diagnostics.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/grpc/test/scenarios/simple-error/input/main.cadl b/packages/grpc/test/scenarios/simple-error/input/main.cadl new file mode 100644 index 00000000000..822af2b7649 --- /dev/null +++ b/packages/grpc/test/scenarios/simple-error/input/main.cadl @@ -0,0 +1,20 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@package("com.azure.test") +namespace Test; + +@service +interface Service { + foo(...Input): Output; +} + +model Input { + @field(0) testInputField: string; +} + +model Output { + @field(1) testOutputField: int32; + @field(2) secondField: string; +} From 91943e4e1a6ac657b79abfd5cda3b2c88eabb30a Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 12:13:47 -0400 Subject: [PATCH 18/50] Check for namespace collisions. --- packages/grpc/src/grpc.ts | 2 ++ packages/grpc/src/lib.ts | 6 +++++ packages/grpc/src/proto.ts | 15 ++++++++----- packages/grpc/src/transform.ts | 40 +++++++++++++++++++++++++++------- packages/grpc/src/write.ts | 3 +++ 5 files changed, 53 insertions(+), 13 deletions(-) diff --git a/packages/grpc/src/grpc.ts b/packages/grpc/src/grpc.ts index 9cc28e4c0bc..1e378f5078f 100644 --- a/packages/grpc/src/grpc.ts +++ b/packages/grpc/src/grpc.ts @@ -51,6 +51,8 @@ export function $package(ctx: DecoratorContext, target: NamespaceType, name: str return; } + // TODO: validate package name is acceptable + ctx.program.stateMap(packageKey).set(target, name); } diff --git a/packages/grpc/src/lib.ts b/packages/grpc/src/lib.ts index c87a2991e47..129dd6a4443 100644 --- a/packages/grpc/src/lib.ts +++ b/packages/grpc/src/lib.ts @@ -62,6 +62,12 @@ export const CadlGrpcLibrary = createCadlLibrary({ "recursive-map": "a protobuf map's 'value' type may not refer to another map", }, }, + "namespace-collision": { + severity: "error", + messages: { + default: paramMessage`the package name ${"name"} has already been used`, + }, + }, }, emitter: { options: EmitterOptionsSchema }, }); diff --git a/packages/grpc/src/proto.ts b/packages/grpc/src/proto.ts index 84a32536e01..815ecdb8c13 100644 --- a/packages/grpc/src/proto.ts +++ b/packages/grpc/src/proto.ts @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { NamespaceType } from "@cadl-lang/compiler"; + /** * This module describes an AST for Protobuf. */ @@ -24,6 +26,11 @@ export interface ProtoFile { * Only `service` and `message` declarations may exist at the root of the file. */ declarations: Array; + + /** + * The original namespace node from which this ProtoFile originated. + */ + source: NamespaceType; } /** @@ -181,7 +188,9 @@ export interface ProtoMethodDeclaration { export interface ProtoMessageDeclaration { kind: "message"; name: string; - declarations: Array; + declarations: Array< + ProtoFieldDeclaration | ProtoMessageDeclaration | ProtoOneOfDeclaration | ProtoEnumDeclaration + >; reservations?: Array; } @@ -219,10 +228,6 @@ export interface ProtoOneOfDeclaration { /** * An `enum` declaration. - * - * TODO: this node type is currently disconnected from the proto AST. Can this - * appear anywhere other than messages? Do we need to emit it _directly_ before - * it's used? */ export interface ProtoEnumDeclaration { kind: "enum"; diff --git a/packages/grpc/src/transform.ts b/packages/grpc/src/transform.ts index ed77e344605..c0045f17061 100644 --- a/packages/grpc/src/transform.ts +++ b/packages/grpc/src/transform.ts @@ -57,7 +57,9 @@ export function createGrpcEmitter( for (const file of files) { // If the file has a package, emit it to a path that is shaped like the package name. Otherwise emit to // main.proto - // TODO: What do we do if there are multiple files without packages, or multiple files with the same package? + + // Collisions have already been detected. + const packageSlug = file.package?.split(".") ?? ["main"]; const filePath = resolvePath(outDir, ...packageSlug.slice(0, -1)); @@ -80,15 +82,20 @@ function cadlToProto(program: Program): ProtoFile[] { const packages = program.stateMap(packageKey) as Map; // Emit a file per package. - return [...packages].map( + const files = [...packages].map( ([namespace, packageName]) => ({ package: packageName, options: {}, declarations: declarationsFromNamespace(namespace), + source: namespace, } as ProtoFile) ); + checkForNamespaceCollisions(files); + + return files; + /** * Recursively searches a namespace for declarations that should be reified as Protobuf. * @@ -194,13 +201,14 @@ function cadlToProto(program: Program): ProtoFile[] { * @returns a reference to the model's message */ function addReturnType(t: Type, operationName: string): ProtoRef { - /* TODO: need to support importing google/protobuf/empty.proto and others - This is also very important for handling datetime values. + // TODO: need to support importing google/protobuf/empty.proto and others + // https://github.com/microsoft/cadl/issues/630 - if (t.kind === "Intrinsic" && t.name === "void") { - return ref("google.protobuf.Empty"); - } - */ + // This is also very important for handling datetime values. + + // if (t.kind === "Intrinsic" && t.name === "void") { + // return ref("google.protobuf.Empty"); + // } switch (t.kind) { case "Model": @@ -364,6 +372,22 @@ function cadlToProto(program: Program): ProtoFile[] { } // #endregion } + + function checkForNamespaceCollisions(files: ProtoFile[]) { + const namespaces = new Set(); + + for (const file of files) { + if (namespaces.has(file.package)) { + reportDiagnostic(program, { + code: "namespace-collision", + format: { + name: `"${file.package}"` ?? "", + }, + target: file.source, + }); + } + } + } } function isMap(t: Type) { diff --git a/packages/grpc/src/write.ts b/packages/grpc/src/write.ts index e945e29328f..6e5d77c09bd 100644 --- a/packages/grpc/src/write.ts +++ b/packages/grpc/src/write.ts @@ -121,6 +121,9 @@ function* writeOneOf(decl: ProtoOneOfDeclaration): Iterable { function* writeEnum(decl: ProtoEnumDeclaration): Iterable { yield `enum ${decl.name} {`; + if (decl.allowAlias) { + yield " option allow_alias = true;"; + } yield* indent(flatMap(decl.variants, ([name, idx]) => `${name} = ${idx};`)); yield "}"; } From ac1b6395b466b5d7c69e4658be2ff1095fce1641 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 23 Jun 2022 12:44:01 -0400 Subject: [PATCH 19/50] Fixed simple-error test --- .../test/scenarios/simple-error/diagnostics.txt | 1 + .../test/scenarios/simple-error/input/main.cadl | 14 +++----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/grpc/test/scenarios/simple-error/diagnostics.txt b/packages/grpc/test/scenarios/simple-error/diagnostics.txt index e69de29bb2d..67dbe438a22 100644 --- a/packages/grpc/test/scenarios/simple-error/diagnostics.txt +++ b/packages/grpc/test/scenarios/simple-error/diagnostics.txt @@ -0,0 +1 @@ +/test/main.cadl:11:7 - error cadl-grpc/field-index: field index 0 is invalid (must be an integer greater than zero) diff --git a/packages/grpc/test/scenarios/simple-error/input/main.cadl b/packages/grpc/test/scenarios/simple-error/input/main.cadl index 822af2b7649..a4e2882ee61 100644 --- a/packages/grpc/test/scenarios/simple-error/input/main.cadl +++ b/packages/grpc/test/scenarios/simple-error/input/main.cadl @@ -2,19 +2,11 @@ import "@cadl-lang/grpc"; using Cadl.Grpc; -@package("com.azure.test") +@package namespace Test; @service interface Service { - foo(...Input): Output; -} - -model Input { - @field(0) testInputField: string; -} - -model Output { - @field(1) testOutputField: int32; - @field(2) secondField: string; + // invalid field index + foo(@field(0) testInputField: string): {}; } From 24e5729f07687694e6da1c8c2027bc08238637f4 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 3 Oct 2022 12:22:51 -0400 Subject: [PATCH 20/50] Re-recorded a simple test. --- packages/grpc/test/scenarios/simple-error/diagnostics.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/grpc/test/scenarios/simple-error/diagnostics.txt b/packages/grpc/test/scenarios/simple-error/diagnostics.txt index 67dbe438a22..867d34e6c84 100644 --- a/packages/grpc/test/scenarios/simple-error/diagnostics.txt +++ b/packages/grpc/test/scenarios/simple-error/diagnostics.txt @@ -1 +1 @@ -/test/main.cadl:11:7 - error cadl-grpc/field-index: field index 0 is invalid (must be an integer greater than zero) +/test/main.cadl:11:7 - error cadl-grpc/field-index: field index 0 is invalid (must be an integer greater than zero) \ No newline at end of file From b287c03c729f1c1758d4545624235e27f587ad1c Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 2 Dec 2022 14:08:48 -0500 Subject: [PATCH 21/50] Renamed grpc -> protobuf, improved handling of many protobuf features --- common/config/rush/pnpm-lock.yaml | 34 + packages/grpc/CHANGELOG.json | 4 - packages/grpc/README.md | 28 - packages/grpc/src/grpc.ts | 168 ----- packages/grpc/src/transform.ts | 455 -------------- .../scenarios/array-nested/diagnostics.txt | 1 - .../enum-nonintegral/diagnostics.txt | 2 - .../scenarios/simple-error/diagnostics.txt | 1 - .../scenarios/simple-error/input/main.cadl | 12 - packages/{grpc => protobuf}/.c8rc.json | 0 packages/{grpc => protobuf}/.eslintrc.cjs | 0 packages/{grpc => protobuf}/.mocharc.yaml | 0 packages/protobuf/CHANGELOG.json | 4 + packages/{grpc => protobuf}/LICENSE | 0 packages/protobuf/README.md | 28 + packages/protobuf/lib/grpc.cadl | 45 ++ packages/{grpc => protobuf}/package.json | 20 +- .../src/proto.ts => protobuf/src/ast.ts} | 31 +- packages/{grpc => protobuf}/src/lib.ts | 69 ++- packages/protobuf/src/proto.ts | 187 ++++++ packages/protobuf/src/transform.ts | 585 ++++++++++++++++++ packages/{grpc => protobuf}/src/write.ts | 21 +- .../{grpc => protobuf}/test/scenarios.spec.ts | 102 +-- .../anonymous-package/input/main.cadl | 6 +- .../anonymous-package/output/main.proto | 2 +- .../scenarios/array-nested/diagnostics.txt | 1 + .../scenarios/array-nested/input/main.cadl | 6 +- .../test/scenarios/array/input/main.cadl | 5 +- .../array/output/com/azure/test.proto | 2 +- .../cross package references/input/main.cadl | 25 + .../cross package references/output/A.proto | 10 + .../cross package references/output/B.proto | 13 + .../enum-nonintegral/diagnostics.txt | 4 + .../enum-nonintegral/input/main.cadl | 9 +- .../scenarios/enum-nozero/diagnostics.txt | 1 + .../scenarios/enum-nozero}/input/main.cadl | 7 +- .../test/scenarios/enum/input/main.cadl | 34 + .../enum/output/com/azure/test.proto | 15 +- .../test/scenarios/extern/input/main.cadl | 17 + .../test/scenarios/extern/output/main.proto | 19 + .../inferred-message-names/input/main.cadl | 5 +- .../output/com/azure/test.proto | 2 +- .../test/scenarios/map/input/main.cadl | 15 + .../test/scenarios/map/output/main.proto | 13 + .../scenarios/reserved fields/input/main.cadl | 16 + .../reserved fields/output/main.proto | 16 + .../scenarios/simple-error/diagnostics.txt | 5 + .../scenarios/simple-error/input/main.cadl | 18 + .../test/scenarios/simple/input/main.cadl | 5 +- .../simple/output/com/azure/test.proto | 2 +- .../test/scenarios/streams/input/main.cadl | 30 + .../test/scenarios/streams/output/main.proto | 19 + .../scenarios/type-validation/diagnostics.txt | 1 + .../scenarios/type-validation/input/main.cadl | 11 + packages/{grpc => protobuf}/tsconfig.json | 0 rush.json | 4 +- 56 files changed, 1361 insertions(+), 774 deletions(-) delete mode 100644 packages/grpc/CHANGELOG.json delete mode 100644 packages/grpc/README.md delete mode 100644 packages/grpc/src/grpc.ts delete mode 100644 packages/grpc/src/transform.ts delete mode 100644 packages/grpc/test/scenarios/array-nested/diagnostics.txt delete mode 100644 packages/grpc/test/scenarios/enum-nonintegral/diagnostics.txt delete mode 100644 packages/grpc/test/scenarios/simple-error/diagnostics.txt delete mode 100644 packages/grpc/test/scenarios/simple-error/input/main.cadl rename packages/{grpc => protobuf}/.c8rc.json (100%) rename packages/{grpc => protobuf}/.eslintrc.cjs (100%) rename packages/{grpc => protobuf}/.mocharc.yaml (100%) create mode 100644 packages/protobuf/CHANGELOG.json rename packages/{grpc => protobuf}/LICENSE (100%) create mode 100644 packages/protobuf/README.md create mode 100644 packages/protobuf/lib/grpc.cadl rename packages/{grpc => protobuf}/package.json (74%) rename packages/{grpc/src/proto.ts => protobuf/src/ast.ts} (92%) rename packages/{grpc => protobuf}/src/lib.ts (56%) create mode 100644 packages/protobuf/src/proto.ts create mode 100644 packages/protobuf/src/transform.ts rename packages/{grpc => protobuf}/src/write.ts (92%) rename packages/{grpc => protobuf}/test/scenarios.spec.ts (57%) rename packages/{grpc => protobuf}/test/scenarios/anonymous-package/input/main.cadl (77%) rename packages/{grpc => protobuf}/test/scenarios/anonymous-package/output/main.proto (71%) create mode 100644 packages/protobuf/test/scenarios/array-nested/diagnostics.txt rename packages/{grpc => protobuf}/test/scenarios/array-nested/input/main.cadl (79%) rename packages/{grpc => protobuf}/test/scenarios/array/input/main.cadl (81%) rename packages/{grpc => protobuf}/test/scenarios/array/output/com/azure/test.proto (77%) create mode 100644 packages/protobuf/test/scenarios/cross package references/input/main.cadl create mode 100644 packages/protobuf/test/scenarios/cross package references/output/A.proto create mode 100644 packages/protobuf/test/scenarios/cross package references/output/B.proto create mode 100644 packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt rename packages/{grpc => protobuf}/test/scenarios/enum-nonintegral/input/main.cadl (80%) create mode 100644 packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt rename packages/{grpc/test/scenarios/enum => protobuf/test/scenarios/enum-nozero}/input/main.cadl (74%) create mode 100644 packages/protobuf/test/scenarios/enum/input/main.cadl rename packages/{grpc => protobuf}/test/scenarios/enum/output/com/azure/test.proto (59%) create mode 100644 packages/protobuf/test/scenarios/extern/input/main.cadl create mode 100644 packages/protobuf/test/scenarios/extern/output/main.proto rename packages/{grpc => protobuf}/test/scenarios/inferred-message-names/input/main.cadl (77%) rename packages/{grpc => protobuf}/test/scenarios/inferred-message-names/output/com/azure/test.proto (77%) create mode 100644 packages/protobuf/test/scenarios/map/input/main.cadl create mode 100644 packages/protobuf/test/scenarios/map/output/main.proto create mode 100644 packages/protobuf/test/scenarios/reserved fields/input/main.cadl create mode 100644 packages/protobuf/test/scenarios/reserved fields/output/main.proto create mode 100644 packages/protobuf/test/scenarios/simple-error/diagnostics.txt create mode 100644 packages/protobuf/test/scenarios/simple-error/input/main.cadl rename packages/{grpc => protobuf}/test/scenarios/simple/input/main.cadl (81%) rename packages/{grpc => protobuf}/test/scenarios/simple/output/com/azure/test.proto (76%) create mode 100644 packages/protobuf/test/scenarios/streams/input/main.cadl create mode 100644 packages/protobuf/test/scenarios/streams/output/main.proto create mode 100644 packages/protobuf/test/scenarios/type-validation/diagnostics.txt create mode 100644 packages/protobuf/test/scenarios/type-validation/input/main.cadl rename packages/{grpc => protobuf}/tsconfig.json (100%) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index b23ff592501..953e19409fd 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -33,6 +33,7 @@ specifiers: '@rush-temp/openapi3': file:./projects/openapi3.tgz '@rush-temp/playground': file:./projects/playground.tgz '@rush-temp/prettier-plugin-cadl': file:./projects/prettier-plugin-cadl.tgz + '@rush-temp/protobuf': file:./projects/protobuf.tgz '@rush-temp/rest': file:./projects/rest.tgz '@rush-temp/samples': file:./projects/samples.tgz '@rush-temp/spec': file:./projects/spec.tgz @@ -44,6 +45,7 @@ specifiers: '@types/babel__code-frame': ~7.0.3 '@types/debounce': ~1.2.1 '@types/js-yaml': ~4.0.1 + '@types/micromatch': ^4.0.2 '@types/mkdirp': ~1.0.1 '@types/mocha': ~10.0.0 '@types/mustache': ~4.2.1 @@ -81,6 +83,7 @@ specifiers: lzutf8: 0.6.2 mdx-mermaid: 1.3.2 mermaid: ~9.1.6 + micromatch: ^4.0.5 mkdirp: ~1.0.4 mocha: ~10.1.0 mocha-junit-reporter: ~2.2.0 @@ -151,6 +154,7 @@ dependencies: '@rush-temp/openapi3': file:projects/openapi3.tgz '@rush-temp/playground': file:projects/playground.tgz_rollup@3.4.0 '@rush-temp/prettier-plugin-cadl': file:projects/prettier-plugin-cadl.tgz + '@rush-temp/protobuf': file:projects/protobuf.tgz '@rush-temp/rest': file:projects/rest.tgz '@rush-temp/samples': file:projects/samples.tgz '@rush-temp/spec': file:projects/spec.tgz @@ -162,6 +166,7 @@ dependencies: '@types/babel__code-frame': 7.0.3 '@types/debounce': 1.2.1 '@types/js-yaml': 4.0.5 + '@types/micromatch': 4.0.2 '@types/mkdirp': 1.0.2 '@types/mocha': 10.0.0 '@types/mustache': 4.2.1 @@ -199,6 +204,7 @@ dependencies: lzutf8: 0.6.2 mdx-mermaid: 1.3.2_mermaid@9.1.7+react@18.2.0 mermaid: 9.1.7 + micromatch: 4.0.5 mkdirp: 1.0.4 mocha: 10.1.0 mocha-junit-reporter: 2.2.0_mocha@10.1.0 @@ -4164,6 +4170,10 @@ packages: '@types/node': 18.11.9 dev: false + /@types/braces/3.0.1: + resolution: {integrity: sha512-+euflG6ygo4bn0JHtn4pYqcXwRtLvElQ7/nnjDu7iYG56H0+OhCd7d6Ug0IE3WcFpZozBKW2+80FUbv5QGk5AQ==} + dev: false + /@types/connect-history-api-fallback/1.3.5: resolution: {integrity: sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw==} dependencies: @@ -4281,6 +4291,12 @@ packages: '@types/unist': 2.0.6 dev: false + /@types/micromatch/4.0.2: + resolution: {integrity: sha512-oqXqVb0ci19GtH0vOA/U2TmHTcRY9kuZl4mqUxe0QmJAlIW13kzhuK5pi1i9+ngav8FjpSb9FVS/GE00GLX1VA==} + dependencies: + '@types/braces': 3.0.1 + dev: false + /@types/mime/3.0.1: resolution: {integrity: sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==} dev: false @@ -14140,6 +14156,24 @@ packages: - supports-color dev: false + file:projects/protobuf.tgz: + resolution: {integrity: sha512-kyBIQ+NqsGJn9HHCnYoLFY7ZV/bVELY07DEb9zE+rybwV2YYWOFHxQm/UlyTE8WIhQLiMMpyiePxb7V4FO9kIw==, tarball: file:projects/protobuf.tgz} + name: '@rush-temp/protobuf' + version: 0.0.0 + dependencies: + '@types/micromatch': 4.0.2 + '@types/mocha': 10.0.0 + '@types/node': 18.11.9 + c8: 7.12.0 + eslint: 8.28.0 + micromatch: 4.0.5 + mocha: 10.1.0 + rimraf: 3.0.2 + typescript: 4.9.3 + transitivePeerDependencies: + - supports-color + dev: false + file:projects/rest.tgz: resolution: {integrity: sha512-TLqBu6PLLgLyacH6oo7i/IcYMW1XiVgRUvh1OrBy/GaylTg7lk6jnbHij1GnI/F8Lhn741uklExQB7+0ImcGuQ==, tarball: file:projects/rest.tgz} name: '@rush-temp/rest' diff --git a/packages/grpc/CHANGELOG.json b/packages/grpc/CHANGELOG.json deleted file mode 100644 index 0c3da0e0847..00000000000 --- a/packages/grpc/CHANGELOG.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "@cadl-lang/grpc", - "entries": [] -} diff --git a/packages/grpc/README.md b/packages/grpc/README.md deleted file mode 100644 index 8f3b0f1ed66..00000000000 --- a/packages/grpc/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# Cadl gRPC library and emitter - -This package provides support for defining gRPC services in [Cadl](https://github.com/microsoft/cadl) and an emitter that generates Protobuf output from Cadl sources. - -## Install - -In your project root: - -```bash -npm install @cadl-lang/grpc -``` - -## Using the gRPC emitter - -1. Using the `cadl` CLI: - -```bash -cadl compile . --emit @cadl-lang/grpc -``` - -2. Using the Cadl project configuration file: - -Add the following to your `cadl-project.yaml` file. - -```yaml -emitters: - @cadl-lang/grpc: true -``` diff --git a/packages/grpc/src/grpc.ts b/packages/grpc/src/grpc.ts deleted file mode 100644 index 7a03e70076d..00000000000 --- a/packages/grpc/src/grpc.ts +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - createDecoratorDefinition, - DecoratorContext, - EmitOptionsFor, - Interface, - ModelProperty, - Namespace, - Program, -} from "@cadl-lang/compiler"; - -import { CadlGrpcLibrary, reportDiagnostic, state } from "./lib.js"; -import { createGrpcEmitter } from "./transform.js"; - -/** - * # cadl-grpc : gRPC/Protobuf Emitter and Decorators for CADL - * - * This module defines an emitter and decorator library for CADL that enables specifying gRPC services and Protobuf - * models. - */ - -/** - * The maximum field index allowed by Protocol Buffers. - */ -const MAX_FIELD_INDEX = 2 ** 29 - 1; - -/** - * The field range between 19000 and 19999 is reserved for Protobuf client implementations. - */ -const IMPLEMENTATION_RESERVED_RANGE = [19000, 19999] as const; - -const packageDecorator = createDecoratorDefinition({ - name: "@package", - args: [{ kind: "String", optional: true }], - target: "Namespace", -} as const); - -/** - * Defined in the [ProtoBuf Language Spec](https://developers.google.com/protocol-buffers/docs/reference/proto3-spec#identifiers). - * - * ident = letter { letter | decimalDigit | "_" } - * fullIdent = ident { "." ident } - */ -export const PROTO_FULL_IDENT = /([a-zA-Z][a-zA-Z0-9_]*)+/; - -/** - * Decorate a namespace as a package, indicating that it represents a single Protobuf unit (a single file with a - * `package` declaration). - * - * @param ctx - decorator context - * @param target - the decorated namespace - * @param name - the package's name (not optional) - */ -export function $package(ctx: DecoratorContext, target: Namespace, name?: string) { - if (!packageDecorator.validate(ctx, target, [name])) { - return; - } - - if (name && !PROTO_FULL_IDENT.test(name)) { - reportDiagnostic(ctx.program, { - code: "invalid-package-name", - target: ctx.getArgumentTarget(0)!, - format: { - name, - }, - }); - } - - ctx.program.stateMap(state.package).set(target, name); -} - -const serviceDecorator = createDecoratorDefinition({ - name: "@service", - args: [], - target: "Interface", -} as const); - -/** - * Decorate an interface as a service, indicating that it represents a gRPC `service` declaration. - * - * @param ctx - decorator context - * @param target - the decorated interface - */ -export function $service(ctx: DecoratorContext, target: Interface) { - if (!serviceDecorator.validate(ctx, target, [])) { - return; - } - - // TODO/DESIGN: do we allow service interfaces to extend/compose other interfaces? - - ctx.program.stateSet(state.service).add(target); -} - -const fieldDecorator = createDecoratorDefinition({ - name: "@field", - args: [{ kind: "Number", optional: false }], - target: "ModelProperty", -} as const); - -/** - * Decorate a model property with a field index. Field indices are required for all fields of emitted messages. - * - * @param param0 - * @param target - * @param fieldIndex - * @returns - */ -export function $field(ctx: DecoratorContext, target: ModelProperty, fieldIndex: number) { - if (!fieldDecorator.validate(ctx, target, [fieldIndex])) { - return; - } - - if (!Number.isInteger(fieldIndex) || fieldIndex <= 0) { - reportDiagnostic(ctx.program, { - code: "field-index", - messageId: "invalid", - format: { - index: String(fieldIndex), - }, - target, - }); - return; - } else if (fieldIndex > MAX_FIELD_INDEX) { - reportDiagnostic(ctx.program, { - code: "field-index", - messageId: "out-of-bounds", - format: { - index: String(fieldIndex), - max: String(MAX_FIELD_INDEX), - }, - target, - }); - return; - } else if ( - fieldIndex >= IMPLEMENTATION_RESERVED_RANGE[0] && - fieldIndex <= IMPLEMENTATION_RESERVED_RANGE[1] - ) { - reportDiagnostic(ctx.program, { - code: "field-index", - messageId: "reserved", - format: { - index: String(fieldIndex), - }, - target, - }); - } - - ctx.program.stateMap(state.fieldIndex).set(target, fieldIndex); -} - -/** - * Emitter main function. - * - * @param program - the program to emit - */ -export async function $onEmit(program: Program, options?: EmitOptionsFor) { - const emitter = createGrpcEmitter(program); - - await emitter({ - outputDirectory: options?.outputDirectory, - }); -} - -export const namespace = "Cadl.Grpc"; - -export { CadlGrpcLibrary as $lib }; diff --git a/packages/grpc/src/transform.ts b/packages/grpc/src/transform.ts deleted file mode 100644 index d66e80d2906..00000000000 --- a/packages/grpc/src/transform.ts +++ /dev/null @@ -1,455 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { - Enum, - getEffectiveModelType, - getIntrinsicModelName, - Interface, - isIntrinsic, - Model, - ModelProperty, - Namespace, - Operation, - Program, - resolvePath, - Type, -} from "@cadl-lang/compiler"; -import { GrpcEmitterOptions, reportDiagnostic, state } from "./lib.js"; -import { - map, - ProtoEnumDeclaration, - ProtoFieldDeclaration, - ProtoFile, - ProtoMessageDeclaration, - ProtoMethodDeclaration, - ProtoRef, - ProtoScalar, - ProtoTopLevelDeclaration, - ProtoType, - ref, - scalar, - ScalarIntegralName, - unreachable, -} from "./proto.js"; -import { writeProtoFile } from "./write.js"; - -// Default options -const DEFAULT_OPTIONS = { - outputDirectory: "./cadl-output/", -} as const; - -/** - * Create a worker function that converts the CADL program to Protobuf and writes it to the file system. - */ -export function createGrpcEmitter( - program: Program -): (options?: GrpcEmitterOptions) => Promise { - return async function doEmit(options) { - const outDir = resolvePath(options?.outputDirectory ?? DEFAULT_OPTIONS.outputDirectory); - - // Convert the program to a set of proto files. - const files = cadlToProto(program); - - if (!program.compilerOptions.noEmit && !program.hasError()) { - for (const file of files) { - // If the file has a package, emit it to a path that is shaped like the package name. Otherwise emit to - // main.proto - - // Collisions have already been detected. - - const packageSlug = file.package?.split(".") ?? ["main"]; - const filePath = resolvePath(outDir, ...packageSlug.slice(0, -1)); - - await program.host.mkdirp(filePath); - await program.host.writeFile( - resolvePath(filePath, packageSlug[packageSlug.length - 1] + ".proto"), - writeProtoFile(file) - ); - } - } - }; -} - -/** - * Create a set of proto files that represent the CADL program. - * - * This is the meat of the emitter. - */ -function cadlToProto(program: Program): ProtoFile[] { - const packages = program.stateMap(state.package) as Map; - - // Emit a file per package. - const files = [...packages].map( - ([namespace, packageName]) => - ({ - package: packageName, - options: {}, - declarations: declarationsFromNamespace(namespace), - source: namespace, - } as ProtoFile) - ); - - checkForNamespaceCollisions(files); - - return files; - - /** - * Recursively searches a namespace for declarations that should be reified as Protobuf. - * - * @param namespace - the namespace to analyze - * @returns an array of declarations - */ - function declarationsFromNamespace(namespace: Namespace): ProtoFile["declarations"] { - const serviceInterfaces = new Set(); - - // This IIFE adds all interfaces decorated with `service` that are reachable from `namespace` - (function recursiveAddInterfaces(namespace: Namespace) { - for (const memberInterface of namespace.interfaces.values()) { - if (program.stateSet(state.service).has(memberInterface)) { - serviceInterfaces.add(memberInterface); - } - } - - for (const nested of namespace.namespaces.values()) { - // !! We only want to recurse on namespaces that are not, themselves, packages. - if (!packages.has(nested)) recursiveAddInterfaces(nested); - } - })(namespace); - - const declarations: ProtoTopLevelDeclaration[] = []; - const visitedTypes = new Set(); - - /** - * Visits a model type, converting it into a message definition and adding it if it has not already been visited. - * @param model - the model type to consider - */ - function visitModel(model: Model) { - if (!visitedTypes.has(model)) { - visitedTypes.add(model); - declarations.push(toMessage(model)); - } - } - - /** - * Visits an enum type, converting it into a Protobuf enum definition and adding it if it has not already been visited. - */ - function visitEnum(e: Enum) { - if (!visitedTypes.has(e)) { - visitedTypes.add(e); - - // We only support enums where every variant is explicitly assigned an integer value - if ( - [...e.members.values()].some( - ({ value: v }) => !v || typeof v !== "number" || !Number.isInteger(v) - ) - ) { - reportDiagnostic(program, { - target: e, - code: "unconvertible-enum", - }); - } - - declarations.push(toEnum(e)); - } - } - - const effectiveModelCache = new Map(); - - // Each interface will be reified as a `service` declaration. - for (const iface of serviceInterfaces) { - declarations.push({ - kind: "service", - name: iface.name, - // The service's methods are just projections of the interface operations. - operations: [...iface.operations.values()].map(toMethodFromOperation), - }); - } - - return declarations; - - // #region inline helpers - - /** - * @param operation - the operation to convert - * @returns a corresponding method declaration - */ - function toMethodFromOperation(operation: Operation): ProtoMethodDeclaration { - // TODO: add support for cross-package type references - // https://github.com/microsoft/cadl/issues/632 - - // TODO: until then, reject cross-package references - return { - kind: "method", - name: capitalize(operation.name), - input: addInputParams(operation.parameters, operation.name), - returns: addReturnType(operation.returnType, operation.name), - }; - } - - /** - * Checks a parameter Model satisfies the constraints for a gRPC method input and adds it to the declarations, - * returning a ProtoRef to the generated named message. - * - * @param model - the model to add - * @returns a reference to the model's message - */ - function addInputParams(paramsModel: Model, operationName: string): ProtoRef { - const effectiveModel = computeEffectiveModel( - paramsModel, - capitalize(operationName) + "Request" - ); - - if (effectiveModel) { - return ref(effectiveModel.name); - } - - reportDiagnostic(program, { - code: "unsupported-input-type", - messageId: "unconvertible", - target: paramsModel, - }); - - return unreachable("unsupported input type"); - } - - /** - * Checks that a return type is a Model and converts it to a message, adding it to the declarations and returning - * a reference to its name. - * - * @param t - the model to add - * @param operationName - the name of the originating operation, used to compute a synthetic model name if required - * @returns a reference to the model's message - */ - function addReturnType(t: Type, operationName: string): ProtoRef { - // TODO: need to support importing google/protobuf/empty.proto and others - // https://github.com/microsoft/cadl/issues/630 - - // This is also very important for handling datetime values. - - // if (t.kind === "Intrinsic" && t.name === "void") { - // return ref("google.protobuf.Empty"); - // } - - switch (t.kind) { - case "Model": - const effectiveModel = computeEffectiveModel(t, capitalize(operationName) + "Response"); - if (effectiveModel) { - return ref(effectiveModel.name); - } - // eslint-disable-next-line no-fallthrough - default: - reportDiagnostic(program, { - code: "unsupported-return-type", - target: t, - }); - - return unreachable("unsupported return type"); - } - } - - /** - * Converts a CADL type to a Protobuf type, adding a corresponding message if necessary. - * - * @param t - the type to add to the ProtoFile. - * @returns a Protobuf type corresponding to the given type - */ - function addType(t: Type): ProtoType { - // We will handle all intrinsics separately, including maps. - if (isIntrinsic(program, t)) return intrinsicToProto(getIntrinsicModelName(program, t), t); - - // Arrays transform into repeated fields, so we'll silently replace `t` with the array's member if this is an array. - // The `repeated` keyword will be added when the field is composed. - if (isArray(t)) { - const valueType = (t as Model).templateArguments![0]; - - // Nested arrays are not supported. - if (isArray(valueType)) { - reportDiagnostic(program, { - code: "nested-array", - target: t, - }); - return ref(""); - } - - return addType(valueType); - } - - // TODO: streams - // https://github.com/microsoft/cadl/issues/633 - - // TODO: reject anonymous models at this stage - - switch (t.kind) { - case "Model": - visitModel(t); - return ref(t.name); - case "Enum": - visitEnum(t); - return ref(t.name); - default: - reportDiagnostic(program, { - code: "unsupported-field-type", - messageId: "unconvertible", - format: { - type: t.kind, - }, - target: t, - }); - return unreachable("unsupported field type"); - } - } - - function intrinsicToProto(name: string, t: Type): ProtoType { - // Check if the type is an instance of Cadl.Map - if (isMap(t)) { - // Intrinsic map. - const [keyType, valueType] = (t as Model).templateArguments ?? []; - - // A map's value cannot be another map. - if (isMap(valueType)) { - reportDiagnostic(program, { - code: "unsupported-field-type", - messageId: "recursive-map", - target: valueType, - }); - return unreachable("recursive map"); - } - - // This is a core compile error. - if (!keyType || !valueType) return unreachable("nonexistent map key or value type"); - - const keyProto = addType(keyType); - const valueProto = addType(valueType) as ProtoRef | ProtoScalar; - - return map(keyProto[1] as "string" | ScalarIntegralName, valueProto); - } - - // TODO: expose control over integer encodings. - // https://github.com/microsoft/cadl/issues/631 - const protoType = { - bytes: scalar("bytes"), - boolean: scalar("bool"), - int32: scalar("int32"), - int64: scalar("int64"), - uint32: scalar("uint32"), - uint64: scalar("uint64"), - string: scalar("string"), - float32: scalar("float"), - float64: scalar("double"), - }[name]; - - if (!protoType) { - reportDiagnostic(program, { - code: "unsupported-field-type", - messageId: "unknown-intrinsic", - format: { - name: name, - }, - target: t, - }); - return unreachable("unknown intrinsic"); - } - - return protoType; - } - - /** - * @param model - the Model to convert - * @returns a corresponding message declaration - */ - function toMessage(model: Model): ProtoMessageDeclaration { - return { - kind: "message", - name: model.name, - declarations: [...model.properties.values()].map(toField), - }; - } - - /** - * @param e - the Enum to convert - * @returns a corresponding protobuf enum declaration - * - * INVARIANT: the enum's members must be integer values - */ - function toEnum(e: Enum): ProtoEnumDeclaration { - return { - kind: "enum", - name: e.name, - variants: [...e.members.values()].map(({ name, value }) => [name, value as number]), - }; - } - - /** - * @param property - the ModelProperty to convert - * @returns a corresponding field declaration - */ - function toField(property: ModelProperty): ProtoFieldDeclaration { - const field: ProtoFieldDeclaration = { - kind: "field", - name: property.name, - type: addType(property.type), - index: program.stateMap(state.fieldIndex).get(property), - }; - - // Determine if the property type is an array - if (isArray(property.type)) field.repeated = true; - - return field; - } - - function computeEffectiveModel(model: Model, anonymousModelName: string): Model | undefined { - if (effectiveModelCache.has(model)) return effectiveModelCache.get(model); - - let effectiveModel = getEffectiveModelType(program, model); - - if (effectiveModel.name === "") { - // Name the model automatically if it is anonymous - effectiveModel = program.checker.createAndFinishType({ - ...model, - name: anonymousModelName, - }); - } - - visitModel(effectiveModel); - - effectiveModelCache.set(model, effectiveModel); - - return effectiveModel; - } - // #endregion - } - - function checkForNamespaceCollisions(files: ProtoFile[]) { - const namespaces = new Set(); - - for (const file of files) { - if (namespaces.has(file.package)) { - reportDiagnostic(program, { - code: "namespace-collision", - format: { - name: `"${file.package}"` ?? "", - }, - target: file.source, - }); - } - - namespaces.add(file.package); - } - } -} - -function isMap(t: Type) { - return t.kind === "Model" && t.name === "Map" && t.namespace?.name === "Cadl"; -} - -function isArray(t: Type) { - return t.kind === "Model" && t.name === "Array" && t.namespace?.name === "Cadl"; -} - -/** - * Simple utility function to capitalize a string. - */ -function capitalize(s: S) { - return (s.slice(0, 1).toUpperCase() + s.slice(1)) as Capitalize; -} diff --git a/packages/grpc/test/scenarios/array-nested/diagnostics.txt b/packages/grpc/test/scenarios/array-nested/diagnostics.txt deleted file mode 100644 index 338b154718f..00000000000 --- a/packages/grpc/test/scenarios/array-nested/diagnostics.txt +++ /dev/null @@ -1 +0,0 @@ -/test/.cadl/lib/lib.cadl:5:1 - error cadl-grpc/nested-array: nested arrays are not supported by the gRPC emitter \ No newline at end of file diff --git a/packages/grpc/test/scenarios/enum-nonintegral/diagnostics.txt b/packages/grpc/test/scenarios/enum-nonintegral/diagnostics.txt deleted file mode 100644 index 5fafeb16db2..00000000000 --- a/packages/grpc/test/scenarios/enum-nonintegral/diagnostics.txt +++ /dev/null @@ -1,2 +0,0 @@ -/test/main.cadl:18:1 - error cadl-grpc/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a gRPC message -/test/main.cadl:23:1 - error cadl-grpc/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a gRPC message \ No newline at end of file diff --git a/packages/grpc/test/scenarios/simple-error/diagnostics.txt b/packages/grpc/test/scenarios/simple-error/diagnostics.txt deleted file mode 100644 index 867d34e6c84..00000000000 --- a/packages/grpc/test/scenarios/simple-error/diagnostics.txt +++ /dev/null @@ -1 +0,0 @@ -/test/main.cadl:11:7 - error cadl-grpc/field-index: field index 0 is invalid (must be an integer greater than zero) \ No newline at end of file diff --git a/packages/grpc/test/scenarios/simple-error/input/main.cadl b/packages/grpc/test/scenarios/simple-error/input/main.cadl deleted file mode 100644 index c358b32fb12..00000000000 --- a/packages/grpc/test/scenarios/simple-error/input/main.cadl +++ /dev/null @@ -1,12 +0,0 @@ -import "@cadl-lang/grpc"; - -using Cadl.Grpc; - -@package -namespace Test; - -@Cadl.Grpc.service -interface Service { - // invalid field index - foo(@field(0) testInputField: string): {}; -} diff --git a/packages/grpc/.c8rc.json b/packages/protobuf/.c8rc.json similarity index 100% rename from packages/grpc/.c8rc.json rename to packages/protobuf/.c8rc.json diff --git a/packages/grpc/.eslintrc.cjs b/packages/protobuf/.eslintrc.cjs similarity index 100% rename from packages/grpc/.eslintrc.cjs rename to packages/protobuf/.eslintrc.cjs diff --git a/packages/grpc/.mocharc.yaml b/packages/protobuf/.mocharc.yaml similarity index 100% rename from packages/grpc/.mocharc.yaml rename to packages/protobuf/.mocharc.yaml diff --git a/packages/protobuf/CHANGELOG.json b/packages/protobuf/CHANGELOG.json new file mode 100644 index 00000000000..ea72e1d2e1e --- /dev/null +++ b/packages/protobuf/CHANGELOG.json @@ -0,0 +1,4 @@ +{ + "name": "@cadl-lang/protobuf", + "entries": [] +} diff --git a/packages/grpc/LICENSE b/packages/protobuf/LICENSE similarity index 100% rename from packages/grpc/LICENSE rename to packages/protobuf/LICENSE diff --git a/packages/protobuf/README.md b/packages/protobuf/README.md new file mode 100644 index 00000000000..dc8878580aa --- /dev/null +++ b/packages/protobuf/README.md @@ -0,0 +1,28 @@ +# Cadl Protobuf library and emitter + +This package provides support for defining and emitting Protobuf specifications in [Cadl](https://github.com/microsoft/cadl) and an emitter that generates Protobuf output from Cadl sources. + +## Install + +In your project root: + +```bash +npm install @cadl-lang/protobuf +``` + +## Using the Protobuf emitter + +1. Using the `cadl` CLI: + +```bash +cadl compile . --emit @cadl-lang/protobuf +``` + +2. Using the Cadl project configuration file: + +Add the following to your `cadl-project.yaml` file. + +```yaml +emitters: + @cadl-lang/protobuf: true +``` diff --git a/packages/protobuf/lib/grpc.cadl b/packages/protobuf/lib/grpc.cadl new file mode 100644 index 00000000000..e64dc67c29e --- /dev/null +++ b/packages/protobuf/lib/grpc.cadl @@ -0,0 +1,45 @@ +import "../dist/src/proto.js"; + +namespace Cadl.Protobuf; + +@externRef(Path, Name) +model Extern { + _extern: never; +} + +namespace WellKnown { + model Empty + is Extern<"google/protobuf/empty.proto", "google.protobuf.Empty">; +} + +// Scalars supported by gRPC. +scalar sint32 extends int32; +scalar sint64 extends int64; +scalar sfixed32 extends int32; +scalar sfixed64 extends int64; +scalar fixed32 extends uint32; +scalar fixed64 extends uint64; + +alias integral = int32 | int64 | boolean; + +@_map +model Map {} + +extern dec externRef(target: object, path: string, name: string); + +extern dec field(target: Cadl.Reflection.ModelProperty, index: uint32); +extern dec serviceInterface(target: Cadl.Reflection.Interface); +extern dec packageName(target: Cadl.Reflection.Namespace, name: string); +extern dec reserve( + target: object, + ...ranges: (string | [uint32, uint32] | uint32)[] +); + +enum StreamMode { + Duplex, + In, + Out, + None, +} + +extern dec stream(target: Cadl.Reflection.Operation, mode: StreamMode); diff --git a/packages/grpc/package.json b/packages/protobuf/package.json similarity index 74% rename from packages/grpc/package.json rename to packages/protobuf/package.json index b56bcc5abdf..e2fc1a5070f 100644 --- a/packages/grpc/package.json +++ b/packages/protobuf/package.json @@ -1,8 +1,8 @@ { - "name": "@cadl-lang/grpc", + "name": "@cadl-lang/protobuf", "version": "0.1.0", "author": "Microsoft Corporation", - "description": "Cadl library and emitter for gRPC/Protobuf", + "description": "Cadl library and emitter for Protobuf (gRPC)", "homepage": "https://github.com/Microsoft/cadl", "readme": "https://github.com/Microsoft/cadl/blob/master/README.md", "license": "MIT", @@ -16,9 +16,9 @@ "keywords": [ "cadl" ], - "main": "dist/src/grpc.js", + "main": "dist/src/lib.js", "type": "module", - "cadlMain": "dist/src/grpc.js", + "cadlMain": "lib/proto.cadl", "scripts": { "clean": "rimraf ./dist ./temp", "build": "tsc -p .", @@ -29,18 +29,18 @@ "lint:fix": "eslint . --fix --ext .ts" }, "dependencies": { - "@cadl-lang/compiler": "~0.35.0" + "@cadl-lang/compiler": "~0.37.0" }, "devDependencies": { "@cadl-lang/eslint-config-cadl": "~0.4.1", "@cadl-lang/eslint-plugin": "~0.1.1", - "@types/mocha": "~9.1.0", - "@types/node": "~16.0.3", - "c8": "~7.11.0", + "@types/mocha": "~10.0.0", + "@types/node": "~18.11.9", + "c8": "~7.12.0", "eslint": "^8.12.0", - "mocha": "~9.2.0", + "mocha": "~10.1.0", "rimraf": "~3.0.2", - "typescript": "~4.8.2", + "typescript": "~4.9.3", "micromatch": "^4.0.5", "@types/micromatch": "^4.0.2" } diff --git a/packages/grpc/src/proto.ts b/packages/protobuf/src/ast.ts similarity index 92% rename from packages/grpc/src/proto.ts rename to packages/protobuf/src/ast.ts index 1235803e513..d445de55619 100644 --- a/packages/grpc/src/proto.ts +++ b/packages/protobuf/src/ast.ts @@ -19,6 +19,11 @@ export interface ProtoFile { */ options: Partial; + /** + * Paths imported by this file. + */ + imports: string[]; + /** * The declarations in the file. * @@ -131,20 +136,26 @@ export function map(k: ScalarIntegralName | "string", v: Exclude(type: ProtoType, pattern: ProtoTypeMatchPatter return pattern.scalar(type[1]); case $map: return pattern.map(type[1], type[2] as Exclude); + /* c8 ignore next 5 */ default: const __exhaust: never = type[0]; throw new Error(`Internal Error: unreachable matchType variant ${__exhaust}`); @@ -184,11 +196,22 @@ export interface ProtoServiceDeclaration { operations: ProtoMethodDeclaration[]; } +/** + * An operation's streaming mode. + */ +export const enum StreamingMode { + Duplex = 3, + In = 2, + Out = 1, + None = 0, +} + /** * An `rfc` method declaration. */ export interface ProtoMethodDeclaration { kind: "method"; + stream: StreamingMode; name: string; input: ProtoRef; returns: ProtoRef; @@ -215,7 +238,7 @@ export interface ProtoFieldDeclaration { /** * Whether or not the field is repeated (i.e. an array). */ - repeated?: true; + repeated?: boolean; options?: Partial; type: ProtoType; index: number; @@ -244,6 +267,6 @@ export interface ProtoOneOfDeclaration { export interface ProtoEnumDeclaration { kind: "enum"; name: string; - allowAlias?: true; + allowAlias?: boolean; variants: [string, number][]; } diff --git a/packages/grpc/src/lib.ts b/packages/protobuf/src/lib.ts similarity index 56% rename from packages/grpc/src/lib.ts rename to packages/protobuf/src/lib.ts index 6a6aa43bb69..b8bda8b0a17 100644 --- a/packages/grpc/src/lib.ts +++ b/packages/protobuf/src/lib.ts @@ -4,26 +4,35 @@ import { createCadlLibrary, JSONSchemaType, paramMessage } from "@cadl-lang/compiler"; /** - * Options that the gRPC emitter accepts. + * Options that the Protobuf emitter accepts. */ -export interface GrpcEmitterOptions { +export interface ProtobufEmitterOptions { /** * The directory where the emitter will write the Protobuf output tree. */ outputDirectory?: string; + + /** + * Don't emit anything. + */ + noEmit?: boolean; } -const EmitterOptionsSchema: JSONSchemaType = { +const EmitterOptionsSchema: JSONSchemaType = { type: "object", additionalProperties: false, properties: { outputDirectory: { type: "string", nullable: true }, + noEmit: { type: "boolean", nullable: true }, }, required: [], }; -export const CadlGrpcLibrary = createCadlLibrary({ - name: "cadl-grpc", +const PACKAGE_NAME = "@cadl-lang/protobuf"; + +export const CadlProtobufLibrary = createCadlLibrary({ + name: PACKAGE_NAME, + requireImports: [PACKAGE_NAME], diagnostics: { "field-index": { severity: "error", @@ -36,22 +45,23 @@ export const CadlGrpcLibrary = createCadlLibrary({ "root-operation": { severity: "error", messages: { - default: "operations in the root namespace are not supported (no associated gRPC service)", + default: + "operations in the root namespace are not supported (no associated Protobuf service)", }, }, "unsupported-return-type": { severity: "error", messages: { - default: "gRPC operations must return a named Model", + default: "Protobuf methods must return a named Model", }, }, "unsupported-input-type": { severity: "error", messages: { "wrong-number": - "gRPC operations must accept exactly one Model input (an empty model will do)", - "wrong-type": "gRPC operations may only accept a named Model as an input", - unconvertible: "input parameters cannot be converted to a gRPC model", + "Protobuf methods must accept exactly one Model input (an empty model will do)", + "wrong-type": "Protobuf methods may only accept a named Model as an input", + unconvertible: "input parameters cannot be converted to a Protobuf message", }, }, "unsupported-field-type": { @@ -59,6 +69,7 @@ export const CadlGrpcLibrary = createCadlLibrary({ messages: { unconvertible: paramMessage`cannot convert a ${"type"} to a protobuf type (only intrinsic types and models are supported)`, "unknown-intrinsic": paramMessage`no known protobuf scalar for intrinsic type ${"name"}`, + "unknown-scalar": paramMessage`no known protobuf scalar for Cadl scalar type ${"name"}`, "recursive-map": "a protobuf map's 'value' type may not refer to another map", }, }, @@ -72,13 +83,15 @@ export const CadlGrpcLibrary = createCadlLibrary({ severity: "error", messages: { default: - "enums must explicitly assign exactly one integer to each member to be used in a gRPC message", + "enums must explicitly assign exactly one integer to each member to be used in a Protobuf message", + "no-zero-first": + "the first variant of an enum must be set to zero to be used in a Protobuf message", }, }, "nested-array": { severity: "error", messages: { - default: "nested arrays are not supported by the gRPC emitter", + default: "nested arrays are not supported by the Protobuf emitter", }, }, "invalid-package-name": { @@ -87,16 +100,40 @@ export const CadlGrpcLibrary = createCadlLibrary({ default: paramMessage`${"name"} is not a valid package name (must consist of letters and numbers separated by ".")`, }, }, + "no-package": { + severity: "error", + messages: { + default: + "this type was used in a Protobuf service, but was outside the scope of any package namespace", + }, + }, + "illegal-reservation": { + severity: "error", + messages: { + default: + "reservation value must be a string literal, uint32 literal, or a tuple of two uint32 literals denoting a range", + }, + }, }, emitter: { options: EmitterOptionsSchema }, }); -export const { reportDiagnostic } = CadlGrpcLibrary; +export const { reportDiagnostic } = CadlProtobufLibrary; + +// TODO: onValidate? +export { $onEmit } from "./proto.js"; -export type CadlGrpcLibrary = typeof CadlGrpcLibrary; +export type CadlProtobufLibrary = typeof CadlProtobufLibrary; -const keys = ["fieldIndex", "service", "package"] as const; +const keys = [ + "fieldIndex", + "serviceInterface", + "packageName", + "externRef", + "stream", + "reserve", +] as const; -export const state = Object.fromEntries(keys.map((k) => [k, Symbol(`cadl-grpc::${k}`)])) as { +export const state = Object.fromEntries(keys.map((k) => [k, Symbol(`cadl-protobuf::${k}`)])) as { [K in typeof keys[number]]: symbol; }; diff --git a/packages/protobuf/src/proto.ts b/packages/protobuf/src/proto.ts new file mode 100644 index 00000000000..d2cf4e17847 --- /dev/null +++ b/packages/protobuf/src/proto.ts @@ -0,0 +1,187 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + DecoratorContext, + EmitOptionsFor, + EnumMember, + Interface, + Model, + ModelProperty, + Namespace, + NumericLiteral, + Operation, + Program, + Tuple, + Type, +} from "@cadl-lang/compiler"; + +import { StreamingMode } from "./ast.js"; +import { CadlProtobufLibrary, reportDiagnostic, state } from "./lib.js"; +import { createProtobufEmitter } from "./transform.js"; + +/** + * # cadl-protobuf : Protobuf/gRPC Emitter and Decorators for CADL + * + * This module defines an emitter and decorator library for CADL that enables specifying Protobuf services and models. + */ + +/** + * The maximum field index allowed by Protocol Buffers. + */ +const MAX_FIELD_INDEX = 2 ** 29 - 1; + +/** + * The field range between 19000 and 19999 is reserved for Protobuf client implementations. + */ +const IMPLEMENTATION_RESERVED_RANGE = [19000, 19999] as const; + +/** + * Defined in the [ProtoBuf Language Spec](https://developers.google.com/protocol-buffers/docs/reference/proto3-spec#identifiers). + * + * ident = letter { letter | decimalDigit | "_" } + * fullIdent = ident { "." ident } + */ +export const PROTO_FULL_IDENT = /([a-zA-Z][a-zA-Z0-9_]*)+/; + +/** + * Decorate an interface as a service, indicating that it represents a Protobuf `service` declaration. + * + * @param ctx - decorator context + * @param target - the decorated interface + */ +export function $serviceInterface(ctx: DecoratorContext, target: Interface) { + ctx.program.stateSet(state.serviceInterface).add(target); +} + +/** + * Rename a package instead of using the implied name of the service namespace. + * + * @param ctx - decorator context + * @param target - target decorator namespace + */ +export function $packageName(ctx: DecoratorContext, target: Namespace, name: string) { + ctx.program.stateMap(state.packageName).set(target, name); +} + +const mapState = Symbol("cadl-protobuf::_map"); + +export function isMap(program: Program, m: Type): boolean { + return program.stateSet(mapState).has(m); +} + +export function $_map(ctx: DecoratorContext, target: Model) { + ctx.program.stateSet(mapState).add(target); +} + +export function $externRef(ctx: DecoratorContext, target: Model, path: string, name: string) { + ctx.program.stateMap(state.externRef).set(target, [path, name]); +} + +export function $stream(ctx: DecoratorContext, target: Operation, mode: EnumMember) { + const emitStreamingMode = { + Duplex: StreamingMode.Duplex, + In: StreamingMode.In, + Out: StreamingMode.Out, + None: StreamingMode.None, + }[mode.name as string]; + + ctx.program.stateMap(state.stream).set(target, emitStreamingMode); +} + +function getTuple(program: Program, t: Type): [number, number] | null { + if (t.kind !== "Tuple" || t.values.some((v) => v.kind !== "Number") || t.values.length !== 2) { + reportDiagnostic(program, { + code: "illegal-reservation", + target: t, + }); + + return null; + } + + return (t as Tuple).values.map((v) => (v as NumericLiteral).value) as [number, number]; +} + +export function $reserve( + ctx: DecoratorContext, + target: Model, + ...reservations: readonly (Type | number | string)[] +) { + const finalReservations = reservations.map((reservation) => + typeof reservation === "object" ? getTuple(ctx.program, reservation) : reservation + ); + + ctx.program.stateMap(state.reserve).set(target, finalReservations); +} + +/** + * Decorate a model property with a field index. Field indices are required for all fields of emitted messages. + * + * @param param0 + * @param target + * @param fieldIndex + * @returns + */ +export function $field(ctx: DecoratorContext, target: ModelProperty, fieldIndex: number) { + if (!Number.isInteger(fieldIndex) || fieldIndex <= 0) { + reportDiagnostic(ctx.program, { + code: "field-index", + messageId: "invalid", + format: { + index: String(fieldIndex), + }, + target, + }); + return; + } else if (fieldIndex > MAX_FIELD_INDEX) { + reportDiagnostic(ctx.program, { + code: "field-index", + messageId: "out-of-bounds", + format: { + index: String(fieldIndex), + max: String(MAX_FIELD_INDEX + 1), + }, + target, + }); + return; + } else if ( + fieldIndex >= IMPLEMENTATION_RESERVED_RANGE[0] && + fieldIndex <= IMPLEMENTATION_RESERVED_RANGE[1] + ) { + reportDiagnostic(ctx.program, { + code: "field-index", + messageId: "reserved", + format: { + index: String(fieldIndex), + }, + target, + }); + } + + ctx.program.stateMap(state.fieldIndex).set(target, fieldIndex); +} + +/** + * Emitter main function. + * + * @param program - the program to emit + */ +export async function $onEmit(program: Program, options?: EmitOptionsFor) { + const emitter = createProtobufEmitter(program); + + await emitter({ + outputDirectory: options?.outputDirectory, + }); +} + +/*export async function $onValidate(program: Program) { + const emitter = createGrpcEmitter(program); + + await emitter({ + noEmit: true, + }); +}*/ + +export const namespace = "Cadl.Protobuf"; + +export { CadlProtobufLibrary as $lib }; diff --git a/packages/protobuf/src/transform.ts b/packages/protobuf/src/transform.ts new file mode 100644 index 00000000000..13f92d033b0 --- /dev/null +++ b/packages/protobuf/src/transform.ts @@ -0,0 +1,585 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + Enum, + getEffectiveModelType, + getTypeName, + Interface, + isDeclaredInNamespace, + listServices, + Model, + ModelProperty, + Namespace, + Operation, + Program, + resolvePath, + Scalar, + Type, +} from "@cadl-lang/compiler"; +import { + map, + ProtoEnumDeclaration, + ProtoFieldDeclaration, + ProtoFile, + ProtoMessageDeclaration, + ProtoMethodDeclaration, + ProtoRef, + ProtoScalar, + ProtoTopLevelDeclaration, + ProtoType, + ref, + scalar, + ScalarIntegralName, + StreamingMode, + unreachable, +} from "./ast.js"; +import { ProtobufEmitterOptions, reportDiagnostic, state } from "./lib.js"; +import { isMap } from "./proto.js"; +import { writeProtoFile } from "./write.js"; + +// Default options +const DEFAULT_OPTIONS = { + outputDirectory: "./cadl-output/", +} as const; + +/** + * Create a worker function that converts the CADL program to Protobuf and writes it to the file system. + */ +export function createProtobufEmitter( + program: Program +): (options?: ProtobufEmitterOptions) => Promise { + return async function doEmit(options) { + const outDir = resolvePath(options?.outputDirectory ?? DEFAULT_OPTIONS.outputDirectory); + + // Convert the program to a set of proto files. + const files = cadlToProto(program); + + if (!program.compilerOptions.noEmit && !options?.noEmit && !program.hasError()) { + for (const file of files) { + // If the file has a package, emit it to a path that is shaped like the package name. Otherwise emit to + // main.proto + + // Collisions have already been detected. + + const packageSlug = file.package?.split(".") ?? ["main"]; + const filePath = resolvePath(outDir, ...packageSlug.slice(0, -1)); + + await program.host.mkdirp(filePath); + await program.host.writeFile( + resolvePath(filePath, packageSlug[packageSlug.length - 1] + ".proto"), + writeProtoFile(file) + ); + } + } + }; +} + +/** + * Create a set of proto files that represent the CADL program. + * + * This is the meat of the emitter. + */ +function cadlToProto(program: Program): ProtoFile[] { + const packages = new Set(listServices(program).map((service) => service.type)); + + const serviceInterfaces = [...(program.stateSet(state.serviceInterface) as Set)]; + + const declarationMap = new Map( + [...packages].map((p) => [p, []]) + ); + + const visitedTypes = new Set(); + + /** + * Visits a model type, converting it into a message definition and adding it if it has not already been visited. + * @param model - the model type to consider + */ + function visitModel(model: Model) { + const modelPackage = getPackageOfType(program, model); + const declarations = modelPackage && declarationMap.get(modelPackage); + if (!visitedTypes.has(model)) { + visitedTypes.add(model); + declarations?.push(toMessage(model)); + } + } + + /** + * Visits an enum type, converting it into a Protobuf enum definition and adding it if it has not already been visited. + */ + function visitEnum(e: Enum) { + const modelPackage = getPackageOfType(program, e); + const declarations = modelPackage && declarationMap.get(modelPackage); + if (!visitedTypes.has(e)) { + visitedTypes.add(e); + + const members = [...e.members.values()]; + + // We only support enums where every variant is explicitly assigned an integer value + if ( + members.some( + ({ value: v }) => v === undefined || typeof v !== "number" || !Number.isInteger(v) + ) + ) { + reportDiagnostic(program, { + target: e, + code: "unconvertible-enum", + }); + } + + // we also only support enums where the first value is zero. + if (members[0].value !== 0) { + reportDiagnostic(program, { + target: members[0], + code: "unconvertible-enum", + messageId: "no-zero-first", + }); + } + + declarations?.push(toEnum(e)); + } + } + + const importMap = new Map([...packages].map((ns) => [ns, new Set()])); + + function typeWantsImport(program: Program, t: Model | Operation, path: string) { + const packageNs = getPackageOfType(program, t); + + if (packageNs) { + importMap.get(packageNs)?.add(path); + } + } + + const effectiveModelCache = new Map(); + + for (const packageNs of packages) { + addDeclarationsOfPackage(packageNs); + } + + // Emit a file per package. + const files = [...packages].map( + (namespace) => + ({ + package: program.stateMap(state.packageName).get(namespace), + + // TODO: The language guide is really unclear about how to handle these. We may also need a facility for + // allowing packages to declare extensions. + options: {}, + + imports: [...(importMap.get(namespace) ?? [])], + + declarations: declarationMap.get(namespace), + source: namespace, + } as ProtoFile) + ); + + checkForNamespaceCollisions(files); + + return files; + + /** + * Recursively searches a namespace for declarations that should be reified as Protobuf. + * + * @param namespace - the namespace to analyze + * @returns an array of declarations + */ + function addDeclarationsOfPackage(namespace: Namespace) { + const interfacesInNamespace = new Set( + serviceInterfaces.filter((iface) => isDeclaredInNamespace(iface, namespace)) + ); + + // Each interface will be reified as a `service` declaration. + const declarations = declarationMap.get(namespace)!; + for (const iface of interfacesInNamespace) { + declarations.push({ + kind: "service", + name: iface.name, + // The service's methods are just projections of the interface operations. + operations: [...iface.operations.values()].map(toMethodFromOperation), + }); + } + } + + // #region inline helpers + + /** + * @param operation - the operation to convert + * @returns a corresponding method declaration + */ + function toMethodFromOperation(operation: Operation): ProtoMethodDeclaration { + // TODO: add support for cross-package type references + // https://github.com/microsoft/cadl/issues/632 + + // TODO: until then, reject cross-package references + + const streamingMode = program.stateMap(state.stream).get(operation) ?? StreamingMode.None; + + return { + kind: "method", + stream: streamingMode, + name: capitalize(operation.name), + input: addInputParams(operation.parameters, operation), + returns: addReturnType(operation.returnType, operation), + }; + } + + /** + * Checks a parameter Model satisfies the constraints for a Protobuf method input and adds it to the declarations, + * returning a ProtoRef to the generated named message. + * + * @param model - the model to add + * @returns a reference to the model's message + */ + function addInputParams(paramsModel: Model, operation: Operation): ProtoRef { + const effectiveModel = computeEffectiveModel( + paramsModel, + capitalize(operation.name) + "Request" + ); + + /* c8 ignore start */ + + // Not sure if this can or can't happen. + if (!effectiveModel) { + reportDiagnostic(program, { + code: "unsupported-input-type", + messageId: "unconvertible", + target: paramsModel, + }); + + return unreachable("unsupported input type"); + } + /* c8 ignore stop */ + + // TODO: I've written this way too many times + const extern = program.stateMap(state.externRef).get(effectiveModel) as + | [string, string] + | undefined; + if (extern) { + typeWantsImport(program, operation, extern[0]); + return ref(extern[1]); + } + + return ref(effectiveModel.name); + } + + /** + * Checks that a return type is a Model and converts it to a message, adding it to the declarations and returning + * a reference to its name. + * + * @param t - the model to add + * @param operationName - the name of the originating operation, used to compute a synthetic model name if required + * @returns a reference to the model's message + */ + function addReturnType(t: Type, operation: Operation): ProtoRef { + // TODO: need to support importing google/protobuf/empty.proto and others + // https://github.com/microsoft/cadl/issues/630 + + // This is also very important for handling datetime values. + + // if (t.kind === "Intrinsic" && t.name === "void") { + // return ref("google.protobuf.Empty"); + // } + + switch (t.kind) { + case "Model": + return addReturnModel(t, operation); + + default: + // TODO: logic is duplicated in addReturnModel + reportDiagnostic(program, { + code: "unsupported-return-type", + target: t, + }); + + return unreachable("unsupported return type"); + } + } + + /** + * Converts a Cadl Model to a Protobuf Ref in return position, adding a corresponding message if necessary. + * + * @param m - the model to add to the Protofile. + * @returns a Protobuf reference to the model + */ + function addReturnModel(m: Model, operation: Operation): ProtoRef { + // TODO: handle import + const extern = program.stateMap(state.externRef).get(m) as [string, string] | undefined; + if (extern) { + typeWantsImport(program, operation, extern[0]); + return ref(extern[1]); + } + + const effectiveModel = computeEffectiveModel(m, capitalize(operation.name) + "Response"); + if (effectiveModel) { + return ref(effectiveModel.name); + } + + reportDiagnostic(program, { + code: "unsupported-return-type", + target: m, + }); + + return unreachable("unsupported return type"); + } + + /** + * Converts a CADL type to a Protobuf type, adding a corresponding message if necessary. + * + * @param t - the type to add to the ProtoFile. + * @returns a Protobuf type corresponding to the given type + */ + function addType(t: Type): ProtoType { + // TODO: too much duplication with addReturnModel + // TODO: handle import of extern + const extern = program.stateMap(state.externRef).get(t) as [string, string] | undefined; + if (extern) { + return ref(extern[1]); + } + + if (isMap(program, t)) { + return mapToProto(t as Model); + } + + // Arrays transform into repeated fields, so we'll silently replace `t` with the array's member if this is an array. + // The `repeated` keyword will be added when the field is composed. + if (isArray(t)) { + return arrayToProto(t as Model); + } + + // TODO: reject anonymous models at this stage + + switch (t.kind) { + case "Model": + visitModel(t); + return ref(t.name); + case "Enum": + visitEnum(t); + return ref(t.name); + case "Scalar": + return scalarToProto(t); + default: + reportDiagnostic(program, { + code: "unsupported-field-type", + messageId: "unconvertible", + format: { + type: t.kind, + }, + target: t, + }); + return unreachable("unsupported field type"); + } + } + + function mapToProto(t: Model): ProtoType { + const [keyType, valueType] = t.templateArguments ?? []; + + // A map's value cannot be another map. + if (isMap(program, valueType)) { + reportDiagnostic(program, { + code: "unsupported-field-type", + messageId: "recursive-map", + target: valueType, + }); + return unreachable("recursive map"); + } + + // This is a core compile error. + if (!keyType || !valueType) return unreachable("nonexistent map key or value type"); + + const keyProto = addType(keyType); + const valueProto = addType(valueType) as ProtoRef | ProtoScalar; + + return map(keyProto[1] as "string" | ScalarIntegralName, valueProto); + } + + function arrayToProto(t: Model): ProtoType { + const valueType = (t as Model).templateArguments![0]; + + // Nested arrays are not supported. + if (isArray(valueType)) { + reportDiagnostic(program, { + code: "nested-array", + target: t, + }); + return ref(""); + } + + return addType(valueType); + } + + function scalarToProto(t: Scalar): ProtoType { + const fullName = getTypeName(t); + + const protoType = { + "Cadl.bytes": scalar("bytes"), + "Cadl.boolean": scalar("bool"), + "Cadl.string": scalar("string"), + "Cadl.int32": scalar("int32"), + "Cadl.int64": scalar("int64"), + "Cadl.uint32": scalar("uint32"), + "Cadl.uint64": scalar("uint64"), + "Cadl.float32": scalar("float"), + "Cadl.float64": scalar("double"), + "Cadl.Protobuf.sfixed32": scalar("sfixed32"), + "Cadl.Protobuf.sfixed64": scalar("sfixed64"), + "Cadl.Protobuf.sint32": scalar("sint32"), + "Cadl.Protobuf.sint64": scalar("sint64"), + "Cadl.Protobuf.fixed32": scalar("fixed32"), + "Cadl.Protobuf.fixed64": scalar("fixed64"), + }[fullName]; + + if (!protoType) { + reportDiagnostic(program, { + code: "unsupported-field-type", + messageId: "unknown-scalar", + format: { + name: fullName, + }, + target: t, + }); + return unreachable("unknown scalar"); + } + + return protoType; + } + + function computeEffectiveModel(model: Model, anonymousModelName: string): Model | undefined { + if (effectiveModelCache.has(model)) return effectiveModelCache.get(model); + + let effectiveModel = getEffectiveModelType(program, model); + + if (effectiveModel.name === "") { + // Name the model automatically if it is anonymous + effectiveModel = program.checker.createAndFinishType({ + ...model, + name: anonymousModelName, + }); + } + + if (!program.stateMap(state.externRef).has(effectiveModel)) { + visitModel(effectiveModel); + } + + effectiveModelCache.set(model, effectiveModel); + + return effectiveModel; + } + // #endregion + + function checkForNamespaceCollisions(files: ProtoFile[]) { + const namespaces = new Set(); + + for (const file of files) { + if (namespaces.has(file.package)) { + reportDiagnostic(program, { + code: "namespace-collision", + format: { + name: `"${file.package}"` ?? "", + }, + target: file.source, + }); + } + + namespaces.add(file.package); + } + } + + /** + * @param model - the Model to convert + * @returns a corresponding message declaration + */ + function toMessage(model: Model): ProtoMessageDeclaration { + return { + kind: "message", + name: model.name, + reservations: program.stateMap(state.reserve).get(model), + declarations: [...model.properties.values()].map(toField), + }; + } + + /** + * @param property - the ModelProperty to convert + * @returns a corresponding field declaration + */ + function toField(property: ModelProperty): ProtoFieldDeclaration { + const field: ProtoFieldDeclaration = { + kind: "field", + name: property.name, + type: addType(property.type), + index: program.stateMap(state.fieldIndex).get(property), + }; + + // Determine if the property type is an array + if (isArray(property.type)) field.repeated = true; + + return field; + } + + /** + * @param e - the Enum to convert + * @returns a corresponding protobuf enum declaration + * + * INVARIANT: the enum's members must be integer values + */ + function toEnum(e: Enum): ProtoEnumDeclaration { + const needsAlias = new Set([...e.members.values()].map((v) => v.value)).size !== e.members.size; + + return { + kind: "enum", + name: e.name, + allowAlias: needsAlias, + variants: [...e.members.values()].map(({ name, value }) => [name, value as number]), + }; + } + + function getPackageOfType( + program: Program, + t: Model | Namespace | Operation | Interface | Enum + ): Namespace | null { + /* c8 ignore start */ + + // Most of this should be unreachable, but we'll guard it with diagnostics anyway in case of eventual synthetic types. + + switch (t.kind) { + case "Enum": + case "Model": + case "Interface": + if (!t.namespace) { + reportDiagnostic(program, { code: "no-package", target: t }); + return null; + } else { + return getPackageOfType(program, t.namespace); + } + case "Operation": { + const logicalParent = t.interface ?? t.namespace; + if (!logicalParent) { + reportDiagnostic(program, { code: "no-package", target: t }); + return null; + } else { + return getPackageOfType(program, logicalParent); + } + } + case "Namespace": + if (packages.has(t)) return t; + + if (!t.namespace) { + reportDiagnostic(program, { code: "no-package", target: t }); + return null; + } else { + return getPackageOfType(program, t.namespace); + } + } + /* c8 ignore stop */ + } +} + +function isArray(t: Type) { + return t.kind === "Model" && t.name === "Array" && t.namespace?.name === "Cadl"; +} + +/** + * Simple utility function to capitalize a string. + */ +function capitalize(s: S) { + return (s.slice(0, 1).toUpperCase() + s.slice(1)) as Capitalize; +} diff --git a/packages/grpc/src/write.ts b/packages/protobuf/src/write.ts similarity index 92% rename from packages/grpc/src/write.ts rename to packages/protobuf/src/write.ts index 2a6db977665..7397f313e1c 100644 --- a/packages/grpc/src/write.ts +++ b/packages/protobuf/src/write.ts @@ -12,7 +12,8 @@ import { ProtoOneOfDeclaration, ProtoServiceDeclaration, ProtoType, -} from "./proto.js"; + StreamingMode, +} from "./ast.js"; // This module defines how to emit the text representation of a ProtoFile AST. @@ -34,6 +35,12 @@ export function writeProtoFile(file: ProtoFile): string { if (file.package) result += `\npackage ${file.package};\n`; + for (const _import of file.imports) { + result += `\nimport "${_import}";`; + } + + if (file.imports.length > 0) result += "\n"; + const opts = Object.entries(file.options); for (const [name, valueData] of opts) { const value = typeof valueData === "string" ? `"${valueData}"` : valueData.toString(); @@ -73,6 +80,7 @@ function* writeDeclaration(decl: ProtoDeclaration): Iterable { case "method": yield writeMethod(decl); return; + /* c8 ignore next 5 */ default: const __exhaust: never = decl; throw __exhaust; @@ -123,7 +131,14 @@ function* writeService(decl: ProtoServiceDeclaration): Iterable { } function writeMethod(decl: ProtoMethodDeclaration): string { - return `rpc ${decl.name}(${writeType(decl.input)}) returns (${writeType(decl.returns)});`; + const [inStream, outStream] = [ + decl.stream & StreamingMode.In, + decl.stream & StreamingMode.Out, + ].map((v) => (v ? "stream " : "")); + + return `rpc ${decl.name}(${inStream}${writeType(decl.input)}) returns (${outStream}${writeType( + decl.returns + )});`; } function* writeOneOf(decl: ProtoOneOfDeclaration): Iterable { @@ -137,6 +152,8 @@ function* writeEnum(decl: ProtoEnumDeclaration): Iterable { yield `enum ${decl.name} {`; if (decl.allowAlias) { yield " option allow_alias = true;"; + + if (decl.variants.length > 0) yield ""; } yield* indent(flatMap(decl.variants, ([name, idx]) => `${name} = ${idx};`)); yield "}"; diff --git a/packages/grpc/test/scenarios.spec.ts b/packages/protobuf/test/scenarios.spec.ts similarity index 57% rename from packages/grpc/test/scenarios.spec.ts rename to packages/protobuf/test/scenarios.spec.ts index d64fe7dcaed..a39887d5a0a 100644 --- a/packages/grpc/test/scenarios.spec.ts +++ b/packages/protobuf/test/scenarios.spec.ts @@ -10,22 +10,24 @@ import { CadlTestLibrary, createTestHost, resolveVirtualPath } from "@cadl-lang/ const SCENARIOS_DIRECTORY = url.fileURLToPath(new url.URL("../../test/scenarios", import.meta.url)); -const patternsToRecord = process.env.RECORD_SCENARIOS?.split(",") ?? []; +const shouldRecord = process.env.RECORD === "true"; +const patternsToRun = process.env.RUN_SCENARIOS?.split(",") ?? ["*"]; const CadlGrpcTestLibrary: CadlTestLibrary = { - name: "@cadl-lang/grpc", + name: "@cadl-lang/protobuf", packageRoot: path.resolve(url.fileURLToPath(import.meta.url), "../../../"), files: [ - { realDir: "", pattern: "package.json", virtualPath: "./node_modules/@cadl-lang/grpc" }, + { realDir: "", pattern: "package.json", virtualPath: "./node_modules/@cadl-lang/protobuf" }, { realDir: "dist/src", pattern: "*.js", - virtualPath: "./node_modules/@cadl-lang/grpc/dist/src", + virtualPath: "./node_modules/@cadl-lang/protobuf/dist/src", }, + { realDir: "lib/", pattern: "*.cadl", virtualPath: "./node_modules/@cadl-lang/protobuf/lib" }, ], }; -describe("gRPC scenarios", function () { +describe("protobuf scenarios", function () { const scenarios = fs .readdirSync(SCENARIOS_DIRECTORY) .map((dn) => path.join(SCENARIOS_DIRECTORY, dn)) @@ -34,56 +36,70 @@ describe("gRPC scenarios", function () { for (const scenario of scenarios) { const scenarioName = path.basename(scenario); - it(scenarioName, async function () { - const inputFiles = await readdirRecursive(path.join(scenario, "input")); - const emitResult = await doEmit(inputFiles); + const shouldRun = micromatch.isMatch(scenarioName, patternsToRun); - const shouldRecord = micromatch.isMatch(scenarioName, patternsToRecord); + shouldRun && + it(scenarioName, async function () { + const inputFiles = await readdirRecursive(path.join(scenario, "input")); + const emitResult = await doEmit(inputFiles); - const expectationDirectory = path.resolve(scenario, "output"); - const diagnosticsExpectationPath = path.resolve(scenario, "diagnostics.txt"); + const expectationDirectory = path.resolve(scenario, "output"); + const diagnosticsExpectationPath = path.resolve(scenario, "diagnostics.txt"); - if (shouldRecord) { - // Write new output to the scenario's output folder. + if (shouldRecord) { + // Write new output to the scenario's output folder. - await writeExpectationDirectory(expectationDirectory, emitResult.files); + await writeExpectationDirectory(expectationDirectory, emitResult.files); - if (emitResult.diagnostics.length > 0) { - const diagnostics = emitResult.diagnostics.join("\n"); + await fs.promises.rm(diagnosticsExpectationPath, { force: true }); - await fs.promises.writeFile(diagnosticsExpectationPath, diagnostics); - } - } else { - // It's an error if any file in the expected files is missing, if any file in the output files doesn't have a - // corresponding expectation, or if any file in the output files doesn't match its corresponding output file - // character for character. - - // `throwIfNoEntry` is not supported with promisified fs.promises.stat. - if (!fs.statSync(expectationDirectory, { throwIfNoEntry: false })) { - assert.strictEqual( - Object.entries(emitResult.files).length, - 0, - "no expectations exist, but output files were generated" - ); - } else { - const expectedFiles = await readdirRecursive(expectationDirectory); + if (emitResult.diagnostics.length > 0) { + const diagnostics = emitResult.diagnostics.join("\n"); - assertFilesAsExpected(emitResult.files, expectedFiles); - } - - if (emitResult.diagnostics.length > 0) { - // Check the diagnostics. + await fs.promises.writeFile(diagnosticsExpectationPath, diagnostics); + } + } else { + // It's an error if any file in the expected files is missing, if any file in the output files doesn't have a + // corresponding expectation, or if any file in the output files doesn't match its corresponding output file + // character for character. + + let err: Error | undefined = undefined; + + // `throwIfNoEntry` is not supported with promisified fs.promises.stat. + if (!fs.statSync(expectationDirectory, { throwIfNoEntry: false })) { + assert.strictEqual( + Object.entries(emitResult.files).length, + 0, + "no expectations exist, but output files were generated" + ); + } else { + const expectedFiles = await readdirRecursive(expectationDirectory); + + // Need to defer this error until we've checked for diagnostics below. If diagnostics were unexpectedly + // raised and inhibited emit, that should be the primary error, not this one. + try { + assertFilesAsExpected(emitResult.files, expectedFiles); + } catch (e: unknown) { + err = e as Error; + } + } + + let expectedDiagnostics: string; + try { + expectedDiagnostics = (await fs.promises.readFile(diagnosticsExpectationPath)).toString( + "utf-8" + ); + } catch { + expectedDiagnostics = ""; + } const diagnostics = emitResult.diagnostics.join("\n"); - const expectedDiagnostics = await ( - await fs.promises.readFile(diagnosticsExpectationPath) - ).toString("utf-8"); + assert.strictEqual(diagnostics, expectedDiagnostics, "expected equivalent diagnostics"); - assert.strictEqual(diagnostics, expectedDiagnostics); + if (err) throw err; } - } - }); + }); } }); diff --git a/packages/grpc/test/scenarios/anonymous-package/input/main.cadl b/packages/protobuf/test/scenarios/anonymous-package/input/main.cadl similarity index 77% rename from packages/grpc/test/scenarios/anonymous-package/input/main.cadl rename to packages/protobuf/test/scenarios/anonymous-package/input/main.cadl index ebf546aaf5c..0907961a0b6 100644 --- a/packages/grpc/test/scenarios/anonymous-package/input/main.cadl +++ b/packages/protobuf/test/scenarios/anonymous-package/input/main.cadl @@ -2,10 +2,12 @@ import "@cadl-lang/grpc"; using Cadl.Grpc; -@Cadl.Grpc.package +@service({ + title: "gRPC Test Service", +}) namespace Test; -@Cadl.Grpc.service +@serviceInterface interface Service { foo(...Input): Output; } diff --git a/packages/grpc/test/scenarios/anonymous-package/output/main.proto b/packages/protobuf/test/scenarios/anonymous-package/output/main.proto similarity index 71% rename from packages/grpc/test/scenarios/anonymous-package/output/main.proto rename to packages/protobuf/test/scenarios/anonymous-package/output/main.proto index 1e4f5333ced..65fdaa19693 100644 --- a/packages/grpc/test/scenarios/anonymous-package/output/main.proto +++ b/packages/protobuf/test/scenarios/anonymous-package/output/main.proto @@ -1,4 +1,4 @@ -/* Generated by Microsoft CADL - Canonical API Definition Language */ +/* Generated by Microsoft Cadl */ syntax = "proto3"; diff --git a/packages/protobuf/test/scenarios/array-nested/diagnostics.txt b/packages/protobuf/test/scenarios/array-nested/diagnostics.txt new file mode 100644 index 00000000000..1f4533faf6c --- /dev/null +++ b/packages/protobuf/test/scenarios/array-nested/diagnostics.txt @@ -0,0 +1 @@ +/test/.cadl/lib/lib.cadl:27:1 - error @cadl-lang/grpc/nested-array: nested arrays are not supported by the gRPC emitter \ No newline at end of file diff --git a/packages/grpc/test/scenarios/array-nested/input/main.cadl b/packages/protobuf/test/scenarios/array-nested/input/main.cadl similarity index 79% rename from packages/grpc/test/scenarios/array-nested/input/main.cadl rename to packages/protobuf/test/scenarios/array-nested/input/main.cadl index e1cc0f3b106..edc1eb41b88 100644 --- a/packages/grpc/test/scenarios/array-nested/input/main.cadl +++ b/packages/protobuf/test/scenarios/array-nested/input/main.cadl @@ -2,10 +2,10 @@ import "@cadl-lang/grpc"; using Cadl.Grpc; -@package("com.azure.test") -namespace Test; +@service +namespace com.azure.Test; -@Cadl.Grpc.service +@serviceInterface interface Service { foo(...Input): Output; } diff --git a/packages/grpc/test/scenarios/array/input/main.cadl b/packages/protobuf/test/scenarios/array/input/main.cadl similarity index 81% rename from packages/grpc/test/scenarios/array/input/main.cadl rename to packages/protobuf/test/scenarios/array/input/main.cadl index 72e23ca9768..8f4c25ed039 100644 --- a/packages/grpc/test/scenarios/array/input/main.cadl +++ b/packages/protobuf/test/scenarios/array/input/main.cadl @@ -2,10 +2,11 @@ import "@cadl-lang/grpc"; using Cadl.Grpc; -@package("com.azure.test") +@service +@packageName("com.azure.test") namespace Test; -@Cadl.Grpc.service +@serviceInterface interface Service { foo(...Input): Output; } diff --git a/packages/grpc/test/scenarios/array/output/com/azure/test.proto b/packages/protobuf/test/scenarios/array/output/com/azure/test.proto similarity index 77% rename from packages/grpc/test/scenarios/array/output/com/azure/test.proto rename to packages/protobuf/test/scenarios/array/output/com/azure/test.proto index a2b6c0acedb..36bdd9dc895 100644 --- a/packages/grpc/test/scenarios/array/output/com/azure/test.proto +++ b/packages/protobuf/test/scenarios/array/output/com/azure/test.proto @@ -1,4 +1,4 @@ -/* Generated by Microsoft CADL - Canonical API Definition Language */ +/* Generated by Microsoft Cadl */ syntax = "proto3"; diff --git a/packages/protobuf/test/scenarios/cross package references/input/main.cadl b/packages/protobuf/test/scenarios/cross package references/input/main.cadl new file mode 100644 index 00000000000..68306f4bf61 --- /dev/null +++ b/packages/protobuf/test/scenarios/cross package references/input/main.cadl @@ -0,0 +1,25 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@packageName("A") +@service +namespace A { + model Output { + @field(1) testOutputField: int32; + @field(2) secondField: string; + } +} + +@packageName("B") +@service +namespace B { + @serviceInterface + interface Service { + foo(...Input): A.Output; + } + + model Input { + @field(1) testInputField: string; + } +} diff --git a/packages/protobuf/test/scenarios/cross package references/output/A.proto b/packages/protobuf/test/scenarios/cross package references/output/A.proto new file mode 100644 index 00000000000..ff9de7b802c --- /dev/null +++ b/packages/protobuf/test/scenarios/cross package references/output/A.proto @@ -0,0 +1,10 @@ +/* Generated by Microsoft Cadl */ + +syntax = "proto3"; + +package A; + +message Output { + int32 testOutputField = 1; + string secondField = 2; +} diff --git a/packages/protobuf/test/scenarios/cross package references/output/B.proto b/packages/protobuf/test/scenarios/cross package references/output/B.proto new file mode 100644 index 00000000000..3dc61405a8d --- /dev/null +++ b/packages/protobuf/test/scenarios/cross package references/output/B.proto @@ -0,0 +1,13 @@ +/* Generated by Microsoft Cadl */ + +syntax = "proto3"; + +package B; + +message Input { + string testInputField = 1; +} + +service Service { + rpc Foo(Input) returns (A.Output); +} diff --git a/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt b/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt new file mode 100644 index 00000000000..3d2a4bd2ff5 --- /dev/null +++ b/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt @@ -0,0 +1,4 @@ +/test/main.cadl:19:1 - error @cadl-lang/grpc/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a gRPC message +/test/main.cadl:20:3 - error @cadl-lang/grpc/unconvertible-enum: the first variant of an enum must be set to zero to be used in a gRPC message +/test/main.cadl:24:1 - error @cadl-lang/grpc/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a gRPC message +/test/main.cadl:25:3 - error @cadl-lang/grpc/unconvertible-enum: the first variant of an enum must be set to zero to be used in a gRPC message \ No newline at end of file diff --git a/packages/grpc/test/scenarios/enum-nonintegral/input/main.cadl b/packages/protobuf/test/scenarios/enum-nonintegral/input/main.cadl similarity index 80% rename from packages/grpc/test/scenarios/enum-nonintegral/input/main.cadl rename to packages/protobuf/test/scenarios/enum-nonintegral/input/main.cadl index 9eab3861a8a..c365e40036b 100644 --- a/packages/grpc/test/scenarios/enum-nonintegral/input/main.cadl +++ b/packages/protobuf/test/scenarios/enum-nonintegral/input/main.cadl @@ -2,10 +2,11 @@ import "@cadl-lang/grpc"; using Cadl.Grpc; -@package("com.azure.test") +@packageName("com.azure.test") +@service namespace Test; -@Cadl.Grpc.service +@serviceInterface interface Service { foo(...Input): Output; } @@ -17,12 +18,12 @@ model Input { enum InputType { FOO: 1, - BAR: "test" + BAR: "test", } enum OutputType { FOO, - BAR + BAR, } model Output { diff --git a/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt b/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt new file mode 100644 index 00000000000..d943cf204b9 --- /dev/null +++ b/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt @@ -0,0 +1 @@ +/test/main.cadl:19:3 - error @cadl-lang/grpc/unconvertible-enum: the first variant of an enum must be set to zero to be used in a gRPC message \ No newline at end of file diff --git a/packages/grpc/test/scenarios/enum/input/main.cadl b/packages/protobuf/test/scenarios/enum-nozero/input/main.cadl similarity index 74% rename from packages/grpc/test/scenarios/enum/input/main.cadl rename to packages/protobuf/test/scenarios/enum-nozero/input/main.cadl index e2891325197..be08539d4aa 100644 --- a/packages/grpc/test/scenarios/enum/input/main.cadl +++ b/packages/protobuf/test/scenarios/enum-nozero/input/main.cadl @@ -2,10 +2,10 @@ import "@cadl-lang/grpc"; using Cadl.Grpc; -@package("com.azure.test") +@service namespace Test; -@Cadl.Grpc.service +@serviceInterface interface Service { foo(...Input): Output; } @@ -17,10 +17,9 @@ model Input { enum InputType { FOO: 1, - BAR: 2 + BAR: 2, } model Output { - @field(1) testOutputField: int32; @field(2) secondField: string; } diff --git a/packages/protobuf/test/scenarios/enum/input/main.cadl b/packages/protobuf/test/scenarios/enum/input/main.cadl new file mode 100644 index 00000000000..a66a08e0f32 --- /dev/null +++ b/packages/protobuf/test/scenarios/enum/input/main.cadl @@ -0,0 +1,34 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@packageName("com.azure.test") +@service +namespace Test; + +@serviceInterface +interface Service { + foo(...Input): Output; +} + +model Input { + @field(1) testInputField: string; + @field(2) type: InputType; + @field(3) aliased: InputTypeWithAlias; +} + +enum InputType { + FOO: 0, + BAR: 1, +} + +enum InputTypeWithAlias { + FOO: 0, + BAR: 1, + BAZ: 1, +} + +model Output { + @field(1) testOutputField: int32; + @field(2) secondField: string; +} diff --git a/packages/grpc/test/scenarios/enum/output/com/azure/test.proto b/packages/protobuf/test/scenarios/enum/output/com/azure/test.proto similarity index 59% rename from packages/grpc/test/scenarios/enum/output/com/azure/test.proto rename to packages/protobuf/test/scenarios/enum/output/com/azure/test.proto index 0d1a49a326b..0d6c35da759 100644 --- a/packages/grpc/test/scenarios/enum/output/com/azure/test.proto +++ b/packages/protobuf/test/scenarios/enum/output/com/azure/test.proto @@ -1,17 +1,26 @@ -/* Generated by Microsoft CADL - Canonical API Definition Language */ +/* Generated by Microsoft Cadl */ syntax = "proto3"; package com.azure.test; enum InputType { - FOO = 1; - BAR = 2; + FOO = 0; + BAR = 1; +} + +enum InputTypeWithAlias { + option allow_alias = true; + + FOO = 0; + BAR = 1; + BAZ = 1; } message Input { string testInputField = 1; InputType type = 2; + InputTypeWithAlias aliased = 3; } message Output { diff --git a/packages/protobuf/test/scenarios/extern/input/main.cadl b/packages/protobuf/test/scenarios/extern/input/main.cadl new file mode 100644 index 00000000000..31363aa303d --- /dev/null +++ b/packages/protobuf/test/scenarios/extern/input/main.cadl @@ -0,0 +1,17 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@service +namespace Test; + +@serviceInterface +interface Service { + foo(...MyExtern): WellKnown.Empty; + + bar(@field(1) empty: WellKnown.Empty): { + @field(1) myExtern: MyExtern; + }; +} + +model MyExtern is Extern<"foo/bar.proto", "foo.Bar">; diff --git a/packages/protobuf/test/scenarios/extern/output/main.proto b/packages/protobuf/test/scenarios/extern/output/main.proto new file mode 100644 index 00000000000..74f67dcfabb --- /dev/null +++ b/packages/protobuf/test/scenarios/extern/output/main.proto @@ -0,0 +1,19 @@ +/* Generated by Microsoft Cadl */ + +syntax = "proto3"; + +import "foo/bar.proto"; +import "google/protobuf/empty.proto"; + +message BarRequest { + google.protobuf.Empty empty = 1; +} + +message BarResponse { + foo.Bar myExtern = 1; +} + +service Service { + rpc Foo(foo.Bar) returns (google.protobuf.Empty); + rpc Bar(BarRequest) returns (BarResponse); +} diff --git a/packages/grpc/test/scenarios/inferred-message-names/input/main.cadl b/packages/protobuf/test/scenarios/inferred-message-names/input/main.cadl similarity index 77% rename from packages/grpc/test/scenarios/inferred-message-names/input/main.cadl rename to packages/protobuf/test/scenarios/inferred-message-names/input/main.cadl index 44dc972f3d8..b667da921ce 100644 --- a/packages/grpc/test/scenarios/inferred-message-names/input/main.cadl +++ b/packages/protobuf/test/scenarios/inferred-message-names/input/main.cadl @@ -2,10 +2,11 @@ import "@cadl-lang/grpc"; using Cadl.Grpc; -@package("com.azure.test") +@packageName("com.azure.test") +@service namespace Test; -@Cadl.Grpc.service +@serviceInterface interface Service { foo(@field(1) testInputField: string): { @field(1) testOutputField: int32; diff --git a/packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto b/packages/protobuf/test/scenarios/inferred-message-names/output/com/azure/test.proto similarity index 77% rename from packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto rename to packages/protobuf/test/scenarios/inferred-message-names/output/com/azure/test.proto index f9a05a14dd7..55904dc42a4 100644 --- a/packages/grpc/test/scenarios/inferred-message-names/output/com/azure/test.proto +++ b/packages/protobuf/test/scenarios/inferred-message-names/output/com/azure/test.proto @@ -1,4 +1,4 @@ -/* Generated by Microsoft CADL - Canonical API Definition Language */ +/* Generated by Microsoft Cadl */ syntax = "proto3"; diff --git a/packages/protobuf/test/scenarios/map/input/main.cadl b/packages/protobuf/test/scenarios/map/input/main.cadl new file mode 100644 index 00000000000..179d8907092 --- /dev/null +++ b/packages/protobuf/test/scenarios/map/input/main.cadl @@ -0,0 +1,15 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@service +namespace Test; + +@serviceInterface +interface Service { + foo(...Input): WellKnown.Empty; +} + +model Input { + @field(1) testInputField: Cadl.Grpc.Map; +} diff --git a/packages/protobuf/test/scenarios/map/output/main.proto b/packages/protobuf/test/scenarios/map/output/main.proto new file mode 100644 index 00000000000..e8dc8172671 --- /dev/null +++ b/packages/protobuf/test/scenarios/map/output/main.proto @@ -0,0 +1,13 @@ +/* Generated by Microsoft Cadl */ + +syntax = "proto3"; + +import "google/protobuf/empty.proto"; + +message Input { + map testInputField = 1; +} + +service Service { + rpc Foo(Input) returns (google.protobuf.Empty); +} diff --git a/packages/protobuf/test/scenarios/reserved fields/input/main.cadl b/packages/protobuf/test/scenarios/reserved fields/input/main.cadl new file mode 100644 index 00000000000..1e3a8551ace --- /dev/null +++ b/packages/protobuf/test/scenarios/reserved fields/input/main.cadl @@ -0,0 +1,16 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@service +namespace Test; + +@serviceInterface +interface Service { + foo(...Input): {}; +} + +@reserve(2, 15, [9, 11], "foo", "bar") +model Input { + @field(1) testInputField: string; +} diff --git a/packages/protobuf/test/scenarios/reserved fields/output/main.proto b/packages/protobuf/test/scenarios/reserved fields/output/main.proto new file mode 100644 index 00000000000..f4746e09cef --- /dev/null +++ b/packages/protobuf/test/scenarios/reserved fields/output/main.proto @@ -0,0 +1,16 @@ +/* Generated by Microsoft Cadl */ + +syntax = "proto3"; + +message Input { + reserved 2, 15, 9 to 11; + reserved "foo", "bar"; + + string testInputField = 1; +} + +message FooResponse {} + +service Service { + rpc Foo(Input) returns (FooResponse); +} diff --git a/packages/protobuf/test/scenarios/simple-error/diagnostics.txt b/packages/protobuf/test/scenarios/simple-error/diagnostics.txt new file mode 100644 index 00000000000..df4672c9a6c --- /dev/null +++ b/packages/protobuf/test/scenarios/simple-error/diagnostics.txt @@ -0,0 +1,5 @@ +/test/main.cadl:12:5 - error @cadl-lang/grpc/field-index: field index 0 is invalid (must be an integer greater than zero) +/test/main.cadl:13:5 - error @cadl-lang/grpc/field-index: field index 536870912 is out of bounds (must be less than 536870912) +/test/main.cadl:14:5 - error @cadl-lang/grpc/field-index: field index 19000 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) +/test/main.cadl:15:5 - error @cadl-lang/grpc/field-index: field index 19123 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) +/test/main.cadl:16:5 - error @cadl-lang/grpc/field-index: field index 19999 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/simple-error/input/main.cadl b/packages/protobuf/test/scenarios/simple-error/input/main.cadl new file mode 100644 index 00000000000..f3e6cab5ea9 --- /dev/null +++ b/packages/protobuf/test/scenarios/simple-error/input/main.cadl @@ -0,0 +1,18 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@service +namespace Test; + +@serviceInterface +interface Service { + // invalid field index + invalidIndices( + @field(0) testInputField: string, + @field(536870912) testInputField2: string, + @field(19000) testInputField3: string, + @field(19123) testInputField4: string, + @field(19999) testInputField5: string + ): {}; +} diff --git a/packages/grpc/test/scenarios/simple/input/main.cadl b/packages/protobuf/test/scenarios/simple/input/main.cadl similarity index 81% rename from packages/grpc/test/scenarios/simple/input/main.cadl rename to packages/protobuf/test/scenarios/simple/input/main.cadl index 0c61ec37b6e..b6d6c10d8d8 100644 --- a/packages/grpc/test/scenarios/simple/input/main.cadl +++ b/packages/protobuf/test/scenarios/simple/input/main.cadl @@ -2,10 +2,11 @@ import "@cadl-lang/grpc"; using Cadl.Grpc; -@package("com.azure.test") +@packageName("com.azure.test") +@service namespace Test; -@Cadl.Grpc.service +@serviceInterface interface Service { foo(...Input): Output; } diff --git a/packages/grpc/test/scenarios/simple/output/com/azure/test.proto b/packages/protobuf/test/scenarios/simple/output/com/azure/test.proto similarity index 76% rename from packages/grpc/test/scenarios/simple/output/com/azure/test.proto rename to packages/protobuf/test/scenarios/simple/output/com/azure/test.proto index d668d7ae43a..ba42bbb740a 100644 --- a/packages/grpc/test/scenarios/simple/output/com/azure/test.proto +++ b/packages/protobuf/test/scenarios/simple/output/com/azure/test.proto @@ -1,4 +1,4 @@ -/* Generated by Microsoft CADL - Canonical API Definition Language */ +/* Generated by Microsoft Cadl */ syntax = "proto3"; diff --git a/packages/protobuf/test/scenarios/streams/input/main.cadl b/packages/protobuf/test/scenarios/streams/input/main.cadl new file mode 100644 index 00000000000..44eeffb22b6 --- /dev/null +++ b/packages/protobuf/test/scenarios/streams/input/main.cadl @@ -0,0 +1,30 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@service +namespace Test; + +@serviceInterface +interface Service { + @stream(StreamMode.Duplex) + duplex(...Input): Output; + + @stream(StreamMode.In) + in(...Input): Output; + + @stream(StreamMode.Out) + out(...Input): Output; + + @stream(StreamMode.None) + none(...Input): Output; +} + +model Input { + @field(1) testInputField: string; +} + +model Output { + @field(1) testOutputField: int32; + @field(2) secondField: string; +} diff --git a/packages/protobuf/test/scenarios/streams/output/main.proto b/packages/protobuf/test/scenarios/streams/output/main.proto new file mode 100644 index 00000000000..8b74f86af92 --- /dev/null +++ b/packages/protobuf/test/scenarios/streams/output/main.proto @@ -0,0 +1,19 @@ +/* Generated by Microsoft Cadl */ + +syntax = "proto3"; + +message Input { + string testInputField = 1; +} + +message Output { + int32 testOutputField = 1; + string secondField = 2; +} + +service Service { + rpc Duplex(stream Input) returns (stream Output); + rpc In(stream Input) returns (Output); + rpc Out(Input) returns (stream Output); + rpc None(Input) returns (Output); +} diff --git a/packages/protobuf/test/scenarios/type-validation/diagnostics.txt b/packages/protobuf/test/scenarios/type-validation/diagnostics.txt new file mode 100644 index 00000000000..b572d5bcddd --- /dev/null +++ b/packages/protobuf/test/scenarios/type-validation/diagnostics.txt @@ -0,0 +1 @@ +/test/.cadl/lib/lib.cadl:8:1 - error @cadl-lang/grpc/unsupported-return-type: gRPC operations must return a named Model \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/type-validation/input/main.cadl b/packages/protobuf/test/scenarios/type-validation/input/main.cadl new file mode 100644 index 00000000000..229a18f3847 --- /dev/null +++ b/packages/protobuf/test/scenarios/type-validation/input/main.cadl @@ -0,0 +1,11 @@ +import "@cadl-lang/grpc"; + +using Cadl.Grpc; + +@service +namespace Test; + +@serviceInterface +interface Service { + invalidReturn(): int32; +} diff --git a/packages/grpc/tsconfig.json b/packages/protobuf/tsconfig.json similarity index 100% rename from packages/grpc/tsconfig.json rename to packages/protobuf/tsconfig.json diff --git a/rush.json b/rush.json index 663e4cc51c6..0ca2932c86d 100644 --- a/rush.json +++ b/rush.json @@ -181,8 +181,8 @@ "shouldPublish": false }, { - "packageName": "@cadl-lang/grpc", - "projectFolder": "packages/grpc", + "packageName": "@cadl-lang/protobuf", + "projectFolder": "packages/protobuf", "reviewCategory": "production", "shouldPublish": false } From 97d6ff6a54e297984600962540a21c26dc59211b Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 2 Dec 2022 16:36:28 -0500 Subject: [PATCH 22/50] Implement cross-package references --- .../protobuf/lib/{grpc.cadl => proto.cadl} | 9 +- packages/protobuf/src/proto.ts | 1 + packages/protobuf/src/transform.ts | 175 ++++++++++++++---- packages/protobuf/test/scenarios.spec.ts | 6 +- .../anonymous-package/input/main.cadl | 4 +- .../scenarios/array-nested/diagnostics.txt | 2 +- .../scenarios/array-nested/input/main.cadl | 4 +- .../test/scenarios/array/input/main.cadl | 4 +- .../cross package references/input/main.cadl | 4 +- .../cross package references/output/B.proto | 2 + .../enum-nonintegral/diagnostics.txt | 8 +- .../enum-nonintegral/input/main.cadl | 4 +- .../scenarios/enum-nozero/diagnostics.txt | 2 +- .../scenarios/enum-nozero/input/main.cadl | 4 +- .../test/scenarios/enum/input/main.cadl | 4 +- .../test/scenarios/extern/input/main.cadl | 4 +- .../diagnostics.txt | 2 + .../input/main.cadl | 16 ++ .../inferred-message-names/input/main.cadl | 4 +- .../test/scenarios/map/input/main.cadl | 6 +- .../scenarios/reserved fields/input/main.cadl | 4 +- .../scenarios/simple-error/diagnostics.txt | 10 +- .../scenarios/simple-error/input/main.cadl | 4 +- .../test/scenarios/simple/input/main.cadl | 4 +- .../test/scenarios/streams/input/main.cadl | 4 +- .../scenarios/type-validation/diagnostics.txt | 2 +- .../scenarios/type-validation/input/main.cadl | 4 +- 27 files changed, 215 insertions(+), 82 deletions(-) rename packages/protobuf/lib/{grpc.cadl => proto.cadl} (79%) create mode 100644 packages/protobuf/test/scenarios/illegal field reservations/diagnostics.txt create mode 100644 packages/protobuf/test/scenarios/illegal field reservations/input/main.cadl diff --git a/packages/protobuf/lib/grpc.cadl b/packages/protobuf/lib/proto.cadl similarity index 79% rename from packages/protobuf/lib/grpc.cadl rename to packages/protobuf/lib/proto.cadl index e64dc67c29e..2fb5eadf2fe 100644 --- a/packages/protobuf/lib/grpc.cadl +++ b/packages/protobuf/lib/proto.cadl @@ -10,9 +10,14 @@ model Extern { namespace WellKnown { model Empty is Extern<"google/protobuf/empty.proto", "google.protobuf.Empty">; + model Timestamp + is Extern< + "google/protobuf/timestamp.proto", + "google.protobuf.Timestamp" + >; } -// Scalars supported by gRPC. +// Protobuf scalars that carry information about encoding. scalar sint32 extends int32; scalar sint64 extends int64; scalar sfixed32 extends int32; @@ -20,7 +25,7 @@ scalar sfixed64 extends int64; scalar fixed32 extends uint32; scalar fixed64 extends uint64; -alias integral = int32 | int64 | boolean; +alias integral = int32 | int64 | uint32 | uint64 | boolean; @_map model Map {} diff --git a/packages/protobuf/src/proto.ts b/packages/protobuf/src/proto.ts index d2cf4e17847..3c2741954bd 100644 --- a/packages/protobuf/src/proto.ts +++ b/packages/protobuf/src/proto.ts @@ -170,6 +170,7 @@ export async function $onEmit(program: Program, options?: EmitOptionsFor(); + const effectiveModelCache = new Map(); for (const packageNs of packages) { @@ -207,19 +214,24 @@ function cadlToProto(program: Program): ProtoFile[] { * @returns a corresponding method declaration */ function toMethodFromOperation(operation: Operation): ProtoMethodDeclaration { - // TODO: add support for cross-package type references - // https://github.com/microsoft/cadl/issues/632 - - // TODO: until then, reject cross-package references - const streamingMode = program.stateMap(state.stream).get(operation) ?? StreamingMode.None; return { kind: "method", stream: streamingMode, name: capitalize(operation.name), - input: addInputParams(operation.parameters, operation), - returns: addReturnType(operation.returnType, operation), + input: addImportSourceForProtoIfNeeded( + program, + addInputParams(operation.parameters, operation), + operation, + operation.parameters + ), + returns: addImportSourceForProtoIfNeeded( + program, + addReturnType(operation.returnType, operation), + operation, + operation.returnType as NamespaceTraversable + ), }; } @@ -271,19 +283,24 @@ function cadlToProto(program: Program): ProtoFile[] { * @returns a reference to the model's message */ function addReturnType(t: Type, operation: Operation): ProtoRef { - // TODO: need to support importing google/protobuf/empty.proto and others - // https://github.com/microsoft/cadl/issues/630 - - // This is also very important for handling datetime values. - - // if (t.kind === "Intrinsic" && t.name === "void") { - // return ref("google.protobuf.Empty"); - // } - switch (t.kind) { case "Model": return addReturnModel(t, operation); - + case "Intrinsic": + switch (t.name) { + case "unknown": + // We just use the built-in "unknown" type to mean the protobuf Any type + return ref("Any"); + case "void": { + const emptyRef = program.resolveTypeReference("Cadl.Protobuf.Empty")[0]; + if (emptyRef) { + const externRef = program.stateMap(state.externRef).get(emptyRef) as [string, string]; + typeWantsImport(program, operation, externRef[0]); + return ref(externRef[1]); + } + } + } + /* eslint-ignore-next-line no-fallthrough */ default: // TODO: logic is duplicated in addReturnModel reportDiagnostic(program, { @@ -302,7 +319,6 @@ function cadlToProto(program: Program): ProtoFile[] { * @returns a Protobuf reference to the model */ function addReturnModel(m: Model, operation: Operation): ProtoRef { - // TODO: handle import const extern = program.stateMap(state.externRef).get(m) as [string, string] | undefined; if (extern) { typeWantsImport(program, operation, extern[0]); @@ -328,22 +344,23 @@ function cadlToProto(program: Program): ProtoFile[] { * @param t - the type to add to the ProtoFile. * @returns a Protobuf type corresponding to the given type */ - function addType(t: Type): ProtoType { + function addType(t: Type, relativeSource: Model | Operation): ProtoType { // TODO: too much duplication with addReturnModel - // TODO: handle import of extern const extern = program.stateMap(state.externRef).get(t) as [string, string] | undefined; if (extern) { return ref(extern[1]); } if (isMap(program, t)) { - return mapToProto(t as Model); + const mapType = mapToProto(t as Model, relativeSource); + mapImportSourceInformation.set(mapType, [relativeSource, t as NamespaceTraversable]); + return mapType; } // Arrays transform into repeated fields, so we'll silently replace `t` with the array's member if this is an array. // The `repeated` keyword will be added when the field is composed. if (isArray(t)) { - return arrayToProto(t as Model); + return arrayToProto(t as Model, relativeSource); } // TODO: reject anonymous models at this stage @@ -370,7 +387,7 @@ function cadlToProto(program: Program): ProtoFile[] { } } - function mapToProto(t: Model): ProtoType { + function mapToProto(t: Model, relativeSource: Model | Operation): ProtoMap { const [keyType, valueType] = t.templateArguments ?? []; // A map's value cannot be another map. @@ -386,13 +403,14 @@ function cadlToProto(program: Program): ProtoFile[] { // This is a core compile error. if (!keyType || !valueType) return unreachable("nonexistent map key or value type"); - const keyProto = addType(keyType); - const valueProto = addType(valueType) as ProtoRef | ProtoScalar; + // TODO: key can be any integral type only + const keyProto = addType(keyType, relativeSource); + const valueProto = addType(valueType, relativeSource) as ProtoRef | ProtoScalar; return map(keyProto[1] as "string" | ScalarIntegralName, valueProto); } - function arrayToProto(t: Model): ProtoType { + function arrayToProto(t: Model, relativeSource: Model | Operation): ProtoType { const valueType = (t as Model).templateArguments![0]; // Nested arrays are not supported. @@ -404,7 +422,7 @@ function cadlToProto(program: Program): ProtoFile[] { return ref(""); } - return addType(valueType); + return addType(valueType, relativeSource); } function scalarToProto(t: Scalar): ProtoType { @@ -493,7 +511,7 @@ function cadlToProto(program: Program): ProtoFile[] { kind: "message", name: model.name, reservations: program.stateMap(state.reserve).get(model), - declarations: [...model.properties.values()].map(toField), + declarations: [...model.properties.values()].map((f) => toField(f, model)), }; } @@ -501,11 +519,16 @@ function cadlToProto(program: Program): ProtoFile[] { * @param property - the ModelProperty to convert * @returns a corresponding field declaration */ - function toField(property: ModelProperty): ProtoFieldDeclaration { + function toField(property: ModelProperty, model: Model): ProtoFieldDeclaration { const field: ProtoFieldDeclaration = { kind: "field", name: property.name, - type: addType(property.type), + type: addImportSourceForProtoIfNeeded( + program, + addType(property.type, model), + model, + property.type as NamespaceTraversable + ), index: program.stateMap(state.fieldIndex).get(property), }; @@ -532,9 +555,12 @@ function cadlToProto(program: Program): ProtoFile[] { }; } + type NamespaceTraversable = Enum | Model | Interface | Operation | Namespace; + function getPackageOfType( program: Program, - t: Model | Namespace | Operation | Interface | Enum + t: NamespaceTraversable, + quiet: boolean = false ): Namespace | null { /* c8 ignore start */ @@ -545,7 +571,7 @@ function cadlToProto(program: Program): ProtoFile[] { case "Model": case "Interface": if (!t.namespace) { - reportDiagnostic(program, { code: "no-package", target: t }); + !quiet && reportDiagnostic(program, { code: "no-package", target: t }); return null; } else { return getPackageOfType(program, t.namespace); @@ -553,7 +579,7 @@ function cadlToProto(program: Program): ProtoFile[] { case "Operation": { const logicalParent = t.interface ?? t.namespace; if (!logicalParent) { - reportDiagnostic(program, { code: "no-package", target: t }); + !quiet && reportDiagnostic(program, { code: "no-package", target: t }); return null; } else { return getPackageOfType(program, logicalParent); @@ -563,7 +589,7 @@ function cadlToProto(program: Program): ProtoFile[] { if (packages.has(t)) return t; if (!t.namespace) { - reportDiagnostic(program, { code: "no-package", target: t }); + !quiet && reportDiagnostic(program, { code: "no-package", target: t }); return null; } else { return getPackageOfType(program, t.namespace); @@ -571,6 +597,87 @@ function cadlToProto(program: Program): ProtoFile[] { } /* c8 ignore stop */ } + + function addImportSourceForProtoIfNeeded( + program: Program, + pt: T, + dependent: Model | Operation, + dependency: NamespaceTraversable + ): T { + { + // Early escape for externs + let effectiveModel: Model | undefined; + if ( + program.stateMap(state.externRef).has(dependency) || + (dependency.kind === "Model" && + (effectiveModel = effectiveModelCache.get(dependency)) && + program.stateMap(state.externRef).has(effectiveModel)) + ) { + return pt; + } + } + + if (isArray(dependency)) { + return addImportSourceForProtoIfNeeded( + program, + pt, + dependent, + (dependency as Model).templateArguments![0] as NamespaceTraversable + ); + } + try { + // If we had an error producing an "unreachable" type, we would actually reach it during validation below, so the + // try/catch allows us to pass the unreachable back up the chain. + return matchType(pt, { + map(k, v) { + const mapInfo = mapImportSourceInformation.get(pt as ProtoMap); + return mapInfo !== undefined + ? (map( + k, + addImportSourceForProtoIfNeeded(program, v, mapInfo[0], mapInfo[1]) as + | ProtoRef + | ProtoScalar + // Anything else is unreachable by construction. + ) as T) + : pt; + }, + scalar() { + return pt; + }, + ref(r) { + const [dependentPackage, dependencyPackage] = [ + getPackageOfType(program, dependent, true), + getPackageOfType(program, dependency, true), + ]; + + if ( + dependentPackage === null || + dependencyPackage === null || + dependentPackage === dependencyPackage + ) + return pt; + + const dependencyPackageName = program + .stateMap(state.packageName) + .get(dependencyPackage) as string | undefined; + + const dependencyPackagePrefix = + dependencyPackageName === undefined || dependencyPackageName === "" + ? "" + : dependencyPackageName + "."; + + const dependencyFileName = + (dependencyPackageName?.split(".") ?? ["main"]).join("/") + ".proto"; + + importMap.get(dependentPackage)?.add(dependencyFileName); + + return ref(dependencyPackagePrefix + r) as T; + }, + }); + } catch { + return pt; + } + } } function isArray(t: Type) { diff --git a/packages/protobuf/test/scenarios.spec.ts b/packages/protobuf/test/scenarios.spec.ts index a39887d5a0a..97256cf55c1 100644 --- a/packages/protobuf/test/scenarios.spec.ts +++ b/packages/protobuf/test/scenarios.spec.ts @@ -13,7 +13,7 @@ const SCENARIOS_DIRECTORY = url.fileURLToPath(new url.URL("../../test/scenarios" const shouldRecord = process.env.RECORD === "true"; const patternsToRun = process.env.RUN_SCENARIOS?.split(",") ?? ["*"]; -const CadlGrpcTestLibrary: CadlTestLibrary = { +const CadlProtobufTestLibrary: CadlTestLibrary = { name: "@cadl-lang/protobuf", packageRoot: path.resolve(url.fileURLToPath(import.meta.url), "../../../"), files: [ @@ -112,7 +112,7 @@ async function doEmit(files: Record): Promise { const baseOutputPath = resolveVirtualPath("test-output/"); const host = await createTestHost({ - libraries: [CadlGrpcTestLibrary], + libraries: [CadlProtobufTestLibrary], }); for (const [fileName, content] of Object.entries(files)) { @@ -123,7 +123,7 @@ async function doEmit(files: Record): Promise { outputPath: baseOutputPath, noEmit: false, emitters: { - "@cadl-lang/grpc": { + "@cadl-lang/protobuf": { outputDirectory: baseOutputPath, }, }, diff --git a/packages/protobuf/test/scenarios/anonymous-package/input/main.cadl b/packages/protobuf/test/scenarios/anonymous-package/input/main.cadl index 0907961a0b6..f6db5ce7fb5 100644 --- a/packages/protobuf/test/scenarios/anonymous-package/input/main.cadl +++ b/packages/protobuf/test/scenarios/anonymous-package/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @service({ title: "gRPC Test Service", diff --git a/packages/protobuf/test/scenarios/array-nested/diagnostics.txt b/packages/protobuf/test/scenarios/array-nested/diagnostics.txt index 1f4533faf6c..4d34e3c97b1 100644 --- a/packages/protobuf/test/scenarios/array-nested/diagnostics.txt +++ b/packages/protobuf/test/scenarios/array-nested/diagnostics.txt @@ -1 +1 @@ -/test/.cadl/lib/lib.cadl:27:1 - error @cadl-lang/grpc/nested-array: nested arrays are not supported by the gRPC emitter \ No newline at end of file +/test/.cadl/lib/lib.cadl:27:1 - error @cadl-lang/protobuf/nested-array: nested arrays are not supported by the Protobuf emitter \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/array-nested/input/main.cadl b/packages/protobuf/test/scenarios/array-nested/input/main.cadl index edc1eb41b88..e1781b60dd6 100644 --- a/packages/protobuf/test/scenarios/array-nested/input/main.cadl +++ b/packages/protobuf/test/scenarios/array-nested/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @service namespace com.azure.Test; diff --git a/packages/protobuf/test/scenarios/array/input/main.cadl b/packages/protobuf/test/scenarios/array/input/main.cadl index 8f4c25ed039..8211662a92a 100644 --- a/packages/protobuf/test/scenarios/array/input/main.cadl +++ b/packages/protobuf/test/scenarios/array/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @service @packageName("com.azure.test") diff --git a/packages/protobuf/test/scenarios/cross package references/input/main.cadl b/packages/protobuf/test/scenarios/cross package references/input/main.cadl index 68306f4bf61..fa176ee759f 100644 --- a/packages/protobuf/test/scenarios/cross package references/input/main.cadl +++ b/packages/protobuf/test/scenarios/cross package references/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @packageName("A") @service diff --git a/packages/protobuf/test/scenarios/cross package references/output/B.proto b/packages/protobuf/test/scenarios/cross package references/output/B.proto index 3dc61405a8d..88d1204a302 100644 --- a/packages/protobuf/test/scenarios/cross package references/output/B.proto +++ b/packages/protobuf/test/scenarios/cross package references/output/B.proto @@ -4,6 +4,8 @@ syntax = "proto3"; package B; +import "A.proto"; + message Input { string testInputField = 1; } diff --git a/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt b/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt index 3d2a4bd2ff5..3d820857aec 100644 --- a/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt +++ b/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt @@ -1,4 +1,4 @@ -/test/main.cadl:19:1 - error @cadl-lang/grpc/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a gRPC message -/test/main.cadl:20:3 - error @cadl-lang/grpc/unconvertible-enum: the first variant of an enum must be set to zero to be used in a gRPC message -/test/main.cadl:24:1 - error @cadl-lang/grpc/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a gRPC message -/test/main.cadl:25:3 - error @cadl-lang/grpc/unconvertible-enum: the first variant of an enum must be set to zero to be used in a gRPC message \ No newline at end of file +/test/main.cadl:19:1 - error @cadl-lang/protobuf/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a Protobuf message +/test/main.cadl:20:3 - error @cadl-lang/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message +/test/main.cadl:24:1 - error @cadl-lang/protobuf/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a Protobuf message +/test/main.cadl:25:3 - error @cadl-lang/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/enum-nonintegral/input/main.cadl b/packages/protobuf/test/scenarios/enum-nonintegral/input/main.cadl index c365e40036b..bea979e11af 100644 --- a/packages/protobuf/test/scenarios/enum-nonintegral/input/main.cadl +++ b/packages/protobuf/test/scenarios/enum-nonintegral/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @packageName("com.azure.test") @service diff --git a/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt b/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt index d943cf204b9..908d760faa0 100644 --- a/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt +++ b/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt @@ -1 +1 @@ -/test/main.cadl:19:3 - error @cadl-lang/grpc/unconvertible-enum: the first variant of an enum must be set to zero to be used in a gRPC message \ No newline at end of file +/test/main.cadl:19:3 - error @cadl-lang/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/enum-nozero/input/main.cadl b/packages/protobuf/test/scenarios/enum-nozero/input/main.cadl index be08539d4aa..d3350b400a2 100644 --- a/packages/protobuf/test/scenarios/enum-nozero/input/main.cadl +++ b/packages/protobuf/test/scenarios/enum-nozero/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @service namespace Test; diff --git a/packages/protobuf/test/scenarios/enum/input/main.cadl b/packages/protobuf/test/scenarios/enum/input/main.cadl index a66a08e0f32..87f5bf3e165 100644 --- a/packages/protobuf/test/scenarios/enum/input/main.cadl +++ b/packages/protobuf/test/scenarios/enum/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @packageName("com.azure.test") @service diff --git a/packages/protobuf/test/scenarios/extern/input/main.cadl b/packages/protobuf/test/scenarios/extern/input/main.cadl index 31363aa303d..3172e3570b5 100644 --- a/packages/protobuf/test/scenarios/extern/input/main.cadl +++ b/packages/protobuf/test/scenarios/extern/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @service namespace Test; diff --git a/packages/protobuf/test/scenarios/illegal field reservations/diagnostics.txt b/packages/protobuf/test/scenarios/illegal field reservations/diagnostics.txt new file mode 100644 index 00000000000..7f9ad2e53fa --- /dev/null +++ b/packages/protobuf/test/scenarios/illegal field reservations/diagnostics.txt @@ -0,0 +1,2 @@ +/test/.cadl/lib/lib.cadl:18:1 - error @cadl-lang/protobuf/illegal-reservation: reservation value must be a string literal, uint32 literal, or a tuple of two uint32 literals denoting a range +/test/.cadl/lib/lib.cadl:12:1 - error @cadl-lang/protobuf/illegal-reservation: reservation value must be a string literal, uint32 literal, or a tuple of two uint32 literals denoting a range \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/illegal field reservations/input/main.cadl b/packages/protobuf/test/scenarios/illegal field reservations/input/main.cadl new file mode 100644 index 00000000000..76bc3dc2604 --- /dev/null +++ b/packages/protobuf/test/scenarios/illegal field reservations/input/main.cadl @@ -0,0 +1,16 @@ +import "@cadl-lang/protobuf"; + +using Cadl.Protobuf; + +@service +namespace Test; + +@serviceInterface +interface Service { + foo(...Input): {}; +} + +@reserve(2, 15, [9, 11], "foo", string, uint32) +model Input { + @field(1) testInputField: string; +} diff --git a/packages/protobuf/test/scenarios/inferred-message-names/input/main.cadl b/packages/protobuf/test/scenarios/inferred-message-names/input/main.cadl index b667da921ce..5d1d25b0fe6 100644 --- a/packages/protobuf/test/scenarios/inferred-message-names/input/main.cadl +++ b/packages/protobuf/test/scenarios/inferred-message-names/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @packageName("com.azure.test") @service diff --git a/packages/protobuf/test/scenarios/map/input/main.cadl b/packages/protobuf/test/scenarios/map/input/main.cadl index 179d8907092..9ad274267ed 100644 --- a/packages/protobuf/test/scenarios/map/input/main.cadl +++ b/packages/protobuf/test/scenarios/map/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @service namespace Test; @@ -11,5 +11,5 @@ interface Service { } model Input { - @field(1) testInputField: Cadl.Grpc.Map; + @field(1) testInputField: Cadl.Protobuf.Map; } diff --git a/packages/protobuf/test/scenarios/reserved fields/input/main.cadl b/packages/protobuf/test/scenarios/reserved fields/input/main.cadl index 1e3a8551ace..2ba113eb823 100644 --- a/packages/protobuf/test/scenarios/reserved fields/input/main.cadl +++ b/packages/protobuf/test/scenarios/reserved fields/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @service namespace Test; diff --git a/packages/protobuf/test/scenarios/simple-error/diagnostics.txt b/packages/protobuf/test/scenarios/simple-error/diagnostics.txt index df4672c9a6c..67312a6660d 100644 --- a/packages/protobuf/test/scenarios/simple-error/diagnostics.txt +++ b/packages/protobuf/test/scenarios/simple-error/diagnostics.txt @@ -1,5 +1,5 @@ -/test/main.cadl:12:5 - error @cadl-lang/grpc/field-index: field index 0 is invalid (must be an integer greater than zero) -/test/main.cadl:13:5 - error @cadl-lang/grpc/field-index: field index 536870912 is out of bounds (must be less than 536870912) -/test/main.cadl:14:5 - error @cadl-lang/grpc/field-index: field index 19000 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) -/test/main.cadl:15:5 - error @cadl-lang/grpc/field-index: field index 19123 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) -/test/main.cadl:16:5 - error @cadl-lang/grpc/field-index: field index 19999 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) \ No newline at end of file +/test/main.cadl:12:5 - error @cadl-lang/protobuf/field-index: field index 0 is invalid (must be an integer greater than zero) +/test/main.cadl:13:5 - error @cadl-lang/protobuf/field-index: field index 536870912 is out of bounds (must be less than 536870912) +/test/main.cadl:14:5 - error @cadl-lang/protobuf/field-index: field index 19000 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) +/test/main.cadl:15:5 - error @cadl-lang/protobuf/field-index: field index 19123 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) +/test/main.cadl:16:5 - error @cadl-lang/protobuf/field-index: field index 19999 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/simple-error/input/main.cadl b/packages/protobuf/test/scenarios/simple-error/input/main.cadl index f3e6cab5ea9..f882a35ff5a 100644 --- a/packages/protobuf/test/scenarios/simple-error/input/main.cadl +++ b/packages/protobuf/test/scenarios/simple-error/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @service namespace Test; diff --git a/packages/protobuf/test/scenarios/simple/input/main.cadl b/packages/protobuf/test/scenarios/simple/input/main.cadl index b6d6c10d8d8..5f6a14ddcc0 100644 --- a/packages/protobuf/test/scenarios/simple/input/main.cadl +++ b/packages/protobuf/test/scenarios/simple/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @packageName("com.azure.test") @service diff --git a/packages/protobuf/test/scenarios/streams/input/main.cadl b/packages/protobuf/test/scenarios/streams/input/main.cadl index 44eeffb22b6..ddd189cf46c 100644 --- a/packages/protobuf/test/scenarios/streams/input/main.cadl +++ b/packages/protobuf/test/scenarios/streams/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @service namespace Test; diff --git a/packages/protobuf/test/scenarios/type-validation/diagnostics.txt b/packages/protobuf/test/scenarios/type-validation/diagnostics.txt index b572d5bcddd..41e99cfff09 100644 --- a/packages/protobuf/test/scenarios/type-validation/diagnostics.txt +++ b/packages/protobuf/test/scenarios/type-validation/diagnostics.txt @@ -1 +1 @@ -/test/.cadl/lib/lib.cadl:8:1 - error @cadl-lang/grpc/unsupported-return-type: gRPC operations must return a named Model \ No newline at end of file +/test/.cadl/lib/lib.cadl:8:1 - error @cadl-lang/protobuf/unsupported-return-type: Protobuf methods must return a named Model \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/type-validation/input/main.cadl b/packages/protobuf/test/scenarios/type-validation/input/main.cadl index 229a18f3847..b6d2f3029e7 100644 --- a/packages/protobuf/test/scenarios/type-validation/input/main.cadl +++ b/packages/protobuf/test/scenarios/type-validation/input/main.cadl @@ -1,6 +1,6 @@ -import "@cadl-lang/grpc"; +import "@cadl-lang/protobuf"; -using Cadl.Grpc; +using Cadl.Protobuf; @service namespace Test; From cb041e1e41fc81da6d2c5125f909f582dc585d56 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 17 Feb 2023 12:29:31 -0500 Subject: [PATCH 23/50] Reworked a bunch of docs issues and diagnostics. --- common/config/rush/pnpm-lock.yaml | 70 +- docs/standard-library/protobuf/overview.md | 152 +++ .../protobuf/reference/data-types.md | 70 ++ .../protobuf/reference/decorators.md | 127 ++ .../protobuf/reference/index.md | 22 + packages/protobuf/docs/overview.md | 152 +++ packages/protobuf/lib/proto.cadl | 254 +++- packages/protobuf/package.json | 6 +- packages/protobuf/src/ast.ts | 15 +- packages/protobuf/src/lib.ts | 30 +- packages/protobuf/src/proto.ts | 63 +- packages/protobuf/src/transform.ts | 291 ++++- packages/protobuf/test/include/foo/bar.proto | 7 + .../anonymous-package/output/cpp/main.pb.cc | 515 ++++++++ .../anonymous-package/output/cpp/main.pb.h | 466 +++++++ .../anonymous-package/output/csharp/Main.cs | 420 +++++++ .../output/objc/Main.pbobjc.h | 80 ++ .../output/objc/Main.pbobjc.m | 149 +++ .../output/php/GPBMetadata/Main.php | 33 + .../anonymous-package/output/php/Input.php | 56 + .../anonymous-package/output/php/Output.php | 56 + .../anonymous-package/output/pyi/main_pb2.pyi | 17 + .../output/python/main_pb2.py | 30 + .../anonymous-package/output/ruby/main_pb.rb | 18 + .../array/output/cpp/com/azure/test.pb.cc | 588 +++++++++ .../array/output/cpp/com/azure/test.pb.h | 619 +++++++++ .../protoc-out/array/output/csharp/Test.cs | 442 +++++++ .../array/output/objc/com/azure/Test.pbobjc.h | 87 ++ .../array/output/objc/com/azure/Test.pbobjc.m | 160 +++ .../array/output/php/Com/Azure/Test/Input.php | 58 + .../output/php/Com/Azure/Test/Output.php | 85 ++ .../output/php/GPBMetadata/Com/Azure/Test.php | 33 + .../array/output/pyi/com/azure/test_pb2.pyi | 20 + .../array/output/python/com/azure/test_pb2.py | 30 + .../array/output/ruby/com/azure/test_pb.rb | 25 + .../output/cpp/A.pb.cc | 349 +++++ .../output/cpp/A.pb.h | 326 +++++ .../output/cpp/B.pb.cc | 318 +++++ .../output/cpp/B.pb.h | 294 +++++ .../output/csharp/A.cs | 269 ++++ .../output/csharp/B.cs | 233 ++++ .../output/objc/A.pbobjc.h | 71 ++ .../output/objc/A.pbobjc.m | 111 ++ .../output/objc/B.pbobjc.h | 68 + .../output/objc/B.pbobjc.m | 101 ++ .../output/php/A/Output.php | 85 ++ .../output/php/B/Input.php | 58 + .../output/php/GPBMetadata/A.php | 29 + .../output/php/GPBMetadata/B.php | 31 + .../output/pyi/A_pb2.pyi | 13 + .../output/pyi/B_pb2.pyi | 12 + .../output/python/A_pb2.py | 26 + .../output/python/B_pb2.py | 29 + .../output/ruby/A_pb.rb | 17 + .../output/ruby/B_pb.rb | 18 + .../protoc-out/enum/output/cpp/main.pb.cc | 677 ++++++++++ .../test/protoc-out/enum/output/cpp/main.pb.h | 669 ++++++++++ .../protoc-out/enum/output/csharp/Main.cs | 549 ++++++++ .../protoc-out/enum/output/objc/Main.pbobjc.h | 156 +++ .../protoc-out/enum/output/objc/Main.pbobjc.m | 281 +++++ .../enum/output/php/GPBMetadata/Main.php | Bin 0 -> 780 bytes .../test/protoc-out/enum/output/php/Input.php | 110 ++ .../protoc-out/enum/output/php/InputType.php | 44 + .../enum/output/php/InputTypeWithAlias.php | 49 + .../protoc-out/enum/output/php/Output.php | 83 ++ .../protoc-out/enum/output/pyi/main_pb2.pyi | 40 + .../protoc-out/enum/output/python/main_pb2.py | 36 + .../protoc-out/enum/output/ruby/main_pb.rb | 32 + .../protoc-out/extern/output/cpp/main.pb.cc | 540 ++++++++ .../protoc-out/extern/output/cpp/main.pb.h | 575 +++++++++ .../protoc-out/extern/output/csharp/Main.cs | 441 +++++++ .../extern/output/objc/Main.pbobjc.h | 86 ++ .../extern/output/objc/Main.pbobjc.m | 153 +++ .../extern/output/php/BarRequest.php | 66 + .../extern/output/php/BarResponse.php | 66 + .../extern/output/php/GPBMetadata/Main.php | 37 + .../protoc-out/extern/output/pyi/main_pb2.pyi | 19 + .../extern/output/python/main_pb2.py | 32 + .../protoc-out/extern/output/ruby/main_pb.rb | 21 + .../output/cpp/com/azure/test.pb.cc | 590 +++++++++ .../output/cpp/com/azure/test.pb.h | 538 ++++++++ .../output/csharp/Test.cs | 462 +++++++ .../output/objc/com/azure/Test.pbobjc.h | 83 ++ .../output/objc/com/azure/Test.pbobjc.m | 160 +++ .../output/php/Com/Azure/Test/FooRequest.php | 58 + .../output/php/Com/Azure/Test/FooResponse.php | 85 ++ .../output/php/GPBMetadata/Com/Azure/Test.php | 34 + .../output/pyi/com/azure/test_pb2.pyi | 19 + .../output/python/com/azure/test_pb2.py | 30 + .../output/ruby/com/azure/test_pb.rb | 25 + .../test/protoc-out/map/output/cpp/main.pb.cc | 372 ++++++ .../test/protoc-out/map/output/cpp/main.pb.h | 320 +++++ .../test/protoc-out/map/output/csharp/Main.cs | 221 ++++ .../protoc-out/map/output/objc/Main.pbobjc.h | 70 ++ .../protoc-out/map/output/objc/Main.pbobjc.m | 107 ++ .../map/output/php/GPBMetadata/Main.php | 35 + .../test/protoc-out/map/output/php/Input.php | 56 + .../protoc-out/map/output/pyi/main_pb2.pyi | 20 + .../protoc-out/map/output/python/main_pb2.py | 33 + .../protoc-out/map/output/ruby/main_pb.rb | 16 + .../reserved fields/output/cpp/main.pb.cc | 375 ++++++ .../reserved fields/output/cpp/main.pb.h | 415 ++++++ .../reserved fields/output/csharp/Main.cs | 384 ++++++ .../reserved fields/output/objc/Main.pbobjc.h | 74 ++ .../reserved fields/output/objc/Main.pbobjc.m | 131 ++ .../output/php/FooResponse.php | 29 + .../output/php/GPBMetadata/Main.php | 32 + .../reserved fields/output/php/Input.php | 56 + .../reserved fields/output/pyi/main_pb2.pyi | 15 + .../reserved fields/output/python/main_pb2.py | 30 + .../reserved fields/output/ruby/main_pb.rb | 17 + .../simple/output/cpp/com/azure/Test.pb.cc | 589 +++++++++ .../simple/output/cpp/com/azure/Test.pb.h | 538 ++++++++ .../protoc-out/simple/output/csharp/Test.cs | 462 +++++++ .../output/objc/com/azure/Test.pbobjc.h | 83 ++ .../output/objc/com/azure/Test.pbobjc.m | 160 +++ .../output/php/Com/Azure/Test/Input.php | 58 + .../output/php/Com/Azure/Test/Output.php | 85 ++ .../output/php/GPBMetadata/Com/Azure/Test.php | 33 + .../simple/output/pyi/com/azure/Test_pb2.pyi | 19 + .../output/python/com/azure/Test_pb2.py | 30 + .../simple/output/ruby/com/azure/Test_pb.rb | 25 + .../protoc-out/streams/output/cpp/main.pb.cc | 578 +++++++++ .../protoc-out/streams/output/cpp/main.pb.h | 526 ++++++++ .../protoc-out/streams/output/csharp/Main.cs | 460 +++++++ .../streams/output/objc/Main.pbobjc.h | 83 ++ .../streams/output/objc/Main.pbobjc.m | 160 +++ .../streams/output/php/GPBMetadata/Main.php | 37 + .../protoc-out/streams/output/php/Input.php | 56 + .../protoc-out/streams/output/php/Output.php | 83 ++ .../streams/output/pyi/main_pb2.pyi | 19 + .../streams/output/python/main_pb2.py | 30 + .../protoc-out/streams/output/ruby/main_pb.rb | 19 + .../protoc-out/union/output/cpp/main.pb.cc | 1120 +++++++++++++++++ .../protoc-out/union/output/cpp/main.pb.h | 1063 ++++++++++++++++ .../protoc-out/union/output/csharp/Main.cs | 936 ++++++++++++++ .../union/output/objc/Main.pbobjc.h | 126 ++ .../union/output/objc/Main.pbobjc.m | 285 +++++ .../union/output/php/GPBMetadata/Main.php | Bin 0 -> 729 bytes .../protoc-out/union/output/php/Input.php | 94 ++ .../protoc-out/union/output/php/InputA.php | 56 + .../protoc-out/union/output/php/InputB.php | 56 + .../protoc-out/union/output/php/Output.php | 83 ++ .../protoc-out/union/output/pyi/main_pb2.pyi | 33 + .../union/output/python/main_pb2.py | 34 + .../protoc-out/union/output/ruby/main_pb.rb | 30 + packages/protobuf/test/scenarios.spec.ts | 8 +- .../anonymous-package/input/main.cadl | 6 +- .../{ => @cadl-lang/protobuf}/main.proto | 0 .../scenarios/array-nested/diagnostics.txt | 2 +- .../scenarios/array-nested/input/main.cadl | 4 +- .../test/scenarios/array/input/main.cadl | 7 +- .../protobuf}/com/azure/test.proto | 0 .../cross package references/input/main.cadl | 12 +- .../output/{ => @cadl-lang/protobuf}/A.proto | 0 .../output/{ => @cadl-lang/protobuf}/B.proto | 0 .../enum-nonintegral/diagnostics.txt | 8 +- .../enum-nonintegral/input/main.cadl | 5 +- .../scenarios/enum-nozero/input/main.cadl | 4 +- .../test/scenarios/enum/input/main.cadl | 11 +- .../protobuf/main.proto} | 8 +- .../test/scenarios/extern/input/main.cadl | 4 +- .../{ => @cadl-lang/protobuf}/main.proto | 0 .../diagnostics.txt | 4 +- .../input/main.cadl | 4 +- .../inferred-message-names/input/main.cadl | 7 +- .../protobuf}/com/azure/test.proto | 0 .../test/scenarios/map/input/main.cadl | 4 +- .../{ => @cadl-lang/protobuf}/main.proto | 0 .../reserved field collisions/diagnostics.txt | 5 + .../reserved field collisions/input/main.cadl | 19 + .../scenarios/reserved fields/input/main.cadl | 4 +- .../{ => @cadl-lang/protobuf}/main.proto | 0 .../scenarios/simple-error/input/main.cadl | 4 +- .../test/scenarios/simple/input/main.cadl | 7 +- .../protobuf/com/azure/Test.proto} | 2 +- .../test/scenarios/streams/input/main.cadl | 4 +- .../{ => @cadl-lang/protobuf}/main.proto | 0 .../scenarios/type-validation/diagnostics.txt | 2 +- .../scenarios/type-validation/input/main.cadl | 4 +- .../test/scenarios/union/input/main.cadl | 35 + .../output/@cadl-lang/protobuf/main.proto | 27 + packages/website/.scripts/regen-ref-docs.mjs | 6 + packages/website/sidebars.js | 8 + 184 files changed, 25426 insertions(+), 206 deletions(-) create mode 100644 docs/standard-library/protobuf/overview.md create mode 100644 docs/standard-library/protobuf/reference/data-types.md create mode 100644 docs/standard-library/protobuf/reference/decorators.md create mode 100644 docs/standard-library/protobuf/reference/index.md create mode 100644 packages/protobuf/docs/overview.md create mode 100644 packages/protobuf/test/include/foo/bar.proto create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.cc create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.h create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/csharp/Main.cs create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/php/GPBMetadata/Main.php create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/php/Input.php create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/php/Output.php create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/pyi/main_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/python/main_pb2.py create mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/ruby/main_pb.rb create mode 100644 packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.cc create mode 100644 packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.h create mode 100644 packages/protobuf/test/protoc-out/array/output/csharp/Test.cs create mode 100644 packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Input.php create mode 100644 packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Output.php create mode 100644 packages/protobuf/test/protoc-out/array/output/php/GPBMetadata/Com/Azure/Test.php create mode 100644 packages/protobuf/test/protoc-out/array/output/pyi/com/azure/test_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/array/output/python/com/azure/test_pb2.py create mode 100644 packages/protobuf/test/protoc-out/array/output/ruby/com/azure/test_pb.rb create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.cc create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.h create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.cc create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.h create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/csharp/A.cs create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/csharp/B.cs create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/php/A/Output.php create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/php/B/Input.php create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/A.php create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/B.php create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/pyi/A_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/pyi/B_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/python/A_pb2.py create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/python/B_pb2.py create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/ruby/A_pb.rb create mode 100644 packages/protobuf/test/protoc-out/cross package references/output/ruby/B_pb.rb create mode 100644 packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.cc create mode 100644 packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.h create mode 100644 packages/protobuf/test/protoc-out/enum/output/csharp/Main.cs create mode 100644 packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/enum/output/php/GPBMetadata/Main.php create mode 100644 packages/protobuf/test/protoc-out/enum/output/php/Input.php create mode 100644 packages/protobuf/test/protoc-out/enum/output/php/InputType.php create mode 100644 packages/protobuf/test/protoc-out/enum/output/php/InputTypeWithAlias.php create mode 100644 packages/protobuf/test/protoc-out/enum/output/php/Output.php create mode 100644 packages/protobuf/test/protoc-out/enum/output/pyi/main_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/enum/output/python/main_pb2.py create mode 100644 packages/protobuf/test/protoc-out/enum/output/ruby/main_pb.rb create mode 100644 packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.cc create mode 100644 packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.h create mode 100644 packages/protobuf/test/protoc-out/extern/output/csharp/Main.cs create mode 100644 packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/extern/output/php/BarRequest.php create mode 100644 packages/protobuf/test/protoc-out/extern/output/php/BarResponse.php create mode 100644 packages/protobuf/test/protoc-out/extern/output/php/GPBMetadata/Main.php create mode 100644 packages/protobuf/test/protoc-out/extern/output/pyi/main_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/extern/output/python/main_pb2.py create mode 100644 packages/protobuf/test/protoc-out/extern/output/ruby/main_pb.rb create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.cc create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.h create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/csharp/Test.cs create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooRequest.php create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooResponse.php create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/php/GPBMetadata/Com/Azure/Test.php create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/pyi/com/azure/test_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/python/com/azure/test_pb2.py create mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/ruby/com/azure/test_pb.rb create mode 100644 packages/protobuf/test/protoc-out/map/output/cpp/main.pb.cc create mode 100644 packages/protobuf/test/protoc-out/map/output/cpp/main.pb.h create mode 100644 packages/protobuf/test/protoc-out/map/output/csharp/Main.cs create mode 100644 packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/map/output/php/GPBMetadata/Main.php create mode 100644 packages/protobuf/test/protoc-out/map/output/php/Input.php create mode 100644 packages/protobuf/test/protoc-out/map/output/pyi/main_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/map/output/python/main_pb2.py create mode 100644 packages/protobuf/test/protoc-out/map/output/ruby/main_pb.rb create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.cc create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.h create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/csharp/Main.cs create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/php/FooResponse.php create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/php/GPBMetadata/Main.php create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/php/Input.php create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/pyi/main_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/python/main_pb2.py create mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/ruby/main_pb.rb create mode 100644 packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.cc create mode 100644 packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.h create mode 100644 packages/protobuf/test/protoc-out/simple/output/csharp/Test.cs create mode 100644 packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Input.php create mode 100644 packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Output.php create mode 100644 packages/protobuf/test/protoc-out/simple/output/php/GPBMetadata/Com/Azure/Test.php create mode 100644 packages/protobuf/test/protoc-out/simple/output/pyi/com/azure/Test_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/simple/output/python/com/azure/Test_pb2.py create mode 100644 packages/protobuf/test/protoc-out/simple/output/ruby/com/azure/Test_pb.rb create mode 100644 packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.cc create mode 100644 packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.h create mode 100644 packages/protobuf/test/protoc-out/streams/output/csharp/Main.cs create mode 100644 packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/streams/output/php/GPBMetadata/Main.php create mode 100644 packages/protobuf/test/protoc-out/streams/output/php/Input.php create mode 100644 packages/protobuf/test/protoc-out/streams/output/php/Output.php create mode 100644 packages/protobuf/test/protoc-out/streams/output/pyi/main_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/streams/output/python/main_pb2.py create mode 100644 packages/protobuf/test/protoc-out/streams/output/ruby/main_pb.rb create mode 100644 packages/protobuf/test/protoc-out/union/output/cpp/main.pb.cc create mode 100644 packages/protobuf/test/protoc-out/union/output/cpp/main.pb.h create mode 100644 packages/protobuf/test/protoc-out/union/output/csharp/Main.cs create mode 100644 packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.h create mode 100644 packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.m create mode 100644 packages/protobuf/test/protoc-out/union/output/php/GPBMetadata/Main.php create mode 100644 packages/protobuf/test/protoc-out/union/output/php/Input.php create mode 100644 packages/protobuf/test/protoc-out/union/output/php/InputA.php create mode 100644 packages/protobuf/test/protoc-out/union/output/php/InputB.php create mode 100644 packages/protobuf/test/protoc-out/union/output/php/Output.php create mode 100644 packages/protobuf/test/protoc-out/union/output/pyi/main_pb2.pyi create mode 100644 packages/protobuf/test/protoc-out/union/output/python/main_pb2.py create mode 100644 packages/protobuf/test/protoc-out/union/output/ruby/main_pb.rb rename packages/protobuf/test/scenarios/anonymous-package/output/{ => @cadl-lang/protobuf}/main.proto (100%) rename packages/protobuf/test/scenarios/array/output/{ => @cadl-lang/protobuf}/com/azure/test.proto (100%) rename packages/protobuf/test/scenarios/cross package references/output/{ => @cadl-lang/protobuf}/A.proto (100%) rename packages/protobuf/test/scenarios/cross package references/output/{ => @cadl-lang/protobuf}/B.proto (100%) rename packages/protobuf/test/scenarios/enum/output/{com/azure/test.proto => @cadl-lang/protobuf/main.proto} (87%) rename packages/protobuf/test/scenarios/extern/output/{ => @cadl-lang/protobuf}/main.proto (100%) rename packages/protobuf/test/scenarios/inferred-message-names/output/{ => @cadl-lang/protobuf}/com/azure/test.proto (100%) rename packages/protobuf/test/scenarios/map/output/{ => @cadl-lang/protobuf}/main.proto (100%) create mode 100644 packages/protobuf/test/scenarios/reserved field collisions/diagnostics.txt create mode 100644 packages/protobuf/test/scenarios/reserved field collisions/input/main.cadl rename packages/protobuf/test/scenarios/reserved fields/output/{ => @cadl-lang/protobuf}/main.proto (100%) rename packages/protobuf/test/scenarios/simple/output/{com/azure/test.proto => @cadl-lang/protobuf/com/azure/Test.proto} (90%) rename packages/protobuf/test/scenarios/streams/output/{ => @cadl-lang/protobuf}/main.proto (100%) create mode 100644 packages/protobuf/test/scenarios/union/input/main.cadl create mode 100644 packages/protobuf/test/scenarios/union/output/@cadl-lang/protobuf/main.proto diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index c65634f0d03..b64ca32c431 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -35,6 +35,7 @@ specifiers: '@rush-temp/openapi3': file:./projects/openapi3.tgz '@rush-temp/playground': file:./projects/playground.tgz '@rush-temp/prettier-plugin-cadl': file:./projects/prettier-plugin-cadl.tgz + '@rush-temp/protobuf': file:./projects/protobuf.tgz '@rush-temp/ref-doc': file:./projects/ref-doc.tgz '@rush-temp/rest': file:./projects/rest.tgz '@rush-temp/samples': file:./projects/samples.tgz @@ -47,6 +48,7 @@ specifiers: '@types/babel__code-frame': ~7.0.3 '@types/debounce': ~1.2.1 '@types/js-yaml': ~4.0.1 + '@types/micromatch': ^4.0.2 '@types/mkdirp': ~1.0.1 '@types/mocha': ~10.0.0 '@types/mustache': ~4.2.1 @@ -86,6 +88,7 @@ specifiers: lzutf8: 0.6.2 mdx-mermaid: 1.3.2 mermaid: ~9.1.6 + micromatch: ^4.0.5 mkdirp: ~1.0.4 mocha: ~10.1.0 mocha-junit-reporter: ~2.2.0 @@ -160,6 +163,7 @@ dependencies: '@rush-temp/openapi3': file:projects/openapi3.tgz '@rush-temp/playground': file:projects/playground.tgz_rollup@3.4.0 '@rush-temp/prettier-plugin-cadl': file:projects/prettier-plugin-cadl.tgz + '@rush-temp/protobuf': file:projects/protobuf.tgz '@rush-temp/ref-doc': file:projects/ref-doc.tgz '@rush-temp/rest': file:projects/rest.tgz '@rush-temp/samples': file:projects/samples.tgz @@ -172,6 +176,7 @@ dependencies: '@types/babel__code-frame': 7.0.3 '@types/debounce': 1.2.1 '@types/js-yaml': 4.0.5 + '@types/micromatch': 4.0.2 '@types/mkdirp': 1.0.2 '@types/mocha': 10.0.0 '@types/mustache': 4.2.1 @@ -211,6 +216,7 @@ dependencies: lzutf8: 0.6.2 mdx-mermaid: 1.3.2_mermaid@9.1.7+react@18.2.0 mermaid: 9.1.7 + micromatch: 4.0.5 mkdirp: 1.0.4 mocha: 10.1.0 mocha-junit-reporter: 2.2.0_mocha@10.1.0 @@ -5184,6 +5190,10 @@ packages: '@types/node': 18.11.9 dev: false + /@types/braces/3.0.1: + resolution: {integrity: sha512-+euflG6ygo4bn0JHtn4pYqcXwRtLvElQ7/nnjDu7iYG56H0+OhCd7d6Ug0IE3WcFpZozBKW2+80FUbv5QGk5AQ==} + dev: false + /@types/connect-history-api-fallback/1.3.5: resolution: {integrity: sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw==} dependencies: @@ -5301,6 +5311,12 @@ packages: '@types/unist': 2.0.6 dev: false + /@types/micromatch/4.0.2: + resolution: {integrity: sha512-oqXqVb0ci19GtH0vOA/U2TmHTcRY9kuZl4mqUxe0QmJAlIW13kzhuK5pi1i9+ngav8FjpSb9FVS/GE00GLX1VA==} + dependencies: + '@types/braces': 3.0.1 + dev: false + /@types/mime/3.0.1: resolution: {integrity: sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==} dev: false @@ -15083,7 +15099,7 @@ packages: dev: false file:projects/bundler.tgz: - resolution: {integrity: sha512-2mgxNeJUr2aTguF9sPfaHVHq8Ntv+E2pJ1jTz2NL+ElKCdLZZt3jcmljJqb0vrZCchr7rGSmJJ/bzaNcjYO0PQ==, tarball: file:projects/bundler.tgz} + resolution: {integrity: sha512-sUO7vssAYoEY7pQrVpcJ0MEHIhN5Lrqlc79wmBLPHb3tuWGpHPGA909BIGNHNuneGLO68kA/gMlDGgBfv4cNgg==, tarball: file:projects/bundler.tgz} name: '@rush-temp/bundler' version: 0.0.0 dependencies: @@ -15113,13 +15129,13 @@ packages: dev: false file:projects/cadl-vs.tgz: - resolution: {integrity: sha512-zbbCNHwIdI3MGU9IlMDMJirbb3pWMXtvmKNgdtZ4EhKlgNnqFuYbkpszcCoGAUHuuLj2Vt+mX+Kkb1DAUSiWmQ==, tarball: file:projects/cadl-vs.tgz} + resolution: {integrity: sha512-i/10VOQOkEl9M0wDLMHSYuZlwiwnSM2gqt7xmTUcdEn5vkbufZGa0x9ZoLRhnC91DB4QYPb67i7IxYeemOKG6w==, tarball: file:projects/cadl-vs.tgz} name: '@rush-temp/cadl-vs' version: 0.0.0 dev: false file:projects/cadl-vscode.tgz: - resolution: {integrity: sha512-uQR0j9m74K9sJLq01aRJYyYH7BRRxMMe2uFdWqGy2Gh8m/N958Jinol+qDo59hYCEBccyAjFJ8uPyxZHTuUyfQ==, tarball: file:projects/cadl-vscode.tgz} + resolution: {integrity: sha512-0N+mjSTMWK0DFvoeFN95U/kIVyq9sYRB+AWLk8dTe7DHsJFKqm3s801KmFQIEn/gKrbxniC8ig3JcSGveMJzdA==, tarball: file:projects/cadl-vscode.tgz} name: '@rush-temp/cadl-vscode' version: 0.0.0 dependencies: @@ -15146,7 +15162,7 @@ packages: dev: false file:projects/compiler.tgz: - resolution: {integrity: sha512-u3LfftlK0A6nTGnQWJVWQsNbP/xY0aswwod6Al+dwogdN6KESuiJ4a9Y1+PJCo5ExSSL+z2LEPE97hyleXPRHA==, tarball: file:projects/compiler.tgz} + resolution: {integrity: sha512-UJAv+1e4kVXMAGTD39WjEuNXO6YXQrVhx11ZnECVnvY2VdkSPkLfU5D/Mzb74Ds9CAa9QXbGVeEFD3hRhdzRrw==, tarball: file:projects/compiler.tgz} name: '@rush-temp/compiler' version: 0.0.0 dependencies: @@ -15233,7 +15249,7 @@ packages: dev: false file:projects/html-program-viewer.tgz: - resolution: {integrity: sha512-D+9xJKsI+UIlpEbwbix4SY8Do9fqXs55HlcfeW7HODkxGABhQkPWlPJIFspWpQVl5aKCXl3US32H8PLDgKcwYw==, tarball: file:projects/html-program-viewer.tgz} + resolution: {integrity: sha512-Sx0YBNJzEm4H8ob+j0qFBftLTkkAct8jsqZfsyz3bQcWRicqqROdXjc8dq+AHrj5wWTlHrYpsA35owxr6/v0mw==, tarball: file:projects/html-program-viewer.tgz} name: '@rush-temp/html-program-viewer' version: 0.0.0 dependencies: @@ -15286,7 +15302,7 @@ packages: dev: false file:projects/library-linter.tgz: - resolution: {integrity: sha512-+gzP6nd+jEsJtQNdAqhep+j1qh7lAaICvfq+Gochjp4sutl4TV/MFf0iC406YYiT1Bmp3uM4s0AszmfRWoRupg==, tarball: file:projects/library-linter.tgz} + resolution: {integrity: sha512-Fka0bz2WHnISX0u4IJzFTvryU1TACZ1Rf0PPossAYZAhpgnTPQc0GTtyxr4MB5iW2TTaWR/OcR8cAFxYn0OypQ==, tarball: file:projects/library-linter.tgz} name: '@rush-temp/library-linter' version: 0.0.0 dependencies: @@ -15304,7 +15320,7 @@ packages: dev: false file:projects/lint.tgz: - resolution: {integrity: sha512-PoOjP6Ebh8TnIFkfDGReoGvDTB30+E7v+3zOy3+O9fMGAHHqulRUSF6BJy2ybxN0m6BxpgI82ZH/4InN/zq+/g==, tarball: file:projects/lint.tgz} + resolution: {integrity: sha512-A5XqSvfcIlQ0zZiEdsFUi/BQYozV9ZlgGH6PTP9r1yjeHF60eRfCn7eQ7qmByAUP4HpuedROQFUc27NeVGhvNQ==, tarball: file:projects/lint.tgz} name: '@rush-temp/lint' version: 0.0.0 dependencies: @@ -15322,7 +15338,7 @@ packages: dev: false file:projects/migrate.tgz: - resolution: {integrity: sha512-JQlj56dOVve2aPc4Q8sDrtSXOnpwsmgsygC+T7TJfy0ctVpm6IZDVspnwXvDDU+A0mPTii5vM07Unn3DywMYDA==, tarball: file:projects/migrate.tgz} + resolution: {integrity: sha512-1Ma3qCMMfG1Ia4PFP2yap3q38qSa5tRfttPbcz4E6NEkCIzT3v10mAttASpeKvTtlcgc4WOA7yhQNceEsQlSVw==, tarball: file:projects/migrate.tgz} name: '@rush-temp/migrate' version: 0.0.0 dependencies: @@ -15342,7 +15358,7 @@ packages: dev: false file:projects/openapi.tgz: - resolution: {integrity: sha512-l/k8MmIfs91AQLHPv3ynvCgXiuDI00srORFNjXCRLyusJi4/h0CikBL2jTF9hWhVsYuk/XryJpxdK7achT19ZQ==, tarball: file:projects/openapi.tgz} + resolution: {integrity: sha512-CK5gME9cSVV9ZYCnXCaoi6gj0zZ7aSSP5vAGqveADERx513T+EL6Q06Lcp+4xwi45A7KSOOGYdeX9S/gnUejAA==, tarball: file:projects/openapi.tgz} name: '@rush-temp/openapi' version: 0.0.0 dependencies: @@ -15360,7 +15376,7 @@ packages: dev: false file:projects/openapi3.tgz: - resolution: {integrity: sha512-kN6ZJvzSKq3wrAnjFRC0s4/E/wSnvlkdNtx0qDP4B8e46RfP0oB07wbCAWErJNBwI82jL5SHSvnTj7X5mFvO/Q==, tarball: file:projects/openapi3.tgz} + resolution: {integrity: sha512-GQHFstH+1aQuPdR8JbXabGkjhZpShwtReIOu45pILsbCeXLB44YF0SJ+6uCc8BAagAKzzGnf/PZx0aXqYxYwEA==, tarball: file:projects/openapi3.tgz} name: '@rush-temp/openapi3' version: 0.0.0 dependencies: @@ -15380,7 +15396,7 @@ packages: dev: false file:projects/playground.tgz_rollup@3.4.0: - resolution: {integrity: sha512-uFUYJZfKVqDEfuDf7lguB9MnguQdZSeacNFkTJwHx6npi5VDoeG5ZXwV6PAwD6VbJ+ssnGGJjZWoweo1TovDIA==, tarball: file:projects/playground.tgz} + resolution: {integrity: sha512-5JQ/htgUdR2QkudeSnFYUuncGJAAtc3rH7PH0rKvd80qYrSioVaiJt4B43NDIdgm/kJzbyIVNsZufnCFy6v0vw==, tarball: file:projects/playground.tgz} id: file:projects/playground.tgz name: '@rush-temp/playground' version: 0.0.0 @@ -15436,7 +15452,7 @@ packages: dev: false file:projects/prettier-plugin-cadl.tgz: - resolution: {integrity: sha512-L7/8t/gKHFW/d36UdzDOrtb73bhTKPX/KWDp/nkAag17KxdfddGZ60KSGp+PmX7ZpMlS+ade0mIjoaX6HIdFOA==, tarball: file:projects/prettier-plugin-cadl.tgz} + resolution: {integrity: sha512-GQEQVjZpwz9D0zGQReL53HT5BBX0Q1hPEDggYYbefl1xvnPhnTm6PWtVJxxzsOVnR51X8GXqZGpsSTHnAyJgzQ==, tarball: file:projects/prettier-plugin-cadl.tgz} name: '@rush-temp/prettier-plugin-cadl' version: 0.0.0 dependencies: @@ -15453,8 +15469,26 @@ packages: - supports-color dev: false + file:projects/protobuf.tgz: + resolution: {integrity: sha512-UTndxpnjzEh4NQdiRr1fj7JJn35DiI1tE/zCeVP77rGFl9qnnzNV2VTggIl9Fz4WDJAoB6wc9SgF2k0a7hi3vQ==, tarball: file:projects/protobuf.tgz} + name: '@rush-temp/protobuf' + version: 0.0.0 + dependencies: + '@types/micromatch': 4.0.2 + '@types/mocha': 10.0.0 + '@types/node': 18.11.9 + c8: 7.12.0 + eslint: 8.28.0 + micromatch: 4.0.5 + mocha: 10.1.0 + rimraf: 3.0.2 + typescript: 4.9.3 + transitivePeerDependencies: + - supports-color + dev: false + file:projects/ref-doc.tgz: - resolution: {integrity: sha512-ZZFxEHmpahIxxgTL7emDOYK6ORPoRxx3prrAo4sjef+75Gss+nVrdpXBOq7GlT7FQq4Qq3XkgHQZecOv3nV2Ug==, tarball: file:projects/ref-doc.tgz} + resolution: {integrity: sha512-wS+w8Y2yYQ+VuQMVvzQ9NNH5WZnje28vj0yRGn+TQ0ROnhHEWBqVFDbJ7kiBS6l7Z4VELj6r5lLPpV49xpMcdA==, tarball: file:projects/ref-doc.tgz} name: '@rush-temp/ref-doc' version: 0.0.0 dependencies: @@ -15477,7 +15511,7 @@ packages: dev: false file:projects/rest.tgz: - resolution: {integrity: sha512-PVprMNtIW1ph1NxTEbdEXxKPohlxOycqxDFn/UVUJ9p9DkQF2MVPD46WIGhsGqTt9RFZ+2X90FsreGuszMz0tg==, tarball: file:projects/rest.tgz} + resolution: {integrity: sha512-qmAjQIZG/a2eXCuOLa9gv2rsXESSO/N/rhuyljhvaer1Tmy6JgNf55ipsNwiijxPCM7qL4ofb0a73DnuZNSjBA==, tarball: file:projects/rest.tgz} name: '@rush-temp/rest' version: 0.0.0 dependencies: @@ -15495,7 +15529,7 @@ packages: dev: false file:projects/samples.tgz: - resolution: {integrity: sha512-moAVhG29T1YmqWLVUJXCs30lQuoL8PWecODceVZ+KRQqfYOEqdK3rOp776yBwQifAGPmW6x0Y47iO1+oivjszA==, tarball: file:projects/samples.tgz} + resolution: {integrity: sha512-CtsdOz3eInsO1vUhgqW1ErY55UZ0xAYRvW6qTC3UuYC1ofVovNhNWvmFV4MduL9kSK50rYjw6JcGPJWunZtPBg==, tarball: file:projects/samples.tgz} name: '@rush-temp/samples' version: 0.0.0 dependencies: @@ -15505,7 +15539,7 @@ packages: dev: false file:projects/spec.tgz: - resolution: {integrity: sha512-YyYDVv6nR4ZKFGXhNAmEXNDbGnZC+QIt2SOzxFdPzx3nY4JzdH75neT0OZBEQAQukaIj3MV7lgUZ96wREv63aA==, tarball: file:projects/spec.tgz} + resolution: {integrity: sha512-v3Z58mWy52wY1DKsE+T0T1K2BTCvjYrYHr4tsih7Zk8QZHZqrhSqfK7tPNTQJ5MLiXdYDusxJZb3inUKmdHClQ==, tarball: file:projects/spec.tgz} name: '@rush-temp/spec' version: 0.0.0 dependencies: @@ -15536,7 +15570,7 @@ packages: dev: false file:projects/versioning.tgz: - resolution: {integrity: sha512-uABDRI/1aDdu4+VYZKDi2bmLmYeXXzL2bbfGvTIz6ADu1K4Xb+MBnpxc5TGdlLtdE1uy70Y8DPtkfaeBftXBgA==, tarball: file:projects/versioning.tgz} + resolution: {integrity: sha512-W9N1Bu61Uv0uucYLOTIUtyWyc90ZMw4IIHpImbxutNRKSwDiB/RezfurWyV00baH309ua3e+Yc2MW0VJZfM9jw==, tarball: file:projects/versioning.tgz} name: '@rush-temp/versioning' version: 0.0.0 dependencies: @@ -15554,7 +15588,7 @@ packages: dev: false file:projects/website.tgz_@types+react@18.0.25: - resolution: {integrity: sha512-3GsmNKLHFMiEtrHwU5lN7UnZSRtZ9f3eFS2/qq9ERMRhDdTiTX6ywOb9iLyVboSSenPIQ6vw7dzrqS/Ti0eDaQ==, tarball: file:projects/website.tgz} + resolution: {integrity: sha512-2QdPBteBUQopsDuQXD+Jd6S60XMMyx4ruWIj/Ys3jcaxAEDI9JUKfWXpz9aR8ySQ5ckj48T63QjsNWo/8fB9yw==, tarball: file:projects/website.tgz} id: file:projects/website.tgz name: '@rush-temp/website' version: 0.0.0 diff --git a/docs/standard-library/protobuf/overview.md b/docs/standard-library/protobuf/overview.md new file mode 100644 index 00000000000..26c20597103 --- /dev/null +++ b/docs/standard-library/protobuf/overview.md @@ -0,0 +1,152 @@ +--- +title: Overview +--- + +# The Protobuf Emitter + +TypeSpec provides an emitter (`@typespec/protobuf`) that generates Protocol Buffers specifications from TypeSpec sources as part of its standard library. The resulting Protobuf files may be used as inputs for creating gRPC services or any other tools compatible with Protocol Buffers. + +**Note**: The Protobuf emitter uses Protocol Buffers 3 (proto3) syntax. Your workflow (`protoc` version, etc.) must support proto3 to utilize this emitter. + +## Install + +In the project root, install the emitter using your JavaScript package manager of choice. For example, using NPM: + +```bash +npm install @typespec/protobuf +``` + +## Installing and enabling + +The `@typespec/protobuf` package provides an emitter that must be enabled in order to generate Protobuf files. Enable it by adding it to your TypeSpec compiler invocation on the CLI or the project configuration file: + +1. Via the CLI + +```bash +typespec compile . --emit @typespec/protobuf +``` + +2. Via the project configuration + +Add the Protobuf emitter to the `emitters` entry (or create one if it does not exist) in `typespec-project.yaml`: + +```yaml +emitters: + @typespec/protobuf: true +``` + +With this configuration entry, Protobuf files will be generated every time the project is compiled using `typespec compile .`. + +## Core concepts + +The Protobuf emitter enables you to write TypeSpec and convert it into equivalent Protocol Buffers for use with Protobuf-enabled systems (such as gRPC). Your TypeSpec models and interfaces must adhere to certain requirements and restrictions in order for the emitter to convert them to Protobuf. + +### Field indices + +Protobuf requires that the offset of each field within a Protobuf message be manually specified. In TypeSpec, the field indices are specified using the [`TypeSpec.Protobuf.field` decorator][protobuf-field]. All fields within a model must have an attached `@field` decorator to be converted into a Protobuf message. + +The following TypeSpec model: + +```typespec +model TestMessage { + @field(1) n: int32 +} +``` + +will be converted into the following Protobuf message: + +```proto3 +message TestMessage { + int32 n = 1; +} +``` + +### Packages + +A protobuf package is defined by the [`TypeSpec.Protobuf.package` decorator][protobuf-package], which applies to a TypeSpec namespace. A package essentially defines a `.proto` file, and everything within the decorated namespace will be emitted to a single file. + +The following TypeSpec namespace results in a Protobuf file named `test.proto` that has the line `package test;` within it. + +```typespec +@package +namespace Test { + // ... +} +``` + +Package names may be explicitly overridden by providing an optional `PackageDetails` item to the `@package` decorator. The following TypeSpec namespace will result in a file `com/example/test.proto` that has the line `package com.example.test;` within it: + +```typespec +@package({ + name: "com.example.test" +}) +namespace Test { + // ... +} +``` + +The TypeSpec program's root namespace is implicitly a package that has no name and will be emitted to `main.proto` if it is not empty. TypeSpec objects (models, enums, etc.) are converted to Protobuf declarations within their nearest ancestor that has a package annotation. As a result, unlike in Protobuf, TypeSpec declarations of packages may be nested arbitrarily. + +### Services + +TypeSpec has a concept of a "service" defined by the [`TypeSpec.service` decorator][native-service], but the Protobuf concept of a "service" is different and is indicated by the [`TypeSpec.Protobuf.service` decorator][protobuf-service]. + +When using the Protobuf emitter, a Protobuf service designation is applied to an _interface_ within a package. For example, the following TypeSpec: + +```typespec +@package +namespace Example { + @Protobuf.service + interface Test { + // ... + } +} +``` + +will yield the following Protobuf file (named `example.proto`): + +```proto3 +syntax = "proto3"; + +package example; + +service Test { + // ... +} +``` + +### Operations + +Within a [service interface](#services), TypeSpec operations represent Protobuf service methods. Each operation in the service interface is converted into an equivalent Protobuf method declaration. + +### Streams + +The Protobuf emitter supports declaring the streaming mode of an operation using the [`TypeSpec.Protobuf.stream` decorator][protobuf-stream]. The streaming mode is specified by the + +## Emitter options + +Emitter options can be provided to the CLI with + +```bash +--option "@typespec/protobuf.=" + +# For example +--option "@typespec/protobuf.noEmit=true" +``` + +or configured through the `typespec-project.yaml` project configuration: + +```yaml +emitters: + '@typespec/protobuf': + : + +# For example +emitters: + '@typespec/protobuf': + noEmit: true +``` + +#### `noEmit` + +If set to `true`, this emitter will not write any files. It will still validate the TypeSpec sources to ensure they are compatible with Protobuf, but the files will simply not be written to the output directory. diff --git a/docs/standard-library/protobuf/reference/data-types.md b/docs/standard-library/protobuf/reference/data-types.md new file mode 100644 index 00000000000..f8ccea4d003 --- /dev/null +++ b/docs/standard-library/protobuf/reference/data-types.md @@ -0,0 +1,70 @@ +--- +title: "Data types" +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +# Data types + +## Cadl.Protobuf + +### `Extern` {#Cadl.Protobuf.Extern} + +A model that represents an external Protobuf reference. This type can be used to import and utilize Protobuf +declarations that are not declared in TypeSpec within TypeSpec sources. When the emitter encounters an `Extern`, it +will insert an `import` statement for the corresponding `Path` and refer to the type by `Name`. + +#### Usage + +If you have a file called `test.proto` that declares a package named `test` and a message named `Widget`, you can +use the `Extern` type to declare a model in TypeSpec that refers to your external definition of `test.Widget`. See +the example below. + +When the TypeSpec definition of `Widget` is encountered, the Protobuf emitter will represent it as a reference to +`test.Widget` and insert an import for it, rather than attempt to convert the model to an equivalent message. + +```cadl +model Extern +``` + +#### Template Parameters + +| Name | Description | +| ---- | ------------------------------------------------------------------------------------------------------------ | +| Path | the relative path to a `.proto` file to import | +| Name | a string containing the fully-qualified reference to the type this model represents within the `.proto` file | + +### `Map` {#Cadl.Protobuf.Map} + +A type representing a Protobuf `map`. Instances of this type in models will be converted to the built-in `map` type +in Protobuf. + +The key type of a Protobuf `map` must be any integral type or `string`. The value type can be any type other than +another `Map`. + +```cadl +model Map +``` + +#### Template Parameters + +| Name | Description | +| ---- | ------------------------------------------ | +| K | the key type (any integral type or string) | +| V | the value type | + +### `PackageDetails` {#Cadl.Protobuf.PackageDetails} + +Details applied to a package definition by the [ + +```cadl +model Cadl.Protobuf.PackageDetails +``` + +### `StreamMode` {#Cadl.Protobuf.StreamMode} + +The streaming mode of an operation. + +```cadl +enum Cadl.Protobuf.StreamMode +``` diff --git a/docs/standard-library/protobuf/reference/decorators.md b/docs/standard-library/protobuf/reference/decorators.md new file mode 100644 index 00000000000..a008cecea1d --- /dev/null +++ b/docs/standard-library/protobuf/reference/decorators.md @@ -0,0 +1,127 @@ +--- +title: "Decorators" +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +# Decorators + +## Cadl.Protobuf + +### `@field` {#@Cadl.Protobuf.field} + +Defines the field index of a model property for conversion to a Protobuf +message. + +The field index of a Protobuf message must: + +- fall between 1 and 229 - 1, inclusive. +- not fall within the implementation reserved range of 19000 to 19999, inclusive. +- not fall within any range that was [marked reserved](# + +```cadl +dec Cadl.Protobuf.field(target: Cadl.Reflection.ModelProperty, index: Cadl.uint32) +``` + +#### Target + +`ModelProperty` + +#### Parameters + +| Name | Type | Description | +| ----- | -------------------- | ------------------------------------ | +| index | `scalar Cadl.uint32` | The whole-number index of the field. | + +### `@reserve` {#@Cadl.Protobuf.reserve} + +Reserve a field index, range, or name. If a field definition collides with a reservation, the emitter will produce +an error. + +This decorator accepts multiple reservations. Each reservation is one of the following: + +- a `string`, in which case the reservation refers to a field name. +- a `uint32`, in which case the reservation refers to a field index. +- a tuple `[uint32, uint32]`, in which case the reservation refers to a field range that is _inclusive_ of both ends. + +Unlike in Protobuf, where field name and index reservations must be separated, you can mix string and numeric field +reservations in a single `@reserve` call in TypeSpec. + +#### API Compatibility Note + +Field reservations prevent users of your Protobuf specification from using the given field names or indices. This can +be useful if a field is removed, as it will further prevent adding a new, incompatible field and will prevent users +from utilizing the field index at runtime in a way that may break compatibility with users of older specifications. + +See _[Protobuf Language Guide - Reserved Fields](https://protobuf.dev/programming-guides/proto3/#reserved)_ for more + +Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int3 + +```cadl +dec Cadl.Protobuf.reserve(target: Cadl.object, ...reservations: Cadl.string | [Cadl.uint32, Cadl.uint32] | Cadl.uint32[]) +``` + +#### Target + +`model Cadl.object` + +#### Parameters + +| Name | Type | Description | +| ------------ | ------------------------------------------------------------------ | ---------------------------- | +| reservations | `model Cadl.string \| [Cadl.uint32, Cadl.uint32] \| Cadl.uint32[]` | a list of field reservations | + +### `@service` {#@Cadl.Protobuf.service} + +Declares that a TypeSPec interface constitutes a Protobuf service. The contents of the interface will be converted to +a `service` declaration in the resulting Protobuf file. + +```cadl +dec Cadl.Protobuf.service(target: Cadl.Reflection.Interface) +``` + +#### Target + +`Interface` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | + +### `@package` {#@Cadl.Protobuf.package} + +Declares that a TypeSpec namespace constitutes a Protobuf package. The contents of the namespace will be emitted to a +single Protobuf file. + +```cadl +dec Cadl.Protobuf.package(target: Cadl.Reflection.Namespace, details?: Cadl.Protobuf.PackageDetails) +``` + +#### Target + +`Namespace` + +#### Parameters + +| Name | Type | Description | +| ------- | ------------------------------------ | ----------------------------------- | +| details | `model Cadl.Protobuf.PackageDetails` | the optional details of the package | + +### `@stream` {#@Cadl.Protobuf.stream} + +Set the streaming mode of an operation. See [StreamMode](#TODO) for more information. + +```cadl +dec Cadl.Protobuf.stream(target: Cadl.Reflection.Operation, mode: Cadl.Protobuf.StreamMode) +``` + +#### Target + +`Operation` + +#### Parameters + +| Name | Type | Description | +| ---- | ------------------------------- | ---------------------------------------------- | +| mode | `enum Cadl.Protobuf.StreamMode` | The streaming mode to apply to this operation. | diff --git a/docs/standard-library/protobuf/reference/index.md b/docs/standard-library/protobuf/reference/index.md new file mode 100644 index 00000000000..7f8b359beea --- /dev/null +++ b/docs/standard-library/protobuf/reference/index.md @@ -0,0 +1,22 @@ +--- +title: Index +sidebar_position: 0 +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +## Cadl.Protobuf + +### Decorators + +- [`@field`](./decorators.md#@Cadl.Protobuf.field) +- [`@reserve`](./decorators.md#@Cadl.Protobuf.reserve) +- [`@service`](./decorators.md#@Cadl.Protobuf.service) +- [`@package`](./decorators.md#@Cadl.Protobuf.package) +- [`@stream`](./decorators.md#@Cadl.Protobuf.stream) + +### Models + +- [`Extern`](./data-types.md#Cadl.Protobuf.Extern) +- [`Map`](./data-types.md#Cadl.Protobuf.Map) +- [`PackageDetails`](./data-types.md#Cadl.Protobuf.PackageDetails) diff --git a/packages/protobuf/docs/overview.md b/packages/protobuf/docs/overview.md new file mode 100644 index 00000000000..26c20597103 --- /dev/null +++ b/packages/protobuf/docs/overview.md @@ -0,0 +1,152 @@ +--- +title: Overview +--- + +# The Protobuf Emitter + +TypeSpec provides an emitter (`@typespec/protobuf`) that generates Protocol Buffers specifications from TypeSpec sources as part of its standard library. The resulting Protobuf files may be used as inputs for creating gRPC services or any other tools compatible with Protocol Buffers. + +**Note**: The Protobuf emitter uses Protocol Buffers 3 (proto3) syntax. Your workflow (`protoc` version, etc.) must support proto3 to utilize this emitter. + +## Install + +In the project root, install the emitter using your JavaScript package manager of choice. For example, using NPM: + +```bash +npm install @typespec/protobuf +``` + +## Installing and enabling + +The `@typespec/protobuf` package provides an emitter that must be enabled in order to generate Protobuf files. Enable it by adding it to your TypeSpec compiler invocation on the CLI or the project configuration file: + +1. Via the CLI + +```bash +typespec compile . --emit @typespec/protobuf +``` + +2. Via the project configuration + +Add the Protobuf emitter to the `emitters` entry (or create one if it does not exist) in `typespec-project.yaml`: + +```yaml +emitters: + @typespec/protobuf: true +``` + +With this configuration entry, Protobuf files will be generated every time the project is compiled using `typespec compile .`. + +## Core concepts + +The Protobuf emitter enables you to write TypeSpec and convert it into equivalent Protocol Buffers for use with Protobuf-enabled systems (such as gRPC). Your TypeSpec models and interfaces must adhere to certain requirements and restrictions in order for the emitter to convert them to Protobuf. + +### Field indices + +Protobuf requires that the offset of each field within a Protobuf message be manually specified. In TypeSpec, the field indices are specified using the [`TypeSpec.Protobuf.field` decorator][protobuf-field]. All fields within a model must have an attached `@field` decorator to be converted into a Protobuf message. + +The following TypeSpec model: + +```typespec +model TestMessage { + @field(1) n: int32 +} +``` + +will be converted into the following Protobuf message: + +```proto3 +message TestMessage { + int32 n = 1; +} +``` + +### Packages + +A protobuf package is defined by the [`TypeSpec.Protobuf.package` decorator][protobuf-package], which applies to a TypeSpec namespace. A package essentially defines a `.proto` file, and everything within the decorated namespace will be emitted to a single file. + +The following TypeSpec namespace results in a Protobuf file named `test.proto` that has the line `package test;` within it. + +```typespec +@package +namespace Test { + // ... +} +``` + +Package names may be explicitly overridden by providing an optional `PackageDetails` item to the `@package` decorator. The following TypeSpec namespace will result in a file `com/example/test.proto` that has the line `package com.example.test;` within it: + +```typespec +@package({ + name: "com.example.test" +}) +namespace Test { + // ... +} +``` + +The TypeSpec program's root namespace is implicitly a package that has no name and will be emitted to `main.proto` if it is not empty. TypeSpec objects (models, enums, etc.) are converted to Protobuf declarations within their nearest ancestor that has a package annotation. As a result, unlike in Protobuf, TypeSpec declarations of packages may be nested arbitrarily. + +### Services + +TypeSpec has a concept of a "service" defined by the [`TypeSpec.service` decorator][native-service], but the Protobuf concept of a "service" is different and is indicated by the [`TypeSpec.Protobuf.service` decorator][protobuf-service]. + +When using the Protobuf emitter, a Protobuf service designation is applied to an _interface_ within a package. For example, the following TypeSpec: + +```typespec +@package +namespace Example { + @Protobuf.service + interface Test { + // ... + } +} +``` + +will yield the following Protobuf file (named `example.proto`): + +```proto3 +syntax = "proto3"; + +package example; + +service Test { + // ... +} +``` + +### Operations + +Within a [service interface](#services), TypeSpec operations represent Protobuf service methods. Each operation in the service interface is converted into an equivalent Protobuf method declaration. + +### Streams + +The Protobuf emitter supports declaring the streaming mode of an operation using the [`TypeSpec.Protobuf.stream` decorator][protobuf-stream]. The streaming mode is specified by the + +## Emitter options + +Emitter options can be provided to the CLI with + +```bash +--option "@typespec/protobuf.=" + +# For example +--option "@typespec/protobuf.noEmit=true" +``` + +or configured through the `typespec-project.yaml` project configuration: + +```yaml +emitters: + '@typespec/protobuf': + : + +# For example +emitters: + '@typespec/protobuf': + noEmit: true +``` + +#### `noEmit` + +If set to `true`, this emitter will not write any files. It will still validate the TypeSpec sources to ensure they are compatible with Protobuf, but the files will simply not be written to the output directory. diff --git a/packages/protobuf/lib/proto.cadl b/packages/protobuf/lib/proto.cadl index 2fb5eadf2fe..1d3c03cde8c 100644 --- a/packages/protobuf/lib/proto.cadl +++ b/packages/protobuf/lib/proto.cadl @@ -2,49 +2,261 @@ import "../dist/src/proto.js"; namespace Cadl.Protobuf; +/** + * A model that represents an external Protobuf reference. This type can be used to import and utilize Protobuf + * declarations that are not declared in TypeSpec within TypeSpec sources. When the emitter encounters an `Extern`, it + * will insert an `import` statement for the corresponding `Path` and refer to the type by `Name`. + * + * #### Usage + * + * If you have a file called `test.proto` that declares a package named `test` and a message named `Widget`, you can + * use the `Extern` type to declare a model in TypeSpec that refers to your external definition of `test.Widget`. See + * the example below. + * + * When the TypeSpec definition of `Widget` is encountered, the Protobuf emitter will represent it as a reference to + * `test.Widget` and insert an import for it, rather than attempt to convert the model to an equivalent message. + * + * @template Path the relative path to a `.proto` file to import + * @template Name the fully-qualified reference to the type this model represents within the `.proto` file + * + * @example + * + * ```typespec + * model Widget is Extern<"path/to/test.proto", "test.Widget">; + * ``` + */ @externRef(Path, Name) model Extern { - _extern: never; + // This _extern property is needed so that getEffectiveModelType will have something to look up. Without it, if an + // Extern model is spread into the parameter of an operation, the resulting model is empty and carries no information + // that can relate it back to its original definition. + _extern: never; } +/** + * Contains some common well-known Protobuf types defined by the google.protobuf library. + */ namespace WellKnown { - model Empty - is Extern<"google/protobuf/empty.proto", "google.protobuf.Empty">; - model Timestamp - is Extern< - "google/protobuf/timestamp.proto", - "google.protobuf.Timestamp" - >; + /** + * An empty message. + * + * This model references `google.protobuf.Empty` from `google/protobuf/empty.proto`. + */ + model Empty is Extern<"google/protobuf/empty.proto", "google.protobuf.Empty">; + + /** + * A timestamp. + * + * This model references `google.protobuf.Timestamp` from `google/protobuf/timestamp.proto`. + */ + model Timestamp is Extern<"google/protobuf/timestamp.proto", "google.protobuf.Timestamp">; } -// Protobuf scalars that carry information about encoding. +/** + * A signed 32-bit integer that will use the `sint32` encoding when used in a Protobuf message. + * + * #### Protobuf binary format + * + * Uses variable-length encoding. These more efficiently encode negative numbers than regular int32s. + */ scalar sint32 extends int32; +/** + * A signed 64-bit integer that will use the `sint64` encoding when used in a Protobuf message. + * + * #### Protobuf binary format + * + * Uses variable-length encoding. These more efficiently encode negative numbers than regular `int64s`. + */ scalar sint64 extends int64; +/** + * A signed 32-bit integer that will use the `sfixed32` encoding when used in a Protobuf message. + * + * #### Protobuf binary format + * + * Always four bytes. + */ scalar sfixed32 extends int32; +/** + * A signed 64-bit integer that will use the `sfixed64` encoding when used in a Protobuf message. + * + * #### Protobuf binary format + * + * Always eight bytes. + */ scalar sfixed64 extends int64; +/** + * An unsigned 32-bit integer that will use the `fixed32` encoding when used in a Protobuf message. + * + * #### Protobuf binary format + * + * Always four bytes. More efficient than `uint32` if values are often greater than 228. + */ scalar fixed32 extends uint32; +/** + * An unsigned 64-bit integer that will use the `fixed64` encoding when used in a Protobuf message. + * + * #### Protobuf binary format + * + * Always eight bytes. More efficient than `uint64` if values are often greater than 256. + */ scalar fixed64 extends uint64; +/** + * Types recognized as "integral" types + */ alias integral = int32 | int64 | uint32 | uint64 | boolean; +/** + * A type representing a Protobuf `map`. Instances of this type in models will be converted to the built-in `map` type + * in Protobuf. + * + * The key type of a Protobuf `map` must be any integral type or `string`. The value type can be any type other than + * another `Map`. + * + * @template K the key type (any integral type or string) + * @template V the value type (any type other than another map) + */ @_map model Map {} -extern dec externRef(target: object, path: string, name: string); - +/** + * Defines the field index of a model property for conversion to a Protobuf + * message. + * + * The field index of a Protobuf message must: + * - fall between 1 and 229 - 1, inclusive. + * - not fall within the implementation reserved range of 19000 to 19999, inclusive. + * - not fall within any range that was [marked reserved](#@TypeSpec.Protobuf.reserve). + * + * #### API Compatibility Note + * + * Fields are accessed by index, so changing the index of a field is an API breaking change. + * + * #### Encoding + * + * Field indices between 1 and 15 are encoded using a single byte, while field indices from 16 through 2047 require two + * bytes, so those indices between 1 and 15 should be preferred and reserved for elements that are frequently or always + * set in the message. See the [Protobuf binary format](https://protobuf.dev/programming-guides/encoding/). + * + * @param index The whole-number index of the field. + * + * @example + * + * ```typespec + * model ExampleMessage { + * @field(1) + * test: string; + * } + * ``` + */ extern dec field(target: Cadl.Reflection.ModelProperty, index: uint32); -extern dec serviceInterface(target: Cadl.Reflection.Interface); -extern dec packageName(target: Cadl.Reflection.Namespace, name: string); -extern dec reserve( - target: object, - ...ranges: (string | [uint32, uint32] | uint32)[] -); +/** + * Reserve a field index, range, or name. If a field definition collides with a reservation, the emitter will produce + * an error. + * + * This decorator accepts multiple reservations. Each reservation is one of the following: + * + * - a `string`, in which case the reservation refers to a field name. + * - a `uint32`, in which case the reservation refers to a field index. + * - a tuple `[uint32, uint32]`, in which case the reservation refers to a field range that is _inclusive_ of both ends. + * + * Unlike in Protobuf, where field name and index reservations must be separated, you can mix string and numeric field + * reservations in a single `@reserve` call in TypeSpec. + * + * #### API Compatibility Note + * + * Field reservations prevent users of your Protobuf specification from using the given field names or indices. This can + * be useful if a field is removed, as it will further prevent adding a new, incompatible field and will prevent users + * from utilizing the field index at runtime in a way that may break compatibility with users of older specifications. + * + * See _[Protobuf Language Guide - Reserved Fields](https://protobuf.dev/programming-guides/proto3/#reserved)_ for more + * + * Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int3 + * + * @param reservations a list of field reservations + * + * @example + * + * ```typespec + * // Reserve the fields 8-15 inclusive, 100, and the field name "test" within a model. + * @reserve([8, 15], 100, "test") + * model Example { + * // ... + * } + * ``` + */ +extern dec reserve(target: object, ...reservations: (string | [uint32, uint32] | uint32)[]); + +/** + * Declares that a TypeSPec interface constitutes a Protobuf service. The contents of the interface will be converted to + * a `service` declaration in the resulting Protobuf file. + */ +extern dec service(target: Cadl.Reflection.Interface); + +/** + * Details applied to a package definition by the [@package](#TODO) decorator. + */ +model PackageDetails { + /** + * The package's name. + * + * By default, the package's name is constructed from the namespace it is applied to. + */ + name?: string; +} + +/** + * Declares that a TypeSpec namespace constitutes a Protobuf package. The contents of the namespace will be emitted to a + * single Protobuf file. + * + * @param details the optional details of the package + */ +extern dec package(target: Cadl.Reflection.Namespace, details?: PackageDetails); + +/** + * The streaming mode of an operation. + */ enum StreamMode { - Duplex, - In, - Out, - None, + /** + * Both the input and output of the operation are streaming. Both the client and service will stream messages to each + * other until the connections are closed. + */ + Duplex, + /** + * The input of the operation is streaming. The client will send a stream of events; and, once the stream is closed, + * the service will respond with a message. + */ + In, + /** + * The output of the operation is streaming. The client will send a message to the service, and the service will send + * a stream of events back to the client. + */ + Out, + /** + * Neither the input nor the output are streaming. This is the default mode of an operation without the `@stream` + * decorator. + */ + None, } +/** + * Set the streaming mode of an operation. See [StreamMode](#TODO) for more information. + * + * @param mode The streaming mode to apply to this operation. + * + * @example + * + * ```typespec + * @stream(StreamMode.Out) + * op logs(...LogsRequest): LogEvent; + * ``` + * + * @example + * + * ```typespec + * @stream(StreamMode.Duplex) + * op connectToMessageService(...Message): Message; + * ``` + */ extern dec stream(target: Cadl.Reflection.Operation, mode: StreamMode); diff --git a/packages/protobuf/package.json b/packages/protobuf/package.json index e2fc1a5070f..54f20c2e65c 100644 --- a/packages/protobuf/package.json +++ b/packages/protobuf/package.json @@ -29,11 +29,11 @@ "lint:fix": "eslint . --fix --ext .ts" }, "dependencies": { - "@cadl-lang/compiler": "~0.37.0" + "@cadl-lang/compiler": "~0.39.0" }, "devDependencies": { - "@cadl-lang/eslint-config-cadl": "~0.4.1", - "@cadl-lang/eslint-plugin": "~0.1.1", + "@cadl-lang/eslint-config-cadl": "~0.5.0", + "@cadl-lang/eslint-plugin": "~0.39.0", "@types/mocha": "~10.0.0", "@types/node": "~18.11.9", "c8": "~7.12.0", diff --git a/packages/protobuf/src/ast.ts b/packages/protobuf/src/ast.ts index d445de55619..4e398dcd19b 100644 --- a/packages/protobuf/src/ast.ts +++ b/packages/protobuf/src/ast.ts @@ -217,15 +217,22 @@ export interface ProtoMethodDeclaration { returns: ProtoRef; } +/** + * A declaration that can fit within the body of a message declaration. + */ +export type ProtoMessageBodyDeclaration = + | ProtoFieldDeclaration + | ProtoMessageDeclaration + | ProtoOneOfDeclaration + | ProtoEnumDeclaration; + /** * A `message` declaration. */ export interface ProtoMessageDeclaration { kind: "message"; name: string; - declarations: Array< - ProtoFieldDeclaration | ProtoMessageDeclaration | ProtoOneOfDeclaration | ProtoEnumDeclaration - >; + declarations: Array; reservations?: Array; } @@ -258,7 +265,7 @@ export interface DefaultFieldOptions { export interface ProtoOneOfDeclaration { kind: "oneof"; name: string; - declarations: [ProtoFieldDeclaration, ...ProtoFieldDeclaration[]]; + declarations: ProtoFieldDeclaration[]; } /** diff --git a/packages/protobuf/src/lib.ts b/packages/protobuf/src/lib.ts index b8bda8b0a17..9623bf30817 100644 --- a/packages/protobuf/src/lib.ts +++ b/packages/protobuf/src/lib.ts @@ -7,11 +7,6 @@ import { createCadlLibrary, JSONSchemaType, paramMessage } from "@cadl-lang/comp * Options that the Protobuf emitter accepts. */ export interface ProtobufEmitterOptions { - /** - * The directory where the emitter will write the Protobuf output tree. - */ - outputDirectory?: string; - /** * Don't emit anything. */ @@ -22,7 +17,6 @@ const EmitterOptionsSchema: JSONSchemaType = { type: "object", additionalProperties: false, properties: { - outputDirectory: { type: "string", nullable: true }, noEmit: { type: "boolean", nullable: true }, }, required: [], @@ -37,9 +31,18 @@ export const CadlProtobufLibrary = createCadlLibrary({ "field-index": { severity: "error", messages: { + missing: paramMessage`field ${"name"} does not have a field index, but one is required (try using the '@field' decorator)`, invalid: paramMessage`field index ${"index"} is invalid (must be an integer greater than zero)`, "out-of-bounds": paramMessage`field index ${"index"} is out of bounds (must be less than ${"max"})`, - reserved: paramMessage`field index ${"index"} falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher)`, + reserved: paramMessage`field index ${"index"} falls within the implementation-reserved range of 19000-19999 inclusive`, + "user-reserved": paramMessage`field index ${"index"} was reserved by a call to @reserve on this model`, + "user-reserved-range": paramMessage`field index ${"index"} falls within a range reserved by a call to @reserve on this model`, + }, + }, + "field-name": { + severity: "error", + messages: { + "user-reserved": paramMessage`field name '${"name"}' was reserved by a call to @reserve on this model`, }, }, "root-operation": { @@ -125,15 +128,10 @@ export { $onEmit } from "./proto.js"; export type CadlProtobufLibrary = typeof CadlProtobufLibrary; -const keys = [ - "fieldIndex", - "serviceInterface", - "packageName", - "externRef", - "stream", - "reserve", -] as const; +const keys = ["fieldIndex", "package", "service", "externRef", "stream", "reserve"] as const; -export const state = Object.fromEntries(keys.map((k) => [k, Symbol(`cadl-protobuf::${k}`)])) as { +export const state = Object.fromEntries( + keys.map((k) => [k, Symbol(`@cadl-lang/protobuf.${k}`)]) +) as { [K in typeof keys[number]]: symbol; }; diff --git a/packages/protobuf/src/proto.ts b/packages/protobuf/src/proto.ts index 3c2741954bd..f5cd8732c4b 100644 --- a/packages/protobuf/src/proto.ts +++ b/packages/protobuf/src/proto.ts @@ -3,6 +3,7 @@ import { DecoratorContext, + EmitContext, EmitOptionsFor, EnumMember, Interface, @@ -12,12 +13,13 @@ import { NumericLiteral, Operation, Program, + resolvePath, Tuple, Type, } from "@cadl-lang/compiler"; import { StreamingMode } from "./ast.js"; -import { CadlProtobufLibrary, reportDiagnostic, state } from "./lib.js"; +import { CadlProtobufLibrary, ProtobufEmitterOptions, reportDiagnostic, state } from "./lib.js"; import { createProtobufEmitter } from "./transform.js"; /** @@ -50,21 +52,26 @@ export const PROTO_FULL_IDENT = /([a-zA-Z][a-zA-Z0-9_]*)+/; * @param ctx - decorator context * @param target - the decorated interface */ -export function $serviceInterface(ctx: DecoratorContext, target: Interface) { - ctx.program.stateSet(state.serviceInterface).add(target); +export function $service(ctx: DecoratorContext, target: Interface) { + ctx.program.stateSet(state.service).add(target); +} + +export interface PackageDetails { + name?: string; } /** - * Rename a package instead of using the implied name of the service namespace. + * Declare a Protobuf package. * * @param ctx - decorator context * @param target - target decorator namespace */ -export function $packageName(ctx: DecoratorContext, target: Namespace, name: string) { - ctx.program.stateMap(state.packageName).set(target, name); +export function $package(ctx: DecoratorContext, target: Namespace, details?: Model) { + // TODO: need to convert details from Model to PackageDetails + ctx.program.stateMap(state.package).set(target, details); } -const mapState = Symbol("cadl-protobuf::_map"); +const mapState = Symbol("@cadl-lang/protobuf._map"); export function isMap(program: Program, m: Type): boolean { return program.stateSet(mapState).has(m); @@ -99,17 +106,24 @@ function getTuple(program: Program, t: Type): [number, number] | null { return null; } - return (t as Tuple).values.map((v) => (v as NumericLiteral).value) as [number, number]; + return Object.assign( + (t as Tuple).values.map((v) => (v as NumericLiteral).value) as [number, number], + { type: t } + ); } +export type Reservation = string | number | ([number, number] & { type: Type }); + export function $reserve( ctx: DecoratorContext, target: Model, ...reservations: readonly (Type | number | string)[] ) { - const finalReservations = reservations.map((reservation) => - typeof reservation === "object" ? getTuple(ctx.program, reservation) : reservation - ); + const finalReservations = reservations + .map((reservation) => + typeof reservation === "object" ? getTuple(ctx.program, reservation) : reservation + ) + .filter((v) => v != null); ctx.program.stateMap(state.reserve).set(target, finalReservations); } @@ -166,22 +180,23 @@ export function $field(ctx: DecoratorContext, target: ModelProperty, fieldIndex: * * @param program - the program to emit */ -export async function $onEmit(program: Program, options?: EmitOptionsFor) { - const emitter = createProtobufEmitter(program); +export async function $onEmit(ctx: EmitContext>) { + const emitter = createProtobufEmitter(ctx.program); - await emitter({ - /* c8 ignore next */ - outputDirectory: options?.outputDirectory, - }); + await emitter(resolvePath(ctx.emitterOutputDir), ctx.options); } -/*export async function $onValidate(program: Program) { - const emitter = createGrpcEmitter(program); - - await emitter({ - noEmit: true, - }); -}*/ +/** + * Validation function + */ +export async function $onValidate(program: Program) { + if (program.compilerOptions.noEmit) { + const options = program.emitters.find((e) => e.emitFunction === $onEmit) + ?.options as ProtobufEmitterOptions; + const emitter = createProtobufEmitter(program); + await emitter("", options); + } +} export const namespace = "Cadl.Protobuf"; diff --git a/packages/protobuf/src/transform.ts b/packages/protobuf/src/transform.ts index cf76b3f42ca..b7974629268 100644 --- a/packages/protobuf/src/transform.ts +++ b/packages/protobuf/src/transform.ts @@ -2,12 +2,13 @@ // Licensed under the MIT license. import { + DiagnosticTarget, Enum, + EnumMember, getEffectiveModelType, getTypeName, Interface, isDeclaredInNamespace, - listServices, Model, ModelProperty, Namespace, @@ -15,7 +16,10 @@ import { Program, resolvePath, Scalar, + StringLiteral, + SyntaxKind, Type, + Union, } from "@cadl-lang/compiler"; import { map, @@ -24,8 +28,10 @@ import { ProtoFieldDeclaration, ProtoFile, ProtoMap, + ProtoMessageBodyDeclaration, ProtoMessageDeclaration, ProtoMethodDeclaration, + ProtoOneOfDeclaration, ProtoRef, ProtoScalar, ProtoTopLevelDeclaration, @@ -37,23 +43,19 @@ import { unreachable, } from "./ast.js"; import { ProtobufEmitterOptions, reportDiagnostic, state } from "./lib.js"; -import { isMap } from "./proto.js"; +import { $field, isMap, Reservation } from "./proto.js"; import { writeProtoFile } from "./write.js"; -// Default options -const DEFAULT_OPTIONS = { - outputDirectory: "./cadl-output/", -} as const; +// Cache for scalar -> ProtoScalar map +let _protoScalarsMap: Map; /** * Create a worker function that converts the CADL program to Protobuf and writes it to the file system. */ export function createProtobufEmitter( program: Program -): (options?: ProtobufEmitterOptions) => Promise { - return async function doEmit(options) { - const outDir = resolvePath(options?.outputDirectory ?? DEFAULT_OPTIONS.outputDirectory); - +): (outDir: string, options: ProtobufEmitterOptions) => Promise { + return async function doEmit(outDir, options) { // Convert the program to a set of proto files. const files = cadlToProto(program); @@ -83,9 +85,11 @@ export function createProtobufEmitter( * This is the meat of the emitter. */ function cadlToProto(program: Program): ProtoFile[] { - const packages = new Set(listServices(program).map((service) => service.type)); + const packages = new Set( + program.stateMap(state.package).keys() as Iterable + ); - const serviceInterfaces = [...(program.stateSet(state.serviceInterface) as Set)]; + const serviceInterfaces = [...(program.stateSet(state.service) as Set)]; const declarationMap = new Map( [...packages].map((p) => [p, []]) @@ -132,7 +136,7 @@ function cadlToProto(program: Program): ProtoFile[] { // we also only support enums where the first value is zero. if (members[0].value !== 0) { reportDiagnostic(program, { - target: members[0], + target: getMemberTypeSyntaxTarget(members[0]), code: "unconvertible-enum", messageId: "no-zero-first", }); @@ -164,21 +168,25 @@ function cadlToProto(program: Program): ProtoFile[] { } // Emit a file per package. - const files = [...packages].map( - (namespace) => - ({ - package: program.stateMap(state.packageName).get(namespace), + const files = [...packages].map((namespace) => { + const details = program.stateMap(state.package).get(namespace) as Model | undefined; + return { + package: ( + (details?.properties.get("name") as ModelProperty | undefined)?.type as + | StringLiteral + | undefined + )?.value, - // TODO: The language guide is really unclear about how to handle these. We may also need a facility for - // allowing packages to declare extensions. - options: {}, + // TODO: The language guide is really unclear about how to handle these. We may also need a facility for + // allowing packages to declare extensions, as extensions may be target/compiler specific. + options: {}, - imports: [...(importMap.get(namespace) ?? [])], + imports: [...(importMap.get(namespace) ?? [])], - declarations: declarationMap.get(namespace), - source: namespace, - } as ProtoFile) - ); + declarations: declarationMap.get(namespace), + source: namespace, + } as ProtoFile; + }); checkForNamespaceCollisions(files); @@ -250,7 +258,7 @@ function cadlToProto(program: Program): ProtoFile[] { /* c8 ignore start */ - // Not sure if this can or can't happen. + // Not sure if this can or can't actually happen at runtime, but we'll defensively handle it anyway. if (!effectiveModel) { reportDiagnostic(program, { code: "unsupported-input-type", @@ -305,7 +313,7 @@ function cadlToProto(program: Program): ProtoFile[] { // TODO: logic is duplicated in addReturnModel reportDiagnostic(program, { code: "unsupported-return-type", - target: t, + target: getOperationReturnSyntaxTarget(operation), }); return unreachable("unsupported return type"); @@ -332,7 +340,7 @@ function cadlToProto(program: Program): ProtoFile[] { reportDiagnostic(program, { code: "unsupported-return-type", - target: m, + target: getOperationReturnSyntaxTarget(operation), }); return unreachable("unsupported return type"); @@ -388,7 +396,7 @@ function cadlToProto(program: Program): ProtoFile[] { } function mapToProto(t: Model, relativeSource: Model | Operation): ProtoMap { - const [keyType, valueType] = t.templateArguments ?? []; + const [keyType, valueType] = t.templateMapper!.args; // A map's value cannot be another map. if (isMap(program, valueType)) { @@ -403,7 +411,7 @@ function cadlToProto(program: Program): ProtoFile[] { // This is a core compile error. if (!keyType || !valueType) return unreachable("nonexistent map key or value type"); - // TODO: key can be any integral type only + // TODO: key can be any integral or string type only const keyProto = addType(keyType, relativeSource); const valueProto = addType(valueType, relativeSource) as ProtoRef | ProtoScalar; @@ -411,13 +419,13 @@ function cadlToProto(program: Program): ProtoFile[] { } function arrayToProto(t: Model, relativeSource: Model | Operation): ProtoType { - const valueType = (t as Model).templateArguments![0]; + const valueType = (t as Model).templateMapper!.args[0]; // Nested arrays are not supported. if (isArray(valueType)) { reportDiagnostic(program, { code: "nested-array", - target: t, + target: valueType, }); return ref(""); } @@ -425,26 +433,34 @@ function cadlToProto(program: Program): ProtoFile[] { return addType(valueType, relativeSource); } + function getProtoScalarsMap(program: Program): Map { + return (_protoScalarsMap ??= new Map( + ( + [ + [program.resolveTypeReference("Cadl.bytes"), scalar("bytes")], + [program.resolveTypeReference("Cadl.boolean"), scalar("bool")], + [program.resolveTypeReference("Cadl.string"), scalar("string")], + [program.resolveTypeReference("Cadl.int32"), scalar("int32")], + [program.resolveTypeReference("Cadl.int64"), scalar("int64")], + [program.resolveTypeReference("Cadl.uint32"), scalar("uint32")], + [program.resolveTypeReference("Cadl.uint64"), scalar("uint64")], + [program.resolveTypeReference("Cadl.float32"), scalar("float")], + [program.resolveTypeReference("Cadl.float64"), scalar("double")], + [program.resolveTypeReference("Cadl.Protobuf.sfixed32"), scalar("sfixed32")], + [program.resolveTypeReference("Cadl.Protobuf.sfixed64"), scalar("sfixed64")], + [program.resolveTypeReference("Cadl.Protobuf.sint32"), scalar("sint32")], + [program.resolveTypeReference("Cadl.Protobuf.sint64"), scalar("sint64")], + [program.resolveTypeReference("Cadl.Protobuf.fixed32"), scalar("fixed32")], + [program.resolveTypeReference("Cadl.Protobuf.fixed64"), scalar("fixed64")], + ] as [[Type, unknown], ProtoScalar][] + ).map(([[type], scalar]) => [type, scalar]) + )); + } + function scalarToProto(t: Scalar): ProtoType { const fullName = getTypeName(t); - const protoType = { - "Cadl.bytes": scalar("bytes"), - "Cadl.boolean": scalar("bool"), - "Cadl.string": scalar("string"), - "Cadl.int32": scalar("int32"), - "Cadl.int64": scalar("int64"), - "Cadl.uint32": scalar("uint32"), - "Cadl.uint64": scalar("uint64"), - "Cadl.float32": scalar("float"), - "Cadl.float64": scalar("double"), - "Cadl.Protobuf.sfixed32": scalar("sfixed32"), - "Cadl.Protobuf.sfixed64": scalar("sfixed64"), - "Cadl.Protobuf.sint32": scalar("sint32"), - "Cadl.Protobuf.sint64": scalar("sint64"), - "Cadl.Protobuf.fixed32": scalar("fixed32"), - "Cadl.Protobuf.fixed64": scalar("fixed64"), - }[fullName]; + const protoType = getProtoScalarsMap(program).get(t); if (!protoType) { reportDiagnostic(program, { @@ -511,15 +527,114 @@ function cadlToProto(program: Program): ProtoFile[] { kind: "message", name: model.name, reservations: program.stateMap(state.reserve).get(model), - declarations: [...model.properties.values()].map((f) => toField(f, model)), + declarations: [...model.properties.values()].map((f) => toMessageBodyDeclaration(f, model)), }; } /** * @param property - the ModelProperty to convert - * @returns a corresponding field declaration + * @returns a corresponding declaration */ - function toField(property: ModelProperty, model: Model): ProtoFieldDeclaration { + function toMessageBodyDeclaration( + property: ModelProperty, + model: Model + ): ProtoMessageBodyDeclaration { + if (property.type.kind === "Union") { + // TODO: union must have at least one variant. + // TODO: union members must have field decorators. + // TODO: union must be anonymous + // TODO: union fields mustn't be arrays or maps. + // TODO: union variants must be string-named + + // TODO: this isn't actually possible at all, because "union has named variants" and "union must be anonymous" + // are currently contradictory, so we can temporarily allow union decls with the understanding that they will be + // certainly inlined. + + const oneof: ProtoOneOfDeclaration = { + kind: "oneof", + name: property.name, + declarations: [...property.type.variants.values()] + .filter(/*TODO:*/ (v) => typeof v.name === "string") + .map( + (v): ProtoFieldDeclaration => ({ + kind: "field", + name: v.name as string, + index: program.stateMap(state.fieldIndex).get(v), + type: addImportSourceForProtoIfNeeded( + program, + addType(v.type, model), + model, + v.type as NamespaceTraversable /*TODO: seems weird*/ + ), + repeated: false, + }) + ), + }; + + return oneof; + } + // TODO: all fields must have an index. + // TODO: validate that the type is OK _before_ calling addImportSourceForProtoIfNeeded + + const fieldIndex = program.stateMap(state.fieldIndex).get(property) as number | undefined; + const fieldIndexNode = property.decorators.find((d) => d.decorator === $field)?.args[0].node; + if (!fieldIndexNode) throw new Error("Failed to recover field decorator argument."); + + if (fieldIndex === undefined) { + reportDiagnostic(program, { + code: "field-index", + messageId: "missing", + format: { + name: property.name, + }, + target: property, + }); + } + + const reservations = program.stateMap(state.reserve).get(model) as Reservation[] | undefined; + + if (reservations) { + for (const reservation of reservations) { + if (typeof reservation === "string" && reservation === property.name) { + reportDiagnostic(program, { + code: "field-name", + messageId: "user-reserved", + format: { + name: property.name, + }, + target: getPropertyNameSyntaxTarget(property), + }); + } else if ( + fieldIndex !== undefined && + typeof reservation === "number" && + reservation === fieldIndex + ) { + reportDiagnostic(program, { + code: "field-index", + messageId: "user-reserved", + format: { + index: fieldIndex.toString(), + }, + target: fieldIndexNode, + }); + } else if ( + fieldIndex !== undefined && + Array.isArray(reservation) && + fieldIndex >= reservation[0] && + fieldIndex <= reservation[1] + ) { + reportDiagnostic(program, { + code: "field-index", + messageId: "user-reserved-range", + format: { + index: fieldIndex.toString(), + }, + target: fieldIndexNode, + }); + } + } + } + const field: ProtoFieldDeclaration = { kind: "field", name: property.name, @@ -555,7 +670,7 @@ function cadlToProto(program: Program): ProtoFile[] { }; } - type NamespaceTraversable = Enum | Model | Interface | Operation | Namespace; + type NamespaceTraversable = Enum | Model | Interface | Union | Operation | Namespace; function getPackageOfType( program: Program, @@ -569,6 +684,7 @@ function cadlToProto(program: Program): ProtoFile[] { switch (t.kind) { case "Enum": case "Model": + case "Union": case "Interface": if (!t.namespace) { !quiet && reportDiagnostic(program, { code: "no-package", target: t }); @@ -657,9 +773,13 @@ function cadlToProto(program: Program): ProtoFile[] { ) return pt; - const dependencyPackageName = program - .stateMap(state.packageName) - .get(dependencyPackage) as string | undefined; + const dependencyDetails = program.stateMap(state.package).get(dependencyPackage) as + | Model + | undefined; + + const dependencyPackageName = ( + dependencyDetails?.properties.get("name")?.type as StringLiteral | undefined + )?.value; const dependencyPackagePrefix = dependencyPackageName === undefined || dependencyPackageName === "" @@ -690,3 +810,62 @@ function isArray(t: Type) { function capitalize(s: S) { return (s.slice(0, 1).toUpperCase() + s.slice(1)) as Capitalize; } + +/** + * Helps us squiggle the right things for operation return types. + */ +function getOperationReturnSyntaxTarget(op: Operation): DiagnosticTarget { + const signature = op.node.signature; + switch (signature.kind) { + case SyntaxKind.OperationSignatureDeclaration: + return signature.returnType; + case SyntaxKind.OperationSignatureReference: + // op foo is whatever; + return op; + default: + const __exhaust: never = signature; + throw new Error( + `Internal Emitter Error: reached unreachable operation signature: ${op.node.signature.kind}` + ); + } +} + +function getMemberTypeSyntaxTarget(property: ModelProperty | EnumMember): DiagnosticTarget { + const node = property.node; + + switch (node.kind) { + case SyntaxKind.ModelProperty: + return node.value; + case SyntaxKind.ModelSpreadProperty: + return node; + case SyntaxKind.EnumMember: + return node.value ?? node; + case SyntaxKind.ProjectionModelProperty: + case SyntaxKind.ProjectionModelSpreadProperty: + return property; + default: + const __exhaust: never = node; + throw new Error( + `Internal Emitter Error: reached unreachable member node: ${property.node.kind}` + ); + } +} + +function getPropertyNameSyntaxTarget(property: ModelProperty): DiagnosticTarget { + const node = property.node; + + switch (node.kind) { + case SyntaxKind.ModelProperty: + return node.id; + case SyntaxKind.ModelSpreadProperty: + return node; + case SyntaxKind.ProjectionModelProperty: + case SyntaxKind.ProjectionModelSpreadProperty: + return property; + default: + const __exhaust: never = node; + throw new Error( + `Internal Emitter Error: reached unreachable model property node: ${property.node.kind}` + ); + } +} diff --git a/packages/protobuf/test/include/foo/bar.proto b/packages/protobuf/test/include/foo/bar.proto new file mode 100644 index 00000000000..ac62127a60f --- /dev/null +++ b/packages/protobuf/test/include/foo/bar.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +package foo; + +message Bar { + int32 field = 1; +} diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.cc new file mode 100644 index 00000000000..3241e74259f --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.cc @@ -0,0 +1,515 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#include "main.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +PROTOBUF_CONSTEXPR Input::Input( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct InputDefaultTypeInternal { + PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputDefaultTypeInternal() {} + union { + Input _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; +PROTOBUF_CONSTEXPR Output::Output( + ::_pbi::ConstantInitialized): _impl_{ + /* ._impl_.testoutputfield_ = */ 0 + + , /*decltype(_impl_._cached_size_)*/{}} {} +struct OutputDefaultTypeInternal { + PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~OutputDefaultTypeInternal() {} + union { + Output _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; +static ::_pb::Metadata file_level_metadata_main_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_main_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_main_2eproto = nullptr; +const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::Input, _impl_.testinputfield_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::Output, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::Output, _impl_.testoutputfield_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::Input)}, + { 9, -1, -1, sizeof(::Output)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_Input_default_instance_._instance, + &::_Output_default_instance_._instance, +}; +const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\nmain.proto\"\037\n\005Input\022\026\n\016testInputField\030" + "\001 \001(\t\"!\n\006Output\022\027\n\017testOutputField\030\001 \001(\005" + "2!\n\007Service\022\026\n\003Foo\022\006.Input\032\007.Outputb\006pro" + "to3" +}; +static ::absl::once_flag descriptor_table_main_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { + false, + false, + 123, + descriptor_table_protodef_main_2eproto, + "main.proto", + &descriptor_table_main_2eproto_once, + nullptr, + 0, + 2, + schemas, + file_default_instances, + TableStruct_main_2eproto::offsets, + file_level_metadata_main_2eproto, + file_level_enum_descriptors_main_2eproto, + file_level_service_descriptors_main_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { + return &descriptor_table_main_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); +// =================================================================== + +class Input::_Internal { + public: +}; + +Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:Input) +} +Input::Input(const Input& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Input* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_testinputfield().empty()) { + _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:Input) +} + +inline void Input::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Input::~Input() { + // @@protoc_insertion_point(destructor:Input) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Input::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testinputfield_.Destroy(); +} + +void Input::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Input::Clear() { +// @@protoc_insertion_point(message_clear_start:Input) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_.ClearToEmpty(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // string testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + auto str = _internal_mutable_testinputfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "Input.testInputField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Input::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:Input) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "Input.testInputField"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_testinputfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:Input) + return target; +} + +::size_t Input::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:Input) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_testinputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Input::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } + + +void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:Input) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_testinputfield().empty()) { + _this->_internal_set_testinputfield(from._internal_testinputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Input::CopyFrom(const Input& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:Input) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Input::IsInitialized() const { + return true; +} + +void Input::InternalSwap(Input* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.testinputfield_, lhs_arena, + &other->_impl_.testinputfield_, rhs_arena + ); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[0]); +} +// =================================================================== + +class Output::_Internal { + public: +}; + +Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:Output) +} +Output::Output(const Output& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>( + from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:Output) +} + +inline void Output::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testoutputfield_) { 0 } + + , /*decltype(_impl_._cached_size_)*/{} + }; +} + +Output::~Output() { + // @@protoc_insertion_point(destructor:Output) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Output::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); +} + +void Output::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Output::Clear() { +// @@protoc_insertion_point(message_clear_start:Output) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testoutputfield_ = 0; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // int32 testOutputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { + _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Output::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:Output) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray( + 1, this->_internal_testoutputfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:Output) + return target; +} + +::size_t Output::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:Output) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( + this->_internal_testoutputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Output::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } + + +void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:Output) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_testoutputfield() != 0) { + _this->_internal_set_testoutputfield(from._internal_testoutputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Output::CopyFrom(const Output& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:Output) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Output::IsInitialized() const { + return true; +} + +void Output::InternalSwap(Output* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + + swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::Input* +Arena::CreateMaybeMessage< ::Input >(Arena* arena) { + return Arena::CreateMessageInternal< ::Input >(arena); +} +template<> PROTOBUF_NOINLINE ::Output* +Arena::CreateMaybeMessage< ::Output >(Arena* arena) { + return Arena::CreateMessageInternal< ::Output >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.h new file mode 100644 index 00000000000..e36f8cedf5e --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.h @@ -0,0 +1,466 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_main_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_main_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_main_2eproto; +class Input; +struct InputDefaultTypeInternal; +extern InputDefaultTypeInternal _Input_default_instance_; +class Output; +struct OutputDefaultTypeInternal; +extern OutputDefaultTypeInternal _Output_default_instance_; +PROTOBUF_NAMESPACE_OPEN +template <> +::Input* Arena::CreateMaybeMessage<::Input>(Arena*); +template <> +::Output* Arena::CreateMaybeMessage<::Output>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + + +// =================================================================== + + +// ------------------------------------------------------------------- + +class Input final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { + public: + inline Input() : Input(nullptr) {} + ~Input() override; + explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Input(const Input& from); + Input(Input&& from) noexcept + : Input() { + *this = ::std::move(from); + } + + inline Input& operator=(const Input& from) { + CopyFrom(from); + return *this; + } + inline Input& operator=(Input&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Input& default_instance() { + return *internal_default_instance(); + } + static inline const Input* internal_default_instance() { + return reinterpret_cast( + &_Input_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Input& a, Input& b) { + a.Swap(&b); + } + inline void Swap(Input* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Input* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Input& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Input& from) { + Input::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Input* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "Input"; + } + protected: + explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + }; + // string testInputField = 1; + void clear_testinputfield() ; + const std::string& testinputfield() const; + template + void set_testinputfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_testinputfield(); + PROTOBUF_NODISCARD std::string* release_testinputfield(); + void set_allocated_testinputfield(std::string* testinputfield); + private: + const std::string& _internal_testinputfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); + std::string* _internal_mutable_testinputfield(); + public: + // @@protoc_insertion_point(class_scope:Input) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +};// ------------------------------------------------------------------- + +class Output final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Output) */ { + public: + inline Output() : Output(nullptr) {} + ~Output() override; + explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Output(const Output& from); + Output(Output&& from) noexcept + : Output() { + *this = ::std::move(from); + } + + inline Output& operator=(const Output& from) { + CopyFrom(from); + return *this; + } + inline Output& operator=(Output&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Output& default_instance() { + return *internal_default_instance(); + } + static inline const Output* internal_default_instance() { + return reinterpret_cast( + &_Output_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(Output& a, Output& b) { + a.Swap(&b); + } + inline void Swap(Output* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Output* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Output& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Output& from) { + Output::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Output* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "Output"; + } + protected: + explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestOutputFieldFieldNumber = 1, + }; + // int32 testOutputField = 1; + void clear_testoutputfield() ; + ::int32_t testoutputfield() const; + void set_testoutputfield(::int32_t value); + + private: + ::int32_t _internal_testoutputfield() const; + void _internal_set_testoutputfield(::int32_t value); + + public: + // @@protoc_insertion_point(class_scope:Output) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::int32_t testoutputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// Input + +// string testInputField = 1; +inline void Input::clear_testinputfield() { + _impl_.testinputfield_.ClearToEmpty(); +} +inline const std::string& Input::testinputfield() const { + // @@protoc_insertion_point(field_get:Input.testInputField) + return _internal_testinputfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { + + _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:Input.testInputField) +} +inline std::string* Input::mutable_testinputfield() { + std::string* _s = _internal_mutable_testinputfield(); + // @@protoc_insertion_point(field_mutable:Input.testInputField) + return _s; +} +inline const std::string& Input::_internal_testinputfield() const { + return _impl_.testinputfield_.Get(); +} +inline void Input::_internal_set_testinputfield(const std::string& value) { + + _impl_.testinputfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Input::_internal_mutable_testinputfield() { + + return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Input::release_testinputfield() { + // @@protoc_insertion_point(field_release:Input.testInputField) + return _impl_.testinputfield_.Release(); +} +inline void Input::set_allocated_testinputfield(std::string* testinputfield) { + _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.testinputfield_.IsDefault()) { + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:Input.testInputField) +} + +// ------------------------------------------------------------------- + +// Output + +// int32 testOutputField = 1; +inline void Output::clear_testoutputfield() { + _impl_.testoutputfield_ = 0; +} +inline ::int32_t Output::testoutputfield() const { + // @@protoc_insertion_point(field_get:Output.testOutputField) + return _internal_testoutputfield(); +} +inline void Output::set_testoutputfield(::int32_t value) { + ; + _internal_set_testoutputfield(value); + // @@protoc_insertion_point(field_set:Output.testOutputField) +} +inline ::int32_t Output::_internal_testoutputfield() const { + return _impl_.testoutputfield_; +} +inline void Output::_internal_set_testoutputfield(::int32_t value) { + ; + _impl_.testoutputfield_ = value; +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/anonymous-package/output/csharp/Main.cs new file mode 100644 index 00000000000..3d457804aed --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/csharp/Main.cs @@ -0,0 +1,420 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +/// Holder for reflection information generated from main.proto +public static partial class MainReflection { + + #region Descriptor + /// File descriptor for main.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MainReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgptYWluLnByb3RvIh8KBUlucHV0EhYKDnRlc3RJbnB1dEZpZWxkGAEgASgJ", + "IiEKBk91dHB1dBIXCg90ZXN0T3V0cHV0RmllbGQYASABKAUyIQoHU2Vydmlj", + "ZRIWCgNGb28SBi5JbnB1dBoHLk91dHB1dGIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "TestInputField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Output), global::Output.Parser, new[]{ "TestOutputField" }, null, null, null, null) + })); + } + #endregion + +} +#region Messages +public sealed partial class Input : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input(Input other) : this() { + testInputField_ = other.testInputField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input Clone() { + return new Input(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private string testInputField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string TestInputField { + get { return testInputField_; } + set { + testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Input); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Input other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestInputField != other.TestInputField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestInputField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Input other) { + if (other == null) { + return; + } + if (other.TestInputField.Length != 0) { + TestInputField = other.TestInputField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + } + #endif + +} + +public sealed partial class Output : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output(Output other) : this() { + testOutputField_ = other.testOutputField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output Clone() { + return new Output(this); + } + + /// Field number for the "testOutputField" field. + public const int TestOutputFieldFieldNumber = 1; + private int testOutputField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int TestOutputField { + get { return testOutputField_; } + set { + testOutputField_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Output); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Output other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestOutputField != other.TestOutputField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestOutputField != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Output other) { + if (other == null) { + return; + } + if (other.TestOutputField != 0) { + TestOutputField = other.TestOutputField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + } + } + } + #endif + +} + +#endregion + + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.h new file mode 100644 index 00000000000..4d7a266069b --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.h @@ -0,0 +1,80 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - MainRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface MainRoot : GPBRootObject +@end + +#pragma mark - Input + +typedef GPB_ENUM(Input_FieldNumber) { + Input_FieldNumber_TestInputField = 1, +}; + +GPB_FINAL @interface Input : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; + +@end + +#pragma mark - Output + +typedef GPB_ENUM(Output_FieldNumber) { + Output_FieldNumber_TestOutputField = 1, +}; + +GPB_FINAL @interface Output : GPBMessage + +@property(nonatomic, readwrite) int32_t testOutputField; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.m new file mode 100644 index 00000000000..a38cf69a9ec --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.m @@ -0,0 +1,149 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "Main.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - MainRoot + +@implementation MainRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - MainRoot_FileDescriptor + +static GPBFileDescriptor *MainRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Input + +@implementation Input + +@dynamic testInputField; + +typedef struct Input__storage_ { + uint32_t _has_storage_[1]; + NSString *testInputField; +} Input__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputField", + .dataTypeSpecific.clazz = Nil, + .number = Input_FieldNumber_TestInputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Input__storage_, testInputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Input class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Input__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\016\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - Output + +@implementation Output + +@dynamic testOutputField; + +typedef struct Output__storage_ { + uint32_t _has_storage_[1]; + int32_t testOutputField; +} Output__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testOutputField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_TestOutputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Output__storage_, testOutputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeInt32, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Output class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Output__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\017\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/anonymous-package/output/php/GPBMetadata/Main.php new file mode 100644 index 00000000000..0979d31f5bb --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/php/GPBMetadata/Main.php @@ -0,0 +1,33 @@ +internalAddGeneratedFile( + ' +{ + +main.proto" +Input +testInputField ( "! +Output +testOutputField (2! +Service +Foo.Input.Outputbproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/php/Input.php b/packages/protobuf/test/protoc-out/anonymous-package/output/php/Input.php new file mode 100644 index 00000000000..b77d7713c23 --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/php/Input.php @@ -0,0 +1,56 @@ +Input + */ +class Input extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string testInputField = 1; + */ + protected $testInputField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $testInputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string testInputField = 1; + * @return string + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field string testInputField = 1; + * @param string $var + * @return $this + */ + public function setTestInputField($var) + { + GPBUtil::checkString($var, True); + $this->testInputField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/php/Output.php b/packages/protobuf/test/protoc-out/anonymous-package/output/php/Output.php new file mode 100644 index 00000000000..e57f5754848 --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/php/Output.php @@ -0,0 +1,56 @@ +Output + */ +class Output extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field int32 testOutputField = 1; + */ + protected $testOutputField = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $testOutputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @return int + */ + public function getTestOutputField() + { + return $this->testOutputField; + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @param int $var + * @return $this + */ + public function setTestOutputField($var) + { + GPBUtil::checkInt32($var); + $this->testOutputField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/anonymous-package/output/pyi/main_pb2.pyi new file mode 100644 index 00000000000..999c2653afb --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/pyi/main_pb2.pyi @@ -0,0 +1,17 @@ +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Optional as _Optional + +DESCRIPTOR: _descriptor.FileDescriptor + +class Input(_message.Message): + __slots__ = ["testInputField"] + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testInputField: str + def __init__(self, testInputField: _Optional[str] = ...) -> None: ... + +class Output(_message.Message): + __slots__ = ["testOutputField"] + TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testOutputField: int + def __init__(self, testOutputField: _Optional[int] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/anonymous-package/output/python/main_pb2.py new file mode 100644 index 00000000000..4079a0f5074 --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/python/main_pb2.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\"\x1f\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\"!\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x32!\n\x07Service\x12\x16\n\x03\x46oo\x12\x06.Input\x1a\x07.Outputb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_INPUT']._serialized_start=14 + _globals['_INPUT']._serialized_end=45 + _globals['_OUTPUT']._serialized_start=47 + _globals['_OUTPUT']._serialized_end=80 + _globals['_SERVICE']._serialized_start=82 + _globals['_SERVICE']._serialized_end=115 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/anonymous-package/output/ruby/main_pb.rb new file mode 100644 index 00000000000..b2b7cffc687 --- /dev/null +++ b/packages/protobuf/test/protoc-out/anonymous-package/output/ruby/main_pb.rb @@ -0,0 +1,18 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("main.proto", :syntax => :proto3) do + add_message "Input" do + optional :testInputField, :string, 1 + end + add_message "Output" do + optional :testOutputField, :int32, 1 + end + end +end + +Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass +Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Output").msgclass diff --git a/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.cc b/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.cc new file mode 100644 index 00000000000..cfc97ec993f --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.cc @@ -0,0 +1,588 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: com/azure/test.proto + +#include "com/azure/test.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +namespace com { +namespace azure { +namespace test { +PROTOBUF_CONSTEXPR Input::Input( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.testinputfield_)*/{} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct InputDefaultTypeInternal { + PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputDefaultTypeInternal() {} + union { + Input _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; +PROTOBUF_CONSTEXPR Output::Output( + ::_pbi::ConstantInitialized): _impl_{ + /* ._impl_.testoutputfield_ = */ {} + ,/* _impl_._testoutputfield_cached_byte_size_ = */ { 0 } + + , /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct OutputDefaultTypeInternal { + PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~OutputDefaultTypeInternal() {} + union { + Output _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; +} // namespace test +} // namespace azure +} // namespace com +static ::_pb::Metadata file_level_metadata_com_2fazure_2ftest_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_com_2fazure_2ftest_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_com_2fazure_2ftest_2eproto = nullptr; +const ::uint32_t TableStruct_com_2fazure_2ftest_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::com::azure::test::Input, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::com::azure::test::Input, _impl_.testinputfield_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::com::azure::test::Output, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::com::azure::test::Output, _impl_.testoutputfield_), + PROTOBUF_FIELD_OFFSET(::com::azure::test::Output, _impl_.secondfield_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::com::azure::test::Input)}, + { 9, -1, -1, sizeof(::com::azure::test::Output)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::com::azure::test::_Input_default_instance_._instance, + &::com::azure::test::_Output_default_instance_._instance, +}; +const char descriptor_table_protodef_com_2fazure_2ftest_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\024com/azure/test.proto\022\016com.azure.test\"\037" + "\n\005Input\022\026\n\016testInputField\030\001 \003(\t\"6\n\006Outpu" + "t\022\027\n\017testOutputField\030\001 \003(\005\022\023\n\013secondFiel" + "d\030\002 \001(\t2\?\n\007Service\0224\n\003Foo\022\025.com.azure.te" + "st.Input\032\026.com.azure.test.Outputb\006proto3" +}; +static ::absl::once_flag descriptor_table_com_2fazure_2ftest_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_com_2fazure_2ftest_2eproto = { + false, + false, + 200, + descriptor_table_protodef_com_2fazure_2ftest_2eproto, + "com/azure/test.proto", + &descriptor_table_com_2fazure_2ftest_2eproto_once, + nullptr, + 0, + 2, + schemas, + file_default_instances, + TableStruct_com_2fazure_2ftest_2eproto::offsets, + file_level_metadata_com_2fazure_2ftest_2eproto, + file_level_enum_descriptors_com_2fazure_2ftest_2eproto, + file_level_service_descriptors_com_2fazure_2ftest_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_com_2fazure_2ftest_2eproto_getter() { + return &descriptor_table_com_2fazure_2ftest_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_com_2fazure_2ftest_2eproto(&descriptor_table_com_2fazure_2ftest_2eproto); +namespace com { +namespace azure { +namespace test { +// =================================================================== + +class Input::_Internal { + public: +}; + +Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:com.azure.test.Input) +} +Input::Input(const Input& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Input* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){from._impl_.testinputfield_} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:com.azure.test.Input) +} + +inline void Input::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){arena} + , /*decltype(_impl_._cached_size_)*/{} + }; +} + +Input::~Input() { + // @@protoc_insertion_point(destructor:com.azure.test.Input) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Input::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testinputfield_.~RepeatedPtrField(); +} + +void Input::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Input::Clear() { +// @@protoc_insertion_point(message_clear_start:com.azure.test.Input) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // repeated string testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_testinputfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "com.azure.test.Input.testInputField")); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Input::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:com.azure.test.Input) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // repeated string testInputField = 1; + for (int i = 0, n = this->_internal_testinputfield_size(); i < n; i++) { + const auto& s = this->_internal_testinputfield(i); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + s.data(), static_cast(s.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "com.azure.test.Input.testInputField"); + target = stream->WriteString(1, s, target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:com.azure.test.Input) + return target; +} + +::size_t Input::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:com.azure.test.Input) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated string testInputField = 1; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.testinputfield_.size()); + for (int i = 0, n = _impl_.testinputfield_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + _impl_.testinputfield_.Get(i)); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Input::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } + + +void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.test.Input) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + _this->_impl_.testinputfield_.MergeFrom(from._impl_.testinputfield_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Input::CopyFrom(const Input& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.test.Input) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Input::IsInitialized() const { + return true; +} + +void Input::InternalSwap(Input* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + _impl_.testinputfield_.InternalSwap(&other->_impl_.testinputfield_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_com_2fazure_2ftest_2eproto_getter, &descriptor_table_com_2fazure_2ftest_2eproto_once, + file_level_metadata_com_2fazure_2ftest_2eproto[0]); +} +// =================================================================== + +class Output::_Internal { + public: +}; + +Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:com.azure.test.Output) +} +Output::Output(const Output& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Output* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.testoutputfield_) { from._impl_.testoutputfield_ } + ,/* _impl_._testoutputfield_cached_byte_size_ = */ { 0 } + + , decltype(_impl_.secondfield_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_secondfield().empty()) { + _this->_impl_.secondfield_.Set(from._internal_secondfield(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:com.azure.test.Output) +} + +inline void Output::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testoutputfield_) { arena } + ,/* _impl_._testoutputfield_cached_byte_size_ = */ { 0 } + + , decltype(_impl_.secondfield_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Output::~Output() { + // @@protoc_insertion_point(destructor:com.azure.test.Output) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Output::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testoutputfield_.~RepeatedField(); + _impl_.secondfield_.Destroy(); +} + +void Output::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Output::Clear() { +// @@protoc_insertion_point(message_clear_start:com.azure.test.Output) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testoutputfield_.Clear(); + _impl_.secondfield_.ClearToEmpty(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // repeated int32 testOutputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_testoutputfield(), ptr, ctx); + CHK_(ptr); + } else if (static_cast<::uint8_t>(tag) == 8) { + _internal_add_testoutputfield(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr)); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + // string secondField = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { + auto str = _internal_mutable_secondfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "com.azure.test.Output.secondField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Output::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:com.azure.test.Output) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // repeated int32 testOutputField = 1; + { + int byte_size = _impl_._testoutputfield_cached_byte_size_.Get(); + if (byte_size > 0) { + target = stream->WriteInt32Packed(1, _internal_testoutputfield(), + byte_size, target); + } + } + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "com.azure.test.Output.secondField"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_secondfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:com.azure.test.Output) + return target; +} + +::size_t Output::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:com.azure.test.Output) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated int32 testOutputField = 1; + { + std::size_t data_size = ::_pbi::WireFormatLite::Int32Size(this->_impl_.testoutputfield_) + ; + _impl_._testoutputfield_cached_byte_size_.Set(::_pbi::ToCachedSize(data_size)); + std::size_t tag_size = data_size == 0 + ? 0 + : 1 + ::_pbi::WireFormatLite::Int32Size( + static_cast(data_size)) + ; + total_size += tag_size + data_size; + } + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_secondfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Output::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } + + +void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.test.Output) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + _this->_impl_.testoutputfield_.MergeFrom(from._impl_.testoutputfield_); + if (!from._internal_secondfield().empty()) { + _this->_internal_set_secondfield(from._internal_secondfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Output::CopyFrom(const Output& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.test.Output) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Output::IsInitialized() const { + return true; +} + +void Output::InternalSwap(Output* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + _impl_.testoutputfield_.InternalSwap(&other->_impl_.testoutputfield_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.secondfield_, lhs_arena, + &other->_impl_.secondfield_, rhs_arena + ); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_com_2fazure_2ftest_2eproto_getter, &descriptor_table_com_2fazure_2ftest_2eproto_once, + file_level_metadata_com_2fazure_2ftest_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +} // namespace test +} // namespace azure +} // namespace com +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::com::azure::test::Input* +Arena::CreateMaybeMessage< ::com::azure::test::Input >(Arena* arena) { + return Arena::CreateMessageInternal< ::com::azure::test::Input >(arena); +} +template<> PROTOBUF_NOINLINE ::com::azure::test::Output* +Arena::CreateMaybeMessage< ::com::azure::test::Output >(Arena* arena) { + return Arena::CreateMessageInternal< ::com::azure::test::Output >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.h b/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.h new file mode 100644 index 00000000000..1adcd851196 --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.h @@ -0,0 +1,619 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: com/azure/test.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_com_2fazure_2ftest_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_com_2fazure_2ftest_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_com_2fazure_2ftest_2eproto; +namespace com { +namespace azure { +namespace test { +class Input; +struct InputDefaultTypeInternal; +extern InputDefaultTypeInternal _Input_default_instance_; +class Output; +struct OutputDefaultTypeInternal; +extern OutputDefaultTypeInternal _Output_default_instance_; +} // namespace test +} // namespace azure +} // namespace com +PROTOBUF_NAMESPACE_OPEN +template <> +::com::azure::test::Input* Arena::CreateMaybeMessage<::com::azure::test::Input>(Arena*); +template <> +::com::azure::test::Output* Arena::CreateMaybeMessage<::com::azure::test::Output>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + +namespace com { +namespace azure { +namespace test { + +// =================================================================== + + +// ------------------------------------------------------------------- + +class Input final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.test.Input) */ { + public: + inline Input() : Input(nullptr) {} + ~Input() override; + explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Input(const Input& from); + Input(Input&& from) noexcept + : Input() { + *this = ::std::move(from); + } + + inline Input& operator=(const Input& from) { + CopyFrom(from); + return *this; + } + inline Input& operator=(Input&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Input& default_instance() { + return *internal_default_instance(); + } + static inline const Input* internal_default_instance() { + return reinterpret_cast( + &_Input_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Input& a, Input& b) { + a.Swap(&b); + } + inline void Swap(Input* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Input* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Input& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Input& from) { + Input::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Input* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "com.azure.test.Input"; + } + protected: + explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + }; + // repeated string testInputField = 1; + int testinputfield_size() const; + private: + int _internal_testinputfield_size() const; + + public: + void clear_testinputfield() ; + const std::string& testinputfield(int index) const; + std::string* mutable_testinputfield(int index); + void set_testinputfield(int index, const std::string& value); + void set_testinputfield(int index, std::string&& value); + void set_testinputfield(int index, const char* value); + void set_testinputfield(int index, absl::string_view value); + void set_testinputfield(int index, const char* value, ::size_t size); + std::string* add_testinputfield(); + void add_testinputfield(const std::string& value); + void add_testinputfield(std::string&& value); + void add_testinputfield(const char* value); + void add_testinputfield(absl::string_view value); + void add_testinputfield(const char* value, ::size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& testinputfield() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_testinputfield(); + private: + const std::string& _internal_testinputfield(int index) const; + std::string* _internal_add_testinputfield(); + public: + // @@protoc_insertion_point(class_scope:com.azure.test.Input) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField testinputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_com_2fazure_2ftest_2eproto; +};// ------------------------------------------------------------------- + +class Output final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.test.Output) */ { + public: + inline Output() : Output(nullptr) {} + ~Output() override; + explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Output(const Output& from); + Output(Output&& from) noexcept + : Output() { + *this = ::std::move(from); + } + + inline Output& operator=(const Output& from) { + CopyFrom(from); + return *this; + } + inline Output& operator=(Output&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Output& default_instance() { + return *internal_default_instance(); + } + static inline const Output* internal_default_instance() { + return reinterpret_cast( + &_Output_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(Output& a, Output& b) { + a.Swap(&b); + } + inline void Swap(Output* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Output* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Output& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Output& from) { + Output::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Output* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "com.azure.test.Output"; + } + protected: + explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestOutputFieldFieldNumber = 1, + kSecondFieldFieldNumber = 2, + }; + // repeated int32 testOutputField = 1; + int testoutputfield_size() const; + private: + int _internal_testoutputfield_size() const; + + public: + void clear_testoutputfield() ; + ::int32_t testoutputfield(int index) const; + void set_testoutputfield(int index, ::int32_t value); + void add_testoutputfield(::int32_t value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>& testoutputfield() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>* mutable_testoutputfield(); + + private: + ::int32_t _internal_testoutputfield(int index) const; + void _internal_add_testoutputfield(::int32_t value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>& _internal_testoutputfield() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>* _internal_mutable_testoutputfield(); + + public: + // string secondField = 2; + void clear_secondfield() ; + const std::string& secondfield() const; + template + void set_secondfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_secondfield(); + PROTOBUF_NODISCARD std::string* release_secondfield(); + void set_allocated_secondfield(std::string* secondfield); + private: + const std::string& _internal_secondfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); + std::string* _internal_mutable_secondfield(); + public: + // @@protoc_insertion_point(class_scope:com.azure.test.Output) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t> testoutputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _testoutputfield_cached_byte_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_com_2fazure_2ftest_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// Input + +// repeated string testInputField = 1; +inline int Input::_internal_testinputfield_size() const { + return _impl_.testinputfield_.size(); +} +inline int Input::testinputfield_size() const { + return _internal_testinputfield_size(); +} +inline void Input::clear_testinputfield() { + _impl_.testinputfield_.Clear(); +} +inline std::string* Input::add_testinputfield() { + std::string* _s = _internal_add_testinputfield(); + // @@protoc_insertion_point(field_add_mutable:com.azure.test.Input.testInputField) + return _s; +} +inline const std::string& Input::_internal_testinputfield(int index) const { + return _impl_.testinputfield_.Get(index); +} +inline const std::string& Input::testinputfield(int index) const { + // @@protoc_insertion_point(field_get:com.azure.test.Input.testInputField) + return _internal_testinputfield(index); +} +inline std::string* Input::mutable_testinputfield(int index) { + // @@protoc_insertion_point(field_mutable:com.azure.test.Input.testInputField) + return _impl_.testinputfield_.Mutable(index); +} +inline void Input::set_testinputfield(int index, const std::string& value) { + _impl_.testinputfield_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set:com.azure.test.Input.testInputField) +} +inline void Input::set_testinputfield(int index, std::string&& value) { + _impl_.testinputfield_.Mutable(index)->assign(std::move(value)); + // @@protoc_insertion_point(field_set:com.azure.test.Input.testInputField) +} +inline void Input::set_testinputfield(int index, const char* value) { + ABSL_DCHECK(value != nullptr); _impl_.testinputfield_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:com.azure.test.Input.testInputField) +} +inline void Input::set_testinputfield(int index, absl::string_view value) { + _impl_.testinputfield_.Mutable(index)->assign(value.data(), value.size()); + // @@protoc_insertion_point(field_set_string_piece:com.azure.test.Input.testInputField) +} +inline void Input::set_testinputfield(int index, const char* value, ::size_t size) { + _impl_.testinputfield_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:com.azure.test.Input.testInputField) +} +inline std::string* Input::_internal_add_testinputfield() { + return _impl_.testinputfield_.Add(); +} +inline void Input::add_testinputfield(const std::string& value) { + _impl_.testinputfield_.Add()->assign(value); + // @@protoc_insertion_point(field_add:com.azure.test.Input.testInputField) +} +inline void Input::add_testinputfield(std::string&& value) { + _impl_.testinputfield_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:com.azure.test.Input.testInputField) +} +inline void Input::add_testinputfield(const char* value) { + ABSL_DCHECK(value != nullptr); _impl_.testinputfield_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:com.azure.test.Input.testInputField) +} +inline void Input::add_testinputfield(absl::string_view value) { + _impl_.testinputfield_.Add()->assign(value.data(), value.size()); + // @@protoc_insertion_point(field_add_string_piece:com.azure.test.Input.testInputField) +} +inline void Input::add_testinputfield(const char* value, ::size_t size) { + _impl_.testinputfield_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:com.azure.test.Input.testInputField) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +Input::testinputfield() const { + // @@protoc_insertion_point(field_list:com.azure.test.Input.testInputField) + return _impl_.testinputfield_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +Input::mutable_testinputfield() { + // @@protoc_insertion_point(field_mutable_list:com.azure.test.Input.testInputField) + return &_impl_.testinputfield_; +} + +// ------------------------------------------------------------------- + +// Output + +// repeated int32 testOutputField = 1; +inline int Output::_internal_testoutputfield_size() const { + return _impl_.testoutputfield_.size(); +} +inline int Output::testoutputfield_size() const { + return _internal_testoutputfield_size(); +} +inline void Output::clear_testoutputfield() { + _impl_.testoutputfield_.Clear(); +} +inline ::int32_t Output::testoutputfield(int index) const { + // @@protoc_insertion_point(field_get:com.azure.test.Output.testOutputField) + return _internal_testoutputfield(index); +} +inline void Output::set_testoutputfield(int index, ::int32_t value) { + _impl_.testoutputfield_.Set(index, value); + // @@protoc_insertion_point(field_set:com.azure.test.Output.testOutputField) +} +inline void Output::add_testoutputfield(::int32_t value) { + _internal_add_testoutputfield(value); + // @@protoc_insertion_point(field_add:com.azure.test.Output.testOutputField) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>& Output::testoutputfield() const { + // @@protoc_insertion_point(field_list:com.azure.test.Output.testOutputField) + return _internal_testoutputfield(); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>* Output::mutable_testoutputfield() { + // @@protoc_insertion_point(field_mutable_list:com.azure.test.Output.testOutputField) + return _internal_mutable_testoutputfield(); +} + +inline ::int32_t Output::_internal_testoutputfield(int index) const { + return _impl_.testoutputfield_.Get(index); +} +inline void Output::_internal_add_testoutputfield(::int32_t value) { _impl_.testoutputfield_.Add(value); } +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>& Output::_internal_testoutputfield() const { + return _impl_.testoutputfield_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>* Output::_internal_mutable_testoutputfield() { + return &_impl_.testoutputfield_; +} + +// string secondField = 2; +inline void Output::clear_secondfield() { + _impl_.secondfield_.ClearToEmpty(); +} +inline const std::string& Output::secondfield() const { + // @@protoc_insertion_point(field_get:com.azure.test.Output.secondField) + return _internal_secondfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { + + _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:com.azure.test.Output.secondField) +} +inline std::string* Output::mutable_secondfield() { + std::string* _s = _internal_mutable_secondfield(); + // @@protoc_insertion_point(field_mutable:com.azure.test.Output.secondField) + return _s; +} +inline const std::string& Output::_internal_secondfield() const { + return _impl_.secondfield_.Get(); +} +inline void Output::_internal_set_secondfield(const std::string& value) { + + _impl_.secondfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Output::_internal_mutable_secondfield() { + + return _impl_.secondfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Output::release_secondfield() { + // @@protoc_insertion_point(field_release:com.azure.test.Output.secondField) + return _impl_.secondfield_.Release(); +} +inline void Output::set_allocated_secondfield(std::string* secondfield) { + _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.secondfield_.IsDefault()) { + _impl_.secondfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:com.azure.test.Output.secondField) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) +} // namespace test +} // namespace azure +} // namespace com + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/array/output/csharp/Test.cs b/packages/protobuf/test/protoc-out/array/output/csharp/Test.cs new file mode 100644 index 00000000000..313e70a1ee5 --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/csharp/Test.cs @@ -0,0 +1,442 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: com/azure/test.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Com.Azure.Test { + + /// Holder for reflection information generated from com/azure/test.proto + public static partial class TestReflection { + + #region Descriptor + /// File descriptor for com/azure/test.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static TestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChRjb20vYXp1cmUvdGVzdC5wcm90bxIOY29tLmF6dXJlLnRlc3QiHwoFSW5w", + "dXQSFgoOdGVzdElucHV0RmllbGQYASADKAkiNgoGT3V0cHV0EhcKD3Rlc3RP", + "dXRwdXRGaWVsZBgBIAMoBRITCgtzZWNvbmRGaWVsZBgCIAEoCTI/CgdTZXJ2", + "aWNlEjQKA0ZvbxIVLmNvbS5henVyZS50ZXN0LklucHV0GhYuY29tLmF6dXJl", + "LnRlc3QuT3V0cHV0YgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.Input), global::Com.Azure.Test.Input.Parser, new[]{ "TestInputField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.Output), global::Com.Azure.Test.Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class Input : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input(Input other) : this() { + testInputField_ = other.testInputField_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input Clone() { + return new Input(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_testInputField_codec + = pb::FieldCodec.ForString(10); + private readonly pbc::RepeatedField testInputField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public pbc::RepeatedField TestInputField { + get { return testInputField_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Input); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Input other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!testInputField_.Equals(other.testInputField_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + hash ^= testInputField_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + testInputField_.WriteTo(output, _repeated_testInputField_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + testInputField_.WriteTo(ref output, _repeated_testInputField_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + size += testInputField_.CalculateSize(_repeated_testInputField_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Input other) { + if (other == null) { + return; + } + testInputField_.Add(other.testInputField_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + testInputField_.AddEntriesFrom(input, _repeated_testInputField_codec); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + testInputField_.AddEntriesFrom(ref input, _repeated_testInputField_codec); + break; + } + } + } + } + #endif + + } + + public sealed partial class Output : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output(Output other) : this() { + testOutputField_ = other.testOutputField_.Clone(); + secondField_ = other.secondField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output Clone() { + return new Output(this); + } + + /// Field number for the "testOutputField" field. + public const int TestOutputFieldFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_testOutputField_codec + = pb::FieldCodec.ForInt32(10); + private readonly pbc::RepeatedField testOutputField_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public pbc::RepeatedField TestOutputField { + get { return testOutputField_; } + } + + /// Field number for the "secondField" field. + public const int SecondFieldFieldNumber = 2; + private string secondField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string SecondField { + get { return secondField_; } + set { + secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Output); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Output other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!testOutputField_.Equals(other.testOutputField_)) return false; + if (SecondField != other.SecondField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + hash ^= testOutputField_.GetHashCode(); + if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + testOutputField_.WriteTo(output, _repeated_testOutputField_codec); + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + testOutputField_.WriteTo(ref output, _repeated_testOutputField_codec); + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + size += testOutputField_.CalculateSize(_repeated_testOutputField_codec); + if (SecondField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Output other) { + if (other == null) { + return; + } + testOutputField_.Add(other.testOutputField_); + if (other.SecondField.Length != 0) { + SecondField = other.SecondField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: + case 8: { + testOutputField_.AddEntriesFrom(input, _repeated_testOutputField_codec); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: + case 8: { + testOutputField_.AddEntriesFrom(ref input, _repeated_testOutputField_codec); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + } + #endif + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.h b/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.h new file mode 100644 index 00000000000..fabc5d7f1d5 --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.h @@ -0,0 +1,87 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: com/azure/test.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - TestRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface TestRoot : GPBRootObject +@end + +#pragma mark - Input + +typedef GPB_ENUM(Input_FieldNumber) { + Input_FieldNumber_TestInputFieldArray = 1, +}; + +GPB_FINAL @interface Input : GPBMessage + +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *testInputFieldArray; +/** The number of items in @c testInputFieldArray without causing the container to be created. */ +@property(nonatomic, readonly) NSUInteger testInputFieldArray_Count; + +@end + +#pragma mark - Output + +typedef GPB_ENUM(Output_FieldNumber) { + Output_FieldNumber_TestOutputFieldArray = 1, + Output_FieldNumber_SecondField = 2, +}; + +GPB_FINAL @interface Output : GPBMessage + +@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *testOutputFieldArray; +/** The number of items in @c testOutputFieldArray without causing the container to be created. */ +@property(nonatomic, readonly) NSUInteger testOutputFieldArray_Count; + +@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.m b/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.m new file mode 100644 index 00000000000..16186aa9cd6 --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.m @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: com/azure/test.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "com/azure/Test.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - TestRoot + +@implementation TestRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - TestRoot_FileDescriptor + +static GPBFileDescriptor *TestRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"com.azure.test" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Input + +@implementation Input + +@dynamic testInputFieldArray, testInputFieldArray_Count; + +typedef struct Input__storage_ { + uint32_t _has_storage_[1]; + NSMutableArray *testInputFieldArray; +} Input__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputFieldArray", + .dataTypeSpecific.clazz = Nil, + .number = Input_FieldNumber_TestInputFieldArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(Input__storage_, testInputFieldArray), + .flags = (GPBFieldFlags)(GPBFieldRepeated | GPBFieldTextFormatNameCustom), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Input class] + file:TestRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Input__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\000testInputField\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - Output + +@implementation Output + +@dynamic testOutputFieldArray, testOutputFieldArray_Count; +@dynamic secondField; + +typedef struct Output__storage_ { + uint32_t _has_storage_[1]; + GPBInt32Array *testOutputFieldArray; + NSString *secondField; +} Output__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testOutputFieldArray", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_TestOutputFieldArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(Output__storage_, testOutputFieldArray), + .flags = (GPBFieldFlags)(GPBFieldRepeated | GPBFieldPacked | GPBFieldTextFormatNameCustom), + .dataType = GPBDataTypeInt32, + }, + { + .name = "secondField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_SecondField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Output__storage_, secondField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Output class] + file:TestRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Output__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\002\001\000testOutputField\000\002\013\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Input.php b/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Input.php new file mode 100644 index 00000000000..b86156b36cc --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Input.php @@ -0,0 +1,58 @@ +com.azure.test.Input + */ +class Input extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated string testInputField = 1; + */ + private $testInputField; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $testInputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Com\Azure\Test::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field repeated string testInputField = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field repeated string testInputField = 1; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setTestInputField($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->testInputField = $arr; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Output.php b/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Output.php new file mode 100644 index 00000000000..63ae45939b8 --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Output.php @@ -0,0 +1,85 @@ +com.azure.test.Output + */ +class Output extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated int32 testOutputField = 1; + */ + private $testOutputField; + /** + * Generated from protobuf field string secondField = 2; + */ + protected $secondField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $testOutputField + * @type string $secondField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Com\Azure\Test::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field repeated int32 testOutputField = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getTestOutputField() + { + return $this->testOutputField; + } + + /** + * Generated from protobuf field repeated int32 testOutputField = 1; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setTestOutputField($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->testOutputField = $arr; + + return $this; + } + + /** + * Generated from protobuf field string secondField = 2; + * @return string + */ + public function getSecondField() + { + return $this->secondField; + } + + /** + * Generated from protobuf field string secondField = 2; + * @param string $var + * @return $this + */ + public function setSecondField($var) + { + GPBUtil::checkString($var, True); + $this->secondField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/array/output/php/GPBMetadata/Com/Azure/Test.php b/packages/protobuf/test/protoc-out/array/output/php/GPBMetadata/Com/Azure/Test.php new file mode 100644 index 00000000000..6648a81797e --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/php/GPBMetadata/Com/Azure/Test.php @@ -0,0 +1,33 @@ +internalAddGeneratedFile( + ' +� +com/azure/test.protocom.azure.test" +Input +testInputField ( "6 +Output +testOutputField ( + secondField ( 2? +Service4 +Foo.com.azure.test.Input.com.azure.test.Outputbproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/packages/protobuf/test/protoc-out/array/output/pyi/com/azure/test_pb2.pyi b/packages/protobuf/test/protoc-out/array/output/pyi/com/azure/test_pb2.pyi new file mode 100644 index 00000000000..bc1d3882971 --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/pyi/com/azure/test_pb2.pyi @@ -0,0 +1,20 @@ +from google.protobuf.internal import containers as _containers +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Iterable as _Iterable, Optional as _Optional + +DESCRIPTOR: _descriptor.FileDescriptor + +class Input(_message.Message): + __slots__ = ["testInputField"] + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testInputField: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, testInputField: _Optional[_Iterable[str]] = ...) -> None: ... + +class Output(_message.Message): + __slots__ = ["testOutputField", "secondField"] + TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] + SECONDFIELD_FIELD_NUMBER: _ClassVar[int] + testOutputField: _containers.RepeatedScalarFieldContainer[int] + secondField: str + def __init__(self, testOutputField: _Optional[_Iterable[int]] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/array/output/python/com/azure/test_pb2.py b/packages/protobuf/test/protoc-out/array/output/python/com/azure/test_pb2.py new file mode 100644 index 00000000000..4cc52faa7f1 --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/python/com/azure/test_pb2.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: com/azure/test.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x63om/azure/test.proto\x12\x0e\x63om.azure.test\"\x1f\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x03(\t\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x03(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t2?\n\x07Service\x12\x34\n\x03\x46oo\x12\x15.com.azure.test.Input\x1a\x16.com.azure.test.Outputb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'com.azure.test_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_INPUT']._serialized_start=40 + _globals['_INPUT']._serialized_end=71 + _globals['_OUTPUT']._serialized_start=73 + _globals['_OUTPUT']._serialized_end=127 + _globals['_SERVICE']._serialized_start=129 + _globals['_SERVICE']._serialized_end=192 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/array/output/ruby/com/azure/test_pb.rb b/packages/protobuf/test/protoc-out/array/output/ruby/com/azure/test_pb.rb new file mode 100644 index 00000000000..555e0977bd6 --- /dev/null +++ b/packages/protobuf/test/protoc-out/array/output/ruby/com/azure/test_pb.rb @@ -0,0 +1,25 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: com/azure/test.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("com/azure/test.proto", :syntax => :proto3) do + add_message "com.azure.test.Input" do + repeated :testInputField, :string, 1 + end + add_message "com.azure.test.Output" do + repeated :testOutputField, :int32, 1 + optional :secondField, :string, 2 + end + end +end + +module Com + module Azure + module Test + Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.test.Input").msgclass + Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.test.Output").msgclass + end + end +end diff --git a/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.cc b/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.cc new file mode 100644 index 00000000000..390ed4a88bd --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.cc @@ -0,0 +1,349 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: A.proto + +#include "A.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +namespace A { +PROTOBUF_CONSTEXPR Output::Output( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /* ._impl_.testoutputfield_ = */ 0 + + , /*decltype(_impl_._cached_size_)*/{}} {} +struct OutputDefaultTypeInternal { + PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~OutputDefaultTypeInternal() {} + union { + Output _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; +} // namespace A +static ::_pb::Metadata file_level_metadata_A_2eproto[1]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_A_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_A_2eproto = nullptr; +const ::uint32_t TableStruct_A_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::A::Output, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::A::Output, _impl_.testoutputfield_), + PROTOBUF_FIELD_OFFSET(::A::Output, _impl_.secondfield_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::A::Output)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::A::_Output_default_instance_._instance, +}; +const char descriptor_table_protodef_A_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\007A.proto\022\001A\"6\n\006Output\022\027\n\017testOutputFiel" + "d\030\001 \001(\005\022\023\n\013secondField\030\002 \001(\tb\006proto3" +}; +static ::absl::once_flag descriptor_table_A_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_A_2eproto = { + false, + false, + 76, + descriptor_table_protodef_A_2eproto, + "A.proto", + &descriptor_table_A_2eproto_once, + nullptr, + 0, + 1, + schemas, + file_default_instances, + TableStruct_A_2eproto::offsets, + file_level_metadata_A_2eproto, + file_level_enum_descriptors_A_2eproto, + file_level_service_descriptors_A_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_A_2eproto_getter() { + return &descriptor_table_A_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_A_2eproto(&descriptor_table_A_2eproto); +namespace A { +// =================================================================== + +class Output::_Internal { + public: +}; + +Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:A.Output) +} +Output::Output(const Output& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Output* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) {} + + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_secondfield().empty()) { + _this->_impl_.secondfield_.Set(from._internal_secondfield(), + _this->GetArenaForAllocation()); + } + _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; + // @@protoc_insertion_point(copy_constructor:A.Output) +} + +inline void Output::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) { 0 } + + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Output::~Output() { + // @@protoc_insertion_point(destructor:A.Output) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Output::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.secondfield_.Destroy(); +} + +void Output::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Output::Clear() { +// @@protoc_insertion_point(message_clear_start:A.Output) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.secondfield_.ClearToEmpty(); + _impl_.testoutputfield_ = 0; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // int32 testOutputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { + _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + // string secondField = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { + auto str = _internal_mutable_secondfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "A.Output.secondField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Output::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:A.Output) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray( + 1, this->_internal_testoutputfield(), target); + } + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "A.Output.secondField"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_secondfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:A.Output) + return target; +} + +::size_t Output::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:A.Output) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_secondfield()); + } + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( + this->_internal_testoutputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Output::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } + + +void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:A.Output) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_secondfield().empty()) { + _this->_internal_set_secondfield(from._internal_secondfield()); + } + if (from._internal_testoutputfield() != 0) { + _this->_internal_set_testoutputfield(from._internal_testoutputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Output::CopyFrom(const Output& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:A.Output) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Output::IsInitialized() const { + return true; +} + +void Output::InternalSwap(Output* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.secondfield_, lhs_arena, + &other->_impl_.secondfield_, rhs_arena + ); + + swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_A_2eproto_getter, &descriptor_table_A_2eproto_once, + file_level_metadata_A_2eproto[0]); +} +// @@protoc_insertion_point(namespace_scope) +} // namespace A +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::A::Output* +Arena::CreateMaybeMessage< ::A::Output >(Arena* arena) { + return Arena::CreateMessageInternal< ::A::Output >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.h b/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.h new file mode 100644 index 00000000000..eaa516d72a2 --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.h @@ -0,0 +1,326 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: A.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_A_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_A_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_A_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_A_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_A_2eproto; +namespace A { +class Output; +struct OutputDefaultTypeInternal; +extern OutputDefaultTypeInternal _Output_default_instance_; +} // namespace A +PROTOBUF_NAMESPACE_OPEN +template <> +::A::Output* Arena::CreateMaybeMessage<::A::Output>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + +namespace A { + +// =================================================================== + + +// ------------------------------------------------------------------- + +class Output final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:A.Output) */ { + public: + inline Output() : Output(nullptr) {} + ~Output() override; + explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Output(const Output& from); + Output(Output&& from) noexcept + : Output() { + *this = ::std::move(from); + } + + inline Output& operator=(const Output& from) { + CopyFrom(from); + return *this; + } + inline Output& operator=(Output&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Output& default_instance() { + return *internal_default_instance(); + } + static inline const Output* internal_default_instance() { + return reinterpret_cast( + &_Output_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Output& a, Output& b) { + a.Swap(&b); + } + inline void Swap(Output* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Output* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Output& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Output& from) { + Output::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Output* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "A.Output"; + } + protected: + explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kSecondFieldFieldNumber = 2, + kTestOutputFieldFieldNumber = 1, + }; + // string secondField = 2; + void clear_secondfield() ; + const std::string& secondfield() const; + template + void set_secondfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_secondfield(); + PROTOBUF_NODISCARD std::string* release_secondfield(); + void set_allocated_secondfield(std::string* secondfield); + private: + const std::string& _internal_secondfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); + std::string* _internal_mutable_secondfield(); + public: + // int32 testOutputField = 1; + void clear_testoutputfield() ; + ::int32_t testoutputfield() const; + void set_testoutputfield(::int32_t value); + + private: + ::int32_t _internal_testoutputfield() const; + void _internal_set_testoutputfield(::int32_t value); + + public: + // @@protoc_insertion_point(class_scope:A.Output) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; + ::int32_t testoutputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_A_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// Output + +// int32 testOutputField = 1; +inline void Output::clear_testoutputfield() { + _impl_.testoutputfield_ = 0; +} +inline ::int32_t Output::testoutputfield() const { + // @@protoc_insertion_point(field_get:A.Output.testOutputField) + return _internal_testoutputfield(); +} +inline void Output::set_testoutputfield(::int32_t value) { + ; + _internal_set_testoutputfield(value); + // @@protoc_insertion_point(field_set:A.Output.testOutputField) +} +inline ::int32_t Output::_internal_testoutputfield() const { + return _impl_.testoutputfield_; +} +inline void Output::_internal_set_testoutputfield(::int32_t value) { + ; + _impl_.testoutputfield_ = value; +} + +// string secondField = 2; +inline void Output::clear_secondfield() { + _impl_.secondfield_.ClearToEmpty(); +} +inline const std::string& Output::secondfield() const { + // @@protoc_insertion_point(field_get:A.Output.secondField) + return _internal_secondfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { + + _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:A.Output.secondField) +} +inline std::string* Output::mutable_secondfield() { + std::string* _s = _internal_mutable_secondfield(); + // @@protoc_insertion_point(field_mutable:A.Output.secondField) + return _s; +} +inline const std::string& Output::_internal_secondfield() const { + return _impl_.secondfield_.Get(); +} +inline void Output::_internal_set_secondfield(const std::string& value) { + + _impl_.secondfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Output::_internal_mutable_secondfield() { + + return _impl_.secondfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Output::release_secondfield() { + // @@protoc_insertion_point(field_release:A.Output.secondField) + return _impl_.secondfield_.Release(); +} +inline void Output::set_allocated_secondfield(std::string* secondfield) { + _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.secondfield_.IsDefault()) { + _impl_.secondfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:A.Output.secondField) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) +} // namespace A + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_A_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.cc b/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.cc new file mode 100644 index 00000000000..9c9b1d3bb04 --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.cc @@ -0,0 +1,318 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: B.proto + +#include "B.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +namespace B { +PROTOBUF_CONSTEXPR Input::Input( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct InputDefaultTypeInternal { + PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputDefaultTypeInternal() {} + union { + Input _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; +} // namespace B +static ::_pb::Metadata file_level_metadata_B_2eproto[1]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_B_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_B_2eproto = nullptr; +const ::uint32_t TableStruct_B_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::B::Input, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::B::Input, _impl_.testinputfield_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::B::Input)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::B::_Input_default_instance_._instance, +}; +const char descriptor_table_protodef_B_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\007B.proto\022\001B\032\007A.proto\"\037\n\005Input\022\026\n\016testIn" + "putField\030\001 \001(\t2%\n\007Service\022\032\n\003Foo\022\010.B.Inp" + "ut\032\t.A.Outputb\006proto3" +}; +static const ::_pbi::DescriptorTable* const descriptor_table_B_2eproto_deps[1] = + { + &::descriptor_table_A_2eproto, +}; +static ::absl::once_flag descriptor_table_B_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_B_2eproto = { + false, + false, + 101, + descriptor_table_protodef_B_2eproto, + "B.proto", + &descriptor_table_B_2eproto_once, + descriptor_table_B_2eproto_deps, + 1, + 1, + schemas, + file_default_instances, + TableStruct_B_2eproto::offsets, + file_level_metadata_B_2eproto, + file_level_enum_descriptors_B_2eproto, + file_level_service_descriptors_B_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_B_2eproto_getter() { + return &descriptor_table_B_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_B_2eproto(&descriptor_table_B_2eproto); +namespace B { +// =================================================================== + +class Input::_Internal { + public: +}; + +Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:B.Input) +} +Input::Input(const Input& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Input* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_testinputfield().empty()) { + _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:B.Input) +} + +inline void Input::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Input::~Input() { + // @@protoc_insertion_point(destructor:B.Input) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Input::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testinputfield_.Destroy(); +} + +void Input::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Input::Clear() { +// @@protoc_insertion_point(message_clear_start:B.Input) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_.ClearToEmpty(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // string testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + auto str = _internal_mutable_testinputfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "B.Input.testInputField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Input::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:B.Input) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "B.Input.testInputField"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_testinputfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:B.Input) + return target; +} + +::size_t Input::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:B.Input) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_testinputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Input::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } + + +void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:B.Input) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_testinputfield().empty()) { + _this->_internal_set_testinputfield(from._internal_testinputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Input::CopyFrom(const Input& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:B.Input) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Input::IsInitialized() const { + return true; +} + +void Input::InternalSwap(Input* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.testinputfield_, lhs_arena, + &other->_impl_.testinputfield_, rhs_arena + ); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_B_2eproto_getter, &descriptor_table_B_2eproto_once, + file_level_metadata_B_2eproto[0]); +} +// @@protoc_insertion_point(namespace_scope) +} // namespace B +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::B::Input* +Arena::CreateMaybeMessage< ::B::Input >(Arena* arena) { + return Arena::CreateMessageInternal< ::B::Input >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.h b/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.h new file mode 100644 index 00000000000..b5949ea593e --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.h @@ -0,0 +1,294 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: B.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_B_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_B_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +#include "A.pb.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_B_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_B_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_B_2eproto; +namespace B { +class Input; +struct InputDefaultTypeInternal; +extern InputDefaultTypeInternal _Input_default_instance_; +} // namespace B +PROTOBUF_NAMESPACE_OPEN +template <> +::B::Input* Arena::CreateMaybeMessage<::B::Input>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + +namespace B { + +// =================================================================== + + +// ------------------------------------------------------------------- + +class Input final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:B.Input) */ { + public: + inline Input() : Input(nullptr) {} + ~Input() override; + explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Input(const Input& from); + Input(Input&& from) noexcept + : Input() { + *this = ::std::move(from); + } + + inline Input& operator=(const Input& from) { + CopyFrom(from); + return *this; + } + inline Input& operator=(Input&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Input& default_instance() { + return *internal_default_instance(); + } + static inline const Input* internal_default_instance() { + return reinterpret_cast( + &_Input_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Input& a, Input& b) { + a.Swap(&b); + } + inline void Swap(Input* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Input* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Input& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Input& from) { + Input::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Input* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "B.Input"; + } + protected: + explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + }; + // string testInputField = 1; + void clear_testinputfield() ; + const std::string& testinputfield() const; + template + void set_testinputfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_testinputfield(); + PROTOBUF_NODISCARD std::string* release_testinputfield(); + void set_allocated_testinputfield(std::string* testinputfield); + private: + const std::string& _internal_testinputfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); + std::string* _internal_mutable_testinputfield(); + public: + // @@protoc_insertion_point(class_scope:B.Input) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_B_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// Input + +// string testInputField = 1; +inline void Input::clear_testinputfield() { + _impl_.testinputfield_.ClearToEmpty(); +} +inline const std::string& Input::testinputfield() const { + // @@protoc_insertion_point(field_get:B.Input.testInputField) + return _internal_testinputfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { + + _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:B.Input.testInputField) +} +inline std::string* Input::mutable_testinputfield() { + std::string* _s = _internal_mutable_testinputfield(); + // @@protoc_insertion_point(field_mutable:B.Input.testInputField) + return _s; +} +inline const std::string& Input::_internal_testinputfield() const { + return _impl_.testinputfield_.Get(); +} +inline void Input::_internal_set_testinputfield(const std::string& value) { + + _impl_.testinputfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Input::_internal_mutable_testinputfield() { + + return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Input::release_testinputfield() { + // @@protoc_insertion_point(field_release:B.Input.testInputField) + return _impl_.testinputfield_.Release(); +} +inline void Input::set_allocated_testinputfield(std::string* testinputfield) { + _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.testinputfield_.IsDefault()) { + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:B.Input.testInputField) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) +} // namespace B + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_B_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/cross package references/output/csharp/A.cs b/packages/protobuf/test/protoc-out/cross package references/output/csharp/A.cs new file mode 100644 index 00000000000..2abe1daf18f --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/csharp/A.cs @@ -0,0 +1,269 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: A.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace A { + + /// Holder for reflection information generated from A.proto + public static partial class AReflection { + + #region Descriptor + /// File descriptor for A.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static AReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgdBLnByb3RvEgFBIjYKBk91dHB1dBIXCg90ZXN0T3V0cHV0RmllbGQYASAB", + "KAUSEwoLc2Vjb25kRmllbGQYAiABKAliBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::A.Output), global::A.Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class Output : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::A.AReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output(Output other) : this() { + testOutputField_ = other.testOutputField_; + secondField_ = other.secondField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output Clone() { + return new Output(this); + } + + /// Field number for the "testOutputField" field. + public const int TestOutputFieldFieldNumber = 1; + private int testOutputField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int TestOutputField { + get { return testOutputField_; } + set { + testOutputField_ = value; + } + } + + /// Field number for the "secondField" field. + public const int SecondFieldFieldNumber = 2; + private string secondField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string SecondField { + get { return secondField_; } + set { + secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Output); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Output other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestOutputField != other.TestOutputField) return false; + if (SecondField != other.SecondField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); + if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestOutputField != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); + } + if (SecondField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Output other) { + if (other == null) { + return; + } + if (other.TestOutputField != 0) { + TestOutputField = other.TestOutputField; + } + if (other.SecondField.Length != 0) { + SecondField = other.SecondField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + } + #endif + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/cross package references/output/csharp/B.cs b/packages/protobuf/test/protoc-out/cross package references/output/csharp/B.cs new file mode 100644 index 00000000000..864f299ff6e --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/csharp/B.cs @@ -0,0 +1,233 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: B.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace B { + + /// Holder for reflection information generated from B.proto + public static partial class BReflection { + + #region Descriptor + /// File descriptor for B.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static BReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgdCLnByb3RvEgFCGgdBLnByb3RvIh8KBUlucHV0EhYKDnRlc3RJbnB1dEZp", + "ZWxkGAEgASgJMiUKB1NlcnZpY2USGgoDRm9vEgguQi5JbnB1dBoJLkEuT3V0", + "cHV0YgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::A.AReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::B.Input), global::B.Input.Parser, new[]{ "TestInputField" }, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class Input : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::B.BReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input(Input other) : this() { + testInputField_ = other.testInputField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input Clone() { + return new Input(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private string testInputField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string TestInputField { + get { return testInputField_; } + set { + testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Input); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Input other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestInputField != other.TestInputField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestInputField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Input other) { + if (other == null) { + return; + } + if (other.TestInputField.Length != 0) { + TestInputField = other.TestInputField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + } + #endif + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.h b/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.h new file mode 100644 index 00000000000..6c9727d056a --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.h @@ -0,0 +1,71 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: A.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - ARoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface ARoot : GPBRootObject +@end + +#pragma mark - Output + +typedef GPB_ENUM(Output_FieldNumber) { + Output_FieldNumber_TestOutputField = 1, + Output_FieldNumber_SecondField = 2, +}; + +GPB_FINAL @interface Output : GPBMessage + +@property(nonatomic, readwrite) int32_t testOutputField; + +@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.m b/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.m new file mode 100644 index 00000000000..46d1e3070b7 --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.m @@ -0,0 +1,111 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: A.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "A.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - ARoot + +@implementation ARoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - ARoot_FileDescriptor + +static GPBFileDescriptor *ARoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"A" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Output + +@implementation Output + +@dynamic testOutputField; +@dynamic secondField; + +typedef struct Output__storage_ { + uint32_t _has_storage_[1]; + int32_t testOutputField; + NSString *secondField; +} Output__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testOutputField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_TestOutputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Output__storage_, testOutputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeInt32, + }, + { + .name = "secondField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_SecondField, + .hasIndex = 1, + .offset = (uint32_t)offsetof(Output__storage_, secondField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Output class] + file:ARoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Output__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\002\001\017\000\002\013\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.h b/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.h new file mode 100644 index 00000000000..9de696ef00b --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.h @@ -0,0 +1,68 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: B.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - BRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface BRoot : GPBRootObject +@end + +#pragma mark - Input + +typedef GPB_ENUM(Input_FieldNumber) { + Input_FieldNumber_TestInputField = 1, +}; + +GPB_FINAL @interface Input : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.m b/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.m new file mode 100644 index 00000000000..6f9995a7220 --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.m @@ -0,0 +1,101 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: B.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "B.pbobjc.h" +#import "A.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - BRoot + +@implementation BRoot + +// No extensions in the file and none of the imports (direct or indirect) +// defined extensions, so no need to generate +extensionRegistry. + +@end + +#pragma mark - BRoot_FileDescriptor + +static GPBFileDescriptor *BRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"B" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Input + +@implementation Input + +@dynamic testInputField; + +typedef struct Input__storage_ { + uint32_t _has_storage_[1]; + NSString *testInputField; +} Input__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputField", + .dataTypeSpecific.clazz = Nil, + .number = Input_FieldNumber_TestInputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Input__storage_, testInputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Input class] + file:BRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Input__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\016\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/cross package references/output/php/A/Output.php b/packages/protobuf/test/protoc-out/cross package references/output/php/A/Output.php new file mode 100644 index 00000000000..8060a81c47e --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/php/A/Output.php @@ -0,0 +1,85 @@ +A.Output + */ +class Output extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field int32 testOutputField = 1; + */ + protected $testOutputField = 0; + /** + * Generated from protobuf field string secondField = 2; + */ + protected $secondField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $testOutputField + * @type string $secondField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\A::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @return int + */ + public function getTestOutputField() + { + return $this->testOutputField; + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @param int $var + * @return $this + */ + public function setTestOutputField($var) + { + GPBUtil::checkInt32($var); + $this->testOutputField = $var; + + return $this; + } + + /** + * Generated from protobuf field string secondField = 2; + * @return string + */ + public function getSecondField() + { + return $this->secondField; + } + + /** + * Generated from protobuf field string secondField = 2; + * @param string $var + * @return $this + */ + public function setSecondField($var) + { + GPBUtil::checkString($var, True); + $this->secondField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/cross package references/output/php/B/Input.php b/packages/protobuf/test/protoc-out/cross package references/output/php/B/Input.php new file mode 100644 index 00000000000..7bfe09ef131 --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/php/B/Input.php @@ -0,0 +1,58 @@ +B.Input + */ +class Input extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string testInputField = 1; + */ + protected $testInputField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $testInputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\B::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string testInputField = 1; + * @return string + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field string testInputField = 1; + * @param string $var + * @return $this + */ + public function setTestInputField($var) + { + GPBUtil::checkString($var, True); + $this->testInputField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/A.php b/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/A.php new file mode 100644 index 00000000000..19a2fdef0c9 --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/A.php @@ -0,0 +1,29 @@ +internalAddGeneratedFile( + ' +L +A.protoA"6 +Output +testOutputField ( + secondField ( bproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/B.php b/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/B.php new file mode 100644 index 00000000000..c9a623c5577 --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/B.php @@ -0,0 +1,31 @@ +internalAddGeneratedFile( + ' +\\ +B.protoB" +Input +testInputField ( 2% +Service +Foo.B.Input .A.Outputbproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/packages/protobuf/test/protoc-out/cross package references/output/pyi/A_pb2.pyi b/packages/protobuf/test/protoc-out/cross package references/output/pyi/A_pb2.pyi new file mode 100644 index 00000000000..be7a595f3b3 --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/pyi/A_pb2.pyi @@ -0,0 +1,13 @@ +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Optional as _Optional + +DESCRIPTOR: _descriptor.FileDescriptor + +class Output(_message.Message): + __slots__ = ["testOutputField", "secondField"] + TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] + SECONDFIELD_FIELD_NUMBER: _ClassVar[int] + testOutputField: int + secondField: str + def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/cross package references/output/pyi/B_pb2.pyi b/packages/protobuf/test/protoc-out/cross package references/output/pyi/B_pb2.pyi new file mode 100644 index 00000000000..e3f282609e3 --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/pyi/B_pb2.pyi @@ -0,0 +1,12 @@ +import A_pb2 as _A_pb2 +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Optional as _Optional + +DESCRIPTOR: _descriptor.FileDescriptor + +class Input(_message.Message): + __slots__ = ["testInputField"] + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testInputField: str + def __init__(self, testInputField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/cross package references/output/python/A_pb2.py b/packages/protobuf/test/protoc-out/cross package references/output/python/A_pb2.py new file mode 100644 index 00000000000..cc819278baf --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/python/A_pb2.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: A.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x07\x41.proto\x12\x01\x41\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\tb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'A_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_OUTPUT']._serialized_start=14 + _globals['_OUTPUT']._serialized_end=68 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/cross package references/output/python/B_pb2.py b/packages/protobuf/test/protoc-out/cross package references/output/python/B_pb2.py new file mode 100644 index 00000000000..bdb5689127f --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/python/B_pb2.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: B.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +import A_pb2 as A__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x07\x42.proto\x12\x01\x42\x1a\x07\x41.proto\"\x1f\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\t2%\n\x07Service\x12\x1a\n\x03\x46oo\x12\x08.B.Input\x1a\t.A.Outputb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'B_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_INPUT']._serialized_start=23 + _globals['_INPUT']._serialized_end=54 + _globals['_SERVICE']._serialized_start=56 + _globals['_SERVICE']._serialized_end=93 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/cross package references/output/ruby/A_pb.rb b/packages/protobuf/test/protoc-out/cross package references/output/ruby/A_pb.rb new file mode 100644 index 00000000000..9843fe0d386 --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/ruby/A_pb.rb @@ -0,0 +1,17 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: A.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("A.proto", :syntax => :proto3) do + add_message "A.Output" do + optional :testOutputField, :int32, 1 + optional :secondField, :string, 2 + end + end +end + +module A + Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("A.Output").msgclass +end diff --git a/packages/protobuf/test/protoc-out/cross package references/output/ruby/B_pb.rb b/packages/protobuf/test/protoc-out/cross package references/output/ruby/B_pb.rb new file mode 100644 index 00000000000..17a5ebff7de --- /dev/null +++ b/packages/protobuf/test/protoc-out/cross package references/output/ruby/B_pb.rb @@ -0,0 +1,18 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: B.proto + +require 'google/protobuf' + +require 'A_pb' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("B.proto", :syntax => :proto3) do + add_message "B.Input" do + optional :testInputField, :string, 1 + end + end +end + +module B + Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("B.Input").msgclass +end diff --git a/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.cc new file mode 100644 index 00000000000..7d5861a58ab --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.cc @@ -0,0 +1,677 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#include "main.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +PROTOBUF_CONSTEXPR Input::Input( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.type_)*/0 + , /*decltype(_impl_.aliased_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} +struct InputDefaultTypeInternal { + PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputDefaultTypeInternal() {} + union { + Input _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; +PROTOBUF_CONSTEXPR Output::Output( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /* ._impl_.testoutputfield_ = */ 0 + + , /*decltype(_impl_._cached_size_)*/{}} {} +struct OutputDefaultTypeInternal { + PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~OutputDefaultTypeInternal() {} + union { + Output _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; +static ::_pb::Metadata file_level_metadata_main_2eproto[2]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_main_2eproto[2]; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_main_2eproto = nullptr; +const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::Input, _impl_.testinputfield_), + PROTOBUF_FIELD_OFFSET(::Input, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::Input, _impl_.aliased_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::Output, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::Output, _impl_.testoutputfield_), + PROTOBUF_FIELD_OFFSET(::Output, _impl_.secondfield_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::Input)}, + { 11, -1, -1, sizeof(::Output)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_Input_default_instance_._instance, + &::_Output_default_instance_._instance, +}; +const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\nmain.proto\"_\n\005Input\022\026\n\016testInputField\030" + "\001 \001(\t\022\030\n\004type\030\002 \001(\0162\n.InputType\022$\n\007alias" + "ed\030\003 \001(\0162\023.InputTypeWithAlias\"6\n\006Output\022" + "\027\n\017testOutputField\030\001 \001(\005\022\023\n\013secondField\030" + "\002 \001(\t*\035\n\tInputType\022\007\n\003FOO\020\000\022\007\n\003BAR\020\001*3\n\022" + "InputTypeWithAlias\022\007\n\003BAZ\020\000\022\007\n\003QUX\020\001\022\007\n\003" + "FUZ\020\001\032\002\020\0012!\n\007Service\022\026\n\003Foo\022\006.Input\032\007.Ou" + "tputb\006proto3" +}; +static ::absl::once_flag descriptor_table_main_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { + false, + false, + 292, + descriptor_table_protodef_main_2eproto, + "main.proto", + &descriptor_table_main_2eproto_once, + nullptr, + 0, + 2, + schemas, + file_default_instances, + TableStruct_main_2eproto::offsets, + file_level_metadata_main_2eproto, + file_level_enum_descriptors_main_2eproto, + file_level_service_descriptors_main_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { + return &descriptor_table_main_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* InputType_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_main_2eproto); + return file_level_enum_descriptors_main_2eproto[0]; +} +bool InputType_IsValid(int value) { + switch (value) { + case 0: + case 1: + return true; + default: + return false; + } +} +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* InputTypeWithAlias_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_main_2eproto); + return file_level_enum_descriptors_main_2eproto[1]; +} +bool InputTypeWithAlias_IsValid(int value) { + switch (value) { + case 0: + case 1: + return true; + default: + return false; + } +} +// =================================================================== + +class Input::_Internal { + public: +}; + +Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:Input) +} +Input::Input(const Input& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Input* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , decltype(_impl_.type_){} + , decltype(_impl_.aliased_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_testinputfield().empty()) { + _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), + _this->GetArenaForAllocation()); + } + ::memcpy(&_impl_.type_, &from._impl_.type_, + static_cast<::size_t>(reinterpret_cast(&_impl_.aliased_) - + reinterpret_cast(&_impl_.type_)) + sizeof(_impl_.aliased_)); + // @@protoc_insertion_point(copy_constructor:Input) +} + +inline void Input::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , decltype(_impl_.type_){0} + , decltype(_impl_.aliased_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Input::~Input() { + // @@protoc_insertion_point(destructor:Input) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Input::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testinputfield_.Destroy(); +} + +void Input::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Input::Clear() { +// @@protoc_insertion_point(message_clear_start:Input) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_.ClearToEmpty(); + ::memset(&_impl_.type_, 0, static_cast<::size_t>( + reinterpret_cast(&_impl_.aliased_) - + reinterpret_cast(&_impl_.type_)) + sizeof(_impl_.aliased_)); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // string testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + auto str = _internal_mutable_testinputfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "Input.testInputField")); + } else { + goto handle_unusual; + } + continue; + // .InputType type = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) { + ::uint32_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + _internal_set_type(static_cast<::InputType>(val)); + } else { + goto handle_unusual; + } + continue; + // .InputTypeWithAlias aliased = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) { + ::uint32_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + _internal_set_aliased(static_cast<::InputTypeWithAlias>(val)); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Input::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:Input) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "Input.testInputField"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_testinputfield(), target); + } + + // .InputType type = 2; + if (this->_internal_type() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 2, this->_internal_type(), target); + } + + // .InputTypeWithAlias aliased = 3; + if (this->_internal_aliased() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 3, this->_internal_aliased(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:Input) + return target; +} + +::size_t Input::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:Input) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_testinputfield()); + } + + // .InputType type = 2; + if (this->_internal_type() != 0) { + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); + } + + // .InputTypeWithAlias aliased = 3; + if (this->_internal_aliased() != 0) { + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_aliased()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Input::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } + + +void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:Input) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_testinputfield().empty()) { + _this->_internal_set_testinputfield(from._internal_testinputfield()); + } + if (from._internal_type() != 0) { + _this->_internal_set_type(from._internal_type()); + } + if (from._internal_aliased() != 0) { + _this->_internal_set_aliased(from._internal_aliased()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Input::CopyFrom(const Input& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:Input) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Input::IsInitialized() const { + return true; +} + +void Input::InternalSwap(Input* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.testinputfield_, lhs_arena, + &other->_impl_.testinputfield_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Input, _impl_.aliased_) + + sizeof(Input::_impl_.aliased_) + - PROTOBUF_FIELD_OFFSET(Input, _impl_.type_)>( + reinterpret_cast(&_impl_.type_), + reinterpret_cast(&other->_impl_.type_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[0]); +} +// =================================================================== + +class Output::_Internal { + public: +}; + +Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:Output) +} +Output::Output(const Output& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Output* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) {} + + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_secondfield().empty()) { + _this->_impl_.secondfield_.Set(from._internal_secondfield(), + _this->GetArenaForAllocation()); + } + _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; + // @@protoc_insertion_point(copy_constructor:Output) +} + +inline void Output::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) { 0 } + + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Output::~Output() { + // @@protoc_insertion_point(destructor:Output) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Output::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.secondfield_.Destroy(); +} + +void Output::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Output::Clear() { +// @@protoc_insertion_point(message_clear_start:Output) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.secondfield_.ClearToEmpty(); + _impl_.testoutputfield_ = 0; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // int32 testOutputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { + _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + // string secondField = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { + auto str = _internal_mutable_secondfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "Output.secondField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Output::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:Output) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray( + 1, this->_internal_testoutputfield(), target); + } + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "Output.secondField"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_secondfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:Output) + return target; +} + +::size_t Output::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:Output) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_secondfield()); + } + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( + this->_internal_testoutputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Output::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } + + +void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:Output) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_secondfield().empty()) { + _this->_internal_set_secondfield(from._internal_secondfield()); + } + if (from._internal_testoutputfield() != 0) { + _this->_internal_set_testoutputfield(from._internal_testoutputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Output::CopyFrom(const Output& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:Output) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Output::IsInitialized() const { + return true; +} + +void Output::InternalSwap(Output* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.secondfield_, lhs_arena, + &other->_impl_.secondfield_, rhs_arena + ); + + swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::Input* +Arena::CreateMaybeMessage< ::Input >(Arena* arena) { + return Arena::CreateMessageInternal< ::Input >(arena); +} +template<> PROTOBUF_NOINLINE ::Output* +Arena::CreateMaybeMessage< ::Output >(Arena* arena) { + return Arena::CreateMessageInternal< ::Output >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.h new file mode 100644 index 00000000000..17ff50254fa --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.h @@ -0,0 +1,669 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/generated_enum_reflection.h" +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_main_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_main_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_main_2eproto; +class Input; +struct InputDefaultTypeInternal; +extern InputDefaultTypeInternal _Input_default_instance_; +class Output; +struct OutputDefaultTypeInternal; +extern OutputDefaultTypeInternal _Output_default_instance_; +PROTOBUF_NAMESPACE_OPEN +template <> +::Input* Arena::CreateMaybeMessage<::Input>(Arena*); +template <> +::Output* Arena::CreateMaybeMessage<::Output>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + +enum InputType : int { + FOO = 0, + BAR = 1, + InputType_INT_MIN_SENTINEL_DO_NOT_USE_ = + std::numeric_limits<::int32_t>::min(), + InputType_INT_MAX_SENTINEL_DO_NOT_USE_ = + std::numeric_limits<::int32_t>::max(), +}; + +bool InputType_IsValid(int value); +constexpr InputType InputType_MIN = static_cast(0); +constexpr InputType InputType_MAX = static_cast(1); +constexpr int InputType_ARRAYSIZE = 1 + 1; +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* +InputType_descriptor(); +template +const std::string& InputType_Name(T value) { + static_assert(std::is_same::value || + std::is_integral::value, + "Incorrect type passed to InputType_Name()."); + return InputType_Name(static_cast(value)); +} +template <> +inline const std::string& InputType_Name(InputType value) { + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum( + static_cast(value)); +} +inline bool InputType_Parse(absl::string_view name, InputType* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + InputType_descriptor(), name, value); +} +enum InputTypeWithAlias : int { + BAZ = 0, + QUX = 1, + FUZ = 1, + InputTypeWithAlias_INT_MIN_SENTINEL_DO_NOT_USE_ = + std::numeric_limits<::int32_t>::min(), + InputTypeWithAlias_INT_MAX_SENTINEL_DO_NOT_USE_ = + std::numeric_limits<::int32_t>::max(), +}; + +bool InputTypeWithAlias_IsValid(int value); +constexpr InputTypeWithAlias InputTypeWithAlias_MIN = static_cast(0); +constexpr InputTypeWithAlias InputTypeWithAlias_MAX = static_cast(1); +constexpr int InputTypeWithAlias_ARRAYSIZE = 1 + 1; +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* +InputTypeWithAlias_descriptor(); +template +const std::string& InputTypeWithAlias_Name(T value) { + static_assert(std::is_same::value || + std::is_integral::value, + "Incorrect type passed to InputTypeWithAlias_Name()."); + return InputTypeWithAlias_Name(static_cast(value)); +} +template <> +inline const std::string& InputTypeWithAlias_Name(InputTypeWithAlias value) { + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum( + static_cast(value)); +} +inline bool InputTypeWithAlias_Parse(absl::string_view name, InputTypeWithAlias* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + InputTypeWithAlias_descriptor(), name, value); +} + +// =================================================================== + + +// ------------------------------------------------------------------- + +class Input final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { + public: + inline Input() : Input(nullptr) {} + ~Input() override; + explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Input(const Input& from); + Input(Input&& from) noexcept + : Input() { + *this = ::std::move(from); + } + + inline Input& operator=(const Input& from) { + CopyFrom(from); + return *this; + } + inline Input& operator=(Input&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Input& default_instance() { + return *internal_default_instance(); + } + static inline const Input* internal_default_instance() { + return reinterpret_cast( + &_Input_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Input& a, Input& b) { + a.Swap(&b); + } + inline void Swap(Input* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Input* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Input& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Input& from) { + Input::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Input* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "Input"; + } + protected: + explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + kTypeFieldNumber = 2, + kAliasedFieldNumber = 3, + }; + // string testInputField = 1; + void clear_testinputfield() ; + const std::string& testinputfield() const; + template + void set_testinputfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_testinputfield(); + PROTOBUF_NODISCARD std::string* release_testinputfield(); + void set_allocated_testinputfield(std::string* testinputfield); + private: + const std::string& _internal_testinputfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); + std::string* _internal_mutable_testinputfield(); + public: + // .InputType type = 2; + void clear_type() ; + ::InputType type() const; + void set_type(::InputType value); + private: + ::InputType _internal_type() const; + void _internal_set_type(::InputType value); + public: + // .InputTypeWithAlias aliased = 3; + void clear_aliased() ; + ::InputTypeWithAlias aliased() const; + void set_aliased(::InputTypeWithAlias value); + private: + ::InputTypeWithAlias _internal_aliased() const; + void _internal_set_aliased(::InputTypeWithAlias value); + public: + // @@protoc_insertion_point(class_scope:Input) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; + int type_; + int aliased_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +};// ------------------------------------------------------------------- + +class Output final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Output) */ { + public: + inline Output() : Output(nullptr) {} + ~Output() override; + explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Output(const Output& from); + Output(Output&& from) noexcept + : Output() { + *this = ::std::move(from); + } + + inline Output& operator=(const Output& from) { + CopyFrom(from); + return *this; + } + inline Output& operator=(Output&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Output& default_instance() { + return *internal_default_instance(); + } + static inline const Output* internal_default_instance() { + return reinterpret_cast( + &_Output_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(Output& a, Output& b) { + a.Swap(&b); + } + inline void Swap(Output* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Output* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Output& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Output& from) { + Output::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Output* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "Output"; + } + protected: + explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kSecondFieldFieldNumber = 2, + kTestOutputFieldFieldNumber = 1, + }; + // string secondField = 2; + void clear_secondfield() ; + const std::string& secondfield() const; + template + void set_secondfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_secondfield(); + PROTOBUF_NODISCARD std::string* release_secondfield(); + void set_allocated_secondfield(std::string* secondfield); + private: + const std::string& _internal_secondfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); + std::string* _internal_mutable_secondfield(); + public: + // int32 testOutputField = 1; + void clear_testoutputfield() ; + ::int32_t testoutputfield() const; + void set_testoutputfield(::int32_t value); + + private: + ::int32_t _internal_testoutputfield() const; + void _internal_set_testoutputfield(::int32_t value); + + public: + // @@protoc_insertion_point(class_scope:Output) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; + ::int32_t testoutputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// Input + +// string testInputField = 1; +inline void Input::clear_testinputfield() { + _impl_.testinputfield_.ClearToEmpty(); +} +inline const std::string& Input::testinputfield() const { + // @@protoc_insertion_point(field_get:Input.testInputField) + return _internal_testinputfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { + + _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:Input.testInputField) +} +inline std::string* Input::mutable_testinputfield() { + std::string* _s = _internal_mutable_testinputfield(); + // @@protoc_insertion_point(field_mutable:Input.testInputField) + return _s; +} +inline const std::string& Input::_internal_testinputfield() const { + return _impl_.testinputfield_.Get(); +} +inline void Input::_internal_set_testinputfield(const std::string& value) { + + _impl_.testinputfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Input::_internal_mutable_testinputfield() { + + return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Input::release_testinputfield() { + // @@protoc_insertion_point(field_release:Input.testInputField) + return _impl_.testinputfield_.Release(); +} +inline void Input::set_allocated_testinputfield(std::string* testinputfield) { + _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.testinputfield_.IsDefault()) { + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:Input.testInputField) +} + +// .InputType type = 2; +inline void Input::clear_type() { + _impl_.type_ = 0; +} +inline ::InputType Input::_internal_type() const { + return static_cast< ::InputType >(_impl_.type_); +} +inline ::InputType Input::type() const { + // @@protoc_insertion_point(field_get:Input.type) + return _internal_type(); +} +inline void Input::_internal_set_type(::InputType value) { + + _impl_.type_ = value; +} +inline void Input::set_type(::InputType value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:Input.type) +} + +// .InputTypeWithAlias aliased = 3; +inline void Input::clear_aliased() { + _impl_.aliased_ = 0; +} +inline ::InputTypeWithAlias Input::_internal_aliased() const { + return static_cast< ::InputTypeWithAlias >(_impl_.aliased_); +} +inline ::InputTypeWithAlias Input::aliased() const { + // @@protoc_insertion_point(field_get:Input.aliased) + return _internal_aliased(); +} +inline void Input::_internal_set_aliased(::InputTypeWithAlias value) { + + _impl_.aliased_ = value; +} +inline void Input::set_aliased(::InputTypeWithAlias value) { + _internal_set_aliased(value); + // @@protoc_insertion_point(field_set:Input.aliased) +} + +// ------------------------------------------------------------------- + +// Output + +// int32 testOutputField = 1; +inline void Output::clear_testoutputfield() { + _impl_.testoutputfield_ = 0; +} +inline ::int32_t Output::testoutputfield() const { + // @@protoc_insertion_point(field_get:Output.testOutputField) + return _internal_testoutputfield(); +} +inline void Output::set_testoutputfield(::int32_t value) { + ; + _internal_set_testoutputfield(value); + // @@protoc_insertion_point(field_set:Output.testOutputField) +} +inline ::int32_t Output::_internal_testoutputfield() const { + return _impl_.testoutputfield_; +} +inline void Output::_internal_set_testoutputfield(::int32_t value) { + ; + _impl_.testoutputfield_ = value; +} + +// string secondField = 2; +inline void Output::clear_secondfield() { + _impl_.secondfield_.ClearToEmpty(); +} +inline const std::string& Output::secondfield() const { + // @@protoc_insertion_point(field_get:Output.secondField) + return _internal_secondfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { + + _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:Output.secondField) +} +inline std::string* Output::mutable_secondfield() { + std::string* _s = _internal_mutable_secondfield(); + // @@protoc_insertion_point(field_mutable:Output.secondField) + return _s; +} +inline const std::string& Output::_internal_secondfield() const { + return _impl_.secondfield_.Get(); +} +inline void Output::_internal_set_secondfield(const std::string& value) { + + _impl_.secondfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Output::_internal_mutable_secondfield() { + + return _impl_.secondfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Output::release_secondfield() { + // @@protoc_insertion_point(field_release:Output.secondField) + return _impl_.secondfield_.Release(); +} +inline void Output::set_allocated_secondfield(std::string* secondfield) { + _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.secondfield_.IsDefault()) { + _impl_.secondfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:Output.secondField) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +PROTOBUF_NAMESPACE_OPEN + +template <> +struct is_proto_enum<::InputType> : std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor<::InputType>() { + return ::InputType_descriptor(); +} +template <> +struct is_proto_enum<::InputTypeWithAlias> : std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor<::InputTypeWithAlias>() { + return ::InputTypeWithAlias_descriptor(); +} + +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/enum/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/enum/output/csharp/Main.cs new file mode 100644 index 00000000000..3504810d371 --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/csharp/Main.cs @@ -0,0 +1,549 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +/// Holder for reflection information generated from main.proto +public static partial class MainReflection { + + #region Descriptor + /// File descriptor for main.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MainReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgptYWluLnByb3RvIl8KBUlucHV0EhYKDnRlc3RJbnB1dEZpZWxkGAEgASgJ", + "EhgKBHR5cGUYAiABKA4yCi5JbnB1dFR5cGUSJAoHYWxpYXNlZBgDIAEoDjIT", + "LklucHV0VHlwZVdpdGhBbGlhcyI2CgZPdXRwdXQSFwoPdGVzdE91dHB1dEZp", + "ZWxkGAEgASgFEhMKC3NlY29uZEZpZWxkGAIgASgJKh0KCUlucHV0VHlwZRIH", + "CgNGT08QABIHCgNCQVIQASozChJJbnB1dFR5cGVXaXRoQWxpYXMSBwoDQkFa", + "EAASBwoDUVVYEAESBwoDRlVaEAEaAhABMiEKB1NlcnZpY2USFgoDRm9vEgYu", + "SW5wdXQaBy5PdXRwdXRiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::InputType), typeof(global::InputTypeWithAlias), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "TestInputField", "Type", "Aliased" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Output), global::Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) + })); + } + #endregion + +} +#region Enums +public enum InputType { + [pbr::OriginalName("FOO")] Foo = 0, + [pbr::OriginalName("BAR")] Bar = 1, +} + +public enum InputTypeWithAlias { + [pbr::OriginalName("BAZ")] Baz = 0, + [pbr::OriginalName("QUX")] Qux = 1, + [pbr::OriginalName("FUZ", PreferredAlias = false)] Fuz = 1, +} + +#endregion + +#region Messages +public sealed partial class Input : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input(Input other) : this() { + testInputField_ = other.testInputField_; + type_ = other.type_; + aliased_ = other.aliased_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input Clone() { + return new Input(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private string testInputField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string TestInputField { + get { return testInputField_; } + set { + testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "type" field. + public const int TypeFieldNumber = 2; + private global::InputType type_ = global::InputType.Foo; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::InputType Type { + get { return type_; } + set { + type_ = value; + } + } + + /// Field number for the "aliased" field. + public const int AliasedFieldNumber = 3; + private global::InputTypeWithAlias aliased_ = global::InputTypeWithAlias.Baz; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::InputTypeWithAlias Aliased { + get { return aliased_; } + set { + aliased_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Input); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Input other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestInputField != other.TestInputField) return false; + if (Type != other.Type) return false; + if (Aliased != other.Aliased) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); + if (Type != global::InputType.Foo) hash ^= Type.GetHashCode(); + if (Aliased != global::InputTypeWithAlias.Baz) hash ^= Aliased.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (Type != global::InputType.Foo) { + output.WriteRawTag(16); + output.WriteEnum((int) Type); + } + if (Aliased != global::InputTypeWithAlias.Baz) { + output.WriteRawTag(24); + output.WriteEnum((int) Aliased); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (Type != global::InputType.Foo) { + output.WriteRawTag(16); + output.WriteEnum((int) Type); + } + if (Aliased != global::InputTypeWithAlias.Baz) { + output.WriteRawTag(24); + output.WriteEnum((int) Aliased); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestInputField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); + } + if (Type != global::InputType.Foo) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); + } + if (Aliased != global::InputTypeWithAlias.Baz) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Aliased); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Input other) { + if (other == null) { + return; + } + if (other.TestInputField.Length != 0) { + TestInputField = other.TestInputField; + } + if (other.Type != global::InputType.Foo) { + Type = other.Type; + } + if (other.Aliased != global::InputTypeWithAlias.Baz) { + Aliased = other.Aliased; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + case 16: { + Type = (global::InputType) input.ReadEnum(); + break; + } + case 24: { + Aliased = (global::InputTypeWithAlias) input.ReadEnum(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + case 16: { + Type = (global::InputType) input.ReadEnum(); + break; + } + case 24: { + Aliased = (global::InputTypeWithAlias) input.ReadEnum(); + break; + } + } + } + } + #endif + +} + +public sealed partial class Output : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output(Output other) : this() { + testOutputField_ = other.testOutputField_; + secondField_ = other.secondField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output Clone() { + return new Output(this); + } + + /// Field number for the "testOutputField" field. + public const int TestOutputFieldFieldNumber = 1; + private int testOutputField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int TestOutputField { + get { return testOutputField_; } + set { + testOutputField_ = value; + } + } + + /// Field number for the "secondField" field. + public const int SecondFieldFieldNumber = 2; + private string secondField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string SecondField { + get { return secondField_; } + set { + secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Output); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Output other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestOutputField != other.TestOutputField) return false; + if (SecondField != other.SecondField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); + if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestOutputField != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); + } + if (SecondField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Output other) { + if (other == null) { + return; + } + if (other.TestOutputField != 0) { + TestOutputField = other.TestOutputField; + } + if (other.SecondField.Length != 0) { + SecondField = other.SecondField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + } + #endif + +} + +#endregion + + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.h new file mode 100644 index 00000000000..dda29dfd430 --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.h @@ -0,0 +1,156 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - Enum InputType + +typedef GPB_ENUM(InputType) { + /** + * Value used if any message's field encounters a value that is not defined + * by this enum. The message will also have C functions to get/set the rawValue + * of the field. + **/ + InputType_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, + InputType_Foo = 0, + InputType_Bar = 1, +}; + +GPBEnumDescriptor *InputType_EnumDescriptor(void); + +/** + * Checks to see if the given value is defined by the enum or was not known at + * the time this source was generated. + **/ +BOOL InputType_IsValidValue(int32_t value); + +#pragma mark - Enum InputTypeWithAlias + +typedef GPB_ENUM(InputTypeWithAlias) { + /** + * Value used if any message's field encounters a value that is not defined + * by this enum. The message will also have C functions to get/set the rawValue + * of the field. + **/ + InputTypeWithAlias_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, + InputTypeWithAlias_Baz = 0, + InputTypeWithAlias_Qux = 1, + InputTypeWithAlias_Fuz = 1, +}; + +GPBEnumDescriptor *InputTypeWithAlias_EnumDescriptor(void); + +/** + * Checks to see if the given value is defined by the enum or was not known at + * the time this source was generated. + **/ +BOOL InputTypeWithAlias_IsValidValue(int32_t value); + +#pragma mark - MainRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface MainRoot : GPBRootObject +@end + +#pragma mark - Input + +typedef GPB_ENUM(Input_FieldNumber) { + Input_FieldNumber_TestInputField = 1, + Input_FieldNumber_Type = 2, + Input_FieldNumber_Aliased = 3, +}; + +GPB_FINAL @interface Input : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; + +@property(nonatomic, readwrite) InputType type; + +@property(nonatomic, readwrite) InputTypeWithAlias aliased; + +@end + +/** + * Fetches the raw value of a @c Input's @c type property, even + * if the value was not defined by the enum at the time the code was generated. + **/ +int32_t Input_Type_RawValue(Input *message); +/** + * Sets the raw value of an @c Input's @c type property, allowing + * it to be set to a value that was not defined by the enum at the time the code + * was generated. + **/ +void SetInput_Type_RawValue(Input *message, int32_t value); + +/** + * Fetches the raw value of a @c Input's @c aliased property, even + * if the value was not defined by the enum at the time the code was generated. + **/ +int32_t Input_Aliased_RawValue(Input *message); +/** + * Sets the raw value of an @c Input's @c aliased property, allowing + * it to be set to a value that was not defined by the enum at the time the code + * was generated. + **/ +void SetInput_Aliased_RawValue(Input *message, int32_t value); + +#pragma mark - Output + +typedef GPB_ENUM(Output_FieldNumber) { + Output_FieldNumber_TestOutputField = 1, + Output_FieldNumber_SecondField = 2, +}; + +GPB_FINAL @interface Output : GPBMessage + +@property(nonatomic, readwrite) int32_t testOutputField; + +@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.m new file mode 100644 index 00000000000..dd8d3d75e2d --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.m @@ -0,0 +1,281 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import + +#import "Main.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - MainRoot + +@implementation MainRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - MainRoot_FileDescriptor + +static GPBFileDescriptor *MainRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Enum InputType + +GPBEnumDescriptor *InputType_EnumDescriptor(void) { + static _Atomic(GPBEnumDescriptor*) descriptor = nil; + if (!descriptor) { + static const char *valueNames = + "Foo\000Bar\000"; + static const int32_t values[] = { + InputType_Foo, + InputType_Bar, + }; + GPBEnumDescriptor *worker = + [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(InputType) + valueNames:valueNames + values:values + count:(uint32_t)(sizeof(values) / sizeof(int32_t)) + enumVerifier:InputType_IsValidValue + flags:GPBEnumDescriptorInitializationFlag_None]; + GPBEnumDescriptor *expected = nil; + if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) { + [worker release]; + } + } + return descriptor; +} + +BOOL InputType_IsValidValue(int32_t value__) { + switch (value__) { + case InputType_Foo: + case InputType_Bar: + return YES; + default: + return NO; + } +} + +#pragma mark - Enum InputTypeWithAlias + +GPBEnumDescriptor *InputTypeWithAlias_EnumDescriptor(void) { + static _Atomic(GPBEnumDescriptor*) descriptor = nil; + if (!descriptor) { + static const char *valueNames = + "Baz\000Qux\000Fuz\000"; + static const int32_t values[] = { + InputTypeWithAlias_Baz, + InputTypeWithAlias_Qux, + InputTypeWithAlias_Fuz, + }; + GPBEnumDescriptor *worker = + [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(InputTypeWithAlias) + valueNames:valueNames + values:values + count:(uint32_t)(sizeof(values) / sizeof(int32_t)) + enumVerifier:InputTypeWithAlias_IsValidValue + flags:GPBEnumDescriptorInitializationFlag_None]; + GPBEnumDescriptor *expected = nil; + if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) { + [worker release]; + } + } + return descriptor; +} + +BOOL InputTypeWithAlias_IsValidValue(int32_t value__) { + switch (value__) { + case InputTypeWithAlias_Baz: + case InputTypeWithAlias_Qux: + return YES; + default: + return NO; + } +} + +#pragma mark - Input + +@implementation Input + +@dynamic testInputField; +@dynamic type; +@dynamic aliased; + +typedef struct Input__storage_ { + uint32_t _has_storage_[1]; + InputType type; + InputTypeWithAlias aliased; + NSString *testInputField; +} Input__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputField", + .dataTypeSpecific.clazz = Nil, + .number = Input_FieldNumber_TestInputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Input__storage_, testInputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + { + .name = "type", + .dataTypeSpecific.enumDescFunc = InputType_EnumDescriptor, + .number = Input_FieldNumber_Type, + .hasIndex = 1, + .offset = (uint32_t)offsetof(Input__storage_, type), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeEnum, + }, + { + .name = "aliased", + .dataTypeSpecific.enumDescFunc = InputTypeWithAlias_EnumDescriptor, + .number = Input_FieldNumber_Aliased, + .hasIndex = 2, + .offset = (uint32_t)offsetof(Input__storage_, aliased), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeEnum, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Input class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Input__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\016\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +int32_t Input_Type_RawValue(Input *message) { + GPBDescriptor *descriptor = [Input descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:Input_FieldNumber_Type]; + return GPBGetMessageRawEnumField(message, field); +} + +void SetInput_Type_RawValue(Input *message, int32_t value) { + GPBDescriptor *descriptor = [Input descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:Input_FieldNumber_Type]; + GPBSetMessageRawEnumField(message, field, value); +} + +int32_t Input_Aliased_RawValue(Input *message) { + GPBDescriptor *descriptor = [Input descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:Input_FieldNumber_Aliased]; + return GPBGetMessageRawEnumField(message, field); +} + +void SetInput_Aliased_RawValue(Input *message, int32_t value) { + GPBDescriptor *descriptor = [Input descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:Input_FieldNumber_Aliased]; + GPBSetMessageRawEnumField(message, field, value); +} + +#pragma mark - Output + +@implementation Output + +@dynamic testOutputField; +@dynamic secondField; + +typedef struct Output__storage_ { + uint32_t _has_storage_[1]; + int32_t testOutputField; + NSString *secondField; +} Output__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testOutputField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_TestOutputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Output__storage_, testOutputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeInt32, + }, + { + .name = "secondField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_SecondField, + .hasIndex = 1, + .offset = (uint32_t)offsetof(Output__storage_, secondField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Output class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Output__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\002\001\017\000\002\013\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/enum/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/enum/output/php/GPBMetadata/Main.php new file mode 100644 index 0000000000000000000000000000000000000000..9168f56801b8ca34d0a625436c9575f9d5c43e9c GIT binary patch literal 780 zcmZ`%QEL-H5cU$AkP&LQf`)=Ht%0V+=Ai{2Qlq5Aggn%Xnxd3I+3Zc4h0E@-yC+o1 zzww8K}er)nwphu}S(;|E$_PAsugXzcZ#i0q@)89io4 z)MPU)FLK?!z@~iV%1%Fu2OWbrE@?+@z?~B4(~jV81z~)T%gZ_YAr@VCFnw8|rSX%uw8_=E1#f@Q1Lgfe#+Ohgy_b&+r;v zdWOQfcHK5}aJS)sa$Rt&qH5?-sHawfw`KAC*&kS1jYv?*6;C99gVr H0~>&Ued6Gm literal 0 HcmV?d00001 diff --git a/packages/protobuf/test/protoc-out/enum/output/php/Input.php b/packages/protobuf/test/protoc-out/enum/output/php/Input.php new file mode 100644 index 00000000000..3f98ae2843b --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/php/Input.php @@ -0,0 +1,110 @@ +Input + */ +class Input extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string testInputField = 1; + */ + protected $testInputField = ''; + /** + * Generated from protobuf field .InputType type = 2; + */ + protected $type = 0; + /** + * Generated from protobuf field .InputTypeWithAlias aliased = 3; + */ + protected $aliased = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $testInputField + * @type int $type + * @type int $aliased + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string testInputField = 1; + * @return string + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field string testInputField = 1; + * @param string $var + * @return $this + */ + public function setTestInputField($var) + { + GPBUtil::checkString($var, True); + $this->testInputField = $var; + + return $this; + } + + /** + * Generated from protobuf field .InputType type = 2; + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * Generated from protobuf field .InputType type = 2; + * @param int $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \InputType::class); + $this->type = $var; + + return $this; + } + + /** + * Generated from protobuf field .InputTypeWithAlias aliased = 3; + * @return int + */ + public function getAliased() + { + return $this->aliased; + } + + /** + * Generated from protobuf field .InputTypeWithAlias aliased = 3; + * @param int $var + * @return $this + */ + public function setAliased($var) + { + GPBUtil::checkEnum($var, \InputTypeWithAlias::class); + $this->aliased = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/enum/output/php/InputType.php b/packages/protobuf/test/protoc-out/enum/output/php/InputType.php new file mode 100644 index 00000000000..1307c6ca2a7 --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/php/InputType.php @@ -0,0 +1,44 @@ +InputType + */ +class InputType +{ + /** + * Generated from protobuf enum FOO = 0; + */ + const FOO = 0; + /** + * Generated from protobuf enum BAR = 1; + */ + const BAR = 1; + + private static $valueToName = [ + self::FOO => 'FOO', + self::BAR => 'BAR', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/packages/protobuf/test/protoc-out/enum/output/php/InputTypeWithAlias.php b/packages/protobuf/test/protoc-out/enum/output/php/InputTypeWithAlias.php new file mode 100644 index 00000000000..81eebb0f373 --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/php/InputTypeWithAlias.php @@ -0,0 +1,49 @@ +InputTypeWithAlias + */ +class InputTypeWithAlias +{ + /** + * Generated from protobuf enum BAZ = 0; + */ + const BAZ = 0; + /** + * Generated from protobuf enum QUX = 1; + */ + const QUX = 1; + /** + * Generated from protobuf enum FUZ = 1; + */ + const FUZ = 1; + + private static $valueToName = [ + self::BAZ => 'BAZ', + self::QUX => 'QUX', + self::FUZ => 'FUZ', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/packages/protobuf/test/protoc-out/enum/output/php/Output.php b/packages/protobuf/test/protoc-out/enum/output/php/Output.php new file mode 100644 index 00000000000..050aef7e894 --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/php/Output.php @@ -0,0 +1,83 @@ +Output + */ +class Output extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field int32 testOutputField = 1; + */ + protected $testOutputField = 0; + /** + * Generated from protobuf field string secondField = 2; + */ + protected $secondField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $testOutputField + * @type string $secondField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @return int + */ + public function getTestOutputField() + { + return $this->testOutputField; + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @param int $var + * @return $this + */ + public function setTestOutputField($var) + { + GPBUtil::checkInt32($var); + $this->testOutputField = $var; + + return $this; + } + + /** + * Generated from protobuf field string secondField = 2; + * @return string + */ + public function getSecondField() + { + return $this->secondField; + } + + /** + * Generated from protobuf field string secondField = 2; + * @param string $var + * @return $this + */ + public function setSecondField($var) + { + GPBUtil::checkString($var, True); + $this->secondField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/enum/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/enum/output/pyi/main_pb2.pyi new file mode 100644 index 00000000000..8f013736192 --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/pyi/main_pb2.pyi @@ -0,0 +1,40 @@ +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class InputType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = [] + FOO: _ClassVar[InputType] + BAR: _ClassVar[InputType] + +class InputTypeWithAlias(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = [] + BAZ: _ClassVar[InputTypeWithAlias] + QUX: _ClassVar[InputTypeWithAlias] + FUZ: _ClassVar[InputTypeWithAlias] +FOO: InputType +BAR: InputType +BAZ: InputTypeWithAlias +QUX: InputTypeWithAlias +FUZ: InputTypeWithAlias + +class Input(_message.Message): + __slots__ = ["testInputField", "type", "aliased"] + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + TYPE_FIELD_NUMBER: _ClassVar[int] + ALIASED_FIELD_NUMBER: _ClassVar[int] + testInputField: str + type: InputType + aliased: InputTypeWithAlias + def __init__(self, testInputField: _Optional[str] = ..., type: _Optional[_Union[InputType, str]] = ..., aliased: _Optional[_Union[InputTypeWithAlias, str]] = ...) -> None: ... + +class Output(_message.Message): + __slots__ = ["testOutputField", "secondField"] + TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] + SECONDFIELD_FIELD_NUMBER: _ClassVar[int] + testOutputField: int + secondField: str + def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/enum/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/enum/output/python/main_pb2.py new file mode 100644 index 00000000000..b8cfba34fcf --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/python/main_pb2.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\"_\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\x12\x18\n\x04type\x18\x02 \x01(\x0e\x32\n.InputType\x12$\n\x07\x61liased\x18\x03 \x01(\x0e\x32\x13.InputTypeWithAlias\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t*\x1d\n\tInputType\x12\x07\n\x03\x46OO\x10\x00\x12\x07\n\x03\x42\x41R\x10\x01*3\n\x12InputTypeWithAlias\x12\x07\n\x03\x42\x41Z\x10\x00\x12\x07\n\x03QUX\x10\x01\x12\x07\n\x03\x46UZ\x10\x01\x1a\x02\x10\x01\x32!\n\x07Service\x12\x16\n\x03\x46oo\x12\x06.Input\x1a\x07.Outputb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _INPUTTYPEWITHALIAS._options = None + _INPUTTYPEWITHALIAS._serialized_options = b'\020\001' + _globals['_INPUTTYPE']._serialized_start=167 + _globals['_INPUTTYPE']._serialized_end=196 + _globals['_INPUTTYPEWITHALIAS']._serialized_start=198 + _globals['_INPUTTYPEWITHALIAS']._serialized_end=249 + _globals['_INPUT']._serialized_start=14 + _globals['_INPUT']._serialized_end=109 + _globals['_OUTPUT']._serialized_start=111 + _globals['_OUTPUT']._serialized_end=165 + _globals['_SERVICE']._serialized_start=251 + _globals['_SERVICE']._serialized_end=284 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/enum/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/enum/output/ruby/main_pb.rb new file mode 100644 index 00000000000..febb5d0a4f8 --- /dev/null +++ b/packages/protobuf/test/protoc-out/enum/output/ruby/main_pb.rb @@ -0,0 +1,32 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("main.proto", :syntax => :proto3) do + add_message "Input" do + optional :testInputField, :string, 1 + optional :type, :enum, 2, "InputType" + optional :aliased, :enum, 3, "InputTypeWithAlias" + end + add_message "Output" do + optional :testOutputField, :int32, 1 + optional :secondField, :string, 2 + end + add_enum "InputType" do + value :FOO, 0 + value :BAR, 1 + end + add_enum "InputTypeWithAlias" do + value :BAZ, 0 + value :QUX, 1 + value :FUZ, 1 + end + end +end + +Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass +Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Output").msgclass +InputType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("InputType").enummodule +InputTypeWithAlias = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("InputTypeWithAlias").enummodule diff --git a/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.cc new file mode 100644 index 00000000000..fb38ad0b87a --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.cc @@ -0,0 +1,540 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#include "main.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +PROTOBUF_CONSTEXPR BarRequest::BarRequest( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.empty_)*/nullptr + , /*decltype(_impl_._cached_size_)*/{}} {} +struct BarRequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR BarRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~BarRequestDefaultTypeInternal() {} + union { + BarRequest _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BarRequestDefaultTypeInternal _BarRequest_default_instance_; +PROTOBUF_CONSTEXPR BarResponse::BarResponse( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.myextern_)*/nullptr + , /*decltype(_impl_._cached_size_)*/{}} {} +struct BarResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR BarResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~BarResponseDefaultTypeInternal() {} + union { + BarResponse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BarResponseDefaultTypeInternal _BarResponse_default_instance_; +static ::_pb::Metadata file_level_metadata_main_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_main_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_main_2eproto = nullptr; +const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::BarRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::BarRequest, _impl_.empty_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::BarResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::BarResponse, _impl_.myextern_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::BarRequest)}, + { 9, -1, -1, sizeof(::BarResponse)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_BarRequest_default_instance_._instance, + &::_BarResponse_default_instance_._instance, +}; +const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\nmain.proto\032\rfoo/bar.proto\032\033google/prot" + "obuf/empty.proto\"3\n\nBarRequest\022%\n\005empty\030" + "\001 \001(\0132\026.google.protobuf.Empty\")\n\013BarResp" + "onse\022\032\n\010myExtern\030\001 \001(\0132\010.foo.Bar2T\n\007Serv" + "ice\022\'\n\003Foo\022\010.foo.Bar\032\026.google.protobuf.E" + "mpty\022 \n\003Bar\022\013.BarRequest\032\014.BarResponseb\006" + "proto3" +}; +static const ::_pbi::DescriptorTable* const descriptor_table_main_2eproto_deps[2] = + { + &::descriptor_table_foo_2fbar_2eproto, + &::descriptor_table_google_2fprotobuf_2fempty_2eproto, +}; +static ::absl::once_flag descriptor_table_main_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { + false, + false, + 246, + descriptor_table_protodef_main_2eproto, + "main.proto", + &descriptor_table_main_2eproto_once, + descriptor_table_main_2eproto_deps, + 2, + 2, + schemas, + file_default_instances, + TableStruct_main_2eproto::offsets, + file_level_metadata_main_2eproto, + file_level_enum_descriptors_main_2eproto, + file_level_service_descriptors_main_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { + return &descriptor_table_main_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); +// =================================================================== + +class BarRequest::_Internal { + public: + static const ::PROTOBUF_NAMESPACE_ID::Empty& empty(const BarRequest* msg); +}; + +const ::PROTOBUF_NAMESPACE_ID::Empty& +BarRequest::_Internal::empty(const BarRequest* msg) { + return *msg->_impl_.empty_; +} +void BarRequest::clear_empty() { + if (GetArenaForAllocation() == nullptr && _impl_.empty_ != nullptr) { + delete _impl_.empty_; + } + _impl_.empty_ = nullptr; +} +BarRequest::BarRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:BarRequest) +} +BarRequest::BarRequest(const BarRequest& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + BarRequest* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.empty_){nullptr} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_empty()) { + _this->_impl_.empty_ = new ::PROTOBUF_NAMESPACE_ID::Empty(*from._impl_.empty_); + } + // @@protoc_insertion_point(copy_constructor:BarRequest) +} + +inline void BarRequest::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.empty_){nullptr} + , /*decltype(_impl_._cached_size_)*/{} + }; +} + +BarRequest::~BarRequest() { + // @@protoc_insertion_point(destructor:BarRequest) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void BarRequest::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + if (this != internal_default_instance()) delete _impl_.empty_; +} + +void BarRequest::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void BarRequest::Clear() { +// @@protoc_insertion_point(message_clear_start:BarRequest) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (GetArenaForAllocation() == nullptr && _impl_.empty_ != nullptr) { + delete _impl_.empty_; + } + _impl_.empty_ = nullptr; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* BarRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // .google.protobuf.Empty empty = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_empty(), ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* BarRequest::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:BarRequest) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // .google.protobuf.Empty empty = 1; + if (this->_internal_has_empty()) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::empty(this), + _Internal::empty(this).GetCachedSize(), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:BarRequest) + return target; +} + +::size_t BarRequest::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:BarRequest) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // .google.protobuf.Empty empty = 1; + if (this->_internal_has_empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.empty_); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData BarRequest::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + BarRequest::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*BarRequest::GetClassData() const { return &_class_data_; } + + +void BarRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:BarRequest) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_has_empty()) { + _this->_internal_mutable_empty()->::PROTOBUF_NAMESPACE_ID::Empty::MergeFrom( + from._internal_empty()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void BarRequest::CopyFrom(const BarRequest& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:BarRequest) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool BarRequest::IsInitialized() const { + return true; +} + +void BarRequest::InternalSwap(BarRequest* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_.empty_, other->_impl_.empty_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata BarRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[0]); +} +// =================================================================== + +class BarResponse::_Internal { + public: + static const ::foo::Bar& myextern(const BarResponse* msg); +}; + +const ::foo::Bar& +BarResponse::_Internal::myextern(const BarResponse* msg) { + return *msg->_impl_.myextern_; +} +void BarResponse::clear_myextern() { + if (GetArenaForAllocation() == nullptr && _impl_.myextern_ != nullptr) { + delete _impl_.myextern_; + } + _impl_.myextern_ = nullptr; +} +BarResponse::BarResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:BarResponse) +} +BarResponse::BarResponse(const BarResponse& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + BarResponse* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.myextern_){nullptr} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_myextern()) { + _this->_impl_.myextern_ = new ::foo::Bar(*from._impl_.myextern_); + } + // @@protoc_insertion_point(copy_constructor:BarResponse) +} + +inline void BarResponse::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.myextern_){nullptr} + , /*decltype(_impl_._cached_size_)*/{} + }; +} + +BarResponse::~BarResponse() { + // @@protoc_insertion_point(destructor:BarResponse) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void BarResponse::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + if (this != internal_default_instance()) delete _impl_.myextern_; +} + +void BarResponse::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void BarResponse::Clear() { +// @@protoc_insertion_point(message_clear_start:BarResponse) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (GetArenaForAllocation() == nullptr && _impl_.myextern_ != nullptr) { + delete _impl_.myextern_; + } + _impl_.myextern_ = nullptr; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* BarResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // .foo.Bar myExtern = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_myextern(), ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* BarResponse::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:BarResponse) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // .foo.Bar myExtern = 1; + if (this->_internal_has_myextern()) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::myextern(this), + _Internal::myextern(this).GetCachedSize(), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:BarResponse) + return target; +} + +::size_t BarResponse::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:BarResponse) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // .foo.Bar myExtern = 1; + if (this->_internal_has_myextern()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.myextern_); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData BarResponse::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + BarResponse::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*BarResponse::GetClassData() const { return &_class_data_; } + + +void BarResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:BarResponse) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_has_myextern()) { + _this->_internal_mutable_myextern()->::foo::Bar::MergeFrom( + from._internal_myextern()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void BarResponse::CopyFrom(const BarResponse& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:BarResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool BarResponse::IsInitialized() const { + return true; +} + +void BarResponse::InternalSwap(BarResponse* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_.myextern_, other->_impl_.myextern_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata BarResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::BarRequest* +Arena::CreateMaybeMessage< ::BarRequest >(Arena* arena) { + return Arena::CreateMessageInternal< ::BarRequest >(arena); +} +template<> PROTOBUF_NOINLINE ::BarResponse* +Arena::CreateMaybeMessage< ::BarResponse >(Arena* arena) { + return Arena::CreateMessageInternal< ::BarResponse >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.h new file mode 100644 index 00000000000..5d12a96c5dd --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.h @@ -0,0 +1,575 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +#include "foo/bar.pb.h" +#include "google/protobuf/empty.pb.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_main_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_main_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_main_2eproto; +class BarRequest; +struct BarRequestDefaultTypeInternal; +extern BarRequestDefaultTypeInternal _BarRequest_default_instance_; +class BarResponse; +struct BarResponseDefaultTypeInternal; +extern BarResponseDefaultTypeInternal _BarResponse_default_instance_; +PROTOBUF_NAMESPACE_OPEN +template <> +::BarRequest* Arena::CreateMaybeMessage<::BarRequest>(Arena*); +template <> +::BarResponse* Arena::CreateMaybeMessage<::BarResponse>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + + +// =================================================================== + + +// ------------------------------------------------------------------- + +class BarRequest final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:BarRequest) */ { + public: + inline BarRequest() : BarRequest(nullptr) {} + ~BarRequest() override; + explicit PROTOBUF_CONSTEXPR BarRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + BarRequest(const BarRequest& from); + BarRequest(BarRequest&& from) noexcept + : BarRequest() { + *this = ::std::move(from); + } + + inline BarRequest& operator=(const BarRequest& from) { + CopyFrom(from); + return *this; + } + inline BarRequest& operator=(BarRequest&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const BarRequest& default_instance() { + return *internal_default_instance(); + } + static inline const BarRequest* internal_default_instance() { + return reinterpret_cast( + &_BarRequest_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(BarRequest& a, BarRequest& b) { + a.Swap(&b); + } + inline void Swap(BarRequest* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(BarRequest* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + BarRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const BarRequest& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const BarRequest& from) { + BarRequest::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(BarRequest* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "BarRequest"; + } + protected: + explicit BarRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kEmptyFieldNumber = 1, + }; + // .google.protobuf.Empty empty = 1; + bool has_empty() const; + private: + bool _internal_has_empty() const; + + public: + void clear_empty() ; + const ::PROTOBUF_NAMESPACE_ID::Empty& empty() const; + PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::Empty* release_empty(); + ::PROTOBUF_NAMESPACE_ID::Empty* mutable_empty(); + void set_allocated_empty(::PROTOBUF_NAMESPACE_ID::Empty* empty); + private: + const ::PROTOBUF_NAMESPACE_ID::Empty& _internal_empty() const; + ::PROTOBUF_NAMESPACE_ID::Empty* _internal_mutable_empty(); + public: + void unsafe_arena_set_allocated_empty( + ::PROTOBUF_NAMESPACE_ID::Empty* empty); + ::PROTOBUF_NAMESPACE_ID::Empty* unsafe_arena_release_empty(); + // @@protoc_insertion_point(class_scope:BarRequest) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::Empty* empty_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +};// ------------------------------------------------------------------- + +class BarResponse final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:BarResponse) */ { + public: + inline BarResponse() : BarResponse(nullptr) {} + ~BarResponse() override; + explicit PROTOBUF_CONSTEXPR BarResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + BarResponse(const BarResponse& from); + BarResponse(BarResponse&& from) noexcept + : BarResponse() { + *this = ::std::move(from); + } + + inline BarResponse& operator=(const BarResponse& from) { + CopyFrom(from); + return *this; + } + inline BarResponse& operator=(BarResponse&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const BarResponse& default_instance() { + return *internal_default_instance(); + } + static inline const BarResponse* internal_default_instance() { + return reinterpret_cast( + &_BarResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(BarResponse& a, BarResponse& b) { + a.Swap(&b); + } + inline void Swap(BarResponse* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(BarResponse* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + BarResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const BarResponse& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const BarResponse& from) { + BarResponse::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(BarResponse* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "BarResponse"; + } + protected: + explicit BarResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kMyExternFieldNumber = 1, + }; + // .foo.Bar myExtern = 1; + bool has_myextern() const; + private: + bool _internal_has_myextern() const; + + public: + void clear_myextern() ; + const ::foo::Bar& myextern() const; + PROTOBUF_NODISCARD ::foo::Bar* release_myextern(); + ::foo::Bar* mutable_myextern(); + void set_allocated_myextern(::foo::Bar* myextern); + private: + const ::foo::Bar& _internal_myextern() const; + ::foo::Bar* _internal_mutable_myextern(); + public: + void unsafe_arena_set_allocated_myextern( + ::foo::Bar* myextern); + ::foo::Bar* unsafe_arena_release_myextern(); + // @@protoc_insertion_point(class_scope:BarResponse) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::foo::Bar* myextern_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// BarRequest + +// .google.protobuf.Empty empty = 1; +inline bool BarRequest::_internal_has_empty() const { + return this != internal_default_instance() && _impl_.empty_ != nullptr; +} +inline bool BarRequest::has_empty() const { + return _internal_has_empty(); +} +inline const ::PROTOBUF_NAMESPACE_ID::Empty& BarRequest::_internal_empty() const { + const ::PROTOBUF_NAMESPACE_ID::Empty* p = _impl_.empty_; + return p != nullptr ? *p : reinterpret_cast( + ::PROTOBUF_NAMESPACE_ID::_Empty_default_instance_); +} +inline const ::PROTOBUF_NAMESPACE_ID::Empty& BarRequest::empty() const { + // @@protoc_insertion_point(field_get:BarRequest.empty) + return _internal_empty(); +} +inline void BarRequest::unsafe_arena_set_allocated_empty( + ::PROTOBUF_NAMESPACE_ID::Empty* empty) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.empty_); + } + _impl_.empty_ = empty; + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:BarRequest.empty) +} +inline ::PROTOBUF_NAMESPACE_ID::Empty* BarRequest::release_empty() { + + ::PROTOBUF_NAMESPACE_ID::Empty* temp = _impl_.empty_; + _impl_.empty_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; +} +inline ::PROTOBUF_NAMESPACE_ID::Empty* BarRequest::unsafe_arena_release_empty() { + // @@protoc_insertion_point(field_release:BarRequest.empty) + + ::PROTOBUF_NAMESPACE_ID::Empty* temp = _impl_.empty_; + _impl_.empty_ = nullptr; + return temp; +} +inline ::PROTOBUF_NAMESPACE_ID::Empty* BarRequest::_internal_mutable_empty() { + + if (_impl_.empty_ == nullptr) { + auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Empty>(GetArenaForAllocation()); + _impl_.empty_ = p; + } + return _impl_.empty_; +} +inline ::PROTOBUF_NAMESPACE_ID::Empty* BarRequest::mutable_empty() { + ::PROTOBUF_NAMESPACE_ID::Empty* _msg = _internal_mutable_empty(); + // @@protoc_insertion_point(field_mutable:BarRequest.empty) + return _msg; +} +inline void BarRequest::set_allocated_empty(::PROTOBUF_NAMESPACE_ID::Empty* empty) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.empty_); + } + if (empty) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(empty)); + if (message_arena != submessage_arena) { + empty = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, empty, submessage_arena); + } + + } else { + + } + _impl_.empty_ = empty; + // @@protoc_insertion_point(field_set_allocated:BarRequest.empty) +} + +// ------------------------------------------------------------------- + +// BarResponse + +// .foo.Bar myExtern = 1; +inline bool BarResponse::_internal_has_myextern() const { + return this != internal_default_instance() && _impl_.myextern_ != nullptr; +} +inline bool BarResponse::has_myextern() const { + return _internal_has_myextern(); +} +inline const ::foo::Bar& BarResponse::_internal_myextern() const { + const ::foo::Bar* p = _impl_.myextern_; + return p != nullptr ? *p : reinterpret_cast( + ::foo::_Bar_default_instance_); +} +inline const ::foo::Bar& BarResponse::myextern() const { + // @@protoc_insertion_point(field_get:BarResponse.myExtern) + return _internal_myextern(); +} +inline void BarResponse::unsafe_arena_set_allocated_myextern( + ::foo::Bar* myextern) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.myextern_); + } + _impl_.myextern_ = myextern; + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:BarResponse.myExtern) +} +inline ::foo::Bar* BarResponse::release_myextern() { + + ::foo::Bar* temp = _impl_.myextern_; + _impl_.myextern_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; +} +inline ::foo::Bar* BarResponse::unsafe_arena_release_myextern() { + // @@protoc_insertion_point(field_release:BarResponse.myExtern) + + ::foo::Bar* temp = _impl_.myextern_; + _impl_.myextern_ = nullptr; + return temp; +} +inline ::foo::Bar* BarResponse::_internal_mutable_myextern() { + + if (_impl_.myextern_ == nullptr) { + auto* p = CreateMaybeMessage<::foo::Bar>(GetArenaForAllocation()); + _impl_.myextern_ = p; + } + return _impl_.myextern_; +} +inline ::foo::Bar* BarResponse::mutable_myextern() { + ::foo::Bar* _msg = _internal_mutable_myextern(); + // @@protoc_insertion_point(field_mutable:BarResponse.myExtern) + return _msg; +} +inline void BarResponse::set_allocated_myextern(::foo::Bar* myextern) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.myextern_); + } + if (myextern) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(myextern)); + if (message_arena != submessage_arena) { + myextern = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, myextern, submessage_arena); + } + + } else { + + } + _impl_.myextern_ = myextern; + // @@protoc_insertion_point(field_set_allocated:BarResponse.myExtern) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/extern/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/extern/output/csharp/Main.cs new file mode 100644 index 00000000000..170a0bdbabc --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/csharp/Main.cs @@ -0,0 +1,441 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +/// Holder for reflection information generated from main.proto +public static partial class MainReflection { + + #region Descriptor + /// File descriptor for main.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MainReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgptYWluLnByb3RvGg1mb28vYmFyLnByb3RvGhtnb29nbGUvcHJvdG9idWYv", + "ZW1wdHkucHJvdG8iMwoKQmFyUmVxdWVzdBIlCgVlbXB0eRgBIAEoCzIWLmdv", + "b2dsZS5wcm90b2J1Zi5FbXB0eSIpCgtCYXJSZXNwb25zZRIaCghteUV4dGVy", + "bhgBIAEoCzIILmZvby5CYXIyVAoHU2VydmljZRInCgNGb28SCC5mb28uQmFy", + "GhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5EiAKA0JhchILLkJhclJlcXVlc3Qa", + "DC5CYXJSZXNwb25zZWIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Foo.BarReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.EmptyReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::BarRequest), global::BarRequest.Parser, new[]{ "Empty" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::BarResponse), global::BarResponse.Parser, new[]{ "MyExtern" }, null, null, null, null) + })); + } + #endregion + +} +#region Messages +public sealed partial class BarRequest : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public BarRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public BarRequest(BarRequest other) : this() { + empty_ = other.empty_ != null ? other.empty_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public BarRequest Clone() { + return new BarRequest(this); + } + + /// Field number for the "empty" field. + public const int EmptyFieldNumber = 1; + private global::Google.Protobuf.WellKnownTypes.Empty empty_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Google.Protobuf.WellKnownTypes.Empty Empty { + get { return empty_; } + set { + empty_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as BarRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(BarRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Empty, other.Empty)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (empty_ != null) hash ^= Empty.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (empty_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Empty); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (empty_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Empty); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (empty_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Empty); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(BarRequest other) { + if (other == null) { + return; + } + if (other.empty_ != null) { + if (empty_ == null) { + Empty = new global::Google.Protobuf.WellKnownTypes.Empty(); + } + Empty.MergeFrom(other.Empty); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + if (empty_ == null) { + Empty = new global::Google.Protobuf.WellKnownTypes.Empty(); + } + input.ReadMessage(Empty); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (empty_ == null) { + Empty = new global::Google.Protobuf.WellKnownTypes.Empty(); + } + input.ReadMessage(Empty); + break; + } + } + } + } + #endif + +} + +public sealed partial class BarResponse : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public BarResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public BarResponse(BarResponse other) : this() { + myExtern_ = other.myExtern_ != null ? other.myExtern_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public BarResponse Clone() { + return new BarResponse(this); + } + + /// Field number for the "myExtern" field. + public const int MyExternFieldNumber = 1; + private global::Foo.Bar myExtern_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Foo.Bar MyExtern { + get { return myExtern_; } + set { + myExtern_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as BarResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(BarResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(MyExtern, other.MyExtern)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (myExtern_ != null) hash ^= MyExtern.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (myExtern_ != null) { + output.WriteRawTag(10); + output.WriteMessage(MyExtern); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (myExtern_ != null) { + output.WriteRawTag(10); + output.WriteMessage(MyExtern); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (myExtern_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(MyExtern); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(BarResponse other) { + if (other == null) { + return; + } + if (other.myExtern_ != null) { + if (myExtern_ == null) { + MyExtern = new global::Foo.Bar(); + } + MyExtern.MergeFrom(other.MyExtern); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + if (myExtern_ == null) { + MyExtern = new global::Foo.Bar(); + } + input.ReadMessage(MyExtern); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (myExtern_ == null) { + MyExtern = new global::Foo.Bar(); + } + input.ReadMessage(MyExtern); + break; + } + } + } + } + #endif + +} + +#endregion + + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.h new file mode 100644 index 00000000000..de1a05cab24 --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.h @@ -0,0 +1,86 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +@class Bar; + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - MainRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface MainRoot : GPBRootObject +@end + +#pragma mark - BarRequest + +typedef GPB_ENUM(BarRequest_FieldNumber) { + BarRequest_FieldNumber_Empty = 1, +}; + +GPB_FINAL @interface BarRequest : GPBMessage + +@property(nonatomic, readwrite, strong, null_resettable) GPBEmpty *empty; +/** Test to see if @c empty has been set. */ +@property(nonatomic, readwrite) BOOL hasEmpty; + +@end + +#pragma mark - BarResponse + +typedef GPB_ENUM(BarResponse_FieldNumber) { + BarResponse_FieldNumber_MyExtern = 1, +}; + +GPB_FINAL @interface BarResponse : GPBMessage + +@property(nonatomic, readwrite, strong, null_resettable) Bar *myExtern; +/** Test to see if @c myExtern has been set. */ +@property(nonatomic, readwrite) BOOL hasMyExtern; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.m new file mode 100644 index 00000000000..69b2a1e3b2a --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.m @@ -0,0 +1,153 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "Main.pbobjc.h" +#import "foo/Bar.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension" + +#pragma mark - Objective C Class declarations +// Forward declarations of Objective C classes that we can use as +// static values in struct initializers. +// We don't use [Foo class] because it is not a static value. +GPBObjCClassDeclaration(Bar); +GPBObjCClassDeclaration(GPBEmpty); + +#pragma mark - MainRoot + +@implementation MainRoot + +// No extensions in the file and none of the imports (direct or indirect) +// defined extensions, so no need to generate +extensionRegistry. + +@end + +#pragma mark - MainRoot_FileDescriptor + +static GPBFileDescriptor *MainRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - BarRequest + +@implementation BarRequest + +@dynamic hasEmpty, empty; + +typedef struct BarRequest__storage_ { + uint32_t _has_storage_[1]; + GPBEmpty *empty; +} BarRequest__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "empty", + .dataTypeSpecific.clazz = GPBObjCClass(GPBEmpty), + .number = BarRequest_FieldNumber_Empty, + .hasIndex = 0, + .offset = (uint32_t)offsetof(BarRequest__storage_, empty), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[BarRequest class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(BarRequest__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - BarResponse + +@implementation BarResponse + +@dynamic hasMyExtern, myExtern; + +typedef struct BarResponse__storage_ { + uint32_t _has_storage_[1]; + Bar *myExtern; +} BarResponse__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "myExtern", + .dataTypeSpecific.clazz = GPBObjCClass(Bar), + .number = BarResponse_FieldNumber_MyExtern, + .hasIndex = 0, + .offset = (uint32_t)offsetof(BarResponse__storage_, myExtern), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom), + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[BarResponse class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(BarResponse__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\010\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/extern/output/php/BarRequest.php b/packages/protobuf/test/protoc-out/extern/output/php/BarRequest.php new file mode 100644 index 00000000000..4fd3d7ded4c --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/php/BarRequest.php @@ -0,0 +1,66 @@ +BarRequest + */ +class BarRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field .google.protobuf.Empty empty = 1; + */ + protected $empty = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\GPBEmpty $empty + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .google.protobuf.Empty empty = 1; + * @return \Google\Protobuf\GPBEmpty|null + */ + public function getEmpty() + { + return $this->empty; + } + + public function hasEmpty() + { + return isset($this->empty); + } + + public function clearEmpty() + { + unset($this->empty); + } + + /** + * Generated from protobuf field .google.protobuf.Empty empty = 1; + * @param \Google\Protobuf\GPBEmpty $var + * @return $this + */ + public function setEmpty($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\GPBEmpty::class); + $this->empty = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/extern/output/php/BarResponse.php b/packages/protobuf/test/protoc-out/extern/output/php/BarResponse.php new file mode 100644 index 00000000000..1f359ba8386 --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/php/BarResponse.php @@ -0,0 +1,66 @@ +BarResponse + */ +class BarResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field .foo.Bar myExtern = 1; + */ + protected $myExtern = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Foo\Bar $myExtern + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .foo.Bar myExtern = 1; + * @return \Foo\Bar|null + */ + public function getMyExtern() + { + return $this->myExtern; + } + + public function hasMyExtern() + { + return isset($this->myExtern); + } + + public function clearMyExtern() + { + unset($this->myExtern); + } + + /** + * Generated from protobuf field .foo.Bar myExtern = 1; + * @param \Foo\Bar $var + * @return $this + */ + public function setMyExtern($var) + { + GPBUtil::checkMessage($var, \Foo\Bar::class); + $this->myExtern = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/extern/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/extern/output/php/GPBMetadata/Main.php new file mode 100644 index 00000000000..cf9f61bf3bc --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/php/GPBMetadata/Main.php @@ -0,0 +1,37 @@ +internalAddGeneratedFile( + ' +� + +main.protogoogle/protobuf/empty.proto"3 + +BarRequest% +empty ( 2.google.protobuf.Empty") + BarResponse +myExtern ( 2.foo.Bar2T +Service\' +Foo.foo.Bar.google.protobuf.Empty +Bar .BarRequest .BarResponsebproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/packages/protobuf/test/protoc-out/extern/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/extern/output/pyi/main_pb2.pyi new file mode 100644 index 00000000000..7f0960e5818 --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/pyi/main_pb2.pyi @@ -0,0 +1,19 @@ +from foo import bar_pb2 as _bar_pb2 +from google.protobuf import empty_pb2 as _empty_pb2 +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class BarRequest(_message.Message): + __slots__ = ["empty"] + EMPTY_FIELD_NUMBER: _ClassVar[int] + empty: _empty_pb2.Empty + def __init__(self, empty: _Optional[_Union[_empty_pb2.Empty, _Mapping]] = ...) -> None: ... + +class BarResponse(_message.Message): + __slots__ = ["myExtern"] + MYEXTERN_FIELD_NUMBER: _ClassVar[int] + myExtern: _bar_pb2.Bar + def __init__(self, myExtern: _Optional[_Union[_bar_pb2.Bar, _Mapping]] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/extern/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/extern/output/python/main_pb2.py new file mode 100644 index 00000000000..f9bf0dcabde --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/python/main_pb2.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from foo import bar_pb2 as foo_dot_bar__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\x1a\rfoo/bar.proto\x1a\x1bgoogle/protobuf/empty.proto\"3\n\nBarRequest\x12%\n\x05\x65mpty\x18\x01 \x01(\x0b\x32\x16.google.protobuf.Empty\")\n\x0b\x42\x61rResponse\x12\x1a\n\x08myExtern\x18\x01 \x01(\x0b\x32\x08.foo.Bar2T\n\x07Service\x12\'\n\x03\x46oo\x12\x08.foo.Bar\x1a\x16.google.protobuf.Empty\x12 \n\x03\x42\x61r\x12\x0b.BarRequest\x1a\x0c.BarResponseb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_BARREQUEST']._serialized_start=58 + _globals['_BARREQUEST']._serialized_end=109 + _globals['_BARRESPONSE']._serialized_start=111 + _globals['_BARRESPONSE']._serialized_end=152 + _globals['_SERVICE']._serialized_start=154 + _globals['_SERVICE']._serialized_end=238 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/extern/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/extern/output/ruby/main_pb.rb new file mode 100644 index 00000000000..72db9a0c78e --- /dev/null +++ b/packages/protobuf/test/protoc-out/extern/output/ruby/main_pb.rb @@ -0,0 +1,21 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto + +require 'google/protobuf' + +require 'foo/bar_pb' +require 'google/protobuf/empty_pb' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("main.proto", :syntax => :proto3) do + add_message "BarRequest" do + optional :empty, :message, 1, "google.protobuf.Empty" + end + add_message "BarResponse" do + optional :myExtern, :message, 1, "foo.Bar" + end + end +end + +BarRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("BarRequest").msgclass +BarResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("BarResponse").msgclass diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.cc b/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.cc new file mode 100644 index 00000000000..7d054db1c93 --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.cc @@ -0,0 +1,590 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: com/azure/test.proto + +#include "com/azure/test.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +namespace com { +namespace azure { +namespace test { +PROTOBUF_CONSTEXPR FooRequest::FooRequest( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct FooRequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR FooRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~FooRequestDefaultTypeInternal() {} + union { + FooRequest _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FooRequestDefaultTypeInternal _FooRequest_default_instance_; +PROTOBUF_CONSTEXPR FooResponse::FooResponse( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /* ._impl_.testoutputfield_ = */ 0 + + , /*decltype(_impl_._cached_size_)*/{}} {} +struct FooResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR FooResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~FooResponseDefaultTypeInternal() {} + union { + FooResponse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FooResponseDefaultTypeInternal _FooResponse_default_instance_; +} // namespace test +} // namespace azure +} // namespace com +static ::_pb::Metadata file_level_metadata_com_2fazure_2ftest_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_com_2fazure_2ftest_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_com_2fazure_2ftest_2eproto = nullptr; +const ::uint32_t TableStruct_com_2fazure_2ftest_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::com::azure::test::FooRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::com::azure::test::FooRequest, _impl_.testinputfield_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::com::azure::test::FooResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::com::azure::test::FooResponse, _impl_.testoutputfield_), + PROTOBUF_FIELD_OFFSET(::com::azure::test::FooResponse, _impl_.secondfield_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::com::azure::test::FooRequest)}, + { 9, -1, -1, sizeof(::com::azure::test::FooResponse)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::com::azure::test::_FooRequest_default_instance_._instance, + &::com::azure::test::_FooResponse_default_instance_._instance, +}; +const char descriptor_table_protodef_com_2fazure_2ftest_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\024com/azure/test.proto\022\016com.azure.test\"$" + "\n\nFooRequest\022\026\n\016testInputField\030\001 \001(\t\";\n\013" + "FooResponse\022\027\n\017testOutputField\030\001 \001(\005\022\023\n\013" + "secondField\030\002 \001(\t2I\n\007Service\022>\n\003Foo\022\032.co" + "m.azure.test.FooRequest\032\033.com.azure.test" + ".FooResponseb\006proto3" +}; +static ::absl::once_flag descriptor_table_com_2fazure_2ftest_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_com_2fazure_2ftest_2eproto = { + false, + false, + 220, + descriptor_table_protodef_com_2fazure_2ftest_2eproto, + "com/azure/test.proto", + &descriptor_table_com_2fazure_2ftest_2eproto_once, + nullptr, + 0, + 2, + schemas, + file_default_instances, + TableStruct_com_2fazure_2ftest_2eproto::offsets, + file_level_metadata_com_2fazure_2ftest_2eproto, + file_level_enum_descriptors_com_2fazure_2ftest_2eproto, + file_level_service_descriptors_com_2fazure_2ftest_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_com_2fazure_2ftest_2eproto_getter() { + return &descriptor_table_com_2fazure_2ftest_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_com_2fazure_2ftest_2eproto(&descriptor_table_com_2fazure_2ftest_2eproto); +namespace com { +namespace azure { +namespace test { +// =================================================================== + +class FooRequest::_Internal { + public: +}; + +FooRequest::FooRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:com.azure.test.FooRequest) +} +FooRequest::FooRequest(const FooRequest& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + FooRequest* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_testinputfield().empty()) { + _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:com.azure.test.FooRequest) +} + +inline void FooRequest::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +FooRequest::~FooRequest() { + // @@protoc_insertion_point(destructor:com.azure.test.FooRequest) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void FooRequest::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testinputfield_.Destroy(); +} + +void FooRequest::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void FooRequest::Clear() { +// @@protoc_insertion_point(message_clear_start:com.azure.test.FooRequest) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_.ClearToEmpty(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* FooRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // string testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + auto str = _internal_mutable_testinputfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "com.azure.test.FooRequest.testInputField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* FooRequest::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:com.azure.test.FooRequest) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "com.azure.test.FooRequest.testInputField"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_testinputfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:com.azure.test.FooRequest) + return target; +} + +::size_t FooRequest::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:com.azure.test.FooRequest) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_testinputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FooRequest::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + FooRequest::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FooRequest::GetClassData() const { return &_class_data_; } + + +void FooRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.test.FooRequest) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_testinputfield().empty()) { + _this->_internal_set_testinputfield(from._internal_testinputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void FooRequest::CopyFrom(const FooRequest& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.test.FooRequest) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool FooRequest::IsInitialized() const { + return true; +} + +void FooRequest::InternalSwap(FooRequest* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.testinputfield_, lhs_arena, + &other->_impl_.testinputfield_, rhs_arena + ); +} + +::PROTOBUF_NAMESPACE_ID::Metadata FooRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_com_2fazure_2ftest_2eproto_getter, &descriptor_table_com_2fazure_2ftest_2eproto_once, + file_level_metadata_com_2fazure_2ftest_2eproto[0]); +} +// =================================================================== + +class FooResponse::_Internal { + public: +}; + +FooResponse::FooResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:com.azure.test.FooResponse) +} +FooResponse::FooResponse(const FooResponse& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + FooResponse* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) {} + + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_secondfield().empty()) { + _this->_impl_.secondfield_.Set(from._internal_secondfield(), + _this->GetArenaForAllocation()); + } + _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; + // @@protoc_insertion_point(copy_constructor:com.azure.test.FooResponse) +} + +inline void FooResponse::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) { 0 } + + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +FooResponse::~FooResponse() { + // @@protoc_insertion_point(destructor:com.azure.test.FooResponse) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void FooResponse::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.secondfield_.Destroy(); +} + +void FooResponse::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void FooResponse::Clear() { +// @@protoc_insertion_point(message_clear_start:com.azure.test.FooResponse) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.secondfield_.ClearToEmpty(); + _impl_.testoutputfield_ = 0; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* FooResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // int32 testOutputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { + _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + // string secondField = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { + auto str = _internal_mutable_secondfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "com.azure.test.FooResponse.secondField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* FooResponse::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:com.azure.test.FooResponse) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray( + 1, this->_internal_testoutputfield(), target); + } + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "com.azure.test.FooResponse.secondField"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_secondfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:com.azure.test.FooResponse) + return target; +} + +::size_t FooResponse::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:com.azure.test.FooResponse) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_secondfield()); + } + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( + this->_internal_testoutputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FooResponse::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + FooResponse::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FooResponse::GetClassData() const { return &_class_data_; } + + +void FooResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.test.FooResponse) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_secondfield().empty()) { + _this->_internal_set_secondfield(from._internal_secondfield()); + } + if (from._internal_testoutputfield() != 0) { + _this->_internal_set_testoutputfield(from._internal_testoutputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void FooResponse::CopyFrom(const FooResponse& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.test.FooResponse) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool FooResponse::IsInitialized() const { + return true; +} + +void FooResponse::InternalSwap(FooResponse* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.secondfield_, lhs_arena, + &other->_impl_.secondfield_, rhs_arena + ); + + swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata FooResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_com_2fazure_2ftest_2eproto_getter, &descriptor_table_com_2fazure_2ftest_2eproto_once, + file_level_metadata_com_2fazure_2ftest_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +} // namespace test +} // namespace azure +} // namespace com +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::com::azure::test::FooRequest* +Arena::CreateMaybeMessage< ::com::azure::test::FooRequest >(Arena* arena) { + return Arena::CreateMessageInternal< ::com::azure::test::FooRequest >(arena); +} +template<> PROTOBUF_NOINLINE ::com::azure::test::FooResponse* +Arena::CreateMaybeMessage< ::com::azure::test::FooResponse >(Arena* arena) { + return Arena::CreateMessageInternal< ::com::azure::test::FooResponse >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.h b/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.h new file mode 100644 index 00000000000..d10a9de7746 --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.h @@ -0,0 +1,538 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: com/azure/test.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_com_2fazure_2ftest_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_com_2fazure_2ftest_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_com_2fazure_2ftest_2eproto; +namespace com { +namespace azure { +namespace test { +class FooRequest; +struct FooRequestDefaultTypeInternal; +extern FooRequestDefaultTypeInternal _FooRequest_default_instance_; +class FooResponse; +struct FooResponseDefaultTypeInternal; +extern FooResponseDefaultTypeInternal _FooResponse_default_instance_; +} // namespace test +} // namespace azure +} // namespace com +PROTOBUF_NAMESPACE_OPEN +template <> +::com::azure::test::FooRequest* Arena::CreateMaybeMessage<::com::azure::test::FooRequest>(Arena*); +template <> +::com::azure::test::FooResponse* Arena::CreateMaybeMessage<::com::azure::test::FooResponse>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + +namespace com { +namespace azure { +namespace test { + +// =================================================================== + + +// ------------------------------------------------------------------- + +class FooRequest final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.test.FooRequest) */ { + public: + inline FooRequest() : FooRequest(nullptr) {} + ~FooRequest() override; + explicit PROTOBUF_CONSTEXPR FooRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + FooRequest(const FooRequest& from); + FooRequest(FooRequest&& from) noexcept + : FooRequest() { + *this = ::std::move(from); + } + + inline FooRequest& operator=(const FooRequest& from) { + CopyFrom(from); + return *this; + } + inline FooRequest& operator=(FooRequest&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const FooRequest& default_instance() { + return *internal_default_instance(); + } + static inline const FooRequest* internal_default_instance() { + return reinterpret_cast( + &_FooRequest_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(FooRequest& a, FooRequest& b) { + a.Swap(&b); + } + inline void Swap(FooRequest* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FooRequest* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + FooRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const FooRequest& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const FooRequest& from) { + FooRequest::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(FooRequest* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "com.azure.test.FooRequest"; + } + protected: + explicit FooRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + }; + // string testInputField = 1; + void clear_testinputfield() ; + const std::string& testinputfield() const; + template + void set_testinputfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_testinputfield(); + PROTOBUF_NODISCARD std::string* release_testinputfield(); + void set_allocated_testinputfield(std::string* testinputfield); + private: + const std::string& _internal_testinputfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); + std::string* _internal_mutable_testinputfield(); + public: + // @@protoc_insertion_point(class_scope:com.azure.test.FooRequest) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_com_2fazure_2ftest_2eproto; +};// ------------------------------------------------------------------- + +class FooResponse final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.test.FooResponse) */ { + public: + inline FooResponse() : FooResponse(nullptr) {} + ~FooResponse() override; + explicit PROTOBUF_CONSTEXPR FooResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + FooResponse(const FooResponse& from); + FooResponse(FooResponse&& from) noexcept + : FooResponse() { + *this = ::std::move(from); + } + + inline FooResponse& operator=(const FooResponse& from) { + CopyFrom(from); + return *this; + } + inline FooResponse& operator=(FooResponse&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const FooResponse& default_instance() { + return *internal_default_instance(); + } + static inline const FooResponse* internal_default_instance() { + return reinterpret_cast( + &_FooResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(FooResponse& a, FooResponse& b) { + a.Swap(&b); + } + inline void Swap(FooResponse* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FooResponse* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + FooResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const FooResponse& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const FooResponse& from) { + FooResponse::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(FooResponse* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "com.azure.test.FooResponse"; + } + protected: + explicit FooResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kSecondFieldFieldNumber = 2, + kTestOutputFieldFieldNumber = 1, + }; + // string secondField = 2; + void clear_secondfield() ; + const std::string& secondfield() const; + template + void set_secondfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_secondfield(); + PROTOBUF_NODISCARD std::string* release_secondfield(); + void set_allocated_secondfield(std::string* secondfield); + private: + const std::string& _internal_secondfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); + std::string* _internal_mutable_secondfield(); + public: + // int32 testOutputField = 1; + void clear_testoutputfield() ; + ::int32_t testoutputfield() const; + void set_testoutputfield(::int32_t value); + + private: + ::int32_t _internal_testoutputfield() const; + void _internal_set_testoutputfield(::int32_t value); + + public: + // @@protoc_insertion_point(class_scope:com.azure.test.FooResponse) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; + ::int32_t testoutputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_com_2fazure_2ftest_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// FooRequest + +// string testInputField = 1; +inline void FooRequest::clear_testinputfield() { + _impl_.testinputfield_.ClearToEmpty(); +} +inline const std::string& FooRequest::testinputfield() const { + // @@protoc_insertion_point(field_get:com.azure.test.FooRequest.testInputField) + return _internal_testinputfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void FooRequest::set_testinputfield(ArgT0&& arg0, ArgT... args) { + + _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:com.azure.test.FooRequest.testInputField) +} +inline std::string* FooRequest::mutable_testinputfield() { + std::string* _s = _internal_mutable_testinputfield(); + // @@protoc_insertion_point(field_mutable:com.azure.test.FooRequest.testInputField) + return _s; +} +inline const std::string& FooRequest::_internal_testinputfield() const { + return _impl_.testinputfield_.Get(); +} +inline void FooRequest::_internal_set_testinputfield(const std::string& value) { + + _impl_.testinputfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* FooRequest::_internal_mutable_testinputfield() { + + return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* FooRequest::release_testinputfield() { + // @@protoc_insertion_point(field_release:com.azure.test.FooRequest.testInputField) + return _impl_.testinputfield_.Release(); +} +inline void FooRequest::set_allocated_testinputfield(std::string* testinputfield) { + _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.testinputfield_.IsDefault()) { + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:com.azure.test.FooRequest.testInputField) +} + +// ------------------------------------------------------------------- + +// FooResponse + +// int32 testOutputField = 1; +inline void FooResponse::clear_testoutputfield() { + _impl_.testoutputfield_ = 0; +} +inline ::int32_t FooResponse::testoutputfield() const { + // @@protoc_insertion_point(field_get:com.azure.test.FooResponse.testOutputField) + return _internal_testoutputfield(); +} +inline void FooResponse::set_testoutputfield(::int32_t value) { + ; + _internal_set_testoutputfield(value); + // @@protoc_insertion_point(field_set:com.azure.test.FooResponse.testOutputField) +} +inline ::int32_t FooResponse::_internal_testoutputfield() const { + return _impl_.testoutputfield_; +} +inline void FooResponse::_internal_set_testoutputfield(::int32_t value) { + ; + _impl_.testoutputfield_ = value; +} + +// string secondField = 2; +inline void FooResponse::clear_secondfield() { + _impl_.secondfield_.ClearToEmpty(); +} +inline const std::string& FooResponse::secondfield() const { + // @@protoc_insertion_point(field_get:com.azure.test.FooResponse.secondField) + return _internal_secondfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void FooResponse::set_secondfield(ArgT0&& arg0, ArgT... args) { + + _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:com.azure.test.FooResponse.secondField) +} +inline std::string* FooResponse::mutable_secondfield() { + std::string* _s = _internal_mutable_secondfield(); + // @@protoc_insertion_point(field_mutable:com.azure.test.FooResponse.secondField) + return _s; +} +inline const std::string& FooResponse::_internal_secondfield() const { + return _impl_.secondfield_.Get(); +} +inline void FooResponse::_internal_set_secondfield(const std::string& value) { + + _impl_.secondfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* FooResponse::_internal_mutable_secondfield() { + + return _impl_.secondfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* FooResponse::release_secondfield() { + // @@protoc_insertion_point(field_release:com.azure.test.FooResponse.secondField) + return _impl_.secondfield_.Release(); +} +inline void FooResponse::set_allocated_secondfield(std::string* secondfield) { + _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.secondfield_.IsDefault()) { + _impl_.secondfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:com.azure.test.FooResponse.secondField) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) +} // namespace test +} // namespace azure +} // namespace com + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/csharp/Test.cs b/packages/protobuf/test/protoc-out/inferred-message-names/output/csharp/Test.cs new file mode 100644 index 00000000000..82b6f3ff744 --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/csharp/Test.cs @@ -0,0 +1,462 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: com/azure/test.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Com.Azure.Test { + + /// Holder for reflection information generated from com/azure/test.proto + public static partial class TestReflection { + + #region Descriptor + /// File descriptor for com/azure/test.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static TestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChRjb20vYXp1cmUvdGVzdC5wcm90bxIOY29tLmF6dXJlLnRlc3QiJAoKRm9v", + "UmVxdWVzdBIWCg50ZXN0SW5wdXRGaWVsZBgBIAEoCSI7CgtGb29SZXNwb25z", + "ZRIXCg90ZXN0T3V0cHV0RmllbGQYASABKAUSEwoLc2Vjb25kRmllbGQYAiAB", + "KAkySQoHU2VydmljZRI+CgNGb28SGi5jb20uYXp1cmUudGVzdC5Gb29SZXF1", + "ZXN0GhsuY29tLmF6dXJlLnRlc3QuRm9vUmVzcG9uc2ViBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.FooRequest), global::Com.Azure.Test.FooRequest.Parser, new[]{ "TestInputField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.FooResponse), global::Com.Azure.Test.FooResponse.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class FooRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public FooRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public FooRequest(FooRequest other) : this() { + testInputField_ = other.testInputField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public FooRequest Clone() { + return new FooRequest(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private string testInputField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string TestInputField { + get { return testInputField_; } + set { + testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as FooRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(FooRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestInputField != other.TestInputField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestInputField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(FooRequest other) { + if (other == null) { + return; + } + if (other.TestInputField.Length != 0) { + TestInputField = other.TestInputField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + } + #endif + + } + + public sealed partial class FooResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public FooResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public FooResponse(FooResponse other) : this() { + testOutputField_ = other.testOutputField_; + secondField_ = other.secondField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public FooResponse Clone() { + return new FooResponse(this); + } + + /// Field number for the "testOutputField" field. + public const int TestOutputFieldFieldNumber = 1; + private int testOutputField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int TestOutputField { + get { return testOutputField_; } + set { + testOutputField_ = value; + } + } + + /// Field number for the "secondField" field. + public const int SecondFieldFieldNumber = 2; + private string secondField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string SecondField { + get { return secondField_; } + set { + secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as FooResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(FooResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestOutputField != other.TestOutputField) return false; + if (SecondField != other.SecondField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); + if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestOutputField != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); + } + if (SecondField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(FooResponse other) { + if (other == null) { + return; + } + if (other.TestOutputField != 0) { + TestOutputField = other.TestOutputField; + } + if (other.SecondField.Length != 0) { + SecondField = other.SecondField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + } + #endif + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.h b/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.h new file mode 100644 index 00000000000..bb2e8245519 --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.h @@ -0,0 +1,83 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: com/azure/test.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - TestRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface TestRoot : GPBRootObject +@end + +#pragma mark - FooRequest + +typedef GPB_ENUM(FooRequest_FieldNumber) { + FooRequest_FieldNumber_TestInputField = 1, +}; + +GPB_FINAL @interface FooRequest : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; + +@end + +#pragma mark - FooResponse + +typedef GPB_ENUM(FooResponse_FieldNumber) { + FooResponse_FieldNumber_TestOutputField = 1, + FooResponse_FieldNumber_SecondField = 2, +}; + +GPB_FINAL @interface FooResponse : GPBMessage + +@property(nonatomic, readwrite) int32_t testOutputField; + +@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.m b/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.m new file mode 100644 index 00000000000..6c3b111f0b1 --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.m @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: com/azure/test.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "com/azure/Test.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - TestRoot + +@implementation TestRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - TestRoot_FileDescriptor + +static GPBFileDescriptor *TestRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"com.azure.test" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - FooRequest + +@implementation FooRequest + +@dynamic testInputField; + +typedef struct FooRequest__storage_ { + uint32_t _has_storage_[1]; + NSString *testInputField; +} FooRequest__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputField", + .dataTypeSpecific.clazz = Nil, + .number = FooRequest_FieldNumber_TestInputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(FooRequest__storage_, testInputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[FooRequest class] + file:TestRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(FooRequest__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\016\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - FooResponse + +@implementation FooResponse + +@dynamic testOutputField; +@dynamic secondField; + +typedef struct FooResponse__storage_ { + uint32_t _has_storage_[1]; + int32_t testOutputField; + NSString *secondField; +} FooResponse__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testOutputField", + .dataTypeSpecific.clazz = Nil, + .number = FooResponse_FieldNumber_TestOutputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(FooResponse__storage_, testOutputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeInt32, + }, + { + .name = "secondField", + .dataTypeSpecific.clazz = Nil, + .number = FooResponse_FieldNumber_SecondField, + .hasIndex = 1, + .offset = (uint32_t)offsetof(FooResponse__storage_, secondField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[FooResponse class] + file:TestRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(FooResponse__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\002\001\017\000\002\013\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooRequest.php b/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooRequest.php new file mode 100644 index 00000000000..81195e7219f --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooRequest.php @@ -0,0 +1,58 @@ +com.azure.test.FooRequest + */ +class FooRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string testInputField = 1; + */ + protected $testInputField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $testInputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Com\Azure\Test::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string testInputField = 1; + * @return string + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field string testInputField = 1; + * @param string $var + * @return $this + */ + public function setTestInputField($var) + { + GPBUtil::checkString($var, True); + $this->testInputField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooResponse.php b/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooResponse.php new file mode 100644 index 00000000000..84b1a0d3113 --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooResponse.php @@ -0,0 +1,85 @@ +com.azure.test.FooResponse + */ +class FooResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field int32 testOutputField = 1; + */ + protected $testOutputField = 0; + /** + * Generated from protobuf field string secondField = 2; + */ + protected $secondField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $testOutputField + * @type string $secondField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Com\Azure\Test::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @return int + */ + public function getTestOutputField() + { + return $this->testOutputField; + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @param int $var + * @return $this + */ + public function setTestOutputField($var) + { + GPBUtil::checkInt32($var); + $this->testOutputField = $var; + + return $this; + } + + /** + * Generated from protobuf field string secondField = 2; + * @return string + */ + public function getSecondField() + { + return $this->secondField; + } + + /** + * Generated from protobuf field string secondField = 2; + * @param string $var + * @return $this + */ + public function setSecondField($var) + { + GPBUtil::checkString($var, True); + $this->secondField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/php/GPBMetadata/Com/Azure/Test.php b/packages/protobuf/test/protoc-out/inferred-message-names/output/php/GPBMetadata/Com/Azure/Test.php new file mode 100644 index 00000000000..0f0508d0397 --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/php/GPBMetadata/Com/Azure/Test.php @@ -0,0 +1,34 @@ +internalAddGeneratedFile( + ' +� +com/azure/test.protocom.azure.test"$ + +FooRequest +testInputField ( "; + FooResponse +testOutputField ( + secondField ( 2I +Service> +Foo.com.azure.test.FooRequest.com.azure.test.FooResponsebproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/pyi/com/azure/test_pb2.pyi b/packages/protobuf/test/protoc-out/inferred-message-names/output/pyi/com/azure/test_pb2.pyi new file mode 100644 index 00000000000..efb8ce7bbae --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/pyi/com/azure/test_pb2.pyi @@ -0,0 +1,19 @@ +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Optional as _Optional + +DESCRIPTOR: _descriptor.FileDescriptor + +class FooRequest(_message.Message): + __slots__ = ["testInputField"] + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testInputField: str + def __init__(self, testInputField: _Optional[str] = ...) -> None: ... + +class FooResponse(_message.Message): + __slots__ = ["testOutputField", "secondField"] + TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] + SECONDFIELD_FIELD_NUMBER: _ClassVar[int] + testOutputField: int + secondField: str + def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/python/com/azure/test_pb2.py b/packages/protobuf/test/protoc-out/inferred-message-names/output/python/com/azure/test_pb2.py new file mode 100644 index 00000000000..7c83d5b4953 --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/python/com/azure/test_pb2.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: com/azure/test.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x63om/azure/test.proto\x12\x0e\x63om.azure.test\"$\n\nFooRequest\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\";\n\x0b\x46ooResponse\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t2I\n\x07Service\x12>\n\x03\x46oo\x12\x1a.com.azure.test.FooRequest\x1a\x1b.com.azure.test.FooResponseb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'com.azure.test_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_FOOREQUEST']._serialized_start=40 + _globals['_FOOREQUEST']._serialized_end=76 + _globals['_FOORESPONSE']._serialized_start=78 + _globals['_FOORESPONSE']._serialized_end=137 + _globals['_SERVICE']._serialized_start=139 + _globals['_SERVICE']._serialized_end=212 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/ruby/com/azure/test_pb.rb b/packages/protobuf/test/protoc-out/inferred-message-names/output/ruby/com/azure/test_pb.rb new file mode 100644 index 00000000000..1c4ab5efe2a --- /dev/null +++ b/packages/protobuf/test/protoc-out/inferred-message-names/output/ruby/com/azure/test_pb.rb @@ -0,0 +1,25 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: com/azure/test.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("com/azure/test.proto", :syntax => :proto3) do + add_message "com.azure.test.FooRequest" do + optional :testInputField, :string, 1 + end + add_message "com.azure.test.FooResponse" do + optional :testOutputField, :int32, 1 + optional :secondField, :string, 2 + end + end +end + +module Com + module Azure + module Test + FooRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.test.FooRequest").msgclass + FooResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.test.FooResponse").msgclass + end + end +end diff --git a/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.cc new file mode 100644 index 00000000000..a01eb7b7099 --- /dev/null +++ b/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.cc @@ -0,0 +1,372 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#include "main.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +PROTOBUF_CONSTEXPR Input_TestInputFieldEntry_DoNotUse::Input_TestInputFieldEntry_DoNotUse( + ::_pbi::ConstantInitialized) {} +struct Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal { + PROTOBUF_CONSTEXPR Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal() {} + union { + Input_TestInputFieldEntry_DoNotUse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal _Input_TestInputFieldEntry_DoNotUse_default_instance_; +PROTOBUF_CONSTEXPR Input::Input( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.testinputfield_)*/{::_pbi::ConstantInitialized()} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct InputDefaultTypeInternal { + PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputDefaultTypeInternal() {} + union { + Input _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; +static ::_pb::Metadata file_level_metadata_main_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_main_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_main_2eproto = nullptr; +const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::Input_TestInputFieldEntry_DoNotUse, _has_bits_), + PROTOBUF_FIELD_OFFSET(::Input_TestInputFieldEntry_DoNotUse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::Input_TestInputFieldEntry_DoNotUse, key_), + PROTOBUF_FIELD_OFFSET(::Input_TestInputFieldEntry_DoNotUse, value_), + 0, + 1, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::Input, _impl_.testinputfield_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 10, -1, sizeof(::Input_TestInputFieldEntry_DoNotUse)}, + { 12, -1, -1, sizeof(::Input)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_Input_TestInputFieldEntry_DoNotUse_default_instance_._instance, + &::_Input_default_instance_._instance, +}; +const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\nmain.proto\032\033google/protobuf/empty.prot" + "o\"r\n\005Input\0222\n\016testInputField\030\001 \003(\0132\032.Inp" + "ut.TestInputFieldEntry\0325\n\023TestInputField" + "Entry\022\013\n\003key\030\001 \001(\017\022\r\n\005value\030\002 \001(\t:\0028\00120\n" + "\007Service\022%\n\003Foo\022\006.Input\032\026.google.protobu" + "f.Emptyb\006proto3" +}; +static const ::_pbi::DescriptorTable* const descriptor_table_main_2eproto_deps[1] = + { + &::descriptor_table_google_2fprotobuf_2fempty_2eproto, +}; +static ::absl::once_flag descriptor_table_main_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { + false, + false, + 215, + descriptor_table_protodef_main_2eproto, + "main.proto", + &descriptor_table_main_2eproto_once, + descriptor_table_main_2eproto_deps, + 1, + 2, + schemas, + file_default_instances, + TableStruct_main_2eproto::offsets, + file_level_metadata_main_2eproto, + file_level_enum_descriptors_main_2eproto, + file_level_service_descriptors_main_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { + return &descriptor_table_main_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); +// =================================================================== + +Input_TestInputFieldEntry_DoNotUse::Input_TestInputFieldEntry_DoNotUse() {} +Input_TestInputFieldEntry_DoNotUse::Input_TestInputFieldEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : SuperType(arena) {} +void Input_TestInputFieldEntry_DoNotUse::MergeFrom(const Input_TestInputFieldEntry_DoNotUse& other) { + MergeFromInternal(other); +} +::PROTOBUF_NAMESPACE_ID::Metadata Input_TestInputFieldEntry_DoNotUse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[0]); +} +// =================================================================== + +class Input::_Internal { + public: +}; + +Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + if (arena != nullptr) { + arena->OwnCustomDestructor(this, &Input::ArenaDtor); + } + // @@protoc_insertion_point(arena_constructor:Input) +} +Input::Input(const Input& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Input* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_.testinputfield_)*/{} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.testinputfield_.MergeFrom(from._impl_.testinputfield_); + // @@protoc_insertion_point(copy_constructor:Input) +} + +inline void Input::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + /*decltype(_impl_.testinputfield_)*/{::_pbi::ArenaInitialized(), arena} + , /*decltype(_impl_._cached_size_)*/{} + }; +} + +Input::~Input() { + // @@protoc_insertion_point(destructor:Input) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + ArenaDtor(this); + return; + } + SharedDtor(); +} + +inline void Input::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testinputfield_.Destruct(); + _impl_.testinputfield_.~MapField(); +} + +void Input::ArenaDtor(void* object) { + Input* _this = reinterpret_cast< Input* >(object); + _this->_impl_.testinputfield_.Destruct(); +} +void Input::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Input::Clear() { +// @@protoc_insertion_point(message_clear_start:Input) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // map testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(&_impl_.testinputfield_, ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Input::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:Input) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // map testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + using MapType = ::_pb::Map<::int32_t, std::string>; + using WireHelper = Input_TestInputFieldEntry_DoNotUse::Funcs; + const auto& map_field = this->_internal_testinputfield(); + auto check_utf8 = [](const MapType::value_type& entry) { + (void)entry; + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + entry.second.data(), static_cast(entry.second.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "Input.TestInputFieldEntry.value"); + }; + + if (stream->IsSerializationDeterministic() && map_field.size() > 1) { + for (const auto& entry : ::_pbi::MapSorterFlat(map_field)) { + target = WireHelper::InternalSerialize(1, entry.first, entry.second, target, stream); + check_utf8(entry); + } + } else { + for (const auto& entry : map_field) { + target = WireHelper::InternalSerialize(1, entry.first, entry.second, target, stream); + check_utf8(entry); + } + } + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:Input) + return target; +} + +::size_t Input::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:Input) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // map testInputField = 1; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_testinputfield_size()); + for (::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >::const_iterator + it = this->_internal_testinputfield().begin(); + it != this->_internal_testinputfield().end(); ++it) { + total_size += Input_TestInputFieldEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Input::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } + + +void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:Input) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + _this->_impl_.testinputfield_.MergeFrom(from._impl_.testinputfield_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Input::CopyFrom(const Input& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:Input) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Input::IsInitialized() const { + return true; +} + +void Input::InternalSwap(Input* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + _impl_.testinputfield_.InternalSwap(&other->_impl_.testinputfield_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::Input_TestInputFieldEntry_DoNotUse* +Arena::CreateMaybeMessage< ::Input_TestInputFieldEntry_DoNotUse >(Arena* arena) { + return Arena::CreateMessageInternal< ::Input_TestInputFieldEntry_DoNotUse >(arena); +} +template<> PROTOBUF_NOINLINE ::Input* +Arena::CreateMaybeMessage< ::Input >(Arena* arena) { + return Arena::CreateMessageInternal< ::Input >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.h new file mode 100644 index 00000000000..980cc648f26 --- /dev/null +++ b/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.h @@ -0,0 +1,320 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/map.h" // IWYU pragma: export +#include "google/protobuf/map_entry.h" +#include "google/protobuf/map_field_inl.h" +#include "google/protobuf/unknown_field_set.h" +#include "google/protobuf/empty.pb.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_main_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_main_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_main_2eproto; +class Input; +struct InputDefaultTypeInternal; +extern InputDefaultTypeInternal _Input_default_instance_; +class Input_TestInputFieldEntry_DoNotUse; +struct Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal; +extern Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal _Input_TestInputFieldEntry_DoNotUse_default_instance_; +PROTOBUF_NAMESPACE_OPEN +template <> +::Input* Arena::CreateMaybeMessage<::Input>(Arena*); +template <> +::Input_TestInputFieldEntry_DoNotUse* Arena::CreateMaybeMessage<::Input_TestInputFieldEntry_DoNotUse>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + + +// =================================================================== + + +// ------------------------------------------------------------------- + +class Input_TestInputFieldEntry_DoNotUse final : public ::PROTOBUF_NAMESPACE_ID::internal::MapEntry { +public: + typedef ::PROTOBUF_NAMESPACE_ID::internal::MapEntry SuperType; + Input_TestInputFieldEntry_DoNotUse(); + explicit PROTOBUF_CONSTEXPR Input_TestInputFieldEntry_DoNotUse( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit Input_TestInputFieldEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void MergeFrom(const Input_TestInputFieldEntry_DoNotUse& other); + static const Input_TestInputFieldEntry_DoNotUse* internal_default_instance() { return reinterpret_cast(&_Input_TestInputFieldEntry_DoNotUse_default_instance_); } + static bool ValidateKey(void*) { return true; } + static bool ValidateValue(std::string* s) { + return ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(s->data(), static_cast(s->size()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "Input.TestInputFieldEntry.value"); + } + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + friend struct ::TableStruct_main_2eproto; +}; +// ------------------------------------------------------------------- + +class Input final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { + public: + inline Input() : Input(nullptr) {} + ~Input() override; + explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Input(const Input& from); + Input(Input&& from) noexcept + : Input() { + *this = ::std::move(from); + } + + inline Input& operator=(const Input& from) { + CopyFrom(from); + return *this; + } + inline Input& operator=(Input&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Input& default_instance() { + return *internal_default_instance(); + } + static inline const Input* internal_default_instance() { + return reinterpret_cast( + &_Input_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(Input& a, Input& b) { + a.Swap(&b); + } + inline void Swap(Input* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Input* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Input& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Input& from) { + Input::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Input* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "Input"; + } + protected: + explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + }; + // map testInputField = 1; + int testinputfield_size() const; + private: + int _internal_testinputfield_size() const; + + public: + void clear_testinputfield() ; + private: + const ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >& + _internal_testinputfield() const; + ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >* + _internal_mutable_testinputfield(); + public: + const ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >& + testinputfield() const; + ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >* + mutable_testinputfield(); + // @@protoc_insertion_point(class_scope:Input) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::MapField< + Input_TestInputFieldEntry_DoNotUse, + ::int32_t, std::string, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_SFIXED32, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING> testinputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// Input + +// map testInputField = 1; +inline int Input::_internal_testinputfield_size() const { + return _impl_.testinputfield_.size(); +} +inline int Input::testinputfield_size() const { + return _internal_testinputfield_size(); +} +inline void Input::clear_testinputfield() { + _impl_.testinputfield_.Clear(); +} +inline const ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >& +Input::_internal_testinputfield() const { + return _impl_.testinputfield_.GetMap(); +} +inline const ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >& +Input::testinputfield() const { + // @@protoc_insertion_point(field_map:Input.testInputField) + return _internal_testinputfield(); +} +inline ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >* +Input::_internal_mutable_testinputfield() { + return _impl_.testinputfield_.MutableMap(); +} +inline ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >* +Input::mutable_testinputfield() { + // @@protoc_insertion_point(field_mutable_map:Input.testInputField) + return _internal_mutable_testinputfield(); +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/map/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/map/output/csharp/Main.cs new file mode 100644 index 00000000000..d99e8a43aeb --- /dev/null +++ b/packages/protobuf/test/protoc-out/map/output/csharp/Main.cs @@ -0,0 +1,221 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +/// Holder for reflection information generated from main.proto +public static partial class MainReflection { + + #region Descriptor + /// File descriptor for main.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MainReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgptYWluLnByb3RvGhtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8icgoF", + "SW5wdXQSMgoOdGVzdElucHV0RmllbGQYASADKAsyGi5JbnB1dC5UZXN0SW5w", + "dXRGaWVsZEVudHJ5GjUKE1Rlc3RJbnB1dEZpZWxkRW50cnkSCwoDa2V5GAEg", + "ASgPEg0KBXZhbHVlGAIgASgJOgI4ATIwCgdTZXJ2aWNlEiUKA0ZvbxIGLklu", + "cHV0GhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5YgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.EmptyReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "TestInputField" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, }) + })); + } + #endregion + +} +#region Messages +public sealed partial class Input : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input(Input other) : this() { + testInputField_ = other.testInputField_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input Clone() { + return new Input(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private static readonly pbc::MapField.Codec _map_testInputField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed32(13, 0), pb::FieldCodec.ForString(18, ""), 10); + private readonly pbc::MapField testInputField_ = new pbc::MapField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public pbc::MapField TestInputField { + get { return testInputField_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Input); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Input other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!TestInputField.Equals(other.TestInputField)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + hash ^= TestInputField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + testInputField_.WriteTo(output, _map_testInputField_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + testInputField_.WriteTo(ref output, _map_testInputField_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + size += testInputField_.CalculateSize(_map_testInputField_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Input other) { + if (other == null) { + return; + } + testInputField_.MergeFrom(other.testInputField_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + testInputField_.AddEntriesFrom(input, _map_testInputField_codec); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + testInputField_.AddEntriesFrom(ref input, _map_testInputField_codec); + break; + } + } + } + } + #endif + +} + +#endregion + + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.h new file mode 100644 index 00000000000..b5127ac4d6f --- /dev/null +++ b/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.h @@ -0,0 +1,70 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - MainRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface MainRoot : GPBRootObject +@end + +#pragma mark - Input + +typedef GPB_ENUM(Input_FieldNumber) { + Input_FieldNumber_TestInputField = 1, +}; + +GPB_FINAL @interface Input : GPBMessage + +@property(nonatomic, readwrite, strong, null_resettable) GPBInt32ObjectDictionary *testInputField; +/** The number of items in @c testInputField without causing the container to be created. */ +@property(nonatomic, readonly) NSUInteger testInputField_Count; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.m new file mode 100644 index 00000000000..fc5cfcaec43 --- /dev/null +++ b/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.m @@ -0,0 +1,107 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "Main.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension" + +#pragma mark - Objective C Class declarations +// Forward declarations of Objective C classes that we can use as +// static values in struct initializers. +// We don't use [Foo class] because it is not a static value. +GPBObjCClassDeclaration(Input); + +#pragma mark - MainRoot + +@implementation MainRoot + +// No extensions in the file and none of the imports (direct or indirect) +// defined extensions, so no need to generate +extensionRegistry. + +@end + +#pragma mark - MainRoot_FileDescriptor + +static GPBFileDescriptor *MainRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Input + +@implementation Input + +@dynamic testInputField, testInputField_Count; + +typedef struct Input__storage_ { + uint32_t _has_storage_[1]; + GPBInt32ObjectDictionary *testInputField; +} Input__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputField", + .dataTypeSpecific.clazz = Nil, + .number = Input_FieldNumber_TestInputField, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(Input__storage_, testInputField), + .flags = (GPBFieldFlags)(GPBFieldMapKeySFixed32 | GPBFieldTextFormatNameCustom), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Input class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Input__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\016\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/map/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/map/output/php/GPBMetadata/Main.php new file mode 100644 index 00000000000..6f14fc1d63c --- /dev/null +++ b/packages/protobuf/test/protoc-out/map/output/php/GPBMetadata/Main.php @@ -0,0 +1,35 @@ +internalAddGeneratedFile( + ' +� + +main.proto"r +Input2 +testInputField ( 2.Input.TestInputFieldEntry5 +TestInputFieldEntry +key ( +value ( :820 +Service% +Foo.Input.google.protobuf.Emptybproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/packages/protobuf/test/protoc-out/map/output/php/Input.php b/packages/protobuf/test/protoc-out/map/output/php/Input.php new file mode 100644 index 00000000000..98621710ed2 --- /dev/null +++ b/packages/protobuf/test/protoc-out/map/output/php/Input.php @@ -0,0 +1,56 @@ +Input + */ +class Input extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field map testInputField = 1; + */ + private $testInputField; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\MapField $testInputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field map testInputField = 1; + * @return \Google\Protobuf\Internal\MapField + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field map testInputField = 1; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setTestInputField($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::SFIXED32, \Google\Protobuf\Internal\GPBType::STRING); + $this->testInputField = $arr; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/map/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/map/output/pyi/main_pb2.pyi new file mode 100644 index 00000000000..ffae4c6f210 --- /dev/null +++ b/packages/protobuf/test/protoc-out/map/output/pyi/main_pb2.pyi @@ -0,0 +1,20 @@ +from google.protobuf import empty_pb2 as _empty_pb2 +from google.protobuf.internal import containers as _containers +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional + +DESCRIPTOR: _descriptor.FileDescriptor + +class Input(_message.Message): + __slots__ = ["testInputField"] + class TestInputFieldEntry(_message.Message): + __slots__ = ["key", "value"] + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: int + value: str + def __init__(self, key: _Optional[int] = ..., value: _Optional[str] = ...) -> None: ... + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testInputField: _containers.ScalarMap[int, str] + def __init__(self, testInputField: _Optional[_Mapping[int, str]] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/map/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/map/output/python/main_pb2.py new file mode 100644 index 00000000000..bcb7f55160b --- /dev/null +++ b/packages/protobuf/test/protoc-out/map/output/python/main_pb2.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\x1a\x1bgoogle/protobuf/empty.proto\"r\n\x05Input\x12\x32\n\x0etestInputField\x18\x01 \x03(\x0b\x32\x1a.Input.TestInputFieldEntry\x1a\x35\n\x13TestInputFieldEntry\x12\x0b\n\x03key\x18\x01 \x01(\x0f\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x32\x30\n\x07Service\x12%\n\x03\x46oo\x12\x06.Input\x1a\x16.google.protobuf.Emptyb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _INPUT_TESTINPUTFIELDENTRY._options = None + _INPUT_TESTINPUTFIELDENTRY._serialized_options = b'8\001' + _globals['_INPUT']._serialized_start=43 + _globals['_INPUT']._serialized_end=157 + _globals['_INPUT_TESTINPUTFIELDENTRY']._serialized_start=104 + _globals['_INPUT_TESTINPUTFIELDENTRY']._serialized_end=157 + _globals['_SERVICE']._serialized_start=159 + _globals['_SERVICE']._serialized_end=207 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/map/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/map/output/ruby/main_pb.rb new file mode 100644 index 00000000000..9b75410c1b6 --- /dev/null +++ b/packages/protobuf/test/protoc-out/map/output/ruby/main_pb.rb @@ -0,0 +1,16 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto + +require 'google/protobuf' + +require 'google/protobuf/empty_pb' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("main.proto", :syntax => :proto3) do + add_message "Input" do + map :testInputField, :sfixed32, :string, 1 + end + end +end + +Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.cc new file mode 100644 index 00000000000..9943d43c5a3 --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.cc @@ -0,0 +1,375 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#include "main.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +PROTOBUF_CONSTEXPR Input::Input( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct InputDefaultTypeInternal { + PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputDefaultTypeInternal() {} + union { + Input _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; +PROTOBUF_CONSTEXPR FooResponse::FooResponse( + ::_pbi::ConstantInitialized) {} +struct FooResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR FooResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~FooResponseDefaultTypeInternal() {} + union { + FooResponse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FooResponseDefaultTypeInternal _FooResponse_default_instance_; +static ::_pb::Metadata file_level_metadata_main_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_main_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_main_2eproto = nullptr; +const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::Input, _impl_.testinputfield_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::FooResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::Input)}, + { 9, -1, -1, sizeof(::FooResponse)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_Input_default_instance_._instance, + &::_FooResponse_default_instance_._instance, +}; +const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\nmain.proto\";\n\005Input\022\026\n\016testInputField\030" + "\001 \001(\tJ\004\010\002\020\003J\004\010\017\020\020J\004\010\t\020\014R\003fooR\003bar\"\r\n\013Foo" + "Response2&\n\007Service\022\033\n\003Foo\022\006.Input\032\014.Foo" + "Responseb\006proto3" +}; +static ::absl::once_flag descriptor_table_main_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { + false, + false, + 136, + descriptor_table_protodef_main_2eproto, + "main.proto", + &descriptor_table_main_2eproto_once, + nullptr, + 0, + 2, + schemas, + file_default_instances, + TableStruct_main_2eproto::offsets, + file_level_metadata_main_2eproto, + file_level_enum_descriptors_main_2eproto, + file_level_service_descriptors_main_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { + return &descriptor_table_main_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); +// =================================================================== + +class Input::_Internal { + public: +}; + +Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:Input) +} +Input::Input(const Input& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Input* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_testinputfield().empty()) { + _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:Input) +} + +inline void Input::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Input::~Input() { + // @@protoc_insertion_point(destructor:Input) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Input::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testinputfield_.Destroy(); +} + +void Input::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Input::Clear() { +// @@protoc_insertion_point(message_clear_start:Input) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_.ClearToEmpty(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // string testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + auto str = _internal_mutable_testinputfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "Input.testInputField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Input::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:Input) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "Input.testInputField"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_testinputfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:Input) + return target; +} + +::size_t Input::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:Input) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_testinputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Input::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } + + +void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:Input) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_testinputfield().empty()) { + _this->_internal_set_testinputfield(from._internal_testinputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Input::CopyFrom(const Input& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:Input) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Input::IsInitialized() const { + return true; +} + +void Input::InternalSwap(Input* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.testinputfield_, lhs_arena, + &other->_impl_.testinputfield_, rhs_arena + ); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[0]); +} +// =================================================================== + +class FooResponse::_Internal { + public: +}; + +FooResponse::FooResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena) { + // @@protoc_insertion_point(arena_constructor:FooResponse) +} +FooResponse::FooResponse(const FooResponse& from) + : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase() { + FooResponse* const _this = this; (void)_this; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:FooResponse) +} + + + + + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FooResponse::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl, + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl, +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FooResponse::GetClassData() const { return &_class_data_; } + + + + + + + +::PROTOBUF_NAMESPACE_ID::Metadata FooResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::Input* +Arena::CreateMaybeMessage< ::Input >(Arena* arena) { + return Arena::CreateMessageInternal< ::Input >(arena); +} +template<> PROTOBUF_NOINLINE ::FooResponse* +Arena::CreateMaybeMessage< ::FooResponse >(Arena* arena) { + return Arena::CreateMessageInternal< ::FooResponse >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.h new file mode 100644 index 00000000000..8e8ce2f365d --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.h @@ -0,0 +1,415 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_bases.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_main_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_main_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_main_2eproto; +class FooResponse; +struct FooResponseDefaultTypeInternal; +extern FooResponseDefaultTypeInternal _FooResponse_default_instance_; +class Input; +struct InputDefaultTypeInternal; +extern InputDefaultTypeInternal _Input_default_instance_; +PROTOBUF_NAMESPACE_OPEN +template <> +::FooResponse* Arena::CreateMaybeMessage<::FooResponse>(Arena*); +template <> +::Input* Arena::CreateMaybeMessage<::Input>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + + +// =================================================================== + + +// ------------------------------------------------------------------- + +class Input final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { + public: + inline Input() : Input(nullptr) {} + ~Input() override; + explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Input(const Input& from); + Input(Input&& from) noexcept + : Input() { + *this = ::std::move(from); + } + + inline Input& operator=(const Input& from) { + CopyFrom(from); + return *this; + } + inline Input& operator=(Input&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Input& default_instance() { + return *internal_default_instance(); + } + static inline const Input* internal_default_instance() { + return reinterpret_cast( + &_Input_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Input& a, Input& b) { + a.Swap(&b); + } + inline void Swap(Input* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Input* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Input& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Input& from) { + Input::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Input* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "Input"; + } + protected: + explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + }; + // string testInputField = 1; + void clear_testinputfield() ; + const std::string& testinputfield() const; + template + void set_testinputfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_testinputfield(); + PROTOBUF_NODISCARD std::string* release_testinputfield(); + void set_allocated_testinputfield(std::string* testinputfield); + private: + const std::string& _internal_testinputfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); + std::string* _internal_mutable_testinputfield(); + public: + // @@protoc_insertion_point(class_scope:Input) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +};// ------------------------------------------------------------------- + +class FooResponse final : + public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:FooResponse) */ { + public: + inline FooResponse() : FooResponse(nullptr) {} + explicit PROTOBUF_CONSTEXPR FooResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + FooResponse(const FooResponse& from); + FooResponse(FooResponse&& from) noexcept + : FooResponse() { + *this = ::std::move(from); + } + + inline FooResponse& operator=(const FooResponse& from) { + CopyFrom(from); + return *this; + } + inline FooResponse& operator=(FooResponse&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const FooResponse& default_instance() { + return *internal_default_instance(); + } + static inline const FooResponse* internal_default_instance() { + return reinterpret_cast( + &_FooResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(FooResponse& a, FooResponse& b) { + a.Swap(&b); + } + inline void Swap(FooResponse* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(FooResponse* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + FooResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyFrom; + inline void CopyFrom(const FooResponse& from) { + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl(*this, from); + } + using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeFrom; + void MergeFrom(const FooResponse& from) { + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl(*this, from); + } + public: + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "FooResponse"; + } + protected: + explicit FooResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // @@protoc_insertion_point(class_scope:FooResponse) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + }; + friend struct ::TableStruct_main_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// Input + +// string testInputField = 1; +inline void Input::clear_testinputfield() { + _impl_.testinputfield_.ClearToEmpty(); +} +inline const std::string& Input::testinputfield() const { + // @@protoc_insertion_point(field_get:Input.testInputField) + return _internal_testinputfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { + + _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:Input.testInputField) +} +inline std::string* Input::mutable_testinputfield() { + std::string* _s = _internal_mutable_testinputfield(); + // @@protoc_insertion_point(field_mutable:Input.testInputField) + return _s; +} +inline const std::string& Input::_internal_testinputfield() const { + return _impl_.testinputfield_.Get(); +} +inline void Input::_internal_set_testinputfield(const std::string& value) { + + _impl_.testinputfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Input::_internal_mutable_testinputfield() { + + return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Input::release_testinputfield() { + // @@protoc_insertion_point(field_release:Input.testInputField) + return _impl_.testinputfield_.Release(); +} +inline void Input::set_allocated_testinputfield(std::string* testinputfield) { + _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.testinputfield_.IsDefault()) { + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:Input.testInputField) +} + +// ------------------------------------------------------------------- + +// FooResponse + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/reserved fields/output/csharp/Main.cs new file mode 100644 index 00000000000..3052ff51989 --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/csharp/Main.cs @@ -0,0 +1,384 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +/// Holder for reflection information generated from main.proto +public static partial class MainReflection { + + #region Descriptor + /// File descriptor for main.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MainReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgptYWluLnByb3RvIjsKBUlucHV0EhYKDnRlc3RJbnB1dEZpZWxkGAEgASgJ", + "SgQIAhADSgQIDxAQSgQICRAMUgNmb29SA2JhciINCgtGb29SZXNwb25zZTIm", + "CgdTZXJ2aWNlEhsKA0ZvbxIGLklucHV0GgwuRm9vUmVzcG9uc2ViBnByb3Rv", + "Mw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "TestInputField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::FooResponse), global::FooResponse.Parser, null, null, null, null, null) + })); + } + #endregion + +} +#region Messages +public sealed partial class Input : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input(Input other) : this() { + testInputField_ = other.testInputField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input Clone() { + return new Input(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private string testInputField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string TestInputField { + get { return testInputField_; } + set { + testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Input); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Input other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestInputField != other.TestInputField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestInputField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Input other) { + if (other == null) { + return; + } + if (other.TestInputField.Length != 0) { + TestInputField = other.TestInputField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + } + #endif + +} + +public sealed partial class FooResponse : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public FooResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public FooResponse(FooResponse other) : this() { + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public FooResponse Clone() { + return new FooResponse(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as FooResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(FooResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(FooResponse other) { + if (other == null) { + return; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + +} + +#endregion + + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.h new file mode 100644 index 00000000000..bf0262c0951 --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.h @@ -0,0 +1,74 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - MainRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface MainRoot : GPBRootObject +@end + +#pragma mark - Input + +typedef GPB_ENUM(Input_FieldNumber) { + Input_FieldNumber_TestInputField = 1, +}; + +GPB_FINAL @interface Input : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; + +@end + +#pragma mark - FooResponse + +GPB_FINAL @interface FooResponse : GPBMessage + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.m new file mode 100644 index 00000000000..9c3a38dc1df --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.m @@ -0,0 +1,131 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "Main.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - MainRoot + +@implementation MainRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - MainRoot_FileDescriptor + +static GPBFileDescriptor *MainRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Input + +@implementation Input + +@dynamic testInputField; + +typedef struct Input__storage_ { + uint32_t _has_storage_[1]; + NSString *testInputField; +} Input__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputField", + .dataTypeSpecific.clazz = Nil, + .number = Input_FieldNumber_TestInputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Input__storage_, testInputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Input class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Input__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\016\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - FooResponse + +@implementation FooResponse + + +typedef struct FooResponse__storage_ { + uint32_t _has_storage_[1]; +} FooResponse__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[FooResponse class] + file:MainRoot_FileDescriptor() + fields:NULL + fieldCount:0 + storageSize:sizeof(FooResponse__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/php/FooResponse.php b/packages/protobuf/test/protoc-out/reserved fields/output/php/FooResponse.php new file mode 100644 index 00000000000..c5a0cc35d65 --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/php/FooResponse.php @@ -0,0 +1,29 @@ +FooResponse + */ +class FooResponse extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + +} + diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/reserved fields/output/php/GPBMetadata/Main.php new file mode 100644 index 00000000000..2f7eb0be98d --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/php/GPBMetadata/Main.php @@ -0,0 +1,32 @@ +internalAddGeneratedFile( + ' +� + +main.proto"; +Input +testInputField ( JJJ  RfooRbar" + FooResponse2& +Service +Foo.Input .FooResponsebproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/php/Input.php b/packages/protobuf/test/protoc-out/reserved fields/output/php/Input.php new file mode 100644 index 00000000000..b77d7713c23 --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/php/Input.php @@ -0,0 +1,56 @@ +Input + */ +class Input extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string testInputField = 1; + */ + protected $testInputField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $testInputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string testInputField = 1; + * @return string + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field string testInputField = 1; + * @param string $var + * @return $this + */ + public function setTestInputField($var) + { + GPBUtil::checkString($var, True); + $this->testInputField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/reserved fields/output/pyi/main_pb2.pyi new file mode 100644 index 00000000000..1fe476adda0 --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/pyi/main_pb2.pyi @@ -0,0 +1,15 @@ +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Optional as _Optional + +DESCRIPTOR: _descriptor.FileDescriptor + +class Input(_message.Message): + __slots__ = ["testInputField"] + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testInputField: str + def __init__(self, testInputField: _Optional[str] = ...) -> None: ... + +class FooResponse(_message.Message): + __slots__ = [] + def __init__(self) -> None: ... diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/reserved fields/output/python/main_pb2.py new file mode 100644 index 00000000000..e7bcdfafc2e --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/python/main_pb2.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\";\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\tJ\x04\x08\x02\x10\x03J\x04\x08\x0f\x10\x10J\x04\x08\t\x10\x0cR\x03\x66ooR\x03\x62\x61r\"\r\n\x0b\x46ooResponse2&\n\x07Service\x12\x1b\n\x03\x46oo\x12\x06.Input\x1a\x0c.FooResponseb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_INPUT']._serialized_start=14 + _globals['_INPUT']._serialized_end=73 + _globals['_FOORESPONSE']._serialized_start=75 + _globals['_FOORESPONSE']._serialized_end=88 + _globals['_SERVICE']._serialized_start=90 + _globals['_SERVICE']._serialized_end=128 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/reserved fields/output/ruby/main_pb.rb new file mode 100644 index 00000000000..b7c1f8134d5 --- /dev/null +++ b/packages/protobuf/test/protoc-out/reserved fields/output/ruby/main_pb.rb @@ -0,0 +1,17 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("main.proto", :syntax => :proto3) do + add_message "Input" do + optional :testInputField, :string, 1 + end + add_message "FooResponse" do + end + end +end + +Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass +FooResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("FooResponse").msgclass diff --git a/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.cc b/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.cc new file mode 100644 index 00000000000..4c99349080a --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.cc @@ -0,0 +1,589 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: com/azure/Test.proto + +#include "com/azure/Test.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +namespace com { +namespace azure { +namespace Test { +PROTOBUF_CONSTEXPR Input::Input( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct InputDefaultTypeInternal { + PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputDefaultTypeInternal() {} + union { + Input _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; +PROTOBUF_CONSTEXPR Output::Output( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /* ._impl_.testoutputfield_ = */ 0 + + , /*decltype(_impl_._cached_size_)*/{}} {} +struct OutputDefaultTypeInternal { + PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~OutputDefaultTypeInternal() {} + union { + Output _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; +} // namespace Test +} // namespace azure +} // namespace com +static ::_pb::Metadata file_level_metadata_com_2fazure_2fTest_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_com_2fazure_2fTest_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_com_2fazure_2fTest_2eproto = nullptr; +const ::uint32_t TableStruct_com_2fazure_2fTest_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::com::azure::Test::Input, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::com::azure::Test::Input, _impl_.testinputfield_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::com::azure::Test::Output, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::com::azure::Test::Output, _impl_.testoutputfield_), + PROTOBUF_FIELD_OFFSET(::com::azure::Test::Output, _impl_.secondfield_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::com::azure::Test::Input)}, + { 9, -1, -1, sizeof(::com::azure::Test::Output)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::com::azure::Test::_Input_default_instance_._instance, + &::com::azure::Test::_Output_default_instance_._instance, +}; +const char descriptor_table_protodef_com_2fazure_2fTest_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\024com/azure/Test.proto\022\016com.azure.Test\"\037" + "\n\005Input\022\026\n\016testInputField\030\001 \001(\t\"6\n\006Outpu" + "t\022\027\n\017testOutputField\030\001 \001(\005\022\023\n\013secondFiel" + "d\030\002 \001(\t2\?\n\007Service\0224\n\003Foo\022\025.com.azure.Te" + "st.Input\032\026.com.azure.Test.Outputb\006proto3" +}; +static ::absl::once_flag descriptor_table_com_2fazure_2fTest_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_com_2fazure_2fTest_2eproto = { + false, + false, + 200, + descriptor_table_protodef_com_2fazure_2fTest_2eproto, + "com/azure/Test.proto", + &descriptor_table_com_2fazure_2fTest_2eproto_once, + nullptr, + 0, + 2, + schemas, + file_default_instances, + TableStruct_com_2fazure_2fTest_2eproto::offsets, + file_level_metadata_com_2fazure_2fTest_2eproto, + file_level_enum_descriptors_com_2fazure_2fTest_2eproto, + file_level_service_descriptors_com_2fazure_2fTest_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_com_2fazure_2fTest_2eproto_getter() { + return &descriptor_table_com_2fazure_2fTest_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_com_2fazure_2fTest_2eproto(&descriptor_table_com_2fazure_2fTest_2eproto); +namespace com { +namespace azure { +namespace Test { +// =================================================================== + +class Input::_Internal { + public: +}; + +Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:com.azure.Test.Input) +} +Input::Input(const Input& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Input* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_testinputfield().empty()) { + _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:com.azure.Test.Input) +} + +inline void Input::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Input::~Input() { + // @@protoc_insertion_point(destructor:com.azure.Test.Input) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Input::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testinputfield_.Destroy(); +} + +void Input::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Input::Clear() { +// @@protoc_insertion_point(message_clear_start:com.azure.Test.Input) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_.ClearToEmpty(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // string testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + auto str = _internal_mutable_testinputfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "com.azure.Test.Input.testInputField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Input::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:com.azure.Test.Input) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "com.azure.Test.Input.testInputField"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_testinputfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:com.azure.Test.Input) + return target; +} + +::size_t Input::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:com.azure.Test.Input) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_testinputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Input::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } + + +void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.Test.Input) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_testinputfield().empty()) { + _this->_internal_set_testinputfield(from._internal_testinputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Input::CopyFrom(const Input& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.Test.Input) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Input::IsInitialized() const { + return true; +} + +void Input::InternalSwap(Input* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.testinputfield_, lhs_arena, + &other->_impl_.testinputfield_, rhs_arena + ); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_com_2fazure_2fTest_2eproto_getter, &descriptor_table_com_2fazure_2fTest_2eproto_once, + file_level_metadata_com_2fazure_2fTest_2eproto[0]); +} +// =================================================================== + +class Output::_Internal { + public: +}; + +Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:com.azure.Test.Output) +} +Output::Output(const Output& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Output* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) {} + + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_secondfield().empty()) { + _this->_impl_.secondfield_.Set(from._internal_secondfield(), + _this->GetArenaForAllocation()); + } + _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; + // @@protoc_insertion_point(copy_constructor:com.azure.Test.Output) +} + +inline void Output::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) { 0 } + + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Output::~Output() { + // @@protoc_insertion_point(destructor:com.azure.Test.Output) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Output::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.secondfield_.Destroy(); +} + +void Output::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Output::Clear() { +// @@protoc_insertion_point(message_clear_start:com.azure.Test.Output) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.secondfield_.ClearToEmpty(); + _impl_.testoutputfield_ = 0; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // int32 testOutputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { + _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + // string secondField = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { + auto str = _internal_mutable_secondfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "com.azure.Test.Output.secondField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Output::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:com.azure.Test.Output) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray( + 1, this->_internal_testoutputfield(), target); + } + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "com.azure.Test.Output.secondField"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_secondfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:com.azure.Test.Output) + return target; +} + +::size_t Output::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:com.azure.Test.Output) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_secondfield()); + } + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( + this->_internal_testoutputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Output::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } + + +void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.Test.Output) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_secondfield().empty()) { + _this->_internal_set_secondfield(from._internal_secondfield()); + } + if (from._internal_testoutputfield() != 0) { + _this->_internal_set_testoutputfield(from._internal_testoutputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Output::CopyFrom(const Output& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.Test.Output) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Output::IsInitialized() const { + return true; +} + +void Output::InternalSwap(Output* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.secondfield_, lhs_arena, + &other->_impl_.secondfield_, rhs_arena + ); + + swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_com_2fazure_2fTest_2eproto_getter, &descriptor_table_com_2fazure_2fTest_2eproto_once, + file_level_metadata_com_2fazure_2fTest_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +} // namespace Test +} // namespace azure +} // namespace com +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::com::azure::Test::Input* +Arena::CreateMaybeMessage< ::com::azure::Test::Input >(Arena* arena) { + return Arena::CreateMessageInternal< ::com::azure::Test::Input >(arena); +} +template<> PROTOBUF_NOINLINE ::com::azure::Test::Output* +Arena::CreateMaybeMessage< ::com::azure::Test::Output >(Arena* arena) { + return Arena::CreateMessageInternal< ::com::azure::Test::Output >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.h b/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.h new file mode 100644 index 00000000000..e70861a2248 --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.h @@ -0,0 +1,538 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: com/azure/Test.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2fTest_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2fTest_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_com_2fazure_2fTest_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_com_2fazure_2fTest_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_com_2fazure_2fTest_2eproto; +namespace com { +namespace azure { +namespace Test { +class Input; +struct InputDefaultTypeInternal; +extern InputDefaultTypeInternal _Input_default_instance_; +class Output; +struct OutputDefaultTypeInternal; +extern OutputDefaultTypeInternal _Output_default_instance_; +} // namespace Test +} // namespace azure +} // namespace com +PROTOBUF_NAMESPACE_OPEN +template <> +::com::azure::Test::Input* Arena::CreateMaybeMessage<::com::azure::Test::Input>(Arena*); +template <> +::com::azure::Test::Output* Arena::CreateMaybeMessage<::com::azure::Test::Output>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + +namespace com { +namespace azure { +namespace Test { + +// =================================================================== + + +// ------------------------------------------------------------------- + +class Input final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.Test.Input) */ { + public: + inline Input() : Input(nullptr) {} + ~Input() override; + explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Input(const Input& from); + Input(Input&& from) noexcept + : Input() { + *this = ::std::move(from); + } + + inline Input& operator=(const Input& from) { + CopyFrom(from); + return *this; + } + inline Input& operator=(Input&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Input& default_instance() { + return *internal_default_instance(); + } + static inline const Input* internal_default_instance() { + return reinterpret_cast( + &_Input_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Input& a, Input& b) { + a.Swap(&b); + } + inline void Swap(Input* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Input* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Input& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Input& from) { + Input::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Input* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "com.azure.Test.Input"; + } + protected: + explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + }; + // string testInputField = 1; + void clear_testinputfield() ; + const std::string& testinputfield() const; + template + void set_testinputfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_testinputfield(); + PROTOBUF_NODISCARD std::string* release_testinputfield(); + void set_allocated_testinputfield(std::string* testinputfield); + private: + const std::string& _internal_testinputfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); + std::string* _internal_mutable_testinputfield(); + public: + // @@protoc_insertion_point(class_scope:com.azure.Test.Input) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_com_2fazure_2fTest_2eproto; +};// ------------------------------------------------------------------- + +class Output final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.Test.Output) */ { + public: + inline Output() : Output(nullptr) {} + ~Output() override; + explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Output(const Output& from); + Output(Output&& from) noexcept + : Output() { + *this = ::std::move(from); + } + + inline Output& operator=(const Output& from) { + CopyFrom(from); + return *this; + } + inline Output& operator=(Output&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Output& default_instance() { + return *internal_default_instance(); + } + static inline const Output* internal_default_instance() { + return reinterpret_cast( + &_Output_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(Output& a, Output& b) { + a.Swap(&b); + } + inline void Swap(Output* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Output* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Output& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Output& from) { + Output::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Output* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "com.azure.Test.Output"; + } + protected: + explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kSecondFieldFieldNumber = 2, + kTestOutputFieldFieldNumber = 1, + }; + // string secondField = 2; + void clear_secondfield() ; + const std::string& secondfield() const; + template + void set_secondfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_secondfield(); + PROTOBUF_NODISCARD std::string* release_secondfield(); + void set_allocated_secondfield(std::string* secondfield); + private: + const std::string& _internal_secondfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); + std::string* _internal_mutable_secondfield(); + public: + // int32 testOutputField = 1; + void clear_testoutputfield() ; + ::int32_t testoutputfield() const; + void set_testoutputfield(::int32_t value); + + private: + ::int32_t _internal_testoutputfield() const; + void _internal_set_testoutputfield(::int32_t value); + + public: + // @@protoc_insertion_point(class_scope:com.azure.Test.Output) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; + ::int32_t testoutputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_com_2fazure_2fTest_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// Input + +// string testInputField = 1; +inline void Input::clear_testinputfield() { + _impl_.testinputfield_.ClearToEmpty(); +} +inline const std::string& Input::testinputfield() const { + // @@protoc_insertion_point(field_get:com.azure.Test.Input.testInputField) + return _internal_testinputfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { + + _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:com.azure.Test.Input.testInputField) +} +inline std::string* Input::mutable_testinputfield() { + std::string* _s = _internal_mutable_testinputfield(); + // @@protoc_insertion_point(field_mutable:com.azure.Test.Input.testInputField) + return _s; +} +inline const std::string& Input::_internal_testinputfield() const { + return _impl_.testinputfield_.Get(); +} +inline void Input::_internal_set_testinputfield(const std::string& value) { + + _impl_.testinputfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Input::_internal_mutable_testinputfield() { + + return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Input::release_testinputfield() { + // @@protoc_insertion_point(field_release:com.azure.Test.Input.testInputField) + return _impl_.testinputfield_.Release(); +} +inline void Input::set_allocated_testinputfield(std::string* testinputfield) { + _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.testinputfield_.IsDefault()) { + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:com.azure.Test.Input.testInputField) +} + +// ------------------------------------------------------------------- + +// Output + +// int32 testOutputField = 1; +inline void Output::clear_testoutputfield() { + _impl_.testoutputfield_ = 0; +} +inline ::int32_t Output::testoutputfield() const { + // @@protoc_insertion_point(field_get:com.azure.Test.Output.testOutputField) + return _internal_testoutputfield(); +} +inline void Output::set_testoutputfield(::int32_t value) { + ; + _internal_set_testoutputfield(value); + // @@protoc_insertion_point(field_set:com.azure.Test.Output.testOutputField) +} +inline ::int32_t Output::_internal_testoutputfield() const { + return _impl_.testoutputfield_; +} +inline void Output::_internal_set_testoutputfield(::int32_t value) { + ; + _impl_.testoutputfield_ = value; +} + +// string secondField = 2; +inline void Output::clear_secondfield() { + _impl_.secondfield_.ClearToEmpty(); +} +inline const std::string& Output::secondfield() const { + // @@protoc_insertion_point(field_get:com.azure.Test.Output.secondField) + return _internal_secondfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { + + _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:com.azure.Test.Output.secondField) +} +inline std::string* Output::mutable_secondfield() { + std::string* _s = _internal_mutable_secondfield(); + // @@protoc_insertion_point(field_mutable:com.azure.Test.Output.secondField) + return _s; +} +inline const std::string& Output::_internal_secondfield() const { + return _impl_.secondfield_.Get(); +} +inline void Output::_internal_set_secondfield(const std::string& value) { + + _impl_.secondfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Output::_internal_mutable_secondfield() { + + return _impl_.secondfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Output::release_secondfield() { + // @@protoc_insertion_point(field_release:com.azure.Test.Output.secondField) + return _impl_.secondfield_.Release(); +} +inline void Output::set_allocated_secondfield(std::string* secondfield) { + _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.secondfield_.IsDefault()) { + _impl_.secondfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:com.azure.Test.Output.secondField) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) +} // namespace Test +} // namespace azure +} // namespace com + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2fTest_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/simple/output/csharp/Test.cs b/packages/protobuf/test/protoc-out/simple/output/csharp/Test.cs new file mode 100644 index 00000000000..fdccdc42942 --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/csharp/Test.cs @@ -0,0 +1,462 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: com/azure/Test.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Com.Azure.Test { + + /// Holder for reflection information generated from com/azure/Test.proto + public static partial class TestReflection { + + #region Descriptor + /// File descriptor for com/azure/Test.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static TestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChRjb20vYXp1cmUvVGVzdC5wcm90bxIOY29tLmF6dXJlLlRlc3QiHwoFSW5w", + "dXQSFgoOdGVzdElucHV0RmllbGQYASABKAkiNgoGT3V0cHV0EhcKD3Rlc3RP", + "dXRwdXRGaWVsZBgBIAEoBRITCgtzZWNvbmRGaWVsZBgCIAEoCTI/CgdTZXJ2", + "aWNlEjQKA0ZvbxIVLmNvbS5henVyZS5UZXN0LklucHV0GhYuY29tLmF6dXJl", + "LlRlc3QuT3V0cHV0YgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.Input), global::Com.Azure.Test.Input.Parser, new[]{ "TestInputField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.Output), global::Com.Azure.Test.Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class Input : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input(Input other) : this() { + testInputField_ = other.testInputField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input Clone() { + return new Input(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private string testInputField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string TestInputField { + get { return testInputField_; } + set { + testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Input); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Input other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestInputField != other.TestInputField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestInputField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Input other) { + if (other == null) { + return; + } + if (other.TestInputField.Length != 0) { + TestInputField = other.TestInputField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + } + #endif + + } + + public sealed partial class Output : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output(Output other) : this() { + testOutputField_ = other.testOutputField_; + secondField_ = other.secondField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output Clone() { + return new Output(this); + } + + /// Field number for the "testOutputField" field. + public const int TestOutputFieldFieldNumber = 1; + private int testOutputField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int TestOutputField { + get { return testOutputField_; } + set { + testOutputField_ = value; + } + } + + /// Field number for the "secondField" field. + public const int SecondFieldFieldNumber = 2; + private string secondField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string SecondField { + get { return secondField_; } + set { + secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Output); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Output other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestOutputField != other.TestOutputField) return false; + if (SecondField != other.SecondField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); + if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestOutputField != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); + } + if (SecondField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Output other) { + if (other == null) { + return; + } + if (other.TestOutputField != 0) { + TestOutputField = other.TestOutputField; + } + if (other.SecondField.Length != 0) { + SecondField = other.SecondField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + } + #endif + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.h b/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.h new file mode 100644 index 00000000000..b3721e1bf7c --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.h @@ -0,0 +1,83 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: com/azure/Test.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - TestRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface TestRoot : GPBRootObject +@end + +#pragma mark - Input + +typedef GPB_ENUM(Input_FieldNumber) { + Input_FieldNumber_TestInputField = 1, +}; + +GPB_FINAL @interface Input : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; + +@end + +#pragma mark - Output + +typedef GPB_ENUM(Output_FieldNumber) { + Output_FieldNumber_TestOutputField = 1, + Output_FieldNumber_SecondField = 2, +}; + +GPB_FINAL @interface Output : GPBMessage + +@property(nonatomic, readwrite) int32_t testOutputField; + +@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.m b/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.m new file mode 100644 index 00000000000..c006ab57bbc --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.m @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: com/azure/Test.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "com/azure/Test.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - TestRoot + +@implementation TestRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - TestRoot_FileDescriptor + +static GPBFileDescriptor *TestRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"com.azure.Test" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Input + +@implementation Input + +@dynamic testInputField; + +typedef struct Input__storage_ { + uint32_t _has_storage_[1]; + NSString *testInputField; +} Input__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputField", + .dataTypeSpecific.clazz = Nil, + .number = Input_FieldNumber_TestInputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Input__storage_, testInputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Input class] + file:TestRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Input__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\016\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - Output + +@implementation Output + +@dynamic testOutputField; +@dynamic secondField; + +typedef struct Output__storage_ { + uint32_t _has_storage_[1]; + int32_t testOutputField; + NSString *secondField; +} Output__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testOutputField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_TestOutputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Output__storage_, testOutputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeInt32, + }, + { + .name = "secondField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_SecondField, + .hasIndex = 1, + .offset = (uint32_t)offsetof(Output__storage_, secondField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Output class] + file:TestRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Output__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\002\001\017\000\002\013\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Input.php b/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Input.php new file mode 100644 index 00000000000..6c7f5c5bd62 --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Input.php @@ -0,0 +1,58 @@ +com.azure.Test.Input + */ +class Input extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string testInputField = 1; + */ + protected $testInputField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $testInputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Com\Azure\Test::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string testInputField = 1; + * @return string + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field string testInputField = 1; + * @param string $var + * @return $this + */ + public function setTestInputField($var) + { + GPBUtil::checkString($var, True); + $this->testInputField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Output.php b/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Output.php new file mode 100644 index 00000000000..1e83abef423 --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Output.php @@ -0,0 +1,85 @@ +com.azure.Test.Output + */ +class Output extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field int32 testOutputField = 1; + */ + protected $testOutputField = 0; + /** + * Generated from protobuf field string secondField = 2; + */ + protected $secondField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $testOutputField + * @type string $secondField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Com\Azure\Test::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @return int + */ + public function getTestOutputField() + { + return $this->testOutputField; + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @param int $var + * @return $this + */ + public function setTestOutputField($var) + { + GPBUtil::checkInt32($var); + $this->testOutputField = $var; + + return $this; + } + + /** + * Generated from protobuf field string secondField = 2; + * @return string + */ + public function getSecondField() + { + return $this->secondField; + } + + /** + * Generated from protobuf field string secondField = 2; + * @param string $var + * @return $this + */ + public function setSecondField($var) + { + GPBUtil::checkString($var, True); + $this->secondField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/simple/output/php/GPBMetadata/Com/Azure/Test.php b/packages/protobuf/test/protoc-out/simple/output/php/GPBMetadata/Com/Azure/Test.php new file mode 100644 index 00000000000..18ee644d1c4 --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/php/GPBMetadata/Com/Azure/Test.php @@ -0,0 +1,33 @@ +internalAddGeneratedFile( + ' +� +com/azure/Test.protocom.azure.Test" +Input +testInputField ( "6 +Output +testOutputField ( + secondField ( 2? +Service4 +Foo.com.azure.Test.Input.com.azure.Test.Outputbproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/packages/protobuf/test/protoc-out/simple/output/pyi/com/azure/Test_pb2.pyi b/packages/protobuf/test/protoc-out/simple/output/pyi/com/azure/Test_pb2.pyi new file mode 100644 index 00000000000..2683aa8091c --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/pyi/com/azure/Test_pb2.pyi @@ -0,0 +1,19 @@ +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Optional as _Optional + +DESCRIPTOR: _descriptor.FileDescriptor + +class Input(_message.Message): + __slots__ = ["testInputField"] + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testInputField: str + def __init__(self, testInputField: _Optional[str] = ...) -> None: ... + +class Output(_message.Message): + __slots__ = ["testOutputField", "secondField"] + TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] + SECONDFIELD_FIELD_NUMBER: _ClassVar[int] + testOutputField: int + secondField: str + def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/simple/output/python/com/azure/Test_pb2.py b/packages/protobuf/test/protoc-out/simple/output/python/com/azure/Test_pb2.py new file mode 100644 index 00000000000..b987cad0140 --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/python/com/azure/Test_pb2.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: com/azure/Test.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x63om/azure/Test.proto\x12\x0e\x63om.azure.Test\"\x1f\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t2?\n\x07Service\x12\x34\n\x03\x46oo\x12\x15.com.azure.Test.Input\x1a\x16.com.azure.Test.Outputb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'com.azure.Test_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_INPUT']._serialized_start=40 + _globals['_INPUT']._serialized_end=71 + _globals['_OUTPUT']._serialized_start=73 + _globals['_OUTPUT']._serialized_end=127 + _globals['_SERVICE']._serialized_start=129 + _globals['_SERVICE']._serialized_end=192 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/simple/output/ruby/com/azure/Test_pb.rb b/packages/protobuf/test/protoc-out/simple/output/ruby/com/azure/Test_pb.rb new file mode 100644 index 00000000000..3a488085898 --- /dev/null +++ b/packages/protobuf/test/protoc-out/simple/output/ruby/com/azure/Test_pb.rb @@ -0,0 +1,25 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: com/azure/Test.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("com/azure/Test.proto", :syntax => :proto3) do + add_message "com.azure.Test.Input" do + optional :testInputField, :string, 1 + end + add_message "com.azure.Test.Output" do + optional :testOutputField, :int32, 1 + optional :secondField, :string, 2 + end + end +end + +module Com + module Azure + module Test + Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.Test.Input").msgclass + Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.Test.Output").msgclass + end + end +end diff --git a/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.cc new file mode 100644 index 00000000000..7d1ee6621a1 --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.cc @@ -0,0 +1,578 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#include "main.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +PROTOBUF_CONSTEXPR Input::Input( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct InputDefaultTypeInternal { + PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputDefaultTypeInternal() {} + union { + Input _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; +PROTOBUF_CONSTEXPR Output::Output( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /* ._impl_.testoutputfield_ = */ 0 + + , /*decltype(_impl_._cached_size_)*/{}} {} +struct OutputDefaultTypeInternal { + PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~OutputDefaultTypeInternal() {} + union { + Output _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; +static ::_pb::Metadata file_level_metadata_main_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_main_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_main_2eproto = nullptr; +const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::Input, _impl_.testinputfield_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::Output, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::Output, _impl_.testoutputfield_), + PROTOBUF_FIELD_OFFSET(::Output, _impl_.secondfield_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::Input)}, + { 9, -1, -1, sizeof(::Output)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_Input_default_instance_._instance, + &::_Output_default_instance_._instance, +}; +const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\nmain.proto\"\037\n\005Input\022\026\n\016testInputField\030" + "\001 \001(\t\"6\n\006Output\022\027\n\017testOutputField\030\001 \001(\005" + "\022\023\n\013secondField\030\002 \001(\t2t\n\007Service\022\035\n\006Dupl" + "ex\022\006.Input\032\007.Output(\0010\001\022\027\n\002In\022\006.Input\032\007." + "Output(\001\022\030\n\003Out\022\006.Input\032\007.Output0\001\022\027\n\004No" + "ne\022\006.Input\032\007.Outputb\006proto3" +}; +static ::absl::once_flag descriptor_table_main_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { + false, + false, + 227, + descriptor_table_protodef_main_2eproto, + "main.proto", + &descriptor_table_main_2eproto_once, + nullptr, + 0, + 2, + schemas, + file_default_instances, + TableStruct_main_2eproto::offsets, + file_level_metadata_main_2eproto, + file_level_enum_descriptors_main_2eproto, + file_level_service_descriptors_main_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { + return &descriptor_table_main_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); +// =================================================================== + +class Input::_Internal { + public: +}; + +Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:Input) +} +Input::Input(const Input& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Input* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_testinputfield().empty()) { + _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:Input) +} + +inline void Input::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Input::~Input() { + // @@protoc_insertion_point(destructor:Input) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Input::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testinputfield_.Destroy(); +} + +void Input::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Input::Clear() { +// @@protoc_insertion_point(message_clear_start:Input) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_.ClearToEmpty(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // string testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + auto str = _internal_mutable_testinputfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "Input.testInputField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Input::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:Input) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "Input.testInputField"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_testinputfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:Input) + return target; +} + +::size_t Input::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:Input) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_testinputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Input::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } + + +void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:Input) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_testinputfield().empty()) { + _this->_internal_set_testinputfield(from._internal_testinputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Input::CopyFrom(const Input& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:Input) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Input::IsInitialized() const { + return true; +} + +void Input::InternalSwap(Input* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.testinputfield_, lhs_arena, + &other->_impl_.testinputfield_, rhs_arena + ); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[0]); +} +// =================================================================== + +class Output::_Internal { + public: +}; + +Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:Output) +} +Output::Output(const Output& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Output* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) {} + + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_secondfield().empty()) { + _this->_impl_.secondfield_.Set(from._internal_secondfield(), + _this->GetArenaForAllocation()); + } + _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; + // @@protoc_insertion_point(copy_constructor:Output) +} + +inline void Output::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) { 0 } + + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Output::~Output() { + // @@protoc_insertion_point(destructor:Output) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Output::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.secondfield_.Destroy(); +} + +void Output::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Output::Clear() { +// @@protoc_insertion_point(message_clear_start:Output) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.secondfield_.ClearToEmpty(); + _impl_.testoutputfield_ = 0; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // int32 testOutputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { + _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + // string secondField = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { + auto str = _internal_mutable_secondfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "Output.secondField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Output::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:Output) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray( + 1, this->_internal_testoutputfield(), target); + } + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "Output.secondField"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_secondfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:Output) + return target; +} + +::size_t Output::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:Output) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_secondfield()); + } + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( + this->_internal_testoutputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Output::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } + + +void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:Output) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_secondfield().empty()) { + _this->_internal_set_secondfield(from._internal_secondfield()); + } + if (from._internal_testoutputfield() != 0) { + _this->_internal_set_testoutputfield(from._internal_testoutputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Output::CopyFrom(const Output& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:Output) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Output::IsInitialized() const { + return true; +} + +void Output::InternalSwap(Output* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.secondfield_, lhs_arena, + &other->_impl_.secondfield_, rhs_arena + ); + + swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::Input* +Arena::CreateMaybeMessage< ::Input >(Arena* arena) { + return Arena::CreateMessageInternal< ::Input >(arena); +} +template<> PROTOBUF_NOINLINE ::Output* +Arena::CreateMaybeMessage< ::Output >(Arena* arena) { + return Arena::CreateMessageInternal< ::Output >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.h new file mode 100644 index 00000000000..86d1a04a53e --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.h @@ -0,0 +1,526 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_main_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_main_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_main_2eproto; +class Input; +struct InputDefaultTypeInternal; +extern InputDefaultTypeInternal _Input_default_instance_; +class Output; +struct OutputDefaultTypeInternal; +extern OutputDefaultTypeInternal _Output_default_instance_; +PROTOBUF_NAMESPACE_OPEN +template <> +::Input* Arena::CreateMaybeMessage<::Input>(Arena*); +template <> +::Output* Arena::CreateMaybeMessage<::Output>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + + +// =================================================================== + + +// ------------------------------------------------------------------- + +class Input final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { + public: + inline Input() : Input(nullptr) {} + ~Input() override; + explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Input(const Input& from); + Input(Input&& from) noexcept + : Input() { + *this = ::std::move(from); + } + + inline Input& operator=(const Input& from) { + CopyFrom(from); + return *this; + } + inline Input& operator=(Input&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Input& default_instance() { + return *internal_default_instance(); + } + static inline const Input* internal_default_instance() { + return reinterpret_cast( + &_Input_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Input& a, Input& b) { + a.Swap(&b); + } + inline void Swap(Input* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Input* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Input& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Input& from) { + Input::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Input* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "Input"; + } + protected: + explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + }; + // string testInputField = 1; + void clear_testinputfield() ; + const std::string& testinputfield() const; + template + void set_testinputfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_testinputfield(); + PROTOBUF_NODISCARD std::string* release_testinputfield(); + void set_allocated_testinputfield(std::string* testinputfield); + private: + const std::string& _internal_testinputfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); + std::string* _internal_mutable_testinputfield(); + public: + // @@protoc_insertion_point(class_scope:Input) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +};// ------------------------------------------------------------------- + +class Output final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Output) */ { + public: + inline Output() : Output(nullptr) {} + ~Output() override; + explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Output(const Output& from); + Output(Output&& from) noexcept + : Output() { + *this = ::std::move(from); + } + + inline Output& operator=(const Output& from) { + CopyFrom(from); + return *this; + } + inline Output& operator=(Output&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Output& default_instance() { + return *internal_default_instance(); + } + static inline const Output* internal_default_instance() { + return reinterpret_cast( + &_Output_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(Output& a, Output& b) { + a.Swap(&b); + } + inline void Swap(Output* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Output* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Output& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Output& from) { + Output::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Output* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "Output"; + } + protected: + explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kSecondFieldFieldNumber = 2, + kTestOutputFieldFieldNumber = 1, + }; + // string secondField = 2; + void clear_secondfield() ; + const std::string& secondfield() const; + template + void set_secondfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_secondfield(); + PROTOBUF_NODISCARD std::string* release_secondfield(); + void set_allocated_secondfield(std::string* secondfield); + private: + const std::string& _internal_secondfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); + std::string* _internal_mutable_secondfield(); + public: + // int32 testOutputField = 1; + void clear_testoutputfield() ; + ::int32_t testoutputfield() const; + void set_testoutputfield(::int32_t value); + + private: + ::int32_t _internal_testoutputfield() const; + void _internal_set_testoutputfield(::int32_t value); + + public: + // @@protoc_insertion_point(class_scope:Output) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; + ::int32_t testoutputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// Input + +// string testInputField = 1; +inline void Input::clear_testinputfield() { + _impl_.testinputfield_.ClearToEmpty(); +} +inline const std::string& Input::testinputfield() const { + // @@protoc_insertion_point(field_get:Input.testInputField) + return _internal_testinputfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { + + _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:Input.testInputField) +} +inline std::string* Input::mutable_testinputfield() { + std::string* _s = _internal_mutable_testinputfield(); + // @@protoc_insertion_point(field_mutable:Input.testInputField) + return _s; +} +inline const std::string& Input::_internal_testinputfield() const { + return _impl_.testinputfield_.Get(); +} +inline void Input::_internal_set_testinputfield(const std::string& value) { + + _impl_.testinputfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Input::_internal_mutable_testinputfield() { + + return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Input::release_testinputfield() { + // @@protoc_insertion_point(field_release:Input.testInputField) + return _impl_.testinputfield_.Release(); +} +inline void Input::set_allocated_testinputfield(std::string* testinputfield) { + _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.testinputfield_.IsDefault()) { + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:Input.testInputField) +} + +// ------------------------------------------------------------------- + +// Output + +// int32 testOutputField = 1; +inline void Output::clear_testoutputfield() { + _impl_.testoutputfield_ = 0; +} +inline ::int32_t Output::testoutputfield() const { + // @@protoc_insertion_point(field_get:Output.testOutputField) + return _internal_testoutputfield(); +} +inline void Output::set_testoutputfield(::int32_t value) { + ; + _internal_set_testoutputfield(value); + // @@protoc_insertion_point(field_set:Output.testOutputField) +} +inline ::int32_t Output::_internal_testoutputfield() const { + return _impl_.testoutputfield_; +} +inline void Output::_internal_set_testoutputfield(::int32_t value) { + ; + _impl_.testoutputfield_ = value; +} + +// string secondField = 2; +inline void Output::clear_secondfield() { + _impl_.secondfield_.ClearToEmpty(); +} +inline const std::string& Output::secondfield() const { + // @@protoc_insertion_point(field_get:Output.secondField) + return _internal_secondfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { + + _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:Output.secondField) +} +inline std::string* Output::mutable_secondfield() { + std::string* _s = _internal_mutable_secondfield(); + // @@protoc_insertion_point(field_mutable:Output.secondField) + return _s; +} +inline const std::string& Output::_internal_secondfield() const { + return _impl_.secondfield_.Get(); +} +inline void Output::_internal_set_secondfield(const std::string& value) { + + _impl_.secondfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Output::_internal_mutable_secondfield() { + + return _impl_.secondfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Output::release_secondfield() { + // @@protoc_insertion_point(field_release:Output.secondField) + return _impl_.secondfield_.Release(); +} +inline void Output::set_allocated_secondfield(std::string* secondfield) { + _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.secondfield_.IsDefault()) { + _impl_.secondfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:Output.secondField) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/streams/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/streams/output/csharp/Main.cs new file mode 100644 index 00000000000..5cbe5d77210 --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/csharp/Main.cs @@ -0,0 +1,460 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +/// Holder for reflection information generated from main.proto +public static partial class MainReflection { + + #region Descriptor + /// File descriptor for main.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MainReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgptYWluLnByb3RvIh8KBUlucHV0EhYKDnRlc3RJbnB1dEZpZWxkGAEgASgJ", + "IjYKBk91dHB1dBIXCg90ZXN0T3V0cHV0RmllbGQYASABKAUSEwoLc2Vjb25k", + "RmllbGQYAiABKAkydAoHU2VydmljZRIdCgZEdXBsZXgSBi5JbnB1dBoHLk91", + "dHB1dCgBMAESFwoCSW4SBi5JbnB1dBoHLk91dHB1dCgBEhgKA091dBIGLklu", + "cHV0GgcuT3V0cHV0MAESFwoETm9uZRIGLklucHV0GgcuT3V0cHV0YgZwcm90", + "bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "TestInputField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Output), global::Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) + })); + } + #endregion + +} +#region Messages +public sealed partial class Input : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input(Input other) : this() { + testInputField_ = other.testInputField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input Clone() { + return new Input(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private string testInputField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string TestInputField { + get { return testInputField_; } + set { + testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Input); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Input other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestInputField != other.TestInputField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestInputField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Input other) { + if (other == null) { + return; + } + if (other.TestInputField.Length != 0) { + TestInputField = other.TestInputField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + } + #endif + +} + +public sealed partial class Output : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output(Output other) : this() { + testOutputField_ = other.testOutputField_; + secondField_ = other.secondField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output Clone() { + return new Output(this); + } + + /// Field number for the "testOutputField" field. + public const int TestOutputFieldFieldNumber = 1; + private int testOutputField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int TestOutputField { + get { return testOutputField_; } + set { + testOutputField_ = value; + } + } + + /// Field number for the "secondField" field. + public const int SecondFieldFieldNumber = 2; + private string secondField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string SecondField { + get { return secondField_; } + set { + secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Output); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Output other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestOutputField != other.TestOutputField) return false; + if (SecondField != other.SecondField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); + if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestOutputField != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); + } + if (SecondField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Output other) { + if (other == null) { + return; + } + if (other.TestOutputField != 0) { + TestOutputField = other.TestOutputField; + } + if (other.SecondField.Length != 0) { + SecondField = other.SecondField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + } + #endif + +} + +#endregion + + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.h new file mode 100644 index 00000000000..12cf27d81f9 --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.h @@ -0,0 +1,83 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - MainRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface MainRoot : GPBRootObject +@end + +#pragma mark - Input + +typedef GPB_ENUM(Input_FieldNumber) { + Input_FieldNumber_TestInputField = 1, +}; + +GPB_FINAL @interface Input : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; + +@end + +#pragma mark - Output + +typedef GPB_ENUM(Output_FieldNumber) { + Output_FieldNumber_TestOutputField = 1, + Output_FieldNumber_SecondField = 2, +}; + +GPB_FINAL @interface Output : GPBMessage + +@property(nonatomic, readwrite) int32_t testOutputField; + +@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.m new file mode 100644 index 00000000000..3d500e82955 --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.m @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "Main.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - MainRoot + +@implementation MainRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - MainRoot_FileDescriptor + +static GPBFileDescriptor *MainRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Input + +@implementation Input + +@dynamic testInputField; + +typedef struct Input__storage_ { + uint32_t _has_storage_[1]; + NSString *testInputField; +} Input__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputField", + .dataTypeSpecific.clazz = Nil, + .number = Input_FieldNumber_TestInputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Input__storage_, testInputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Input class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Input__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\016\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - Output + +@implementation Output + +@dynamic testOutputField; +@dynamic secondField; + +typedef struct Output__storage_ { + uint32_t _has_storage_[1]; + int32_t testOutputField; + NSString *secondField; +} Output__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testOutputField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_TestOutputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Output__storage_, testOutputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeInt32, + }, + { + .name = "secondField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_SecondField, + .hasIndex = 1, + .offset = (uint32_t)offsetof(Output__storage_, secondField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Output class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Output__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\002\001\017\000\002\013\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/streams/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/streams/output/php/GPBMetadata/Main.php new file mode 100644 index 00000000000..54d427533d2 --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/php/GPBMetadata/Main.php @@ -0,0 +1,37 @@ +internalAddGeneratedFile( + ' +� + +main.proto" +Input +testInputField ( "6 +Output +testOutputField ( + secondField ( 2t +Service +Duplex.Input.Output(0 +In.Input.Output( +Out.Input.Output0 +None.Input.Outputbproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/packages/protobuf/test/protoc-out/streams/output/php/Input.php b/packages/protobuf/test/protoc-out/streams/output/php/Input.php new file mode 100644 index 00000000000..b77d7713c23 --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/php/Input.php @@ -0,0 +1,56 @@ +Input + */ +class Input extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string testInputField = 1; + */ + protected $testInputField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $testInputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string testInputField = 1; + * @return string + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field string testInputField = 1; + * @param string $var + * @return $this + */ + public function setTestInputField($var) + { + GPBUtil::checkString($var, True); + $this->testInputField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/streams/output/php/Output.php b/packages/protobuf/test/protoc-out/streams/output/php/Output.php new file mode 100644 index 00000000000..050aef7e894 --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/php/Output.php @@ -0,0 +1,83 @@ +Output + */ +class Output extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field int32 testOutputField = 1; + */ + protected $testOutputField = 0; + /** + * Generated from protobuf field string secondField = 2; + */ + protected $secondField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $testOutputField + * @type string $secondField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @return int + */ + public function getTestOutputField() + { + return $this->testOutputField; + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @param int $var + * @return $this + */ + public function setTestOutputField($var) + { + GPBUtil::checkInt32($var); + $this->testOutputField = $var; + + return $this; + } + + /** + * Generated from protobuf field string secondField = 2; + * @return string + */ + public function getSecondField() + { + return $this->secondField; + } + + /** + * Generated from protobuf field string secondField = 2; + * @param string $var + * @return $this + */ + public function setSecondField($var) + { + GPBUtil::checkString($var, True); + $this->secondField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/streams/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/streams/output/pyi/main_pb2.pyi new file mode 100644 index 00000000000..2683aa8091c --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/pyi/main_pb2.pyi @@ -0,0 +1,19 @@ +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Optional as _Optional + +DESCRIPTOR: _descriptor.FileDescriptor + +class Input(_message.Message): + __slots__ = ["testInputField"] + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testInputField: str + def __init__(self, testInputField: _Optional[str] = ...) -> None: ... + +class Output(_message.Message): + __slots__ = ["testOutputField", "secondField"] + TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] + SECONDFIELD_FIELD_NUMBER: _ClassVar[int] + testOutputField: int + secondField: str + def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/streams/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/streams/output/python/main_pb2.py new file mode 100644 index 00000000000..669a39e5855 --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/python/main_pb2.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\"\x1f\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t2t\n\x07Service\x12\x1d\n\x06\x44uplex\x12\x06.Input\x1a\x07.Output(\x01\x30\x01\x12\x17\n\x02In\x12\x06.Input\x1a\x07.Output(\x01\x12\x18\n\x03Out\x12\x06.Input\x1a\x07.Output0\x01\x12\x17\n\x04None\x12\x06.Input\x1a\x07.Outputb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_INPUT']._serialized_start=14 + _globals['_INPUT']._serialized_end=45 + _globals['_OUTPUT']._serialized_start=47 + _globals['_OUTPUT']._serialized_end=101 + _globals['_SERVICE']._serialized_start=103 + _globals['_SERVICE']._serialized_end=219 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/streams/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/streams/output/ruby/main_pb.rb new file mode 100644 index 00000000000..0766cd00e0c --- /dev/null +++ b/packages/protobuf/test/protoc-out/streams/output/ruby/main_pb.rb @@ -0,0 +1,19 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("main.proto", :syntax => :proto3) do + add_message "Input" do + optional :testInputField, :string, 1 + end + add_message "Output" do + optional :testOutputField, :int32, 1 + optional :secondField, :string, 2 + end + end +end + +Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass +Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Output").msgclass diff --git a/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.cc new file mode 100644 index 00000000000..918d439740f --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.cc @@ -0,0 +1,1120 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#include "main.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; +PROTOBUF_CONSTEXPR InputA::InputA( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} +struct InputADefaultTypeInternal { + PROTOBUF_CONSTEXPR InputADefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputADefaultTypeInternal() {} + union { + InputA _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputADefaultTypeInternal _InputA_default_instance_; +PROTOBUF_CONSTEXPR InputB::InputB( + ::_pbi::ConstantInitialized): _impl_{ + /* ._impl_.testinputfield_ = */ 0u + + , /*decltype(_impl_._cached_size_)*/{}} {} +struct InputBDefaultTypeInternal { + PROTOBUF_CONSTEXPR InputBDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputBDefaultTypeInternal() {} + union { + InputB _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputBDefaultTypeInternal _InputB_default_instance_; +PROTOBUF_CONSTEXPR Input::Input( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.value_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_._oneof_case_)*/{}} {} +struct InputDefaultTypeInternal { + PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~InputDefaultTypeInternal() {} + union { + Input _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; +PROTOBUF_CONSTEXPR Output::Output( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /* ._impl_.testoutputfield_ = */ 0 + + , /*decltype(_impl_._cached_size_)*/{}} {} +struct OutputDefaultTypeInternal { + PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~OutputDefaultTypeInternal() {} + union { + Output _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; +static ::_pb::Metadata file_level_metadata_main_2eproto[4]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_main_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_main_2eproto = nullptr; +const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::InputA, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::InputA, _impl_.testinputfield_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::InputB, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::InputB, _impl_.testinputfield_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), + ~0u, // no _extensions_ + PROTOBUF_FIELD_OFFSET(::Input, _impl_._oneof_case_[0]), + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + ::_pbi::kInvalidFieldOffsetTag, + ::_pbi::kInvalidFieldOffsetTag, + PROTOBUF_FIELD_OFFSET(::Input, _impl_.value_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::Output, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::Output, _impl_.testoutputfield_), + PROTOBUF_FIELD_OFFSET(::Output, _impl_.secondfield_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::InputA)}, + { 9, -1, -1, sizeof(::InputB)}, + { 18, -1, -1, sizeof(::Input)}, + { 29, -1, -1, sizeof(::Output)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_InputA_default_instance_._instance, + &::_InputB_default_instance_._instance, + &::_Input_default_instance_._instance, + &::_Output_default_instance_._instance, +}; +const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\nmain.proto\" \n\006InputA\022\026\n\016testInputField" + "\030\001 \001(\t\" \n\006InputB\022\026\n\016testInputField\030\001 \001(\r" + "\"<\n\005Input\022\024\n\001a\030\001 \001(\0132\007.InputAH\000\022\024\n\001b\030\002 \001" + "(\0132\007.InputBH\000B\007\n\005value\"6\n\006Output\022\027\n\017test" + "OutputField\030\001 \001(\005\022\023\n\013secondField\030\002 \001(\t2!" + "\n\007Service\022\026\n\003Foo\022\006.Input\032\007.Outputb\006proto" + "3" +}; +static ::absl::once_flag descriptor_table_main_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { + false, + false, + 241, + descriptor_table_protodef_main_2eproto, + "main.proto", + &descriptor_table_main_2eproto_once, + nullptr, + 0, + 4, + schemas, + file_default_instances, + TableStruct_main_2eproto::offsets, + file_level_metadata_main_2eproto, + file_level_enum_descriptors_main_2eproto, + file_level_service_descriptors_main_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { + return &descriptor_table_main_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); +// =================================================================== + +class InputA::_Internal { + public: +}; + +InputA::InputA(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:InputA) +} +InputA::InputA(const InputA& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + InputA* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_testinputfield().empty()) { + _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), + _this->GetArenaForAllocation()); + } + // @@protoc_insertion_point(copy_constructor:InputA) +} + +inline void InputA::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.testinputfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +InputA::~InputA() { + // @@protoc_insertion_point(destructor:InputA) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void InputA::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.testinputfield_.Destroy(); +} + +void InputA::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void InputA::Clear() { +// @@protoc_insertion_point(message_clear_start:InputA) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_.ClearToEmpty(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* InputA::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // string testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + auto str = _internal_mutable_testinputfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "InputA.testInputField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* InputA::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:InputA) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "InputA.testInputField"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_testinputfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:InputA) + return target; +} + +::size_t InputA::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:InputA) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string testInputField = 1; + if (!this->_internal_testinputfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_testinputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData InputA::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + InputA::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*InputA::GetClassData() const { return &_class_data_; } + + +void InputA::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:InputA) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_testinputfield().empty()) { + _this->_internal_set_testinputfield(from._internal_testinputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void InputA::CopyFrom(const InputA& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:InputA) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool InputA::IsInitialized() const { + return true; +} + +void InputA::InternalSwap(InputA* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.testinputfield_, lhs_arena, + &other->_impl_.testinputfield_, rhs_arena + ); +} + +::PROTOBUF_NAMESPACE_ID::Metadata InputA::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[0]); +} +// =================================================================== + +class InputB::_Internal { + public: +}; + +InputB::InputB(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:InputB) +} +InputB::InputB(const InputB& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>( + from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:InputB) +} + +inline void InputB::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.testinputfield_) { 0u } + + , /*decltype(_impl_._cached_size_)*/{} + }; +} + +InputB::~InputB() { + // @@protoc_insertion_point(destructor:InputB) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void InputB::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); +} + +void InputB::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void InputB::Clear() { +// @@protoc_insertion_point(message_clear_start:InputB) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.testinputfield_ = 0u; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* InputB::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // uint32 testInputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { + _impl_.testinputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* InputB::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:InputB) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // uint32 testInputField = 1; + if (this->_internal_testinputfield() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray( + 1, this->_internal_testinputfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:InputB) + return target; +} + +::size_t InputB::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:InputB) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // uint32 testInputField = 1; + if (this->_internal_testinputfield() != 0) { + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne( + this->_internal_testinputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData InputB::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + InputB::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*InputB::GetClassData() const { return &_class_data_; } + + +void InputB::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:InputB) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_testinputfield() != 0) { + _this->_internal_set_testinputfield(from._internal_testinputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void InputB::CopyFrom(const InputB& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:InputB) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool InputB::IsInitialized() const { + return true; +} + +void InputB::InternalSwap(InputB* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + + swap(_impl_.testinputfield_, other->_impl_.testinputfield_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata InputB::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[1]); +} +// =================================================================== + +class Input::_Internal { + public: + static constexpr ::int32_t kOneofCaseOffset = + PROTOBUF_FIELD_OFFSET(::Input, _impl_._oneof_case_); + static const ::InputA& a(const Input* msg); + static const ::InputB& b(const Input* msg); +}; + +const ::InputA& +Input::_Internal::a(const Input* msg) { + return *msg->_impl_.value_.a_; +} +const ::InputB& +Input::_Internal::b(const Input* msg) { + return *msg->_impl_.value_.b_; +} +void Input::set_allocated_a(::InputA* a) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + clear_value(); + if (a) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(a); + if (message_arena != submessage_arena) { + a = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, a, submessage_arena); + } + set_has_a(); + _impl_.value_.a_ = a; + } + // @@protoc_insertion_point(field_set_allocated:Input.a) +} +void Input::set_allocated_b(::InputB* b) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + clear_value(); + if (b) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(b); + if (message_arena != submessage_arena) { + b = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, b, submessage_arena); + } + set_has_b(); + _impl_.value_.b_ = b; + } + // @@protoc_insertion_point(field_set_allocated:Input.b) +} +Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:Input) +} +Input::Input(const Input& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Input* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_._oneof_case_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + clear_has_value(); + switch (from.value_case()) { + case kA: { + _this->_internal_mutable_a()->::InputA::MergeFrom( + from._internal_a()); + break; + } + case kB: { + _this->_internal_mutable_b()->::InputB::MergeFrom( + from._internal_b()); + break; + } + case VALUE_NOT_SET: { + break; + } + } + // @@protoc_insertion_point(copy_constructor:Input) +} + +inline void Input::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_._oneof_case_)*/{} + }; + clear_has_value(); +} + +Input::~Input() { + // @@protoc_insertion_point(destructor:Input) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Input::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + if (has_value()) { + clear_value(); + } +} + +void Input::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Input::clear_value() { +// @@protoc_insertion_point(one_of_clear_start:Input) + switch (value_case()) { + case kA: { + if (GetArenaForAllocation() == nullptr) { + delete _impl_.value_.a_; + } + break; + } + case kB: { + if (GetArenaForAllocation() == nullptr) { + delete _impl_.value_.b_; + } + break; + } + case VALUE_NOT_SET: { + break; + } + } + _impl_._oneof_case_[0] = VALUE_NOT_SET; +} + + +void Input::Clear() { +// @@protoc_insertion_point(message_clear_start:Input) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + clear_value(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // .InputA a = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_a(), ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + // .InputB b = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { + ptr = ctx->ParseMessage(_internal_mutable_b(), ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Input::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:Input) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // .InputA a = 1; + if (value_case() == kA) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::a(this), + _Internal::a(this).GetCachedSize(), target, stream); + } + + // .InputB b = 2; + if (value_case() == kB) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, _Internal::b(this), + _Internal::b(this).GetCachedSize(), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:Input) + return target; +} + +::size_t Input::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:Input) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + switch (value_case()) { + // .InputA a = 1; + case kA: { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.value_.a_); + break; + } + // .InputB b = 2; + case kB: { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.value_.b_); + break; + } + case VALUE_NOT_SET: { + break; + } + } + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Input::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } + + +void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:Input) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + switch (from.value_case()) { + case kA: { + _this->_internal_mutable_a()->::InputA::MergeFrom( + from._internal_a()); + break; + } + case kB: { + _this->_internal_mutable_b()->::InputB::MergeFrom( + from._internal_b()); + break; + } + case VALUE_NOT_SET: { + break; + } + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Input::CopyFrom(const Input& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:Input) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Input::IsInitialized() const { + return true; +} + +void Input::InternalSwap(Input* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_.value_, other->_impl_.value_); + swap(_impl_._oneof_case_[0], other->_impl_._oneof_case_[0]); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[2]); +} +// =================================================================== + +class Output::_Internal { + public: +}; + +Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:Output) +} +Output::Output(const Output& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Output* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) {} + + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_secondfield().empty()) { + _this->_impl_.secondfield_.Set(from._internal_secondfield(), + _this->GetArenaForAllocation()); + } + _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; + // @@protoc_insertion_point(copy_constructor:Output) +} + +inline void Output::SharedCtor(::_pb::Arena* arena) { + (void)arena; + new (&_impl_) Impl_{ + decltype(_impl_.secondfield_){} + , decltype(_impl_.testoutputfield_) { 0 } + + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.secondfield_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.secondfield_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Output::~Output() { + // @@protoc_insertion_point(destructor:Output) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Output::SharedDtor() { + ABSL_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.secondfield_.Destroy(); +} + +void Output::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Output::Clear() { +// @@protoc_insertion_point(message_clear_start:Output) + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.secondfield_.ClearToEmpty(); + _impl_.testoutputfield_ = 0; + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // int32 testOutputField = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { + _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; + // string secondField = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { + auto str = _internal_mutable_secondfield(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "Output.secondField")); + } else { + goto handle_unusual; + } + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +::uint8_t* Output::_InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:Output) + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray( + 1, this->_internal_testoutputfield(), target); + } + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "Output.secondField"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_secondfield(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:Output) + return target; +} + +::size_t Output::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:Output) + ::size_t total_size = 0; + + ::uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string secondField = 2; + if (!this->_internal_secondfield().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_secondfield()); + } + + // int32 testOutputField = 1; + if (this->_internal_testoutputfield() != 0) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( + this->_internal_testoutputfield()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Output::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } + + +void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:Output) + ABSL_DCHECK_NE(&from, _this); + ::uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_secondfield().empty()) { + _this->_internal_set_secondfield(from._internal_secondfield()); + } + if (from._internal_testoutputfield() != 0) { + _this->_internal_set_testoutputfield(from._internal_testoutputfield()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Output::CopyFrom(const Output& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:Output) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Output::IsInitialized() const { + return true; +} + +void Output::InternalSwap(Output* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.secondfield_, lhs_arena, + &other->_impl_.secondfield_, rhs_arena + ); + + swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, + file_level_metadata_main_2eproto[3]); +} +// @@protoc_insertion_point(namespace_scope) +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::InputA* +Arena::CreateMaybeMessage< ::InputA >(Arena* arena) { + return Arena::CreateMessageInternal< ::InputA >(arena); +} +template<> PROTOBUF_NOINLINE ::InputB* +Arena::CreateMaybeMessage< ::InputB >(Arena* arena) { + return Arena::CreateMessageInternal< ::InputB >(arena); +} +template<> PROTOBUF_NOINLINE ::Input* +Arena::CreateMaybeMessage< ::Input >(Arena* arena) { + return Arena::CreateMessageInternal< ::Input >(arena); +} +template<> PROTOBUF_NOINLINE ::Output* +Arena::CreateMaybeMessage< ::Output >(Arena* arena) { + return Arena::CreateMessageInternal< ::Output >(arena); +} +PROTOBUF_NAMESPACE_CLOSE +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.h new file mode 100644 index 00000000000..6e4650a5c08 --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.h @@ -0,0 +1,1063 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh + +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4022000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_main_2eproto + +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_main_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_main_2eproto; +class Input; +struct InputDefaultTypeInternal; +extern InputDefaultTypeInternal _Input_default_instance_; +class InputA; +struct InputADefaultTypeInternal; +extern InputADefaultTypeInternal _InputA_default_instance_; +class InputB; +struct InputBDefaultTypeInternal; +extern InputBDefaultTypeInternal _InputB_default_instance_; +class Output; +struct OutputDefaultTypeInternal; +extern OutputDefaultTypeInternal _Output_default_instance_; +PROTOBUF_NAMESPACE_OPEN +template <> +::Input* Arena::CreateMaybeMessage<::Input>(Arena*); +template <> +::InputA* Arena::CreateMaybeMessage<::InputA>(Arena*); +template <> +::InputB* Arena::CreateMaybeMessage<::InputB>(Arena*); +template <> +::Output* Arena::CreateMaybeMessage<::Output>(Arena*); +PROTOBUF_NAMESPACE_CLOSE + + +// =================================================================== + + +// ------------------------------------------------------------------- + +class InputA final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:InputA) */ { + public: + inline InputA() : InputA(nullptr) {} + ~InputA() override; + explicit PROTOBUF_CONSTEXPR InputA(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + InputA(const InputA& from); + InputA(InputA&& from) noexcept + : InputA() { + *this = ::std::move(from); + } + + inline InputA& operator=(const InputA& from) { + CopyFrom(from); + return *this; + } + inline InputA& operator=(InputA&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const InputA& default_instance() { + return *internal_default_instance(); + } + static inline const InputA* internal_default_instance() { + return reinterpret_cast( + &_InputA_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(InputA& a, InputA& b) { + a.Swap(&b); + } + inline void Swap(InputA* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(InputA* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + InputA* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const InputA& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const InputA& from) { + InputA::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(InputA* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "InputA"; + } + protected: + explicit InputA(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + }; + // string testInputField = 1; + void clear_testinputfield() ; + const std::string& testinputfield() const; + template + void set_testinputfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_testinputfield(); + PROTOBUF_NODISCARD std::string* release_testinputfield(); + void set_allocated_testinputfield(std::string* testinputfield); + private: + const std::string& _internal_testinputfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); + std::string* _internal_mutable_testinputfield(); + public: + // @@protoc_insertion_point(class_scope:InputA) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +};// ------------------------------------------------------------------- + +class InputB final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:InputB) */ { + public: + inline InputB() : InputB(nullptr) {} + ~InputB() override; + explicit PROTOBUF_CONSTEXPR InputB(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + InputB(const InputB& from); + InputB(InputB&& from) noexcept + : InputB() { + *this = ::std::move(from); + } + + inline InputB& operator=(const InputB& from) { + CopyFrom(from); + return *this; + } + inline InputB& operator=(InputB&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const InputB& default_instance() { + return *internal_default_instance(); + } + static inline const InputB* internal_default_instance() { + return reinterpret_cast( + &_InputB_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(InputB& a, InputB& b) { + a.Swap(&b); + } + inline void Swap(InputB* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(InputB* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + InputB* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const InputB& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const InputB& from) { + InputB::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(InputB* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "InputB"; + } + protected: + explicit InputB(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTestInputFieldFieldNumber = 1, + }; + // uint32 testInputField = 1; + void clear_testinputfield() ; + ::uint32_t testinputfield() const; + void set_testinputfield(::uint32_t value); + + private: + ::uint32_t _internal_testinputfield() const; + void _internal_set_testinputfield(::uint32_t value); + + public: + // @@protoc_insertion_point(class_scope:InputB) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::uint32_t testinputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +};// ------------------------------------------------------------------- + +class Input final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { + public: + inline Input() : Input(nullptr) {} + ~Input() override; + explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Input(const Input& from); + Input(Input&& from) noexcept + : Input() { + *this = ::std::move(from); + } + + inline Input& operator=(const Input& from) { + CopyFrom(from); + return *this; + } + inline Input& operator=(Input&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Input& default_instance() { + return *internal_default_instance(); + } + enum ValueCase { + kA = 1, + kB = 2, + VALUE_NOT_SET = 0, + }; + + static inline const Input* internal_default_instance() { + return reinterpret_cast( + &_Input_default_instance_); + } + static constexpr int kIndexInFileMessages = + 2; + + friend void swap(Input& a, Input& b) { + a.Swap(&b); + } + inline void Swap(Input* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Input* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Input& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Input& from) { + Input::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Input* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "Input"; + } + protected: + explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kAFieldNumber = 1, + kBFieldNumber = 2, + }; + // .InputA a = 1; + bool has_a() const; + private: + bool _internal_has_a() const; + + public: + void clear_a() ; + const ::InputA& a() const; + PROTOBUF_NODISCARD ::InputA* release_a(); + ::InputA* mutable_a(); + void set_allocated_a(::InputA* a); + private: + const ::InputA& _internal_a() const; + ::InputA* _internal_mutable_a(); + public: + void unsafe_arena_set_allocated_a( + ::InputA* a); + ::InputA* unsafe_arena_release_a(); + // .InputB b = 2; + bool has_b() const; + private: + bool _internal_has_b() const; + + public: + void clear_b() ; + const ::InputB& b() const; + PROTOBUF_NODISCARD ::InputB* release_b(); + ::InputB* mutable_b(); + void set_allocated_b(::InputB* b); + private: + const ::InputB& _internal_b() const; + ::InputB* _internal_mutable_b(); + public: + void unsafe_arena_set_allocated_b( + ::InputB* b); + ::InputB* unsafe_arena_release_b(); + void clear_value(); + ValueCase value_case() const; + // @@protoc_insertion_point(class_scope:Input) + private: + class _Internal; + void set_has_a(); + void set_has_b(); + + inline bool has_value() const; + inline void clear_has_value(); + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + union ValueUnion { + constexpr ValueUnion() : _constinit_{} {} + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; + ::InputA* a_; + ::InputB* b_; + } value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::uint32_t _oneof_case_[1]; + + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +};// ------------------------------------------------------------------- + +class Output final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Output) */ { + public: + inline Output() : Output(nullptr) {} + ~Output() override; + explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Output(const Output& from); + Output(Output&& from) noexcept + : Output() { + *this = ::std::move(from); + } + + inline Output& operator=(const Output& from) { + CopyFrom(from); + return *this; + } + inline Output& operator=(Output&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Output& default_instance() { + return *internal_default_instance(); + } + static inline const Output* internal_default_instance() { + return reinterpret_cast( + &_Output_default_instance_); + } + static constexpr int kIndexInFileMessages = + 3; + + friend void swap(Output& a, Output& b) { + a.Swap(&b); + } + inline void Swap(Output* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Output* other) { + if (other == this) return; + ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Output& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Output& from) { + Output::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + ::size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::uint8_t* _InternalSerialize( + ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Output* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "Output"; + } + protected: + explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kSecondFieldFieldNumber = 2, + kTestOutputFieldFieldNumber = 1, + }; + // string secondField = 2; + void clear_secondfield() ; + const std::string& secondfield() const; + template + void set_secondfield(ArgT0&& arg0, ArgT... args); + std::string* mutable_secondfield(); + PROTOBUF_NODISCARD std::string* release_secondfield(); + void set_allocated_secondfield(std::string* secondfield); + private: + const std::string& _internal_secondfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); + std::string* _internal_mutable_secondfield(); + public: + // int32 testOutputField = 1; + void clear_testoutputfield() ; + ::int32_t testoutputfield() const; + void set_testoutputfield(::int32_t value); + + private: + ::int32_t _internal_testoutputfield() const; + void _internal_set_testoutputfield(::int32_t value); + + public: + // @@protoc_insertion_point(class_scope:Output) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; + ::int32_t testoutputfield_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_main_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// InputA + +// string testInputField = 1; +inline void InputA::clear_testinputfield() { + _impl_.testinputfield_.ClearToEmpty(); +} +inline const std::string& InputA::testinputfield() const { + // @@protoc_insertion_point(field_get:InputA.testInputField) + return _internal_testinputfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void InputA::set_testinputfield(ArgT0&& arg0, ArgT... args) { + + _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:InputA.testInputField) +} +inline std::string* InputA::mutable_testinputfield() { + std::string* _s = _internal_mutable_testinputfield(); + // @@protoc_insertion_point(field_mutable:InputA.testInputField) + return _s; +} +inline const std::string& InputA::_internal_testinputfield() const { + return _impl_.testinputfield_.Get(); +} +inline void InputA::_internal_set_testinputfield(const std::string& value) { + + _impl_.testinputfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* InputA::_internal_mutable_testinputfield() { + + return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* InputA::release_testinputfield() { + // @@protoc_insertion_point(field_release:InputA.testInputField) + return _impl_.testinputfield_.Release(); +} +inline void InputA::set_allocated_testinputfield(std::string* testinputfield) { + _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.testinputfield_.IsDefault()) { + _impl_.testinputfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:InputA.testInputField) +} + +// ------------------------------------------------------------------- + +// InputB + +// uint32 testInputField = 1; +inline void InputB::clear_testinputfield() { + _impl_.testinputfield_ = 0u; +} +inline ::uint32_t InputB::testinputfield() const { + // @@protoc_insertion_point(field_get:InputB.testInputField) + return _internal_testinputfield(); +} +inline void InputB::set_testinputfield(::uint32_t value) { + ; + _internal_set_testinputfield(value); + // @@protoc_insertion_point(field_set:InputB.testInputField) +} +inline ::uint32_t InputB::_internal_testinputfield() const { + return _impl_.testinputfield_; +} +inline void InputB::_internal_set_testinputfield(::uint32_t value) { + ; + _impl_.testinputfield_ = value; +} + +// ------------------------------------------------------------------- + +// Input + +// .InputA a = 1; +inline bool Input::has_a() const { + return value_case() == kA; +} +inline bool Input::_internal_has_a() const { + return value_case() == kA; +} +inline void Input::set_has_a() { + _impl_._oneof_case_[0] = kA; +} +inline void Input::clear_a() { + if (value_case() == kA) { + if (GetArenaForAllocation() == nullptr) { + delete _impl_.value_.a_; + } + clear_has_value(); + } +} +inline ::InputA* Input::release_a() { + // @@protoc_insertion_point(field_release:Input.a) + if (value_case() == kA) { + clear_has_value(); + ::InputA* temp = _impl_.value_.a_; + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + _impl_.value_.a_ = nullptr; + return temp; + } else { + return nullptr; + } +} +inline const ::InputA& Input::_internal_a() const { + return value_case() == kA + ? *_impl_.value_.a_ + : reinterpret_cast< ::InputA&>(::_InputA_default_instance_); +} +inline const ::InputA& Input::a() const { + // @@protoc_insertion_point(field_get:Input.a) + return _internal_a(); +} +inline ::InputA* Input::unsafe_arena_release_a() { + // @@protoc_insertion_point(field_unsafe_arena_release:Input.a) + if (value_case() == kA) { + clear_has_value(); + ::InputA* temp = _impl_.value_.a_; + _impl_.value_.a_ = nullptr; + return temp; + } else { + return nullptr; + } +} +inline void Input::unsafe_arena_set_allocated_a(::InputA* a) { + clear_value(); + if (a) { + set_has_a(); + _impl_.value_.a_ = a; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:Input.a) +} +inline ::InputA* Input::_internal_mutable_a() { + if (value_case() != kA) { + clear_value(); + set_has_a(); + _impl_.value_.a_ = CreateMaybeMessage< ::InputA >(GetArenaForAllocation()); + } + return _impl_.value_.a_; +} +inline ::InputA* Input::mutable_a() { + ::InputA* _msg = _internal_mutable_a(); + // @@protoc_insertion_point(field_mutable:Input.a) + return _msg; +} + +// .InputB b = 2; +inline bool Input::has_b() const { + return value_case() == kB; +} +inline bool Input::_internal_has_b() const { + return value_case() == kB; +} +inline void Input::set_has_b() { + _impl_._oneof_case_[0] = kB; +} +inline void Input::clear_b() { + if (value_case() == kB) { + if (GetArenaForAllocation() == nullptr) { + delete _impl_.value_.b_; + } + clear_has_value(); + } +} +inline ::InputB* Input::release_b() { + // @@protoc_insertion_point(field_release:Input.b) + if (value_case() == kB) { + clear_has_value(); + ::InputB* temp = _impl_.value_.b_; + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + _impl_.value_.b_ = nullptr; + return temp; + } else { + return nullptr; + } +} +inline const ::InputB& Input::_internal_b() const { + return value_case() == kB + ? *_impl_.value_.b_ + : reinterpret_cast< ::InputB&>(::_InputB_default_instance_); +} +inline const ::InputB& Input::b() const { + // @@protoc_insertion_point(field_get:Input.b) + return _internal_b(); +} +inline ::InputB* Input::unsafe_arena_release_b() { + // @@protoc_insertion_point(field_unsafe_arena_release:Input.b) + if (value_case() == kB) { + clear_has_value(); + ::InputB* temp = _impl_.value_.b_; + _impl_.value_.b_ = nullptr; + return temp; + } else { + return nullptr; + } +} +inline void Input::unsafe_arena_set_allocated_b(::InputB* b) { + clear_value(); + if (b) { + set_has_b(); + _impl_.value_.b_ = b; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:Input.b) +} +inline ::InputB* Input::_internal_mutable_b() { + if (value_case() != kB) { + clear_value(); + set_has_b(); + _impl_.value_.b_ = CreateMaybeMessage< ::InputB >(GetArenaForAllocation()); + } + return _impl_.value_.b_; +} +inline ::InputB* Input::mutable_b() { + ::InputB* _msg = _internal_mutable_b(); + // @@protoc_insertion_point(field_mutable:Input.b) + return _msg; +} + +inline bool Input::has_value() const { + return value_case() != VALUE_NOT_SET; +} +inline void Input::clear_has_value() { + _impl_._oneof_case_[0] = VALUE_NOT_SET; +} +inline Input::ValueCase Input::value_case() const { + return Input::ValueCase(_impl_._oneof_case_[0]); +} +// ------------------------------------------------------------------- + +// Output + +// int32 testOutputField = 1; +inline void Output::clear_testoutputfield() { + _impl_.testoutputfield_ = 0; +} +inline ::int32_t Output::testoutputfield() const { + // @@protoc_insertion_point(field_get:Output.testOutputField) + return _internal_testoutputfield(); +} +inline void Output::set_testoutputfield(::int32_t value) { + ; + _internal_set_testoutputfield(value); + // @@protoc_insertion_point(field_set:Output.testOutputField) +} +inline ::int32_t Output::_internal_testoutputfield() const { + return _impl_.testoutputfield_; +} +inline void Output::_internal_set_testoutputfield(::int32_t value) { + ; + _impl_.testoutputfield_ = value; +} + +// string secondField = 2; +inline void Output::clear_secondfield() { + _impl_.secondfield_.ClearToEmpty(); +} +inline const std::string& Output::secondfield() const { + // @@protoc_insertion_point(field_get:Output.secondField) + return _internal_secondfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { + + _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:Output.secondField) +} +inline std::string* Output::mutable_secondfield() { + std::string* _s = _internal_mutable_secondfield(); + // @@protoc_insertion_point(field_mutable:Output.secondField) + return _s; +} +inline const std::string& Output::_internal_secondfield() const { + return _impl_.secondfield_.Get(); +} +inline void Output::_internal_set_secondfield(const std::string& value) { + + _impl_.secondfield_.Set(value, GetArenaForAllocation()); +} +inline std::string* Output::_internal_mutable_secondfield() { + + return _impl_.secondfield_.Mutable(GetArenaForAllocation()); +} +inline std::string* Output::release_secondfield() { + // @@protoc_insertion_point(field_release:Output.secondField) + return _impl_.secondfield_.Release(); +} +inline void Output::set_allocated_secondfield(std::string* secondfield) { + _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.secondfield_.IsDefault()) { + _impl_.secondfield_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:Output.secondField) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/union/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/union/output/csharp/Main.cs new file mode 100644 index 00000000000..18c2f46a56c --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/csharp/Main.cs @@ -0,0 +1,936 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: main.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +/// Holder for reflection information generated from main.proto +public static partial class MainReflection { + + #region Descriptor + /// File descriptor for main.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MainReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgptYWluLnByb3RvIiAKBklucHV0QRIWCg50ZXN0SW5wdXRGaWVsZBgBIAEo", + "CSIgCgZJbnB1dEISFgoOdGVzdElucHV0RmllbGQYASABKA0iPAoFSW5wdXQS", + "FAoBYRgBIAEoCzIHLklucHV0QUgAEhQKAWIYAiABKAsyBy5JbnB1dEJIAEIH", + "CgV2YWx1ZSI2CgZPdXRwdXQSFwoPdGVzdE91dHB1dEZpZWxkGAEgASgFEhMK", + "C3NlY29uZEZpZWxkGAIgASgJMiEKB1NlcnZpY2USFgoDRm9vEgYuSW5wdXQa", + "By5PdXRwdXRiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::InputA), global::InputA.Parser, new[]{ "TestInputField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::InputB), global::InputB.Parser, new[]{ "TestInputField" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "A", "B" }, new[]{ "Value" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Output), global::Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) + })); + } + #endregion + +} +#region Messages +public sealed partial class InputA : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new InputA()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public InputA() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public InputA(InputA other) : this() { + testInputField_ = other.testInputField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public InputA Clone() { + return new InputA(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private string testInputField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string TestInputField { + get { return testInputField_; } + set { + testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as InputA); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(InputA other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestInputField != other.TestInputField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestInputField.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestInputField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(InputA other) { + if (other == null) { + return; + } + if (other.TestInputField.Length != 0) { + TestInputField = other.TestInputField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + TestInputField = input.ReadString(); + break; + } + } + } + } + #endif + +} + +public sealed partial class InputB : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new InputB()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public InputB() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public InputB(InputB other) : this() { + testInputField_ = other.testInputField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public InputB Clone() { + return new InputB(this); + } + + /// Field number for the "testInputField" field. + public const int TestInputFieldFieldNumber = 1; + private uint testInputField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public uint TestInputField { + get { return testInputField_; } + set { + testInputField_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as InputB); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(InputB other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestInputField != other.TestInputField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestInputField != 0) hash ^= TestInputField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestInputField != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestInputField != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TestInputField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestInputField != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TestInputField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(InputB other) { + if (other == null) { + return; + } + if (other.TestInputField != 0) { + TestInputField = other.TestInputField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TestInputField = input.ReadUInt32(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TestInputField = input.ReadUInt32(); + break; + } + } + } + } + #endif + +} + +public sealed partial class Input : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input(Input other) : this() { + switch (other.ValueCase) { + case ValueOneofCase.A: + A = other.A.Clone(); + break; + case ValueOneofCase.B: + B = other.B.Clone(); + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Input Clone() { + return new Input(this); + } + + /// Field number for the "a" field. + public const int AFieldNumber = 1; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::InputA A { + get { return valueCase_ == ValueOneofCase.A ? (global::InputA) value_ : null; } + set { + value_ = value; + valueCase_ = value == null ? ValueOneofCase.None : ValueOneofCase.A; + } + } + + /// Field number for the "b" field. + public const int BFieldNumber = 2; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::InputB B { + get { return valueCase_ == ValueOneofCase.B ? (global::InputB) value_ : null; } + set { + value_ = value; + valueCase_ = value == null ? ValueOneofCase.None : ValueOneofCase.B; + } + } + + private object value_; + /// Enum of possible cases for the "value" oneof. + public enum ValueOneofCase { + None = 0, + A = 1, + B = 2, + } + private ValueOneofCase valueCase_ = ValueOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ValueOneofCase ValueCase { + get { return valueCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void ClearValue() { + valueCase_ = ValueOneofCase.None; + value_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Input); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Input other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(A, other.A)) return false; + if (!object.Equals(B, other.B)) return false; + if (ValueCase != other.ValueCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (valueCase_ == ValueOneofCase.A) hash ^= A.GetHashCode(); + if (valueCase_ == ValueOneofCase.B) hash ^= B.GetHashCode(); + hash ^= (int) valueCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (valueCase_ == ValueOneofCase.A) { + output.WriteRawTag(10); + output.WriteMessage(A); + } + if (valueCase_ == ValueOneofCase.B) { + output.WriteRawTag(18); + output.WriteMessage(B); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (valueCase_ == ValueOneofCase.A) { + output.WriteRawTag(10); + output.WriteMessage(A); + } + if (valueCase_ == ValueOneofCase.B) { + output.WriteRawTag(18); + output.WriteMessage(B); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (valueCase_ == ValueOneofCase.A) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(A); + } + if (valueCase_ == ValueOneofCase.B) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(B); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Input other) { + if (other == null) { + return; + } + switch (other.ValueCase) { + case ValueOneofCase.A: + if (A == null) { + A = new global::InputA(); + } + A.MergeFrom(other.A); + break; + case ValueOneofCase.B: + if (B == null) { + B = new global::InputB(); + } + B.MergeFrom(other.B); + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + global::InputA subBuilder = new global::InputA(); + if (valueCase_ == ValueOneofCase.A) { + subBuilder.MergeFrom(A); + } + input.ReadMessage(subBuilder); + A = subBuilder; + break; + } + case 18: { + global::InputB subBuilder = new global::InputB(); + if (valueCase_ == ValueOneofCase.B) { + subBuilder.MergeFrom(B); + } + input.ReadMessage(subBuilder); + B = subBuilder; + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + global::InputA subBuilder = new global::InputA(); + if (valueCase_ == ValueOneofCase.A) { + subBuilder.MergeFrom(A); + } + input.ReadMessage(subBuilder); + A = subBuilder; + break; + } + case 18: { + global::InputB subBuilder = new global::InputB(); + if (valueCase_ == ValueOneofCase.B) { + subBuilder.MergeFrom(B); + } + input.ReadMessage(subBuilder); + B = subBuilder; + break; + } + } + } + } + #endif + +} + +public sealed partial class Output : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif +{ + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::MainReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output(Output other) : this() { + testOutputField_ = other.testOutputField_; + secondField_ = other.secondField_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Output Clone() { + return new Output(this); + } + + /// Field number for the "testOutputField" field. + public const int TestOutputFieldFieldNumber = 1; + private int testOutputField_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int TestOutputField { + get { return testOutputField_; } + set { + testOutputField_ = value; + } + } + + /// Field number for the "secondField" field. + public const int SecondFieldFieldNumber = 2; + private string secondField_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string SecondField { + get { return secondField_; } + set { + secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Output); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Output other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TestOutputField != other.TestOutputField) return false; + if (SecondField != other.SecondField) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); + if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TestOutputField != 0) { + output.WriteRawTag(8); + output.WriteInt32(TestOutputField); + } + if (SecondField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SecondField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (TestOutputField != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); + } + if (SecondField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Output other) { + if (other == null) { + return; + } + if (other.TestOutputField != 0) { + TestOutputField = other.TestOutputField; + } + if (other.SecondField.Length != 0) { + SecondField = other.SecondField; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TestOutputField = input.ReadInt32(); + break; + } + case 18: { + SecondField = input.ReadString(); + break; + } + } + } + } + #endif + +} + +#endregion + + +#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.h new file mode 100644 index 00000000000..301a3249d51 --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.h @@ -0,0 +1,126 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +@class InputA; +@class InputB; + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - MainRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +GPB_FINAL @interface MainRoot : GPBRootObject +@end + +#pragma mark - InputA + +typedef GPB_ENUM(InputA_FieldNumber) { + InputA_FieldNumber_TestInputField = 1, +}; + +GPB_FINAL @interface InputA : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; + +@end + +#pragma mark - InputB + +typedef GPB_ENUM(InputB_FieldNumber) { + InputB_FieldNumber_TestInputField = 1, +}; + +GPB_FINAL @interface InputB : GPBMessage + +@property(nonatomic, readwrite) uint32_t testInputField; + +@end + +#pragma mark - Input + +typedef GPB_ENUM(Input_FieldNumber) { + Input_FieldNumber_A = 1, + Input_FieldNumber_B = 2, +}; + +typedef GPB_ENUM(Input_Value_OneOfCase) { + Input_Value_OneOfCase_GPBUnsetOneOfCase = 0, + Input_Value_OneOfCase_A = 1, + Input_Value_OneOfCase_B = 2, +}; + +GPB_FINAL @interface Input : GPBMessage + +@property(nonatomic, readonly) Input_Value_OneOfCase valueOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) InputA *a; + +@property(nonatomic, readwrite, strong, null_resettable) InputB *b; + +@end + +/** + * Clears whatever value was set for the oneof 'value'. + **/ +void Input_ClearValueOneOfCase(Input *message); + +#pragma mark - Output + +typedef GPB_ENUM(Output_FieldNumber) { + Output_FieldNumber_TestOutputField = 1, + Output_FieldNumber_SecondField = 2, +}; + +GPB_FINAL @interface Output : GPBMessage + +@property(nonatomic, readwrite) int32_t testOutputField; + +@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.m new file mode 100644 index 00000000000..3bdb17df400 --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.m @@ -0,0 +1,285 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// clang-format off +// source: main.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#import "Main.pbobjc.h" +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#pragma clang diagnostic ignored "-Wdirect-ivar-access" +#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension" + +#pragma mark - Objective C Class declarations +// Forward declarations of Objective C classes that we can use as +// static values in struct initializers. +// We don't use [Foo class] because it is not a static value. +GPBObjCClassDeclaration(InputA); +GPBObjCClassDeclaration(InputB); + +#pragma mark - MainRoot + +@implementation MainRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - MainRoot_FileDescriptor + +static GPBFileDescriptor *MainRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - InputA + +@implementation InputA + +@dynamic testInputField; + +typedef struct InputA__storage_ { + uint32_t _has_storage_[1]; + NSString *testInputField; +} InputA__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputField", + .dataTypeSpecific.clazz = Nil, + .number = InputA_FieldNumber_TestInputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(InputA__storage_, testInputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[InputA class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(InputA__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\016\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - InputB + +@implementation InputB + +@dynamic testInputField; + +typedef struct InputB__storage_ { + uint32_t _has_storage_[1]; + uint32_t testInputField; +} InputB__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testInputField", + .dataTypeSpecific.clazz = Nil, + .number = InputB_FieldNumber_TestInputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(InputB__storage_, testInputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeUInt32, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[InputB class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(InputB__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\016\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - Input + +@implementation Input + +@dynamic valueOneOfCase; +@dynamic a; +@dynamic b; + +typedef struct Input__storage_ { + uint32_t _has_storage_[2]; + InputA *a; + InputB *b; +} Input__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "a", + .dataTypeSpecific.clazz = GPBObjCClass(InputA), + .number = Input_FieldNumber_A, + .hasIndex = -1, + .offset = (uint32_t)offsetof(Input__storage_, a), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "b", + .dataTypeSpecific.clazz = GPBObjCClass(InputB), + .number = Input_FieldNumber_B, + .hasIndex = -1, + .offset = (uint32_t)offsetof(Input__storage_, b), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Input class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Input__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; + static const char *oneofs[] = { + "value", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void Input_ClearValueOneOfCase(Input *message) { + GPBDescriptor *descriptor = [Input descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - Output + +@implementation Output + +@dynamic testOutputField; +@dynamic secondField; + +typedef struct Output__storage_ { + uint32_t _has_storage_[1]; + int32_t testOutputField; + NSString *secondField; +} Output__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "testOutputField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_TestOutputField, + .hasIndex = 0, + .offset = (uint32_t)offsetof(Output__storage_, testOutputField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeInt32, + }, + { + .name = "secondField", + .dataTypeSpecific.clazz = Nil, + .number = Output_FieldNumber_SecondField, + .hasIndex = 1, + .offset = (uint32_t)offsetof(Output__storage_, secondField), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[Output class] + file:MainRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(Output__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\002\001\017\000\002\013\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) + +// clang-format on diff --git a/packages/protobuf/test/protoc-out/union/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/union/output/php/GPBMetadata/Main.php new file mode 100644 index 0000000000000000000000000000000000000000..cdd2159e81dc49e8ba1bee3ca6520edef9aa4548 GIT binary patch literal 729 zcmZ{iL2DZ^5QXCw+hjso*p@c*G;ssjK?X*X;FA-b$Iy!YnQXitBd8v~zlMv5%+RABxW{SBe9+H0;Q=2cmeMXuLINU}r3 z$pU{ZuJC*^zuFI0rz^`T!!;9XSla*;Taz=46V8_7OY*E>o}B=2$(+N>poIT`VVNqI zf}``yhtGj(f+_EcQCs zNw-_Y_yxu8;1s&GD|rtcR=akN`@<&oVk=hjy;mWtt&T6Y#(n7CGFj2!JM3|j9J^q`_TVQ_EvBTV6UfIC%vZUr~a^s$b0qQ^X;%5!Ix&T RPafjMN2ry}yf?4`xCf(5)1UwV literal 0 HcmV?d00001 diff --git a/packages/protobuf/test/protoc-out/union/output/php/Input.php b/packages/protobuf/test/protoc-out/union/output/php/Input.php new file mode 100644 index 00000000000..b79189675b7 --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/php/Input.php @@ -0,0 +1,94 @@ +Input + */ +class Input extends \Google\Protobuf\Internal\Message +{ + protected $value; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \InputA $a + * @type \InputB $b + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .InputA a = 1; + * @return \InputA|null + */ + public function getA() + { + return $this->readOneof(1); + } + + public function hasA() + { + return $this->hasOneof(1); + } + + /** + * Generated from protobuf field .InputA a = 1; + * @param \InputA $var + * @return $this + */ + public function setA($var) + { + GPBUtil::checkMessage($var, \InputA::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Generated from protobuf field .InputB b = 2; + * @return \InputB|null + */ + public function getB() + { + return $this->readOneof(2); + } + + public function hasB() + { + return $this->hasOneof(2); + } + + /** + * Generated from protobuf field .InputB b = 2; + * @param \InputB $var + * @return $this + */ + public function setB($var) + { + GPBUtil::checkMessage($var, \InputB::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * @return string + */ + public function getValue() + { + return $this->whichOneof("value"); + } + +} + diff --git a/packages/protobuf/test/protoc-out/union/output/php/InputA.php b/packages/protobuf/test/protoc-out/union/output/php/InputA.php new file mode 100644 index 00000000000..c325ab1b725 --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/php/InputA.php @@ -0,0 +1,56 @@ +InputA + */ +class InputA extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string testInputField = 1; + */ + protected $testInputField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $testInputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string testInputField = 1; + * @return string + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field string testInputField = 1; + * @param string $var + * @return $this + */ + public function setTestInputField($var) + { + GPBUtil::checkString($var, True); + $this->testInputField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/union/output/php/InputB.php b/packages/protobuf/test/protoc-out/union/output/php/InputB.php new file mode 100644 index 00000000000..ed041182348 --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/php/InputB.php @@ -0,0 +1,56 @@ +InputB + */ +class InputB extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field uint32 testInputField = 1; + */ + protected $testInputField = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $testInputField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field uint32 testInputField = 1; + * @return int + */ + public function getTestInputField() + { + return $this->testInputField; + } + + /** + * Generated from protobuf field uint32 testInputField = 1; + * @param int $var + * @return $this + */ + public function setTestInputField($var) + { + GPBUtil::checkUint32($var); + $this->testInputField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/union/output/php/Output.php b/packages/protobuf/test/protoc-out/union/output/php/Output.php new file mode 100644 index 00000000000..050aef7e894 --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/php/Output.php @@ -0,0 +1,83 @@ +Output + */ +class Output extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field int32 testOutputField = 1; + */ + protected $testOutputField = 0; + /** + * Generated from protobuf field string secondField = 2; + */ + protected $secondField = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $testOutputField + * @type string $secondField + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Main::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @return int + */ + public function getTestOutputField() + { + return $this->testOutputField; + } + + /** + * Generated from protobuf field int32 testOutputField = 1; + * @param int $var + * @return $this + */ + public function setTestOutputField($var) + { + GPBUtil::checkInt32($var); + $this->testOutputField = $var; + + return $this; + } + + /** + * Generated from protobuf field string secondField = 2; + * @return string + */ + public function getSecondField() + { + return $this->secondField; + } + + /** + * Generated from protobuf field string secondField = 2; + * @param string $var + * @return $this + */ + public function setSecondField($var) + { + GPBUtil::checkString($var, True); + $this->secondField = $var; + + return $this; + } + +} + diff --git a/packages/protobuf/test/protoc-out/union/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/union/output/pyi/main_pb2.pyi new file mode 100644 index 00000000000..41246f5296a --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/pyi/main_pb2.pyi @@ -0,0 +1,33 @@ +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class InputA(_message.Message): + __slots__ = ["testInputField"] + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testInputField: str + def __init__(self, testInputField: _Optional[str] = ...) -> None: ... + +class InputB(_message.Message): + __slots__ = ["testInputField"] + TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] + testInputField: int + def __init__(self, testInputField: _Optional[int] = ...) -> None: ... + +class Input(_message.Message): + __slots__ = ["a", "b"] + A_FIELD_NUMBER: _ClassVar[int] + B_FIELD_NUMBER: _ClassVar[int] + a: InputA + b: InputB + def __init__(self, a: _Optional[_Union[InputA, _Mapping]] = ..., b: _Optional[_Union[InputB, _Mapping]] = ...) -> None: ... + +class Output(_message.Message): + __slots__ = ["testOutputField", "secondField"] + TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] + SECONDFIELD_FIELD_NUMBER: _ClassVar[int] + testOutputField: int + secondField: str + def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/union/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/union/output/python/main_pb2.py new file mode 100644 index 00000000000..f2cb1b8e789 --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/python/main_pb2.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\" \n\x06InputA\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\" \n\x06InputB\x12\x16\n\x0etestInputField\x18\x01 \x01(\r\"<\n\x05Input\x12\x14\n\x01\x61\x18\x01 \x01(\x0b\x32\x07.InputAH\x00\x12\x14\n\x01\x62\x18\x02 \x01(\x0b\x32\x07.InputBH\x00\x42\x07\n\x05value\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t2!\n\x07Service\x12\x16\n\x03\x46oo\x12\x06.Input\x1a\x07.Outputb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _globals['_INPUTA']._serialized_start=14 + _globals['_INPUTA']._serialized_end=46 + _globals['_INPUTB']._serialized_start=48 + _globals['_INPUTB']._serialized_end=80 + _globals['_INPUT']._serialized_start=82 + _globals['_INPUT']._serialized_end=142 + _globals['_OUTPUT']._serialized_start=144 + _globals['_OUTPUT']._serialized_end=198 + _globals['_SERVICE']._serialized_start=200 + _globals['_SERVICE']._serialized_end=233 +# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/union/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/union/output/ruby/main_pb.rb new file mode 100644 index 00000000000..3a2f4b5718b --- /dev/null +++ b/packages/protobuf/test/protoc-out/union/output/ruby/main_pb.rb @@ -0,0 +1,30 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: main.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("main.proto", :syntax => :proto3) do + add_message "InputA" do + optional :testInputField, :string, 1 + end + add_message "InputB" do + optional :testInputField, :uint32, 1 + end + add_message "Input" do + oneof :value do + optional :a, :message, 1, "InputA" + optional :b, :message, 2, "InputB" + end + end + add_message "Output" do + optional :testOutputField, :int32, 1 + optional :secondField, :string, 2 + end + end +end + +InputA = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("InputA").msgclass +InputB = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("InputB").msgclass +Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass +Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Output").msgclass diff --git a/packages/protobuf/test/scenarios.spec.ts b/packages/protobuf/test/scenarios.spec.ts index 97256cf55c1..3b89b33b16e 100644 --- a/packages/protobuf/test/scenarios.spec.ts +++ b/packages/protobuf/test/scenarios.spec.ts @@ -120,12 +120,10 @@ async function doEmit(files: Record): Promise { } const [, diagnostics] = await host.compileAndDiagnose("main.cadl", { - outputPath: baseOutputPath, + outputDir: baseOutputPath, noEmit: false, emitters: { - "@cadl-lang/protobuf": { - outputDirectory: baseOutputPath, - }, + "@cadl-lang/protobuf": {}, }, }); @@ -192,7 +190,7 @@ async function readdirRecursive(dir: string, base: string = dir): Promise Date: Wed, 8 Mar 2023 15:46:53 -0500 Subject: [PATCH 24/50] Lazy initialize scalars map --- packages/protobuf/src/transform.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/protobuf/src/transform.ts b/packages/protobuf/src/transform.ts index 3cb4933348d..4878c6e2d60 100644 --- a/packages/protobuf/src/transform.ts +++ b/packages/protobuf/src/transform.ts @@ -434,6 +434,7 @@ function tspToProto(program: Program): ProtoFile[] { } function getProtoScalarsMap(program: Program): Map { + // Lazy initialize this map of known proto scalars. return (_protoScalarsMap ??= new Map( ( [ @@ -738,7 +739,7 @@ function tspToProto(program: Program): ProtoFile[] { program, pt, dependent, - (dependency as Model).templateArguments![0] as NamespaceTraversable + (dependency as Model).templateMapper!.args[0] as NamespaceTraversable ); } try { @@ -812,6 +813,8 @@ function capitalize(s: S) { } /** + * Gets the syntactic return type target for an operation. + * * Helps us squiggle the right things for operation return types. */ function getOperationReturnSyntaxTarget(op: Operation): DiagnosticTarget { @@ -830,6 +833,9 @@ function getOperationReturnSyntaxTarget(op: Operation): DiagnosticTarget { } } +/** + * Gets the syntactic type position for a model or enum field. + */ function getMemberTypeSyntaxTarget(property: ModelProperty | EnumMember): DiagnosticTarget { const node = property.node; @@ -851,6 +857,9 @@ function getMemberTypeSyntaxTarget(property: ModelProperty | EnumMember): Diagno } } +/** + * Gets the syntactic position of a model property name. + */ function getPropertyNameSyntaxTarget(property: ModelProperty): DiagnosticTarget { const node = property.node; From c3c9a66cd1da0d8b75dc5df3350602b6c6598320 Mon Sep 17 00:00:00 2001 From: Will Date: Tue, 14 Mar 2023 14:49:11 -0400 Subject: [PATCH 25/50] Some doc updates --- docs/standard-library/protobuf/overview.md | 18 +++--- .../protobuf/reference/data-types.md | 49 ++++++++------- .../protobuf/reference/decorators.md | 63 +++++++++---------- .../protobuf/reference/index.md | 18 +++--- packages/protobuf/lib/proto.tsp | 29 +++++---- packages/website/.scripts/regen-ref-docs.mjs | 2 +- 6 files changed, 94 insertions(+), 85 deletions(-) diff --git a/docs/standard-library/protobuf/overview.md b/docs/standard-library/protobuf/overview.md index 26c20597103..178bda9f17b 100644 --- a/docs/standard-library/protobuf/overview.md +++ b/docs/standard-library/protobuf/overview.md @@ -23,19 +23,19 @@ The `@typespec/protobuf` package provides an emitter that must be enabled in ord 1. Via the CLI ```bash -typespec compile . --emit @typespec/protobuf +tsp compile . --emit @typespec/protobuf ``` 2. Via the project configuration -Add the Protobuf emitter to the `emitters` entry (or create one if it does not exist) in `typespec-project.yaml`: +Add the Protobuf emitter to the `emitters` entry (or create one if it does not exist) in `tsp-project.yaml`: ```yaml emitters: @typespec/protobuf: true ``` -With this configuration entry, Protobuf files will be generated every time the project is compiled using `typespec compile .`. +With this configuration entry, Protobuf files will be generated every time the project is compiled using `tsp compile .`. ## Core concepts @@ -49,7 +49,7 @@ The following TypeSpec model: ```typespec model TestMessage { - @field(1) n: int32 + @field(1) n: int32; } ``` @@ -70,7 +70,8 @@ The following TypeSpec namespace results in a Protobuf file named `test.proto` t ```typespec @package namespace Test { - // ... +// ... + } ``` @@ -78,10 +79,11 @@ Package names may be explicitly overridden by providing an optional `PackageDeta ```typespec @package({ - name: "com.example.test" + name: "com.example.test", }) namespace Test { - // ... +// ... + } ``` @@ -150,3 +152,5 @@ emitters: #### `noEmit` If set to `true`, this emitter will not write any files. It will still validate the TypeSpec sources to ensure they are compatible with Protobuf, but the files will simply not be written to the output directory. + +[protobuf-package]: reference/decorators#@TypeSpec.Protobuf.package diff --git a/docs/standard-library/protobuf/reference/data-types.md b/docs/standard-library/protobuf/reference/data-types.md index f8ccea4d003..a07454514da 100644 --- a/docs/standard-library/protobuf/reference/data-types.md +++ b/docs/standard-library/protobuf/reference/data-types.md @@ -6,9 +6,9 @@ toc_max_heading_level: 3 # Data types -## Cadl.Protobuf +## TypeSpec.Protobuf -### `Extern` {#Cadl.Protobuf.Extern} +### `Extern` {#TypeSpec.Protobuf.Extern} A model that represents an external Protobuf reference. This type can be used to import and utilize Protobuf declarations that are not declared in TypeSpec within TypeSpec sources. When the emitter encounters an `Extern`, it @@ -23,18 +23,18 @@ the example below. When the TypeSpec definition of `Widget` is encountered, the Protobuf emitter will represent it as a reference to `test.Widget` and insert an import for it, rather than attempt to convert the model to an equivalent message. -```cadl +```typespec model Extern ``` #### Template Parameters -| Name | Description | -| ---- | ------------------------------------------------------------------------------------------------------------ | -| Path | the relative path to a `.proto` file to import | -| Name | a string containing the fully-qualified reference to the type this model represents within the `.proto` file | +| Name | Description | +| ---- | ---------------------------------------------------------------------------------------- | +| Path | the relative path to a `.proto` file to import | +| Name | the fully-qualified reference to the type this model represents within the `.proto` file | -### `Map` {#Cadl.Protobuf.Map} +### `Map` {#TypeSpec.Protobuf.Map} A type representing a Protobuf `map`. Instances of this type in models will be converted to the built-in `map` type in Protobuf. @@ -42,29 +42,36 @@ in Protobuf. The key type of a Protobuf `map` must be any integral type or `string`. The value type can be any type other than another `Map`. -```cadl +```typespec model Map ``` #### Template Parameters -| Name | Description | -| ---- | ------------------------------------------ | -| K | the key type (any integral type or string) | -| V | the value type | +| Name | Description | +| ---- | ------------------------------------------------ | +| K | the key type (any integral type or string) | +| V | the value type (any type other than another map) | -### `PackageDetails` {#Cadl.Protobuf.PackageDetails} +### `PackageDetails` {#TypeSpec.Protobuf.PackageDetails} -Details applied to a package definition by the [ +Details applied to a package definition by the [`@package`](#TODO) decorator. -```cadl -model Cadl.Protobuf.PackageDetails +```typespec +model TypeSpec.Protobuf.PackageDetails ``` -### `StreamMode` {#Cadl.Protobuf.StreamMode} +### `StreamMode` {#TypeSpec.Protobuf.StreamMode} -The streaming mode of an operation. +The streaming mode of an operation. One of: -```cadl -enum Cadl.Protobuf.StreamMode +- `Duplex`: both the input and output of the operation are streaming. +- `In`: the input of the operation is streaming. +- `Out`: the output of the operation is streaming. +- `None`: neither the input nor the output are streaming. + +See the [`@stream`](#TODO) decorator. + +```typespec +enum TypeSpec.Protobuf.StreamMode ``` diff --git a/docs/standard-library/protobuf/reference/decorators.md b/docs/standard-library/protobuf/reference/decorators.md index a008cecea1d..b9e1595fadd 100644 --- a/docs/standard-library/protobuf/reference/decorators.md +++ b/docs/standard-library/protobuf/reference/decorators.md @@ -6,9 +6,9 @@ toc_max_heading_level: 3 # Decorators -## Cadl.Protobuf +## TypeSpec.Protobuf -### `@field` {#@Cadl.Protobuf.field} +### `@field` {#@TypeSpec.Protobuf.field} Defines the field index of a model property for conversion to a Protobuf message. @@ -19,8 +19,8 @@ The field index of a Protobuf message must: - not fall within the implementation reserved range of 19000 to 19999, inclusive. - not fall within any range that was [marked reserved](# -```cadl -dec Cadl.Protobuf.field(target: Cadl.Reflection.ModelProperty, index: Cadl.uint32) +```typespec +dec TypeSpec.Protobuf.field(target: TypeSpec.Reflection.ModelProperty, index: TypeSpec.uint32) ``` #### Target @@ -29,11 +29,11 @@ dec Cadl.Protobuf.field(target: Cadl.Reflection.ModelProperty, index: Cadl.uint3 #### Parameters -| Name | Type | Description | -| ----- | -------------------- | ------------------------------------ | -| index | `scalar Cadl.uint32` | The whole-number index of the field. | +| Name | Type | Description | +| ----- | ------------------------ | ------------------------------------ | +| index | `scalar TypeSpec.uint32` | The whole-number index of the field. | -### `@reserve` {#@Cadl.Protobuf.reserve} +### `@reserve` {#@TypeSpec.Protobuf.reserve} Reserve a field index, range, or name. If a field definition collides with a reservation, the emitter will produce an error. @@ -54,30 +54,29 @@ be useful if a field is removed, as it will further prevent adding a new, incomp from utilizing the field index at runtime in a way that may break compatibility with users of older specifications. See _[Protobuf Language Guide - Reserved Fields](https://protobuf.dev/programming-guides/proto3/#reserved)_ for more +information. -Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int3 - -```cadl -dec Cadl.Protobuf.reserve(target: Cadl.object, ...reservations: Cadl.string | [Cadl.uint32, Cadl.uint32] | Cadl.uint32[]) +```typespec +dec TypeSpec.Protobuf.reserve(target: TypeSpec.object, ...reservations: TypeSpec.string | [TypeSpec.uint32, TypeSpec.uint32] | TypeSpec.uint32[]) ``` #### Target -`model Cadl.object` +`model TypeSpec.object` #### Parameters -| Name | Type | Description | -| ------------ | ------------------------------------------------------------------ | ---------------------------- | -| reservations | `model Cadl.string \| [Cadl.uint32, Cadl.uint32] \| Cadl.uint32[]` | a list of field reservations | +| Name | Type | Description | +| ------------ | ---------------------------------------------------------------------------------- | ---------------------------- | +| reservations | `model TypeSpec.string \| [TypeSpec.uint32, TypeSpec.uint32] \| TypeSpec.uint32[]` | a list of field reservations | -### `@service` {#@Cadl.Protobuf.service} +### `@service` {#@TypeSpec.Protobuf.service} -Declares that a TypeSPec interface constitutes a Protobuf service. The contents of the interface will be converted to +Declares that a TypeSpec interface constitutes a Protobuf service. The contents of the interface will be converted to a `service` declaration in the resulting Protobuf file. -```cadl -dec Cadl.Protobuf.service(target: Cadl.Reflection.Interface) +```typespec +dec TypeSpec.Protobuf.service(target: TypeSpec.Reflection.Interface) ``` #### Target @@ -89,13 +88,13 @@ dec Cadl.Protobuf.service(target: Cadl.Reflection.Interface) | Name | Type | Description | | ---- | ---- | ----------- | -### `@package` {#@Cadl.Protobuf.package} +### `@package` {#@TypeSpec.Protobuf.package} Declares that a TypeSpec namespace constitutes a Protobuf package. The contents of the namespace will be emitted to a single Protobuf file. -```cadl -dec Cadl.Protobuf.package(target: Cadl.Reflection.Namespace, details?: Cadl.Protobuf.PackageDetails) +```typespec +dec TypeSpec.Protobuf.package(target: TypeSpec.Reflection.Namespace, details?: TypeSpec.Protobuf.PackageDetails) ``` #### Target @@ -104,16 +103,16 @@ dec Cadl.Protobuf.package(target: Cadl.Reflection.Namespace, details?: Cadl.Prot #### Parameters -| Name | Type | Description | -| ------- | ------------------------------------ | ----------------------------------- | -| details | `model Cadl.Protobuf.PackageDetails` | the optional details of the package | +| Name | Type | Description | +| ------- | ---------------------------------------- | ----------------------------------- | +| details | `model TypeSpec.Protobuf.PackageDetails` | the optional details of the package | -### `@stream` {#@Cadl.Protobuf.stream} +### `@stream` {#@TypeSpec.Protobuf.stream} Set the streaming mode of an operation. See [StreamMode](#TODO) for more information. -```cadl -dec Cadl.Protobuf.stream(target: Cadl.Reflection.Operation, mode: Cadl.Protobuf.StreamMode) +```typespec +dec TypeSpec.Protobuf.stream(target: TypeSpec.Reflection.Operation, mode: TypeSpec.Protobuf.StreamMode) ``` #### Target @@ -122,6 +121,6 @@ dec Cadl.Protobuf.stream(target: Cadl.Reflection.Operation, mode: Cadl.Protobuf. #### Parameters -| Name | Type | Description | -| ---- | ------------------------------- | ---------------------------------------------- | -| mode | `enum Cadl.Protobuf.StreamMode` | The streaming mode to apply to this operation. | +| Name | Type | Description | +| ---- | ----------------------------------- | ---------------------------------------------- | +| mode | `enum TypeSpec.Protobuf.StreamMode` | The streaming mode to apply to this operation. | diff --git a/docs/standard-library/protobuf/reference/index.md b/docs/standard-library/protobuf/reference/index.md index 7f8b359beea..0c50f28d160 100644 --- a/docs/standard-library/protobuf/reference/index.md +++ b/docs/standard-library/protobuf/reference/index.md @@ -5,18 +5,18 @@ toc_min_heading_level: 2 toc_max_heading_level: 3 --- -## Cadl.Protobuf +## TypeSpec.Protobuf ### Decorators -- [`@field`](./decorators.md#@Cadl.Protobuf.field) -- [`@reserve`](./decorators.md#@Cadl.Protobuf.reserve) -- [`@service`](./decorators.md#@Cadl.Protobuf.service) -- [`@package`](./decorators.md#@Cadl.Protobuf.package) -- [`@stream`](./decorators.md#@Cadl.Protobuf.stream) +- [`@field`](./decorators.md#@TypeSpec.Protobuf.field) +- [`@reserve`](./decorators.md#@TypeSpec.Protobuf.reserve) +- [`@service`](./decorators.md#@TypeSpec.Protobuf.service) +- [`@package`](./decorators.md#@TypeSpec.Protobuf.package) +- [`@stream`](./decorators.md#@TypeSpec.Protobuf.stream) ### Models -- [`Extern`](./data-types.md#Cadl.Protobuf.Extern) -- [`Map`](./data-types.md#Cadl.Protobuf.Map) -- [`PackageDetails`](./data-types.md#Cadl.Protobuf.PackageDetails) +- [`Extern`](./data-types.md#TypeSpec.Protobuf.Extern) +- [`Map`](./data-types.md#TypeSpec.Protobuf.Map) +- [`PackageDetails`](./data-types.md#TypeSpec.Protobuf.PackageDetails) diff --git a/packages/protobuf/lib/proto.tsp b/packages/protobuf/lib/proto.tsp index ec5ad0e5549..54d3b11cf0a 100644 --- a/packages/protobuf/lib/proto.tsp +++ b/packages/protobuf/lib/proto.tsp @@ -49,8 +49,7 @@ namespace WellKnown { * * This model references `google.protobuf.Timestamp` from `google/protobuf/timestamp.proto`. */ - model Timestamp - is Extern<"google/protobuf/timestamp.proto", "google.protobuf.Timestamp">; + model Timestamp is Extern<"google/protobuf/timestamp.proto", "google.protobuf.Timestamp">; } /** @@ -172,8 +171,7 @@ extern dec field(target: TypeSpec.Reflection.ModelProperty, index: uint32); * from utilizing the field index at runtime in a way that may break compatibility with users of older specifications. * * See _[Protobuf Language Guide - Reserved Fields](https://protobuf.dev/programming-guides/proto3/#reserved)_ for more - * - * Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int3 + * information. * * @param reservations a list of field reservations * @@ -187,19 +185,16 @@ extern dec field(target: TypeSpec.Reflection.ModelProperty, index: uint32); * } * ``` */ -extern dec reserve( - target: object, - ...reservations: (string | [uint32, uint32] | uint32)[] -); +extern dec reserve(target: object, ...reservations: (string | [uint32, uint32] | uint32)[]); /** - * Declares that a TypeSPec interface constitutes a Protobuf service. The contents of the interface will be converted to + * Declares that a TypeSpec interface constitutes a Protobuf service. The contents of the interface will be converted to * a `service` declaration in the resulting Protobuf file. */ extern dec service(target: TypeSpec.Reflection.Interface); /** - * Details applied to a package definition by the [@package](#TODO) decorator. + * Details applied to a package definition by the [`@package`](#TODO) decorator. */ model PackageDetails { /** @@ -216,13 +211,17 @@ model PackageDetails { * * @param details the optional details of the package */ -extern dec package( - target: TypeSpec.Reflection.Namespace, - details?: PackageDetails -); +extern dec package(target: TypeSpec.Reflection.Namespace, details?: PackageDetails); /** - * The streaming mode of an operation. + * The streaming mode of an operation. One of: + * + * - `Duplex`: both the input and output of the operation are streaming. + * - `In`: the input of the operation is streaming. + * - `Out`: the output of the operation is streaming. + * - `None`: neither the input nor the output are streaming. + * + * See the [`@stream`](#TODO) decorator. */ enum StreamMode { /** diff --git a/packages/website/.scripts/regen-ref-docs.mjs b/packages/website/.scripts/regen-ref-docs.mjs index fc2b2168e89..62c70d56602 100644 --- a/packages/website/.scripts/regen-ref-docs.mjs +++ b/packages/website/.scripts/regen-ref-docs.mjs @@ -29,6 +29,6 @@ await generateLibraryDocs( await generateLibraryDocs( join(repoRoot, "packages/protobuf"), - ["Cadl.Protobuf"], + ["TypeSpec.Protobuf"], join(repoRoot, "docs/standard-library/protobuf/reference") ); From f0f6e00cb77e04684e74bd99c1841133cfe5d16a Mon Sep 17 00:00:00 2001 From: Will Date: Tue, 14 Mar 2023 14:57:29 -0400 Subject: [PATCH 26/50] Removed protoc output --- .../anonymous-package/output/cpp/main.pb.cc | 515 -------- .../anonymous-package/output/cpp/main.pb.h | 466 ------- .../anonymous-package/output/csharp/Main.cs | 420 ------- .../output/objc/Main.pbobjc.h | 80 -- .../output/objc/Main.pbobjc.m | 149 --- .../output/php/GPBMetadata/Main.php | 33 - .../anonymous-package/output/php/Input.php | 56 - .../anonymous-package/output/php/Output.php | 56 - .../anonymous-package/output/pyi/main_pb2.pyi | 17 - .../output/python/main_pb2.py | 30 - .../anonymous-package/output/ruby/main_pb.rb | 18 - .../array/output/cpp/com/azure/test.pb.cc | 588 --------- .../array/output/cpp/com/azure/test.pb.h | 619 --------- .../protoc-out/array/output/csharp/Test.cs | 442 ------- .../array/output/objc/com/azure/Test.pbobjc.h | 87 -- .../array/output/objc/com/azure/Test.pbobjc.m | 160 --- .../array/output/php/Com/Azure/Test/Input.php | 58 - .../output/php/Com/Azure/Test/Output.php | 85 -- .../output/php/GPBMetadata/Com/Azure/Test.php | 33 - .../array/output/pyi/com/azure/test_pb2.pyi | 20 - .../array/output/python/com/azure/test_pb2.py | 30 - .../array/output/ruby/com/azure/test_pb.rb | 25 - .../output/cpp/A.pb.cc | 349 ----- .../output/cpp/A.pb.h | 326 ----- .../output/cpp/B.pb.cc | 318 ----- .../output/cpp/B.pb.h | 294 ----- .../output/csharp/A.cs | 269 ---- .../output/csharp/B.cs | 233 ---- .../output/objc/A.pbobjc.h | 71 -- .../output/objc/A.pbobjc.m | 111 -- .../output/objc/B.pbobjc.h | 68 - .../output/objc/B.pbobjc.m | 101 -- .../output/php/A/Output.php | 85 -- .../output/php/B/Input.php | 58 - .../output/php/GPBMetadata/A.php | 29 - .../output/php/GPBMetadata/B.php | 31 - .../output/pyi/A_pb2.pyi | 13 - .../output/pyi/B_pb2.pyi | 12 - .../output/python/A_pb2.py | 26 - .../output/python/B_pb2.py | 29 - .../output/ruby/A_pb.rb | 17 - .../output/ruby/B_pb.rb | 18 - .../protoc-out/enum/output/cpp/main.pb.cc | 677 ---------- .../test/protoc-out/enum/output/cpp/main.pb.h | 669 ---------- .../protoc-out/enum/output/csharp/Main.cs | 549 -------- .../protoc-out/enum/output/objc/Main.pbobjc.h | 156 --- .../protoc-out/enum/output/objc/Main.pbobjc.m | 281 ----- .../enum/output/php/GPBMetadata/Main.php | Bin 780 -> 0 bytes .../test/protoc-out/enum/output/php/Input.php | 110 -- .../protoc-out/enum/output/php/InputType.php | 44 - .../enum/output/php/InputTypeWithAlias.php | 49 - .../protoc-out/enum/output/php/Output.php | 83 -- .../protoc-out/enum/output/pyi/main_pb2.pyi | 40 - .../protoc-out/enum/output/python/main_pb2.py | 36 - .../protoc-out/enum/output/ruby/main_pb.rb | 32 - .../protoc-out/extern/output/cpp/main.pb.cc | 540 -------- .../protoc-out/extern/output/cpp/main.pb.h | 575 --------- .../protoc-out/extern/output/csharp/Main.cs | 441 ------- .../extern/output/objc/Main.pbobjc.h | 86 -- .../extern/output/objc/Main.pbobjc.m | 153 --- .../extern/output/php/BarRequest.php | 66 - .../extern/output/php/BarResponse.php | 66 - .../extern/output/php/GPBMetadata/Main.php | 37 - .../protoc-out/extern/output/pyi/main_pb2.pyi | 19 - .../extern/output/python/main_pb2.py | 32 - .../protoc-out/extern/output/ruby/main_pb.rb | 21 - .../output/cpp/com/azure/test.pb.cc | 590 --------- .../output/cpp/com/azure/test.pb.h | 538 -------- .../output/csharp/Test.cs | 462 ------- .../output/objc/com/azure/Test.pbobjc.h | 83 -- .../output/objc/com/azure/Test.pbobjc.m | 160 --- .../output/php/Com/Azure/Test/FooRequest.php | 58 - .../output/php/Com/Azure/Test/FooResponse.php | 85 -- .../output/php/GPBMetadata/Com/Azure/Test.php | 34 - .../output/pyi/com/azure/test_pb2.pyi | 19 - .../output/python/com/azure/test_pb2.py | 30 - .../output/ruby/com/azure/test_pb.rb | 25 - .../test/protoc-out/map/output/cpp/main.pb.cc | 372 ------ .../test/protoc-out/map/output/cpp/main.pb.h | 320 ----- .../test/protoc-out/map/output/csharp/Main.cs | 221 ---- .../protoc-out/map/output/objc/Main.pbobjc.h | 70 -- .../protoc-out/map/output/objc/Main.pbobjc.m | 107 -- .../map/output/php/GPBMetadata/Main.php | 35 - .../test/protoc-out/map/output/php/Input.php | 56 - .../protoc-out/map/output/pyi/main_pb2.pyi | 20 - .../protoc-out/map/output/python/main_pb2.py | 33 - .../protoc-out/map/output/ruby/main_pb.rb | 16 - .../reserved fields/output/cpp/main.pb.cc | 375 ------ .../reserved fields/output/cpp/main.pb.h | 415 ------ .../reserved fields/output/csharp/Main.cs | 384 ------ .../reserved fields/output/objc/Main.pbobjc.h | 74 -- .../reserved fields/output/objc/Main.pbobjc.m | 131 -- .../output/php/FooResponse.php | 29 - .../output/php/GPBMetadata/Main.php | 32 - .../reserved fields/output/php/Input.php | 56 - .../reserved fields/output/pyi/main_pb2.pyi | 15 - .../reserved fields/output/python/main_pb2.py | 30 - .../reserved fields/output/ruby/main_pb.rb | 17 - .../simple/output/cpp/com/azure/Test.pb.cc | 589 --------- .../simple/output/cpp/com/azure/Test.pb.h | 538 -------- .../protoc-out/simple/output/csharp/Test.cs | 462 ------- .../output/objc/com/azure/Test.pbobjc.h | 83 -- .../output/objc/com/azure/Test.pbobjc.m | 160 --- .../output/php/Com/Azure/Test/Input.php | 58 - .../output/php/Com/Azure/Test/Output.php | 85 -- .../output/php/GPBMetadata/Com/Azure/Test.php | 33 - .../simple/output/pyi/com/azure/Test_pb2.pyi | 19 - .../output/python/com/azure/Test_pb2.py | 30 - .../simple/output/ruby/com/azure/Test_pb.rb | 25 - .../protoc-out/streams/output/cpp/main.pb.cc | 578 --------- .../protoc-out/streams/output/cpp/main.pb.h | 526 -------- .../protoc-out/streams/output/csharp/Main.cs | 460 ------- .../streams/output/objc/Main.pbobjc.h | 83 -- .../streams/output/objc/Main.pbobjc.m | 160 --- .../streams/output/php/GPBMetadata/Main.php | 37 - .../protoc-out/streams/output/php/Input.php | 56 - .../protoc-out/streams/output/php/Output.php | 83 -- .../streams/output/pyi/main_pb2.pyi | 19 - .../streams/output/python/main_pb2.py | 30 - .../protoc-out/streams/output/ruby/main_pb.rb | 19 - .../protoc-out/union/output/cpp/main.pb.cc | 1120 ----------------- .../protoc-out/union/output/cpp/main.pb.h | 1063 ---------------- .../protoc-out/union/output/csharp/Main.cs | 936 -------------- .../union/output/objc/Main.pbobjc.h | 126 -- .../union/output/objc/Main.pbobjc.m | 285 ----- .../union/output/php/GPBMetadata/Main.php | Bin 729 -> 0 bytes .../protoc-out/union/output/php/Input.php | 94 -- .../protoc-out/union/output/php/InputA.php | 56 - .../protoc-out/union/output/php/InputB.php | 56 - .../protoc-out/union/output/php/Output.php | 83 -- .../protoc-out/union/output/pyi/main_pb2.pyi | 33 - .../union/output/python/main_pb2.py | 34 - .../protoc-out/union/output/ruby/main_pb.rb | 30 - 133 files changed, 24148 deletions(-) delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.h delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/csharp/Main.cs delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/php/GPBMetadata/Main.php delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/php/Input.php delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/php/Output.php delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/pyi/main_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/python/main_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/anonymous-package/output/ruby/main_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.h delete mode 100644 packages/protobuf/test/protoc-out/array/output/csharp/Test.cs delete mode 100644 packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Input.php delete mode 100644 packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Output.php delete mode 100644 packages/protobuf/test/protoc-out/array/output/php/GPBMetadata/Com/Azure/Test.php delete mode 100644 packages/protobuf/test/protoc-out/array/output/pyi/com/azure/test_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/array/output/python/com/azure/test_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/array/output/ruby/com/azure/test_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.h delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.h delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/csharp/A.cs delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/csharp/B.cs delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/php/A/Output.php delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/php/B/Input.php delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/A.php delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/B.php delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/pyi/A_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/pyi/B_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/python/A_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/python/B_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/ruby/A_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/cross package references/output/ruby/B_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.h delete mode 100644 packages/protobuf/test/protoc-out/enum/output/csharp/Main.cs delete mode 100644 packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/enum/output/php/GPBMetadata/Main.php delete mode 100644 packages/protobuf/test/protoc-out/enum/output/php/Input.php delete mode 100644 packages/protobuf/test/protoc-out/enum/output/php/InputType.php delete mode 100644 packages/protobuf/test/protoc-out/enum/output/php/InputTypeWithAlias.php delete mode 100644 packages/protobuf/test/protoc-out/enum/output/php/Output.php delete mode 100644 packages/protobuf/test/protoc-out/enum/output/pyi/main_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/enum/output/python/main_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/enum/output/ruby/main_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.h delete mode 100644 packages/protobuf/test/protoc-out/extern/output/csharp/Main.cs delete mode 100644 packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/extern/output/php/BarRequest.php delete mode 100644 packages/protobuf/test/protoc-out/extern/output/php/BarResponse.php delete mode 100644 packages/protobuf/test/protoc-out/extern/output/php/GPBMetadata/Main.php delete mode 100644 packages/protobuf/test/protoc-out/extern/output/pyi/main_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/extern/output/python/main_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/extern/output/ruby/main_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.h delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/csharp/Test.cs delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooRequest.php delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooResponse.php delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/php/GPBMetadata/Com/Azure/Test.php delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/pyi/com/azure/test_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/python/com/azure/test_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/inferred-message-names/output/ruby/com/azure/test_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/map/output/cpp/main.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/map/output/cpp/main.pb.h delete mode 100644 packages/protobuf/test/protoc-out/map/output/csharp/Main.cs delete mode 100644 packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/map/output/php/GPBMetadata/Main.php delete mode 100644 packages/protobuf/test/protoc-out/map/output/php/Input.php delete mode 100644 packages/protobuf/test/protoc-out/map/output/pyi/main_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/map/output/python/main_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/map/output/ruby/main_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.h delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/csharp/Main.cs delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/php/FooResponse.php delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/php/GPBMetadata/Main.php delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/php/Input.php delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/pyi/main_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/python/main_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/reserved fields/output/ruby/main_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.h delete mode 100644 packages/protobuf/test/protoc-out/simple/output/csharp/Test.cs delete mode 100644 packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Input.php delete mode 100644 packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Output.php delete mode 100644 packages/protobuf/test/protoc-out/simple/output/php/GPBMetadata/Com/Azure/Test.php delete mode 100644 packages/protobuf/test/protoc-out/simple/output/pyi/com/azure/Test_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/simple/output/python/com/azure/Test_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/simple/output/ruby/com/azure/Test_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.h delete mode 100644 packages/protobuf/test/protoc-out/streams/output/csharp/Main.cs delete mode 100644 packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/streams/output/php/GPBMetadata/Main.php delete mode 100644 packages/protobuf/test/protoc-out/streams/output/php/Input.php delete mode 100644 packages/protobuf/test/protoc-out/streams/output/php/Output.php delete mode 100644 packages/protobuf/test/protoc-out/streams/output/pyi/main_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/streams/output/python/main_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/streams/output/ruby/main_pb.rb delete mode 100644 packages/protobuf/test/protoc-out/union/output/cpp/main.pb.cc delete mode 100644 packages/protobuf/test/protoc-out/union/output/cpp/main.pb.h delete mode 100644 packages/protobuf/test/protoc-out/union/output/csharp/Main.cs delete mode 100644 packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.h delete mode 100644 packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.m delete mode 100644 packages/protobuf/test/protoc-out/union/output/php/GPBMetadata/Main.php delete mode 100644 packages/protobuf/test/protoc-out/union/output/php/Input.php delete mode 100644 packages/protobuf/test/protoc-out/union/output/php/InputA.php delete mode 100644 packages/protobuf/test/protoc-out/union/output/php/InputB.php delete mode 100644 packages/protobuf/test/protoc-out/union/output/php/Output.php delete mode 100644 packages/protobuf/test/protoc-out/union/output/pyi/main_pb2.pyi delete mode 100644 packages/protobuf/test/protoc-out/union/output/python/main_pb2.py delete mode 100644 packages/protobuf/test/protoc-out/union/output/ruby/main_pb.rb diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.cc deleted file mode 100644 index 3241e74259f..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.cc +++ /dev/null @@ -1,515 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#include "main.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -PROTOBUF_CONSTEXPR Input::Input( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_._cached_size_)*/{}} {} -struct InputDefaultTypeInternal { - PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputDefaultTypeInternal() {} - union { - Input _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; -PROTOBUF_CONSTEXPR Output::Output( - ::_pbi::ConstantInitialized): _impl_{ - /* ._impl_.testoutputfield_ = */ 0 - - , /*decltype(_impl_._cached_size_)*/{}} {} -struct OutputDefaultTypeInternal { - PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~OutputDefaultTypeInternal() {} - union { - Output _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; -static ::_pb::Metadata file_level_metadata_main_2eproto[2]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_main_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_main_2eproto = nullptr; -const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::Input, _impl_.testinputfield_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::Output, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::Output, _impl_.testoutputfield_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::Input)}, - { 9, -1, -1, sizeof(::Output)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::_Input_default_instance_._instance, - &::_Output_default_instance_._instance, -}; -const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\nmain.proto\"\037\n\005Input\022\026\n\016testInputField\030" - "\001 \001(\t\"!\n\006Output\022\027\n\017testOutputField\030\001 \001(\005" - "2!\n\007Service\022\026\n\003Foo\022\006.Input\032\007.Outputb\006pro" - "to3" -}; -static ::absl::once_flag descriptor_table_main_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { - false, - false, - 123, - descriptor_table_protodef_main_2eproto, - "main.proto", - &descriptor_table_main_2eproto_once, - nullptr, - 0, - 2, - schemas, - file_default_instances, - TableStruct_main_2eproto::offsets, - file_level_metadata_main_2eproto, - file_level_enum_descriptors_main_2eproto, - file_level_service_descriptors_main_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { - return &descriptor_table_main_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); -// =================================================================== - -class Input::_Internal { - public: -}; - -Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:Input) -} -Input::Input(const Input& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Input* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_testinputfield().empty()) { - _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), - _this->GetArenaForAllocation()); - } - // @@protoc_insertion_point(copy_constructor:Input) -} - -inline void Input::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Input::~Input() { - // @@protoc_insertion_point(destructor:Input) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Input::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testinputfield_.Destroy(); -} - -void Input::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Input::Clear() { -// @@protoc_insertion_point(message_clear_start:Input) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_.ClearToEmpty(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // string testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - auto str = _internal_mutable_testinputfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "Input.testInputField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Input::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:Input) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "Input.testInputField"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_testinputfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:Input) - return target; -} - -::size_t Input::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:Input) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_testinputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Input::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } - - -void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:Input) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_testinputfield().empty()) { - _this->_internal_set_testinputfield(from._internal_testinputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Input::CopyFrom(const Input& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:Input) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Input::IsInitialized() const { - return true; -} - -void Input::InternalSwap(Input* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.testinputfield_, lhs_arena, - &other->_impl_.testinputfield_, rhs_arena - ); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[0]); -} -// =================================================================== - -class Output::_Internal { - public: -}; - -Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:Output) -} -Output::Output(const Output& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>( - from._internal_metadata_); - // @@protoc_insertion_point(copy_constructor:Output) -} - -inline void Output::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testoutputfield_) { 0 } - - , /*decltype(_impl_._cached_size_)*/{} - }; -} - -Output::~Output() { - // @@protoc_insertion_point(destructor:Output) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Output::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); -} - -void Output::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Output::Clear() { -// @@protoc_insertion_point(message_clear_start:Output) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testoutputfield_ = 0; - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // int32 testOutputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { - _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Output::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:Output) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray( - 1, this->_internal_testoutputfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:Output) - return target; -} - -::size_t Output::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:Output) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( - this->_internal_testoutputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Output::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } - - -void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:Output) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (from._internal_testoutputfield() != 0) { - _this->_internal_set_testoutputfield(from._internal_testoutputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Output::CopyFrom(const Output& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:Output) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Output::IsInitialized() const { - return true; -} - -void Output::InternalSwap(Output* other) { - using std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - - swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[1]); -} -// @@protoc_insertion_point(namespace_scope) -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::Input* -Arena::CreateMaybeMessage< ::Input >(Arena* arena) { - return Arena::CreateMessageInternal< ::Input >(arena); -} -template<> PROTOBUF_NOINLINE ::Output* -Arena::CreateMaybeMessage< ::Output >(Arena* arena) { - return Arena::CreateMessageInternal< ::Output >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.h deleted file mode 100644 index e36f8cedf5e..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/cpp/main.pb.h +++ /dev/null @@ -1,466 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/unknown_field_set.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_main_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_main_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_main_2eproto; -class Input; -struct InputDefaultTypeInternal; -extern InputDefaultTypeInternal _Input_default_instance_; -class Output; -struct OutputDefaultTypeInternal; -extern OutputDefaultTypeInternal _Output_default_instance_; -PROTOBUF_NAMESPACE_OPEN -template <> -::Input* Arena::CreateMaybeMessage<::Input>(Arena*); -template <> -::Output* Arena::CreateMaybeMessage<::Output>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - - -// =================================================================== - - -// ------------------------------------------------------------------- - -class Input final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { - public: - inline Input() : Input(nullptr) {} - ~Input() override; - explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Input(const Input& from); - Input(Input&& from) noexcept - : Input() { - *this = ::std::move(from); - } - - inline Input& operator=(const Input& from) { - CopyFrom(from); - return *this; - } - inline Input& operator=(Input&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Input& default_instance() { - return *internal_default_instance(); - } - static inline const Input* internal_default_instance() { - return reinterpret_cast( - &_Input_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Input& a, Input& b) { - a.Swap(&b); - } - inline void Swap(Input* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Input* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Input& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Input& from) { - Input::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Input* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "Input"; - } - protected: - explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - }; - // string testInputField = 1; - void clear_testinputfield() ; - const std::string& testinputfield() const; - template - void set_testinputfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_testinputfield(); - PROTOBUF_NODISCARD std::string* release_testinputfield(); - void set_allocated_testinputfield(std::string* testinputfield); - private: - const std::string& _internal_testinputfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); - std::string* _internal_mutable_testinputfield(); - public: - // @@protoc_insertion_point(class_scope:Input) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -};// ------------------------------------------------------------------- - -class Output final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Output) */ { - public: - inline Output() : Output(nullptr) {} - ~Output() override; - explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Output(const Output& from); - Output(Output&& from) noexcept - : Output() { - *this = ::std::move(from); - } - - inline Output& operator=(const Output& from) { - CopyFrom(from); - return *this; - } - inline Output& operator=(Output&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Output& default_instance() { - return *internal_default_instance(); - } - static inline const Output* internal_default_instance() { - return reinterpret_cast( - &_Output_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(Output& a, Output& b) { - a.Swap(&b); - } - inline void Swap(Output* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Output* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Output& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Output& from) { - Output::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Output* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "Output"; - } - protected: - explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestOutputFieldFieldNumber = 1, - }; - // int32 testOutputField = 1; - void clear_testoutputfield() ; - ::int32_t testoutputfield() const; - void set_testoutputfield(::int32_t value); - - private: - ::int32_t _internal_testoutputfield() const; - void _internal_set_testoutputfield(::int32_t value); - - public: - // @@protoc_insertion_point(class_scope:Output) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::int32_t testoutputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// Input - -// string testInputField = 1; -inline void Input::clear_testinputfield() { - _impl_.testinputfield_.ClearToEmpty(); -} -inline const std::string& Input::testinputfield() const { - // @@protoc_insertion_point(field_get:Input.testInputField) - return _internal_testinputfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { - - _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:Input.testInputField) -} -inline std::string* Input::mutable_testinputfield() { - std::string* _s = _internal_mutable_testinputfield(); - // @@protoc_insertion_point(field_mutable:Input.testInputField) - return _s; -} -inline const std::string& Input::_internal_testinputfield() const { - return _impl_.testinputfield_.Get(); -} -inline void Input::_internal_set_testinputfield(const std::string& value) { - - _impl_.testinputfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Input::_internal_mutable_testinputfield() { - - return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Input::release_testinputfield() { - // @@protoc_insertion_point(field_release:Input.testInputField) - return _impl_.testinputfield_.Release(); -} -inline void Input::set_allocated_testinputfield(std::string* testinputfield) { - _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.testinputfield_.IsDefault()) { - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:Input.testInputField) -} - -// ------------------------------------------------------------------- - -// Output - -// int32 testOutputField = 1; -inline void Output::clear_testoutputfield() { - _impl_.testoutputfield_ = 0; -} -inline ::int32_t Output::testoutputfield() const { - // @@protoc_insertion_point(field_get:Output.testOutputField) - return _internal_testoutputfield(); -} -inline void Output::set_testoutputfield(::int32_t value) { - ; - _internal_set_testoutputfield(value); - // @@protoc_insertion_point(field_set:Output.testOutputField) -} -inline ::int32_t Output::_internal_testoutputfield() const { - return _impl_.testoutputfield_; -} -inline void Output::_internal_set_testoutputfield(::int32_t value) { - ; - _impl_.testoutputfield_ = value; -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/anonymous-package/output/csharp/Main.cs deleted file mode 100644 index 3d457804aed..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/csharp/Main.cs +++ /dev/null @@ -1,420 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -/// Holder for reflection information generated from main.proto -public static partial class MainReflection { - - #region Descriptor - /// File descriptor for main.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static MainReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgptYWluLnByb3RvIh8KBUlucHV0EhYKDnRlc3RJbnB1dEZpZWxkGAEgASgJ", - "IiEKBk91dHB1dBIXCg90ZXN0T3V0cHV0RmllbGQYASABKAUyIQoHU2Vydmlj", - "ZRIWCgNGb28SBi5JbnB1dBoHLk91dHB1dGIGcHJvdG8z")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "TestInputField" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Output), global::Output.Parser, new[]{ "TestOutputField" }, null, null, null, null) - })); - } - #endregion - -} -#region Messages -public sealed partial class Input : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input(Input other) : this() { - testInputField_ = other.testInputField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input Clone() { - return new Input(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private string testInputField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string TestInputField { - get { return testInputField_; } - set { - testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Input); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Input other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestInputField != other.TestInputField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestInputField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Input other) { - if (other == null) { - return; - } - if (other.TestInputField.Length != 0) { - TestInputField = other.TestInputField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - } - #endif - -} - -public sealed partial class Output : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output(Output other) : this() { - testOutputField_ = other.testOutputField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output Clone() { - return new Output(this); - } - - /// Field number for the "testOutputField" field. - public const int TestOutputFieldFieldNumber = 1; - private int testOutputField_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int TestOutputField { - get { return testOutputField_; } - set { - testOutputField_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Output); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Output other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestOutputField != other.TestOutputField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestOutputField != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Output other) { - if (other == null) { - return; - } - if (other.TestOutputField != 0) { - TestOutputField = other.TestOutputField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - } - } - } - #endif - -} - -#endregion - - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.h deleted file mode 100644 index 4d7a266069b..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.h +++ /dev/null @@ -1,80 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - MainRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface MainRoot : GPBRootObject -@end - -#pragma mark - Input - -typedef GPB_ENUM(Input_FieldNumber) { - Input_FieldNumber_TestInputField = 1, -}; - -GPB_FINAL @interface Input : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; - -@end - -#pragma mark - Output - -typedef GPB_ENUM(Output_FieldNumber) { - Output_FieldNumber_TestOutputField = 1, -}; - -GPB_FINAL @interface Output : GPBMessage - -@property(nonatomic, readwrite) int32_t testOutputField; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.m deleted file mode 100644 index a38cf69a9ec..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/objc/Main.pbobjc.m +++ /dev/null @@ -1,149 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "Main.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -#pragma mark - MainRoot - -@implementation MainRoot - -// No extensions in the file and no imports, so no need to generate -// +extensionRegistry. - -@end - -#pragma mark - MainRoot_FileDescriptor - -static GPBFileDescriptor *MainRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - Input - -@implementation Input - -@dynamic testInputField; - -typedef struct Input__storage_ { - uint32_t _has_storage_[1]; - NSString *testInputField; -} Input__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputField", - .dataTypeSpecific.clazz = Nil, - .number = Input_FieldNumber_TestInputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Input__storage_, testInputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Input class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Input__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\016\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - Output - -@implementation Output - -@dynamic testOutputField; - -typedef struct Output__storage_ { - uint32_t _has_storage_[1]; - int32_t testOutputField; -} Output__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testOutputField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_TestOutputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Output__storage_, testOutputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeInt32, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Output class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Output__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\017\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/anonymous-package/output/php/GPBMetadata/Main.php deleted file mode 100644 index 0979d31f5bb..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/php/GPBMetadata/Main.php +++ /dev/null @@ -1,33 +0,0 @@ -internalAddGeneratedFile( - ' -{ - -main.proto" -Input -testInputField ( "! -Output -testOutputField (2! -Service -Foo.Input.Outputbproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/php/Input.php b/packages/protobuf/test/protoc-out/anonymous-package/output/php/Input.php deleted file mode 100644 index b77d7713c23..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/php/Input.php +++ /dev/null @@ -1,56 +0,0 @@ -Input - */ -class Input extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field string testInputField = 1; - */ - protected $testInputField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $testInputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field string testInputField = 1; - * @return string - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field string testInputField = 1; - * @param string $var - * @return $this - */ - public function setTestInputField($var) - { - GPBUtil::checkString($var, True); - $this->testInputField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/php/Output.php b/packages/protobuf/test/protoc-out/anonymous-package/output/php/Output.php deleted file mode 100644 index e57f5754848..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/php/Output.php +++ /dev/null @@ -1,56 +0,0 @@ -Output - */ -class Output extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field int32 testOutputField = 1; - */ - protected $testOutputField = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $testOutputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @return int - */ - public function getTestOutputField() - { - return $this->testOutputField; - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @param int $var - * @return $this - */ - public function setTestOutputField($var) - { - GPBUtil::checkInt32($var); - $this->testOutputField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/anonymous-package/output/pyi/main_pb2.pyi deleted file mode 100644 index 999c2653afb..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/pyi/main_pb2.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Optional as _Optional - -DESCRIPTOR: _descriptor.FileDescriptor - -class Input(_message.Message): - __slots__ = ["testInputField"] - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testInputField: str - def __init__(self, testInputField: _Optional[str] = ...) -> None: ... - -class Output(_message.Message): - __slots__ = ["testOutputField"] - TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testOutputField: int - def __init__(self, testOutputField: _Optional[int] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/anonymous-package/output/python/main_pb2.py deleted file mode 100644 index 4079a0f5074..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/python/main_pb2.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\"\x1f\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\"!\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x32!\n\x07Service\x12\x16\n\x03\x46oo\x12\x06.Input\x1a\x07.Outputb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _globals['_INPUT']._serialized_start=14 - _globals['_INPUT']._serialized_end=45 - _globals['_OUTPUT']._serialized_start=47 - _globals['_OUTPUT']._serialized_end=80 - _globals['_SERVICE']._serialized_start=82 - _globals['_SERVICE']._serialized_end=115 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/anonymous-package/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/anonymous-package/output/ruby/main_pb.rb deleted file mode 100644 index b2b7cffc687..00000000000 --- a/packages/protobuf/test/protoc-out/anonymous-package/output/ruby/main_pb.rb +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("main.proto", :syntax => :proto3) do - add_message "Input" do - optional :testInputField, :string, 1 - end - add_message "Output" do - optional :testOutputField, :int32, 1 - end - end -end - -Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass -Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Output").msgclass diff --git a/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.cc b/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.cc deleted file mode 100644 index cfc97ec993f..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.cc +++ /dev/null @@ -1,588 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: com/azure/test.proto - -#include "com/azure/test.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -namespace com { -namespace azure { -namespace test { -PROTOBUF_CONSTEXPR Input::Input( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.testinputfield_)*/{} - , /*decltype(_impl_._cached_size_)*/{}} {} -struct InputDefaultTypeInternal { - PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputDefaultTypeInternal() {} - union { - Input _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; -PROTOBUF_CONSTEXPR Output::Output( - ::_pbi::ConstantInitialized): _impl_{ - /* ._impl_.testoutputfield_ = */ {} - ,/* _impl_._testoutputfield_cached_byte_size_ = */ { 0 } - - , /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_._cached_size_)*/{}} {} -struct OutputDefaultTypeInternal { - PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~OutputDefaultTypeInternal() {} - union { - Output _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; -} // namespace test -} // namespace azure -} // namespace com -static ::_pb::Metadata file_level_metadata_com_2fazure_2ftest_2eproto[2]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_com_2fazure_2ftest_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_com_2fazure_2ftest_2eproto = nullptr; -const ::uint32_t TableStruct_com_2fazure_2ftest_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::com::azure::test::Input, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::com::azure::test::Input, _impl_.testinputfield_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::com::azure::test::Output, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::com::azure::test::Output, _impl_.testoutputfield_), - PROTOBUF_FIELD_OFFSET(::com::azure::test::Output, _impl_.secondfield_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::com::azure::test::Input)}, - { 9, -1, -1, sizeof(::com::azure::test::Output)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::com::azure::test::_Input_default_instance_._instance, - &::com::azure::test::_Output_default_instance_._instance, -}; -const char descriptor_table_protodef_com_2fazure_2ftest_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\024com/azure/test.proto\022\016com.azure.test\"\037" - "\n\005Input\022\026\n\016testInputField\030\001 \003(\t\"6\n\006Outpu" - "t\022\027\n\017testOutputField\030\001 \003(\005\022\023\n\013secondFiel" - "d\030\002 \001(\t2\?\n\007Service\0224\n\003Foo\022\025.com.azure.te" - "st.Input\032\026.com.azure.test.Outputb\006proto3" -}; -static ::absl::once_flag descriptor_table_com_2fazure_2ftest_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_com_2fazure_2ftest_2eproto = { - false, - false, - 200, - descriptor_table_protodef_com_2fazure_2ftest_2eproto, - "com/azure/test.proto", - &descriptor_table_com_2fazure_2ftest_2eproto_once, - nullptr, - 0, - 2, - schemas, - file_default_instances, - TableStruct_com_2fazure_2ftest_2eproto::offsets, - file_level_metadata_com_2fazure_2ftest_2eproto, - file_level_enum_descriptors_com_2fazure_2ftest_2eproto, - file_level_service_descriptors_com_2fazure_2ftest_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_com_2fazure_2ftest_2eproto_getter() { - return &descriptor_table_com_2fazure_2ftest_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_com_2fazure_2ftest_2eproto(&descriptor_table_com_2fazure_2ftest_2eproto); -namespace com { -namespace azure { -namespace test { -// =================================================================== - -class Input::_Internal { - public: -}; - -Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:com.azure.test.Input) -} -Input::Input(const Input& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Input* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){from._impl_.testinputfield_} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - // @@protoc_insertion_point(copy_constructor:com.azure.test.Input) -} - -inline void Input::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){arena} - , /*decltype(_impl_._cached_size_)*/{} - }; -} - -Input::~Input() { - // @@protoc_insertion_point(destructor:com.azure.test.Input) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Input::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testinputfield_.~RepeatedPtrField(); -} - -void Input::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Input::Clear() { -// @@protoc_insertion_point(message_clear_start:com.azure.test.Input) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // repeated string testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_testinputfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "com.azure.test.Input.testInputField")); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Input::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:com.azure.test.Input) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // repeated string testInputField = 1; - for (int i = 0, n = this->_internal_testinputfield_size(); i < n; i++) { - const auto& s = this->_internal_testinputfield(i); - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - s.data(), static_cast(s.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "com.azure.test.Input.testInputField"); - target = stream->WriteString(1, s, target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:com.azure.test.Input) - return target; -} - -::size_t Input::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:com.azure.test.Input) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated string testInputField = 1; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.testinputfield_.size()); - for (int i = 0, n = _impl_.testinputfield_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - _impl_.testinputfield_.Get(i)); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Input::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } - - -void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.test.Input) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - _this->_impl_.testinputfield_.MergeFrom(from._impl_.testinputfield_); - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Input::CopyFrom(const Input& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.test.Input) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Input::IsInitialized() const { - return true; -} - -void Input::InternalSwap(Input* other) { - using std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - _impl_.testinputfield_.InternalSwap(&other->_impl_.testinputfield_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_com_2fazure_2ftest_2eproto_getter, &descriptor_table_com_2fazure_2ftest_2eproto_once, - file_level_metadata_com_2fazure_2ftest_2eproto[0]); -} -// =================================================================== - -class Output::_Internal { - public: -}; - -Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:com.azure.test.Output) -} -Output::Output(const Output& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Output* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.testoutputfield_) { from._impl_.testoutputfield_ } - ,/* _impl_._testoutputfield_cached_byte_size_ = */ { 0 } - - , decltype(_impl_.secondfield_){} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_secondfield().empty()) { - _this->_impl_.secondfield_.Set(from._internal_secondfield(), - _this->GetArenaForAllocation()); - } - // @@protoc_insertion_point(copy_constructor:com.azure.test.Output) -} - -inline void Output::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testoutputfield_) { arena } - ,/* _impl_._testoutputfield_cached_byte_size_ = */ { 0 } - - , decltype(_impl_.secondfield_){} - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Output::~Output() { - // @@protoc_insertion_point(destructor:com.azure.test.Output) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Output::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testoutputfield_.~RepeatedField(); - _impl_.secondfield_.Destroy(); -} - -void Output::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Output::Clear() { -// @@protoc_insertion_point(message_clear_start:com.azure.test.Output) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testoutputfield_.Clear(); - _impl_.secondfield_.ClearToEmpty(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // repeated int32 testOutputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_testoutputfield(), ptr, ctx); - CHK_(ptr); - } else if (static_cast<::uint8_t>(tag) == 8) { - _internal_add_testoutputfield(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr)); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - // string secondField = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { - auto str = _internal_mutable_secondfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "com.azure.test.Output.secondField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Output::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:com.azure.test.Output) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // repeated int32 testOutputField = 1; - { - int byte_size = _impl_._testoutputfield_cached_byte_size_.Get(); - if (byte_size > 0) { - target = stream->WriteInt32Packed(1, _internal_testoutputfield(), - byte_size, target); - } - } - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "com.azure.test.Output.secondField"); - target = stream->WriteStringMaybeAliased( - 2, this->_internal_secondfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:com.azure.test.Output) - return target; -} - -::size_t Output::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:com.azure.test.Output) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated int32 testOutputField = 1; - { - std::size_t data_size = ::_pbi::WireFormatLite::Int32Size(this->_impl_.testoutputfield_) - ; - _impl_._testoutputfield_cached_byte_size_.Set(::_pbi::ToCachedSize(data_size)); - std::size_t tag_size = data_size == 0 - ? 0 - : 1 + ::_pbi::WireFormatLite::Int32Size( - static_cast(data_size)) - ; - total_size += tag_size + data_size; - } - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_secondfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Output::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } - - -void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.test.Output) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - _this->_impl_.testoutputfield_.MergeFrom(from._impl_.testoutputfield_); - if (!from._internal_secondfield().empty()) { - _this->_internal_set_secondfield(from._internal_secondfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Output::CopyFrom(const Output& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.test.Output) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Output::IsInitialized() const { - return true; -} - -void Output::InternalSwap(Output* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - _impl_.testoutputfield_.InternalSwap(&other->_impl_.testoutputfield_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.secondfield_, lhs_arena, - &other->_impl_.secondfield_, rhs_arena - ); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_com_2fazure_2ftest_2eproto_getter, &descriptor_table_com_2fazure_2ftest_2eproto_once, - file_level_metadata_com_2fazure_2ftest_2eproto[1]); -} -// @@protoc_insertion_point(namespace_scope) -} // namespace test -} // namespace azure -} // namespace com -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::com::azure::test::Input* -Arena::CreateMaybeMessage< ::com::azure::test::Input >(Arena* arena) { - return Arena::CreateMessageInternal< ::com::azure::test::Input >(arena); -} -template<> PROTOBUF_NOINLINE ::com::azure::test::Output* -Arena::CreateMaybeMessage< ::com::azure::test::Output >(Arena* arena) { - return Arena::CreateMessageInternal< ::com::azure::test::Output >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.h b/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.h deleted file mode 100644 index 1adcd851196..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/cpp/com/azure/test.pb.h +++ /dev/null @@ -1,619 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: com/azure/test.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/unknown_field_set.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_com_2fazure_2ftest_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_com_2fazure_2ftest_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_com_2fazure_2ftest_2eproto; -namespace com { -namespace azure { -namespace test { -class Input; -struct InputDefaultTypeInternal; -extern InputDefaultTypeInternal _Input_default_instance_; -class Output; -struct OutputDefaultTypeInternal; -extern OutputDefaultTypeInternal _Output_default_instance_; -} // namespace test -} // namespace azure -} // namespace com -PROTOBUF_NAMESPACE_OPEN -template <> -::com::azure::test::Input* Arena::CreateMaybeMessage<::com::azure::test::Input>(Arena*); -template <> -::com::azure::test::Output* Arena::CreateMaybeMessage<::com::azure::test::Output>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - -namespace com { -namespace azure { -namespace test { - -// =================================================================== - - -// ------------------------------------------------------------------- - -class Input final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.test.Input) */ { - public: - inline Input() : Input(nullptr) {} - ~Input() override; - explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Input(const Input& from); - Input(Input&& from) noexcept - : Input() { - *this = ::std::move(from); - } - - inline Input& operator=(const Input& from) { - CopyFrom(from); - return *this; - } - inline Input& operator=(Input&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Input& default_instance() { - return *internal_default_instance(); - } - static inline const Input* internal_default_instance() { - return reinterpret_cast( - &_Input_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Input& a, Input& b) { - a.Swap(&b); - } - inline void Swap(Input* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Input* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Input& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Input& from) { - Input::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Input* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "com.azure.test.Input"; - } - protected: - explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - }; - // repeated string testInputField = 1; - int testinputfield_size() const; - private: - int _internal_testinputfield_size() const; - - public: - void clear_testinputfield() ; - const std::string& testinputfield(int index) const; - std::string* mutable_testinputfield(int index); - void set_testinputfield(int index, const std::string& value); - void set_testinputfield(int index, std::string&& value); - void set_testinputfield(int index, const char* value); - void set_testinputfield(int index, absl::string_view value); - void set_testinputfield(int index, const char* value, ::size_t size); - std::string* add_testinputfield(); - void add_testinputfield(const std::string& value); - void add_testinputfield(std::string&& value); - void add_testinputfield(const char* value); - void add_testinputfield(absl::string_view value); - void add_testinputfield(const char* value, ::size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& testinputfield() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_testinputfield(); - private: - const std::string& _internal_testinputfield(int index) const; - std::string* _internal_add_testinputfield(); - public: - // @@protoc_insertion_point(class_scope:com.azure.test.Input) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField testinputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_com_2fazure_2ftest_2eproto; -};// ------------------------------------------------------------------- - -class Output final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.test.Output) */ { - public: - inline Output() : Output(nullptr) {} - ~Output() override; - explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Output(const Output& from); - Output(Output&& from) noexcept - : Output() { - *this = ::std::move(from); - } - - inline Output& operator=(const Output& from) { - CopyFrom(from); - return *this; - } - inline Output& operator=(Output&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Output& default_instance() { - return *internal_default_instance(); - } - static inline const Output* internal_default_instance() { - return reinterpret_cast( - &_Output_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(Output& a, Output& b) { - a.Swap(&b); - } - inline void Swap(Output* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Output* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Output& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Output& from) { - Output::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Output* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "com.azure.test.Output"; - } - protected: - explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestOutputFieldFieldNumber = 1, - kSecondFieldFieldNumber = 2, - }; - // repeated int32 testOutputField = 1; - int testoutputfield_size() const; - private: - int _internal_testoutputfield_size() const; - - public: - void clear_testoutputfield() ; - ::int32_t testoutputfield(int index) const; - void set_testoutputfield(int index, ::int32_t value); - void add_testoutputfield(::int32_t value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>& testoutputfield() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>* mutable_testoutputfield(); - - private: - ::int32_t _internal_testoutputfield(int index) const; - void _internal_add_testoutputfield(::int32_t value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>& _internal_testoutputfield() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>* _internal_mutable_testoutputfield(); - - public: - // string secondField = 2; - void clear_secondfield() ; - const std::string& secondfield() const; - template - void set_secondfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_secondfield(); - PROTOBUF_NODISCARD std::string* release_secondfield(); - void set_allocated_secondfield(std::string* secondfield); - private: - const std::string& _internal_secondfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); - std::string* _internal_mutable_secondfield(); - public: - // @@protoc_insertion_point(class_scope:com.azure.test.Output) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t> testoutputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _testoutputfield_cached_byte_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_com_2fazure_2ftest_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// Input - -// repeated string testInputField = 1; -inline int Input::_internal_testinputfield_size() const { - return _impl_.testinputfield_.size(); -} -inline int Input::testinputfield_size() const { - return _internal_testinputfield_size(); -} -inline void Input::clear_testinputfield() { - _impl_.testinputfield_.Clear(); -} -inline std::string* Input::add_testinputfield() { - std::string* _s = _internal_add_testinputfield(); - // @@protoc_insertion_point(field_add_mutable:com.azure.test.Input.testInputField) - return _s; -} -inline const std::string& Input::_internal_testinputfield(int index) const { - return _impl_.testinputfield_.Get(index); -} -inline const std::string& Input::testinputfield(int index) const { - // @@protoc_insertion_point(field_get:com.azure.test.Input.testInputField) - return _internal_testinputfield(index); -} -inline std::string* Input::mutable_testinputfield(int index) { - // @@protoc_insertion_point(field_mutable:com.azure.test.Input.testInputField) - return _impl_.testinputfield_.Mutable(index); -} -inline void Input::set_testinputfield(int index, const std::string& value) { - _impl_.testinputfield_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set:com.azure.test.Input.testInputField) -} -inline void Input::set_testinputfield(int index, std::string&& value) { - _impl_.testinputfield_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:com.azure.test.Input.testInputField) -} -inline void Input::set_testinputfield(int index, const char* value) { - ABSL_DCHECK(value != nullptr); _impl_.testinputfield_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:com.azure.test.Input.testInputField) -} -inline void Input::set_testinputfield(int index, absl::string_view value) { - _impl_.testinputfield_.Mutable(index)->assign(value.data(), value.size()); - // @@protoc_insertion_point(field_set_string_piece:com.azure.test.Input.testInputField) -} -inline void Input::set_testinputfield(int index, const char* value, ::size_t size) { - _impl_.testinputfield_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:com.azure.test.Input.testInputField) -} -inline std::string* Input::_internal_add_testinputfield() { - return _impl_.testinputfield_.Add(); -} -inline void Input::add_testinputfield(const std::string& value) { - _impl_.testinputfield_.Add()->assign(value); - // @@protoc_insertion_point(field_add:com.azure.test.Input.testInputField) -} -inline void Input::add_testinputfield(std::string&& value) { - _impl_.testinputfield_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:com.azure.test.Input.testInputField) -} -inline void Input::add_testinputfield(const char* value) { - ABSL_DCHECK(value != nullptr); _impl_.testinputfield_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:com.azure.test.Input.testInputField) -} -inline void Input::add_testinputfield(absl::string_view value) { - _impl_.testinputfield_.Add()->assign(value.data(), value.size()); - // @@protoc_insertion_point(field_add_string_piece:com.azure.test.Input.testInputField) -} -inline void Input::add_testinputfield(const char* value, ::size_t size) { - _impl_.testinputfield_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:com.azure.test.Input.testInputField) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -Input::testinputfield() const { - // @@protoc_insertion_point(field_list:com.azure.test.Input.testInputField) - return _impl_.testinputfield_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -Input::mutable_testinputfield() { - // @@protoc_insertion_point(field_mutable_list:com.azure.test.Input.testInputField) - return &_impl_.testinputfield_; -} - -// ------------------------------------------------------------------- - -// Output - -// repeated int32 testOutputField = 1; -inline int Output::_internal_testoutputfield_size() const { - return _impl_.testoutputfield_.size(); -} -inline int Output::testoutputfield_size() const { - return _internal_testoutputfield_size(); -} -inline void Output::clear_testoutputfield() { - _impl_.testoutputfield_.Clear(); -} -inline ::int32_t Output::testoutputfield(int index) const { - // @@protoc_insertion_point(field_get:com.azure.test.Output.testOutputField) - return _internal_testoutputfield(index); -} -inline void Output::set_testoutputfield(int index, ::int32_t value) { - _impl_.testoutputfield_.Set(index, value); - // @@protoc_insertion_point(field_set:com.azure.test.Output.testOutputField) -} -inline void Output::add_testoutputfield(::int32_t value) { - _internal_add_testoutputfield(value); - // @@protoc_insertion_point(field_add:com.azure.test.Output.testOutputField) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>& Output::testoutputfield() const { - // @@protoc_insertion_point(field_list:com.azure.test.Output.testOutputField) - return _internal_testoutputfield(); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>* Output::mutable_testoutputfield() { - // @@protoc_insertion_point(field_mutable_list:com.azure.test.Output.testOutputField) - return _internal_mutable_testoutputfield(); -} - -inline ::int32_t Output::_internal_testoutputfield(int index) const { - return _impl_.testoutputfield_.Get(index); -} -inline void Output::_internal_add_testoutputfield(::int32_t value) { _impl_.testoutputfield_.Add(value); } -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>& Output::_internal_testoutputfield() const { - return _impl_.testoutputfield_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField<::int32_t>* Output::_internal_mutable_testoutputfield() { - return &_impl_.testoutputfield_; -} - -// string secondField = 2; -inline void Output::clear_secondfield() { - _impl_.secondfield_.ClearToEmpty(); -} -inline const std::string& Output::secondfield() const { - // @@protoc_insertion_point(field_get:com.azure.test.Output.secondField) - return _internal_secondfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { - - _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:com.azure.test.Output.secondField) -} -inline std::string* Output::mutable_secondfield() { - std::string* _s = _internal_mutable_secondfield(); - // @@protoc_insertion_point(field_mutable:com.azure.test.Output.secondField) - return _s; -} -inline const std::string& Output::_internal_secondfield() const { - return _impl_.secondfield_.Get(); -} -inline void Output::_internal_set_secondfield(const std::string& value) { - - _impl_.secondfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Output::_internal_mutable_secondfield() { - - return _impl_.secondfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Output::release_secondfield() { - // @@protoc_insertion_point(field_release:com.azure.test.Output.secondField) - return _impl_.secondfield_.Release(); -} -inline void Output::set_allocated_secondfield(std::string* secondfield) { - _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.secondfield_.IsDefault()) { - _impl_.secondfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:com.azure.test.Output.secondField) -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) -} // namespace test -} // namespace azure -} // namespace com - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/array/output/csharp/Test.cs b/packages/protobuf/test/protoc-out/array/output/csharp/Test.cs deleted file mode 100644 index 313e70a1ee5..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/csharp/Test.cs +++ /dev/null @@ -1,442 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: com/azure/test.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Com.Azure.Test { - - /// Holder for reflection information generated from com/azure/test.proto - public static partial class TestReflection { - - #region Descriptor - /// File descriptor for com/azure/test.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static TestReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChRjb20vYXp1cmUvdGVzdC5wcm90bxIOY29tLmF6dXJlLnRlc3QiHwoFSW5w", - "dXQSFgoOdGVzdElucHV0RmllbGQYASADKAkiNgoGT3V0cHV0EhcKD3Rlc3RP", - "dXRwdXRGaWVsZBgBIAMoBRITCgtzZWNvbmRGaWVsZBgCIAEoCTI/CgdTZXJ2", - "aWNlEjQKA0ZvbxIVLmNvbS5henVyZS50ZXN0LklucHV0GhYuY29tLmF6dXJl", - "LnRlc3QuT3V0cHV0YgZwcm90bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.Input), global::Com.Azure.Test.Input.Parser, new[]{ "TestInputField" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.Output), global::Com.Azure.Test.Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class Input : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input(Input other) : this() { - testInputField_ = other.testInputField_.Clone(); - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input Clone() { - return new Input(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private static readonly pb::FieldCodec _repeated_testInputField_codec - = pb::FieldCodec.ForString(10); - private readonly pbc::RepeatedField testInputField_ = new pbc::RepeatedField(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public pbc::RepeatedField TestInputField { - get { return testInputField_; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Input); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Input other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if(!testInputField_.Equals(other.testInputField_)) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - hash ^= testInputField_.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - testInputField_.WriteTo(output, _repeated_testInputField_codec); - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - testInputField_.WriteTo(ref output, _repeated_testInputField_codec); - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - size += testInputField_.CalculateSize(_repeated_testInputField_codec); - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Input other) { - if (other == null) { - return; - } - testInputField_.Add(other.testInputField_); - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - testInputField_.AddEntriesFrom(input, _repeated_testInputField_codec); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - testInputField_.AddEntriesFrom(ref input, _repeated_testInputField_codec); - break; - } - } - } - } - #endif - - } - - public sealed partial class Output : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output(Output other) : this() { - testOutputField_ = other.testOutputField_.Clone(); - secondField_ = other.secondField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output Clone() { - return new Output(this); - } - - /// Field number for the "testOutputField" field. - public const int TestOutputFieldFieldNumber = 1; - private static readonly pb::FieldCodec _repeated_testOutputField_codec - = pb::FieldCodec.ForInt32(10); - private readonly pbc::RepeatedField testOutputField_ = new pbc::RepeatedField(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public pbc::RepeatedField TestOutputField { - get { return testOutputField_; } - } - - /// Field number for the "secondField" field. - public const int SecondFieldFieldNumber = 2; - private string secondField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string SecondField { - get { return secondField_; } - set { - secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Output); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Output other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if(!testOutputField_.Equals(other.testOutputField_)) return false; - if (SecondField != other.SecondField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - hash ^= testOutputField_.GetHashCode(); - if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - testOutputField_.WriteTo(output, _repeated_testOutputField_codec); - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - testOutputField_.WriteTo(ref output, _repeated_testOutputField_codec); - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - size += testOutputField_.CalculateSize(_repeated_testOutputField_codec); - if (SecondField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Output other) { - if (other == null) { - return; - } - testOutputField_.Add(other.testOutputField_); - if (other.SecondField.Length != 0) { - SecondField = other.SecondField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: - case 8: { - testOutputField_.AddEntriesFrom(input, _repeated_testOutputField_codec); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: - case 8: { - testOutputField_.AddEntriesFrom(ref input, _repeated_testOutputField_codec); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - } - #endif - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.h b/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.h deleted file mode 100644 index fabc5d7f1d5..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.h +++ /dev/null @@ -1,87 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: com/azure/test.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - TestRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface TestRoot : GPBRootObject -@end - -#pragma mark - Input - -typedef GPB_ENUM(Input_FieldNumber) { - Input_FieldNumber_TestInputFieldArray = 1, -}; - -GPB_FINAL @interface Input : GPBMessage - -@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *testInputFieldArray; -/** The number of items in @c testInputFieldArray without causing the container to be created. */ -@property(nonatomic, readonly) NSUInteger testInputFieldArray_Count; - -@end - -#pragma mark - Output - -typedef GPB_ENUM(Output_FieldNumber) { - Output_FieldNumber_TestOutputFieldArray = 1, - Output_FieldNumber_SecondField = 2, -}; - -GPB_FINAL @interface Output : GPBMessage - -@property(nonatomic, readwrite, strong, null_resettable) GPBInt32Array *testOutputFieldArray; -/** The number of items in @c testOutputFieldArray without causing the container to be created. */ -@property(nonatomic, readonly) NSUInteger testOutputFieldArray_Count; - -@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.m b/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.m deleted file mode 100644 index 16186aa9cd6..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/objc/com/azure/Test.pbobjc.m +++ /dev/null @@ -1,160 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: com/azure/test.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "com/azure/Test.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -#pragma mark - TestRoot - -@implementation TestRoot - -// No extensions in the file and no imports, so no need to generate -// +extensionRegistry. - -@end - -#pragma mark - TestRoot_FileDescriptor - -static GPBFileDescriptor *TestRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"com.azure.test" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - Input - -@implementation Input - -@dynamic testInputFieldArray, testInputFieldArray_Count; - -typedef struct Input__storage_ { - uint32_t _has_storage_[1]; - NSMutableArray *testInputFieldArray; -} Input__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputFieldArray", - .dataTypeSpecific.clazz = Nil, - .number = Input_FieldNumber_TestInputFieldArray, - .hasIndex = GPBNoHasBit, - .offset = (uint32_t)offsetof(Input__storage_, testInputFieldArray), - .flags = (GPBFieldFlags)(GPBFieldRepeated | GPBFieldTextFormatNameCustom), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Input class] - file:TestRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Input__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\000testInputField\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - Output - -@implementation Output - -@dynamic testOutputFieldArray, testOutputFieldArray_Count; -@dynamic secondField; - -typedef struct Output__storage_ { - uint32_t _has_storage_[1]; - GPBInt32Array *testOutputFieldArray; - NSString *secondField; -} Output__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testOutputFieldArray", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_TestOutputFieldArray, - .hasIndex = GPBNoHasBit, - .offset = (uint32_t)offsetof(Output__storage_, testOutputFieldArray), - .flags = (GPBFieldFlags)(GPBFieldRepeated | GPBFieldPacked | GPBFieldTextFormatNameCustom), - .dataType = GPBDataTypeInt32, - }, - { - .name = "secondField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_SecondField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Output__storage_, secondField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Output class] - file:TestRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Output__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\002\001\000testOutputField\000\002\013\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Input.php b/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Input.php deleted file mode 100644 index b86156b36cc..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Input.php +++ /dev/null @@ -1,58 +0,0 @@ -com.azure.test.Input - */ -class Input extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field repeated string testInputField = 1; - */ - private $testInputField; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array|\Google\Protobuf\Internal\RepeatedField $testInputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Com\Azure\Test::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field repeated string testInputField = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field repeated string testInputField = 1; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setTestInputField($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->testInputField = $arr; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Output.php b/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Output.php deleted file mode 100644 index 63ae45939b8..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/php/Com/Azure/Test/Output.php +++ /dev/null @@ -1,85 +0,0 @@ -com.azure.test.Output - */ -class Output extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field repeated int32 testOutputField = 1; - */ - private $testOutputField; - /** - * Generated from protobuf field string secondField = 2; - */ - protected $secondField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array|\Google\Protobuf\Internal\RepeatedField $testOutputField - * @type string $secondField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Com\Azure\Test::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field repeated int32 testOutputField = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getTestOutputField() - { - return $this->testOutputField; - } - - /** - * Generated from protobuf field repeated int32 testOutputField = 1; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setTestOutputField($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); - $this->testOutputField = $arr; - - return $this; - } - - /** - * Generated from protobuf field string secondField = 2; - * @return string - */ - public function getSecondField() - { - return $this->secondField; - } - - /** - * Generated from protobuf field string secondField = 2; - * @param string $var - * @return $this - */ - public function setSecondField($var) - { - GPBUtil::checkString($var, True); - $this->secondField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/array/output/php/GPBMetadata/Com/Azure/Test.php b/packages/protobuf/test/protoc-out/array/output/php/GPBMetadata/Com/Azure/Test.php deleted file mode 100644 index 6648a81797e..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/php/GPBMetadata/Com/Azure/Test.php +++ /dev/null @@ -1,33 +0,0 @@ -internalAddGeneratedFile( - ' -� -com/azure/test.protocom.azure.test" -Input -testInputField ( "6 -Output -testOutputField ( - secondField ( 2? -Service4 -Foo.com.azure.test.Input.com.azure.test.Outputbproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/packages/protobuf/test/protoc-out/array/output/pyi/com/azure/test_pb2.pyi b/packages/protobuf/test/protoc-out/array/output/pyi/com/azure/test_pb2.pyi deleted file mode 100644 index bc1d3882971..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/pyi/com/azure/test_pb2.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from google.protobuf.internal import containers as _containers -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Iterable as _Iterable, Optional as _Optional - -DESCRIPTOR: _descriptor.FileDescriptor - -class Input(_message.Message): - __slots__ = ["testInputField"] - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testInputField: _containers.RepeatedScalarFieldContainer[str] - def __init__(self, testInputField: _Optional[_Iterable[str]] = ...) -> None: ... - -class Output(_message.Message): - __slots__ = ["testOutputField", "secondField"] - TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] - SECONDFIELD_FIELD_NUMBER: _ClassVar[int] - testOutputField: _containers.RepeatedScalarFieldContainer[int] - secondField: str - def __init__(self, testOutputField: _Optional[_Iterable[int]] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/array/output/python/com/azure/test_pb2.py b/packages/protobuf/test/protoc-out/array/output/python/com/azure/test_pb2.py deleted file mode 100644 index 4cc52faa7f1..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/python/com/azure/test_pb2.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: com/azure/test.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x63om/azure/test.proto\x12\x0e\x63om.azure.test\"\x1f\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x03(\t\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x03(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t2?\n\x07Service\x12\x34\n\x03\x46oo\x12\x15.com.azure.test.Input\x1a\x16.com.azure.test.Outputb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'com.azure.test_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _globals['_INPUT']._serialized_start=40 - _globals['_INPUT']._serialized_end=71 - _globals['_OUTPUT']._serialized_start=73 - _globals['_OUTPUT']._serialized_end=127 - _globals['_SERVICE']._serialized_start=129 - _globals['_SERVICE']._serialized_end=192 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/array/output/ruby/com/azure/test_pb.rb b/packages/protobuf/test/protoc-out/array/output/ruby/com/azure/test_pb.rb deleted file mode 100644 index 555e0977bd6..00000000000 --- a/packages/protobuf/test/protoc-out/array/output/ruby/com/azure/test_pb.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: com/azure/test.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("com/azure/test.proto", :syntax => :proto3) do - add_message "com.azure.test.Input" do - repeated :testInputField, :string, 1 - end - add_message "com.azure.test.Output" do - repeated :testOutputField, :int32, 1 - optional :secondField, :string, 2 - end - end -end - -module Com - module Azure - module Test - Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.test.Input").msgclass - Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.test.Output").msgclass - end - end -end diff --git a/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.cc b/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.cc deleted file mode 100644 index 390ed4a88bd..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.cc +++ /dev/null @@ -1,349 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: A.proto - -#include "A.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -namespace A { -PROTOBUF_CONSTEXPR Output::Output( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /* ._impl_.testoutputfield_ = */ 0 - - , /*decltype(_impl_._cached_size_)*/{}} {} -struct OutputDefaultTypeInternal { - PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~OutputDefaultTypeInternal() {} - union { - Output _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; -} // namespace A -static ::_pb::Metadata file_level_metadata_A_2eproto[1]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_A_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_A_2eproto = nullptr; -const ::uint32_t TableStruct_A_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::A::Output, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::A::Output, _impl_.testoutputfield_), - PROTOBUF_FIELD_OFFSET(::A::Output, _impl_.secondfield_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::A::Output)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::A::_Output_default_instance_._instance, -}; -const char descriptor_table_protodef_A_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\007A.proto\022\001A\"6\n\006Output\022\027\n\017testOutputFiel" - "d\030\001 \001(\005\022\023\n\013secondField\030\002 \001(\tb\006proto3" -}; -static ::absl::once_flag descriptor_table_A_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_A_2eproto = { - false, - false, - 76, - descriptor_table_protodef_A_2eproto, - "A.proto", - &descriptor_table_A_2eproto_once, - nullptr, - 0, - 1, - schemas, - file_default_instances, - TableStruct_A_2eproto::offsets, - file_level_metadata_A_2eproto, - file_level_enum_descriptors_A_2eproto, - file_level_service_descriptors_A_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_A_2eproto_getter() { - return &descriptor_table_A_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_A_2eproto(&descriptor_table_A_2eproto); -namespace A { -// =================================================================== - -class Output::_Internal { - public: -}; - -Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:A.Output) -} -Output::Output(const Output& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Output* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) {} - - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_secondfield().empty()) { - _this->_impl_.secondfield_.Set(from._internal_secondfield(), - _this->GetArenaForAllocation()); - } - _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; - // @@protoc_insertion_point(copy_constructor:A.Output) -} - -inline void Output::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) { 0 } - - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Output::~Output() { - // @@protoc_insertion_point(destructor:A.Output) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Output::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.secondfield_.Destroy(); -} - -void Output::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Output::Clear() { -// @@protoc_insertion_point(message_clear_start:A.Output) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.secondfield_.ClearToEmpty(); - _impl_.testoutputfield_ = 0; - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // int32 testOutputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { - _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - // string secondField = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { - auto str = _internal_mutable_secondfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "A.Output.secondField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Output::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:A.Output) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray( - 1, this->_internal_testoutputfield(), target); - } - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "A.Output.secondField"); - target = stream->WriteStringMaybeAliased( - 2, this->_internal_secondfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:A.Output) - return target; -} - -::size_t Output::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:A.Output) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_secondfield()); - } - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( - this->_internal_testoutputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Output::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } - - -void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:A.Output) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_secondfield().empty()) { - _this->_internal_set_secondfield(from._internal_secondfield()); - } - if (from._internal_testoutputfield() != 0) { - _this->_internal_set_testoutputfield(from._internal_testoutputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Output::CopyFrom(const Output& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:A.Output) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Output::IsInitialized() const { - return true; -} - -void Output::InternalSwap(Output* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.secondfield_, lhs_arena, - &other->_impl_.secondfield_, rhs_arena - ); - - swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_A_2eproto_getter, &descriptor_table_A_2eproto_once, - file_level_metadata_A_2eproto[0]); -} -// @@protoc_insertion_point(namespace_scope) -} // namespace A -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::A::Output* -Arena::CreateMaybeMessage< ::A::Output >(Arena* arena) { - return Arena::CreateMessageInternal< ::A::Output >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.h b/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.h deleted file mode 100644 index eaa516d72a2..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/cpp/A.pb.h +++ /dev/null @@ -1,326 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: A.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_A_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_A_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/unknown_field_set.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_A_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_A_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_A_2eproto; -namespace A { -class Output; -struct OutputDefaultTypeInternal; -extern OutputDefaultTypeInternal _Output_default_instance_; -} // namespace A -PROTOBUF_NAMESPACE_OPEN -template <> -::A::Output* Arena::CreateMaybeMessage<::A::Output>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - -namespace A { - -// =================================================================== - - -// ------------------------------------------------------------------- - -class Output final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:A.Output) */ { - public: - inline Output() : Output(nullptr) {} - ~Output() override; - explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Output(const Output& from); - Output(Output&& from) noexcept - : Output() { - *this = ::std::move(from); - } - - inline Output& operator=(const Output& from) { - CopyFrom(from); - return *this; - } - inline Output& operator=(Output&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Output& default_instance() { - return *internal_default_instance(); - } - static inline const Output* internal_default_instance() { - return reinterpret_cast( - &_Output_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Output& a, Output& b) { - a.Swap(&b); - } - inline void Swap(Output* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Output* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Output& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Output& from) { - Output::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Output* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "A.Output"; - } - protected: - explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kSecondFieldFieldNumber = 2, - kTestOutputFieldFieldNumber = 1, - }; - // string secondField = 2; - void clear_secondfield() ; - const std::string& secondfield() const; - template - void set_secondfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_secondfield(); - PROTOBUF_NODISCARD std::string* release_secondfield(); - void set_allocated_secondfield(std::string* secondfield); - private: - const std::string& _internal_secondfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); - std::string* _internal_mutable_secondfield(); - public: - // int32 testOutputField = 1; - void clear_testoutputfield() ; - ::int32_t testoutputfield() const; - void set_testoutputfield(::int32_t value); - - private: - ::int32_t _internal_testoutputfield() const; - void _internal_set_testoutputfield(::int32_t value); - - public: - // @@protoc_insertion_point(class_scope:A.Output) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; - ::int32_t testoutputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_A_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// Output - -// int32 testOutputField = 1; -inline void Output::clear_testoutputfield() { - _impl_.testoutputfield_ = 0; -} -inline ::int32_t Output::testoutputfield() const { - // @@protoc_insertion_point(field_get:A.Output.testOutputField) - return _internal_testoutputfield(); -} -inline void Output::set_testoutputfield(::int32_t value) { - ; - _internal_set_testoutputfield(value); - // @@protoc_insertion_point(field_set:A.Output.testOutputField) -} -inline ::int32_t Output::_internal_testoutputfield() const { - return _impl_.testoutputfield_; -} -inline void Output::_internal_set_testoutputfield(::int32_t value) { - ; - _impl_.testoutputfield_ = value; -} - -// string secondField = 2; -inline void Output::clear_secondfield() { - _impl_.secondfield_.ClearToEmpty(); -} -inline const std::string& Output::secondfield() const { - // @@protoc_insertion_point(field_get:A.Output.secondField) - return _internal_secondfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { - - _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:A.Output.secondField) -} -inline std::string* Output::mutable_secondfield() { - std::string* _s = _internal_mutable_secondfield(); - // @@protoc_insertion_point(field_mutable:A.Output.secondField) - return _s; -} -inline const std::string& Output::_internal_secondfield() const { - return _impl_.secondfield_.Get(); -} -inline void Output::_internal_set_secondfield(const std::string& value) { - - _impl_.secondfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Output::_internal_mutable_secondfield() { - - return _impl_.secondfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Output::release_secondfield() { - // @@protoc_insertion_point(field_release:A.Output.secondField) - return _impl_.secondfield_.Release(); -} -inline void Output::set_allocated_secondfield(std::string* secondfield) { - _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.secondfield_.IsDefault()) { - _impl_.secondfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:A.Output.secondField) -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) -} // namespace A - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_A_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.cc b/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.cc deleted file mode 100644 index 9c9b1d3bb04..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.cc +++ /dev/null @@ -1,318 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: B.proto - -#include "B.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -namespace B { -PROTOBUF_CONSTEXPR Input::Input( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_._cached_size_)*/{}} {} -struct InputDefaultTypeInternal { - PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputDefaultTypeInternal() {} - union { - Input _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; -} // namespace B -static ::_pb::Metadata file_level_metadata_B_2eproto[1]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_B_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_B_2eproto = nullptr; -const ::uint32_t TableStruct_B_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::B::Input, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::B::Input, _impl_.testinputfield_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::B::Input)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::B::_Input_default_instance_._instance, -}; -const char descriptor_table_protodef_B_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\007B.proto\022\001B\032\007A.proto\"\037\n\005Input\022\026\n\016testIn" - "putField\030\001 \001(\t2%\n\007Service\022\032\n\003Foo\022\010.B.Inp" - "ut\032\t.A.Outputb\006proto3" -}; -static const ::_pbi::DescriptorTable* const descriptor_table_B_2eproto_deps[1] = - { - &::descriptor_table_A_2eproto, -}; -static ::absl::once_flag descriptor_table_B_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_B_2eproto = { - false, - false, - 101, - descriptor_table_protodef_B_2eproto, - "B.proto", - &descriptor_table_B_2eproto_once, - descriptor_table_B_2eproto_deps, - 1, - 1, - schemas, - file_default_instances, - TableStruct_B_2eproto::offsets, - file_level_metadata_B_2eproto, - file_level_enum_descriptors_B_2eproto, - file_level_service_descriptors_B_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_B_2eproto_getter() { - return &descriptor_table_B_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_B_2eproto(&descriptor_table_B_2eproto); -namespace B { -// =================================================================== - -class Input::_Internal { - public: -}; - -Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:B.Input) -} -Input::Input(const Input& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Input* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_testinputfield().empty()) { - _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), - _this->GetArenaForAllocation()); - } - // @@protoc_insertion_point(copy_constructor:B.Input) -} - -inline void Input::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Input::~Input() { - // @@protoc_insertion_point(destructor:B.Input) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Input::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testinputfield_.Destroy(); -} - -void Input::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Input::Clear() { -// @@protoc_insertion_point(message_clear_start:B.Input) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_.ClearToEmpty(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // string testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - auto str = _internal_mutable_testinputfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "B.Input.testInputField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Input::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:B.Input) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "B.Input.testInputField"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_testinputfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:B.Input) - return target; -} - -::size_t Input::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:B.Input) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_testinputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Input::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } - - -void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:B.Input) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_testinputfield().empty()) { - _this->_internal_set_testinputfield(from._internal_testinputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Input::CopyFrom(const Input& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:B.Input) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Input::IsInitialized() const { - return true; -} - -void Input::InternalSwap(Input* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.testinputfield_, lhs_arena, - &other->_impl_.testinputfield_, rhs_arena - ); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_B_2eproto_getter, &descriptor_table_B_2eproto_once, - file_level_metadata_B_2eproto[0]); -} -// @@protoc_insertion_point(namespace_scope) -} // namespace B -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::B::Input* -Arena::CreateMaybeMessage< ::B::Input >(Arena* arena) { - return Arena::CreateMessageInternal< ::B::Input >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.h b/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.h deleted file mode 100644 index b5949ea593e..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/cpp/B.pb.h +++ /dev/null @@ -1,294 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: B.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_B_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_B_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/unknown_field_set.h" -#include "A.pb.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_B_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_B_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_B_2eproto; -namespace B { -class Input; -struct InputDefaultTypeInternal; -extern InputDefaultTypeInternal _Input_default_instance_; -} // namespace B -PROTOBUF_NAMESPACE_OPEN -template <> -::B::Input* Arena::CreateMaybeMessage<::B::Input>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - -namespace B { - -// =================================================================== - - -// ------------------------------------------------------------------- - -class Input final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:B.Input) */ { - public: - inline Input() : Input(nullptr) {} - ~Input() override; - explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Input(const Input& from); - Input(Input&& from) noexcept - : Input() { - *this = ::std::move(from); - } - - inline Input& operator=(const Input& from) { - CopyFrom(from); - return *this; - } - inline Input& operator=(Input&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Input& default_instance() { - return *internal_default_instance(); - } - static inline const Input* internal_default_instance() { - return reinterpret_cast( - &_Input_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Input& a, Input& b) { - a.Swap(&b); - } - inline void Swap(Input* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Input* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Input& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Input& from) { - Input::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Input* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "B.Input"; - } - protected: - explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - }; - // string testInputField = 1; - void clear_testinputfield() ; - const std::string& testinputfield() const; - template - void set_testinputfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_testinputfield(); - PROTOBUF_NODISCARD std::string* release_testinputfield(); - void set_allocated_testinputfield(std::string* testinputfield); - private: - const std::string& _internal_testinputfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); - std::string* _internal_mutable_testinputfield(); - public: - // @@protoc_insertion_point(class_scope:B.Input) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_B_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// Input - -// string testInputField = 1; -inline void Input::clear_testinputfield() { - _impl_.testinputfield_.ClearToEmpty(); -} -inline const std::string& Input::testinputfield() const { - // @@protoc_insertion_point(field_get:B.Input.testInputField) - return _internal_testinputfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { - - _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:B.Input.testInputField) -} -inline std::string* Input::mutable_testinputfield() { - std::string* _s = _internal_mutable_testinputfield(); - // @@protoc_insertion_point(field_mutable:B.Input.testInputField) - return _s; -} -inline const std::string& Input::_internal_testinputfield() const { - return _impl_.testinputfield_.Get(); -} -inline void Input::_internal_set_testinputfield(const std::string& value) { - - _impl_.testinputfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Input::_internal_mutable_testinputfield() { - - return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Input::release_testinputfield() { - // @@protoc_insertion_point(field_release:B.Input.testInputField) - return _impl_.testinputfield_.Release(); -} -inline void Input::set_allocated_testinputfield(std::string* testinputfield) { - _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.testinputfield_.IsDefault()) { - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:B.Input.testInputField) -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) -} // namespace B - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_B_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/cross package references/output/csharp/A.cs b/packages/protobuf/test/protoc-out/cross package references/output/csharp/A.cs deleted file mode 100644 index 2abe1daf18f..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/csharp/A.cs +++ /dev/null @@ -1,269 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: A.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace A { - - /// Holder for reflection information generated from A.proto - public static partial class AReflection { - - #region Descriptor - /// File descriptor for A.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static AReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgdBLnByb3RvEgFBIjYKBk91dHB1dBIXCg90ZXN0T3V0cHV0RmllbGQYASAB", - "KAUSEwoLc2Vjb25kRmllbGQYAiABKAliBnByb3RvMw==")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::A.Output), global::A.Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class Output : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::A.AReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output(Output other) : this() { - testOutputField_ = other.testOutputField_; - secondField_ = other.secondField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output Clone() { - return new Output(this); - } - - /// Field number for the "testOutputField" field. - public const int TestOutputFieldFieldNumber = 1; - private int testOutputField_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int TestOutputField { - get { return testOutputField_; } - set { - testOutputField_ = value; - } - } - - /// Field number for the "secondField" field. - public const int SecondFieldFieldNumber = 2; - private string secondField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string SecondField { - get { return secondField_; } - set { - secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Output); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Output other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestOutputField != other.TestOutputField) return false; - if (SecondField != other.SecondField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); - if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestOutputField != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); - } - if (SecondField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Output other) { - if (other == null) { - return; - } - if (other.TestOutputField != 0) { - TestOutputField = other.TestOutputField; - } - if (other.SecondField.Length != 0) { - SecondField = other.SecondField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - } - #endif - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/cross package references/output/csharp/B.cs b/packages/protobuf/test/protoc-out/cross package references/output/csharp/B.cs deleted file mode 100644 index 864f299ff6e..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/csharp/B.cs +++ /dev/null @@ -1,233 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: B.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace B { - - /// Holder for reflection information generated from B.proto - public static partial class BReflection { - - #region Descriptor - /// File descriptor for B.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static BReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgdCLnByb3RvEgFCGgdBLnByb3RvIh8KBUlucHV0EhYKDnRlc3RJbnB1dEZp", - "ZWxkGAEgASgJMiUKB1NlcnZpY2USGgoDRm9vEgguQi5JbnB1dBoJLkEuT3V0", - "cHV0YgZwcm90bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::A.AReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::B.Input), global::B.Input.Parser, new[]{ "TestInputField" }, null, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class Input : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::B.BReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input(Input other) : this() { - testInputField_ = other.testInputField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input Clone() { - return new Input(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private string testInputField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string TestInputField { - get { return testInputField_; } - set { - testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Input); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Input other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestInputField != other.TestInputField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestInputField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Input other) { - if (other == null) { - return; - } - if (other.TestInputField.Length != 0) { - TestInputField = other.TestInputField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - } - #endif - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.h b/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.h deleted file mode 100644 index 6c9727d056a..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.h +++ /dev/null @@ -1,71 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: A.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - ARoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface ARoot : GPBRootObject -@end - -#pragma mark - Output - -typedef GPB_ENUM(Output_FieldNumber) { - Output_FieldNumber_TestOutputField = 1, - Output_FieldNumber_SecondField = 2, -}; - -GPB_FINAL @interface Output : GPBMessage - -@property(nonatomic, readwrite) int32_t testOutputField; - -@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.m b/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.m deleted file mode 100644 index 46d1e3070b7..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/objc/A.pbobjc.m +++ /dev/null @@ -1,111 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: A.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "A.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -#pragma mark - ARoot - -@implementation ARoot - -// No extensions in the file and no imports, so no need to generate -// +extensionRegistry. - -@end - -#pragma mark - ARoot_FileDescriptor - -static GPBFileDescriptor *ARoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"A" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - Output - -@implementation Output - -@dynamic testOutputField; -@dynamic secondField; - -typedef struct Output__storage_ { - uint32_t _has_storage_[1]; - int32_t testOutputField; - NSString *secondField; -} Output__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testOutputField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_TestOutputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Output__storage_, testOutputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeInt32, - }, - { - .name = "secondField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_SecondField, - .hasIndex = 1, - .offset = (uint32_t)offsetof(Output__storage_, secondField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Output class] - file:ARoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Output__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\002\001\017\000\002\013\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.h b/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.h deleted file mode 100644 index 9de696ef00b..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.h +++ /dev/null @@ -1,68 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: B.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - BRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface BRoot : GPBRootObject -@end - -#pragma mark - Input - -typedef GPB_ENUM(Input_FieldNumber) { - Input_FieldNumber_TestInputField = 1, -}; - -GPB_FINAL @interface Input : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.m b/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.m deleted file mode 100644 index 6f9995a7220..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/objc/B.pbobjc.m +++ /dev/null @@ -1,101 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: B.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "B.pbobjc.h" -#import "A.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -#pragma mark - BRoot - -@implementation BRoot - -// No extensions in the file and none of the imports (direct or indirect) -// defined extensions, so no need to generate +extensionRegistry. - -@end - -#pragma mark - BRoot_FileDescriptor - -static GPBFileDescriptor *BRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"B" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - Input - -@implementation Input - -@dynamic testInputField; - -typedef struct Input__storage_ { - uint32_t _has_storage_[1]; - NSString *testInputField; -} Input__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputField", - .dataTypeSpecific.clazz = Nil, - .number = Input_FieldNumber_TestInputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Input__storage_, testInputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Input class] - file:BRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Input__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\016\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/cross package references/output/php/A/Output.php b/packages/protobuf/test/protoc-out/cross package references/output/php/A/Output.php deleted file mode 100644 index 8060a81c47e..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/php/A/Output.php +++ /dev/null @@ -1,85 +0,0 @@ -A.Output - */ -class Output extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field int32 testOutputField = 1; - */ - protected $testOutputField = 0; - /** - * Generated from protobuf field string secondField = 2; - */ - protected $secondField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $testOutputField - * @type string $secondField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\A::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @return int - */ - public function getTestOutputField() - { - return $this->testOutputField; - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @param int $var - * @return $this - */ - public function setTestOutputField($var) - { - GPBUtil::checkInt32($var); - $this->testOutputField = $var; - - return $this; - } - - /** - * Generated from protobuf field string secondField = 2; - * @return string - */ - public function getSecondField() - { - return $this->secondField; - } - - /** - * Generated from protobuf field string secondField = 2; - * @param string $var - * @return $this - */ - public function setSecondField($var) - { - GPBUtil::checkString($var, True); - $this->secondField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/cross package references/output/php/B/Input.php b/packages/protobuf/test/protoc-out/cross package references/output/php/B/Input.php deleted file mode 100644 index 7bfe09ef131..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/php/B/Input.php +++ /dev/null @@ -1,58 +0,0 @@ -B.Input - */ -class Input extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field string testInputField = 1; - */ - protected $testInputField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $testInputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\B::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field string testInputField = 1; - * @return string - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field string testInputField = 1; - * @param string $var - * @return $this - */ - public function setTestInputField($var) - { - GPBUtil::checkString($var, True); - $this->testInputField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/A.php b/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/A.php deleted file mode 100644 index 19a2fdef0c9..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/A.php +++ /dev/null @@ -1,29 +0,0 @@ -internalAddGeneratedFile( - ' -L -A.protoA"6 -Output -testOutputField ( - secondField ( bproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/B.php b/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/B.php deleted file mode 100644 index c9a623c5577..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/php/GPBMetadata/B.php +++ /dev/null @@ -1,31 +0,0 @@ -internalAddGeneratedFile( - ' -\\ -B.protoB" -Input -testInputField ( 2% -Service -Foo.B.Input .A.Outputbproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/packages/protobuf/test/protoc-out/cross package references/output/pyi/A_pb2.pyi b/packages/protobuf/test/protoc-out/cross package references/output/pyi/A_pb2.pyi deleted file mode 100644 index be7a595f3b3..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/pyi/A_pb2.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Optional as _Optional - -DESCRIPTOR: _descriptor.FileDescriptor - -class Output(_message.Message): - __slots__ = ["testOutputField", "secondField"] - TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] - SECONDFIELD_FIELD_NUMBER: _ClassVar[int] - testOutputField: int - secondField: str - def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/cross package references/output/pyi/B_pb2.pyi b/packages/protobuf/test/protoc-out/cross package references/output/pyi/B_pb2.pyi deleted file mode 100644 index e3f282609e3..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/pyi/B_pb2.pyi +++ /dev/null @@ -1,12 +0,0 @@ -import A_pb2 as _A_pb2 -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Optional as _Optional - -DESCRIPTOR: _descriptor.FileDescriptor - -class Input(_message.Message): - __slots__ = ["testInputField"] - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testInputField: str - def __init__(self, testInputField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/cross package references/output/python/A_pb2.py b/packages/protobuf/test/protoc-out/cross package references/output/python/A_pb2.py deleted file mode 100644 index cc819278baf..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/python/A_pb2.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: A.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x07\x41.proto\x12\x01\x41\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\tb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'A_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _globals['_OUTPUT']._serialized_start=14 - _globals['_OUTPUT']._serialized_end=68 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/cross package references/output/python/B_pb2.py b/packages/protobuf/test/protoc-out/cross package references/output/python/B_pb2.py deleted file mode 100644 index bdb5689127f..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/python/B_pb2.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: B.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -import A_pb2 as A__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x07\x42.proto\x12\x01\x42\x1a\x07\x41.proto\"\x1f\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\t2%\n\x07Service\x12\x1a\n\x03\x46oo\x12\x08.B.Input\x1a\t.A.Outputb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'B_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _globals['_INPUT']._serialized_start=23 - _globals['_INPUT']._serialized_end=54 - _globals['_SERVICE']._serialized_start=56 - _globals['_SERVICE']._serialized_end=93 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/cross package references/output/ruby/A_pb.rb b/packages/protobuf/test/protoc-out/cross package references/output/ruby/A_pb.rb deleted file mode 100644 index 9843fe0d386..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/ruby/A_pb.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: A.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("A.proto", :syntax => :proto3) do - add_message "A.Output" do - optional :testOutputField, :int32, 1 - optional :secondField, :string, 2 - end - end -end - -module A - Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("A.Output").msgclass -end diff --git a/packages/protobuf/test/protoc-out/cross package references/output/ruby/B_pb.rb b/packages/protobuf/test/protoc-out/cross package references/output/ruby/B_pb.rb deleted file mode 100644 index 17a5ebff7de..00000000000 --- a/packages/protobuf/test/protoc-out/cross package references/output/ruby/B_pb.rb +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: B.proto - -require 'google/protobuf' - -require 'A_pb' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("B.proto", :syntax => :proto3) do - add_message "B.Input" do - optional :testInputField, :string, 1 - end - end -end - -module B - Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("B.Input").msgclass -end diff --git a/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.cc deleted file mode 100644 index 7d5861a58ab..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.cc +++ /dev/null @@ -1,677 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#include "main.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -PROTOBUF_CONSTEXPR Input::Input( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.type_)*/0 - , /*decltype(_impl_.aliased_)*/0 - , /*decltype(_impl_._cached_size_)*/{}} {} -struct InputDefaultTypeInternal { - PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputDefaultTypeInternal() {} - union { - Input _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; -PROTOBUF_CONSTEXPR Output::Output( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /* ._impl_.testoutputfield_ = */ 0 - - , /*decltype(_impl_._cached_size_)*/{}} {} -struct OutputDefaultTypeInternal { - PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~OutputDefaultTypeInternal() {} - union { - Output _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; -static ::_pb::Metadata file_level_metadata_main_2eproto[2]; -static const ::_pb::EnumDescriptor* file_level_enum_descriptors_main_2eproto[2]; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_main_2eproto = nullptr; -const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::Input, _impl_.testinputfield_), - PROTOBUF_FIELD_OFFSET(::Input, _impl_.type_), - PROTOBUF_FIELD_OFFSET(::Input, _impl_.aliased_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::Output, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::Output, _impl_.testoutputfield_), - PROTOBUF_FIELD_OFFSET(::Output, _impl_.secondfield_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::Input)}, - { 11, -1, -1, sizeof(::Output)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::_Input_default_instance_._instance, - &::_Output_default_instance_._instance, -}; -const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\nmain.proto\"_\n\005Input\022\026\n\016testInputField\030" - "\001 \001(\t\022\030\n\004type\030\002 \001(\0162\n.InputType\022$\n\007alias" - "ed\030\003 \001(\0162\023.InputTypeWithAlias\"6\n\006Output\022" - "\027\n\017testOutputField\030\001 \001(\005\022\023\n\013secondField\030" - "\002 \001(\t*\035\n\tInputType\022\007\n\003FOO\020\000\022\007\n\003BAR\020\001*3\n\022" - "InputTypeWithAlias\022\007\n\003BAZ\020\000\022\007\n\003QUX\020\001\022\007\n\003" - "FUZ\020\001\032\002\020\0012!\n\007Service\022\026\n\003Foo\022\006.Input\032\007.Ou" - "tputb\006proto3" -}; -static ::absl::once_flag descriptor_table_main_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { - false, - false, - 292, - descriptor_table_protodef_main_2eproto, - "main.proto", - &descriptor_table_main_2eproto_once, - nullptr, - 0, - 2, - schemas, - file_default_instances, - TableStruct_main_2eproto::offsets, - file_level_metadata_main_2eproto, - file_level_enum_descriptors_main_2eproto, - file_level_service_descriptors_main_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { - return &descriptor_table_main_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* InputType_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_main_2eproto); - return file_level_enum_descriptors_main_2eproto[0]; -} -bool InputType_IsValid(int value) { - switch (value) { - case 0: - case 1: - return true; - default: - return false; - } -} -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* InputTypeWithAlias_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_main_2eproto); - return file_level_enum_descriptors_main_2eproto[1]; -} -bool InputTypeWithAlias_IsValid(int value) { - switch (value) { - case 0: - case 1: - return true; - default: - return false; - } -} -// =================================================================== - -class Input::_Internal { - public: -}; - -Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:Input) -} -Input::Input(const Input& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Input* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , decltype(_impl_.type_){} - , decltype(_impl_.aliased_){} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_testinputfield().empty()) { - _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), - _this->GetArenaForAllocation()); - } - ::memcpy(&_impl_.type_, &from._impl_.type_, - static_cast<::size_t>(reinterpret_cast(&_impl_.aliased_) - - reinterpret_cast(&_impl_.type_)) + sizeof(_impl_.aliased_)); - // @@protoc_insertion_point(copy_constructor:Input) -} - -inline void Input::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , decltype(_impl_.type_){0} - , decltype(_impl_.aliased_){0} - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Input::~Input() { - // @@protoc_insertion_point(destructor:Input) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Input::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testinputfield_.Destroy(); -} - -void Input::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Input::Clear() { -// @@protoc_insertion_point(message_clear_start:Input) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_.ClearToEmpty(); - ::memset(&_impl_.type_, 0, static_cast<::size_t>( - reinterpret_cast(&_impl_.aliased_) - - reinterpret_cast(&_impl_.type_)) + sizeof(_impl_.aliased_)); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // string testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - auto str = _internal_mutable_testinputfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "Input.testInputField")); - } else { - goto handle_unusual; - } - continue; - // .InputType type = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 16)) { - ::uint32_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - _internal_set_type(static_cast<::InputType>(val)); - } else { - goto handle_unusual; - } - continue; - // .InputTypeWithAlias aliased = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) { - ::uint32_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - _internal_set_aliased(static_cast<::InputTypeWithAlias>(val)); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Input::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:Input) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "Input.testInputField"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_testinputfield(), target); - } - - // .InputType type = 2; - if (this->_internal_type() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 2, this->_internal_type(), target); - } - - // .InputTypeWithAlias aliased = 3; - if (this->_internal_aliased() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteEnumToArray( - 3, this->_internal_aliased(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:Input) - return target; -} - -::size_t Input::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:Input) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_testinputfield()); - } - - // .InputType type = 2; - if (this->_internal_type() != 0) { - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); - } - - // .InputTypeWithAlias aliased = 3; - if (this->_internal_aliased() != 0) { - total_size += 1 + - ::_pbi::WireFormatLite::EnumSize(this->_internal_aliased()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Input::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } - - -void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:Input) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_testinputfield().empty()) { - _this->_internal_set_testinputfield(from._internal_testinputfield()); - } - if (from._internal_type() != 0) { - _this->_internal_set_type(from._internal_type()); - } - if (from._internal_aliased() != 0) { - _this->_internal_set_aliased(from._internal_aliased()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Input::CopyFrom(const Input& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:Input) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Input::IsInitialized() const { - return true; -} - -void Input::InternalSwap(Input* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.testinputfield_, lhs_arena, - &other->_impl_.testinputfield_, rhs_arena - ); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Input, _impl_.aliased_) - + sizeof(Input::_impl_.aliased_) - - PROTOBUF_FIELD_OFFSET(Input, _impl_.type_)>( - reinterpret_cast(&_impl_.type_), - reinterpret_cast(&other->_impl_.type_)); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[0]); -} -// =================================================================== - -class Output::_Internal { - public: -}; - -Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:Output) -} -Output::Output(const Output& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Output* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) {} - - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_secondfield().empty()) { - _this->_impl_.secondfield_.Set(from._internal_secondfield(), - _this->GetArenaForAllocation()); - } - _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; - // @@protoc_insertion_point(copy_constructor:Output) -} - -inline void Output::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) { 0 } - - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Output::~Output() { - // @@protoc_insertion_point(destructor:Output) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Output::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.secondfield_.Destroy(); -} - -void Output::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Output::Clear() { -// @@protoc_insertion_point(message_clear_start:Output) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.secondfield_.ClearToEmpty(); - _impl_.testoutputfield_ = 0; - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // int32 testOutputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { - _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - // string secondField = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { - auto str = _internal_mutable_secondfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "Output.secondField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Output::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:Output) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray( - 1, this->_internal_testoutputfield(), target); - } - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "Output.secondField"); - target = stream->WriteStringMaybeAliased( - 2, this->_internal_secondfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:Output) - return target; -} - -::size_t Output::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:Output) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_secondfield()); - } - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( - this->_internal_testoutputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Output::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } - - -void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:Output) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_secondfield().empty()) { - _this->_internal_set_secondfield(from._internal_secondfield()); - } - if (from._internal_testoutputfield() != 0) { - _this->_internal_set_testoutputfield(from._internal_testoutputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Output::CopyFrom(const Output& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:Output) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Output::IsInitialized() const { - return true; -} - -void Output::InternalSwap(Output* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.secondfield_, lhs_arena, - &other->_impl_.secondfield_, rhs_arena - ); - - swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[1]); -} -// @@protoc_insertion_point(namespace_scope) -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::Input* -Arena::CreateMaybeMessage< ::Input >(Arena* arena) { - return Arena::CreateMessageInternal< ::Input >(arena); -} -template<> PROTOBUF_NOINLINE ::Output* -Arena::CreateMaybeMessage< ::Output >(Arena* arena) { - return Arena::CreateMessageInternal< ::Output >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.h deleted file mode 100644 index 17ff50254fa..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/cpp/main.pb.h +++ /dev/null @@ -1,669 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/generated_enum_reflection.h" -#include "google/protobuf/unknown_field_set.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_main_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_main_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_main_2eproto; -class Input; -struct InputDefaultTypeInternal; -extern InputDefaultTypeInternal _Input_default_instance_; -class Output; -struct OutputDefaultTypeInternal; -extern OutputDefaultTypeInternal _Output_default_instance_; -PROTOBUF_NAMESPACE_OPEN -template <> -::Input* Arena::CreateMaybeMessage<::Input>(Arena*); -template <> -::Output* Arena::CreateMaybeMessage<::Output>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - -enum InputType : int { - FOO = 0, - BAR = 1, - InputType_INT_MIN_SENTINEL_DO_NOT_USE_ = - std::numeric_limits<::int32_t>::min(), - InputType_INT_MAX_SENTINEL_DO_NOT_USE_ = - std::numeric_limits<::int32_t>::max(), -}; - -bool InputType_IsValid(int value); -constexpr InputType InputType_MIN = static_cast(0); -constexpr InputType InputType_MAX = static_cast(1); -constexpr int InputType_ARRAYSIZE = 1 + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* -InputType_descriptor(); -template -const std::string& InputType_Name(T value) { - static_assert(std::is_same::value || - std::is_integral::value, - "Incorrect type passed to InputType_Name()."); - return InputType_Name(static_cast(value)); -} -template <> -inline const std::string& InputType_Name(InputType value) { - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum( - static_cast(value)); -} -inline bool InputType_Parse(absl::string_view name, InputType* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - InputType_descriptor(), name, value); -} -enum InputTypeWithAlias : int { - BAZ = 0, - QUX = 1, - FUZ = 1, - InputTypeWithAlias_INT_MIN_SENTINEL_DO_NOT_USE_ = - std::numeric_limits<::int32_t>::min(), - InputTypeWithAlias_INT_MAX_SENTINEL_DO_NOT_USE_ = - std::numeric_limits<::int32_t>::max(), -}; - -bool InputTypeWithAlias_IsValid(int value); -constexpr InputTypeWithAlias InputTypeWithAlias_MIN = static_cast(0); -constexpr InputTypeWithAlias InputTypeWithAlias_MAX = static_cast(1); -constexpr int InputTypeWithAlias_ARRAYSIZE = 1 + 1; -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* -InputTypeWithAlias_descriptor(); -template -const std::string& InputTypeWithAlias_Name(T value) { - static_assert(std::is_same::value || - std::is_integral::value, - "Incorrect type passed to InputTypeWithAlias_Name()."); - return InputTypeWithAlias_Name(static_cast(value)); -} -template <> -inline const std::string& InputTypeWithAlias_Name(InputTypeWithAlias value) { - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfDenseEnum( - static_cast(value)); -} -inline bool InputTypeWithAlias_Parse(absl::string_view name, InputTypeWithAlias* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - InputTypeWithAlias_descriptor(), name, value); -} - -// =================================================================== - - -// ------------------------------------------------------------------- - -class Input final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { - public: - inline Input() : Input(nullptr) {} - ~Input() override; - explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Input(const Input& from); - Input(Input&& from) noexcept - : Input() { - *this = ::std::move(from); - } - - inline Input& operator=(const Input& from) { - CopyFrom(from); - return *this; - } - inline Input& operator=(Input&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Input& default_instance() { - return *internal_default_instance(); - } - static inline const Input* internal_default_instance() { - return reinterpret_cast( - &_Input_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Input& a, Input& b) { - a.Swap(&b); - } - inline void Swap(Input* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Input* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Input& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Input& from) { - Input::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Input* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "Input"; - } - protected: - explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - kTypeFieldNumber = 2, - kAliasedFieldNumber = 3, - }; - // string testInputField = 1; - void clear_testinputfield() ; - const std::string& testinputfield() const; - template - void set_testinputfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_testinputfield(); - PROTOBUF_NODISCARD std::string* release_testinputfield(); - void set_allocated_testinputfield(std::string* testinputfield); - private: - const std::string& _internal_testinputfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); - std::string* _internal_mutable_testinputfield(); - public: - // .InputType type = 2; - void clear_type() ; - ::InputType type() const; - void set_type(::InputType value); - private: - ::InputType _internal_type() const; - void _internal_set_type(::InputType value); - public: - // .InputTypeWithAlias aliased = 3; - void clear_aliased() ; - ::InputTypeWithAlias aliased() const; - void set_aliased(::InputTypeWithAlias value); - private: - ::InputTypeWithAlias _internal_aliased() const; - void _internal_set_aliased(::InputTypeWithAlias value); - public: - // @@protoc_insertion_point(class_scope:Input) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; - int type_; - int aliased_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -};// ------------------------------------------------------------------- - -class Output final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Output) */ { - public: - inline Output() : Output(nullptr) {} - ~Output() override; - explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Output(const Output& from); - Output(Output&& from) noexcept - : Output() { - *this = ::std::move(from); - } - - inline Output& operator=(const Output& from) { - CopyFrom(from); - return *this; - } - inline Output& operator=(Output&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Output& default_instance() { - return *internal_default_instance(); - } - static inline const Output* internal_default_instance() { - return reinterpret_cast( - &_Output_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(Output& a, Output& b) { - a.Swap(&b); - } - inline void Swap(Output* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Output* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Output& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Output& from) { - Output::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Output* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "Output"; - } - protected: - explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kSecondFieldFieldNumber = 2, - kTestOutputFieldFieldNumber = 1, - }; - // string secondField = 2; - void clear_secondfield() ; - const std::string& secondfield() const; - template - void set_secondfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_secondfield(); - PROTOBUF_NODISCARD std::string* release_secondfield(); - void set_allocated_secondfield(std::string* secondfield); - private: - const std::string& _internal_secondfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); - std::string* _internal_mutable_secondfield(); - public: - // int32 testOutputField = 1; - void clear_testoutputfield() ; - ::int32_t testoutputfield() const; - void set_testoutputfield(::int32_t value); - - private: - ::int32_t _internal_testoutputfield() const; - void _internal_set_testoutputfield(::int32_t value); - - public: - // @@protoc_insertion_point(class_scope:Output) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; - ::int32_t testoutputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// Input - -// string testInputField = 1; -inline void Input::clear_testinputfield() { - _impl_.testinputfield_.ClearToEmpty(); -} -inline const std::string& Input::testinputfield() const { - // @@protoc_insertion_point(field_get:Input.testInputField) - return _internal_testinputfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { - - _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:Input.testInputField) -} -inline std::string* Input::mutable_testinputfield() { - std::string* _s = _internal_mutable_testinputfield(); - // @@protoc_insertion_point(field_mutable:Input.testInputField) - return _s; -} -inline const std::string& Input::_internal_testinputfield() const { - return _impl_.testinputfield_.Get(); -} -inline void Input::_internal_set_testinputfield(const std::string& value) { - - _impl_.testinputfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Input::_internal_mutable_testinputfield() { - - return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Input::release_testinputfield() { - // @@protoc_insertion_point(field_release:Input.testInputField) - return _impl_.testinputfield_.Release(); -} -inline void Input::set_allocated_testinputfield(std::string* testinputfield) { - _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.testinputfield_.IsDefault()) { - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:Input.testInputField) -} - -// .InputType type = 2; -inline void Input::clear_type() { - _impl_.type_ = 0; -} -inline ::InputType Input::_internal_type() const { - return static_cast< ::InputType >(_impl_.type_); -} -inline ::InputType Input::type() const { - // @@protoc_insertion_point(field_get:Input.type) - return _internal_type(); -} -inline void Input::_internal_set_type(::InputType value) { - - _impl_.type_ = value; -} -inline void Input::set_type(::InputType value) { - _internal_set_type(value); - // @@protoc_insertion_point(field_set:Input.type) -} - -// .InputTypeWithAlias aliased = 3; -inline void Input::clear_aliased() { - _impl_.aliased_ = 0; -} -inline ::InputTypeWithAlias Input::_internal_aliased() const { - return static_cast< ::InputTypeWithAlias >(_impl_.aliased_); -} -inline ::InputTypeWithAlias Input::aliased() const { - // @@protoc_insertion_point(field_get:Input.aliased) - return _internal_aliased(); -} -inline void Input::_internal_set_aliased(::InputTypeWithAlias value) { - - _impl_.aliased_ = value; -} -inline void Input::set_aliased(::InputTypeWithAlias value) { - _internal_set_aliased(value); - // @@protoc_insertion_point(field_set:Input.aliased) -} - -// ------------------------------------------------------------------- - -// Output - -// int32 testOutputField = 1; -inline void Output::clear_testoutputfield() { - _impl_.testoutputfield_ = 0; -} -inline ::int32_t Output::testoutputfield() const { - // @@protoc_insertion_point(field_get:Output.testOutputField) - return _internal_testoutputfield(); -} -inline void Output::set_testoutputfield(::int32_t value) { - ; - _internal_set_testoutputfield(value); - // @@protoc_insertion_point(field_set:Output.testOutputField) -} -inline ::int32_t Output::_internal_testoutputfield() const { - return _impl_.testoutputfield_; -} -inline void Output::_internal_set_testoutputfield(::int32_t value) { - ; - _impl_.testoutputfield_ = value; -} - -// string secondField = 2; -inline void Output::clear_secondfield() { - _impl_.secondfield_.ClearToEmpty(); -} -inline const std::string& Output::secondfield() const { - // @@protoc_insertion_point(field_get:Output.secondField) - return _internal_secondfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { - - _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:Output.secondField) -} -inline std::string* Output::mutable_secondfield() { - std::string* _s = _internal_mutable_secondfield(); - // @@protoc_insertion_point(field_mutable:Output.secondField) - return _s; -} -inline const std::string& Output::_internal_secondfield() const { - return _impl_.secondfield_.Get(); -} -inline void Output::_internal_set_secondfield(const std::string& value) { - - _impl_.secondfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Output::_internal_mutable_secondfield() { - - return _impl_.secondfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Output::release_secondfield() { - // @@protoc_insertion_point(field_release:Output.secondField) - return _impl_.secondfield_.Release(); -} -inline void Output::set_allocated_secondfield(std::string* secondfield) { - _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.secondfield_.IsDefault()) { - _impl_.secondfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:Output.secondField) -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) - - -PROTOBUF_NAMESPACE_OPEN - -template <> -struct is_proto_enum<::InputType> : std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor<::InputType>() { - return ::InputType_descriptor(); -} -template <> -struct is_proto_enum<::InputTypeWithAlias> : std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor<::InputTypeWithAlias>() { - return ::InputTypeWithAlias_descriptor(); -} - -PROTOBUF_NAMESPACE_CLOSE - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/enum/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/enum/output/csharp/Main.cs deleted file mode 100644 index 3504810d371..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/csharp/Main.cs +++ /dev/null @@ -1,549 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -/// Holder for reflection information generated from main.proto -public static partial class MainReflection { - - #region Descriptor - /// File descriptor for main.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static MainReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgptYWluLnByb3RvIl8KBUlucHV0EhYKDnRlc3RJbnB1dEZpZWxkGAEgASgJ", - "EhgKBHR5cGUYAiABKA4yCi5JbnB1dFR5cGUSJAoHYWxpYXNlZBgDIAEoDjIT", - "LklucHV0VHlwZVdpdGhBbGlhcyI2CgZPdXRwdXQSFwoPdGVzdE91dHB1dEZp", - "ZWxkGAEgASgFEhMKC3NlY29uZEZpZWxkGAIgASgJKh0KCUlucHV0VHlwZRIH", - "CgNGT08QABIHCgNCQVIQASozChJJbnB1dFR5cGVXaXRoQWxpYXMSBwoDQkFa", - "EAASBwoDUVVYEAESBwoDRlVaEAEaAhABMiEKB1NlcnZpY2USFgoDRm9vEgYu", - "SW5wdXQaBy5PdXRwdXRiBnByb3RvMw==")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::InputType), typeof(global::InputTypeWithAlias), }, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "TestInputField", "Type", "Aliased" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Output), global::Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) - })); - } - #endregion - -} -#region Enums -public enum InputType { - [pbr::OriginalName("FOO")] Foo = 0, - [pbr::OriginalName("BAR")] Bar = 1, -} - -public enum InputTypeWithAlias { - [pbr::OriginalName("BAZ")] Baz = 0, - [pbr::OriginalName("QUX")] Qux = 1, - [pbr::OriginalName("FUZ", PreferredAlias = false)] Fuz = 1, -} - -#endregion - -#region Messages -public sealed partial class Input : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input(Input other) : this() { - testInputField_ = other.testInputField_; - type_ = other.type_; - aliased_ = other.aliased_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input Clone() { - return new Input(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private string testInputField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string TestInputField { - get { return testInputField_; } - set { - testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "type" field. - public const int TypeFieldNumber = 2; - private global::InputType type_ = global::InputType.Foo; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::InputType Type { - get { return type_; } - set { - type_ = value; - } - } - - /// Field number for the "aliased" field. - public const int AliasedFieldNumber = 3; - private global::InputTypeWithAlias aliased_ = global::InputTypeWithAlias.Baz; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::InputTypeWithAlias Aliased { - get { return aliased_; } - set { - aliased_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Input); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Input other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestInputField != other.TestInputField) return false; - if (Type != other.Type) return false; - if (Aliased != other.Aliased) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); - if (Type != global::InputType.Foo) hash ^= Type.GetHashCode(); - if (Aliased != global::InputTypeWithAlias.Baz) hash ^= Aliased.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (Type != global::InputType.Foo) { - output.WriteRawTag(16); - output.WriteEnum((int) Type); - } - if (Aliased != global::InputTypeWithAlias.Baz) { - output.WriteRawTag(24); - output.WriteEnum((int) Aliased); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (Type != global::InputType.Foo) { - output.WriteRawTag(16); - output.WriteEnum((int) Type); - } - if (Aliased != global::InputTypeWithAlias.Baz) { - output.WriteRawTag(24); - output.WriteEnum((int) Aliased); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestInputField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); - } - if (Type != global::InputType.Foo) { - size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); - } - if (Aliased != global::InputTypeWithAlias.Baz) { - size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Aliased); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Input other) { - if (other == null) { - return; - } - if (other.TestInputField.Length != 0) { - TestInputField = other.TestInputField; - } - if (other.Type != global::InputType.Foo) { - Type = other.Type; - } - if (other.Aliased != global::InputTypeWithAlias.Baz) { - Aliased = other.Aliased; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - case 16: { - Type = (global::InputType) input.ReadEnum(); - break; - } - case 24: { - Aliased = (global::InputTypeWithAlias) input.ReadEnum(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - case 16: { - Type = (global::InputType) input.ReadEnum(); - break; - } - case 24: { - Aliased = (global::InputTypeWithAlias) input.ReadEnum(); - break; - } - } - } - } - #endif - -} - -public sealed partial class Output : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output(Output other) : this() { - testOutputField_ = other.testOutputField_; - secondField_ = other.secondField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output Clone() { - return new Output(this); - } - - /// Field number for the "testOutputField" field. - public const int TestOutputFieldFieldNumber = 1; - private int testOutputField_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int TestOutputField { - get { return testOutputField_; } - set { - testOutputField_ = value; - } - } - - /// Field number for the "secondField" field. - public const int SecondFieldFieldNumber = 2; - private string secondField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string SecondField { - get { return secondField_; } - set { - secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Output); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Output other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestOutputField != other.TestOutputField) return false; - if (SecondField != other.SecondField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); - if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestOutputField != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); - } - if (SecondField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Output other) { - if (other == null) { - return; - } - if (other.TestOutputField != 0) { - TestOutputField = other.TestOutputField; - } - if (other.SecondField.Length != 0) { - SecondField = other.SecondField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - } - #endif - -} - -#endregion - - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.h deleted file mode 100644 index dda29dfd430..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.h +++ /dev/null @@ -1,156 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - Enum InputType - -typedef GPB_ENUM(InputType) { - /** - * Value used if any message's field encounters a value that is not defined - * by this enum. The message will also have C functions to get/set the rawValue - * of the field. - **/ - InputType_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, - InputType_Foo = 0, - InputType_Bar = 1, -}; - -GPBEnumDescriptor *InputType_EnumDescriptor(void); - -/** - * Checks to see if the given value is defined by the enum or was not known at - * the time this source was generated. - **/ -BOOL InputType_IsValidValue(int32_t value); - -#pragma mark - Enum InputTypeWithAlias - -typedef GPB_ENUM(InputTypeWithAlias) { - /** - * Value used if any message's field encounters a value that is not defined - * by this enum. The message will also have C functions to get/set the rawValue - * of the field. - **/ - InputTypeWithAlias_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, - InputTypeWithAlias_Baz = 0, - InputTypeWithAlias_Qux = 1, - InputTypeWithAlias_Fuz = 1, -}; - -GPBEnumDescriptor *InputTypeWithAlias_EnumDescriptor(void); - -/** - * Checks to see if the given value is defined by the enum or was not known at - * the time this source was generated. - **/ -BOOL InputTypeWithAlias_IsValidValue(int32_t value); - -#pragma mark - MainRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface MainRoot : GPBRootObject -@end - -#pragma mark - Input - -typedef GPB_ENUM(Input_FieldNumber) { - Input_FieldNumber_TestInputField = 1, - Input_FieldNumber_Type = 2, - Input_FieldNumber_Aliased = 3, -}; - -GPB_FINAL @interface Input : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; - -@property(nonatomic, readwrite) InputType type; - -@property(nonatomic, readwrite) InputTypeWithAlias aliased; - -@end - -/** - * Fetches the raw value of a @c Input's @c type property, even - * if the value was not defined by the enum at the time the code was generated. - **/ -int32_t Input_Type_RawValue(Input *message); -/** - * Sets the raw value of an @c Input's @c type property, allowing - * it to be set to a value that was not defined by the enum at the time the code - * was generated. - **/ -void SetInput_Type_RawValue(Input *message, int32_t value); - -/** - * Fetches the raw value of a @c Input's @c aliased property, even - * if the value was not defined by the enum at the time the code was generated. - **/ -int32_t Input_Aliased_RawValue(Input *message); -/** - * Sets the raw value of an @c Input's @c aliased property, allowing - * it to be set to a value that was not defined by the enum at the time the code - * was generated. - **/ -void SetInput_Aliased_RawValue(Input *message, int32_t value); - -#pragma mark - Output - -typedef GPB_ENUM(Output_FieldNumber) { - Output_FieldNumber_TestOutputField = 1, - Output_FieldNumber_SecondField = 2, -}; - -GPB_FINAL @interface Output : GPBMessage - -@property(nonatomic, readwrite) int32_t testOutputField; - -@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.m deleted file mode 100644 index dd8d3d75e2d..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/objc/Main.pbobjc.m +++ /dev/null @@ -1,281 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import - -#import "Main.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -#pragma mark - MainRoot - -@implementation MainRoot - -// No extensions in the file and no imports, so no need to generate -// +extensionRegistry. - -@end - -#pragma mark - MainRoot_FileDescriptor - -static GPBFileDescriptor *MainRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - Enum InputType - -GPBEnumDescriptor *InputType_EnumDescriptor(void) { - static _Atomic(GPBEnumDescriptor*) descriptor = nil; - if (!descriptor) { - static const char *valueNames = - "Foo\000Bar\000"; - static const int32_t values[] = { - InputType_Foo, - InputType_Bar, - }; - GPBEnumDescriptor *worker = - [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(InputType) - valueNames:valueNames - values:values - count:(uint32_t)(sizeof(values) / sizeof(int32_t)) - enumVerifier:InputType_IsValidValue - flags:GPBEnumDescriptorInitializationFlag_None]; - GPBEnumDescriptor *expected = nil; - if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) { - [worker release]; - } - } - return descriptor; -} - -BOOL InputType_IsValidValue(int32_t value__) { - switch (value__) { - case InputType_Foo: - case InputType_Bar: - return YES; - default: - return NO; - } -} - -#pragma mark - Enum InputTypeWithAlias - -GPBEnumDescriptor *InputTypeWithAlias_EnumDescriptor(void) { - static _Atomic(GPBEnumDescriptor*) descriptor = nil; - if (!descriptor) { - static const char *valueNames = - "Baz\000Qux\000Fuz\000"; - static const int32_t values[] = { - InputTypeWithAlias_Baz, - InputTypeWithAlias_Qux, - InputTypeWithAlias_Fuz, - }; - GPBEnumDescriptor *worker = - [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(InputTypeWithAlias) - valueNames:valueNames - values:values - count:(uint32_t)(sizeof(values) / sizeof(int32_t)) - enumVerifier:InputTypeWithAlias_IsValidValue - flags:GPBEnumDescriptorInitializationFlag_None]; - GPBEnumDescriptor *expected = nil; - if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) { - [worker release]; - } - } - return descriptor; -} - -BOOL InputTypeWithAlias_IsValidValue(int32_t value__) { - switch (value__) { - case InputTypeWithAlias_Baz: - case InputTypeWithAlias_Qux: - return YES; - default: - return NO; - } -} - -#pragma mark - Input - -@implementation Input - -@dynamic testInputField; -@dynamic type; -@dynamic aliased; - -typedef struct Input__storage_ { - uint32_t _has_storage_[1]; - InputType type; - InputTypeWithAlias aliased; - NSString *testInputField; -} Input__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputField", - .dataTypeSpecific.clazz = Nil, - .number = Input_FieldNumber_TestInputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Input__storage_, testInputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - { - .name = "type", - .dataTypeSpecific.enumDescFunc = InputType_EnumDescriptor, - .number = Input_FieldNumber_Type, - .hasIndex = 1, - .offset = (uint32_t)offsetof(Input__storage_, type), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeEnum, - }, - { - .name = "aliased", - .dataTypeSpecific.enumDescFunc = InputTypeWithAlias_EnumDescriptor, - .number = Input_FieldNumber_Aliased, - .hasIndex = 2, - .offset = (uint32_t)offsetof(Input__storage_, aliased), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeEnum, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Input class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Input__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\016\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -int32_t Input_Type_RawValue(Input *message) { - GPBDescriptor *descriptor = [Input descriptor]; - GPBFieldDescriptor *field = [descriptor fieldWithNumber:Input_FieldNumber_Type]; - return GPBGetMessageRawEnumField(message, field); -} - -void SetInput_Type_RawValue(Input *message, int32_t value) { - GPBDescriptor *descriptor = [Input descriptor]; - GPBFieldDescriptor *field = [descriptor fieldWithNumber:Input_FieldNumber_Type]; - GPBSetMessageRawEnumField(message, field, value); -} - -int32_t Input_Aliased_RawValue(Input *message) { - GPBDescriptor *descriptor = [Input descriptor]; - GPBFieldDescriptor *field = [descriptor fieldWithNumber:Input_FieldNumber_Aliased]; - return GPBGetMessageRawEnumField(message, field); -} - -void SetInput_Aliased_RawValue(Input *message, int32_t value) { - GPBDescriptor *descriptor = [Input descriptor]; - GPBFieldDescriptor *field = [descriptor fieldWithNumber:Input_FieldNumber_Aliased]; - GPBSetMessageRawEnumField(message, field, value); -} - -#pragma mark - Output - -@implementation Output - -@dynamic testOutputField; -@dynamic secondField; - -typedef struct Output__storage_ { - uint32_t _has_storage_[1]; - int32_t testOutputField; - NSString *secondField; -} Output__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testOutputField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_TestOutputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Output__storage_, testOutputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeInt32, - }, - { - .name = "secondField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_SecondField, - .hasIndex = 1, - .offset = (uint32_t)offsetof(Output__storage_, secondField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Output class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Output__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\002\001\017\000\002\013\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/enum/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/enum/output/php/GPBMetadata/Main.php deleted file mode 100644 index 9168f56801b8ca34d0a625436c9575f9d5c43e9c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 780 zcmZ`%QEL-H5cU$AkP&LQf`)=Ht%0V+=Ai{2Qlq5Aggn%Xnxd3I+3Zc4h0E@-yC+o1 zzww8K}er)nwphu}S(;|E$_PAsugXzcZ#i0q@)89io4 z)MPU)FLK?!z@~iV%1%Fu2OWbrE@?+@z?~B4(~jV81z~)T%gZ_YAr@VCFnw8|rSX%uw8_=E1#f@Q1Lgfe#+Ohgy_b&+r;v zdWOQfcHK5}aJS)sa$Rt&qH5?-sHawfw`KAC*&kS1jYv?*6;C99gVr H0~>&Ued6Gm diff --git a/packages/protobuf/test/protoc-out/enum/output/php/Input.php b/packages/protobuf/test/protoc-out/enum/output/php/Input.php deleted file mode 100644 index 3f98ae2843b..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/php/Input.php +++ /dev/null @@ -1,110 +0,0 @@ -Input - */ -class Input extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field string testInputField = 1; - */ - protected $testInputField = ''; - /** - * Generated from protobuf field .InputType type = 2; - */ - protected $type = 0; - /** - * Generated from protobuf field .InputTypeWithAlias aliased = 3; - */ - protected $aliased = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $testInputField - * @type int $type - * @type int $aliased - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field string testInputField = 1; - * @return string - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field string testInputField = 1; - * @param string $var - * @return $this - */ - public function setTestInputField($var) - { - GPBUtil::checkString($var, True); - $this->testInputField = $var; - - return $this; - } - - /** - * Generated from protobuf field .InputType type = 2; - * @return int - */ - public function getType() - { - return $this->type; - } - - /** - * Generated from protobuf field .InputType type = 2; - * @param int $var - * @return $this - */ - public function setType($var) - { - GPBUtil::checkEnum($var, \InputType::class); - $this->type = $var; - - return $this; - } - - /** - * Generated from protobuf field .InputTypeWithAlias aliased = 3; - * @return int - */ - public function getAliased() - { - return $this->aliased; - } - - /** - * Generated from protobuf field .InputTypeWithAlias aliased = 3; - * @param int $var - * @return $this - */ - public function setAliased($var) - { - GPBUtil::checkEnum($var, \InputTypeWithAlias::class); - $this->aliased = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/enum/output/php/InputType.php b/packages/protobuf/test/protoc-out/enum/output/php/InputType.php deleted file mode 100644 index 1307c6ca2a7..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/php/InputType.php +++ /dev/null @@ -1,44 +0,0 @@ -InputType - */ -class InputType -{ - /** - * Generated from protobuf enum FOO = 0; - */ - const FOO = 0; - /** - * Generated from protobuf enum BAR = 1; - */ - const BAR = 1; - - private static $valueToName = [ - self::FOO => 'FOO', - self::BAR => 'BAR', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - diff --git a/packages/protobuf/test/protoc-out/enum/output/php/InputTypeWithAlias.php b/packages/protobuf/test/protoc-out/enum/output/php/InputTypeWithAlias.php deleted file mode 100644 index 81eebb0f373..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/php/InputTypeWithAlias.php +++ /dev/null @@ -1,49 +0,0 @@ -InputTypeWithAlias - */ -class InputTypeWithAlias -{ - /** - * Generated from protobuf enum BAZ = 0; - */ - const BAZ = 0; - /** - * Generated from protobuf enum QUX = 1; - */ - const QUX = 1; - /** - * Generated from protobuf enum FUZ = 1; - */ - const FUZ = 1; - - private static $valueToName = [ - self::BAZ => 'BAZ', - self::QUX => 'QUX', - self::FUZ => 'FUZ', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - diff --git a/packages/protobuf/test/protoc-out/enum/output/php/Output.php b/packages/protobuf/test/protoc-out/enum/output/php/Output.php deleted file mode 100644 index 050aef7e894..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/php/Output.php +++ /dev/null @@ -1,83 +0,0 @@ -Output - */ -class Output extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field int32 testOutputField = 1; - */ - protected $testOutputField = 0; - /** - * Generated from protobuf field string secondField = 2; - */ - protected $secondField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $testOutputField - * @type string $secondField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @return int - */ - public function getTestOutputField() - { - return $this->testOutputField; - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @param int $var - * @return $this - */ - public function setTestOutputField($var) - { - GPBUtil::checkInt32($var); - $this->testOutputField = $var; - - return $this; - } - - /** - * Generated from protobuf field string secondField = 2; - * @return string - */ - public function getSecondField() - { - return $this->secondField; - } - - /** - * Generated from protobuf field string secondField = 2; - * @param string $var - * @return $this - */ - public function setSecondField($var) - { - GPBUtil::checkString($var, True); - $this->secondField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/enum/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/enum/output/pyi/main_pb2.pyi deleted file mode 100644 index 8f013736192..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/pyi/main_pb2.pyi +++ /dev/null @@ -1,40 +0,0 @@ -from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union - -DESCRIPTOR: _descriptor.FileDescriptor - -class InputType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): - __slots__ = [] - FOO: _ClassVar[InputType] - BAR: _ClassVar[InputType] - -class InputTypeWithAlias(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): - __slots__ = [] - BAZ: _ClassVar[InputTypeWithAlias] - QUX: _ClassVar[InputTypeWithAlias] - FUZ: _ClassVar[InputTypeWithAlias] -FOO: InputType -BAR: InputType -BAZ: InputTypeWithAlias -QUX: InputTypeWithAlias -FUZ: InputTypeWithAlias - -class Input(_message.Message): - __slots__ = ["testInputField", "type", "aliased"] - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - TYPE_FIELD_NUMBER: _ClassVar[int] - ALIASED_FIELD_NUMBER: _ClassVar[int] - testInputField: str - type: InputType - aliased: InputTypeWithAlias - def __init__(self, testInputField: _Optional[str] = ..., type: _Optional[_Union[InputType, str]] = ..., aliased: _Optional[_Union[InputTypeWithAlias, str]] = ...) -> None: ... - -class Output(_message.Message): - __slots__ = ["testOutputField", "secondField"] - TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] - SECONDFIELD_FIELD_NUMBER: _ClassVar[int] - testOutputField: int - secondField: str - def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/enum/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/enum/output/python/main_pb2.py deleted file mode 100644 index b8cfba34fcf..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/python/main_pb2.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\"_\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\x12\x18\n\x04type\x18\x02 \x01(\x0e\x32\n.InputType\x12$\n\x07\x61liased\x18\x03 \x01(\x0e\x32\x13.InputTypeWithAlias\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t*\x1d\n\tInputType\x12\x07\n\x03\x46OO\x10\x00\x12\x07\n\x03\x42\x41R\x10\x01*3\n\x12InputTypeWithAlias\x12\x07\n\x03\x42\x41Z\x10\x00\x12\x07\n\x03QUX\x10\x01\x12\x07\n\x03\x46UZ\x10\x01\x1a\x02\x10\x01\x32!\n\x07Service\x12\x16\n\x03\x46oo\x12\x06.Input\x1a\x07.Outputb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _INPUTTYPEWITHALIAS._options = None - _INPUTTYPEWITHALIAS._serialized_options = b'\020\001' - _globals['_INPUTTYPE']._serialized_start=167 - _globals['_INPUTTYPE']._serialized_end=196 - _globals['_INPUTTYPEWITHALIAS']._serialized_start=198 - _globals['_INPUTTYPEWITHALIAS']._serialized_end=249 - _globals['_INPUT']._serialized_start=14 - _globals['_INPUT']._serialized_end=109 - _globals['_OUTPUT']._serialized_start=111 - _globals['_OUTPUT']._serialized_end=165 - _globals['_SERVICE']._serialized_start=251 - _globals['_SERVICE']._serialized_end=284 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/enum/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/enum/output/ruby/main_pb.rb deleted file mode 100644 index febb5d0a4f8..00000000000 --- a/packages/protobuf/test/protoc-out/enum/output/ruby/main_pb.rb +++ /dev/null @@ -1,32 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("main.proto", :syntax => :proto3) do - add_message "Input" do - optional :testInputField, :string, 1 - optional :type, :enum, 2, "InputType" - optional :aliased, :enum, 3, "InputTypeWithAlias" - end - add_message "Output" do - optional :testOutputField, :int32, 1 - optional :secondField, :string, 2 - end - add_enum "InputType" do - value :FOO, 0 - value :BAR, 1 - end - add_enum "InputTypeWithAlias" do - value :BAZ, 0 - value :QUX, 1 - value :FUZ, 1 - end - end -end - -Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass -Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Output").msgclass -InputType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("InputType").enummodule -InputTypeWithAlias = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("InputTypeWithAlias").enummodule diff --git a/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.cc deleted file mode 100644 index fb38ad0b87a..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.cc +++ /dev/null @@ -1,540 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#include "main.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -PROTOBUF_CONSTEXPR BarRequest::BarRequest( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.empty_)*/nullptr - , /*decltype(_impl_._cached_size_)*/{}} {} -struct BarRequestDefaultTypeInternal { - PROTOBUF_CONSTEXPR BarRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~BarRequestDefaultTypeInternal() {} - union { - BarRequest _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BarRequestDefaultTypeInternal _BarRequest_default_instance_; -PROTOBUF_CONSTEXPR BarResponse::BarResponse( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.myextern_)*/nullptr - , /*decltype(_impl_._cached_size_)*/{}} {} -struct BarResponseDefaultTypeInternal { - PROTOBUF_CONSTEXPR BarResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~BarResponseDefaultTypeInternal() {} - union { - BarResponse _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BarResponseDefaultTypeInternal _BarResponse_default_instance_; -static ::_pb::Metadata file_level_metadata_main_2eproto[2]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_main_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_main_2eproto = nullptr; -const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::BarRequest, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::BarRequest, _impl_.empty_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::BarResponse, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::BarResponse, _impl_.myextern_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::BarRequest)}, - { 9, -1, -1, sizeof(::BarResponse)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::_BarRequest_default_instance_._instance, - &::_BarResponse_default_instance_._instance, -}; -const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\nmain.proto\032\rfoo/bar.proto\032\033google/prot" - "obuf/empty.proto\"3\n\nBarRequest\022%\n\005empty\030" - "\001 \001(\0132\026.google.protobuf.Empty\")\n\013BarResp" - "onse\022\032\n\010myExtern\030\001 \001(\0132\010.foo.Bar2T\n\007Serv" - "ice\022\'\n\003Foo\022\010.foo.Bar\032\026.google.protobuf.E" - "mpty\022 \n\003Bar\022\013.BarRequest\032\014.BarResponseb\006" - "proto3" -}; -static const ::_pbi::DescriptorTable* const descriptor_table_main_2eproto_deps[2] = - { - &::descriptor_table_foo_2fbar_2eproto, - &::descriptor_table_google_2fprotobuf_2fempty_2eproto, -}; -static ::absl::once_flag descriptor_table_main_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { - false, - false, - 246, - descriptor_table_protodef_main_2eproto, - "main.proto", - &descriptor_table_main_2eproto_once, - descriptor_table_main_2eproto_deps, - 2, - 2, - schemas, - file_default_instances, - TableStruct_main_2eproto::offsets, - file_level_metadata_main_2eproto, - file_level_enum_descriptors_main_2eproto, - file_level_service_descriptors_main_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { - return &descriptor_table_main_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); -// =================================================================== - -class BarRequest::_Internal { - public: - static const ::PROTOBUF_NAMESPACE_ID::Empty& empty(const BarRequest* msg); -}; - -const ::PROTOBUF_NAMESPACE_ID::Empty& -BarRequest::_Internal::empty(const BarRequest* msg) { - return *msg->_impl_.empty_; -} -void BarRequest::clear_empty() { - if (GetArenaForAllocation() == nullptr && _impl_.empty_ != nullptr) { - delete _impl_.empty_; - } - _impl_.empty_ = nullptr; -} -BarRequest::BarRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:BarRequest) -} -BarRequest::BarRequest(const BarRequest& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - BarRequest* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.empty_){nullptr} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - if (from._internal_has_empty()) { - _this->_impl_.empty_ = new ::PROTOBUF_NAMESPACE_ID::Empty(*from._impl_.empty_); - } - // @@protoc_insertion_point(copy_constructor:BarRequest) -} - -inline void BarRequest::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.empty_){nullptr} - , /*decltype(_impl_._cached_size_)*/{} - }; -} - -BarRequest::~BarRequest() { - // @@protoc_insertion_point(destructor:BarRequest) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void BarRequest::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - if (this != internal_default_instance()) delete _impl_.empty_; -} - -void BarRequest::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void BarRequest::Clear() { -// @@protoc_insertion_point(message_clear_start:BarRequest) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - if (GetArenaForAllocation() == nullptr && _impl_.empty_ != nullptr) { - delete _impl_.empty_; - } - _impl_.empty_ = nullptr; - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* BarRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // .google.protobuf.Empty empty = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - ptr = ctx->ParseMessage(_internal_mutable_empty(), ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* BarRequest::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:BarRequest) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // .google.protobuf.Empty empty = 1; - if (this->_internal_has_empty()) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, _Internal::empty(this), - _Internal::empty(this).GetCachedSize(), target, stream); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:BarRequest) - return target; -} - -::size_t BarRequest::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:BarRequest) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // .google.protobuf.Empty empty = 1; - if (this->_internal_has_empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.empty_); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData BarRequest::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - BarRequest::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*BarRequest::GetClassData() const { return &_class_data_; } - - -void BarRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:BarRequest) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (from._internal_has_empty()) { - _this->_internal_mutable_empty()->::PROTOBUF_NAMESPACE_ID::Empty::MergeFrom( - from._internal_empty()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void BarRequest::CopyFrom(const BarRequest& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:BarRequest) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool BarRequest::IsInitialized() const { - return true; -} - -void BarRequest::InternalSwap(BarRequest* other) { - using std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_.empty_, other->_impl_.empty_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata BarRequest::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[0]); -} -// =================================================================== - -class BarResponse::_Internal { - public: - static const ::foo::Bar& myextern(const BarResponse* msg); -}; - -const ::foo::Bar& -BarResponse::_Internal::myextern(const BarResponse* msg) { - return *msg->_impl_.myextern_; -} -void BarResponse::clear_myextern() { - if (GetArenaForAllocation() == nullptr && _impl_.myextern_ != nullptr) { - delete _impl_.myextern_; - } - _impl_.myextern_ = nullptr; -} -BarResponse::BarResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:BarResponse) -} -BarResponse::BarResponse(const BarResponse& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - BarResponse* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.myextern_){nullptr} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - if (from._internal_has_myextern()) { - _this->_impl_.myextern_ = new ::foo::Bar(*from._impl_.myextern_); - } - // @@protoc_insertion_point(copy_constructor:BarResponse) -} - -inline void BarResponse::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.myextern_){nullptr} - , /*decltype(_impl_._cached_size_)*/{} - }; -} - -BarResponse::~BarResponse() { - // @@protoc_insertion_point(destructor:BarResponse) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void BarResponse::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - if (this != internal_default_instance()) delete _impl_.myextern_; -} - -void BarResponse::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void BarResponse::Clear() { -// @@protoc_insertion_point(message_clear_start:BarResponse) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - if (GetArenaForAllocation() == nullptr && _impl_.myextern_ != nullptr) { - delete _impl_.myextern_; - } - _impl_.myextern_ = nullptr; - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* BarResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // .foo.Bar myExtern = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - ptr = ctx->ParseMessage(_internal_mutable_myextern(), ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* BarResponse::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:BarResponse) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // .foo.Bar myExtern = 1; - if (this->_internal_has_myextern()) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, _Internal::myextern(this), - _Internal::myextern(this).GetCachedSize(), target, stream); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:BarResponse) - return target; -} - -::size_t BarResponse::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:BarResponse) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // .foo.Bar myExtern = 1; - if (this->_internal_has_myextern()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.myextern_); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData BarResponse::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - BarResponse::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*BarResponse::GetClassData() const { return &_class_data_; } - - -void BarResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:BarResponse) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (from._internal_has_myextern()) { - _this->_internal_mutable_myextern()->::foo::Bar::MergeFrom( - from._internal_myextern()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void BarResponse::CopyFrom(const BarResponse& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:BarResponse) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool BarResponse::IsInitialized() const { - return true; -} - -void BarResponse::InternalSwap(BarResponse* other) { - using std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_.myextern_, other->_impl_.myextern_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata BarResponse::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[1]); -} -// @@protoc_insertion_point(namespace_scope) -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::BarRequest* -Arena::CreateMaybeMessage< ::BarRequest >(Arena* arena) { - return Arena::CreateMessageInternal< ::BarRequest >(arena); -} -template<> PROTOBUF_NOINLINE ::BarResponse* -Arena::CreateMaybeMessage< ::BarResponse >(Arena* arena) { - return Arena::CreateMessageInternal< ::BarResponse >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.h deleted file mode 100644 index 5d12a96c5dd..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/cpp/main.pb.h +++ /dev/null @@ -1,575 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/unknown_field_set.h" -#include "foo/bar.pb.h" -#include "google/protobuf/empty.pb.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_main_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_main_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_main_2eproto; -class BarRequest; -struct BarRequestDefaultTypeInternal; -extern BarRequestDefaultTypeInternal _BarRequest_default_instance_; -class BarResponse; -struct BarResponseDefaultTypeInternal; -extern BarResponseDefaultTypeInternal _BarResponse_default_instance_; -PROTOBUF_NAMESPACE_OPEN -template <> -::BarRequest* Arena::CreateMaybeMessage<::BarRequest>(Arena*); -template <> -::BarResponse* Arena::CreateMaybeMessage<::BarResponse>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - - -// =================================================================== - - -// ------------------------------------------------------------------- - -class BarRequest final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:BarRequest) */ { - public: - inline BarRequest() : BarRequest(nullptr) {} - ~BarRequest() override; - explicit PROTOBUF_CONSTEXPR BarRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - BarRequest(const BarRequest& from); - BarRequest(BarRequest&& from) noexcept - : BarRequest() { - *this = ::std::move(from); - } - - inline BarRequest& operator=(const BarRequest& from) { - CopyFrom(from); - return *this; - } - inline BarRequest& operator=(BarRequest&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const BarRequest& default_instance() { - return *internal_default_instance(); - } - static inline const BarRequest* internal_default_instance() { - return reinterpret_cast( - &_BarRequest_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(BarRequest& a, BarRequest& b) { - a.Swap(&b); - } - inline void Swap(BarRequest* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(BarRequest* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - BarRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const BarRequest& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const BarRequest& from) { - BarRequest::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(BarRequest* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "BarRequest"; - } - protected: - explicit BarRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kEmptyFieldNumber = 1, - }; - // .google.protobuf.Empty empty = 1; - bool has_empty() const; - private: - bool _internal_has_empty() const; - - public: - void clear_empty() ; - const ::PROTOBUF_NAMESPACE_ID::Empty& empty() const; - PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::Empty* release_empty(); - ::PROTOBUF_NAMESPACE_ID::Empty* mutable_empty(); - void set_allocated_empty(::PROTOBUF_NAMESPACE_ID::Empty* empty); - private: - const ::PROTOBUF_NAMESPACE_ID::Empty& _internal_empty() const; - ::PROTOBUF_NAMESPACE_ID::Empty* _internal_mutable_empty(); - public: - void unsafe_arena_set_allocated_empty( - ::PROTOBUF_NAMESPACE_ID::Empty* empty); - ::PROTOBUF_NAMESPACE_ID::Empty* unsafe_arena_release_empty(); - // @@protoc_insertion_point(class_scope:BarRequest) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::Empty* empty_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -};// ------------------------------------------------------------------- - -class BarResponse final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:BarResponse) */ { - public: - inline BarResponse() : BarResponse(nullptr) {} - ~BarResponse() override; - explicit PROTOBUF_CONSTEXPR BarResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - BarResponse(const BarResponse& from); - BarResponse(BarResponse&& from) noexcept - : BarResponse() { - *this = ::std::move(from); - } - - inline BarResponse& operator=(const BarResponse& from) { - CopyFrom(from); - return *this; - } - inline BarResponse& operator=(BarResponse&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const BarResponse& default_instance() { - return *internal_default_instance(); - } - static inline const BarResponse* internal_default_instance() { - return reinterpret_cast( - &_BarResponse_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(BarResponse& a, BarResponse& b) { - a.Swap(&b); - } - inline void Swap(BarResponse* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(BarResponse* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - BarResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const BarResponse& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const BarResponse& from) { - BarResponse::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(BarResponse* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "BarResponse"; - } - protected: - explicit BarResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kMyExternFieldNumber = 1, - }; - // .foo.Bar myExtern = 1; - bool has_myextern() const; - private: - bool _internal_has_myextern() const; - - public: - void clear_myextern() ; - const ::foo::Bar& myextern() const; - PROTOBUF_NODISCARD ::foo::Bar* release_myextern(); - ::foo::Bar* mutable_myextern(); - void set_allocated_myextern(::foo::Bar* myextern); - private: - const ::foo::Bar& _internal_myextern() const; - ::foo::Bar* _internal_mutable_myextern(); - public: - void unsafe_arena_set_allocated_myextern( - ::foo::Bar* myextern); - ::foo::Bar* unsafe_arena_release_myextern(); - // @@protoc_insertion_point(class_scope:BarResponse) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::foo::Bar* myextern_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// BarRequest - -// .google.protobuf.Empty empty = 1; -inline bool BarRequest::_internal_has_empty() const { - return this != internal_default_instance() && _impl_.empty_ != nullptr; -} -inline bool BarRequest::has_empty() const { - return _internal_has_empty(); -} -inline const ::PROTOBUF_NAMESPACE_ID::Empty& BarRequest::_internal_empty() const { - const ::PROTOBUF_NAMESPACE_ID::Empty* p = _impl_.empty_; - return p != nullptr ? *p : reinterpret_cast( - ::PROTOBUF_NAMESPACE_ID::_Empty_default_instance_); -} -inline const ::PROTOBUF_NAMESPACE_ID::Empty& BarRequest::empty() const { - // @@protoc_insertion_point(field_get:BarRequest.empty) - return _internal_empty(); -} -inline void BarRequest::unsafe_arena_set_allocated_empty( - ::PROTOBUF_NAMESPACE_ID::Empty* empty) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.empty_); - } - _impl_.empty_ = empty; - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:BarRequest.empty) -} -inline ::PROTOBUF_NAMESPACE_ID::Empty* BarRequest::release_empty() { - - ::PROTOBUF_NAMESPACE_ID::Empty* temp = _impl_.empty_; - _impl_.empty_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::PROTOBUF_NAMESPACE_ID::Empty* BarRequest::unsafe_arena_release_empty() { - // @@protoc_insertion_point(field_release:BarRequest.empty) - - ::PROTOBUF_NAMESPACE_ID::Empty* temp = _impl_.empty_; - _impl_.empty_ = nullptr; - return temp; -} -inline ::PROTOBUF_NAMESPACE_ID::Empty* BarRequest::_internal_mutable_empty() { - - if (_impl_.empty_ == nullptr) { - auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Empty>(GetArenaForAllocation()); - _impl_.empty_ = p; - } - return _impl_.empty_; -} -inline ::PROTOBUF_NAMESPACE_ID::Empty* BarRequest::mutable_empty() { - ::PROTOBUF_NAMESPACE_ID::Empty* _msg = _internal_mutable_empty(); - // @@protoc_insertion_point(field_mutable:BarRequest.empty) - return _msg; -} -inline void BarRequest::set_allocated_empty(::PROTOBUF_NAMESPACE_ID::Empty* empty) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.empty_); - } - if (empty) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( - reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(empty)); - if (message_arena != submessage_arena) { - empty = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, empty, submessage_arena); - } - - } else { - - } - _impl_.empty_ = empty; - // @@protoc_insertion_point(field_set_allocated:BarRequest.empty) -} - -// ------------------------------------------------------------------- - -// BarResponse - -// .foo.Bar myExtern = 1; -inline bool BarResponse::_internal_has_myextern() const { - return this != internal_default_instance() && _impl_.myextern_ != nullptr; -} -inline bool BarResponse::has_myextern() const { - return _internal_has_myextern(); -} -inline const ::foo::Bar& BarResponse::_internal_myextern() const { - const ::foo::Bar* p = _impl_.myextern_; - return p != nullptr ? *p : reinterpret_cast( - ::foo::_Bar_default_instance_); -} -inline const ::foo::Bar& BarResponse::myextern() const { - // @@protoc_insertion_point(field_get:BarResponse.myExtern) - return _internal_myextern(); -} -inline void BarResponse::unsafe_arena_set_allocated_myextern( - ::foo::Bar* myextern) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.myextern_); - } - _impl_.myextern_ = myextern; - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:BarResponse.myExtern) -} -inline ::foo::Bar* BarResponse::release_myextern() { - - ::foo::Bar* temp = _impl_.myextern_; - _impl_.myextern_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::foo::Bar* BarResponse::unsafe_arena_release_myextern() { - // @@protoc_insertion_point(field_release:BarResponse.myExtern) - - ::foo::Bar* temp = _impl_.myextern_; - _impl_.myextern_ = nullptr; - return temp; -} -inline ::foo::Bar* BarResponse::_internal_mutable_myextern() { - - if (_impl_.myextern_ == nullptr) { - auto* p = CreateMaybeMessage<::foo::Bar>(GetArenaForAllocation()); - _impl_.myextern_ = p; - } - return _impl_.myextern_; -} -inline ::foo::Bar* BarResponse::mutable_myextern() { - ::foo::Bar* _msg = _internal_mutable_myextern(); - // @@protoc_insertion_point(field_mutable:BarResponse.myExtern) - return _msg; -} -inline void BarResponse::set_allocated_myextern(::foo::Bar* myextern) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.myextern_); - } - if (myextern) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( - reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(myextern)); - if (message_arena != submessage_arena) { - myextern = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, myextern, submessage_arena); - } - - } else { - - } - _impl_.myextern_ = myextern; - // @@protoc_insertion_point(field_set_allocated:BarResponse.myExtern) -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/extern/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/extern/output/csharp/Main.cs deleted file mode 100644 index 170a0bdbabc..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/csharp/Main.cs +++ /dev/null @@ -1,441 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -/// Holder for reflection information generated from main.proto -public static partial class MainReflection { - - #region Descriptor - /// File descriptor for main.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static MainReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgptYWluLnByb3RvGg1mb28vYmFyLnByb3RvGhtnb29nbGUvcHJvdG9idWYv", - "ZW1wdHkucHJvdG8iMwoKQmFyUmVxdWVzdBIlCgVlbXB0eRgBIAEoCzIWLmdv", - "b2dsZS5wcm90b2J1Zi5FbXB0eSIpCgtCYXJSZXNwb25zZRIaCghteUV4dGVy", - "bhgBIAEoCzIILmZvby5CYXIyVAoHU2VydmljZRInCgNGb28SCC5mb28uQmFy", - "GhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5EiAKA0JhchILLkJhclJlcXVlc3Qa", - "DC5CYXJSZXNwb25zZWIGcHJvdG8z")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::Foo.BarReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.EmptyReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::BarRequest), global::BarRequest.Parser, new[]{ "Empty" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::BarResponse), global::BarResponse.Parser, new[]{ "MyExtern" }, null, null, null, null) - })); - } - #endregion - -} -#region Messages -public sealed partial class BarRequest : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarRequest()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public BarRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public BarRequest(BarRequest other) : this() { - empty_ = other.empty_ != null ? other.empty_.Clone() : null; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public BarRequest Clone() { - return new BarRequest(this); - } - - /// Field number for the "empty" field. - public const int EmptyFieldNumber = 1; - private global::Google.Protobuf.WellKnownTypes.Empty empty_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::Google.Protobuf.WellKnownTypes.Empty Empty { - get { return empty_; } - set { - empty_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as BarRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(BarRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!object.Equals(Empty, other.Empty)) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (empty_ != null) hash ^= Empty.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (empty_ != null) { - output.WriteRawTag(10); - output.WriteMessage(Empty); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (empty_ != null) { - output.WriteRawTag(10); - output.WriteMessage(Empty); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (empty_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Empty); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(BarRequest other) { - if (other == null) { - return; - } - if (other.empty_ != null) { - if (empty_ == null) { - Empty = new global::Google.Protobuf.WellKnownTypes.Empty(); - } - Empty.MergeFrom(other.Empty); - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - if (empty_ == null) { - Empty = new global::Google.Protobuf.WellKnownTypes.Empty(); - } - input.ReadMessage(Empty); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - if (empty_ == null) { - Empty = new global::Google.Protobuf.WellKnownTypes.Empty(); - } - input.ReadMessage(Empty); - break; - } - } - } - } - #endif - -} - -public sealed partial class BarResponse : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public BarResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public BarResponse(BarResponse other) : this() { - myExtern_ = other.myExtern_ != null ? other.myExtern_.Clone() : null; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public BarResponse Clone() { - return new BarResponse(this); - } - - /// Field number for the "myExtern" field. - public const int MyExternFieldNumber = 1; - private global::Foo.Bar myExtern_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::Foo.Bar MyExtern { - get { return myExtern_; } - set { - myExtern_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as BarResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(BarResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!object.Equals(MyExtern, other.MyExtern)) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (myExtern_ != null) hash ^= MyExtern.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (myExtern_ != null) { - output.WriteRawTag(10); - output.WriteMessage(MyExtern); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (myExtern_ != null) { - output.WriteRawTag(10); - output.WriteMessage(MyExtern); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (myExtern_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(MyExtern); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(BarResponse other) { - if (other == null) { - return; - } - if (other.myExtern_ != null) { - if (myExtern_ == null) { - MyExtern = new global::Foo.Bar(); - } - MyExtern.MergeFrom(other.MyExtern); - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - if (myExtern_ == null) { - MyExtern = new global::Foo.Bar(); - } - input.ReadMessage(MyExtern); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - if (myExtern_ == null) { - MyExtern = new global::Foo.Bar(); - } - input.ReadMessage(MyExtern); - break; - } - } - } - } - #endif - -} - -#endregion - - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.h deleted file mode 100644 index de1a05cab24..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.h +++ /dev/null @@ -1,86 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -@class Bar; - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - MainRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface MainRoot : GPBRootObject -@end - -#pragma mark - BarRequest - -typedef GPB_ENUM(BarRequest_FieldNumber) { - BarRequest_FieldNumber_Empty = 1, -}; - -GPB_FINAL @interface BarRequest : GPBMessage - -@property(nonatomic, readwrite, strong, null_resettable) GPBEmpty *empty; -/** Test to see if @c empty has been set. */ -@property(nonatomic, readwrite) BOOL hasEmpty; - -@end - -#pragma mark - BarResponse - -typedef GPB_ENUM(BarResponse_FieldNumber) { - BarResponse_FieldNumber_MyExtern = 1, -}; - -GPB_FINAL @interface BarResponse : GPBMessage - -@property(nonatomic, readwrite, strong, null_resettable) Bar *myExtern; -/** Test to see if @c myExtern has been set. */ -@property(nonatomic, readwrite) BOOL hasMyExtern; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.m deleted file mode 100644 index 69b2a1e3b2a..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/objc/Main.pbobjc.m +++ /dev/null @@ -1,153 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "Main.pbobjc.h" -#import "foo/Bar.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension" - -#pragma mark - Objective C Class declarations -// Forward declarations of Objective C classes that we can use as -// static values in struct initializers. -// We don't use [Foo class] because it is not a static value. -GPBObjCClassDeclaration(Bar); -GPBObjCClassDeclaration(GPBEmpty); - -#pragma mark - MainRoot - -@implementation MainRoot - -// No extensions in the file and none of the imports (direct or indirect) -// defined extensions, so no need to generate +extensionRegistry. - -@end - -#pragma mark - MainRoot_FileDescriptor - -static GPBFileDescriptor *MainRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - BarRequest - -@implementation BarRequest - -@dynamic hasEmpty, empty; - -typedef struct BarRequest__storage_ { - uint32_t _has_storage_[1]; - GPBEmpty *empty; -} BarRequest__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "empty", - .dataTypeSpecific.clazz = GPBObjCClass(GPBEmpty), - .number = BarRequest_FieldNumber_Empty, - .hasIndex = 0, - .offset = (uint32_t)offsetof(BarRequest__storage_, empty), - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[BarRequest class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(BarRequest__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - BarResponse - -@implementation BarResponse - -@dynamic hasMyExtern, myExtern; - -typedef struct BarResponse__storage_ { - uint32_t _has_storage_[1]; - Bar *myExtern; -} BarResponse__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "myExtern", - .dataTypeSpecific.clazz = GPBObjCClass(Bar), - .number = BarResponse_FieldNumber_MyExtern, - .hasIndex = 0, - .offset = (uint32_t)offsetof(BarResponse__storage_, myExtern), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom), - .dataType = GPBDataTypeMessage, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[BarResponse class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(BarResponse__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\010\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/extern/output/php/BarRequest.php b/packages/protobuf/test/protoc-out/extern/output/php/BarRequest.php deleted file mode 100644 index 4fd3d7ded4c..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/php/BarRequest.php +++ /dev/null @@ -1,66 +0,0 @@ -BarRequest - */ -class BarRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field .google.protobuf.Empty empty = 1; - */ - protected $empty = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Protobuf\GPBEmpty $empty - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field .google.protobuf.Empty empty = 1; - * @return \Google\Protobuf\GPBEmpty|null - */ - public function getEmpty() - { - return $this->empty; - } - - public function hasEmpty() - { - return isset($this->empty); - } - - public function clearEmpty() - { - unset($this->empty); - } - - /** - * Generated from protobuf field .google.protobuf.Empty empty = 1; - * @param \Google\Protobuf\GPBEmpty $var - * @return $this - */ - public function setEmpty($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\GPBEmpty::class); - $this->empty = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/extern/output/php/BarResponse.php b/packages/protobuf/test/protoc-out/extern/output/php/BarResponse.php deleted file mode 100644 index 1f359ba8386..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/php/BarResponse.php +++ /dev/null @@ -1,66 +0,0 @@ -BarResponse - */ -class BarResponse extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field .foo.Bar myExtern = 1; - */ - protected $myExtern = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Foo\Bar $myExtern - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field .foo.Bar myExtern = 1; - * @return \Foo\Bar|null - */ - public function getMyExtern() - { - return $this->myExtern; - } - - public function hasMyExtern() - { - return isset($this->myExtern); - } - - public function clearMyExtern() - { - unset($this->myExtern); - } - - /** - * Generated from protobuf field .foo.Bar myExtern = 1; - * @param \Foo\Bar $var - * @return $this - */ - public function setMyExtern($var) - { - GPBUtil::checkMessage($var, \Foo\Bar::class); - $this->myExtern = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/extern/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/extern/output/php/GPBMetadata/Main.php deleted file mode 100644 index cf9f61bf3bc..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/php/GPBMetadata/Main.php +++ /dev/null @@ -1,37 +0,0 @@ -internalAddGeneratedFile( - ' -� - -main.protogoogle/protobuf/empty.proto"3 - -BarRequest% -empty ( 2.google.protobuf.Empty") - BarResponse -myExtern ( 2.foo.Bar2T -Service\' -Foo.foo.Bar.google.protobuf.Empty -Bar .BarRequest .BarResponsebproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/packages/protobuf/test/protoc-out/extern/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/extern/output/pyi/main_pb2.pyi deleted file mode 100644 index 7f0960e5818..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/pyi/main_pb2.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from foo import bar_pb2 as _bar_pb2 -from google.protobuf import empty_pb2 as _empty_pb2 -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union - -DESCRIPTOR: _descriptor.FileDescriptor - -class BarRequest(_message.Message): - __slots__ = ["empty"] - EMPTY_FIELD_NUMBER: _ClassVar[int] - empty: _empty_pb2.Empty - def __init__(self, empty: _Optional[_Union[_empty_pb2.Empty, _Mapping]] = ...) -> None: ... - -class BarResponse(_message.Message): - __slots__ = ["myExtern"] - MYEXTERN_FIELD_NUMBER: _ClassVar[int] - myExtern: _bar_pb2.Bar - def __init__(self, myExtern: _Optional[_Union[_bar_pb2.Bar, _Mapping]] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/extern/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/extern/output/python/main_pb2.py deleted file mode 100644 index f9bf0dcabde..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/python/main_pb2.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from foo import bar_pb2 as foo_dot_bar__pb2 -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\x1a\rfoo/bar.proto\x1a\x1bgoogle/protobuf/empty.proto\"3\n\nBarRequest\x12%\n\x05\x65mpty\x18\x01 \x01(\x0b\x32\x16.google.protobuf.Empty\")\n\x0b\x42\x61rResponse\x12\x1a\n\x08myExtern\x18\x01 \x01(\x0b\x32\x08.foo.Bar2T\n\x07Service\x12\'\n\x03\x46oo\x12\x08.foo.Bar\x1a\x16.google.protobuf.Empty\x12 \n\x03\x42\x61r\x12\x0b.BarRequest\x1a\x0c.BarResponseb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _globals['_BARREQUEST']._serialized_start=58 - _globals['_BARREQUEST']._serialized_end=109 - _globals['_BARRESPONSE']._serialized_start=111 - _globals['_BARRESPONSE']._serialized_end=152 - _globals['_SERVICE']._serialized_start=154 - _globals['_SERVICE']._serialized_end=238 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/extern/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/extern/output/ruby/main_pb.rb deleted file mode 100644 index 72db9a0c78e..00000000000 --- a/packages/protobuf/test/protoc-out/extern/output/ruby/main_pb.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto - -require 'google/protobuf' - -require 'foo/bar_pb' -require 'google/protobuf/empty_pb' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("main.proto", :syntax => :proto3) do - add_message "BarRequest" do - optional :empty, :message, 1, "google.protobuf.Empty" - end - add_message "BarResponse" do - optional :myExtern, :message, 1, "foo.Bar" - end - end -end - -BarRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("BarRequest").msgclass -BarResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("BarResponse").msgclass diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.cc b/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.cc deleted file mode 100644 index 7d054db1c93..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.cc +++ /dev/null @@ -1,590 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: com/azure/test.proto - -#include "com/azure/test.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -namespace com { -namespace azure { -namespace test { -PROTOBUF_CONSTEXPR FooRequest::FooRequest( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_._cached_size_)*/{}} {} -struct FooRequestDefaultTypeInternal { - PROTOBUF_CONSTEXPR FooRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~FooRequestDefaultTypeInternal() {} - union { - FooRequest _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FooRequestDefaultTypeInternal _FooRequest_default_instance_; -PROTOBUF_CONSTEXPR FooResponse::FooResponse( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /* ._impl_.testoutputfield_ = */ 0 - - , /*decltype(_impl_._cached_size_)*/{}} {} -struct FooResponseDefaultTypeInternal { - PROTOBUF_CONSTEXPR FooResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~FooResponseDefaultTypeInternal() {} - union { - FooResponse _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FooResponseDefaultTypeInternal _FooResponse_default_instance_; -} // namespace test -} // namespace azure -} // namespace com -static ::_pb::Metadata file_level_metadata_com_2fazure_2ftest_2eproto[2]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_com_2fazure_2ftest_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_com_2fazure_2ftest_2eproto = nullptr; -const ::uint32_t TableStruct_com_2fazure_2ftest_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::com::azure::test::FooRequest, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::com::azure::test::FooRequest, _impl_.testinputfield_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::com::azure::test::FooResponse, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::com::azure::test::FooResponse, _impl_.testoutputfield_), - PROTOBUF_FIELD_OFFSET(::com::azure::test::FooResponse, _impl_.secondfield_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::com::azure::test::FooRequest)}, - { 9, -1, -1, sizeof(::com::azure::test::FooResponse)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::com::azure::test::_FooRequest_default_instance_._instance, - &::com::azure::test::_FooResponse_default_instance_._instance, -}; -const char descriptor_table_protodef_com_2fazure_2ftest_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\024com/azure/test.proto\022\016com.azure.test\"$" - "\n\nFooRequest\022\026\n\016testInputField\030\001 \001(\t\";\n\013" - "FooResponse\022\027\n\017testOutputField\030\001 \001(\005\022\023\n\013" - "secondField\030\002 \001(\t2I\n\007Service\022>\n\003Foo\022\032.co" - "m.azure.test.FooRequest\032\033.com.azure.test" - ".FooResponseb\006proto3" -}; -static ::absl::once_flag descriptor_table_com_2fazure_2ftest_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_com_2fazure_2ftest_2eproto = { - false, - false, - 220, - descriptor_table_protodef_com_2fazure_2ftest_2eproto, - "com/azure/test.proto", - &descriptor_table_com_2fazure_2ftest_2eproto_once, - nullptr, - 0, - 2, - schemas, - file_default_instances, - TableStruct_com_2fazure_2ftest_2eproto::offsets, - file_level_metadata_com_2fazure_2ftest_2eproto, - file_level_enum_descriptors_com_2fazure_2ftest_2eproto, - file_level_service_descriptors_com_2fazure_2ftest_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_com_2fazure_2ftest_2eproto_getter() { - return &descriptor_table_com_2fazure_2ftest_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_com_2fazure_2ftest_2eproto(&descriptor_table_com_2fazure_2ftest_2eproto); -namespace com { -namespace azure { -namespace test { -// =================================================================== - -class FooRequest::_Internal { - public: -}; - -FooRequest::FooRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:com.azure.test.FooRequest) -} -FooRequest::FooRequest(const FooRequest& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - FooRequest* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_testinputfield().empty()) { - _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), - _this->GetArenaForAllocation()); - } - // @@protoc_insertion_point(copy_constructor:com.azure.test.FooRequest) -} - -inline void FooRequest::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -FooRequest::~FooRequest() { - // @@protoc_insertion_point(destructor:com.azure.test.FooRequest) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void FooRequest::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testinputfield_.Destroy(); -} - -void FooRequest::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void FooRequest::Clear() { -// @@protoc_insertion_point(message_clear_start:com.azure.test.FooRequest) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_.ClearToEmpty(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* FooRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // string testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - auto str = _internal_mutable_testinputfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "com.azure.test.FooRequest.testInputField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* FooRequest::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:com.azure.test.FooRequest) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "com.azure.test.FooRequest.testInputField"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_testinputfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:com.azure.test.FooRequest) - return target; -} - -::size_t FooRequest::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:com.azure.test.FooRequest) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_testinputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FooRequest::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - FooRequest::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FooRequest::GetClassData() const { return &_class_data_; } - - -void FooRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.test.FooRequest) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_testinputfield().empty()) { - _this->_internal_set_testinputfield(from._internal_testinputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void FooRequest::CopyFrom(const FooRequest& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.test.FooRequest) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool FooRequest::IsInitialized() const { - return true; -} - -void FooRequest::InternalSwap(FooRequest* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.testinputfield_, lhs_arena, - &other->_impl_.testinputfield_, rhs_arena - ); -} - -::PROTOBUF_NAMESPACE_ID::Metadata FooRequest::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_com_2fazure_2ftest_2eproto_getter, &descriptor_table_com_2fazure_2ftest_2eproto_once, - file_level_metadata_com_2fazure_2ftest_2eproto[0]); -} -// =================================================================== - -class FooResponse::_Internal { - public: -}; - -FooResponse::FooResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:com.azure.test.FooResponse) -} -FooResponse::FooResponse(const FooResponse& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - FooResponse* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) {} - - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_secondfield().empty()) { - _this->_impl_.secondfield_.Set(from._internal_secondfield(), - _this->GetArenaForAllocation()); - } - _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; - // @@protoc_insertion_point(copy_constructor:com.azure.test.FooResponse) -} - -inline void FooResponse::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) { 0 } - - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -FooResponse::~FooResponse() { - // @@protoc_insertion_point(destructor:com.azure.test.FooResponse) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void FooResponse::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.secondfield_.Destroy(); -} - -void FooResponse::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void FooResponse::Clear() { -// @@protoc_insertion_point(message_clear_start:com.azure.test.FooResponse) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.secondfield_.ClearToEmpty(); - _impl_.testoutputfield_ = 0; - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* FooResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // int32 testOutputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { - _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - // string secondField = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { - auto str = _internal_mutable_secondfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "com.azure.test.FooResponse.secondField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* FooResponse::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:com.azure.test.FooResponse) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray( - 1, this->_internal_testoutputfield(), target); - } - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "com.azure.test.FooResponse.secondField"); - target = stream->WriteStringMaybeAliased( - 2, this->_internal_secondfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:com.azure.test.FooResponse) - return target; -} - -::size_t FooResponse::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:com.azure.test.FooResponse) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_secondfield()); - } - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( - this->_internal_testoutputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FooResponse::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - FooResponse::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FooResponse::GetClassData() const { return &_class_data_; } - - -void FooResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.test.FooResponse) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_secondfield().empty()) { - _this->_internal_set_secondfield(from._internal_secondfield()); - } - if (from._internal_testoutputfield() != 0) { - _this->_internal_set_testoutputfield(from._internal_testoutputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void FooResponse::CopyFrom(const FooResponse& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.test.FooResponse) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool FooResponse::IsInitialized() const { - return true; -} - -void FooResponse::InternalSwap(FooResponse* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.secondfield_, lhs_arena, - &other->_impl_.secondfield_, rhs_arena - ); - - swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata FooResponse::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_com_2fazure_2ftest_2eproto_getter, &descriptor_table_com_2fazure_2ftest_2eproto_once, - file_level_metadata_com_2fazure_2ftest_2eproto[1]); -} -// @@protoc_insertion_point(namespace_scope) -} // namespace test -} // namespace azure -} // namespace com -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::com::azure::test::FooRequest* -Arena::CreateMaybeMessage< ::com::azure::test::FooRequest >(Arena* arena) { - return Arena::CreateMessageInternal< ::com::azure::test::FooRequest >(arena); -} -template<> PROTOBUF_NOINLINE ::com::azure::test::FooResponse* -Arena::CreateMaybeMessage< ::com::azure::test::FooResponse >(Arena* arena) { - return Arena::CreateMessageInternal< ::com::azure::test::FooResponse >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.h b/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.h deleted file mode 100644 index d10a9de7746..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/cpp/com/azure/test.pb.h +++ /dev/null @@ -1,538 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: com/azure/test.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/unknown_field_set.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_com_2fazure_2ftest_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_com_2fazure_2ftest_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_com_2fazure_2ftest_2eproto; -namespace com { -namespace azure { -namespace test { -class FooRequest; -struct FooRequestDefaultTypeInternal; -extern FooRequestDefaultTypeInternal _FooRequest_default_instance_; -class FooResponse; -struct FooResponseDefaultTypeInternal; -extern FooResponseDefaultTypeInternal _FooResponse_default_instance_; -} // namespace test -} // namespace azure -} // namespace com -PROTOBUF_NAMESPACE_OPEN -template <> -::com::azure::test::FooRequest* Arena::CreateMaybeMessage<::com::azure::test::FooRequest>(Arena*); -template <> -::com::azure::test::FooResponse* Arena::CreateMaybeMessage<::com::azure::test::FooResponse>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - -namespace com { -namespace azure { -namespace test { - -// =================================================================== - - -// ------------------------------------------------------------------- - -class FooRequest final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.test.FooRequest) */ { - public: - inline FooRequest() : FooRequest(nullptr) {} - ~FooRequest() override; - explicit PROTOBUF_CONSTEXPR FooRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - FooRequest(const FooRequest& from); - FooRequest(FooRequest&& from) noexcept - : FooRequest() { - *this = ::std::move(from); - } - - inline FooRequest& operator=(const FooRequest& from) { - CopyFrom(from); - return *this; - } - inline FooRequest& operator=(FooRequest&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const FooRequest& default_instance() { - return *internal_default_instance(); - } - static inline const FooRequest* internal_default_instance() { - return reinterpret_cast( - &_FooRequest_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(FooRequest& a, FooRequest& b) { - a.Swap(&b); - } - inline void Swap(FooRequest* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(FooRequest* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - FooRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const FooRequest& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const FooRequest& from) { - FooRequest::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(FooRequest* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "com.azure.test.FooRequest"; - } - protected: - explicit FooRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - }; - // string testInputField = 1; - void clear_testinputfield() ; - const std::string& testinputfield() const; - template - void set_testinputfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_testinputfield(); - PROTOBUF_NODISCARD std::string* release_testinputfield(); - void set_allocated_testinputfield(std::string* testinputfield); - private: - const std::string& _internal_testinputfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); - std::string* _internal_mutable_testinputfield(); - public: - // @@protoc_insertion_point(class_scope:com.azure.test.FooRequest) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_com_2fazure_2ftest_2eproto; -};// ------------------------------------------------------------------- - -class FooResponse final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.test.FooResponse) */ { - public: - inline FooResponse() : FooResponse(nullptr) {} - ~FooResponse() override; - explicit PROTOBUF_CONSTEXPR FooResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - FooResponse(const FooResponse& from); - FooResponse(FooResponse&& from) noexcept - : FooResponse() { - *this = ::std::move(from); - } - - inline FooResponse& operator=(const FooResponse& from) { - CopyFrom(from); - return *this; - } - inline FooResponse& operator=(FooResponse&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const FooResponse& default_instance() { - return *internal_default_instance(); - } - static inline const FooResponse* internal_default_instance() { - return reinterpret_cast( - &_FooResponse_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(FooResponse& a, FooResponse& b) { - a.Swap(&b); - } - inline void Swap(FooResponse* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(FooResponse* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - FooResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const FooResponse& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const FooResponse& from) { - FooResponse::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(FooResponse* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "com.azure.test.FooResponse"; - } - protected: - explicit FooResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kSecondFieldFieldNumber = 2, - kTestOutputFieldFieldNumber = 1, - }; - // string secondField = 2; - void clear_secondfield() ; - const std::string& secondfield() const; - template - void set_secondfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_secondfield(); - PROTOBUF_NODISCARD std::string* release_secondfield(); - void set_allocated_secondfield(std::string* secondfield); - private: - const std::string& _internal_secondfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); - std::string* _internal_mutable_secondfield(); - public: - // int32 testOutputField = 1; - void clear_testoutputfield() ; - ::int32_t testoutputfield() const; - void set_testoutputfield(::int32_t value); - - private: - ::int32_t _internal_testoutputfield() const; - void _internal_set_testoutputfield(::int32_t value); - - public: - // @@protoc_insertion_point(class_scope:com.azure.test.FooResponse) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; - ::int32_t testoutputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_com_2fazure_2ftest_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// FooRequest - -// string testInputField = 1; -inline void FooRequest::clear_testinputfield() { - _impl_.testinputfield_.ClearToEmpty(); -} -inline const std::string& FooRequest::testinputfield() const { - // @@protoc_insertion_point(field_get:com.azure.test.FooRequest.testInputField) - return _internal_testinputfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void FooRequest::set_testinputfield(ArgT0&& arg0, ArgT... args) { - - _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:com.azure.test.FooRequest.testInputField) -} -inline std::string* FooRequest::mutable_testinputfield() { - std::string* _s = _internal_mutable_testinputfield(); - // @@protoc_insertion_point(field_mutable:com.azure.test.FooRequest.testInputField) - return _s; -} -inline const std::string& FooRequest::_internal_testinputfield() const { - return _impl_.testinputfield_.Get(); -} -inline void FooRequest::_internal_set_testinputfield(const std::string& value) { - - _impl_.testinputfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* FooRequest::_internal_mutable_testinputfield() { - - return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* FooRequest::release_testinputfield() { - // @@protoc_insertion_point(field_release:com.azure.test.FooRequest.testInputField) - return _impl_.testinputfield_.Release(); -} -inline void FooRequest::set_allocated_testinputfield(std::string* testinputfield) { - _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.testinputfield_.IsDefault()) { - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:com.azure.test.FooRequest.testInputField) -} - -// ------------------------------------------------------------------- - -// FooResponse - -// int32 testOutputField = 1; -inline void FooResponse::clear_testoutputfield() { - _impl_.testoutputfield_ = 0; -} -inline ::int32_t FooResponse::testoutputfield() const { - // @@protoc_insertion_point(field_get:com.azure.test.FooResponse.testOutputField) - return _internal_testoutputfield(); -} -inline void FooResponse::set_testoutputfield(::int32_t value) { - ; - _internal_set_testoutputfield(value); - // @@protoc_insertion_point(field_set:com.azure.test.FooResponse.testOutputField) -} -inline ::int32_t FooResponse::_internal_testoutputfield() const { - return _impl_.testoutputfield_; -} -inline void FooResponse::_internal_set_testoutputfield(::int32_t value) { - ; - _impl_.testoutputfield_ = value; -} - -// string secondField = 2; -inline void FooResponse::clear_secondfield() { - _impl_.secondfield_.ClearToEmpty(); -} -inline const std::string& FooResponse::secondfield() const { - // @@protoc_insertion_point(field_get:com.azure.test.FooResponse.secondField) - return _internal_secondfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void FooResponse::set_secondfield(ArgT0&& arg0, ArgT... args) { - - _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:com.azure.test.FooResponse.secondField) -} -inline std::string* FooResponse::mutable_secondfield() { - std::string* _s = _internal_mutable_secondfield(); - // @@protoc_insertion_point(field_mutable:com.azure.test.FooResponse.secondField) - return _s; -} -inline const std::string& FooResponse::_internal_secondfield() const { - return _impl_.secondfield_.Get(); -} -inline void FooResponse::_internal_set_secondfield(const std::string& value) { - - _impl_.secondfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* FooResponse::_internal_mutable_secondfield() { - - return _impl_.secondfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* FooResponse::release_secondfield() { - // @@protoc_insertion_point(field_release:com.azure.test.FooResponse.secondField) - return _impl_.secondfield_.Release(); -} -inline void FooResponse::set_allocated_secondfield(std::string* secondfield) { - _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.secondfield_.IsDefault()) { - _impl_.secondfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:com.azure.test.FooResponse.secondField) -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) -} // namespace test -} // namespace azure -} // namespace com - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2ftest_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/csharp/Test.cs b/packages/protobuf/test/protoc-out/inferred-message-names/output/csharp/Test.cs deleted file mode 100644 index 82b6f3ff744..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/csharp/Test.cs +++ /dev/null @@ -1,462 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: com/azure/test.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Com.Azure.Test { - - /// Holder for reflection information generated from com/azure/test.proto - public static partial class TestReflection { - - #region Descriptor - /// File descriptor for com/azure/test.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static TestReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChRjb20vYXp1cmUvdGVzdC5wcm90bxIOY29tLmF6dXJlLnRlc3QiJAoKRm9v", - "UmVxdWVzdBIWCg50ZXN0SW5wdXRGaWVsZBgBIAEoCSI7CgtGb29SZXNwb25z", - "ZRIXCg90ZXN0T3V0cHV0RmllbGQYASABKAUSEwoLc2Vjb25kRmllbGQYAiAB", - "KAkySQoHU2VydmljZRI+CgNGb28SGi5jb20uYXp1cmUudGVzdC5Gb29SZXF1", - "ZXN0GhsuY29tLmF6dXJlLnRlc3QuRm9vUmVzcG9uc2ViBnByb3RvMw==")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.FooRequest), global::Com.Azure.Test.FooRequest.Parser, new[]{ "TestInputField" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.FooResponse), global::Com.Azure.Test.FooResponse.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class FooRequest : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooRequest()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FooRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FooRequest(FooRequest other) : this() { - testInputField_ = other.testInputField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FooRequest Clone() { - return new FooRequest(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private string testInputField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string TestInputField { - get { return testInputField_; } - set { - testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as FooRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(FooRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestInputField != other.TestInputField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestInputField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(FooRequest other) { - if (other == null) { - return; - } - if (other.TestInputField.Length != 0) { - TestInputField = other.TestInputField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - } - #endif - - } - - public sealed partial class FooResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FooResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FooResponse(FooResponse other) : this() { - testOutputField_ = other.testOutputField_; - secondField_ = other.secondField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FooResponse Clone() { - return new FooResponse(this); - } - - /// Field number for the "testOutputField" field. - public const int TestOutputFieldFieldNumber = 1; - private int testOutputField_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int TestOutputField { - get { return testOutputField_; } - set { - testOutputField_ = value; - } - } - - /// Field number for the "secondField" field. - public const int SecondFieldFieldNumber = 2; - private string secondField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string SecondField { - get { return secondField_; } - set { - secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as FooResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(FooResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestOutputField != other.TestOutputField) return false; - if (SecondField != other.SecondField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); - if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestOutputField != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); - } - if (SecondField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(FooResponse other) { - if (other == null) { - return; - } - if (other.TestOutputField != 0) { - TestOutputField = other.TestOutputField; - } - if (other.SecondField.Length != 0) { - SecondField = other.SecondField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - } - #endif - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.h b/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.h deleted file mode 100644 index bb2e8245519..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.h +++ /dev/null @@ -1,83 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: com/azure/test.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - TestRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface TestRoot : GPBRootObject -@end - -#pragma mark - FooRequest - -typedef GPB_ENUM(FooRequest_FieldNumber) { - FooRequest_FieldNumber_TestInputField = 1, -}; - -GPB_FINAL @interface FooRequest : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; - -@end - -#pragma mark - FooResponse - -typedef GPB_ENUM(FooResponse_FieldNumber) { - FooResponse_FieldNumber_TestOutputField = 1, - FooResponse_FieldNumber_SecondField = 2, -}; - -GPB_FINAL @interface FooResponse : GPBMessage - -@property(nonatomic, readwrite) int32_t testOutputField; - -@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.m b/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.m deleted file mode 100644 index 6c3b111f0b1..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/objc/com/azure/Test.pbobjc.m +++ /dev/null @@ -1,160 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: com/azure/test.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "com/azure/Test.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -#pragma mark - TestRoot - -@implementation TestRoot - -// No extensions in the file and no imports, so no need to generate -// +extensionRegistry. - -@end - -#pragma mark - TestRoot_FileDescriptor - -static GPBFileDescriptor *TestRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"com.azure.test" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - FooRequest - -@implementation FooRequest - -@dynamic testInputField; - -typedef struct FooRequest__storage_ { - uint32_t _has_storage_[1]; - NSString *testInputField; -} FooRequest__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputField", - .dataTypeSpecific.clazz = Nil, - .number = FooRequest_FieldNumber_TestInputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(FooRequest__storage_, testInputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[FooRequest class] - file:TestRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(FooRequest__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\016\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - FooResponse - -@implementation FooResponse - -@dynamic testOutputField; -@dynamic secondField; - -typedef struct FooResponse__storage_ { - uint32_t _has_storage_[1]; - int32_t testOutputField; - NSString *secondField; -} FooResponse__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testOutputField", - .dataTypeSpecific.clazz = Nil, - .number = FooResponse_FieldNumber_TestOutputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(FooResponse__storage_, testOutputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeInt32, - }, - { - .name = "secondField", - .dataTypeSpecific.clazz = Nil, - .number = FooResponse_FieldNumber_SecondField, - .hasIndex = 1, - .offset = (uint32_t)offsetof(FooResponse__storage_, secondField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[FooResponse class] - file:TestRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(FooResponse__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\002\001\017\000\002\013\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooRequest.php b/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooRequest.php deleted file mode 100644 index 81195e7219f..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooRequest.php +++ /dev/null @@ -1,58 +0,0 @@ -com.azure.test.FooRequest - */ -class FooRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field string testInputField = 1; - */ - protected $testInputField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $testInputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Com\Azure\Test::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field string testInputField = 1; - * @return string - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field string testInputField = 1; - * @param string $var - * @return $this - */ - public function setTestInputField($var) - { - GPBUtil::checkString($var, True); - $this->testInputField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooResponse.php b/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooResponse.php deleted file mode 100644 index 84b1a0d3113..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/php/Com/Azure/Test/FooResponse.php +++ /dev/null @@ -1,85 +0,0 @@ -com.azure.test.FooResponse - */ -class FooResponse extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field int32 testOutputField = 1; - */ - protected $testOutputField = 0; - /** - * Generated from protobuf field string secondField = 2; - */ - protected $secondField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $testOutputField - * @type string $secondField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Com\Azure\Test::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @return int - */ - public function getTestOutputField() - { - return $this->testOutputField; - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @param int $var - * @return $this - */ - public function setTestOutputField($var) - { - GPBUtil::checkInt32($var); - $this->testOutputField = $var; - - return $this; - } - - /** - * Generated from protobuf field string secondField = 2; - * @return string - */ - public function getSecondField() - { - return $this->secondField; - } - - /** - * Generated from protobuf field string secondField = 2; - * @param string $var - * @return $this - */ - public function setSecondField($var) - { - GPBUtil::checkString($var, True); - $this->secondField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/php/GPBMetadata/Com/Azure/Test.php b/packages/protobuf/test/protoc-out/inferred-message-names/output/php/GPBMetadata/Com/Azure/Test.php deleted file mode 100644 index 0f0508d0397..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/php/GPBMetadata/Com/Azure/Test.php +++ /dev/null @@ -1,34 +0,0 @@ -internalAddGeneratedFile( - ' -� -com/azure/test.protocom.azure.test"$ - -FooRequest -testInputField ( "; - FooResponse -testOutputField ( - secondField ( 2I -Service> -Foo.com.azure.test.FooRequest.com.azure.test.FooResponsebproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/pyi/com/azure/test_pb2.pyi b/packages/protobuf/test/protoc-out/inferred-message-names/output/pyi/com/azure/test_pb2.pyi deleted file mode 100644 index efb8ce7bbae..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/pyi/com/azure/test_pb2.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Optional as _Optional - -DESCRIPTOR: _descriptor.FileDescriptor - -class FooRequest(_message.Message): - __slots__ = ["testInputField"] - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testInputField: str - def __init__(self, testInputField: _Optional[str] = ...) -> None: ... - -class FooResponse(_message.Message): - __slots__ = ["testOutputField", "secondField"] - TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] - SECONDFIELD_FIELD_NUMBER: _ClassVar[int] - testOutputField: int - secondField: str - def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/python/com/azure/test_pb2.py b/packages/protobuf/test/protoc-out/inferred-message-names/output/python/com/azure/test_pb2.py deleted file mode 100644 index 7c83d5b4953..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/python/com/azure/test_pb2.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: com/azure/test.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x63om/azure/test.proto\x12\x0e\x63om.azure.test\"$\n\nFooRequest\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\";\n\x0b\x46ooResponse\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t2I\n\x07Service\x12>\n\x03\x46oo\x12\x1a.com.azure.test.FooRequest\x1a\x1b.com.azure.test.FooResponseb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'com.azure.test_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _globals['_FOOREQUEST']._serialized_start=40 - _globals['_FOOREQUEST']._serialized_end=76 - _globals['_FOORESPONSE']._serialized_start=78 - _globals['_FOORESPONSE']._serialized_end=137 - _globals['_SERVICE']._serialized_start=139 - _globals['_SERVICE']._serialized_end=212 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/inferred-message-names/output/ruby/com/azure/test_pb.rb b/packages/protobuf/test/protoc-out/inferred-message-names/output/ruby/com/azure/test_pb.rb deleted file mode 100644 index 1c4ab5efe2a..00000000000 --- a/packages/protobuf/test/protoc-out/inferred-message-names/output/ruby/com/azure/test_pb.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: com/azure/test.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("com/azure/test.proto", :syntax => :proto3) do - add_message "com.azure.test.FooRequest" do - optional :testInputField, :string, 1 - end - add_message "com.azure.test.FooResponse" do - optional :testOutputField, :int32, 1 - optional :secondField, :string, 2 - end - end -end - -module Com - module Azure - module Test - FooRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.test.FooRequest").msgclass - FooResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.test.FooResponse").msgclass - end - end -end diff --git a/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.cc deleted file mode 100644 index a01eb7b7099..00000000000 --- a/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.cc +++ /dev/null @@ -1,372 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#include "main.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -PROTOBUF_CONSTEXPR Input_TestInputFieldEntry_DoNotUse::Input_TestInputFieldEntry_DoNotUse( - ::_pbi::ConstantInitialized) {} -struct Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal { - PROTOBUF_CONSTEXPR Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal() {} - union { - Input_TestInputFieldEntry_DoNotUse _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal _Input_TestInputFieldEntry_DoNotUse_default_instance_; -PROTOBUF_CONSTEXPR Input::Input( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.testinputfield_)*/{::_pbi::ConstantInitialized()} - , /*decltype(_impl_._cached_size_)*/{}} {} -struct InputDefaultTypeInternal { - PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputDefaultTypeInternal() {} - union { - Input _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; -static ::_pb::Metadata file_level_metadata_main_2eproto[2]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_main_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_main_2eproto = nullptr; -const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - PROTOBUF_FIELD_OFFSET(::Input_TestInputFieldEntry_DoNotUse, _has_bits_), - PROTOBUF_FIELD_OFFSET(::Input_TestInputFieldEntry_DoNotUse, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::Input_TestInputFieldEntry_DoNotUse, key_), - PROTOBUF_FIELD_OFFSET(::Input_TestInputFieldEntry_DoNotUse, value_), - 0, - 1, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::Input, _impl_.testinputfield_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, 10, -1, sizeof(::Input_TestInputFieldEntry_DoNotUse)}, - { 12, -1, -1, sizeof(::Input)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::_Input_TestInputFieldEntry_DoNotUse_default_instance_._instance, - &::_Input_default_instance_._instance, -}; -const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\nmain.proto\032\033google/protobuf/empty.prot" - "o\"r\n\005Input\0222\n\016testInputField\030\001 \003(\0132\032.Inp" - "ut.TestInputFieldEntry\0325\n\023TestInputField" - "Entry\022\013\n\003key\030\001 \001(\017\022\r\n\005value\030\002 \001(\t:\0028\00120\n" - "\007Service\022%\n\003Foo\022\006.Input\032\026.google.protobu" - "f.Emptyb\006proto3" -}; -static const ::_pbi::DescriptorTable* const descriptor_table_main_2eproto_deps[1] = - { - &::descriptor_table_google_2fprotobuf_2fempty_2eproto, -}; -static ::absl::once_flag descriptor_table_main_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { - false, - false, - 215, - descriptor_table_protodef_main_2eproto, - "main.proto", - &descriptor_table_main_2eproto_once, - descriptor_table_main_2eproto_deps, - 1, - 2, - schemas, - file_default_instances, - TableStruct_main_2eproto::offsets, - file_level_metadata_main_2eproto, - file_level_enum_descriptors_main_2eproto, - file_level_service_descriptors_main_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { - return &descriptor_table_main_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); -// =================================================================== - -Input_TestInputFieldEntry_DoNotUse::Input_TestInputFieldEntry_DoNotUse() {} -Input_TestInputFieldEntry_DoNotUse::Input_TestInputFieldEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : SuperType(arena) {} -void Input_TestInputFieldEntry_DoNotUse::MergeFrom(const Input_TestInputFieldEntry_DoNotUse& other) { - MergeFromInternal(other); -} -::PROTOBUF_NAMESPACE_ID::Metadata Input_TestInputFieldEntry_DoNotUse::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[0]); -} -// =================================================================== - -class Input::_Internal { - public: -}; - -Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - if (arena != nullptr) { - arena->OwnCustomDestructor(this, &Input::ArenaDtor); - } - // @@protoc_insertion_point(arena_constructor:Input) -} -Input::Input(const Input& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Input* const _this = this; (void)_this; - new (&_impl_) Impl_{ - /*decltype(_impl_.testinputfield_)*/{} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _this->_impl_.testinputfield_.MergeFrom(from._impl_.testinputfield_); - // @@protoc_insertion_point(copy_constructor:Input) -} - -inline void Input::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - /*decltype(_impl_.testinputfield_)*/{::_pbi::ArenaInitialized(), arena} - , /*decltype(_impl_._cached_size_)*/{} - }; -} - -Input::~Input() { - // @@protoc_insertion_point(destructor:Input) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - ArenaDtor(this); - return; - } - SharedDtor(); -} - -inline void Input::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testinputfield_.Destruct(); - _impl_.testinputfield_.~MapField(); -} - -void Input::ArenaDtor(void* object) { - Input* _this = reinterpret_cast< Input* >(object); - _this->_impl_.testinputfield_.Destruct(); -} -void Input::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Input::Clear() { -// @@protoc_insertion_point(message_clear_start:Input) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // map testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(&_impl_.testinputfield_, ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Input::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:Input) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // map testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - using MapType = ::_pb::Map<::int32_t, std::string>; - using WireHelper = Input_TestInputFieldEntry_DoNotUse::Funcs; - const auto& map_field = this->_internal_testinputfield(); - auto check_utf8 = [](const MapType::value_type& entry) { - (void)entry; - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - entry.second.data(), static_cast(entry.second.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "Input.TestInputFieldEntry.value"); - }; - - if (stream->IsSerializationDeterministic() && map_field.size() > 1) { - for (const auto& entry : ::_pbi::MapSorterFlat(map_field)) { - target = WireHelper::InternalSerialize(1, entry.first, entry.second, target, stream); - check_utf8(entry); - } - } else { - for (const auto& entry : map_field) { - target = WireHelper::InternalSerialize(1, entry.first, entry.second, target, stream); - check_utf8(entry); - } - } - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:Input) - return target; -} - -::size_t Input::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:Input) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // map testInputField = 1; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_testinputfield_size()); - for (::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >::const_iterator - it = this->_internal_testinputfield().begin(); - it != this->_internal_testinputfield().end(); ++it) { - total_size += Input_TestInputFieldEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Input::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } - - -void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:Input) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - _this->_impl_.testinputfield_.MergeFrom(from._impl_.testinputfield_); - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Input::CopyFrom(const Input& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:Input) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Input::IsInitialized() const { - return true; -} - -void Input::InternalSwap(Input* other) { - using std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - _impl_.testinputfield_.InternalSwap(&other->_impl_.testinputfield_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[1]); -} -// @@protoc_insertion_point(namespace_scope) -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::Input_TestInputFieldEntry_DoNotUse* -Arena::CreateMaybeMessage< ::Input_TestInputFieldEntry_DoNotUse >(Arena* arena) { - return Arena::CreateMessageInternal< ::Input_TestInputFieldEntry_DoNotUse >(arena); -} -template<> PROTOBUF_NOINLINE ::Input* -Arena::CreateMaybeMessage< ::Input >(Arena* arena) { - return Arena::CreateMessageInternal< ::Input >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.h deleted file mode 100644 index 980cc648f26..00000000000 --- a/packages/protobuf/test/protoc-out/map/output/cpp/main.pb.h +++ /dev/null @@ -1,320 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/map.h" // IWYU pragma: export -#include "google/protobuf/map_entry.h" -#include "google/protobuf/map_field_inl.h" -#include "google/protobuf/unknown_field_set.h" -#include "google/protobuf/empty.pb.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_main_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_main_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_main_2eproto; -class Input; -struct InputDefaultTypeInternal; -extern InputDefaultTypeInternal _Input_default_instance_; -class Input_TestInputFieldEntry_DoNotUse; -struct Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal; -extern Input_TestInputFieldEntry_DoNotUseDefaultTypeInternal _Input_TestInputFieldEntry_DoNotUse_default_instance_; -PROTOBUF_NAMESPACE_OPEN -template <> -::Input* Arena::CreateMaybeMessage<::Input>(Arena*); -template <> -::Input_TestInputFieldEntry_DoNotUse* Arena::CreateMaybeMessage<::Input_TestInputFieldEntry_DoNotUse>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - - -// =================================================================== - - -// ------------------------------------------------------------------- - -class Input_TestInputFieldEntry_DoNotUse final : public ::PROTOBUF_NAMESPACE_ID::internal::MapEntry { -public: - typedef ::PROTOBUF_NAMESPACE_ID::internal::MapEntry SuperType; - Input_TestInputFieldEntry_DoNotUse(); - explicit PROTOBUF_CONSTEXPR Input_TestInputFieldEntry_DoNotUse( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - explicit Input_TestInputFieldEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void MergeFrom(const Input_TestInputFieldEntry_DoNotUse& other); - static const Input_TestInputFieldEntry_DoNotUse* internal_default_instance() { return reinterpret_cast(&_Input_TestInputFieldEntry_DoNotUse_default_instance_); } - static bool ValidateKey(void*) { return true; } - static bool ValidateValue(std::string* s) { - return ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(s->data(), static_cast(s->size()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "Input.TestInputFieldEntry.value"); - } - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - friend struct ::TableStruct_main_2eproto; -}; -// ------------------------------------------------------------------- - -class Input final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { - public: - inline Input() : Input(nullptr) {} - ~Input() override; - explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Input(const Input& from); - Input(Input&& from) noexcept - : Input() { - *this = ::std::move(from); - } - - inline Input& operator=(const Input& from) { - CopyFrom(from); - return *this; - } - inline Input& operator=(Input&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Input& default_instance() { - return *internal_default_instance(); - } - static inline const Input* internal_default_instance() { - return reinterpret_cast( - &_Input_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(Input& a, Input& b) { - a.Swap(&b); - } - inline void Swap(Input* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Input* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Input& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Input& from) { - Input::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Input* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "Input"; - } - protected: - explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - }; - // map testInputField = 1; - int testinputfield_size() const; - private: - int _internal_testinputfield_size() const; - - public: - void clear_testinputfield() ; - private: - const ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >& - _internal_testinputfield() const; - ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >* - _internal_mutable_testinputfield(); - public: - const ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >& - testinputfield() const; - ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >* - mutable_testinputfield(); - // @@protoc_insertion_point(class_scope:Input) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::MapField< - Input_TestInputFieldEntry_DoNotUse, - ::int32_t, std::string, - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_SFIXED32, - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING> testinputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// Input - -// map testInputField = 1; -inline int Input::_internal_testinputfield_size() const { - return _impl_.testinputfield_.size(); -} -inline int Input::testinputfield_size() const { - return _internal_testinputfield_size(); -} -inline void Input::clear_testinputfield() { - _impl_.testinputfield_.Clear(); -} -inline const ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >& -Input::_internal_testinputfield() const { - return _impl_.testinputfield_.GetMap(); -} -inline const ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >& -Input::testinputfield() const { - // @@protoc_insertion_point(field_map:Input.testInputField) - return _internal_testinputfield(); -} -inline ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >* -Input::_internal_mutable_testinputfield() { - return _impl_.testinputfield_.MutableMap(); -} -inline ::PROTOBUF_NAMESPACE_ID::Map< ::int32_t, std::string >* -Input::mutable_testinputfield() { - // @@protoc_insertion_point(field_mutable_map:Input.testInputField) - return _internal_mutable_testinputfield(); -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/map/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/map/output/csharp/Main.cs deleted file mode 100644 index d99e8a43aeb..00000000000 --- a/packages/protobuf/test/protoc-out/map/output/csharp/Main.cs +++ /dev/null @@ -1,221 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -/// Holder for reflection information generated from main.proto -public static partial class MainReflection { - - #region Descriptor - /// File descriptor for main.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static MainReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgptYWluLnByb3RvGhtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8icgoF", - "SW5wdXQSMgoOdGVzdElucHV0RmllbGQYASADKAsyGi5JbnB1dC5UZXN0SW5w", - "dXRGaWVsZEVudHJ5GjUKE1Rlc3RJbnB1dEZpZWxkRW50cnkSCwoDa2V5GAEg", - "ASgPEg0KBXZhbHVlGAIgASgJOgI4ATIwCgdTZXJ2aWNlEiUKA0ZvbxIGLklu", - "cHV0GhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5YgZwcm90bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.EmptyReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "TestInputField" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, }) - })); - } - #endregion - -} -#region Messages -public sealed partial class Input : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input(Input other) : this() { - testInputField_ = other.testInputField_.Clone(); - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input Clone() { - return new Input(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private static readonly pbc::MapField.Codec _map_testInputField_codec - = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed32(13, 0), pb::FieldCodec.ForString(18, ""), 10); - private readonly pbc::MapField testInputField_ = new pbc::MapField(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public pbc::MapField TestInputField { - get { return testInputField_; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Input); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Input other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!TestInputField.Equals(other.TestInputField)) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - hash ^= TestInputField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - testInputField_.WriteTo(output, _map_testInputField_codec); - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - testInputField_.WriteTo(ref output, _map_testInputField_codec); - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - size += testInputField_.CalculateSize(_map_testInputField_codec); - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Input other) { - if (other == null) { - return; - } - testInputField_.MergeFrom(other.testInputField_); - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - testInputField_.AddEntriesFrom(input, _map_testInputField_codec); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - testInputField_.AddEntriesFrom(ref input, _map_testInputField_codec); - break; - } - } - } - } - #endif - -} - -#endregion - - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.h deleted file mode 100644 index b5127ac4d6f..00000000000 --- a/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.h +++ /dev/null @@ -1,70 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - MainRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface MainRoot : GPBRootObject -@end - -#pragma mark - Input - -typedef GPB_ENUM(Input_FieldNumber) { - Input_FieldNumber_TestInputField = 1, -}; - -GPB_FINAL @interface Input : GPBMessage - -@property(nonatomic, readwrite, strong, null_resettable) GPBInt32ObjectDictionary *testInputField; -/** The number of items in @c testInputField without causing the container to be created. */ -@property(nonatomic, readonly) NSUInteger testInputField_Count; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.m deleted file mode 100644 index fc5cfcaec43..00000000000 --- a/packages/protobuf/test/protoc-out/map/output/objc/Main.pbobjc.m +++ /dev/null @@ -1,107 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "Main.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension" - -#pragma mark - Objective C Class declarations -// Forward declarations of Objective C classes that we can use as -// static values in struct initializers. -// We don't use [Foo class] because it is not a static value. -GPBObjCClassDeclaration(Input); - -#pragma mark - MainRoot - -@implementation MainRoot - -// No extensions in the file and none of the imports (direct or indirect) -// defined extensions, so no need to generate +extensionRegistry. - -@end - -#pragma mark - MainRoot_FileDescriptor - -static GPBFileDescriptor *MainRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - Input - -@implementation Input - -@dynamic testInputField, testInputField_Count; - -typedef struct Input__storage_ { - uint32_t _has_storage_[1]; - GPBInt32ObjectDictionary *testInputField; -} Input__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputField", - .dataTypeSpecific.clazz = Nil, - .number = Input_FieldNumber_TestInputField, - .hasIndex = GPBNoHasBit, - .offset = (uint32_t)offsetof(Input__storage_, testInputField), - .flags = (GPBFieldFlags)(GPBFieldMapKeySFixed32 | GPBFieldTextFormatNameCustom), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Input class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Input__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\016\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/map/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/map/output/php/GPBMetadata/Main.php deleted file mode 100644 index 6f14fc1d63c..00000000000 --- a/packages/protobuf/test/protoc-out/map/output/php/GPBMetadata/Main.php +++ /dev/null @@ -1,35 +0,0 @@ -internalAddGeneratedFile( - ' -� - -main.proto"r -Input2 -testInputField ( 2.Input.TestInputFieldEntry5 -TestInputFieldEntry -key ( -value ( :820 -Service% -Foo.Input.google.protobuf.Emptybproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/packages/protobuf/test/protoc-out/map/output/php/Input.php b/packages/protobuf/test/protoc-out/map/output/php/Input.php deleted file mode 100644 index 98621710ed2..00000000000 --- a/packages/protobuf/test/protoc-out/map/output/php/Input.php +++ /dev/null @@ -1,56 +0,0 @@ -Input - */ -class Input extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field map testInputField = 1; - */ - private $testInputField; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array|\Google\Protobuf\Internal\MapField $testInputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field map testInputField = 1; - * @return \Google\Protobuf\Internal\MapField - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field map testInputField = 1; - * @param array|\Google\Protobuf\Internal\MapField $var - * @return $this - */ - public function setTestInputField($var) - { - $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::SFIXED32, \Google\Protobuf\Internal\GPBType::STRING); - $this->testInputField = $arr; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/map/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/map/output/pyi/main_pb2.pyi deleted file mode 100644 index ffae4c6f210..00000000000 --- a/packages/protobuf/test/protoc-out/map/output/pyi/main_pb2.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from google.protobuf import empty_pb2 as _empty_pb2 -from google.protobuf.internal import containers as _containers -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional - -DESCRIPTOR: _descriptor.FileDescriptor - -class Input(_message.Message): - __slots__ = ["testInputField"] - class TestInputFieldEntry(_message.Message): - __slots__ = ["key", "value"] - KEY_FIELD_NUMBER: _ClassVar[int] - VALUE_FIELD_NUMBER: _ClassVar[int] - key: int - value: str - def __init__(self, key: _Optional[int] = ..., value: _Optional[str] = ...) -> None: ... - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testInputField: _containers.ScalarMap[int, str] - def __init__(self, testInputField: _Optional[_Mapping[int, str]] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/map/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/map/output/python/main_pb2.py deleted file mode 100644 index bcb7f55160b..00000000000 --- a/packages/protobuf/test/protoc-out/map/output/python/main_pb2.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\x1a\x1bgoogle/protobuf/empty.proto\"r\n\x05Input\x12\x32\n\x0etestInputField\x18\x01 \x03(\x0b\x32\x1a.Input.TestInputFieldEntry\x1a\x35\n\x13TestInputFieldEntry\x12\x0b\n\x03key\x18\x01 \x01(\x0f\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x32\x30\n\x07Service\x12%\n\x03\x46oo\x12\x06.Input\x1a\x16.google.protobuf.Emptyb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _INPUT_TESTINPUTFIELDENTRY._options = None - _INPUT_TESTINPUTFIELDENTRY._serialized_options = b'8\001' - _globals['_INPUT']._serialized_start=43 - _globals['_INPUT']._serialized_end=157 - _globals['_INPUT_TESTINPUTFIELDENTRY']._serialized_start=104 - _globals['_INPUT_TESTINPUTFIELDENTRY']._serialized_end=157 - _globals['_SERVICE']._serialized_start=159 - _globals['_SERVICE']._serialized_end=207 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/map/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/map/output/ruby/main_pb.rb deleted file mode 100644 index 9b75410c1b6..00000000000 --- a/packages/protobuf/test/protoc-out/map/output/ruby/main_pb.rb +++ /dev/null @@ -1,16 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto - -require 'google/protobuf' - -require 'google/protobuf/empty_pb' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("main.proto", :syntax => :proto3) do - add_message "Input" do - map :testInputField, :sfixed32, :string, 1 - end - end -end - -Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.cc deleted file mode 100644 index 9943d43c5a3..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.cc +++ /dev/null @@ -1,375 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#include "main.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -PROTOBUF_CONSTEXPR Input::Input( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_._cached_size_)*/{}} {} -struct InputDefaultTypeInternal { - PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputDefaultTypeInternal() {} - union { - Input _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; -PROTOBUF_CONSTEXPR FooResponse::FooResponse( - ::_pbi::ConstantInitialized) {} -struct FooResponseDefaultTypeInternal { - PROTOBUF_CONSTEXPR FooResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~FooResponseDefaultTypeInternal() {} - union { - FooResponse _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FooResponseDefaultTypeInternal _FooResponse_default_instance_; -static ::_pb::Metadata file_level_metadata_main_2eproto[2]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_main_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_main_2eproto = nullptr; -const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::Input, _impl_.testinputfield_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::FooResponse, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::Input)}, - { 9, -1, -1, sizeof(::FooResponse)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::_Input_default_instance_._instance, - &::_FooResponse_default_instance_._instance, -}; -const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\nmain.proto\";\n\005Input\022\026\n\016testInputField\030" - "\001 \001(\tJ\004\010\002\020\003J\004\010\017\020\020J\004\010\t\020\014R\003fooR\003bar\"\r\n\013Foo" - "Response2&\n\007Service\022\033\n\003Foo\022\006.Input\032\014.Foo" - "Responseb\006proto3" -}; -static ::absl::once_flag descriptor_table_main_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { - false, - false, - 136, - descriptor_table_protodef_main_2eproto, - "main.proto", - &descriptor_table_main_2eproto_once, - nullptr, - 0, - 2, - schemas, - file_default_instances, - TableStruct_main_2eproto::offsets, - file_level_metadata_main_2eproto, - file_level_enum_descriptors_main_2eproto, - file_level_service_descriptors_main_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { - return &descriptor_table_main_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); -// =================================================================== - -class Input::_Internal { - public: -}; - -Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:Input) -} -Input::Input(const Input& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Input* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_testinputfield().empty()) { - _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), - _this->GetArenaForAllocation()); - } - // @@protoc_insertion_point(copy_constructor:Input) -} - -inline void Input::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Input::~Input() { - // @@protoc_insertion_point(destructor:Input) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Input::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testinputfield_.Destroy(); -} - -void Input::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Input::Clear() { -// @@protoc_insertion_point(message_clear_start:Input) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_.ClearToEmpty(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // string testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - auto str = _internal_mutable_testinputfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "Input.testInputField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Input::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:Input) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "Input.testInputField"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_testinputfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:Input) - return target; -} - -::size_t Input::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:Input) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_testinputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Input::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } - - -void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:Input) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_testinputfield().empty()) { - _this->_internal_set_testinputfield(from._internal_testinputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Input::CopyFrom(const Input& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:Input) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Input::IsInitialized() const { - return true; -} - -void Input::InternalSwap(Input* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.testinputfield_, lhs_arena, - &other->_impl_.testinputfield_, rhs_arena - ); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[0]); -} -// =================================================================== - -class FooResponse::_Internal { - public: -}; - -FooResponse::FooResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena) { - // @@protoc_insertion_point(arena_constructor:FooResponse) -} -FooResponse::FooResponse(const FooResponse& from) - : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase() { - FooResponse* const _this = this; (void)_this; - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - // @@protoc_insertion_point(copy_constructor:FooResponse) -} - - - - - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FooResponse::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl, - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl, -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FooResponse::GetClassData() const { return &_class_data_; } - - - - - - - -::PROTOBUF_NAMESPACE_ID::Metadata FooResponse::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[1]); -} -// @@protoc_insertion_point(namespace_scope) -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::Input* -Arena::CreateMaybeMessage< ::Input >(Arena* arena) { - return Arena::CreateMessageInternal< ::Input >(arena); -} -template<> PROTOBUF_NOINLINE ::FooResponse* -Arena::CreateMaybeMessage< ::FooResponse >(Arena* arena) { - return Arena::CreateMessageInternal< ::FooResponse >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.h deleted file mode 100644 index 8e8ce2f365d..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/cpp/main.pb.h +++ /dev/null @@ -1,415 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_bases.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/unknown_field_set.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_main_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_main_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_main_2eproto; -class FooResponse; -struct FooResponseDefaultTypeInternal; -extern FooResponseDefaultTypeInternal _FooResponse_default_instance_; -class Input; -struct InputDefaultTypeInternal; -extern InputDefaultTypeInternal _Input_default_instance_; -PROTOBUF_NAMESPACE_OPEN -template <> -::FooResponse* Arena::CreateMaybeMessage<::FooResponse>(Arena*); -template <> -::Input* Arena::CreateMaybeMessage<::Input>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - - -// =================================================================== - - -// ------------------------------------------------------------------- - -class Input final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { - public: - inline Input() : Input(nullptr) {} - ~Input() override; - explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Input(const Input& from); - Input(Input&& from) noexcept - : Input() { - *this = ::std::move(from); - } - - inline Input& operator=(const Input& from) { - CopyFrom(from); - return *this; - } - inline Input& operator=(Input&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Input& default_instance() { - return *internal_default_instance(); - } - static inline const Input* internal_default_instance() { - return reinterpret_cast( - &_Input_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Input& a, Input& b) { - a.Swap(&b); - } - inline void Swap(Input* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Input* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Input& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Input& from) { - Input::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Input* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "Input"; - } - protected: - explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - }; - // string testInputField = 1; - void clear_testinputfield() ; - const std::string& testinputfield() const; - template - void set_testinputfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_testinputfield(); - PROTOBUF_NODISCARD std::string* release_testinputfield(); - void set_allocated_testinputfield(std::string* testinputfield); - private: - const std::string& _internal_testinputfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); - std::string* _internal_mutable_testinputfield(); - public: - // @@protoc_insertion_point(class_scope:Input) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -};// ------------------------------------------------------------------- - -class FooResponse final : - public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:FooResponse) */ { - public: - inline FooResponse() : FooResponse(nullptr) {} - explicit PROTOBUF_CONSTEXPR FooResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - FooResponse(const FooResponse& from); - FooResponse(FooResponse&& from) noexcept - : FooResponse() { - *this = ::std::move(from); - } - - inline FooResponse& operator=(const FooResponse& from) { - CopyFrom(from); - return *this; - } - inline FooResponse& operator=(FooResponse&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const FooResponse& default_instance() { - return *internal_default_instance(); - } - static inline const FooResponse* internal_default_instance() { - return reinterpret_cast( - &_FooResponse_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(FooResponse& a, FooResponse& b) { - a.Swap(&b); - } - inline void Swap(FooResponse* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(FooResponse* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - FooResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyFrom; - inline void CopyFrom(const FooResponse& from) { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl(*this, from); - } - using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeFrom; - void MergeFrom(const FooResponse& from) { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl(*this, from); - } - public: - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "FooResponse"; - } - protected: - explicit FooResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // @@protoc_insertion_point(class_scope:FooResponse) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - }; - friend struct ::TableStruct_main_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// Input - -// string testInputField = 1; -inline void Input::clear_testinputfield() { - _impl_.testinputfield_.ClearToEmpty(); -} -inline const std::string& Input::testinputfield() const { - // @@protoc_insertion_point(field_get:Input.testInputField) - return _internal_testinputfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { - - _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:Input.testInputField) -} -inline std::string* Input::mutable_testinputfield() { - std::string* _s = _internal_mutable_testinputfield(); - // @@protoc_insertion_point(field_mutable:Input.testInputField) - return _s; -} -inline const std::string& Input::_internal_testinputfield() const { - return _impl_.testinputfield_.Get(); -} -inline void Input::_internal_set_testinputfield(const std::string& value) { - - _impl_.testinputfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Input::_internal_mutable_testinputfield() { - - return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Input::release_testinputfield() { - // @@protoc_insertion_point(field_release:Input.testInputField) - return _impl_.testinputfield_.Release(); -} -inline void Input::set_allocated_testinputfield(std::string* testinputfield) { - _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.testinputfield_.IsDefault()) { - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:Input.testInputField) -} - -// ------------------------------------------------------------------- - -// FooResponse - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/reserved fields/output/csharp/Main.cs deleted file mode 100644 index 3052ff51989..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/csharp/Main.cs +++ /dev/null @@ -1,384 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -/// Holder for reflection information generated from main.proto -public static partial class MainReflection { - - #region Descriptor - /// File descriptor for main.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static MainReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgptYWluLnByb3RvIjsKBUlucHV0EhYKDnRlc3RJbnB1dEZpZWxkGAEgASgJ", - "SgQIAhADSgQIDxAQSgQICRAMUgNmb29SA2JhciINCgtGb29SZXNwb25zZTIm", - "CgdTZXJ2aWNlEhsKA0ZvbxIGLklucHV0GgwuRm9vUmVzcG9uc2ViBnByb3Rv", - "Mw==")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "TestInputField" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::FooResponse), global::FooResponse.Parser, null, null, null, null, null) - })); - } - #endregion - -} -#region Messages -public sealed partial class Input : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input(Input other) : this() { - testInputField_ = other.testInputField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input Clone() { - return new Input(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private string testInputField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string TestInputField { - get { return testInputField_; } - set { - testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Input); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Input other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestInputField != other.TestInputField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestInputField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Input other) { - if (other == null) { - return; - } - if (other.TestInputField.Length != 0) { - TestInputField = other.TestInputField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - } - #endif - -} - -public sealed partial class FooResponse : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FooResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FooResponse(FooResponse other) : this() { - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FooResponse Clone() { - return new FooResponse(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as FooResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(FooResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(FooResponse other) { - if (other == null) { - return; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - } - } - } - #endif - -} - -#endregion - - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.h deleted file mode 100644 index bf0262c0951..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.h +++ /dev/null @@ -1,74 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - MainRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface MainRoot : GPBRootObject -@end - -#pragma mark - Input - -typedef GPB_ENUM(Input_FieldNumber) { - Input_FieldNumber_TestInputField = 1, -}; - -GPB_FINAL @interface Input : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; - -@end - -#pragma mark - FooResponse - -GPB_FINAL @interface FooResponse : GPBMessage - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.m deleted file mode 100644 index 9c3a38dc1df..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/objc/Main.pbobjc.m +++ /dev/null @@ -1,131 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "Main.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -#pragma mark - MainRoot - -@implementation MainRoot - -// No extensions in the file and no imports, so no need to generate -// +extensionRegistry. - -@end - -#pragma mark - MainRoot_FileDescriptor - -static GPBFileDescriptor *MainRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - Input - -@implementation Input - -@dynamic testInputField; - -typedef struct Input__storage_ { - uint32_t _has_storage_[1]; - NSString *testInputField; -} Input__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputField", - .dataTypeSpecific.clazz = Nil, - .number = Input_FieldNumber_TestInputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Input__storage_, testInputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Input class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Input__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\016\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - FooResponse - -@implementation FooResponse - - -typedef struct FooResponse__storage_ { - uint32_t _has_storage_[1]; -} FooResponse__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[FooResponse class] - file:MainRoot_FileDescriptor() - fields:NULL - fieldCount:0 - storageSize:sizeof(FooResponse__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/php/FooResponse.php b/packages/protobuf/test/protoc-out/reserved fields/output/php/FooResponse.php deleted file mode 100644 index c5a0cc35d65..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/php/FooResponse.php +++ /dev/null @@ -1,29 +0,0 @@ -FooResponse - */ -class FooResponse extends \Google\Protobuf\Internal\Message -{ - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - -} - diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/reserved fields/output/php/GPBMetadata/Main.php deleted file mode 100644 index 2f7eb0be98d..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/php/GPBMetadata/Main.php +++ /dev/null @@ -1,32 +0,0 @@ -internalAddGeneratedFile( - ' -� - -main.proto"; -Input -testInputField ( JJJ  RfooRbar" - FooResponse2& -Service -Foo.Input .FooResponsebproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/php/Input.php b/packages/protobuf/test/protoc-out/reserved fields/output/php/Input.php deleted file mode 100644 index b77d7713c23..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/php/Input.php +++ /dev/null @@ -1,56 +0,0 @@ -Input - */ -class Input extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field string testInputField = 1; - */ - protected $testInputField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $testInputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field string testInputField = 1; - * @return string - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field string testInputField = 1; - * @param string $var - * @return $this - */ - public function setTestInputField($var) - { - GPBUtil::checkString($var, True); - $this->testInputField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/reserved fields/output/pyi/main_pb2.pyi deleted file mode 100644 index 1fe476adda0..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/pyi/main_pb2.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Optional as _Optional - -DESCRIPTOR: _descriptor.FileDescriptor - -class Input(_message.Message): - __slots__ = ["testInputField"] - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testInputField: str - def __init__(self, testInputField: _Optional[str] = ...) -> None: ... - -class FooResponse(_message.Message): - __slots__ = [] - def __init__(self) -> None: ... diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/reserved fields/output/python/main_pb2.py deleted file mode 100644 index e7bcdfafc2e..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/python/main_pb2.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\";\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\tJ\x04\x08\x02\x10\x03J\x04\x08\x0f\x10\x10J\x04\x08\t\x10\x0cR\x03\x66ooR\x03\x62\x61r\"\r\n\x0b\x46ooResponse2&\n\x07Service\x12\x1b\n\x03\x46oo\x12\x06.Input\x1a\x0c.FooResponseb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _globals['_INPUT']._serialized_start=14 - _globals['_INPUT']._serialized_end=73 - _globals['_FOORESPONSE']._serialized_start=75 - _globals['_FOORESPONSE']._serialized_end=88 - _globals['_SERVICE']._serialized_start=90 - _globals['_SERVICE']._serialized_end=128 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/reserved fields/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/reserved fields/output/ruby/main_pb.rb deleted file mode 100644 index b7c1f8134d5..00000000000 --- a/packages/protobuf/test/protoc-out/reserved fields/output/ruby/main_pb.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("main.proto", :syntax => :proto3) do - add_message "Input" do - optional :testInputField, :string, 1 - end - add_message "FooResponse" do - end - end -end - -Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass -FooResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("FooResponse").msgclass diff --git a/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.cc b/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.cc deleted file mode 100644 index 4c99349080a..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.cc +++ /dev/null @@ -1,589 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: com/azure/Test.proto - -#include "com/azure/Test.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -namespace com { -namespace azure { -namespace Test { -PROTOBUF_CONSTEXPR Input::Input( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_._cached_size_)*/{}} {} -struct InputDefaultTypeInternal { - PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputDefaultTypeInternal() {} - union { - Input _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; -PROTOBUF_CONSTEXPR Output::Output( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /* ._impl_.testoutputfield_ = */ 0 - - , /*decltype(_impl_._cached_size_)*/{}} {} -struct OutputDefaultTypeInternal { - PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~OutputDefaultTypeInternal() {} - union { - Output _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; -} // namespace Test -} // namespace azure -} // namespace com -static ::_pb::Metadata file_level_metadata_com_2fazure_2fTest_2eproto[2]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_com_2fazure_2fTest_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_com_2fazure_2fTest_2eproto = nullptr; -const ::uint32_t TableStruct_com_2fazure_2fTest_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::com::azure::Test::Input, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::com::azure::Test::Input, _impl_.testinputfield_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::com::azure::Test::Output, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::com::azure::Test::Output, _impl_.testoutputfield_), - PROTOBUF_FIELD_OFFSET(::com::azure::Test::Output, _impl_.secondfield_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::com::azure::Test::Input)}, - { 9, -1, -1, sizeof(::com::azure::Test::Output)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::com::azure::Test::_Input_default_instance_._instance, - &::com::azure::Test::_Output_default_instance_._instance, -}; -const char descriptor_table_protodef_com_2fazure_2fTest_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\024com/azure/Test.proto\022\016com.azure.Test\"\037" - "\n\005Input\022\026\n\016testInputField\030\001 \001(\t\"6\n\006Outpu" - "t\022\027\n\017testOutputField\030\001 \001(\005\022\023\n\013secondFiel" - "d\030\002 \001(\t2\?\n\007Service\0224\n\003Foo\022\025.com.azure.Te" - "st.Input\032\026.com.azure.Test.Outputb\006proto3" -}; -static ::absl::once_flag descriptor_table_com_2fazure_2fTest_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_com_2fazure_2fTest_2eproto = { - false, - false, - 200, - descriptor_table_protodef_com_2fazure_2fTest_2eproto, - "com/azure/Test.proto", - &descriptor_table_com_2fazure_2fTest_2eproto_once, - nullptr, - 0, - 2, - schemas, - file_default_instances, - TableStruct_com_2fazure_2fTest_2eproto::offsets, - file_level_metadata_com_2fazure_2fTest_2eproto, - file_level_enum_descriptors_com_2fazure_2fTest_2eproto, - file_level_service_descriptors_com_2fazure_2fTest_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_com_2fazure_2fTest_2eproto_getter() { - return &descriptor_table_com_2fazure_2fTest_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_com_2fazure_2fTest_2eproto(&descriptor_table_com_2fazure_2fTest_2eproto); -namespace com { -namespace azure { -namespace Test { -// =================================================================== - -class Input::_Internal { - public: -}; - -Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:com.azure.Test.Input) -} -Input::Input(const Input& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Input* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_testinputfield().empty()) { - _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), - _this->GetArenaForAllocation()); - } - // @@protoc_insertion_point(copy_constructor:com.azure.Test.Input) -} - -inline void Input::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Input::~Input() { - // @@protoc_insertion_point(destructor:com.azure.Test.Input) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Input::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testinputfield_.Destroy(); -} - -void Input::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Input::Clear() { -// @@protoc_insertion_point(message_clear_start:com.azure.Test.Input) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_.ClearToEmpty(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // string testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - auto str = _internal_mutable_testinputfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "com.azure.Test.Input.testInputField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Input::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:com.azure.Test.Input) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "com.azure.Test.Input.testInputField"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_testinputfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:com.azure.Test.Input) - return target; -} - -::size_t Input::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:com.azure.Test.Input) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_testinputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Input::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } - - -void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.Test.Input) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_testinputfield().empty()) { - _this->_internal_set_testinputfield(from._internal_testinputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Input::CopyFrom(const Input& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.Test.Input) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Input::IsInitialized() const { - return true; -} - -void Input::InternalSwap(Input* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.testinputfield_, lhs_arena, - &other->_impl_.testinputfield_, rhs_arena - ); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_com_2fazure_2fTest_2eproto_getter, &descriptor_table_com_2fazure_2fTest_2eproto_once, - file_level_metadata_com_2fazure_2fTest_2eproto[0]); -} -// =================================================================== - -class Output::_Internal { - public: -}; - -Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:com.azure.Test.Output) -} -Output::Output(const Output& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Output* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) {} - - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_secondfield().empty()) { - _this->_impl_.secondfield_.Set(from._internal_secondfield(), - _this->GetArenaForAllocation()); - } - _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; - // @@protoc_insertion_point(copy_constructor:com.azure.Test.Output) -} - -inline void Output::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) { 0 } - - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Output::~Output() { - // @@protoc_insertion_point(destructor:com.azure.Test.Output) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Output::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.secondfield_.Destroy(); -} - -void Output::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Output::Clear() { -// @@protoc_insertion_point(message_clear_start:com.azure.Test.Output) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.secondfield_.ClearToEmpty(); - _impl_.testoutputfield_ = 0; - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // int32 testOutputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { - _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - // string secondField = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { - auto str = _internal_mutable_secondfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "com.azure.Test.Output.secondField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Output::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:com.azure.Test.Output) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray( - 1, this->_internal_testoutputfield(), target); - } - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "com.azure.Test.Output.secondField"); - target = stream->WriteStringMaybeAliased( - 2, this->_internal_secondfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:com.azure.Test.Output) - return target; -} - -::size_t Output::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:com.azure.Test.Output) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_secondfield()); - } - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( - this->_internal_testoutputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Output::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } - - -void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:com.azure.Test.Output) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_secondfield().empty()) { - _this->_internal_set_secondfield(from._internal_secondfield()); - } - if (from._internal_testoutputfield() != 0) { - _this->_internal_set_testoutputfield(from._internal_testoutputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Output::CopyFrom(const Output& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:com.azure.Test.Output) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Output::IsInitialized() const { - return true; -} - -void Output::InternalSwap(Output* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.secondfield_, lhs_arena, - &other->_impl_.secondfield_, rhs_arena - ); - - swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_com_2fazure_2fTest_2eproto_getter, &descriptor_table_com_2fazure_2fTest_2eproto_once, - file_level_metadata_com_2fazure_2fTest_2eproto[1]); -} -// @@protoc_insertion_point(namespace_scope) -} // namespace Test -} // namespace azure -} // namespace com -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::com::azure::Test::Input* -Arena::CreateMaybeMessage< ::com::azure::Test::Input >(Arena* arena) { - return Arena::CreateMessageInternal< ::com::azure::Test::Input >(arena); -} -template<> PROTOBUF_NOINLINE ::com::azure::Test::Output* -Arena::CreateMaybeMessage< ::com::azure::Test::Output >(Arena* arena) { - return Arena::CreateMessageInternal< ::com::azure::Test::Output >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.h b/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.h deleted file mode 100644 index e70861a2248..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/cpp/com/azure/Test.pb.h +++ /dev/null @@ -1,538 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: com/azure/Test.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2fTest_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2fTest_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/unknown_field_set.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_com_2fazure_2fTest_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_com_2fazure_2fTest_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_com_2fazure_2fTest_2eproto; -namespace com { -namespace azure { -namespace Test { -class Input; -struct InputDefaultTypeInternal; -extern InputDefaultTypeInternal _Input_default_instance_; -class Output; -struct OutputDefaultTypeInternal; -extern OutputDefaultTypeInternal _Output_default_instance_; -} // namespace Test -} // namespace azure -} // namespace com -PROTOBUF_NAMESPACE_OPEN -template <> -::com::azure::Test::Input* Arena::CreateMaybeMessage<::com::azure::Test::Input>(Arena*); -template <> -::com::azure::Test::Output* Arena::CreateMaybeMessage<::com::azure::Test::Output>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - -namespace com { -namespace azure { -namespace Test { - -// =================================================================== - - -// ------------------------------------------------------------------- - -class Input final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.Test.Input) */ { - public: - inline Input() : Input(nullptr) {} - ~Input() override; - explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Input(const Input& from); - Input(Input&& from) noexcept - : Input() { - *this = ::std::move(from); - } - - inline Input& operator=(const Input& from) { - CopyFrom(from); - return *this; - } - inline Input& operator=(Input&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Input& default_instance() { - return *internal_default_instance(); - } - static inline const Input* internal_default_instance() { - return reinterpret_cast( - &_Input_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Input& a, Input& b) { - a.Swap(&b); - } - inline void Swap(Input* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Input* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Input& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Input& from) { - Input::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Input* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "com.azure.Test.Input"; - } - protected: - explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - }; - // string testInputField = 1; - void clear_testinputfield() ; - const std::string& testinputfield() const; - template - void set_testinputfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_testinputfield(); - PROTOBUF_NODISCARD std::string* release_testinputfield(); - void set_allocated_testinputfield(std::string* testinputfield); - private: - const std::string& _internal_testinputfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); - std::string* _internal_mutable_testinputfield(); - public: - // @@protoc_insertion_point(class_scope:com.azure.Test.Input) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_com_2fazure_2fTest_2eproto; -};// ------------------------------------------------------------------- - -class Output final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:com.azure.Test.Output) */ { - public: - inline Output() : Output(nullptr) {} - ~Output() override; - explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Output(const Output& from); - Output(Output&& from) noexcept - : Output() { - *this = ::std::move(from); - } - - inline Output& operator=(const Output& from) { - CopyFrom(from); - return *this; - } - inline Output& operator=(Output&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Output& default_instance() { - return *internal_default_instance(); - } - static inline const Output* internal_default_instance() { - return reinterpret_cast( - &_Output_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(Output& a, Output& b) { - a.Swap(&b); - } - inline void Swap(Output* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Output* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Output& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Output& from) { - Output::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Output* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "com.azure.Test.Output"; - } - protected: - explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kSecondFieldFieldNumber = 2, - kTestOutputFieldFieldNumber = 1, - }; - // string secondField = 2; - void clear_secondfield() ; - const std::string& secondfield() const; - template - void set_secondfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_secondfield(); - PROTOBUF_NODISCARD std::string* release_secondfield(); - void set_allocated_secondfield(std::string* secondfield); - private: - const std::string& _internal_secondfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); - std::string* _internal_mutable_secondfield(); - public: - // int32 testOutputField = 1; - void clear_testoutputfield() ; - ::int32_t testoutputfield() const; - void set_testoutputfield(::int32_t value); - - private: - ::int32_t _internal_testoutputfield() const; - void _internal_set_testoutputfield(::int32_t value); - - public: - // @@protoc_insertion_point(class_scope:com.azure.Test.Output) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; - ::int32_t testoutputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_com_2fazure_2fTest_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// Input - -// string testInputField = 1; -inline void Input::clear_testinputfield() { - _impl_.testinputfield_.ClearToEmpty(); -} -inline const std::string& Input::testinputfield() const { - // @@protoc_insertion_point(field_get:com.azure.Test.Input.testInputField) - return _internal_testinputfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { - - _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:com.azure.Test.Input.testInputField) -} -inline std::string* Input::mutable_testinputfield() { - std::string* _s = _internal_mutable_testinputfield(); - // @@protoc_insertion_point(field_mutable:com.azure.Test.Input.testInputField) - return _s; -} -inline const std::string& Input::_internal_testinputfield() const { - return _impl_.testinputfield_.Get(); -} -inline void Input::_internal_set_testinputfield(const std::string& value) { - - _impl_.testinputfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Input::_internal_mutable_testinputfield() { - - return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Input::release_testinputfield() { - // @@protoc_insertion_point(field_release:com.azure.Test.Input.testInputField) - return _impl_.testinputfield_.Release(); -} -inline void Input::set_allocated_testinputfield(std::string* testinputfield) { - _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.testinputfield_.IsDefault()) { - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:com.azure.Test.Input.testInputField) -} - -// ------------------------------------------------------------------- - -// Output - -// int32 testOutputField = 1; -inline void Output::clear_testoutputfield() { - _impl_.testoutputfield_ = 0; -} -inline ::int32_t Output::testoutputfield() const { - // @@protoc_insertion_point(field_get:com.azure.Test.Output.testOutputField) - return _internal_testoutputfield(); -} -inline void Output::set_testoutputfield(::int32_t value) { - ; - _internal_set_testoutputfield(value); - // @@protoc_insertion_point(field_set:com.azure.Test.Output.testOutputField) -} -inline ::int32_t Output::_internal_testoutputfield() const { - return _impl_.testoutputfield_; -} -inline void Output::_internal_set_testoutputfield(::int32_t value) { - ; - _impl_.testoutputfield_ = value; -} - -// string secondField = 2; -inline void Output::clear_secondfield() { - _impl_.secondfield_.ClearToEmpty(); -} -inline const std::string& Output::secondfield() const { - // @@protoc_insertion_point(field_get:com.azure.Test.Output.secondField) - return _internal_secondfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { - - _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:com.azure.Test.Output.secondField) -} -inline std::string* Output::mutable_secondfield() { - std::string* _s = _internal_mutable_secondfield(); - // @@protoc_insertion_point(field_mutable:com.azure.Test.Output.secondField) - return _s; -} -inline const std::string& Output::_internal_secondfield() const { - return _impl_.secondfield_.Get(); -} -inline void Output::_internal_set_secondfield(const std::string& value) { - - _impl_.secondfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Output::_internal_mutable_secondfield() { - - return _impl_.secondfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Output::release_secondfield() { - // @@protoc_insertion_point(field_release:com.azure.Test.Output.secondField) - return _impl_.secondfield_.Release(); -} -inline void Output::set_allocated_secondfield(std::string* secondfield) { - _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.secondfield_.IsDefault()) { - _impl_.secondfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:com.azure.Test.Output.secondField) -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) -} // namespace Test -} // namespace azure -} // namespace com - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_com_2fazure_2fTest_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/simple/output/csharp/Test.cs b/packages/protobuf/test/protoc-out/simple/output/csharp/Test.cs deleted file mode 100644 index fdccdc42942..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/csharp/Test.cs +++ /dev/null @@ -1,462 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: com/azure/Test.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Com.Azure.Test { - - /// Holder for reflection information generated from com/azure/Test.proto - public static partial class TestReflection { - - #region Descriptor - /// File descriptor for com/azure/Test.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static TestReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChRjb20vYXp1cmUvVGVzdC5wcm90bxIOY29tLmF6dXJlLlRlc3QiHwoFSW5w", - "dXQSFgoOdGVzdElucHV0RmllbGQYASABKAkiNgoGT3V0cHV0EhcKD3Rlc3RP", - "dXRwdXRGaWVsZBgBIAEoBRITCgtzZWNvbmRGaWVsZBgCIAEoCTI/CgdTZXJ2", - "aWNlEjQKA0ZvbxIVLmNvbS5henVyZS5UZXN0LklucHV0GhYuY29tLmF6dXJl", - "LlRlc3QuT3V0cHV0YgZwcm90bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.Input), global::Com.Azure.Test.Input.Parser, new[]{ "TestInputField" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Com.Azure.Test.Output), global::Com.Azure.Test.Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class Input : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input(Input other) : this() { - testInputField_ = other.testInputField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input Clone() { - return new Input(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private string testInputField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string TestInputField { - get { return testInputField_; } - set { - testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Input); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Input other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestInputField != other.TestInputField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestInputField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Input other) { - if (other == null) { - return; - } - if (other.TestInputField.Length != 0) { - TestInputField = other.TestInputField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - } - #endif - - } - - public sealed partial class Output : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Com.Azure.Test.TestReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output(Output other) : this() { - testOutputField_ = other.testOutputField_; - secondField_ = other.secondField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output Clone() { - return new Output(this); - } - - /// Field number for the "testOutputField" field. - public const int TestOutputFieldFieldNumber = 1; - private int testOutputField_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int TestOutputField { - get { return testOutputField_; } - set { - testOutputField_ = value; - } - } - - /// Field number for the "secondField" field. - public const int SecondFieldFieldNumber = 2; - private string secondField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string SecondField { - get { return secondField_; } - set { - secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Output); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Output other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestOutputField != other.TestOutputField) return false; - if (SecondField != other.SecondField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); - if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestOutputField != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); - } - if (SecondField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Output other) { - if (other == null) { - return; - } - if (other.TestOutputField != 0) { - TestOutputField = other.TestOutputField; - } - if (other.SecondField.Length != 0) { - SecondField = other.SecondField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - } - #endif - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.h b/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.h deleted file mode 100644 index b3721e1bf7c..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.h +++ /dev/null @@ -1,83 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: com/azure/Test.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - TestRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface TestRoot : GPBRootObject -@end - -#pragma mark - Input - -typedef GPB_ENUM(Input_FieldNumber) { - Input_FieldNumber_TestInputField = 1, -}; - -GPB_FINAL @interface Input : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; - -@end - -#pragma mark - Output - -typedef GPB_ENUM(Output_FieldNumber) { - Output_FieldNumber_TestOutputField = 1, - Output_FieldNumber_SecondField = 2, -}; - -GPB_FINAL @interface Output : GPBMessage - -@property(nonatomic, readwrite) int32_t testOutputField; - -@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.m b/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.m deleted file mode 100644 index c006ab57bbc..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/objc/com/azure/Test.pbobjc.m +++ /dev/null @@ -1,160 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: com/azure/Test.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "com/azure/Test.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -#pragma mark - TestRoot - -@implementation TestRoot - -// No extensions in the file and no imports, so no need to generate -// +extensionRegistry. - -@end - -#pragma mark - TestRoot_FileDescriptor - -static GPBFileDescriptor *TestRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"com.azure.Test" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - Input - -@implementation Input - -@dynamic testInputField; - -typedef struct Input__storage_ { - uint32_t _has_storage_[1]; - NSString *testInputField; -} Input__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputField", - .dataTypeSpecific.clazz = Nil, - .number = Input_FieldNumber_TestInputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Input__storage_, testInputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Input class] - file:TestRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Input__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\016\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - Output - -@implementation Output - -@dynamic testOutputField; -@dynamic secondField; - -typedef struct Output__storage_ { - uint32_t _has_storage_[1]; - int32_t testOutputField; - NSString *secondField; -} Output__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testOutputField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_TestOutputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Output__storage_, testOutputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeInt32, - }, - { - .name = "secondField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_SecondField, - .hasIndex = 1, - .offset = (uint32_t)offsetof(Output__storage_, secondField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Output class] - file:TestRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Output__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\002\001\017\000\002\013\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Input.php b/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Input.php deleted file mode 100644 index 6c7f5c5bd62..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Input.php +++ /dev/null @@ -1,58 +0,0 @@ -com.azure.Test.Input - */ -class Input extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field string testInputField = 1; - */ - protected $testInputField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $testInputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Com\Azure\Test::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field string testInputField = 1; - * @return string - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field string testInputField = 1; - * @param string $var - * @return $this - */ - public function setTestInputField($var) - { - GPBUtil::checkString($var, True); - $this->testInputField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Output.php b/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Output.php deleted file mode 100644 index 1e83abef423..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/php/Com/Azure/Test/Output.php +++ /dev/null @@ -1,85 +0,0 @@ -com.azure.Test.Output - */ -class Output extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field int32 testOutputField = 1; - */ - protected $testOutputField = 0; - /** - * Generated from protobuf field string secondField = 2; - */ - protected $secondField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $testOutputField - * @type string $secondField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Com\Azure\Test::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @return int - */ - public function getTestOutputField() - { - return $this->testOutputField; - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @param int $var - * @return $this - */ - public function setTestOutputField($var) - { - GPBUtil::checkInt32($var); - $this->testOutputField = $var; - - return $this; - } - - /** - * Generated from protobuf field string secondField = 2; - * @return string - */ - public function getSecondField() - { - return $this->secondField; - } - - /** - * Generated from protobuf field string secondField = 2; - * @param string $var - * @return $this - */ - public function setSecondField($var) - { - GPBUtil::checkString($var, True); - $this->secondField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/simple/output/php/GPBMetadata/Com/Azure/Test.php b/packages/protobuf/test/protoc-out/simple/output/php/GPBMetadata/Com/Azure/Test.php deleted file mode 100644 index 18ee644d1c4..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/php/GPBMetadata/Com/Azure/Test.php +++ /dev/null @@ -1,33 +0,0 @@ -internalAddGeneratedFile( - ' -� -com/azure/Test.protocom.azure.Test" -Input -testInputField ( "6 -Output -testOutputField ( - secondField ( 2? -Service4 -Foo.com.azure.Test.Input.com.azure.Test.Outputbproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/packages/protobuf/test/protoc-out/simple/output/pyi/com/azure/Test_pb2.pyi b/packages/protobuf/test/protoc-out/simple/output/pyi/com/azure/Test_pb2.pyi deleted file mode 100644 index 2683aa8091c..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/pyi/com/azure/Test_pb2.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Optional as _Optional - -DESCRIPTOR: _descriptor.FileDescriptor - -class Input(_message.Message): - __slots__ = ["testInputField"] - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testInputField: str - def __init__(self, testInputField: _Optional[str] = ...) -> None: ... - -class Output(_message.Message): - __slots__ = ["testOutputField", "secondField"] - TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] - SECONDFIELD_FIELD_NUMBER: _ClassVar[int] - testOutputField: int - secondField: str - def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/simple/output/python/com/azure/Test_pb2.py b/packages/protobuf/test/protoc-out/simple/output/python/com/azure/Test_pb2.py deleted file mode 100644 index b987cad0140..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/python/com/azure/Test_pb2.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: com/azure/Test.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14\x63om/azure/Test.proto\x12\x0e\x63om.azure.Test\"\x1f\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t2?\n\x07Service\x12\x34\n\x03\x46oo\x12\x15.com.azure.Test.Input\x1a\x16.com.azure.Test.Outputb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'com.azure.Test_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _globals['_INPUT']._serialized_start=40 - _globals['_INPUT']._serialized_end=71 - _globals['_OUTPUT']._serialized_start=73 - _globals['_OUTPUT']._serialized_end=127 - _globals['_SERVICE']._serialized_start=129 - _globals['_SERVICE']._serialized_end=192 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/simple/output/ruby/com/azure/Test_pb.rb b/packages/protobuf/test/protoc-out/simple/output/ruby/com/azure/Test_pb.rb deleted file mode 100644 index 3a488085898..00000000000 --- a/packages/protobuf/test/protoc-out/simple/output/ruby/com/azure/Test_pb.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: com/azure/Test.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("com/azure/Test.proto", :syntax => :proto3) do - add_message "com.azure.Test.Input" do - optional :testInputField, :string, 1 - end - add_message "com.azure.Test.Output" do - optional :testOutputField, :int32, 1 - optional :secondField, :string, 2 - end - end -end - -module Com - module Azure - module Test - Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.Test.Input").msgclass - Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.azure.Test.Output").msgclass - end - end -end diff --git a/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.cc deleted file mode 100644 index 7d1ee6621a1..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.cc +++ /dev/null @@ -1,578 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#include "main.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -PROTOBUF_CONSTEXPR Input::Input( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_._cached_size_)*/{}} {} -struct InputDefaultTypeInternal { - PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputDefaultTypeInternal() {} - union { - Input _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; -PROTOBUF_CONSTEXPR Output::Output( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /* ._impl_.testoutputfield_ = */ 0 - - , /*decltype(_impl_._cached_size_)*/{}} {} -struct OutputDefaultTypeInternal { - PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~OutputDefaultTypeInternal() {} - union { - Output _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; -static ::_pb::Metadata file_level_metadata_main_2eproto[2]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_main_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_main_2eproto = nullptr; -const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::Input, _impl_.testinputfield_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::Output, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::Output, _impl_.testoutputfield_), - PROTOBUF_FIELD_OFFSET(::Output, _impl_.secondfield_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::Input)}, - { 9, -1, -1, sizeof(::Output)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::_Input_default_instance_._instance, - &::_Output_default_instance_._instance, -}; -const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\nmain.proto\"\037\n\005Input\022\026\n\016testInputField\030" - "\001 \001(\t\"6\n\006Output\022\027\n\017testOutputField\030\001 \001(\005" - "\022\023\n\013secondField\030\002 \001(\t2t\n\007Service\022\035\n\006Dupl" - "ex\022\006.Input\032\007.Output(\0010\001\022\027\n\002In\022\006.Input\032\007." - "Output(\001\022\030\n\003Out\022\006.Input\032\007.Output0\001\022\027\n\004No" - "ne\022\006.Input\032\007.Outputb\006proto3" -}; -static ::absl::once_flag descriptor_table_main_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { - false, - false, - 227, - descriptor_table_protodef_main_2eproto, - "main.proto", - &descriptor_table_main_2eproto_once, - nullptr, - 0, - 2, - schemas, - file_default_instances, - TableStruct_main_2eproto::offsets, - file_level_metadata_main_2eproto, - file_level_enum_descriptors_main_2eproto, - file_level_service_descriptors_main_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { - return &descriptor_table_main_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); -// =================================================================== - -class Input::_Internal { - public: -}; - -Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:Input) -} -Input::Input(const Input& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Input* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_testinputfield().empty()) { - _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), - _this->GetArenaForAllocation()); - } - // @@protoc_insertion_point(copy_constructor:Input) -} - -inline void Input::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Input::~Input() { - // @@protoc_insertion_point(destructor:Input) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Input::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testinputfield_.Destroy(); -} - -void Input::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Input::Clear() { -// @@protoc_insertion_point(message_clear_start:Input) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_.ClearToEmpty(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // string testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - auto str = _internal_mutable_testinputfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "Input.testInputField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Input::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:Input) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "Input.testInputField"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_testinputfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:Input) - return target; -} - -::size_t Input::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:Input) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_testinputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Input::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } - - -void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:Input) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_testinputfield().empty()) { - _this->_internal_set_testinputfield(from._internal_testinputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Input::CopyFrom(const Input& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:Input) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Input::IsInitialized() const { - return true; -} - -void Input::InternalSwap(Input* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.testinputfield_, lhs_arena, - &other->_impl_.testinputfield_, rhs_arena - ); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[0]); -} -// =================================================================== - -class Output::_Internal { - public: -}; - -Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:Output) -} -Output::Output(const Output& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Output* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) {} - - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_secondfield().empty()) { - _this->_impl_.secondfield_.Set(from._internal_secondfield(), - _this->GetArenaForAllocation()); - } - _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; - // @@protoc_insertion_point(copy_constructor:Output) -} - -inline void Output::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) { 0 } - - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Output::~Output() { - // @@protoc_insertion_point(destructor:Output) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Output::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.secondfield_.Destroy(); -} - -void Output::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Output::Clear() { -// @@protoc_insertion_point(message_clear_start:Output) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.secondfield_.ClearToEmpty(); - _impl_.testoutputfield_ = 0; - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // int32 testOutputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { - _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - // string secondField = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { - auto str = _internal_mutable_secondfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "Output.secondField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Output::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:Output) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray( - 1, this->_internal_testoutputfield(), target); - } - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "Output.secondField"); - target = stream->WriteStringMaybeAliased( - 2, this->_internal_secondfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:Output) - return target; -} - -::size_t Output::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:Output) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_secondfield()); - } - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( - this->_internal_testoutputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Output::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } - - -void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:Output) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_secondfield().empty()) { - _this->_internal_set_secondfield(from._internal_secondfield()); - } - if (from._internal_testoutputfield() != 0) { - _this->_internal_set_testoutputfield(from._internal_testoutputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Output::CopyFrom(const Output& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:Output) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Output::IsInitialized() const { - return true; -} - -void Output::InternalSwap(Output* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.secondfield_, lhs_arena, - &other->_impl_.secondfield_, rhs_arena - ); - - swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[1]); -} -// @@protoc_insertion_point(namespace_scope) -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::Input* -Arena::CreateMaybeMessage< ::Input >(Arena* arena) { - return Arena::CreateMessageInternal< ::Input >(arena); -} -template<> PROTOBUF_NOINLINE ::Output* -Arena::CreateMaybeMessage< ::Output >(Arena* arena) { - return Arena::CreateMessageInternal< ::Output >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.h deleted file mode 100644 index 86d1a04a53e..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/cpp/main.pb.h +++ /dev/null @@ -1,526 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/unknown_field_set.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_main_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_main_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_main_2eproto; -class Input; -struct InputDefaultTypeInternal; -extern InputDefaultTypeInternal _Input_default_instance_; -class Output; -struct OutputDefaultTypeInternal; -extern OutputDefaultTypeInternal _Output_default_instance_; -PROTOBUF_NAMESPACE_OPEN -template <> -::Input* Arena::CreateMaybeMessage<::Input>(Arena*); -template <> -::Output* Arena::CreateMaybeMessage<::Output>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - - -// =================================================================== - - -// ------------------------------------------------------------------- - -class Input final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { - public: - inline Input() : Input(nullptr) {} - ~Input() override; - explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Input(const Input& from); - Input(Input&& from) noexcept - : Input() { - *this = ::std::move(from); - } - - inline Input& operator=(const Input& from) { - CopyFrom(from); - return *this; - } - inline Input& operator=(Input&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Input& default_instance() { - return *internal_default_instance(); - } - static inline const Input* internal_default_instance() { - return reinterpret_cast( - &_Input_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Input& a, Input& b) { - a.Swap(&b); - } - inline void Swap(Input* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Input* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Input& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Input& from) { - Input::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Input* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "Input"; - } - protected: - explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - }; - // string testInputField = 1; - void clear_testinputfield() ; - const std::string& testinputfield() const; - template - void set_testinputfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_testinputfield(); - PROTOBUF_NODISCARD std::string* release_testinputfield(); - void set_allocated_testinputfield(std::string* testinputfield); - private: - const std::string& _internal_testinputfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); - std::string* _internal_mutable_testinputfield(); - public: - // @@protoc_insertion_point(class_scope:Input) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -};// ------------------------------------------------------------------- - -class Output final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Output) */ { - public: - inline Output() : Output(nullptr) {} - ~Output() override; - explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Output(const Output& from); - Output(Output&& from) noexcept - : Output() { - *this = ::std::move(from); - } - - inline Output& operator=(const Output& from) { - CopyFrom(from); - return *this; - } - inline Output& operator=(Output&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Output& default_instance() { - return *internal_default_instance(); - } - static inline const Output* internal_default_instance() { - return reinterpret_cast( - &_Output_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(Output& a, Output& b) { - a.Swap(&b); - } - inline void Swap(Output* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Output* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Output& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Output& from) { - Output::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Output* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "Output"; - } - protected: - explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kSecondFieldFieldNumber = 2, - kTestOutputFieldFieldNumber = 1, - }; - // string secondField = 2; - void clear_secondfield() ; - const std::string& secondfield() const; - template - void set_secondfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_secondfield(); - PROTOBUF_NODISCARD std::string* release_secondfield(); - void set_allocated_secondfield(std::string* secondfield); - private: - const std::string& _internal_secondfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); - std::string* _internal_mutable_secondfield(); - public: - // int32 testOutputField = 1; - void clear_testoutputfield() ; - ::int32_t testoutputfield() const; - void set_testoutputfield(::int32_t value); - - private: - ::int32_t _internal_testoutputfield() const; - void _internal_set_testoutputfield(::int32_t value); - - public: - // @@protoc_insertion_point(class_scope:Output) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; - ::int32_t testoutputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// Input - -// string testInputField = 1; -inline void Input::clear_testinputfield() { - _impl_.testinputfield_.ClearToEmpty(); -} -inline const std::string& Input::testinputfield() const { - // @@protoc_insertion_point(field_get:Input.testInputField) - return _internal_testinputfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Input::set_testinputfield(ArgT0&& arg0, ArgT... args) { - - _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:Input.testInputField) -} -inline std::string* Input::mutable_testinputfield() { - std::string* _s = _internal_mutable_testinputfield(); - // @@protoc_insertion_point(field_mutable:Input.testInputField) - return _s; -} -inline const std::string& Input::_internal_testinputfield() const { - return _impl_.testinputfield_.Get(); -} -inline void Input::_internal_set_testinputfield(const std::string& value) { - - _impl_.testinputfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Input::_internal_mutable_testinputfield() { - - return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Input::release_testinputfield() { - // @@protoc_insertion_point(field_release:Input.testInputField) - return _impl_.testinputfield_.Release(); -} -inline void Input::set_allocated_testinputfield(std::string* testinputfield) { - _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.testinputfield_.IsDefault()) { - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:Input.testInputField) -} - -// ------------------------------------------------------------------- - -// Output - -// int32 testOutputField = 1; -inline void Output::clear_testoutputfield() { - _impl_.testoutputfield_ = 0; -} -inline ::int32_t Output::testoutputfield() const { - // @@protoc_insertion_point(field_get:Output.testOutputField) - return _internal_testoutputfield(); -} -inline void Output::set_testoutputfield(::int32_t value) { - ; - _internal_set_testoutputfield(value); - // @@protoc_insertion_point(field_set:Output.testOutputField) -} -inline ::int32_t Output::_internal_testoutputfield() const { - return _impl_.testoutputfield_; -} -inline void Output::_internal_set_testoutputfield(::int32_t value) { - ; - _impl_.testoutputfield_ = value; -} - -// string secondField = 2; -inline void Output::clear_secondfield() { - _impl_.secondfield_.ClearToEmpty(); -} -inline const std::string& Output::secondfield() const { - // @@protoc_insertion_point(field_get:Output.secondField) - return _internal_secondfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { - - _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:Output.secondField) -} -inline std::string* Output::mutable_secondfield() { - std::string* _s = _internal_mutable_secondfield(); - // @@protoc_insertion_point(field_mutable:Output.secondField) - return _s; -} -inline const std::string& Output::_internal_secondfield() const { - return _impl_.secondfield_.Get(); -} -inline void Output::_internal_set_secondfield(const std::string& value) { - - _impl_.secondfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Output::_internal_mutable_secondfield() { - - return _impl_.secondfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Output::release_secondfield() { - // @@protoc_insertion_point(field_release:Output.secondField) - return _impl_.secondfield_.Release(); -} -inline void Output::set_allocated_secondfield(std::string* secondfield) { - _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.secondfield_.IsDefault()) { - _impl_.secondfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:Output.secondField) -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/streams/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/streams/output/csharp/Main.cs deleted file mode 100644 index 5cbe5d77210..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/csharp/Main.cs +++ /dev/null @@ -1,460 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -/// Holder for reflection information generated from main.proto -public static partial class MainReflection { - - #region Descriptor - /// File descriptor for main.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static MainReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgptYWluLnByb3RvIh8KBUlucHV0EhYKDnRlc3RJbnB1dEZpZWxkGAEgASgJ", - "IjYKBk91dHB1dBIXCg90ZXN0T3V0cHV0RmllbGQYASABKAUSEwoLc2Vjb25k", - "RmllbGQYAiABKAkydAoHU2VydmljZRIdCgZEdXBsZXgSBi5JbnB1dBoHLk91", - "dHB1dCgBMAESFwoCSW4SBi5JbnB1dBoHLk91dHB1dCgBEhgKA091dBIGLklu", - "cHV0GgcuT3V0cHV0MAESFwoETm9uZRIGLklucHV0GgcuT3V0cHV0YgZwcm90", - "bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "TestInputField" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Output), global::Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) - })); - } - #endregion - -} -#region Messages -public sealed partial class Input : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input(Input other) : this() { - testInputField_ = other.testInputField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input Clone() { - return new Input(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private string testInputField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string TestInputField { - get { return testInputField_; } - set { - testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Input); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Input other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestInputField != other.TestInputField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestInputField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Input other) { - if (other == null) { - return; - } - if (other.TestInputField.Length != 0) { - TestInputField = other.TestInputField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - } - #endif - -} - -public sealed partial class Output : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output(Output other) : this() { - testOutputField_ = other.testOutputField_; - secondField_ = other.secondField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output Clone() { - return new Output(this); - } - - /// Field number for the "testOutputField" field. - public const int TestOutputFieldFieldNumber = 1; - private int testOutputField_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int TestOutputField { - get { return testOutputField_; } - set { - testOutputField_ = value; - } - } - - /// Field number for the "secondField" field. - public const int SecondFieldFieldNumber = 2; - private string secondField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string SecondField { - get { return secondField_; } - set { - secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Output); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Output other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestOutputField != other.TestOutputField) return false; - if (SecondField != other.SecondField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); - if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestOutputField != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); - } - if (SecondField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Output other) { - if (other == null) { - return; - } - if (other.TestOutputField != 0) { - TestOutputField = other.TestOutputField; - } - if (other.SecondField.Length != 0) { - SecondField = other.SecondField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - } - #endif - -} - -#endregion - - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.h deleted file mode 100644 index 12cf27d81f9..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.h +++ /dev/null @@ -1,83 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - MainRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface MainRoot : GPBRootObject -@end - -#pragma mark - Input - -typedef GPB_ENUM(Input_FieldNumber) { - Input_FieldNumber_TestInputField = 1, -}; - -GPB_FINAL @interface Input : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; - -@end - -#pragma mark - Output - -typedef GPB_ENUM(Output_FieldNumber) { - Output_FieldNumber_TestOutputField = 1, - Output_FieldNumber_SecondField = 2, -}; - -GPB_FINAL @interface Output : GPBMessage - -@property(nonatomic, readwrite) int32_t testOutputField; - -@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.m deleted file mode 100644 index 3d500e82955..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/objc/Main.pbobjc.m +++ /dev/null @@ -1,160 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "Main.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -#pragma mark - MainRoot - -@implementation MainRoot - -// No extensions in the file and no imports, so no need to generate -// +extensionRegistry. - -@end - -#pragma mark - MainRoot_FileDescriptor - -static GPBFileDescriptor *MainRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - Input - -@implementation Input - -@dynamic testInputField; - -typedef struct Input__storage_ { - uint32_t _has_storage_[1]; - NSString *testInputField; -} Input__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputField", - .dataTypeSpecific.clazz = Nil, - .number = Input_FieldNumber_TestInputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Input__storage_, testInputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Input class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Input__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\016\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - Output - -@implementation Output - -@dynamic testOutputField; -@dynamic secondField; - -typedef struct Output__storage_ { - uint32_t _has_storage_[1]; - int32_t testOutputField; - NSString *secondField; -} Output__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testOutputField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_TestOutputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Output__storage_, testOutputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeInt32, - }, - { - .name = "secondField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_SecondField, - .hasIndex = 1, - .offset = (uint32_t)offsetof(Output__storage_, secondField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Output class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Output__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\002\001\017\000\002\013\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/streams/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/streams/output/php/GPBMetadata/Main.php deleted file mode 100644 index 54d427533d2..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/php/GPBMetadata/Main.php +++ /dev/null @@ -1,37 +0,0 @@ -internalAddGeneratedFile( - ' -� - -main.proto" -Input -testInputField ( "6 -Output -testOutputField ( - secondField ( 2t -Service -Duplex.Input.Output(0 -In.Input.Output( -Out.Input.Output0 -None.Input.Outputbproto3' - , true); - - static::$is_initialized = true; - } -} - diff --git a/packages/protobuf/test/protoc-out/streams/output/php/Input.php b/packages/protobuf/test/protoc-out/streams/output/php/Input.php deleted file mode 100644 index b77d7713c23..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/php/Input.php +++ /dev/null @@ -1,56 +0,0 @@ -Input - */ -class Input extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field string testInputField = 1; - */ - protected $testInputField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $testInputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field string testInputField = 1; - * @return string - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field string testInputField = 1; - * @param string $var - * @return $this - */ - public function setTestInputField($var) - { - GPBUtil::checkString($var, True); - $this->testInputField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/streams/output/php/Output.php b/packages/protobuf/test/protoc-out/streams/output/php/Output.php deleted file mode 100644 index 050aef7e894..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/php/Output.php +++ /dev/null @@ -1,83 +0,0 @@ -Output - */ -class Output extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field int32 testOutputField = 1; - */ - protected $testOutputField = 0; - /** - * Generated from protobuf field string secondField = 2; - */ - protected $secondField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $testOutputField - * @type string $secondField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @return int - */ - public function getTestOutputField() - { - return $this->testOutputField; - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @param int $var - * @return $this - */ - public function setTestOutputField($var) - { - GPBUtil::checkInt32($var); - $this->testOutputField = $var; - - return $this; - } - - /** - * Generated from protobuf field string secondField = 2; - * @return string - */ - public function getSecondField() - { - return $this->secondField; - } - - /** - * Generated from protobuf field string secondField = 2; - * @param string $var - * @return $this - */ - public function setSecondField($var) - { - GPBUtil::checkString($var, True); - $this->secondField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/streams/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/streams/output/pyi/main_pb2.pyi deleted file mode 100644 index 2683aa8091c..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/pyi/main_pb2.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Optional as _Optional - -DESCRIPTOR: _descriptor.FileDescriptor - -class Input(_message.Message): - __slots__ = ["testInputField"] - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testInputField: str - def __init__(self, testInputField: _Optional[str] = ...) -> None: ... - -class Output(_message.Message): - __slots__ = ["testOutputField", "secondField"] - TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] - SECONDFIELD_FIELD_NUMBER: _ClassVar[int] - testOutputField: int - secondField: str - def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/streams/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/streams/output/python/main_pb2.py deleted file mode 100644 index 669a39e5855..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/python/main_pb2.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\"\x1f\n\x05Input\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t2t\n\x07Service\x12\x1d\n\x06\x44uplex\x12\x06.Input\x1a\x07.Output(\x01\x30\x01\x12\x17\n\x02In\x12\x06.Input\x1a\x07.Output(\x01\x12\x18\n\x03Out\x12\x06.Input\x1a\x07.Output0\x01\x12\x17\n\x04None\x12\x06.Input\x1a\x07.Outputb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _globals['_INPUT']._serialized_start=14 - _globals['_INPUT']._serialized_end=45 - _globals['_OUTPUT']._serialized_start=47 - _globals['_OUTPUT']._serialized_end=101 - _globals['_SERVICE']._serialized_start=103 - _globals['_SERVICE']._serialized_end=219 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/streams/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/streams/output/ruby/main_pb.rb deleted file mode 100644 index 0766cd00e0c..00000000000 --- a/packages/protobuf/test/protoc-out/streams/output/ruby/main_pb.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("main.proto", :syntax => :proto3) do - add_message "Input" do - optional :testInputField, :string, 1 - end - add_message "Output" do - optional :testOutputField, :int32, 1 - optional :secondField, :string, 2 - end - end -end - -Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass -Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Output").msgclass diff --git a/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.cc b/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.cc deleted file mode 100644 index 918d439740f..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.cc +++ /dev/null @@ -1,1120 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#include "main.pb.h" - -#include -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/extension_set.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/reflection_ops.h" -#include "google/protobuf/wire_format.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" -PROTOBUF_PRAGMA_INIT_SEG -namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; -PROTOBUF_CONSTEXPR InputA::InputA( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.testinputfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_._cached_size_)*/{}} {} -struct InputADefaultTypeInternal { - PROTOBUF_CONSTEXPR InputADefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputADefaultTypeInternal() {} - union { - InputA _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputADefaultTypeInternal _InputA_default_instance_; -PROTOBUF_CONSTEXPR InputB::InputB( - ::_pbi::ConstantInitialized): _impl_{ - /* ._impl_.testinputfield_ = */ 0u - - , /*decltype(_impl_._cached_size_)*/{}} {} -struct InputBDefaultTypeInternal { - PROTOBUF_CONSTEXPR InputBDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputBDefaultTypeInternal() {} - union { - InputB _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputBDefaultTypeInternal _InputB_default_instance_; -PROTOBUF_CONSTEXPR Input::Input( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.value_)*/{} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_._oneof_case_)*/{}} {} -struct InputDefaultTypeInternal { - PROTOBUF_CONSTEXPR InputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~InputDefaultTypeInternal() {} - union { - Input _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 InputDefaultTypeInternal _Input_default_instance_; -PROTOBUF_CONSTEXPR Output::Output( - ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.secondfield_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /* ._impl_.testoutputfield_ = */ 0 - - , /*decltype(_impl_._cached_size_)*/{}} {} -struct OutputDefaultTypeInternal { - PROTOBUF_CONSTEXPR OutputDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} - ~OutputDefaultTypeInternal() {} - union { - Output _instance; - }; -}; - -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OutputDefaultTypeInternal _Output_default_instance_; -static ::_pb::Metadata file_level_metadata_main_2eproto[4]; -static constexpr const ::_pb::EnumDescriptor** - file_level_enum_descriptors_main_2eproto = nullptr; -static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_main_2eproto = nullptr; -const ::uint32_t TableStruct_main_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( - protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::InputA, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::InputA, _impl_.testinputfield_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::InputB, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::InputB, _impl_.testinputfield_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::Input, _internal_metadata_), - ~0u, // no _extensions_ - PROTOBUF_FIELD_OFFSET(::Input, _impl_._oneof_case_[0]), - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - ::_pbi::kInvalidFieldOffsetTag, - ::_pbi::kInvalidFieldOffsetTag, - PROTOBUF_FIELD_OFFSET(::Input, _impl_.value_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::Output, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::Output, _impl_.testoutputfield_), - PROTOBUF_FIELD_OFFSET(::Output, _impl_.secondfield_), -}; - -static const ::_pbi::MigrationSchema - schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::InputA)}, - { 9, -1, -1, sizeof(::InputB)}, - { 18, -1, -1, sizeof(::Input)}, - { 29, -1, -1, sizeof(::Output)}, -}; - -static const ::_pb::Message* const file_default_instances[] = { - &::_InputA_default_instance_._instance, - &::_InputB_default_instance_._instance, - &::_Input_default_instance_._instance, - &::_Output_default_instance_._instance, -}; -const char descriptor_table_protodef_main_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\nmain.proto\" \n\006InputA\022\026\n\016testInputField" - "\030\001 \001(\t\" \n\006InputB\022\026\n\016testInputField\030\001 \001(\r" - "\"<\n\005Input\022\024\n\001a\030\001 \001(\0132\007.InputAH\000\022\024\n\001b\030\002 \001" - "(\0132\007.InputBH\000B\007\n\005value\"6\n\006Output\022\027\n\017test" - "OutputField\030\001 \001(\005\022\023\n\013secondField\030\002 \001(\t2!" - "\n\007Service\022\026\n\003Foo\022\006.Input\032\007.Outputb\006proto" - "3" -}; -static ::absl::once_flag descriptor_table_main_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_main_2eproto = { - false, - false, - 241, - descriptor_table_protodef_main_2eproto, - "main.proto", - &descriptor_table_main_2eproto_once, - nullptr, - 0, - 4, - schemas, - file_default_instances, - TableStruct_main_2eproto::offsets, - file_level_metadata_main_2eproto, - file_level_enum_descriptors_main_2eproto, - file_level_service_descriptors_main_2eproto, -}; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_main_2eproto_getter() { - return &descriptor_table_main_2eproto; -} -// Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_main_2eproto(&descriptor_table_main_2eproto); -// =================================================================== - -class InputA::_Internal { - public: -}; - -InputA::InputA(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:InputA) -} -InputA::InputA(const InputA& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - InputA* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_testinputfield().empty()) { - _this->_impl_.testinputfield_.Set(from._internal_testinputfield(), - _this->GetArenaForAllocation()); - } - // @@protoc_insertion_point(copy_constructor:InputA) -} - -inline void InputA::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_){} - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.testinputfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -InputA::~InputA() { - // @@protoc_insertion_point(destructor:InputA) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void InputA::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.testinputfield_.Destroy(); -} - -void InputA::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void InputA::Clear() { -// @@protoc_insertion_point(message_clear_start:InputA) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_.ClearToEmpty(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* InputA::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // string testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - auto str = _internal_mutable_testinputfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "InputA.testInputField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* InputA::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:InputA) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_testinputfield().data(), static_cast(this->_internal_testinputfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "InputA.testInputField"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_testinputfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:InputA) - return target; -} - -::size_t InputA::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:InputA) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string testInputField = 1; - if (!this->_internal_testinputfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_testinputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData InputA::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - InputA::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*InputA::GetClassData() const { return &_class_data_; } - - -void InputA::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:InputA) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_testinputfield().empty()) { - _this->_internal_set_testinputfield(from._internal_testinputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void InputA::CopyFrom(const InputA& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:InputA) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool InputA::IsInitialized() const { - return true; -} - -void InputA::InternalSwap(InputA* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.testinputfield_, lhs_arena, - &other->_impl_.testinputfield_, rhs_arena - ); -} - -::PROTOBUF_NAMESPACE_ID::Metadata InputA::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[0]); -} -// =================================================================== - -class InputB::_Internal { - public: -}; - -InputB::InputB(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:InputB) -} -InputB::InputB(const InputB& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), _impl_(from._impl_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>( - from._internal_metadata_); - // @@protoc_insertion_point(copy_constructor:InputB) -} - -inline void InputB::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.testinputfield_) { 0u } - - , /*decltype(_impl_._cached_size_)*/{} - }; -} - -InputB::~InputB() { - // @@protoc_insertion_point(destructor:InputB) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void InputB::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); -} - -void InputB::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void InputB::Clear() { -// @@protoc_insertion_point(message_clear_start:InputB) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.testinputfield_ = 0u; - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* InputB::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // uint32 testInputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { - _impl_.testinputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* InputB::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:InputB) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // uint32 testInputField = 1; - if (this->_internal_testinputfield() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray( - 1, this->_internal_testinputfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:InputB) - return target; -} - -::size_t InputB::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:InputB) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // uint32 testInputField = 1; - if (this->_internal_testinputfield() != 0) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne( - this->_internal_testinputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData InputB::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - InputB::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*InputB::GetClassData() const { return &_class_data_; } - - -void InputB::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:InputB) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (from._internal_testinputfield() != 0) { - _this->_internal_set_testinputfield(from._internal_testinputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void InputB::CopyFrom(const InputB& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:InputB) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool InputB::IsInitialized() const { - return true; -} - -void InputB::InternalSwap(InputB* other) { - using std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - - swap(_impl_.testinputfield_, other->_impl_.testinputfield_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata InputB::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[1]); -} -// =================================================================== - -class Input::_Internal { - public: - static constexpr ::int32_t kOneofCaseOffset = - PROTOBUF_FIELD_OFFSET(::Input, _impl_._oneof_case_); - static const ::InputA& a(const Input* msg); - static const ::InputB& b(const Input* msg); -}; - -const ::InputA& -Input::_Internal::a(const Input* msg) { - return *msg->_impl_.value_.a_; -} -const ::InputB& -Input::_Internal::b(const Input* msg) { - return *msg->_impl_.value_.b_; -} -void Input::set_allocated_a(::InputA* a) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - clear_value(); - if (a) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(a); - if (message_arena != submessage_arena) { - a = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, a, submessage_arena); - } - set_has_a(); - _impl_.value_.a_ = a; - } - // @@protoc_insertion_point(field_set_allocated:Input.a) -} -void Input::set_allocated_b(::InputB* b) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - clear_value(); - if (b) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(b); - if (message_arena != submessage_arena) { - b = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, b, submessage_arena); - } - set_has_b(); - _impl_.value_.b_ = b; - } - // @@protoc_insertion_point(field_set_allocated:Input.b) -} -Input::Input(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:Input) -} -Input::Input(const Input& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Input* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.value_){} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_._oneof_case_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - clear_has_value(); - switch (from.value_case()) { - case kA: { - _this->_internal_mutable_a()->::InputA::MergeFrom( - from._internal_a()); - break; - } - case kB: { - _this->_internal_mutable_b()->::InputB::MergeFrom( - from._internal_b()); - break; - } - case VALUE_NOT_SET: { - break; - } - } - // @@protoc_insertion_point(copy_constructor:Input) -} - -inline void Input::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.value_){} - , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_._oneof_case_)*/{} - }; - clear_has_value(); -} - -Input::~Input() { - // @@protoc_insertion_point(destructor:Input) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Input::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - if (has_value()) { - clear_value(); - } -} - -void Input::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Input::clear_value() { -// @@protoc_insertion_point(one_of_clear_start:Input) - switch (value_case()) { - case kA: { - if (GetArenaForAllocation() == nullptr) { - delete _impl_.value_.a_; - } - break; - } - case kB: { - if (GetArenaForAllocation() == nullptr) { - delete _impl_.value_.b_; - } - break; - } - case VALUE_NOT_SET: { - break; - } - } - _impl_._oneof_case_[0] = VALUE_NOT_SET; -} - - -void Input::Clear() { -// @@protoc_insertion_point(message_clear_start:Input) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - clear_value(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Input::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // .InputA a = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) { - ptr = ctx->ParseMessage(_internal_mutable_a(), ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - // .InputB b = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { - ptr = ctx->ParseMessage(_internal_mutable_b(), ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Input::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:Input) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // .InputA a = 1; - if (value_case() == kA) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, _Internal::a(this), - _Internal::a(this).GetCachedSize(), target, stream); - } - - // .InputB b = 2; - if (value_case() == kB) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, _Internal::b(this), - _Internal::b(this).GetCachedSize(), target, stream); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:Input) - return target; -} - -::size_t Input::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:Input) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - switch (value_case()) { - // .InputA a = 1; - case kA: { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.value_.a_); - break; - } - // .InputB b = 2; - case kB: { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.value_.b_); - break; - } - case VALUE_NOT_SET: { - break; - } - } - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Input::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Input::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Input::GetClassData() const { return &_class_data_; } - - -void Input::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:Input) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - switch (from.value_case()) { - case kA: { - _this->_internal_mutable_a()->::InputA::MergeFrom( - from._internal_a()); - break; - } - case kB: { - _this->_internal_mutable_b()->::InputB::MergeFrom( - from._internal_b()); - break; - } - case VALUE_NOT_SET: { - break; - } - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Input::CopyFrom(const Input& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:Input) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Input::IsInitialized() const { - return true; -} - -void Input::InternalSwap(Input* other) { - using std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_.value_, other->_impl_.value_); - swap(_impl_._oneof_case_[0], other->_impl_._oneof_case_[0]); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Input::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[2]); -} -// =================================================================== - -class Output::_Internal { - public: -}; - -Output::Output(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(arena); - // @@protoc_insertion_point(arena_constructor:Output) -} -Output::Output(const Output& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { - Output* const _this = this; (void)_this; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) {} - - , /*decltype(_impl_._cached_size_)*/{}}; - - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (!from._internal_secondfield().empty()) { - _this->_impl_.secondfield_.Set(from._internal_secondfield(), - _this->GetArenaForAllocation()); - } - _this->_impl_.testoutputfield_ = from._impl_.testoutputfield_; - // @@protoc_insertion_point(copy_constructor:Output) -} - -inline void Output::SharedCtor(::_pb::Arena* arena) { - (void)arena; - new (&_impl_) Impl_{ - decltype(_impl_.secondfield_){} - , decltype(_impl_.testoutputfield_) { 0 } - - , /*decltype(_impl_._cached_size_)*/{} - }; - _impl_.secondfield_.InitDefault(); - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.secondfield_.Set("", GetArenaForAllocation()); - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -} - -Output::~Output() { - // @@protoc_insertion_point(destructor:Output) - if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { - (void)arena; - return; - } - SharedDtor(); -} - -inline void Output::SharedDtor() { - ABSL_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.secondfield_.Destroy(); -} - -void Output::SetCachedSize(int size) const { - _impl_._cached_size_.Set(size); -} - -void Output::Clear() { -// @@protoc_insertion_point(message_clear_start:Output) - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - _impl_.secondfield_.ClearToEmpty(); - _impl_.testoutputfield_ = 0; - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Output::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::uint32_t tag; - ptr = ::_pbi::ReadTag(ptr, &tag); - switch (tag >> 3) { - // int32 testOutputField = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 8)) { - _impl_.testoutputfield_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } else { - goto handle_unusual; - } - continue; - // string secondField = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) { - auto str = _internal_mutable_secondfield(); - ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); - CHK_(ptr); - CHK_(::_pbi::VerifyUTF8(str, "Output.secondField")); - } else { - goto handle_unusual; - } - continue; - default: - goto handle_unusual; - } // switch - handle_unusual: - if ((tag == 0) || ((tag & 7) == 4)) { - CHK_(ptr); - ctx->SetLastTag(tag); - goto message_done; - } - ptr = UnknownFieldParse( - tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - } // while -message_done: - return ptr; -failure: - ptr = nullptr; - goto message_done; -#undef CHK_ -} - -::uint8_t* Output::_InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:Output) - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray( - 1, this->_internal_testoutputfield(), target); - } - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_secondfield().data(), static_cast(this->_internal_secondfield().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "Output.secondField"); - target = stream->WriteStringMaybeAliased( - 2, this->_internal_secondfield(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:Output) - return target; -} - -::size_t Output::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:Output) - ::size_t total_size = 0; - - ::uint32_t cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // string secondField = 2; - if (!this->_internal_secondfield().empty()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_secondfield()); - } - - // int32 testOutputField = 1; - if (this->_internal_testoutputfield() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne( - this->_internal_testoutputfield()); - } - - return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); -} - -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Output::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, - Output::MergeImpl -}; -const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Output::GetClassData() const { return &_class_data_; } - - -void Output::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { - auto* const _this = static_cast(&to_msg); - auto& from = static_cast(from_msg); - // @@protoc_insertion_point(class_specific_merge_from_start:Output) - ABSL_DCHECK_NE(&from, _this); - ::uint32_t cached_has_bits = 0; - (void) cached_has_bits; - - if (!from._internal_secondfield().empty()) { - _this->_internal_set_secondfield(from._internal_secondfield()); - } - if (from._internal_testoutputfield() != 0) { - _this->_internal_set_testoutputfield(from._internal_testoutputfield()); - } - _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Output::CopyFrom(const Output& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:Output) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Output::IsInitialized() const { - return true; -} - -void Output::InternalSwap(Output* other) { - using std::swap; - auto* lhs_arena = GetArenaForAllocation(); - auto* rhs_arena = other->GetArenaForAllocation(); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.secondfield_, lhs_arena, - &other->_impl_.secondfield_, rhs_arena - ); - - swap(_impl_.testoutputfield_, other->_impl_.testoutputfield_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Output::GetMetadata() const { - return ::_pbi::AssignDescriptors( - &descriptor_table_main_2eproto_getter, &descriptor_table_main_2eproto_once, - file_level_metadata_main_2eproto[3]); -} -// @@protoc_insertion_point(namespace_scope) -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::InputA* -Arena::CreateMaybeMessage< ::InputA >(Arena* arena) { - return Arena::CreateMessageInternal< ::InputA >(arena); -} -template<> PROTOBUF_NOINLINE ::InputB* -Arena::CreateMaybeMessage< ::InputB >(Arena* arena) { - return Arena::CreateMessageInternal< ::InputB >(arena); -} -template<> PROTOBUF_NOINLINE ::Input* -Arena::CreateMaybeMessage< ::Input >(Arena* arena) { - return Arena::CreateMessageInternal< ::Input >(arena); -} -template<> PROTOBUF_NOINLINE ::Output* -Arena::CreateMaybeMessage< ::Output >(Arena* arena) { - return Arena::CreateMessageInternal< ::Output >(arena); -} -PROTOBUF_NAMESPACE_CLOSE -// @@protoc_insertion_point(global_scope) -#include "google/protobuf/port_undef.inc" diff --git a/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.h b/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.h deleted file mode 100644 index 6e4650a5c08..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/cpp/main.pb.h +++ /dev/null @@ -1,1063 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh - -#include -#include -#include - -#include "google/protobuf/port_def.inc" -#if PROTOBUF_VERSION < 4022000 -#error "This file was generated by a newer version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please update" -#error "your headers." -#endif // PROTOBUF_VERSION - -#if 4022000 < PROTOBUF_MIN_PROTOC_VERSION -#error "This file was generated by an older version of protoc which is" -#error "incompatible with your Protocol Buffer headers. Please" -#error "regenerate this file with a newer version of protoc." -#endif // PROTOBUF_MIN_PROTOC_VERSION -#include "google/protobuf/port_undef.inc" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/arena.h" -#include "google/protobuf/arenastring.h" -#include "google/protobuf/generated_message_util.h" -#include "google/protobuf/metadata_lite.h" -#include "google/protobuf/generated_message_reflection.h" -#include "google/protobuf/message.h" -#include "google/protobuf/repeated_field.h" // IWYU pragma: export -#include "google/protobuf/extension_set.h" // IWYU pragma: export -#include "google/protobuf/unknown_field_set.h" -// @@protoc_insertion_point(includes) - -// Must be included last. -#include "google/protobuf/port_def.inc" - -#define PROTOBUF_INTERNAL_EXPORT_main_2eproto - -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_main_2eproto { - static const ::uint32_t offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable - descriptor_table_main_2eproto; -class Input; -struct InputDefaultTypeInternal; -extern InputDefaultTypeInternal _Input_default_instance_; -class InputA; -struct InputADefaultTypeInternal; -extern InputADefaultTypeInternal _InputA_default_instance_; -class InputB; -struct InputBDefaultTypeInternal; -extern InputBDefaultTypeInternal _InputB_default_instance_; -class Output; -struct OutputDefaultTypeInternal; -extern OutputDefaultTypeInternal _Output_default_instance_; -PROTOBUF_NAMESPACE_OPEN -template <> -::Input* Arena::CreateMaybeMessage<::Input>(Arena*); -template <> -::InputA* Arena::CreateMaybeMessage<::InputA>(Arena*); -template <> -::InputB* Arena::CreateMaybeMessage<::InputB>(Arena*); -template <> -::Output* Arena::CreateMaybeMessage<::Output>(Arena*); -PROTOBUF_NAMESPACE_CLOSE - - -// =================================================================== - - -// ------------------------------------------------------------------- - -class InputA final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:InputA) */ { - public: - inline InputA() : InputA(nullptr) {} - ~InputA() override; - explicit PROTOBUF_CONSTEXPR InputA(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - InputA(const InputA& from); - InputA(InputA&& from) noexcept - : InputA() { - *this = ::std::move(from); - } - - inline InputA& operator=(const InputA& from) { - CopyFrom(from); - return *this; - } - inline InputA& operator=(InputA&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const InputA& default_instance() { - return *internal_default_instance(); - } - static inline const InputA* internal_default_instance() { - return reinterpret_cast( - &_InputA_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(InputA& a, InputA& b) { - a.Swap(&b); - } - inline void Swap(InputA* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(InputA* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - InputA* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const InputA& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const InputA& from) { - InputA::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(InputA* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "InputA"; - } - protected: - explicit InputA(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - }; - // string testInputField = 1; - void clear_testinputfield() ; - const std::string& testinputfield() const; - template - void set_testinputfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_testinputfield(); - PROTOBUF_NODISCARD std::string* release_testinputfield(); - void set_allocated_testinputfield(std::string* testinputfield); - private: - const std::string& _internal_testinputfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_testinputfield(const std::string& value); - std::string* _internal_mutable_testinputfield(); - public: - // @@protoc_insertion_point(class_scope:InputA) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr testinputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -};// ------------------------------------------------------------------- - -class InputB final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:InputB) */ { - public: - inline InputB() : InputB(nullptr) {} - ~InputB() override; - explicit PROTOBUF_CONSTEXPR InputB(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - InputB(const InputB& from); - InputB(InputB&& from) noexcept - : InputB() { - *this = ::std::move(from); - } - - inline InputB& operator=(const InputB& from) { - CopyFrom(from); - return *this; - } - inline InputB& operator=(InputB&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const InputB& default_instance() { - return *internal_default_instance(); - } - static inline const InputB* internal_default_instance() { - return reinterpret_cast( - &_InputB_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(InputB& a, InputB& b) { - a.Swap(&b); - } - inline void Swap(InputB* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(InputB* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - InputB* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const InputB& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const InputB& from) { - InputB::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(InputB* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "InputB"; - } - protected: - explicit InputB(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTestInputFieldFieldNumber = 1, - }; - // uint32 testInputField = 1; - void clear_testinputfield() ; - ::uint32_t testinputfield() const; - void set_testinputfield(::uint32_t value); - - private: - ::uint32_t _internal_testinputfield() const; - void _internal_set_testinputfield(::uint32_t value); - - public: - // @@protoc_insertion_point(class_scope:InputB) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::uint32_t testinputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -};// ------------------------------------------------------------------- - -class Input final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Input) */ { - public: - inline Input() : Input(nullptr) {} - ~Input() override; - explicit PROTOBUF_CONSTEXPR Input(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Input(const Input& from); - Input(Input&& from) noexcept - : Input() { - *this = ::std::move(from); - } - - inline Input& operator=(const Input& from) { - CopyFrom(from); - return *this; - } - inline Input& operator=(Input&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Input& default_instance() { - return *internal_default_instance(); - } - enum ValueCase { - kA = 1, - kB = 2, - VALUE_NOT_SET = 0, - }; - - static inline const Input* internal_default_instance() { - return reinterpret_cast( - &_Input_default_instance_); - } - static constexpr int kIndexInFileMessages = - 2; - - friend void swap(Input& a, Input& b) { - a.Swap(&b); - } - inline void Swap(Input* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Input* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Input* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Input& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Input& from) { - Input::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Input* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "Input"; - } - protected: - explicit Input(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kAFieldNumber = 1, - kBFieldNumber = 2, - }; - // .InputA a = 1; - bool has_a() const; - private: - bool _internal_has_a() const; - - public: - void clear_a() ; - const ::InputA& a() const; - PROTOBUF_NODISCARD ::InputA* release_a(); - ::InputA* mutable_a(); - void set_allocated_a(::InputA* a); - private: - const ::InputA& _internal_a() const; - ::InputA* _internal_mutable_a(); - public: - void unsafe_arena_set_allocated_a( - ::InputA* a); - ::InputA* unsafe_arena_release_a(); - // .InputB b = 2; - bool has_b() const; - private: - bool _internal_has_b() const; - - public: - void clear_b() ; - const ::InputB& b() const; - PROTOBUF_NODISCARD ::InputB* release_b(); - ::InputB* mutable_b(); - void set_allocated_b(::InputB* b); - private: - const ::InputB& _internal_b() const; - ::InputB* _internal_mutable_b(); - public: - void unsafe_arena_set_allocated_b( - ::InputB* b); - ::InputB* unsafe_arena_release_b(); - void clear_value(); - ValueCase value_case() const; - // @@protoc_insertion_point(class_scope:Input) - private: - class _Internal; - void set_has_a(); - void set_has_b(); - - inline bool has_value() const; - inline void clear_has_value(); - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - union ValueUnion { - constexpr ValueUnion() : _constinit_{} {} - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; - ::InputA* a_; - ::InputB* b_; - } value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::uint32_t _oneof_case_[1]; - - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -};// ------------------------------------------------------------------- - -class Output final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:Output) */ { - public: - inline Output() : Output(nullptr) {} - ~Output() override; - explicit PROTOBUF_CONSTEXPR Output(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Output(const Output& from); - Output(Output&& from) noexcept - : Output() { - *this = ::std::move(from); - } - - inline Output& operator=(const Output& from) { - CopyFrom(from); - return *this; - } - inline Output& operator=(Output&& from) noexcept { - if (this == &from) return *this; - if (GetOwningArena() == from.GetOwningArena() - #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - && GetOwningArena() != nullptr - #endif // !PROTOBUF_FORCE_COPY_IN_MOVE - ) { - InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return default_instance().GetMetadata().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return default_instance().GetMetadata().reflection; - } - static const Output& default_instance() { - return *internal_default_instance(); - } - static inline const Output* internal_default_instance() { - return reinterpret_cast( - &_Output_default_instance_); - } - static constexpr int kIndexInFileMessages = - 3; - - friend void swap(Output& a, Output& b) { - a.Swap(&b); - } - inline void Swap(Output* other) { - if (other == this) return; - #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() != nullptr && - GetOwningArena() == other->GetOwningArena()) { - #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetOwningArena() == other->GetOwningArena()) { - #endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Output* other) { - if (other == this) return; - ABSL_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Output* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Output& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Output& from) { - Output::MergeImpl(*this, from); - } - private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); - public: - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - ::size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::uint8_t* _InternalSerialize( - ::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _impl_._cached_size_.Get(); } - - private: - void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Output* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::absl::string_view FullMessageName() { - return "Output"; - } - protected: - explicit Output(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kSecondFieldFieldNumber = 2, - kTestOutputFieldFieldNumber = 1, - }; - // string secondField = 2; - void clear_secondfield() ; - const std::string& secondfield() const; - template - void set_secondfield(ArgT0&& arg0, ArgT... args); - std::string* mutable_secondfield(); - PROTOBUF_NODISCARD std::string* release_secondfield(); - void set_allocated_secondfield(std::string* secondfield); - private: - const std::string& _internal_secondfield() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_secondfield(const std::string& value); - std::string* _internal_mutable_secondfield(); - public: - // int32 testOutputField = 1; - void clear_testoutputfield() ; - ::int32_t testoutputfield() const; - void set_testoutputfield(::int32_t value); - - private: - ::int32_t _internal_testoutputfield() const; - void _internal_set_testoutputfield(::int32_t value); - - public: - // @@protoc_insertion_point(class_scope:Output) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr secondfield_; - ::int32_t testoutputfield_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_main_2eproto; -}; - -// =================================================================== - - - - -// =================================================================== - - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// InputA - -// string testInputField = 1; -inline void InputA::clear_testinputfield() { - _impl_.testinputfield_.ClearToEmpty(); -} -inline const std::string& InputA::testinputfield() const { - // @@protoc_insertion_point(field_get:InputA.testInputField) - return _internal_testinputfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void InputA::set_testinputfield(ArgT0&& arg0, ArgT... args) { - - _impl_.testinputfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:InputA.testInputField) -} -inline std::string* InputA::mutable_testinputfield() { - std::string* _s = _internal_mutable_testinputfield(); - // @@protoc_insertion_point(field_mutable:InputA.testInputField) - return _s; -} -inline const std::string& InputA::_internal_testinputfield() const { - return _impl_.testinputfield_.Get(); -} -inline void InputA::_internal_set_testinputfield(const std::string& value) { - - _impl_.testinputfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* InputA::_internal_mutable_testinputfield() { - - return _impl_.testinputfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* InputA::release_testinputfield() { - // @@protoc_insertion_point(field_release:InputA.testInputField) - return _impl_.testinputfield_.Release(); -} -inline void InputA::set_allocated_testinputfield(std::string* testinputfield) { - _impl_.testinputfield_.SetAllocated(testinputfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.testinputfield_.IsDefault()) { - _impl_.testinputfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:InputA.testInputField) -} - -// ------------------------------------------------------------------- - -// InputB - -// uint32 testInputField = 1; -inline void InputB::clear_testinputfield() { - _impl_.testinputfield_ = 0u; -} -inline ::uint32_t InputB::testinputfield() const { - // @@protoc_insertion_point(field_get:InputB.testInputField) - return _internal_testinputfield(); -} -inline void InputB::set_testinputfield(::uint32_t value) { - ; - _internal_set_testinputfield(value); - // @@protoc_insertion_point(field_set:InputB.testInputField) -} -inline ::uint32_t InputB::_internal_testinputfield() const { - return _impl_.testinputfield_; -} -inline void InputB::_internal_set_testinputfield(::uint32_t value) { - ; - _impl_.testinputfield_ = value; -} - -// ------------------------------------------------------------------- - -// Input - -// .InputA a = 1; -inline bool Input::has_a() const { - return value_case() == kA; -} -inline bool Input::_internal_has_a() const { - return value_case() == kA; -} -inline void Input::set_has_a() { - _impl_._oneof_case_[0] = kA; -} -inline void Input::clear_a() { - if (value_case() == kA) { - if (GetArenaForAllocation() == nullptr) { - delete _impl_.value_.a_; - } - clear_has_value(); - } -} -inline ::InputA* Input::release_a() { - // @@protoc_insertion_point(field_release:Input.a) - if (value_case() == kA) { - clear_has_value(); - ::InputA* temp = _impl_.value_.a_; - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - _impl_.value_.a_ = nullptr; - return temp; - } else { - return nullptr; - } -} -inline const ::InputA& Input::_internal_a() const { - return value_case() == kA - ? *_impl_.value_.a_ - : reinterpret_cast< ::InputA&>(::_InputA_default_instance_); -} -inline const ::InputA& Input::a() const { - // @@protoc_insertion_point(field_get:Input.a) - return _internal_a(); -} -inline ::InputA* Input::unsafe_arena_release_a() { - // @@protoc_insertion_point(field_unsafe_arena_release:Input.a) - if (value_case() == kA) { - clear_has_value(); - ::InputA* temp = _impl_.value_.a_; - _impl_.value_.a_ = nullptr; - return temp; - } else { - return nullptr; - } -} -inline void Input::unsafe_arena_set_allocated_a(::InputA* a) { - clear_value(); - if (a) { - set_has_a(); - _impl_.value_.a_ = a; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:Input.a) -} -inline ::InputA* Input::_internal_mutable_a() { - if (value_case() != kA) { - clear_value(); - set_has_a(); - _impl_.value_.a_ = CreateMaybeMessage< ::InputA >(GetArenaForAllocation()); - } - return _impl_.value_.a_; -} -inline ::InputA* Input::mutable_a() { - ::InputA* _msg = _internal_mutable_a(); - // @@protoc_insertion_point(field_mutable:Input.a) - return _msg; -} - -// .InputB b = 2; -inline bool Input::has_b() const { - return value_case() == kB; -} -inline bool Input::_internal_has_b() const { - return value_case() == kB; -} -inline void Input::set_has_b() { - _impl_._oneof_case_[0] = kB; -} -inline void Input::clear_b() { - if (value_case() == kB) { - if (GetArenaForAllocation() == nullptr) { - delete _impl_.value_.b_; - } - clear_has_value(); - } -} -inline ::InputB* Input::release_b() { - // @@protoc_insertion_point(field_release:Input.b) - if (value_case() == kB) { - clear_has_value(); - ::InputB* temp = _impl_.value_.b_; - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - _impl_.value_.b_ = nullptr; - return temp; - } else { - return nullptr; - } -} -inline const ::InputB& Input::_internal_b() const { - return value_case() == kB - ? *_impl_.value_.b_ - : reinterpret_cast< ::InputB&>(::_InputB_default_instance_); -} -inline const ::InputB& Input::b() const { - // @@protoc_insertion_point(field_get:Input.b) - return _internal_b(); -} -inline ::InputB* Input::unsafe_arena_release_b() { - // @@protoc_insertion_point(field_unsafe_arena_release:Input.b) - if (value_case() == kB) { - clear_has_value(); - ::InputB* temp = _impl_.value_.b_; - _impl_.value_.b_ = nullptr; - return temp; - } else { - return nullptr; - } -} -inline void Input::unsafe_arena_set_allocated_b(::InputB* b) { - clear_value(); - if (b) { - set_has_b(); - _impl_.value_.b_ = b; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:Input.b) -} -inline ::InputB* Input::_internal_mutable_b() { - if (value_case() != kB) { - clear_value(); - set_has_b(); - _impl_.value_.b_ = CreateMaybeMessage< ::InputB >(GetArenaForAllocation()); - } - return _impl_.value_.b_; -} -inline ::InputB* Input::mutable_b() { - ::InputB* _msg = _internal_mutable_b(); - // @@protoc_insertion_point(field_mutable:Input.b) - return _msg; -} - -inline bool Input::has_value() const { - return value_case() != VALUE_NOT_SET; -} -inline void Input::clear_has_value() { - _impl_._oneof_case_[0] = VALUE_NOT_SET; -} -inline Input::ValueCase Input::value_case() const { - return Input::ValueCase(_impl_._oneof_case_[0]); -} -// ------------------------------------------------------------------- - -// Output - -// int32 testOutputField = 1; -inline void Output::clear_testoutputfield() { - _impl_.testoutputfield_ = 0; -} -inline ::int32_t Output::testoutputfield() const { - // @@protoc_insertion_point(field_get:Output.testOutputField) - return _internal_testoutputfield(); -} -inline void Output::set_testoutputfield(::int32_t value) { - ; - _internal_set_testoutputfield(value); - // @@protoc_insertion_point(field_set:Output.testOutputField) -} -inline ::int32_t Output::_internal_testoutputfield() const { - return _impl_.testoutputfield_; -} -inline void Output::_internal_set_testoutputfield(::int32_t value) { - ; - _impl_.testoutputfield_ = value; -} - -// string secondField = 2; -inline void Output::clear_secondfield() { - _impl_.secondfield_.ClearToEmpty(); -} -inline const std::string& Output::secondfield() const { - // @@protoc_insertion_point(field_get:Output.secondField) - return _internal_secondfield(); -} -template -inline PROTOBUF_ALWAYS_INLINE -void Output::set_secondfield(ArgT0&& arg0, ArgT... args) { - - _impl_.secondfield_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:Output.secondField) -} -inline std::string* Output::mutable_secondfield() { - std::string* _s = _internal_mutable_secondfield(); - // @@protoc_insertion_point(field_mutable:Output.secondField) - return _s; -} -inline const std::string& Output::_internal_secondfield() const { - return _impl_.secondfield_.Get(); -} -inline void Output::_internal_set_secondfield(const std::string& value) { - - _impl_.secondfield_.Set(value, GetArenaForAllocation()); -} -inline std::string* Output::_internal_mutable_secondfield() { - - return _impl_.secondfield_.Mutable(GetArenaForAllocation()); -} -inline std::string* Output::release_secondfield() { - // @@protoc_insertion_point(field_release:Output.secondField) - return _impl_.secondfield_.Release(); -} -inline void Output::set_allocated_secondfield(std::string* secondfield) { - _impl_.secondfield_.SetAllocated(secondfield, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.secondfield_.IsDefault()) { - _impl_.secondfield_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:Output.secondField) -} - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif // __GNUC__ - -// @@protoc_insertion_point(namespace_scope) - - -// @@protoc_insertion_point(global_scope) - -#include "google/protobuf/port_undef.inc" - -#endif // GOOGLE_PROTOBUF_INCLUDED_main_2eproto_2epb_2eh diff --git a/packages/protobuf/test/protoc-out/union/output/csharp/Main.cs b/packages/protobuf/test/protoc-out/union/output/csharp/Main.cs deleted file mode 100644 index 18c2f46a56c..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/csharp/Main.cs +++ /dev/null @@ -1,936 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: main.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -/// Holder for reflection information generated from main.proto -public static partial class MainReflection { - - #region Descriptor - /// File descriptor for main.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static MainReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgptYWluLnByb3RvIiAKBklucHV0QRIWCg50ZXN0SW5wdXRGaWVsZBgBIAEo", - "CSIgCgZJbnB1dEISFgoOdGVzdElucHV0RmllbGQYASABKA0iPAoFSW5wdXQS", - "FAoBYRgBIAEoCzIHLklucHV0QUgAEhQKAWIYAiABKAsyBy5JbnB1dEJIAEIH", - "CgV2YWx1ZSI2CgZPdXRwdXQSFwoPdGVzdE91dHB1dEZpZWxkGAEgASgFEhMK", - "C3NlY29uZEZpZWxkGAIgASgJMiEKB1NlcnZpY2USFgoDRm9vEgYuSW5wdXQa", - "By5PdXRwdXRiBnByb3RvMw==")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::InputA), global::InputA.Parser, new[]{ "TestInputField" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::InputB), global::InputB.Parser, new[]{ "TestInputField" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Input), global::Input.Parser, new[]{ "A", "B" }, new[]{ "Value" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Output), global::Output.Parser, new[]{ "TestOutputField", "SecondField" }, null, null, null, null) - })); - } - #endregion - -} -#region Messages -public sealed partial class InputA : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new InputA()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public InputA() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public InputA(InputA other) : this() { - testInputField_ = other.testInputField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public InputA Clone() { - return new InputA(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private string testInputField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string TestInputField { - get { return testInputField_; } - set { - testInputField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as InputA); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(InputA other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestInputField != other.TestInputField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestInputField.Length != 0) hash ^= TestInputField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestInputField.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestInputField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(TestInputField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(InputA other) { - if (other == null) { - return; - } - if (other.TestInputField.Length != 0) { - TestInputField = other.TestInputField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - TestInputField = input.ReadString(); - break; - } - } - } - } - #endif - -} - -public sealed partial class InputB : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new InputB()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public InputB() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public InputB(InputB other) : this() { - testInputField_ = other.testInputField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public InputB Clone() { - return new InputB(this); - } - - /// Field number for the "testInputField" field. - public const int TestInputFieldFieldNumber = 1; - private uint testInputField_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public uint TestInputField { - get { return testInputField_; } - set { - testInputField_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as InputB); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(InputB other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestInputField != other.TestInputField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestInputField != 0) hash ^= TestInputField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestInputField != 0) { - output.WriteRawTag(8); - output.WriteUInt32(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestInputField != 0) { - output.WriteRawTag(8); - output.WriteUInt32(TestInputField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestInputField != 0) { - size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TestInputField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(InputB other) { - if (other == null) { - return; - } - if (other.TestInputField != 0) { - TestInputField = other.TestInputField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - TestInputField = input.ReadUInt32(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - TestInputField = input.ReadUInt32(); - break; - } - } - } - } - #endif - -} - -public sealed partial class Input : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Input()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[2]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input(Input other) : this() { - switch (other.ValueCase) { - case ValueOneofCase.A: - A = other.A.Clone(); - break; - case ValueOneofCase.B: - B = other.B.Clone(); - break; - } - - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Input Clone() { - return new Input(this); - } - - /// Field number for the "a" field. - public const int AFieldNumber = 1; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::InputA A { - get { return valueCase_ == ValueOneofCase.A ? (global::InputA) value_ : null; } - set { - value_ = value; - valueCase_ = value == null ? ValueOneofCase.None : ValueOneofCase.A; - } - } - - /// Field number for the "b" field. - public const int BFieldNumber = 2; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::InputB B { - get { return valueCase_ == ValueOneofCase.B ? (global::InputB) value_ : null; } - set { - value_ = value; - valueCase_ = value == null ? ValueOneofCase.None : ValueOneofCase.B; - } - } - - private object value_; - /// Enum of possible cases for the "value" oneof. - public enum ValueOneofCase { - None = 0, - A = 1, - B = 2, - } - private ValueOneofCase valueCase_ = ValueOneofCase.None; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ValueOneofCase ValueCase { - get { return valueCase_; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void ClearValue() { - valueCase_ = ValueOneofCase.None; - value_ = null; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Input); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Input other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!object.Equals(A, other.A)) return false; - if (!object.Equals(B, other.B)) return false; - if (ValueCase != other.ValueCase) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (valueCase_ == ValueOneofCase.A) hash ^= A.GetHashCode(); - if (valueCase_ == ValueOneofCase.B) hash ^= B.GetHashCode(); - hash ^= (int) valueCase_; - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (valueCase_ == ValueOneofCase.A) { - output.WriteRawTag(10); - output.WriteMessage(A); - } - if (valueCase_ == ValueOneofCase.B) { - output.WriteRawTag(18); - output.WriteMessage(B); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (valueCase_ == ValueOneofCase.A) { - output.WriteRawTag(10); - output.WriteMessage(A); - } - if (valueCase_ == ValueOneofCase.B) { - output.WriteRawTag(18); - output.WriteMessage(B); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (valueCase_ == ValueOneofCase.A) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(A); - } - if (valueCase_ == ValueOneofCase.B) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(B); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Input other) { - if (other == null) { - return; - } - switch (other.ValueCase) { - case ValueOneofCase.A: - if (A == null) { - A = new global::InputA(); - } - A.MergeFrom(other.A); - break; - case ValueOneofCase.B: - if (B == null) { - B = new global::InputB(); - } - B.MergeFrom(other.B); - break; - } - - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - global::InputA subBuilder = new global::InputA(); - if (valueCase_ == ValueOneofCase.A) { - subBuilder.MergeFrom(A); - } - input.ReadMessage(subBuilder); - A = subBuilder; - break; - } - case 18: { - global::InputB subBuilder = new global::InputB(); - if (valueCase_ == ValueOneofCase.B) { - subBuilder.MergeFrom(B); - } - input.ReadMessage(subBuilder); - B = subBuilder; - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - global::InputA subBuilder = new global::InputA(); - if (valueCase_ == ValueOneofCase.A) { - subBuilder.MergeFrom(A); - } - input.ReadMessage(subBuilder); - A = subBuilder; - break; - } - case 18: { - global::InputB subBuilder = new global::InputB(); - if (valueCase_ == ValueOneofCase.B) { - subBuilder.MergeFrom(B); - } - input.ReadMessage(subBuilder); - B = subBuilder; - break; - } - } - } - } - #endif - -} - -public sealed partial class Output : pb::IMessage -#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage -#endif -{ - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Output()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::MainReflection.Descriptor.MessageTypes[3]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output(Output other) : this() { - testOutputField_ = other.testOutputField_; - secondField_ = other.secondField_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public Output Clone() { - return new Output(this); - } - - /// Field number for the "testOutputField" field. - public const int TestOutputFieldFieldNumber = 1; - private int testOutputField_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int TestOutputField { - get { return testOutputField_; } - set { - testOutputField_ = value; - } - } - - /// Field number for the "secondField" field. - public const int SecondFieldFieldNumber = 2; - private string secondField_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string SecondField { - get { return secondField_; } - set { - secondField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as Output); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(Output other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (TestOutputField != other.TestOutputField) return false; - if (SecondField != other.SecondField) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (TestOutputField != 0) hash ^= TestOutputField.GetHashCode(); - if (SecondField.Length != 0) hash ^= SecondField.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (TestOutputField != 0) { - output.WriteRawTag(8); - output.WriteInt32(TestOutputField); - } - if (SecondField.Length != 0) { - output.WriteRawTag(18); - output.WriteString(SecondField); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (TestOutputField != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(TestOutputField); - } - if (SecondField.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(SecondField); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(Output other) { - if (other == null) { - return; - } - if (other.TestOutputField != 0) { - TestOutputField = other.TestOutputField; - } - if (other.SecondField.Length != 0) { - SecondField = other.SecondField; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - TestOutputField = input.ReadInt32(); - break; - } - case 18: { - SecondField = input.ReadString(); - break; - } - } - } - } - #endif - -} - -#endregion - - -#endregion Designer generated code diff --git a/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.h b/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.h deleted file mode 100644 index 301a3249d51..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.h +++ /dev/null @@ -1,126 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers.h" -#endif - -#if GOOGLE_PROTOBUF_OBJC_VERSION < 30006 -#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. -#endif -#if 30006 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION -#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. -#endif - -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -CF_EXTERN_C_BEGIN - -@class InputA; -@class InputB; - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark - MainRoot - -/** - * Exposes the extension registry for this file. - * - * The base class provides: - * @code - * + (GPBExtensionRegistry *)extensionRegistry; - * @endcode - * which is a @c GPBExtensionRegistry that includes all the extensions defined by - * this file and all files that it depends on. - **/ -GPB_FINAL @interface MainRoot : GPBRootObject -@end - -#pragma mark - InputA - -typedef GPB_ENUM(InputA_FieldNumber) { - InputA_FieldNumber_TestInputField = 1, -}; - -GPB_FINAL @interface InputA : GPBMessage - -@property(nonatomic, readwrite, copy, null_resettable) NSString *testInputField; - -@end - -#pragma mark - InputB - -typedef GPB_ENUM(InputB_FieldNumber) { - InputB_FieldNumber_TestInputField = 1, -}; - -GPB_FINAL @interface InputB : GPBMessage - -@property(nonatomic, readwrite) uint32_t testInputField; - -@end - -#pragma mark - Input - -typedef GPB_ENUM(Input_FieldNumber) { - Input_FieldNumber_A = 1, - Input_FieldNumber_B = 2, -}; - -typedef GPB_ENUM(Input_Value_OneOfCase) { - Input_Value_OneOfCase_GPBUnsetOneOfCase = 0, - Input_Value_OneOfCase_A = 1, - Input_Value_OneOfCase_B = 2, -}; - -GPB_FINAL @interface Input : GPBMessage - -@property(nonatomic, readonly) Input_Value_OneOfCase valueOneOfCase; - -@property(nonatomic, readwrite, strong, null_resettable) InputA *a; - -@property(nonatomic, readwrite, strong, null_resettable) InputB *b; - -@end - -/** - * Clears whatever value was set for the oneof 'value'. - **/ -void Input_ClearValueOneOfCase(Input *message); - -#pragma mark - Output - -typedef GPB_ENUM(Output_FieldNumber) { - Output_FieldNumber_TestOutputField = 1, - Output_FieldNumber_SecondField = 2, -}; - -GPB_FINAL @interface Output : GPBMessage - -@property(nonatomic, readwrite) int32_t testOutputField; - -@property(nonatomic, readwrite, copy, null_resettable) NSString *secondField; - -@end - -NS_ASSUME_NONNULL_END - -CF_EXTERN_C_END - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.m b/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.m deleted file mode 100644 index 3bdb17df400..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/objc/Main.pbobjc.m +++ /dev/null @@ -1,285 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// clang-format off -// source: main.proto - -// This CPP symbol can be defined to use imports that match up to the framework -// imports needed when using CocoaPods. -#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) - #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 -#endif - -#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS - #import -#else - #import "GPBProtocolBuffers_RuntimeSupport.h" -#endif - -#import "Main.pbobjc.h" -// @@protoc_insertion_point(imports) - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -#pragma clang diagnostic ignored "-Wdirect-ivar-access" -#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension" - -#pragma mark - Objective C Class declarations -// Forward declarations of Objective C classes that we can use as -// static values in struct initializers. -// We don't use [Foo class] because it is not a static value. -GPBObjCClassDeclaration(InputA); -GPBObjCClassDeclaration(InputB); - -#pragma mark - MainRoot - -@implementation MainRoot - -// No extensions in the file and no imports, so no need to generate -// +extensionRegistry. - -@end - -#pragma mark - MainRoot_FileDescriptor - -static GPBFileDescriptor *MainRoot_FileDescriptor(void) { - // This is called by +initialize so there is no need to worry - // about thread safety of the singleton. - static GPBFileDescriptor *descriptor = NULL; - if (!descriptor) { - GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); - descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"" - syntax:GPBFileSyntaxProto3]; - } - return descriptor; -} - -#pragma mark - InputA - -@implementation InputA - -@dynamic testInputField; - -typedef struct InputA__storage_ { - uint32_t _has_storage_[1]; - NSString *testInputField; -} InputA__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputField", - .dataTypeSpecific.clazz = Nil, - .number = InputA_FieldNumber_TestInputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(InputA__storage_, testInputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[InputA class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(InputA__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\016\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - InputB - -@implementation InputB - -@dynamic testInputField; - -typedef struct InputB__storage_ { - uint32_t _has_storage_[1]; - uint32_t testInputField; -} InputB__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testInputField", - .dataTypeSpecific.clazz = Nil, - .number = InputB_FieldNumber_TestInputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(InputB__storage_, testInputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeUInt32, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[InputB class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(InputB__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\001\001\016\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -#pragma mark - Input - -@implementation Input - -@dynamic valueOneOfCase; -@dynamic a; -@dynamic b; - -typedef struct Input__storage_ { - uint32_t _has_storage_[2]; - InputA *a; - InputB *b; -} Input__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "a", - .dataTypeSpecific.clazz = GPBObjCClass(InputA), - .number = Input_FieldNumber_A, - .hasIndex = -1, - .offset = (uint32_t)offsetof(Input__storage_, a), - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - }, - { - .name = "b", - .dataTypeSpecific.clazz = GPBObjCClass(InputB), - .number = Input_FieldNumber_B, - .hasIndex = -1, - .offset = (uint32_t)offsetof(Input__storage_, b), - .flags = GPBFieldOptional, - .dataType = GPBDataTypeMessage, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Input class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Input__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; - static const char *oneofs[] = { - "value", - }; - [localDescriptor setupOneofs:oneofs - count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) - firstHasIndex:-1]; - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - -void Input_ClearValueOneOfCase(Input *message) { - GPBDescriptor *descriptor = [Input descriptor]; - GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; - GPBClearOneof(message, oneof); -} -#pragma mark - Output - -@implementation Output - -@dynamic testOutputField; -@dynamic secondField; - -typedef struct Output__storage_ { - uint32_t _has_storage_[1]; - int32_t testOutputField; - NSString *secondField; -} Output__storage_; - -// This method is threadsafe because it is initially called -// in +initialize for each subclass. -+ (GPBDescriptor *)descriptor { - static GPBDescriptor *descriptor = nil; - if (!descriptor) { - static GPBMessageFieldDescription fields[] = { - { - .name = "testOutputField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_TestOutputField, - .hasIndex = 0, - .offset = (uint32_t)offsetof(Output__storage_, testOutputField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeInt32, - }, - { - .name = "secondField", - .dataTypeSpecific.clazz = Nil, - .number = Output_FieldNumber_SecondField, - .hasIndex = 1, - .offset = (uint32_t)offsetof(Output__storage_, secondField), - .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom | GPBFieldClearHasIvarOnZero), - .dataType = GPBDataTypeString, - }, - }; - GPBDescriptor *localDescriptor = - [GPBDescriptor allocDescriptorForClass:[Output class] - file:MainRoot_FileDescriptor() - fields:fields - fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) - storageSize:sizeof(Output__storage_) - flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown | GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)]; -#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - static const char *extraTextFormatInfo = - "\002\001\017\000\002\013\000"; - [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; -#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS - #if defined(DEBUG) && DEBUG - NSAssert(descriptor == nil, @"Startup recursed!"); - #endif // DEBUG - descriptor = localDescriptor; - } - return descriptor; -} - -@end - - -#pragma clang diagnostic pop - -// @@protoc_insertion_point(global_scope) - -// clang-format on diff --git a/packages/protobuf/test/protoc-out/union/output/php/GPBMetadata/Main.php b/packages/protobuf/test/protoc-out/union/output/php/GPBMetadata/Main.php deleted file mode 100644 index cdd2159e81dc49e8ba1bee3ca6520edef9aa4548..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 729 zcmZ{iL2DZ^5QXCw+hjso*p@c*G;ssjK?X*X;FA-b$Iy!YnQXitBd8v~zlMv5%+RABxW{SBe9+H0;Q=2cmeMXuLINU}r3 z$pU{ZuJC*^zuFI0rz^`T!!;9XSla*;Taz=46V8_7OY*E>o}B=2$(+N>poIT`VVNqI zf}``yhtGj(f+_EcQCs zNw-_Y_yxu8;1s&GD|rtcR=akN`@<&oVk=hjy;mWtt&T6Y#(n7CGFj2!JM3|j9J^q`_TVQ_EvBTV6UfIC%vZUr~a^s$b0qQ^X;%5!Ix&T RPafjMN2ry}yf?4`xCf(5)1UwV diff --git a/packages/protobuf/test/protoc-out/union/output/php/Input.php b/packages/protobuf/test/protoc-out/union/output/php/Input.php deleted file mode 100644 index b79189675b7..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/php/Input.php +++ /dev/null @@ -1,94 +0,0 @@ -Input - */ -class Input extends \Google\Protobuf\Internal\Message -{ - protected $value; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \InputA $a - * @type \InputB $b - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field .InputA a = 1; - * @return \InputA|null - */ - public function getA() - { - return $this->readOneof(1); - } - - public function hasA() - { - return $this->hasOneof(1); - } - - /** - * Generated from protobuf field .InputA a = 1; - * @param \InputA $var - * @return $this - */ - public function setA($var) - { - GPBUtil::checkMessage($var, \InputA::class); - $this->writeOneof(1, $var); - - return $this; - } - - /** - * Generated from protobuf field .InputB b = 2; - * @return \InputB|null - */ - public function getB() - { - return $this->readOneof(2); - } - - public function hasB() - { - return $this->hasOneof(2); - } - - /** - * Generated from protobuf field .InputB b = 2; - * @param \InputB $var - * @return $this - */ - public function setB($var) - { - GPBUtil::checkMessage($var, \InputB::class); - $this->writeOneof(2, $var); - - return $this; - } - - /** - * @return string - */ - public function getValue() - { - return $this->whichOneof("value"); - } - -} - diff --git a/packages/protobuf/test/protoc-out/union/output/php/InputA.php b/packages/protobuf/test/protoc-out/union/output/php/InputA.php deleted file mode 100644 index c325ab1b725..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/php/InputA.php +++ /dev/null @@ -1,56 +0,0 @@ -InputA - */ -class InputA extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field string testInputField = 1; - */ - protected $testInputField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $testInputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field string testInputField = 1; - * @return string - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field string testInputField = 1; - * @param string $var - * @return $this - */ - public function setTestInputField($var) - { - GPBUtil::checkString($var, True); - $this->testInputField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/union/output/php/InputB.php b/packages/protobuf/test/protoc-out/union/output/php/InputB.php deleted file mode 100644 index ed041182348..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/php/InputB.php +++ /dev/null @@ -1,56 +0,0 @@ -InputB - */ -class InputB extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field uint32 testInputField = 1; - */ - protected $testInputField = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $testInputField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field uint32 testInputField = 1; - * @return int - */ - public function getTestInputField() - { - return $this->testInputField; - } - - /** - * Generated from protobuf field uint32 testInputField = 1; - * @param int $var - * @return $this - */ - public function setTestInputField($var) - { - GPBUtil::checkUint32($var); - $this->testInputField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/union/output/php/Output.php b/packages/protobuf/test/protoc-out/union/output/php/Output.php deleted file mode 100644 index 050aef7e894..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/php/Output.php +++ /dev/null @@ -1,83 +0,0 @@ -Output - */ -class Output extends \Google\Protobuf\Internal\Message -{ - /** - * Generated from protobuf field int32 testOutputField = 1; - */ - protected $testOutputField = 0; - /** - * Generated from protobuf field string secondField = 2; - */ - protected $secondField = ''; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int $testOutputField - * @type string $secondField - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Main::initOnce(); - parent::__construct($data); - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @return int - */ - public function getTestOutputField() - { - return $this->testOutputField; - } - - /** - * Generated from protobuf field int32 testOutputField = 1; - * @param int $var - * @return $this - */ - public function setTestOutputField($var) - { - GPBUtil::checkInt32($var); - $this->testOutputField = $var; - - return $this; - } - - /** - * Generated from protobuf field string secondField = 2; - * @return string - */ - public function getSecondField() - { - return $this->secondField; - } - - /** - * Generated from protobuf field string secondField = 2; - * @param string $var - * @return $this - */ - public function setSecondField($var) - { - GPBUtil::checkString($var, True); - $this->secondField = $var; - - return $this; - } - -} - diff --git a/packages/protobuf/test/protoc-out/union/output/pyi/main_pb2.pyi b/packages/protobuf/test/protoc-out/union/output/pyi/main_pb2.pyi deleted file mode 100644 index 41246f5296a..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/pyi/main_pb2.pyi +++ /dev/null @@ -1,33 +0,0 @@ -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union - -DESCRIPTOR: _descriptor.FileDescriptor - -class InputA(_message.Message): - __slots__ = ["testInputField"] - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testInputField: str - def __init__(self, testInputField: _Optional[str] = ...) -> None: ... - -class InputB(_message.Message): - __slots__ = ["testInputField"] - TESTINPUTFIELD_FIELD_NUMBER: _ClassVar[int] - testInputField: int - def __init__(self, testInputField: _Optional[int] = ...) -> None: ... - -class Input(_message.Message): - __slots__ = ["a", "b"] - A_FIELD_NUMBER: _ClassVar[int] - B_FIELD_NUMBER: _ClassVar[int] - a: InputA - b: InputB - def __init__(self, a: _Optional[_Union[InputA, _Mapping]] = ..., b: _Optional[_Union[InputB, _Mapping]] = ...) -> None: ... - -class Output(_message.Message): - __slots__ = ["testOutputField", "secondField"] - TESTOUTPUTFIELD_FIELD_NUMBER: _ClassVar[int] - SECONDFIELD_FIELD_NUMBER: _ClassVar[int] - testOutputField: int - secondField: str - def __init__(self, testOutputField: _Optional[int] = ..., secondField: _Optional[str] = ...) -> None: ... diff --git a/packages/protobuf/test/protoc-out/union/output/python/main_pb2.py b/packages/protobuf/test/protoc-out/union/output/python/main_pb2.py deleted file mode 100644 index f2cb1b8e789..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/python/main_pb2.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto -"""Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nmain.proto\" \n\x06InputA\x12\x16\n\x0etestInputField\x18\x01 \x01(\t\" \n\x06InputB\x12\x16\n\x0etestInputField\x18\x01 \x01(\r\"<\n\x05Input\x12\x14\n\x01\x61\x18\x01 \x01(\x0b\x32\x07.InputAH\x00\x12\x14\n\x01\x62\x18\x02 \x01(\x0b\x32\x07.InputBH\x00\x42\x07\n\x05value\"6\n\x06Output\x12\x17\n\x0ftestOutputField\x18\x01 \x01(\x05\x12\x13\n\x0bsecondField\x18\x02 \x01(\t2!\n\x07Service\x12\x16\n\x03\x46oo\x12\x06.Input\x1a\x07.Outputb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'main_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _globals['_INPUTA']._serialized_start=14 - _globals['_INPUTA']._serialized_end=46 - _globals['_INPUTB']._serialized_start=48 - _globals['_INPUTB']._serialized_end=80 - _globals['_INPUT']._serialized_start=82 - _globals['_INPUT']._serialized_end=142 - _globals['_OUTPUT']._serialized_start=144 - _globals['_OUTPUT']._serialized_end=198 - _globals['_SERVICE']._serialized_start=200 - _globals['_SERVICE']._serialized_end=233 -# @@protoc_insertion_point(module_scope) diff --git a/packages/protobuf/test/protoc-out/union/output/ruby/main_pb.rb b/packages/protobuf/test/protoc-out/union/output/ruby/main_pb.rb deleted file mode 100644 index 3a2f4b5718b..00000000000 --- a/packages/protobuf/test/protoc-out/union/output/ruby/main_pb.rb +++ /dev/null @@ -1,30 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: main.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("main.proto", :syntax => :proto3) do - add_message "InputA" do - optional :testInputField, :string, 1 - end - add_message "InputB" do - optional :testInputField, :uint32, 1 - end - add_message "Input" do - oneof :value do - optional :a, :message, 1, "InputA" - optional :b, :message, 2, "InputB" - end - end - add_message "Output" do - optional :testOutputField, :int32, 1 - optional :secondField, :string, 2 - end - end -end - -InputA = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("InputA").msgclass -InputB = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("InputB").msgclass -Input = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Input").msgclass -Output = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Output").msgclass From 3e73c4254b43d943d82559aa0eb009b4cfa8b9a9 Mon Sep 17 00:00:00 2001 From: Will Date: Tue, 14 Mar 2023 15:05:04 -0400 Subject: [PATCH 27/50] Renamed tests to .tsp --- packages/protobuf/docs/overview.md | 152 ------------------ .../input/{main.cadl => main.tsp} | 0 .../input/{main.cadl => main.tsp} | 0 .../array/input/{main.cadl => main.tsp} | 0 .../input/{main.cadl => main.tsp} | 0 .../input/{main.cadl => main.tsp} | 0 .../enum-nozero/input/{main.cadl => main.tsp} | 0 .../enum/input/{main.cadl => main.tsp} | 0 .../extern/input/{main.cadl => main.tsp} | 0 .../input/{main.cadl => main.tsp} | 0 .../input/{main.cadl => main.tsp} | 0 .../map/input/{main.cadl => main.tsp} | 0 .../input/{main.cadl => main.tsp} | 0 .../input/{main.cadl => main.tsp} | 0 .../input/{main.cadl => main.tsp} | 0 .../simple/input/{main.cadl => main.tsp} | 0 .../streams/input/{main.cadl => main.tsp} | 0 .../input/{main.cadl => main.tsp} | 0 .../union/input/{main.cadl => main.tsp} | 0 19 files changed, 152 deletions(-) delete mode 100644 packages/protobuf/docs/overview.md rename packages/protobuf/test/scenarios/anonymous-package/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/array-nested/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/array/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/cross package references/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/enum-nonintegral/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/enum-nozero/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/enum/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/extern/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/illegal field reservations/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/inferred-message-names/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/map/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/reserved field collisions/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/reserved fields/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/simple-error/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/simple/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/streams/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/type-validation/input/{main.cadl => main.tsp} (100%) rename packages/protobuf/test/scenarios/union/input/{main.cadl => main.tsp} (100%) diff --git a/packages/protobuf/docs/overview.md b/packages/protobuf/docs/overview.md deleted file mode 100644 index 26c20597103..00000000000 --- a/packages/protobuf/docs/overview.md +++ /dev/null @@ -1,152 +0,0 @@ ---- -title: Overview ---- - -# The Protobuf Emitter - -TypeSpec provides an emitter (`@typespec/protobuf`) that generates Protocol Buffers specifications from TypeSpec sources as part of its standard library. The resulting Protobuf files may be used as inputs for creating gRPC services or any other tools compatible with Protocol Buffers. - -**Note**: The Protobuf emitter uses Protocol Buffers 3 (proto3) syntax. Your workflow (`protoc` version, etc.) must support proto3 to utilize this emitter. - -## Install - -In the project root, install the emitter using your JavaScript package manager of choice. For example, using NPM: - -```bash -npm install @typespec/protobuf -``` - -## Installing and enabling - -The `@typespec/protobuf` package provides an emitter that must be enabled in order to generate Protobuf files. Enable it by adding it to your TypeSpec compiler invocation on the CLI or the project configuration file: - -1. Via the CLI - -```bash -typespec compile . --emit @typespec/protobuf -``` - -2. Via the project configuration - -Add the Protobuf emitter to the `emitters` entry (or create one if it does not exist) in `typespec-project.yaml`: - -```yaml -emitters: - @typespec/protobuf: true -``` - -With this configuration entry, Protobuf files will be generated every time the project is compiled using `typespec compile .`. - -## Core concepts - -The Protobuf emitter enables you to write TypeSpec and convert it into equivalent Protocol Buffers for use with Protobuf-enabled systems (such as gRPC). Your TypeSpec models and interfaces must adhere to certain requirements and restrictions in order for the emitter to convert them to Protobuf. - -### Field indices - -Protobuf requires that the offset of each field within a Protobuf message be manually specified. In TypeSpec, the field indices are specified using the [`TypeSpec.Protobuf.field` decorator][protobuf-field]. All fields within a model must have an attached `@field` decorator to be converted into a Protobuf message. - -The following TypeSpec model: - -```typespec -model TestMessage { - @field(1) n: int32 -} -``` - -will be converted into the following Protobuf message: - -```proto3 -message TestMessage { - int32 n = 1; -} -``` - -### Packages - -A protobuf package is defined by the [`TypeSpec.Protobuf.package` decorator][protobuf-package], which applies to a TypeSpec namespace. A package essentially defines a `.proto` file, and everything within the decorated namespace will be emitted to a single file. - -The following TypeSpec namespace results in a Protobuf file named `test.proto` that has the line `package test;` within it. - -```typespec -@package -namespace Test { - // ... -} -``` - -Package names may be explicitly overridden by providing an optional `PackageDetails` item to the `@package` decorator. The following TypeSpec namespace will result in a file `com/example/test.proto` that has the line `package com.example.test;` within it: - -```typespec -@package({ - name: "com.example.test" -}) -namespace Test { - // ... -} -``` - -The TypeSpec program's root namespace is implicitly a package that has no name and will be emitted to `main.proto` if it is not empty. TypeSpec objects (models, enums, etc.) are converted to Protobuf declarations within their nearest ancestor that has a package annotation. As a result, unlike in Protobuf, TypeSpec declarations of packages may be nested arbitrarily. - -### Services - -TypeSpec has a concept of a "service" defined by the [`TypeSpec.service` decorator][native-service], but the Protobuf concept of a "service" is different and is indicated by the [`TypeSpec.Protobuf.service` decorator][protobuf-service]. - -When using the Protobuf emitter, a Protobuf service designation is applied to an _interface_ within a package. For example, the following TypeSpec: - -```typespec -@package -namespace Example { - @Protobuf.service - interface Test { - // ... - } -} -``` - -will yield the following Protobuf file (named `example.proto`): - -```proto3 -syntax = "proto3"; - -package example; - -service Test { - // ... -} -``` - -### Operations - -Within a [service interface](#services), TypeSpec operations represent Protobuf service methods. Each operation in the service interface is converted into an equivalent Protobuf method declaration. - -### Streams - -The Protobuf emitter supports declaring the streaming mode of an operation using the [`TypeSpec.Protobuf.stream` decorator][protobuf-stream]. The streaming mode is specified by the - -## Emitter options - -Emitter options can be provided to the CLI with - -```bash ---option "@typespec/protobuf.=" - -# For example ---option "@typespec/protobuf.noEmit=true" -``` - -or configured through the `typespec-project.yaml` project configuration: - -```yaml -emitters: - '@typespec/protobuf': - : - -# For example -emitters: - '@typespec/protobuf': - noEmit: true -``` - -#### `noEmit` - -If set to `true`, this emitter will not write any files. It will still validate the TypeSpec sources to ensure they are compatible with Protobuf, but the files will simply not be written to the output directory. diff --git a/packages/protobuf/test/scenarios/anonymous-package/input/main.cadl b/packages/protobuf/test/scenarios/anonymous-package/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/anonymous-package/input/main.cadl rename to packages/protobuf/test/scenarios/anonymous-package/input/main.tsp diff --git a/packages/protobuf/test/scenarios/array-nested/input/main.cadl b/packages/protobuf/test/scenarios/array-nested/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/array-nested/input/main.cadl rename to packages/protobuf/test/scenarios/array-nested/input/main.tsp diff --git a/packages/protobuf/test/scenarios/array/input/main.cadl b/packages/protobuf/test/scenarios/array/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/array/input/main.cadl rename to packages/protobuf/test/scenarios/array/input/main.tsp diff --git a/packages/protobuf/test/scenarios/cross package references/input/main.cadl b/packages/protobuf/test/scenarios/cross package references/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/cross package references/input/main.cadl rename to packages/protobuf/test/scenarios/cross package references/input/main.tsp diff --git a/packages/protobuf/test/scenarios/enum-nonintegral/input/main.cadl b/packages/protobuf/test/scenarios/enum-nonintegral/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/enum-nonintegral/input/main.cadl rename to packages/protobuf/test/scenarios/enum-nonintegral/input/main.tsp diff --git a/packages/protobuf/test/scenarios/enum-nozero/input/main.cadl b/packages/protobuf/test/scenarios/enum-nozero/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/enum-nozero/input/main.cadl rename to packages/protobuf/test/scenarios/enum-nozero/input/main.tsp diff --git a/packages/protobuf/test/scenarios/enum/input/main.cadl b/packages/protobuf/test/scenarios/enum/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/enum/input/main.cadl rename to packages/protobuf/test/scenarios/enum/input/main.tsp diff --git a/packages/protobuf/test/scenarios/extern/input/main.cadl b/packages/protobuf/test/scenarios/extern/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/extern/input/main.cadl rename to packages/protobuf/test/scenarios/extern/input/main.tsp diff --git a/packages/protobuf/test/scenarios/illegal field reservations/input/main.cadl b/packages/protobuf/test/scenarios/illegal field reservations/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/illegal field reservations/input/main.cadl rename to packages/protobuf/test/scenarios/illegal field reservations/input/main.tsp diff --git a/packages/protobuf/test/scenarios/inferred-message-names/input/main.cadl b/packages/protobuf/test/scenarios/inferred-message-names/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/inferred-message-names/input/main.cadl rename to packages/protobuf/test/scenarios/inferred-message-names/input/main.tsp diff --git a/packages/protobuf/test/scenarios/map/input/main.cadl b/packages/protobuf/test/scenarios/map/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/map/input/main.cadl rename to packages/protobuf/test/scenarios/map/input/main.tsp diff --git a/packages/protobuf/test/scenarios/reserved field collisions/input/main.cadl b/packages/protobuf/test/scenarios/reserved field collisions/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/reserved field collisions/input/main.cadl rename to packages/protobuf/test/scenarios/reserved field collisions/input/main.tsp diff --git a/packages/protobuf/test/scenarios/reserved fields/input/main.cadl b/packages/protobuf/test/scenarios/reserved fields/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/reserved fields/input/main.cadl rename to packages/protobuf/test/scenarios/reserved fields/input/main.tsp diff --git a/packages/protobuf/test/scenarios/simple-error/input/main.cadl b/packages/protobuf/test/scenarios/simple-error/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/simple-error/input/main.cadl rename to packages/protobuf/test/scenarios/simple-error/input/main.tsp diff --git a/packages/protobuf/test/scenarios/simple/input/main.cadl b/packages/protobuf/test/scenarios/simple/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/simple/input/main.cadl rename to packages/protobuf/test/scenarios/simple/input/main.tsp diff --git a/packages/protobuf/test/scenarios/streams/input/main.cadl b/packages/protobuf/test/scenarios/streams/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/streams/input/main.cadl rename to packages/protobuf/test/scenarios/streams/input/main.tsp diff --git a/packages/protobuf/test/scenarios/type-validation/input/main.cadl b/packages/protobuf/test/scenarios/type-validation/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/type-validation/input/main.cadl rename to packages/protobuf/test/scenarios/type-validation/input/main.tsp diff --git a/packages/protobuf/test/scenarios/union/input/main.cadl b/packages/protobuf/test/scenarios/union/input/main.tsp similarity index 100% rename from packages/protobuf/test/scenarios/union/input/main.cadl rename to packages/protobuf/test/scenarios/union/input/main.tsp From 166cda9ebef38af32a94af4abbc652372d92dd4a Mon Sep 17 00:00:00 2001 From: Will Date: Wed, 15 Mar 2023 13:44:07 -0400 Subject: [PATCH 28/50] Updated diagnostics and some documentation --- packages/protobuf/lib/proto.tsp | 10 +++ packages/protobuf/src/proto.ts | 2 +- .../src/{transform.ts => transform/index.ts} | 64 +++++++++++-------- .../protobuf/main.proto | 0 .../scenarios/array-nested/diagnostics.txt | 2 +- .../protobuf/com/azure/test.proto | 0 .../protobuf/A.proto | 0 .../protobuf/B.proto | 0 .../enum-nonintegral/diagnostics.txt | 4 +- .../scenarios/enum-nozero/diagnostics.txt | 2 +- .../protobuf/main.proto | 0 .../protobuf/main.proto | 0 .../diagnostics.txt | 4 +- .../protobuf/com/azure/test.proto | 0 .../protobuf/main.proto | 0 .../reserved field collisions/diagnostics.txt | 2 +- .../protobuf/main.proto | 0 .../scenarios/simple-error/diagnostics.txt | 6 +- .../protobuf/com/azure/Test.proto | 0 .../protobuf/main.proto | 0 .../scenarios/type-validation/diagnostics.txt | 2 +- .../test/scenarios/union/diagnostics.txt | 2 + .../output/@cadl-lang/protobuf/main.proto | 27 -------- 23 files changed, 62 insertions(+), 65 deletions(-) rename packages/protobuf/src/{transform.ts => transform/index.ts} (92%) rename packages/protobuf/test/scenarios/anonymous-package/output/{@cadl-lang => @typespec}/protobuf/main.proto (100%) rename packages/protobuf/test/scenarios/array/output/{@cadl-lang => @typespec}/protobuf/com/azure/test.proto (100%) rename packages/protobuf/test/scenarios/cross package references/output/{@cadl-lang => @typespec}/protobuf/A.proto (100%) rename packages/protobuf/test/scenarios/cross package references/output/{@cadl-lang => @typespec}/protobuf/B.proto (100%) rename packages/protobuf/test/scenarios/enum/output/{@cadl-lang => @typespec}/protobuf/main.proto (100%) rename packages/protobuf/test/scenarios/extern/output/{@cadl-lang => @typespec}/protobuf/main.proto (100%) rename packages/protobuf/test/scenarios/inferred-message-names/output/{@cadl-lang => @typespec}/protobuf/com/azure/test.proto (100%) rename packages/protobuf/test/scenarios/map/output/{@cadl-lang => @typespec}/protobuf/main.proto (100%) rename packages/protobuf/test/scenarios/reserved fields/output/{@cadl-lang => @typespec}/protobuf/main.proto (100%) rename packages/protobuf/test/scenarios/simple/output/{@cadl-lang => @typespec}/protobuf/com/azure/Test.proto (100%) rename packages/protobuf/test/scenarios/streams/output/{@cadl-lang => @typespec}/protobuf/main.proto (100%) create mode 100644 packages/protobuf/test/scenarios/union/diagnostics.txt delete mode 100644 packages/protobuf/test/scenarios/union/output/@cadl-lang/protobuf/main.proto diff --git a/packages/protobuf/lib/proto.tsp b/packages/protobuf/lib/proto.tsp index 54d3b11cf0a..6180875ea88 100644 --- a/packages/protobuf/lib/proto.tsp +++ b/packages/protobuf/lib/proto.tsp @@ -1,5 +1,8 @@ import "../dist/src/proto.js"; +/** + * Documentation? + */ namespace TypeSpec.Protobuf; /** @@ -50,6 +53,13 @@ namespace WellKnown { * This model references `google.protobuf.Timestamp` from `google/protobuf/timestamp.proto`. */ model Timestamp is Extern<"google/protobuf/timestamp.proto", "google.protobuf.Timestamp">; + + /** + * Any value. + * + * This model references `google.protobuf.Any` from `google/protobuf/any.proto`. + */ + model Any is Extern<"google/protobuf/any.proto", "google.protobuf.Any">; } /** diff --git a/packages/protobuf/src/proto.ts b/packages/protobuf/src/proto.ts index cf34cd70d05..cacd3e8b31f 100644 --- a/packages/protobuf/src/proto.ts +++ b/packages/protobuf/src/proto.ts @@ -20,7 +20,7 @@ import { import { StreamingMode } from "./ast.js"; import { ProtobufEmitterOptions, reportDiagnostic, state, TypeSpecProtobufLibrary } from "./lib.js"; -import { createProtobufEmitter } from "./transform.js"; +import { createProtobufEmitter } from "./transform/index.js"; /** * # @typespec/protobuf : Protobuf/gRPC Emitter and Decorators for TypeSpec diff --git a/packages/protobuf/src/transform.ts b/packages/protobuf/src/transform/index.ts similarity index 92% rename from packages/protobuf/src/transform.ts rename to packages/protobuf/src/transform/index.ts index 4878c6e2d60..02a85e2e386 100644 --- a/packages/protobuf/src/transform.ts +++ b/packages/protobuf/src/transform/index.ts @@ -41,13 +41,13 @@ import { ScalarIntegralName, StreamingMode, unreachable, -} from "./ast.js"; -import { ProtobufEmitterOptions, reportDiagnostic, state } from "./lib.js"; -import { $field, isMap, Reservation } from "./proto.js"; -import { writeProtoFile } from "./write.js"; +} from "../ast.js"; +import { ProtobufEmitterOptions, reportDiagnostic, state } from "../lib.js"; +import { $field, isMap, Reservation } from "../proto.js"; +import { writeProtoFile } from "../write.js"; // Cache for scalar -> ProtoScalar map -let _protoScalarsMap: Map; +let _protoScalarsMap = new WeakMap>(); /** * Create a worker function that converts the TypeSpec program to Protobuf and writes it to the file system. @@ -434,28 +434,40 @@ function tspToProto(program: Program): ProtoFile[] { } function getProtoScalarsMap(program: Program): Map { + // The type references are different object identities in different programs, so we need to cache the map per program. + // This really only affects tests in our current use case, but someone could be using the compiler API to compile + // multiple programs and it also affects that. + let scalarMap; + if (_protoScalarsMap.has(program)) { + scalarMap = _protoScalarsMap.get(program)!; + } else { + scalarMap = new Map( + ( + [ + [program.resolveTypeReference("TypeSpec.bytes"), scalar("bytes")], + [program.resolveTypeReference("TypeSpec.boolean"), scalar("bool")], + [program.resolveTypeReference("TypeSpec.string"), scalar("string")], + [program.resolveTypeReference("TypeSpec.int32"), scalar("int32")], + [program.resolveTypeReference("TypeSpec.int64"), scalar("int64")], + [program.resolveTypeReference("TypeSpec.uint32"), scalar("uint32")], + [program.resolveTypeReference("TypeSpec.uint64"), scalar("uint64")], + [program.resolveTypeReference("TypeSpec.float32"), scalar("float")], + [program.resolveTypeReference("TypeSpec.float64"), scalar("double")], + [program.resolveTypeReference("TypeSpec.Protobuf.sfixed32"), scalar("sfixed32")], + [program.resolveTypeReference("TypeSpec.Protobuf.sfixed64"), scalar("sfixed64")], + [program.resolveTypeReference("TypeSpec.Protobuf.sint32"), scalar("sint32")], + [program.resolveTypeReference("TypeSpec.Protobuf.sint64"), scalar("sint64")], + [program.resolveTypeReference("TypeSpec.Protobuf.fixed32"), scalar("fixed32")], + [program.resolveTypeReference("TypeSpec.Protobuf.fixed64"), scalar("fixed64")], + ] as [[Type, unknown], ProtoScalar][] + ).map(([[type], scalar]) => [type, scalar]) + ); + + _protoScalarsMap.set(program, scalarMap); + } // Lazy initialize this map of known proto scalars. - return (_protoScalarsMap ??= new Map( - ( - [ - [program.resolveTypeReference("TypeSpec.bytes"), scalar("bytes")], - [program.resolveTypeReference("TypeSpec.boolean"), scalar("bool")], - [program.resolveTypeReference("TypeSpec.string"), scalar("string")], - [program.resolveTypeReference("TypeSpec.int32"), scalar("int32")], - [program.resolveTypeReference("TypeSpec.int64"), scalar("int64")], - [program.resolveTypeReference("TypeSpec.uint32"), scalar("uint32")], - [program.resolveTypeReference("TypeSpec.uint64"), scalar("uint64")], - [program.resolveTypeReference("TypeSpec.float32"), scalar("float")], - [program.resolveTypeReference("TypeSpec.float64"), scalar("double")], - [program.resolveTypeReference("TypeSpec.Protobuf.sfixed32"), scalar("sfixed32")], - [program.resolveTypeReference("TypeSpec.Protobuf.sfixed64"), scalar("sfixed64")], - [program.resolveTypeReference("TypeSpec.Protobuf.sint32"), scalar("sint32")], - [program.resolveTypeReference("TypeSpec.Protobuf.sint64"), scalar("sint64")], - [program.resolveTypeReference("TypeSpec.Protobuf.fixed32"), scalar("fixed32")], - [program.resolveTypeReference("TypeSpec.Protobuf.fixed64"), scalar("fixed64")], - ] as [[Type, unknown], ProtoScalar][] - ).map(([[type], scalar]) => [type, scalar]) - )); + + return scalarMap; } function scalarToProto(t: Scalar): ProtoType { diff --git a/packages/protobuf/test/scenarios/anonymous-package/output/@cadl-lang/protobuf/main.proto b/packages/protobuf/test/scenarios/anonymous-package/output/@typespec/protobuf/main.proto similarity index 100% rename from packages/protobuf/test/scenarios/anonymous-package/output/@cadl-lang/protobuf/main.proto rename to packages/protobuf/test/scenarios/anonymous-package/output/@typespec/protobuf/main.proto diff --git a/packages/protobuf/test/scenarios/array-nested/diagnostics.txt b/packages/protobuf/test/scenarios/array-nested/diagnostics.txt index 4ac0a37e4b7..4cf543a00ed 100644 --- a/packages/protobuf/test/scenarios/array-nested/diagnostics.txt +++ b/packages/protobuf/test/scenarios/array-nested/diagnostics.txt @@ -1 +1 @@ -/test/.typespec/lib/lib.tsp:116:1 - error @typespec/protobuf/nested-array: nested arrays are not supported by the Protobuf emitter +/test/.tsp/lib/lib.tsp:116:1 - error @typespec/protobuf/nested-array: nested arrays are not supported by the Protobuf emitter \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/array/output/@cadl-lang/protobuf/com/azure/test.proto b/packages/protobuf/test/scenarios/array/output/@typespec/protobuf/com/azure/test.proto similarity index 100% rename from packages/protobuf/test/scenarios/array/output/@cadl-lang/protobuf/com/azure/test.proto rename to packages/protobuf/test/scenarios/array/output/@typespec/protobuf/com/azure/test.proto diff --git a/packages/protobuf/test/scenarios/cross package references/output/@cadl-lang/protobuf/A.proto b/packages/protobuf/test/scenarios/cross package references/output/@typespec/protobuf/A.proto similarity index 100% rename from packages/protobuf/test/scenarios/cross package references/output/@cadl-lang/protobuf/A.proto rename to packages/protobuf/test/scenarios/cross package references/output/@typespec/protobuf/A.proto diff --git a/packages/protobuf/test/scenarios/cross package references/output/@cadl-lang/protobuf/B.proto b/packages/protobuf/test/scenarios/cross package references/output/@typespec/protobuf/B.proto similarity index 100% rename from packages/protobuf/test/scenarios/cross package references/output/@cadl-lang/protobuf/B.proto rename to packages/protobuf/test/scenarios/cross package references/output/@typespec/protobuf/B.proto diff --git a/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt b/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt index 327989959cd..4875ee98567 100644 --- a/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt +++ b/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt @@ -1,4 +1,4 @@ /test/main.tsp:18:1 - error @typespec/protobuf/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a Protobuf message -/test/main.tsp:19:3 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message +/test/main.tsp:19:8 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message /test/main.tsp:23:1 - error @typespec/protobuf/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a Protobuf message -/test/main.tsp:24:3 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message +/test/main.tsp:24:3 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt b/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt index e4f6b67f2b3..d0152855203 100644 --- a/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt +++ b/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt @@ -1 +1 @@ -/test/main.tsp:19:3 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message +/test/main.tsp:19:8 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/enum/output/@cadl-lang/protobuf/main.proto b/packages/protobuf/test/scenarios/enum/output/@typespec/protobuf/main.proto similarity index 100% rename from packages/protobuf/test/scenarios/enum/output/@cadl-lang/protobuf/main.proto rename to packages/protobuf/test/scenarios/enum/output/@typespec/protobuf/main.proto diff --git a/packages/protobuf/test/scenarios/extern/output/@cadl-lang/protobuf/main.proto b/packages/protobuf/test/scenarios/extern/output/@typespec/protobuf/main.proto similarity index 100% rename from packages/protobuf/test/scenarios/extern/output/@cadl-lang/protobuf/main.proto rename to packages/protobuf/test/scenarios/extern/output/@typespec/protobuf/main.proto diff --git a/packages/protobuf/test/scenarios/illegal field reservations/diagnostics.txt b/packages/protobuf/test/scenarios/illegal field reservations/diagnostics.txt index 66af7dba769..da65b9cb4e5 100644 --- a/packages/protobuf/test/scenarios/illegal field reservations/diagnostics.txt +++ b/packages/protobuf/test/scenarios/illegal field reservations/diagnostics.txt @@ -1,2 +1,2 @@ -/test/.typespec/lib/lib.tsp:81:1 - error @typespec/protobuf/illegal-reservation: reservation value must be a string literal, uint32 literal, or a tuple of two uint32 literals denoting a range -/test/.typespec/lib/lib.tsp:51:1 - error @typespec/protobuf/illegal-reservation: reservation value must be a string literal, uint32 literal, or a tuple of two uint32 literals denoting a range +/test/.tsp/lib/lib.tsp:81:1 - error @typespec/protobuf/illegal-reservation: reservation value must be a string literal, uint32 literal, or a tuple of two uint32 literals denoting a range +/test/.tsp/lib/lib.tsp:51:1 - error @typespec/protobuf/illegal-reservation: reservation value must be a string literal, uint32 literal, or a tuple of two uint32 literals denoting a range \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/inferred-message-names/output/@cadl-lang/protobuf/com/azure/test.proto b/packages/protobuf/test/scenarios/inferred-message-names/output/@typespec/protobuf/com/azure/test.proto similarity index 100% rename from packages/protobuf/test/scenarios/inferred-message-names/output/@cadl-lang/protobuf/com/azure/test.proto rename to packages/protobuf/test/scenarios/inferred-message-names/output/@typespec/protobuf/com/azure/test.proto diff --git a/packages/protobuf/test/scenarios/map/output/@cadl-lang/protobuf/main.proto b/packages/protobuf/test/scenarios/map/output/@typespec/protobuf/main.proto similarity index 100% rename from packages/protobuf/test/scenarios/map/output/@cadl-lang/protobuf/main.proto rename to packages/protobuf/test/scenarios/map/output/@typespec/protobuf/main.proto diff --git a/packages/protobuf/test/scenarios/reserved field collisions/diagnostics.txt b/packages/protobuf/test/scenarios/reserved field collisions/diagnostics.txt index c609a427259..d133a9c75f1 100644 --- a/packages/protobuf/test/scenarios/reserved field collisions/diagnostics.txt +++ b/packages/protobuf/test/scenarios/reserved field collisions/diagnostics.txt @@ -2,4 +2,4 @@ /test/main.tsp:16:10 - error @typespec/protobuf/field-index: field index 2 was reserved by a call to @reserve on this model /test/main.tsp:17:10 - error @typespec/protobuf/field-index: field index 9 falls within a range reserved by a call to @reserve on this model /test/main.tsp:18:10 - error @typespec/protobuf/field-index: field index 11 falls within a range reserved by a call to @reserve on this model -/test/main.tsp:18:14 - error @typespec/protobuf/field-name: field name 'bar' was reserved by a call to @reserve on this model +/test/main.tsp:18:14 - error @typespec/protobuf/field-name: field name 'bar' was reserved by a call to @reserve on this model \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/reserved fields/output/@cadl-lang/protobuf/main.proto b/packages/protobuf/test/scenarios/reserved fields/output/@typespec/protobuf/main.proto similarity index 100% rename from packages/protobuf/test/scenarios/reserved fields/output/@cadl-lang/protobuf/main.proto rename to packages/protobuf/test/scenarios/reserved fields/output/@typespec/protobuf/main.proto diff --git a/packages/protobuf/test/scenarios/simple-error/diagnostics.txt b/packages/protobuf/test/scenarios/simple-error/diagnostics.txt index 7c39259481f..a7780a68d7b 100644 --- a/packages/protobuf/test/scenarios/simple-error/diagnostics.txt +++ b/packages/protobuf/test/scenarios/simple-error/diagnostics.txt @@ -1,5 +1,5 @@ /test/main.tsp:12:5 - error @typespec/protobuf/field-index: field index 0 is invalid (must be an integer greater than zero) /test/main.tsp:13:5 - error @typespec/protobuf/field-index: field index 536870912 is out of bounds (must be less than 536870912) -/test/main.tsp:14:5 - error @typespec/protobuf/field-index: field index 19000 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) -/test/main.tsp:15:5 - error @typespec/protobuf/field-index: field index 19123 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) -/test/main.tsp:16:5 - error @typespec/protobuf/field-index: field index 19999 falls within the implementation-reserved range of 19000-19999 (try an index value of 20,000 or higher) +/test/main.tsp:14:5 - error @typespec/protobuf/field-index: field index 19000 falls within the implementation-reserved range of 19000-19999 inclusive +/test/main.tsp:15:5 - error @typespec/protobuf/field-index: field index 19123 falls within the implementation-reserved range of 19000-19999 inclusive +/test/main.tsp:16:5 - error @typespec/protobuf/field-index: field index 19999 falls within the implementation-reserved range of 19000-19999 inclusive \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/simple/output/@cadl-lang/protobuf/com/azure/Test.proto b/packages/protobuf/test/scenarios/simple/output/@typespec/protobuf/com/azure/Test.proto similarity index 100% rename from packages/protobuf/test/scenarios/simple/output/@cadl-lang/protobuf/com/azure/Test.proto rename to packages/protobuf/test/scenarios/simple/output/@typespec/protobuf/com/azure/Test.proto diff --git a/packages/protobuf/test/scenarios/streams/output/@cadl-lang/protobuf/main.proto b/packages/protobuf/test/scenarios/streams/output/@typespec/protobuf/main.proto similarity index 100% rename from packages/protobuf/test/scenarios/streams/output/@cadl-lang/protobuf/main.proto rename to packages/protobuf/test/scenarios/streams/output/@typespec/protobuf/main.proto diff --git a/packages/protobuf/test/scenarios/type-validation/diagnostics.txt b/packages/protobuf/test/scenarios/type-validation/diagnostics.txt index 9a71ad71233..7fdfc7c127d 100644 --- a/packages/protobuf/test/scenarios/type-validation/diagnostics.txt +++ b/packages/protobuf/test/scenarios/type-validation/diagnostics.txt @@ -1 +1 @@ -/test/main.tsp:10:3 - error @typespec/protobuf/unsupported-return-type: Protobuf methods must return a named Model +/test/main.tsp:10:20 - error @typespec/protobuf/unsupported-return-type: Protobuf methods must return a named Model \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/union/diagnostics.txt b/packages/protobuf/test/scenarios/union/diagnostics.txt new file mode 100644 index 00000000000..c489aaba557 --- /dev/null +++ b/packages/protobuf/test/scenarios/union/diagnostics.txt @@ -0,0 +1,2 @@ +/test/main.tsp:22:3 - error decorator-wrong-target: Cannot apply @field decorator to Test.InputA since it is not assignable to TypeSpec.Reflection.ModelProperty +/test/main.tsp:24:3 - error decorator-wrong-target: Cannot apply @field decorator to Test.InputB since it is not assignable to TypeSpec.Reflection.ModelProperty \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/union/output/@cadl-lang/protobuf/main.proto b/packages/protobuf/test/scenarios/union/output/@cadl-lang/protobuf/main.proto deleted file mode 100644 index 4b2f7858d10..00000000000 --- a/packages/protobuf/test/scenarios/union/output/@cadl-lang/protobuf/main.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* Generated by Microsoft TypeSpec */ - -syntax = "proto3"; - -message InputA { - string testInputField = 1; -} - -message InputB { - uint32 testInputField = 1; -} - -message Input { - oneof value { - InputA a = 1; - InputB b = 2; - } -} - -message Output { - int32 testOutputField = 1; - string secondField = 2; -} - -service Service { - rpc Foo(Input) returns (Output); -} From 6d696a40392b76d39e034dbf652cc4be211fa290 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 16 Mar 2023 08:44:42 -0400 Subject: [PATCH 29/50] Updated entrypoint from typespecMain to tspMain --- packages/protobuf/lib/proto.tsp | 3 --- packages/protobuf/package.json | 2 +- packages/protobuf/src/lib.ts | 3 +-- packages/protobuf/src/transform/index.ts | 3 --- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/protobuf/lib/proto.tsp b/packages/protobuf/lib/proto.tsp index 6180875ea88..89812a608d3 100644 --- a/packages/protobuf/lib/proto.tsp +++ b/packages/protobuf/lib/proto.tsp @@ -1,8 +1,5 @@ import "../dist/src/proto.js"; -/** - * Documentation? - */ namespace TypeSpec.Protobuf; /** diff --git a/packages/protobuf/package.json b/packages/protobuf/package.json index f521f81bc08..e6a5fa8e099 100644 --- a/packages/protobuf/package.json +++ b/packages/protobuf/package.json @@ -20,7 +20,7 @@ ], "main": "dist/src/lib.js", "type": "module", - "typespecMain": "lib/proto.tsp", + "tspMain": "lib/proto.tsp", "scripts": { "clean": "rimraf ./dist ./temp", "build": "tsc -p .", diff --git a/packages/protobuf/src/lib.ts b/packages/protobuf/src/lib.ts index d4da9eea4c2..debcb4faf62 100644 --- a/packages/protobuf/src/lib.ts +++ b/packages/protobuf/src/lib.ts @@ -123,7 +123,6 @@ export const TypeSpecProtobufLibrary = createTypeSpecLibrary({ export const { reportDiagnostic } = TypeSpecProtobufLibrary; -// TODO: onValidate? export { $onEmit } from "./proto.js"; export type TypeSpecProtobufLibrary = typeof TypeSpecProtobufLibrary; @@ -133,5 +132,5 @@ const keys = ["fieldIndex", "package", "service", "externRef", "stream", "reserv export const state = Object.fromEntries( keys.map((k) => [k, Symbol(`@typespec/protobuf.${k}`)]) ) as { - [K in typeof keys[number]]: symbol; + [K in (typeof keys)[number]]: symbol; }; diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index 02a85e2e386..48db761249c 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -310,7 +310,6 @@ function tspToProto(program: Program): ProtoFile[] { } /* eslint-ignore-next-line no-fallthrough */ default: - // TODO: logic is duplicated in addReturnModel reportDiagnostic(program, { code: "unsupported-return-type", target: getOperationReturnSyntaxTarget(operation), @@ -586,8 +585,6 @@ function tspToProto(program: Program): ProtoFile[] { return oneof; } - // TODO: all fields must have an index. - // TODO: validate that the type is OK _before_ calling addImportSourceForProtoIfNeeded const fieldIndex = program.stateMap(state.fieldIndex).get(property) as number | undefined; const fieldIndexNode = property.decorators.find((d) => d.decorator === $field)?.args[0].node; From cdf59a6bb60719c889558c4e706037ab002b1f9a Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 16 Mar 2023 08:45:00 -0400 Subject: [PATCH 30/50] Updated docs --- docs/standard-library/protobuf/overview.md | 80 ++++++++++++++++------ 1 file changed, 58 insertions(+), 22 deletions(-) diff --git a/docs/standard-library/protobuf/overview.md b/docs/standard-library/protobuf/overview.md index 178bda9f17b..76dc5260782 100644 --- a/docs/standard-library/protobuf/overview.md +++ b/docs/standard-library/protobuf/overview.md @@ -41,26 +41,6 @@ With this configuration entry, Protobuf files will be generated every time the p The Protobuf emitter enables you to write TypeSpec and convert it into equivalent Protocol Buffers for use with Protobuf-enabled systems (such as gRPC). Your TypeSpec models and interfaces must adhere to certain requirements and restrictions in order for the emitter to convert them to Protobuf. -### Field indices - -Protobuf requires that the offset of each field within a Protobuf message be manually specified. In TypeSpec, the field indices are specified using the [`TypeSpec.Protobuf.field` decorator][protobuf-field]. All fields within a model must have an attached `@field` decorator to be converted into a Protobuf message. - -The following TypeSpec model: - -```typespec -model TestMessage { - @field(1) n: int32; -} -``` - -will be converted into the following Protobuf message: - -```proto3 -message TestMessage { - int32 n = 1; -} -``` - ### Packages A protobuf package is defined by the [`TypeSpec.Protobuf.package` decorator][protobuf-package], which applies to a TypeSpec namespace. A package essentially defines a `.proto` file, and everything within the decorated namespace will be emitted to a single file. @@ -117,13 +97,69 @@ service Test { } ``` +### Field indices + +Protobuf requires that the offset of each field within a Protobuf message be manually specified. In TypeSpec, the field indices are specified using the [`TypeSpec.Protobuf.field` decorator][protobuf-field]. All fields within a model must have an attached `@field` decorator to be converted into a Protobuf message. + +The following TypeSpec model: + +```typespec +model TestMessage { + @field(1) n: int32; +} +``` + +will be converted into the following Protobuf message: + +```proto3 +message TestMessage { + int32 n = 1; +} +``` + ### Operations -Within a [service interface](#services), TypeSpec operations represent Protobuf service methods. Each operation in the service interface is converted into an equivalent Protobuf method declaration. +Within a [service interface](#services), TypeSpec operations represent Protobuf service methods. Each operation in the service interface is converted into an equivalent Protobuf method declaration. For example, the following specification: + +```typespec +model Input { + @field(1) exampleField: string; +} + +model Output { + @field(1) parsed: uint32; +} + +@Protobuf.service +interface Example { + testOperation(...Input): Output; +} +``` + +Results in the following `.proto` file: + +```proto3 +message Input { + string exampleField = 1; +} + +message Output { + uint32 parsed = 1; +} + +service Example { + rpc TestOperation(Input) returns (Output); +} +``` ### Streams -The Protobuf emitter supports declaring the streaming mode of an operation using the [`TypeSpec.Protobuf.stream` decorator][protobuf-stream]. The streaming mode is specified by the +The Protobuf emitter supports declaring the streaming mode of an operation using the [`TypeSpec.Protobuf.stream` decorator][protobuf-stream]. The streaming mode is specified using the [`StreamMode`][protobuf-stream-mode] enum. An operation can have one of four streaming modes: + +- `None`: this is the default mode and indicates that neither the request nor response are streamed (`rpc Example(In) returns (Out);`). +- `In`: indicates that the request is streamed, but the response is received synchronously (`rpc Example(stream In) returns (Out);`). +- `Out`: indicates that the request is sent synchronously, but the response is streamed (`rpc Example(In) returns (stream Out);`). +- `Duplex`: indicates that both the request and response are streamed (`rpc Example(stream In) returns (stream Out);`). ## Emitter options From 8dcd5f08ae0a98beaf1f9f26deae06a4c0565ef6 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 16 Mar 2023 09:04:41 -0400 Subject: [PATCH 31/50] Lint/spell fixes --- cspell.yaml | 5 ++- packages/protobuf/src/transform/index.ts | 47 ++++++++++++------------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/cspell.yaml b/cspell.yaml index 92fce3962e8..e3216275144 100644 --- a/cspell.yaml +++ b/cspell.yaml @@ -25,8 +25,10 @@ words: - globby - inmemory - instanceid + - interner - intrinsics - jsyaml + - keyer - lzutf - msbuild - MSRC @@ -49,6 +51,7 @@ words: - rushx - safeint - segmentof + - sfixed - strs - TRYIT - TSES @@ -64,8 +67,6 @@ words: - vswhere - westus - xplat - - keyer - - interner ignorePaths: - "**/node_modules/**" - "**/dist/**" diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index 48db761249c..239d2a99a60 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -4,7 +4,6 @@ import { DiagnosticTarget, Enum, - EnumMember, getEffectiveModelType, getTypeName, Interface, @@ -47,7 +46,7 @@ import { $field, isMap, Reservation } from "../proto.js"; import { writeProtoFile } from "../write.js"; // Cache for scalar -> ProtoScalar map -let _protoScalarsMap = new WeakMap>(); +const _protoScalarsMap = new WeakMap>(); /** * Create a worker function that converts the TypeSpec program to Protobuf and writes it to the file system. @@ -136,7 +135,7 @@ function tspToProto(program: Program): ProtoFile[] { // we also only support enums where the first value is zero. if (members[0].value !== 0) { reportDiagnostic(program, { - target: getMemberTypeSyntaxTarget(members[0]), + target: members[0], code: "unconvertible-enum", messageId: "no-zero-first", }); @@ -845,26 +844,28 @@ function getOperationReturnSyntaxTarget(op: Operation): DiagnosticTarget { /** * Gets the syntactic type position for a model or enum field. */ -function getMemberTypeSyntaxTarget(property: ModelProperty | EnumMember): DiagnosticTarget { - const node = property.node; - - switch (node.kind) { - case SyntaxKind.ModelProperty: - return node.value; - case SyntaxKind.ModelSpreadProperty: - return node; - case SyntaxKind.EnumMember: - return node.value ?? node; - case SyntaxKind.ProjectionModelProperty: - case SyntaxKind.ProjectionModelSpreadProperty: - return property; - default: - const __exhaust: never = node; - throw new Error( - `Internal Emitter Error: reached unreachable member node: ${property.node.kind}` - ); - } -} +// This function was used to get the syntactic position for enum members, and it's still here in case we want to use it +// for model properties. +// function getMemberTypeSyntaxTarget(property: ModelProperty | EnumMember): DiagnosticTarget { +// const node = property.node; + +// switch (node.kind) { +// case SyntaxKind.ModelProperty: +// return node.value; +// case SyntaxKind.ModelSpreadProperty: +// return node; +// case SyntaxKind.EnumMember: +// return node.value ?? node; +// case SyntaxKind.ProjectionModelProperty: +// case SyntaxKind.ProjectionModelSpreadProperty: +// return property; +// default: +// const __exhaust: never = node; +// throw new Error( +// `Internal Emitter Error: reached unreachable member node: ${property.node.kind}` +// ); +// } +// } /** * Gets the syntactic position of a model property name. From 5eb3f0899fdcf4a0c8ca8e06132f3cd6b9755da4 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 16 Mar 2023 09:10:06 -0400 Subject: [PATCH 32/50] Updated enum error messages --- .../protobuf/test/scenarios/enum-nonintegral/diagnostics.txt | 2 +- packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt b/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt index 4875ee98567..b021264163c 100644 --- a/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt +++ b/packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt @@ -1,4 +1,4 @@ /test/main.tsp:18:1 - error @typespec/protobuf/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a Protobuf message -/test/main.tsp:19:8 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message +/test/main.tsp:19:3 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message /test/main.tsp:23:1 - error @typespec/protobuf/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a Protobuf message /test/main.tsp:24:3 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt b/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt index d0152855203..0ccdc9734ef 100644 --- a/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt +++ b/packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt @@ -1 +1 @@ -/test/main.tsp:19:8 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message \ No newline at end of file +/test/main.tsp:19:3 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message \ No newline at end of file From b8123cc857ec502f9f5fbda47fea3b3365ac8842 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 16 Mar 2023 09:24:35 -0400 Subject: [PATCH 33/50] Improved namespace handling --- docs/standard-library/protobuf/overview.md | 6 ++-- packages/protobuf/src/lib.ts | 6 ++++ packages/protobuf/src/transform/index.ts | 28 ++++++++++--------- .../model-no-package/diagnostics.txt | 2 ++ .../scenarios/model-no-package/input/main.tsp | 19 +++++++++++++ 5 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 packages/protobuf/test/scenarios/model-no-package/diagnostics.txt create mode 100644 packages/protobuf/test/scenarios/model-no-package/input/main.tsp diff --git a/docs/standard-library/protobuf/overview.md b/docs/standard-library/protobuf/overview.md index 76dc5260782..9d19292194e 100644 --- a/docs/standard-library/protobuf/overview.md +++ b/docs/standard-library/protobuf/overview.md @@ -45,7 +45,7 @@ The Protobuf emitter enables you to write TypeSpec and convert it into equivalen A protobuf package is defined by the [`TypeSpec.Protobuf.package` decorator][protobuf-package], which applies to a TypeSpec namespace. A package essentially defines a `.proto` file, and everything within the decorated namespace will be emitted to a single file. -The following TypeSpec namespace results in a Protobuf file named `test.proto` that has the line `package test;` within it. +The following TypeSpec namespace results in a Protobuf file named `main.proto` that contains the contents of the `Test` namespace converted into Protobuf. ```typespec @package @@ -55,7 +55,7 @@ namespace Test { } ``` -Package names may be explicitly overridden by providing an optional `PackageDetails` item to the `@package` decorator. The following TypeSpec namespace will result in a file `com/example/test.proto` that has the line `package com.example.test;` within it: +Package names may be provided using the optional `PackageDetails` argument to the `@package` decorator. The following TypeSpec namespace will result in a file `com/example/test.proto` that has the line `package com.example.test;` within it: ```typespec @package({ @@ -67,7 +67,7 @@ namespace Test { } ``` -The TypeSpec program's root namespace is implicitly a package that has no name and will be emitted to `main.proto` if it is not empty. TypeSpec objects (models, enums, etc.) are converted to Protobuf declarations within their nearest ancestor that has a package annotation. As a result, unlike in Protobuf, TypeSpec declarations of packages may be nested arbitrarily. +TypeSpec objects (models, enums, etc.) are converted to Protobuf declarations within their nearest ancestor that has a package annotation. As a result, unlike in Protobuf, TypeSpec declarations of packages may be nested arbitrarily. ### Services diff --git a/packages/protobuf/src/lib.ts b/packages/protobuf/src/lib.ts index debcb4faf62..bf42f54078c 100644 --- a/packages/protobuf/src/lib.ts +++ b/packages/protobuf/src/lib.ts @@ -117,6 +117,12 @@ export const TypeSpecProtobufLibrary = createTypeSpecLibrary({ "reservation value must be a string literal, uint32 literal, or a tuple of two uint32 literals denoting a range", }, }, + "model-not-in-package": { + severity: "error", + messages: { + default: paramMessage`model ${"name"} is not in a namespace that uses the '@Protobuf.package' decorator`, + }, + }, }, emitter: { options: EmitterOptionsSchema }, }); diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index 239d2a99a60..70ebb4a6ed3 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -100,9 +100,18 @@ function tspToProto(program: Program): ProtoFile[] { * Visits a model type, converting it into a message definition and adding it if it has not already been visited. * @param model - the model type to consider */ - function visitModel(model: Model) { + function visitModel(model: Model, source: Type) { const modelPackage = getPackageOfType(program, model); const declarations = modelPackage && declarationMap.get(modelPackage); + + if (!declarations) { + reportDiagnostic(program, { + target: source, + code: "model-not-in-package", + format: { name: model.name }, + }); + } + if (!visitedTypes.has(model)) { visitedTypes.add(model); declarations?.push(toMessage(model)); @@ -373,7 +382,7 @@ function tspToProto(program: Program): ProtoFile[] { switch (t.kind) { case "Model": - visitModel(t); + visitModel(t, relativeSource); return ref(t.name); case "Enum": visitEnum(t); @@ -502,7 +511,7 @@ function tspToProto(program: Program): ProtoFile[] { } if (!program.stateMap(state.externRef).has(effectiveModel)) { - visitModel(effectiveModel); + visitModel(effectiveModel, model); } effectiveModelCache.set(model, effectiveModel); @@ -681,11 +690,7 @@ function tspToProto(program: Program): ProtoFile[] { type NamespaceTraversable = Enum | Model | Interface | Union | Operation | Namespace; - function getPackageOfType( - program: Program, - t: NamespaceTraversable, - quiet: boolean = false - ): Namespace | null { + function getPackageOfType(program: Program, t: NamespaceTraversable): Namespace | null { /* c8 ignore start */ // Most of this should be unreachable, but we'll guard it with diagnostics anyway in case of eventual synthetic types. @@ -696,7 +701,6 @@ function tspToProto(program: Program): ProtoFile[] { case "Union": case "Interface": if (!t.namespace) { - !quiet && reportDiagnostic(program, { code: "no-package", target: t }); return null; } else { return getPackageOfType(program, t.namespace); @@ -704,7 +708,6 @@ function tspToProto(program: Program): ProtoFile[] { case "Operation": { const logicalParent = t.interface ?? t.namespace; if (!logicalParent) { - !quiet && reportDiagnostic(program, { code: "no-package", target: t }); return null; } else { return getPackageOfType(program, logicalParent); @@ -714,7 +717,6 @@ function tspToProto(program: Program): ProtoFile[] { if (packages.has(t)) return t; if (!t.namespace) { - !quiet && reportDiagnostic(program, { code: "no-package", target: t }); return null; } else { return getPackageOfType(program, t.namespace); @@ -771,8 +773,8 @@ function tspToProto(program: Program): ProtoFile[] { }, ref(r) { const [dependentPackage, dependencyPackage] = [ - getPackageOfType(program, dependent, true), - getPackageOfType(program, dependency, true), + getPackageOfType(program, dependent), + getPackageOfType(program, dependency), ]; if ( diff --git a/packages/protobuf/test/scenarios/model-no-package/diagnostics.txt b/packages/protobuf/test/scenarios/model-no-package/diagnostics.txt new file mode 100644 index 00000000000..cf20bd1ef9e --- /dev/null +++ b/packages/protobuf/test/scenarios/model-no-package/diagnostics.txt @@ -0,0 +1,2 @@ +/test/main.tsp:14:12 - error @typespec/protobuf/model-not-in-package: model Input is not in a namespace that uses the '@Protobuf.package' decorator +/test/main.tsp:17:13 - error @typespec/protobuf/model-not-in-package: model Input is not in a namespace that uses the '@Protobuf.package' decorator \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/model-no-package/input/main.tsp b/packages/protobuf/test/scenarios/model-no-package/input/main.tsp new file mode 100644 index 00000000000..4cd41b90f77 --- /dev/null +++ b/packages/protobuf/test/scenarios/model-no-package/input/main.tsp @@ -0,0 +1,19 @@ +import "@typespec/protobuf"; + +using TypeSpec.Protobuf; + +model Input { + @field(1) name: string; +} + +@package +namespace Test { + @Protobuf.service + interface Service { + // Reference a message type that isn't in this package. + example(@field(1) input: Input): WellKnown.Empty; + + // Spread input directly + example2(...Input): WellKnown.Any; + } +} From 1a51df91d5c982564353a58c966225f1cebc4f14 Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 16 Mar 2023 09:42:23 -0400 Subject: [PATCH 34/50] Reject anonymous models in messages --- packages/protobuf/src/lib.ts | 13 ++++---- packages/protobuf/src/transform/index.ts | 31 +++++++++++++------ .../scenarios/anonymous-model/diagnostics.txt | 1 + .../scenarios/anonymous-model/input/main.tsp | 24 ++++++++++++++ 4 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 packages/protobuf/test/scenarios/anonymous-model/diagnostics.txt create mode 100644 packages/protobuf/test/scenarios/anonymous-model/input/main.tsp diff --git a/packages/protobuf/src/lib.ts b/packages/protobuf/src/lib.ts index bf42f54078c..a104571fe20 100644 --- a/packages/protobuf/src/lib.ts +++ b/packages/protobuf/src/lib.ts @@ -103,13 +103,6 @@ export const TypeSpecProtobufLibrary = createTypeSpecLibrary({ default: paramMessage`${"name"} is not a valid package name (must consist of letters and numbers separated by ".")`, }, }, - "no-package": { - severity: "error", - messages: { - default: - "this type was used in a Protobuf service, but was outside the scope of any package namespace", - }, - }, "illegal-reservation": { severity: "error", messages: { @@ -123,6 +116,12 @@ export const TypeSpecProtobufLibrary = createTypeSpecLibrary({ default: paramMessage`model ${"name"} is not in a namespace that uses the '@Protobuf.package' decorator`, }, }, + "anonymous-model": { + severity: "error", + messages: { + default: "anonymous models cannot be used in Protobuf messages", + }, + }, }, emitter: { options: EmitterOptionsSchema }, }); diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index 70ebb4a6ed3..b1f89801881 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -185,8 +185,9 @@ function tspToProto(program: Program): ProtoFile[] { | undefined )?.value, - // TODO: The language guide is really unclear about how to handle these. We may also need a facility for + // TODO: The language guide is really unclear about how to handle options. We may also need a facility for // allowing packages to declare extensions, as extensions may be target/compiler specific. + // https://protobuf.dev/programming-guides/proto3/#options options: {}, imports: [...(importMap.get(namespace) ?? [])], @@ -278,16 +279,20 @@ function tspToProto(program: Program): ProtoFile[] { } /* c8 ignore stop */ - // TODO: I've written this way too many times - const extern = program.stateMap(state.externRef).get(effectiveModel) as - | [string, string] - | undefined; + return checkExtern(effectiveModel, operation); + } + + /** + * Returns an extern ref if the given type is an instance of `Extern`, otherwise returns a ref to the model's name. + */ + function checkExtern(model: Model, relativeSource: Model | Operation): ProtoRef { + const extern = program.stateMap(state.externRef).get(model) as [string, string] | undefined; if (extern) { - typeWantsImport(program, operation, extern[0]); + typeWantsImport(program, relativeSource, extern[0]); return ref(extern[1]); } - return ref(effectiveModel.name); + return ref(model.name); } /** @@ -360,7 +365,7 @@ function tspToProto(program: Program): ProtoFile[] { * @returns a Protobuf type corresponding to the given type */ function addType(t: Type, relativeSource: Model | Operation): ProtoType { - // TODO: too much duplication with addReturnModel + // Exit early if this type is an extern. const extern = program.stateMap(state.externRef).get(t) as [string, string] | undefined; if (extern) { return ref(extern[1]); @@ -378,10 +383,16 @@ function tspToProto(program: Program): ProtoFile[] { return arrayToProto(t as Model, relativeSource); } - // TODO: reject anonymous models at this stage - switch (t.kind) { case "Model": + // If we came from another model and this model is anonymous, then we can't reference it by name. + if (t.name === "" && relativeSource.kind === "Model") { + reportDiagnostic(program, { + code: "anonymous-model", + target: t, + }); + return unreachable("anonymous model"); + } visitModel(t, relativeSource); return ref(t.name); case "Enum": diff --git a/packages/protobuf/test/scenarios/anonymous-model/diagnostics.txt b/packages/protobuf/test/scenarios/anonymous-model/diagnostics.txt new file mode 100644 index 00000000000..1775d2f146a --- /dev/null +++ b/packages/protobuf/test/scenarios/anonymous-model/diagnostics.txt @@ -0,0 +1 @@ +/test/main.tsp:16:29 - error @typespec/protobuf/anonymous-model: anonymous models cannot be used in Protobuf messages \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/anonymous-model/input/main.tsp b/packages/protobuf/test/scenarios/anonymous-model/input/main.tsp new file mode 100644 index 00000000000..ef50660d206 --- /dev/null +++ b/packages/protobuf/test/scenarios/anonymous-model/input/main.tsp @@ -0,0 +1,24 @@ +import "@typespec/protobuf"; + +using TypeSpec.Protobuf; + +@package({ + name: "com.azure.Test", +}) +namespace Test; + +@Protobuf.service +interface Service { + foo(...Input): Output; +} + +model Input { + @field(1) testInputField: { + @field(1) testNestedField: int32; + }; +} + +model Output { + @field(1) testOutputField: int32; + @field(2) secondField: string; +} From 8fcaa82ff183bda5a7088cd653839adf247da1bf Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 16 Mar 2023 09:45:25 -0400 Subject: [PATCH 35/50] Removed TODOs --- packages/protobuf/src/proto.ts | 1 - packages/protobuf/src/transform/index.ts | 2 +- packages/protobuf/test/scenarios/map/input/main.tsp | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/protobuf/src/proto.ts b/packages/protobuf/src/proto.ts index cacd3e8b31f..aa6be35ea89 100644 --- a/packages/protobuf/src/proto.ts +++ b/packages/protobuf/src/proto.ts @@ -78,7 +78,6 @@ export function isMap(program: Program, m: Type): boolean { } export function $_map(ctx: DecoratorContext, target: Model) { - // TODO: validate map here. ctx.program.stateSet(mapState).add(target); } diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index b1f89801881..e31815b9584 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -429,7 +429,7 @@ function tspToProto(program: Program): ProtoFile[] { // This is a core compile error. if (!keyType || !valueType) return unreachable("nonexistent map key or value type"); - // TODO: key can be any integral or string type only + // Key constraint (integral | string) is enforced by the type constraint on the `Map<>` type. const keyProto = addType(keyType, relativeSource); const valueProto = addType(valueType, relativeSource) as ProtoRef | ProtoScalar; diff --git a/packages/protobuf/test/scenarios/map/input/main.tsp b/packages/protobuf/test/scenarios/map/input/main.tsp index a27c5aa7cd6..b09d77d9ccb 100644 --- a/packages/protobuf/test/scenarios/map/input/main.tsp +++ b/packages/protobuf/test/scenarios/map/input/main.tsp @@ -11,5 +11,5 @@ interface Service { } model Input { - @field(1) testInputField: TypeSpec.Protobuf.Map; + @field(1) testInputField: Map; } From a4caf3e43dce03fdc1d062d6323f5937313fdfac Mon Sep 17 00:00:00 2001 From: Will Temple Date: Thu, 16 Mar 2023 10:00:34 -0400 Subject: [PATCH 36/50] Fixed test harness on windows --- packages/protobuf/test/scenarios.spec.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/protobuf/test/scenarios.spec.ts b/packages/protobuf/test/scenarios.spec.ts index fc759ae0455..977323b9053 100644 --- a/packages/protobuf/test/scenarios.spec.ts +++ b/packages/protobuf/test/scenarios.spec.ts @@ -97,7 +97,13 @@ describe("protobuf scenarios", function () { expectedDiagnostics = ""; } - const diagnostics = emitResult.diagnostics.join("\n"); + // Fix the start of lines on Windows + const processedDiagnostics = + process.platform === "win32" + ? emitResult.diagnostics.map((d) => d.replace(/^Z:/, "")) + : emitResult.diagnostics; + + const diagnostics = processedDiagnostics.join("\n"); assert.strictEqual(diagnostics, expectedDiagnostics, "expected equivalent diagnostics"); @@ -196,7 +202,12 @@ async function readdirRecursive(dir: string, base: string = dir): Promise Date: Thu, 16 Mar 2023 10:23:55 -0400 Subject: [PATCH 37/50] addressbook scenario --- packages/protobuf/src/transform/index.ts | 11 +++++--- .../addressbook/input/addressbook.tsp | 27 +++++++++++++++++++ .../test/scenarios/addressbook/input/main.tsp | 13 +++++++++ .../@typespec/protobuf/addressbook.proto | 26 ++++++++++++++++++ .../output/@typespec/protobuf/main.proto | 14 ++++++++++ 5 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 packages/protobuf/test/scenarios/addressbook/input/addressbook.tsp create mode 100644 packages/protobuf/test/scenarios/addressbook/input/main.tsp create mode 100644 packages/protobuf/test/scenarios/addressbook/output/@typespec/protobuf/addressbook.proto create mode 100644 packages/protobuf/test/scenarios/addressbook/output/@typespec/protobuf/main.proto diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index e31815b9584..7dbe3cf721f 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -368,6 +368,7 @@ function tspToProto(program: Program): ProtoFile[] { // Exit early if this type is an extern. const extern = program.stateMap(state.externRef).get(t) as [string, string] | undefined; if (extern) { + typeWantsImport(program, relativeSource, extern[0]); return ref(extern[1]); } @@ -607,7 +608,6 @@ function tspToProto(program: Program): ProtoFile[] { const fieldIndex = program.stateMap(state.fieldIndex).get(property) as number | undefined; const fieldIndexNode = property.decorators.find((d) => d.decorator === $field)?.args[0].node; - if (!fieldIndexNode) throw new Error("Failed to recover field decorator argument."); if (fieldIndex === undefined) { reportDiagnostic(program, { @@ -620,6 +620,9 @@ function tspToProto(program: Program): ProtoFile[] { }); } + if (fieldIndex && !fieldIndexNode) + throw new Error("Failed to recover field decorator argument."); + const reservations = program.stateMap(state.reserve).get(model) as Reservation[] | undefined; if (reservations) { @@ -644,7 +647,9 @@ function tspToProto(program: Program): ProtoFile[] { format: { index: fieldIndex.toString(), }, - target: fieldIndexNode, + // Fail over to using the model if the field index node is missing... this should never occur but it's the + // simplest way to satisfy the type system. + target: fieldIndexNode ?? model, }); } else if ( fieldIndex !== undefined && @@ -658,7 +663,7 @@ function tspToProto(program: Program): ProtoFile[] { format: { index: fieldIndex.toString(), }, - target: fieldIndexNode, + target: fieldIndexNode ?? model, }); } } diff --git a/packages/protobuf/test/scenarios/addressbook/input/addressbook.tsp b/packages/protobuf/test/scenarios/addressbook/input/addressbook.tsp new file mode 100644 index 00000000000..d0fdd62b034 --- /dev/null +++ b/packages/protobuf/test/scenarios/addressbook/input/addressbook.tsp @@ -0,0 +1,27 @@ +import "@typespec/protobuf"; + +using TypeSpec.Protobuf; + +@package({ + name: "addressbook", +}) +namespace AddressBook; + +enum PhoneType { + MOBILE: 0, + HOME: 1, + WORK: 2, +} + +model PhoneNumber { + @field(1) number: string; + @field(2) type: PhoneType; +} + +model Person { + @field(1) name: string; + @field(2) id: int32; + @field(3) email: string; + @field(4) phones: PhoneNumber[]; + @field(5) last_updated: WellKnown.Timestamp; +} diff --git a/packages/protobuf/test/scenarios/addressbook/input/main.tsp b/packages/protobuf/test/scenarios/addressbook/input/main.tsp new file mode 100644 index 00000000000..4153b8ec33c --- /dev/null +++ b/packages/protobuf/test/scenarios/addressbook/input/main.tsp @@ -0,0 +1,13 @@ +import "@typespec/protobuf"; +import "./addressbook.tsp"; + +using TypeSpec.Protobuf; +using TypeSpec.Protobuf.WellKnown; + +@package +namespace Example; + +@Protobuf.service +interface AddressBookService { + addPerson(@field(1) person: AddressBook.Person): Empty; +} diff --git a/packages/protobuf/test/scenarios/addressbook/output/@typespec/protobuf/addressbook.proto b/packages/protobuf/test/scenarios/addressbook/output/@typespec/protobuf/addressbook.proto new file mode 100644 index 00000000000..2fdbab6edee --- /dev/null +++ b/packages/protobuf/test/scenarios/addressbook/output/@typespec/protobuf/addressbook.proto @@ -0,0 +1,26 @@ +/* Generated by Microsoft TypeSpec */ + +syntax = "proto3"; + +package addressbook; + +import "google/protobuf/timestamp.proto"; + +enum PhoneType { + MOBILE = 0; + HOME = 1; + WORK = 2; +} + +message PhoneNumber { + string number = 1; + PhoneType type = 2; +} + +message Person { + string name = 1; + int32 id = 2; + string email = 3; + repeated PhoneNumber phones = 4; + google.protobuf.Timestamp last_updated = 5; +} diff --git a/packages/protobuf/test/scenarios/addressbook/output/@typespec/protobuf/main.proto b/packages/protobuf/test/scenarios/addressbook/output/@typespec/protobuf/main.proto new file mode 100644 index 00000000000..dde2c147648 --- /dev/null +++ b/packages/protobuf/test/scenarios/addressbook/output/@typespec/protobuf/main.proto @@ -0,0 +1,14 @@ +/* Generated by Microsoft TypeSpec */ + +syntax = "proto3"; + +import "addressbook.proto"; +import "google/protobuf/empty.proto"; + +message AddPersonRequest { + addressbook.Person person = 1; +} + +service AddressBookService { + rpc AddPerson(AddPersonRequest) returns (google.protobuf.Empty); +} From 39b43c16bae632280d019fc011fafae742896009 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 27 Mar 2023 12:02:34 -0400 Subject: [PATCH 38/50] Several small updates --- docs/standard-library/protobuf/overview.md | 91 ++++++++++++++----- .../protobuf/reference/data-types.md | 4 +- .../protobuf/reference/decorators.md | 26 +++++- .../protobuf/reference/index.md | 1 + packages/protobuf/lib/proto.tsp | 27 +++++- packages/protobuf/src/lib.ts | 16 +++- packages/protobuf/src/proto.ts | 7 +- packages/protobuf/src/transform/index.ts | 33 ++++++- packages/protobuf/src/write.ts | 4 +- .../scenarios/name-collision/input/main.tsp | 24 +++++ .../output/@typespec/protobuf/main.proto | 24 +++++ .../scenarios/options-invalid/diagnostics.txt | 1 + .../scenarios/options-invalid/input/main.tsp | 25 +++++ .../test/scenarios/options/input/main.tsp | 25 +++++ .../@typespec/protobuf/com/azure/Test.proto | 20 ++++ .../scenarios/simple-error/diagnostics.txt | 3 +- .../scenarios/simple-error/input/main.tsp | 4 + .../simple-no-service/input/main.tsp | 22 +++++ .../@typespec/protobuf/com/azure/Test.proto | 18 ++++ 19 files changed, 335 insertions(+), 40 deletions(-) create mode 100644 packages/protobuf/test/scenarios/name-collision/input/main.tsp create mode 100644 packages/protobuf/test/scenarios/name-collision/output/@typespec/protobuf/main.proto create mode 100644 packages/protobuf/test/scenarios/options-invalid/diagnostics.txt create mode 100644 packages/protobuf/test/scenarios/options-invalid/input/main.tsp create mode 100644 packages/protobuf/test/scenarios/options/input/main.tsp create mode 100644 packages/protobuf/test/scenarios/options/output/@typespec/protobuf/com/azure/Test.proto create mode 100644 packages/protobuf/test/scenarios/simple-no-service/input/main.tsp create mode 100644 packages/protobuf/test/scenarios/simple-no-service/output/@typespec/protobuf/com/azure/Test.proto diff --git a/docs/standard-library/protobuf/overview.md b/docs/standard-library/protobuf/overview.md index 9d19292194e..41db29ff24e 100644 --- a/docs/standard-library/protobuf/overview.md +++ b/docs/standard-library/protobuf/overview.md @@ -67,37 +67,33 @@ namespace Test { } ``` -TypeSpec objects (models, enums, etc.) are converted to Protobuf declarations within their nearest ancestor that has a package annotation. As a result, unlike in Protobuf, TypeSpec declarations of packages may be nested arbitrarily. +TypeSpec objects (models, enums, etc.) are converted to Protobuf declarations within their nearest ancestor that has a package annotation. As a result, unlike in Protobuf, TypeSpec declarations of packages may be nested arbitrarily.p -### Services - -TypeSpec has a concept of a "service" defined by the [`TypeSpec.service` decorator][native-service], but the Protobuf concept of a "service" is different and is indicated by the [`TypeSpec.Protobuf.service` decorator][protobuf-service]. +### Messages -When using the Protobuf emitter, a Protobuf service designation is applied to an _interface_ within a package. For example, the following TypeSpec: +TypeSpec models are converted into Protobuf messages. The following TypeSpec model: ```typespec -@package -namespace Example { - @Protobuf.service - interface Test { - // ... - } +model TestMessage { + @field(1) n: int32; } ``` -will yield the following Protobuf file (named `example.proto`): +will be converted into the following Protobuf message: ```proto3 -syntax = "proto3"; - -package example; - -service Test { - // ... +message TestMessage { + int32 n = 1; } ``` -### Field indices +Models are converted into messages and included in the Protobuf file if any of the following conditions are met: + +- The model is explicitly annotated with the [`TypeSpec.Protobuf.message` decorator][protobuf-message]. +- The model is referenced by any service operation (see [Services](#services) below). +- The model is a direct child of a [package namespace](#packages) and has _every_ field annotated with the [`TypeSpec.Protobuf.field` decorator][protobuf-field]. + +#### Field indices Protobuf requires that the offset of each field within a Protobuf message be manually specified. In TypeSpec, the field indices are specified using the [`TypeSpec.Protobuf.field` decorator][protobuf-field]. All fields within a model must have an attached `@field` decorator to be converted into a Protobuf message. @@ -117,7 +113,35 @@ message TestMessage { } ``` -### Operations +### Services + +TypeSpec has a concept of a "service" defined by the [`TypeSpec.service` decorator][native-service], but the Protobuf concept of a "service" is different and is indicated by the [`TypeSpec.Protobuf.service` decorator][protobuf-service]. + +When using the Protobuf emitter, a Protobuf service designation is applied to an _interface_ within a package. For example, the following TypeSpec: + +```typespec +@package +namespace Example { + @Protobuf.service + interface Test { + // ... + } +} +``` + +will yield the following Protobuf file (named `example.proto`): + +```proto3 +syntax = "proto3"; + +package example; + +service Test { + // ... +} +``` + +#### Operations Within a [service interface](#services), TypeSpec operations represent Protobuf service methods. Each operation in the service interface is converted into an equivalent Protobuf method declaration. For example, the following specification: @@ -152,14 +176,25 @@ service Example { } ``` -### Streams +#### Streams The Protobuf emitter supports declaring the streaming mode of an operation using the [`TypeSpec.Protobuf.stream` decorator][protobuf-stream]. The streaming mode is specified using the [`StreamMode`][protobuf-stream-mode] enum. An operation can have one of four streaming modes: -- `None`: this is the default mode and indicates that neither the request nor response are streamed (`rpc Example(In) returns (Out);`). -- `In`: indicates that the request is streamed, but the response is received synchronously (`rpc Example(stream In) returns (Out);`). -- `Out`: indicates that the request is sent synchronously, but the response is streamed (`rpc Example(In) returns (stream Out);`). -- `Duplex`: indicates that both the request and response are streamed (`rpc Example(stream In) returns (stream Out);`). +- `None`: this is the default mode and indicates that neither the request nor response are streamed. + + Example: `rpc Example(In) returns (Out);` + +- `In`: indicates that the request is streamed, but the response is received synchronously. + + Example: `rpc Example(stream In) returns (Out);` + +- `Out`: indicates that the request is sent synchronously, but the response is streamed. + + Example: `rpc Example(In) returns (stream Out);` + +- `Duplex`: indicates that both the request and response are streamed. + + Example: `rpc Example(stream In) returns (stream Out);` ## Emitter options @@ -189,4 +224,10 @@ emitters: If set to `true`, this emitter will not write any files. It will still validate the TypeSpec sources to ensure they are compatible with Protobuf, but the files will simply not be written to the output directory. +[native-service]: ../built-in-decorators#service +[protobuf-service]: reference/decorators#@TypeSpec.Protobuf.service [protobuf-package]: reference/decorators#@TypeSpec.Protobuf.package +[protobuf-field]: reference/decorators#@TypeSpec.Protobuf.field +[protobuf-stream]: reference/decorators#@TypeSpec.Protobuf.stream +[protobuf-stream-mode]: reference/data-types#TypeSpec.Protobuf.StreamMode +[protobuf-message]: reference/decorators#@TypeSpec.Protobuf.message diff --git a/docs/standard-library/protobuf/reference/data-types.md b/docs/standard-library/protobuf/reference/data-types.md index a07454514da..9fbd600810c 100644 --- a/docs/standard-library/protobuf/reference/data-types.md +++ b/docs/standard-library/protobuf/reference/data-types.md @@ -55,7 +55,7 @@ model Map ### `PackageDetails` {#TypeSpec.Protobuf.PackageDetails} -Details applied to a package definition by the [`@package`](#TODO) decorator. +Details applied to a package definition by the [`@package`](./decorators# ```typespec model TypeSpec.Protobuf.PackageDetails @@ -70,7 +70,7 @@ The streaming mode of an operation. One of: - `Out`: the output of the operation is streaming. - `None`: neither the input nor the output are streaming. -See the [`@stream`](#TODO) decorator. +See the [`@stream`](./decorators# ```typespec enum TypeSpec.Protobuf.StreamMode diff --git a/docs/standard-library/protobuf/reference/decorators.md b/docs/standard-library/protobuf/reference/decorators.md index b9e1595fadd..5606e02fd40 100644 --- a/docs/standard-library/protobuf/reference/decorators.md +++ b/docs/standard-library/protobuf/reference/decorators.md @@ -8,6 +8,30 @@ toc_max_heading_level: 3 ## TypeSpec.Protobuf +### `@message` {#@TypeSpec.Protobuf.message} + +Declares that a model is a Protobuf message. + +Messages can be detected automatically if either of the following two conditions are met: + +- The model has a `@field` annotation on all of its properties. +- The model is referenced by any service operation. + +This decorator will force the emitter to check and emit a model. + +```typespec +dec TypeSpec.Protobuf.message(target: TypeSpec.object) +``` + +#### Target + +`model TypeSpec.object` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | + ### `@field` {#@TypeSpec.Protobuf.field} Defines the field index of a model property for conversion to a Protobuf @@ -109,7 +133,7 @@ dec TypeSpec.Protobuf.package(target: TypeSpec.Reflection.Namespace, details?: T ### `@stream` {#@TypeSpec.Protobuf.stream} -Set the streaming mode of an operation. See [StreamMode](#TODO) for more information. +Set the streaming mode of an operation. See [StreamMode](./data-types#TypeSpec.Protobuf.StreamMode) for more information. ```typespec dec TypeSpec.Protobuf.stream(target: TypeSpec.Reflection.Operation, mode: TypeSpec.Protobuf.StreamMode) diff --git a/docs/standard-library/protobuf/reference/index.md b/docs/standard-library/protobuf/reference/index.md index 0c50f28d160..23fb1cae080 100644 --- a/docs/standard-library/protobuf/reference/index.md +++ b/docs/standard-library/protobuf/reference/index.md @@ -9,6 +9,7 @@ toc_max_heading_level: 3 ### Decorators +- [`@message`](./decorators.md#@TypeSpec.Protobuf.message) - [`@field`](./decorators.md#@TypeSpec.Protobuf.field) - [`@reserve`](./decorators.md#@TypeSpec.Protobuf.reserve) - [`@service`](./decorators.md#@TypeSpec.Protobuf.service) diff --git a/packages/protobuf/lib/proto.tsp b/packages/protobuf/lib/proto.tsp index 89812a608d3..bea96e092ae 100644 --- a/packages/protobuf/lib/proto.tsp +++ b/packages/protobuf/lib/proto.tsp @@ -126,6 +126,18 @@ alias integral = int32 | int64 | uint32 | uint64 | boolean; @_map model Map {} +/** + * Declares that a model is a Protobuf message. + * + * Messages can be detected automatically if either of the following two conditions are met: + * + * - The model has a `@field` annotation on all of its properties. + * - The model is referenced by any service operation. + * + * This decorator will force the emitter to check and emit a model. + */ +extern dec message(target: object); + /** * Defines the field index of a model property for conversion to a Protobuf * message. @@ -200,8 +212,9 @@ extern dec reserve(target: object, ...reservations: (string | [uint32, uint32] | */ extern dec service(target: TypeSpec.Reflection.Interface); +// FIXME: cannot link to the package decorator directly because it is detected as a broken link. /** - * Details applied to a package definition by the [`@package`](#TODO) decorator. + * Details applied to a package definition by the [`@package`](./decorators#@TypeSpec.Protobuf.package) decorator. */ model PackageDetails { /** @@ -210,6 +223,14 @@ model PackageDetails { * By default, the package's name is constructed from the namespace it is applied to. */ name?: string; + /** + * The package's top-level options. + * + * See the [Protobuf Language Guide - Options](https://protobuf.dev/programming-guides/proto3/#options) for more information. + * + * Currently, only string, boolean, and numeric options are supported. + */ + options?: Record; } /** @@ -228,7 +249,7 @@ extern dec package(target: TypeSpec.Reflection.Namespace, details?: PackageDetai * - `Out`: the output of the operation is streaming. * - `None`: neither the input nor the output are streaming. * - * See the [`@stream`](#TODO) decorator. + * See the [`@stream`](./decorators#@TypeSpec.Protobuf.stream) decorator. */ enum StreamMode { /** @@ -254,7 +275,7 @@ enum StreamMode { } /** - * Set the streaming mode of an operation. See [StreamMode](#TODO) for more information. + * Set the streaming mode of an operation. See [StreamMode](./data-types#TypeSpec.Protobuf.StreamMode) for more information. * * @param mode The streaming mode to apply to this operation. * diff --git a/packages/protobuf/src/lib.ts b/packages/protobuf/src/lib.ts index a104571fe20..d68b84e0145 100644 --- a/packages/protobuf/src/lib.ts +++ b/packages/protobuf/src/lib.ts @@ -122,6 +122,12 @@ export const TypeSpecProtobufLibrary = createTypeSpecLibrary({ default: "anonymous models cannot be used in Protobuf messages", }, }, + package: { + severity: "error", + messages: { + "disallowed-option-type": paramMessage`option '${"name"}' with type '${"type"}' is not allowed in a package declaration (only string, boolean, and number values are allowed)`, + }, + }, }, emitter: { options: EmitterOptionsSchema }, }); @@ -132,7 +138,15 @@ export { $onEmit } from "./proto.js"; export type TypeSpecProtobufLibrary = typeof TypeSpecProtobufLibrary; -const keys = ["fieldIndex", "package", "service", "externRef", "stream", "reserve"] as const; +const keys = [ + "fieldIndex", + "package", + "service", + "externRef", + "stream", + "reserve", + "message", +] as const; export const state = Object.fromEntries( keys.map((k) => [k, Symbol(`@typespec/protobuf.${k}`)]) diff --git a/packages/protobuf/src/proto.ts b/packages/protobuf/src/proto.ts index aa6be35ea89..168b29d6742 100644 --- a/packages/protobuf/src/proto.ts +++ b/packages/protobuf/src/proto.ts @@ -67,7 +67,6 @@ export interface PackageDetails { * @param target - target decorator namespace */ export function $package(ctx: DecoratorContext, target: Namespace, details?: Model) { - // TODO: need to convert details from Model to PackageDetails ctx.program.stateMap(state.package).set(target, details); } @@ -128,6 +127,10 @@ export function $reserve( ctx.program.stateMap(state.reserve).set(target, finalReservations); } +export function $message(ctx: DecoratorContext, target: Model) { + ctx.program.stateSet(state.message).add(target); +} + /** * Decorate a model property with a field index. Field indices are required for all fields of emitted messages. * @@ -190,6 +193,7 @@ export async function $onEmit(ctx: EmitContext e.emitFunction === $onEmit) ?.options as ProtobufEmitterOptions; @@ -197,5 +201,6 @@ export async function $onValidate(program: Program) { await emitter("", options); } } + export const namespace = "TypeSpec.Protobuf"; export { TypeSpecProtobufLibrary as $lib }; diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index 7dbe3cf721f..b060788533b 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -178,6 +178,17 @@ function tspToProto(program: Program): ProtoFile[] { // Emit a file per package. const files = [...packages].map((namespace) => { const details = program.stateMap(state.package).get(namespace) as Model | undefined; + const packageOptionsRaw = details?.properties.get("options")?.type as Model | undefined; + + const packageOptions = [...(packageOptionsRaw?.properties.entries() ?? [])] + .map(([k, { type }]) => { + // This condition is enforced by the definition of `dec package` + if (type.kind === "Boolean" || type.kind === "String" || type.kind === "Number") { + return [k, type.value] as [string, unknown]; + } else throw new Error(`Unexpected option type ${type.kind}`); + }) + .filter((v) => !!v) as [string, unknown][]; + return { package: ( (details?.properties.get("name") as ModelProperty | undefined)?.type as @@ -185,10 +196,7 @@ function tspToProto(program: Program): ProtoFile[] { | undefined )?.value, - // TODO: The language guide is really unclear about how to handle options. We may also need a facility for - // allowing packages to declare extensions, as extensions may be target/compiler specific. - // https://protobuf.dev/programming-guides/proto3/#options - options: {}, + options: Object.fromEntries(packageOptions), imports: [...(importMap.get(namespace) ?? [])], @@ -208,6 +216,23 @@ function tspToProto(program: Program): ProtoFile[] { * @returns an array of declarations */ function addDeclarationsOfPackage(namespace: Namespace) { + const models = [...namespace.models.values()]; + + // Eagerly visit all models in the namespace. + for (const model of models) { + // Don't eagerly visit externs + if ( + // Don't eagerly visit externs + !program.stateMap(state.externRef).has(model) && + // Only eagerly visit models where every field has a field index annotation. + ([...model.properties.values()].every((p) => program.stateMap(state.fieldIndex).has(p)) || + // OR where the model has been explicitly marked as a message. + program.stateSet(state.message).has(model)) + ) { + visitModel(model, model); + } + } + const interfacesInNamespace = new Set( serviceInterfaces.filter((iface) => isDeclaredInNamespace(iface, namespace)) ); diff --git a/packages/protobuf/src/write.ts b/packages/protobuf/src/write.ts index 6487a413dc4..5826d5d4048 100644 --- a/packages/protobuf/src/write.ts +++ b/packages/protobuf/src/write.ts @@ -44,7 +44,7 @@ export function writeProtoFile(file: ProtoFile): string { const opts = Object.entries(file.options); for (const [name, valueData] of opts) { const value = typeof valueData === "string" ? `"${valueData}"` : valueData.toString(); - result += `\noption (${name}) = ${value}`; + result += `\noption ${name} = ${value};`; } // Give the declarations a little breathing room if options were provided @@ -125,7 +125,7 @@ function* writeService(decl: ProtoServiceDeclaration): Iterable { if (decl.operations.length > 0) { yield head; - yield* indent(flatMap(decl.operations, writeMethod)); + yield* indent(flatMap(decl.operations, writeDeclaration)); yield tail; } else yield head + tail; } diff --git a/packages/protobuf/test/scenarios/name-collision/input/main.tsp b/packages/protobuf/test/scenarios/name-collision/input/main.tsp new file mode 100644 index 00000000000..e8ae67325e7 --- /dev/null +++ b/packages/protobuf/test/scenarios/name-collision/input/main.tsp @@ -0,0 +1,24 @@ +import "@typespec/protobuf"; + +using TypeSpec.Protobuf; + +@package +namespace Test; + +model ExampleRequest { + @field(1) test: uint32; +} + +model ExampleResponse { + @field(1) test: string; +} + +@Protobuf.service +interface Service { + // invalid field index + example(@field(1) test: string): { + @field(1) test: uint32; + }; + + example2(...ExampleRequest): ExampleResponse; +} diff --git a/packages/protobuf/test/scenarios/name-collision/output/@typespec/protobuf/main.proto b/packages/protobuf/test/scenarios/name-collision/output/@typespec/protobuf/main.proto new file mode 100644 index 00000000000..bd7a640d097 --- /dev/null +++ b/packages/protobuf/test/scenarios/name-collision/output/@typespec/protobuf/main.proto @@ -0,0 +1,24 @@ +/* Generated by Microsoft TypeSpec */ + +syntax = "proto3"; + +message ExampleRequest { + uint32 test = 1; +} + +message ExampleResponse { + string test = 1; +} + +message ExampleRequest { + string test = 1; +} + +message ExampleResponse { + uint32 test = 1; +} + +service Service { + rpc Example(ExampleRequest) returns (ExampleResponse); + rpc Example2(ExampleRequest) returns (ExampleResponse); +} diff --git a/packages/protobuf/test/scenarios/options-invalid/diagnostics.txt b/packages/protobuf/test/scenarios/options-invalid/diagnostics.txt new file mode 100644 index 00000000000..08e74b4b2b1 --- /dev/null +++ b/packages/protobuf/test/scenarios/options-invalid/diagnostics.txt @@ -0,0 +1 @@ +/test/main.tsp:5:10 - error invalid-argument: Argument '(anonymous model)' is not assignable to parameter of type 'TypeSpec.Protobuf.PackageDetails' \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/options-invalid/input/main.tsp b/packages/protobuf/test/scenarios/options-invalid/input/main.tsp new file mode 100644 index 00000000000..26f01df0b86 --- /dev/null +++ b/packages/protobuf/test/scenarios/options-invalid/input/main.tsp @@ -0,0 +1,25 @@ +import "@typespec/protobuf"; + +using TypeSpec.Protobuf; + +@package({ + name: "com.azure.Test", + options: { + java_package: {}, + }, +}) +namespace Test; + +@Protobuf.service +interface Service { + foo(...Input): Output; +} + +model Input { + @field(1) testInputField: string; +} + +model Output { + @field(1) testOutputField: int32; + @field(2) secondField: string; +} diff --git a/packages/protobuf/test/scenarios/options/input/main.tsp b/packages/protobuf/test/scenarios/options/input/main.tsp new file mode 100644 index 00000000000..427312d8324 --- /dev/null +++ b/packages/protobuf/test/scenarios/options/input/main.tsp @@ -0,0 +1,25 @@ +import "@typespec/protobuf"; + +using TypeSpec.Protobuf; + +@package({ + name: "com.azure.Test", + options: { + java_package: "com.azure.test", + }, +}) +namespace Test; + +@Protobuf.service +interface Service { + foo(...Input): Output; +} + +model Input { + @field(1) testInputField: string; +} + +model Output { + @field(1) testOutputField: int32; + @field(2) secondField: string; +} diff --git a/packages/protobuf/test/scenarios/options/output/@typespec/protobuf/com/azure/Test.proto b/packages/protobuf/test/scenarios/options/output/@typespec/protobuf/com/azure/Test.proto new file mode 100644 index 00000000000..f5457833f28 --- /dev/null +++ b/packages/protobuf/test/scenarios/options/output/@typespec/protobuf/com/azure/Test.proto @@ -0,0 +1,20 @@ +/* Generated by Microsoft TypeSpec */ + +syntax = "proto3"; + +package com.azure.Test; + +option java_package = "com.azure.test"; + +message Input { + string testInputField = 1; +} + +message Output { + int32 testOutputField = 1; + string secondField = 2; +} + +service Service { + rpc Foo(Input) returns (Output); +} diff --git a/packages/protobuf/test/scenarios/simple-error/diagnostics.txt b/packages/protobuf/test/scenarios/simple-error/diagnostics.txt index a7780a68d7b..d7c26dc20d5 100644 --- a/packages/protobuf/test/scenarios/simple-error/diagnostics.txt +++ b/packages/protobuf/test/scenarios/simple-error/diagnostics.txt @@ -2,4 +2,5 @@ /test/main.tsp:13:5 - error @typespec/protobuf/field-index: field index 536870912 is out of bounds (must be less than 536870912) /test/main.tsp:14:5 - error @typespec/protobuf/field-index: field index 19000 falls within the implementation-reserved range of 19000-19999 inclusive /test/main.tsp:15:5 - error @typespec/protobuf/field-index: field index 19123 falls within the implementation-reserved range of 19000-19999 inclusive -/test/main.tsp:16:5 - error @typespec/protobuf/field-index: field index 19999 falls within the implementation-reserved range of 19000-19999 inclusive \ No newline at end of file +/test/main.tsp:16:5 - error @typespec/protobuf/field-index: field index 19999 falls within the implementation-reserved range of 19000-19999 inclusive +/test/main.tsp:21:1 - error decorator-wrong-target: Cannot apply @message decorator to Test.Test since it is not assignable to TypeSpec.object \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/simple-error/input/main.tsp b/packages/protobuf/test/scenarios/simple-error/input/main.tsp index e76e3037f69..f4b649246a1 100644 --- a/packages/protobuf/test/scenarios/simple-error/input/main.tsp +++ b/packages/protobuf/test/scenarios/simple-error/input/main.tsp @@ -16,3 +16,7 @@ interface Service { @field(19999) testInputField5: string ): {}; } + +// Cannot apply @message to interface +@message +interface Test {} diff --git a/packages/protobuf/test/scenarios/simple-no-service/input/main.tsp b/packages/protobuf/test/scenarios/simple-no-service/input/main.tsp new file mode 100644 index 00000000000..c70c2060d13 --- /dev/null +++ b/packages/protobuf/test/scenarios/simple-no-service/input/main.tsp @@ -0,0 +1,22 @@ +import "@typespec/protobuf"; + +using TypeSpec.Protobuf; + +@package({ + name: "com.azure.Test", +}) +namespace Test; + +model Input { + @field(1) testInputField: string; +} + +model Output { + @field(1) testOutputField: int32; + @field(2) secondField: string; +} + +@message +model ExplicitlyDeclared { + @field(2) testField: string; +} diff --git a/packages/protobuf/test/scenarios/simple-no-service/output/@typespec/protobuf/com/azure/Test.proto b/packages/protobuf/test/scenarios/simple-no-service/output/@typespec/protobuf/com/azure/Test.proto new file mode 100644 index 00000000000..2aeda7b5782 --- /dev/null +++ b/packages/protobuf/test/scenarios/simple-no-service/output/@typespec/protobuf/com/azure/Test.proto @@ -0,0 +1,18 @@ +/* Generated by Microsoft TypeSpec */ + +syntax = "proto3"; + +package com.azure.Test; + +message Input { + string testInputField = 1; +} + +message Output { + int32 testOutputField = 1; + string secondField = 2; +} + +message ExplicitlyDeclared { + string testField = 2; +} From 9fbde4e7a2bb6e224b0aa89f74b245b898e72543 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 27 Mar 2023 12:03:12 -0400 Subject: [PATCH 39/50] Ignored .protoc-out integration folder --- packages/protobuf/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/protobuf/.gitignore diff --git a/packages/protobuf/.gitignore b/packages/protobuf/.gitignore new file mode 100644 index 00000000000..bea41e259d6 --- /dev/null +++ b/packages/protobuf/.gitignore @@ -0,0 +1 @@ +.protoc-out From 7ec412a817f3f6a52fc6ffe92eb30daf35c4769f Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 13:12:47 -0400 Subject: [PATCH 40/50] Updated a few documentation entries --- packages/protobuf/README.md | 4 ++-- packages/protobuf/src/lib.ts | 4 ++-- packages/protobuf/src/transform/index.ts | 27 ------------------------ packages/protobuf/test/scenarios.spec.ts | 11 ++++++++++ 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/packages/protobuf/README.md b/packages/protobuf/README.md index 6d0257d14a4..7e6b97b1bfd 100644 --- a/packages/protobuf/README.md +++ b/packages/protobuf/README.md @@ -23,6 +23,6 @@ tsp compile . --emit @typespec/protobuf Add the following to your `tspproject.yaml` file. ```yaml -emitters: - @typespec/protobuf: true +emit: + - "@typespec/protobuf" ``` diff --git a/packages/protobuf/src/lib.ts b/packages/protobuf/src/lib.ts index d68b84e0145..9a7e510c98e 100644 --- a/packages/protobuf/src/lib.ts +++ b/packages/protobuf/src/lib.ts @@ -125,7 +125,7 @@ export const TypeSpecProtobufLibrary = createTypeSpecLibrary({ package: { severity: "error", messages: { - "disallowed-option-type": paramMessage`option '${"name"}' with type '${"type"}' is not allowed in a package declaration (only string, boolean, and number values are allowed)`, + "disallowed-option-type": paramMessage`option '${"name"}' with type '${"type"}' is not allowed in a package declaration (only string, boolean, and numeric types are allowed)`, }, }, }, @@ -149,7 +149,7 @@ const keys = [ ] as const; export const state = Object.fromEntries( - keys.map((k) => [k, Symbol(`@typespec/protobuf.${k}`)]) + keys.map((k) => [k, TypeSpecProtobufLibrary.createStateSymbol(k)]) ) as { [K in (typeof keys)[number]]: symbol; }; diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index b060788533b..13e79e962d5 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -874,7 +874,6 @@ function getOperationReturnSyntaxTarget(op: Operation): DiagnosticTarget { case SyntaxKind.OperationSignatureDeclaration: return signature.returnType; case SyntaxKind.OperationSignatureReference: - // op foo is whatever; return op; default: const __exhaust: never = signature; @@ -884,32 +883,6 @@ function getOperationReturnSyntaxTarget(op: Operation): DiagnosticTarget { } } -/** - * Gets the syntactic type position for a model or enum field. - */ -// This function was used to get the syntactic position for enum members, and it's still here in case we want to use it -// for model properties. -// function getMemberTypeSyntaxTarget(property: ModelProperty | EnumMember): DiagnosticTarget { -// const node = property.node; - -// switch (node.kind) { -// case SyntaxKind.ModelProperty: -// return node.value; -// case SyntaxKind.ModelSpreadProperty: -// return node; -// case SyntaxKind.EnumMember: -// return node.value ?? node; -// case SyntaxKind.ProjectionModelProperty: -// case SyntaxKind.ProjectionModelSpreadProperty: -// return property; -// default: -// const __exhaust: never = node; -// throw new Error( -// `Internal Emitter Error: reached unreachable member node: ${property.node.kind}` -// ); -// } -// } - /** * Gets the syntactic position of a model property name. */ diff --git a/packages/protobuf/test/scenarios.spec.ts b/packages/protobuf/test/scenarios.spec.ts index 977323b9053..fad597bdabc 100644 --- a/packages/protobuf/test/scenarios.spec.ts +++ b/packages/protobuf/test/scenarios.spec.ts @@ -167,6 +167,12 @@ function assertFilesAsExpected( } } +/** + * Writes an expectation map to disk. + * + * @param expectationDirectory - The directory to write to. + * @param outputFiles - A map of relative paths to file contents. + */ async function writeExpectationDirectory( expectationDirectory: string, outputFiles: Record @@ -189,6 +195,11 @@ async function writeExpectationDirectory( } } +/** + * @param dir - The directory to read recursively. + * @param base - The base directory to use for relative paths. + * @returns A map of relative paths to file contents. + */ async function readdirRecursive(dir: string, base: string = dir): Promise> { const res: Record = {}; From 55bab13416abf0a908500bccc6324989b3d2a8b3 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 13:13:02 -0400 Subject: [PATCH 41/50] Import from fs rather than import fs --- packages/protobuf/test/scenarios.spec.ts | 36 +++++++++++------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/packages/protobuf/test/scenarios.spec.ts b/packages/protobuf/test/scenarios.spec.ts index fad597bdabc..4b4e2bb659b 100644 --- a/packages/protobuf/test/scenarios.spec.ts +++ b/packages/protobuf/test/scenarios.spec.ts @@ -1,5 +1,4 @@ import assert from "assert"; -import fs from "fs"; import path from "path"; import url from "url"; @@ -11,6 +10,8 @@ import { resolveVirtualPath, TypeSpecTestLibrary, } from "@typespec/compiler/testing"; +import { readdirSync, statSync } from "fs"; +import { mkdir, readdir, readFile, rm, stat, writeFile } from "fs/promises"; const SCENARIOS_DIRECTORY = url.fileURLToPath(new url.URL("../../test/scenarios", import.meta.url)); @@ -32,10 +33,9 @@ const TypeSpecProtobufTestLibrary: TypeSpecTestLibrary = { }; describe("protobuf scenarios", function () { - const scenarios = fs - .readdirSync(SCENARIOS_DIRECTORY) + const scenarios = readdirSync(SCENARIOS_DIRECTORY) .map((dn) => path.join(SCENARIOS_DIRECTORY, dn)) - .filter((dn) => fs.statSync(dn).isDirectory()); + .filter((dn) => statSync(dn).isDirectory()); for (const scenario of scenarios) { const scenarioName = path.basename(scenario); @@ -55,12 +55,12 @@ describe("protobuf scenarios", function () { await writeExpectationDirectory(expectationDirectory, emitResult.files); - await fs.promises.rm(diagnosticsExpectationPath, { force: true }); + await rm(diagnosticsExpectationPath, { force: true }); if (emitResult.diagnostics.length > 0) { const diagnostics = emitResult.diagnostics.join("\n"); - await fs.promises.writeFile(diagnosticsExpectationPath, diagnostics); + await writeFile(diagnosticsExpectationPath, diagnostics); } } else { // It's an error if any file in the expected files is missing, if any file in the output files doesn't have a @@ -70,7 +70,7 @@ describe("protobuf scenarios", function () { let err: Error | undefined = undefined; // `throwIfNoEntry` is not supported with promisified fs.promises.stat. - if (!fs.statSync(expectationDirectory, { throwIfNoEntry: false })) { + if (!statSync(expectationDirectory, { throwIfNoEntry: false })) { assert.strictEqual( Object.entries(emitResult.files).length, 0, @@ -90,9 +90,7 @@ describe("protobuf scenarios", function () { let expectedDiagnostics: string; try { - expectedDiagnostics = (await fs.promises.readFile(diagnosticsExpectationPath)).toString( - "utf-8" - ); + expectedDiagnostics = (await readFile(diagnosticsExpectationPath)).toString("utf-8"); } catch { expectedDiagnostics = ""; } @@ -184,14 +182,14 @@ async function writeExpectationDirectory( return; } - await fs.promises.rm(expectationDirectory, { recursive: true, force: true }); + await rm(expectationDirectory, { recursive: true, force: true }); - await fs.promises.mkdir(expectationDirectory); + await mkdir(expectationDirectory); for (const [fn, content] of fileEntries) { const fullPath = path.join(expectationDirectory, fn); - await fs.promises.mkdir(path.dirname(fullPath), { recursive: true }); - await fs.promises.writeFile(fullPath, content); + await mkdir(path.dirname(fullPath), { recursive: true }); + await writeFile(fullPath, content); } } @@ -203,15 +201,15 @@ async function writeExpectationDirectory( async function readdirRecursive(dir: string, base: string = dir): Promise> { const res: Record = {}; - for (const entry of (await fs.promises.readdir(dir)).map((e) => path.join(dir, e))) { - const stat = await fs.promises.stat(entry); + for (const entry of (await readdir(dir)).map((e) => path.join(dir, e))) { + const stats = await stat(entry); - if (stat.isDirectory()) { + if (stats.isDirectory()) { for (const [name, content] of Object.entries(await readdirRecursive(entry, base))) { res[name] = content; } - } else if (stat.isFile()) { - const content = (await fs.promises.readFile(entry)).toString("utf-8"); + } else if (stats.isFile()) { + const content = (await readFile(entry)).toString("utf-8"); const relativePath = path.relative(base, entry); From 43dfbfa070dff5ade9e1f6b78e6acc55c18f22f8 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 13:31:43 -0400 Subject: [PATCH 42/50] Increased resilience to failed scalar resolutions. --- packages/protobuf/src/transform/index.ts | 51 ++++++++++++++---------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index 13e79e962d5..99eae0cced5 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -4,6 +4,7 @@ import { DiagnosticTarget, Enum, + formatDiagnostic, getEffectiveModelType, getTypeName, Interface, @@ -20,6 +21,7 @@ import { Type, Union, } from "@typespec/compiler"; +import { EOL } from "os"; import { map, matchType, @@ -485,27 +487,34 @@ function tspToProto(program: Program): ProtoFile[] { if (_protoScalarsMap.has(program)) { scalarMap = _protoScalarsMap.get(program)!; } else { - scalarMap = new Map( - ( - [ - [program.resolveTypeReference("TypeSpec.bytes"), scalar("bytes")], - [program.resolveTypeReference("TypeSpec.boolean"), scalar("bool")], - [program.resolveTypeReference("TypeSpec.string"), scalar("string")], - [program.resolveTypeReference("TypeSpec.int32"), scalar("int32")], - [program.resolveTypeReference("TypeSpec.int64"), scalar("int64")], - [program.resolveTypeReference("TypeSpec.uint32"), scalar("uint32")], - [program.resolveTypeReference("TypeSpec.uint64"), scalar("uint64")], - [program.resolveTypeReference("TypeSpec.float32"), scalar("float")], - [program.resolveTypeReference("TypeSpec.float64"), scalar("double")], - [program.resolveTypeReference("TypeSpec.Protobuf.sfixed32"), scalar("sfixed32")], - [program.resolveTypeReference("TypeSpec.Protobuf.sfixed64"), scalar("sfixed64")], - [program.resolveTypeReference("TypeSpec.Protobuf.sint32"), scalar("sint32")], - [program.resolveTypeReference("TypeSpec.Protobuf.sint64"), scalar("sint64")], - [program.resolveTypeReference("TypeSpec.Protobuf.fixed32"), scalar("fixed32")], - [program.resolveTypeReference("TypeSpec.Protobuf.fixed64"), scalar("fixed64")], - ] as [[Type, unknown], ProtoScalar][] - ).map(([[type], scalar]) => [type, scalar]) - ); + const entries = [ + [program.resolveTypeReference("TypeSpec.bytes"), scalar("bytes")], + [program.resolveTypeReference("TypeSpec.boolean"), scalar("bool")], + [program.resolveTypeReference("TypeSpec.string"), scalar("string")], + [program.resolveTypeReference("TypeSpec.int32"), scalar("int32")], + [program.resolveTypeReference("TypeSpec.int64"), scalar("int64")], + [program.resolveTypeReference("TypeSpec.uint32"), scalar("uint32")], + [program.resolveTypeReference("TypeSpec.uint64"), scalar("uint64")], + [program.resolveTypeReference("TypeSpec.float32"), scalar("float")], + [program.resolveTypeReference("TypeSpec.float64"), scalar("double")], + [program.resolveTypeReference("TypeSpec.Protobuf.sfixed32"), scalar("sfixed32")], + [program.resolveTypeReference("TypeSpec.Protobuf.sfixed64"), scalar("sfixed64")], + [program.resolveTypeReference("TypeSpec.Protobuf.sint32"), scalar("sint32")], + [program.resolveTypeReference("TypeSpec.Protobuf.sint64"), scalar("sint64")], + [program.resolveTypeReference("TypeSpec.Protobuf.fixed32"), scalar("fixed32")], + [program.resolveTypeReference("TypeSpec.Protobuf.fixed64"), scalar("fixed64")], + ] as const; + + for (const [[type, diagnostics]] of entries) { + if (!type) { + const diagnosticString = diagnostics.map(formatDiagnostic).join(EOL); + throw new Error( + `Failed to construct TypeSpec -> Protobuf scalar map. Unexpected failure to resolve TypeSpec scalar: ${diagnosticString}` + ); + } + } + + scalarMap = new Map(entries.map(([[type], scalar]) => [type!, scalar])); _protoScalarsMap.set(program, scalarMap); } From 4b9da2d22c317e521f370dbe9815f5fcd2b6ad64 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 13:35:38 -0400 Subject: [PATCH 43/50] Support derived scalars by traversing the scalar inheritance links. --- packages/protobuf/src/transform/index.ts | 22 ++++++++++------- .../scenarios/derived-scalar/input/main.tsp | 24 +++++++++++++++++++ .../@typespec/protobuf/com/azure/Test.proto | 18 ++++++++++++++ 3 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 packages/protobuf/test/scenarios/derived-scalar/input/main.tsp create mode 100644 packages/protobuf/test/scenarios/derived-scalar/output/@typespec/protobuf/com/azure/Test.proto diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index 99eae0cced5..87a7575b94e 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -529,15 +529,19 @@ function tspToProto(program: Program): ProtoFile[] { const protoType = getProtoScalarsMap(program).get(t); if (!protoType) { - reportDiagnostic(program, { - code: "unsupported-field-type", - messageId: "unknown-scalar", - format: { - name: fullName, - }, - target: t, - }); - return unreachable("unknown scalar"); + if (t.baseScalar) { + return scalarToProto(t.baseScalar); + } else { + reportDiagnostic(program, { + code: "unsupported-field-type", + messageId: "unknown-scalar", + format: { + name: fullName, + }, + target: t, + }); + return unreachable("unknown scalar"); + } } return protoType; diff --git a/packages/protobuf/test/scenarios/derived-scalar/input/main.tsp b/packages/protobuf/test/scenarios/derived-scalar/input/main.tsp new file mode 100644 index 00000000000..f02f998755f --- /dev/null +++ b/packages/protobuf/test/scenarios/derived-scalar/input/main.tsp @@ -0,0 +1,24 @@ +import "@typespec/protobuf"; + +using TypeSpec.Protobuf; + +@package({ + name: "com.azure.Test", +}) +namespace Test; + +scalar MyInt32 extends int32; + +@Protobuf.service +interface Service { + foo(...Input): Output; +} + +model Input { + @field(1) testInputField: string; +} + +model Output { + @field(1) testOutputField: MyInt32; + @field(2) secondField: string; +} diff --git a/packages/protobuf/test/scenarios/derived-scalar/output/@typespec/protobuf/com/azure/Test.proto b/packages/protobuf/test/scenarios/derived-scalar/output/@typespec/protobuf/com/azure/Test.proto new file mode 100644 index 00000000000..32114a3b14a --- /dev/null +++ b/packages/protobuf/test/scenarios/derived-scalar/output/@typespec/protobuf/com/azure/Test.proto @@ -0,0 +1,18 @@ +/* Generated by Microsoft TypeSpec */ + +syntax = "proto3"; + +package com.azure.Test; + +message Input { + string testInputField = 1; +} + +message Output { + int32 testOutputField = 1; + string secondField = 2; +} + +service Service { + rpc Foo(Input) returns (Output); +} From 10551b2c1d3491e32eab1fc40f439d38a76496d5 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 13:37:28 -0400 Subject: [PATCH 44/50] Add protobuf as website dependency --- packages/website/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/website/package.json b/packages/website/package.json index 6c2226a7860..501b9f30eb0 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -36,6 +36,7 @@ "@typespec/http": "~0.42.0", "@typespec/rest": "~0.42.0", "@typespec/openapi": "~0.42.0", + "@typespec/protobuf": "~0.42.0", "@docusaurus/module-type-aliases": "^2.2.0", "@docusaurus/types": "^2.2.0", "@tsconfig/docusaurus": "^1.0.5", From ab00e49eb99840c635f5ef50d525d5a52e24ac7f Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 14:04:30 -0400 Subject: [PATCH 45/50] Just don't support unions for now --- packages/protobuf/src/lib.ts | 1 + packages/protobuf/src/transform/index.ts | 41 ++++--------------- .../test/scenarios/union/diagnostics.txt | 3 +- .../test/scenarios/union/input/main.tsp | 2 - 4 files changed, 10 insertions(+), 37 deletions(-) diff --git a/packages/protobuf/src/lib.ts b/packages/protobuf/src/lib.ts index 9a7e510c98e..e841edfa1ca 100644 --- a/packages/protobuf/src/lib.ts +++ b/packages/protobuf/src/lib.ts @@ -74,6 +74,7 @@ export const TypeSpecProtobufLibrary = createTypeSpecLibrary({ "unknown-intrinsic": paramMessage`no known protobuf scalar for intrinsic type ${"name"}`, "unknown-scalar": paramMessage`no known protobuf scalar for TypeSpec scalar type ${"name"}`, "recursive-map": "a protobuf map's 'value' type may not refer to another map", + union: "a message field's type may not be a union", }, }, "namespace-collision": { diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index 87a7575b94e..cbac2b579ea 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -32,7 +32,6 @@ import { ProtoMessageBodyDeclaration, ProtoMessageDeclaration, ProtoMethodDeclaration, - ProtoOneOfDeclaration, ProtoRef, ProtoScalar, ProtoTopLevelDeclaration, @@ -610,38 +609,14 @@ function tspToProto(program: Program): ProtoFile[] { model: Model ): ProtoMessageBodyDeclaration { if (property.type.kind === "Union") { - // TODO: union must have at least one variant. - // TODO: union members must have field decorators. - // TODO: union must be anonymous - // TODO: union fields mustn't be arrays or maps. - // TODO: union variants must be string-named - - // TODO: this isn't actually possible at all, because "union has named variants" and "union must be anonymous" - // are currently contradictory, so we can temporarily allow union decls with the understanding that they will be - // certainly inlined. - - const oneof: ProtoOneOfDeclaration = { - kind: "oneof", - name: property.name, - declarations: [...property.type.variants.values()] - .filter(/*TODO:*/ (v) => typeof v.name === "string") - .map( - (v): ProtoFieldDeclaration => ({ - kind: "field", - name: v.name as string, - index: program.stateMap(state.fieldIndex).get(v), - type: addImportSourceForProtoIfNeeded( - program, - addType(v.type, model), - model, - v.type as NamespaceTraversable /*TODO: seems weird*/ - ), - repeated: false, - }) - ), - }; - - return oneof; + // Unions are difficult to represent in protobuf, so for now we don't support them. + // See : https://github.com/microsoft/typespec/issues/1854 + reportDiagnostic(program, { + code: "unsupported-field-type", + messageId: "union", + target: property, + }); + return unreachable("union"); } const fieldIndex = program.stateMap(state.fieldIndex).get(property) as number | undefined; diff --git a/packages/protobuf/test/scenarios/union/diagnostics.txt b/packages/protobuf/test/scenarios/union/diagnostics.txt index c036c96c0eb..7f3697fa282 100644 --- a/packages/protobuf/test/scenarios/union/diagnostics.txt +++ b/packages/protobuf/test/scenarios/union/diagnostics.txt @@ -1,2 +1 @@ -/test/main.tsp:22:3 - error decorator-wrong-target: Cannot apply @field decorator to Test.InputA since it is not assignable to ModelProperty -/test/main.tsp:24:3 - error decorator-wrong-target: Cannot apply @field decorator to Test.InputB since it is not assignable to ModelProperty \ No newline at end of file +/test/main.tsp:14:3 - error @typespec/protobuf/unsupported-field-type: a message field's type may not be a union \ No newline at end of file diff --git a/packages/protobuf/test/scenarios/union/input/main.tsp b/packages/protobuf/test/scenarios/union/input/main.tsp index b2693ae071d..76ac3fdd8f7 100644 --- a/packages/protobuf/test/scenarios/union/input/main.tsp +++ b/packages/protobuf/test/scenarios/union/input/main.tsp @@ -19,9 +19,7 @@ model InputA { } union U { - @field(1) a: InputA, - @field(2) b: InputB, } From 34eb9e7db21b00bc93b97bdafbd1c2ea2a624614 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 15:29:10 -0400 Subject: [PATCH 46/50] Better handling of intrinsic types --- packages/protobuf/src/lib.ts | 6 + packages/protobuf/src/transform/index.ts | 109 +++++++++++++++--- .../test/scenarios/intrinsics/input/main.tsp | 17 +++ .../@typespec/protobuf/com/azure/Test.proto | 16 +++ 4 files changed, 134 insertions(+), 14 deletions(-) create mode 100644 packages/protobuf/test/scenarios/intrinsics/input/main.tsp create mode 100644 packages/protobuf/test/scenarios/intrinsics/output/@typespec/protobuf/com/azure/Test.proto diff --git a/packages/protobuf/src/lib.ts b/packages/protobuf/src/lib.ts index e841edfa1ca..085557f7b3f 100644 --- a/packages/protobuf/src/lib.ts +++ b/packages/protobuf/src/lib.ts @@ -52,6 +52,12 @@ export const TypeSpecProtobufLibrary = createTypeSpecLibrary({ "operations in the root namespace are not supported (no associated Protobuf service)", }, }, + "unsupported-intrinsic": { + severity: "error", + messages: { + default: paramMessage`intrinsic type ${"name"} is not supported in Protobuf`, + }, + }, "unsupported-return-type": { severity: "error", messages: { diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index cbac2b579ea..6b2b61d9d09 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -8,6 +8,7 @@ import { getEffectiveModelType, getTypeName, Interface, + IntrinsicType, isDeclaredInNamespace, Model, ModelProperty, @@ -48,6 +49,7 @@ import { writeProtoFile } from "../write.js"; // Cache for scalar -> ProtoScalar map const _protoScalarsMap = new WeakMap>(); +const _protoExternMap = new WeakMap>(); /** * Create a worker function that converts the TypeSpec program to Protobuf and writes it to the file system. @@ -321,6 +323,52 @@ function tspToProto(program: Program): ProtoFile[] { return ref(model.name); } + /** + * Gets a cached intrinsic type. This will also attach desired imports to the relative reference source. + */ + function getCachedExternType( + program: Program, + relativeSource: Operation | Model, + name: string + ): ProtoRef { + let cache = _protoExternMap.get(program); + + if (!cache) { + cache = new Map(); + _protoExternMap.set(program, cache); + } + + const cachedRef = cache.get(name); + + if (cachedRef) { + const [source, ref] = cachedRef; + typeWantsImport(program, relativeSource, source); + return ref; + } + + const [emptyType, diagnostics] = program.resolveTypeReference(name); + + if (!emptyType) { + throw new Error( + `Could not resolve the empty type: ${diagnostics.map(formatDiagnostic).join(EOL)}` + ); + } + + const extern = program.stateMap(state.externRef).get(emptyType) as [string, string] | undefined; + + if (!extern) { + throw new Error(`Unexpected: '${name}' was resolved but is not an extern type.`); + } + + const [source, protoName] = extern; + typeWantsImport(program, relativeSource, source); + const result = ref(protoName); + + cache.set(name, [source, result]); + + return result; + } + /** * Checks that a return type is a Model and converts it to a message, adding it to the declarations and returning * a reference to its name. @@ -334,19 +382,7 @@ function tspToProto(program: Program): ProtoFile[] { case "Model": return addReturnModel(t, operation); case "Intrinsic": - switch (t.name) { - case "unknown": - // We just use the built-in "unknown" type to mean the protobuf Any type - return ref("Any"); - case "void": { - const emptyRef = program.resolveTypeReference("TypeSpec.Protobuf.Empty")[0]; - if (emptyRef) { - const externRef = program.stateMap(state.externRef).get(emptyRef) as [string, string]; - typeWantsImport(program, operation, externRef[0]); - return ref(externRef[1]); - } - } - } + return addIntrinsicType(t, operation); /* eslint-ignore-next-line no-fallthrough */ default: reportDiagnostic(program, { @@ -358,6 +394,31 @@ function tspToProto(program: Program): ProtoFile[] { } } + /** + * Adds an intrinsic type. Intrinsics are assumed to map to Extern types, so this will add the appropriate import. + * + * @param t - the intrinsic type to add + * @param relativeSource - the relative source of the type + * @returns a reference to the type's message + */ + function addIntrinsicType(t: IntrinsicType, relativeSource: Operation | Model): ProtoRef { + switch (t.name) { + case "unknown": + return getCachedExternType(program, relativeSource, "TypeSpec.Protobuf.WellKnown.Any"); + case "void": { + return getCachedExternType(program, relativeSource, "TypeSpec.Protobuf.WellKnown.Empty"); + } + } + + reportDiagnostic(program, { + code: "unsupported-intrinsic", + format: { type: t.name }, + target: t, + }); + + return unreachable("unsupported intrinsic type"); + } + /** * Converts a TypeSpec Model to a Protobuf Ref in return position, adding a corresponding message if necessary. * @@ -427,6 +488,8 @@ function tspToProto(program: Program): ProtoFile[] { return ref(t.name); case "Scalar": return scalarToProto(t); + case "Intrinsic": + return addIntrinsicType(t, relativeSource); default: reportDiagnostic(program, { code: "unsupported-field-type", @@ -717,7 +780,14 @@ function tspToProto(program: Program): ProtoFile[] { }; } - type NamespaceTraversable = Enum | Model | Interface | Union | Operation | Namespace; + type NamespaceTraversable = + | Enum + | Model + | Interface + | Union + | Operation + | Namespace + | IntrinsicType; function getPackageOfType(program: Program, t: NamespaceTraversable): Namespace | null { /* c8 ignore start */ @@ -725,6 +795,9 @@ function tspToProto(program: Program): ProtoFile[] { // Most of this should be unreachable, but we'll guard it with diagnostics anyway in case of eventual synthetic types. switch (t.kind) { + case "Intrinsic": + // Intrinsics are all handled explicitly. + return null; case "Enum": case "Model": case "Union": @@ -760,6 +833,14 @@ function tspToProto(program: Program): ProtoFile[] { dependent: Model | Operation, dependency: NamespaceTraversable ): T { + { + // Early escape for intrinsics + if (dependency.kind === "Intrinsic") { + // Intrinsics and imports are handled explicitly by the emitter. + return pt; + } + } + { // Early escape for externs let effectiveModel: Model | undefined; diff --git a/packages/protobuf/test/scenarios/intrinsics/input/main.tsp b/packages/protobuf/test/scenarios/intrinsics/input/main.tsp new file mode 100644 index 00000000000..3fcc60752e4 --- /dev/null +++ b/packages/protobuf/test/scenarios/intrinsics/input/main.tsp @@ -0,0 +1,17 @@ +import "@typespec/protobuf"; + +using TypeSpec.Protobuf; + +@package({ + name: "com.azure.Test", +}) +namespace Test; + +@Protobuf.service +interface Service { + foo(...Input): void; +} + +model Input { + @field(1) testInputField: unknown; +} diff --git a/packages/protobuf/test/scenarios/intrinsics/output/@typespec/protobuf/com/azure/Test.proto b/packages/protobuf/test/scenarios/intrinsics/output/@typespec/protobuf/com/azure/Test.proto new file mode 100644 index 00000000000..292c1a06207 --- /dev/null +++ b/packages/protobuf/test/scenarios/intrinsics/output/@typespec/protobuf/com/azure/Test.proto @@ -0,0 +1,16 @@ +/* Generated by Microsoft TypeSpec */ + +syntax = "proto3"; + +package com.azure.Test; + +import "google/protobuf/any.proto"; +import "google/protobuf/empty.proto"; + +message Input { + google.protobuf.Any testInputField = 1; +} + +service Service { + rpc Foo(Input) returns (google.protobuf.Empty); +} From db0ce3bc2727afb6c23b118bea48efa45e121069 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 15:36:39 -0400 Subject: [PATCH 47/50] Added a note about onValidate --- packages/protobuf/src/proto.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/protobuf/src/proto.ts b/packages/protobuf/src/proto.ts index 168b29d6742..c141aacfdfc 100644 --- a/packages/protobuf/src/proto.ts +++ b/packages/protobuf/src/proto.ts @@ -193,6 +193,7 @@ export async function $onEmit(ctx: EmitContext e.emitFunction === $onEmit) From 7803dd59836daf22f7cf885e32d02a183b3b7bce Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 15:52:17 -0400 Subject: [PATCH 48/50] Added a note about syntax target functions --- packages/protobuf/src/transform/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/protobuf/src/transform/index.ts b/packages/protobuf/src/transform/index.ts index 6b2b61d9d09..121febbe620 100644 --- a/packages/protobuf/src/transform/index.ts +++ b/packages/protobuf/src/transform/index.ts @@ -936,6 +936,9 @@ function capitalize(s: S) { * Gets the syntactic return type target for an operation. * * Helps us squiggle the right things for operation return types. + * + * See https://github.com/microsoft/typespec/issues/1650. This issue tracks helpers for doing this without requiring + * emitters to implement this functionality. */ function getOperationReturnSyntaxTarget(op: Operation): DiagnosticTarget { const signature = op.node.signature; @@ -954,6 +957,9 @@ function getOperationReturnSyntaxTarget(op: Operation): DiagnosticTarget { /** * Gets the syntactic position of a model property name. + * + * See https://github.com/microsoft/typespec/issues/1650. This issue tracks helpers for doing this without requiring + * emitters to implement this functionality. */ function getPropertyNameSyntaxTarget(property: ModelProperty): DiagnosticTarget { const node = property.node; From fa954f8a94a4517e01f119d43eddb4ed12aeed46 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 16:09:26 -0400 Subject: [PATCH 49/50] Move a symbol --- packages/protobuf/src/lib.ts | 1 + packages/protobuf/src/proto.ts | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/protobuf/src/lib.ts b/packages/protobuf/src/lib.ts index 085557f7b3f..bbf1d936fff 100644 --- a/packages/protobuf/src/lib.ts +++ b/packages/protobuf/src/lib.ts @@ -153,6 +153,7 @@ const keys = [ "stream", "reserve", "message", + "_map", ] as const; export const state = Object.fromEntries( diff --git a/packages/protobuf/src/proto.ts b/packages/protobuf/src/proto.ts index c141aacfdfc..3e17d03566d 100644 --- a/packages/protobuf/src/proto.ts +++ b/packages/protobuf/src/proto.ts @@ -70,14 +70,25 @@ export function $package(ctx: DecoratorContext, target: Namespace, details?: Mod ctx.program.stateMap(state.package).set(target, details); } -const mapState = Symbol("@typespec/protobuf._map"); - +/** + * Determines whether a type represents a Protobuf map. + * + * @param program - the program context + * @param m - the type to test + * @returns true if the internal representation of a Protobuf map is bound to this type. + */ export function isMap(program: Program, m: Type): boolean { - return program.stateSet(mapState).has(m); + return program.stateSet(state._map).has(m); } +/** + * Binds the internal representation of a Protobuf map. + * @internal + * @param ctx + * @param target + */ export function $_map(ctx: DecoratorContext, target: Model) { - ctx.program.stateSet(mapState).add(target); + ctx.program.stateSet(state._map).add(target); } export function $externRef(ctx: DecoratorContext, target: Model, path: string, name: string) { From 9320334327b5170054bec6e39345f8b5e17c1c59 Mon Sep 17 00:00:00 2001 From: Will Date: Mon, 24 Apr 2023 16:17:18 -0400 Subject: [PATCH 50/50] Add a readme warning. --- packages/protobuf/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/protobuf/README.md b/packages/protobuf/README.md index 7e6b97b1bfd..5143cc0445c 100644 --- a/packages/protobuf/README.md +++ b/packages/protobuf/README.md @@ -1,5 +1,7 @@ # TypeSpec Protobuf library and emitter +**Warning** :warning:: This pre-release emitter is in active development and may change. Your feedback is highly appreciated. + This package provides support for defining and emitting Protobuf specifications in [TypeSpec](https://github.com/microsoft/typespec) and an emitter that generates Protobuf output files from TypeSpec sources. ## Install